Ignore:
Timestamp:
08/03/17 15:50:40 (7 years ago)
Author:
mhnguyen
Message:

Fixing a bug on writting axis label

+) Axis label is correctly processed before being written
+) Do some code cleaning and add some comments

Test
+) On Curie
+) OK

File:
1 edited

Legend:

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

    r1222 r1235  
    11361136        int zoom_size  = (MULTI_FILE == SuperClass::type) ? axis->zoom_n 
    11371137                                                          : axis->global_zoom_n; 
    1138         int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->zoom_begin 
    1139                                                           : axis->global_zoom_begin; 
     1138 
     1139        int zoom_count = axis->zoom_n;                                                  
     1140        int zoom_begin = axis->zoom_begin; 
     1141        // int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->global_zoom_begin  
     1142        //                                                   : axis->zoom_begin; 
    11401143 
    11411144        if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return; 
     
    11481151        nc_type typePrec ; 
    11491152        if (axis->prec.isEmpty()) typePrec =  NC_FLOAT ; 
    1150         else if (axis->prec==4)  typePrec =  NC_FLOAT ; 
     1153        else if (axis->prec==4)   typePrec =  NC_FLOAT ; 
    11511154        else if (axis->prec==8)   typePrec =  NC_DOUBLE ; 
    11521155          
     
    11981201            for (int i = 0; i < nbWritten; i++) axis_value(i) = axis->value(indexToWrite(i)); 
    11991202            CArray<double,2> axis_bounds; 
     1203            CArray<string,1> axis_label; 
     1204            if (!axis->label.isEmpty()) 
     1205            { 
     1206              axis_label.resize(indexToWrite.numElements()); 
     1207              for (int i = 0; i < nbWritten; i++) axis_label(i) = axis->label(indexToWrite(i)); 
     1208            } 
    12001209 
    12011210            switch (SuperClass::type) 
     
    12031212              case MULTI_FILE: 
    12041213              { 
    1205                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
     1214                if (axis->label.isEmpty()) 
     1215                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 
    12061216 
    12071217                if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
     
    12091219 
    12101220                // Need to check after 
    1211                 if (! axis->label.isEmpty())  SuperClassWriter::writeData(axis->label_srv, axisid, isCollective, 0); 
     1221                if (!axis->label.isEmpty())  
     1222                  SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); 
    12121223  
    12131224                SuperClassWriter::definition_start(); 
     
    12191230                std::vector<StdSize> count(1), countBounds(2) ; 
    12201231                start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; 
    1221                 count[0] = countBounds[0] = zoom_size; 
     1232                count[0] = countBounds[0] = zoom_count; // zoom_size 
    12221233                startBounds[1] = 0; 
    12231234                countBounds[1] = 2; 
    1224                 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
    1225  
    1226                 if (!axis->bounds.isEmpty()&& axis->label.isEmpty()) 
     1235 
     1236                if (axis->label.isEmpty()) 
     1237                  SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); 
     1238 
     1239                if (!axis->bounds.isEmpty() && axis->label.isEmpty()) 
    12271240                { 
    12281241                  axis_bounds.resize(2, indexToWrite.numElements()); 
     
    12361249 
    12371250                // Need to check after 
    1238                 if (! axis->label.isEmpty())  SuperClassWriter::writeData(axis->label_srv, axisid, isCollective, 0); 
     1251                if (!axis->label.isEmpty()) 
     1252                { 
     1253                  std::vector<StdSize> startLabel(2), countLabel(2); 
     1254                  startLabel[0] = start[0]; startLabel[1] = 0; 
     1255                  countLabel[0] = count[0]; countLabel[1] = stringArrayLen; 
     1256                  SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); 
     1257                } 
    12391258 
    12401259                SuperClassWriter::definition_start(); 
Note: See TracChangeset for help on using the changeset viewer.