[gradsusr] Creating a Binary File in Grads

James T. Potemra jimp at hawaii.edu
Mon Jan 26 13:57:15 EST 2015


Valeria,

Can you show how time is defined in these four descriptor files (TDEF)?  
I think the issue might be that time is being defined in the first file, 
and t=1 in the first file is not the same date as t=1 in the second.  If 
you add "set dfile 1", "set dfile 2", etc. before each while loop, it 
shoudl work (dfile 1 before the first loop, dfile 2 before the second, 
and so on).

Another way to do this is to use the template option.  In this way you 
have a single data descriptor file that accesses each of the monthly 
files.  Details are at http://www.iges.org/grads/gadoc/gadocindex.html 
under "templates".

Jim

On 1/23/15 7:41 PM, Valeria Benson-Lira 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 <mailto: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/20150126/87e59035/attachment.html 


More information about the gradsusr mailing list