FORTRAN inside C -- I/O init for UNIX
George A. Planansky
gplan at umb.umb.edu
Sat Sep 2 03:30:30 AEST 1989
I want to put a C wrapper around Fortran utilities, to make command line
parsing and so on easy. The Sun FORTRAN programmer's guide, section 11.3
(The C-FORTRAN Interface), page 186 (revision A 6 May 1988), says, with
regard to execution that starts with the C main and so does not do the
FORTRAN I/O library initializations for a FORTRAN subroutine that it
calls:
The C program should initialize I/O by inserting the
following line at the start of the program:
call f_init()
This establishes the preconnection of units 0, 5, 6.
This does not look like C code to me, or, to cc -- I nonetheless did put
the line in some plausible places, but it didn't take.
1. where and how do f_init() and f_exit() really go?
2. how do I tell cc, or f77, where to find/ resolve these objects?
3. in general, in Unix (Sun OS and 4.3BSD), how do you compile FORTRAN
subroutines, to run under a C main(argc, argv) ? The Sun manual says:
cc main.c fsub.f -lF77 -lI77 -lU77 -lc -lm
Are these libraries and that invocation standard in 4.3? I would like to
run the same stuff on our Suns (3/60's, 3/280, OS 4.01) and our Alliant
fx40 (4.3 BSD essentially).
Alliant's FORTRAN manual tells me that, to get the I/O stuff, I need to
put a FORTRAN wrapper around my C-wrapper, that is:
program fmain
call cmain
end
for:
#include <stdio.h>
cmain()
{
...
fsub_()
}
with:
subroutine fsub()
...
end
But this defeats my intention, of using C's command line arguments. How
else can I get the necessary I/O or init stuff?
Please send your enlightening replies to me, and I will summarize if there
is interest.
email to : gplan at ra.umb.edu
George Planansky
Atmosphere Environment Research
Cambridge MA
(617) 547-6207
More information about the Comp.sys.sun
mailing list