GitHub for modern-minpack: GitHub - fortran-lang/minpack: Modernized Minpack: for solving nonlinear equations and nonlinear least squares problems An official version that has already been downloaded can be found in minpack.zip Detailed instructions can be found on the official website. Here is my personal understanding: Assuming you are using a Linux system:
- Download and install fpm from https://fpm.fortran-lang.org/. I have a downloaded latest version of fpm-0.7.0-linux-x86_64 here.
- Use “sudo chmod +x fpm-0.7.0-linux-x86_64” to give permission.
- Use “sudo cp fpm-0.7.0-linux-x86_64 /usr/local/bin” to copy it to /usr/local/bin
- Unzip minpack.zip
- CD into the minpack directory
- Use “fpm test”. This will run a lot of tests, but almost all of them will fail, e.g., Execution failed for object " test_hybrd " Execution failed for object " test_hybrj " Execution failed for object " test_lmder " Execution failed for object " test_lmdif " Execution failed for object " test_lmstr "
- I specifically focused on the example_primes file in the “example” directory. Running “fpm run --example example_primes --compiler gfortran --flag -O3” resulted in a failure: Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error: #0 0x7f93d8170d21 in ??? #1 0x7f93d816fef5 in ??? #2 0x7f93d7e1308f in ??? at /build/glibc-SzIz7B/glibc-2.31/signal/…/sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 #3 0x7fffd8a9f668 in ??? Segmentation fault (core dumped) Execution failed for object " example_primes " cmd_run:stopping due to failed executions
- Other examples in the “example” directory can run by replacing example_primes, but they will also fail if the optimizer is not specified with “–flag -O3”. Compiling with ifort will also fail regardless of the optimization level. There seems to be a problem with this program, and it is unclear if some syntax has been misused.
- Regardless of the compiler used, the debug information shows that the program fails when calling the subroutine “fcn(m, n, x, fvec, iflag)”. This program is contained within the subroutine “find_fit(data_x, data_y, expr, pars)”. Therefore, in theory, “data_y” does not need to be defined before calling the subroutine “find_fit(data_x, data_y, expr, pars)”.
- The error occurs when the “subroutine fcn” is called as a “func2” procedure in the “subroutine lmdif1(fcn, m, n, x, Fvec, Tol, Info, Iwa, Wa, Lwa)”. This error is encountered when “subroutine fcn” is passed as a “func2” procedure into “subroutine lmdif(fcn, m, n, x, Fvec, Ftol, Xtol, Gtol, Maxfev, Epsfcn, Diag, Mode, Factor, Nprint, Info, Nfev, Fjac, Ldfjac, Ipvt, Qtf, Wa1, Wa2, Wa3, Wa4)” within the subroutine.
Assuming using Windows: You only need to consider the example_primes.f90 file and two source files in the src folder.
Possible issues:
- The subroutine calling is incorrect.
- Your system environment configuration may not meet the requirements of these new syntax, and there may be other dependencies that need to be installed.