[MITgcm-support] Bug in external_fields_load when using periodicExternalForcing
Christopher L. Wolfe
clwolfe at ucsd.edu
Tue Apr 12 15:47:03 EDT 2011
Hi all,
I appear to have found a bug in the part of external_fields_load which
calculates interpolation weights and which records to load when using
periodicExternalForcing. The bug arises due to round-off errors incurred
when the variables are converted to integers using INT and NINT. It can
cause the model to crash when it goes looking for "impossible" record
numbers and also result in the interpolation weights being calculated
incorrectly. As an example of what can go wrong, consider
deltaTclock = 86400 (one day)
externForcingCycle = 31536000 (one 365-day year)
externForcingPeriod = 2628000 (1/12 of a 365-day year)
For mod(myIter,365) = 10, 11, ..., 14 this gives intime0 = 13, which is
"impossible" given that there should be only 12 records. This causes the
model to crash since Iftm(n)-Ifprd*(intime0(n)-1) .eq. 0 when
mod(myIter,365) = 10, thus causing the model to go looking for record
number 13. Simply duplicating record 1 as record 13 will prevent the
crash, but now the interpolation weights will be calculated incorrectly.
In particular, for mod(myIter,365) = 10, 11, ..., 14 aWght < .5 when it
should be greater than 0.5.
I've attached a diff which appears to fix these problems for the case
above, but I haven't extensively tested it with different values of
deltaTclock, externForcingCycle, etc. Also, I've introduced a SAVE
statement to make it easier to figure out whether a new record should be
loaded. This works in my case, but it will no doubt break TAF. It
shouldn't be hard to rewrite the routine to avoid the use of the SAVE
statement.
Cheers,
Christopher
-----------------------------------------------------------
Dr. Christopher L. Wolfe 858-534-4560
Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography, UCSD clwolfe at ucsd.edu
-----------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: external_fields_load.diff
Type: text/x-patch
Size: 2525 bytes
Desc: not available
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20110412/f69a0f6a/attachment.bin>
More information about the MITgcm-support
mailing list