Changeset 614 for XIOS/branchs


Ignore:
Timestamp:
06/11/15 10:30:11 (9 years ago)
Author:
rlacroix
Message:

Improve CF compliance: Minor tweaks and improvements.

  • Bump the CF version to 1.5.
  • Use the same bounds dimension for all axis, including time axis.
  • Add a standard_name attribute for cell area variables.
  • Set the interval part of cell_methods attribute only when the write interval and the operation interval are different.
Location:
XIOS/branchs/xios-1.0/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/branchs/xios-1.0/src/calendar_util.cpp

    r501 r614  
    126126 
    127127      //----------------------------------------------------------------- 
     128 
     129    bool operator==(const CDuration& ddr, const CDuration& dr) 
     130    { 
     131      return ((ddr.year == dr.year) && (ddr.month  == dr.month)  && (dr.day    == ddr.day) && 
     132              (ddr.hour == dr.hour) && (ddr.minute == dr.minute) && (dr.second == ddr.second) && 
     133              (ddr.timestep == dr.timestep)); 
     134    } 
     135 
     136    bool operator!=(const CDuration& ddr, const CDuration& dr) 
     137    { 
     138      return !(ddr == dr); 
     139    } 
    128140 
    129141      /// Les opérateurs de comparaison. (Non testés pour le moment) 
  • XIOS/branchs/xios-1.0/src/calendar_util.hpp

    r501 r614  
    2323 
    2424      /// Les opérateurs de comparaison. (Non testés pour le moment) 
     25      bool operator==(const CDuration& ddr, const CDuration& dr); 
     26      bool operator!=(const CDuration& ddr, const CDuration& dr); 
     27 
    2528      bool operator==(const CDate& dt0, const CDate& dt1); 
    2629      bool operator< (const CDate& dt0, const CDate& dt1); 
  • XIOS/branchs/xios-1.0/src/output/nc4_data_output.cpp

    r613 r614  
    214214                 { 
    215215                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     216                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    216217                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    217218                 } 
     
    270271                   dim0.push_back(dimYid); dim0.push_back(dimXid); 
    271272                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     273                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    272274                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    273275                   dim0.clear(); 
     
    433435                 { 
    434436                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     437                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    435438                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    436439                 } 
     
    484487                   dim0.push_back(dimXid); 
    485488                   SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); 
     489                   SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); 
    486490                   SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); 
    487491                 } 
     
    639643       try 
    640644       { 
    641         SuperClassWriter::addDimension("time_counter"); 
    642         SuperClassWriter::addDimension("time_bounds", 2); 
     645         SuperClassWriter::addDimension("time_counter"); 
    643646       } 
    644647       catch (CNetCdfException& e) 
    645648       { 
    646          StdString msg("On writing time dimension : time_couter, time_bounds \n"); 
     649         StdString msg("On writing time dimension : time_couter\n"); 
    647650         msg.append("In the context : "); 
    648651         CContext* context = CContext::getCurrent() ; 
     
    797800           if (wtime) 
    798801           { 
    799               CDuration duration = CDuration::FromString(field->freq_op); 
    800               duration.solveTimeStep(*context->calendar); 
    801               StdString freqOpStr = duration.toStringUDUnits(); 
     802              CDuration freqOp = CDuration::FromString(field->freq_op); 
     803              freqOp.solveTimeStep(*context->calendar); 
     804              StdString freqOpStr = freqOp.toStringUDUnits(); 
    802805              SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 
    803806 
    804               duration = CDuration::FromString(field->getRelFile()->output_freq); 
    805               duration.solveTimeStep(*context->calendar); 
    806               SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 
     807              CDuration freqOut = CDuration::FromString(field->getRelFile()->output_freq); 
     808              freqOut.solveTimeStep(*context->calendar); 
     809              SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); 
    807810 
    808811              StdString cellMethods = coodinates.front() + ": "; 
     
    811814              else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 
    812815              else cellMethods += field->operation; 
    813               cellMethods += " (interval: " + freqOpStr + ")"; 
     816              if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) 
     817                cellMethods += " (interval: " + freqOpStr + ")"; 
    814818              SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 
    815819           } 
     
    881885         { 
    882886           this->writeFileAttributes(filename, description, 
    883                                      StdString("CF-1.1"), 
     887                                     StdString("CF-1.5"), 
    884888                                     StdString("An IPSL model"), 
    885889                                     this->getTimeStamp()); 
    886890 
    887            if (file->nbAxis >= 1) 
    888              SuperClassWriter::addDimension("axis_nbounds", 2); 
     891           SuperClassWriter::addDimension("axis_nbounds", 2); 
    889892         } 
    890893         catch (CNetCdfException& e) 
     
    12081211         StdString axisBoundId("time_centered_bounds"); 
    12091212         StdString timeid("time_counter"); 
    1210          StdString timeBoundId("time_bounds"); 
     1213         StdString timeBoundId("axis_nbounds"); 
    12111214 
    12121215         if (field->foperation->timeType() == func::CFunctor::instant) 
Note: See TracChangeset for help on using the changeset viewer.