source:
IO_handling/trunk/ppio/modeltime.patch
@
288
Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/IO_handling/trunk/ppio/modeltime.patch@288
Revision 288, 6.5 KB checked in by jkettleb, 17 years ago (diff) | |
---|---|
|
-
libcdms/include/cdunifpp/cdunifpp.h
diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/cdunifpp.h cdat-4.0b3.1/libcdms/include/cdunifpp/cdunifpp.h
old new 117 117 typedef enum pp_filetype PPfiletype; 118 118 typedef enum pp_axistype PPaxistype; 119 119 typedef enum pp_lev_val_type PPlevvaltype; 120 typedef enum pp_calendartype PPcalendartype; 121 122 enum pp_calendartype { 123 gregorian, 124 cal360day, 125 model 126 }; 120 127 121 128 enum pp_filetype { 122 129 pp_type, … … 586 593 PPdata *pp_taxis_to_values(const PPtaxis *, PPlist *); 587 594 PPdata *pp_taxis_to_boundary_values(const PPtaxis *, PPlist *); 588 595 int pp_is_time_mean(Fint); 589 int pp_is_360day_calendar(Fint);590 596 Freal pp_time_diff(Fint, const PPdate *, const PPdate *); 597 PPcalendartype pp_calendar_type(Fint); 591 598 long long pp_gregorian_to_secs(const PPdate *); 592 599 char *pp_t_units(const PPtaxis *, PPlist *); 593 600 -
libcdms/src/cdunif/cdunifpp/cdunifpp_axisvals.c
diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_axisvals.c cdat-4.0b3.1/libcdms/src/cdunif/cdunifpp/cdunifpp_axisvals.c
old new 211 211 return (ib == 2) || (ib == 3); 212 212 } 213 213 214 int pp_is_360day_calendar(Fint LBTIM) {215 int ic;216 ic=LBTIM % 10;217 return (ic == 2);218 }219 220 214 221 215 /* float_time returns time in days since origin time */ 222 216 … … 226 220 227 221 const Freal sec_to_day = 1. / 86400.; 228 222 229 if (pp_is_360day_calendar(LBTIM)) { 230 223 switch(pp_calendar_type(LBTIM)) { 224 case gregorian: 225 return (pp_gregorian_to_secs(date) - pp_gregorian_to_secs(orig_date)) * sec_to_day; 226 break; /* notreached */ 227 case cal360day: 231 228 secs = 232 229 date->second - orig_date->second + 233 230 60 * (date->minute - orig_date->minute + … … 237 234 12 * (long long) (date->year - orig_date->year) )))); 238 235 239 236 return secs * sec_to_day; 237 break; /* notreached */ 238 case model: 239 secs = 240 date->second - orig_date->second + 241 60 * (date->minute - orig_date->minute + 242 60 * (date->hour - orig_date->hour + 243 24 * (long long) (date->day - orig_date->day))); 244 245 return secs * sec_to_day; 246 break; 240 247 } 248 } 241 249 242 else{250 PPcalendartype pp_calendar_type(Fint type){ 243 251 244 return (pp_gregorian_to_secs(date) - pp_gregorian_to_secs(orig_date)) * sec_to_day; 252 switch(type%10) { 253 254 case 0: 255 /* fallthrough */ 256 case 3: 257 return model; 258 break; /* notreached */ 259 case 1: 260 return gregorian; 261 break; /* notreached */ 262 case 2: 263 return cal360day; 264 break; /* notreached */ 265 default: pp_switch_bug(); 266 245 267 } 246 268 } 247 269 270 248 271 long long pp_gregorian_to_secs(const PPdate *date) 249 272 { 250 273 /* FIXME: uses builtin time functions; these have a range 1902 - 2038 (approx). -
libcdms/src/cdunif/cdunifpp/cdunifpp_error.c
diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c cdat-4.0b3.1/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c
old new 11 11 12 12 int pp_switch_bug() 13 13 { 14 pp_error("no match in switch statement; may indicate coding bug in CDUNIFPP ");14 pp_error("no match in switch statement; may indicate coding bug in CDUNIFPP or unexpected header value"); 15 15 return 0; 16 16 } 17 17 -
libcdms/src/cdunif/cdunifpp/cdunifpp_process.c
diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c cdat-4.0b3.1/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c
old new 19 19 PPzaxis *zaxis; 20 20 PPtaxis *taxis; 21 21 PPlevel *lev; 22 PPtime *time ;22 PPtime *time, *tval; 23 23 void *oldptr; 24 24 PPlist *heaplist, *xaxes, *yaxes, *zaxes, *taxes; 25 25 PPlist *fieldvars; 26 PPlistpos handle ;26 PPlistpos handle, thandle; 27 27 PPlist *gatts,*catts; 28 28 29 29 int ndims, dimid; … … 38 38 PPvar *ppvar; 39 39 PPlist *axislist; 40 40 void *axis; 41 char *tunits ;41 char *tunits, *calatt; 42 42 int have_hybrid=1; 43 43 PPaxistype axistype; 44 44 … … 450 450 451 451 while ((axis=pp_list_walk(axislist,0,&handle))!=NULL) { 452 452 453 units=NULL; /* reset */ 454 axisname=NULL; 455 standardname=NULL; 456 pointspacing=NULL; 457 posdir=NULL; 458 453 459 dim=&cudims[dimid]; 454 460 var=&cuvars[varid]; 455 461 ppdim=(PPdim*) dim->internp; … … 565 571 taxis=(PPtaxis*) axis; 566 572 taxis->dimid = dimid; 567 573 sprintf(dim->name,"time%d",idim); 574 575 switch(pp_calendar_type(taxis->type)) { 576 case gregorian: 577 calatt="gregorian"; 578 break; 579 case cal360day: 580 calatt="360_day"; 581 break; 582 case model: 583 pp_list_startwalk(taxis->values,&thandle); 584 tval = pp_list_walk(taxis->values,0,&thandle); 585 586 taxis->time_orig.year = tval->time1.year; 587 taxis->time_orig.month = tval->time1.month; 588 taxis->time_orig.day = tval->time1.day; 589 taxis->time_orig.hour = tval->time1.hour; 590 taxis->time_orig.minute= tval->time1.minute; 591 taxis->time_orig.second= tval->time1.second; 592 calatt="none"; 593 break; 594 } 595 596 if( pp_add_string_att(ppvar->atts,"calendar", 597 calatt, 598 heaplist) !=0) goto err; 599 568 600 if(( tunits=pp_t_units(taxis,heaplist) )==NULL) goto err; 569 601 dim->len = pp_list_size(taxis->values); 570 602 if(( ppvar->data = pp_taxis_to_values(taxis,heaplist) )==NULL) goto err; 571 if( pp_add_string_att(ppvar->atts,"calendar",572 pp_is_360day_calendar(taxis->type) ? "360_day" : "gregorian",573 heaplist) !=0) goto err;574 603 axisname="T"; 575 604 standardname="time"; 576 605 units=tunits; … … 585 614 var->ndims=1; 586 615 var->dims[0] = dimid; 587 616 588 if (units ) {617 if (units != NULL) { 589 618 if( pp_add_string_att(ppvar->atts,"units",units,heaplist) !=0) goto err; 590 619 strncpy(dim->units,units,CU_MAX_NAME); 591 620 dim->units[CU_MAX_NAME]='\0'; 592 621 } 593 622 594 if (axisname )623 if (axisname != NULL) 595 624 if( pp_add_string_att(ppvar->atts,"axis",axisname,heaplist) !=0) goto err; 596 625 597 if (standardname )626 if (standardname != NULL) 598 627 if( pp_add_string_att(ppvar->atts,"standard_name",standardname,heaplist) !=0) goto err; 599 628 600 if (pointspacing )629 if (pointspacing != NULL) 601 630 if( pp_add_string_att(ppvar->atts,"point_spacing",pointspacing,heaplist) !=0) goto err; 602 631 603 if (posdir )632 if (posdir != NULL) 604 633 if( pp_add_string_att(ppvar->atts,"positive",posdir,heaplist) !=0) goto err; 605 634 606 635 varid++;
Note: See TracBrowser
for help on using the repository browser.