/* Y2K Bug - fixed 11/16/01 by Catherine Cormack. Year was being hardwired to 1900. */ date (sd, st, itime) char sd[],st[]; long int itime; { long int itime2; int mon,day,yr=1970,tday,i,ndays=365,ind; int hr,min,sec; static int julian[2][12] = { {1,32,60,91,121,152,182,213,244,274,305,335}, {1,32,61,92,122,153,183,214,245,275,306,336}}; static char *smon[]={"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG", "SEP","OCT","NOV","DEC"} ; itime2 = itime; while ((itime2 - ndays*86400) > 0) { yr = yr + 1; itime2 = itime2 - ndays*86400; if (yr%4 == 0) ndays = 366; else ndays = 365; } if (yr%4 == 0) ind = 1; else ind = 0; mon = 12; tday = itime2/86400; for (i=1; i<=12; i++) { if (julian[ind][i-1] > tday+1) { mon = i-1; break; } } day = tday - julian[ind][mon-1] + 2; itime2 = itime2 - (julian[ind][mon-1]+day-2)*86400; hr = itime2/3600; itime2 = itime2 - hr*3600; min = itime2/60; itime2 = itime2 - min*60; sec = itime2; sprintf(sd,"%d%d%c%c%c%4.4d", day/10, day%10, smon[mon-1][0], smon[mon-1][1], smon[mon-1][2], yr); sprintf(st,"%d%d:%d%d",hr/10,hr%10,min/10,min%10); /* printf("st = %s\n", st); printf("sd = %s\n", sd); */ return(1); } mdate(time) int time; /*************************************************************/ /* this function determines the month for a given time in */ /* seconds from jan 1, 1987 as is the format for the ssmi */ /* data. */ /*************************************************************/ { int mon,yr=87,tday,i,ndays=365,ind; static int julian[2][12] = { { 1,32,60,91,121,152,182,213,244,274,305,335 }, { 1,32,61,92,122,153,183,214,245,275,306,336 } }; while ((time - ndays*86400) > 0) { yr = yr + 1; time = time - ndays*86400; if (yr%4 == 0) ndays = 366; else ndays = 365; } if (yr%4 == 0) ind = 1; else ind = 0; mon = 12; tday = time/86400; for (i=1; i<=12; i++) { if (julian[ind][i-1] > tday+1) { mon = i-1; break; } } return(mon); } pdate(time) int time; /*************************************************************/ /* this function determines the day for a given time in */ /* seconds from jan 1, 1987 as is the format for the ssmi */ /* data. */ /*************************************************************/ { int mon,yr=87,tday,i,ndays=365,ind,pentad; static int julian[2][12] = { { 1,32,60,91,121,152,182,213,244,274,305,335 }, { 1,32,61,92,122,153,183,214,245,275,306,336 } }; while ((time - ndays*86400) > 0) { yr = yr + 1; time = time - ndays*86400; if (yr%4 == 0) ndays = 366; else ndays = 365; } if (yr%4 == 0) ind = 1; else ind = 0; mon = 12; tday = time/86400; for (i=1; i<=12; i++) { if (julian[ind][i-1] > tday+1) { mon = i-1; break; } } if (ndays == 365) pentad = tday/5 + 1; else { if (tday+1 < 61) pentad = tday/5 + 1; else pentad = (tday-1)/5 + 1; } return(pentad); } float bounds(alon) float alon; { float tmpln; tmpln = alon; if (tmpln > 180.0) tmpln = tmpln - 360.0; if (tmpln < -180.0) tmpln = tmpln + 360.0; if (tmpln > 180.0) tmpln = -999.0; if (tmpln < -180.0) tmpln = -999.0; return(tmpln); } upper(string,len) char string[]; int len; { int i; char c; for (i=0; i<=len-1; i++) { c = string[i]; if (c >= 'a' && c <= 'z') c = c - 'a' + 'A'; string[i] = c; } return(1); }