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

Tricky recursive glitch in sfsetnk #13

Open
jguterl opened this issue Mar 31, 2020 · 0 comments
Open

Tricky recursive glitch in sfsetnk #13

jguterl opened this issue Mar 31, 2020 · 0 comments

Comments

@jguterl
Copy link
Contributor

jguterl commented Mar 31, 2020

The routine sfsetnk is calling the routine to construct the jacobian jac_calc using the argument sf, which is also the dummy output argument of sfsetnk used to assign sfscal in the calls to sfsetnk (line 266,289,297 in odesolve.m).

The argument sf in the call to jac_cal, however, corresponds to the dummy argument wk which is a worker array in jac_calc and is thus modified in jac_calc. Meanwhile, the value of sfscal is also used in jac_calc to build the jacobian, leading to a recursive assignment of sfscal during the call to jac_calc. A numerical glitch may thus appear depending on the compiler and the compilation option (e.g. fno-automatic).

A simple fix is to defined temporary worker array in sfsetnk to be used when calling jac_calc:
real wk(neq)
...
wk(1:neq)=0 ! just for precaution
call jac_calc (neq, tp, yl, yldot0, lbw, ubw, wk,
. nnzmx, jac, jacj, jaci)

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

1 participant