Ignore:
Timestamp:
01/24/18 18:45:14 (6 years ago)
Author:
oabramkina
Message:

Improving protocol for reading : grid attributes such longitude, latitude, etc are read by clients locally.
It concerns only curvilinear and unstructured domains. Local attributes such as ni/nj, ibegin/jbegin are mandatory as before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/io/nc4_data_input.cpp

    r1310 r1410  
    264264    if ((CDomain::type_attr::rectilinear == domain->type)) 
    265265    { 
    266       // Ok, try to read some f.. attributes such as longitude and latitude 
     266      // Ok, try to read some attributes such as longitude and latitude 
    267267      bool hasLat = SuperClassWriter::hasVariable(itMapNj->first); 
    268268      if (hasLat) 
     
    283283    else if ((CDomain::type_attr::curvilinear == domain->type)) 
    284284    { 
    285       int ni = domain->ni; 
    286       int nj = domain->nj; 
     285      int ni, nj; 
    287286      std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 
    288       nBeginLatLon[0] = 0; nBeginLatLon[1] = 0; 
    289       nSizeLatLon[0]  = domain->nj_glo.getValue(); nSizeLatLon[1] = domain->ni_glo.getValue(); 
     287 
     288      if (domain->ni.isEmpty()) 
     289      { 
     290        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     291          << " Value of attribute ni should be defined for domain " << domain->getDomainOutputName() 
     292          << " in file " << this->filename << "." 
     293          << " The value can be provided by a user or generated automatically by XIOS." 
     294          << " Functionality generate_rectilinear_domain can also be used for curvilinear domains." 
     295          << std::endl); 
     296      } 
     297 
     298      if (domain->nj.isEmpty()) 
     299      { 
     300        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     301          << " Value of attribute nj should be defined for domain " << domain->getDomainOutputName() 
     302          << " in file " << this->filename << "." 
     303          << " The value can be provided by a user or generated automatically by XIOS." 
     304          << " Functionality generate_rectilinear_domain can also be used for curvilinear domains." 
     305          << std::endl); 
     306      } 
     307 
     308      if (domain->ibegin.isEmpty()) 
     309      { 
     310        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     311          << " Value of attribute ibegin should be defined for domain " << domain->getDomainOutputName() 
     312          << " in file " << this->filename << "." 
     313          << " The value can be provided by a user or generated automatically by XIOS." 
     314          << " Functionality generate_rectilinear_domain can also be used for curvilinear domains." 
     315          << std::endl); 
     316      } 
     317 
     318      if (domain->jbegin.isEmpty()) 
     319      { 
     320        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     321          << " Value of attribute jbegin should be defined for domain " << domain->getDomainOutputName() 
     322          << " in file " << this->filename << "." 
     323          << " The value can be provided by a user or generated automatically by XIOS." 
     324          << " Functionality generate_rectilinear_domain can also be used for curvilinear domains." 
     325          << std::endl); 
     326      } 
     327 
     328      ni = domain->ni; 
     329      nj = domain->nj; 
     330      nBeginLatLon[0] = domain->jbegin; nBeginLatLon[1] = domain->ibegin; 
     331      nSizeLatLon[0]  = nj; nSizeLatLon[1] = ni; 
     332//      ni = domain->ni_glo; 
     333//      nj = domain->nj_glo; 
     334//      nBeginLatLon[0] = 0; nBeginLatLon[1] = 0; 
     335//      nSizeLatLon[0]  = domain->nj_glo.getValue(); nSizeLatLon[1] = domain->ni_glo.getValue(); 
    290336 
    291337      StdString latName = this->getLatCoordName(fieldId); 
    292338      if (SuperClassWriter::hasVariable(latName)) 
    293339      { 
    294         domain->latvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     340        domain->latvalue_curvilinear_read_from_file.resize(ni,nj); 
    295341        readFieldVariableValue(domain->latvalue_curvilinear_read_from_file, latName, nBeginLatLon, nSizeLatLon); 
    296342      } 
     
    298344      if (SuperClassWriter::hasVariable(lonName)) 
    299345      { 
    300         domain->lonvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     346        domain->lonvalue_curvilinear_read_from_file.resize(ni,nj); 
    301347        readFieldVariableValue(domain->lonvalue_curvilinear_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    302348      } 
     
    320366 
    321367      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
    322       nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
    323       nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->ni_glo.getValue(); 
     368      nBeginBndsLatLon[0] = domain->jbegin; nSizeBndsLatLon[0] = domain->nj.getValue(); 
     369      nBeginBndsLatLon[1] = domain->ibegin; nSizeBndsLatLon[1] = domain->ni.getValue(); 
    324370      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
     371//      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
     372//      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->ni_glo.getValue(); 
     373//      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    325374 
    326375      if (SuperClassWriter::hasVariable(boundsLatName)) 
    327376      { 
    328         domain->bounds_latvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     377        domain->bounds_latvalue_curvilinear_read_from_file.resize(nbVertex,ni,nj); 
    329378        readFieldVariableValue(domain->bounds_latvalue_curvilinear_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    330379 
     
    332381      if (SuperClassWriter::hasVariable(boundsLonName))  
    333382      { 
    334         domain->bounds_lonvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     383        domain->bounds_lonvalue_curvilinear_read_from_file.resize(nbVertex,ni,nj); 
    335384        readFieldVariableValue(domain->bounds_lonvalue_curvilinear_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    336385      }       
     
    338387    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId))) 
    339388    { 
     389      if (domain->ni.isEmpty()) 
     390      { 
     391        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     392          << " Value of attribute ni should be defined for domain " << domain->getDomainOutputName() 
     393          << " in file " << this->filename << "." 
     394          << std::endl); 
     395      } 
     396 
     397      if (domain->ibegin.isEmpty()) 
     398      { 
     399        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     400          << " Value of attribute ibegin should be defined for domain " << domain->getDomainOutputName() 
     401          << " in file " << this->filename << "." 
     402          << std::endl); 
     403      } 
     404 
     405      int ni; 
    340406      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    341       nSizeLatLon[0]  = domain->ni_glo.getValue(); 
    342       CArray<double,1> globalLonLat(domain->ni_glo.getValue()); 
     407 
     408      ni = domain->ni; 
     409      nBeginLatLon[0] = domain->ibegin; 
     410//      ni = domain->ni_glo; 
     411//      nBeginLatLon[0] = 0; 
     412      nSizeLatLon[0] = ni; 
    343413 
    344414      StdString latName = this->getLatCoordName(fieldId); 
    345415      if (SuperClassWriter::hasVariable(latName)) 
    346416      { 
    347         domain->latvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     417        domain->latvalue_unstructured_read_from_file.resize(ni); 
    348418        readFieldVariableValue(domain->latvalue_unstructured_read_from_file, latName, nBeginLatLon, nSizeLatLon);   
    349419      } 
     
    352422      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 
    353423      { 
    354         // readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
    355         domain->lonvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     424        domain->lonvalue_unstructured_read_from_file.resize(ni); 
    356425        readFieldVariableValue(domain->lonvalue_unstructured_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    357426      } 
     
    375444 
    376445      std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 
    377       nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 
    378       nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
    379  
    380       if (SuperClassWriter::hasVariable(boundsLatName))  
     446 
     447      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni.getValue(); 
     448      nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = nbVertex; 
     449//      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 
     450//      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
     451 
     452        if (SuperClassWriter::hasVariable(boundsLatName)) 
    381453      { 
    382454        domain->bounds_latvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
Note: See TracChangeset for help on using the changeset viewer.