[Mingw-users] How to associate filenames to unit numbers in a gfortran program without recompilation ?

4 views
Skip to first unread message

Claude Berger

unread,
Mar 13, 2012, 9:52:27 PM3/13/12
to mingw...@lists.sourceforge.net

I am a newcomer to MinGW and I have a very simple question. I installed MinGW and ran simple FORTRAN programs using the gfortran compiler.  I have to write and run programs that read many input data files and/or produce many output files. I am wondering if there is a way, other than specifying the filenames in OPEN statements, to  establish a correspondence between the unit numbers and the filenames.  In Unix, it is possible to write scripts with SETENV statements associating filenames to unit numbers.  The FORTRAN program makes use of the GETENV procedure to obtain the names..  I am wondering if something similar exists for gfortran on a Windows system.  If not, what is the best way to provide the filenames to the program without a recompilation each time the filenames are changed ?

 

 

Earnie Boyd

unread,
Mar 14, 2012, 8:19:58 AM3/14/12
to MinGW Users List

I don't fortran but I see no reason why setenv and getenv shouldn't
work for you on Windows since there are C equivalents that do the same
thing.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
MinGW-users mailing list
MinGW...@lists.sourceforge.net

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-use...@lists.sourceforge.net?subject=unsubscribe

Craig Dedo

unread,
Mar 14, 2012, 9:08:12 AM3/14/12
to MinGW Users List
> -----Original Message-----
> From: Earnie Boyd [mailto:ear...@users.sourceforge.net]
> Sent: Wednesday, March 14, 2012 07:20
> To: MinGW Users List
> Subject: Re: [Mingw-users] How to associate filenames to unit numbers in a gfortran
> program without recompilation ?
>
> On Tue, Mar 13, 2012 at 9:52 PM, Claude Berger <berger...@sympatico.ca> wrote:
> > I am a newcomer to MinGW and I have a very simple question. I
> > installed MinGW and ran simple FORTRAN programs using the gfortran
> > compiler. I have to write and run programs that read many input data
> > files and/or produce many output files. I am wondering if there is a
> > way, other than specifying the filenames in OPEN statements, to
> > establish a correspondence between the unit numbers and the filenames.
> > In Unix, it is possible to write scripts with SETENV statements
> > associating filenames to unit numbers. The FORTRAN program makes use
> > of the GETENV procedure to obtain the names.. I am wondering if
> > something similar exists for gfortran on a Windows system. If not,
> > what is the best way to provide the filenames to the program without a
> recompilation each time the filenames are changed ?
>
> I don't fortran but I see no reason why setenv and getenv shouldn't work for you on
> Windows since there are C equivalents that do the same thing.
>
> --
> Earnie
> -- https://sites.google.com/site/earnieboyd
>

I use GFortran every day, on Windows Vista SP2.

GFortran does not support SETENV but it dos support both GETENV and GET_ENVIRONMENT_VARIABLE. GETENV is non-standard. GET_ENVIRONMENT_VARIABLE is standard Fortran starting with Fortran 2003. I strongly recommend that you use the standard intrinsic subroutine GET_ENVIRONMENT_VARIABLE.

Please feel free to contact me at any time with any questions or concerns that you may have.

Sincerely,
Craig T. Dedo
17130 W. Burleigh Place
P. O. Box 423 Mobile Phone: (414) 412-5869
Brookfield, WI 53008-0423 E-mail: <cr...@ctdedo.com>
USA
Linked-In: http://www.linkedin.com/in/craigdedo

Reply all
Reply to author
Forward
0 new messages