Changes in Mortran and R

Tracing progress fixes in Mortran and R

  1. Changed the function definition
subroutine get_int_parms(sml,eps,big,mnlam,rsqmax,pmin,exmx);

to

subroutine get_int_parms(sml,eps,big,mnlam,rsqmax,pmin,exmx,itrace);

taking on itrace as a switch for tracing progress. Added an entry chg_itrace to change itrace.

  1. Changed all calls to get_int_parms to include extra parameter.

  2. Corresponding changes to glmnet.control.R to include itrace as a parameter.

  3. Fixes in relax.glmnet.R for displaying the progress by temporarily turning off and on tracing, if it was on.

Unused variable fixes in Mortran.

  1. The subroutines spstandard, spstandard1, multspstandard1 had jerr as an unused argument.
  2. The subroutines coxnet1, fishnet1, spfishnet1 had isd as an unused argument.
  3. The subroutine risk had ni as an unusued argument.

In all these cases, I merely added a no-op statement to the function/subroutine (e.g. jerr = jerr * 1 or ni = ni * 1) to stop compiler warnings. More advanced compilers may detect these shenanigans. We can address that later if it comes up.

Some extraneous tabs in Mortran.

  1. The subroutine multstandard1 has an extra tabl between the arguments ju and xm that I removed. This is most likely because Emacs replaces 8 spaces with tabs.

Uninitialized variable in Mortran

  1. The gfortran compiler warns that the variable alf is uninitialized in elnet1. The logic is correct, but the compiler is unable to detect it. So I initialized alf=1 and combined it with a previous fix for alm=0.0 in elnet1. I am reasonably certain this will not affect any logic.

Generating Fortran from Mortran

Note that it is Mortran processing that generates unusued labels. So each time you run Mortran to generate the Fortran, you will have to deal with the problem of unused labels. No worries, however, if you follow this procedure.

  1. Install the latest SUtools package, after deleting your old one, if you had it.
  2. Execute the following, assuming GLMNET_DIR is your glmnet package directory.
library(SUtools)
GLMNET_DIR  <- "~/GITHUB/glmnet"
mortran <- readLines(file.path(GLMNET_DIR, "inst", "mortran", "glmnet5dpclean.m"))
result  <- process_mortran(input_mortran_file = "glmnet5dpclean.m",
                           pkg_name = "glmnet",
                           control = sutools_control(fix_allocate = FALSE))

The fortran file can now be written out to a file. For example, you may choose to overwrite the old fortran with the new fortran.

writeLines(fixed_fortran, file.path(GLMNET_DIR, "src", "glmnet5dpclean.f"))

Maxit bug fixed

Mortran would branch to :again: when convergence was not reached, and not check if maxit had been reached. On the new mac M1 this could get into a state with a degenerate example where it never terminated. Added a maxit check immediately after again throughout.



Try the glmnet package in your browser

Any scripts or data that you put into this service are public.

glmnet documentation built on Nov. 3, 2021, 1:07 a.m.