- Timestamp:
- 09/15/14 17:34:57 (10 years ago)
- Location:
- XIOS/trunk/src/output
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/output/nc4_data_output.cpp
r472 r488 37 37 38 38 SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; 39 39 40 40 // if (!exist) 41 41 // SuperClassWriter::addDimension(timeid); … … 62 62 return ; 63 63 } 64 64 65 65 CContext* context = CContext::getCurrent() ; 66 66 CContextServer* server=context->server ; 67 67 68 68 if (domain->IsWritten(this->filename)) return; 69 69 domain->checkAttributes(); 70 71 if (domain->isEmpty()) 70 71 if (domain->isEmpty()) 72 72 if (SuperClass::type==MULTI_FILE) return ; 73 73 … … 79 79 80 80 StdString dimXid, dimYid ; 81 81 82 82 switch (domain->type) 83 83 { … … 93 93 dimXid = StdString("cell").append(appendDomid); 94 94 break; 95 } 96 95 } 96 97 97 string lonid,latid,bounds_lonid,bounds_latid ; 98 98 /* … … 110 110 { 111 111 // if (domain->isEmpty()) return; 112 112 113 113 if (server->intraCommSize > 1) 114 114 { … … 138 138 break; 139 139 } 140 140 141 141 if (domain->type == CDomain::type_attr::unstructured) 142 142 { … … 148 148 SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv); 149 149 } 150 150 151 151 if (server->intraCommSize > 1) 152 152 { … … 158 158 domain->zoom_nj_srv, 159 159 appendDomid); 160 160 161 161 if (singleDomain) this->writeLocalAttributes_IOIPSL(domain->zoom_ibegin_srv, 162 162 domain->zoom_ni_srv, … … 167 167 } 168 168 } 169 169 170 170 switch (domain->type) 171 171 { … … 182 182 SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); 183 183 } 184 184 185 185 this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); 186 186 this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); … … 202 202 // supress mask domain->data_jbegin.getValue()*/); 203 203 // supress mask } 204 204 205 205 //SuperClassWriter::setDefaultValue(maskid, &dvm); 206 206 … … 212 212 SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); 213 213 SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); 214 break; 214 break; 215 215 case CDomain::type_attr::regular : 216 216 CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; … … 229 229 SuperClassWriter::addDimension(dimYid, domain->zoom_nj.getValue()); 230 230 231 231 232 232 switch (domain->type) 233 233 { … … 260 260 case CDomain::type_attr::curvilinear : 261 261 { 262 std::vector<StdSize> start(2) ; 262 std::vector<StdSize> start(2) ; 263 263 std::vector<StdSize> count(2) ; 264 264 if (domain->isEmpty()) 265 265 { 266 start[0]=0 ; start [1]=0 ; 267 count[0]=0 ; count[1]=0 ; 266 start[0]=0 ; start [1]=0 ; 267 count[0]=0 ; count[1]=0 ; 268 268 } 269 269 else 270 270 { 271 start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 272 count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 271 start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 272 count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 273 273 } 274 274 275 275 SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 276 276 SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); … … 279 279 case CDomain::type_attr::regular : 280 280 { 281 std::vector<StdSize> start(1) ; 281 std::vector<StdSize> start(1) ; 282 282 std::vector<StdSize> count(1) ; 283 283 if (domain->isEmpty()) 284 284 { 285 start[0]=0 ; 286 count[0]=0 ; 285 start[0]=0 ; 286 count[0]=0 ; 287 287 SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 288 288 SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); } 289 289 else 290 290 { 291 start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 292 count[0]=domain->zoom_nj_srv ; 291 start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 292 count[0]=domain->zoom_nj_srv ; 293 293 CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; 294 294 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 295 295 296 start[0]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; 297 count[0]=domain->zoom_ni_srv ; 296 start[0]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; 297 count[0]=domain->zoom_ni_srv ; 298 298 CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ; 299 299 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); … … 304 304 SuperClassWriter::definition_start(); 305 305 break; 306 } 306 } 307 307 default : 308 308 ERROR("CNc4DataOutput::writeDomain(domain)", … … 317 317 CContext* context = CContext::getCurrent() ; 318 318 CContextServer* server=context->server ; 319 319 320 320 if (domain->IsWritten(this->filename)) return; 321 321 domain->checkAttributes(); 322 323 if (domain->isEmpty()) 322 323 if (domain->isEmpty()) 324 324 if (SuperClass::type==MULTI_FILE) return ; 325 325 … … 332 332 StdString dimXid = StdString("cell").append(appendDomid); 333 333 StdString dimVertId = StdString("nvertex").append(appendDomid); 334 334 335 335 string lonid,latid,bounds_lonid,bounds_latid ; 336 336 … … 346 346 SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); 347 347 SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); 348 348 349 349 bounds_lonid = StdString("bounds_lon").append(appendDomid); 350 350 bounds_latid = StdString("bounds_lat").append(appendDomid); 351 352 351 352 353 353 this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); 354 354 if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); … … 358 358 dim0.clear(); 359 359 if (domain->hasBounds) 360 { 360 { 361 361 dim0.push_back(dimXid); 362 362 dim0.push_back(dimVertId); … … 364 364 SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0); 365 365 } 366 366 367 367 dim0.clear(); 368 368 dim0.push_back(dimXid); … … 372 372 SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); 373 373 SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); 374 374 375 375 if (domain->hasBounds) 376 { 376 { 377 377 SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0); 378 378 SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0); … … 394 394 this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); 395 395 if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); 396 this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); 396 this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); 397 397 if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); 398 398 if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); 399 399 dim0.clear(); 400 401 if (domain->hasBounds) 400 401 if (domain->hasBounds) 402 402 { 403 403 dim0.push_back(dimXid); … … 406 406 SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0); 407 407 } 408 408 409 409 SuperClassWriter::definition_end(); 410 411 std::vector<StdSize> start(1), startBounds(2) ; 410 411 std::vector<StdSize> start(1), startBounds(2) ; 412 412 std::vector<StdSize> count(1), countBounds(2) ; 413 413 if (domain->isEmpty()) 414 414 { 415 start[0]=0 ; 416 count[0]=0 ; 417 startBounds[1]=0 ; 415 start[0]=0 ; 416 count[0]=0 ; 417 startBounds[1]=0 ; 418 418 countBounds[1]=domain->nvertex ; 419 startBounds[0]=0 ; 420 countBounds[0]=0 ; 419 startBounds[0]=0 ; 420 countBounds[0]=0 ; 421 421 } 422 422 else 423 423 { 424 start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; 425 count[0]=domain->zoom_nj_srv ; 426 startBounds[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; 427 startBounds[1]=0 ; 428 countBounds[0]=domain->zoom_nj_srv ; 424 start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; 425 count[0]=domain->zoom_nj_srv ; 426 startBounds[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; 427 startBounds[1]=0 ; 428 countBounds[0]=domain->zoom_nj_srv ; 429 429 countBounds[1]=domain->nvertex ; 430 430 } 431 431 SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); 432 432 SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); 433 if (domain->hasBounds) 433 if (domain->hasBounds) 434 434 { 435 435 SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 436 436 SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0,&startBounds,&countBounds); 437 437 } 438 439 440 SuperClassWriter::definition_start(); 441 442 break; 443 } 444 default : 445 ERROR("CNc4DataOutput::writeDomain(domain)", 446 << "[ type = " << SuperClass::type << "]" 447 << " not implemented yet !"); 448 } 449 domain->addRelFile(this->filename); 450 } 451 //-------------------------------------------------------------- 452 453 void CNc4DataOutput::writeAxis_(CAxis* axis) 454 { 455 if (axis->IsWritten(this->filename)) return; 456 axis->checkAttributes(); 457 StdSize zoom_size=axis->zoom_size.getValue() ; 458 StdSize zoom_begin=axis->zoom_begin.getValue()-1 ; 459 460 std::vector<StdString> dims; 461 StdString axisid = (!axis->name.isEmpty()) 462 ? axis->name.getValue() : axis->getId(); 463 SuperClassWriter::addDimension(axisid, zoom_size); 464 dims.push_back(axisid); 465 466 switch (SuperClass::type) 467 { 468 case (MULTI_FILE ) : 469 {} 470 case (ONE_FILE) : 471 { 472 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 473 474 SuperClassWriter::addAttribute("axis", StdString("Z"), &axisid); 475 476 if (!axis->standard_name.isEmpty()) 477 SuperClassWriter::addAttribute 478 ("standard_name", axis->standard_name.getValue(), &axisid); 479 480 if (!axis->long_name.isEmpty()) 481 SuperClassWriter::addAttribute 482 ("long_name", axis->long_name.getValue(), &axisid); 483 484 if (!axis->unit.isEmpty()) 485 SuperClassWriter::addAttribute 486 ("units", axis->unit.getValue(), &axisid); 487 488 if (!axis->positive.isEmpty()) 489 if (axis->positive==CAxis::positive_attr::up) SuperClassWriter::addAttribute("positive", string("up"), &axisid); 490 else SuperClassWriter::addAttribute("positive", string("down"), &axisid); 491 492 SuperClassWriter::definition_end(); 493 494 CArray<double,1> axis_value(zoom_size) ; 495 for(StdSize i = 0 ; i < zoom_size ; i++) axis_value(i)=axis->value(i+zoom_begin) ; 496 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 497 438 439 498 440 SuperClassWriter::definition_start(); 499 441 … … 505 447 << " not implemented yet !"); 506 448 } 449 domain->addRelFile(this->filename); 450 } 451 //-------------------------------------------------------------- 452 453 void CNc4DataOutput::writeAxis_(CAxis* axis) 454 { 455 if (axis->IsWritten(this->filename)) return; 456 axis->checkAttributes(); 457 StdSize zoom_size=axis->zoom_size.getValue() ; 458 StdSize zoom_begin=axis->zoom_begin.getValue()-1 ; 459 460 std::vector<StdString> dims; 461 StdString axisid = (!axis->name.isEmpty()) 462 ? axis->name.getValue() : axis->getId(); 463 SuperClassWriter::addDimension(axisid, zoom_size); 464 dims.push_back(axisid); 465 466 switch (SuperClass::type) 467 { 468 case (MULTI_FILE ) : 469 {} 470 case (ONE_FILE) : 471 { 472 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 473 474 SuperClassWriter::addAttribute("axis", StdString("Z"), &axisid); 475 476 if (!axis->standard_name.isEmpty()) 477 SuperClassWriter::addAttribute 478 ("standard_name", axis->standard_name.getValue(), &axisid); 479 480 if (!axis->long_name.isEmpty()) 481 SuperClassWriter::addAttribute 482 ("long_name", axis->long_name.getValue(), &axisid); 483 484 if (!axis->unit.isEmpty()) 485 SuperClassWriter::addAttribute 486 ("units", axis->unit.getValue(), &axisid); 487 488 if (!axis->positive.isEmpty()) 489 if (axis->positive==CAxis::positive_attr::up) SuperClassWriter::addAttribute("positive", string("up"), &axisid); 490 else SuperClassWriter::addAttribute("positive", string("down"), &axisid); 491 492 SuperClassWriter::definition_end(); 493 494 CArray<double,1> axis_value(zoom_size) ; 495 for(StdSize i = 0 ; i < zoom_size ; i++) axis_value(i)=axis->value(i+zoom_begin) ; 496 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 497 498 SuperClassWriter::definition_start(); 499 500 break; 501 } 502 default : 503 ERROR("CNc4DataOutput::writeDomain(domain)", 504 << "[ type = " << SuperClass::type << "]" 505 << " not implemented yet !"); 506 } 507 507 axis->addRelFile(this->filename); 508 508 } 509 509 510 510 void CNc4DataOutput::writeTimeDimension_(void) 511 511 { 512 512 SuperClassWriter::addDimension("time_counter"); 513 SuperClassWriter::addDimension("time_bounds", 2); 513 514 } 514 515 //-------------------------------------------------------------- … … 522 523 CGrid* grid = field->grid; 523 524 CDomain* domain = grid->domain; 524 525 if (domain->isEmpty()) 525 526 if (domain->isEmpty()) 526 527 if (SuperClass::type==MULTI_FILE) return ; 527 528 … … 530 531 ? domain->name.getValue() : domain->getId(); 531 532 StdString appendDomid = (singleDomain) ? "" : "_"+domid ; 532 533 // bool isCurvilinear = domain->isCurvilinear ; 533 534 // bool isCurvilinear = domain->isCurvilinear ; 534 535 // bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ; 535 536 536 537 StdString dimXid,dimYid ; 537 538 538 539 switch (domain->type) 539 540 { … … 550 551 break ; 551 552 } 552 553 /* 553 554 /* 554 555 StdString lonid_loc = (server->intraCommSize > 1) 555 556 ? StdString("lon").append(appendDomid).append("_local") … … 564 565 // unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); 565 566 // bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); 566 // bool isCurvilinear = domain->isCurvilinear ; 567 567 // bool isCurvilinear = domain->isCurvilinear ; 568 568 569 nc_type type ; 569 570 if (field->prec.isEmpty()) type = NC_FLOAT ; … … 572 573 if (field->prec==2) type = NC_SHORT ; 573 574 else if (field->prec==4) type = NC_FLOAT ; 574 else if (field->prec==8) type = NC_DOUBLE ; 575 } 576 575 else if (field->prec==8) type = NC_DOUBLE ; 576 } 577 577 578 bool wtime = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once); 578 579 579 580 if (wtime) 580 581 { 581 582 582 583 //StdOStringStream oss; 583 584 // oss << "time_" << field->operation.getValue() 584 585 // << "_" << field->getRelFile()->output_freq.getValue(); 585 //oss 586 //oss 586 587 if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); 587 588 else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); … … 603 604 coodinates.push_back(StdString("nav_lat").append(appendDomid)); 604 605 break; 605 case CDomain::type_attr::regular : 606 case CDomain::type_attr::unstructured : 606 case CDomain::type_attr::regular : 607 case CDomain::type_attr::unstructured : 607 608 coodinates.push_back(StdString("lon").append(appendDomid)); 608 609 coodinates.push_back(StdString("lat").append(appendDomid)); … … 612 613 if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid); 613 614 dims.push_back(dimXid); 614 615 615 616 SuperClassWriter::addVariable(fieldid, type, dims); 616 617 617 618 if (!field->standard_name.isEmpty()) 618 619 SuperClassWriter::addAttribute … … 642 643 SuperClassWriter::addAttribute 643 644 ("add_offset", field->add_offset.getValue(), &fieldid); 644 645 645 646 SuperClassWriter::addAttribute 646 647 ("online_operation", field->operation.getValue(), &fieldid); 647 648 648 649 // write child variables as attributes 649 650 650 651 651 652 vector<CVariable*> listVars = field->getAllVariables() ; 652 653 for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; 653 654 654 655 655 656 if (wtime) 656 657 { … … 665 666 SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); 666 667 } 667 668 668 669 if (!field->default_value.isEmpty()) 669 670 { … … 679 680 double * default_value = NULL; 680 681 SuperClassWriter::setDefaultValue(fieldid, default_value); 681 } 682 } 682 683 683 684 { // Ecriture des coordonnées 684 685 685 686 StdString coordstr; //boost::algorithm::join(coodinates, " ") 686 std::vector<StdString>::iterator 687 std::vector<StdString>::iterator 687 688 itc = coodinates.begin(), endc = coodinates.end(); 688 689 689 690 for (; itc!= endc; itc++) 690 691 { … … 717 718 else singleDomain=false ; 718 719 } 719 720 720 721 void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId) 721 722 { … … 724 725 else if (var->hasId()) name=var->getId() ; 725 726 else return ; 726 727 if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>(),&fieldId) ; 728 else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>(),&fieldId) ; 729 else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>(),&fieldId) ; 730 else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>(),&fieldId) ; 731 else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>(),&fieldId) ; 732 else addAttribute(name,var->getData<string>(),&fieldId) ; 727 728 if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>(),&fieldId) ; 729 else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>(),&fieldId) ; 730 else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>(),&fieldId) ; 731 else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>(),&fieldId) ; 732 else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>(),&fieldId) ; 733 else addAttribute(name,var->getData<string>(),&fieldId) ; 733 734 } 734 735 735 736 void CNc4DataOutput::writeAttribute_ (CVariable* var) 736 737 { … … 739 740 else if (var->hasId()) name=var->getId() ; 740 741 else return ; 741 742 if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>()) ; 743 else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>()) ; 744 else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>()) ; 745 else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>()) ; 746 else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>()) ; 747 else addAttribute(name,var->getData<string>()) ; 748 } 749 742 743 if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>()) ; 744 else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>()) ; 745 else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>()) ; 746 else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>()) ; 747 else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>()) ; 748 else addAttribute(name,var->getData<string>()) ; 749 } 750 750 751 void CNc4DataOutput::syncFile_ (void) 751 752 { … … 773 774 return (StdString(buffer)); 774 775 } 775 776 776 777 //--------------------------------------------------------------- 777 778 778 779 void CNc4DataOutput::writeFieldData_ (CField* field) 779 780 { … … 784 785 CGrid* grid = field->grid ; 785 786 CDomain* domain = grid->domain ; 786 787 787 788 if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return; 788 789 789 790 790 StdString fieldid = (!field->name.isEmpty()) 791 ? field->name.getValue() 791 StdString fieldid = (!field->name.isEmpty()) 792 ? field->name.getValue() 792 793 : field->getBaseFieldReference()->getId(); 793 794 794 795 StdOStringStream oss; 795 796 string timeAxisId ; … … 797 798 else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisId="time_centered" ; 798 799 799 800 StdString timeBoundId("time_counter_bounds"); 801 802 StdString timeAxisBoundId; 803 if (field->foperation->timeType() == func::CFunctor::instant) timeAxisBoundId="time_instant_bounds" ; 804 else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisBoundId="time_centered_bounds" ; 805 800 806 CArray<double,1> time_data(1) ; 801 807 CArray<double,1> time_counter(1) ; 802 808 CArray<double,1> time_counter_bound(2); 809 CArray<double,1> time_data_bound(2); 810 803 811 bool wtime = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once)); 804 812 805 813 if (wtime) 806 814 { 807 815 time_counter(0)= (Time(*field->last_Write_srv)+Time(*field->lastlast_Write_srv))/2 -Time(context->calendar->getTimeOrigin()); 808 if (field->foperation->timeType() == func::CFunctor::instant) 816 if (field->foperation->timeType() == func::CFunctor::instant) 809 817 time_data(0) = Time(*field->last_Write_srv)-Time(context->calendar->getTimeOrigin()); 810 818 else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0); 811 812 } 813 814 819 820 time_counter_bound(0) = Time(*field->lastlast_Write_srv) - Time(context->calendar->getTimeOrigin()); 821 time_counter_bound(1) = Time(*field->last_Write_srv) - Time(context->calendar->getTimeOrigin()); 822 if (field->foperation->timeType() == func::CFunctor::instant) 823 time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv)-Time(context->calendar->getTimeOrigin()); 824 else if (field->foperation->timeType() == func::CFunctor::centered) 825 { 826 time_data_bound(0) = time_counter_bound(0); 827 time_data_bound(1) = time_counter_bound(1); 828 } 829 } 830 815 831 bool isRoot ; 816 832 if (server->intraCommRank==0) isRoot=true ; 817 833 else isRoot=false ; 818 834 819 835 if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) 820 836 { … … 825 841 field->scaleFactorAddOffset(scaleFactor,addOffset) ; 826 842 } 827 843 828 844 if (grid->hasAxis()) // 3D 829 845 { … … 841 857 { 842 858 SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1); 843 if (wtime) 859 if (wtime) 844 860 { 845 861 SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 846 862 SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 863 SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 864 SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 847 865 } 848 866 break ; … … 850 868 case (ONE_FILE) : 851 869 { 852 std::vector<StdSize> start(3) ; 870 std::vector<StdSize> start(3) ; 853 871 std::vector<StdSize> count(3) ; 854 872 if (domain->isEmpty()) … … 864 882 } 865 883 SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); 866 if (wtime) 884 if (wtime) 867 885 { 868 886 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); 869 887 SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); 888 SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); 889 SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 870 890 } 871 891 break; 872 892 } 873 893 } 874 894 875 895 } 876 896 else // 2D … … 885 905 { 886 906 SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1); 887 if (wtime) 907 if (wtime) 888 908 { 889 909 SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); 890 910 SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); 911 SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); 912 SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); 891 913 } 892 914 break; … … 894 916 case (ONE_FILE) : 895 917 { 896 std::vector<StdSize> start(2) ; 918 std::vector<StdSize> start(2) ; 897 919 std::vector<StdSize> count(2) ; 898 920 if (domain->isEmpty()) … … 903 925 else 904 926 { 905 start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 927 start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; 906 928 count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 907 929 } 908 930 909 931 SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count); 910 if (wtime) 932 if (wtime) 911 933 { 912 934 SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot); 913 935 SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot); 914 } 915 break; 916 936 SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot); 937 SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); 938 } 939 break; 940 917 941 } 918 942 } … … 927 951 { 928 952 StdOStringStream oss; 929 953 930 954 // if (field->operation.getValue().compare("once") == 0) return ; 931 955 if (field->foperation->timeType() == func::CFunctor::once) return ; 932 956 933 957 // oss << "time_" << field->operation.getValue() 934 958 // << "_" << field->getRelFile()->output_freq.getValue(); 935 936 string axisid ; 937 if (field->foperation->timeType() == func::CFunctor::centered) axisid="time_centered" ; 938 else if (field->foperation->timeType() == func::CFunctor::instant) axisid="time_instant" ; 939 959 960 // StdString axisid = oss.str(); 961 // if (field->foperation->timeType() == func::CFunctor::centered) axisid="time_centered" ; 962 // else if (field->foperation->timeType() == func::CFunctor::instant) axisid="time_instant" ; 963 964 StdString axisid("time_centered") ; 965 StdString axisBoundId("time_centered_bounds"); 966 StdString timeid("time_counter"); 967 StdString timeBoundId("time_bounds"); 968 969 if (field->foperation->timeType() == func::CFunctor::instant) 970 { 971 axisid = "time_instant"; 972 axisBoundId = "time_instant_bounds"; 973 } 974 975 // Adding time_instant or time_centered 940 976 std::vector<StdString> dims; 941 // StdString axisid = oss.str();942 StdString timeid = StdString("time_counter");943 944 977 dims.push_back(timeid); 945 978 if (!SuperClassWriter::varExist(axisid)) 946 979 { 947 980 SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); 948 981 949 982 CDate timeOrigin=cal->getTimeOrigin() ; 950 //StdOStringStream oss2;983 StdOStringStream oss2; 951 984 // oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" " 952 985 // <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ; 953 //StdString strInitdate=oss2.str() ;986 StdString strInitdate=oss2.str() ; 954 987 StdString strTimeOrigin=timeOrigin.toString() ; 955 988 this->writeTimeAxisAttributes 956 989 (axisid, cal->getType(), 957 990 StdString("seconds since ").append(strTimeOrigin), 958 strTimeOrigin); 959 } 960 991 strTimeOrigin, axisBoundId); 992 } 993 994 // Adding time_instant_bounds or time_centered_bounds variables 995 if (!SuperClassWriter::varExist(axisBoundId)) 996 { 997 dims.clear() ; 998 dims.push_back(timeid); 999 dims.push_back(timeBoundId); 1000 SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 1001 } 1002 1003 // Adding time_counter 1004 axisid = "time_counter" ; 1005 axisBoundId = "time_counter_bounds" ; 961 1006 dims.clear() ; 962 axisid = "time_counter" ;963 timeid = "time_counter" ;964 965 1007 dims.push_back(timeid); 966 1008 if (!SuperClassWriter::varExist(axisid)) … … 970 1012 CDate timeOrigin=cal->getTimeOrigin() ; 971 1013 StdString strTimeOrigin=timeOrigin.toString() ; 1014 972 1015 this->writeTimeAxisAttributes 973 1016 (axisid, cal->getType(), 974 1017 StdString("seconds since ").append(strTimeOrigin), 975 strTimeOrigin); 976 } 977 978 1018 strTimeOrigin, axisBoundId); 1019 } 1020 1021 // Adding time_counter_bound dimension 1022 if (!SuperClassWriter::varExist(axisBoundId)) 1023 { 1024 dims.clear(); 1025 dims.push_back(timeid); 1026 dims.push_back(timeBoundId); 1027 SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); 1028 } 979 1029 } 980 1030 981 1031 //--------------------------------------------------------------- 982 1032 983 1033 void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, 984 1034 const StdString & calendar, 985 1035 const StdString & units, 986 1036 const StdString & time_origin, 1037 const StdString & time_bounds, 987 1038 const StdString & standard_name, 988 1039 const StdString & long_name, … … 995 1046 SuperClassWriter::addAttribute("units", units , &axis_name); 996 1047 SuperClassWriter::addAttribute("time_origin", time_origin , &axis_name); 997 } 998 1048 SuperClassWriter::addAttribute("bounds", time_bounds , &axis_name); 1049 } 1050 999 1051 //--------------------------------------------------------------- 1000 1052 … … 1014 1066 1015 1067 //--------------------------------------------------------------- 1016 1068 1017 1069 void CNc4DataOutput::writeLocalAttributes 1018 1070 (int ibegin, int ni, int jbegin, int nj, StdString domid) -
XIOS/trunk/src/output/nc4_data_output.hpp
r472 r488 54 54 55 55 protected : 56 void writeUnstructuredDomain (CDomain* domain); 56 void writeUnstructuredDomain (CDomain* domain); 57 57 void writeLocalAttributes(int ibegin, int ni, int jbegin, int nj, StdString domid); 58 58 void writeLocalAttributes_IOIPSL(int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size) ; … … 61 61 const StdString & units, 62 62 const StdString & time_origin, 63 const StdString & time_bounds = StdString("bounds"), 63 64 const StdString & standard_name = StdString("time"), 64 65 const StdString & long_name = StdString("Time axis"),
Note: See TracChangeset
for help on using the changeset viewer.