Hi all,
I apologize in advance as my question is not Enzo related, but given the expertise some people here have and that it will eventually involve Enzo, I thought I would just ask.
My goal is to use the tabulated EoS from the stellar evolution code MESA into Enzo. The difficulty is MESA is written in fortran77, so I need to do some funky C++/F77 linking.
I am really at the first step, where I use a fortran module from MESA (module_eos.f), which I try to call in a C++ program (main_cpp.C). As a test, I also called the module in a Fortran program (main_fortran.f) to check that everything was working correctly before involving C++.
When I build everything, I get the following error at linking:
#------------------------------------------------------------------------------------------------------------------------------------------------------
[12:18:07] Obiwan:$ make
/Applications/mesasdk/bin/gfortran -ffixed-form -ffixed-line-length-132 -x f77-cpp-input -o module_eos.o -I/Users/jcpassy/Work/MESA/mesa_7503/include -c module_eos.f
/Applications/mesasdk/bin/g++ -c -fopenmp -L/Users/jcpassy/Work/MESA/mesa_7503/lib -lstar -lionization -latm -lcolors -lmlt -lnse -lnet -leos -lkap -lrates -lneu -lchem -linterp_2d -linterp_1d -lnum -lf2crlibm -lcrlibm -lmtx -lconst -lutils -lmesaklu `mesasdk_lapack_link` `mesasdk_blas_link` `mesasdk_pgplot_link` `mesasdk_se_link` -lgfortran main_cpp.C
g++.exec: warning: /Applications/mesasdk/lib/liblapack.a: linker input file unused because linking not done
g++.exec: warning: /Applications/mesasdk/lib/libxblas.a: linker input file unused because linking not done
g++.exec: warning: /Applications/mesasdk/lib/libblas.a: linker input file unused because linking not done
g++.exec: warning: /Applications/mesasdk/lib/libblas.a: linker input file unused because linking not done
/Applications/mesasdk/bin/g++ -o bin/main_cpp.exe -fopenmp -L/Users/jcpassy/Work/MESA/mesa_7503/lib -lstar -lionization -latm -lcolors -lmlt -lnse -lnet -leos -lkap -lrates -lneu -lchem -linterp_2d -linterp_1d -lnum -lf2crlibm -lcrlibm -lmtx -lconst -lutils -lmesaklu `mesasdk_lapack_link` `mesasdk_blas_link` `mesasdk_pgplot_link` `mesasdk_se_link` -lgfortran \
main_cpp.o module_eos.o
Undefined symbols for architecture x86_64:
"_Sample", referenced from:
_main in main_cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
#------------------------------------------------------------------------------------------------------------------------------------------------------
The problem seems to be in adding an extra underscore to the function name. I know this is a common issue, and Enzo deals with that with the macros FORTRAN_NAME and PFORTRAN_NAME. However, I tried for almost a day, but could not figure it out.
I would be happy if someone could help me to solve this problem. Once it is done, I will try to compile these files with the MPI compilers, and include them in Enzo.
Thanks a ton,
JC
PS: I am on OSX 10.10, GNU compilers v. 4.9.3.