Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!brl-tgr!gwyn From: gwyn@brl-tgr.ARPA (Doug Gwyn ) Newsgroups: net.unix Subject: Re: Calling f77 routines from C: HELP! Message-ID: <1996@brl-tgr.ARPA> Date: Sat, 25-Jan-86 23:41:55 EST Article-I.D.: brl-tgr.1996 Posted: Sat Jan 25 23:41:55 1986 Date-Received: Wed, 29-Jan-86 04:15:11 EST References: <1930@uwmacc.UUCP> Distribution: net Organization: Ballistic Research Lab Lines: 24 > 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.