Template option for files with Julian Day names

Stegert stegert at IFM.UNI-HAMBURG.DE
Mon Jul 7 05:23:44 EDT 2008


Dear Renu,

even though I work with GrADS for a longer time, there are
still so many options and functions within GrADS I do not know
(as the CHSUB I didn't consider yet, same as variables in the
CTL file: "%y2"...).

So, for GrADS itself I do not know a fine solution - and that's
the point when I start a workaround.
For your needs three ways come to my mind:
1) To edit the CTL with 20448 CHSUBs is impossible, yet not a
   hard effort within a batch script I guess.
   Within 3 loops the year, the JD and the time are incremented
   and the .bin filename is formed of these variables.

2) Opening one .bin file by another by editing the first and the 10th
   line of the CTL in a loop and opening (and closing!) it each time.

3) I personally prefer data sets including all necessary data in one
   file (as long not getting too complex).
   So, I would most obviously compile all .bin files in one file first
   A Fortran program would do it quite fast I guess...
   open(1,file='per.bin',access='direct',form='unformatted',recl=RecLen)
   Also with three loops of yr, jd and hr building up the filename
   in a variable "BinName" while incrementing "RecNumber" each time.
    open(2,file=BinName)
    DO yr=...
    DO mon=...
    DO hr=...
     <compile variable name>
     read(2,*)per  ! the right way to read depends on your file format...
     write(1,rec=RecNumber,iostat=ios)per
     close(2)
    ENDDO
    ENDDO
    ENDDO
   The CTL would then have
   TDEF 20448 LINEAR 00z01jan2001 3 hr
   and you could access it in normal GrADS way...

Hope this helps. If you'd like detailed information on one of these
skripts feel free to write again.

Cheers, Christoph

Renu R. Joseph schrieb:
> Hello All,
>
> I need suggestions/solutions on dealing with the problem of opening
> files with julian day included in the names.
>
> I have files that named with the following name format: m6s4_3hYYDDDHH.bin,
> where YY represents the last two digits of the years (01 is 2001); DDD
> is julian day; HH is the hour of the start of the measurement
>
> If grads allowed a julian day formats it could have been opened with
> "m6s4_3h%y2%jd%h200.bin" in the dset file location as follows.
>
> dset ^m6s4_3h%y2%jd3%h2.bin
> OPTIONS template
> OPTIONS big_endian
> OPTIONS yrev
> UNDEF  -9999
> TITLE  Precipitation estimates
> XDEF 1440 LINEAR    0.125  0.25
> YDEF 480 LINEAR  -59.875  0.25
> ZDEF  01 LEVELS 1
> TDEF 1 LINEAR  00z01jan2001 3 hr
> VARS 1
> per   1   99  (mm/hr)
> ENDVARS
>
> Since I cannot do that, I know that one of the options is to use
> DSET ^m6s4_3h%ch.bin
> CHSUB   1  1 m6s4_3h0100100.bin
> CHSUB   2  2 m6s4_3h0100100.bin
> ..................................................
> CHSUB  20448 20448 m6s4_3h0736521.bin
> OPTIONS template
>
> but that includes so many lines. Is there a way around this, unless I
> physically rename files to be consistent with grads format names?
>
> Thanks,
> -Renu
>
>
>

--
Christoph Stegert:  Ecological Modelling group
Institut für Meereskunde - Universität Hamburg, Germany
Zentrum f. Marine u. Atmosphärische Wissenschaften ZMAW
Bundesstr.53, 20146 Hamburg - Phone: +49-40/ 42838-7486



More information about the gradsusr mailing list