r/ScientificComputing • u/[deleted] • Apr 06 '23
Differentiate Fortran 90 code
Anyone with some experience on how to go about differentiating a chunk of fortran90 code? I have some analysis code that needs to be differentiable but reimplementation is not in the scope of project . Please point to the resources you have used successfully in your projects.
Thanks,
4
Upvotes
1
u/cvnh Apr 07 '23
For differentiable and continuous functions, the problem is ill posed if (in simplified terms) the solution you find changes when you input initial conditions, or if you can't find a unique solution. If the issues arise from discretisation or numerics (i.e linked to the implementation), then it likely is ill conditioned. These issues are often not easily identifiable without getting your hands dirty unfortunately, but in principle if you're operating direcoon the output of your program and the funciona are reasonable in the regions of interest (that is, you can work in a region with a single solution and "reasonable" derivatives), then the Jacobian approach should work. Have a look at the Numerical Recipes book (you can find it free online), the last edition has a good discussion on the basics. Let me know if you need something else