1 | |
---|
2 | #include "nc4_data_output.hpp" |
---|
3 | |
---|
4 | #include <boost/lexical_cast.hpp> |
---|
5 | #include "attribute_template.hpp" |
---|
6 | #include "group_template.hpp" |
---|
7 | |
---|
8 | #include "file.hpp" |
---|
9 | #include "calendar.hpp" |
---|
10 | #include "context.hpp" |
---|
11 | #include "context_server.hpp" |
---|
12 | #include "netCdfException.hpp" |
---|
13 | #include "exception.hpp" |
---|
14 | |
---|
15 | namespace xios |
---|
16 | { |
---|
17 | /// ////////////////////// Définitions ////////////////////// /// |
---|
18 | CNc4DataOutput::CNc4DataOutput |
---|
19 | (const StdString & filename, bool exist) |
---|
20 | : SuperClass() |
---|
21 | , SuperClassWriter(filename, exist) |
---|
22 | , filename(filename) |
---|
23 | { |
---|
24 | StdString timeid = StdString("time_counter"); |
---|
25 | SuperClass::type = MULTI_FILE; |
---|
26 | // if (!exist) |
---|
27 | // SuperClassWriter::addDimension(timeid); |
---|
28 | } |
---|
29 | |
---|
30 | CNc4DataOutput::CNc4DataOutput |
---|
31 | (const StdString & filename, bool exist, bool useClassicFormat, |
---|
32 | MPI_Comm comm_file,bool multifile, bool isCollective) |
---|
33 | : SuperClass() |
---|
34 | , SuperClassWriter(filename, exist, useClassicFormat, &comm_file, multifile) |
---|
35 | , comm_file(comm_file) |
---|
36 | , filename(filename) |
---|
37 | , isCollective(isCollective) |
---|
38 | { |
---|
39 | StdString timeid = StdString("time_counter"); |
---|
40 | |
---|
41 | SuperClass::type = (multifile) ? MULTI_FILE : ONE_FILE; |
---|
42 | |
---|
43 | // if (!exist) |
---|
44 | // SuperClassWriter::addDimension(timeid); |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | CNc4DataOutput::~CNc4DataOutput(void) |
---|
49 | { /* Ne rien faire de plus */ } |
---|
50 | |
---|
51 | ///-------------------------------------------------------------- |
---|
52 | |
---|
53 | const StdString & CNc4DataOutput::getFileName(void) const |
---|
54 | { |
---|
55 | return (this->filename); |
---|
56 | } |
---|
57 | |
---|
58 | //--------------------------------------------------------------- |
---|
59 | |
---|
60 | void CNc4DataOutput::writeDomain_(CDomain* domain) |
---|
61 | { |
---|
62 | if (domain->type == CDomain::type_attr::unstructured) |
---|
63 | { |
---|
64 | writeUnstructuredDomain(domain) ; |
---|
65 | return ; |
---|
66 | } |
---|
67 | |
---|
68 | CContext* context = CContext::getCurrent() ; |
---|
69 | CContextServer* server=context->server ; |
---|
70 | |
---|
71 | if (domain->IsWritten(this->filename)) return; |
---|
72 | domain->checkAttributes(); |
---|
73 | |
---|
74 | if (domain->isEmpty()) |
---|
75 | if (SuperClass::type==MULTI_FILE) return ; |
---|
76 | |
---|
77 | std::vector<StdString> dim0, dim1; |
---|
78 | StdString domid = (!domain->name.isEmpty()) |
---|
79 | ? domain->name.getValue() : domain->getId(); |
---|
80 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
81 | |
---|
82 | |
---|
83 | StdString dimXid, dimYid ; |
---|
84 | |
---|
85 | switch (domain->type) |
---|
86 | { |
---|
87 | case CDomain::type_attr::curvilinear : |
---|
88 | dimXid = StdString("x").append(appendDomid); |
---|
89 | dimYid = StdString("y").append(appendDomid); |
---|
90 | break ; |
---|
91 | case CDomain::type_attr::regular : |
---|
92 | dimXid = StdString("lon").append(appendDomid); |
---|
93 | dimYid = StdString("lat").append(appendDomid); |
---|
94 | break; |
---|
95 | case CDomain::type_attr::unstructured : |
---|
96 | dimXid = StdString("cell").append(appendDomid); |
---|
97 | break; |
---|
98 | } |
---|
99 | |
---|
100 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
101 | string areaId = "area" + appendDomid; |
---|
102 | /* |
---|
103 | StdString lonid_loc = (server->intraCommSize > 1) |
---|
104 | ? StdString("lon").append(appendDomid).append("_local") |
---|
105 | : lonid; |
---|
106 | StdString latid_loc = (server->intraCommSize > 1) |
---|
107 | ? StdString("lat").append(appendDomid).append("_local") |
---|
108 | : latid; |
---|
109 | */ |
---|
110 | |
---|
111 | try |
---|
112 | { |
---|
113 | switch (SuperClass::type) |
---|
114 | { |
---|
115 | case (MULTI_FILE) : |
---|
116 | { |
---|
117 | // if (domain->isEmpty()) return; |
---|
118 | |
---|
119 | if (server->intraCommSize > 1) |
---|
120 | { |
---|
121 | // SuperClassWriter::addDimension(lonid, domain->zoom_ni.getValue()); |
---|
122 | // SuperClassWriter::addDimension(latid, domain->zoom_nj.getValue()); |
---|
123 | } |
---|
124 | |
---|
125 | switch (domain->type) |
---|
126 | { |
---|
127 | case CDomain::type_attr::curvilinear : |
---|
128 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
129 | lonid = StdString("nav_lon").append(appendDomid); |
---|
130 | latid = StdString("nav_lat").append(appendDomid); |
---|
131 | break ; |
---|
132 | case CDomain::type_attr::regular : |
---|
133 | lonid = StdString("lon").append(appendDomid); |
---|
134 | latid = StdString("lat").append(appendDomid); |
---|
135 | dim0.push_back(dimYid); |
---|
136 | dim1.push_back(dimXid); |
---|
137 | break; |
---|
138 | case CDomain::type_attr::unstructured : |
---|
139 | lonid = StdString("lon").append(appendDomid); |
---|
140 | latid = StdString("lat").append(appendDomid); |
---|
141 | bounds_lonid=string("bounds_lon").append(appendDomid); |
---|
142 | bounds_latid=string("bounds_lat").append(appendDomid); |
---|
143 | dim0.push_back(dimXid); |
---|
144 | break; |
---|
145 | } |
---|
146 | |
---|
147 | if (domain->type == CDomain::type_attr::unstructured) |
---|
148 | { |
---|
149 | SuperClassWriter::addDimension(dimXid, domain->nj_glo); |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv); |
---|
154 | SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv); |
---|
155 | } |
---|
156 | |
---|
157 | if (server->intraCommSize > 1) |
---|
158 | { |
---|
159 | if (domain->type != CDomain::type_attr::unstructured) |
---|
160 | { |
---|
161 | this->writeLocalAttributes(domain->zoom_ibegin_srv, |
---|
162 | domain->zoom_ni_srv, |
---|
163 | domain->zoom_jbegin_srv, |
---|
164 | domain->zoom_nj_srv, |
---|
165 | appendDomid); |
---|
166 | |
---|
167 | if (singleDomain) this->writeLocalAttributes_IOIPSL(domain->zoom_ibegin_srv, |
---|
168 | domain->zoom_ni_srv, |
---|
169 | domain->zoom_jbegin_srv, |
---|
170 | domain->zoom_nj_srv, |
---|
171 | domain->ni_glo,domain->nj_glo, |
---|
172 | server->intraCommRank,server->intraCommSize); |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | switch (domain->type) |
---|
177 | { |
---|
178 | case CDomain::type_attr::curvilinear : |
---|
179 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
180 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); |
---|
181 | break ; |
---|
182 | case CDomain::type_attr::regular : |
---|
183 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
184 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1); |
---|
185 | break ; |
---|
186 | case CDomain::type_attr::unstructured : |
---|
187 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
188 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); |
---|
189 | } |
---|
190 | |
---|
191 | this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); |
---|
192 | this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); |
---|
193 | |
---|
194 | dim0.clear(); |
---|
195 | if (domain->type != CDomain::type_attr::unstructured) dim0.push_back(dimYid); |
---|
196 | dim0.push_back(dimXid); |
---|
197 | |
---|
198 | |
---|
199 | // supress mask if (server->intraCommSize > 1) |
---|
200 | // supress mask { |
---|
201 | // supress mask SuperClassWriter::addVariable(maskid, NC_INT, dim0); |
---|
202 | // supress mask |
---|
203 | // supress mask this->writeMaskAttributes(maskid, |
---|
204 | // supress mask domain->data_dim.getValue()/*, |
---|
205 | // supress mask domain->data_ni.getValue(), |
---|
206 | // supress mask domain->data_nj.getValue(), |
---|
207 | // supress mask domain->data_ibegin.getValue(), |
---|
208 | // supress mask domain->data_jbegin.getValue()*/); |
---|
209 | // supress mask } |
---|
210 | |
---|
211 | //SuperClassWriter::setDefaultValue(maskid, &dvm); |
---|
212 | |
---|
213 | if (domain->hasArea) |
---|
214 | { |
---|
215 | SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); |
---|
216 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
217 | } |
---|
218 | |
---|
219 | SuperClassWriter::definition_end(); |
---|
220 | |
---|
221 | switch (domain->type) |
---|
222 | { |
---|
223 | case CDomain::type_attr::curvilinear : |
---|
224 | SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); |
---|
225 | SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); |
---|
226 | break; |
---|
227 | case CDomain::type_attr::regular : |
---|
228 | CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; |
---|
229 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); |
---|
230 | CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ; |
---|
231 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); |
---|
232 | break; |
---|
233 | } |
---|
234 | |
---|
235 | if (domain->hasArea) |
---|
236 | SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0); |
---|
237 | |
---|
238 | SuperClassWriter::definition_start(); |
---|
239 | |
---|
240 | break; |
---|
241 | } |
---|
242 | case (ONE_FILE) : |
---|
243 | { |
---|
244 | SuperClassWriter::addDimension(dimXid, domain->zoom_ni.getValue()); |
---|
245 | SuperClassWriter::addDimension(dimYid, domain->zoom_nj.getValue()); |
---|
246 | |
---|
247 | switch (domain->type) |
---|
248 | { |
---|
249 | case CDomain::type_attr::curvilinear : |
---|
250 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
251 | lonid = StdString("nav_lon").append(appendDomid); |
---|
252 | latid = StdString("nav_lat").append(appendDomid); |
---|
253 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
254 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); |
---|
255 | break; |
---|
256 | |
---|
257 | case CDomain::type_attr::regular : |
---|
258 | dim0.push_back(dimYid); |
---|
259 | dim1.push_back(dimXid); |
---|
260 | lonid = StdString("lon").append(appendDomid); |
---|
261 | latid = StdString("lat").append(appendDomid); |
---|
262 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
263 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim1); |
---|
264 | break; |
---|
265 | } |
---|
266 | |
---|
267 | if (domain->hasArea) |
---|
268 | { |
---|
269 | dim0.clear(); |
---|
270 | dim0.push_back(dimYid); dim0.push_back(dimXid); |
---|
271 | SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); |
---|
272 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
273 | dim0.clear(); |
---|
274 | } |
---|
275 | |
---|
276 | this->writeAxisAttributes |
---|
277 | (lonid, "X", "longitude", "Longitude", "degrees_east", domid); |
---|
278 | this->writeAxisAttributes |
---|
279 | (latid, "Y", "latitude", "Latitude", "degrees_north", domid); |
---|
280 | |
---|
281 | SuperClassWriter::definition_end(); |
---|
282 | |
---|
283 | switch (domain->type) |
---|
284 | { |
---|
285 | case CDomain::type_attr::curvilinear : |
---|
286 | { |
---|
287 | std::vector<StdSize> start(2) ; |
---|
288 | std::vector<StdSize> count(2) ; |
---|
289 | if (domain->isEmpty()) |
---|
290 | { |
---|
291 | start[0]=0 ; start[1]=0 ; |
---|
292 | count[0]=0 ; count[1]=0 ; |
---|
293 | } |
---|
294 | else |
---|
295 | { |
---|
296 | start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; |
---|
297 | count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; |
---|
298 | } |
---|
299 | |
---|
300 | SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); |
---|
301 | SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); |
---|
302 | break; |
---|
303 | } |
---|
304 | case CDomain::type_attr::regular : |
---|
305 | { |
---|
306 | std::vector<StdSize> start(1) ; |
---|
307 | std::vector<StdSize> count(1) ; |
---|
308 | if (domain->isEmpty()) |
---|
309 | { |
---|
310 | start[0]=0 ; |
---|
311 | count[0]=0 ; |
---|
312 | SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); |
---|
313 | SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); } |
---|
314 | else |
---|
315 | { |
---|
316 | start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; |
---|
317 | count[0]=domain->zoom_nj_srv ; |
---|
318 | CArray<double,1> lat = domain->latvalue_srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ; |
---|
319 | SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); |
---|
320 | |
---|
321 | start[0]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; |
---|
322 | count[0]=domain->zoom_ni_srv ; |
---|
323 | CArray<double,1> lon=domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ; |
---|
324 | SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); |
---|
325 | } |
---|
326 | break; |
---|
327 | } |
---|
328 | } |
---|
329 | |
---|
330 | if (domain->hasArea) |
---|
331 | { |
---|
332 | std::vector<StdSize> start(2); |
---|
333 | std::vector<StdSize> count(2); |
---|
334 | |
---|
335 | if (domain->isEmpty()) |
---|
336 | { |
---|
337 | start[0] = 0; start[1] = 0; |
---|
338 | count[0] = 0; count[1] = 0; |
---|
339 | } |
---|
340 | else |
---|
341 | { |
---|
342 | start[1] = domain->zoom_ibegin_srv - domain->zoom_ibegin.getValue(); |
---|
343 | start[0] = domain->zoom_jbegin_srv - domain->zoom_jbegin.getValue(); |
---|
344 | count[1] = domain->zoom_ni_srv; |
---|
345 | count[0] = domain->zoom_nj_srv; |
---|
346 | } |
---|
347 | |
---|
348 | SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count); |
---|
349 | } |
---|
350 | |
---|
351 | SuperClassWriter::definition_start(); |
---|
352 | break; |
---|
353 | } |
---|
354 | default : |
---|
355 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
356 | << "[ type = " << SuperClass::type << "]" |
---|
357 | << " not implemented yet !"); |
---|
358 | } |
---|
359 | } |
---|
360 | catch (CNetCdfException& e) |
---|
361 | { |
---|
362 | StdString msg("On writing the domain : "); |
---|
363 | msg.append(domid); msg.append("\n"); |
---|
364 | msg.append("In the context : "); |
---|
365 | msg.append(context->getId()); msg.append("\n"); |
---|
366 | msg.append(e.what()); |
---|
367 | ERROR("CNc4DataOutput::writeDomain_(CDomain* domain)", << msg); |
---|
368 | } |
---|
369 | |
---|
370 | domain->addRelFile(this->filename); |
---|
371 | } |
---|
372 | |
---|
373 | void CNc4DataOutput::writeUnstructuredDomain(CDomain* domain) |
---|
374 | { |
---|
375 | CContext* context = CContext::getCurrent() ; |
---|
376 | CContextServer* server=context->server ; |
---|
377 | |
---|
378 | if (domain->IsWritten(this->filename)) return; |
---|
379 | domain->checkAttributes(); |
---|
380 | |
---|
381 | if (domain->isEmpty()) |
---|
382 | if (SuperClass::type==MULTI_FILE) return ; |
---|
383 | |
---|
384 | std::vector<StdString> dim0, dim1; |
---|
385 | StdString domid = (!domain->name.isEmpty()) |
---|
386 | ? domain->name.getValue() : domain->getId(); |
---|
387 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
388 | |
---|
389 | |
---|
390 | StdString dimXid = StdString("cell").append(appendDomid); |
---|
391 | StdString dimVertId = StdString("nvertex").append(appendDomid); |
---|
392 | |
---|
393 | string lonid,latid,bounds_lonid,bounds_latid ; |
---|
394 | string areaId = "area" + appendDomid; |
---|
395 | |
---|
396 | try |
---|
397 | { |
---|
398 | switch (SuperClass::type) |
---|
399 | { |
---|
400 | case (MULTI_FILE) : |
---|
401 | { |
---|
402 | lonid = StdString("lon").append(appendDomid); |
---|
403 | latid = StdString("lat").append(appendDomid); |
---|
404 | dim0.push_back(dimXid); |
---|
405 | |
---|
406 | SuperClassWriter::addDimension(dimXid, domain->zoom_nj_srv); |
---|
407 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
408 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); |
---|
409 | |
---|
410 | bounds_lonid = StdString("bounds_lon").append(appendDomid); |
---|
411 | bounds_latid = StdString("bounds_lat").append(appendDomid); |
---|
412 | |
---|
413 | |
---|
414 | this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); |
---|
415 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
416 | this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); |
---|
417 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
418 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
419 | dim0.clear(); |
---|
420 | if (domain->hasBounds) |
---|
421 | { |
---|
422 | dim0.push_back(dimXid); |
---|
423 | dim0.push_back(dimVertId); |
---|
424 | SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0); |
---|
425 | SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0); |
---|
426 | } |
---|
427 | |
---|
428 | dim0.clear(); |
---|
429 | dim0.push_back(dimXid); |
---|
430 | |
---|
431 | if (domain->hasArea) |
---|
432 | { |
---|
433 | SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); |
---|
434 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
435 | } |
---|
436 | |
---|
437 | SuperClassWriter::definition_end(); |
---|
438 | |
---|
439 | SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0); |
---|
440 | SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0); |
---|
441 | |
---|
442 | if (domain->hasBounds) |
---|
443 | { |
---|
444 | SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0); |
---|
445 | SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0); |
---|
446 | } |
---|
447 | |
---|
448 | if (domain->hasArea) |
---|
449 | SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0); |
---|
450 | |
---|
451 | SuperClassWriter::definition_start(); |
---|
452 | break ; |
---|
453 | } |
---|
454 | |
---|
455 | case (ONE_FILE) : |
---|
456 | { |
---|
457 | lonid = StdString("lon").append(appendDomid); |
---|
458 | latid = StdString("lat").append(appendDomid); |
---|
459 | bounds_lonid = StdString("bounds_lon").append(appendDomid); |
---|
460 | bounds_latid = StdString("bounds_lat").append(appendDomid); |
---|
461 | dim0.push_back(dimXid); |
---|
462 | SuperClassWriter::addDimension(dimXid, domain->nj_glo); |
---|
463 | SuperClassWriter::addVariable(latid, NC_FLOAT, dim0); |
---|
464 | SuperClassWriter::addVariable(lonid, NC_FLOAT, dim0); |
---|
465 | this->writeAxisAttributes(lonid, "X", "longitude", "Longitude", "degrees_east", domid); |
---|
466 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_lonid, &lonid); |
---|
467 | this->writeAxisAttributes(latid, "Y", "latitude", "Latitude", "degrees_north", domid); |
---|
468 | if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); |
---|
469 | if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex); |
---|
470 | dim0.clear(); |
---|
471 | |
---|
472 | if (domain->hasBounds) |
---|
473 | { |
---|
474 | dim0.push_back(dimXid); |
---|
475 | dim0.push_back(dimVertId); |
---|
476 | SuperClassWriter::addVariable(bounds_lonid, NC_FLOAT, dim0); |
---|
477 | SuperClassWriter::addVariable(bounds_latid, NC_FLOAT, dim0); |
---|
478 | } |
---|
479 | |
---|
480 | if (domain->hasArea) |
---|
481 | { |
---|
482 | dim0.clear(); |
---|
483 | dim0.push_back(dimXid); |
---|
484 | SuperClassWriter::addVariable(areaId, NC_FLOAT, dim0); |
---|
485 | SuperClassWriter::addAttribute("units", StdString("m2"), &areaId); |
---|
486 | } |
---|
487 | |
---|
488 | SuperClassWriter::definition_end(); |
---|
489 | |
---|
490 | std::vector<StdSize> start(1), startBounds(2) ; |
---|
491 | std::vector<StdSize> count(1), countBounds(2) ; |
---|
492 | if (domain->isEmpty()) |
---|
493 | { |
---|
494 | start[0]=0 ; |
---|
495 | count[0]=0 ; |
---|
496 | startBounds[1]=0 ; |
---|
497 | countBounds[1]=domain->nvertex ; |
---|
498 | startBounds[0]=0 ; |
---|
499 | countBounds[0]=0 ; |
---|
500 | } |
---|
501 | else |
---|
502 | { |
---|
503 | start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; |
---|
504 | count[0]=domain->zoom_nj_srv ; |
---|
505 | startBounds[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin ; |
---|
506 | startBounds[1]=0 ; |
---|
507 | countBounds[0]=domain->zoom_nj_srv ; |
---|
508 | countBounds[1]=domain->nvertex ; |
---|
509 | } |
---|
510 | SuperClassWriter::writeData(domain->latvalue_srv, latid, isCollective, 0,&start,&count); |
---|
511 | SuperClassWriter::writeData(domain->lonvalue_srv, lonid, isCollective, 0,&start,&count); |
---|
512 | if (domain->hasBounds) |
---|
513 | { |
---|
514 | SuperClassWriter::writeData(domain->bounds_lon_srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds); |
---|
515 | SuperClassWriter::writeData(domain->bounds_lat_srv, bounds_latid, isCollective, 0,&startBounds,&countBounds); |
---|
516 | } |
---|
517 | |
---|
518 | if (domain->hasArea) |
---|
519 | SuperClassWriter::writeData(domain->area_srv, areaId, isCollective, 0, &start, &count); |
---|
520 | |
---|
521 | SuperClassWriter::definition_start(); |
---|
522 | |
---|
523 | break; |
---|
524 | } |
---|
525 | default : |
---|
526 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
527 | << "[ type = " << SuperClass::type << "]" |
---|
528 | << " not implemented yet !"); |
---|
529 | } |
---|
530 | } |
---|
531 | catch (CNetCdfException& e) |
---|
532 | { |
---|
533 | StdString msg("On writing the domain : "); |
---|
534 | msg.append(domid); msg.append("\n"); |
---|
535 | msg.append("In the context : "); |
---|
536 | msg.append(context->getId()); msg.append("\n"); |
---|
537 | msg.append(e.what()); |
---|
538 | ERROR("CNc4DataOutput::writeUnstructuredDomain(CDomain* domain)", << msg); |
---|
539 | } |
---|
540 | domain->addRelFile(this->filename); |
---|
541 | } |
---|
542 | //-------------------------------------------------------------- |
---|
543 | |
---|
544 | void CNc4DataOutput::writeAxis_(CAxis* axis) |
---|
545 | { |
---|
546 | if (axis->IsWritten(this->filename)) return; |
---|
547 | axis->checkAttributes(); |
---|
548 | int zoom_size_srv = axis->zoom_size_srv; |
---|
549 | int zoom_begin_srv = axis->zoom_begin_srv; |
---|
550 | int zoom_size = (MULTI_FILE == SuperClass::type) ? zoom_size_srv : axis->zoom_size; |
---|
551 | int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv : axis->zoom_begin; |
---|
552 | |
---|
553 | |
---|
554 | std::vector<StdString> dims; |
---|
555 | StdString axisid = !axis->name.isEmpty() ? axis->name.getValue() : axis->getId(); |
---|
556 | try |
---|
557 | { |
---|
558 | SuperClassWriter::addDimension(axisid, zoom_size); |
---|
559 | dims.push_back(axisid); |
---|
560 | |
---|
561 | switch (SuperClass::type) |
---|
562 | { |
---|
563 | case MULTI_FILE: |
---|
564 | case ONE_FILE: |
---|
565 | { |
---|
566 | SuperClassWriter::addVariable(axisid, NC_FLOAT, dims); |
---|
567 | |
---|
568 | SuperClassWriter::addAttribute("axis", StdString("Z"), &axisid); |
---|
569 | |
---|
570 | if (!axis->name.isEmpty()) |
---|
571 | SuperClassWriter::addAttribute("name", axis->name.getValue(), &axisid); |
---|
572 | |
---|
573 | if (!axis->standard_name.isEmpty()) |
---|
574 | SuperClassWriter::addAttribute("standard_name", axis->standard_name.getValue(), &axisid); |
---|
575 | |
---|
576 | if (!axis->long_name.isEmpty()) |
---|
577 | SuperClassWriter::addAttribute("long_name", axis->long_name.getValue(), &axisid); |
---|
578 | |
---|
579 | if (!axis->unit.isEmpty()) |
---|
580 | SuperClassWriter::addAttribute("units", axis->unit.getValue(), &axisid); |
---|
581 | |
---|
582 | if (!axis->positive.isEmpty()) |
---|
583 | if (axis->positive == CAxis::positive_attr::up) SuperClassWriter::addAttribute("positive", string("up"), &axisid); |
---|
584 | else SuperClassWriter::addAttribute("positive", string("down"), &axisid); |
---|
585 | |
---|
586 | StdString axisBoundsId = axisid + "_bounds"; |
---|
587 | if (!axis->bounds.isEmpty()) |
---|
588 | { |
---|
589 | dims.push_back("axis_nbounds"); |
---|
590 | SuperClassWriter::addVariable(axisBoundsId, NC_FLOAT, dims); |
---|
591 | SuperClassWriter::addAttribute("bounds", axisBoundsId, &axisid); |
---|
592 | } |
---|
593 | |
---|
594 | SuperClassWriter::definition_end(); |
---|
595 | |
---|
596 | CArray<double,1> axis_value(zoom_size); |
---|
597 | for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value(i + zoom_begin_srv); |
---|
598 | SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); |
---|
599 | |
---|
600 | if (!axis->bounds.isEmpty()) |
---|
601 | { |
---|
602 | CArray<double,2> axisBounds(zoom_size, 2); |
---|
603 | for (int i = 0; i < zoom_size_srv; i++) |
---|
604 | { |
---|
605 | axisBounds(i, 0) = axis->bounds(i + zoom_begin_srv, 0); |
---|
606 | axisBounds(i, 1) = axis->bounds(i + zoom_begin_srv, 1); |
---|
607 | } |
---|
608 | SuperClassWriter::writeData(axisBounds, axisBoundsId, isCollective, 0); |
---|
609 | } |
---|
610 | |
---|
611 | SuperClassWriter::definition_start(); |
---|
612 | |
---|
613 | break; |
---|
614 | } |
---|
615 | default : |
---|
616 | ERROR("CNc4DataOutput::writeDomain(domain)", |
---|
617 | << "[ type = " << SuperClass::type << "]" |
---|
618 | << " not implemented yet !"); |
---|
619 | } |
---|
620 | } |
---|
621 | catch (CNetCdfException& e) |
---|
622 | { |
---|
623 | StdString msg("On writing the axis : "); |
---|
624 | msg.append(axisid); msg.append("\n"); |
---|
625 | msg.append("In the context : "); |
---|
626 | CContext* context = CContext::getCurrent() ; |
---|
627 | msg.append(context->getId()); msg.append("\n"); |
---|
628 | msg.append(e.what()); |
---|
629 | ERROR("CNc4DataOutput::writeAxis_(CAxis* axis)", << msg); |
---|
630 | } |
---|
631 | axis->addRelFile(this->filename); |
---|
632 | } |
---|
633 | |
---|
634 | void CNc4DataOutput::writeTimeDimension_(void) |
---|
635 | { |
---|
636 | try |
---|
637 | { |
---|
638 | SuperClassWriter::addDimension("time_counter"); |
---|
639 | SuperClassWriter::addDimension("time_bounds", 2); |
---|
640 | } |
---|
641 | catch (CNetCdfException& e) |
---|
642 | { |
---|
643 | StdString msg("On writing time dimension : time_couter, time_bounds \n"); |
---|
644 | msg.append("In the context : "); |
---|
645 | CContext* context = CContext::getCurrent() ; |
---|
646 | msg.append(context->getId()); msg.append("\n"); |
---|
647 | msg.append(e.what()); |
---|
648 | ERROR("CNc4DataOutput::writeTimeDimension_(void)", << msg); |
---|
649 | } |
---|
650 | } |
---|
651 | //-------------------------------------------------------------- |
---|
652 | |
---|
653 | void CNc4DataOutput::writeField_(CField* field) |
---|
654 | { |
---|
655 | CContext* context = CContext::getCurrent() ; |
---|
656 | CContextServer* server=context->server ; |
---|
657 | |
---|
658 | std::vector<StdString> dims, coodinates; |
---|
659 | CGrid* grid = field->grid; |
---|
660 | if (!grid->doGridHaveDataToWrite()) |
---|
661 | if (SuperClass::type==MULTI_FILE) return ; |
---|
662 | |
---|
663 | CArray<bool,1> axisDomainOrder = grid->axis_domain_order; |
---|
664 | int numElement = axisDomainOrder.numElements(), idxDomain = 0, idxAxis = 0; |
---|
665 | std::vector<StdString> domainList = grid->getDomainList(); |
---|
666 | std::vector<StdString> axisList = grid->getAxisList(); |
---|
667 | |
---|
668 | StdString timeid = StdString("time_counter"); |
---|
669 | StdString dimXid,dimYid; |
---|
670 | std::deque<StdString> dimIdList, dimCoordList; |
---|
671 | bool hasArea = false; |
---|
672 | StdString cellMeasures = "area:"; |
---|
673 | |
---|
674 | for (int i = 0; i < numElement; ++i) |
---|
675 | { |
---|
676 | if (axisDomainOrder(i)) |
---|
677 | { |
---|
678 | CDomain* domain = CDomain::get(domainList[idxDomain]); |
---|
679 | StdString domid = (!domain->name.isEmpty()) |
---|
680 | ? domain->name.getValue() : domain->getId(); |
---|
681 | StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
682 | switch (domain->type) |
---|
683 | { |
---|
684 | case CDomain::type_attr::curvilinear : |
---|
685 | dimXid = StdString("x").append(appendDomid); |
---|
686 | dimIdList.push_back(dimXid); |
---|
687 | dimYid = StdString("y").append(appendDomid); |
---|
688 | dimIdList.push_back(dimYid); |
---|
689 | dimCoordList.push_back(StdString("nav_lon").append(appendDomid)); |
---|
690 | dimCoordList.push_back(StdString("nav_lat").append(appendDomid)); |
---|
691 | break ; |
---|
692 | case CDomain::type_attr::regular : |
---|
693 | dimXid = StdString("lon").append(appendDomid); |
---|
694 | dimIdList.push_back(dimXid); |
---|
695 | dimYid = StdString("lat").append(appendDomid); |
---|
696 | dimIdList.push_back(dimYid); |
---|
697 | break ; |
---|
698 | case CDomain::type_attr::unstructured : |
---|
699 | dimXid = StdString("cell").append(appendDomid); |
---|
700 | dimIdList.push_back(dimXid); |
---|
701 | dimCoordList.push_back(StdString("lon").append(appendDomid)); |
---|
702 | dimCoordList.push_back(StdString("lat").append(appendDomid)); |
---|
703 | break ; |
---|
704 | } |
---|
705 | if (domain->hasArea) |
---|
706 | { |
---|
707 | hasArea = true; |
---|
708 | cellMeasures += " area" + appendDomid; |
---|
709 | } |
---|
710 | ++idxDomain; |
---|
711 | } |
---|
712 | else |
---|
713 | { |
---|
714 | CAxis* axis = CAxis::get(axisList[idxAxis]); |
---|
715 | StdString axisid = (!axis->name.isEmpty()) |
---|
716 | ? axis->name.getValue() : axis->getId(); |
---|
717 | dimIdList.push_back(axisid); |
---|
718 | dimCoordList.push_back(axisid); |
---|
719 | ++idxAxis; |
---|
720 | } |
---|
721 | } |
---|
722 | |
---|
723 | /* |
---|
724 | StdString lonid_loc = (server->intraCommSize > 1) |
---|
725 | ? StdString("lon").append(appendDomid).append("_local") |
---|
726 | : lonid; |
---|
727 | StdString latid_loc = (server->intraCommSize > 1) |
---|
728 | ? StdString("lat").append(appendDomid).append("_local") |
---|
729 | : latid; |
---|
730 | */ |
---|
731 | StdString fieldid = (!field->name.isEmpty()) |
---|
732 | ? field->name.getValue() : field->getBaseFieldReference()->getId(); |
---|
733 | |
---|
734 | // unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); |
---|
735 | // bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); |
---|
736 | // bool isCurvilinear = domain->isCurvilinear ; |
---|
737 | |
---|
738 | nc_type type ; |
---|
739 | if (field->prec.isEmpty()) type = NC_FLOAT ; |
---|
740 | else |
---|
741 | { |
---|
742 | if (field->prec==2) type = NC_SHORT ; |
---|
743 | else if (field->prec==4) type = NC_FLOAT ; |
---|
744 | else if (field->prec==8) type = NC_DOUBLE ; |
---|
745 | } |
---|
746 | |
---|
747 | bool wtime = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once); |
---|
748 | |
---|
749 | if (wtime) |
---|
750 | { |
---|
751 | |
---|
752 | //StdOStringStream oss; |
---|
753 | // oss << "time_" << field->operation.getValue() |
---|
754 | // << "_" << field->getRelFile()->output_freq.getValue(); |
---|
755 | //oss |
---|
756 | if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); |
---|
757 | else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); |
---|
758 | dims.push_back(timeid); |
---|
759 | } |
---|
760 | |
---|
761 | while (!dimIdList.empty()) |
---|
762 | { |
---|
763 | dims.push_back(dimIdList.back()); |
---|
764 | dimIdList.pop_back(); |
---|
765 | } |
---|
766 | |
---|
767 | while (!dimCoordList.empty()) |
---|
768 | { |
---|
769 | coodinates.push_back(dimCoordList.back()); |
---|
770 | dimCoordList.pop_back(); |
---|
771 | } |
---|
772 | |
---|
773 | try |
---|
774 | { |
---|
775 | SuperClassWriter::addVariable(fieldid, type, dims); |
---|
776 | |
---|
777 | if (!field->standard_name.isEmpty()) |
---|
778 | SuperClassWriter::addAttribute |
---|
779 | ("standard_name", field->standard_name.getValue(), &fieldid); |
---|
780 | |
---|
781 | if (!field->long_name.isEmpty()) |
---|
782 | SuperClassWriter::addAttribute |
---|
783 | ("long_name", field->long_name.getValue(), &fieldid); |
---|
784 | |
---|
785 | if (!field->unit.isEmpty()) |
---|
786 | SuperClassWriter::addAttribute |
---|
787 | ("units", field->unit.getValue(), &fieldid); |
---|
788 | |
---|
789 | if (!field->valid_min.isEmpty()) |
---|
790 | SuperClassWriter::addAttribute |
---|
791 | ("valid_min", field->valid_min.getValue(), &fieldid); |
---|
792 | |
---|
793 | if (!field->valid_max.isEmpty()) |
---|
794 | SuperClassWriter::addAttribute |
---|
795 | ("valid_max", field->valid_max.getValue(), &fieldid); |
---|
796 | |
---|
797 | if (!field->scale_factor.isEmpty()) |
---|
798 | SuperClassWriter::addAttribute |
---|
799 | ("scale_factor", field->scale_factor.getValue(), &fieldid); |
---|
800 | |
---|
801 | if (!field->add_offset.isEmpty()) |
---|
802 | SuperClassWriter::addAttribute |
---|
803 | ("add_offset", field->add_offset.getValue(), &fieldid); |
---|
804 | |
---|
805 | SuperClassWriter::addAttribute |
---|
806 | ("online_operation", field->operation.getValue(), &fieldid); |
---|
807 | |
---|
808 | // write child variables as attributes |
---|
809 | |
---|
810 | |
---|
811 | vector<CVariable*> listVars = field->getAllVariables() ; |
---|
812 | for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; |
---|
813 | |
---|
814 | |
---|
815 | if (wtime) |
---|
816 | { |
---|
817 | CDuration duration = field->freq_op.getValue(); |
---|
818 | duration.solveTimeStep(*(context->calendar)); |
---|
819 | SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); |
---|
820 | |
---|
821 | duration = field->getRelFile()->output_freq.getValue(); |
---|
822 | duration.solveTimeStep(*(context->calendar)); |
---|
823 | SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); |
---|
824 | } |
---|
825 | |
---|
826 | if (hasArea) |
---|
827 | SuperClassWriter::addAttribute("cell_measures", cellMeasures, &fieldid); |
---|
828 | |
---|
829 | if (!field->default_value.isEmpty()) |
---|
830 | { |
---|
831 | double default_value = field->default_value.getValue(); |
---|
832 | float fdefault_value = (float)default_value; |
---|
833 | if (type == NC_DOUBLE) |
---|
834 | SuperClassWriter::setDefaultValue(fieldid, &default_value); |
---|
835 | else |
---|
836 | SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); |
---|
837 | } |
---|
838 | else |
---|
839 | SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); |
---|
840 | |
---|
841 | if (field->compression_level.isEmpty()) |
---|
842 | field->compression_level = field->file->compression_level.isEmpty() ? 0 : field->file->compression_level; |
---|
843 | SuperClassWriter::setCompressionLevel(fieldid, field->compression_level); |
---|
844 | |
---|
845 | { // Ecriture des coordonnées |
---|
846 | |
---|
847 | StdString coordstr; //boost::algorithm::join(coodinates, " ") |
---|
848 | std::vector<StdString>::iterator |
---|
849 | itc = coodinates.begin(), endc = coodinates.end(); |
---|
850 | |
---|
851 | for (; itc!= endc; itc++) |
---|
852 | { |
---|
853 | StdString & coord = *itc; |
---|
854 | if (itc+1 != endc) |
---|
855 | coordstr.append(coord).append(" "); |
---|
856 | else coordstr.append(coord); |
---|
857 | } |
---|
858 | |
---|
859 | SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); |
---|
860 | |
---|
861 | } |
---|
862 | } |
---|
863 | catch (CNetCdfException& e) |
---|
864 | { |
---|
865 | StdString msg("On writing field : "); |
---|
866 | msg.append(fieldid); msg.append("\n"); |
---|
867 | msg.append("In the context : "); |
---|
868 | msg.append(context->getId()); msg.append("\n"); |
---|
869 | msg.append(e.what()); |
---|
870 | ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); |
---|
871 | } |
---|
872 | } |
---|
873 | |
---|
874 | |
---|
875 | // void CNc4DataOutput::writeField_(CField* field) |
---|
876 | // { |
---|
877 | // CContext* context = CContext::getCurrent() ; |
---|
878 | // CContextServer* server=context->server ; |
---|
879 | // |
---|
880 | // std::vector<StdString> dims, coodinates; |
---|
881 | // CGrid* grid = field->grid; |
---|
882 | // CDomain* domain = grid->domain; |
---|
883 | // |
---|
884 | // if (domain->isEmpty()) |
---|
885 | // if (SuperClass::type==MULTI_FILE) return ; |
---|
886 | // |
---|
887 | // StdString timeid = StdString("time_counter"); |
---|
888 | // StdString domid = (!domain->name.isEmpty()) |
---|
889 | // ? domain->name.getValue() : domain->getId(); |
---|
890 | // StdString appendDomid = (singleDomain) ? "" : "_"+domid ; |
---|
891 | // |
---|
892 | //// bool isCurvilinear = domain->isCurvilinear ; |
---|
893 | //// bool isCurvilinear = (domain->type == CDomain::type_attr::curvilinear) ; |
---|
894 | // |
---|
895 | // StdString dimXid,dimYid ; |
---|
896 | // |
---|
897 | // switch (domain->type) |
---|
898 | // { |
---|
899 | // case CDomain::type_attr::curvilinear : |
---|
900 | // dimXid = StdString("x").append(appendDomid); |
---|
901 | // dimYid = StdString("y").append(appendDomid); |
---|
902 | // break ; |
---|
903 | // case CDomain::type_attr::regular : |
---|
904 | // dimXid = StdString("lon").append(appendDomid); |
---|
905 | // dimYid = StdString("lat").append(appendDomid); |
---|
906 | // break ; |
---|
907 | // case CDomain::type_attr::unstructured : |
---|
908 | // dimXid = StdString("cell").append(appendDomid); |
---|
909 | // break ; |
---|
910 | // } |
---|
911 | // |
---|
912 | ///* |
---|
913 | // StdString lonid_loc = (server->intraCommSize > 1) |
---|
914 | // ? StdString("lon").append(appendDomid).append("_local") |
---|
915 | // : lonid; |
---|
916 | // StdString latid_loc = (server->intraCommSize > 1) |
---|
917 | // ? StdString("lat").append(appendDomid).append("_local") |
---|
918 | // : latid; |
---|
919 | //*/ |
---|
920 | // StdString fieldid = (!field->name.isEmpty()) |
---|
921 | // ? field->name.getValue() : field->getBaseFieldReference()->getId(); |
---|
922 | // |
---|
923 | //// unsigned int ssize = domain->zoom_ni_loc.getValue() * domain->zoom_nj_loc.getValue(); |
---|
924 | //// bool isCurvilinear = (domain->lonvalue.getValue()->size() == ssize); |
---|
925 | //// bool isCurvilinear = domain->isCurvilinear ; |
---|
926 | // |
---|
927 | // nc_type type ; |
---|
928 | // if (field->prec.isEmpty()) type = NC_FLOAT ; |
---|
929 | // else |
---|
930 | // { |
---|
931 | // if (field->prec==2) type = NC_SHORT ; |
---|
932 | // else if (field->prec==4) type = NC_FLOAT ; |
---|
933 | // else if (field->prec==8) type = NC_DOUBLE ; |
---|
934 | // } |
---|
935 | // |
---|
936 | // bool wtime = !(!field->operation.isEmpty() && field->foperation->timeType() == func::CFunctor::once); |
---|
937 | // |
---|
938 | // if (wtime) |
---|
939 | // { |
---|
940 | // |
---|
941 | // //StdOStringStream oss; |
---|
942 | // // oss << "time_" << field->operation.getValue() |
---|
943 | // // << "_" << field->getRelFile()->output_freq.getValue(); |
---|
944 | // //oss |
---|
945 | // if (field->foperation->timeType() == func::CFunctor::instant) coodinates.push_back(string("time_instant")); |
---|
946 | // else if (field->foperation->timeType() == func::CFunctor::centered) coodinates.push_back(string("time_centered")); |
---|
947 | // dims.push_back(timeid); |
---|
948 | // } |
---|
949 | // |
---|
950 | // std::vector<StdString> axisList = grid->getAxisList(); |
---|
951 | // if (!axisList.empty()) |
---|
952 | // { |
---|
953 | // std::vector<StdString>::const_iterator itAxis = axisList.begin(), iteAxis = axisList.end(); |
---|
954 | // for (; itAxis != iteAxis; ++itAxis) |
---|
955 | // { |
---|
956 | // CAxis* axis = CAxis::get(*itAxis); |
---|
957 | // StdString axisid = (!axis->name.isEmpty()) |
---|
958 | // ? axis->name.getValue() : axis->getId(); |
---|
959 | // |
---|
960 | // dims.push_back(axisid); |
---|
961 | // coodinates.push_back(axisid); |
---|
962 | // } |
---|
963 | // } |
---|
964 | // |
---|
965 | // switch (domain->type) |
---|
966 | // { |
---|
967 | // case CDomain::type_attr::curvilinear : |
---|
968 | // coodinates.push_back(StdString("nav_lon").append(appendDomid)); |
---|
969 | // coodinates.push_back(StdString("nav_lat").append(appendDomid)); |
---|
970 | // break; |
---|
971 | // case CDomain::type_attr::regular : |
---|
972 | // case CDomain::type_attr::unstructured : |
---|
973 | // coodinates.push_back(StdString("lon").append(appendDomid)); |
---|
974 | // coodinates.push_back(StdString("lat").append(appendDomid)); |
---|
975 | // break; |
---|
976 | // } |
---|
977 | // |
---|
978 | // if ( domain->type == CDomain::type_attr::curvilinear || domain->type == CDomain::type_attr::regular)dims.push_back(dimYid); |
---|
979 | // dims.push_back(dimXid); |
---|
980 | // |
---|
981 | // try |
---|
982 | // { |
---|
983 | // SuperClassWriter::addVariable(fieldid, type, dims); |
---|
984 | // |
---|
985 | // if (!field->standard_name.isEmpty()) |
---|
986 | // SuperClassWriter::addAttribute |
---|
987 | // ("standard_name", field->standard_name.getValue(), &fieldid); |
---|
988 | // |
---|
989 | // if (!field->long_name.isEmpty()) |
---|
990 | // SuperClassWriter::addAttribute |
---|
991 | // ("long_name", field->long_name.getValue(), &fieldid); |
---|
992 | // |
---|
993 | // if (!field->unit.isEmpty()) |
---|
994 | // SuperClassWriter::addAttribute |
---|
995 | // ("units", field->unit.getValue(), &fieldid); |
---|
996 | // |
---|
997 | // if (!field->valid_min.isEmpty()) |
---|
998 | // SuperClassWriter::addAttribute |
---|
999 | // ("valid_min", field->valid_min.getValue(), &fieldid); |
---|
1000 | // |
---|
1001 | // if (!field->valid_max.isEmpty()) |
---|
1002 | // SuperClassWriter::addAttribute |
---|
1003 | // ("valid_max", field->valid_max.getValue(), &fieldid); |
---|
1004 | // |
---|
1005 | // if (!field->scale_factor.isEmpty()) |
---|
1006 | // SuperClassWriter::addAttribute |
---|
1007 | // ("scale_factor", field->scale_factor.getValue(), &fieldid); |
---|
1008 | // |
---|
1009 | // if (!field->add_offset.isEmpty()) |
---|
1010 | // SuperClassWriter::addAttribute |
---|
1011 | // ("add_offset", field->add_offset.getValue(), &fieldid); |
---|
1012 | // |
---|
1013 | // SuperClassWriter::addAttribute |
---|
1014 | // ("online_operation", field->operation.getValue(), &fieldid); |
---|
1015 | // |
---|
1016 | // // write child variables as attributes |
---|
1017 | // |
---|
1018 | // |
---|
1019 | // vector<CVariable*> listVars = field->getAllVariables() ; |
---|
1020 | // for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) writeAttribute_(*it, fieldid) ; |
---|
1021 | // |
---|
1022 | // |
---|
1023 | // if (wtime) |
---|
1024 | // { |
---|
1025 | // CDuration duration = field->freq_op.getValue(); |
---|
1026 | // duration.solveTimeStep(*(context->calendar)); |
---|
1027 | // SuperClassWriter::addAttribute("interval_operation", duration.toString(), &fieldid); |
---|
1028 | // |
---|
1029 | // duration = field->getRelFile()->output_freq.getValue(); |
---|
1030 | // duration.solveTimeStep(*(context->calendar)); |
---|
1031 | // SuperClassWriter::addAttribute("interval_write", duration.toString(), &fieldid); |
---|
1032 | // } |
---|
1033 | // |
---|
1034 | // if (!field->default_value.isEmpty()) |
---|
1035 | // { |
---|
1036 | // double default_value = field->default_value.getValue(); |
---|
1037 | // float fdefault_value = (float)default_value; |
---|
1038 | // if (type == NC_DOUBLE) |
---|
1039 | // SuperClassWriter::setDefaultValue(fieldid, &default_value); |
---|
1040 | // else |
---|
1041 | // SuperClassWriter::setDefaultValue(fieldid, &fdefault_value); |
---|
1042 | // } |
---|
1043 | // else |
---|
1044 | // SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); |
---|
1045 | // |
---|
1046 | // { // Ecriture des coordonnées |
---|
1047 | // |
---|
1048 | // StdString coordstr; //boost::algorithm::join(coodinates, " ") |
---|
1049 | // std::vector<StdString>::iterator |
---|
1050 | // itc = coodinates.begin(), endc = coodinates.end(); |
---|
1051 | // |
---|
1052 | // for (; itc!= endc; itc++) |
---|
1053 | // { |
---|
1054 | // StdString & coord = *itc; |
---|
1055 | // if (itc+1 != endc) |
---|
1056 | // coordstr.append(coord).append(" "); |
---|
1057 | // else coordstr.append(coord); |
---|
1058 | // } |
---|
1059 | // |
---|
1060 | // SuperClassWriter::addAttribute("coordinates", coordstr, &fieldid); |
---|
1061 | // |
---|
1062 | // } |
---|
1063 | // } |
---|
1064 | // catch (CNetCdfException& e) |
---|
1065 | // { |
---|
1066 | // StdString msg("On writing field : "); |
---|
1067 | // msg.append(fieldid); msg.append("\n"); |
---|
1068 | // msg.append("In the context : "); |
---|
1069 | // msg.append(context->getId()); msg.append("\n"); |
---|
1070 | // msg.append(e.what()); |
---|
1071 | // ERROR("CNc4DataOutput::writeField_(CField* field)", << msg); |
---|
1072 | // } |
---|
1073 | // } |
---|
1074 | |
---|
1075 | //-------------------------------------------------------------- |
---|
1076 | |
---|
1077 | void CNc4DataOutput::writeFile_ (CFile* file) |
---|
1078 | { |
---|
1079 | StdString filename = (!file->name.isEmpty()) |
---|
1080 | ? file->name.getValue() : file->getId(); |
---|
1081 | StdString description = (!file->description.isEmpty()) |
---|
1082 | ? file->description.getValue() |
---|
1083 | : StdString("Created by xios"); |
---|
1084 | |
---|
1085 | singleDomain = (file->nbDomains == 1); |
---|
1086 | |
---|
1087 | try |
---|
1088 | { |
---|
1089 | this->writeFileAttributes(filename, description, |
---|
1090 | StdString("CF-1.1"), |
---|
1091 | StdString("An IPSL model"), |
---|
1092 | this->getTimeStamp()); |
---|
1093 | |
---|
1094 | if (file->nbAxis >= 1) |
---|
1095 | SuperClassWriter::addDimension("axis_nbounds", 2); |
---|
1096 | } |
---|
1097 | catch (CNetCdfException& e) |
---|
1098 | { |
---|
1099 | StdString msg("On writing file : "); |
---|
1100 | msg.append(filename); msg.append("\n"); |
---|
1101 | msg.append("In the context : "); |
---|
1102 | CContext* context = CContext::getCurrent() ; |
---|
1103 | msg.append(context->getId()); msg.append("\n"); |
---|
1104 | msg.append(e.what()); |
---|
1105 | ERROR("CNc4DataOutput::writeFile_ (CFile* file)", << msg); |
---|
1106 | } |
---|
1107 | } |
---|
1108 | |
---|
1109 | void CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId) |
---|
1110 | { |
---|
1111 | string name ; |
---|
1112 | if (!var->name.isEmpty()) name=var->name ; |
---|
1113 | else if (var->hasId()) name=var->getId() ; |
---|
1114 | else return ; |
---|
1115 | |
---|
1116 | try |
---|
1117 | { |
---|
1118 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
1119 | addAttribute(name, var->getData<int>(), &fieldId); |
---|
1120 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
1121 | addAttribute(name, var->getData<short int>(), &fieldId); |
---|
1122 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
1123 | addAttribute(name, var->getData<float>(), &fieldId); |
---|
1124 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
1125 | addAttribute(name, var->getData<double>(), &fieldId); |
---|
1126 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
1127 | addAttribute(name, var->getData<string>(), &fieldId); |
---|
1128 | else |
---|
1129 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", |
---|
1130 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
1131 | } |
---|
1132 | catch (CNetCdfException& e) |
---|
1133 | { |
---|
1134 | StdString msg("On writing attributes of variable with name : "); |
---|
1135 | msg.append(name); msg.append("in the field "); msg.append(fieldId); msg.append("\n"); |
---|
1136 | msg.append("In the context : "); |
---|
1137 | CContext* context = CContext::getCurrent() ; |
---|
1138 | msg.append(context->getId()); msg.append("\n"); |
---|
1139 | msg.append(e.what()); |
---|
1140 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var, const string& fieldId)", << msg); |
---|
1141 | } |
---|
1142 | } |
---|
1143 | |
---|
1144 | void CNc4DataOutput::writeAttribute_ (CVariable* var) |
---|
1145 | { |
---|
1146 | string name ; |
---|
1147 | if (!var->name.isEmpty()) name=var->name ; |
---|
1148 | else if (var->hasId()) name=var->getId() ; |
---|
1149 | else return ; |
---|
1150 | try |
---|
1151 | { |
---|
1152 | if (var->type.getValue() == CVariable::type_attr::t_int || var->type.getValue() == CVariable::type_attr::t_int32) |
---|
1153 | addAttribute(name, var->getData<int>()); |
---|
1154 | else if (var->type.getValue() == CVariable::type_attr::t_int16) |
---|
1155 | addAttribute(name, var->getData<short int>()); |
---|
1156 | else if (var->type.getValue() == CVariable::type_attr::t_float) |
---|
1157 | addAttribute(name, var->getData<float>()); |
---|
1158 | else if (var->type.getValue() == CVariable::type_attr::t_double) |
---|
1159 | addAttribute(name, var->getData<double>()); |
---|
1160 | else if (var->type.getValue() == CVariable::type_attr::t_string) |
---|
1161 | addAttribute(name, var->getData<string>()); |
---|
1162 | else |
---|
1163 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", |
---|
1164 | << "Unsupported variable of type " << var->type.getStringValue()); |
---|
1165 | } |
---|
1166 | catch (CNetCdfException& e) |
---|
1167 | { |
---|
1168 | StdString msg("On writing attributes of variable with name : "); |
---|
1169 | msg.append(name); msg.append("\n"); |
---|
1170 | msg.append("In the context : "); |
---|
1171 | CContext* context = CContext::getCurrent() ; |
---|
1172 | msg.append(context->getId()); msg.append("\n"); |
---|
1173 | msg.append(e.what()); |
---|
1174 | ERROR("CNc4DataOutput::writeAttribute_ (CVariable* var)", << msg); |
---|
1175 | } |
---|
1176 | } |
---|
1177 | |
---|
1178 | void CNc4DataOutput::syncFile_ (void) |
---|
1179 | { |
---|
1180 | try |
---|
1181 | { |
---|
1182 | SuperClassWriter::sync() ; |
---|
1183 | } |
---|
1184 | catch (CNetCdfException& e) |
---|
1185 | { |
---|
1186 | StdString msg("On synchronizing the write among processes"); |
---|
1187 | msg.append("In the context : "); |
---|
1188 | CContext* context = CContext::getCurrent() ; |
---|
1189 | msg.append(context->getId()); msg.append("\n"); |
---|
1190 | msg.append(e.what()); |
---|
1191 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
1192 | } |
---|
1193 | } |
---|
1194 | |
---|
1195 | void CNc4DataOutput::closeFile_ (void) |
---|
1196 | { |
---|
1197 | try |
---|
1198 | { |
---|
1199 | SuperClassWriter::close() ; |
---|
1200 | } |
---|
1201 | catch (CNetCdfException& e) |
---|
1202 | { |
---|
1203 | StdString msg("On closing file"); |
---|
1204 | msg.append("In the context : "); |
---|
1205 | CContext* context = CContext::getCurrent() ; |
---|
1206 | msg.append(context->getId()); msg.append("\n"); |
---|
1207 | msg.append(e.what()); |
---|
1208 | ERROR("CNc4DataOutput::syncFile_ (void)", << msg); |
---|
1209 | } |
---|
1210 | |
---|
1211 | } |
---|
1212 | |
---|
1213 | //--------------------------------------------------------------- |
---|
1214 | |
---|
1215 | StdString CNc4DataOutput::getTimeStamp(void) const |
---|
1216 | { |
---|
1217 | const int buffer_size = 100; |
---|
1218 | time_t rawtime; |
---|
1219 | struct tm * timeinfo = NULL; |
---|
1220 | char buffer [buffer_size]; |
---|
1221 | |
---|
1222 | time ( &rawtime ); |
---|
1223 | timeinfo = localtime ( &rawtime ); |
---|
1224 | strftime (buffer, buffer_size, "%Y-%b-%d %H:%M:%S %Z", timeinfo); |
---|
1225 | |
---|
1226 | return (StdString(buffer)); |
---|
1227 | } |
---|
1228 | |
---|
1229 | //--------------------------------------------------------------- |
---|
1230 | |
---|
1231 | void CNc4DataOutput::writeFieldData_ (CField* field) |
---|
1232 | { |
---|
1233 | CContext* context = CContext::getCurrent() ; |
---|
1234 | // if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ; |
---|
1235 | CContextServer* server=context->server ; |
---|
1236 | |
---|
1237 | CGrid* grid = field->grid ; |
---|
1238 | |
---|
1239 | if (!grid->doGridHaveDataToWrite()) |
---|
1240 | if (SuperClass::type==MULTI_FILE || !isCollective) return ; |
---|
1241 | |
---|
1242 | StdString fieldid = (!field->name.isEmpty()) |
---|
1243 | ? field->name.getValue() |
---|
1244 | : field->getBaseFieldReference()->getId(); |
---|
1245 | |
---|
1246 | StdOStringStream oss; |
---|
1247 | string timeAxisId ; |
---|
1248 | if (field->foperation->timeType() == func::CFunctor::instant) timeAxisId="time_instant" ; |
---|
1249 | else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisId="time_centered" ; |
---|
1250 | |
---|
1251 | StdString timeBoundId("time_counter_bounds"); |
---|
1252 | |
---|
1253 | StdString timeAxisBoundId; |
---|
1254 | if (field->foperation->timeType() == func::CFunctor::instant) timeAxisBoundId="time_instant_bounds" ; |
---|
1255 | else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisBoundId="time_centered_bounds" ; |
---|
1256 | |
---|
1257 | CArray<double,1> time_data(1) ; |
---|
1258 | CArray<double,1> time_counter(1) ; |
---|
1259 | CArray<double,1> time_counter_bound(2); |
---|
1260 | CArray<double,1> time_data_bound(2); |
---|
1261 | |
---|
1262 | bool wtime = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once)); |
---|
1263 | |
---|
1264 | if (wtime) |
---|
1265 | { |
---|
1266 | time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2; |
---|
1267 | if (field->foperation->timeType() == func::CFunctor::instant) |
---|
1268 | time_data(0) = Time(*field->last_Write_srv); |
---|
1269 | else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0); |
---|
1270 | |
---|
1271 | time_counter_bound(0) = Time(*field->lastlast_Write_srv); |
---|
1272 | time_counter_bound(1) = Time(*field->last_Write_srv); |
---|
1273 | if (field->foperation->timeType() == func::CFunctor::instant) |
---|
1274 | time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv); |
---|
1275 | else if (field->foperation->timeType() == func::CFunctor::centered) |
---|
1276 | { |
---|
1277 | time_data_bound(0) = time_counter_bound(0); |
---|
1278 | time_data_bound(1) = time_counter_bound(1); |
---|
1279 | } |
---|
1280 | } |
---|
1281 | |
---|
1282 | bool isRoot ; |
---|
1283 | if (server->intraCommRank==0) isRoot=true ; |
---|
1284 | else isRoot=false ; |
---|
1285 | |
---|
1286 | if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) |
---|
1287 | { |
---|
1288 | double scaleFactor=1. ; |
---|
1289 | double addOffset=0. ; |
---|
1290 | if (!field->scale_factor.isEmpty()) scaleFactor=field->scale_factor ; |
---|
1291 | if (!field->add_offset.isEmpty()) addOffset=field->add_offset ; |
---|
1292 | field->scaleFactorAddOffset(scaleFactor,addOffset) ; |
---|
1293 | } |
---|
1294 | |
---|
1295 | try |
---|
1296 | { |
---|
1297 | CArray<double,1> fieldData(grid->getWrittenDataSize()); |
---|
1298 | if (!field->default_value.isEmpty()) fieldData = field->default_value; |
---|
1299 | field->outputField(fieldData); |
---|
1300 | if (!field->prec.isEmpty() && field->prec==2) fieldData=round(fieldData) ; |
---|
1301 | |
---|
1302 | switch (SuperClass::type) |
---|
1303 | { |
---|
1304 | case (MULTI_FILE) : |
---|
1305 | { |
---|
1306 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1); |
---|
1307 | if (wtime) |
---|
1308 | { |
---|
1309 | SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); |
---|
1310 | SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); |
---|
1311 | SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); |
---|
1312 | SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); |
---|
1313 | } |
---|
1314 | break ; |
---|
1315 | } |
---|
1316 | case (ONE_FILE) : |
---|
1317 | { |
---|
1318 | std::vector<int> nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); |
---|
1319 | std::vector<int> nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); |
---|
1320 | std::vector<int> nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); |
---|
1321 | |
---|
1322 | int ssize = nZoomBeginGlobal.size(); |
---|
1323 | |
---|
1324 | std::vector<StdSize> start(ssize) ; |
---|
1325 | std::vector<StdSize> count(ssize) ; |
---|
1326 | |
---|
1327 | for (int i = 0; i < ssize; ++i) |
---|
1328 | { |
---|
1329 | start[i] = nZoomBeginServer[ssize-i-1] - nZoomBeginGlobal[ssize-i-1]; |
---|
1330 | count[i] = nZoomSizeServer[ssize-i-1]; |
---|
1331 | } |
---|
1332 | |
---|
1333 | SuperClassWriter::writeData(fieldData, fieldid, isCollective, field->getNStep()-1,&start,&count ); |
---|
1334 | if (wtime) |
---|
1335 | { |
---|
1336 | SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); |
---|
1337 | SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); |
---|
1338 | SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); |
---|
1339 | SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); |
---|
1340 | } |
---|
1341 | |
---|
1342 | break; |
---|
1343 | } |
---|
1344 | } |
---|
1345 | } |
---|
1346 | catch (CNetCdfException& e) |
---|
1347 | { |
---|
1348 | StdString msg("On writing field data: "); |
---|
1349 | msg.append(fieldid); msg.append("\n"); |
---|
1350 | msg.append("In the context : "); |
---|
1351 | msg.append(context->getId()); msg.append("\n"); |
---|
1352 | msg.append(e.what()); |
---|
1353 | ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg); |
---|
1354 | } |
---|
1355 | } |
---|
1356 | |
---|
1357 | // //--------------------------------------------------------------- |
---|
1358 | // |
---|
1359 | // void CNc4DataOutput::writeFieldData_ (CField* field) |
---|
1360 | // { |
---|
1361 | // CContext* context = CContext::getCurrent() ; |
---|
1362 | //// if (field->getRelFile()->isSyncTime()) SuperClassWriter::sync() ; |
---|
1363 | // CContextServer* server=context->server ; |
---|
1364 | // |
---|
1365 | // CGrid* grid = field->grid ; |
---|
1366 | // CDomain* domain = grid->domain ; |
---|
1367 | // |
---|
1368 | // if(SuperClass::type==MULTI_FILE || !isCollective) if (domain->isEmpty()) return; |
---|
1369 | // |
---|
1370 | // |
---|
1371 | // StdString fieldid = (!field->name.isEmpty()) |
---|
1372 | // ? field->name.getValue() |
---|
1373 | // : field->getBaseFieldReference()->getId(); |
---|
1374 | // |
---|
1375 | // StdOStringStream oss; |
---|
1376 | // string timeAxisId ; |
---|
1377 | // if (field->foperation->timeType() == func::CFunctor::instant) timeAxisId="time_instant" ; |
---|
1378 | // else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisId="time_centered" ; |
---|
1379 | // |
---|
1380 | // StdString timeBoundId("time_counter_bounds"); |
---|
1381 | // |
---|
1382 | // StdString timeAxisBoundId; |
---|
1383 | // if (field->foperation->timeType() == func::CFunctor::instant) timeAxisBoundId="time_instant_bounds" ; |
---|
1384 | // else if (field->foperation->timeType() == func::CFunctor::centered) timeAxisBoundId="time_centered_bounds" ; |
---|
1385 | // |
---|
1386 | // CArray<double,1> time_data(1) ; |
---|
1387 | // CArray<double,1> time_counter(1) ; |
---|
1388 | // CArray<double,1> time_counter_bound(2); |
---|
1389 | // CArray<double,1> time_data_bound(2); |
---|
1390 | // |
---|
1391 | // bool wtime = !(!field->operation.isEmpty() && (field->foperation->timeType() == func::CFunctor::once)); |
---|
1392 | // |
---|
1393 | // if (wtime) |
---|
1394 | // { |
---|
1395 | // time_counter(0)= (Time(*field->last_Write_srv) + Time(*field->lastlast_Write_srv)) / 2; |
---|
1396 | // if (field->foperation->timeType() == func::CFunctor::instant) |
---|
1397 | // time_data(0) = Time(*field->last_Write_srv); |
---|
1398 | // else if (field->foperation->timeType() == func::CFunctor::centered) time_data(0) = time_counter(0); |
---|
1399 | // |
---|
1400 | // time_counter_bound(0) = Time(*field->lastlast_Write_srv); |
---|
1401 | // time_counter_bound(1) = Time(*field->last_Write_srv); |
---|
1402 | // if (field->foperation->timeType() == func::CFunctor::instant) |
---|
1403 | // time_data_bound(0) = time_data_bound(1) = Time(*field->last_Write_srv); |
---|
1404 | // else if (field->foperation->timeType() == func::CFunctor::centered) |
---|
1405 | // { |
---|
1406 | // time_data_bound(0) = time_counter_bound(0); |
---|
1407 | // time_data_bound(1) = time_counter_bound(1); |
---|
1408 | // } |
---|
1409 | // } |
---|
1410 | // |
---|
1411 | // bool isRoot ; |
---|
1412 | // if (server->intraCommRank==0) isRoot=true ; |
---|
1413 | // else isRoot=false ; |
---|
1414 | // |
---|
1415 | // if (!field->scale_factor.isEmpty() || !field->add_offset.isEmpty()) |
---|
1416 | // { |
---|
1417 | // double scaleFactor=1. ; |
---|
1418 | // double addOffset=0. ; |
---|
1419 | // if (!field->scale_factor.isEmpty()) scaleFactor=field->scale_factor ; |
---|
1420 | // if (!field->add_offset.isEmpty()) addOffset=field->add_offset ; |
---|
1421 | // field->scaleFactorAddOffset(scaleFactor,addOffset) ; |
---|
1422 | // } |
---|
1423 | // |
---|
1424 | // try |
---|
1425 | // { |
---|
1426 | // if (grid->hasAxis()) // 3D |
---|
1427 | // { |
---|
1428 | // CAxis* axis = grid->axis ; |
---|
1429 | // CArray<double,3> field_data3D(domain->zoom_ni_srv,domain->zoom_nj_srv,axis->zoom_size) ; |
---|
1430 | // if (!field->default_value.isEmpty()) field_data3D = field->default_value ; |
---|
1431 | // |
---|
1432 | // field->outputField(field_data3D); |
---|
1433 | // |
---|
1434 | // if (!field->prec.isEmpty() && field->prec==2) field_data3D=round(field_data3D) ; |
---|
1435 | // |
---|
1436 | // switch (SuperClass::type) |
---|
1437 | // { |
---|
1438 | // case (MULTI_FILE) : |
---|
1439 | // { |
---|
1440 | // SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1); |
---|
1441 | // if (wtime) |
---|
1442 | // { |
---|
1443 | // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); |
---|
1444 | // SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); |
---|
1445 | // SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); |
---|
1446 | // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); |
---|
1447 | // } |
---|
1448 | // break ; |
---|
1449 | // } |
---|
1450 | // case (ONE_FILE) : |
---|
1451 | // { |
---|
1452 | // std::vector<StdSize> start(3) ; |
---|
1453 | // std::vector<StdSize> count(3) ; |
---|
1454 | // if (domain->isEmpty()) |
---|
1455 | // { |
---|
1456 | // start[0]=0 ; start[1]=0 ; start[2]=0 ; |
---|
1457 | // count[0]=0 ; count[1]=0 ; start[2]=0 ; |
---|
1458 | // } |
---|
1459 | // else |
---|
1460 | // { |
---|
1461 | // // start[2]=domain->zoom_ibegin_loc.getValue()-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_loc.getValue()-domain->zoom_jbegin.getValue() ; start[0]=0 ; |
---|
1462 | // start[2]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start [1]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; start[0]=0 ; |
---|
1463 | // count[2]=domain->zoom_ni_srv ; count[1]=domain->zoom_nj_srv ; count[0] = axis->zoom_size.getValue(); |
---|
1464 | // } |
---|
1465 | // SuperClassWriter::writeData(field_data3D, fieldid, isCollective, field->getNStep()-1,&start,&count ); |
---|
1466 | // if (wtime) |
---|
1467 | // { |
---|
1468 | // SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot ); |
---|
1469 | // SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot ); |
---|
1470 | // SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot ); |
---|
1471 | // SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); |
---|
1472 | // } |
---|
1473 | // break; |
---|
1474 | // } |
---|
1475 | // } |
---|
1476 | // |
---|
1477 | // } |
---|
1478 | // else // 2D |
---|
1479 | // { |
---|
1480 | // CArray<double,2> field_data2D(domain->zoom_ni_srv,domain->zoom_nj_srv) ; |
---|
1481 | // if (!field->default_value.isEmpty()) field_data2D = field->default_value ; |
---|
1482 | // field->outputField(field_data2D); |
---|
1483 | // if (!field->prec.isEmpty() && field->prec==2) field_data2D=round(field_data2D) ; |
---|
1484 | // switch (SuperClass::type) |
---|
1485 | // { |
---|
1486 | // case (MULTI_FILE) : |
---|
1487 | // { |
---|
1488 | // SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1); |
---|
1489 | // if (wtime) |
---|
1490 | // { |
---|
1491 | // SuperClassWriter::writeData(time_data, timeAxisId, isCollective, field->getNStep()-1); |
---|
1492 | // SuperClassWriter::writeData(time_counter, string("time_counter"), isCollective, field->getNStep()-1); |
---|
1493 | // SuperClassWriter::writeData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1); |
---|
1494 | // SuperClassWriter::writeData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1); |
---|
1495 | // } |
---|
1496 | // break; |
---|
1497 | // } |
---|
1498 | // case (ONE_FILE) : |
---|
1499 | // { |
---|
1500 | // std::vector<StdSize> start(2) ; |
---|
1501 | // std::vector<StdSize> count(2) ; |
---|
1502 | // if (domain->isEmpty()) |
---|
1503 | // { |
---|
1504 | // start[0]=0 ; start[1]=0 ; |
---|
1505 | // count[0]=0 ; count[1]=0 ; |
---|
1506 | // } |
---|
1507 | // else |
---|
1508 | // { |
---|
1509 | // start[1]=domain->zoom_ibegin_srv-domain->zoom_ibegin.getValue() ; start[0]=domain->zoom_jbegin_srv-domain->zoom_jbegin.getValue() ; |
---|
1510 | // count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; |
---|
1511 | // } |
---|
1512 | // |
---|
1513 | // SuperClassWriter::writeData(field_data2D, fieldid, isCollective, field->getNStep()-1,&start,&count); |
---|
1514 | // if (wtime) |
---|
1515 | // { |
---|
1516 | // SuperClassWriter::writeTimeAxisData(time_data, timeAxisId, isCollective, field->getNStep()-1,isRoot); |
---|
1517 | // SuperClassWriter::writeTimeAxisData(time_counter, string("time_counter"), isCollective, field->getNStep()-1,isRoot); |
---|
1518 | // SuperClassWriter::writeTimeAxisData(time_counter_bound, timeBoundId, isCollective, field->getNStep()-1, isRoot); |
---|
1519 | // SuperClassWriter::writeTimeAxisData(time_data_bound, timeAxisBoundId, isCollective, field->getNStep()-1, isRoot); |
---|
1520 | // } |
---|
1521 | // break; |
---|
1522 | // |
---|
1523 | // } |
---|
1524 | // } |
---|
1525 | // } |
---|
1526 | // } |
---|
1527 | // catch (CNetCdfException& e) |
---|
1528 | // { |
---|
1529 | // StdString msg("On writing field data: "); |
---|
1530 | // msg.append(fieldid); msg.append("\n"); |
---|
1531 | // msg.append("In the context : "); |
---|
1532 | // msg.append(context->getId()); msg.append("\n"); |
---|
1533 | // msg.append(e.what()); |
---|
1534 | // ERROR("CNc4DataOutput::writeFieldData_ (CField* field)", << msg); |
---|
1535 | // } |
---|
1536 | // } |
---|
1537 | |
---|
1538 | //--------------------------------------------------------------- |
---|
1539 | |
---|
1540 | void CNc4DataOutput::writeTimeAxis_ |
---|
1541 | (CField* field, |
---|
1542 | const boost::shared_ptr<CCalendar> cal) |
---|
1543 | { |
---|
1544 | StdOStringStream oss; |
---|
1545 | |
---|
1546 | // if (field->operation.getValue().compare("once") == 0) return ; |
---|
1547 | if (field->foperation->timeType() == func::CFunctor::once) return ; |
---|
1548 | |
---|
1549 | // oss << "time_" << field->operation.getValue() |
---|
1550 | // << "_" << field->getRelFile()->output_freq.getValue(); |
---|
1551 | |
---|
1552 | // StdString axisid = oss.str(); |
---|
1553 | // if (field->foperation->timeType() == func::CFunctor::centered) axisid="time_centered" ; |
---|
1554 | // else if (field->foperation->timeType() == func::CFunctor::instant) axisid="time_instant" ; |
---|
1555 | |
---|
1556 | StdString axisid("time_centered") ; |
---|
1557 | StdString axisBoundId("time_centered_bounds"); |
---|
1558 | StdString timeid("time_counter"); |
---|
1559 | StdString timeBoundId("time_bounds"); |
---|
1560 | |
---|
1561 | if (field->foperation->timeType() == func::CFunctor::instant) |
---|
1562 | { |
---|
1563 | axisid = "time_instant"; |
---|
1564 | axisBoundId = "time_instant_bounds"; |
---|
1565 | } |
---|
1566 | |
---|
1567 | try |
---|
1568 | { |
---|
1569 | // Adding time_instant or time_centered |
---|
1570 | std::vector<StdString> dims; |
---|
1571 | dims.push_back(timeid); |
---|
1572 | if (!SuperClassWriter::varExist(axisid)) |
---|
1573 | { |
---|
1574 | SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); |
---|
1575 | |
---|
1576 | CDate timeOrigin=cal->getTimeOrigin() ; |
---|
1577 | StdOStringStream oss2; |
---|
1578 | // oss2<<initDate.getYear()<<"-"<<initDate.getMonth()<<"-"<<initDate.getDay()<<" " |
---|
1579 | // <<initDate.getHour()<<"-"<<initDate.getMinute()<<"-"<<initDate.getSecond() ; |
---|
1580 | StdString strInitdate=oss2.str() ; |
---|
1581 | StdString strTimeOrigin=timeOrigin.toString() ; |
---|
1582 | this->writeTimeAxisAttributes |
---|
1583 | (axisid, cal->getType(), |
---|
1584 | StdString("seconds since ").append(strTimeOrigin), |
---|
1585 | strTimeOrigin, axisBoundId); |
---|
1586 | } |
---|
1587 | |
---|
1588 | // Adding time_instant_bounds or time_centered_bounds variables |
---|
1589 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
1590 | { |
---|
1591 | dims.clear() ; |
---|
1592 | dims.push_back(timeid); |
---|
1593 | dims.push_back(timeBoundId); |
---|
1594 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
1595 | } |
---|
1596 | |
---|
1597 | // Adding time_counter |
---|
1598 | axisid = "time_counter" ; |
---|
1599 | axisBoundId = "time_counter_bounds" ; |
---|
1600 | dims.clear() ; |
---|
1601 | dims.push_back(timeid); |
---|
1602 | if (!SuperClassWriter::varExist(axisid)) |
---|
1603 | { |
---|
1604 | SuperClassWriter::addVariable(axisid, NC_DOUBLE, dims); |
---|
1605 | SuperClassWriter::addAttribute("axis", string("T"), &axisid); |
---|
1606 | CDate timeOrigin=cal->getTimeOrigin() ; |
---|
1607 | StdString strTimeOrigin=timeOrigin.toString() ; |
---|
1608 | |
---|
1609 | this->writeTimeAxisAttributes |
---|
1610 | (axisid, cal->getType(), |
---|
1611 | StdString("seconds since ").append(strTimeOrigin), |
---|
1612 | strTimeOrigin, axisBoundId); |
---|
1613 | } |
---|
1614 | |
---|
1615 | // Adding time_counter_bound dimension |
---|
1616 | if (!SuperClassWriter::varExist(axisBoundId)) |
---|
1617 | { |
---|
1618 | dims.clear(); |
---|
1619 | dims.push_back(timeid); |
---|
1620 | dims.push_back(timeBoundId); |
---|
1621 | SuperClassWriter::addVariable(axisBoundId, NC_DOUBLE, dims); |
---|
1622 | } |
---|
1623 | } |
---|
1624 | catch (CNetCdfException& e) |
---|
1625 | { |
---|
1626 | StdString msg("On writing time axis data: "); |
---|
1627 | msg.append("In the context : "); |
---|
1628 | CContext* context = CContext::getCurrent() ; |
---|
1629 | msg.append(context->getId()); msg.append("\n"); |
---|
1630 | msg.append(e.what()); |
---|
1631 | ERROR("CNc4DataOutput::writeTimeAxis_ (CField* field, \ |
---|
1632 | const boost::shared_ptr<CCalendar> cal)", << msg); |
---|
1633 | } |
---|
1634 | } |
---|
1635 | |
---|
1636 | //--------------------------------------------------------------- |
---|
1637 | |
---|
1638 | void CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, |
---|
1639 | const StdString & calendar, |
---|
1640 | const StdString & units, |
---|
1641 | const StdString & time_origin, |
---|
1642 | const StdString & time_bounds, |
---|
1643 | const StdString & standard_name, |
---|
1644 | const StdString & long_name, |
---|
1645 | const StdString & title) |
---|
1646 | { |
---|
1647 | try |
---|
1648 | { |
---|
1649 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
1650 | SuperClassWriter::addAttribute("long_name", long_name , &axis_name); |
---|
1651 | SuperClassWriter::addAttribute("title", title , &axis_name); |
---|
1652 | SuperClassWriter::addAttribute("calendar", calendar , &axis_name); |
---|
1653 | SuperClassWriter::addAttribute("units", units , &axis_name); |
---|
1654 | SuperClassWriter::addAttribute("time_origin", time_origin , &axis_name); |
---|
1655 | SuperClassWriter::addAttribute("bounds", time_bounds , &axis_name); |
---|
1656 | } |
---|
1657 | catch (CNetCdfException& e) |
---|
1658 | { |
---|
1659 | StdString msg("On writing time axis Attribute: "); |
---|
1660 | msg.append("In the context : "); |
---|
1661 | CContext* context = CContext::getCurrent() ; |
---|
1662 | msg.append(context->getId()); msg.append("\n"); |
---|
1663 | msg.append(e.what()); |
---|
1664 | ERROR("CNc4DataOutput::writeTimeAxisAttributes(const StdString & axis_name, \ |
---|
1665 | const StdString & calendar,\ |
---|
1666 | const StdString & units, \ |
---|
1667 | const StdString & time_origin, \ |
---|
1668 | const StdString & time_bounds, \ |
---|
1669 | const StdString & standard_name, \ |
---|
1670 | const StdString & long_name, \ |
---|
1671 | const StdString & title)", << msg); |
---|
1672 | } |
---|
1673 | } |
---|
1674 | |
---|
1675 | //--------------------------------------------------------------- |
---|
1676 | |
---|
1677 | void CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, |
---|
1678 | const StdString & axis, |
---|
1679 | const StdString & standard_name, |
---|
1680 | const StdString & long_name, |
---|
1681 | const StdString & units, |
---|
1682 | const StdString & nav_model) |
---|
1683 | { |
---|
1684 | try |
---|
1685 | { |
---|
1686 | SuperClassWriter::addAttribute("axis" , axis , &axis_name); |
---|
1687 | SuperClassWriter::addAttribute("standard_name", standard_name, &axis_name); |
---|
1688 | SuperClassWriter::addAttribute("long_name" , long_name , &axis_name); |
---|
1689 | SuperClassWriter::addAttribute("units" , units , &axis_name); |
---|
1690 | SuperClassWriter::addAttribute("nav_model" , nav_model , &axis_name); |
---|
1691 | } |
---|
1692 | catch (CNetCdfException& e) |
---|
1693 | { |
---|
1694 | StdString msg("On writing Axis Attribute: "); |
---|
1695 | msg.append("In the context : "); |
---|
1696 | CContext* context = CContext::getCurrent() ; |
---|
1697 | msg.append(context->getId()); msg.append("\n"); |
---|
1698 | msg.append(e.what()); |
---|
1699 | ERROR("CNc4DataOutput::writeAxisAttributes(const StdString & axis_name, \ |
---|
1700 | const StdString & axis, \ |
---|
1701 | const StdString & standard_name, \ |
---|
1702 | const StdString & long_name, \ |
---|
1703 | const StdString & units, \ |
---|
1704 | const StdString & nav_model)", << msg); |
---|
1705 | } |
---|
1706 | } |
---|
1707 | |
---|
1708 | //--------------------------------------------------------------- |
---|
1709 | |
---|
1710 | void CNc4DataOutput::writeLocalAttributes |
---|
1711 | (int ibegin, int ni, int jbegin, int nj, StdString domid) |
---|
1712 | { |
---|
1713 | try |
---|
1714 | { |
---|
1715 | SuperClassWriter::addAttribute(StdString("ibegin").append(domid), ibegin); |
---|
1716 | SuperClassWriter::addAttribute(StdString("ni" ).append(domid), ni); |
---|
1717 | SuperClassWriter::addAttribute(StdString("jbegin").append(domid), jbegin); |
---|
1718 | SuperClassWriter::addAttribute(StdString("nj" ).append(domid), nj); |
---|
1719 | } |
---|
1720 | catch (CNetCdfException& e) |
---|
1721 | { |
---|
1722 | StdString msg("On writing Local Attributes: "); |
---|
1723 | msg.append("In the context : "); |
---|
1724 | CContext* context = CContext::getCurrent() ; |
---|
1725 | msg.append(context->getId()); msg.append("\n"); |
---|
1726 | msg.append(e.what()); |
---|
1727 | ERROR("CNc4DataOutput::writeLocalAttributes \ |
---|
1728 | (int ibegin, int ni, int jbegin, int nj, StdString domid)", << msg); |
---|
1729 | } |
---|
1730 | |
---|
1731 | } |
---|
1732 | |
---|
1733 | void CNc4DataOutput::writeLocalAttributes_IOIPSL |
---|
1734 | (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size) |
---|
1735 | { |
---|
1736 | CArray<int,1> array(2) ; |
---|
1737 | |
---|
1738 | try |
---|
1739 | { |
---|
1740 | SuperClassWriter::addAttribute("DOMAIN_number_total",size ) ; |
---|
1741 | SuperClassWriter::addAttribute("DOMAIN_number", rank) ; |
---|
1742 | array=1,2 ; |
---|
1743 | SuperClassWriter::addAttribute("DOMAIN_dimensions_ids",array) ; |
---|
1744 | array=ni_glo,nj_glo ; |
---|
1745 | SuperClassWriter::addAttribute("DOMAIN_size_global", array) ; |
---|
1746 | array=ni,nj ; |
---|
1747 | SuperClassWriter::addAttribute("DOMAIN_size_local", array) ; |
---|
1748 | array=ibegin,jbegin ; |
---|
1749 | SuperClassWriter::addAttribute("DOMAIN_position_first", array) ; |
---|
1750 | array=ibegin+ni-1,jbegin+nj-1 ; |
---|
1751 | SuperClassWriter::addAttribute("DOMAIN_position_last",array) ; |
---|
1752 | array=0,0 ; |
---|
1753 | SuperClassWriter::addAttribute("DOMAIN_halo_size_start", array) ; |
---|
1754 | SuperClassWriter::addAttribute("DOMAIN_halo_size_end", array); |
---|
1755 | SuperClassWriter::addAttribute("DOMAIN_type",string("box")) ; |
---|
1756 | /* |
---|
1757 | SuperClassWriter::addAttribute("DOMAIN_DIM_N001",string("x")) ; |
---|
1758 | SuperClassWriter::addAttribute("DOMAIN_DIM_N002",string("y")) ; |
---|
1759 | SuperClassWriter::addAttribute("DOMAIN_DIM_N003",string("axis_A")) ; |
---|
1760 | SuperClassWriter::addAttribute("DOMAIN_DIM_N004",string("time_counter")) ; |
---|
1761 | */ |
---|
1762 | } |
---|
1763 | catch (CNetCdfException& e) |
---|
1764 | { |
---|
1765 | StdString msg("On writing Local Attributes IOI PSL \n"); |
---|
1766 | msg.append("In the context : "); |
---|
1767 | CContext* context = CContext::getCurrent() ; |
---|
1768 | msg.append(context->getId()); msg.append("\n"); |
---|
1769 | msg.append(e.what()); |
---|
1770 | ERROR("CNc4DataOutput::writeLocalAttributes_IOIPSL \ |
---|
1771 | (int ibegin, int ni, int jbegin, int nj, int ni_glo, int nj_glo, int rank, int size)", << msg); |
---|
1772 | } |
---|
1773 | } |
---|
1774 | //--------------------------------------------------------------- |
---|
1775 | |
---|
1776 | void CNc4DataOutput:: writeFileAttributes(const StdString & name, |
---|
1777 | const StdString & description, |
---|
1778 | const StdString & conventions, |
---|
1779 | const StdString & production, |
---|
1780 | const StdString & timeStamp) |
---|
1781 | { |
---|
1782 | try |
---|
1783 | { |
---|
1784 | SuperClassWriter::addAttribute("name" , name); |
---|
1785 | SuperClassWriter::addAttribute("description", description); |
---|
1786 | SuperClassWriter::addAttribute("conventions", conventions); |
---|
1787 | SuperClassWriter::addAttribute("production" , production); |
---|
1788 | SuperClassWriter::addAttribute("timeStamp" , timeStamp); |
---|
1789 | } |
---|
1790 | catch (CNetCdfException& e) |
---|
1791 | { |
---|
1792 | StdString msg("On writing File Attributes \n "); |
---|
1793 | msg.append("In the context : "); |
---|
1794 | CContext* context = CContext::getCurrent() ; |
---|
1795 | msg.append(context->getId()); msg.append("\n"); |
---|
1796 | msg.append(e.what()); |
---|
1797 | ERROR("CNc4DataOutput:: writeFileAttributes(const StdString & name, \ |
---|
1798 | const StdString & description, \ |
---|
1799 | const StdString & conventions, \ |
---|
1800 | const StdString & production, \ |
---|
1801 | const StdString & timeStamp)", << msg); |
---|
1802 | } |
---|
1803 | } |
---|
1804 | |
---|
1805 | //--------------------------------------------------------------- |
---|
1806 | |
---|
1807 | void CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, |
---|
1808 | int data_dim, |
---|
1809 | int data_ni, |
---|
1810 | int data_nj, |
---|
1811 | int data_ibegin, |
---|
1812 | int data_jbegin) |
---|
1813 | { |
---|
1814 | try |
---|
1815 | { |
---|
1816 | SuperClassWriter::addAttribute("data_dim" , data_dim , &mask_name); |
---|
1817 | SuperClassWriter::addAttribute("data_ni" , data_ni , &mask_name); |
---|
1818 | SuperClassWriter::addAttribute("data_nj" , data_nj , &mask_name); |
---|
1819 | SuperClassWriter::addAttribute("data_ibegin", data_ibegin, &mask_name); |
---|
1820 | SuperClassWriter::addAttribute("data_jbegin", data_jbegin, &mask_name); |
---|
1821 | } |
---|
1822 | catch (CNetCdfException& e) |
---|
1823 | { |
---|
1824 | StdString msg("On writing Mask Attributes \n "); |
---|
1825 | msg.append("In the context : "); |
---|
1826 | CContext* context = CContext::getCurrent() ; |
---|
1827 | msg.append(context->getId()); msg.append("\n"); |
---|
1828 | msg.append(e.what()); |
---|
1829 | ERROR("CNc4DataOutput::writeMaskAttributes(const StdString & mask_name, \ |
---|
1830 | int data_dim, \ |
---|
1831 | int data_ni, \ |
---|
1832 | int data_nj, \ |
---|
1833 | int data_ibegin, \ |
---|
1834 | int data_jbegin)", << msg); |
---|
1835 | } |
---|
1836 | } |
---|
1837 | |
---|
1838 | ///-------------------------------------------------------------- |
---|
1839 | |
---|
1840 | } // namespace xios |
---|