Hello.  Im still struggling with converting a binary file to an ascii file.  I just 
dont understand how to use seek and unpack.  I understand that one needs to know the 
format of the binary file, therefore, I have pasted below FORTRAN code that reads the 
ascii file and writes a binary file.  The files I work with are typically 
meteorological files full of numbers (and short headers) that need to be averaged or 
interpolated etc.. I just need to do it in perl.  In FORTRAN, the ascii file is simply 
read (with a known format ie. 2100) and written to an unformatted binary file.  In 
this example, the code "knows" the format (or the elements of each record) of the 
ascii file.

My goal is to be able to:

1) convert a binary file to ascii and 
2) to read and manipulate (or use) a binary file on the fly (w/o using the FORTAN 
code).

If anyone else could provide further direction it would be very appreciated.

Thanks, - Tyler Cruickshank

FORTRAN CODE:
#-----------------------------------------------------------------------------
OPEN (5,FILE=File.ascii)
OPEN (9,FORM='UNFORMATTED',FILE=File.binary)

READ(5,2100)IFILE, NOTE,NSEG, NSPECS, IDATE, BEGTIM, JDATE, ENDTIM
WRITE(9)IFILE,NOTE,NSEG,NSPECS,IDATE,BEGTIM,JDATE,ENDTIM

READ(5,2001) ORGX, ORGY, IZONE, UTMX, UTMY, DELTAX, DELTAY,  NX, NY, NZ, NZLOWR, 
NZUPPR, HTSUR, HTLOW, HTUPP
WRITE(9)  ORGX,ORGY,IZONE,UTMX,UTMY,DELTAX,DELTAY,NX,NY, 
NZ,NZLOWR,NZUPPR,HTSUR,HTLOW,HTUPP

READ(5,1002) IX, IY, NXCLL, NYCLL
WRITE(9)IX,IY,NXCLL,NYCLL

   READ(5,1003) ((MSPEC(M,L),M=1,10),L=1,NSPECS)
10 IBHR=BEGTIM + 1
   IEHR=ENDTIM
   WRITE (9)((MSPEC(I,J),I=1,10),J=1,NSPECS)


2100 FORMAT(10A1,60A1,/,I2,1X,I2,1X,I6,F6.0,I6,F6.0)



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to