12 use netcdf,
only: nf90_inquire_attribute, nf90_global, nf90_byte, &
13 nf90_short, nf90_int, nf90_float, nf90_double, nf90_char, &
59 integer(i_long),
intent(in) :: file_ncdr_id
60 character(len=*),
intent(in) :: var_name
62 integer(i_long) :: var_index
66 do var_index = 1,
ncdr_files(file_ncdr_id)%nvars
67 if (
ncdr_files(file_ncdr_id)%vars(var_index)%var_name == var_name) &
72 call ncdr_error(
"The specified variable '" // var_name //
"' does not exist!")
76 character(len=*),
intent(in) :: var_name
78 integer(i_long) :: var_index
86 integer(i_long),
intent(in) :: file_ncdr_id
87 character(len=*),
intent(in) :: var_name
88 character(len=*),
intent(in) :: attr_name
89 integer(i_long),
intent(out) :: attr_type
90 integer(i_long),
intent(out) :: attr_len
92 integer(i_long) :: var_id
101 attr_name, attr_type, attr_len))
105 character(*),
intent(in) :: var_name
106 character(len=*),
intent(in) :: attr_name
107 integer(i_long),
intent(out) :: attr_type
108 integer(i_long),
intent(out) :: attr_len
116 integer(i_long),
intent(in) :: file_ncdr_id
117 character(len=*),
intent(in) :: attr_name
118 integer(i_long),
intent(out) :: attr_type
119 integer(i_long),
intent(out) :: attr_len
125 attr_name, attr_type, attr_len))
129 character(len=*),
intent(in) :: attr_name
130 integer(i_long),
intent(out) :: attr_type
131 integer(i_long),
intent(out) :: attr_len
139 integer(i_long) :: var_type
140 integer(i_long) :: correct_var_type
143 call ncdr_error(
"Mismatched type for variable! Got " // &
147 " was expected for the variable!")
151 integer(i_long) :: attr_type
152 integer(i_long) :: correct_attr_type
154 if (attr_type /= correct_attr_type) &
155 call ncdr_error(
"Mismatched type for attribute! Got " // &
159 " was expected for the attribute!")
163 integer(i_long) :: attr_type
164 integer(i_long) :: correct_attr_type
166 if (attr_type /= correct_attr_type) &
167 call ncdr_error(
"Mismatched type for global attribute! Got " // &
171 " was expected for the global attribute!")
176 character(len=:),
allocatable :: type_str
179 type_str =
"NF90_BYTE" 180 else if (
var_type == nf90_short)
then 181 type_str =
"NF90_SHORT" 183 type_str =
"NF90_INT" 184 else if (
var_type == nf90_float)
then 185 type_str =
"NF90_FLOAT" 186 else if (
var_type == nf90_double)
then 187 type_str =
"NF90_DOUBLE" 188 else if (
var_type == nf90_char)
then 189 type_str =
"NF90_CHAR" 190 else if (
var_type == nf90_string)
then 191 type_str =
"NF90_STRING (not supported)" 193 type_str =
"(unknown type)" 198 integer(i_long) :: var_ndims
199 integer(i_long) :: correct_var_ndims
201 if (var_ndims /= correct_var_ndims) &
202 call ncdr_error(
"Mismatched dimensions for variable!")
209 character(len=*),
intent(in) :: var_stor
210 integer(i_long),
dimension(:),
intent(in) :: correct_dims
211 integer(i_long),
parameter :: correct_ndims = 1
213 if (
size(correct_dims) /= correct_ndims) &
214 call ncdr_error(
"Invalid number of dimensions for variable!")
215 if (len(var_stor) < correct_dims(1)) &
216 call ncdr_error(
"Mismatched dimensions for variable storage!")
220 integer(i_byte),
intent(in) :: var_stor
221 integer(i_long),
dimension(:),
intent(in) :: correct_dims
222 integer(i_long),
parameter :: correct_ndims = 1
224 if (
size(correct_dims) /= correct_ndims) &
225 call ncdr_error(
"Invalid number of dimensions for variable!")
226 if (correct_dims(1) /= 1) &
227 call ncdr_error(
"Mismatched dimensions for variable storage!")
231 integer(i_short),
intent(in) :: var_stor
232 integer(i_long),
dimension(:),
intent(in) :: correct_dims
233 integer(i_long),
parameter :: correct_ndims = 1
235 if (
size(correct_dims) /= correct_ndims) &
236 call ncdr_error(
"Invalid number of dimensions for variable!")
237 if (correct_dims(1) /= 1) &
238 call ncdr_error(
"Mismatched dimensions for variable storage!")
242 integer(i_long),
intent(in) :: var_stor
243 integer(i_long),
dimension(:),
intent(in) :: correct_dims
244 integer(i_long),
parameter :: correct_ndims = 1
246 if (
size(correct_dims) /= correct_ndims) &
247 call ncdr_error(
"Invalid number of dimensions for variable!")
248 if (correct_dims(1) /= 1) &
249 call ncdr_error(
"Mismatched dimensions for variable storage!")
253 real(r_single) ,
intent(in) :: var_stor
254 integer(i_long),
dimension(:),
intent(in) :: correct_dims
255 integer(i_long),
parameter :: correct_ndims = 1
257 if (
size(correct_dims) /= correct_ndims) &
258 call ncdr_error(
"Invalid number of dimensions for variable!")
259 if (correct_dims(1) /= 1) &
260 call ncdr_error(
"Mismatched dimensions for variable storage!")
264 real(r_double) ,
intent(in) :: var_stor
265 integer(i_long),
dimension(:),
intent(in) :: correct_dims
266 integer(i_long),
parameter :: correct_ndims = 1
268 if (
size(correct_dims) /= correct_ndims) &
269 call ncdr_error(
"Invalid number of dimensions for variable!")
270 if (correct_dims(1) /= 1) &
271 call ncdr_error(
"Mismatched dimensions for variable storage!")
275 character(len=:),
allocatable,
intent(inout) :: var_stor
276 integer(i_long),
dimension(:),
intent(in) :: correct_dims
277 integer(i_long),
parameter :: correct_ndims = 1
281 if (
allocated(var_stor))
then 282 if (
size(correct_dims) /= correct_ndims) &
283 call ncdr_error(
"Invalid number of dimensions for variable!")
284 if (len(var_stor) /= correct_dims(1)) &
285 call ncdr_error(
"Mismatched dimensions for variable storage!")
287 allocate(
character(len=correct_dims(1)) :: var_stor)
292 integer(i_byte),
dimension(:),
allocatable,
intent(inout) :: var_stor
293 integer(i_long),
dimension(:),
intent(in) :: correct_dims
294 integer(i_long),
parameter :: correct_ndims = 1
298 if (
allocated(var_stor))
then 299 if (
size(correct_dims) /= correct_ndims) &
300 call ncdr_error(
"Invalid number of dimensions for variable!")
301 if (any(shape(var_stor) /= correct_dims)) &
302 call ncdr_error(
"Mismatched dimensions for variable storage!")
304 allocate(var_stor(correct_dims(1)))
309 integer(i_short),
dimension(:),
allocatable,
intent(inout) :: var_stor
310 integer(i_long),
dimension(:),
intent(in) :: correct_dims
311 integer(i_long),
parameter :: correct_ndims = 1
315 if (
allocated(var_stor))
then 316 if (
size(correct_dims) /= correct_ndims) &
317 call ncdr_error(
"Invalid number of dimensions for variable!")
318 if (any(shape(var_stor) /= correct_dims)) &
319 call ncdr_error(
"Mismatched dimensions for variable storage!")
321 allocate(var_stor(correct_dims(1)))
326 integer(i_long),
dimension(:),
allocatable,
intent(inout) :: var_stor
327 integer(i_long),
dimension(:),
intent(in) :: correct_dims
328 integer(i_long),
parameter :: correct_ndims = 1
332 if (
allocated(var_stor))
then 333 if (
size(correct_dims) /= correct_ndims) &
334 call ncdr_error(
"Invalid number of dimensions for variable!")
335 if (any(shape(var_stor) /= correct_dims)) &
336 call ncdr_error(
"Mismatched dimensions for variable storage!")
338 allocate(var_stor(correct_dims(1)))
343 real(r_single),
dimension(:),
allocatable,
intent(inout) :: var_stor
344 integer(i_long),
dimension(:),
intent(in) :: correct_dims
345 integer(i_long),
parameter :: correct_ndims = 1
349 if (
allocated(var_stor))
then 350 if (
size(correct_dims) /= correct_ndims) &
351 call ncdr_error(
"Invalid number of dimensions for variable!")
352 if (any(shape(var_stor) /= correct_dims)) &
353 call ncdr_error(
"Mismatched dimensions for variable storage!")
355 allocate(var_stor(correct_dims(1)))
360 real(r_double),
dimension(:),
allocatable,
intent(inout) :: var_stor
361 integer(i_long),
dimension(:),
intent(in) :: correct_dims
362 integer(i_long),
parameter :: correct_ndims = 1
366 if (
allocated(var_stor))
then 367 if (
size(correct_dims) /= correct_ndims) &
368 call ncdr_error(
"Invalid number of dimensions for variable!")
369 if (any(shape(var_stor) /= correct_dims)) &
370 call ncdr_error(
"Mismatched dimensions for variable storage!")
372 allocate(var_stor(correct_dims(1)))
377 character(len=:),
dimension(:),
allocatable,
intent(inout) :: var_stor
378 integer(i_long),
dimension(:),
intent(in) :: correct_dims
379 integer(i_long),
parameter :: correct_ndims = 2
383 if (
allocated(var_stor))
then 384 if (
size(correct_dims) /= correct_ndims) &
385 call ncdr_error(
"Invalid number of dimensions for variable!")
386 if (len(var_stor) /= correct_dims(1)) &
387 call ncdr_error(
"Mismatched dimensions for variable storage!")
388 if (
size(var_stor) /= correct_dims(2)) &
389 call ncdr_error(
"Mismatched dimensions for variable storage!")
391 allocate(
character(len=correct_dims(1)) :: var_stor(correct_dims(2)))
396 integer(i_byte),
dimension(:,:),
allocatable,
intent(inout):: var_stor
397 integer(i_long),
dimension(:),
intent(in) :: correct_dims
398 integer(i_long),
parameter :: correct_ndims = 2
402 if (
allocated(var_stor))
then 403 if (
size(correct_dims) /= correct_ndims) &
404 call ncdr_error(
"Invalid number of dimensions for variable!")
405 if (any(shape(var_stor) /= correct_dims)) &
406 call ncdr_error(
"Mismatched dimensions for variable storage!")
408 allocate(var_stor(correct_dims(1), correct_dims(2)))
413 integer(i_short),
dimension(:,:),
allocatable,
intent(inout):: var_stor
414 integer(i_long),
dimension(:),
intent(in) :: correct_dims
415 integer(i_long),
parameter :: correct_ndims = 2
419 if (
allocated(var_stor))
then 420 if (
size(correct_dims) /= correct_ndims) &
421 call ncdr_error(
"Invalid number of dimensions for variable!")
422 if (any(shape(var_stor) /= correct_dims)) &
423 call ncdr_error(
"Mismatched dimensions for variable storage!")
425 allocate(var_stor(correct_dims(1), correct_dims(2)))
430 integer(i_long),
dimension(:,:),
allocatable,
intent(inout):: var_stor
431 integer(i_long),
dimension(:),
intent(in) :: correct_dims
432 integer(i_long),
parameter :: correct_ndims = 2
436 if (
allocated(var_stor))
then 437 if (
size(correct_dims) /= correct_ndims) &
438 call ncdr_error(
"Invalid number of dimensions for variable!")
439 if (any(shape(var_stor) /= correct_dims)) &
440 call ncdr_error(
"Mismatched dimensions for variable storage!")
442 allocate(var_stor(correct_dims(1), correct_dims(2)))
447 real(r_single),
dimension(:,:),
allocatable,
intent(inout):: var_stor
448 integer(i_long),
dimension(:),
intent(in) :: correct_dims
449 integer(i_long),
parameter :: correct_ndims = 2
453 if (
allocated(var_stor))
then 454 if (
size(correct_dims) /= correct_ndims) &
455 call ncdr_error(
"Invalid number of dimensions for variable!")
456 if (any(shape(var_stor) /= correct_dims)) &
457 call ncdr_error(
"Mismatched dimensions for variable storage!")
459 allocate(var_stor(correct_dims(1), correct_dims(2)))
464 real(r_double),
dimension(:,:),
allocatable,
intent(inout):: var_stor
465 integer(i_long),
dimension(:),
intent(in) :: correct_dims
466 integer(i_long),
parameter :: correct_ndims = 2
470 if (
allocated(var_stor))
then 471 if (
size(correct_dims) /= correct_ndims) &
472 call ncdr_error(
"Invalid number of dimensions for variable!")
473 if (any(shape(var_stor) /= correct_dims)) &
474 call ncdr_error(
"Mismatched dimensions for variable storage!")
476 allocate(var_stor(correct_dims(1), correct_dims(2)))
481 character(len=:),
dimension(:,:),
allocatable,
intent(inout):: var_stor
482 integer(i_long),
dimension(:),
intent(in) :: correct_dims
483 integer(i_long),
parameter :: correct_ndims = 3
487 if (
allocated(var_stor))
then 488 if (
size(correct_dims) /= correct_ndims) &
489 call ncdr_error(
"Invalid number of dimensions for variable!")
490 if (len(var_stor) /= correct_dims(1)) &
491 call ncdr_error(
"Mismatched dimensions for variable storage!")
492 if (any(shape(var_stor) /= correct_dims(2:3))) &
493 call ncdr_error(
"Mismatched dimensions for variable storage!")
495 allocate(
character(len=correct_dims(1)) :: var_stor(correct_dims(2), correct_dims(3)))
subroutine nc_diag_read_id_assert_global_attr(file_ncdr_id, attr_name, attr_type, attr_len)
integer, parameter, public i_byte
character(len=:) function, allocatable nc_diag_read_get_type_str(var_type)
subroutine nc_diag_read_noid_assert_attr(var_name, attr_name, attr_type, attr_len)
subroutine nc_diag_read_noid_assert_global_attr(attr_name, attr_type, attr_len)
integer, parameter, public i_long
subroutine ncdr_nc_check(status)
subroutine nc_diag_read_assert_dims_single_float(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_2d_float(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_alloc_string(var_stor, correct_dims)
integer(i_long) current_ncdr_id
type(ncdr_file), dimension(:), allocatable ncdr_files
subroutine ncdr_check_current_ncdr_id
subroutine nc_diag_read_assert_dims_2d_long(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_2d_short(var_stor, correct_dims)
subroutine nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
subroutine nc_diag_read_assert_dims_2d_double(var_stor, correct_dims)
integer(i_long) function nc_diag_read_id_assert_var(file_ncdr_id, var_name)
subroutine nc_diag_read_assert_dims_1d_byte(var_stor, correct_dims)
subroutine ncdr_check_ncdr_id(file_ncdr_id)
subroutine nc_diag_read_assert_dims_single_long(var_stor, correct_dims)
subroutine nc_diag_read_assert_global_attr_type(attr_type, correct_attr_type)
subroutine nc_diag_read_assert_dims_1d_short(var_stor, correct_dims)
integer, parameter, public i_short
subroutine nc_diag_read_assert_dims_single_byte(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_single_short(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_2d_string(var_stor, correct_dims)
subroutine nc_diag_read_assert_attr_type(attr_type, correct_attr_type)
subroutine ncdr_error(err)
subroutine nc_diag_read_assert_dims_1d_string(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_2d_byte(var_stor, correct_dims)
integer, parameter, public r_double
integer, parameter, public r_single
subroutine nc_diag_read_assert_dims_string(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_single_double(var_stor, correct_dims)
subroutine nc_diag_read_assert_var_type(var_type, correct_var_type)
subroutine nc_diag_read_assert_var_ndims(var_ndims, correct_var_ndims)
subroutine nc_diag_read_assert_dims_1d_long(var_stor, correct_dims)
subroutine nc_diag_read_assert_dims_1d_float(var_stor, correct_dims)
integer(i_long) function nc_diag_read_noid_assert_var(var_name)
subroutine nc_diag_read_assert_dims_1d_double(var_stor, correct_dims)