text file reading, FORTRAN

Sestak, Dr. Michael michael.sestak at FNMOC.NAVY.MIL
Wed Jan 4 10:59:29 EST 2006


Since you have only one parameter before the difficult to handle station
name, the parsing can be simplified, greatly.

Read the whole line into a single character variable
   read(5,'(a)') longstring
Use an internal read to get the first variable
   read(longstring,*) first
Get the location of the comma after the first parameter
   loc1=index(longsgring,',')
Make a new string without the first parameter
   restofstring=longstring(loc1+1:len_trim(longstring))
Get the location of the comma after the station name
   loc2=index(restofstring,',')
Get the station name
   stname=restofstring(1:loc2-1)
Make a new string without the station name
   finally=restofstring(loc2+1,len_trim(restofstring))
Use internal read for the rest of the parameters
   read(finally,*) a,b,c,d,e,f,.........

It may take a little tweeking to get it exactly right, but that's the
general idea.


> -----Original Message-----
> From: GRADSUSR at LIST.CINECA.IT
> [mailto:GRADSUSR at LIST.CINECA.IT]On Behalf
> Of Huamei Yin
> Sent: Tuesday, January 03, 2006 9:43 PM
> To: GRADSUSR at LIST.CINECA.IT
> Subject: Re: text file reading, FORTRAN
>
>
> Thanks, Youhua, bhatt and Dave,
>
> The data lines in my file are like the following and I am
> reading it in
> FORTRAN(windows version):
>
> 1100030,AB FORD A,49.033,-122.367,0.3,-2.9,,,,0,,59.6,,466.14,89.44
> 3010010,ABEE
> AGDM,54.283,-112.967,-1.3,-20.4,,,,0.4,24,22.5,,21.4,19.45
>
> I cannot replace all commas with spaces. In that way, the
> station names
> will be
> truncated. And there are missing records between commas.
>
> Dave, could you please tell me more about the parser? What command
> should I use?
> Thanks again.
>
> Huamei
>



More information about the gradsusr mailing list