Leap Year
Katherin Kullgren
kullgren at CRCES.ORG
Mon Jan 8 15:00:12 EST 2007
MJ,
What I think is happening, is that it is trying to say each year has
366 days, because my binary file is 160 bytes too large, (160/4 = 40)
and for 5 variables (40/5 = 8) which means it is writing 366 days for
10 years instead of 365 for 8 years and 366 for 2 years (from 1950 -
1959).
Do you have any suggestions on how I can change/improve this script
so it reads the proper number of days?
Should I include a
else (rc not equal 0) ??
How would I do that?
Thanks for your help!
Katherin
On Jan 8, 2007, at 2:26 PM, Mary Jo Nath wrote:
> Katherin,
>
> Your syntax is off a little. There is no "then" on an "if"
> statement in
> GrADS scripting language. Instead of:
>
> if (rc = 0) then
>
> use
>
> if (rc = 0)
>
>
> MJ
>
>
>
> Katherin Kullgren wrote:
>> Good Afternoon,
>> I am having some trouble with my program. I want to write daily
>> data from
>> year files of 4 different variables, into one file. It looks like
>> in my
>> loop, when it moves onto the next file, it still tries to read say
>> line 366
>> of the previous file instead of line 1 of the next file. I am
>> sure it is
>> some order of commands error, but I cannot figure it out. Could
>> someone
>> please take a look?
>> Thanks in advance,
>> Katherin
>>
>> lat = 168
>> lon = 173
>> starttime = 1
>> year = 1950
>> endday = 365
>> leap = 366
>> pfile = 1
>> rfile = 11
>> wfile = 21
>> tfile = 31
>> num_2 = 4
>>
>> * write the new data into a file
>> 'set gxout fwrite'
>> 'set fwrite 10110204.data'
>>
>> *********
>> while (pfile <= 10)
>> num_1 = year
>> rc = math_mod(num_1,num_2)
>> tt=starttime
>> imap = 1
>> jmap = 8
>> 'set x 'lat
>> 'set y 'lon
>>
>> if (rc = 0) then
>>
>> while (tt<=leap)
>> 'set dfile 'tfile
>> 'd max(tair2,t='imap',t='jmap')-273.16'
>> 'd min(tair2,t='imap',t='jmap')-273.16'
>> 'set dfile 'pfile
>> 'set t 'tt
>> 'd prate*86400'
>> 'set dfile 'rfile
>> 'set t 'tt
>> 'd rh/100'
>> 'set dfile 'wfile
>> 'set t 'tt
>> 'd wind*1.3'
>> imap = imap + 8
>> jmap = jmap + 8
>> tt = tt + 1
>> endwhile
>>
>> else
>>
>> tt=starttime
>> imap = 1
>> jmap = 8
>>
>> while (tt<=endday)
>> 'set dfile 'tfile
>> 'd max(tair2,t='imap',t='jmap')-273.16'
>> 'd min(tair2,t='imap',t='jmap')-273.16'
>> 'set dfile 'pfile
>> 'set t 'tt
>> 'd prate*86400'
>> 'set dfile 'rfile
>> 'set t 'tt
>> 'd rh/100'
>> 'set dfile 'wfile
>> 'set t 'tt
>> 'd wind*1.3'
>> imap = imap + 8
>> jmap = jmap + 8
>> tt = tt + 1
>> endwhile
>>
>> endif
>>
>> year = year + 1
>> pfile = pfile + 1
>> rfile = rfile + 1
>> wfile = wfile + 1
>> tfile = tfile + 1
>> endwhile
>>
>>
>> 'disable fwrite'
>>
>> <Mary-Jo.Nath.vcf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20070108/96f17beb/attachment.html
More information about the gradsusr
mailing list