Re: Generating filenames



James Van Buskirk wrote:
<Joli.LeChat@xxxxxxxxx> wrote in message
news:1138414918.698445.266290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


I wrote a program that does a simulation in function of a parameter.
This parameter is variable inside a DO loop.
I'd like to ask you if there's a way to generate a filename for each
step of the loop, so I can store the results. Something like
result1.dat, result2.dat, etc.


program untested
   implicit none
   integer i
   character(80) filename

   do i = 1, 10
      write(filename,'(a,i0,a)') 'result',i,'.dat'
      open(10,file=filename)
      write(10,'(a,i0)') 'For this file, i =',i
      close(10)
   end do
end program untested

oo oo .... I forgot about i0! Darn it! :o)

cheers,

paulv


-- Paul van Delst CIMSS @ NOAA/NCEP/EMC .



Relevant Pages

  • filenames with spaces and list in a for loop
    ... Second attempt was to double quote the "`ls -1A $1`", which generates ONE huge argument to the for loop. ... Unfortunately, the list also generates a newline every 80 characters in the $LIST, so once in a while I was left with each_item being set to something like "\nfilename". ... At the first occurrence of $each_item in the function I would get something like <filename> not found. ... what if I have a directory with more than 65000 characters worth? ...
    (comp.unix.shell)
  • Re: long running perl programs & memory untilization
    ... >> It does setup stuff, and then goes into a loop. ... # reads in temporary capture file adds timestamp, ... # Argument 1 is filename that the labled image should be stored as ... my $grab = $_; ...
    (comp.lang.perl.misc)
  • Re: DTS query result to file - can I loop it?
    ... How to loop through a global variable Rowset ... How can I change the filename for a text file connection? ... The values for @MyType are stored in a database table so a cursor ... > existing DTS package or will I have to create a new package to handle each ...
    (microsoft.public.sqlserver.dts)
  • Re: python skipping lines?
    ... and your first pass through this loop, you exhaust RawData by reading to the end. ... The second pass through the UnitList loop, you pass the exhausted RawData to PullHourlyData. ... I'm thinking you'd need to RawData.seekor some such "rewind" ability. ... Part of the confusion stems from the fact that what you refer to as "filename" is actually a file object that contains state. ...
    (comp.lang.python)
  • Re: Best way to integrate all filenames in a directory with SQL Recordset?
    ... Actual filename value transform from old to new is more like Filename.1 -> ... mismatch lists if something goes wrong. ... I will see what I can do to add another loop mid-stream to catch all file ... > Your destination I can only presume has 4 attributes ...
    (microsoft.public.sqlserver.dts)