home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!milo.mcs.anl.gov!pepper.ra.anl.gov!froehle
- From: froehle@pepper.ra.anl.gov (P Froehle RE/207/xxx 4882)
- Subject: Re: Data initialization: FORTRAN program called as SUBROUTINE
- Message-ID: <72236599512731@pepper.ra.anl.gov>
- Sender: usenet@mcs.anl.gov
- Nntp-Posting-Host: pepper.ra.anl.gov
- Organization: Argonne National Laboratory, Argonne IL
- References: <1992Nov18.025912.13187@netcom.com>
- Date: Sat, 21 Nov 1992 17:13:15 GMT
- Lines: 30
-
- In article <1992Nov18.025912.13187@netcom.com> jchauvin@netcom.com (John H. Chauvin) writes:
- >
- >I am currently working on a mix language program in which a C program
- >calls a large FORTRAN program ( 15,000 lines , 100+ SUBROUTINES,
- >and extensive use of COMMON blocks). I have converted the main routine
- >from the FORTRAN into a SUBROUTINE and am calling the routine from
- >the C code. I pass file information from the C program to the FORTRAN
- >program using C data structures to FORTRAN common blocks. The
- >general program flow is: C calls FORTRAN , waits, FORTRAN updates C,
- >FORTRAN returns to C, C calls FORTRAN ,etc.. The C and FORTRAN
- >routines are linked into one large binary program. All FORTRAN variables
- >required SAVE status. The main advantage to the above approach is the
- >ease to which I can exchange data between the C (graphics front end) and
- >the FORTRAN (number crunchier).
- >
- >Everything works great until I try and call the FORTRAN a second time.
- >The variables and COMMON blocks still retain values from the first call.
- >(Not surprisingly) How can I reinitialize all the COMMON blocks and
- >variables to the state that existed at the beginning of the first call?
- >Normally the FORTRAN would be executed as a stand alone program
- >from the command line , loaded into memory and the variables initialized
- >each time it is used. This is the behavior I want to achieve with each call to
- >the FORTRAN. Initializing all the variables myself is out of the questions
- >because of the size of the code and the fact that all the variables have
- >been SAVEd. Is there a way to do this? Any help or suggestions would be
- >GREATLY appreciated.
- >
- Another way is to pass the data in a file and have the c program spawn
- the fortran program. That way the fortran program initializes each time.
- ..paul ... phfroehle@anl.gov
-