- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good evening Mister/Miss,
I have a program written in Fortran 77 and I am using the compaq visual fortran compiler ver 6.5 in order to run it.
Suppose know that I have generated on my hard disk 1000 input files and that those files are named tango1, tango2,..., tango1000. In order to run my program 1000 times, I need to write a do loops instruction like the following one:
DO 3333 I = 1, 1000
OPEN (UNIT=NI,FILE=FILNAM,STATUS='OLD',ERR=996)
........................
3333 CONTINUE
Where filename is tango1, tango2, ..., tango1000. In order to do this, I have two choices. The first one concatenate the string tango with each integer I. The second choice is to convert an integer into a string then concatenate the two strings together to make the poper filename and open thoses files one by one.
COULD YOU PLEASE GIVE ME AN EXAMPLE HOW TO ACHIVE THAT. DON'T REFER ME TO ONE OF YOUR MANUAL
BECAUSE I AM NOT AN EXPERIENCED PROGRAMMER.
I have a program written in Fortran 77 and I am using the compaq visual fortran compiler ver 6.5 in order to run it.
Suppose know that I have generated on my hard disk 1000 input files and that those files are named tango1, tango2,..., tango1000. In order to run my program 1000 times, I need to write a do loops instruction like the following one:
DO 3333 I = 1, 1000
OPEN (UNIT=NI,FILE=FILNAM,STATUS='OLD',ERR=996)
........................
3333 CONTINUE
Where filename is tango1, tango2, ..., tango1000. In order to do this, I have two choices. The first one concatenate the string tango with each integer I. The second choice is to convert an integer into a string then concatenate the two strings together to make the poper filename and open thoses files one by one.
COULD YOU PLEASE GIVE ME AN EXAMPLE HOW TO ACHIVE THAT. DON'T REFER ME TO ONE OF YOUR MANUAL
BECAUSE I AM NOT AN EXPERIENCED PROGRAMMER.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
character*4 seqstring integer*4 seqnum do seqnum=1,1000 write (seqstring,'(I0)') seqnum open (unit=ni,file='TANGO'//trim(seqstring),status='old',err=996) !... close (unit=ni) end do end
This uses two interesting Fortran features - one is the Internal WRITE statement, which is how you convert numeric to string, and the zero-width I format, which is new to Fortran 95 (CVF 6.5 supports that.) I0 means "use the minimum field width appropriate"
Steve

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