stephenbeckr / L-BFGS-B-C

L-BFGS-B, converted from Fortran to C, with Matlab wrapper
BSD 3-Clause "New" or "Revised" License
109 stars 57 forks source link

Several `printf`s are not behind an `iprint` check #8

Closed frjnn closed 2 years ago

frjnn commented 2 years ago

Line 2164 of subalgorithms.c.

Line 128 of linesearch.c.

stephenbeckr commented 2 years ago

The way it is now is how the fortran code was setup. I'm OK with changing it, but first there are two issues with the pull request: (1) the variable iprint needs to be passed into the subfunctions. Can you change that (and also compile and run the code to make sure it's OK)? (2) *iprint >= 0 in linesearch.c is OK with me, because if this is called, it causes the program to return. However, the *iprint >= 0 in subalgorithms.c is probably not in line with the documentation of iprint in the main lbfgsb.c code, since this could be called every iteration, anytime the code uses a backtracking step, which could be quite often. I would suggest we change the condition to *iprint >= 99 so that this is only printed if the user is expecting output every iteration

frjnn commented 2 years ago

(1) the variable iprint needs to be passed into the subfunctions. Can you change that (and also compile and run the code to make sure it's OK)?

Yes, sorry about that, I badly overlooked it, thanks for pointing it out.

I've updated the code with your suggestions, which I find super reasonable. The code compiles fine and the drivers run fine too. Let me know if you are ok with the order in which iprint now appears among the arguments of lnsrlb.