Click to See Complete Forum and Search --> : Compiling after f2c


tardebut
09-05-2007, 10:39 AM
Hello there!

I'm running Fedora 7 on an IBM Station M Pro 9229.
I want to compile a utility from NetLib (Dierckx) after translating it from source Fortran 77 to C using f2c. The original code is composed by the high-level routine concon.f that has dependency on 7 subrutines.
For translating the 8 .f files into .c files I used,

[root@interaction2 Dierckx]# f2c -A *.f

8 .c files were produced. However, when I tried to compile them with

[root@interaction2 Dierckx]# cc -o dierckx *.c -lf2c -lm

I got the error:

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libf2c.so: undefined reference to `MAIN__'
collect2: ld returned 1 exit status

How can I overcome this issue?

Thanks in advance.

hotcold
09-05-2007, 02:03 PM
Hi.

Did you have a main program (transfer address)?

Translating a Fortran main.f program with f2c causes a main.c to contain (in part):
int MAIN__(void)
cheers, hotcold

tardebut
09-06-2007, 04:42 AM
Thanks Hotcold!
The translated code has not "main_" at any point, not even the code of the principal function, the one that makes calls to subroutines. I was puzzled by that but as my experience with C and Fortran is almost 0, I'm kind of lost on whether shall I include some code by myself or some option in f2c in order to compile the output. Shouldn't be expected the file with the highest-level code to contain "main_" after translation?
I look forward.
Thanks again.

phlipant
09-06-2007, 11:41 AM
f2c is both klunky and poorly supported. Have you concidered using the GNU/fortran compiler (gfortran).

http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gfortran/

tardebut
09-07-2007, 04:49 AM
Thanks Phlipant.
I wasn't just interested in compilation but mainly in translation from Fortran to C. I needed the C code to create a .mex file for Octave. However, I'm now reading that .mex files accept also Fortran sources so that I may not need such a translation.
I appreciate the help of all of you.