Changeset 1064


Ignore:
Timestamp:
03/02/17 10:42:39 (4 years ago)
Author:
mhnguyen
Message:

Auto-distribution of unstructured grid read from a file.

+ Unstructured grid read from a file is now distributed automatically among clients if there is
no distribution information provided.
+ Attributes of grid can be setup: From model (highest priority), from file (reading), or auto-generation (lowest priority).
If an attribute can be setup by several ways, it will be setup by one with the higher priority.

Test
+ On Curie
+ Tests pass

Location:
XIOS/trunk
Files:
1 deleted
7 edited

Legend:

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

    r1018 r1064  
    55   <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" /> 
    66   <field_definition level="1" > 
    7     <field_group id="fields_src" operation="instant"> 
     7    <field_group id="fields_src" operation="instant" default_value="100000"> 
    88       <field id="src_field_2D" domain_ref="src_domain" /> 
    9        <field id="src_field_2D_clone" domain_ref="src_domain_clone"/> 
     9       <field id="src_field_2D_clone" domain_ref="src_domain_clone" detect_missing_value=".TRUE." /> 
    1010       <field id="src_field_3D" domain_ref="src_domain" axis_ref="src_axis"  /> 
    11        <field id="src_field_3D_clone" grid_ref="src_grid_3D" detect_missing_value=".TRUE." default_value="100000" />        
     11       <field id="src_field_3D_clone" grid_ref="src_grid_3D" detect_missing_value=".TRUE." />        
    1212       <field id="src_field_3D_pression" grid_ref="src_grid_3D"  /> 
    13        <field id="src_field_4D" grid_ref="src_grid_4D" detect_missing_value=".TRUE." default_value="100000"/>        
     13       <field id="src_field_4D" grid_ref="src_grid_4D" detect_missing_value=".TRUE." />        
    1414    </field_group> 
    1515    <field_group  id="fields_dst"> 
    1616      <field id="dst_field_2D" field_ref="src_field_2D" domain_ref="dst_domain"/> 
    1717      <field id="dst_field_2D_regular_pole" field_ref="src_field_2D" domain_ref="dst_domain_regular_pole"/> 
    18       <field id="dst_field_2D_clone" field_ref="src_field_2D_clone" domain_ref="dst_domain"/> 
     18      <field id="dst_field_2D_clone" field_ref="src_field_2D_clone" domain_ref="dst_domain_regular_pole"  expr="@this" operation="average" detect_missing_value=".true."/> 
    1919      <field id="dst_field_2D_extract" field_ref="src_field_3D_clone" grid_ref="dst_grid_2D_extract"/> 
    2020      <field id="dst_field_3D" field_ref="src_field_3D" grid_ref="dst_grid_3D"/> 
     
    2323    </field_group> 
    2424    <field_group id="read_fields" operation="instant"> 
    25 <!--       <field id="tmp_field_0" domain_ref="src_domain_regular_read"/> 
    26       <field id="tmp_field_clone" field_ref="tmp_field_0"/> 
     25      <field id="tmp_field_0" domain_ref="src_domain_regular_read"/>       
    2726      <field id="tmp_field_1" grid_ref="src_grid_curvilinear_read" /> 
    2827      <field id="tmp_field_2" grid_ref="src_grid_unstructured_read" /> 
     28      <field id="tmp_field_clone" field_ref="tmp_field_0"/> 
    2929      <field id="dst_field_regular" field_ref="tmp_field_2" grid_ref="dst_grid_regular"/>       
    3030      <field id="dst_field_regular_pole_0" field_ref="tmp_field_0" domain_ref="dst_domain_regular_pole"/> 
    31       <field id="dst_field_regular_pole_1" field_ref="tmp_field_clone" domain_ref="dst_domain_regular_pole"/> --> 
     31      <field id="dst_field_regular_pole_1" field_ref="tmp_field_clone" domain_ref="dst_domain_regular_pole"/> 
    3232    </field_group>  
    3333   </field_definition> 
     
    3737        <file id="output_2D" name="output_2D" > 
    3838          <field field_ref="src_field_2D" name="field_src" /> 
     39          <field field_ref="src_field_2D_clone" name="field_src_clone" /> 
    3940          <field field_ref="src_field_2D" name="field_dst_regular_0"  domain_ref="dst_domain_regular_pole" /> 
    4041          <field field_ref="dst_field_2D" name="field_dst_regular_1" /> 
     
    4950          <field field_ref="dst_field_3D_interp" name="field_dst_interp_domain_axis" domain_ref="dst_domain_regular_pole"/>   
    5051       </file> 
    51        <file id="output_4D" name="output_4D" enabled=".FALSE."> 
     52       <file id="output_4D" name="output_4D" enabled=".TRUE."> 
    5253          <field field_ref="src_field_4D" name="field_4D" /> 
    5354          <field field_ref="dst_field_4D_extract" name="field_4D_extract" /> 
     
    5556     </file_group> 
    5657     <file_group id="read_files" > 
    57 <!--        <file id="output_src_regular" name="output_src_regular" mode="read" > 
     58       <file id="output_src_regular" name="output_src_regular" mode="read" > 
    5859          <field id="src_field_regular" name="field" grid_ref="src_grid_regular_read" operation="instant"/> 
    5960       </file> 
     
    6364       <file id="output_src_unstructured" name="output_src_unstructured" mode="read" > 
    6465          <field id="src_field_unstructured" name="field" grid_ref="src_grid_unstructured_read" operation="instant"/> 
    65        </file> --> 
     66       </file> 
    6667      </file_group> 
    67      <file_group id="read_then_write_files" enabled=".FALSE."> 
    68 <!--        <file id="output_regular_pole" name="output_dst_regular" > 
     68     <file_group id="read_then_write_files" enabled=".TRUE."> 
     69       <file id="output_regular_pole" name="output_dst_regular" > 
     70          <field field_ref="tmp_field_0" name="field_regular_0" /> 
    6971          <field field_ref="dst_field_regular" name="field_regular" /> 
    7072          <field field_ref="dst_field_regular_pole_0" name="field_regular_pole_0" /> 
     
    7678       <file id="output_dst_unstructured" name="output_dst_unstructured" > 
    7779          <field field_ref="tmp_field_2" operation="instant"/> 
    78        </file> --> 
     80       </file> 
    7981     </file_group> 
    8082   </file_definition> 
     
    9496      <axis id="src_axis" positive="down" /> 
    9597      <axis id="nq" positive="down" /> 
    96       <axis id="src_axis_curvilinear_read" /> 
     98      <axis id="src_axis_curvilinear_read" positive="down" /> 
    9799    </axis_group> 
    98100    <axis_group id="axis_dst"> 
     
    113115      </domain> 
    114116      <domain id="src_domain_unstructured_read" type="unstructured"> 
     117        <generate_rectilinear_domain/> 
    115118      </domain> 
    116119    </domain_group> 
     
    126129     <domain id="dst_domain_regular_pole" ni_glo="90" nj_glo="45" type="rectilinear"> 
    127130       <generate_rectilinear_domain id="domain_regular_pole"/> 
    128        <interpolate_domain write_weight="false"/>        
     131       <interpolate_domain write_weight="false" order="1" renormalize="true"/>        
    129132       <!-- <zoom_domain ibegin="0" ni="45" jbegin="0" nj="45" /> --> 
    130133     </domain> 
  • XIOS/trunk/src/config/domain_attribute_private.conf

    r821 r1064  
    1010DECLARE_ATTRIBUTE_PRIVATE(double,  bounds_lat_end) 
    1111 
    12 // Array contain whole value (non distributed) of longitude and latitude read from a file 
     12// Array contain whole value (non distributed) of longitude and latitude of rectilinear read from a file 
    1313DECLARE_ARRAY_PRIVATE(double, 1, lonvalue_rectilinear_read_from_file) 
    1414DECLARE_ARRAY_PRIVATE(double, 1, latvalue_rectilinear_read_from_file) 
     15 
     16// Array contain whole value (non distributed) of longitude and latitude of curvilinear read from a file 
     17DECLARE_ARRAY_PRIVATE(double, 2, lonvalue_curvilinear_read_from_file) 
     18DECLARE_ARRAY_PRIVATE(double, 2, latvalue_curvilinear_read_from_file) 
     19DECLARE_ARRAY_PRIVATE(double, 3, bounds_lonvalue_curvilinear_read_from_file) 
     20DECLARE_ARRAY_PRIVATE(double, 3, bounds_latvalue_curvilinear_read_from_file) 
     21 
     22// Array contain whole value (non distributed) of longitude and latitude of unstructured read from a file 
     23DECLARE_ARRAY_PRIVATE(double, 1, lonvalue_unstructured_read_from_file) 
     24DECLARE_ARRAY_PRIVATE(double, 1, latvalue_unstructured_read_from_file) 
     25DECLARE_ARRAY_PRIVATE(double, 2, bounds_lonvalue_unstructured_read_from_file) 
     26DECLARE_ARRAY_PRIVATE(double, 2, bounds_latvalue_unstructured_read_from_file) 
    1527 
    1628DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_ibegin) 
  • XIOS/trunk/src/io/nc4_data_input.cpp

    r967 r1064  
    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); 
     320 
    311321      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; 
     322      nBeginBndsLatLon[0] = 0; nSizeBndsLatLon[0] = domain->nj_glo.getValue(); 
     323      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = domain->nj_glo.getValue(); 
    314324      nBeginBndsLatLon[2] = 0; nSizeBndsLatLon[2] = nbVertex; 
    315325 
    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       } 
     326      if (SuperClassWriter::hasVariable(boundsLatName)) 
     327      { 
     328        domain->bounds_latvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     329        readFieldVariableValue(domain->bounds_latvalue_curvilinear_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     330 
     331      } 
     332      if (SuperClassWriter::hasVariable(boundsLonName))  
     333      { 
     334        domain->bounds_lonvalue_curvilinear_read_from_file.resize(nbVertex,domain->ni_glo,domain->nj_glo); 
     335        readFieldVariableValue(domain->bounds_lonvalue_curvilinear_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     336      }       
    327337    } 
    328338    else if ((CDomain::type_attr::unstructured == domain->type))// || (this->isUnstructured(fieldId))) 
    329339    { 
    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  
    349340      std::vector<StdSize> nBeginLatLon(1,0), nSizeLatLon(1,0); 
    350341      nSizeLatLon[0]  = domain->ni_glo.getValue(); 
     
    352343 
    353344      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)); 
     345      if (SuperClassWriter::hasVariable(latName)) 
     346      { 
     347        domain->latvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     348        readFieldVariableValue(domain->latvalue_unstructured_read_from_file, latName, nBeginLatLon, nSizeLatLon);   
    360349      } 
    361350 
     
    363352      if (SuperClassWriter::hasVariable(lonName)) //(0 != lonName.compare("")) 
    364353      { 
    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)); 
     354        // readFieldVariableValue(globalLonLat, lonName, nBeginLatLon, nSizeLatLon); 
     355        domain->lonvalue_unstructured_read_from_file.resize(domain->ni_glo); 
     356        readFieldVariableValue(domain->lonvalue_unstructured_read_from_file, lonName, nBeginLatLon, nSizeLatLon); 
    369357      } 
    370358 
     
    373361 
    374362      int nbVertex = this->getNbVertex(fieldId); 
    375       if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName)) // (0 != boundsLatName.compare("")) || (0 != boundsLonName.compare(""))) 
     363      if (!domain->nvertex.isEmpty() && (domain->nvertex != nbVertex)) 
     364      { 
     365        ERROR("void CNc4DataInput::readDomainAttributeValueFromFile(...)", 
     366          << "The domain " << domain->getDomainOutputName() 
     367          << " has nvertex read from file " << this->filename << " and nvertex provided from model" 
     368          << " are not coherent. They should be the same." << std::endl  
     369          << " nvertex read from file: "<< nbVertex 
     370          << " nvertex from model: "<< domain->nvertex << std::endl); 
     371      }  
     372       
     373      if (SuperClassWriter::hasVariable(boundsLatName) || SuperClassWriter::hasVariable(boundsLonName))  
    376374        domain->nvertex.setValue(nbVertex); 
    377375 
     
    380378      nBeginBndsLatLon[1] = 0; nSizeBndsLatLon[1] = nbVertex; 
    381379 
    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     } 
     380      if (SuperClassWriter::hasVariable(boundsLatName))  
     381      { 
     382        domain->bounds_latvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
     383        readFieldVariableValue(domain->bounds_latvalue_unstructured_read_from_file, boundsLatName, nBeginBndsLatLon, nSizeBndsLatLon); 
     384      } 
     385 
     386      if (SuperClassWriter::hasVariable(boundsLonName))  
     387      { 
     388        domain->bounds_lonvalue_unstructured_read_from_file.resize(nSizeBndsLatLon[1], nSizeBndsLatLon[0]); 
     389        readFieldVariableValue(domain->bounds_lonvalue_unstructured_read_from_file, boundsLonName, nBeginBndsLatLon, nSizeBndsLatLon); 
     390      }       
     391    } 
     392    domain->fillInLonLat(); 
    402393  } 
    403394 
     
    421412    if (this->isRectilinear(fieldId) || this->isCurvilinear(fieldId)) 
    422413    { 
     414      if (!domain->nj_glo.isEmpty() && (domain->nj_glo != itMapNj->second)) 
     415      { 
     416        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     417          << "The domain " << domain->getDomainOutputName() 
     418          << " has nj_glo read from file " << this->filename << " and nj_glo provided from model" 
     419          << " are not coherent. They should be the same." << std::endl  
     420          << " nj_glo read from file: "<< itMapNj->second 
     421          << " nj_glo from model: "<< domain->nj_glo << std::endl); 
     422      }  
    423423      domain->nj_glo.setValue(itMapNj->second); 
     424 
     425      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second)) 
     426      { 
     427        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     428          << "The domain " << domain->getDomainOutputName() 
     429          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model" 
     430          << " are not coherent. They should be the same." << std::endl  
     431          << " ni_glo read from file: "<< itMapNi->second 
     432          << " ni_glo from model: "<< domain->ni_glo << std::endl); 
     433      }  
    424434      domain->ni_glo.setValue(itMapNi->second); 
    425435    } 
     
    427437    { 
    428438      domain->nj_glo.setValue(1); 
     439 
     440      if (!domain->ni_glo.isEmpty() && (domain->ni_glo != itMapNi->second)) 
     441      { 
     442        ERROR("void CNc4DataInput::readDomainAttributesFromFile(...)", 
     443          << "The domain " << domain->getDomainOutputName() 
     444          << " has ni_glo read from file " << this->filename << " and ni_glo provided from model" 
     445          << " are not coherent. They should be the same." << std::endl  
     446          << " ni_glo read from file: "<< itMapNi->second 
     447          << " ni_glo from model: "<< domain->ni_glo << std::endl); 
     448      }        
    429449      domain->ni_glo.setValue(itMapNi->second); 
    430450    } 
     
    444464                                                              iteMap = dimSizeMap.end(); 
    445465    for (int i = 0; i < elementPosition; ++i, ++itMapN) {} 
     466 
     467    if (!axis->n_glo.isEmpty() && (axis->n_glo != itMapN->second)) 
     468    { 
     469      ERROR("void CNc4DataInput::readAxisAttributesFromFile(...)", 
     470        << "The axis " << axis->getAxisOutputName() 
     471        << " has n_glo read from file " << this->filename << " and n_glo provided from model" 
     472        << " are not coherent. They should be the same." << std::endl  
     473        << " n_glo read from file: "<< itMapN->second 
     474        << " n_glo from model: "<< axis->n_glo << std::endl); 
     475    }     
    446476    axis->n_glo.setValue(itMapN->second); 
    447477  } 
     
    483513                                                  int elementPosition, const StdString& fieldId) 
    484514  { 
    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); 
     515    /*Nothing to do */ 
    489516  } 
    490517 
     
    499526                                                      int elementPosition, const StdString& fieldId) 
    500527  { 
    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 //    } 
     528    /*Nothing to do */ 
    515529  } 
    516530 
  • XIOS/trunk/src/node/domain.cpp

    r1062 r1064  
    225225 
    226226   //---------------------------------------------------------------- 
     227 
     228   /*! 
     229      Verify if all distribution information of a domain are available 
     230      This checking verifies the definition of distribution attributes (ni, nj, ibegin, jbegin) 
     231   */ 
     232   bool CDomain::distributionAttributesHaveValue() const 
     233   { 
     234      bool hasValues = true; 
     235 
     236      if (ni.isEmpty() && ibegin.isEmpty() && i_index.isEmpty()) 
     237      { 
     238        hasValues = false; 
     239        return hasValues; 
     240      } 
     241 
     242      return hasValues; 
     243   } 
    227244 
    228245   /*! 
     
    333350            ni.setValue(ni_glo - ibeginVec[iIdx]); 
    334351          } 
    335         } 
    336  
    337         // Now fill other attributes 
    338         if (type_attr::rectilinear == type) fillInRectilinearLonLat(); 
     352        }  
    339353     } 
    340354     else  // unstructured domain 
     
    382396            nj.setValue(1); 
    383397          } 
     398 
     399          i_index.resize(ni);           
     400          for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; 
    384401        } 
    385402        else 
     
    393410 
    394411     checkDomain(); 
     412   } 
     413 
     414   /*! 
     415     Fill in longitude and latitude whose values are read from file 
     416   */ 
     417   void CDomain::fillInLonLat() 
     418   { 
     419     switch (type) 
     420     { 
     421      case type_attr::rectilinear: 
     422        fillInRectilinearLonLat(); 
     423        break; 
     424      case type_attr::curvilinear: 
     425        fillInCurvilinearLonLat(); 
     426        break; 
     427      case type_attr::unstructured: 
     428        fillInUnstructuredLonLat(); 
     429        break; 
     430 
     431      default: 
     432      break; 
     433     } 
     434 
    395435   } 
    396436 
     
    470510   } 
    471511 
    472  
    473  
     512    /* 
     513      Fill in longitude and latitude of curvilinear domain read from a file 
     514      If there are already longitude and latitude defined by model. We just igonore reading value. 
     515    */ 
     516   void CDomain::fillInCurvilinearLonLat() 
     517   { 
     518     if (!lonvalue_curvilinear_read_from_file.isEmpty() && lonvalue_2d.isEmpty()) 
     519     { 
     520       lonvalue_2d.resize(ni,nj); 
     521       for (int jdx = 0; jdx < nj; ++jdx) 
     522        for (int idx = 0; idx < ni; ++idx) 
     523         lonvalue_2d(idx,jdx) = lonvalue_curvilinear_read_from_file(idx+ibegin, jdx+jbegin); 
     524 
     525       lonvalue_curvilinear_read_from_file.free(); 
     526     } 
     527 
     528     if (!latvalue_curvilinear_read_from_file.isEmpty() && latvalue_2d.isEmpty()) 
     529     { 
     530       latvalue_2d.resize(ni,nj); 
     531       for (int jdx = 0; jdx < nj; ++jdx) 
     532        for (int idx = 0; idx < ni; ++idx) 
     533         latvalue_2d(idx,jdx) = latvalue_curvilinear_read_from_file(idx+ibegin, jdx+jbegin); 
     534 
     535       latvalue_curvilinear_read_from_file.free(); 
     536     } 
     537 
     538     if (!bounds_lonvalue_curvilinear_read_from_file.isEmpty() && bounds_lon_2d.isEmpty()) 
     539     { 
     540       bounds_lon_2d.resize(nvertex,ni,nj); 
     541       for (int jdx = 0; jdx < nj; ++jdx) 
     542        for (int idx = 0; idx < ni; ++idx) 
     543          for (int ndx = 0; ndx < nvertex; ++ndx) 
     544         bounds_lon_2d(ndx,idx,jdx) = bounds_lonvalue_curvilinear_read_from_file(ndx,idx+ibegin, jdx+jbegin); 
     545 
     546       bounds_lonvalue_curvilinear_read_from_file.free(); 
     547     } 
     548 
     549     if (!bounds_latvalue_curvilinear_read_from_file.isEmpty() && bounds_lat_2d.isEmpty()) 
     550     { 
     551       bounds_lat_2d.resize(nvertex,ni,nj); 
     552       for (int jdx = 0; jdx < nj; ++jdx) 
     553        for (int idx = 0; idx < ni; ++idx) 
     554          for (int ndx = 0; ndx < nvertex; ++ndx) 
     555            bounds_lat_2d(ndx,idx,jdx) = bounds_latvalue_curvilinear_read_from_file(ndx,idx+ibegin, jdx+jbegin); 
     556 
     557       bounds_latvalue_curvilinear_read_from_file.free(); 
     558     } 
     559 
     560   } 
     561 
     562    /* 
     563      Fill in longitude and latitude of unstructured domain read from a file 
     564      If there are already longitude and latitude defined by model. We just igonore reading value. 
     565    */ 
     566   void CDomain::fillInUnstructuredLonLat() 
     567   { 
     568     if (i_index.isEmpty()) 
     569     { 
     570       i_index.resize(ni); 
     571       for(int idx = 0; idx < ni; ++idx) i_index(idx)=ibegin+idx; 
     572     } 
     573 
     574     if (!lonvalue_unstructured_read_from_file.isEmpty() && lonvalue_1d.isEmpty()) 
     575     { 
     576        lonvalue_1d.resize(ni); 
     577        for (int idx = 0; idx < ni; ++idx) 
     578          lonvalue_1d(idx) = lonvalue_unstructured_read_from_file(i_index(idx)); 
     579 
     580        // We dont need these values anymore, so just delete them 
     581        lonvalue_unstructured_read_from_file.free(); 
     582     }  
     583 
     584     if (!latvalue_unstructured_read_from_file.isEmpty() && latvalue_1d.isEmpty()) 
     585     { 
     586        latvalue_1d.resize(ni); 
     587        for (int idx = 0; idx < ni; ++idx) 
     588          latvalue_1d(idx) =  latvalue_unstructured_read_from_file(i_index(idx)); 
     589 
     590        // We dont need these values anymore, so just delete them 
     591        latvalue_unstructured_read_from_file.free(); 
     592     } 
     593 
     594     if (!bounds_lonvalue_unstructured_read_from_file.isEmpty() && bounds_lon_1d.isEmpty()) 
     595     { 
     596        int nbVertex = nvertex; 
     597        bounds_lon_1d.resize(nbVertex,ni); 
     598        for (int idx = 0; idx < ni; ++idx) 
     599          for (int jdx = 0; jdx < nbVertex; ++jdx) 
     600            bounds_lon_1d(jdx,idx) = bounds_lonvalue_unstructured_read_from_file(jdx, i_index(idx)); 
     601 
     602        // We dont need these values anymore, so just delete them 
     603        lonvalue_unstructured_read_from_file.free(); 
     604     } 
     605 
     606     if (!bounds_latvalue_unstructured_read_from_file.isEmpty() && bounds_lat_1d.isEmpty()) 
     607     { 
     608        int nbVertex = nvertex; 
     609        bounds_lat_1d.resize(nbVertex,ni); 
     610        for (int idx = 0; idx < ni; ++idx) 
     611          for (int jdx = 0; jdx < nbVertex; ++jdx) 
     612            bounds_lat_1d(jdx,idx) = bounds_latvalue_unstructured_read_from_file(jdx, i_index(idx)); 
     613 
     614        // We dont need these values anymore, so just delete them 
     615        lonvalue_unstructured_read_from_file.free(); 
     616     } 
     617   } 
     618 
     619  /* 
     620    Get global longitude and latitude of rectilinear domain. 
     621  */ 
    474622   void CDomain::AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, CArray<double,1>& lon_g, CArray<double,1>& lat_g) 
    475623   { 
  • XIOS/trunk/src/node/domain.hpp

    r953 r1064  
    103103         bool isDistributed(void) const; 
    104104         bool isCompressible(void) const; 
     105         bool distributionAttributesHaveValue() const; 
    105106 
    106107         int ni_srv,ibegin_srv,iend_srv ; 
     
    136137         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    137138                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 
    138          void fillInRectilinearLonLat(); 
     139          
     140         void fillInLonLat(); 
    139141 
    140142         static bool dispatchEvent(CEventServer& event); 
     
    189191         void sendLonLat(); 
    190192 
     193         void fillInRectilinearLonLat(); 
     194         void fillInCurvilinearLonLat(); 
     195         void fillInUnstructuredLonLat(); 
    191196       private: 
    192197         bool isChecked; 
  • XIOS/trunk/src/test/test_remap.f90

    r1018 r1064  
    1616  TYPE(xios_context) :: ctx_hdl 
    1717 
    18   DOUBLE PRECISION,ALLOCATABLE :: src_lon(:), dst_lon(:) 
    19   DOUBLE PRECISION,ALLOCATABLE :: src_lat(:), dst_lat(:) 
     18  DOUBLE PRECISION,ALLOCATABLE :: src_lon(:), dst_lon(:), src_lon_tmp(:) 
     19  DOUBLE PRECISION,ALLOCATABLE :: src_lat(:), dst_lat(:), src_lat_tmp(:) 
    2020  DOUBLE PRECISION,ALLOCATABLE :: src_boundslon(:,:), dst_boundslon(:,:) 
    2121  DOUBLE PRECISION,ALLOCATABLE :: src_boundslat(:,:), dst_boundslat(:,:) 
    22   DOUBLE PRECISION,ALLOCATABLE :: src_field_2D(:) 
     22  DOUBLE PRECISION,ALLOCATABLE :: src_field_2D(:), src_field_2D_clone(:) 
    2323  DOUBLE PRECISION,ALLOCATABLE :: tmp_field_0(:), tmp_field_1(:), tmp_field_2(:) 
    2424  DOUBLE PRECISION,ALLOCATABLE :: src_field_3D(:,:), src_field_4D(:,:,:), lval(:), lval1(:), lval2(:), src_field_pression(:,:) 
     
    3636  INTEGER :: varid 
    3737  INTEGER :: ts 
    38   INTEGER :: i 
     38  INTEGER :: i,j 
    3939  INTEGER,PARAMETER :: llm=5, interpolatedLlm = 4, llm2 = 6 
     40  DOUBLE PRECISION, PARAMETER :: missing_value = 100000 
    4041 
    4142  CALL MPI_INIT(ierr) 
     
    6465  ENDIF 
    6566 
    66   ALLOCATE(src_lon(src_ni)) 
    67   ALLOCATE(src_lat(src_ni)) 
     67  ALLOCATE(src_lon(src_ni), src_lon_tmp(src_ni)) 
     68  ALLOCATE(src_lat(src_ni), src_lat_tmp(src_ni)) 
    6869  ALLOCATE(src_boundslon(src_nvertex,src_ni)) 
    6970  ALLOCATE(src_boundslat(src_nvertex,src_ni)) 
    70   ALLOCATE(src_field_2D(src_ni)) 
     71  ALLOCATE(src_field_2D(src_ni), src_field_2D_clone(src_ni)) 
    7172  ALLOCATE(src_field_3D(src_ni,llm)) 
    7273  ALLOCATE(src_field_4D(src_ni,llm,llm2)) 
     
    8990  DO i=1,src_ni 
    9091    src_field_3D(i,:) = src_field_2D(i) 
    91     IF (MOD(i,10)==0) THEN 
     92    IF ((23.5 < src_lat(i)) .AND. (src_lat(i) < 65.5) .AND. (0 < src_lon(i)) .AND. (src_lon(i) < 30)) THEN 
    9293      src_mask_2D(i)=.FALSE. 
    93       src_field_2D(i) = 100000 
     94      src_field_2D(i) = missing_value 
    9495    ELSE 
    9596      src_mask_2D(i)=.TRUE.       
    9697    ENDIF 
    97   ENDDO 
     98    src_lon_tmp(i) = src_lon(i) + 1000 
     99    src_lat_tmp(i) = src_lat(i) + 10000 
     100  ENDDO 
     101  src_field_2D_clone = src_field_2D 
    98102 
    99103  DO i=1,llm 
     
    101105    src_field_pression(:,i) = i * 100 
    102106    IF (MOD(i,3)==0) THEN 
    103       ! src_field_pression(:,i) = 100000 
    104       src_field_3D(:,i) = 100000 
     107      ! src_field_pression(:,i) = missing_value 
     108      src_field_3D(:,i) = missing_value 
    105109    ELSE 
    106110      ! src_field_pression(:,i) = i * 100 
     
    170174                            bounds_lon_1D=dst_boundslon, bounds_lat_1D=dst_boundslat, nvertex=dst_nvertex) 
    171175 
     176  CALL xios_set_domain_attr("src_domain_unstructured_read", ni_glo=src_ni_glo, ibegin=src_ibegin, ni=src_ni, type="unstructured") 
     177  CALL xios_set_domain_attr("src_domain_unstructured_read", lonvalue_1D=src_lon_tmp, latvalue_1D=src_lat_tmp, & 
     178                            bounds_lon_1D=src_boundslon, bounds_lat_1D=src_boundslat, nvertex=src_nvertex) 
     179 
     180 
    172181  dtime%second = 3600 
    173182  CALL xios_set_timestep(dtime) 
    174183 
    175184  CALL xios_close_context_definition() 
    176   ! CALL xios_get_domain_attr("src_domain_regular_read", ni=src_tmp_ni, nj=src_tmp_nj) 
    177   ! ALLOCATE(tmp_field_0(src_tmp_ni*src_tmp_nj)) 
    178  
    179   ! CALL xios_get_axis_attr("src_axis_curvilinear_read", n=src_tmp_n) 
    180   ! CALL xios_get_domain_attr("src_domain_curvilinear_read", ni=src_tmp_ni, nj=src_tmp_nj) 
    181   ! ALLOCATE(tmp_field_1(src_tmp_ni*src_tmp_nj*src_tmp_n)) 
    182  
    183   ! CALL xios_get_domain_attr("src_domain_unstructured_read", ni=src_tmp_ni, nj=src_tmp_nj) 
    184   ! ALLOCATE(tmp_field_2(src_tmp_ni*src_tmp_nj)) 
    185  
    186   DO ts=1,5 
    187     ! CALL xios_recv_field("src_field_regular", tmp_field_0) 
    188     ! CALL xios_recv_field("src_field_curvilinear", tmp_field_1) 
    189     ! CALL xios_recv_field("src_field_unstructured", tmp_field_2) 
     185  CALL xios_get_domain_attr("src_domain_regular_read", ni=src_tmp_ni, nj=src_tmp_nj) 
     186  ALLOCATE(tmp_field_0(src_tmp_ni*src_tmp_nj)) 
     187 
     188  CALL xios_get_axis_attr("src_axis_curvilinear_read", n=src_tmp_n) 
     189  CALL xios_get_domain_attr("src_domain_curvilinear_read", ni=src_tmp_ni, nj=src_tmp_nj) 
     190  ALLOCATE(tmp_field_1(src_tmp_ni*src_tmp_nj*src_tmp_n)) 
     191 
     192  CALL xios_get_domain_attr("src_domain_unstructured_read", ni=src_tmp_ni, nj=src_tmp_nj) 
     193  ALLOCATE(tmp_field_2(src_tmp_ni*src_tmp_nj)) 
     194 
     195  DO ts=1,1 
     196    CALL xios_recv_field("src_field_regular", tmp_field_0) 
     197    CALL xios_recv_field("src_field_curvilinear", tmp_field_1) 
     198    CALL xios_recv_field("src_field_unstructured", tmp_field_2) 
    190199    CALL xios_update_calendar(ts) 
    191200    CALL xios_send_field("src_field_2D",src_field_2D) 
    192     CALL xios_send_field("src_field_2D_clone",src_field_2D) 
     201     
     202    DO i=1,src_ni 
     203      src_field_2D_clone(i) = src_field_2D(i) 
     204      IF ((23.5 * ts < src_lat(i)) .AND. (src_lat(i) < 65.5 *ts) .AND. (0 < src_lon(i)) .AND. (src_lon(i) < 30*ts)) THEN       
     205        src_field_2D_clone(i) = missing_value     
     206      ENDIF 
     207    ENDDO 
     208 
     209    CALL xios_send_field("src_field_2D_clone",src_field_2D_clone) 
    193210    CALL xios_send_field("src_field_3D",src_field_3D) 
    194211    CALL xios_send_field("src_field_3D_clone",src_field_3D) 
    195212    CALL xios_send_field("src_field_4D",src_field_4D) 
    196213    CALL xios_send_field("src_field_3D_pression",src_field_pression) 
    197     ! CALL xios_send_field("tmp_field_0",tmp_field_0) 
    198     ! CALL xios_send_field("tmp_field_1",tmp_field_1) 
    199     ! CALL xios_send_field("tmp_field_2",tmp_field_2) 
     214    CALL xios_send_field("tmp_field_0",tmp_field_0) 
     215    CALL xios_send_field("tmp_field_1",tmp_field_1) 
     216    CALL xios_send_field("tmp_field_2",tmp_field_2) 
    200217    CALL wait_us(5000) ; 
    201218   ENDDO 
     
    205222  DEALLOCATE(src_lon, src_lat, src_boundslon,src_boundslat, src_field_2D) 
    206223  DEALLOCATE(dst_lon, dst_lat, dst_boundslon,dst_boundslat) 
    207   ! DEALLOCATE(tmp_field_0, tmp_field_1, tmp_field_2) 
     224  DEALLOCATE(tmp_field_0, tmp_field_1, tmp_field_2) 
    208225 
    209226  CALL MPI_COMM_FREE(comm, ierr) 
  • XIOS/trunk/src/transformation/domain_algorithm_generate_rectilinear.cpp

    r933 r1064  
    127127void CDomainAlgorithmGenerateRectilinear::fillInAttributesDomainDestination() 
    128128{ 
    129   domainDest_->redistribute(nbDomainDistributedPart_); 
     129  if (!domainDest_->distributionAttributesHaveValue()) 
     130    domainDest_->redistribute(nbDomainDistributedPart_); 
     131  domainDest_->fillInLonLat(); 
    130132} 
    131133 
Note: See TracChangeset for help on using the changeset viewer.