<div>Help needed with the station data problem which I met more than five years ago and, as far as I remember, many other grads users also faced. I have gone through the archives, I do not find the solution.</div> <div><STRONG>The problem:</STRONG></div> <div>I want to write station rainfall to binary to display. I used the example of rainfall in the grads documentation. When I run stnmap I get the error below. I wrote the data with acess='direct', in which case the time group terminator is padded with zeros since it has six items as opposed to 7 for the data group. I thought this was the Invalid station hdr found in station binary file.<BR>I then wrote the data with access='sequential (now no zeros padded).</div> <div>The program re-reads and re-writes the data and it appears ok (though I do not understand the 10-digit number as flag = 1123457434 in the error message below).</div> <div>I have attached the fortran program, ctl file and data, below.</div>
<div> </div> <div>Will appreciate anybody with a fix for my problem</div> <div>Zilore Mumba</div> <div> </div> <div> Name of binary data set: rainout.dat<BR> Number of times in the data set: 2<BR> Number of surface variables: 1<BR> Number of level dependent variables: 0</div> <div>Starting scan of station data binary file.<BR>Binary data file open: rainout.dat<BR>Processing time = 1<BR> Invalid station hdr found in station binary file<BR> Possible causes: Invalid level count in hdr<BR> Descriptor file mismatch<BR> File not station data<BR> Invalid relative time<BR>
levs = 1 flag = 1123457434 time = 1.4013e-45 <BR>Open Error: Can't open description file<BR>File name is: rain<BR>Open Error: Can't open description file<BR>File name is: rain<BR>Open Error: Can't open description file<BR>File name is: rain<BR>Open Error: Can't open description file<BR>File name is: rain<BR>Open Error: Can't open description file<BR>File name is: rain<BR></div> <div>$debug<BR> program stndata</div> <div> implicit none</div> <div> integer :: i<BR> integer :: IYEAR,IMONTH,IYROLD,IMNOLD<BR> integer :: NFLAG,IFLAG,NLEV<BR> </div> <div> real ::
LAT,LON,RVAL,tim</div> <div> </div> <div> CHARACTER(len=4) :: STID<BR> <BR> OPEN (8,NAME='rainin.dat',status='old') <BR> OPEN (12,file='rainout.dat',FORM='BINARY',ACCESS='SEQUENTIAL')</div> <div> !OPEN (12,file='rainout.dat',form='unformatted',access='direct',recl=8*7)<BR> <BR> IFLAG = 0 </div> <div>! Read and Write<BR>10 READ (8,9000,END=90) IYEAR,IMONTH,STID,LAT,LON,RVAL <BR>9000 FORMAT (1x,I4,2X,I1,2X,A3,3(2x,F5.1))</div> <div> IF (IFLAG.EQ.0) THEN<BR> IFLAG = 1 <BR> IYROLD = IYEAR<BR> IMNOLD = IMONTH
<BR> ENDIF </div> <div>! If new time group, write time group terminator. <BR>! Assuming no empty time groups. <BR> <BR> IF (IYROLD.NE.IYEAR.OR.IMNOLD.NE.IMONTH) THEN <BR> NLEV = 0<BR> write(12)stid,lat,lon,tim,nlev,nflag<BR> ENDIF<BR> <BR> IYROLD = IYEAR <BR> IMNOLD = IMONTH </div> <div>! Write this report <BR> tim = 0.0 <BR> NLEV = 1 <BR> NFLAG = 1<BR> <BR> write(12)stid,lat,lon,tim,nlev,nflag,rval</div> <div> GOTO 10<BR> <BR>! On end
of file write last time group terminator. </div> <div>90 CONTINUE <BR> NLEV = 0<BR> <BR> write(12)stid,lat,lon,tim,nlev,nflag</div> <div> close(12)<BR> <BR>!****open output file to check how data was written *************</div> <div> open(10,file='rainout.dat',FORM='BINARY',ACCESS='SEQUENTIAL')<BR> <BR> do i=1,4<BR> read(10) stid,lat,lon,tim,nlev,nflag,rval !*** read and print the ***<BR> print*, stid,lat,lon,tim,nlev,nflag,rval !** four stations at t=1***<BR> enddo<BR> read(10) stid,lat,lon,tim,nlev,nflag !*** read and print the***<BR> print*,stid,lat,lon,tim,nlev,nflag !**time group terminator*<BR> <BR> do
i=1,4<BR> read(10) stid,lat,lon,tim,nlev,nflag,rval<BR> print*, stid,lat,lon,tim,nlev,nflag,rval<BR> enddo<BR> read(10) stid,lat,lon,tim,nlev,nflag<BR> print*,stid,lat,lon,tim,nlev,nflag<BR> <BR> END program stndata<BR></div> <div>DSET ^rainout.dat<BR>DTYPE station<BR>STNMAP ^rainout.map<BR>UNDEF -99<BR>TITLE Station Data Sample<BR>TDEF 2 linear 06z01Mar2007 6hr<BR>VARS 1<BR>r 0 99 rainfall<BR>ENDVARS<BR></div> <div> 1980 1 QQQ 8.3 05.5 123.3<BR> 1980 1 RRR 14.2 10.5 87.1<BR> 1980 1 SSS 10.4 -03.5 412.8<BR> 1980 1 TTT 06.4 01.5 23.3<BR> 1980 2 QQQ
8.3 05.5 145.1<BR> 1980 2 RRR 14.2 10.5 871.4<BR> 1980 2 SSS 10.4 -03.5 223.1<BR> 1980 2 TTT 06.4 01.5 45.5</div><BR><BR><p> 
<hr size=1>Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a>