DonPasqual
Technical User
Hi there,
I have a problem with FORTRAN 77.
I'm trying to read some variables from a text file called fort.51
The first line of this file looks like this:
00005 06/25/1851 M= 4 1 SNBR= 1 NOT NAMED XING=1 SSS=1
There are several characters I need to skip.
My aim is to read all numbers and the name (here: NOT NAMED) to use it further.
My solution looks like this:
program testread
integer month,year,m,numbtot,numbyear,xing,sss,zahl
character(len=11) name
character(len=1) dummy1,dummy2
character(len=3) dummy3
character(len=5) dummy4,dummy5
read(51,100,err=999,end=998) zahl,month,dummy1,day,dummy2,
> year,dummy3,m,numbyear,dummy3
> numbtot,name,dummy4,xing,sss
100 format(i5,i3,A,i2,A,i4,A,i2,i3,1x,A,i4,1x,A,A,i1,A,i1)
...
I introduced some dummy characters to skip the unused characters with reading them.
there's an error after reading "month" and the following variables get a wrong value.
What did I do wrong? Is there another possibility to skip those slashes and unusable text parts?
Thanks,
Pascal
I have a problem with FORTRAN 77.
I'm trying to read some variables from a text file called fort.51
The first line of this file looks like this:
00005 06/25/1851 M= 4 1 SNBR= 1 NOT NAMED XING=1 SSS=1
There are several characters I need to skip.
My aim is to read all numbers and the name (here: NOT NAMED) to use it further.
My solution looks like this:
program testread
integer month,year,m,numbtot,numbyear,xing,sss,zahl
character(len=11) name
character(len=1) dummy1,dummy2
character(len=3) dummy3
character(len=5) dummy4,dummy5
read(51,100,err=999,end=998) zahl,month,dummy1,day,dummy2,
> year,dummy3,m,numbyear,dummy3
> numbtot,name,dummy4,xing,sss
100 format(i5,i3,A,i2,A,i4,A,i2,i3,1x,A,i4,1x,A,A,i1,A,i1)
...
I introduced some dummy characters to skip the unused characters with reading them.
there's an error after reading "month" and the following variables get a wrong value.
What did I do wrong? Is there another possibility to skip those slashes and unusable text parts?
Thanks,
Pascal