In porting CESM to a small gcc based computer, I have been trying to build the small test example and reached what appears to be the final link step when 'Building cesm".
The linker produces a large number of error messages indicating that it cannot link between the fortran and C routines within the gptl library (libgptl.a). The link stage also had undefined references to 'chdir_' and 'system_'.
I checked the contents of 'libgptl.a' using the "nm" command and found in the case of the gptlstop routine, that the name appears in three of the *.o files:
gptl.o:
...
0000000000003b76 T GPTLstop
0000000000004040 T GPTLstopf
00000000000042ca T GPTLstopf_handle
0000000000003db9 T GPTLstop_handle
0000000000003a2a T GPTLstop_instr
...
f_wrappers.o [Compiled from f_wrappers.c]
...
0000000000000218 T gptlstop
U GPTLstopf
U GPTLstopf_handle
0000000000000226 T gptlstop_handle
...
perf_mod.o [Comiled from perf_mod.F]
...
U gptlstop_
...
00000000000006c7 T __perf_mod_MOD_t_stopf
where '...' indicates lots of other output. From this I conclude that "perf_mod.o" requires a link to 'gprlstop_', but "f_wrappers.o" only supplies 'gprlstop' without the underscore.
The directory used by the script 'case.build', to compile the gptl library is "cime/src/share/timing/", although the same routines are also in
"cime/src/externals/pio1/timing" and "cime/src/externals/pio2/src/gptl".
I checked "perf_mod.F" and " f_wrappers.c", and was surprised to see that the fortran file does not use 'iso_binding_c' or 'bind(c)'. Instead the C file has a series of if/elif statements with options FORTRANCAPS/INCLUDE_CMAKE_FCI/FORTRANUNDERSCORE/FORTRANDOUBLEUNDERSCORE without explanation. Presumably the code predates Fortran 2003.
I tried adding -DFORTRANUNDERSCORE to the options used when compiling C, as some of the machines do for C++ in the standard config_machines.xml file. This solved the problem for libgptl.a - but I find it odd that none of the many gnu compiler machines listed use this flag. Is there another flag I should have used?
At the moment I still have the undefined references to 'chdir_' and 'system_'. Is this a separate issue or is there a single solution to both this and the libgptl.a problem?
Regards, David.
The linker produces a large number of error messages indicating that it cannot link between the fortran and C routines within the gptl library (libgptl.a). The link stage also had undefined references to 'chdir_' and 'system_'.
I checked the contents of 'libgptl.a' using the "nm" command and found in the case of the gptlstop routine, that the name appears in three of the *.o files:
gptl.o:
...
0000000000003b76 T GPTLstop
0000000000004040 T GPTLstopf
00000000000042ca T GPTLstopf_handle
0000000000003db9 T GPTLstop_handle
0000000000003a2a T GPTLstop_instr
...
f_wrappers.o [Compiled from f_wrappers.c]
...
0000000000000218 T gptlstop
U GPTLstopf
U GPTLstopf_handle
0000000000000226 T gptlstop_handle
...
perf_mod.o [Comiled from perf_mod.F]
...
U gptlstop_
...
00000000000006c7 T __perf_mod_MOD_t_stopf
where '...' indicates lots of other output. From this I conclude that "perf_mod.o" requires a link to 'gprlstop_', but "f_wrappers.o" only supplies 'gprlstop' without the underscore.
The directory used by the script 'case.build', to compile the gptl library is "cime/src/share/timing/", although the same routines are also in
"cime/src/externals/pio1/timing" and "cime/src/externals/pio2/src/gptl".
I checked "perf_mod.F" and " f_wrappers.c", and was surprised to see that the fortran file does not use 'iso_binding_c' or 'bind(c)'. Instead the C file has a series of if/elif statements with options FORTRANCAPS/INCLUDE_CMAKE_FCI/FORTRANUNDERSCORE/FORTRANDOUBLEUNDERSCORE without explanation. Presumably the code predates Fortran 2003.
I tried adding -DFORTRANUNDERSCORE to the options used when compiling C, as some of the machines do for C++ in the standard config_machines.xml file. This solved the problem for libgptl.a - but I find it odd that none of the many gnu compiler machines listed use this flag. Is there another flag I should have used?
At the moment I still have the undefined references to 'chdir_' and 'system_'. Is this a separate issue or is there a single solution to both this and the libgptl.a problem?
Regards, David.