Ignore:
Timestamp:
01/11/17 16:50:27 (7 years ago)
Author:
oabramkina
Message:

Minor modifications in the merged version of dev.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/io/nc4_data_output.cpp

    r1025 r1027  
    10431043      { 
    10441044        CContext* context = CContext::getCurrent(); 
    1045         CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 
    1046  
    1047         if (axis->IsWritten(this->filename)) return; 
    1048         axis->checkAttributes(); 
    1049  
    1050         int local_size_write  = axis->getLocalWriteSize(); 
    1051         int global_size_write = axis->getGlobalWriteSize(); 
    1052         int start_write = axis->getStartWriteIndex(); 
    1053         int count_write = axis->getCountWriteIndex(); 
    1054  
    1055         if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 
    1056  
    1057         std::vector<StdString> dims; 
    1058         StdString axisid = axis->getAxisOutputName(); 
    1059         if (isWrittenAxis(axisid)) return ; 
    1060         else setWrittenAxis(axisid); 
    1061  
    1062         try 
     1045 
     1046        int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1047        for (int i = 0; i < nbSrvPools; ++i) 
    10631048        { 
    1064           SuperClassWriter::addDimension(axisid, global_size_write); 
    1065           if (axis->hasValue) 
     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 
    10661067          { 
    1067             dims.push_back(axisid); 
    1068             SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); 
    1069  
    1070             if (!axis->name.isEmpty()) 
    1071               SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); 
    1072  
    1073             if (!axis->standard_name.isEmpty()) 
    1074               SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); 
    1075  
    1076             if (!axis->long_name.isEmpty()) 
    1077               SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); 
    1078  
    1079             if (!axis->unit.isEmpty()) 
    1080               SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); 
    1081  
    1082             if (!axis->positive.isEmpty()) 
     1068            SuperClassWriter::addDimension(axisid, global_size_write); 
     1069            if (axis->hasValue) 
    10831070            { 
    1084               SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
    1085               SuperClassWriter::addAttribute("positive", 
    1086                                              (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
    1087                                              &axisid); 
    1088             } 
    1089  
    1090             StdString axisBoundsId = axisid + "_bounds"; 
    1091             if (!axis->bounds.isEmpty()) 
    1092             { 
    1093               dims.push_back("axis_nbounds"); 
    1094               SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
    1095               SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    1096             } 
    1097  
    1098             SuperClassWriter::definition_end(); 
    1099  
    1100             switch (SuperClass::type) 
    1101             { 
    1102               case MULTI_FILE: 
     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()) 
    11031087              { 
    1104                 CArray<double,1> axis_value(local_size_write); 
    1105                 for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 
    1106                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    1107  
    1108                 if (!axis->bounds.isEmpty()) 
    1109                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 
    1110  
    1111                 SuperClassWriter::definition_start(); 
    1112  
    1113                 break; 
     1088                SuperClassWriter::addAttribute("axis", string("Z"), &axisid); 
     1089                SuperClassWriter::addAttribute("positive", 
     1090                                               (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), 
     1091                                               &axisid); 
    11141092              } 
    1115               case ONE_FILE: 
     1093 
     1094              StdString axisBoundsId = axisid + "_bounds"; 
     1095              if (!axis->bounds.isEmpty()) 
    11161096              { 
    1117                 CArray<double,1> axis_value(count_write); 
    1118                 axis_value = axis->value; 
    1119  
    1120                 std::vector<StdSize> start(1), startBounds(2) ; 
    1121                 std::vector<StdSize> count(1), countBounds(2) ; 
    1122                 start[0] = startBounds[0] = start_write; 
    1123                 count[0] = countBounds[0] = count_write; 
    1124                 startBounds[1] = 0; 
    1125                 countBounds[1] = 2; 
    1126                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
    1127  
    1128                 if (!axis->bounds.isEmpty()) 
    1129                   SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 
    1130  
    1131                 SuperClassWriter::definition_start(); 
    1132  
    1133                 break; 
     1097                dims.push_back("axis_nbounds"); 
     1098                SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); 
     1099                SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); 
    11341100              } 
    1135               default : 
    1136                 ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", 
    1137                       << "[ type = " << SuperClass::type << "]" 
    1138                       << " not implemented yet !"); 
     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              } 
    11391144            } 
    11401145          } 
    1141         } 
    1142         catch (CNetCdfException& e) 
    1143         { 
    1144           StdString msg("On writing the axis : "); 
    1145           msg.append(axisid); msg.append("\n"); 
    1146           msg.append("In the context : "); 
    1147           CContext* context = CContext::getCurrent() ; 
    1148           msg.append(context->getId()); msg.append("\n"); 
    1149           msg.append(e.what()); 
    1150           ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); 
    1151         } 
    1152         axis->addRelFile(this->filename); 
     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 
     1157      axis->addRelFile(this->filename); 
    11531158     } 
    11541159 
Note: See TracChangeset for help on using the changeset viewer.