Changeset 785 for XIOS


Ignore:
Timestamp:
11/12/15 16:33:18 (8 years ago)
Author:
mhnguyen
Message:

Allowing each process to retrieve its own distribution with i_index

+) Read value and data from unstructured grid with provided i_index value

Test
+) On Curie
+) test_remap works

Location:
XIOS/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r783 r785  
    2525     </file> 
    2626     <file id="out_dst_regular_pole" name="out_dst_regular_pole" type="one_file"> 
    27 <!--        <field field_ref="dst_field_regular_pole" name="field" />--> 
     27        <field field_ref="dst_field_regular_pole" name="field" /> 
    2828     </file> 
    2929     <file id="output_dst_regular" name="output_dst_regular" type="one_file"> 
     
    6868       <generate_rectilinear_domain lat_start="-90" lat_end="90" lon_start="2" lon_end="360"/> 
    6969       <interpolate_domain/> 
     70<!--       <zoom_domain id="dst_domain_regular_pole"/>--> 
    7071     </domain> 
    7172     <domain id="dst_domain_regular" domain_src="src_domain_regular_tmp" ni_glo="90" nj_glo="45" type="rectilinear"> 
  • XIOS/trunk/src/io/nc4_data_input.cpp

    r783 r785  
    232232      domain->fillInRectilinearLonLat(); 
    233233    } 
     234    else if (this->isCurvilinear(fieldId)) 
     235    { 
     236      int ni = domain->ni; 
     237      int nj = domain->nj; 
     238      std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 
     239      nBeginLatLon[0] = domain->jbegin.getValue(); nBeginLatLon[1] = domain->ibegin.getValue(); 
     240      nSizeLatLon[0]  = nj; nSizeLatLon[1] = ni; 
     241 
     242      StdString latName = this->getLatCoordName(fieldId); 
     243      domain->latvalue_2d.resize(ni,nj); 
     244      readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 
     245      StdString lonName = this->getLonCoordName(fieldId); 
     246      domain->lonvalue_2d.resize(ni,nj); 
     247      readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 
     248 
     249      StdString boundsLatName = this->getBoundsId(latName); 
     250      if (0 == boundsLatName.compare("")) 
     251         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     252              << "Field '" << fieldId << std::endl 
     253              << "Trying to read attributes from curvilinear grid." 
     254              << "Latitude variable " << latName << " does not have bounds."); 
     255      StdString boundsLonName = this->getBoundsId(lonName); 
     256      if (0 == boundsLonName.compare("")) 
     257         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     258              << "Field '" << fieldId << std::endl 
     259              << "Trying to read attributes from curvilinear grid." 
     260              << "Longitude variable " << lonName << " does not have bounds."); 
     261 
     262      int nbVertex = this->getNbVertex(fieldId); 
     263      domain->nvertex.setValue(nbVertex); 
     264      std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
     265      nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 
     266      nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 
     267      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
     268 
     269      domain->bounds_lat_2d.resize(nbVertex,ni,nj); 
     270      readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     271      domain->bounds_lon_2d.resize(nbVertex,ni,nj); 
     272      readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     273    } 
    234274    else if (this->isUnstructured(fieldId)) 
    235275    { 
    236       int ni = domain->ni; 
     276      if (domain->i_index.isEmpty()) 
     277         ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     278              << "Field '" << fieldId << std::endl 
     279              << "Trying to read attributes from unstructured grid." 
     280              << "i_index of domain" << domain->getId() << " is mandatory"); 
     281 
     282      int ni = domain->i_index.numElements(); 
    237283      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    238       nBeginLatLon[0] = domain->ibegin.getValue(); 
    239       nSizeLatLon[0]  = ni; 
     284      nSizeLatLon[0]  = domain->ni_glo.getValue(); 
     285      CArray<double,1> globalLonLat(domain->ni_glo.getValue()); 
    240286 
    241287      StdString latName = this->getLatCoordName(fieldId); 
     288      readFieldVariableValue(globalLonLat, latName, nBeginLatLon, nSizeLatLon); 
    242289      domain->latvalue_1d.resize(ni); 
    243       readFieldVariableValue(domain->latvalue_1d, latName, nBeginLatLon, nSizeLatLon); 
     290      for (int idx = 0; idx < ni; ++idx) 
     291        domain->latvalue_1d(idx) =  globalLonLat(domain->i_index(idx)); 
     292 
    244293      StdString lonName = this->getLonCoordName(fieldId); 
     294      readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
    245295      domain->lonvalue_1d.resize(ni); 
    246       readFieldVariableValue(domain->lonvalue_1d, lonName, nBeginLatLon, nSizeLatLon); 
     296      for (int idx = 0; idx < ni; ++idx) 
     297        domain->lonvalue_1d(idx) = globalLonLat(domain->i_index(idx)); 
    247298 
    248299      StdString boundsLatName = this->getBoundsId(latName); 
     
    262313      domain->nvertex.setValue(nbVertex); 
    263314      std::vector<StdSize> nBeginBndsLatLon(2), nSizeBndsLatLon(2); 
    264       nBeginBndsLatLon[0] = domain->ibegin.getValue(); nSizeBndsLatLon[0] = ni; 
     315      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->ni_glo.getValue(); 
    265316      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
    266317 
     318      CArray<double,2> globalBndsLonLat(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
     319      readFieldVariableValue(globalBndsLonLat, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    267320      domain->bounds_lat_1d.resize(nbVertex,ni); 
    268       readFieldVariableValue(domain->bounds_lat_1d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     321      for (int idx = 0; idx < ni; ++idx) 
     322        for (int jdx = 0; jdx < nbVertex; ++jdx) 
     323          domain->bounds_lat_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 
     324 
     325      readFieldVariableValue(globalBndsLonLat, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    269326      domain->bounds_lon_1d.resize(nbVertex,ni); 
    270       readFieldVariableValue(domain->bounds_lon_1d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
    271     } 
    272     else if (this->isCurvilinear(fieldId)) 
    273     { 
    274       int ni = domain->ni; 
    275       int nj = domain->nj; 
    276       std::vector<StdSize> nBeginLatLon(2), nSizeLatLon(2); 
    277       nBeginLatLon[0] = domain->jbegin.getValue(); nBeginLatLon[1] = domain->ibegin.getValue(); 
    278       nSizeLatLon[0]  = nj; nSizeLatLon[1] = ni; 
    279  
    280       StdString latName = this->getLatCoordName(fieldId); 
    281       domain->latvalue_2d.resize(ni,nj); 
    282       readFieldVariableValue(domain->latvalue_2d, latName, nBeginLatLon, nSizeLatLon); 
    283       StdString lonName = this->getLonCoordName(fieldId); 
    284       domain->lonvalue_2d.resize(ni,nj); 
    285       readFieldVariableValue(domain->lonvalue_2d, lonName, nBeginLatLon, nSizeLatLon); 
    286  
    287       StdString boundsLatName = this->getBoundsId(latName); 
    288       if (0 == boundsLatName.compare("")) 
    289          ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
    290               << "Field '" << fieldId << std::endl 
    291               << "Trying to read attributes from curvilinear grid." 
    292               << "Latitude variable " << latName << " does not have bounds."); 
    293       StdString boundsLonName = this->getBoundsId(lonName); 
    294       if (0 == boundsLonName.compare("")) 
    295          ERROR("CNc4DataInput::readDomainAttributeValueFromFile(...)", 
    296               << "Field '" << fieldId << std::endl 
    297               << "Trying to read attributes from curvilinear grid." 
    298               << "Longitude variable " << lonName << " does not have bounds."); 
    299  
    300       int nbVertex = this->getNbVertex(fieldId); 
    301       domain->nvertex.setValue(nbVertex); 
    302       std::vector<StdSize> nBeginBndsLatLon(3), nSizeBndsLatLon(3); 
    303       nBeginBndsLatLon[0] = domain->jbegin.getValue(); nSizeBndsLatLon[0] = nj; 
    304       nBeginBndsLatLon[1] = domain->ibegin.getValue(); nSizeBndsLatLon[1] = ni; 
    305       nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    306  
    307       domain->bounds_lat_2d.resize(nbVertex,ni,nj); 
    308       readFieldVariableValue(domain->bounds_lat_2d, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
    309       domain->bounds_lon_2d.resize(nbVertex,ni,nj); 
    310       readFieldVariableValue(domain->bounds_lon_2d, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     327      for (int idx = 0; idx < ni; ++idx) 
     328        for (int jdx = 0; jdx < nbVertex; ++jdx) 
     329          domain->bounds_lon_1d(jdx,idx) = globalBndsLonLat(jdx, domain->i_index(idx)); 
    311330    } 
    312331  } 
  • XIOS/trunk/src/node/domain.cpp

    r784 r785  
    332332     else  // unstructured domain 
    333333     { 
    334         int globalDomainSize = ni_glo * nj_glo; 
    335         if (globalDomainSize <= nbLocalDomain) 
    336         { 
    337           for (int idx = 0; idx < nbLocalDomain; ++idx) 
     334       if (this->i_index.isEmpty()) 
     335       { 
     336          int globalDomainSize = ni_glo * nj_glo; 
     337          if (globalDomainSize <= nbLocalDomain) 
    338338          { 
    339             if (rankOnDomain < globalDomainSize) 
     339            for (int idx = 0; idx < nbLocalDomain; ++idx) 
    340340            { 
    341               int iIdx = rankOnDomain % ni_glo; 
    342               int jIdx = rankOnDomain / ni_glo; 
    343               ibegin.setValue(iIdx); jbegin.setValue(jIdx); 
    344               ni.setValue(1); nj.setValue(1); 
     341              if (rankOnDomain < globalDomainSize) 
     342              { 
     343                int iIdx = rankOnDomain % ni_glo; 
     344                int jIdx = rankOnDomain / ni_glo; 
     345                ibegin.setValue(iIdx); jbegin.setValue(jIdx); 
     346                ni.setValue(1); nj.setValue(1); 
     347              } 
     348              else 
     349              { 
     350                ibegin.setValue(0); jbegin.setValue(0); 
     351                ni.setValue(0); nj.setValue(0); 
     352              } 
    345353            } 
    346             else 
     354          } 
     355          else 
     356          { 
     357            float njGlo = nj_glo.getValue(); 
     358            float niGlo = ni_glo.getValue(); 
     359            std::vector<int> ibeginVec(nbLocalDomain,0); 
     360            std::vector<int> niVec(nbLocalDomain); 
     361            for (int i = 1; i < nbLocalDomain; ++i) 
    347362            { 
    348               ibegin.setValue(0); jbegin.setValue(0); 
    349               ni.setValue(0); nj.setValue(0); 
     363              int range = ni_glo / nbLocalDomain; 
     364              if (i < (ni_glo%nbLocalDomain)) ++range; 
     365              niVec[i-1] = range; 
     366              ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; 
    350367            } 
     368            niVec[nbLocalDomain-1] = ni_glo - ibeginVec[nbLocalDomain-1]; 
     369 
     370            int iIdx = rankOnDomain % nbLocalDomain; 
     371            ibegin.setValue(ibeginVec[iIdx]); 
     372            jbegin.setValue(0); 
     373            ni.setValue(niVec[iIdx]); 
     374            nj.setValue(1); 
    351375          } 
    352376        } 
    353377        else 
    354378        { 
    355           float njGlo = nj_glo.getValue(); 
    356           float niGlo = ni_glo.getValue(); 
    357           std::vector<int> ibeginVec(nbLocalDomain,0); 
    358           std::vector<int> niVec(nbLocalDomain); 
    359           for (int i = 1; i < nbLocalDomain; ++i) 
    360           { 
    361             int range = ni_glo / nbLocalDomain; 
    362             if (i < (ni_glo%nbLocalDomain)) ++range; 
    363             niVec[i-1] = range; 
    364             ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; 
    365           } 
    366           niVec[nbLocalDomain-1] = ni_glo - ibeginVec[nbLocalDomain-1]; 
    367  
    368           int iIdx = rankOnDomain % nbLocalDomain; 
    369           ibegin.setValue(ibeginVec[iIdx]); 
     379          ibegin.setValue(this->i_index(0)); 
    370380          jbegin.setValue(0); 
    371           ni.setValue(niVec[iIdx]); 
     381          ni.setValue(this->i_index.numElements()); 
    372382          nj.setValue(1); 
    373383        } 
    374384     } 
     385 
     386     checkDomain(); 
    375387   } 
    376388 
  • XIOS/trunk/src/test/test_remap.f90

    r783 r785  
    120120                            bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 
    121121 
     122!  CALL xios_set_zoom_domain_attr("dst_domain_regular_pole", zoom_ibegin=10, zoom_ni=10, & 
     123!                                 zoom_jbegin=10, zoom_nj=10) 
    122124 
    123125  dtime%second = 3600 
Note: See TracChangeset for help on using the changeset viewer.