[gradsusr] Creating a Station Data File from ASCII: stnmap error

MY funnytyphoon at gmail.com
Sat Jul 10 03:31:41 EDT 2010


Hi, Shawn,

I think those keywards used to "open" the station data file are very
important for writing the data. Those keywords are compiler-dependent.
I'm not familar with your compiler, so, please test them by yourself.

Also, the code can be improved. For example (I use F77):
------------
program station_demo
parameter (ml=11, ms=160, mt=10)     !  ml: levels for upper level
data,  ms: total stations, mt: total time records
integer nlev, nflag
parameter (nflag=1, nlev=nflag+ml)
character*8  endstn, stid(ms)              !  I use endstn in the
"tail record", please see below.
real       lat(ms), lon(ms), lev(ml), dtime(ms,mt)
real       ps(ms,mt), us(ms,mt), vs(ms,mt)
real       z(ml,ms,mt), u(ml,ms,mt), v(ml,ms,mt)
data     endstn/‘end_time’/
data     lev/1000.,925.,850.,700.,600.,500.,400.,300.,200.,100./

!  open file  (CVF 6.5 compiler)
open(10,file='station.dat', form='binary')

!  for time looping
do it=1,mt

     !  for station looping
     do is=1,ms

         ! write the "header record for particular station. please use
different "stid" for different stations
          write(10) stid(is), lat(is), lon(is), dtime(is,it), nlev, nflag

          ! write the surface data record for particular station, if
no surface data, just skip it
          write(10) ps(is,it), us(is,it), vs(is,it)

          ! write the upper levels data (total ml levels), if no upper
levels data, just skip this "do" loop
          do il=1,ml
               write(10) lev(il), z(il,is,it), u(il,is,it), v(il,is,it)
          enddo

     enddo

     ! "tail record" to announce the end of one time record
     write(10) endstn, 0., 0., 0., 0, 0
enddo

close(10)
end
-----------

Hope these may be helpful.

Best wishes,
MY

2010/7/10 Shawn Milrad <shawn.milrad at gmail.com>:
> Hi,
>
> I am trying to convert an ASCII file into a format GrADS can read.  My ASCII
> file has 12 variables (it's sounding data) and looks like this:
>    0 46     144    849.1   22.0  25  4.860   36.23   2.6  11  40.630  //////
>    0 48     151    848.4   22.0  25  4.860   36.30   2.6  11  40.630  //////
>    0 50     157    847.8   21.9  25  4.840   36.26   2.7  10  40.630  //////
>    0 52     161    847.4   21.9  25  4.840   36.30   2.7  10  40.630  //////
>    0 54     165    847.0   21.9  25  4.840   36.34   2.7  10  40.630  //////
>    0 56     172    846.4   21.8  26  5.010   36.30   2.7  10  40.630  //////
>
>
> My Fortran 90 program is below.  It compiles and creates the binary file
> successfully but when I run the stnmap utility I get the following error.
> stnmap -i test.ctl
>   Name of binary data set: testbin.dat
>   Number of times in the data set: 1
>   Number of surface variables: 0
>   Number of level dependent variables: 12
>
> Starting scan of station data binary file.
> Binary data file open: testbin.dat
>
> Processing time step 1
> Sequential Read Error: Record size greater than one station report: 32 :: 28
>
> Has anyone seen this before/know how to fix it?
> Thanks,
> Shawn Milrad
>
>
>
>
>       program fortrantest
>        character*8 STID, RLON
>        OPEN (8,FILE='10030000.txt')
>        OPEN (10,FILE='testbin.dat',FORM='UNFORMATTED', &
>        ACCESS='SEQUENTIAL')
>        IFLAG = 0
>        STID = 'WHEELER'
> !  Read and Write
> 10     READ (8,9000,END=90) IMIN,ISEC,IHGHT,PRES,TMPC, &
>        IRELH,RMIX,THETAC,SPED,IDIR,RLAT,RLON
> 9000   FORMAT (2x,I2,2X,I2,5X,I4,3X,F5.1,3X,F4.1,2X,I2,2X, &
>        F5.3,3x,F5.2,1x,F4.1,1x,I3,2x,F6.3,2x,A6)
>        IF (IFLAG.EQ.0) THEN
>           IFLAG = 1
>           IMINOLD = IMIN
>           ISECOLD = ISEC
>        ENDIF
> !  If new time group, write time group terminator.
> !  Assuming no empty time groups.
>        IF (IMINOLD.NE.IMIN.OR.ISECOLD.NE.ISEC) THEN
>           NLEV = 0
>           WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
>           ENDIF
>           IMINOLD = IMIN
>           ISECOLD = ISEC
> !  Write this report
>        TIM = 0.0
>        NLEV = 1
>        NFLAG = 1
>        WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
>        WRITE (10) IHGHT,PRES,TMPC,IRELH,RMIX,THETAC, &
>        SPED,IDIR
>        GO TO 10
> !  On end of file write last time group terminator.
> 90     CONTINUE
>        NLEV = 0
>        WRITE (10) STID, RLAT, RLON, TIM,NLEV,NFLAG
>        STOP
>        END
>
> --
> Shawn Milrad, Ph. D.
> Staff Scientist
> AER, Inc.
>
>
> --
> Shawn Milrad
> Cell:  732-261-3594
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>



-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++
YING, Ming
Shanghai Typhoon Institute of China Meteorological Administration
166 Puxi Road, Xuhui District, Shanghai, 200030
PR China
++++++++++++++++++++++++++++++++++++++++++++++++++++




More information about the gradsusr mailing list