Calling procedure from included .mod file, without explicit `use` statement

Very similarly:

$ objdump -x testCGfit | grep -i bracket

Did not print anything.

Hence the surprise point moves… now I understand why I did not need a copy of bracket inside my test code. With the Makefile it just compiles and runs with no problems whatsoever and, as we can see with both objdump and -fdump-tree-original, there is no trace of bracket in the final executable. Fine.

Then the question moves to: why does fpm fail to compile my driver program as a test, specifically complaining about bracket?

[gbellomi@login2 Test_CGfit]$ fpm clean
Delete build, excluding dependencies (y/n)? y
 + rm -rf build/mpif90_9892AC5BA6456D09
[gbellomi@login2 Test_CGfit]$ 
[gbellomi@login2 Test_CGfit]$ 
[gbellomi@login2 Test_CGfit]$ fpm test --flag "$(pkg-config --cflags scifor) $(pkg-config --libs scifor)"
minimize_krauth.f                      done.
optimize_cgfit_routines.f90            done.
minimize_sascha.f                      done.
VARS_GLOBAL.f90                        done.
OPTIMIZATION.f90                       done.
BATH_AUX.f90                           done.
BATH_FIT.f90                           done.
libCGfit.a                             done.
testCGfit.f90                          done.
testCGfit                              failed.
[100%] Compiling...
build/gfortran_07A77609A9445D9C/CGfit/test_testCGfit.f90.o: In function `MAIN__':
[... < other problems that here are off-topic > ...]
build/gfortran_07A77609A9445D9C/CGfit/libCGfit.a(src_optimize_cgfit_routines.f90.o): In function `__cgfit_routines_MOD_dbrent_nograd':
optimize_cgfit_routines.f90:(.text+0xe41): undefined reference to `bracket_'
optimize_cgfit_routines.f90:(.text+0xed3): undefined reference to `bracket_'
build/gfortran_07A77609A9445D9C/CGfit/libCGfit.a(src_optimize_cgfit_routines.f90.o): In function `__cgfit_routines_MOD_dbrent_wgrad':
optimize_cgfit_routines.f90:(.text+0x117e): undefined reference to `bracket_'
optimize_cgfit_routines.f90:(.text+0x1214): undefined reference to `bracket_'
build/gfortran_07A77609A9445D9C/CGfit/libCGfit.a(src_optimize_cgfit_routines.f90.o): In function `__cgfit_routines_MOD_brent':
optimize_cgfit_routines.f90:(.text+0x1bff): undefined reference to `bracket_'
build/gfortran_07A77609A9445D9C/CGfit/libCGfit.a(src_optimize_cgfit_routines.f90.o):optimize_cgfit_routines.f90:(.text+0x1c95): more undefined references to `bracket_' follow
collect2: error: ld returned 1 exit status
<ERROR> Compilation failed for object " testCGfit "
<ERROR>stopping due to failed compilation
STOP 1

This is what originally made me search for bracket in the code, find that I forgot to copy it, etcetera… But given that make succeeds to compile (and it runs fine) this might be a “me vs fpm” problem afterall, so it might be better to close here and open a new post. The only caveat is that I don’t know what compiler flags fpm is passing to gfortran, so I should pass exactly the same as in my Makefile to really compare, i.e.

-O0 -p -g -fimplicit-none -Wsurprising  -Waliasing -fwhole-file -fcheck=all -pedantic -fbacktrace -ffree-line-length-none