Changeset 612
- Timestamp:
- 06/10/15 15:11:22 (9 years ago)
- Location:
- XIOS
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/branchs/xios-1.0/src/duration.cpp
r579 r612 27 27 StdOStream & operator<<(StdOStream & out, const CDuration & duration) 28 28 { 29 StdOStringStream sout; 30 bool testValue = true; 31 if(duration.year != 0.0) { testValue = false; sout << duration.year << "y "; } 32 if(duration.month != 0.0) { testValue = false; sout << duration.month << "mo "; } 33 if(duration.day != 0.0) { testValue = false; sout << duration.day << "d "; } 34 if(duration.hour != 0.0) { testValue = false; sout << duration.hour << "h "; } 35 if(duration.minute != 0.0) { testValue = false; sout << duration.minute << "mi "; } 36 if(duration.second != 0.0) { testValue = false; sout << duration.second << "s "; } 37 if(duration.timestep != 0.0 || testValue) { sout << duration.timestep << "ts "; } 38 39 // << suppression de l'espace en fin de chaîne. 40 out << (sout.str().substr(0, sout.str().size()-1)); 29 out << duration.toString(); 41 30 return out; 42 31 } … … 145 134 StdString CDuration::toString(void) const 146 135 { 147 const CDuration & own = *this; 148 StdOStringStream oss; oss << own; 149 return oss.str(); 136 StdOStringStream sout; 137 bool forceOutput = true; 138 139 if (year != 0.0) { forceOutput = false; sout << year << "y "; } 140 if (month != 0.0) { forceOutput = false; sout << month << "mo "; } 141 if (day != 0.0) { forceOutput = false; sout << day << "d "; } 142 if (hour != 0.0) { forceOutput = false; sout << hour << "h "; } 143 if (minute != 0.0) { forceOutput = false; sout << minute << "mi "; } 144 if (second != 0.0) { forceOutput = false; sout << second << "s "; } 145 if (timestep != 0.0 || forceOutput) { sout << timestep << "ts "; } 146 147 // Remove the trailing space 148 StdString strOut = sout.str(); 149 return strOut.erase(strOut.size() - 1); 150 } 151 152 StdString CDuration::toStringUDUnits(void) const 153 { 154 if (timestep != 0.0) 155 ERROR("StdString CDuration::toStringUDUnits(void) const", 156 "Impossible to convert a duration to string using UDUnits when a timestep is set."); 157 158 StdOStringStream sout; 159 bool forceOutput = true; 160 161 if (year != 0.0) { forceOutput = false; sout << year << " yr "; } 162 if (month != 0.0) { forceOutput = false; sout << month << " month "; } 163 if (day != 0.0) { forceOutput = false; sout << day << " d "; } 164 if (hour != 0.0) { forceOutput = false; sout << hour << " h "; } 165 if (minute != 0.0) { forceOutput = false; sout << minute << " min "; } 166 if (second != 0.0 || forceOutput) { sout << second << " s "; } 167 168 // Remove the trailing space 169 StdString strOut = sout.str(); 170 return strOut.erase(strOut.size() - 1); 150 171 } 151 172 -
XIOS/branchs/xios-1.0/src/duration.hpp
r501 r612 31 31 /// Autres /// 32 32 StdString toString(void) const; 33 StdString toStringUDUnits(void) const; 33 34 34 35 public: /* static */ -
XIOS/branchs/xios-1.0/src/output/nc4_data_output.cpp
r611 r612 794 794 if (wtime) 795 795 { 796 CDuration duration ; 797 798 duration=CDuration::FromString(field->freq_op) ; 799 duration.solveTimeStep(*(context->calendar)); 800 SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); 801 802 duration=CDuration::FromString(field->getRelFile()->output_freq) ; 803 duration.solveTimeStep(*(context->calendar)); 804 SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); 796 CDuration duration = CDuration::FromString(field->freq_op); 797 duration.solveTimeStep(*context->calendar); 798 StdString freqOpStr = duration.toStringUDUnits(); 799 SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 800 801 duration = CDuration::FromString(field->getRelFile()->output_freq); 802 duration.solveTimeStep(*context->calendar); 803 SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 804 805 StdString cellMethods = coodinates.front() + ": "; 806 if (field->operation.getValue() == "instant") cellMethods += "point"; 807 else if (field->operation.getValue() == "average") cellMethods += "mean"; 808 else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 809 else cellMethods += field->operation; 810 cellMethods += " (interval: " + freqOpStr + ")"; 811 SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 805 812 } 806 813 -
XIOS/trunk/src/duration.cpp
r579 r612 28 28 StdOStream& operator<<(StdOStream& out, const CDuration& duration) 29 29 { 30 StdOStringStream sout; 31 bool forceOutput = true; 32 33 if (duration.year != 0.0) { forceOutput = false; sout << duration.year << "y "; } 34 if (duration.month != 0.0) { forceOutput = false; sout << duration.month << "mo "; } 35 if (duration.day != 0.0) { forceOutput = false; sout << duration.day << "d "; } 36 if (duration.hour != 0.0) { forceOutput = false; sout << duration.hour << "h "; } 37 if (duration.minute != 0.0) { forceOutput = false; sout << duration.minute << "mi "; } 38 if (duration.second != 0.0) { forceOutput = false; sout << duration.second << "s "; } 39 if (duration.timestep != 0.0 || forceOutput) { sout << duration.timestep << "ts "; } 40 41 // suppression de l'espace en fin de chaîne. 42 StdString strOut = sout.str(); 43 out << strOut.erase(strOut.size() - 1); 44 return out; 30 out << duration.toString(); 31 return out; 45 32 } 46 33 … … 124 111 StdString CDuration::toString(void) const 125 112 { 126 StdOStringStream oss; oss << *this; 127 return oss.str(); 113 StdOStringStream sout; 114 bool forceOutput = true; 115 116 if (year != 0.0) { forceOutput = false; sout << year << "y "; } 117 if (month != 0.0) { forceOutput = false; sout << month << "mo "; } 118 if (day != 0.0) { forceOutput = false; sout << day << "d "; } 119 if (hour != 0.0) { forceOutput = false; sout << hour << "h "; } 120 if (minute != 0.0) { forceOutput = false; sout << minute << "mi "; } 121 if (second != 0.0) { forceOutput = false; sout << second << "s "; } 122 if (timestep != 0.0 || forceOutput) { sout << timestep << "ts "; } 123 124 // Remove the trailing space 125 StdString strOut = sout.str(); 126 return strOut.erase(strOut.size() - 1); 127 } 128 129 StdString CDuration::toStringUDUnits(void) const 130 { 131 if (timestep != 0.0) 132 ERROR("StdString CDuration::toStringUDUnits(void) const", 133 "Impossible to convert a duration to string using UDUnits when a timestep is set."); 134 135 StdOStringStream sout; 136 bool forceOutput = true; 137 138 if (year != 0.0) { forceOutput = false; sout << year << " yr "; } 139 if (month != 0.0) { forceOutput = false; sout << month << " month "; } 140 if (day != 0.0) { forceOutput = false; sout << day << " d "; } 141 if (hour != 0.0) { forceOutput = false; sout << hour << " h "; } 142 if (minute != 0.0) { forceOutput = false; sout << minute << " min "; } 143 if (second != 0.0 || forceOutput) { sout << second << " s "; } 144 145 // Remove the trailing space 146 StdString strOut = sout.str(); 147 return strOut.erase(strOut.size() - 1); 128 148 } 129 149 -
XIOS/trunk/src/duration.hpp
r591 r612 34 34 /// Autres /// 35 35 StdString toString(void) const; 36 StdString toStringUDUnits(void) const; 36 37 37 38 /// Propriétés publiques /// -
XIOS/trunk/src/output/nc4_data_output.cpp
r611 r612 816 816 { 817 817 CDuration duration = field->freq_op.getValue(); 818 duration.solveTimeStep(*(context->calendar)); 819 SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); 818 duration.solveTimeStep(*context->calendar); 819 StdString freqOpStr = duration.toStringUDUnits(); 820 SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); 820 821 821 822 duration = field->getRelFile()->output_freq.getValue(); 822 duration.solveTimeStep(*(context->calendar)); 823 SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); 823 duration.solveTimeStep(*context->calendar); 824 SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 825 826 StdString cellMethods = coodinates.front() + ": "; 827 if (field->operation.getValue() == "instant") cellMethods += "point"; 828 else if (field->operation.getValue() == "average") cellMethods += "mean"; 829 else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; 830 else cellMethods += field->operation; 831 cellMethods += " (interval: " + freqOpStr + ")"; 832 SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); 824 833 } 825 834 … … 1025 1034 // CDuration duration = field->freq_op.getValue(); 1026 1035 // duration.solveTimeStep(*(context->calendar)); 1027 // SuperClassWriter::addAttribute("interval_operation", duration.toString (), &fieldid);1036 // SuperClassWriter::addAttribute("interval_operation", duration.toStringUDUnits(), &fieldid); 1028 1037 // 1029 1038 // duration = field->getRelFile()->output_freq.getValue(); 1030 1039 // duration.solveTimeStep(*(context->calendar)); 1031 // SuperClassWriter::addAttribute("interval_write", duration.toString (), &fieldid);1040 // SuperClassWriter::addAttribute("interval_write", duration.toStringUDUnits(), &fieldid); 1032 1041 // } 1033 1042 //
Note: See TracChangeset
for help on using the changeset viewer.