Old station data problem

Charles Seman Charles.Seman at NOAA.GOV
Thu Jan 24 10:45:13 EST 2008


Zilore,

Have you tried using CHARACTER(len=8) for STID?  Not sure, but
http://grads.iges.org/grads/gadoc/aboutstationdata.html#station C and
DEC Fortran example programs show use of 8 for length of variable "STID"...

I hope this helps,
Chuck

zilore mumba wrote:
> 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.
> *The problem:*
> 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.
> I then wrote the data with access='sequential (now no zeros padded).
> 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).
> I have attached the fortran program, ctl file and data, below.
>
> Will appreciate anybody with a fix for my problem
> Zilore Mumba
>
>  Name of binary data set: rainout.dat
>   Number of times in the data set: 2
>   Number of surface variables: 1
>   Number of level dependent variables: 0
> Starting scan of station data binary file.
> Binary data file open: rainout.dat
> Processing time = 1
>   Invalid station hdr found in station binary file
>   Possible causes:  Invalid level count in hdr
>                     Descriptor file mismatch
>                     File not station data
>                     Invalid relative time
>     levs = 1  flag = 1123457434  time = 1.4013e-45
> Open Error:  Can't open description file
> File name is:  rain
> Open Error:  Can't open description file
> File name is:  rain
> Open Error:  Can't open description file
> File name is:  rain
> Open Error:  Can't open description file
> File name is:  rain
> Open Error:  Can't open description file
> File name is:  rain
> $debug
>  program stndata
>  implicit none
>     integer          :: i
>     integer          :: IYEAR,IMONTH,IYROLD,IMNOLD
>     integer          :: NFLAG,IFLAG,NLEV
>
>     real              :: LAT,LON,RVAL,tim
>
>     CHARACTER(len=4) :: STID
>
>        OPEN (8,NAME='rainin.dat',status='old')
>        OPEN (12,file='rainout.dat',FORM='BINARY',ACCESS='SEQUENTIAL')
>        !OPEN
> (12,file='rainout.dat',form='unformatted',access='direct',recl=8*7)
>
>     IFLAG = 0
> !  Read and Write
> 10     READ (8,9000,END=90) IYEAR,IMONTH,STID,LAT,LON,RVAL
> 9000   FORMAT (1x,I4,2X,I1,2X,A3,3(2x,F5.1))
>        IF (IFLAG.EQ.0) THEN
>           IFLAG = 1
>           IYROLD = IYEAR
>           IMNOLD = IMONTH
>        ENDIF
> !  If new time group, write time group terminator.
> !  Assuming no empty time groups.
>
>        IF (IYROLD.NE.IYEAR.OR.IMNOLD.NE.IMONTH) THEN
>           NLEV = 0
>           write(12)stid,lat,lon,tim,nlev,nflag
>        ENDIF
>
>        IYROLD = IYEAR
>        IMNOLD = IMONTH
> !  Write this report
>        tim = 0.0
>        NLEV = 1
>        NFLAG = 1
>
>        write(12)stid,lat,lon,tim,nlev,nflag,rval
>        GOTO 10
>
> !  On end of file write last time group terminator.
> 90    CONTINUE
>        NLEV = 0
>
>     write(12)stid,lat,lon,tim,nlev,nflag
>     close(12)
>
> !****open output file to check how data was written *************
>     open(10,file='rainout.dat',FORM='BINARY',ACCESS='SEQUENTIAL')
>
>  do i=1,4
>       read(10) stid,lat,lon,tim,nlev,nflag,rval    !*** read and print
> the ***
>       print*, stid,lat,lon,tim,nlev,nflag,rval    !** four stations at
> t=1***
>  enddo
>  read(10) stid,lat,lon,tim,nlev,nflag     !*** read and print the***
>  print*,stid,lat,lon,tim,nlev,nflag      !**time group terminator*
>
>  do i=1,4
>        read(10) stid,lat,lon,tim,nlev,nflag,rval
>        print*, stid,lat,lon,tim,nlev,nflag,rval
>  enddo
>  read(10) stid,lat,lon,tim,nlev,nflag
>  print*,stid,lat,lon,tim,nlev,nflag
>
>     END program stndata
> DSET ^rainout.dat
> DTYPE  station
> STNMAP ^rainout.map
> UNDEF  -99
> TITLE  Station Data Sample
> TDEF   2 linear 06z01Mar2007 6hr
> VARS 1
> r   0 99 rainfall
> ENDVARS
>  1980  1  QQQ    8.3   05.5  123.3
>  1980  1  RRR   14.2   10.5    87.1
>  1980  1  SSS   10.4  -03.5  412.8
>  1980  1  TTT     06.4   01.5   23.3
>  1980  2  QQQ    8.3   05.5  145.1
>  1980  2  RRR   14.2   10.5  871.4
>  1980  2  SSS   10.4  -03.5  223.1
>  1980  2  TTT    06.4   01.5    45.5
>
>
> ------------------------------------------------------------------------
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try
> it now.
> <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20>


--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."



More information about the gradsusr mailing list