Ignore:
Timestamp:
12/03/14 11:41:54 (7 years ago)
Author:
rlacroix
Message:

Make the variable typing stricter.

The type must now be one of:

  • bool
  • int or int32
  • int16
  • int64
  • float
  • double
  • string

WARNING: The variable type was previously not checked and using an unsupported type did not lead to any error message. Be aware that this change can make your existing configuration files invalid. However the adjustments required to adapt existing files should be minor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r517 r527  
    803803        try 
    804804        { 
    805           if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>(),&fieldId) ; 
    806           else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>(),&fieldId) ; 
    807           else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>(),&fieldId) ; 
    808           else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>(),&fieldId) ; 
    809           else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>(),&fieldId) ; 
    810           else addAttribute(name,var->getData<string>(),&fieldId) ; 
     805          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) 
     806            addAttribute(name, var->getData<int>(), &fieldId); 
     807          else if (var->type.getValue() == CVariable::type_attr::t_int16) 
     808            addAttribute(name, var->getData<short int>(), &fieldId); 
     809          else if (var->type.getValue() == CVariable::type_attr::t_float) 
     810            addAttribute(name, var->getData<float>(), &fieldId); 
     811          else if (var->type.getValue() == CVariable::type_attr::t_double) 
     812            addAttribute(name, var->getData<double>(), &fieldId); 
     813          else if (var->type.getValue() == CVariable::type_attr::t_string) 
     814            addAttribute(name, var->getData<string>(), &fieldId); 
     815          else 
     816            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", 
     817                  << "Unsupported variable of type " << var->type.getStringValue()); 
    811818        } 
    812819       catch (CNetCdfException& e) 
     
    830837        try 
    831838        { 
    832           if (var->getVarType()==CVariable::t_int) addAttribute(name,var->getData<int>()) ; 
    833           else if (var->getVarType()==CVariable::t_short_int) addAttribute(name,var->getData<short int>()) ; 
    834           else if (var->getVarType()==CVariable::t_long_int) addAttribute(name,var->getData<long int>()) ; 
    835           else if (var->getVarType()==CVariable::t_float) addAttribute(name,var->getData<float>()) ; 
    836           else if (var->getVarType()==CVariable::t_double) addAttribute(name,var->getData<double>()) ; 
    837           else addAttribute(name,var->getData<string>()) ; 
     839          if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) 
     840            addAttribute(name, var->getData<int>()); 
     841          else if (var->type.getValue() == CVariable::type_attr::t_int16) 
     842            addAttribute(name, var->getData<short int>()); 
     843          else if (var->type.getValue() == CVariable::type_attr::t_float) 
     844            addAttribute(name, var->getData<float>()); 
     845          else if (var->type.getValue() == CVariable::type_attr::t_double) 
     846            addAttribute(name, var->getData<double>()); 
     847          else if (var->type.getValue() == CVariable::type_attr::t_string) 
     848            addAttribute(name, var->getData<string>()); 
     849          else 
     850            ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", 
     851                  << "Unsupported variable of type " << var->type.getStringValue()); 
    838852        } 
    839853       catch (CNetCdfException& e) 
Note: See TracChangeset for help on using the changeset viewer.