[gradsusr] Creating a Binary File in Grads

Kishore Ragi kishoreragi at gmail.com
Sat Jan 24 01:07:34 EST 2015


*Hi Valeria Benson-Lira,*
If you don't have problem working with nc files, I will give you other
option to achieve your task.

First, you make your ctl file into netcdf files as below

cdo -f nc import_binary ENCB1_precip_apr2008.ctl precip.april.nc
cdo -f nc import_binary ENCB1_precip_may2008.ct precip.may.nc
cdo -f nc import_binary ENCB1_precip_jun2008.ctl precip.june.nc
cdo -f nc import_binary ENCB1_precip_july2008.ctl precip.july.nc

now merge them all in a single file like below

cdo mergetime precip.april.nc precip.may.nc precip.june.nc precip.july.nc
precip.AMJJ.nc

Though, I did not help with grads, hope this helps.

Cheers,

Kishore

On Sat, Jan 24, 2015 at 11:11 AM, Valeria Benson-Lira <vbensonl at asu.edu>
wrote:

> Dear Grads users,
>
> Can someone please help me with my script? I am trying to write a binary
> file that contains all the values recorded in four different control files.
> My new binary file will have the hourly precipitation records from April
> through July. So far, the script works for the first month but not for the
> following months.
>
> This is the script:
>
>
> 'reinit'
>
> 'open ENCB1_precip_apr2008.ctl'
>
> 'open ENCB1_precip_may2008.ct'
>
> 'open ENCB1_precip_jun2008.ctl'
>
> 'open ENCB1_precip_july2008.ctl'
>
>
> 'set gxout fwrite'
>
> 'set fwrite ENCB1_AMJJ_precip.dat '
>
>
> *****Write April data First.
>
> *****Recall that April has 720 hours (30 days)
>
> *index*_t = 1
>
> while(*index*_t<=720)
>
>   'set t '*index*_t
>
>   say *index*_t
>
>   'd precip.1 '
>
>   *index*_t = *index*_t + 1
>
> endwhile
>
>
> *****Write May data Next.
>
> *****Recall that May has 744 hours (31 days)
>
> *index*_t = 1
>
> while(*index*_t<=744)
>
>   'set t '*index*_t
>
>   say *index*_t
>
>   'd precip.2 '
>
>   *index*_t = *index*_t + 1
>
> endwhile
>
>
> *****Write June data Next.
>
> *****Recall that June has 720 hours (30 days)
>
> *index*_t = 1
>
> while(*index*_t<=720)
>
>   'set t '*index*_t
>
>   say *index*_t
>
>   'd precip.3 '
>
>   *index*_t = *index*_t + 1
>
> endwhile
>
>
> *****Write July data Next.
>
> *****Recall that July has 744 hours (31 days)
>
> *index*_t = 1
>
> while(*index*_t<=744)
>
>   'set t '*index*_t
>
>   say *index*_t
>
>   'd precip.4 '
>
>   *index*_t = *index*_t + 1
>
> endwhile
>
>
> *************************
>
> 'disable fwrite'
>
> *************************
>
> *****Always reinitialize when finished,
>
> *****to avoid mistakingly writing extraneous data
>
> 'reinit'
>
>
> Do you have a suggestion of how I can fix it?
>
> Thanks,
>
> *Valeria Benson-Lira*
> *Graduate Teaching Assistant, Geography M.A.*
> *e-mail: vbensonl at asu.edu <vbensonl at asu.edu>*
>
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150124/1d27d0c4/attachment.html 


More information about the gradsusr mailing list