Operating System - HP-UX
1834142 Members
2167 Online
110064 Solutions
New Discussion

Re: How to call a fortran code from a c code??

 
Genong Li
New Member

How to call a fortran code from a c code??

I tried to call a Fortran code from a C code. A makefile
was written for that purpose in the past, but it is specifically for SGI machine
with irix6r10. Is there anyone who knows how to change the following variables:

CFLAGS_HPUX11=
FFLAGS_HPUX11=
LDFLAGS_HPUX11=
LIBS_HPUX11=

such that they are equilavent to

CFLAGS_IRIX6R10= -KPIC -O -n32
FFLAGS_IRIX6R10= -O -KPIC -n32
LDFLAGS_IRIX6R10= -shared -n32
LIBS_IRIX6R10= -lftn -lm -lc

Thanks!
1 REPLY 1
Gregory Fruth
Esteemed Contributor

Re: How to call a fortran code from a c code??

The HP C and FORTRAN manuals at docs.hp.com
have extensive info on using C and FORTRAN
together.

CFLAGS_HPUX11= +z -O
FFLAGS_HPUX11= +z -O
LDFLAGS_HPUX11= -a shared
LIBS_HPUX11= -lcl -lm -lc

The linker will warn you if you need to change the
+z options to +Z.

The SGI compiler most likely adds underscores
to FORTRAN symbol names, so you may need
to add +ppu to FFLAGS. Check the f77 or f90
man page to see what the default is for your
compiler.

For some reason the HP-UX FORTRAN
runtime library is called "libcl", hence the "-lcl".
The "-lc" is the C runtime library and is usually
automatically added by the linker, but I guess it
doesn't hurt to say it explicitly.