PDA

View Full Version : Run multiple binary files


Zar
11-10-2009, 04:48 PM
I'm using a Fortran program that reads a single binary file and writes a single ascii file. As I have many files I would like the program to read and write to ascii those multiple binary files once.
Example files: c_002.bip_c1.bin, c_005.bip_c1.bin, c_006.bip_c1.bin,c_008.bip_c1.bin,c_010.bip_c1.bin ,c_013.bip_c1.bin etc. Only the numbers after the "c_" change from one file to the other.Below is the program:

implicit none
integer lat, lon, irec,x,y
real*4 bmap(180,90)
parameter(irec=180*90*4)
open(21,file=
& 'c_015.bip_c1.bin',
& access='direct',
& form='unformatted',
& recl=irec,status='old',err=999)
read(21,rec=1,err=999)
& ((bmap(lon,lat),lon=1,180),lat=1,90)
close(21)
open(31,file=

& 'c_015.bip_c1.txt',
& form='formatted')
do 123 y=1,90
write(31,30) (bmap(x,y),x=1,180)
30 Format(180F12.6)
123 continue

999 continue

stop
End


Thanks for your help
Zar

tzeis
11-21-2009, 08:29 PM
You could try making a file which contains a list of the files you want to read, and go through a loop processing each file in turn. To create the output file name, you have the character function len_trim to tell you how many characters long the filename is, armed with this information you can combine a character substring with the concatenation operator to compose the output filename.