Home > Archive > Fortran > May 2005 > how to open list of files
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to open list of files
|
|
| wiggy13 2005-05-18, 4:01 am |
| Hello,
I would like to know if there is a way to open a list of files
and read them. examples like file a b c d ,... and read values of x,y
in them
| |
| beliavsky@aol.com 2005-05-18, 4:01 am |
| wiggy13 wrote:
> Hello,
> I would like to know if there is a way to open a list of
files
> and read them. examples like file a b c d ,... and read values of
x,y
> in them
You can store the list of file names in a file and then have your
program read the file names and then open them. In my programs, the
input files are usually in the same directory and share the same
suffix, so the full file names can be constructed from the directory
name, prefix, and suffix using the // operator and the TRIM function.
Do all the files need to be open at the same time? I think compilers
limit the number of files that can be open at one time.
| |
| wiggy13 2005-05-18, 4:00 pm |
| Hi,
How do you do that? Let say I got files like acx-800.txt,
acx-801.txt, ...
all this are consists of x and y data in them. Usually I read each by
acx-800.txt
usually i compile by f77 prog.f
then it a.out
when I try a.out
I enter infile and return
How do u try to "a.out infile" in one line and return
I'm still new at this
****************************************
****************************************
*
read (*, '(a80)') infile
lun = 10
open (unit=lun, file = infile,
1 form = 'formatted', status = 'old')
i = 0
ios = 0
do while ( ios .eq. 0 )
read (lun, fmt = '(a80)', iostat = ios) line
if (ios .eq. 0 .and. line(1:1) .ne. '"') then
i = i + 1
read (line, *) x(i),y(i)
endif
end do
close (lun)
|
|
|
|
|