Petros,
After some searching on the OPEN behavior, I guess it is OK not to close the
opened unit, even if it is to be opened again. However, in our case, the
calling program (a GUI program) is required to open and process the files that
are created by the Fortran DLL. Thus I have to close the files and reopen
them in the C++ code.
I think it is a good programming practice to explicitly close all opened
files. In one of my project, I have written some modules to make
create/open/close multiple files easier. One of the module allows me to
search for any unused unit number and I can use the returned unit number like
a file handler in C. The module will not work correctly if files are not
explicitly close after used.
Thanks for your comments.
Shyan Lam
[log in to unmask]
[log in to unmask] (Petros Dafniotis, DuPont Central R & D)
wrote:
> According to [log in to unmask] message, dated 25-FEB-2000,
> with subject: Re: [opening files from a dll]
>
> > Catherine,
> > We have just converted three of our Fortran programs into DLL and they
are
> > called by a VC++ program. All the Fortran DLLs open and create several
files
> > during the call and that does not caused any problem.
> >
> > However we need to modify the Fortran sources since it is no longer a
> > stand-lone program:
> [...]
> > 2. Before return to the calling program, make sure all the opened units
are
> > closed. The original codes simply let the clean up code to do the job.
>
> Why? Assuming that the DLL is statically linked (i.e. no use of
LoadLibrary)
> why does one need to do that? The only reason I can think of is that the
> variables in DLL are forgotten?
>
> Thank you for any responses. Kind regards,
>
> Petros
> ----------------------
> Petros Dafniotis, PhD
> DuPont de Nemours Intl. S.A. - Central Research & Development
> [log in to unmask]
> ---
> DISCLAIMER: My employer, DuPont de Nemours, has nothing to do with
> the opinions and ideas expressed in this post / message.
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|