Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

write a series of file

Status
Not open for further replies.

albert1981

New member
Feb 16, 2007
61
Hallo everybody,

I would like to write a series of file where they are different only for the name, like name_1, name_2,name_3 ecc...

what I'm doing is something like this:

do j=1:50
open(unit=2,access='sequential',file='name_'j'.inp',status='old')
end do

how can put the J in the name in order to have a list of file which name is:

name_1.inp
name_2.inp
name_3.inp
.
.
name_50.inp


thanks,
Albert
 
Replies continue below

Recommended for you

A little trick: write j with I0 format. Remember to close the file after opening it. I don't know what happens if you open a file and then open another one on the same channel. It probably stays open but is unreachable and cannot be modified until you close the program.
Code:
   character*32:: filename
   integer:: j

   do j = 1, 50
      write (filename, 10) j
10    format ('name', I0, '.inp')
      open (unit=2, access='sequential', file=filename, status='old')
      ...
      close (2)
   enddo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor