Changeset 744


Ignore:
Timestamp:
10/21/15 11:50:09 (6 years ago)
Author:
rlacroix
Message:

Grid: Force 'grid_ref' and 'axis_ref'/'domain_ref' to be mutually exclusive.

Users must ensure that they don't mix those arguments even when using 'field_ref'.

Location:
XIOS/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/COMPLETE/context_atmosphere.xml

    r742 r744  
    55  <field_definition level="1" enabled=".FALSE." default_value="9.96921e+36"> 
    66    <field id="field_A_atm"  name="field_A_atm_origin" operation="average" freq_op="1ts" grid_ref="grid_A_atm" /> 
    7     <field id="field_A_atm_zoom"  name="field_A_atm" operation="average" freq_op="1ts" field_ref="field_A_atm" domain_ref="domain_atm_zoom" axis_ref="axis_atm" /> 
     7    <field id="field_A_atm_zoom"  name="field_A_atm" operation="average" freq_op="1ts" field_ref="field_A_atm" grid_ref="grid_A_atm_zoom" /> 
    88  </field_definition> 
    99 
     
    3636     <axis axis_ref="axis_atm" /> 
    3737   </grid> 
     38   <grid id="grid_A_atm_zoom"> 
     39     <domain domain_ref="domain_atm_zoom" /> 
     40     <axis axis_ref="axis_atm_zoom" /> 
     41   </grid> 
    3842  </grid_definition> 
    3943 
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r743 r744  
    77 
    88   <field_definition level="1" > 
    9      <field id="src_field"  operation="instant" domain_ref="src_domain"/> 
    10      <field id="dst_field"  operation="instant" field_ref="src_field" domain_ref="dst_domain"/> 
    11      <field id="tmp_field"  operation="instant" domain_ref="src_domain_regular"/> 
    12      <field id="dst_field_regular_grid"  operation="instant" field_ref="tmp_field" grid_ref="dst_grid_regular"  read_access="true"/> 
    13      <field id="dst_field_regular"  operation="instant" field_ref="tmp_field" domain_ref="dst_domain_regular"  read_access="true"/> 
    14      <field id="dst_field_regular_pole"  operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole"  read_access="true"/> 
    15  
     9     <field id="src_field" operation="instant" domain_ref="src_domain"/> 
     10     <field id="dst_field" operation="instant" field_ref="src_field" domain_ref="dst_domain"/> 
     11     <field id="tmp_field" operation="instant" domain_ref="src_domain_regular"/> 
     12     <field id="dst_field_regular" operation="instant" field_ref="tmp_field" domain_ref="dst_domain_regular" read_access="true"/> 
     13     <field id="dst_field_regular_pole" operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole" read_access="true"/> 
    1614   </field_definition> 
    1715 
     
    2927     <file id="output_dst_regular" name="output_dst_regular" type="one_file"> 
    3028        <field field_ref="dst_field_regular" name="field" /> 
    31         <field field_ref="dst_field_regular_grid" name="field_grid" /> 
    3229     </file> 
    3330     <file id="output_src_regular" name="output_src_regular" mode="read" type="multiple_file"> 
     
    6057     </domain> 
    6158   </domain_definition> 
    62  
    63    <grid_definition> 
    64      <grid id="dst_grid_regular"> 
    65        <domain domain_ref="dst_domain_regular" /> 
    66      </grid> 
    67    </grid_definition> 
    6859  </context> 
    6960 
  • XIOS/trunk/src/node/field.cpp

    r742 r744  
    758758      { 
    759759        ERROR("CField::solveGridReference(void)", 
    760               << "At least one dimension must be defined for this field."); 
    761       } 
    762  
    763       CDomain* domain; 
    764       CAxis* axis; 
    765       std::vector<CDomain*> vecDom; 
    766       std::vector<CAxis*> vecAxis; 
    767       std::vector<std::string> domList, axisList; 
    768  
    769       // In some cases, domain_ref, axis_ref and grid_ref don't come from the current field but from his direct field_ref 
    770       // To make sure to use the correct *_ref, we need to compare these values to direct field_ref's 
    771       CField* baseFieldRef = this->getBaseFieldReference(); 
    772       bool hasDomainFromFieldRef = false; 
    773       bool hasAxisFromFieldRef = false; 
    774       bool hasGridFromFieldRef = false; 
    775  
    776       if (!domain_ref.isEmpty()) 
    777       { 
    778          if (0 != baseFieldRef) 
    779          { 
    780            if ((!baseFieldRef->domain_ref.isEmpty()) && (baseFieldRef->domain_ref.getValue() == domain_ref.getValue())) 
    781             hasDomainFromFieldRef = true; 
    782          } 
    783  
    784          if (CDomain::has(domain_ref.getValue())) 
    785          { 
    786            domain = CDomain::get(domain_ref.getValue()); 
    787            // It's a direct reference, so we use this ref as its name 
    788            domain->name.setValue(domain_ref.getValue()); 
    789  
    790            vecDom.push_back(domain); 
    791          } 
    792          else 
     760              << "A grid must be defined for field '" << (!name.isEmpty() ? name.getValue() : getId()) << "' ."); 
     761      } 
     762      else if (!grid_ref.isEmpty() && (!domain_ref.isEmpty() || !axis_ref.isEmpty())) 
     763      { 
     764        ERROR("CField::solveGridReference(void)", 
     765              << "Field '" << (!name.isEmpty() ? name.getValue() : getId()) << "' has both a grid and a domain/axis." << std::endl 
     766              << "Please define either 'grid_ref' or 'domain_ref'/'axis_ref'."); 
     767      } 
     768 
     769      if (grid_ref.isEmpty()) 
     770      { 
     771        std::vector<CDomain*> vecDom; 
     772        std::vector<CAxis*> vecAxis; 
     773 
     774        if (!domain_ref.isEmpty()) 
     775        { 
     776          if (CDomain::has(domain_ref)) 
     777            vecDom.push_back(CDomain::get(domain_ref)); 
     778          else 
    793779            ERROR("CField::solveGridReference(void)", 
    794                   << "Reference to the domain \'" 
    795                   << domain_ref.getValue() << "\' is wrong"); 
    796       } 
    797  
    798       if (!axis_ref.isEmpty()) 
    799       { 
    800          if (0 != baseFieldRef) 
    801          { 
    802            if ((!baseFieldRef->axis_ref.isEmpty()) && (baseFieldRef->axis_ref.getValue() == axis_ref.getValue())) 
    803             hasAxisFromFieldRef = true; 
    804          } 
    805          if (CAxis::has(axis_ref.getValue())) 
    806          { 
    807            axis = CAxis::get(axis_ref.getValue()); 
    808                       // It's a direct reference, so we use this ref as its name 
    809            axis->name.setValue(axis_ref.getValue()); 
    810  
    811            vecAxis.push_back(axis); 
    812          } 
    813          else 
     780                  << "Invalid reference to domain '" << domain_ref.getValue() << "'."); 
     781        } 
     782 
     783        if (!axis_ref.isEmpty()) 
     784        { 
     785          if (CAxis::has(axis_ref)) 
     786            vecAxis.push_back(CAxis::get(axis_ref)); 
     787          else 
    814788            ERROR("CField::solveGridReference(void)", 
    815                   << "Reference to the axis \'" 
    816                   << axis_ref.getValue() <<"\' is wrong"); 
    817       } 
    818  
    819       if (!grid_ref.isEmpty()) 
    820       { 
    821          if (0 != baseFieldRef) 
    822          { 
    823            if ((!baseFieldRef->grid_ref.isEmpty()) && (baseFieldRef->grid_ref.getValue() == grid_ref.getValue())) 
    824             hasGridFromFieldRef = true; 
    825          } 
    826  
    827         if ((domain_ref.isEmpty() && axis_ref.isEmpty()) || (!hasGridFromFieldRef)) 
    828         { 
    829            if (CGrid::has(grid_ref.getValue())) 
    830            { 
    831              this->grid = CGrid::get(grid_ref.getValue()); 
    832            } 
    833            else 
    834               ERROR("CField::solveGridReference(void)", 
    835                     << "Reference to the grid \'" 
    836                     << grid_ref.getValue() << "\' is wrong"); 
     789                  << "Invalid reference to axis '" << axis_ref.getValue() << "'."); 
    837790        } 
     791 
     792        this->grid = CGrid::createGrid(vecDom, vecAxis); 
     793      } 
     794      else 
     795      { 
     796        if (CGrid::has(grid_ref)) 
     797          this->grid = CGrid::get(grid_ref); 
    838798        else 
    839         { 
    840           this->grid = CGrid::createGrid(vecDom, vecAxis); 
    841           this->grid_ref.setValue(this->grid->getId()); 
    842         } 
    843       } 
    844       else 
    845       { 
    846          this->grid = CGrid::createGrid(vecDom, vecAxis); 
    847          this->grid_ref.setValue(this->grid->getId()); 
     799          ERROR("CField::solveGridReference(void)", 
     800                << "Invalid reference to grid '" << grid_ref.getValue() << "'."); 
    848801      } 
    849802   } 
Note: See TracChangeset for help on using the changeset viewer.