Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in SPEC (for Lfindzero=1) #37

Closed
jloizu opened this issue Feb 27, 2018 · 5 comments
Closed

Bug in SPEC (for Lfindzero=1) #37

jloizu opened this issue Feb 27, 2018 · 5 comments
Assignees

Comments

@jloizu
Copy link
Collaborator

jloizu commented Feb 27, 2018

The option Lfindzero=1 (instead of the common Lfindzero=2) does not seem to work (not even in fixed-boundary). The error is

fcn1 : fatal : myid= 0 ; .true. ; illegal irevcm : C05P*F error ;

and is displayed while executing the fcn1 subroutine defined in newton.h. Somehow irevcm (which should be 0 or 1 according to fcn1) takes an illegal value and execution is aborted.

The subroutine fcn1 is used when calling hybrd, which is the replacement to NAG introduced by Caoxiang on Jul20,

commit 560c6b2
Author: Caoxiang Zhu czhu@pppl.gov
Date: Thu Jul 20 22:01:40 2017 -0400

replace C05NDF & C05PDF with hybrd & hybrj in MINPACK
@zhucaoxiang
Copy link
Collaborator

@jloizu Could you give / point out a test case? I will check this.

@jloizu
Copy link
Collaborator Author

jloizu commented Feb 27, 2018

Here is an input file that does not work (Lfindzero=1) but does work if you set Lfindzero=2.

M=4.N=0.Lcon=0.Lfree=0.sp.txt

(you have to remove the txt extension)

@zhisong
Copy link
Collaborator

zhisong commented Mar 8, 2018

In minpack subroutine "hybrd", the function-to-optimize, "fcn1", is called with value irevcm=2. The logic of "fcn1" is that if irevcm=0 or 1, it works normally, otherwise returns an error.
Careful inspection shows "fcn1" should not report an error but should work exactly the same as irevcm=1. This happens when "fdjac1", the subroutine calculates the derivatives using forward finite difference, passes irevcm=2 to "fcn1".
A quick fix will be making "fcn1" do the same job in =1 and =2 case.
I have pushed a new branch, Lfindzero-fix, and created a pull request. Tests are welcome before merging.

@zhucaoxiang
Copy link
Collaborator

Sorry, I was distracted by other things. zhisong's fix should work, but I cannot test it in a quick time. I don't have a valid environmental file on PPPL cluster to compile & run SPEC (the current one I have somehow doesn't work).
The variable irevcm is historic and was used for NAG C05PDF & C05NDF. When I replaced the two NAG subroutines by hybrd & hybrj in MINPACK, I used irevcm to play as iflag need by MINPACK subroutines.

@jloizu
Copy link
Collaborator Author

jloizu commented Apr 25, 2018

Yes Zhisong's fix seems to solve the problem! I tested the branch and everything looks good. I am now merging it into master.

@jloizu jloizu closed this as completed Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants