Daily Data in Grads
Takashi Kagimoto
kagimoto at JAMSTEC.GO.JP
Thu Sep 7 01:13:23 EDT 2006
Hello Wajeeha,
I'm not sure how to handle a 360 days calendar data with
the original binary package distributed from the GrADS site.
You can, however, do it if you rebuild the GrADS using the
patch file attached below. With the patch file, the following
option
360_day_calendar
is added.
Best regard
----
Takashi Kagimoto
Frontier Research Center for Global Change/JAMSTEC
3173-25 Showamachi, Kanazawa-ku, Yokohama, Kanagawa 236-0001, JAPAN
(tel) +81-45-778-5516 (fax) +81-45-778-5707
----
-------------- next part --------------
--- src/gaddes.c.orig 2005-05-18 23:48:36.000000000 +0900
+++ src/gaddes.c 2006-09-05 15:37:52.000000000 +0900
@@ -239,6 +239,13 @@
pfi->calendar=1;
mfcmn.cal365=pfi->calendar;
}
+/* ----> Kagimoto */
+ else if (cmpwrd("360_day_calendar",ch)) {
+ pfi->calendar=2;
+ mfcmn.cal360=1;
+ setup_360_day_calendar();
+ }
+/* <---- Kagimoto */
else if (cmpwrd("big_endian",ch)) {
if (!BYTEORDER) pfi->bswap = 1;
}
--- src/gautil.c.orig 2005-05-18 23:48:36.000000000 +0900
+++ src/gautil.c 2006-09-05 15:43:34.000000000 +0900
@@ -123,6 +123,20 @@
static int mnacul[13] = {0,0,44640,86400,131040,174240,218880,
262080,306720,351360,394560,439200,482400};
+/* ----> Kagimoto */
+void setup_360_day_calendar () {
+ int i;
+
+ for (i = 1; i < 13; i++) {
+ mosiz[i] = 30;
+ momn[i] = 43200;
+ }
+ for (i = 2; i < 13; i++) {
+ mnacum[i] = mnacum[i-1] + momn[i-1];
+ mnacul[i] = mnacum[i];
+ }
+}
+/* <---- Kagimoto */
/* Add an offset to a time. Output to dto. */
void timadd (struct dt *dtim, struct dt *dto) {
@@ -208,7 +222,12 @@
/* Adjust for leaps */
+/* removed by Kagimoto
if (dto->mo==2 && dto->dy==29 && !qleap(dto->yr)) {
+ */
+/* ----> Kagimoto */
+ if (!mfcmn.cal360 && dto->mo==2 && dto->dy==29 && !qleap(dto->yr)) {
+/* <---- Kagimoto */
dto->mo=3; dto->dy=1;
}
}
@@ -353,8 +372,16 @@
yr = dtim1->yr;
while (yr < dtim2->yr) {
+/* removed by Kagimoto
if (qleap(yr)) min2 += 527040L;
else min2 += 525600L;
+ */
+/* ----> Kagimoto */
+ if(mfcmn.cal360 != 1) {
+ if (qleap(yr)) min2 += 527040L;
+ else min2 += 525600L;
+ } else min2 +=518400L;
+/* <---- Kagimoto */
yr++;
}
@@ -386,6 +413,9 @@
/*mf - disable if 365 day calendar mf*/
if(mfcmn.cal365 == 1) return(0);
+/* ----> Kagimoto */
+ if(mfcmn.cal360 == 1) return(0);
+/* <---- Kagimoto */
y = year;
--- src/grads.h.orig 2005-05-18 23:29:17.000000000 +0900
+++ src/grads.h 2006-09-05 15:44:41.000000000 +0900
@@ -138,6 +138,7 @@
/*mf 9612105 Contains global information for Mike Fiorino and Gary Love 980114 mf*/
struct gamfcmn {
+ int cal360 ; /* 360 (30days per month) calendar */ /* added by Kagimoto */
int cal365 ; /* 365 (no leap year) calendar */
int fullyear ; /* 1 - must specify full year 0 old default */
int warnflg; /* warning level flag for messages */
More information about the gradsusr
mailing list