Ignore:
Timestamp:
03/22/18 10:43:20 (6 years ago)
Author:
yushan
Message:

branch_openmp merged with XIOS_DEV_CMIP6@1459

File:
1 edited

Legend:

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

    r1338 r1460  
    188188      listDimSize.push_front(*itMap); 
    189189*/ 
    190     for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 
    191       listDimSize.push_front(*dimSizeMap.find(*it)); 
     190 
     191    if (!SuperClassWriter::isRectilinear(fieldId)) 
     192    { 
     193      for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 
     194        listDimSize.push_front(*dimSizeMap.find(*it)); 
     195    } 
     196    else 
     197    { 
     198       std::list<StdString> coords = SuperClassWriter::getCoordinatesIdList(fieldId); 
     199       std::list<StdString>::const_iterator itCoord = coords.begin(); 
     200       for (; itCoord != coords.end(); itCoord++) 
     201       { 
     202         const StdString& coord = *itCoord; 
     203         if (SuperClassWriter::hasVariable(coord) && !SuperClassWriter::isTemporal(coord)) 
     204         { 
     205           std::map<StdString, StdSize> dimsTmp = SuperClassWriter::getDimensions(&coord); 
     206           StdString dimNameTmp = dimsTmp.begin()->first; 
     207           StdSize dimSizeTmp = dimsTmp.begin()->second; 
     208           listDimSize.push_front(make_pair(coord, dimSizeTmp)); 
     209           dimSizeMap.erase(dimNameTmp); 
     210           dimList.remove(dimNameTmp); 
     211         } 
     212       } 
     213       for (std::list<StdString>::const_iterator it = dimList.begin(); it != dimList.end(); ++it) 
     214        listDimSize.push_front(*dimSizeMap.find(*it)); 
     215    } 
    192216 
    193217    // Now process domain and axis 
     
    268292    if ((CDomain::type_attr::rectilinear == domain->type)) 
    269293    { 
    270       // Ok, try to read some f.. attributes such as longitude and latitude 
     294      // Ok, try to read some attributes such as longitude and latitude 
    271295      bool hasLat = SuperClassWriter::hasVariable(itMapNj->first); 
    272296      if (hasLat) 
     
    287311    else if ((CDomain::type_attr::curvilinear == domain->type)) 
    288312    { 
    289       int ni = domain->ni; 
    290       int nj = domain->nj; 
     313      // Make sure that if there is no local domain defined on a process, the process still reads just one value. 
     314      int ni, nj, ibegin, jbegin; 
     315      if (domain->ni == 0) 
     316      { 
     317        ni = 1; 
     318        ibegin = 0; 
     319      } 
     320      else 
     321      { 
     322        ni = domain->ni; 
     323        ibegin = domain->ibegin; 
     324      } 
     325      if (domain->nj == 0) 
     326      { 
     327        nj = 1; 
     328        jbegin = 0; 
     329      } 
     330      else 
     331      { 
     332        nj = domain->nj; 
     333        jbegin = domain->jbegin; 
     334      } 
     335 
    291336      std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 
    292       nBeginLatLon[0] = 0; nBeginLatLon[1] = 0; 
    293       nSizeLatLon[0]  = domain->nj_glo.getValue(); nSizeLatLon[1] = domain->ni_glo.getValue(); 
     337      nBeginLatLon[0] = jbegin; nBeginLatLon[1] = ibegin; 
     338      nSizeLatLon[0]  = nj; nSizeLatLon[1] = ni; 
    294339 
    295340      StdString latName = this->getLatCoordName(fieldId); 
    296341      if (SuperClassWriter::hasVariable(latName)) 
    297342      { 
    298         domain->latvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     343        domain->latvalue_curvilinear_read_from_file.resize(ni, nj); 
    299344        readFieldVariableValue(domain->latvalue_curvilinear_read_from_file, latName, nBeginLatLon, nSizeLatLon); 
    300345      } 
     
    302347      if (SuperClassWriter::hasVariable(lonName)) 
    303348      { 
    304         domain->lonvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     349        domain->lonvalue_curvilinear_read_from_file.resize(ni, nj); 
    305350        readFieldVariableValue(domain->lonvalue_curvilinear_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    306351      } 
     
    309354      StdString boundsLonName = this->getBoundsId(lonName); 
    310355 
    311       int nbVertex = this->getNbVertex(fieldId); 
     356      int nbVertex = 4; //this->getNbVertex(fieldId); 
    312357      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex)) 
    313358      { 
     
    324369 
    325370      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
    326       nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
    327       nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->ni_glo.getValue(); 
     371      nBeginBndsLatLon[0] = jbegin; nSizeBndsLatLon[0] = nj; 
     372      nBeginBndsLatLon[1] = ibegin; nSizeBndsLatLon[1] = ni; 
    328373      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    329374 
    330375      if (SuperClassWriter::hasVariable(boundsLatName)) 
    331376      { 
    332         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); 
    333378        readFieldVariableValue(domain->bounds_latvalue_curvilinear_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    334379 
     
    336381      if (SuperClassWriter::hasVariable(boundsLonName))  
    337382      { 
    338         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); 
    339384        readFieldVariableValue(domain->bounds_lonvalue_curvilinear_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    340385      }       
     
    342387    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId))) 
    343388    { 
     389      // Make sure that if there is no local domain defined on a process, the process still reads just one value. 
     390      int ni, ibegin; 
     391      if (domain->ni == 0) 
     392      { 
     393        ni = 1; 
     394        ibegin = 0; 
     395      } 
     396      else 
     397      { 
     398        ni = domain->ni; 
     399        ibegin = domain->ibegin; 
     400      } 
     401 
    344402      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    345       nSizeLatLon[0]  = domain->ni_glo.getValue(); 
    346       CArray<double,1> globalLonLat(domain->ni_glo.getValue()); 
     403      nBeginLatLon[0] = ibegin; 
     404      nSizeLatLon[0]  = ni; 
    347405 
    348406      StdString latName = this->getLatCoordName(fieldId); 
    349407      if (SuperClassWriter::hasVariable(latName)) 
    350408      { 
    351         domain->latvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     409        domain->latvalue_unstructured_read_from_file.resize(ni); 
    352410        readFieldVariableValue(domain->latvalue_unstructured_read_from_file, latName, nBeginLatLon, nSizeLatLon);   
    353411      } 
     
    356414      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 
    357415      { 
    358         // readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
    359         domain->lonvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     416        domain->lonvalue_unstructured_read_from_file.resize(ni); 
    360417        readFieldVariableValue(domain->lonvalue_unstructured_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    361418      } 
     
    379436 
    380437      std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 
    381       nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 
     438      nBeginBndsLatLon[0] = ibegin; nSizeBndsLatLon[0] = ni; 
    382439      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
    383440 
     
    496553 
    497554    { // Read axis value 
    498       std::vector<StdSize> nBegin(1, 0), nSize(1, itMapN->second); 
    499       CArray<double,1> readAxisValue(itMapN->second); 
    500       readFieldVariableValue(readAxisValue, itMapN->first, nBegin, nSize, true); 
    501       int begin = 0, n = itMapN->second; 
    502       if (!axis->begin.isEmpty()) begin = axis->begin.getValue(); 
    503       if (!axis->n.isEmpty()) n = axis->n.getValue(); 
    504       axis->value.resize(n); 
    505       for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 
     555      bool hasValue = SuperClassWriter::hasVariable(itMapN->first); 
     556      if (hasValue) 
     557      { 
     558        std::vector<StdSize> nBegin(1, 0), nSize(1, itMapN->second); 
     559        CArray<double,1> readAxisValue(itMapN->second); 
     560        readFieldVariableValue(readAxisValue, itMapN->first, nBegin, nSize, true); 
     561        int begin = 0, n = itMapN->second; 
     562        if (!axis->begin.isEmpty()) begin = axis->begin.getValue(); 
     563        if (!axis->n.isEmpty()) n = axis->n.getValue(); 
     564        axis->value.resize(n); 
     565        for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 
     566      } 
    506567    } 
    507568  } 
Note: See TracChangeset for help on using the changeset viewer.