- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can somebody please tell me how to open and write in multiple files using Compaq Visual Fortran.
For example,in a simple Do iteration loop:
number=0
do i=1,100
number=number+1
What do i have to write next so that each ''number'' is written in a different file,and not overwrite the file
created with a normal open file statement.Furthermore,is there any possible way to control the file name,
so that the 100 files generated will have the following names: file_1.dat,file_2.dat,and so on.
Thank you.
For example,in a simple Do iteration loop:
number=0
do i=1,100
number=number+1
What do i have to write next so that each ''number'' is written in a different file,and not overwrite the file
created with a normal open file statement.Furthermore,is there any possible way to control the file name,
so that the 100 files generated will have the following names: file_1.dat,file_2.dat,and so on.
Thank you.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
simply create a filename character string.
Then use an internal write to increment the filename string 'name'
use open to open the files (and close after if you no longer need)
so for example
character*255 myfilename
number=0
do i=1,100
number= number+1
write(myfilename,100) number
100 format('file_',i3.3,'.dat')
open (filename=myfilename, unit=number)
write(i,110) number
110 format(' this is file', i3.3)
end do
Then use an internal write to increment the filename string 'name'
use open to open the files (and close after if you no longer need)
so for example
character*255 myfilename
number=0
do i=1,100
number= number+1
write(myfilename,100) number
100 format('file_',i3.3,'.dat')
open (filename=myfilename, unit=number)
write(i,110) number
110 format(' this is file', i3.3)
end do
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page