| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Greetings all, I have some simple data files that are named in numerical order, such as 01.dat, 02.dat, 03.dat, etc.. These files are not binary files, just ordinary files that can be viewed in a text editor. I have a fortran 77 program that needs to open each file one at a time, do some stuff with it, close it, then open the next one automatically. So the files need to be opened in some sort of do loop. However, there doesn't appear to be any easy way to do this that I know of. Can someone please help me? Thanks, Brad |
|
#2
| |||
| |||
| In article <95f7c7f3-24bc-44e8-b331-d4a585333a67@w7g2000hsa.googlegroups.com>, torn8o2001@yahoo.com writes: > Greetings all, > > I have some simple data files that are named in numerical order, such > as 01.dat, 02.dat, 03.dat, etc.. These files are not binary files, > just ordinary files that can be viewed in a text editor. I have a > fortran 77 program that needs to open each file one at a time, do some > stuff with it, close it, then open the next one automatically. So the > files need to be opened in some sort of do loop. However, there > doesn't appear to be any easy way to do this that I know of. > > Can someone please help me? program torn implicit none integer i, fd character(len=10) name fd = 10 do i = 1, 10 write(name,'(I2.2)') i ! Internal write name = trim(name) // '.dat' ! Append suffix open(file=name, unit=fd, status='old') ! Open file ! ! Do you processing here. ! close(fd) ! Close file end do end program torn -- Steve http://troutmask.apl.washington.edu/~kargl/ |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.