Fortran Main with C I/O

Flint Pellett flint at gistdev.gist.com
Sun Sep 23 08:54:48 AEST 1990


mike at DRD.Com (Mike Rovak) writes:

>bill%biomel at cs.dal.ca wrote:
>} In article <1044 at helens.Stanford.EDU> joe at hanauma.Stanford.EDU (Joe Dellinger) writes:
>} >
>} >We just got the latest OS upgrade, which is the first one to be
>} >"POSIX-compliant". Now we are told "if you want to be able to use C I/O
>} >you'll have to have your mains in C"! This means rewriting a LOT of software.
>} >
>} >	OK. Are we really a special case? Is there anybody else out there
>} >that writes Fortran mains but uses C to do the I/O? If so, let me know, so
>} >we can make a case to them not to do this!

No.  We have an app here which used C for all I/O from a main body in
FORTRAN for a long time, since it ran about twice as fast using C I/O as
it did using whatever it is that FORTRAN uses.  However, it now lives
with a C main, a FORTRAN middle, and C I/O, because it is ever so much
nicer to get command line options with getopt() than to try to manhandle
them in FORTRAN.

>} This would be an absolute disaster.  We use C I/O extensively for things
>} like graphics, raw input, and to do things like display a file directory
>} when asking the user to input a data file name.  If true, someone had
>} better come up with a fix awfully fast!

>Not a problem, guys.  Make a C main function whose sole purpose is to call
>the Fortran routine.  Change the word "PROGRAM" in each Fortran routine
>to "SUBROUTINE" and your job is done.

My guess is that you've never done it on a "real" program.  If your
FORTRAN main is messing around getting command line parameters in, you're
going to have more to do than just this: handing the null-terminated C
argv[] strings down to the FORTRAN part that expects space-filled strings
is not especially difficult, but it isn't a 1 minute fix either.
-- 
Flint Pellett, Global Information Systems Technology, Inc.
1800 Woodfield Drive, Savoy, IL  61874     (217) 352-1165
uunet!gistdev!flint or flint at gistdev.gist.com



More information about the Comp.lang.c mailing list