27 use ieee_arithmetic,
only : ieee_is_nan
30 nf90_open, nf90_close, nf90_strerror, nf90_def_dim, nf90_def_var, &
31 nf90_put_var, nf90_get_var, nf90_put_att, nf90_get_att, nf90_inq_attname, &
32 nf90_inquire, nf90_inq_dimid, nf90_inquire_dimension, &
33 nf90_inq_varid, nf90_inq_varids, nf90_inquire_variable, nf90_inquire_attribute, &
34 nf90_inq_ncid, nf90_inq_grp_parent, nf90_inq_grpname, nf90_def_grp, &
35 nf90_rename_dim, nf90_rename_var, nf90_rename_att, nf90_sync, &
36 nf90_open, nf90_netcdf4, nf90_create, nf90_write, nf90_nowrite, &
37 nf90_byte, nf90_short, nf90_int, nf90_int64, nf90_float, nf90_double, nf90_char, &
38 nf90_fill_byte, nf90_fill_short, nf90_fill_int, nf90_fill_float, nf90_fill_double, &
39 nf90_noerr, nf90_unlimited, nf90_global, nf90_share, nf90_hdf5, &
40 nf90_64bit_offset, nf90_classic_model
72 procedure,
public :: hasattribute
73 procedure,
public :: renameattribute
74 procedure,
private :: getattributableids
75 procedure,
public :: getattributenames
77 procedure,
private :: setattribute_0d_sp
78 generic,
public :: setattribute => setattribute_0d_sp
79 procedure,
private :: getattribute_0d_sp
80 generic,
public :: getattribute => getattribute_0d_sp
81 procedure,
private :: setattribute_1d_sp
82 generic,
public :: setattribute => setattribute_1d_sp
83 procedure,
private :: getattribute_1d_sp
84 generic,
public :: getattribute => getattribute_1d_sp
85 procedure,
private :: setattribute_0d_dp
86 generic,
public :: setattribute => setattribute_0d_dp
87 procedure,
private :: getattribute_0d_dp
88 generic,
public :: getattribute => getattribute_0d_dp
89 procedure,
private :: setattribute_1d_dp
90 generic,
public :: setattribute => setattribute_1d_dp
91 procedure,
private :: getattribute_1d_dp
92 generic,
public :: getattribute => getattribute_1d_dp
93 procedure,
private :: setattribute_0d_i1
94 generic,
public :: setattribute => setattribute_0d_i1
95 procedure,
private :: getattribute_0d_i1
96 generic,
public :: getattribute => getattribute_0d_i1
97 procedure,
private :: setattribute_1d_i1
98 generic,
public :: setattribute => setattribute_1d_i1
99 procedure,
private :: getattribute_1d_i1
100 generic,
public :: getattribute => getattribute_1d_i1
101 procedure,
private :: setattribute_0d_i2
102 generic,
public :: setattribute => setattribute_0d_i2
103 procedure,
private :: getattribute_0d_i2
104 generic,
public :: getattribute => getattribute_0d_i2
105 procedure,
private :: setattribute_1d_i2
106 generic,
public :: setattribute => setattribute_1d_i2
107 procedure,
private :: getattribute_1d_i2
108 generic,
public :: getattribute => getattribute_1d_i2
109 procedure,
private :: setattribute_0d_i4
110 generic,
public :: setattribute => setattribute_0d_i4
111 procedure,
private :: getattribute_0d_i4
112 generic,
public :: getattribute => getattribute_0d_i4
113 procedure,
private :: setattribute_1d_i4
114 generic,
public :: setattribute => setattribute_1d_i4
115 procedure,
private :: getattribute_1d_i4
116 generic,
public :: getattribute => getattribute_1d_i4
117 procedure,
private :: setattribute_0d_i8
118 generic,
public :: setattribute => setattribute_0d_i8
119 procedure,
private :: getattribute_0d_i8
120 generic,
public :: getattribute => getattribute_0d_i8
121 procedure,
private :: setattribute_1d_i8
122 generic,
public :: setattribute => setattribute_1d_i8
123 procedure,
private :: getattribute_1d_i8
124 generic,
public :: getattribute => getattribute_1d_i8
125 procedure,
private :: setattribute_0d_char
126 generic,
public :: setattribute => setattribute_0d_char
127 procedure,
private :: getattribute_0d_char
128 generic,
public :: getattribute => getattribute_0d_char
140 procedure,
private :: getVariableIds
141 procedure,
public :: getvariables
142 procedure,
public :: getunlimiteddimension
143 procedure,
public :: getnovariables
145 procedure,
private :: getdimensionbyname
146 procedure,
private :: getdimensionbyid
148 procedure,
public :: getparent => getgroupparent
149 procedure,
public :: getname => getgroupname
150 procedure,
public :: getgroup => getgroupbyname
151 procedure,
public :: getvariable => getvariablebyname
152 generic,
public :: getdimension => &
157 procedure,
public :: hasvariable
158 procedure,
public :: hasdimension
159 procedure,
public :: hasgroup
160 procedure,
public :: isunlimited => isdatasetunlimited
163 procedure,
public :: setgroup
164 procedure,
public :: setdimension
165 procedure,
public :: setcoordinate
166 procedure,
private :: set_scrip_dimension
167 procedure,
private :: set_1d_coordinate_variable
168 procedure,
private :: setvariablewithtypes
169 procedure,
private :: setvariablewithnames
170 procedure,
private :: setvariablewithids
172 generic,
public :: setvariable => &
173 setvariablewithnames, &
174 setvariablewithtypes, &
188 character(256) :: fname
193 procedure,
public :: sync
194 procedure,
public :: close
199 procedure newncdataset
209 procedure,
public :: renamedimension
210 procedure,
public :: getparent => getdimensionparent
211 procedure,
public :: getname => getdimensionname
212 procedure,
public :: getlength => getdimensionlength
213 procedure,
public :: isunlimited => isunlimiteddimension
217 procedure newncdimension
227 procedure,
public :: renamevariable
228 procedure,
public :: getparent => getvariableparent
229 procedure,
public :: getname => getvariablename
230 procedure,
private :: getslicingshape
232 procedure,
private :: setdata_0d_sp
233 generic,
public :: setdata => setdata_0d_sp
234 procedure,
private :: getdata_0d_sp
235 generic,
public :: getdata => getdata_0d_sp
236 procedure,
private :: setdata_1d_sp
237 generic,
public :: setdata => setdata_1d_sp
238 procedure,
private :: getdata_1d_sp
239 generic,
public :: getdata => getdata_1d_sp
240 procedure,
private :: setdata_2d_sp
241 generic,
public :: setdata => setdata_2d_sp
242 procedure,
private :: getdata_2d_sp
243 generic,
public :: getdata => getdata_2d_sp
244 procedure,
private :: setdata_3d_sp
245 generic,
public :: setdata => setdata_3d_sp
246 procedure,
private :: getdata_3d_sp
247 generic,
public :: getdata => getdata_3d_sp
248 procedure,
private :: setdata_4d_sp
249 generic,
public :: setdata => setdata_4d_sp
250 procedure,
private :: getdata_4d_sp
251 generic,
public :: getdata => getdata_4d_sp
252 procedure,
private :: setdata_5d_sp
253 generic,
public :: setdata => setdata_5d_sp
254 procedure,
private :: getdata_5d_sp
255 generic,
public :: getdata => getdata_5d_sp
256 procedure,
private :: setdata_6d_sp
257 generic,
public :: setdata => setdata_6d_sp
258 procedure,
private :: getdata_6d_sp
259 generic,
public :: getdata => getdata_6d_sp
260 procedure,
private :: getcfattributes_sp
261 generic,
public :: getcfattributes => getcfattributes_sp
262 procedure,
private :: setvariablefillvalue_sp
263 generic,
public :: setfillvalue => setvariablefillvalue_sp
264 procedure,
private :: getvariablefillvalue_sp
265 generic,
public :: getfillvalue => getvariablefillvalue_sp
266 procedure,
private :: setdata_0d_dp
267 generic,
public :: setdata => setdata_0d_dp
268 procedure,
private :: getdata_0d_dp
269 generic,
public :: getdata => getdata_0d_dp
270 procedure,
private :: setdata_1d_dp
271 generic,
public :: setdata => setdata_1d_dp
272 procedure,
private :: getdata_1d_dp
273 generic,
public :: getdata => getdata_1d_dp
274 procedure,
private :: setdata_2d_dp
275 generic,
public :: setdata => setdata_2d_dp
276 procedure,
private :: getdata_2d_dp
277 generic,
public :: getdata => getdata_2d_dp
278 procedure,
private :: setdata_3d_dp
279 generic,
public :: setdata => setdata_3d_dp
280 procedure,
private :: getdata_3d_dp
281 generic,
public :: getdata => getdata_3d_dp
282 procedure,
private :: setdata_4d_dp
283 generic,
public :: setdata => setdata_4d_dp
284 procedure,
private :: getdata_4d_dp
285 generic,
public :: getdata => getdata_4d_dp
286 procedure,
private :: setdata_5d_dp
287 generic,
public :: setdata => setdata_5d_dp
288 procedure,
private :: getdata_5d_dp
289 generic,
public :: getdata => getdata_5d_dp
290 procedure,
private :: setdata_6d_dp
291 generic,
public :: setdata => setdata_6d_dp
292 procedure,
private :: getdata_6d_dp
293 generic,
public :: getdata => getdata_6d_dp
294 procedure,
private :: getcfattributes_dp
295 generic,
public :: getcfattributes => getcfattributes_dp
296 procedure,
private :: setvariablefillvalue_dp
297 generic,
public :: setfillvalue => setvariablefillvalue_dp
298 procedure,
private :: getvariablefillvalue_dp
299 generic,
public :: getfillvalue => getvariablefillvalue_dp
300 procedure,
private :: setdata_0d_i1
301 generic,
public :: setdata => setdata_0d_i1
302 procedure,
private :: getdata_0d_i1
303 generic,
public :: getdata => getdata_0d_i1
304 procedure,
private :: setdata_1d_i1
305 generic,
public :: setdata => setdata_1d_i1
306 procedure,
private :: getdata_1d_i1
307 generic,
public :: getdata => getdata_1d_i1
308 procedure,
private :: setdata_2d_i1
309 generic,
public :: setdata => setdata_2d_i1
310 procedure,
private :: getdata_2d_i1
311 generic,
public :: getdata => getdata_2d_i1
312 procedure,
private :: setdata_3d_i1
313 generic,
public :: setdata => setdata_3d_i1
314 procedure,
private :: getdata_3d_i1
315 generic,
public :: getdata => getdata_3d_i1
316 procedure,
private :: setdata_4d_i1
317 generic,
public :: setdata => setdata_4d_i1
318 procedure,
private :: getdata_4d_i1
319 generic,
public :: getdata => getdata_4d_i1
320 procedure,
private :: setdata_5d_i1
321 generic,
public :: setdata => setdata_5d_i1
322 procedure,
private :: getdata_5d_i1
323 generic,
public :: getdata => getdata_5d_i1
324 procedure,
private :: setdata_6d_i1
325 generic,
public :: setdata => setdata_6d_i1
326 procedure,
private :: getdata_6d_i1
327 generic,
public :: getdata => getdata_6d_i1
328 procedure,
private :: getcfattributes_i1
329 generic,
public :: getcfattributes => getcfattributes_i1
330 procedure,
private :: setvariablefillvalue_i1
331 generic,
public :: setfillvalue => setvariablefillvalue_i1
332 procedure,
private :: getvariablefillvalue_i1
333 generic,
public :: getfillvalue => getvariablefillvalue_i1
334 procedure,
private :: setdata_0d_i2
335 generic,
public :: setdata => setdata_0d_i2
336 procedure,
private :: getdata_0d_i2
337 generic,
public :: getdata => getdata_0d_i2
338 procedure,
private :: setdata_1d_i2
339 generic,
public :: setdata => setdata_1d_i2
340 procedure,
private :: getdata_1d_i2
341 generic,
public :: getdata => getdata_1d_i2
342 procedure,
private :: setdata_2d_i2
343 generic,
public :: setdata => setdata_2d_i2
344 procedure,
private :: getdata_2d_i2
345 generic,
public :: getdata => getdata_2d_i2
346 procedure,
private :: setdata_3d_i2
347 generic,
public :: setdata => setdata_3d_i2
348 procedure,
private :: getdata_3d_i2
349 generic,
public :: getdata => getdata_3d_i2
350 procedure,
private :: setdata_4d_i2
351 generic,
public :: setdata => setdata_4d_i2
352 procedure,
private :: getdata_4d_i2
353 generic,
public :: getdata => getdata_4d_i2
354 procedure,
private :: setdata_5d_i2
355 generic,
public :: setdata => setdata_5d_i2
356 procedure,
private :: getdata_5d_i2
357 generic,
public :: getdata => getdata_5d_i2
358 procedure,
private :: setdata_6d_i2
359 generic,
public :: setdata => setdata_6d_i2
360 procedure,
private :: getdata_6d_i2
361 generic,
public :: getdata => getdata_6d_i2
362 procedure,
private :: getcfattributes_i2
363 generic,
public :: getcfattributes => getcfattributes_i2
364 procedure,
private :: setvariablefillvalue_i2
365 generic,
public :: setfillvalue => setvariablefillvalue_i2
366 procedure,
private :: getvariablefillvalue_i2
367 generic,
public :: getfillvalue => getvariablefillvalue_i2
368 procedure,
private :: setdata_0d_i4
369 generic,
public :: setdata => setdata_0d_i4
370 procedure,
private :: getdata_0d_i4
371 generic,
public :: getdata => getdata_0d_i4
372 procedure,
private :: setdata_1d_i4
373 generic,
public :: setdata => setdata_1d_i4
374 procedure,
private :: getdata_1d_i4
375 generic,
public :: getdata => getdata_1d_i4
376 procedure,
private :: setdata_2d_i4
377 generic,
public :: setdata => setdata_2d_i4
378 procedure,
private :: getdata_2d_i4
379 generic,
public :: getdata => getdata_2d_i4
380 procedure,
private :: setdata_3d_i4
381 generic,
public :: setdata => setdata_3d_i4
382 procedure,
private :: getdata_3d_i4
383 generic,
public :: getdata => getdata_3d_i4
384 procedure,
private :: setdata_4d_i4
385 generic,
public :: setdata => setdata_4d_i4
386 procedure,
private :: getdata_4d_i4
387 generic,
public :: getdata => getdata_4d_i4
388 procedure,
private :: setdata_5d_i4
389 generic,
public :: setdata => setdata_5d_i4
390 procedure,
private :: getdata_5d_i4
391 generic,
public :: getdata => getdata_5d_i4
392 procedure,
private :: setdata_6d_i4
393 generic,
public :: setdata => setdata_6d_i4
394 procedure,
private :: getdata_6d_i4
395 generic,
public :: getdata => getdata_6d_i4
396 procedure,
private :: getcfattributes_i4
397 generic,
public :: getcfattributes => getcfattributes_i4
398 procedure,
private :: setvariablefillvalue_i4
399 generic,
public :: setfillvalue => setvariablefillvalue_i4
400 procedure,
private :: getvariablefillvalue_i4
401 generic,
public :: getfillvalue => getvariablefillvalue_i4
402 procedure,
private :: setdata_0d_i8
403 generic,
public :: setdata => setdata_0d_i8
404 procedure,
private :: getdata_0d_i8
405 generic,
public :: getdata => getdata_0d_i8
406 procedure,
private :: setdata_1d_i8
407 generic,
public :: setdata => setdata_1d_i8
408 procedure,
private :: getdata_1d_i8
409 generic,
public :: getdata => getdata_1d_i8
410 procedure,
private :: setdata_2d_i8
411 generic,
public :: setdata => setdata_2d_i8
412 procedure,
private :: getdata_2d_i8
413 generic,
public :: getdata => getdata_2d_i8
414 procedure,
private :: setdata_3d_i8
415 generic,
public :: setdata => setdata_3d_i8
416 procedure,
private :: getdata_3d_i8
417 generic,
public :: getdata => getdata_3d_i8
418 procedure,
private :: setdata_4d_i8
419 generic,
public :: setdata => setdata_4d_i8
420 procedure,
private :: getdata_4d_i8
421 generic,
public :: getdata => getdata_4d_i8
422 procedure,
private :: setdata_5d_i8
423 generic,
public :: setdata => setdata_5d_i8
424 procedure,
private :: getdata_5d_i8
425 generic,
public :: getdata => getdata_5d_i8
426 procedure,
private :: setdata_6d_i8
427 generic,
public :: setdata => setdata_6d_i8
428 procedure,
private :: getdata_6d_i8
429 generic,
public :: getdata => getdata_6d_i8
430 procedure,
private :: getcfattributes_i8
431 generic,
public :: getcfattributes => getcfattributes_i8
432 procedure,
private :: setvariablefillvalue_i8
433 generic,
public :: setfillvalue => setvariablefillvalue_i8
434 procedure,
private :: getvariablefillvalue_i8
435 generic,
public :: getfillvalue => getvariablefillvalue_i8
437 procedure,
public :: getnodimensions
439 procedure,
public :: getdimensions => getvariabledimensions
441 procedure,
public :: getrank => getvariablerank
443 procedure,
public :: getshape => getvariableshape
445 procedure,
public :: getdtype => getvariabledtype
447 procedure,
public :: isunlimited => isunlimitedvariable
453 procedure newncvariable
462 class(NcBase),
intent(in) :: self
463 character(len = 256) :: getNameInterface
469 class(NcBase),
intent(in) :: self
470 type(NcGroup) :: getParentInterface
475 interface operator (==)
476 procedure equalNcBases
477 end interface operator (==)
481 function newncdataset(fname, fmode, cmode)
result(out)
482 character(*),
intent(in) :: fname
483 character(1),
intent(in) :: fmode
484 character(*),
intent(inout),
optional :: cmode
485 integer(i4) :: status
486 type(NcDataset) :: out
490 status = nf90_create(trim(fname), getcreationmode(cmode), out%id)
492 status = nf90_open(trim(fname), nf90_nowrite, out%id)
494 status = nf90_open(trim(fname), nf90_write, out%id)
496 write(*, *)
"Mode argument must be in 'w','r','a' ! "
499 call check(status,
"Failed to open file: " // fname)
503 end function newncdataset
505 function newncvariable(id, parent)
result(out)
506 integer(i4),
intent(in) :: id
507 type(NcGroup),
intent(in) :: parent
508 type(NcVariable) :: out
512 end function newncvariable
514 function newncdimension(id, parent)
result(out)
515 integer(i4),
intent(in) :: id
516 type(NcGroup),
intent(in) :: parent
517 type(NcDimension) :: out
521 end function newncdimension
523 function newncgroup(id)
result(out)
524 integer(i4),
intent(in) :: id
528 end function newncgroup
530 subroutine sync(self)
531 class(NcDataset) :: self
533 call check(nf90_sync(self%id),
"Failed to sync file: " // self%fname)
536 subroutine close(self)
537 class(NcDataset) :: self
539 call check(nf90_close(self%id),
"Failed to close file: " // self%fname)
542 function setgroup(self, name)
543 class(NcGroup),
intent(inout) :: self
544 character(*),
intent(in) :: name
546 type(NcGroup) :: setGroup
548 call check(nf90_def_grp(self%id, name, id),
"Failed to create new group: " // name)
550 end function setgroup
552 function getgroupparent(self)
553 class(NcGroup),
intent(in) :: self
555 type(NcGroup) :: getGroupParent
557 call check(nf90_inq_grp_parent(self%id, id),
"Failed to get parent group of: " // self%getName())
559 end function getgroupparent
561 function getgroupname(self)
562 class(NcGroup),
intent(in) :: self
563 character(256) :: getGroupName
565 call check(nf90_inq_grpname(self%id, getgroupname),
"Failed to inquire group name")
566 end function getgroupname
568 function getnovariables(self)
569 class(NcGroup),
intent(in) :: self
570 integer(i4) :: getNoVariables
572 call check(nf90_inquire(self%id, nvariables = getnovariables),
"Failed inquire number of variables")
573 end function getnovariables
575 function getdimensionparent(self)
576 class(NcDimension),
intent(in) :: self
577 type(NcGroup) :: getDimensionParent
579 getdimensionparent = self%parent
580 end function getdimensionparent
582 function getvariableparent(self)
583 class(NcVariable),
intent(in) :: self
584 type(NcGroup) :: getVariableParent
586 getvariableparent = self%parent
587 end function getvariableparent
589 function getvariableids(self)
590 class(NcGroup),
intent(in) :: self
591 integer(i4),
dimension(:),
allocatable :: getVariableIds
594 allocate(getvariableids(self%getNoVariables()))
595 call check(nf90_inq_varids(self%id, tmp, getvariableids),
"Failed to inquire variable ids")
596 end function getvariableids
598 function getvariables(self)
599 class(NcGroup),
intent(in) :: self
600 type(NcVariable),
dimension(:),
allocatable :: getVariables
601 integer(i4),
dimension(:),
allocatable :: varids
602 integer(i4) :: i, nvars
604 nvars = self%getNoVariables()
605 allocate(getvariables(nvars), varids(nvars))
607 varids = self%getVariableIds()
608 do i = 1,
size(varids)
612 end function getvariables
614 function getdimensionname(self)
615 class(NcDimension),
intent(in) :: self
616 character(len = 256) :: getDimensionName
618 call check(nf90_inquire_dimension(self%parent%id, self%id, name = getdimensionname), &
619 "Failed to inquire dimension name")
620 end function getdimensionname
622 function getdimensionlength(self)
623 class(NcDimension),
intent(in) :: self
624 integer(i4) :: getDimensionLength
626 call check(nf90_inquire_dimension(self%parent%id, self%id, len = getdimensionlength), &
627 "Failed to inquire dimension: " // self%getName())
628 end function getdimensionlength
630 function isdatasetunlimited(self)
631 class(NcGroup),
intent(in) :: self
632 logical :: isDatasetUnlimited
635 call check(nf90_inquire(self%id, unlimiteddimid = dimid), &
636 "Failed to inquire group " // self%getName())
637 isdatasetunlimited = (dimid /= -1)
638 end function isdatasetunlimited
640 function getunlimiteddimension(self)
641 class(NcGroup),
intent(in) :: self
642 type(NcDimension) :: getUnlimitedDimension
645 call check(nf90_inquire(self%id, unlimiteddimid = dimid), &
646 "Failed to inquire group " // self%getName())
648 if (dimid == -1)
then
649 write(*, *)
"Dataset has no unlimited dimension"
653 getunlimiteddimension = self%getDimension(dimid)
654 end function getunlimiteddimension
656 function equalncbases(left, right)
result(out)
657 class(NcBase),
intent(in) :: left, right
660 out = (left%id == right%id)
661 end function equalncbases
663 function isunlimiteddimension(self)
664 class(NcDimension),
intent(in) :: self
665 logical :: isUnlimitedDimension
667 isunlimiteddimension = .false.
668 if (self%parent%isUnlimited())
then
669 isunlimiteddimension = (self == self%parent%getUnlimitedDimension())
671 end function isunlimiteddimension
673 function set_scrip_dimension(self, centersDim1, centersDim2, cornersDim1, cornersDim2, subDimSizes, units) &
675 class(NcGroup),
intent(in) :: self
676 real(dp) ,
intent(in),
dimension(:) :: centersDim1
677 real(dp) ,
intent(in),
dimension(:) :: centersDim2
678 real(dp) ,
intent(in),
dimension(:,:) :: cornersDim1
679 real(dp) ,
intent(in),
dimension(:,:) :: cornersDim2
680 integer(i4) ,
intent(in),
dimension(:) :: subDimSizes
681 character(256),
intent(in) :: units
682 type(NcDimension) :: ncDim
684 type(NcDimension) :: cornerDim, rankDim
685 type(NcVariable) :: ncVar
686 integer(i4),
allocatable,
dimension(:) :: imask_data
689 ncdim = self%setDimension(
'grid_size',
size(centersdim1))
690 cornerdim = self%setDimension(
'grid_corners',
size(cornersdim1, 1))
691 rankdim = self%setDimension(
'grid_rank',
size(subdimsizes))
693 ncvar = self%setVariable(
'grid_center_lon',
"f64", [ncdim])
694 call ncvar%setData(centersdim1)
695 call ncvar%setAttribute(
'units', trim(units))
696 ncvar = self%setVariable(
'grid_center_lat',
"f64", [ncdim])
697 call ncvar%setData(centersdim2)
698 call ncvar%setAttribute(
'units', trim(units))
699 ncvar = self%setVariable(
'grid_corner_lon',
"f64", [cornerdim, ncdim])
700 call ncvar%setData(cornersdim1)
701 call ncvar%setAttribute(
'units', trim(units))
702 ncvar = self%setVariable(
'grid_corner_lat',
"f64", [cornerdim, ncdim])
703 call ncvar%setData(cornersdim2)
704 call ncvar%setAttribute(
'units', trim(units))
705 ncvar = self%setVariable(
'grid_dims',
"i32", [rankdim])
706 call ncvar%setData(subdimsizes)
708 ncvar = self%setVariable(
'grid_imask',
"i32", [ncdim])
709 allocate(imask_data(
size(centersdim1)))
711 call ncvar%setData(imask_data)
712 deallocate(imask_data)
713 call ncvar%setAttribute(
'units',
'unitless')
715 end function set_scrip_dimension
717 subroutine set_1d_coordinate_variable(self, name, ncDim, bounds, referenceArg, ncVar)
718 class(NcGroup),
intent(in) :: self
719 character(*) ,
intent(in) :: name
720 type(NcDimension),
intent(in) :: ncDim
721 real(dp) ,
intent(in),
dimension(:) :: bounds
722 integer(i4) ,
intent(in),
optional :: referenceArg
723 type(NcVariable),
intent(out) :: ncVar
725 type(NcVariable) :: ncVarBounds
726 type(NcDimension) :: bndsDim
727 integer(i8) :: dimLength, iBound
728 integer(i4) :: reference
729 character(256) :: dimBoundName
730 real(dp),
allocatable,
dimension(:, :) :: boundData
733 dimlength =
size(bounds, kind=
i8)
735 if (
present(referencearg))
then
736 reference = referencearg
739 ncvar = self%setVariable(name,
"f64", [ncdim])
741 select case(reference)
744 call ncvar%setData(bounds(1_i8:dimlength - 1_i8))
747 call ncvar%setData((bounds(2_i8:dimlength) + bounds(1_i8:dimlength-1_i8)) / 2.0_dp)
750 call ncvar%setData(bounds(2_i8:dimlength))
752 write(*,*)
"reference id for set_Dimension is ", reference,
", must be 0, 1 or 2."
758 dimboundname = trim(name) //
"_bnds"
760 call ncvar%setAttribute(
'bounds', trim(dimboundname))
762 if (self%hasDimension(
"bnds"))
then
764 bndsdim = self%getDimension(
"bnds")
766 bndsdim = self%setDimension(
"bnds", 2_i4)
768 ncvarbounds = self%setVariable(dimboundname,
"f64", [bndsdim, ncdim])
771 allocate(bounddata(2_i8, dimlength-1_i8))
772 do ibound = 1_i8, dimlength-1_i8
773 bounddata(1_i8, ibound) = bounds(ibound)
774 bounddata(2_i8, ibound) = bounds(ibound + 1_i8)
776 call ncvarbounds%setData(bounddata)
777 deallocate(bounddata)
779 end subroutine set_1d_coordinate_variable
781 function setdimension(self, name, length)
result(ncDim)
782 class(NcGroup),
intent(in) :: self
783 character(*) ,
intent(in) :: name
784 integer(i4),
intent(in),
optional :: length
786 type(NcDimension) :: ncDim
787 integer(i4) :: dimLength
790 dimlength = nf90_unlimited
791 if (
present(length))
then
792 if (length > 0_i4)
then
797 call check(nf90_def_dim(self%id, name, dimlength, id), &
798 "Failed to create dimension: " // name)
802 end function setdimension
804 function setcoordinate(self, name, length, bounds, reference, attribute_names, attribute_values, &
805 centersDim1, centersDim2, cornersDim1, cornersDim2, subDimSizes, units)
result(ncDim)
806 class(NcGroup),
intent(in) :: self
807 character(*) ,
intent(in) :: name
808 integer(i4),
intent(in),
optional :: length
809 real(dp) ,
intent(in),
optional,
dimension(:) :: bounds
810 integer(i4) ,
intent(in),
optional :: reference
811 character(*) ,
intent(in),
optional,
dimension(:) :: attribute_names
812 character(*) ,
intent(in),
optional,
dimension(:) :: attribute_values
813 real(dp) ,
intent(in),
optional,
dimension(:) :: centersDim1
814 real(dp) ,
intent(in),
optional,
dimension(:) :: centersDim2
815 real(dp) ,
intent(in),
optional,
dimension(:,:) :: cornersDim1
816 real(dp) ,
intent(in),
optional,
dimension(:,:) :: cornersDim2
817 integer(i4) ,
intent(in),
optional,
dimension(:) :: subDimSizes
818 character(*),
intent(in),
optional :: units
820 type(NcDimension) :: ncDim
821 type(NcVariable) :: ncVar
824 if (
present(centersdim1) .and.
present(centersdim2) .and.
present(cornersdim1) .and.
present(cornersdim2) &
825 .and.
present(subdimsizes) .and.
present(units))
then
826 ncdim = self%set_scrip_dimension(centersdim1, centersdim2, cornersdim1, cornersdim2, subdimsizes, units)
829 ncdim = self%setDimension(name, length)
831 if (
present(bounds))
then
832 call self%set_1D_coordinate_variable(name, ncdim, bounds, reference, ncvar)
835 if (
present(attribute_names) .and.
present(attribute_values))
then
836 do iatt = 1,
size(attribute_names)
837 call ncvar%setAttribute(trim(attribute_names(iatt)), &
838 trim(attribute_values(iatt)))
844 end function setcoordinate
846 function hasvariable(self, name)
847 class(NcGroup),
intent(in) :: self
848 character(*),
intent(in) :: name
849 logical :: hasVariable
852 hasvariable = (nf90_inq_varid(self%id, name, tmpid) == nf90_noerr)
853 end function hasvariable
855 function hasdimension(self, name)
856 class(NcGroup),
intent(in) :: self
857 character(*),
intent(in) :: name
858 logical :: hasDimension
861 hasdimension = (nf90_inq_dimid(self%id, name, tmpid) == nf90_noerr)
862 end function hasdimension
864 function hasgroup(self, name)
865 class(NcGroup),
intent(in) :: self
866 character(*),
intent(in) :: name
870 hasgroup = (nf90_inq_ncid(self%id, name, tmpid) == nf90_noerr)
871 end function hasgroup
873 function setvariablewithids(self, name, dtype, dimensions, contiguous, &
874 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
875 cache_size, cache_nelems, cache_preemption)
876 class(NcGroup),
intent(in) :: self
877 character(*),
intent(in) :: name
878 character(*),
intent(in) :: dtype
879 integer(i4),
intent(in) :: dimensions(:)
880 logical,
intent(in),
optional ::
contiguous, shuffle, fletcher32
881 integer(i4),
intent(in),
optional :: endianness, deflate_level, cache_size, &
882 cache_nelems, cache_preemption, chunksizes(:)
883 type(NcVariable) :: setVariableWithIds
884 integer(i4) :: varid, status
886 status = nf90_def_var(self%id, name, getdtypefromstring(dtype), dimensions, varid,
contiguous, &
887 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
888 cache_size, cache_nelems, cache_preemption)
889 call check(status,
"Failed to create variable: " // name)
891 end function setvariablewithids
893 function setvariablewithnames(self, name, dtype, dimensions, contiguous, &
894 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
895 cache_size, cache_nelems, cache_preemption)
897 class(NcGroup),
intent(in) :: self
898 character(*),
intent(in) :: name
899 character(*),
intent(in) :: dtype
900 character(*),
intent(in) :: dimensions(:)
901 logical,
intent(in),
optional ::
contiguous, shuffle, fletcher32
902 integer(i4),
intent(in),
optional :: endianness, deflate_level, cache_size, &
903 cache_nelems, cache_preemption, chunksizes(:)
904 type(NcVariable) :: setVariableWithNames
905 type(NcDimension) :: dim
906 integer(i4) :: i, dimids(size(dimensions))
908 do i = 1,
size(dimensions)
909 dim = self%getDimension(dimensions(i))
913 setvariablewithnames = setvariablewithids(self, name, dtype, dimids,
contiguous, &
914 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
915 cache_size, cache_nelems, cache_preemption)
916 end function setvariablewithnames
918 function setvariablewithtypes(self, name, dtype, dimensions, contiguous, &
919 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
920 cache_size, cache_nelems, cache_preemption)
921 class(NcGroup),
intent(in) :: self
922 character(*),
intent(in) :: name
923 character(*),
intent(in) :: dtype
924 type(NcDimension),
intent(in) :: dimensions(:)
925 logical,
intent(in),
optional ::
contiguous, shuffle, fletcher32
926 integer(i4),
intent(in),
optional :: endianness, deflate_level, cache_size, &
927 cache_nelems, cache_preemption, chunksizes(:)
928 type(NcVariable) :: setVariableWithTypes
929 type(NcDimension) :: dim
930 integer(i4) :: i, dimids(size(dimensions))
932 do i = 1,
size(dimensions)
937 setvariablewithtypes = setvariablewithids(self, name, dtype, dimids,
contiguous, &
938 chunksizes, deflate_level, shuffle, fletcher32, endianness, &
939 cache_size, cache_nelems, cache_preemption)
940 end function setvariablewithtypes
942 function getdimensionbyid(self, id)
943 class(NcGroup),
intent(in) :: self
945 type(NcDimension) :: getDimensionById
946 character(32) :: msg, name
949 call check(nf90_inquire_dimension(self%id, id, name), &
950 "Could not inquire dimension: " // msg)
952 end function getdimensionbyid
954 function getdimensionbyname(self, name)
955 class(NcGroup),
intent(in) :: self
957 type(NcDimension) :: getDimensionByName
960 call check(nf90_inq_dimid(self%id, name, id), &
961 "Could not inquire dimension: " // name)
962 getdimensionbyname = self%getDimensionById(id)
963 end function getdimensionbyname
965 function getgroupbyname(self, name)
966 class(NcGroup),
intent(in) :: self
967 character(*),
intent(in) :: name
968 type(NcGroup) :: getGroupByName
971 call check(nf90_inq_ncid(self%id, name, id), &
972 "Could not inquire variable: " // name)
974 end function getgroupbyname
976 function getvariablebyname(self, name)
977 class(NcGroup),
intent(in) :: self
978 character(*),
intent(in) :: name
979 type(NcVariable) :: getVariableByName
982 call check(nf90_inq_varid(self%id, name, id), &
983 "Could not inquire variable: " // name)
986 end function getvariablebyname
988 function getvariablename(self)
989 class(NcVariable),
intent(in) :: self
990 character(len = 256) :: getVariableName
992 call check(nf90_inquire_variable(self%parent%id, self%id, name = getvariablename), &
993 "Could not inquire variable name")
994 end function getvariablename
996 function getnodimensions(self)
997 class(NcVariable),
intent(in) :: self
998 integer(i4) :: getNoDimensions
1000 call check(nf90_inquire_variable(self%parent%id, self%id, ndims = getnodimensions), &
1001 "Could not inquire variable: " // self%getName())
1002 end function getnodimensions
1004 function getvariabledimensions(self)
1005 class(NcVariable),
intent(in) :: self
1006 type(NcDimension),
allocatable :: getVariableDimensions(:)
1007 integer(i4),
allocatable :: dimids(:)
1008 integer(i4) :: ii, ndims
1010 ndims = self%getNoDimensions()
1011 allocate(dimids(ndims), getvariabledimensions(ndims))
1012 call check(nf90_inquire_variable(self%parent%id, self%id, dimids = dimids), &
1013 "Could not inquire variable: " // self%getName())
1016 getvariabledimensions(ii) = self%parent%getDimension(dimids(ii))
1018 end function getvariabledimensions
1020 function getvariableshape(self)
1021 class(NcVariable),
intent(in) :: self
1022 integer(i4),
allocatable :: getVariableShape(:)
1023 type(NcDimension),
allocatable :: dims(:)
1024 integer(i4) :: ii, ndims
1026 ndims = self%getNoDimensions()
1027 allocate(getvariableshape(ndims), dims(ndims))
1029 dims = self%getDimensions()
1030 do ii = 1,
size(dims)
1031 getvariableshape(ii) = dims(ii)%getLength()
1033 end function getvariableshape
1035 function getvariablerank(self)
1036 class(NcVariable),
intent(in) :: self
1037 integer(i4) :: getVariableRank
1039 getvariablerank =
size(self%getDimensions())
1040 end function getvariablerank
1042 function getvariabledtype(self)
1043 class(NcVariable),
intent(in) :: self
1044 integer(i4) :: dtype
1045 character(4) :: getVariableDtype
1047 call check(nf90_inquire_variable(self%parent%id, self%id, xtype = dtype), &
1048 "Could not inquire variable: " // self%getName())
1049 getvariabledtype = getdtypefrominteger(dtype)
1050 end function getvariabledtype
1052 function isunlimitedvariable(self)
1053 class(NcVariable),
intent(in) :: self
1054 logical :: isUnlimitedVariable
1055 type(NcDimension),
allocatable :: dims(:)
1056 type(NcDimension) :: dim
1059 allocate(dims(self%getNoDimensions()))
1061 isunlimitedvariable = .false.
1062 dims = self%getDimensions()
1064 do ii = 1,
size(dims)
1066 if (dim%isUnlimited())
then
1067 isunlimitedvariable = .true.
1070 end function isunlimitedvariable
1072 logical function hasattribute(self, name, xtype, len, attnum)
1073 class(NcAttributable),
intent(in) :: self
1074 character(*),
intent(in) :: name
1075 integer(i4),
intent(out),
optional :: xtype
1076 integer(i4),
intent(out),
optional :: len
1077 integer(i4),
intent(out),
optional :: attnum
1078 integer(i4) :: status
1082 status = nf90_inquire_attribute(self%id, nf90_global, name, xtype=xtype, len=len, attnum=attnum)
1084 status = nf90_inquire_attribute(self%parent%id, self%id, name, xtype=xtype, len=len, attnum=attnum)
1087 hasattribute = (status == nf90_noerr)
1088 end function hasattribute
1090 function getattributenames(self)
result(attributeNames)
1091 class(NcAttributable),
intent(in) :: self
1092 character(256),
dimension(:),
allocatable :: attributeNames
1094 integer(i4),
parameter :: maxNames = 100_i4
1095 integer(i4) :: nAtts
1096 integer(i4) :: status
1099 allocate(attributenames(maxnames))
1101 do while (natts < maxnames)
1104 status = nf90_inq_attname(self%id, nf90_global, natts + 1_i4, attributenames(natts + 1_i4))
1106 status = nf90_inq_attname(self%parent%id, self%id, natts + 1_i4, attributenames(natts + 1_i4))
1109 if (status /= nf90_noerr)
then
1112 natts = natts + 1_i4
1116 attributenames = attributenames(1:natts)
1118 end function getattributenames
1122 subroutine setattribute_0d_sp(self, name, data)
1123 class(NcAttributable),
intent(in) :: self
1124 character(len=*),
intent(in) :: name
1125 real(sp),
intent(in) :: data
1126 integer(i4) :: ids(2)
1128 ids = self%getAttributableIds()
1129 call check(nf90_put_att(ids(1), ids(2), name, data), &
1130 "Failed to write attribute: " // name)
1132 end subroutine setattribute_0d_sp
1134 subroutine getattribute_0d_sp(self, name, avalue)
1135 class(NcAttributable),
intent(in) :: self
1136 character(len=*),
intent(in) :: name
1137 real(sp),
intent(out) :: avalue
1138 integer(i4) :: length, ids(2)
1140 ids = self%getAttributableIds()
1141 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1142 "Could not inquire attribute " // name)
1143 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1144 "Could not read attribute " // name)
1146 end subroutine getattribute_0d_sp
1148 subroutine setattribute_1d_sp(self, name, data)
1149 class(NcAttributable),
intent(in) :: self
1150 character(len=*),
intent(in) :: name
1151 real(sp),
intent(in) :: data(:)
1152 integer(i4) :: ids(2)
1154 ids = self%getAttributableIds()
1155 call check(nf90_put_att(ids(1), ids(2), name, data), &
1156 "Failed to write attribute: " // name)
1158 end subroutine setattribute_1d_sp
1160 subroutine getattribute_1d_sp(self, name, avalue)
1161 class(NcAttributable),
intent(in) :: self
1162 character(len=*),
intent(in) :: name
1163 real(sp),
intent(out) :: avalue(:)
1164 integer(i4) :: length, ids(2)
1166 ids = self%getAttributableIds()
1167 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1168 "Could not inquire attribute " // name)
1169 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1170 "Could not read attribute " // name)
1172 end subroutine getattribute_1d_sp
1174 subroutine setattribute_0d_dp(self, name, data)
1175 class(NcAttributable),
intent(in) :: self
1176 character(len=*),
intent(in) :: name
1177 real(dp),
intent(in) :: data
1178 integer(i4) :: ids(2)
1180 ids = self%getAttributableIds()
1181 call check(nf90_put_att(ids(1), ids(2), name, data), &
1182 "Failed to write attribute: " // name)
1184 end subroutine setattribute_0d_dp
1186 subroutine getattribute_0d_dp(self, name, avalue)
1187 class(NcAttributable),
intent(in) :: self
1188 character(len=*),
intent(in) :: name
1189 real(dp),
intent(out) :: avalue
1190 integer(i4) :: length, ids(2)
1192 ids = self%getAttributableIds()
1193 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1194 "Could not inquire attribute " // name)
1195 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1196 "Could not read attribute " // name)
1198 end subroutine getattribute_0d_dp
1200 subroutine setattribute_1d_dp(self, name, data)
1201 class(NcAttributable),
intent(in) :: self
1202 character(len=*),
intent(in) :: name
1203 real(dp),
intent(in) :: data(:)
1204 integer(i4) :: ids(2)
1206 ids = self%getAttributableIds()
1207 call check(nf90_put_att(ids(1), ids(2), name, data), &
1208 "Failed to write attribute: " // name)
1210 end subroutine setattribute_1d_dp
1212 subroutine getattribute_1d_dp(self, name, avalue)
1213 class(NcAttributable),
intent(in) :: self
1214 character(len=*),
intent(in) :: name
1215 real(dp),
intent(out) :: avalue(:)
1216 integer(i4) :: length, ids(2)
1218 ids = self%getAttributableIds()
1219 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1220 "Could not inquire attribute " // name)
1221 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1222 "Could not read attribute " // name)
1224 end subroutine getattribute_1d_dp
1226 subroutine setattribute_0d_i1(self, name, data)
1227 class(NcAttributable),
intent(in) :: self
1228 character(len=*),
intent(in) :: name
1229 integer(i1),
intent(in) :: data
1230 integer(i4) :: ids(2)
1232 ids = self%getAttributableIds()
1233 call check(nf90_put_att(ids(1), ids(2), name, data), &
1234 "Failed to write attribute: " // name)
1236 end subroutine setattribute_0d_i1
1238 subroutine getattribute_0d_i1(self, name, avalue)
1239 class(NcAttributable),
intent(in) :: self
1240 character(len=*),
intent(in) :: name
1241 integer(i1),
intent(out) :: avalue
1242 integer(i4) :: length, ids(2)
1244 ids = self%getAttributableIds()
1245 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1246 "Could not inquire attribute " // name)
1247 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1248 "Could not read attribute " // name)
1250 end subroutine getattribute_0d_i1
1252 subroutine setattribute_1d_i1(self, name, data)
1253 class(NcAttributable),
intent(in) :: self
1254 character(len=*),
intent(in) :: name
1255 integer(i1),
intent(in) :: data(:)
1256 integer(i4) :: ids(2)
1258 ids = self%getAttributableIds()
1259 call check(nf90_put_att(ids(1), ids(2), name, data), &
1260 "Failed to write attribute: " // name)
1262 end subroutine setattribute_1d_i1
1264 subroutine getattribute_1d_i1(self, name, avalue)
1265 class(NcAttributable),
intent(in) :: self
1266 character(len=*),
intent(in) :: name
1267 integer(i1),
intent(out) :: avalue(:)
1268 integer(i4) :: length, ids(2)
1270 ids = self%getAttributableIds()
1271 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1272 "Could not inquire attribute " // name)
1273 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1274 "Could not read attribute " // name)
1276 end subroutine getattribute_1d_i1
1278 subroutine setattribute_0d_i2(self, name, data)
1279 class(NcAttributable),
intent(in) :: self
1280 character(len=*),
intent(in) :: name
1281 integer(i2),
intent(in) :: data
1282 integer(i4) :: ids(2)
1284 ids = self%getAttributableIds()
1285 call check(nf90_put_att(ids(1), ids(2), name, data), &
1286 "Failed to write attribute: " // name)
1288 end subroutine setattribute_0d_i2
1290 subroutine getattribute_0d_i2(self, name, avalue)
1291 class(NcAttributable),
intent(in) :: self
1292 character(len=*),
intent(in) :: name
1293 integer(i2),
intent(out) :: avalue
1294 integer(i4) :: length, ids(2)
1296 ids = self%getAttributableIds()
1297 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1298 "Could not inquire attribute " // name)
1299 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1300 "Could not read attribute " // name)
1302 end subroutine getattribute_0d_i2
1304 subroutine setattribute_1d_i2(self, name, data)
1305 class(NcAttributable),
intent(in) :: self
1306 character(len=*),
intent(in) :: name
1307 integer(i2),
intent(in) :: data(:)
1308 integer(i4) :: ids(2)
1310 ids = self%getAttributableIds()
1311 call check(nf90_put_att(ids(1), ids(2), name, data), &
1312 "Failed to write attribute: " // name)
1314 end subroutine setattribute_1d_i2
1316 subroutine getattribute_1d_i2(self, name, avalue)
1317 class(NcAttributable),
intent(in) :: self
1318 character(len=*),
intent(in) :: name
1319 integer(i2),
intent(out) :: avalue(:)
1320 integer(i4) :: length, ids(2)
1322 ids = self%getAttributableIds()
1323 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1324 "Could not inquire attribute " // name)
1325 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1326 "Could not read attribute " // name)
1328 end subroutine getattribute_1d_i2
1330 subroutine setattribute_0d_i4(self, name, data)
1331 class(NcAttributable),
intent(in) :: self
1332 character(len=*),
intent(in) :: name
1333 integer(i4),
intent(in) :: data
1334 integer(i4) :: ids(2)
1336 ids = self%getAttributableIds()
1337 call check(nf90_put_att(ids(1), ids(2), name, data), &
1338 "Failed to write attribute: " // name)
1340 end subroutine setattribute_0d_i4
1342 subroutine getattribute_0d_i4(self, name, avalue)
1343 class(NcAttributable),
intent(in) :: self
1344 character(len=*),
intent(in) :: name
1345 integer(i4),
intent(out) :: avalue
1346 integer(i4) :: length, ids(2)
1348 ids = self%getAttributableIds()
1349 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1350 "Could not inquire attribute " // name)
1351 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1352 "Could not read attribute " // name)
1354 end subroutine getattribute_0d_i4
1356 subroutine setattribute_1d_i4(self, name, data)
1357 class(NcAttributable),
intent(in) :: self
1358 character(len=*),
intent(in) :: name
1359 integer(i4),
intent(in) :: data(:)
1360 integer(i4) :: ids(2)
1362 ids = self%getAttributableIds()
1363 call check(nf90_put_att(ids(1), ids(2), name, data), &
1364 "Failed to write attribute: " // name)
1366 end subroutine setattribute_1d_i4
1368 subroutine getattribute_1d_i4(self, name, avalue)
1369 class(NcAttributable),
intent(in) :: self
1370 character(len=*),
intent(in) :: name
1371 integer(i4),
intent(out) :: avalue(:)
1372 integer(i4) :: length, ids(2)
1374 ids = self%getAttributableIds()
1375 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1376 "Could not inquire attribute " // name)
1377 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1378 "Could not read attribute " // name)
1380 end subroutine getattribute_1d_i4
1382 subroutine setattribute_0d_i8(self, name, data)
1383 class(NcAttributable),
intent(in) :: self
1384 character(len=*),
intent(in) :: name
1385 integer(i8),
intent(in) :: data
1386 integer(i4) :: ids(2)
1388 ids = self%getAttributableIds()
1389 call check(nf90_put_att(ids(1), ids(2), name, data), &
1390 "Failed to write attribute: " // name)
1392 end subroutine setattribute_0d_i8
1394 subroutine getattribute_0d_i8(self, name, avalue)
1395 class(NcAttributable),
intent(in) :: self
1396 character(len=*),
intent(in) :: name
1397 integer(i8),
intent(out) :: avalue
1398 integer(i4) :: length, ids(2)
1400 ids = self%getAttributableIds()
1401 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1402 "Could not inquire attribute " // name)
1403 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1404 "Could not read attribute " // name)
1406 end subroutine getattribute_0d_i8
1408 subroutine setattribute_1d_i8(self, name, data)
1409 class(NcAttributable),
intent(in) :: self
1410 character(len=*),
intent(in) :: name
1411 integer(i8),
intent(in) :: data(:)
1412 integer(i4) :: ids(2)
1414 ids = self%getAttributableIds()
1415 call check(nf90_put_att(ids(1), ids(2), name, data), &
1416 "Failed to write attribute: " // name)
1418 end subroutine setattribute_1d_i8
1420 subroutine getattribute_1d_i8(self, name, avalue)
1421 class(NcAttributable),
intent(in) :: self
1422 character(len=*),
intent(in) :: name
1423 integer(i8),
intent(out) :: avalue(:)
1424 integer(i4) :: length, ids(2)
1426 ids = self%getAttributableIds()
1427 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1428 "Could not inquire attribute " // name)
1429 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1430 "Could not read attribute " // name)
1432 end subroutine getattribute_1d_i8
1434 subroutine setattribute_0d_char(self, name, data)
1435 class(NcAttributable),
intent(in) :: self
1436 character(len=*),
intent(in) :: name
1437 character(len=*),
intent(in) :: data
1438 integer(i4) :: ids(2)
1440 ids = self%getAttributableIds()
1441 call check(nf90_put_att(ids(1), ids(2), name, data), &
1442 "Failed to write attribute: " // name)
1444 end subroutine setattribute_0d_char
1446 subroutine getattribute_0d_char(self, name, avalue)
1447 class(NcAttributable),
intent(in) :: self
1448 character(len=*),
intent(in) :: name
1449 character(len=*),
intent(out) :: avalue
1450 integer(i4) :: length, ids(2)
1452 ids = self%getAttributableIds()
1453 call check(nf90_inquire_attribute(ids(1), ids(2), name, len = length), &
1454 "Could not inquire attribute " // name)
1455 call check(nf90_get_att(ids(1), ids(2), name, avalue), &
1456 "Could not read attribute " // name)
1458 end subroutine getattribute_0d_char
1461 function getattributableids(self)
1462 class(NcAttributable),
intent(in) :: self
1463 integer(i4) :: getAttributableIds(2)
1466 getattributableids(1) = self%id
1467 getattributableids(2) = nf90_global
1469 getattributableids(1) = self%parent%id
1470 getattributableids(2) = self%id
1472 end function getattributableids
1474 subroutine renameattribute(self, oldname, newname)
1475 class(NcAttributable),
intent(inout) :: self
1476 character(len = *),
intent(in) :: oldname, newname
1477 integer(i4) :: ids(2)
1478 ids = self%getAttributableIds()
1479 call check(nf90_rename_att(ids(1), ids(2), oldname, newname),
"Failed to rename attribute: " // oldname)
1480 end subroutine renameattribute
1482 subroutine renamevariable(self, name)
1483 class(NcVariable),
intent(inout) :: self
1484 character(len = *),
intent(in) :: name
1485 call check(nf90_rename_var(self%parent%id, self%id, name),
"Failed to rename variable: " // self%getName())
1486 end subroutine renamevariable
1488 subroutine renamedimension(self, name)
1489 class(NcDimension),
intent(inout) :: self
1490 character(len = *),
intent(in) :: name
1491 call check(nf90_rename_dim(self%parent%id, self%id, name),
"Failed to rename dimension: " // self%getName())
1492 end subroutine renamedimension
1499 subroutine getdata_0d_sp(self, data, start, cnt, stride, map, mask)
1500 class(NcVariable),
intent(in) :: self
1501 real(sp),
intent(out),
allocatable :: data
1502 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1503 logical,
intent(out),
allocatable,
optional :: mask
1505 integer(i4) :: flagMissing
1506 real(sp) :: fillValue, minValue, maxValue
1509 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
1510 "Could not read data from variable: " // trim(self%getName()))
1512 if (
present(mask))
then
1514 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1515 select case(flagmissing)
1517 mask =
ne(
data, fillvalue)
1519 mask = .not. ieee_is_nan(data)
1521 mask =
data > minvalue
1523 mask =
data < maxvalue
1525 mask = (
data < maxvalue) .and. (
data > minvalue)
1529 end subroutine getdata_0d_sp
1531 subroutine setdata_0d_sp(self, values, start, cnt, stride, map)
1532 class(NcVariable),
intent(in) :: self
1533 real(sp),
intent(in) :: values
1534 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1535 call check(nf90_put_var(self%parent%id, self%id, values, start), &
1536 "Failed to write data into variable: " // trim(self%getName()))
1538 end subroutine setdata_0d_sp
1540 subroutine getdata_1d_sp(self, data, start, cnt, stride, map, mask)
1541 class(NcVariable),
intent(in) :: self
1542 real(sp),
intent(out),
allocatable :: data(:)
1543 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1544 logical,
intent(out),
allocatable,
optional :: mask(:)
1546 integer(i4) :: flagMissing
1547 real(sp) :: fillValue, minValue, maxValue
1548 integer(i4),
allocatable :: slcshape(:), datashape(:)
1550 slcshape = self%getSlicingShape(start, cnt, stride)
1551 datashape = getreadshape(slcshape,
size(shape(data)))
1552 allocate(
data(datashape(1)))
1553 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1554 "Could not read data from variable: " // trim(self%getName()))
1555 if (
present(mask))
then
1556 allocate(mask(datashape(1)))
1558 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1559 select case(flagmissing)
1561 mask =
ne(
data, fillvalue)
1563 mask = .not. ieee_is_nan(data)
1565 mask =
data > minvalue
1567 mask =
data < maxvalue
1569 mask = (
data < maxvalue) .and. (
data > minvalue)
1573 end subroutine getdata_1d_sp
1575 subroutine setdata_1d_sp(self, values, start, cnt, stride, map)
1576 class(NcVariable),
intent(in) :: self
1577 real(sp),
intent(in) :: values(:)
1578 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1579 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1580 "Failed to write data into variable: " // trim(self%getName()))
1582 end subroutine setdata_1d_sp
1584 subroutine getdata_2d_sp(self, data, start, cnt, stride, map, mask)
1585 class(NcVariable),
intent(in) :: self
1586 real(sp),
intent(out),
allocatable :: data(:,:)
1587 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1588 logical,
intent(out),
allocatable,
optional :: mask(:,:)
1590 integer(i4) :: flagMissing
1591 real(sp) :: fillValue, minValue, maxValue
1592 integer(i4),
allocatable :: slcshape(:), datashape(:)
1594 slcshape = self%getSlicingShape(start, cnt, stride)
1595 datashape = getreadshape(slcshape,
size(shape(data)))
1596 allocate(
data(datashape(1), datashape(2)))
1597 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1598 "Could not read data from variable: " // trim(self%getName()))
1599 if (
present(mask))
then
1600 allocate(mask(datashape(1), datashape(2)))
1602 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1603 select case(flagmissing)
1605 mask =
ne(
data, fillvalue)
1607 mask = .not. ieee_is_nan(data)
1609 mask =
data > minvalue
1611 mask =
data < maxvalue
1613 mask = (
data < maxvalue) .and. (
data > minvalue)
1617 end subroutine getdata_2d_sp
1619 subroutine setdata_2d_sp(self, values, start, cnt, stride, map)
1620 class(NcVariable),
intent(in) :: self
1621 real(sp),
intent(in) :: values(:,:)
1622 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1623 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1624 "Failed to write data into variable: " // trim(self%getName()))
1626 end subroutine setdata_2d_sp
1628 subroutine getdata_3d_sp(self, data, start, cnt, stride, map, mask)
1629 class(NcVariable),
intent(in) :: self
1630 real(sp),
intent(out),
allocatable :: data(:,:,:)
1631 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1632 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
1634 integer(i4) :: flagMissing
1635 real(sp) :: fillValue, minValue, maxValue
1636 integer(i4),
allocatable :: slcshape(:), datashape(:)
1638 slcshape = self%getSlicingShape(start, cnt, stride)
1639 datashape = getreadshape(slcshape,
size(shape(data)))
1640 allocate(
data(datashape(1), datashape(2), datashape(3)))
1641 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1642 "Could not read data from variable: " // trim(self%getName()))
1643 if (
present(mask))
then
1644 allocate(mask(datashape(1), datashape(2), datashape(3)))
1646 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1647 select case(flagmissing)
1649 mask =
ne(
data, fillvalue)
1651 mask = .not. ieee_is_nan(data)
1653 mask =
data > minvalue
1655 mask =
data < maxvalue
1657 mask = (
data < maxvalue) .and. (
data > minvalue)
1661 end subroutine getdata_3d_sp
1663 subroutine setdata_3d_sp(self, values, start, cnt, stride, map)
1664 class(NcVariable),
intent(in) :: self
1665 real(sp),
intent(in) :: values(:,:,:)
1666 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1667 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1668 "Failed to write data into variable: " // trim(self%getName()))
1670 end subroutine setdata_3d_sp
1672 subroutine getdata_4d_sp(self, data, start, cnt, stride, map, mask)
1673 class(NcVariable),
intent(in) :: self
1674 real(sp),
intent(out),
allocatable :: data(:,:,:,:)
1675 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1676 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
1678 integer(i4) :: flagMissing
1679 real(sp) :: fillValue, minValue, maxValue
1680 integer(i4),
allocatable :: slcshape(:), datashape(:)
1682 slcshape = self%getSlicingShape(start, cnt, stride)
1683 datashape = getreadshape(slcshape,
size(shape(data)))
1684 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
1685 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1686 "Could not read data from variable: " // trim(self%getName()))
1687 if (
present(mask))
then
1688 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
1690 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1691 select case(flagmissing)
1693 mask =
ne(
data, fillvalue)
1695 mask = .not. ieee_is_nan(data)
1697 mask =
data > minvalue
1699 mask =
data < maxvalue
1701 mask = (
data < maxvalue) .and. (
data > minvalue)
1705 end subroutine getdata_4d_sp
1707 subroutine setdata_4d_sp(self, values, start, cnt, stride, map)
1708 class(NcVariable),
intent(in) :: self
1709 real(sp),
intent(in) :: values(:,:,:,:)
1710 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1711 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1712 "Failed to write data into variable: " // trim(self%getName()))
1714 end subroutine setdata_4d_sp
1716 subroutine getdata_5d_sp(self, data, start, cnt, stride, map, mask)
1717 class(NcVariable),
intent(in) :: self
1718 real(sp),
intent(out),
allocatable :: data(:,:,:,:,:)
1719 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1720 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
1722 integer(i4) :: flagMissing
1723 real(sp) :: fillValue, minValue, maxValue
1724 integer(i4),
allocatable :: slcshape(:), datashape(:)
1726 slcshape = self%getSlicingShape(start, cnt, stride)
1727 datashape = getreadshape(slcshape,
size(shape(data)))
1728 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
1729 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1730 "Could not read data from variable: " // trim(self%getName()))
1731 if (
present(mask))
then
1732 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
1734 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1735 select case(flagmissing)
1737 mask =
ne(
data, fillvalue)
1739 mask = .not. ieee_is_nan(data)
1741 mask =
data > minvalue
1743 mask =
data < maxvalue
1745 mask = (
data < maxvalue) .and. (
data > minvalue)
1749 end subroutine getdata_5d_sp
1751 subroutine setdata_5d_sp(self, values, start, cnt, stride, map)
1752 class(NcVariable),
intent(in) :: self
1753 real(sp),
intent(in) :: values(:,:,:,:,:)
1754 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1755 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1756 "Failed to write data into variable: " // trim(self%getName()))
1758 end subroutine setdata_5d_sp
1760 subroutine getdata_6d_sp(self, data, start, cnt, stride, map, mask)
1761 class(NcVariable),
intent(in) :: self
1762 real(sp),
intent(out),
allocatable :: data(:,:,:,:,:,:)
1763 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1764 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
1766 integer(i4) :: flagMissing
1767 real(sp) :: fillValue, minValue, maxValue
1768 integer(i4),
allocatable :: slcshape(:), datashape(:)
1770 slcshape = self%getSlicingShape(start, cnt, stride)
1771 datashape = getreadshape(slcshape,
size(shape(data)))
1772 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
1773 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1774 "Could not read data from variable: " // trim(self%getName()))
1775 if (
present(mask))
then
1776 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
1778 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1779 select case(flagmissing)
1781 mask =
ne(
data, fillvalue)
1783 mask = .not. ieee_is_nan(data)
1785 mask =
data > minvalue
1787 mask =
data < maxvalue
1789 mask = (
data < maxvalue) .and. (
data > minvalue)
1793 end subroutine getdata_6d_sp
1795 subroutine setdata_6d_sp(self, values, start, cnt, stride, map)
1796 class(NcVariable),
intent(in) :: self
1797 real(sp),
intent(in) :: values(:,:,:,:,:,:)
1798 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1799 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1800 "Failed to write data into variable: " // trim(self%getName()))
1802 end subroutine setdata_6d_sp
1804 subroutine getvariablefillvalue_sp(self, fvalue)
1805 class(NcVariable),
intent(in) :: self
1806 real(sp),
intent(out) :: fvalue
1811 fvalue = nf90_fill_float
1814 end subroutine getvariablefillvalue_sp
1816 subroutine getcfattributes_sp(self, minValue, maxValue, fillValue, flagMissing)
1817 class(NcVariable),
intent(in) :: self
1818 real(sp),
intent(out) :: minValue, maxValue, fillValue
1819 integer(i4),
intent(out) :: flagMissing
1821 real(sp) :: valid_range(2)
1824 call self%getFillValue(fillvalue)
1825 if (ieee_is_nan(fillvalue))
then
1831 minvalue = valid_range(1)
1832 maxvalue = valid_range(2)
1841 end subroutine getcfattributes_sp
1843 subroutine setvariablefillvalue_sp(self, fvalue)
1844 class(NcVariable),
intent(inout) :: self
1845 real(sp),
intent(in) :: fvalue
1851 end subroutine setvariablefillvalue_sp
1853 subroutine getdata_0d_dp(self, data, start, cnt, stride, map, mask)
1854 class(NcVariable),
intent(in) :: self
1855 real(dp),
intent(out),
allocatable :: data
1856 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1857 logical,
intent(out),
allocatable,
optional :: mask
1859 integer(i4) :: flagMissing
1860 real(dp) :: fillValue, minValue, maxValue
1863 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
1864 "Could not read data from variable: " // trim(self%getName()))
1866 if (
present(mask))
then
1868 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1869 select case(flagmissing)
1871 mask =
ne(
data, fillvalue)
1873 mask = .not. ieee_is_nan(data)
1875 mask =
data > minvalue
1877 mask =
data < maxvalue
1879 mask = (
data < maxvalue) .and. (
data > minvalue)
1883 end subroutine getdata_0d_dp
1885 subroutine setdata_0d_dp(self, values, start, cnt, stride, map)
1886 class(NcVariable),
intent(in) :: self
1887 real(dp),
intent(in) :: values
1888 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1889 call check(nf90_put_var(self%parent%id, self%id, values, start), &
1890 "Failed to write data into variable: " // trim(self%getName()))
1892 end subroutine setdata_0d_dp
1894 subroutine getdata_1d_dp(self, data, start, cnt, stride, map, mask)
1895 class(NcVariable),
intent(in) :: self
1896 real(dp),
intent(out),
allocatable :: data(:)
1897 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1898 logical,
intent(out),
allocatable,
optional :: mask(:)
1900 integer(i4) :: flagMissing
1901 real(dp) :: fillValue, minValue, maxValue
1902 integer(i4),
allocatable :: slcshape(:), datashape(:)
1904 slcshape = self%getSlicingShape(start, cnt, stride)
1905 datashape = getreadshape(slcshape,
size(shape(data)))
1906 allocate(
data(datashape(1)))
1907 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1908 "Could not read data from variable: " // trim(self%getName()))
1909 if (
present(mask))
then
1910 allocate(mask(datashape(1)))
1912 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1913 select case(flagmissing)
1915 mask =
ne(
data, fillvalue)
1917 mask = .not. ieee_is_nan(data)
1919 mask =
data > minvalue
1921 mask =
data < maxvalue
1923 mask = (
data < maxvalue) .and. (
data > minvalue)
1927 end subroutine getdata_1d_dp
1929 subroutine setdata_1d_dp(self, values, start, cnt, stride, map)
1930 class(NcVariable),
intent(in) :: self
1931 real(dp),
intent(in) :: values(:)
1932 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1933 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1934 "Failed to write data into variable: " // trim(self%getName()))
1936 end subroutine setdata_1d_dp
1938 subroutine getdata_2d_dp(self, data, start, cnt, stride, map, mask)
1939 class(NcVariable),
intent(in) :: self
1940 real(dp),
intent(out),
allocatable :: data(:,:)
1941 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1942 logical,
intent(out),
allocatable,
optional :: mask(:,:)
1944 integer(i4) :: flagMissing
1945 real(dp) :: fillValue, minValue, maxValue
1946 integer(i4),
allocatable :: slcshape(:), datashape(:)
1948 slcshape = self%getSlicingShape(start, cnt, stride)
1949 datashape = getreadshape(slcshape,
size(shape(data)))
1950 allocate(
data(datashape(1), datashape(2)))
1951 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1952 "Could not read data from variable: " // trim(self%getName()))
1953 if (
present(mask))
then
1954 allocate(mask(datashape(1), datashape(2)))
1956 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
1957 select case(flagmissing)
1959 mask =
ne(
data, fillvalue)
1961 mask = .not. ieee_is_nan(data)
1963 mask =
data > minvalue
1965 mask =
data < maxvalue
1967 mask = (
data < maxvalue) .and. (
data > minvalue)
1971 end subroutine getdata_2d_dp
1973 subroutine setdata_2d_dp(self, values, start, cnt, stride, map)
1974 class(NcVariable),
intent(in) :: self
1975 real(dp),
intent(in) :: values(:,:)
1976 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1977 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
1978 "Failed to write data into variable: " // trim(self%getName()))
1980 end subroutine setdata_2d_dp
1982 subroutine getdata_3d_dp(self, data, start, cnt, stride, map, mask)
1983 class(NcVariable),
intent(in) :: self
1984 real(dp),
intent(out),
allocatable :: data(:,:,:)
1985 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
1986 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
1988 integer(i4) :: flagMissing
1989 real(dp) :: fillValue, minValue, maxValue
1990 integer(i4),
allocatable :: slcshape(:), datashape(:)
1992 slcshape = self%getSlicingShape(start, cnt, stride)
1993 datashape = getreadshape(slcshape,
size(shape(data)))
1994 allocate(
data(datashape(1), datashape(2), datashape(3)))
1995 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
1996 "Could not read data from variable: " // trim(self%getName()))
1997 if (
present(mask))
then
1998 allocate(mask(datashape(1), datashape(2), datashape(3)))
2000 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2001 select case(flagmissing)
2003 mask =
ne(
data, fillvalue)
2005 mask = .not. ieee_is_nan(data)
2007 mask =
data > minvalue
2009 mask =
data < maxvalue
2011 mask = (
data < maxvalue) .and. (
data > minvalue)
2015 end subroutine getdata_3d_dp
2017 subroutine setdata_3d_dp(self, values, start, cnt, stride, map)
2018 class(NcVariable),
intent(in) :: self
2019 real(dp),
intent(in) :: values(:,:,:)
2020 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2021 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2022 "Failed to write data into variable: " // trim(self%getName()))
2024 end subroutine setdata_3d_dp
2026 subroutine getdata_4d_dp(self, data, start, cnt, stride, map, mask)
2027 class(NcVariable),
intent(in) :: self
2028 real(dp),
intent(out),
allocatable :: data(:,:,:,:)
2029 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2030 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
2032 integer(i4) :: flagMissing
2033 real(dp) :: fillValue, minValue, maxValue
2034 integer(i4),
allocatable :: slcshape(:), datashape(:)
2036 slcshape = self%getSlicingShape(start, cnt, stride)
2037 datashape = getreadshape(slcshape,
size(shape(data)))
2038 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
2039 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2040 "Could not read data from variable: " // trim(self%getName()))
2041 if (
present(mask))
then
2042 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
2044 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2045 select case(flagmissing)
2047 mask =
ne(
data, fillvalue)
2049 mask = .not. ieee_is_nan(data)
2051 mask =
data > minvalue
2053 mask =
data < maxvalue
2055 mask = (
data < maxvalue) .and. (
data > minvalue)
2059 end subroutine getdata_4d_dp
2061 subroutine setdata_4d_dp(self, values, start, cnt, stride, map)
2062 class(NcVariable),
intent(in) :: self
2063 real(dp),
intent(in) :: values(:,:,:,:)
2064 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2065 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2066 "Failed to write data into variable: " // trim(self%getName()))
2068 end subroutine setdata_4d_dp
2070 subroutine getdata_5d_dp(self, data, start, cnt, stride, map, mask)
2071 class(NcVariable),
intent(in) :: self
2072 real(dp),
intent(out),
allocatable :: data(:,:,:,:,:)
2073 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2074 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
2076 integer(i4) :: flagMissing
2077 real(dp) :: fillValue, minValue, maxValue
2078 integer(i4),
allocatable :: slcshape(:), datashape(:)
2080 slcshape = self%getSlicingShape(start, cnt, stride)
2081 datashape = getreadshape(slcshape,
size(shape(data)))
2082 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2083 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2084 "Could not read data from variable: " // trim(self%getName()))
2085 if (
present(mask))
then
2086 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2088 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2089 select case(flagmissing)
2091 mask =
ne(
data, fillvalue)
2093 mask = .not. ieee_is_nan(data)
2095 mask =
data > minvalue
2097 mask =
data < maxvalue
2099 mask = (
data < maxvalue) .and. (
data > minvalue)
2103 end subroutine getdata_5d_dp
2105 subroutine setdata_5d_dp(self, values, start, cnt, stride, map)
2106 class(NcVariable),
intent(in) :: self
2107 real(dp),
intent(in) :: values(:,:,:,:,:)
2108 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2109 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2110 "Failed to write data into variable: " // trim(self%getName()))
2112 end subroutine setdata_5d_dp
2114 subroutine getdata_6d_dp(self, data, start, cnt, stride, map, mask)
2115 class(NcVariable),
intent(in) :: self
2116 real(dp),
intent(out),
allocatable :: data(:,:,:,:,:,:)
2117 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2118 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
2120 integer(i4) :: flagMissing
2121 real(dp) :: fillValue, minValue, maxValue
2122 integer(i4),
allocatable :: slcshape(:), datashape(:)
2124 slcshape = self%getSlicingShape(start, cnt, stride)
2125 datashape = getreadshape(slcshape,
size(shape(data)))
2126 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2127 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2128 "Could not read data from variable: " // trim(self%getName()))
2129 if (
present(mask))
then
2130 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2132 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2133 select case(flagmissing)
2135 mask =
ne(
data, fillvalue)
2137 mask = .not. ieee_is_nan(data)
2139 mask =
data > minvalue
2141 mask =
data < maxvalue
2143 mask = (
data < maxvalue) .and. (
data > minvalue)
2147 end subroutine getdata_6d_dp
2149 subroutine setdata_6d_dp(self, values, start, cnt, stride, map)
2150 class(NcVariable),
intent(in) :: self
2151 real(dp),
intent(in) :: values(:,:,:,:,:,:)
2152 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2153 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2154 "Failed to write data into variable: " // trim(self%getName()))
2156 end subroutine setdata_6d_dp
2158 subroutine getvariablefillvalue_dp(self, fvalue)
2159 class(NcVariable),
intent(in) :: self
2160 real(dp),
intent(out) :: fvalue
2165 fvalue = nf90_fill_double
2168 end subroutine getvariablefillvalue_dp
2170 subroutine getcfattributes_dp(self, minValue, maxValue, fillValue, flagMissing)
2171 class(NcVariable),
intent(in) :: self
2172 real(dp),
intent(out) :: minValue, maxValue, fillValue
2173 integer(i4),
intent(out) :: flagMissing
2175 real(dp) :: valid_range(2)
2178 call self%getFillValue(fillvalue)
2179 if (ieee_is_nan(fillvalue))
then
2185 minvalue = valid_range(1)
2186 maxvalue = valid_range(2)
2195 end subroutine getcfattributes_dp
2197 subroutine setvariablefillvalue_dp(self, fvalue)
2198 class(NcVariable),
intent(inout) :: self
2199 real(dp),
intent(in) :: fvalue
2205 end subroutine setvariablefillvalue_dp
2207 subroutine getdata_0d_i1(self, data, start, cnt, stride, map, mask)
2208 class(NcVariable),
intent(in) :: self
2209 integer(i1),
intent(out),
allocatable :: data
2210 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2211 logical,
intent(out),
allocatable,
optional :: mask
2213 integer(i4) :: flagMissing
2214 integer(i1) :: fillValue, minValue, maxValue
2215 integer(i1) :: tmp(1)
2217 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
2218 "Could not read data from variable: " // trim(self%getName()))
2220 if (
present(mask))
then
2222 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2223 select case(flagmissing)
2225 mask = .not. (
data == fillvalue)
2227 mask =
data >= minvalue
2229 mask =
data <= maxvalue
2231 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2235 end subroutine getdata_0d_i1
2237 subroutine setdata_0d_i1(self, values, start, cnt, stride, map)
2238 class(NcVariable),
intent(in) :: self
2239 integer(i1),
intent(in) :: values
2240 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2241 call check(nf90_put_var(self%parent%id, self%id, values, start), &
2242 "Failed to write data into variable: " // trim(self%getName()))
2244 end subroutine setdata_0d_i1
2246 subroutine getdata_1d_i1(self, data, start, cnt, stride, map, mask)
2247 class(NcVariable),
intent(in) :: self
2248 integer(i1),
intent(out),
allocatable :: data(:)
2249 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2250 logical,
intent(out),
allocatable,
optional :: mask(:)
2252 integer(i4) :: flagMissing
2253 integer(i1) :: fillValue, minValue, maxValue
2254 integer(i4),
allocatable :: slcshape(:), datashape(:)
2256 slcshape = self%getSlicingShape(start, cnt, stride)
2257 datashape = getreadshape(slcshape,
size(shape(data)))
2258 allocate(
data(datashape(1)))
2259 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2260 "Could not read data from variable: " // trim(self%getName()))
2261 if (
present(mask))
then
2262 allocate(mask(datashape(1)))
2264 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2265 select case(flagmissing)
2267 mask = .not. (
data == fillvalue)
2269 mask =
data >= minvalue
2271 mask =
data <= maxvalue
2273 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2277 end subroutine getdata_1d_i1
2279 subroutine setdata_1d_i1(self, values, start, cnt, stride, map)
2280 class(NcVariable),
intent(in) :: self
2281 integer(i1),
intent(in) :: values(:)
2282 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2283 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2284 "Failed to write data into variable: " // trim(self%getName()))
2286 end subroutine setdata_1d_i1
2288 subroutine getdata_2d_i1(self, data, start, cnt, stride, map, mask)
2289 class(NcVariable),
intent(in) :: self
2290 integer(i1),
intent(out),
allocatable :: data(:,:)
2291 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2292 logical,
intent(out),
allocatable,
optional :: mask(:,:)
2294 integer(i4) :: flagMissing
2295 integer(i1) :: fillValue, minValue, maxValue
2296 integer(i4),
allocatable :: slcshape(:), datashape(:)
2298 slcshape = self%getSlicingShape(start, cnt, stride)
2299 datashape = getreadshape(slcshape,
size(shape(data)))
2300 allocate(
data(datashape(1), datashape(2)))
2301 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2302 "Could not read data from variable: " // trim(self%getName()))
2303 if (
present(mask))
then
2304 allocate(mask(datashape(1), datashape(2)))
2306 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2307 select case(flagmissing)
2309 mask = .not. (
data == fillvalue)
2311 mask =
data >= minvalue
2313 mask =
data <= maxvalue
2315 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2319 end subroutine getdata_2d_i1
2321 subroutine setdata_2d_i1(self, values, start, cnt, stride, map)
2322 class(NcVariable),
intent(in) :: self
2323 integer(i1),
intent(in) :: values(:,:)
2324 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2325 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2326 "Failed to write data into variable: " // trim(self%getName()))
2328 end subroutine setdata_2d_i1
2330 subroutine getdata_3d_i1(self, data, start, cnt, stride, map, mask)
2331 class(NcVariable),
intent(in) :: self
2332 integer(i1),
intent(out),
allocatable :: data(:,:,:)
2333 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2334 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
2336 integer(i4) :: flagMissing
2337 integer(i1) :: fillValue, minValue, maxValue
2338 integer(i4),
allocatable :: slcshape(:), datashape(:)
2340 slcshape = self%getSlicingShape(start, cnt, stride)
2341 datashape = getreadshape(slcshape,
size(shape(data)))
2342 allocate(
data(datashape(1), datashape(2), datashape(3)))
2343 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2344 "Could not read data from variable: " // trim(self%getName()))
2345 if (
present(mask))
then
2346 allocate(mask(datashape(1), datashape(2), datashape(3)))
2348 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2349 select case(flagmissing)
2351 mask = .not. (
data == fillvalue)
2353 mask =
data >= minvalue
2355 mask =
data <= maxvalue
2357 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2361 end subroutine getdata_3d_i1
2363 subroutine setdata_3d_i1(self, values, start, cnt, stride, map)
2364 class(NcVariable),
intent(in) :: self
2365 integer(i1),
intent(in) :: values(:,:,:)
2366 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2367 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2368 "Failed to write data into variable: " // trim(self%getName()))
2370 end subroutine setdata_3d_i1
2372 subroutine getdata_4d_i1(self, data, start, cnt, stride, map, mask)
2373 class(NcVariable),
intent(in) :: self
2374 integer(i1),
intent(out),
allocatable :: data(:,:,:,:)
2375 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2376 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
2378 integer(i4) :: flagMissing
2379 integer(i1) :: fillValue, minValue, maxValue
2380 integer(i4),
allocatable :: slcshape(:), datashape(:)
2382 slcshape = self%getSlicingShape(start, cnt, stride)
2383 datashape = getreadshape(slcshape,
size(shape(data)))
2384 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
2385 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2386 "Could not read data from variable: " // trim(self%getName()))
2387 if (
present(mask))
then
2388 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
2390 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2391 select case(flagmissing)
2393 mask = .not. (
data == fillvalue)
2395 mask =
data >= minvalue
2397 mask =
data <= maxvalue
2399 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2403 end subroutine getdata_4d_i1
2405 subroutine setdata_4d_i1(self, values, start, cnt, stride, map)
2406 class(NcVariable),
intent(in) :: self
2407 integer(i1),
intent(in) :: values(:,:,:,:)
2408 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2409 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2410 "Failed to write data into variable: " // trim(self%getName()))
2412 end subroutine setdata_4d_i1
2414 subroutine getdata_5d_i1(self, data, start, cnt, stride, map, mask)
2415 class(NcVariable),
intent(in) :: self
2416 integer(i1),
intent(out),
allocatable :: data(:,:,:,:,:)
2417 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2418 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
2420 integer(i4) :: flagMissing
2421 integer(i1) :: fillValue, minValue, maxValue
2422 integer(i4),
allocatable :: slcshape(:), datashape(:)
2424 slcshape = self%getSlicingShape(start, cnt, stride)
2425 datashape = getreadshape(slcshape,
size(shape(data)))
2426 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2427 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2428 "Could not read data from variable: " // trim(self%getName()))
2429 if (
present(mask))
then
2430 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2432 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2433 select case(flagmissing)
2435 mask = .not. (
data == fillvalue)
2437 mask =
data >= minvalue
2439 mask =
data <= maxvalue
2441 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2445 end subroutine getdata_5d_i1
2447 subroutine setdata_5d_i1(self, values, start, cnt, stride, map)
2448 class(NcVariable),
intent(in) :: self
2449 integer(i1),
intent(in) :: values(:,:,:,:,:)
2450 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2451 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2452 "Failed to write data into variable: " // trim(self%getName()))
2454 end subroutine setdata_5d_i1
2456 subroutine getdata_6d_i1(self, data, start, cnt, stride, map, mask)
2457 class(NcVariable),
intent(in) :: self
2458 integer(i1),
intent(out),
allocatable :: data(:,:,:,:,:,:)
2459 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2460 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
2462 integer(i4) :: flagMissing
2463 integer(i1) :: fillValue, minValue, maxValue
2464 integer(i4),
allocatable :: slcshape(:), datashape(:)
2466 slcshape = self%getSlicingShape(start, cnt, stride)
2467 datashape = getreadshape(slcshape,
size(shape(data)))
2468 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2469 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2470 "Could not read data from variable: " // trim(self%getName()))
2471 if (
present(mask))
then
2472 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2474 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2475 select case(flagmissing)
2477 mask = .not. (
data == fillvalue)
2479 mask =
data >= minvalue
2481 mask =
data <= maxvalue
2483 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2487 end subroutine getdata_6d_i1
2489 subroutine setdata_6d_i1(self, values, start, cnt, stride, map)
2490 class(NcVariable),
intent(in) :: self
2491 integer(i1),
intent(in) :: values(:,:,:,:,:,:)
2492 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2493 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2494 "Failed to write data into variable: " // trim(self%getName()))
2496 end subroutine setdata_6d_i1
2498 subroutine getvariablefillvalue_i1(self, fvalue)
2499 class(NcVariable),
intent(in) :: self
2500 integer(i1),
intent(out) :: fvalue
2505 fvalue = nf90_fill_byte
2508 end subroutine getvariablefillvalue_i1
2510 subroutine getcfattributes_i1(self, minValue, maxValue, fillValue, flagMissing)
2511 class(NcVariable),
intent(in) :: self
2512 integer(i1),
intent(out) :: minValue, maxValue, fillValue
2513 integer(i4),
intent(out) :: flagMissing
2515 integer(i1) :: valid_range(2)
2518 call self%getFillValue(fillvalue)
2522 minvalue = valid_range(1)
2523 maxvalue = valid_range(2)
2532 end subroutine getcfattributes_i1
2534 subroutine setvariablefillvalue_i1(self, fvalue)
2535 class(NcVariable),
intent(inout) :: self
2536 integer(i1),
intent(in) :: fvalue
2542 end subroutine setvariablefillvalue_i1
2544 subroutine getdata_0d_i2(self, data, start, cnt, stride, map, mask)
2545 class(NcVariable),
intent(in) :: self
2546 integer(i2),
intent(out),
allocatable :: data
2547 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2548 logical,
intent(out),
allocatable,
optional :: mask
2550 integer(i4) :: flagMissing
2551 integer(i2) :: fillValue, minValue, maxValue
2552 integer(i2) :: tmp(1)
2554 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
2555 "Could not read data from variable: " // trim(self%getName()))
2557 if (
present(mask))
then
2559 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2560 select case(flagmissing)
2562 mask = .not. (
data == fillvalue)
2564 mask =
data >= minvalue
2566 mask =
data <= maxvalue
2568 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2572 end subroutine getdata_0d_i2
2574 subroutine setdata_0d_i2(self, values, start, cnt, stride, map)
2575 class(NcVariable),
intent(in) :: self
2576 integer(i2),
intent(in) :: values
2577 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2578 call check(nf90_put_var(self%parent%id, self%id, values, start), &
2579 "Failed to write data into variable: " // trim(self%getName()))
2581 end subroutine setdata_0d_i2
2583 subroutine getdata_1d_i2(self, data, start, cnt, stride, map, mask)
2584 class(NcVariable),
intent(in) :: self
2585 integer(i2),
intent(out),
allocatable :: data(:)
2586 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2587 logical,
intent(out),
allocatable,
optional :: mask(:)
2589 integer(i4) :: flagMissing
2590 integer(i2) :: fillValue, minValue, maxValue
2591 integer(i4),
allocatable :: slcshape(:), datashape(:)
2593 slcshape = self%getSlicingShape(start, cnt, stride)
2594 datashape = getreadshape(slcshape,
size(shape(data)))
2595 allocate(
data(datashape(1)))
2596 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2597 "Could not read data from variable: " // trim(self%getName()))
2598 if (
present(mask))
then
2599 allocate(mask(datashape(1)))
2601 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2602 select case(flagmissing)
2604 mask = .not. (
data == fillvalue)
2606 mask =
data >= minvalue
2608 mask =
data <= maxvalue
2610 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2614 end subroutine getdata_1d_i2
2616 subroutine setdata_1d_i2(self, values, start, cnt, stride, map)
2617 class(NcVariable),
intent(in) :: self
2618 integer(i2),
intent(in) :: values(:)
2619 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2620 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2621 "Failed to write data into variable: " // trim(self%getName()))
2623 end subroutine setdata_1d_i2
2625 subroutine getdata_2d_i2(self, data, start, cnt, stride, map, mask)
2626 class(NcVariable),
intent(in) :: self
2627 integer(i2),
intent(out),
allocatable :: data(:,:)
2628 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2629 logical,
intent(out),
allocatable,
optional :: mask(:,:)
2631 integer(i4) :: flagMissing
2632 integer(i2) :: fillValue, minValue, maxValue
2633 integer(i4),
allocatable :: slcshape(:), datashape(:)
2635 slcshape = self%getSlicingShape(start, cnt, stride)
2636 datashape = getreadshape(slcshape,
size(shape(data)))
2637 allocate(
data(datashape(1), datashape(2)))
2638 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2639 "Could not read data from variable: " // trim(self%getName()))
2640 if (
present(mask))
then
2641 allocate(mask(datashape(1), datashape(2)))
2643 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2644 select case(flagmissing)
2646 mask = .not. (
data == fillvalue)
2648 mask =
data >= minvalue
2650 mask =
data <= maxvalue
2652 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2656 end subroutine getdata_2d_i2
2658 subroutine setdata_2d_i2(self, values, start, cnt, stride, map)
2659 class(NcVariable),
intent(in) :: self
2660 integer(i2),
intent(in) :: values(:,:)
2661 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2662 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2663 "Failed to write data into variable: " // trim(self%getName()))
2665 end subroutine setdata_2d_i2
2667 subroutine getdata_3d_i2(self, data, start, cnt, stride, map, mask)
2668 class(NcVariable),
intent(in) :: self
2669 integer(i2),
intent(out),
allocatable :: data(:,:,:)
2670 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2671 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
2673 integer(i4) :: flagMissing
2674 integer(i2) :: fillValue, minValue, maxValue
2675 integer(i4),
allocatable :: slcshape(:), datashape(:)
2677 slcshape = self%getSlicingShape(start, cnt, stride)
2678 datashape = getreadshape(slcshape,
size(shape(data)))
2679 allocate(
data(datashape(1), datashape(2), datashape(3)))
2680 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2681 "Could not read data from variable: " // trim(self%getName()))
2682 if (
present(mask))
then
2683 allocate(mask(datashape(1), datashape(2), datashape(3)))
2685 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2686 select case(flagmissing)
2688 mask = .not. (
data == fillvalue)
2690 mask =
data >= minvalue
2692 mask =
data <= maxvalue
2694 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2698 end subroutine getdata_3d_i2
2700 subroutine setdata_3d_i2(self, values, start, cnt, stride, map)
2701 class(NcVariable),
intent(in) :: self
2702 integer(i2),
intent(in) :: values(:,:,:)
2703 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2704 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2705 "Failed to write data into variable: " // trim(self%getName()))
2707 end subroutine setdata_3d_i2
2709 subroutine getdata_4d_i2(self, data, start, cnt, stride, map, mask)
2710 class(NcVariable),
intent(in) :: self
2711 integer(i2),
intent(out),
allocatable :: data(:,:,:,:)
2712 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2713 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
2715 integer(i4) :: flagMissing
2716 integer(i2) :: fillValue, minValue, maxValue
2717 integer(i4),
allocatable :: slcshape(:), datashape(:)
2719 slcshape = self%getSlicingShape(start, cnt, stride)
2720 datashape = getreadshape(slcshape,
size(shape(data)))
2721 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
2722 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2723 "Could not read data from variable: " // trim(self%getName()))
2724 if (
present(mask))
then
2725 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
2727 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2728 select case(flagmissing)
2730 mask = .not. (
data == fillvalue)
2732 mask =
data >= minvalue
2734 mask =
data <= maxvalue
2736 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2740 end subroutine getdata_4d_i2
2742 subroutine setdata_4d_i2(self, values, start, cnt, stride, map)
2743 class(NcVariable),
intent(in) :: self
2744 integer(i2),
intent(in) :: values(:,:,:,:)
2745 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2746 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2747 "Failed to write data into variable: " // trim(self%getName()))
2749 end subroutine setdata_4d_i2
2751 subroutine getdata_5d_i2(self, data, start, cnt, stride, map, mask)
2752 class(NcVariable),
intent(in) :: self
2753 integer(i2),
intent(out),
allocatable :: data(:,:,:,:,:)
2754 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2755 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
2757 integer(i4) :: flagMissing
2758 integer(i2) :: fillValue, minValue, maxValue
2759 integer(i4),
allocatable :: slcshape(:), datashape(:)
2761 slcshape = self%getSlicingShape(start, cnt, stride)
2762 datashape = getreadshape(slcshape,
size(shape(data)))
2763 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2764 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2765 "Could not read data from variable: " // trim(self%getName()))
2766 if (
present(mask))
then
2767 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
2769 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2770 select case(flagmissing)
2772 mask = .not. (
data == fillvalue)
2774 mask =
data >= minvalue
2776 mask =
data <= maxvalue
2778 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2782 end subroutine getdata_5d_i2
2784 subroutine setdata_5d_i2(self, values, start, cnt, stride, map)
2785 class(NcVariable),
intent(in) :: self
2786 integer(i2),
intent(in) :: values(:,:,:,:,:)
2787 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2788 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2789 "Failed to write data into variable: " // trim(self%getName()))
2791 end subroutine setdata_5d_i2
2793 subroutine getdata_6d_i2(self, data, start, cnt, stride, map, mask)
2794 class(NcVariable),
intent(in) :: self
2795 integer(i2),
intent(out),
allocatable :: data(:,:,:,:,:,:)
2796 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2797 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
2799 integer(i4) :: flagMissing
2800 integer(i2) :: fillValue, minValue, maxValue
2801 integer(i4),
allocatable :: slcshape(:), datashape(:)
2803 slcshape = self%getSlicingShape(start, cnt, stride)
2804 datashape = getreadshape(slcshape,
size(shape(data)))
2805 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2806 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2807 "Could not read data from variable: " // trim(self%getName()))
2808 if (
present(mask))
then
2809 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
2811 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2812 select case(flagmissing)
2814 mask = .not. (
data == fillvalue)
2816 mask =
data >= minvalue
2818 mask =
data <= maxvalue
2820 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2824 end subroutine getdata_6d_i2
2826 subroutine setdata_6d_i2(self, values, start, cnt, stride, map)
2827 class(NcVariable),
intent(in) :: self
2828 integer(i2),
intent(in) :: values(:,:,:,:,:,:)
2829 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2830 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2831 "Failed to write data into variable: " // trim(self%getName()))
2833 end subroutine setdata_6d_i2
2835 subroutine getvariablefillvalue_i2(self, fvalue)
2836 class(NcVariable),
intent(in) :: self
2837 integer(i2),
intent(out) :: fvalue
2842 fvalue = nf90_fill_short
2845 end subroutine getvariablefillvalue_i2
2847 subroutine getcfattributes_i2(self, minValue, maxValue, fillValue, flagMissing)
2848 class(NcVariable),
intent(in) :: self
2849 integer(i2),
intent(out) :: minValue, maxValue, fillValue
2850 integer(i4),
intent(out) :: flagMissing
2852 integer(i2) :: valid_range(2)
2855 call self%getFillValue(fillvalue)
2859 minvalue = valid_range(1)
2860 maxvalue = valid_range(2)
2869 end subroutine getcfattributes_i2
2871 subroutine setvariablefillvalue_i2(self, fvalue)
2872 class(NcVariable),
intent(inout) :: self
2873 integer(i2),
intent(in) :: fvalue
2879 end subroutine setvariablefillvalue_i2
2881 subroutine getdata_0d_i4(self, data, start, cnt, stride, map, mask)
2882 class(NcVariable),
intent(in) :: self
2883 integer(i4),
intent(out),
allocatable :: data
2884 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2885 logical,
intent(out),
allocatable,
optional :: mask
2887 integer(i4) :: flagMissing
2888 integer(i4) :: fillValue, minValue, maxValue
2889 integer(i4) :: tmp(1)
2891 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
2892 "Could not read data from variable: " // trim(self%getName()))
2894 if (
present(mask))
then
2896 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2897 select case(flagmissing)
2899 mask = .not. (
data == fillvalue)
2901 mask =
data >= minvalue
2903 mask =
data <= maxvalue
2905 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2909 end subroutine getdata_0d_i4
2911 subroutine setdata_0d_i4(self, values, start, cnt, stride, map)
2912 class(NcVariable),
intent(in) :: self
2913 integer(i4),
intent(in) :: values
2914 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2915 call check(nf90_put_var(self%parent%id, self%id, values, start), &
2916 "Failed to write data into variable: " // trim(self%getName()))
2918 end subroutine setdata_0d_i4
2920 subroutine getdata_1d_i4(self, data, start, cnt, stride, map, mask)
2921 class(NcVariable),
intent(in) :: self
2922 integer(i4),
intent(out),
allocatable :: data(:)
2923 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2924 logical,
intent(out),
allocatable,
optional :: mask(:)
2926 integer(i4) :: flagMissing
2927 integer(i4) :: fillValue, minValue, maxValue
2928 integer(i4),
allocatable :: slcshape(:), datashape(:)
2930 slcshape = self%getSlicingShape(start, cnt, stride)
2931 datashape = getreadshape(slcshape,
size(shape(data)))
2932 allocate(
data(datashape(1)))
2933 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2934 "Could not read data from variable: " // trim(self%getName()))
2935 if (
present(mask))
then
2936 allocate(mask(datashape(1)))
2938 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2939 select case(flagmissing)
2941 mask = .not. (
data == fillvalue)
2943 mask =
data >= minvalue
2945 mask =
data <= maxvalue
2947 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2951 end subroutine getdata_1d_i4
2953 subroutine setdata_1d_i4(self, values, start, cnt, stride, map)
2954 class(NcVariable),
intent(in) :: self
2955 integer(i4),
intent(in) :: values(:)
2956 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2957 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
2958 "Failed to write data into variable: " // trim(self%getName()))
2960 end subroutine setdata_1d_i4
2962 subroutine getdata_2d_i4(self, data, start, cnt, stride, map, mask)
2963 class(NcVariable),
intent(in) :: self
2964 integer(i4),
intent(out),
allocatable :: data(:,:)
2965 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2966 logical,
intent(out),
allocatable,
optional :: mask(:,:)
2968 integer(i4) :: flagMissing
2969 integer(i4) :: fillValue, minValue, maxValue
2970 integer(i4),
allocatable :: slcshape(:), datashape(:)
2972 slcshape = self%getSlicingShape(start, cnt, stride)
2973 datashape = getreadshape(slcshape,
size(shape(data)))
2974 allocate(
data(datashape(1), datashape(2)))
2975 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
2976 "Could not read data from variable: " // trim(self%getName()))
2977 if (
present(mask))
then
2978 allocate(mask(datashape(1), datashape(2)))
2980 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
2981 select case(flagmissing)
2983 mask = .not. (
data == fillvalue)
2985 mask =
data >= minvalue
2987 mask =
data <= maxvalue
2989 mask = (
data <= maxvalue) .and. (
data >= minvalue)
2993 end subroutine getdata_2d_i4
2995 subroutine setdata_2d_i4(self, values, start, cnt, stride, map)
2996 class(NcVariable),
intent(in) :: self
2997 integer(i4),
intent(in) :: values(:,:)
2998 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
2999 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3000 "Failed to write data into variable: " // trim(self%getName()))
3002 end subroutine setdata_2d_i4
3004 subroutine getdata_3d_i4(self, data, start, cnt, stride, map, mask)
3005 class(NcVariable),
intent(in) :: self
3006 integer(i4),
intent(out),
allocatable :: data(:,:,:)
3007 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3008 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
3010 integer(i4) :: flagMissing
3011 integer(i4) :: fillValue, minValue, maxValue
3012 integer(i4),
allocatable :: slcshape(:), datashape(:)
3014 slcshape = self%getSlicingShape(start, cnt, stride)
3015 datashape = getreadshape(slcshape,
size(shape(data)))
3016 allocate(
data(datashape(1), datashape(2), datashape(3)))
3017 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3018 "Could not read data from variable: " // trim(self%getName()))
3019 if (
present(mask))
then
3020 allocate(mask(datashape(1), datashape(2), datashape(3)))
3022 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3023 select case(flagmissing)
3025 mask = .not. (
data == fillvalue)
3027 mask =
data >= minvalue
3029 mask =
data <= maxvalue
3031 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3035 end subroutine getdata_3d_i4
3037 subroutine setdata_3d_i4(self, values, start, cnt, stride, map)
3038 class(NcVariable),
intent(in) :: self
3039 integer(i4),
intent(in) :: values(:,:,:)
3040 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3041 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3042 "Failed to write data into variable: " // trim(self%getName()))
3044 end subroutine setdata_3d_i4
3046 subroutine getdata_4d_i4(self, data, start, cnt, stride, map, mask)
3047 class(NcVariable),
intent(in) :: self
3048 integer(i4),
intent(out),
allocatable :: data(:,:,:,:)
3049 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3050 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
3052 integer(i4) :: flagMissing
3053 integer(i4) :: fillValue, minValue, maxValue
3054 integer(i4),
allocatable :: slcshape(:), datashape(:)
3056 slcshape = self%getSlicingShape(start, cnt, stride)
3057 datashape = getreadshape(slcshape,
size(shape(data)))
3058 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
3059 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3060 "Could not read data from variable: " // trim(self%getName()))
3061 if (
present(mask))
then
3062 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
3064 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3065 select case(flagmissing)
3067 mask = .not. (
data == fillvalue)
3069 mask =
data >= minvalue
3071 mask =
data <= maxvalue
3073 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3077 end subroutine getdata_4d_i4
3079 subroutine setdata_4d_i4(self, values, start, cnt, stride, map)
3080 class(NcVariable),
intent(in) :: self
3081 integer(i4),
intent(in) :: values(:,:,:,:)
3082 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3083 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3084 "Failed to write data into variable: " // trim(self%getName()))
3086 end subroutine setdata_4d_i4
3088 subroutine getdata_5d_i4(self, data, start, cnt, stride, map, mask)
3089 class(NcVariable),
intent(in) :: self
3090 integer(i4),
intent(out),
allocatable :: data(:,:,:,:,:)
3091 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3092 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
3094 integer(i4) :: flagMissing
3095 integer(i4) :: fillValue, minValue, maxValue
3096 integer(i4),
allocatable :: slcshape(:), datashape(:)
3098 slcshape = self%getSlicingShape(start, cnt, stride)
3099 datashape = getreadshape(slcshape,
size(shape(data)))
3100 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
3101 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3102 "Could not read data from variable: " // trim(self%getName()))
3103 if (
present(mask))
then
3104 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
3106 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3107 select case(flagmissing)
3109 mask = .not. (
data == fillvalue)
3111 mask =
data >= minvalue
3113 mask =
data <= maxvalue
3115 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3119 end subroutine getdata_5d_i4
3121 subroutine setdata_5d_i4(self, values, start, cnt, stride, map)
3122 class(NcVariable),
intent(in) :: self
3123 integer(i4),
intent(in) :: values(:,:,:,:,:)
3124 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3125 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3126 "Failed to write data into variable: " // trim(self%getName()))
3128 end subroutine setdata_5d_i4
3130 subroutine getdata_6d_i4(self, data, start, cnt, stride, map, mask)
3131 class(NcVariable),
intent(in) :: self
3132 integer(i4),
intent(out),
allocatable :: data(:,:,:,:,:,:)
3133 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3134 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
3136 integer(i4) :: flagMissing
3137 integer(i4) :: fillValue, minValue, maxValue
3138 integer(i4),
allocatable :: slcshape(:), datashape(:)
3140 slcshape = self%getSlicingShape(start, cnt, stride)
3141 datashape = getreadshape(slcshape,
size(shape(data)))
3142 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
3143 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3144 "Could not read data from variable: " // trim(self%getName()))
3145 if (
present(mask))
then
3146 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
3148 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3149 select case(flagmissing)
3151 mask = .not. (
data == fillvalue)
3153 mask =
data >= minvalue
3155 mask =
data <= maxvalue
3157 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3161 end subroutine getdata_6d_i4
3163 subroutine setdata_6d_i4(self, values, start, cnt, stride, map)
3164 class(NcVariable),
intent(in) :: self
3165 integer(i4),
intent(in) :: values(:,:,:,:,:,:)
3166 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3167 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3168 "Failed to write data into variable: " // trim(self%getName()))
3170 end subroutine setdata_6d_i4
3172 subroutine getvariablefillvalue_i4(self, fvalue)
3173 class(NcVariable),
intent(in) :: self
3174 integer(i4),
intent(out) :: fvalue
3179 fvalue = nf90_fill_int
3182 end subroutine getvariablefillvalue_i4
3184 subroutine getcfattributes_i4(self, minValue, maxValue, fillValue, flagMissing)
3185 class(NcVariable),
intent(in) :: self
3186 integer(i4),
intent(out) :: minValue, maxValue, fillValue
3187 integer(i4),
intent(out) :: flagMissing
3189 integer(i4) :: valid_range(2)
3192 call self%getFillValue(fillvalue)
3196 minvalue = valid_range(1)
3197 maxvalue = valid_range(2)
3206 end subroutine getcfattributes_i4
3208 subroutine setvariablefillvalue_i4(self, fvalue)
3209 class(NcVariable),
intent(inout) :: self
3210 integer(i4),
intent(in) :: fvalue
3216 end subroutine setvariablefillvalue_i4
3218 subroutine getdata_0d_i8(self, data, start, cnt, stride, map, mask)
3219 class(NcVariable),
intent(in) :: self
3220 integer(i8),
intent(out),
allocatable :: data
3221 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3222 logical,
intent(out),
allocatable,
optional :: mask
3224 integer(i4) :: flagMissing
3225 integer(i8) :: fillValue, minValue, maxValue
3226 integer(i8) :: tmp(1)
3228 call check (nf90_get_var(self%parent%id, self%id, tmp, start, cnt, stride, map), &
3229 "Could not read data from variable: " // trim(self%getName()))
3231 if (
present(mask))
then
3233 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3234 select case(flagmissing)
3236 mask = .not. (
data == fillvalue)
3238 mask =
data >= minvalue
3240 mask =
data <= maxvalue
3242 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3246 end subroutine getdata_0d_i8
3248 subroutine setdata_0d_i8(self, values, start, cnt, stride, map)
3249 class(NcVariable),
intent(in) :: self
3250 integer(i8),
intent(in) :: values
3251 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3252 call check(nf90_put_var(self%parent%id, self%id, values, start), &
3253 "Failed to write data into variable: " // trim(self%getName()))
3255 end subroutine setdata_0d_i8
3257 subroutine getdata_1d_i8(self, data, start, cnt, stride, map, mask)
3258 class(NcVariable),
intent(in) :: self
3259 integer(i8),
intent(out),
allocatable :: data(:)
3260 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3261 logical,
intent(out),
allocatable,
optional :: mask(:)
3263 integer(i4) :: flagMissing
3264 integer(i8) :: fillValue, minValue, maxValue
3265 integer(i4),
allocatable :: slcshape(:), datashape(:)
3267 slcshape = self%getSlicingShape(start, cnt, stride)
3268 datashape = getreadshape(slcshape,
size(shape(data)))
3269 allocate(
data(datashape(1)))
3270 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3271 "Could not read data from variable: " // trim(self%getName()))
3272 if (
present(mask))
then
3273 allocate(mask(datashape(1)))
3275 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3276 select case(flagmissing)
3278 mask = .not. (
data == fillvalue)
3280 mask =
data >= minvalue
3282 mask =
data <= maxvalue
3284 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3288 end subroutine getdata_1d_i8
3290 subroutine setdata_1d_i8(self, values, start, cnt, stride, map)
3291 class(NcVariable),
intent(in) :: self
3292 integer(i8),
intent(in) :: values(:)
3293 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3294 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3295 "Failed to write data into variable: " // trim(self%getName()))
3297 end subroutine setdata_1d_i8
3299 subroutine getdata_2d_i8(self, data, start, cnt, stride, map, mask)
3300 class(NcVariable),
intent(in) :: self
3301 integer(i8),
intent(out),
allocatable :: data(:,:)
3302 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3303 logical,
intent(out),
allocatable,
optional :: mask(:,:)
3305 integer(i4) :: flagMissing
3306 integer(i8) :: fillValue, minValue, maxValue
3307 integer(i4),
allocatable :: slcshape(:), datashape(:)
3309 slcshape = self%getSlicingShape(start, cnt, stride)
3310 datashape = getreadshape(slcshape,
size(shape(data)))
3311 allocate(
data(datashape(1), datashape(2)))
3312 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3313 "Could not read data from variable: " // trim(self%getName()))
3314 if (
present(mask))
then
3315 allocate(mask(datashape(1), datashape(2)))
3317 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3318 select case(flagmissing)
3320 mask = .not. (
data == fillvalue)
3322 mask =
data >= minvalue
3324 mask =
data <= maxvalue
3326 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3330 end subroutine getdata_2d_i8
3332 subroutine setdata_2d_i8(self, values, start, cnt, stride, map)
3333 class(NcVariable),
intent(in) :: self
3334 integer(i8),
intent(in) :: values(:,:)
3335 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3336 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3337 "Failed to write data into variable: " // trim(self%getName()))
3339 end subroutine setdata_2d_i8
3341 subroutine getdata_3d_i8(self, data, start, cnt, stride, map, mask)
3342 class(NcVariable),
intent(in) :: self
3343 integer(i8),
intent(out),
allocatable :: data(:,:,:)
3344 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3345 logical,
intent(out),
allocatable,
optional :: mask(:,:,:)
3347 integer(i4) :: flagMissing
3348 integer(i8) :: fillValue, minValue, maxValue
3349 integer(i4),
allocatable :: slcshape(:), datashape(:)
3351 slcshape = self%getSlicingShape(start, cnt, stride)
3352 datashape = getreadshape(slcshape,
size(shape(data)))
3353 allocate(
data(datashape(1), datashape(2), datashape(3)))
3354 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3355 "Could not read data from variable: " // trim(self%getName()))
3356 if (
present(mask))
then
3357 allocate(mask(datashape(1), datashape(2), datashape(3)))
3359 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3360 select case(flagmissing)
3362 mask = .not. (
data == fillvalue)
3364 mask =
data >= minvalue
3366 mask =
data <= maxvalue
3368 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3372 end subroutine getdata_3d_i8
3374 subroutine setdata_3d_i8(self, values, start, cnt, stride, map)
3375 class(NcVariable),
intent(in) :: self
3376 integer(i8),
intent(in) :: values(:,:,:)
3377 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3378 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3379 "Failed to write data into variable: " // trim(self%getName()))
3381 end subroutine setdata_3d_i8
3383 subroutine getdata_4d_i8(self, data, start, cnt, stride, map, mask)
3384 class(NcVariable),
intent(in) :: self
3385 integer(i8),
intent(out),
allocatable :: data(:,:,:,:)
3386 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3387 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:)
3389 integer(i4) :: flagMissing
3390 integer(i8) :: fillValue, minValue, maxValue
3391 integer(i4),
allocatable :: slcshape(:), datashape(:)
3393 slcshape = self%getSlicingShape(start, cnt, stride)
3394 datashape = getreadshape(slcshape,
size(shape(data)))
3395 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4)))
3396 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3397 "Could not read data from variable: " // trim(self%getName()))
3398 if (
present(mask))
then
3399 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4)))
3401 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3402 select case(flagmissing)
3404 mask = .not. (
data == fillvalue)
3406 mask =
data >= minvalue
3408 mask =
data <= maxvalue
3410 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3414 end subroutine getdata_4d_i8
3416 subroutine setdata_4d_i8(self, values, start, cnt, stride, map)
3417 class(NcVariable),
intent(in) :: self
3418 integer(i8),
intent(in) :: values(:,:,:,:)
3419 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3420 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3421 "Failed to write data into variable: " // trim(self%getName()))
3423 end subroutine setdata_4d_i8
3425 subroutine getdata_5d_i8(self, data, start, cnt, stride, map, mask)
3426 class(NcVariable),
intent(in) :: self
3427 integer(i8),
intent(out),
allocatable :: data(:,:,:,:,:)
3428 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3429 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:)
3431 integer(i4) :: flagMissing
3432 integer(i8) :: fillValue, minValue, maxValue
3433 integer(i4),
allocatable :: slcshape(:), datashape(:)
3435 slcshape = self%getSlicingShape(start, cnt, stride)
3436 datashape = getreadshape(slcshape,
size(shape(data)))
3437 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
3438 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3439 "Could not read data from variable: " // trim(self%getName()))
3440 if (
present(mask))
then
3441 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5)))
3443 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3444 select case(flagmissing)
3446 mask = .not. (
data == fillvalue)
3448 mask =
data >= minvalue
3450 mask =
data <= maxvalue
3452 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3456 end subroutine getdata_5d_i8
3458 subroutine setdata_5d_i8(self, values, start, cnt, stride, map)
3459 class(NcVariable),
intent(in) :: self
3460 integer(i8),
intent(in) :: values(:,:,:,:,:)
3461 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3462 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3463 "Failed to write data into variable: " // trim(self%getName()))
3465 end subroutine setdata_5d_i8
3467 subroutine getdata_6d_i8(self, data, start, cnt, stride, map, mask)
3468 class(NcVariable),
intent(in) :: self
3469 integer(i8),
intent(out),
allocatable :: data(:,:,:,:,:,:)
3470 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3471 logical,
intent(out),
allocatable,
optional :: mask(:,:,:,:,:,:)
3473 integer(i4) :: flagMissing
3474 integer(i8) :: fillValue, minValue, maxValue
3475 integer(i4),
allocatable :: slcshape(:), datashape(:)
3477 slcshape = self%getSlicingShape(start, cnt, stride)
3478 datashape = getreadshape(slcshape,
size(shape(data)))
3479 allocate(
data(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
3480 call check (nf90_get_var(self%parent%id, self%id,
data, start, cnt, stride, map), &
3481 "Could not read data from variable: " // trim(self%getName()))
3482 if (
present(mask))
then
3483 allocate(mask(datashape(1), datashape(2), datashape(3), datashape(4), datashape(5), datashape(6)))
3485 call self%getCFAttributes(minvalue, maxvalue, fillvalue, flagmissing)
3486 select case(flagmissing)
3488 mask = .not. (
data == fillvalue)
3490 mask =
data >= minvalue
3492 mask =
data <= maxvalue
3494 mask = (
data <= maxvalue) .and. (
data >= minvalue)
3498 end subroutine getdata_6d_i8
3500 subroutine setdata_6d_i8(self, values, start, cnt, stride, map)
3501 class(NcVariable),
intent(in) :: self
3502 integer(i8),
intent(in) :: values(:,:,:,:,:,:)
3503 integer(i4),
intent(in),
optional :: start(:), cnt(:), stride(:), map(:)
3504 call check(nf90_put_var(self%parent%id, self%id, values, start, cnt, stride, map), &
3505 "Failed to write data into variable: " // trim(self%getName()))
3507 end subroutine setdata_6d_i8
3509 subroutine getvariablefillvalue_i8(self, fvalue)
3510 class(NcVariable),
intent(in) :: self
3511 integer(i8),
intent(out) :: fvalue
3516 fvalue = nf90_fill_int
3519 end subroutine getvariablefillvalue_i8
3521 subroutine getcfattributes_i8(self, minValue, maxValue, fillValue, flagMissing)
3522 class(NcVariable),
intent(in) :: self
3523 integer(i8),
intent(out) :: minValue, maxValue, fillValue
3524 integer(i4),
intent(out) :: flagMissing
3526 integer(i8) :: valid_range(2)
3529 call self%getFillValue(fillvalue)
3533 minvalue = valid_range(1)
3534 maxvalue = valid_range(2)
3543 end subroutine getcfattributes_i8
3545 subroutine setvariablefillvalue_i8(self, fvalue)
3546 class(NcVariable),
intent(inout) :: self
3547 integer(i8),
intent(in) :: fvalue
3553 end subroutine setvariablefillvalue_i8
3556 function getslicingshape(self, instart, incnt, instride)
result(out)
3557 class(NcVariable),
intent(in) :: self
3558 integer(i4),
intent(in),
optional :: instart(:), incnt(:), instride(:)
3559 integer(i4),
allocatable :: out(:)
3561 out = self%getShape()
3563 if (
present(incnt))
then
3564 out(:
size(incnt)) = incnt
3567 if (
present(instart))
then
3568 out(:
size(instart)) = out(:
size(instart)) - (instart - 1)
3570 if (
present(instride))
then
3571 out(:
size(instride)) = out(:
size(instride)) / instride
3575 end function getslicingshape
3577 function getreadshape(slcshape, outrank)
result(out)
3578 integer(i4),
intent(in) :: slcshape(:)
3579 integer(i4),
intent(in) :: outrank
3580 integer(i4) :: naxis
3581 integer(i4),
allocatable :: out(:)
3583 naxis = count(slcshape > 1)
3585 if (all(slcshape == 1))
then
3587 allocate(out(
size(slcshape)))
3589 else if (
size(slcshape) == outrank)
then
3592 else if (naxis == outrank)
then
3593 out = pack(slcshape, slcshape > 1)
3597 write(*, *)
"Given indices do not match output variable rank!"
3600 end function getreadshape
3602 function getdtypefromstring(dtype)
3603 integer(i4) :: getDtypeFromString
3604 character(*) :: dtype
3608 getdtypefromstring = nf90_float
3610 getdtypefromstring = nf90_double
3612 getdtypefromstring = nf90_byte
3614 getdtypefromstring = nf90_short
3616 getdtypefromstring = nf90_int
3618 getdtypefromstring = nf90_int64
3620 getdtypefromstring = nf90_char
3622 write(*,*)
"Datatype not understood: ", dtype
3625 end function getdtypefromstring
3627 function getdtypefrominteger(dtype)
3628 character(4) :: getDtypeFromInteger
3629 integer(i4) :: dtype
3633 getdtypefrominteger =
"f32"
3635 getdtypefrominteger =
"f64"
3637 getdtypefrominteger =
"i8"
3639 getdtypefrominteger =
"i16"
3641 getdtypefrominteger =
"i32"
3643 getdtypefrominteger =
"i64"
3645 getdtypefrominteger =
"char"
3647 write(*,*)
"Datatype not understood: ", dtype
3650 end function getdtypefrominteger
3652 function getcreationmode(cmode)
3653 character(*),
intent(in),
optional :: cmode
3654 integer(i4) :: getCreationMode
3655 character(256) :: mode
3657 if (.not. (
present(cmode)))
then
3663 select case(trim(mode))
3665 getcreationmode = nf90_netcdf4
3667 getcreationmode = nf90_share
3669 getcreationmode = nf90_classic_model
3671 getcreationmode = nf90_hdf5
3672 case (
"64BIT_OFFSET")
3673 getcreationmode = nf90_64bit_offset
3675 print*,
"Creation mode not understood: " // trim(mode)
3679 end function getcreationmode
3681 subroutine check(status, msg)
3682 integer(i4),
intent(in) :: status
3683 character(*),
intent(in) :: msg
3685 if (status /= nf90_noerr)
then
3687 write(*, *) nf90_strerror(status)
3690 end subroutine check
get name abstract interface
get parent abstract interface
Comparison of real values for inequality.
Define number representations.
integer, parameter sp
Single Precision Real Kind.
integer, parameter i4
4 Byte Integer Kind
integer, parameter i8
8 Byte Integer Kind
integer, parameter i2
2 Byte Integer Kind
integer, parameter i1
1 Byte Integer Kind
integer, parameter dp
Double Precision Real Kind.
NetCDF Fortran 90 interface wrapper.
integer(i4), parameter cf_use_valid_max
CF use valid max.
character(9), parameter cf_valid_min
CF valid min.
integer(i4), parameter cf_use_valid_range
CF use valid range.
integer(i4), parameter cf_use_nan
CF use nan.
character(10), parameter cf_fill_value
CF fill value.
character(11), parameter cf_valid_range
CF valid range.
character(9), parameter cf_valid_max
CF valid max.
integer(i4), parameter cf_use_fill_value
CF use fill value.
integer(i4), parameter cf_use_valid_min
CF use valid min.
General utilities for the CHS library.
NetCDF attributable class.