Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

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

    r967 r1158  
    262262    itMapNj = itMapNi; ++itMapNj; 
    263263 
    264     if ((CDomain::type_attr::rectilinear == domain->type))// || this->isRectilinear(fieldId)) 
     264    if ((CDomain::type_attr::rectilinear == domain->type)) 
    265265    { 
    266266      // Ok, try to read some f.. attributes such as longitude and latitude 
     
    279279        std::vector<StdSize> nBeginLon(1, 0), nSizeLon(1, itMapNi->second); 
    280280        readFieldVariableValue(domain->lonvalue_rectilinear_read_from_file, itMapNi->first, nBeginLon, nSizeLon, true); 
    281       } 
    282       domain->fillInRectilinearLonLat(); 
    283     } 
    284     else if ((CDomain::type_attr::curvilinear == domain->type))// || (this->isCurvilinear(fieldId))) 
     281      }       
     282    } 
     283    else if ((CDomain::type_attr::curvilinear == domain->type)) 
    285284    { 
    286285      int ni = domain->ni; 
    287286      int nj = domain->nj; 
    288287      std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 
    289       nBeginLatLon[0] = domain->jbegin.getValue(); nBeginLatLon[1] = domain->ibegin.getValue(); 
    290       nSizeLatLon[0]  = nj; nSizeLatLon[1] = ni; 
     288      nBeginLatLon[0] = 0; nBeginLatLon[1] = 0; 
     289      nSizeLatLon[0]  = domain->nj_glo.getValue(); nSizeLatLon[1] = domain->ni_glo.getValue(); 
    291290 
    292291      StdString latName = this->getLatCoordName(fieldId); 
    293       if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare("")) 
    294       { 
    295         domain->latvalue_2d.resize(ni,nj); 
    296         readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 
     292      if (SuperClassWriter::hasVariable(latName)) 
     293      { 
     294        domain->latvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     295        readFieldVariableValue(domain->latvalue_curvilinear_read_from_file, latName, nBeginLatLon, nSizeLatLon); 
    297296      } 
    298297      StdString lonName = this->getLonCoordName(fieldId); 
    299       if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 
    300       { 
    301         domain->lonvalue_2d.resize(ni,nj); 
    302         readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 
     298      if (SuperClassWriter::hasVariable(lonName)) 
     299      { 
     300        domain->lonvalue_curvilinear_read_from_file.resize(domain->ni_glo,domain->nj_glo); 
     301        readFieldVariableValue(domain->lonvalue_curvilinear_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    303302      } 
    304303 
     
    307306 
    308307      int nbVertex = this->getNbVertex(fieldId); 
    309       if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) //if ((0 != boundsLatName.compare("")) || (0 != boundsLonName.compare(""))) 
     308      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex)) 
     309      { 
     310        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     311          << "The domain " << domain->getDomainOutputName() 
     312          << " has nvertex read from file " << this->filename << " and nvertex provided from model" 
     313          << " are not coherent. They should be the same." << std::endl  
     314          << " nvertex read from file: "<< nbVertex 
     315          << " nvertex from model: "<< domain->nvertex << std::endl); 
     316      }  
     317 
     318      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName))  
    310319        domain->nvertex.setValue(nbVertex); 
    311320      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
    312       nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 
    313       nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 
     321      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
     322      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->nj_glo.getValue(); 
    314323      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    315324 
    316       if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare("")) 
    317       { 
    318         domain->bounds_lat_2d.resize(nbVertex,ni,nj); 
    319         readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    320  
    321       } 
    322       if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare("")) 
    323       { 
    324         domain->bounds_lon_2d.resize(nbVertex,ni,nj); 
    325         readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    326       } 
     325      if (SuperClassWriter::hasVariable(boundsLatName)) 
     326      { 
     327        domain->bounds_latvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     328        readFieldVariableValue(domain->bounds_latvalue_curvilinear_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     329 
     330      } 
     331      if (SuperClassWriter::hasVariable(boundsLonName))  
     332      { 
     333        domain->bounds_lonvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     334        readFieldVariableValue(domain->bounds_lonvalue_curvilinear_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     335      }       
    327336    } 
    328337    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId))) 
    329338    { 
    330       /* 
    331       if (domain->i_index.isEmpty()) 
    332          ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
    333               << "Field '" << fieldId << std::endl 
    334               << "Trying to read attributes from unstructured grid." 
    335               << "i_index of domain" << domain->getId() << " is mandatory"); 
    336  
    337       int ni = domain->i_index.numElements(); 
    338 */ 
    339  
    340       int ni     = domain->ni.isEmpty() ? 0 : domain->ni; 
    341       int ibegin = domain->ibegin.isEmpty() ? 0 : domain->ibegin; 
    342  
    343       if (domain->i_index.isEmpty() && (!domain->ni.isEmpty()) ) 
    344       { 
    345         domain->i_index.resize(ni) ; 
    346         for(int idx = 0; idx < ni; ++idx) domain->i_index(idx)=ibegin+idx ; 
    347       } 
    348  
    349339      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    350340      nSizeLatLon[0]  = domain->ni_glo.getValue(); 
     
    352342 
    353343      StdString latName = this->getLatCoordName(fieldId); 
    354       if (SuperClassWriter::hasVariable(latName)) //(0 != latName.compare("")) 
    355       { 
    356         readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon); 
    357         domain->latvalue_1d.resize(ni); 
    358         for (int idx = 0; idx < ni; ++idx) 
    359           domain->latvalue_1d(idx) =  globalLonLat(domain->i_index(idx)); 
     344      if (SuperClassWriter::hasVariable(latName)) 
     345      { 
     346        domain->latvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     347        readFieldVariableValue(domain->latvalue_unstructured_read_from_file, latName, nBeginLatLon, nSizeLatLon);   
    360348      } 
    361349 
     
    363351      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 
    364352      { 
    365         readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
    366         domain->lonvalue_1d.resize(ni); 
    367         for (int idx = 0; idx < ni; ++idx) 
    368           domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 
     353        // readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
     354        domain->lonvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     355        readFieldVariableValue(domain->lonvalue_unstructured_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    369356      } 
    370357 
     
    373360 
    374361      int nbVertex = this->getNbVertex(fieldId); 
    375       if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) // (0 != boundsLatName.compare("")) || (0 != boundsLonName.compare(""))) 
     362      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex)) 
     363      { 
     364        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     365          << "The domain " << domain->getDomainOutputName() 
     366          << " has nvertex read from file " << this->filename << " and nvertex provided from model" 
     367          << " are not coherent. They should be the same." << std::endl  
     368          << " nvertex read from file: "<< nbVertex 
     369          << " nvertex from model: "<< domain->nvertex << std::endl); 
     370      }  
     371       
     372      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName))  
    376373        domain->nvertex.setValue(nbVertex); 
    377374 
     
    380377      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
    381378 
    382       if (SuperClassWriter::hasVariable(boundsLatName)) //(0 != boundsLatName.compare("")) 
    383       { 
    384         CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
    385         readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    386         domain->bounds_lat_1d.resize(nbVertex,ni); 
    387         for (int idx = 0; idx < ni; ++idx) 
    388           for (int jdx = 0; jdx < nbVertex; ++jdx) 
    389             domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 
    390       } 
    391  
    392       if (SuperClassWriter::hasVariable(boundsLonName)) //(0 != boundsLonName.compare("")) 
    393       { 
    394         CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
    395         readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    396         domain->bounds_lon_1d.resize(nbVertex,ni); 
    397         for (int idx = 0; idx < ni; ++idx) 
    398           for (int jdx = 0; jdx < nbVertex; ++jdx) 
    399             domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 
    400       } 
    401     } 
     379      if (SuperClassWriter::hasVariable(boundsLatName))  
     380      { 
     381        domain->bounds_latvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
     382        readFieldVariableValue(domain->bounds_latvalue_unstructured_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     383      } 
     384 
     385      if (SuperClassWriter::hasVariable(boundsLonName))  
     386      { 
     387        domain->bounds_lonvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
     388        readFieldVariableValue(domain->bounds_lonvalue_unstructured_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     389      }       
     390    } 
     391    domain->fillInLonLat(); 
    402392  } 
    403393 
     
    421411    if (this->isRectilinear(fieldId) || this->isCurvilinear(fieldId)) 
    422412    { 
     413      if (!domain->nj_glo.isEmpty() && (domain->nj_glo != itMapNj->second)) 
     414      { 
     415        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     416          << "The domain " << domain->getDomainOutputName() 
     417          << " has nj_glo read from file " << this->filename << " and nj_glo provided from model" 
     418          << " are not coherent. They should be the same." << std::endl  
     419          << " nj_glo read from file: "<< itMapNj->second 
     420          << " nj_glo from model: "<< domain->nj_glo << std::endl); 
     421      }  
    423422      domain->nj_glo.setValue(itMapNj->second); 
     423 
     424      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second)) 
     425      { 
     426        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     427          << "The domain " << domain->getDomainOutputName() 
     428          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model" 
     429          << " are not coherent. They should be the same." << std::endl  
     430          << " ni_glo read from file: "<< itMapNi->second 
     431          << " ni_glo from model: "<< domain->ni_glo << std::endl); 
     432      }  
    424433      domain->ni_glo.setValue(itMapNi->second); 
    425434    } 
     
    427436    { 
    428437      domain->nj_glo.setValue(1); 
     438 
     439      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second)) 
     440      { 
     441        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     442          << "The domain " << domain->getDomainOutputName() 
     443          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model" 
     444          << " are not coherent. They should be the same." << std::endl  
     445          << " ni_glo read from file: "<< itMapNi->second 
     446          << " ni_glo from model: "<< domain->ni_glo << std::endl); 
     447      }        
    429448      domain->ni_glo.setValue(itMapNi->second); 
    430449    } 
     
    444463                                                              iteMap = dimSizeMap.end(); 
    445464    for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 
     465 
     466    if (!axis->n_glo.isEmpty() && (axis->n_glo != itMapN->second)) 
     467    { 
     468      ERROR("void CNc4DataInput::readAxisAttributesFromFile(...)", 
     469        << "The axis " << axis->getAxisOutputName() 
     470        << " has n_glo read from file " << this->filename << " and n_glo provided from model" 
     471        << " are not coherent. They should be the same." << std::endl  
     472        << " n_glo read from file: "<< itMapN->second 
     473        << " n_glo from model: "<< axis->n_glo << std::endl); 
     474    }     
    446475    axis->n_glo.setValue(itMapN->second); 
    447476  } 
     
    483512                                                  int elementPosition, const StdString& fieldId) 
    484513  { 
    485 //    std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), 
    486 //                                                              iteMap = dimSizeMap.end(); 
    487 //    for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 
    488 //    axis->n_glo.setValue(itMapN->second); 
     514    /*Nothing to do */ 
    489515  } 
    490516 
     
    499525                                                      int elementPosition, const StdString& fieldId) 
    500526  { 
    501 //    std::list<std::pair<StdString, StdSize> >::const_iterator itMapN = dimSizeMap.begin(), 
    502 //                                                              iteMap = dimSizeMap.end(); 
    503 //    for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 
    504 // 
    505 //    { // Read axis value 
    506 //      std::vector<StdSize> nBegin(1, 0), nSize(1, itMapN->second); 
    507 //      CArray<double,1> readAxisValue(itMapN->second); 
    508 //      readFieldVariableValue(readAxisValue, itMapN->first, nBegin, nSize, true); 
    509 //      int begin = 0, n = itMapN->second; 
    510 //      if (!axis->begin.isEmpty()) begin = axis->begin.getValue(); 
    511 //      if (!axis->n.isEmpty()) n = axis->n.getValue(); 
    512 //      axis->value.resize(n); 
    513 //      for (int i = 0; i < n; ++i) axis->value(i) = readAxisValue(begin + i); 
    514 //    } 
     527    /*Nothing to do */ 
    515528  } 
    516529 
Note: See TracChangeset for help on using the changeset viewer.