Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

output file

Status
Not open for further replies.

thewooly

Programmer
Joined
Dec 14, 2008
Messages
1
Hi guys,

I am tryin to get my program to output multiple files with the name of the file dependent on a number of integer variables in the program, any help with this would be greatfully appreciated. Cheers
 
Hi,thewooly

I do not understand what you want to do exactly. What do you mean by "number of integer variables in the program"?
It this maybe what you want to do (use a value in an integer variable to make the file name)?:

program test
implicit none

character*24 str
integer*2 i,null,lstr

null = char(0)

i = 1
write(str,'(a,i4.4,a,a)') 'File',i,'.txt',null
open(i,file=str)

i = 2
write(str,'(a,i4.4,a,a)') 'File',i,'.txt',null
open(i,file=str)

i = 3
write(str,'(a,i4.4,a,a)') 'File',i,'.txt',null
lstr = len_trim(str)
open(i,file=str(1:lstr))

end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top