Calling f77 routines from C: HELP!
Doug Gwyn <gwyn>
gwyn at brl-tgr.ARPA
Sun Jan 26 14:41:55 AEST 1986
> I am trying to call a f77 subroutine from a C program,
> and I find that the supposedly "preconnected" i/o units 5 and 6
> are not connected. That is, when I do a simple print in the
> Fortran subroutine, like:
>
> print *, 'hi!'
>
> I get an entry in a file called fort.6. What makes this especially
> unfortunate, is that this works fine in 2.8BSD, and we have found that
> the C/f77 programs that we wrote under 2.8BSD are failing to run
> as expected under Ultrix (for the reason just described).
>
> Is there a way to preserve the "preconnections" advertised in the
> f77 documentation?
In general, it is unwise to mix C and Fortran unless the main
module is Fortran, and even then there are restrictions on
what is safe to do with respect to I/O. This is due to the
need to set up Fortran I/O for the run-time system before
doing any Fortran I/O; this is normally done for you in the
Fortran start-off module. You can try doing it "by hand" by
calling the function f_init(); some "f77" implementations
(e.g., SVR2) keep track of whether or not initialization has
been done and do it automatically if necessary.
More information about the Comp.unix
mailing list