Xref: utzoo comp.lang.c:32088 comp.lang.fortran:3839 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!uunet!gistdev!flint From: flint@gistdev.gist.com (Flint Pellett) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: Fortran Main with C I/O Keywords: peace, calm, smart Message-ID: <1008@gistdev.gist.com> Date: 22 Sep 90 22:54:48 GMT References: <1044@helens.Stanford.EDU> <1990Sep20.221007.8515@cs.dal.ca> <1990Sep21.132232.11305@DRD.Com> Followup-To: comp.lang.c Distribution: usa Organization: Global Information Systems Technology Inc., Savoy, IL Lines: 38 mike@DRD.Com (Mike Rovak) writes: >bill%biomel@cs.dal.ca wrote: >} In article <1044@helens.Stanford.EDU> joe@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@gistdev.gist.com