Changeset 1030 for XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
- Timestamp:
- 01/20/17 16:17:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
r1027 r1030 1044 1044 CContext* context = CContext::getCurrent(); 1045 1045 1046 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 1047 for (int i = 0; i < nbSrvPools; ++i) 1046 if (axis->IsWritten(this->filename)) return; 1047 axis->checkAttributes(); 1048 1049 int local_size_write = axis->getLocalWriteSize(); 1050 int global_size_write = axis->getGlobalWriteSize(); 1051 int start_write = axis->getStartWriteIndex(); 1052 int count_write = axis->getCountWriteIndex(); 1053 1054 if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 1055 1056 std::vector<StdString> dims; 1057 StdString axisid = axis->getAxisOutputName(); 1058 if (isWrittenAxis(axisid)) return ; 1059 else setWrittenAxis(axisid); 1060 1061 try 1048 1062 { 1049 CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[i]; 1050 1051 if (axis->IsWritten(this->filename)) return; 1052 axis->checkAttributes(); 1053 1054 int local_size_write = axis->getLocalWriteSize(); 1055 int global_size_write = axis->getGlobalWriteSize(); 1056 int start_write = axis->getStartWriteIndex(); 1057 int count_write = axis->getCountWriteIndex(); 1058 1059 if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 1060 1061 std::vector<StdString> dims; 1062 StdString axisid = axis->getAxisOutputName(); 1063 if (isWrittenAxis(axisid)) return ; 1064 else setWrittenAxis(axisid); 1065 1066 try 1063 SuperClassWriter::addDimension(axisid, global_size_write); 1064 if (axis->hasValue) 1067 1065 { 1068 SuperClassWriter::addDimension(axisid, global_size_write); 1069 if (axis->hasValue) 1066 dims.push_back(axisid); 1067 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 1068 1069 if (!axis->name.isEmpty()) 1070 SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 1071 1072 if (!axis->standard_name.isEmpty()) 1073 SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 1074 1075 if (!axis->long_name.isEmpty()) 1076 SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 1077 1078 if (!axis->unit.isEmpty()) 1079 SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 1080 1081 if (!axis->positive.isEmpty()) 1070 1082 { 1071 dims.push_back(axisid); 1072 SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 1073 1074 if (!axis->name.isEmpty()) 1075 SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 1076 1077 if (!axis->standard_name.isEmpty()) 1078 SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 1079 1080 if (!axis->long_name.isEmpty()) 1081 SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 1082 1083 if (!axis->unit.isEmpty()) 1084 SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 1085 1086 if (!axis->positive.isEmpty()) 1083 SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 1084 SuperClassWriter::addAttribute("positive", 1085 (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 1086 &axisid); 1087 } 1088 1089 StdString axisBoundsId = axisid + "_bounds"; 1090 if (!axis->bounds.isEmpty()) 1091 { 1092 dims.push_back("axis_nbounds"); 1093 SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 1094 SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 1095 } 1096 1097 SuperClassWriter::definition_end(); 1098 1099 switch (SuperClass::type) 1100 { 1101 case MULTI_FILE: 1087 1102 { 1088 SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 1089 SuperClassWriter::addAttribute("positive", 1090 (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 1091 &axisid); 1103 CArray<double,1> axis_value(local_size_write); 1104 for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 1105 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 1106 1107 if (!axis->bounds.isEmpty()) 1108 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 1109 1110 SuperClassWriter::definition_start(); 1111 1112 break; 1092 1113 } 1093 1094 StdString axisBoundsId = axisid + "_bounds"; 1095 if (!axis->bounds.isEmpty()) 1114 case ONE_FILE: 1096 1115 { 1097 dims.push_back("axis_nbounds"); 1098 SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 1099 SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 1116 CArray<double,1> axis_value(count_write); 1117 axis_value = axis->value; 1118 1119 std::vector<StdSize> start(1), startBounds(2) ; 1120 std::vector<StdSize> count(1), countBounds(2) ; 1121 start[0] = startBounds[0] = start_write; 1122 count[0] = countBounds[0] = count_write; 1123 startBounds[1] = 0; 1124 countBounds[1] = 2; 1125 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 1126 1127 if (!axis->bounds.isEmpty()) 1128 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1129 1130 SuperClassWriter::definition_start(); 1131 1132 break; 1100 1133 } 1101 1102 SuperClassWriter::definition_end(); 1103 1104 switch (SuperClass::type) 1105 { 1106 case MULTI_FILE: 1107 { 1108 CArray<double,1> axis_value(local_size_write); 1109 for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 1110 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 1111 1112 if (!axis->bounds.isEmpty()) 1113 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 1114 1115 SuperClassWriter::definition_start(); 1116 1117 break; 1118 } 1119 case ONE_FILE: 1120 { 1121 CArray<double,1> axis_value(count_write); 1122 axis_value = axis->value; 1123 1124 std::vector<StdSize> start(1), startBounds(2) ; 1125 std::vector<StdSize> count(1), countBounds(2) ; 1126 start[0] = startBounds[0] = start_write; 1127 count[0] = countBounds[0] = count_write; 1128 startBounds[1] = 0; 1129 countBounds[1] = 2; 1130 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 1131 1132 if (!axis->bounds.isEmpty()) 1133 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1134 1135 SuperClassWriter::definition_start(); 1136 1137 break; 1138 } 1139 default : 1140 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 1141 << "[ type = " << SuperClass::type << "]" 1142 << " not implemented yet !"); 1143 } 1134 default : 1135 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 1136 << "[ type = " << SuperClass::type << "]" 1137 << " not implemented yet !"); 1144 1138 } 1145 1139 } 1146 catch (CNetCdfException& e) 1147 { 1148 StdString msg("On writing the axis : "); 1149 msg.append(axisid); msg.append("\n"); 1150 msg.append("In the context : "); 1151 CContext* context = CContext::getCurrent() ; 1152 msg.append(context->getId()); msg.append("\n"); 1153 msg.append(e.what()); 1154 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); 1155 } 1156 } // loop over nbSrvPools 1140 } 1141 catch (CNetCdfException& e) 1142 { 1143 StdString msg("On writing the axis : "); 1144 msg.append(axisid); msg.append("\n"); 1145 msg.append("In the context : "); 1146 CContext* context = CContext::getCurrent() ; 1147 msg.append(context->getId()); msg.append("\n"); 1148 msg.append(e.what()); 1149 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); 1150 } 1151 1157 1152 axis->addRelFile(this->filename); 1158 1153 }
Note: See TracChangeset
for help on using the changeset viewer.