I'm trying to get this superLU sparse matrix solver to run, but I can't seem to compile it. I'm writing my program with Fortran, and so I'm trying to call superLU from my program. I'm using g95 compiler for fortran.
http://crd.lbl.gov/~xiaoye/SuperLU/#superlu
How can I compile this in Fortran? I tried and it said开发者_开发技巧 error cannot exec 'cc1'
, no file found. I don't care what Fortran compiler I use, just any way I can call this superLU from Fortran.
I don't know much about linking Fortran with C++ programs, what I did is g95 -o test f77_main.f hbcode1.f c_fortran_dgssv.c
I recommend the use of the Fortran ISO C Binding for calling C routines from Fortran, or vice-a-versa. This binding, which is part of Fortran 2003 but widely available for several years, informs Fortran to use C calling conventions. It is part of the language and so compiler and platform independent. Besides previous answers here, there are code examples in the gfortran manual under "Mixed-Language Programming". There are also many examples of Fortran interfaces to call the C routines of the GNU Scientific Library at http://www.lrz.de/services/software/mathematik/gsl/fortran/index.html.
Re how to compile & link a mixed Fortran & C program ... generally is easier to use the Fortran compiler for the linking step because it brings in extra Fortran runtime libraries. So proceed in two steps: compile your C routines to object files, then in the next step compile the Fortran routines and link the Fortran routines and the pre-compiled C routines. If using C++, use "extern C" to make it compatible with C. So, for example:
gcc -c MyCRoutine.c
gfortran FortranMain.f95 MyCRoutine.o
A good start to solving your problem can be found in a previous answer here.
It looks a bit strange that you are passing a .c file to g95. You should compile the C file using GCC, then link the resulting .o file to your compiled fortran code.
精彩评论