1 | #include "nc4_data_output.hpp" |
---|
2 | |
---|
3 | #include "attribute_template.hpp" |
---|
4 | #include "group_template.hpp" |
---|
5 | |
---|
6 | #include "file.hpp" |
---|
7 | #include "calendar.hpp" |
---|
8 | #include "context.hpp" |
---|
9 | #include "context_server.hpp" |
---|
10 | #include "netCdfException.hpp" |
---|
11 | #include "exception.hpp" |
---|
12 | #include "timer.hpp" |
---|
13 | #include "uuid.hpp" |
---|
14 | namespace xios |
---|
15 | { |
---|
16 | /// ////////////////////// Dfinitions ////////////////////// /// |
---|
17 | CNc4DataOutput::CNc4DataOutput |
---|
18 | (CFile* file, const StdString & filename, bool exist) |
---|
19 | : SuperClass() |
---|
20 | , SuperClassWriter(filename, exist) |
---|
21 | , filename(filename) |
---|
22 | , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) |
---|
23 | { |
---|
24 | SuperClass::type = MULTI_FILE; |
---|
25 | compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; |
---|
26 | } |
---|
27 | |
---|
28 | CNc4DataOutput::CNc4DataOutput |
---|
29 | (CFile* file, const StdString & filename, bool exist, bool useClassicFormat, bool useCFConvention, |
---|
30 | MPI_Comm comm_file, bool multifile, bool isCollective, const StdString& timeCounterName) |
---|
31 | : SuperClass() |
---|
32 | , SuperClassWriter(filename, exist, useClassicFormat, useCFConvention, &comm_file, multifile, timeCounterName) |
---|
33 | , comm_file(comm_file) |
---|
34 | , filename(filename) |
---|
35 | , isCollective(isCollective) |
---|
36 | , file(file),hasTimeInstant(false),hasTimeCentered(false), timeCounterType(none) |
---|
37 | { |
---|
38 | SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; |
---|
39 | if (file==NULL) compressionLevel = 0 ; |
---|
40 | else compressionLevel= file->compression_level.isEmpty() ? 0 :file->compression_level ; |
---|
41 | } |
---|
42 | |
---|
43 | CNc4DataOutput::~CNc4DataOutput(void) |
---|
44 | { /* Ne rien faire de plus */ } |
---|
45 | |
---|
46 | ///-------------------------------------------------------------- |
---|
47 | |
---|
48 | const StdString & CNc4DataOutput::getFileName(void) const |
---|
49 | { |
---|
50 | return (this->filename); |
---|
51 | } |
---|
52 | |
---|
53 | //--------------------------------------------------------------- |
---|
54 | |
---|
55 | void CNc4DataOutput::writeDomain_(CDomain* domain) |
---|
56 | { |
---|
57 | StdString lonName,latName ; |
---|
58 | |
---|
59 | domain->computeWrittenIndex(); |
---|
60 | domain->computeWrittenCompressedIndex(comm_file); |
---|
61 | |
---|
62 | if (domain->type == CDomain::type_attr::unstructured) |
---|
63 | { |
---|
64 | if (SuperClassWriter::useCFConvention) |
---|
65 | writeUnstructuredDomain(domain) ; |
---|
66 | else |
---|
67 | writeUnstructuredDomainUgrid(domain) ; |
---|
68 | return ; |
---|
69 | } |
---|
70 | |
---|
71 | CContext* context = CContext::getCurrent() ; |
---|
72 | CContextServer* server=context->server ; |
---|
73 | |
---|
74 | if (domain->IsWritten(this->filename)) return; |
---|
75 | domain->checkAttributes(); |
---|
76 | |
---|
77 | if (domain->isEmpty()) |
---|
78 | if (SuperClass::type==MULTI_FILE) return; |
---|
79 | |
---|
80 | std::vector<StdString> dim0, dim1; |
---|
81 | StdString domid = domain->getDomainOutputName(); |
---|
82 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
83 | if (isWrittenDomain(domid)) return ; |
---|
84 | else setWrittenDomain(domid); |
---|
85 | |
---|
86 | int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; |
---|
87 | |
---|
88 | |
---|
89 | StdString dimXid, dimYid ; |
---|
90 | |
---|
91 | nc_type typePrec ; |
---|
92 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
93 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
94 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
95 | |
---|
96 | bool isRegularDomain = (domain->type == CDomain::type_attr::rectilinear); |
---|
97 | switch (domain->type) |
---|
98 | { |
---|
99 | case CDomain::type_attr::curvilinear : |
---|
100 | |
---|
101 | if (domain->lon_name.isEmpty()) lonName = "nav_lon"; |
---|
102 | else lonName = domain->lon_name; |
---|
103 | |
---|
104 | if (domain->lat_name.isEmpty()) latName = "nav_lat"; |
---|
105 | else latName = domain->lat_name; |
---|
106 | |
---|
107 | if (domain->dim_i_name.isEmpty()) dimXid=StdString("x").append(appendDomid); |
---|
108 | else dimXid=domain->dim_i_name.getValue() + appendDomid; |
---|
109 | |
---|
110 | if (domain->dim_j_name.isEmpty()) dimYid=StdString("y").append(appendDomid); |
---|
111 | else dimYid=domain->dim_j_name.getValue() + appendDomid; |
---|
112 | |
---|
113 | break ; |
---|
114 | |
---|
115 | case CDomain::type_attr::rectilinear : |
---|
116 | |
---|
117 | if (domain->lon_name.isEmpty()) |
---|
118 | { |
---|
119 | if (domain->dim_i_name.isEmpty()) |
---|
120 | lonName = "lon"; |
---|
121 | else |
---|
122 | lonName = domain->dim_i_name.getValue(); |
---|
123 | } |
---|
124 | else lonName = domain->lon_name; |
---|
125 | |
---|
126 | if (domain->lat_name.isEmpty()) |
---|
127 | { |
---|
128 | if (domain->dim_j_name.isEmpty()) |
---|
129 | latName = "lat"; |
---|
130 | else |
---|
131 | latName = domain->dim_j_name.getValue(); |
---|
132 | } |
---|
133 | else latName = domain->lat_name; |
---|
134 | |
---|
135 | if (domain->dim_i_name.isEmpty()) dimXid = lonName+appendDomid; |
---|
136 | else dimXid = domain->dim_i_name.getValue()+appendDomid; |
---|
137 | |
---|
138 | if (domain->dim_j_name.isEmpty()) dimYid = latName+appendDomid; |
---|
139 | else dimYid = domain->dim_j_name.getValue()+appendDomid; |
---|
140 | break; |
---|
141 | } |
---|
142 | |
---|
143 | StdString dimVertId = StdString("nvertex").append(appendDomid); |
---|
144 | |
---|
145 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
146 | string areaId = "area" + appendDomid; |
---|
147 | /* |
---|
148 | StdString lonid_loc = (server->intraCommSize > 1) |
---|
149 | ? StdString("lon").append(appendDomid).append("_local") |
---|
150 | : lonid; |
---|
151 | StdString latid_loc = (server->intraCommSize > 1) |
---|
152 | ? StdString("lat").append(appendDomid).append("_local") |
---|
153 | : latid; |
---|
154 | */ |
---|
155 | |
---|
156 | CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; |
---|
157 | int nbWritten = indexToWrite.numElements(); |
---|
158 | CArray<double,1> writtenLat, writtenLon; |
---|
159 | CArray<double,2> writtenBndsLat, writtenBndsLon; |
---|
160 | CArray<double,1> writtenArea; |
---|
161 | |
---|
162 | if (domain->hasLonLat) |
---|
163 | { |
---|
164 | writtenLat.resize(nbWritten); |
---|
165 | writtenLon.resize(nbWritten); |
---|
166 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
167 | { |
---|
168 | if (indexToWrite(idx) < 0) |
---|
169 | { |
---|
170 | writtenLat(idx) = -1.; // hole |
---|
171 | writtenLon(idx) = -1.; |
---|
172 | } |
---|
173 | else |
---|
174 | { |
---|
175 | writtenLat(idx) = domain->latvalue(indexToWrite(idx)); |
---|
176 | writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | if (domain->hasBounds) |
---|
181 | { |
---|
182 | int nvertex = domain->nvertex, idx; |
---|
183 | writtenBndsLat.resize(nvertex, nbWritten); |
---|
184 | writtenBndsLon.resize(nvertex, nbWritten); |
---|
185 | CArray<double,2>& boundslat = domain->bounds_latvalue; |
---|
186 | CArray<double,2>& boundslon = domain->bounds_lonvalue; |
---|
187 | for (idx = 0; idx < nbWritten; ++idx) |
---|
188 | for (int nv = 0; nv < nvertex; ++nv) |
---|
189 | { |
---|
190 | if (indexToWrite(idx) < 0) |
---|
191 | { |
---|
192 | writtenBndsLat(nv, idx) = -1.; // hole |
---|
193 | writtenBndsLon(nv, idx) = -1.; |
---|
194 | } |
---|
195 | else |
---|
196 | { |
---|
197 | writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); |
---|
198 | writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); |
---|
199 | } |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | if (domain->hasArea) |
---|
205 | { |
---|
206 | writtenArea.resize(nbWritten); |
---|
207 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
208 | { |
---|
209 | if (indexToWrite(idx) < 0) |
---|
210 | writtenArea(idx) = -1.; |
---|
211 | else |
---|
212 | writtenArea(idx) = domain->areavalue(indexToWrite(idx)); |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | try |
---|
217 | { |
---|
218 | switch (SuperClass::type) |
---|
219 | { |
---|
220 | case (MULTI_FILE) : |
---|
221 | { |
---|
222 | switch (domain->type) |
---|
223 | { |
---|
224 | case CDomain::type_attr::curvilinear : |
---|
225 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
226 | lonid = lonName+appendDomid; |
---|
227 | latid = latName+appendDomid; |
---|
228 | break ; |
---|
229 | case CDomain::type_attr::rectilinear : |
---|
230 | lonid = lonName+appendDomid; |
---|
231 | latid = latName+appendDomid; |
---|
232 | dim0.push_back(dimYid); |
---|
233 | dim1.push_back(dimXid); |
---|
234 | break; |
---|
235 | } |
---|
236 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
237 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
238 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
239 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
240 | |
---|
241 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni); |
---|
242 | SuperClassWriter::addDimension(dimYid, domain->zoom_nj); |
---|
243 | |
---|
244 | if (domain->hasBounds) |
---|
245 | SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
246 | |
---|
247 | if (server->intraCommSize > 1) |
---|
248 | { |
---|
249 | this->writeLocalAttributes(domain->zoom_ibegin, |
---|
250 | domain->zoom_ni, |
---|
251 | domain->zoom_jbegin, |
---|
252 | domain->zoom_nj, |
---|
253 | appendDomid); |
---|
254 | |
---|
255 | if (singleDomain) |
---|
256 | this->writeLocalAttributes_IOIPSL(dimXid, dimYid, |
---|
257 | domain->zoom_ibegin, |
---|
258 | domain->zoom_ni, |
---|
259 | domain->zoom_jbegin, |
---|
260 | domain->zoom_nj, |
---|
261 | domain->ni_glo,domain->nj_glo, |
---|
262 | server->intraCommRank,server->intraCommSize); |
---|
263 | } |
---|
264 | |
---|
265 | if (domain->hasLonLat) |
---|
266 | { |
---|
267 | switch (domain->type) |
---|
268 | { |
---|
269 | case CDomain::type_attr::curvilinear : |
---|
270 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
271 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
272 | break ; |
---|
273 | case CDomain::type_attr::rectilinear : |
---|
274 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
275 | SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); |
---|
276 | break ; |
---|
277 | } |
---|
278 | |
---|
279 | this->writeAxisAttributes(lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid); |
---|
280 | this->writeAxisAttributes(latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid); |
---|
281 | |
---|
282 | if (domain->hasBounds) |
---|
283 | { |
---|
284 | SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid); |
---|
285 | SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); |
---|
286 | |
---|
287 | dim0.clear(); |
---|
288 | dim0.push_back(dimYid); |
---|
289 | dim0.push_back(dimXid); |
---|
290 | dim0.push_back(dimVertId); |
---|
291 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
292 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | dim0.clear(); |
---|
297 | dim0.push_back(dimYid); |
---|
298 | dim0.push_back(dimXid); |
---|
299 | |
---|
300 | |
---|
301 | // supress mask if (server->intraCommSize > 1) |
---|
302 | // supress mask { |
---|
303 | // supress mask SuperClassWriter::addVariable(maskid, NC_INT, dim0); |
---|
304 | // supress mask |
---|
305 | // supress mask this->writeMaskAttributes(maskid, |
---|
306 | // supress mask domain->data_dim.getValue()/*, |
---|
307 | // supress mask domain->data_ni.getValue(), |
---|
308 | // supress mask domain->data_nj.getValue(), |
---|
309 | // supress mask domain->data_ibegin.getValue(), |
---|
310 | // supress mask domain->data_jbegin.getValue()*/); |
---|
311 | // supress mask } |
---|
312 | |
---|
313 | //SuperClassWriter::setDefaultValue(maskid, &dvm); |
---|
314 | |
---|
315 | if (domain->hasArea) |
---|
316 | { |
---|
317 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
318 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
319 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
320 | } |
---|
321 | |
---|
322 | SuperClassWriter::definition_end(); |
---|
323 | |
---|
324 | if (domain->hasLonLat) |
---|
325 | { |
---|
326 | switch (domain->type) |
---|
327 | { |
---|
328 | case CDomain::type_attr::curvilinear : |
---|
329 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); |
---|
330 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); |
---|
331 | break; |
---|
332 | case CDomain::type_attr::rectilinear : |
---|
333 | CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)) ; |
---|
334 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); |
---|
335 | CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)) ; |
---|
336 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); |
---|
337 | break; |
---|
338 | } |
---|
339 | |
---|
340 | if (domain->hasBounds) |
---|
341 | { |
---|
342 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); |
---|
343 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); |
---|
344 | } |
---|
345 | } |
---|
346 | |
---|
347 | if (domain->hasArea) |
---|
348 | { |
---|
349 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); |
---|
350 | } |
---|
351 | |
---|
352 | SuperClassWriter::definition_start(); |
---|
353 | |
---|
354 | break; |
---|
355 | } |
---|
356 | case (ONE_FILE) : |
---|
357 | { |
---|
358 | SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni); |
---|
359 | SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj); |
---|
360 | |
---|
361 | if (domain->hasBounds) |
---|
362 | SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
363 | |
---|
364 | if (domain->hasLonLat) |
---|
365 | { |
---|
366 | switch (domain->type) |
---|
367 | { |
---|
368 | case CDomain::type_attr::curvilinear : |
---|
369 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
370 | lonid = lonName+appendDomid; |
---|
371 | latid = latName+appendDomid; |
---|
372 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
373 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
374 | break; |
---|
375 | |
---|
376 | case CDomain::type_attr::rectilinear : |
---|
377 | dim0.push_back(dimYid); |
---|
378 | dim1.push_back(dimXid); |
---|
379 | lonid = lonName+appendDomid; |
---|
380 | latid = latName+appendDomid; |
---|
381 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
382 | SuperClassWriter::addVariable(lonid, typePrec, dim1, compressionLevel); |
---|
383 | break; |
---|
384 | } |
---|
385 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
386 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
387 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
388 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
389 | |
---|
390 | this->writeAxisAttributes |
---|
391 | (lonid, isRegularDomain ? "X" : "", "longitude", "Longitude", "degrees_east", domid); |
---|
392 | this->writeAxisAttributes |
---|
393 | (latid, isRegularDomain ? "Y" : "", "latitude", "Latitude", "degrees_north", domid); |
---|
394 | |
---|
395 | if (domain->hasBounds) |
---|
396 | { |
---|
397 | SuperClassWriter::addAttribute("bounds", bounds_lonid, &lonid); |
---|
398 | SuperClassWriter::addAttribute("bounds", bounds_latid, &latid); |
---|
399 | |
---|
400 | dim0.clear(); |
---|
401 | dim0.push_back(dimYid); |
---|
402 | dim0.push_back(dimXid); |
---|
403 | dim0.push_back(dimVertId); |
---|
404 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
405 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | if (domain->hasArea) |
---|
410 | { |
---|
411 | dim0.clear(); |
---|
412 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
413 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
414 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
415 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
416 | dim0.clear(); |
---|
417 | } |
---|
418 | |
---|
419 | SuperClassWriter::definition_end(); |
---|
420 | |
---|
421 | switch (domain->type) |
---|
422 | { |
---|
423 | case CDomain::type_attr::curvilinear : |
---|
424 | { |
---|
425 | std::vector<StdSize> start(2) ; |
---|
426 | std::vector<StdSize> count(2) ; |
---|
427 | // Comment out because it is not working for a hole |
---|
428 | // if (domain->isEmpty()) |
---|
429 | // { |
---|
430 | // start[0]=0 ; start[1]=0 ; |
---|
431 | // count[0]=0 ; count[1]=0 ; |
---|
432 | // } |
---|
433 | // else |
---|
434 | { |
---|
435 | start[1]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
436 | start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; |
---|
437 | count[1]=domain->zoom_ni ; count[0]=domain->zoom_nj ; |
---|
438 | } |
---|
439 | |
---|
440 | if (domain->hasLonLat) |
---|
441 | { |
---|
442 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
443 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
444 | } |
---|
445 | break; |
---|
446 | } |
---|
447 | case CDomain::type_attr::rectilinear : |
---|
448 | { |
---|
449 | if (domain->hasLonLat) |
---|
450 | { |
---|
451 | std::vector<StdSize> start(1) ; |
---|
452 | std::vector<StdSize> count(1) ; |
---|
453 | if (domain->isEmpty()) |
---|
454 | { |
---|
455 | start[0]=0 ; |
---|
456 | count[0]=0 ; |
---|
457 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
458 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
459 | } |
---|
460 | else |
---|
461 | { |
---|
462 | start[0]=domain->zoom_jbegin-domain->global_zoom_jbegin; |
---|
463 | count[0]=domain->zoom_nj; |
---|
464 | CArray<double,1> lat = writtenLat(Range(fromStart,toEnd,domain->zoom_ni)); |
---|
465 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); |
---|
466 | |
---|
467 | start[0]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
468 | count[0]=domain->zoom_ni; |
---|
469 | CArray<double,1> lon = writtenLon(Range(0,domain->zoom_ni-1)); |
---|
470 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); |
---|
471 | } |
---|
472 | } |
---|
473 | break; |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | if (domain->hasBounds) |
---|
478 | { |
---|
479 | std::vector<StdSize> start(3); |
---|
480 | std::vector<StdSize> count(3); |
---|
481 | if (domain->isEmpty()) |
---|
482 | { |
---|
483 | start[2] = start[1] = start[0] = 0; |
---|
484 | count[2] = count[1] = count[0] = 0; |
---|
485 | } |
---|
486 | else |
---|
487 | { |
---|
488 | start[2] = 0; |
---|
489 | start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
490 | start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin; |
---|
491 | count[2] = domain->nvertex; |
---|
492 | count[1] = domain->zoom_ni; |
---|
493 | count[0] = domain->zoom_nj; |
---|
494 | } |
---|
495 | |
---|
496 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0, &start, &count); |
---|
497 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0, &start, &count); |
---|
498 | } |
---|
499 | |
---|
500 | if (domain->hasArea) |
---|
501 | { |
---|
502 | std::vector<StdSize> start(2); |
---|
503 | std::vector<StdSize> count(2); |
---|
504 | |
---|
505 | if (domain->isEmpty()) |
---|
506 | { |
---|
507 | start[0] = 0; start[1] = 0; |
---|
508 | count[0] = 0; count[1] = 0; |
---|
509 | } |
---|
510 | else |
---|
511 | { |
---|
512 | start[1] = domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
513 | start[0] = domain->zoom_jbegin - domain->global_zoom_jbegin; |
---|
514 | count[1] = domain->zoom_ni; |
---|
515 | count[0] = domain->zoom_nj; |
---|
516 | } |
---|
517 | |
---|
518 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); |
---|
519 | } |
---|
520 | |
---|
521 | SuperClassWriter::definition_start(); |
---|
522 | break; |
---|
523 | } |
---|
524 | default : |
---|
525 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
526 | << "[ type = " << SuperClass::type << "]" |
---|
527 | << " not implemented yet !"); |
---|
528 | } |
---|
529 | } |
---|
530 | catch (CNetCdfException& e) |
---|
531 | { |
---|
532 | StdString msg("On writing the domain : "); |
---|
533 | msg.append(domid); msg.append("\n"); |
---|
534 | msg.append("In the context : "); |
---|
535 | msg.append(context->getId()); msg.append("\n"); |
---|
536 | msg.append(e.what()); |
---|
537 | ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg); |
---|
538 | } |
---|
539 | |
---|
540 | domain->addRelFile(this->filename); |
---|
541 | } |
---|
542 | |
---|
543 | //-------------------------------------------------------------- |
---|
544 | |
---|
545 | void CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain) |
---|
546 | { |
---|
547 | CContext* context = CContext::getCurrent() ; |
---|
548 | CContextServer* server=context->server ; |
---|
549 | |
---|
550 | if (domain->IsWritten(this->filename)) return; |
---|
551 | |
---|
552 | StdString domid = domain->getDomainOutputName(); |
---|
553 | |
---|
554 | // The first domain for the same mesh that will be written is that with the highest value of nvertex. |
---|
555 | // Thus the entire mesh connectivity will be generated at once. |
---|
556 | if (isWrittenDomain(domid)) return ; |
---|
557 | else setWrittenDomain(domid); |
---|
558 | |
---|
559 | domain->checkAttributes(); |
---|
560 | if (domain->isEmpty()) |
---|
561 | if (SuperClass::type==MULTI_FILE) return ; |
---|
562 | |
---|
563 | nc_type typePrec ; |
---|
564 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
565 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
566 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
567 | |
---|
568 | std::vector<StdString> dim0; |
---|
569 | StdString domainName = domain->name; |
---|
570 | domain->assignMesh(domainName, domain->nvertex); |
---|
571 | domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); |
---|
572 | |
---|
573 | StdString node_x = domainName + "_node_x"; |
---|
574 | StdString node_y = domainName + "_node_y"; |
---|
575 | |
---|
576 | StdString edge_x = domainName + "_edge_x"; |
---|
577 | StdString edge_y = domainName + "_edge_y"; |
---|
578 | StdString edge_nodes = domainName + "_edge_nodes"; |
---|
579 | |
---|
580 | StdString face_x = domainName + "_face_x"; |
---|
581 | StdString face_y = domainName + "_face_y"; |
---|
582 | StdString face_nodes = domainName + "_face_nodes"; |
---|
583 | StdString face_edges = domainName + "_face_edges"; |
---|
584 | StdString edge_faces = domainName + "_edge_face_links"; |
---|
585 | StdString face_faces = domainName + "_face_links"; |
---|
586 | |
---|
587 | StdString dimNode = "n" + domainName + "_node"; |
---|
588 | StdString dimEdge = "n" + domainName + "_edge"; |
---|
589 | StdString dimFace = "n" + domainName + "_face"; |
---|
590 | StdString dimVertex = "n" + domainName + "_vertex"; |
---|
591 | StdString dimTwo = "Two"; |
---|
592 | |
---|
593 | if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); |
---|
594 | dim0.clear(); |
---|
595 | SuperClassWriter::addVariable(domainName, NC_INT, dim0, compressionLevel); |
---|
596 | SuperClassWriter::addAttribute("cf_role", StdString("mesh_topology"), &domainName); |
---|
597 | SuperClassWriter::addAttribute("long_name", StdString("Topology data of 2D unstructured mesh"), &domainName); |
---|
598 | SuperClassWriter::addAttribute("topology_dimension", 2, &domainName); |
---|
599 | SuperClassWriter::addAttribute("node_coordinates", node_x + " " + node_y, &domainName); |
---|
600 | |
---|
601 | try |
---|
602 | { |
---|
603 | switch (SuperClass::type) |
---|
604 | { |
---|
605 | case (ONE_FILE) : |
---|
606 | { |
---|
607 | // Adding nodes |
---|
608 | if (domain->nvertex == 1) |
---|
609 | { |
---|
610 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
611 | { |
---|
612 | SuperClassWriter::addDimension(dimNode, domain->ni_glo); |
---|
613 | dim0.clear(); |
---|
614 | dim0.push_back(dimNode); |
---|
615 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
616 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
617 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
618 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
619 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
620 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
621 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
622 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
623 | } |
---|
624 | } // domain->nvertex == 1 |
---|
625 | |
---|
626 | // Adding edges and nodes, if nodes have not been defined previously |
---|
627 | if (domain->nvertex == 2) |
---|
628 | { |
---|
629 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
630 | { |
---|
631 | SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo); |
---|
632 | dim0.clear(); |
---|
633 | dim0.push_back(dimNode); |
---|
634 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
635 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
636 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
637 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
638 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
639 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
640 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
641 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
642 | } |
---|
643 | SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); |
---|
644 | SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); |
---|
645 | SuperClassWriter::addDimension(dimEdge, domain->ni_glo); |
---|
646 | dim0.clear(); |
---|
647 | dim0.push_back(dimEdge); |
---|
648 | SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); |
---|
649 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); |
---|
650 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); |
---|
651 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); |
---|
652 | SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); |
---|
653 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); |
---|
654 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); |
---|
655 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); |
---|
656 | dim0.clear(); |
---|
657 | dim0.push_back(dimEdge); |
---|
658 | dim0.push_back(dimTwo); |
---|
659 | SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); |
---|
660 | SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); |
---|
661 | SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); |
---|
662 | SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); |
---|
663 | } // domain->nvertex == 2 |
---|
664 | |
---|
665 | // Adding faces, edges, and nodes, if edges and nodes have not been defined previously |
---|
666 | if (domain->nvertex > 2) |
---|
667 | { |
---|
668 | // Nodes |
---|
669 | if (!SuperClassWriter::varExist(node_x) || !SuperClassWriter::varExist(node_y)) |
---|
670 | { |
---|
671 | SuperClassWriter::addDimension(dimNode, domain->mesh->nbNodesGlo); |
---|
672 | dim0.clear(); |
---|
673 | dim0.push_back(dimNode); |
---|
674 | SuperClassWriter::addVariable(node_x, typePrec, dim0, compressionLevel); |
---|
675 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &node_x); |
---|
676 | SuperClassWriter::addAttribute("long_name", StdString("Longitude of mesh nodes."), &node_x); |
---|
677 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &node_x); |
---|
678 | SuperClassWriter::addVariable(node_y, typePrec, dim0, compressionLevel); |
---|
679 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &node_y); |
---|
680 | SuperClassWriter::addAttribute("long_name", StdString("Latitude of mesh nodes."), &node_y); |
---|
681 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &node_y); |
---|
682 | } |
---|
683 | if (!SuperClassWriter::varExist(edge_x) || !SuperClassWriter::varExist(edge_y)) |
---|
684 | { |
---|
685 | SuperClassWriter::addAttribute("edge_coordinates", edge_x + " " + edge_y, &domainName); |
---|
686 | SuperClassWriter::addAttribute("edge_node_connectivity", edge_nodes, &domainName); |
---|
687 | SuperClassWriter::addDimension(dimEdge, domain->mesh->nbEdgesGlo); |
---|
688 | dim0.clear(); |
---|
689 | dim0.push_back(dimEdge); |
---|
690 | SuperClassWriter::addVariable(edge_x, typePrec, dim0, compressionLevel); |
---|
691 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &edge_x); |
---|
692 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh edges."), &edge_x); |
---|
693 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &edge_x); |
---|
694 | SuperClassWriter::addVariable(edge_y, typePrec, dim0, compressionLevel); |
---|
695 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &edge_y); |
---|
696 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh edges."), &edge_y); |
---|
697 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &edge_y); |
---|
698 | dim0.clear(); |
---|
699 | dim0.push_back(dimEdge); |
---|
700 | dim0.push_back(dimTwo); |
---|
701 | SuperClassWriter::addVariable(edge_nodes, NC_INT, dim0, compressionLevel); |
---|
702 | SuperClassWriter::addAttribute("cf_role", StdString("edge_node_connectivity"), &edge_nodes); |
---|
703 | SuperClassWriter::addAttribute("long_name", StdString("Maps every edge/link to two nodes that it connects."), &edge_nodes); |
---|
704 | SuperClassWriter::addAttribute("start_index", 0, &edge_nodes); |
---|
705 | } |
---|
706 | SuperClassWriter::addAttribute("face_coordinates", face_x + " " + face_y, &domainName); |
---|
707 | SuperClassWriter::addAttribute("face_node_connectivity", face_nodes, &domainName); |
---|
708 | SuperClassWriter::addDimension(dimFace, domain->ni_glo); |
---|
709 | SuperClassWriter::addDimension(dimVertex, domain->nvertex); |
---|
710 | dim0.clear(); |
---|
711 | dim0.push_back(dimFace); |
---|
712 | SuperClassWriter::addVariable(face_x, typePrec, dim0, compressionLevel); |
---|
713 | SuperClassWriter::addAttribute("standard_name", StdString("longitude"), &face_x); |
---|
714 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic longitude of mesh faces."), &face_x); |
---|
715 | SuperClassWriter::addAttribute("units", StdString("degrees_east"), &face_x); |
---|
716 | SuperClassWriter::addVariable(face_y, typePrec, dim0, compressionLevel); |
---|
717 | SuperClassWriter::addAttribute("standard_name", StdString("latitude"), &face_y); |
---|
718 | SuperClassWriter::addAttribute("long_name", StdString("Characteristic latitude of mesh faces."), &face_y); |
---|
719 | SuperClassWriter::addAttribute("units", StdString("degrees_north"), &face_y); |
---|
720 | dim0.clear(); |
---|
721 | dim0.push_back(dimFace); |
---|
722 | dim0.push_back(dimVertex); |
---|
723 | SuperClassWriter::addVariable(face_nodes, NC_INT, dim0, compressionLevel); |
---|
724 | SuperClassWriter::addAttribute("cf_role", StdString("face_node_connectivity"), &face_nodes); |
---|
725 | SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its corner nodes."), &face_nodes); |
---|
726 | SuperClassWriter::addAttribute("start_index", 0, &face_nodes); |
---|
727 | dim0.clear(); |
---|
728 | dim0.push_back(dimFace); |
---|
729 | dim0.push_back(dimVertex); |
---|
730 | SuperClassWriter::addVariable(face_edges, NC_INT, dim0, compressionLevel); |
---|
731 | SuperClassWriter::addAttribute("cf_role", StdString("face_edge_connectivity"), &face_edges); |
---|
732 | SuperClassWriter::addAttribute("long_name", StdString("Maps every face to its edges."), &face_edges); |
---|
733 | SuperClassWriter::addAttribute("start_index", 0, &face_edges); |
---|
734 | SuperClassWriter::addAttribute("_FillValue", 999999, &face_edges); |
---|
735 | dim0.clear(); |
---|
736 | dim0.push_back(dimEdge); |
---|
737 | dim0.push_back(dimTwo); |
---|
738 | SuperClassWriter::addVariable(edge_faces, NC_INT, dim0, compressionLevel); |
---|
739 | SuperClassWriter::addAttribute("cf_role", StdString("edge_face connectivity"), &edge_faces); |
---|
740 | SuperClassWriter::addAttribute("long_name", StdString("neighbor faces for edges"), &edge_faces); |
---|
741 | SuperClassWriter::addAttribute("start_index", 0, &edge_faces); |
---|
742 | SuperClassWriter::addAttribute("_FillValue", -999, &edge_faces); |
---|
743 | SuperClassWriter::addAttribute("comment", StdString("missing neighbor faces are indicated using _FillValue"), &edge_faces); |
---|
744 | dim0.clear(); |
---|
745 | dim0.push_back(dimFace); |
---|
746 | dim0.push_back(dimVertex); |
---|
747 | SuperClassWriter::addVariable(face_faces, NC_INT, dim0, compressionLevel); |
---|
748 | SuperClassWriter::addAttribute("cf_role", StdString("face_face connectivity"), &face_faces); |
---|
749 | SuperClassWriter::addAttribute("long_name", StdString("Indicates which other faces neighbor each face"), &face_faces); |
---|
750 | SuperClassWriter::addAttribute("start_index", 0, &face_faces); |
---|
751 | SuperClassWriter::addAttribute("_FillValue", 999999, &face_faces); |
---|
752 | SuperClassWriter::addAttribute("flag_values", -1, &face_faces); |
---|
753 | SuperClassWriter::addAttribute("flag_meanings", StdString("out_of_mesh"), &face_faces); |
---|
754 | } // domain->nvertex > 2 |
---|
755 | |
---|
756 | SuperClassWriter::definition_end(); |
---|
757 | |
---|
758 | std::vector<StdSize> startEdges(1) ; |
---|
759 | std::vector<StdSize> countEdges(1) ; |
---|
760 | std::vector<StdSize> startNodes(1) ; |
---|
761 | std::vector<StdSize> countNodes(1) ; |
---|
762 | std::vector<StdSize> startFaces(1) ; |
---|
763 | std::vector<StdSize> countFaces(1) ; |
---|
764 | std::vector<StdSize> startEdgeNodes(2) ; |
---|
765 | std::vector<StdSize> countEdgeNodes(2) ; |
---|
766 | std::vector<StdSize> startEdgeFaces(2) ; |
---|
767 | std::vector<StdSize> countEdgeFaces(2) ; |
---|
768 | std::vector<StdSize> startFaceConctv(2) ; |
---|
769 | std::vector<StdSize> countFaceConctv(2) ; |
---|
770 | |
---|
771 | if (domain->nvertex == 1) |
---|
772 | { |
---|
773 | if (domain->isEmpty()) |
---|
774 | { |
---|
775 | startNodes[0]=0 ; |
---|
776 | countNodes[0]=0 ; |
---|
777 | } |
---|
778 | else |
---|
779 | { |
---|
780 | startNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
781 | countNodes[0] = domain->zoom_ni ; |
---|
782 | } |
---|
783 | |
---|
784 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
785 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
786 | } |
---|
787 | else if (domain->nvertex == 2) |
---|
788 | { |
---|
789 | if (domain->isEmpty()) |
---|
790 | { |
---|
791 | startEdges[0]=0 ; |
---|
792 | countEdges[0]=0 ; |
---|
793 | startNodes[0]=0 ; |
---|
794 | countNodes[0]=0 ; |
---|
795 | startEdgeNodes[0]=0; |
---|
796 | startEdgeNodes[1]=0; |
---|
797 | countEdgeNodes[0]=0; |
---|
798 | countEdgeNodes[1]=0; |
---|
799 | |
---|
800 | } |
---|
801 | else |
---|
802 | { |
---|
803 | startEdges[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
804 | countEdges[0] = domain->zoom_ni; |
---|
805 | startNodes[0] = domain->mesh->node_start; |
---|
806 | countNodes[0] = domain->mesh->node_count; |
---|
807 | startEdgeNodes[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
808 | startEdgeNodes[1] = 0; |
---|
809 | countEdgeNodes[0] = domain->zoom_ni; |
---|
810 | countEdgeNodes[1] = 2; |
---|
811 | } |
---|
812 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
813 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
814 | SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); |
---|
815 | SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); |
---|
816 | SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); |
---|
817 | } |
---|
818 | else |
---|
819 | { |
---|
820 | if (domain->isEmpty()) |
---|
821 | { |
---|
822 | startFaces[0] = 0 ; |
---|
823 | countFaces[0] = 0 ; |
---|
824 | startNodes[0] = 0; |
---|
825 | countNodes[0] = 0; |
---|
826 | startEdges[0] = 0; |
---|
827 | countEdges[0] = 0; |
---|
828 | startEdgeFaces[0] = 0; |
---|
829 | startEdgeFaces[1] = 0; |
---|
830 | countEdgeFaces[0] = 0; |
---|
831 | countEdgeFaces[1] = 0; |
---|
832 | startFaceConctv[0] = 0; |
---|
833 | startFaceConctv[1] = 0; |
---|
834 | countFaceConctv[0] = 0; |
---|
835 | countFaceConctv[1] = 0; |
---|
836 | } |
---|
837 | else |
---|
838 | { |
---|
839 | startFaces[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
840 | countFaces[0] = domain->zoom_ni ; |
---|
841 | startNodes[0] = domain->mesh->node_start; |
---|
842 | countNodes[0] = domain->mesh->node_count; |
---|
843 | startEdges[0] = domain->mesh->edge_start; |
---|
844 | countEdges[0] = domain->mesh->edge_count; |
---|
845 | startEdgeNodes[0] = domain->mesh->edge_start; |
---|
846 | startEdgeNodes[1] = 0; |
---|
847 | countEdgeNodes[0] = domain->mesh->edge_count; |
---|
848 | countEdgeNodes[1]= 2; |
---|
849 | startEdgeFaces[0] = domain->mesh->edge_start; |
---|
850 | startEdgeFaces[1]= 0; |
---|
851 | countEdgeFaces[0] = domain->mesh->edge_count; |
---|
852 | countEdgeFaces[1]= 2; |
---|
853 | startFaceConctv[0] = domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
854 | startFaceConctv[1] = 0; |
---|
855 | countFaceConctv[0] = domain->zoom_ni; |
---|
856 | countFaceConctv[1] = domain->nvertex; |
---|
857 | } |
---|
858 | SuperClassWriter::writeData(domain->mesh->node_lat, node_y, isCollective, 0, &startNodes, &countNodes); |
---|
859 | SuperClassWriter::writeData(domain->mesh->node_lon, node_x, isCollective, 0, &startNodes, &countNodes); |
---|
860 | SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); |
---|
861 | SuperClassWriter::writeData(domain->mesh->edge_lon, edge_x, isCollective, 0, &startEdges, &countEdges); |
---|
862 | SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); |
---|
863 | SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); |
---|
864 | SuperClassWriter::writeData(domain->mesh->face_lon, face_x, isCollective, 0, &startFaces, &countFaces); |
---|
865 | SuperClassWriter::writeData(domain->mesh->face_nodes, face_nodes, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
866 | SuperClassWriter::writeData(domain->mesh->face_edges, face_edges, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
867 | SuperClassWriter::writeData(domain->mesh->edge_faces, edge_faces, isCollective, 0, &startEdgeFaces, &countEdgeFaces); |
---|
868 | SuperClassWriter::writeData(domain->mesh->face_faces, face_faces, isCollective, 0, &startFaceConctv, &countFaceConctv); |
---|
869 | } |
---|
870 | SuperClassWriter::definition_start(); |
---|
871 | |
---|
872 | break; |
---|
873 | } // ONE_FILE |
---|
874 | |
---|
875 | case (MULTI_FILE) : |
---|
876 | { |
---|
877 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
878 | << "[ type = multiple_file ]" |
---|
879 | << " is not yet implemented for UGRID files !"); |
---|
880 | break; |
---|
881 | } |
---|
882 | |
---|
883 | default : |
---|
884 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
885 | << "[ type = " << SuperClass::type << "]" |
---|
886 | << " not implemented yet !"); |
---|
887 | } // switch |
---|
888 | } // try |
---|
889 | |
---|
890 | catch (CNetCdfException& e) |
---|
891 | { |
---|
892 | StdString msg("On writing the domain : "); |
---|
893 | msg.append(domid); msg.append("\n"); |
---|
894 | msg.append("In the context : "); |
---|
895 | msg.append(context->getId()); msg.append("\n"); |
---|
896 | msg.append(e.what()); |
---|
897 | ERROR("CNc4DataOutput::writeUnstructuredDomainUgrid(CDomain* domain)", << msg); |
---|
898 | } |
---|
899 | |
---|
900 | domain->addRelFile(this->filename); |
---|
901 | } |
---|
902 | |
---|
903 | //-------------------------------------------------------------- |
---|
904 | |
---|
905 | void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain) |
---|
906 | { |
---|
907 | CContext* context = CContext::getCurrent() ; |
---|
908 | CContextServer* server=context->server ; |
---|
909 | |
---|
910 | if (domain->IsWritten(this->filename)) return; |
---|
911 | domain->checkAttributes(); |
---|
912 | |
---|
913 | if (domain->isEmpty()) |
---|
914 | if (SuperClass::type==MULTI_FILE) return ; |
---|
915 | |
---|
916 | std::vector<StdString> dim0, dim1; |
---|
917 | StdString domid = domain->getDomainOutputName(); |
---|
918 | if (isWrittenDomain(domid)) return ; |
---|
919 | else setWrittenDomain(domid); |
---|
920 | |
---|
921 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
922 | |
---|
923 | StdString lonName,latName, cellName ; |
---|
924 | if (domain->lon_name.isEmpty()) lonName = "lon"; |
---|
925 | else lonName = domain->lon_name; |
---|
926 | |
---|
927 | if (domain->lat_name.isEmpty()) latName = "lat"; |
---|
928 | else latName = domain->lat_name; |
---|
929 | |
---|
930 | if (!domain->dim_i_name.isEmpty()) cellName=domain->dim_i_name; |
---|
931 | else cellName="cell"; |
---|
932 | StdString dimXid = cellName+appendDomid; |
---|
933 | StdString dimVertId = StdString("nvertex").append(appendDomid); |
---|
934 | |
---|
935 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
936 | string areaId = "area" + appendDomid; |
---|
937 | |
---|
938 | nc_type typePrec ; |
---|
939 | if (domain->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
940 | else if (domain->prec==4) typePrec = NC_FLOAT ; |
---|
941 | else if (domain->prec==8) typePrec = NC_DOUBLE ; |
---|
942 | |
---|
943 | int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; |
---|
944 | |
---|
945 | CArray<int, 1>& indexToWrite = domain->localIndexToWriteOnServer; |
---|
946 | int nbWritten = indexToWrite.numElements(); |
---|
947 | CArray<double,1> writtenLat, writtenLon; |
---|
948 | CArray<double,2> writtenBndsLat, writtenBndsLon; |
---|
949 | CArray<double,1> writtenArea; |
---|
950 | |
---|
951 | if (domain->hasLonLat) |
---|
952 | { |
---|
953 | writtenLat.resize(nbWritten); |
---|
954 | writtenLon.resize(nbWritten); |
---|
955 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
956 | { |
---|
957 | if (indexToWrite(idx) < 0) |
---|
958 | { |
---|
959 | writtenLat(idx) = -1.; |
---|
960 | writtenLon(idx) = -1.; |
---|
961 | } |
---|
962 | else |
---|
963 | { |
---|
964 | writtenLat(idx) = domain->latvalue(indexToWrite(idx)); |
---|
965 | writtenLon(idx) = domain->lonvalue(indexToWrite(idx)); |
---|
966 | } |
---|
967 | } |
---|
968 | } |
---|
969 | |
---|
970 | if (domain->hasBounds) |
---|
971 | { |
---|
972 | int nvertex = domain->nvertex, idx; |
---|
973 | writtenBndsLat.resize(nvertex, nbWritten); |
---|
974 | writtenBndsLon.resize(nvertex, nbWritten); |
---|
975 | CArray<double,2>& boundslat = domain->bounds_latvalue; |
---|
976 | CArray<double,2>& boundslon = domain->bounds_lonvalue; |
---|
977 | for (idx = 0; idx < nbWritten; ++idx) |
---|
978 | { |
---|
979 | for (int nv = 0; nv < nvertex; ++nv) |
---|
980 | { |
---|
981 | if (indexToWrite(idx) < 0) |
---|
982 | { |
---|
983 | writtenBndsLat(nv, idx) = -1.; |
---|
984 | writtenBndsLon(nv, idx) = -1.; |
---|
985 | } |
---|
986 | else |
---|
987 | { |
---|
988 | writtenBndsLat(nv, idx) = boundslat(nv, int(indexToWrite(idx))); |
---|
989 | writtenBndsLon(nv, idx) = boundslon(nv, int(indexToWrite(idx))); |
---|
990 | } |
---|
991 | } |
---|
992 | } |
---|
993 | } |
---|
994 | |
---|
995 | if (domain->hasArea) |
---|
996 | { |
---|
997 | writtenArea.resize(nbWritten); |
---|
998 | for (int idx = 0; idx < nbWritten; ++idx) |
---|
999 | { |
---|
1000 | if (indexToWrite(idx) < 0) |
---|
1001 | writtenArea(idx) = -1.; |
---|
1002 | else |
---|
1003 | writtenArea(idx) = domain->areavalue(indexToWrite(idx)); |
---|
1004 | } |
---|
1005 | } |
---|
1006 | |
---|
1007 | try |
---|
1008 | { |
---|
1009 | switch (SuperClass::type) |
---|
1010 | { |
---|
1011 | case (MULTI_FILE) : |
---|
1012 | { |
---|
1013 | dim0.push_back(dimXid); |
---|
1014 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni); |
---|
1015 | |
---|
1016 | lonid = lonName+appendDomid; |
---|
1017 | latid = latName+appendDomid; |
---|
1018 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
1019 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
1020 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
1021 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
1022 | |
---|
1023 | if (domain->hasLonLat) |
---|
1024 | { |
---|
1025 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
1026 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
1027 | this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); |
---|
1028 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
1029 | this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); |
---|
1030 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
1031 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
1032 | } |
---|
1033 | dim0.clear(); |
---|
1034 | if (domain->hasBounds) |
---|
1035 | { |
---|
1036 | dim0.push_back(dimXid); |
---|
1037 | dim0.push_back(dimVertId); |
---|
1038 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
1039 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
1040 | } |
---|
1041 | |
---|
1042 | dim0.clear(); |
---|
1043 | dim0.push_back(dimXid); |
---|
1044 | if (domain->hasArea) |
---|
1045 | { |
---|
1046 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
1047 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
1048 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
1049 | } |
---|
1050 | |
---|
1051 | SuperClassWriter::definition_end(); |
---|
1052 | |
---|
1053 | if (domain->hasLonLat) |
---|
1054 | { |
---|
1055 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0); |
---|
1056 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0); |
---|
1057 | if (domain->hasBounds) |
---|
1058 | { |
---|
1059 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0); |
---|
1060 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0); |
---|
1061 | } |
---|
1062 | } |
---|
1063 | |
---|
1064 | if (domain->hasArea) |
---|
1065 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0); |
---|
1066 | |
---|
1067 | SuperClassWriter::definition_start(); |
---|
1068 | break ; |
---|
1069 | } |
---|
1070 | |
---|
1071 | case (ONE_FILE) : |
---|
1072 | { |
---|
1073 | lonid = lonName+appendDomid; |
---|
1074 | latid = latName+appendDomid; |
---|
1075 | if (!domain->bounds_lon_name.isEmpty()) bounds_lonid = domain->bounds_lon_name; |
---|
1076 | else bounds_lonid = "bounds_"+lonName+appendDomid; |
---|
1077 | if (!domain->bounds_lat_name.isEmpty()) bounds_latid = domain->bounds_lat_name; |
---|
1078 | else bounds_latid = "bounds_"+latName+appendDomid; |
---|
1079 | |
---|
1080 | dim0.push_back(dimXid); |
---|
1081 | SuperClassWriter::addDimension(dimXid, domain->ni_glo); |
---|
1082 | if (domain->hasLonLat) |
---|
1083 | { |
---|
1084 | SuperClassWriter::addVariable(latid, typePrec, dim0, compressionLevel); |
---|
1085 | SuperClassWriter::addVariable(lonid, typePrec, dim0, compressionLevel); |
---|
1086 | |
---|
1087 | this->writeAxisAttributes(lonid, "", "longitude", "Longitude", "degrees_east", domid); |
---|
1088 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
1089 | this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); |
---|
1090 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
1091 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, nvertex); |
---|
1092 | } |
---|
1093 | dim0.clear(); |
---|
1094 | |
---|
1095 | if (domain->hasBounds) |
---|
1096 | { |
---|
1097 | dim0.push_back(dimXid); |
---|
1098 | dim0.push_back(dimVertId); |
---|
1099 | SuperClassWriter::addVariable(bounds_lonid, typePrec, dim0, compressionLevel); |
---|
1100 | SuperClassWriter::addVariable(bounds_latid, typePrec, dim0, compressionLevel); |
---|
1101 | } |
---|
1102 | |
---|
1103 | if (domain->hasArea) |
---|
1104 | { |
---|
1105 | dim0.clear(); |
---|
1106 | dim0.push_back(dimXid); |
---|
1107 | SuperClassWriter::addVariable(areaId, typePrec, dim0, compressionLevel); |
---|
1108 | SuperClassWriter::addAttribute("standard_name", StdString("cell_area"), &areaId); |
---|
1109 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
1110 | } |
---|
1111 | |
---|
1112 | SuperClassWriter::definition_end(); |
---|
1113 | |
---|
1114 | std::vector<StdSize> start(1), startBounds(2) ; |
---|
1115 | std::vector<StdSize> count(1), countBounds(2) ; |
---|
1116 | if (domain->isEmpty()) |
---|
1117 | { |
---|
1118 | start[0]=0 ; |
---|
1119 | count[0]=0 ; |
---|
1120 | startBounds[1]=0 ; |
---|
1121 | countBounds[1]=nvertex ; |
---|
1122 | startBounds[0]=0 ; |
---|
1123 | countBounds[0]=0 ; |
---|
1124 | } |
---|
1125 | else |
---|
1126 | { |
---|
1127 | start[0]=domain->zoom_ibegin - domain->global_zoom_ibegin; |
---|
1128 | count[0]=domain->zoom_ni; |
---|
1129 | startBounds[0]=domain->zoom_ibegin-domain->global_zoom_ibegin; |
---|
1130 | startBounds[1]=0 ; |
---|
1131 | countBounds[0]=domain->zoom_ni; |
---|
1132 | countBounds[1]=nvertex ; |
---|
1133 | } |
---|
1134 | |
---|
1135 | if (domain->hasLonLat) |
---|
1136 | { |
---|
1137 | SuperClassWriter::writeData(writtenLat, latid, isCollective, 0,&start,&count); |
---|
1138 | SuperClassWriter::writeData(writtenLon, lonid, isCollective, 0,&start,&count); |
---|
1139 | if (domain->hasBounds) |
---|
1140 | { |
---|
1141 | SuperClassWriter::writeData(writtenBndsLon, bounds_lonid, isCollective, 0,&startBounds,&countBounds); |
---|
1142 | SuperClassWriter::writeData(writtenBndsLat, bounds_latid, isCollective, 0,&startBounds,&countBounds); |
---|
1143 | } |
---|
1144 | } |
---|
1145 | |
---|
1146 | if (domain->hasArea) |
---|
1147 | SuperClassWriter::writeData(writtenArea, areaId, isCollective, 0, &start, &count); |
---|
1148 | |
---|
1149 | SuperClassWriter::definition_start(); |
---|
1150 | |
---|
1151 | break; |
---|
1152 | } |
---|
1153 | default : |
---|
1154 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
1155 | << "[ type = " << SuperClass::type << "]" |
---|
1156 | << " not implemented yet !"); |
---|
1157 | } |
---|
1158 | } |
---|
1159 | catch (CNetCdfException& e) |
---|
1160 | { |
---|
1161 | StdString msg("On writing the domain : "); |
---|
1162 | msg.append(domid); msg.append("\n"); |
---|
1163 | msg.append("In the context : "); |
---|
1164 | msg.append(context->getId()); msg.append("\n"); |
---|
1165 | msg.append(e.what()); |
---|
1166 | ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg); |
---|
1167 | } |
---|
1168 | domain->addRelFile(this->filename); |
---|
1169 | } |
---|
1170 | //-------------------------------------------------------------- |
---|
1171 | |
---|
1172 | void CNc4DataOutput::writeAxis_(CAxis* axis) |
---|
1173 | { |
---|
1174 | if (axis->IsWritten(this->filename)) return; |
---|
1175 | axis->checkAttributes(); |
---|
1176 | |
---|
1177 | axis->computeWrittenIndex(); |
---|
1178 | axis->computeWrittenCompressedIndex(comm_file); |
---|
1179 | |
---|
1180 | int zoom_size = (MULTI_FILE == SuperClass::type) ? axis->zoom_n.getValue() |
---|
1181 | : axis->global_zoom_n.getValue(); |
---|
1182 | |
---|
1183 | int zoom_count = axis->zoom_n; |
---|
1184 | int zoom_begin = axis->zoom_begin; |
---|
1185 | // int zoom_begin = (MULTI_FILE == SuperClass::type) ? axis->global_zoom_begin |
---|
1186 | // : axis->zoom_begin; |
---|
1187 | |
---|
1188 | if ((0 == axis->zoom_n) && (MULTI_FILE == SuperClass::type)) return; |
---|
1189 | |
---|
1190 | std::vector<StdString> dims; |
---|
1191 | StdString axisid = axis->getAxisOutputName(); |
---|
1192 | StdString axisDim, axisBoundsId; |
---|
1193 | if (isWrittenAxis(axisid)) return ; |
---|
1194 | else setWrittenAxis(axisid); |
---|
1195 | |
---|
1196 | nc_type typePrec ; |
---|
1197 | if (axis->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
1198 | else if (axis->prec==4) typePrec = NC_FLOAT ; |
---|
1199 | else if (axis->prec==8) typePrec = NC_DOUBLE ; |
---|
1200 | |
---|
1201 | if (!axis->label.isEmpty()) typePrec = NC_CHAR ; |
---|
1202 | string strId="str_len" ; |
---|
1203 | try |
---|
1204 | { |
---|
1205 | if (axis->dim_name.isEmpty()) axisDim = axisid; |
---|
1206 | else axisDim=axis->dim_name.getValue(); |
---|
1207 | SuperClassWriter::addDimension(axisDim, zoom_size); |
---|
1208 | dims.push_back(axisDim); |
---|
1209 | |
---|
1210 | if (!axis->label.isEmpty() && !SuperClassWriter::dimExist(strId)) SuperClassWriter::addDimension(strId, stringArrayLen); |
---|
1211 | |
---|
1212 | if (axis->hasValue || !axis->label.isEmpty()) |
---|
1213 | { |
---|
1214 | if (!axis->label.isEmpty()) dims.push_back(strId); |
---|
1215 | |
---|
1216 | SuperClassWriter::addVariable(axisid, typePrec, dims, compressionLevel); |
---|
1217 | |
---|
1218 | if (!axis->name.isEmpty()) |
---|
1219 | SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); |
---|
1220 | |
---|
1221 | if (!axis->standard_name.isEmpty()) |
---|
1222 | SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); |
---|
1223 | |
---|
1224 | if (!axis->long_name.isEmpty()) |
---|
1225 | SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); |
---|
1226 | |
---|
1227 | if (!axis->unit.isEmpty()) |
---|
1228 | SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); |
---|
1229 | |
---|
1230 | if (!axis->axis_type.isEmpty()) |
---|
1231 | { |
---|
1232 | switch(axis->axis_type) |
---|
1233 | { |
---|
1234 | case CAxis::axis_type_attr::X : |
---|
1235 | SuperClassWriter::addAttribute("axis", string("X"), &axisid); |
---|
1236 | break; |
---|
1237 | case CAxis::axis_type_attr::Y : |
---|
1238 | SuperClassWriter::addAttribute("axis", string("Y"), &axisid); |
---|
1239 | break; |
---|
1240 | case CAxis::axis_type_attr::Z : |
---|
1241 | SuperClassWriter::addAttribute("axis", string("Z"), &axisid); |
---|
1242 | break; |
---|
1243 | case CAxis::axis_type_attr::T : |
---|
1244 | SuperClassWriter::addAttribute("axis", string("T"), &axisid); |
---|
1245 | break; |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | if (!axis->positive.isEmpty()) |
---|
1250 | { |
---|
1251 | SuperClassWriter::addAttribute("positive", |
---|
1252 | (axis->positive == CAxis::positive_attr::up) ? string("up") : string("down"), |
---|
1253 | &axisid); |
---|
1254 | } |
---|
1255 | |
---|
1256 | if (!axis->formula.isEmpty()) |
---|
1257 | SuperClassWriter::addAttribute("formula", axis->formula.getValue(), &axisid); |
---|
1258 | |
---|
1259 | if (!axis->formula_term.isEmpty()) |
---|
1260 | SuperClassWriter::addAttribute("formula_term", axis->formula_term.getValue(), &axisid); |
---|
1261 | |
---|
1262 | axisBoundsId = (axis->bounds_name.isEmpty()) ? axisid + "_bounds" : axis->bounds_name; |
---|
1263 | if (!axis->bounds.isEmpty() && axis->label.isEmpty()) |
---|
1264 | { |
---|
1265 | dims.push_back("axis_nbounds"); |
---|
1266 | SuperClassWriter::addVariable(axisBoundsId, typePrec, dims, compressionLevel); |
---|
1267 | SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); |
---|
1268 | |
---|
1269 | if (!axis->standard_name.isEmpty()) |
---|
1270 | SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisBoundsId); |
---|
1271 | |
---|
1272 | if (!axis->unit.isEmpty()) |
---|
1273 | SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisBoundsId); |
---|
1274 | |
---|
1275 | if (!axis->formula_bounds.isEmpty()) |
---|
1276 | SuperClassWriter::addAttribute("formula", axis->formula_bounds.getValue(), &axisBoundsId); |
---|
1277 | |
---|
1278 | if (!axis->formula_term_bounds.isEmpty()) |
---|
1279 | SuperClassWriter::addAttribute("formula_term", axis->formula_term_bounds.getValue(), &axisBoundsId); |
---|
1280 | } |
---|
1281 | } |
---|
1282 | |
---|
1283 | SuperClassWriter::definition_end(); |
---|
1284 | |
---|
1285 | CArray<int, 1>& indexToWrite = axis->localIndexToWriteOnServer; |
---|
1286 | int nbWritten = indexToWrite.numElements(); |
---|
1287 | CArray<double,1> axis_value(indexToWrite.numElements()); |
---|
1288 | if (!axis->value.isEmpty()) |
---|
1289 | { |
---|
1290 | for (int i = 0; i < nbWritten; i++) |
---|
1291 | { |
---|
1292 | if (indexToWrite(i) < 0) |
---|
1293 | axis_value(i) = -1; // Some value in case of a hole |
---|
1294 | else |
---|
1295 | axis_value(i) = axis->value(indexToWrite(i)); |
---|
1296 | } |
---|
1297 | } |
---|
1298 | CArray<double,2> axis_bounds; |
---|
1299 | CArray<string,1> axis_label; |
---|
1300 | if (!axis->label.isEmpty()) |
---|
1301 | { |
---|
1302 | axis_label.resize(indexToWrite.numElements()); |
---|
1303 | for (int i = 0; i < nbWritten; i++) |
---|
1304 | { |
---|
1305 | if (indexToWrite(i) < 0) |
---|
1306 | axis_label(i) = boost::lexical_cast<string>(-1); // Some value in case of a hole |
---|
1307 | else |
---|
1308 | axis_label(i) = axis->label(indexToWrite(i)); |
---|
1309 | } |
---|
1310 | } |
---|
1311 | |
---|
1312 | switch (SuperClass::type) |
---|
1313 | { |
---|
1314 | case MULTI_FILE: |
---|
1315 | { |
---|
1316 | if (axis->label.isEmpty()) |
---|
1317 | { |
---|
1318 | if (!axis->value.isEmpty()) |
---|
1319 | SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); |
---|
1320 | |
---|
1321 | if (!axis->bounds.isEmpty()) |
---|
1322 | { |
---|
1323 | axis_bounds.resize(2, indexToWrite.numElements()); |
---|
1324 | for (int i = 0; i < nbWritten; ++i) |
---|
1325 | { |
---|
1326 | if (indexToWrite(i) < 0) |
---|
1327 | { |
---|
1328 | axis_bounds(0, i) = -1.; // Some value in case of a hole |
---|
1329 | axis_bounds(1, i) = -1.; |
---|
1330 | } |
---|
1331 | else |
---|
1332 | { |
---|
1333 | axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); |
---|
1334 | axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); |
---|
1335 | } |
---|
1336 | } |
---|
1337 | SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0); |
---|
1338 | } |
---|
1339 | } |
---|
1340 | else |
---|
1341 | SuperClassWriter::writeData(axis_label, axisid, isCollective, 0); |
---|
1342 | |
---|
1343 | SuperClassWriter::definition_start(); |
---|
1344 | break; |
---|
1345 | } |
---|
1346 | case ONE_FILE: |
---|
1347 | { |
---|
1348 | std::vector<StdSize> start(1), startBounds(2) ; |
---|
1349 | std::vector<StdSize> count(1), countBounds(2) ; |
---|
1350 | start[0] = startBounds[0] = zoom_begin - axis->global_zoom_begin; |
---|
1351 | count[0] = countBounds[0] = zoom_count; // zoom_size |
---|
1352 | startBounds[1] = 0; |
---|
1353 | countBounds[1] = 2; |
---|
1354 | |
---|
1355 | if (axis->label.isEmpty()) |
---|
1356 | { |
---|
1357 | if (!axis->value.isEmpty()) |
---|
1358 | SuperClassWriter::writeData(axis_value, axisid, isCollective, 0, &start, &count); |
---|
1359 | |
---|
1360 | if (!axis->bounds.isEmpty()) |
---|
1361 | { |
---|
1362 | axis_bounds.resize(2, indexToWrite.numElements()); |
---|
1363 | for (int i = 0; i < nbWritten; ++i) |
---|
1364 | { |
---|
1365 | if (indexToWrite(i) < 0) |
---|
1366 | { |
---|
1367 | axis_bounds(0, i) = -1.; |
---|
1368 | axis_bounds(1, i) = -1.; |
---|
1369 | } |
---|
1370 | else |
---|
1371 | { |
---|
1372 | axis_bounds(0, i) = axis->bounds(0, int(indexToWrite(i))); |
---|
1373 | axis_bounds(1, i) = axis->bounds(1, int(indexToWrite(i))); |
---|
1374 | } |
---|
1375 | } |
---|
1376 | SuperClassWriter::writeData(axis_bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); |
---|
1377 | } |
---|
1378 | } |
---|
1379 | else |
---|
1380 | { |
---|
1381 | std::vector<StdSize> startLabel(2), countLabel(2); |
---|
1382 | startLabel[0] = start[0]; startLabel[1] = 0; |
---|
1383 | countLabel[0] = count[0]; countLabel[1] = stringArrayLen; |
---|
1384 | SuperClassWriter::writeData(axis_label, axisid, isCollective, 0, &startLabel, &countLabel); |
---|
1385 | } |
---|
1386 | |
---|
1387 | SuperClassWriter::definition_start(); |
---|
1388 | |
---|
1389 | break; |
---|
1390 | } |
---|
1391 | default : |
---|
1392 | ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", |
---|
1393 | << "[ type = " << SuperClass::type << "]" |
---|
1394 | << " not implemented yet !"); |
---|
1395 | } |
---|
1396 | } |
---|
1397 | catch (CNetCdfException& e) |
---|
1398 | { |
---|
1399 | StdString msg("On writing the axis : "); |
---|
1400 | msg.append(axisid); msg.append("\n"); |
---|
1401 | msg.append("In the context : "); |
---|
1402 | CContext* context = CContext::getCurrent() ; |
---|
1403 | msg.append(context->getId()); msg.append("\n"); |
---|
1404 | msg.append(e.what()); |
---|
1405 | ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); |
---|
1406 | } |
---|
1407 | axis->addRelFile(this->filename); |
---|
1408 | } |
---|
1409 | |
---|
1410 | void CNc4DataOutput::writeScalar_(CScalar* scalar) |
---|
1411 | { |
---|
1412 | if (scalar->IsWritten(this->filename)) return; |
---|
1413 | scalar->checkAttributes(); |
---|
1414 | int scalarSize = 1; |
---|
1415 | |
---|
1416 | StdString scalaId = scalar->getScalarOutputName(); |
---|
1417 | StdString boundsId; |
---|
1418 | if (isWrittenAxis(scalaId)) return ; |
---|
1419 | else setWrittenAxis(scalaId); |
---|
1420 | |
---|
1421 | nc_type typePrec ; |
---|
1422 | if (scalar->prec.isEmpty()) typePrec = NC_FLOAT ; |
---|
1423 | else if (scalar->prec==4) typePrec = NC_FLOAT ; |
---|
1424 | else if (scalar->prec==8) typePrec = NC_DOUBLE ; |
---|
1425 | |
---|
1426 | if (!scalar->label.isEmpty()) typePrec = NC_CHAR ; |
---|
1427 | string strId="str_len" ; |
---|
1428 | |
---|
1429 | try |
---|
1430 | { |
---|
1431 | if (!scalar->label.isEmpty() && !SuperClassWriter::dimExist(strId)) SuperClassWriter::addDimension(strId, stringArrayLen); |
---|
1432 | |
---|
1433 | if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) |
---|
1434 | { |
---|
1435 | std::vector<StdString> dims; |
---|
1436 | StdString scalarDim = scalaId; |
---|
1437 | |
---|
1438 | if (!scalar->label.isEmpty()) dims.push_back(strId); |
---|
1439 | |
---|
1440 | SuperClassWriter::addVariable(scalaId, typePrec, dims); |
---|
1441 | |
---|
1442 | if (!scalar->name.isEmpty()) |
---|
1443 | SuperClassWriter::addAttribute("name", scalar->name.getValue(), &scalaId); |
---|
1444 | |
---|
1445 | if (!scalar->standard_name.isEmpty()) |
---|
1446 | SuperClassWriter::addAttribute("standard_name", scalar->standard_name.getValue(), &scalaId); |
---|
1447 | |
---|
1448 | if (!scalar->long_name.isEmpty()) |
---|
1449 | SuperClassWriter::addAttribute("long_name", scalar->long_name.getValue(), &scalaId); |
---|
1450 | |
---|
1451 | if (!scalar->unit.isEmpty()) |
---|
1452 | SuperClassWriter::addAttribute("units", scalar->unit.getValue(), &scalaId); |
---|
1453 | |
---|
1454 | if (!scalar->axis_type.isEmpty()) |
---|
1455 | { |
---|
1456 | switch(scalar->axis_type) |
---|
1457 | { |
---|
1458 | case CScalar::axis_type_attr::X : |
---|
1459 | SuperClassWriter::addAttribute("axis", string("X"), &scalaId); |
---|
1460 | break; |
---|
1461 | case CScalar::axis_type_attr::Y : |
---|
1462 | SuperClassWriter::addAttribute("axis", string("Y"), &scalaId); |
---|
1463 | break; |
---|
1464 | case CScalar::axis_type_attr::Z : |
---|
1465 | SuperClassWriter::addAttribute("axis", string("Z"), &scalaId); |
---|
1466 | break; |
---|
1467 | case CScalar::axis_type_attr::T : |
---|
1468 | SuperClassWriter::addAttribute("axis", string("T"), &scalaId); |
---|
1469 | break; |
---|
1470 | } |
---|
1471 | } |
---|
1472 | |
---|
1473 | if (!scalar->positive.isEmpty()) |
---|
1474 | { |
---|
1475 | SuperClassWriter::addAttribute("positive", |
---|
1476 | (scalar->positive == CScalar::positive_attr::up) ? string("up") : string("down"), |
---|
1477 | &scalaId); |
---|
1478 | } |
---|
1479 | |
---|
1480 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
1481 | { |
---|
1482 | dims.clear(); |
---|
1483 | dims.push_back("axis_nbounds"); |
---|
1484 | boundsId = (scalar->bounds_name.isEmpty()) ? (scalaId + "_bounds") : scalar->bounds_name.getValue(); |
---|
1485 | SuperClassWriter::addVariable(boundsId, typePrec, dims); |
---|
1486 | SuperClassWriter::addAttribute("bounds", boundsId, &scalaId); |
---|
1487 | } |
---|
1488 | |
---|
1489 | SuperClassWriter::definition_end(); |
---|
1490 | |
---|
1491 | switch (SuperClass::type) |
---|
1492 | { |
---|
1493 | case MULTI_FILE: |
---|
1494 | { |
---|
1495 | CArray<double,1> scalarValue(scalarSize); |
---|
1496 | CArray<string,1> scalarLabel(scalarSize); |
---|
1497 | CArray<double,1> scalarBounds(scalarSize*2); |
---|
1498 | |
---|
1499 | if (!scalar->value.isEmpty() && scalar->label.isEmpty()) |
---|
1500 | { |
---|
1501 | scalarValue(0) = scalar->value; |
---|
1502 | SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0); |
---|
1503 | } |
---|
1504 | |
---|
1505 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
1506 | { |
---|
1507 | scalarBounds(0) = scalar->bounds(0); |
---|
1508 | scalarBounds(1) = scalar->bounds(1); |
---|
1509 | SuperClassWriter::writeData(scalarBounds, boundsId, isCollective, 0); |
---|
1510 | } |
---|
1511 | |
---|
1512 | if (!scalar->label.isEmpty()) |
---|
1513 | { |
---|
1514 | scalarLabel(0) = scalar->label; |
---|
1515 | SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0); |
---|
1516 | } |
---|
1517 | |
---|
1518 | SuperClassWriter::definition_start(); |
---|
1519 | |
---|
1520 | break; |
---|
1521 | } |
---|
1522 | case ONE_FILE: |
---|
1523 | { |
---|
1524 | CArray<double,1> scalarValue(scalarSize); |
---|
1525 | CArray<string,1> scalarLabel(scalarSize); |
---|
1526 | CArray<double,1> scalarBounds(scalarSize*2); |
---|
1527 | |
---|
1528 | std::vector<StdSize> start(1); |
---|
1529 | std::vector<StdSize> count(1); |
---|
1530 | start[0] = 0; |
---|
1531 | count[0] = 1; |
---|
1532 | if (!scalar->value.isEmpty() && scalar->label.isEmpty()) |
---|
1533 | { |
---|
1534 | scalarValue(0) = scalar->value; |
---|
1535 | SuperClassWriter::writeData(scalarValue, scalaId, isCollective, 0, &start, &count); |
---|
1536 | } |
---|
1537 | if (!scalar->bounds.isEmpty() && scalar->label.isEmpty()) |
---|
1538 | { |
---|
1539 | scalarBounds(0) = scalar->bounds(0); |
---|
1540 | scalarBounds(1) = scalar->bounds(1); |
---|
1541 | count[0] = 2; |
---|
1542 | SuperClassWriter::writeData(scalarBounds, boundsId, isCollective, 0, &start, &count); |
---|
1543 | } |
---|
1544 | if (!scalar->label.isEmpty()) |
---|
1545 | { |
---|
1546 | scalarLabel(0) = scalar->label; |
---|
1547 | count[0] = stringArrayLen; |
---|
1548 | SuperClassWriter::writeData(scalarLabel, scalaId, isCollective, 0, &start, &count); |
---|
1549 | } |
---|
1550 | |
---|
1551 | SuperClassWriter::definition_start(); |
---|
1552 | |
---|
1553 | break; |
---|
1554 | } |
---|
1555 | default : |
---|
1556 | ERROR("CNc4DataOutput::writeAxis_(CAxis* scalar)", |
---|
1557 | << "[ type = " << SuperClass::type << "]" |
---|
1558 | << " not implemented yet !"); |
---|
1559 | } |
---|
1560 | } |
---|
1561 | } |
---|
1562 | catch (CNetCdfException& e) |
---|
1563 | { |
---|
1564 | StdString msg("On writing the scalar : "); |
---|
1565 | msg.append(scalaId); msg.append("\n"); |
---|
1566 | msg.append("In the context : "); |
---|
1567 | CContext* context = CContext::getCurrent() ; |
---|
1568 | msg.append(context->getId()); msg.append("\n"); |
---|
1569 | msg.append(e.what()); |
---|
1570 | ERROR("CNc4DataOutput::writeScalar_(CScalar* scalar)", << msg); |
---|
1571 | } |
---|
1572 | scalar->addRelFile(this->filename); |
---|
1573 | } |
---|
1574 | |
---|
1575 | //-------------------------------------------------------------- |
---|
1576 | |
---|
1577 | void CNc4DataOutput::writeGridCompressed_(CGrid* grid) |
---|
1578 | { |
---|
1579 | if (grid->isScalarGrid() || grid->isWrittenCompressed(this->filename)) return; |
---|
1580 | |
---|
1581 | try |
---|
1582 | { |
---|
1583 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
1584 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
1585 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
1586 | std::vector<StdString> scalarList = grid->getScalarList(); |
---|
1587 | int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; |
---|
1588 | |
---|
1589 | std::vector<StdString> dims; |
---|
1590 | |
---|
1591 | if (grid->isCompressible()) |
---|
1592 | { |
---|
1593 | StdString varId = grid->getId() + "_points"; |
---|
1594 | |
---|
1595 | int nbIndexes = (SuperClass::type == MULTI_FILE) ? grid->getNumberWrittenIndexes() : grid->getTotalNumberWrittenIndexes(); |
---|
1596 | SuperClassWriter::addDimension(varId, nbIndexes); |
---|
1597 | |
---|
1598 | dims.push_back(varId); |
---|
1599 | SuperClassWriter::addVariable(varId, NC_INT, dims); |
---|
1600 | |
---|
1601 | StdOStringStream compress; |
---|
1602 | for (int i = numElement - 1; i >= 0; --i) |
---|
1603 | { |
---|
1604 | if (2 == axisDomainOrder(i)) |
---|
1605 | { |
---|
1606 | CDomain* domain = CDomain::get(domainList[domainList.size() - idxDomain - 1]); |
---|
1607 | StdString domId = domain->getDomainOutputName(); |
---|
1608 | StdString appendDomId = singleDomain ? "" : "_" + domId; |
---|
1609 | |
---|
1610 | switch (domain->type) |
---|
1611 | { |
---|
1612 | case CDomain::type_attr::curvilinear: |
---|
1613 | compress << "y" << appendDomId << " x" << appendDomId; |
---|
1614 | break; |
---|
1615 | case CDomain::type_attr::rectilinear: |
---|
1616 | compress << "lat" << appendDomId << " lon" << appendDomId; |
---|
1617 | break; |
---|
1618 | case CDomain::type_attr::unstructured: |
---|
1619 | StdString cellName = (!domain->dim_i_name.isEmpty()) ? cellName=domain->dim_i_name : "cell"; |
---|
1620 | compress << cellName << appendDomId; |
---|
1621 | // compress << "cell" << appendDomId; |
---|
1622 | break; |
---|
1623 | } |
---|
1624 | ++idxDomain; |
---|
1625 | } |
---|
1626 | else if (1 == axisDomainOrder(i)) |
---|
1627 | { |
---|
1628 | CAxis* axis = CAxis::get(axisList[axisList.size() - idxAxis - 1]); |
---|
1629 | compress << axis->getAxisOutputName(); |
---|
1630 | ++idxAxis; |
---|
1631 | } |
---|
1632 | else |
---|
1633 | { |
---|
1634 | CScalar* scalar = CScalar::get(scalarList[scalarList.size() - idxScalar - 1]); |
---|
1635 | compress << scalar->getScalarOutputName(); |
---|
1636 | ++idxScalar; |
---|
1637 | } |
---|
1638 | |
---|
1639 | if (i != 0) compress << ' '; |
---|
1640 | } |
---|
1641 | SuperClassWriter::addAttribute("compress", compress.str(), &varId); |
---|
1642 | |
---|
1643 | CArray<int, 1> indexes(grid->getNumberWrittenIndexes()); |
---|
1644 | indexes = grid->localIndexToWriteOnServer; |
---|
1645 | |
---|
1646 | switch (SuperClass::type) |
---|
1647 | { |
---|
1648 | case (MULTI_FILE): |
---|
1649 | { |
---|
1650 | SuperClassWriter::writeData(indexes, varId, isCollective, 0); |
---|
1651 | break; |
---|
1652 | } |
---|
1653 | case (ONE_FILE): |
---|
1654 | { |
---|
1655 | if (grid->doGridHaveDataDistributed()) |
---|
1656 | grid->getDistributionServer()->computeGlobalIndex(indexes); |
---|
1657 | |
---|
1658 | std::vector<StdSize> start, count; |
---|
1659 | start.push_back(grid->getOffsetWrittenIndexes()); |
---|
1660 | count.push_back(grid->getNumberWrittenIndexes()); |
---|
1661 | |
---|
1662 | SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); |
---|
1663 | break; |
---|
1664 | } |
---|
1665 | } |
---|
1666 | } |
---|
1667 | else |
---|
1668 | { |
---|
1669 | for (int i = 0; i < numElement; ++i) |
---|
1670 | { |
---|
1671 | StdString varId, compress; |
---|
1672 | CArray<int, 1> indexes; |
---|
1673 | bool isDistributed; |
---|
1674 | StdSize nbIndexes, totalNbIndexes, offset; |
---|
1675 | int firstGlobalIndex; |
---|
1676 | |
---|
1677 | if (2 == axisDomainOrder(i)) |
---|
1678 | { |
---|
1679 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
1680 | StdString domId = domain->getDomainOutputName(); |
---|
1681 | |
---|
1682 | if (!domain->isCompressible() |
---|
1683 | || domain->type == CDomain::type_attr::unstructured |
---|
1684 | || domain->isWrittenCompressed(this->filename) |
---|
1685 | || isWrittenCompressedDomain(domId)) |
---|
1686 | continue; |
---|
1687 | |
---|
1688 | StdString appendDomId = singleDomain ? "" : "_" + domId; |
---|
1689 | |
---|
1690 | varId = domId + "_points"; |
---|
1691 | switch (domain->type) |
---|
1692 | { |
---|
1693 | case CDomain::type_attr::curvilinear: |
---|
1694 | compress = "y" + appendDomId + " x" + appendDomId; |
---|
1695 | break; |
---|
1696 | case CDomain::type_attr::rectilinear: |
---|
1697 | compress = "lat" + appendDomId + " lon" + appendDomId; |
---|
1698 | break; |
---|
1699 | } |
---|
1700 | |
---|
1701 | // indexes.resize(domain->compressedIndexToWriteOnServer[comm_file].numElements()); |
---|
1702 | // indexes = domain->compressedIndexToWriteOnServer[com_file]; |
---|
1703 | indexes.resize(domain->getCompressedIndexToWriteOnServer(comm_file).numElements()); |
---|
1704 | indexes = domain->getCompressedIndexToWriteOnServer(comm_file); |
---|
1705 | |
---|
1706 | isDistributed = domain->isDistributed(); |
---|
1707 | nbIndexes = domain->getNumberWrittenIndexes(comm_file); |
---|
1708 | totalNbIndexes = domain->getTotalNumberWrittenIndexes(comm_file); |
---|
1709 | offset = domain->getOffsetWrittenIndexes(comm_file); |
---|
1710 | firstGlobalIndex = domain->ibegin + domain->jbegin * domain->ni_glo; |
---|
1711 | |
---|
1712 | domain->addRelFileCompressed(this->filename); |
---|
1713 | setWrittenCompressedDomain(domId); |
---|
1714 | ++idxDomain; |
---|
1715 | } |
---|
1716 | else if (1 == axisDomainOrder(i)) |
---|
1717 | { |
---|
1718 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
1719 | StdString axisId = axis->getAxisOutputName(); |
---|
1720 | |
---|
1721 | if (!axis->isCompressible() |
---|
1722 | || axis->isWrittenCompressed(this->filename) |
---|
1723 | || isWrittenCompressedAxis(axisId)) |
---|
1724 | continue; |
---|
1725 | |
---|
1726 | varId = axisId + "_points"; |
---|
1727 | compress = axisId; |
---|
1728 | |
---|
1729 | // indexes.resize(axis->compressedIndexToWriteOnServer.numElements()); |
---|
1730 | // indexes = axis->compressedIndexToWriteOnServer; |
---|
1731 | |
---|
1732 | indexes.resize(axis->getCompressedIndexToWriteOnServer(comm_file).numElements()); |
---|
1733 | indexes = axis->getCompressedIndexToWriteOnServer(comm_file); |
---|
1734 | |
---|
1735 | isDistributed = axis->isDistributed(); |
---|
1736 | nbIndexes = axis->getNumberWrittenIndexes(comm_file); |
---|
1737 | totalNbIndexes = axis->getTotalNumberWrittenIndexes(comm_file); |
---|
1738 | offset = axis->getOffsetWrittenIndexes(comm_file); |
---|
1739 | firstGlobalIndex = axis->begin; |
---|
1740 | |
---|
1741 | axis->addRelFileCompressed(this->filename); |
---|
1742 | setWrittenCompressedAxis(axisId); |
---|
1743 | ++idxAxis; |
---|
1744 | } |
---|
1745 | else |
---|
1746 | { |
---|
1747 | } |
---|
1748 | |
---|
1749 | if (!varId.empty()) |
---|
1750 | { |
---|
1751 | SuperClassWriter::addDimension(varId, (SuperClass::type == MULTI_FILE) ? nbIndexes : totalNbIndexes); |
---|
1752 | |
---|
1753 | dims.clear(); |
---|
1754 | dims.push_back(varId); |
---|
1755 | SuperClassWriter::addVariable(varId, NC_INT, dims); |
---|
1756 | |
---|
1757 | SuperClassWriter::addAttribute("compress", compress, &varId); |
---|
1758 | |
---|
1759 | switch (SuperClass::type) |
---|
1760 | { |
---|
1761 | case (MULTI_FILE): |
---|
1762 | { |
---|
1763 | indexes -= firstGlobalIndex; |
---|
1764 | SuperClassWriter::writeData(indexes, varId, isCollective, 0); |
---|
1765 | break; |
---|
1766 | } |
---|
1767 | case (ONE_FILE): |
---|
1768 | { |
---|
1769 | std::vector<StdSize> start, count; |
---|
1770 | start.push_back(offset); |
---|
1771 | count.push_back(nbIndexes); |
---|
1772 | |
---|
1773 | SuperClassWriter::writeData(indexes, varId, isCollective, 0, &start, &count); |
---|
1774 | break; |
---|
1775 | } |
---|
1776 | } |
---|
1777 | } |
---|
1778 | } |
---|
1779 | } |
---|
1780 | |
---|
1781 | grid->addRelFileCompressed(this->filename); |
---|
1782 | } |
---|
1783 | catch (CNetCdfException& e) |
---|
1784 | { |
---|
1785 | StdString msg("On writing compressed grid : "); |
---|
1786 | msg.append(grid->getId()); msg.append("\n"); |
---|
1787 | msg.append("In the context : "); |
---|
1788 | CContext* context = CContext::getCurrent(); |
---|
1789 | msg.append(context->getId()); msg.append("\n"); |
---|
1790 | msg.append(e.what()); |
---|
1791 | ERROR("CNc4DataOutput::writeGridCompressed_(CGrid* grid)", << msg); |
---|
1792 | } |
---|
1793 | } |
---|
1794 | |
---|
1795 | //-------------------------------------------------------------- |
---|
1796 | |
---|
1797 | void CNc4DataOutput::writeTimeDimension_(void) |
---|
1798 | { |
---|
1799 | try |
---|
1800 | { |
---|
1801 | SuperClassWriter::addDimension(getTimeCounterName()); |
---|
1802 | } |
---|
1803 | catch (CNetCdfException& e) |
---|
1804 | { |
---|
1805 | StdString msg("On writing time dimension : time_couter\n"); |
---|
1806 | msg.append("In the context : "); |
---|
1807 | CContext* context = CContext::getCurrent() ; |
---|
1808 | msg.append(context->getId()); msg.append("\n"); |
---|
1809 | msg.append(e.what()); |
---|
1810 | ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg); |
---|
1811 | } |
---|
1812 | } |
---|
1813 | |
---|
1814 | //-------------------------------------------------------------- |
---|
1815 | |
---|
1816 | void CNc4DataOutput::writeField_(CField* field) |
---|
1817 | { |
---|
1818 | CContext* context = CContext::getCurrent() ; |
---|
1819 | CContextServer* server=context->server ; |
---|
1820 | |
---|
1821 | std::vector<StdString> dims, coodinates; |
---|
1822 | CGrid* grid = field->grid; |
---|
1823 | if (!grid->doGridHaveDataToWrite()) |
---|
1824 | if (SuperClass::type==MULTI_FILE) return ; |
---|
1825 | |
---|
1826 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
1827 | int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0, idxScalar = 0; |
---|
1828 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
1829 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
1830 | std::vector<StdString> scalarList = grid->getScalarList(); |
---|
1831 | |
---|
1832 | StdString timeid = getTimeCounterName(); |
---|
1833 | StdString dimXid,dimYid; |
---|
1834 | std::deque<StdString> dimIdList, dimCoordList; |
---|
1835 | bool hasArea = false; |
---|
1836 | StdString cellMeasures = "area:"; |
---|
1837 | bool compressedOutput = !field->indexed_output.isEmpty() && field->indexed_output; |
---|
1838 | |
---|
1839 | for (int i = 0; i < numElement; ++i) |
---|
1840 | { |
---|
1841 | if (2 == axisDomainOrder(i)) |
---|
1842 | { |
---|
1843 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
1844 | StdString domId = domain->getDomainOutputName(); |
---|
1845 | StdString appendDomId = singleDomain ? "" : "_" + domId ; |
---|
1846 | StdString lonName,latName ; |
---|
1847 | StdString dimIname,dimJname ; |
---|
1848 | |
---|
1849 | if (domain->lon_name.isEmpty()) |
---|
1850 | { |
---|
1851 | if (domain->type==CDomain::type_attr::curvilinear) lonName = "nav_lon"; |
---|
1852 | else lonName = "lon"; |
---|
1853 | } |
---|
1854 | else lonName = domain->lon_name; |
---|
1855 | |
---|
1856 | if (domain->lat_name.isEmpty()) |
---|
1857 | { |
---|
1858 | if (domain->type==CDomain::type_attr::curvilinear) latName = "nav_lat"; |
---|
1859 | else latName = "lat"; |
---|
1860 | } |
---|
1861 | else latName = domain->lat_name; |
---|
1862 | |
---|
1863 | if (domain->dim_i_name.isEmpty()) |
---|
1864 | { |
---|
1865 | if (domain->type==CDomain::type_attr::curvilinear) dimIname = "x"; |
---|
1866 | else if (domain->type==CDomain::type_attr::unstructured) dimIname = "cell"; |
---|
1867 | else dimIname = lonName; |
---|
1868 | } |
---|
1869 | else dimIname = domain->dim_i_name; |
---|
1870 | |
---|
1871 | if (domain->dim_j_name.isEmpty()) |
---|
1872 | { |
---|
1873 | if (domain->type==CDomain::type_attr::curvilinear) dimJname = "y"; |
---|
1874 | else dimJname = latName; |
---|
1875 | } |
---|
1876 | else dimJname = domain->dim_j_name; |
---|
1877 | |
---|
1878 | if (compressedOutput && domain->isCompressible() && domain->type != CDomain::type_attr::unstructured) |
---|
1879 | { |
---|
1880 | dimIdList.push_back(domId + "_points"); |
---|
1881 | field->setUseCompressedOutput(); |
---|
1882 | } |
---|
1883 | |
---|
1884 | switch (domain->type) |
---|
1885 | { |
---|
1886 | case CDomain::type_attr::curvilinear: |
---|
1887 | if (!compressedOutput || !domain->isCompressible()) |
---|
1888 | { |
---|
1889 | dimXid=dimIname+appendDomId; |
---|
1890 | dimYid=dimJname+appendDomId; |
---|
1891 | dimIdList.push_back(dimXid); |
---|
1892 | dimIdList.push_back(dimYid); |
---|
1893 | } |
---|
1894 | dimCoordList.push_back(lonName+appendDomId); |
---|
1895 | dimCoordList.push_back(latName+appendDomId); |
---|
1896 | break ; |
---|
1897 | case CDomain::type_attr::rectilinear: |
---|
1898 | if (!compressedOutput || !domain->isCompressible()) |
---|
1899 | { |
---|
1900 | dimXid = dimIname+appendDomId; |
---|
1901 | dimYid = dimJname+appendDomId; |
---|
1902 | dimIdList.push_back(dimXid); |
---|
1903 | dimIdList.push_back(dimYid); |
---|
1904 | } |
---|
1905 | if (lonName != dimIname) dimCoordList.push_back(lonName+appendDomId); |
---|
1906 | if (latName != dimJname) dimCoordList.push_back(latName+appendDomId); |
---|
1907 | |
---|
1908 | break ; |
---|
1909 | case CDomain::type_attr::unstructured: |
---|
1910 | { |
---|
1911 | if (SuperClassWriter::useCFConvention) |
---|
1912 | { |
---|
1913 | dimXid = dimIname + appendDomId; |
---|
1914 | dimIdList.push_back(dimXid); |
---|
1915 | dimCoordList.push_back(lonName+appendDomId); |
---|
1916 | dimCoordList.push_back(latName+appendDomId); |
---|
1917 | } |
---|
1918 | else |
---|
1919 | { |
---|
1920 | StdString domainName = domain->name; |
---|
1921 | if (domain->nvertex == 1) |
---|
1922 | { |
---|
1923 | dimXid = "n" + domainName + "_node"; |
---|
1924 | dimIdList.push_back(dimXid); |
---|
1925 | dimCoordList.push_back(StdString(domainName + "_node_x")); |
---|
1926 | dimCoordList.push_back(StdString(domainName + "_node_y")); |
---|
1927 | } |
---|
1928 | else if (domain->nvertex == 2) |
---|
1929 | { |
---|
1930 | dimXid = "n" + domainName + "_edge"; |
---|
1931 | dimIdList.push_back(dimXid); |
---|
1932 | dimCoordList.push_back(StdString(domainName + "_edge_x")); |
---|
1933 | dimCoordList.push_back(StdString(domainName + "_edge_y")); |
---|
1934 | } |
---|
1935 | else |
---|
1936 | { |
---|
1937 | dimXid = "n" + domainName + "_face"; |
---|
1938 | dimIdList.push_back(dimXid); |
---|
1939 | dimCoordList.push_back(StdString(domainName + "_face_x")); |
---|
1940 | dimCoordList.push_back(StdString(domainName + "_face_y")); |
---|
1941 | } |
---|
1942 | } // ugrid convention |
---|
1943 | } // case unstructured domain |
---|
1944 | } |
---|
1945 | |
---|
1946 | if (domain->hasArea) |
---|
1947 | { |
---|
1948 | hasArea = true; |
---|
1949 | cellMeasures += " area" + appendDomId; |
---|
1950 | } |
---|
1951 | ++idxDomain; |
---|
1952 | } |
---|
1953 | else if (1 == axisDomainOrder(i)) |
---|
1954 | { |
---|
1955 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
1956 | StdString axisId = axis->getAxisOutputName(); |
---|
1957 | StdString axisDim; |
---|
1958 | |
---|
1959 | if (axis->dim_name.isEmpty()) axisDim = axisId; |
---|
1960 | else axisDim=axis->dim_name.getValue(); |
---|
1961 | |
---|
1962 | if (compressedOutput && axis->isCompressible()) |
---|
1963 | { |
---|
1964 | dimIdList.push_back(axisDim + "_points"); |
---|
1965 | field->setUseCompressedOutput(); |
---|
1966 | } |
---|
1967 | else |
---|
1968 | dimIdList.push_back(axisDim); |
---|
1969 | |
---|
1970 | if (axisDim != axisId) dimCoordList.push_back(axisId); |
---|
1971 | ++idxAxis; |
---|
1972 | } |
---|
1973 | else |
---|
1974 | { |
---|
1975 | CScalar* scalar = CScalar::get(scalarList[idxScalar]); |
---|
1976 | StdString scalarId = scalar->getScalarOutputName(); |
---|
1977 | if (!scalar->value.isEmpty() || !scalar->label.isEmpty()) |
---|
1978 | dimCoordList.push_back(scalarId); |
---|
1979 | ++idxScalar; |
---|
1980 | } |
---|
1981 | } |
---|
1982 | |
---|
1983 | StdString fieldid = field->getFieldOutputName(); |
---|
1984 | |
---|
1985 | nc_type type ; |
---|
1986 | if (field->prec.isEmpty()) type = NC_FLOAT ; |
---|
1987 | else |
---|
1988 | { |
---|
1989 | if (field->prec==2) type = NC_SHORT ; |
---|
1990 | else if (field->prec==4) type = NC_FLOAT ; |
---|
1991 | else if (field->prec==8) type = NC_DOUBLE ; |
---|
1992 | } |
---|
1993 | |
---|
1994 | bool wtime = !(!field->operation.isEmpty() && field->getOperationTimeType() == func::CFunctor::once); |
---|
1995 | |
---|
1996 | if (wtime) |
---|
1997 | { |
---|
1998 | if (field->hasTimeInstant && hasTimeInstant) coodinates.push_back(string("time_instant")); |
---|
1999 | else if (field->hasTimeCentered && hasTimeCentered) coodinates.push_back(string("time_centered")); |
---|
2000 | dims.push_back(timeid); |
---|
2001 | } |
---|
2002 | |
---|
2003 | if (compressedOutput && grid->isCompressible()) |
---|
2004 | { |
---|
2005 | dims.push_back(grid->getId() + "_points"); |
---|
2006 | field->setUseCompressedOutput(); |
---|
2007 | } |
---|
2008 | else |
---|
2009 | { |
---|
2010 | while (!dimIdList.empty()) |
---|
2011 | { |
---|
2012 | dims.push_back(dimIdList.back()); |
---|
2013 | dimIdList.pop_back(); |
---|
2014 | } |
---|
2015 | } |
---|
2016 | |
---|
2017 | while (!dimCoordList.empty()) |
---|
2018 | { |
---|
2019 | coodinates.push_back(dimCoordList.back()); |
---|
2020 | dimCoordList.pop_back(); |
---|
2021 | } |
---|
2022 | |
---|
2023 | try |
---|
2024 | { |
---|
2025 | SuperClassWriter::addVariable(fieldid, type, dims); |
---|
2026 | |
---|
2027 | if (!field->standard_name.isEmpty()) |
---|
2028 | SuperClassWriter::addAttribute |
---|
2029 | ("standard_name", field->standard_name.getValue(), &fieldid); |
---|
2030 | |
---|
2031 | if (!field->long_name.isEmpty()) |
---|
2032 | SuperClassWriter::addAttribute |
---|
2033 | ("long_name", field->long_name.getValue(), &fieldid); |
---|
2034 | |
---|
2035 | if (!field->unit.isEmpty()) |
---|
2036 | SuperClassWriter::addAttribute |
---|
2037 | ("units", field->unit.getValue(), &fieldid); |
---|
2038 | |
---|
2039 | // Ugrid field attributes "mesh" and "location" |
---|
2040 | if (!SuperClassWriter::useCFConvention) |
---|
2041 | { |
---|
2042 | if (!domainList.empty()) |
---|
2043 | { |
---|
2044 | CDomain* domain = CDomain::get(domainList[0]); // Suppose that we have only domain |
---|
2045 | StdString mesh = domain->name; |
---|
2046 | SuperClassWriter::addAttribute("mesh", mesh, &fieldid); |
---|
2047 | StdString location; |
---|
2048 | if (domain->nvertex == 1) |
---|
2049 | location = "node"; |
---|
2050 | else if (domain->nvertex == 2) |
---|
2051 | location = "edge"; |
---|
2052 | else if (domain->nvertex > 2) |
---|
2053 | location = "face"; |
---|
2054 | SuperClassWriter::addAttribute("location", location, &fieldid); |
---|
2055 | } |
---|
2056 | |
---|
2057 | } |
---|
2058 | |
---|
2059 | if (!field->valid_min.isEmpty()) |
---|
2060 | SuperClassWriter::addAttribute |
---|
2061 | ("valid_min", field->valid_min.getValue(), &fieldid); |
---|
2062 | |
---|
2063 | if (!field->valid_max.isEmpty()) |
---|
2064 | SuperClassWriter::addAttribute |
---|
2065 | ("valid_max", field->valid_max.getValue(), &fieldid); |
---|
2066 | |
---|
2067 | if (!field->scale_factor.isEmpty()) |
---|
2068 | SuperClassWriter::addAttribute |
---|
2069 | ("scale_factor", field->scale_factor.getValue(), &fieldid); |
---|
2070 | |
---|
2071 | if (!field->add_offset.isEmpty()) |
---|
2072 | SuperClassWriter::addAttribute |
---|
2073 | ("add_offset", field->add_offset.getValue(), &fieldid); |
---|
2074 | |
---|
2075 | SuperClassWriter::addAttribute |
---|
2076 | ("online_operation", field->operation.getValue(), &fieldid); |
---|
2077 | |
---|
2078 | // write child variables as attributes |
---|
2079 | |
---|
2080 | |
---|
2081 | bool alreadyAddCellMethod = false; |
---|
2082 | StdString cellMethodsPrefix(""), cellMethodsSuffix(""); |
---|
2083 | if (!field->cell_methods.isEmpty()) |
---|
2084 | { |
---|
2085 | StdString cellMethodString = field->cell_methods; |
---|
2086 | if (field->cell_methods_mode.isEmpty() || |
---|
2087 | (CField::cell_methods_mode_attr::overwrite == field->cell_methods_mode)) |
---|
2088 | { |
---|
2089 | SuperClassWriter::addAttribute("cell_methods", cellMethodString, &fieldid); |
---|
2090 | alreadyAddCellMethod = true; |
---|
2091 | } |
---|
2092 | else |
---|
2093 | { |
---|
2094 | switch (field->cell_methods_mode) |
---|
2095 | { |
---|
2096 | case (CField::cell_methods_mode_attr::prefix): |
---|
2097 | cellMethodsPrefix = cellMethodString; |
---|
2098 | cellMethodsPrefix += " "; |
---|
2099 | break; |
---|
2100 | case (CField::cell_methods_mode_attr::suffix): |
---|
2101 | cellMethodsSuffix = " "; |
---|
2102 | cellMethodsSuffix += cellMethodString; |
---|
2103 | break; |
---|
2104 | case (CField::cell_methods_mode_attr::none): |
---|
2105 | break; |
---|
2106 | default: |
---|
2107 | break; |
---|
2108 | } |
---|
2109 | } |
---|
2110 | } |
---|
2111 | |
---|
2112 | |
---|
2113 | if (wtime) |
---|
2114 | { |
---|
2115 | CDuration freqOp = field->freq_op.getValue(); |
---|
2116 | freqOp.solveTimeStep(*context->calendar); |
---|
2117 | StdString freqOpStr = freqOp.toStringUDUnits(); |
---|
2118 | SuperClassWriter::addAttribute("interval_operation", freqOpStr, &fieldid); |
---|
2119 | |
---|
2120 | CDuration freqOut = field->getRelFile()->output_freq.getValue(); |
---|
2121 | freqOut.solveTimeStep(*context->calendar); |
---|
2122 | SuperClassWriter::addAttribute("interval_write", freqOut.toStringUDUnits(), &fieldid); |
---|
2123 | |
---|
2124 | StdString cellMethods(cellMethodsPrefix + "time: "); |
---|
2125 | if (field->operation.getValue() == "instant") cellMethods += "point"; |
---|
2126 | else if (field->operation.getValue() == "average") cellMethods += "mean"; |
---|
2127 | else if (field->operation.getValue() == "accumulate") cellMethods += "sum"; |
---|
2128 | else cellMethods += field->operation; |
---|
2129 | if (freqOp.resolve(*context->calendar) != freqOut.resolve(*context->calendar)) |
---|
2130 | cellMethods += " (interval: " + freqOpStr + ")"; |
---|
2131 | cellMethods += cellMethodsSuffix; |
---|
2132 | if (!alreadyAddCellMethod) |
---|
2133 | SuperClassWriter::addAttribute("cell_methods", cellMethods, &fieldid); |
---|
2134 | } |
---|
2135 | |
---|
2136 | if (hasArea) |
---|
2137 | SuperClassWriter::addAttribute("cell_measures", cellMeasures, &fieldid); |
---|
2138 | |
---|
2139 | if (!field->default_value.isEmpty()) |
---|
2140 | { |
---|
2141 | double default_value = field->default_value.getValue(); |
---|
2142 | if (type == NC_DOUBLE) |
---|
2143 | { |
---|
2144 | SuperClassWriter::setDefaultValue(fieldid, &default_value); |
---|
2145 | } |
---|
2146 | else if (type == NC_SHORT) |
---|
2147 | { |
---|
2148 | short sdefault_value = (short)default_value; |
---|
2149 | SuperClassWriter::setDefaultValue(fieldid, &sdefault_value); |
---|
2150 | } |
---|
2151 | else |
---|
2152 | { |
---|
2153 | float fdefault_value = (float)default_value; |
---|
2154 | SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); |
---|
2155 | } |
---|
2156 | } |
---|
2157 | else |
---|
2158 | SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); |
---|
2159 | |
---|
2160 | if (field->compression_level.isEmpty()) |
---|
2161 | field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; |
---|
2162 | SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); |
---|
2163 | |
---|
2164 | { // Ecriture des coordonnes |
---|
2165 | |
---|
2166 | StdString coordstr; //boost::algorithm::join(coodinates, " ") |
---|
2167 | std::vector<StdString>::iterator |
---|
2168 | itc = coodinates.begin(), endc = coodinates.end(); |
---|
2169 | |
---|
2170 | for (; itc!= endc; itc++) |
---|
2171 | { |
---|
2172 | StdString & coord = *itc; |
---|
2173 | if (itc+1 != endc) |
---|
2174 | coordstr.append(coord).append(" "); |
---|
2175 | else coordstr.append(coord); |
---|
2176 | } |
---|
2177 | |
---|
2178 | SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); |
---|
2179 | |
---|
2180 | } |
---|
2181 | |
---|
2182 | vector<CVariable*> listVars = field->getAllVariables() ; |
---|
2183 | for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; |
---|
2184 | |
---|
2185 | } |
---|
2186 | catch (CNetCdfException& e) |
---|
2187 | { |
---|
2188 | StdString msg("On writing field : "); |
---|
2189 | msg.append(fieldid); msg.append("\n"); |
---|
2190 | msg.append("In the context : "); |
---|
2191 | msg.append(context->getId()); msg.append("\n"); |
---|
2192 | msg.append(e.what()); |
---|
2193 | ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); |
---|
2194 | } |
---|
2195 | } // writeField_() |
---|
2196 | |
---|
2197 | //-------------------------------------------------------------- |
---|
2198 | |
---|
2199 | void CNc4DataOutput::writeFile_ (CFile* file) |
---|
2200 | { |
---|
2201 | StdString filename = file->getFileOutputName(); |
---|
2202 | StdString description = (!file->description.isEmpty()) |
---|
2203 | ? file->description.getValue() |
---|
2204 | : StdString("Created by xios"); |
---|
2205 | |
---|
2206 | singleDomain = (file->nbDomains == 1); |
---|
2207 | |
---|
2208 | StdString conv_str ; |
---|
2209 | if (file->convention_str.isEmpty()) |
---|
2210 | { |
---|
2211 | if (SuperClassWriter::useCFConvention) conv_str="CF-1.6" ; |
---|
2212 | else conv_str="UGRID" ; |
---|
2213 | } |
---|
2214 | else conv_str=file->convention_str ; |
---|
2215 | |
---|
2216 | try |
---|
2217 | { |
---|
2218 | if (!appendMode) this->writeFileAttributes(filename, description, |
---|
2219 | conv_str, |
---|
2220 | StdString("An IPSL model"), |
---|
2221 | this->getTimeStamp()); |
---|
2222 | |
---|
2223 | if (!appendMode) |
---|
2224 | SuperClassWriter::addDimension("axis_nbounds", 2); |
---|
2225 | } |
---|
2226 | catch (CNetCdfException& e) |
---|
2227 | { |
---|
2228 | StdString msg("On writing file : "); |
---|
2229 | msg.append(filename); msg.append("\n"); |
---|
2230 | msg.append("In the context : "); |
---|
2231 | CContext* context = CContext::getCurrent() ; |
---|
2232 | msg.append(context->getId()); msg.append("\n"); |
---|
2233 | msg.append(e.what()); |
---|
2234 | ERROR("CNc4DataOutput::writeFile_ (CFile* file)", << msg); |
---|
2235 | } |
---|
2236 | } |
---|
2237 | |
---|
2238 | void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId) |
---|
2239 | { |
---|
2240 | StdString name = var->getVariableOutputName(); |
---|
2241 | |
---|
2242 | try |
---|
2243 | { |
---|
2244 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
2245 | addAttribute(name, var->getData<int>(), &fieldId); |
---|
2246 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
2247 | addAttribute(name, var->getData<short int>(), &fieldId); |
---|
2248 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
2249 | addAttribute(name, var->getData<float>(), &fieldId); |
---|
2250 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
2251 | addAttribute(name, var->getData<double>(), &fieldId); |
---|
2252 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
2253 | addAttribute(name, var->getData<string>(), &fieldId); |
---|
2254 | else |
---|
2255 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", |
---|
2256 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
2257 | } |
---|
2258 | catch (CNetCdfException& e) |
---|
2259 | { |
---|
2260 | StdString msg("On writing attributes of variable with name : "); |
---|
2261 | msg.append(name); msg.append("in the field "); msg.append(fieldId); msg.append("\n"); |
---|
2262 | msg.append("In the context : "); |
---|
2263 | CContext* context = CContext::getCurrent() ; |
---|
2264 | msg.append(context->getId()); msg.append("\n"); |
---|
2265 | msg.append(e.what()); |
---|
2266 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", << msg); |
---|
2267 | } |
---|
2268 | } |
---|
2269 | |
---|
2270 | void CNc4DataOutput::writeAttribute_ (CVariable* var) |
---|
2271 | { |
---|
2272 | StdString name = var->getVariableOutputName(); |
---|
2273 | |
---|
2274 | try |
---|
2275 | { |
---|
2276 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
2277 | addAttribute(name, var->getData<int>()); |
---|
2278 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
2279 | addAttribute(name, var->getData<short int>()); |
---|
2280 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
2281 | addAttribute(name, var->getData<float>()); |
---|
2282 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
2283 | addAttribute(name, var->getData<double>()); |
---|
2284 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
2285 | addAttribute(name, var->getData<string>()); |
---|
2286 | else |
---|
2287 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", |
---|
2288 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
2289 | } |
---|
2290 | catch (CNetCdfException& e) |
---|
2291 | { |
---|
2292 | StdString msg("On writing attributes of variable with name : "); |
---|
2293 | msg.append(name); msg.append("\n"); |
---|
2294 | msg.append("In the context : "); |
---|
2295 | CContext* context = CContext::getCurrent() ; |
---|
2296 | msg.append(context->getId()); msg.append("\n"); |
---|
2297 | msg.append(e.what()); |
---|
2298 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", << msg); |
---|
2299 | } |
---|
2300 | } |
---|
2301 | |
---|
2302 | void CNc4DataOutput::syncFile_ (void) |
---|
2303 | { |
---|
2304 | try |
---|
2305 | { |
---|
2306 | SuperClassWriter::sync() ; |
---|
2307 | } |
---|
2308 | catch (CNetCdfException& e) |
---|
2309 | { |
---|
2310 | StdString msg("On synchronizing the write among processes"); |
---|
2311 | msg.append("In the context : "); |
---|
2312 | CContext* context = CContext::getCurrent() ; |
---|
2313 | msg.append(context->getId()); msg.append("\n"); |
---|
2314 | msg.append(e.what()); |
---|
2315 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
2316 | } |
---|
2317 | } |
---|
2318 | |
---|
2319 | void CNc4DataOutput::closeFile_ (void) |
---|
2320 | { |
---|
2321 | try |
---|
2322 | { |
---|
2323 | SuperClassWriter::close() ; |
---|
2324 | } |
---|
2325 | catch (CNetCdfException& e) |
---|
2326 | { |
---|
2327 | StdString msg("On closing file"); |
---|
2328 | msg.append("In the context : "); |
---|
2329 | CContext* context = CContext::getCurrent() ; |
---|
2330 | msg.append(context->getId()); msg.append("\n"); |
---|
2331 | msg.append(e.what()); |
---|
2332 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
2333 | } |
---|
2334 | |
---|
2335 | } |
---|
2336 | |
---|
2337 | //--------------------------------------------------------------- |
---|
2338 | |
---|
2339 | StdString CNc4DataOutput::getTimeStamp(void) const |
---|
2340 | { |
---|
2341 | const int buffer_size = 100; |
---|
2342 | time_t rawtime; |
---|
2343 | struct tm * timeinfo = NULL; |
---|
2344 | char buffer [buffer_size]; |
---|
2345 | StdString formatStr; |
---|
2346 | if (file->time_stamp_format.isEmpty()) formatStr="%Y-%b-%d %H:%M:%S %Z" ; |
---|
2347 | else formatStr=file->time_stamp_format; |
---|
2348 | |
---|
2349 | // time ( &rawtime ); |
---|
2350 | // timeinfo = localtime ( &rawtime ); |
---|
2351 | time ( &rawtime ); |
---|
2352 | timeinfo = gmtime ( &rawtime ); |
---|
2353 | strftime (buffer, buffer_size, formatStr.c_str(), timeinfo); |
---|
2354 | |
---|
2355 | return (StdString(buffer)); |
---|
2356 | } |
---|
2357 | |
---|
2358 | //--------------------------------------------------------------- |
---|
2359 | |
---|
2360 | void CNc4DataOutput::writeFieldData_ (CField* field) |
---|
2361 | { |
---|
2362 | CContext* context = CContext::getCurrent(); |
---|
2363 | CContextServer* server = context->server; |
---|
2364 | CGrid* grid = field->grid; |
---|
2365 | |
---|
2366 | if (field->getNStep()<1) |
---|
2367 | { |
---|
2368 | return; |
---|
2369 | } |
---|
2370 | |
---|
2371 | if (!grid->doGridHaveDataToWrite()) |
---|
2372 | if (SuperClass::type == MULTI_FILE || !isCollective) |
---|
2373 | { |
---|
2374 | return; |
---|
2375 | } |
---|
2376 | |
---|
2377 | StdString fieldid = field->getFieldOutputName(); |
---|
2378 | |
---|
2379 | StdOStringStream oss; |
---|
2380 | string timeAxisId; |
---|
2381 | if (field->hasTimeInstant) timeAxisId = "time_instant"; |
---|
2382 | else if (field->hasTimeCentered) timeAxisId = "time_centered"; |
---|
2383 | |
---|
2384 | StdString timeBoundId = getTimeCounterName() + "_bounds"; |
---|
2385 | |
---|
2386 | StdString timeAxisBoundId; |
---|
2387 | if (field->hasTimeInstant) timeAxisBoundId = "time_instant_bounds"; |
---|
2388 | else if (field->hasTimeCentered) timeAxisBoundId = "time_centered_bounds"; |
---|
2389 | |
---|
2390 | if (!field->wasWritten()) |
---|
2391 | { |
---|
2392 | if (appendMode && field->file->record_offset.isEmpty() && |
---|
2393 | field->getOperationTimeType() != func::CFunctor::once) |
---|
2394 | { |
---|
2395 | double factorUnit; |
---|
2396 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) |
---|
2397 | factorUnit=context->getCalendar()->getDayLengthInSeconds() ; |
---|
2398 | else factorUnit=1 ; |
---|
2399 | field->resetNStep(getRecordFromTime(field->last_Write_srv,factorUnit) + 1); |
---|
2400 | } |
---|
2401 | |
---|
2402 | field->setWritten(); |
---|
2403 | } |
---|
2404 | |
---|
2405 | |
---|
2406 | CArray<double,1> time_data(1); |
---|
2407 | CArray<double,1> time_data_bound(2); |
---|
2408 | CArray<double,1> time_counter(1); |
---|
2409 | CArray<double,1> time_counter_bound(2); |
---|
2410 | |
---|
2411 | bool wtime = (field->getOperationTimeType() != func::CFunctor::once); |
---|
2412 | bool wtimeCounter =false ; |
---|
2413 | bool wtimeData =false ; |
---|
2414 | |
---|
2415 | |
---|
2416 | if (wtime) |
---|
2417 | { |
---|
2418 | Time lastWrite = field->last_Write_srv; |
---|
2419 | Time lastLastWrite = field->lastlast_Write_srv; |
---|
2420 | |
---|
2421 | |
---|
2422 | if (field->hasTimeInstant) |
---|
2423 | { |
---|
2424 | time_data(0) = time_data_bound(1) = lastWrite; |
---|
2425 | time_data_bound(0) = time_data_bound(1) = lastWrite; |
---|
2426 | if (timeCounterType==instant) |
---|
2427 | { |
---|
2428 | time_counter(0) = time_data(0); |
---|
2429 | time_counter_bound(0) = time_data_bound(0); |
---|
2430 | time_counter_bound(1) = time_data_bound(1); |
---|
2431 | wtimeCounter=true ; |
---|
2432 | } |
---|
2433 | if (hasTimeInstant) wtimeData=true ; |
---|
2434 | } |
---|
2435 | else if (field->hasTimeCentered) |
---|
2436 | { |
---|
2437 | time_data(0) = (lastWrite + lastLastWrite) / 2; |
---|
2438 | time_data_bound(0) = lastLastWrite; |
---|
2439 | time_data_bound(1) = lastWrite; |
---|
2440 | if (timeCounterType==centered) |
---|
2441 | { |
---|
2442 | time_counter(0) = time_data(0) ; |
---|
2443 | time_counter_bound(0) = time_data_bound(0) ; |
---|
2444 | time_counter_bound(1) = time_data_bound(1) ; |
---|
2445 | wtimeCounter=true ; |
---|
2446 | } |
---|
2447 | if (hasTimeCentered) wtimeData=true ; |
---|
2448 | } |
---|
2449 | |
---|
2450 | if (timeCounterType==record) |
---|
2451 | { |
---|
2452 | time_counter(0) = field->getNStep() - 1; |
---|
2453 | time_counter_bound(0) = time_counter_bound(1) = field->getNStep() - 1; |
---|
2454 | wtimeCounter=true ; |
---|
2455 | } |
---|
2456 | |
---|
2457 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) |
---|
2458 | { |
---|
2459 | double secByDay=context->getCalendar()->getDayLengthInSeconds() ; |
---|
2460 | time_data/=secByDay; |
---|
2461 | time_data_bound/=secByDay; |
---|
2462 | time_counter/=secByDay; |
---|
2463 | time_counter_bound/=secByDay; |
---|
2464 | } |
---|
2465 | } |
---|
2466 | |
---|
2467 | bool isRoot = (server->intraCommRank == 0); |
---|
2468 | |
---|
2469 | if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) |
---|
2470 | { |
---|
2471 | double scaleFactor = 1.0; |
---|
2472 | double addOffset = 0.0; |
---|
2473 | if (!field->scale_factor.isEmpty()) scaleFactor = field->scale_factor; |
---|
2474 | if (!field->add_offset.isEmpty()) addOffset = field->add_offset; |
---|
2475 | field->scaleFactorAddOffset(scaleFactor, addOffset); |
---|
2476 | } |
---|
2477 | |
---|
2478 | try |
---|
2479 | { |
---|
2480 | size_t writtenSize; |
---|
2481 | if (field->getUseCompressedOutput()) |
---|
2482 | writtenSize = grid->getNumberWrittenIndexes(); |
---|
2483 | else |
---|
2484 | writtenSize = grid->getWrittenDataSize(); |
---|
2485 | |
---|
2486 | CArray<double,1> fieldData(writtenSize); |
---|
2487 | if (!field->default_value.isEmpty()) fieldData = field->default_value; |
---|
2488 | |
---|
2489 | if (field->getUseCompressedOutput()) |
---|
2490 | field->outputCompressedField(fieldData); |
---|
2491 | else |
---|
2492 | field->outputField(fieldData); |
---|
2493 | |
---|
2494 | if (!field->prec.isEmpty() && field->prec == 2) fieldData = round(fieldData); |
---|
2495 | |
---|
2496 | switch (SuperClass::type) |
---|
2497 | { |
---|
2498 | case (MULTI_FILE) : |
---|
2499 | { |
---|
2500 | CTimer::get("Files : writing data").resume(); |
---|
2501 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1); |
---|
2502 | CTimer::get("Files : writing data").suspend(); |
---|
2503 | if (wtime) |
---|
2504 | { |
---|
2505 | CTimer::get("Files : writing time axis").resume(); |
---|
2506 | if ( wtimeData) |
---|
2507 | { |
---|
2508 | SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); |
---|
2509 | SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
2510 | } |
---|
2511 | if (wtimeCounter) |
---|
2512 | { |
---|
2513 | SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); |
---|
2514 | if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
2515 | } |
---|
2516 | CTimer::get("Files : writing time axis").suspend(); |
---|
2517 | } |
---|
2518 | break; |
---|
2519 | } |
---|
2520 | case (ONE_FILE) : |
---|
2521 | { |
---|
2522 | const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); |
---|
2523 | const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); |
---|
2524 | const std::vector<int>& nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); |
---|
2525 | |
---|
2526 | std::vector<StdSize> start, count; |
---|
2527 | |
---|
2528 | if (field->getUseCompressedOutput()) |
---|
2529 | { |
---|
2530 | if (grid->isCompressible()) |
---|
2531 | { |
---|
2532 | start.push_back(grid->getOffsetWrittenIndexes()); |
---|
2533 | count.push_back(grid->getNumberWrittenIndexes()); |
---|
2534 | } |
---|
2535 | else |
---|
2536 | { |
---|
2537 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
2538 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
2539 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
2540 | int numElement = axisDomainOrder.numElements(); |
---|
2541 | int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; |
---|
2542 | int idx = nZoomBeginGlobal.size() - 1; |
---|
2543 | |
---|
2544 | start.reserve(nZoomBeginGlobal.size()); |
---|
2545 | count.reserve(nZoomBeginGlobal.size()); |
---|
2546 | |
---|
2547 | |
---|
2548 | for (int i = numElement - 1; i >= 0; --i) |
---|
2549 | { |
---|
2550 | if (2 == axisDomainOrder(i)) |
---|
2551 | { |
---|
2552 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
2553 | |
---|
2554 | if (domain->isCompressible()) |
---|
2555 | { |
---|
2556 | start.push_back(domain->getOffsetWrittenIndexes(comm_file)); |
---|
2557 | count.push_back(domain->getNumberWrittenIndexes(comm_file)); |
---|
2558 | idx -= 2; |
---|
2559 | } |
---|
2560 | else |
---|
2561 | { |
---|
2562 | if ((domain->type) != CDomain::type_attr::unstructured) |
---|
2563 | { |
---|
2564 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
2565 | count.push_back(nZoomSizeServer[idx]); |
---|
2566 | } |
---|
2567 | --idx; |
---|
2568 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
2569 | count.push_back(nZoomSizeServer[idx]); |
---|
2570 | --idx; |
---|
2571 | } |
---|
2572 | --idxDomain; |
---|
2573 | } |
---|
2574 | else if (1 == axisDomainOrder(i)) |
---|
2575 | { |
---|
2576 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
2577 | |
---|
2578 | if (axis->isCompressible()) |
---|
2579 | { |
---|
2580 | start.push_back(axis->getOffsetWrittenIndexes(comm_file)); |
---|
2581 | count.push_back(axis->getNumberWrittenIndexes(comm_file)); |
---|
2582 | } |
---|
2583 | else |
---|
2584 | { |
---|
2585 | start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); |
---|
2586 | count.push_back(nZoomSizeServer[idx]); |
---|
2587 | } |
---|
2588 | --idxAxis; |
---|
2589 | --idx; |
---|
2590 | } |
---|
2591 | } |
---|
2592 | } |
---|
2593 | } |
---|
2594 | else |
---|
2595 | { |
---|
2596 | CArray<int,1> axisDomainOrder = grid->axis_domain_order; |
---|
2597 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
2598 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
2599 | int numElement = axisDomainOrder.numElements(); |
---|
2600 | int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; |
---|
2601 | int idx = domainList.size() * 2 + axisList.size() - 1; |
---|
2602 | |
---|
2603 | start.reserve(nZoomBeginGlobal.size()); |
---|
2604 | count.reserve(nZoomBeginGlobal.size()); |
---|
2605 | |
---|
2606 | for (int i = numElement - 1; i >= 0; --i) |
---|
2607 | { |
---|
2608 | if (2 == axisDomainOrder(i)) |
---|
2609 | { |
---|
2610 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
2611 | if ((domain->type) != CDomain::type_attr::unstructured) |
---|
2612 | { |
---|
2613 | start.push_back(domain->zoom_jbegin - domain->global_zoom_jbegin); |
---|
2614 | count.push_back(domain->zoom_nj); |
---|
2615 | } |
---|
2616 | --idx ; |
---|
2617 | |
---|
2618 | start.push_back(domain->zoom_ibegin - domain->global_zoom_ibegin); |
---|
2619 | count.push_back(domain->zoom_ni); |
---|
2620 | --idx ; |
---|
2621 | --idxDomain; |
---|
2622 | } |
---|
2623 | else if (1 == axisDomainOrder(i)) |
---|
2624 | { |
---|
2625 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
2626 | start.push_back(axis->zoom_begin - axis->global_zoom_begin); |
---|
2627 | count.push_back(axis->zoom_n); |
---|
2628 | --idx; |
---|
2629 | --idxAxis; |
---|
2630 | } |
---|
2631 | else |
---|
2632 | { |
---|
2633 | if (1 == axisDomainOrder.numElements()) |
---|
2634 | { |
---|
2635 | start.push_back(0); |
---|
2636 | count.push_back(1); |
---|
2637 | } |
---|
2638 | --idx; |
---|
2639 | } |
---|
2640 | } |
---|
2641 | } |
---|
2642 | |
---|
2643 | |
---|
2644 | CTimer::get("Files : writing data").resume(); |
---|
2645 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep() - 1, &start, &count); |
---|
2646 | CTimer::get("Files : writing data").suspend(); |
---|
2647 | |
---|
2648 | if (wtime) |
---|
2649 | { |
---|
2650 | CTimer::get("Files : writing time axis").resume(); |
---|
2651 | if ( wtimeData) |
---|
2652 | { |
---|
2653 | SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep() - 1, isRoot); |
---|
2654 | SuperClassWriter::writeTimeAxisDataBounds(time_data_bound, timeAxisBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
2655 | } |
---|
2656 | if (wtimeCounter) |
---|
2657 | { |
---|
2658 | SuperClassWriter::writeTimeAxisData(time_counter, getTimeCounterName(), isCollective, field->getNStep() - 1,isRoot); |
---|
2659 | if (timeCounterType!=record) SuperClassWriter::writeTimeAxisDataBounds(time_counter_bound, timeBoundId, isCollective, field->getNStep() - 1, isRoot); |
---|
2660 | |
---|
2661 | } |
---|
2662 | CTimer::get("Files : writing time axis").suspend(); |
---|
2663 | } |
---|
2664 | |
---|
2665 | break; |
---|
2666 | } |
---|
2667 | } |
---|
2668 | } |
---|
2669 | catch (CNetCdfException& e) |
---|
2670 | { |
---|
2671 | StdString msg("On writing field data: "); |
---|
2672 | msg.append(fieldid); msg.append("\n"); |
---|
2673 | msg.append("In the context : "); |
---|
2674 | msg.append(context->getId()); msg.append("\n"); |
---|
2675 | msg.append(e.what()); |
---|
2676 | ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg); |
---|
2677 | } |
---|
2678 | } |
---|
2679 | |
---|
2680 | //--------------------------------------------------------------- |
---|
2681 | |
---|
2682 | void CNc4DataOutput::writeTimeAxis_ |
---|
2683 | (CField* field, |
---|
2684 | const boost::shared_ptr<CCalendar> cal) |
---|
2685 | { |
---|
2686 | StdOStringStream oss; |
---|
2687 | bool createInstantAxis=false ; |
---|
2688 | bool createCenteredAxis=false ; |
---|
2689 | bool createTimeCounterAxis=false ; |
---|
2690 | |
---|
2691 | if (field->getOperationTimeType() == func::CFunctor::once) return ; |
---|
2692 | |
---|
2693 | |
---|
2694 | StdString axisId ; |
---|
2695 | StdString axisBoundId; |
---|
2696 | StdString timeid(getTimeCounterName()); |
---|
2697 | StdString timeBoundId("axis_nbounds"); |
---|
2698 | |
---|
2699 | StdString strTimeUnits ; |
---|
2700 | if (!field->file->time_units.isEmpty() && field->file->time_units==CFile::time_units_attr::days) strTimeUnits="days since " ; |
---|
2701 | else strTimeUnits="seconds since " ; |
---|
2702 | |
---|
2703 | if (field->getOperationTimeType() == func::CFunctor::instant) field->hasTimeInstant = true; |
---|
2704 | if (field->getOperationTimeType() == func::CFunctor::centered) field->hasTimeCentered = true; |
---|
2705 | |
---|
2706 | |
---|
2707 | if (field->file->time_counter.isEmpty()) |
---|
2708 | { |
---|
2709 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2710 | if (field->hasTimeCentered) |
---|
2711 | { |
---|
2712 | timeCounterType=centered ; |
---|
2713 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2714 | } |
---|
2715 | if (field->hasTimeInstant) |
---|
2716 | { |
---|
2717 | if (timeCounterType==none) timeCounterType=instant ; |
---|
2718 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2719 | } |
---|
2720 | } |
---|
2721 | else if (field->file->time_counter==CFile::time_counter_attr::instant) |
---|
2722 | { |
---|
2723 | if (field->hasTimeCentered) |
---|
2724 | { |
---|
2725 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2726 | } |
---|
2727 | if (field->hasTimeInstant) |
---|
2728 | { |
---|
2729 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2730 | timeCounterType=instant ; |
---|
2731 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2732 | } |
---|
2733 | } |
---|
2734 | else if (field->file->time_counter==CFile::time_counter_attr::centered) |
---|
2735 | { |
---|
2736 | if (field->hasTimeCentered) |
---|
2737 | { |
---|
2738 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2739 | timeCounterType=centered ; |
---|
2740 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2741 | } |
---|
2742 | if (field->hasTimeInstant) |
---|
2743 | { |
---|
2744 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2745 | } |
---|
2746 | } |
---|
2747 | else if (field->file->time_counter==CFile::time_counter_attr::instant_exclusive) |
---|
2748 | { |
---|
2749 | if (field->hasTimeCentered) |
---|
2750 | { |
---|
2751 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2752 | } |
---|
2753 | if (field->hasTimeInstant) |
---|
2754 | { |
---|
2755 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2756 | timeCounterType=instant ; |
---|
2757 | } |
---|
2758 | } |
---|
2759 | else if (field->file->time_counter==CFile::time_counter_attr::centered_exclusive) |
---|
2760 | { |
---|
2761 | if (field->hasTimeCentered) |
---|
2762 | { |
---|
2763 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2764 | timeCounterType=centered ; |
---|
2765 | } |
---|
2766 | if (field->hasTimeInstant) |
---|
2767 | { |
---|
2768 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2769 | } |
---|
2770 | } |
---|
2771 | else if (field->file->time_counter==CFile::time_counter_attr::exclusive) |
---|
2772 | { |
---|
2773 | if (field->hasTimeCentered) |
---|
2774 | { |
---|
2775 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2776 | if (timeCounterType==instant) createInstantAxis=true ; |
---|
2777 | timeCounterType=centered ; |
---|
2778 | } |
---|
2779 | if (field->hasTimeInstant) |
---|
2780 | { |
---|
2781 | if (timeCounterType==none) |
---|
2782 | { |
---|
2783 | createTimeCounterAxis=true ; |
---|
2784 | timeCounterType=instant ; |
---|
2785 | } |
---|
2786 | if (timeCounterType==centered) |
---|
2787 | { |
---|
2788 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2789 | } |
---|
2790 | } |
---|
2791 | } |
---|
2792 | else if (field->file->time_counter==CFile::time_counter_attr::none) |
---|
2793 | { |
---|
2794 | if (field->hasTimeCentered) |
---|
2795 | { |
---|
2796 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2797 | } |
---|
2798 | if (field->hasTimeInstant) |
---|
2799 | { |
---|
2800 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2801 | } |
---|
2802 | } |
---|
2803 | else if (field->file->time_counter==CFile::time_counter_attr::record) |
---|
2804 | { |
---|
2805 | if (timeCounterType==none) createTimeCounterAxis=true ; |
---|
2806 | timeCounterType=record ; |
---|
2807 | if (field->hasTimeCentered) |
---|
2808 | { |
---|
2809 | if (!hasTimeCentered) createCenteredAxis=true ; |
---|
2810 | } |
---|
2811 | if (field->hasTimeInstant) |
---|
2812 | { |
---|
2813 | if (!hasTimeInstant) createInstantAxis=true ; |
---|
2814 | } |
---|
2815 | } |
---|
2816 | |
---|
2817 | if (createInstantAxis) |
---|
2818 | { |
---|
2819 | axisId="time_instant" ; |
---|
2820 | axisBoundId="time_instant_bounds"; |
---|
2821 | hasTimeInstant=true ; |
---|
2822 | } |
---|
2823 | |
---|
2824 | if (createCenteredAxis) |
---|
2825 | { |
---|
2826 | axisId="time_centered" ; |
---|
2827 | axisBoundId="time_centered_bounds"; |
---|
2828 | hasTimeCentered=true ; |
---|
2829 | } |
---|
2830 | |
---|
2831 | |
---|
2832 | try |
---|
2833 | { |
---|
2834 | std::vector<StdString> dims; |
---|
2835 | |
---|
2836 | if (createInstantAxis || createCenteredAxis) |
---|
2837 | { |
---|
2838 | // Adding time_instant or time_centered |
---|
2839 | dims.push_back(timeid); |
---|
2840 | if (!SuperClassWriter::varExist(axisId)) |
---|
2841 | { |
---|
2842 | SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); |
---|
2843 | |
---|
2844 | CDate timeOrigin=cal->getTimeOrigin() ; |
---|
2845 | StdOStringStream oss2; |
---|
2846 | StdString strInitdate=oss2.str() ; |
---|
2847 | StdString strTimeOrigin=timeOrigin.toString() ; |
---|
2848 | this->writeTimeAxisAttributes(axisId, cal->getType(),strTimeUnits+strTimeOrigin, |
---|
2849 | strTimeOrigin, axisBoundId); |
---|
2850 | } |
---|
2851 | |
---|
2852 | // Adding time_instant_bounds or time_centered_bounds variables |
---|
2853 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
2854 | { |
---|
2855 | dims.clear() ; |
---|
2856 | dims.push_back(timeid); |
---|
2857 | dims.push_back(timeBoundId); |
---|
2858 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
2859 | } |
---|
2860 | } |
---|
2861 | |
---|
2862 | if (createTimeCounterAxis) |
---|
2863 | { |
---|
2864 | // Adding time_counter |
---|
2865 | axisId = getTimeCounterName(); |
---|
2866 | axisBoundId = getTimeCounterName() + "_bounds"; |
---|
2867 | dims.clear(); |
---|
2868 | dims.push_back(timeid); |
---|
2869 | if (!SuperClassWriter::varExist(axisId)) |
---|
2870 | { |
---|
2871 | SuperClassWriter::addVariable(axisId, NC_DOUBLE, dims); |
---|
2872 | SuperClassWriter::addAttribute("axis", string("T"), &axisId); |
---|
2873 | |
---|
2874 | if (field->file->time_counter.isEmpty() || |
---|
2875 | (field->file->time_counter != CFile::time_counter_attr::record)) |
---|
2876 | { |
---|
2877 | CDate timeOrigin = cal->getTimeOrigin(); |
---|
2878 | StdString strTimeOrigin = timeOrigin.toString(); |
---|
2879 | |
---|
2880 | this->writeTimeAxisAttributes(axisId, cal->getType(), |
---|
2881 | strTimeUnits+strTimeOrigin, |
---|
2882 | strTimeOrigin, axisBoundId); |
---|
2883 | } |
---|
2884 | } |
---|
2885 | |
---|
2886 | // Adding time_counter_bound dimension |
---|
2887 | if (field->file->time_counter.isEmpty() || (field->file->time_counter != CFile::time_counter_attr::record)) |
---|
2888 | { |
---|
2889 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
2890 | { |
---|
2891 | dims.clear(); |
---|
2892 | dims.push_back(timeid); |
---|
2893 | dims.push_back(timeBoundId); |
---|
2894 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
2895 | } |
---|
2896 | } |
---|
2897 | } |
---|
2898 | } |
---|
2899 | catch (CNetCdfException& e) |
---|
2900 | { |
---|
2901 | StdString msg("On writing time axis data: "); |
---|
2902 | msg.append("In the context : "); |
---|
2903 | CContext* context = CContext::getCurrent() ; |
---|
2904 | msg.append(context->getId()); msg.append("\n"); |
---|
2905 | msg.append(e.what()); |
---|
2906 | ERROR("CNc4DataOutput::writeTimeAxis_ (CField* field, \ |
---|
2907 | const boost::shared_ptr<CCalendar> cal)", << msg); |
---|
2908 | } |
---|
2909 | } |
---|
2910 | |
---|
2911 | //--------------------------------------------------------------- |
---|
2912 | |
---|
2913 | void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, |
---|
2914 | const StdString & calendar, |
---|
2915 | const StdString & units, |
---|
2916 | const StdString & time_origin, |
---|
2917 | const StdString & time_bounds, |
---|
2918 | const StdString & standard_name, |
---|
2919 | const StdString & long_name) |
---|
2920 | { |
---|
2921 | try |
---|
2922 | { |
---|
2923 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
2924 | SuperClassWriter::addAttribute("long_name", long_name , &axis_name); |
---|
2925 | SuperClassWriter::addAttribute("calendar", calendar , &axis_name); |
---|
2926 | SuperClassWriter::addAttribute("units", units , &axis_name); |
---|
2927 | SuperClassWriter::addAttribute("time_origin", time_origin , &axis_name); |
---|
2928 | SuperClassWriter::addAttribute("bounds", time_bounds , &axis_name); |
---|
2929 | } |
---|
2930 | catch (CNetCdfException& e) |
---|
2931 | { |
---|
2932 | StdString msg("On writing time axis Attribute: "); |
---|
2933 | msg.append("In the context : "); |
---|
2934 | CContext* context = CContext::getCurrent() ; |
---|
2935 | msg.append(context->getId()); msg.append("\n"); |
---|
2936 | msg.append(e.what()); |
---|
2937 | ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \ |
---|
2938 | const StdString & calendar,\ |
---|
2939 | const StdString & units, \ |
---|
2940 | const StdString & time_origin, \ |
---|
2941 | const StdString & time_bounds, \ |
---|
2942 | const StdString & standard_name, \ |
---|
2943 | const StdString & long_name)", << msg); |
---|
2944 | } |
---|
2945 | } |
---|
2946 | |
---|
2947 | //--------------------------------------------------------------- |
---|
2948 | |
---|
2949 | void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, |
---|
2950 | const StdString & axis, |
---|
2951 | const StdString & standard_name, |
---|
2952 | const StdString & long_name, |
---|
2953 | const StdString & units, |
---|
2954 | const StdString & nav_model) |
---|
2955 | { |
---|
2956 | try |
---|
2957 | { |
---|
2958 | if (!axis.empty()) |
---|
2959 | SuperClassWriter::addAttribute("axis" , axis , &axis_name); |
---|
2960 | |
---|
2961 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
2962 | SuperClassWriter::addAttribute("long_name" , long_name , &axis_name); |
---|
2963 | SuperClassWriter::addAttribute("units" , units , &axis_name); |
---|
2964 | // SuperClassWriter::addAttribute("nav_model" , nav_model , &axis_name); |
---|
2965 | } |
---|
2966 | catch (CNetCdfException& e) |
---|
2967 | { |
---|
2968 | StdString msg("On writing Axis Attribute: "); |
---|
2969 | msg.append("In the context : "); |
---|
2970 | CContext* context = CContext::getCurrent() ; |
---|
2971 | msg.append(context->getId()); msg.append("\n"); |
---|
2972 | msg.append(e.what()); |
---|
2973 | ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \ |
---|
2974 | const StdString & axis, \ |
---|
2975 | const StdString & standard_name, \ |
---|
2976 | const StdString & long_name, \ |
---|
2977 | const StdString & units, \ |
---|
2978 | const StdString & nav_model)", << msg); |
---|
2979 | } |
---|
2980 | } |
---|
2981 | |
---|
2982 | //--------------------------------------------------------------- |
---|
2983 | |
---|
2984 | void CNc4DataOutput::writeLocalAttributes |
---|
2985 | (int ibegin, int ni, int jbegin, int nj, StdString domid) |
---|
2986 | { |
---|
2987 | try |
---|
2988 | { |
---|
2989 | SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin); |
---|
2990 | SuperClassWriter::addAttribute(StdString("ni" ).append(domid), ni); |
---|
2991 | SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin); |
---|
2992 | SuperClassWriter::addAttribute(StdString("nj" ).append(domid), nj); |
---|
2993 | } |
---|
2994 | catch (CNetCdfException& e) |
---|
2995 | { |
---|
2996 | StdString msg("On writing Local Attributes: "); |
---|
2997 | msg.append("In the context : "); |
---|
2998 | CContext* context = CContext::getCurrent() ; |
---|
2999 | msg.append(context->getId()); msg.append("\n"); |
---|
3000 | msg.append(e.what()); |
---|
3001 | ERROR("CNc4DataOutput::writeLocalAttributes \ |
---|
3002 | (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg); |
---|
3003 | } |
---|
3004 | |
---|
3005 | } |
---|
3006 | |
---|
3007 | void CNc4DataOutput::writeLocalAttributes_IOIPSL(const StdString& dimXid, const StdString& dimYid, |
---|
3008 | int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size) |
---|
3009 | { |
---|
3010 | CArray<int,1> array(2) ; |
---|
3011 | |
---|
3012 | try |
---|
3013 | { |
---|
3014 | SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ; |
---|
3015 | SuperClassWriter::addAttribute("DOMAIN_number", rank) ; |
---|
3016 | array = SuperClassWriter::getDimension(dimXid) + 1, SuperClassWriter::getDimension(dimYid) + 1; |
---|
3017 | SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ; |
---|
3018 | array=ni_glo,nj_glo ; |
---|
3019 | SuperClassWriter::addAttribute("DOMAIN_size_global", array) ; |
---|
3020 | array=ni,nj ; |
---|
3021 | SuperClassWriter::addAttribute("DOMAIN_size_local", array) ; |
---|
3022 | array=ibegin+1,jbegin+1 ; |
---|
3023 | SuperClassWriter::addAttribute("DOMAIN_position_first", array) ; |
---|
3024 | array=ibegin+ni-1+1,jbegin+nj-1+1 ; |
---|
3025 | SuperClassWriter::addAttribute("DOMAIN_position_last",array) ; |
---|
3026 | array=0,0 ; |
---|
3027 | SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ; |
---|
3028 | SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array); |
---|
3029 | SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ; |
---|
3030 | /* |
---|
3031 | SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ; |
---|
3032 | SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ; |
---|
3033 | SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ; |
---|
3034 | SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ; |
---|
3035 | */ |
---|
3036 | } |
---|
3037 | catch (CNetCdfException& e) |
---|
3038 | { |
---|
3039 | StdString msg("On writing Local Attributes IOIPSL \n"); |
---|
3040 | msg.append("In the context : "); |
---|
3041 | CContext* context = CContext::getCurrent() ; |
---|
3042 | msg.append(context->getId()); msg.append("\n"); |
---|
3043 | msg.append(e.what()); |
---|
3044 | ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \ |
---|
3045 | (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg); |
---|
3046 | } |
---|
3047 | } |
---|
3048 | //--------------------------------------------------------------- |
---|
3049 | |
---|
3050 | void CNc4DataOutput:: writeFileAttributes(const StdString & name, |
---|
3051 | const StdString & description, |
---|
3052 | const StdString & conventions, |
---|
3053 | const StdString & production, |
---|
3054 | const StdString & timeStamp) |
---|
3055 | { |
---|
3056 | try |
---|
3057 | { |
---|
3058 | SuperClassWriter::addAttribute("name" , name); |
---|
3059 | SuperClassWriter::addAttribute("description", description); |
---|
3060 | SuperClassWriter::addAttribute("title" , description); |
---|
3061 | SuperClassWriter::addAttribute("Conventions", conventions); |
---|
3062 | // SuperClassWriter::addAttribute("production" , production); |
---|
3063 | |
---|
3064 | StdString timeStampStr ; |
---|
3065 | if (file->time_stamp_name.isEmpty()) timeStampStr="timeStamp" ; |
---|
3066 | else timeStampStr=file->time_stamp_name ; |
---|
3067 | SuperClassWriter::addAttribute(timeStampStr, timeStamp); |
---|
3068 | |
---|
3069 | StdString uuidName ; |
---|
3070 | if (file->uuid_name.isEmpty()) uuidName="uuid" ; |
---|
3071 | else uuidName=file->uuid_name ; |
---|
3072 | |
---|
3073 | if (file->uuid_format.isEmpty()) SuperClassWriter::addAttribute(uuidName, getUuidStr()); |
---|
3074 | else SuperClassWriter::addAttribute(uuidName, getUuidStr(file->uuid_format)); |
---|
3075 | |
---|
3076 | } |
---|
3077 | catch (CNetCdfException& e) |
---|
3078 | { |
---|
3079 | StdString msg("On writing File Attributes \n "); |
---|
3080 | msg.append("In the context : "); |
---|
3081 | CContext* context = CContext::getCurrent() ; |
---|
3082 | msg.append(context->getId()); msg.append("\n"); |
---|
3083 | msg.append(e.what()); |
---|
3084 | ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \ |
---|
3085 | const StdString & description, \ |
---|
3086 | const StdString & conventions, \ |
---|
3087 | const StdString & production, \ |
---|
3088 | const StdString & timeStamp)", << msg); |
---|
3089 | } |
---|
3090 | } |
---|
3091 | |
---|
3092 | //--------------------------------------------------------------- |
---|
3093 | |
---|
3094 | void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, |
---|
3095 | int data_dim, |
---|
3096 | int data_ni, |
---|
3097 | int data_nj, |
---|
3098 | int data_ibegin, |
---|
3099 | int data_jbegin) |
---|
3100 | { |
---|
3101 | try |
---|
3102 | { |
---|
3103 | SuperClassWriter::addAttribute("data_dim" , data_dim , &mask_name); |
---|
3104 | SuperClassWriter::addAttribute("data_ni" , data_ni , &mask_name); |
---|
3105 | SuperClassWriter::addAttribute("data_nj" , data_nj , &mask_name); |
---|
3106 | SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name); |
---|
3107 | SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name); |
---|
3108 | } |
---|
3109 | catch (CNetCdfException& e) |
---|
3110 | { |
---|
3111 | StdString msg("On writing Mask Attributes \n "); |
---|
3112 | msg.append("In the context : "); |
---|
3113 | CContext* context = CContext::getCurrent() ; |
---|
3114 | msg.append(context->getId()); msg.append("\n"); |
---|
3115 | msg.append(e.what()); |
---|
3116 | ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \ |
---|
3117 | int data_dim, \ |
---|
3118 | int data_ni, \ |
---|
3119 | int data_nj, \ |
---|
3120 | int data_ibegin, \ |
---|
3121 | int data_jbegin)", << msg); |
---|
3122 | } |
---|
3123 | } |
---|
3124 | |
---|
3125 | ///-------------------------------------------------------------- |
---|
3126 | |
---|
3127 | StdSize CNc4DataOutput::getRecordFromTime(Time time, double factorUnit) |
---|
3128 | { |
---|
3129 | std::map<Time, StdSize>::const_iterator it = timeToRecordCache.find(time); |
---|
3130 | if (it == timeToRecordCache.end()) |
---|
3131 | { |
---|
3132 | StdString timeAxisBoundsId(getTimeCounterName() + "_bounds"); |
---|
3133 | if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_centered_bounds"; |
---|
3134 | if (!SuperClassWriter::varExist(timeAxisBoundsId)) timeAxisBoundsId = "time_instant_bounds"; |
---|
3135 | |
---|
3136 | CArray<double,2> timeAxisBounds; |
---|
3137 | std::vector<StdSize> dimSize(SuperClassWriter::getDimensions(timeAxisBoundsId)) ; |
---|
3138 | |
---|
3139 | StdSize record = 0; |
---|
3140 | double dtime(time); |
---|
3141 | for (int n = dimSize[0] - 1; n >= 0; n--) |
---|
3142 | { |
---|
3143 | SuperClassWriter::getTimeAxisBounds(timeAxisBounds, timeAxisBoundsId, isCollective, n); |
---|
3144 | timeAxisBounds*=factorUnit ; |
---|
3145 | if (timeAxisBounds(1, 0) < dtime) |
---|
3146 | { |
---|
3147 | record = n + 1; |
---|
3148 | break; |
---|
3149 | } |
---|
3150 | } |
---|
3151 | it = timeToRecordCache.insert(std::make_pair(time, record)).first; |
---|
3152 | } |
---|
3153 | return it->second; |
---|
3154 | } |
---|
3155 | |
---|
3156 | ///-------------------------------------------------------------- |
---|
3157 | |
---|
3158 | bool CNc4DataOutput::isWrittenDomain(const std::string& domainName) const |
---|
3159 | { |
---|
3160 | return (this->writtenDomains.find(domainName) != this->writtenDomains.end()); |
---|
3161 | } |
---|
3162 | |
---|
3163 | bool CNc4DataOutput::isWrittenCompressedDomain(const std::string& domainName) const |
---|
3164 | { |
---|
3165 | return (this->writtenCompressedDomains.find(domainName) != this->writtenCompressedDomains.end()); |
---|
3166 | } |
---|
3167 | |
---|
3168 | bool CNc4DataOutput::isWrittenAxis(const std::string& axisName) const |
---|
3169 | { |
---|
3170 | return (this->writtenAxis.find(axisName) != this->writtenAxis.end()); |
---|
3171 | } |
---|
3172 | |
---|
3173 | bool CNc4DataOutput::isWrittenCompressedAxis(const std::string& axisName) const |
---|
3174 | { |
---|
3175 | return (this->writtenCompressedAxis.find(axisName) != this->writtenCompressedAxis.end()); |
---|
3176 | } |
---|
3177 | |
---|
3178 | bool CNc4DataOutput::isWrittenScalar(const std::string& scalarName) const |
---|
3179 | { |
---|
3180 | return (this->writtenScalar.find(scalarName) != this->writtenScalar.end()); |
---|
3181 | } |
---|
3182 | |
---|
3183 | void CNc4DataOutput::setWrittenDomain(const std::string& domainName) |
---|
3184 | { |
---|
3185 | this->writtenDomains.insert(domainName); |
---|
3186 | } |
---|
3187 | |
---|
3188 | void CNc4DataOutput::setWrittenCompressedDomain(const std::string& domainName) |
---|
3189 | { |
---|
3190 | this->writtenCompressedDomains.insert(domainName); |
---|
3191 | } |
---|
3192 | |
---|
3193 | void CNc4DataOutput::setWrittenAxis(const std::string& axisName) |
---|
3194 | { |
---|
3195 | this->writtenAxis.insert(axisName); |
---|
3196 | } |
---|
3197 | |
---|
3198 | void CNc4DataOutput::setWrittenCompressedAxis(const std::string& axisName) |
---|
3199 | { |
---|
3200 | this->writtenCompressedAxis.insert(axisName); |
---|
3201 | } |
---|
3202 | |
---|
3203 | void CNc4DataOutput::setWrittenScalar(const std::string& scalarName) |
---|
3204 | { |
---|
3205 | this->writtenScalar.insert(scalarName); |
---|
3206 | } |
---|
3207 | } // namespace xios |
---|