8 use netcdf,
only: nf90_inquire_variable, nf90_max_name
52 integer(i_long),
intent(in) :: file_ncid
53 integer(i_long),
intent(in) :: file_index
54 integer(i_long),
intent(in) :: num_vars
56 integer(i_long) :: i, j
58 character(len=NF90_MAX_NAME) :: var_name
61 allocate(
ncdr_files(file_index)%vars(num_vars))
68 ndims =
ncdr_files(file_index)%vars(i)%var_ndims, &
69 xtype =
ncdr_files(file_index)%vars(i)%var_type))
71 ncdr_files(file_index)%vars(i)%var_name = trim(var_name)
73 allocate(
ncdr_files(file_index)%vars(i)%var_dim_inds( &
77 dimids =
ncdr_files(file_index)%vars(i)%var_dim_inds))
84 allocate(
ncdr_files(file_index)%vars(i)%var_dim_sizes( &
87 do j = 1,
ncdr_files(file_index)%vars(i)%var_ndims
88 ncdr_files(file_index)%vars(i)%var_dim_sizes(j) = &
90 ncdr_files(file_index)%vars(i)%var_dim_inds(j) &
97 integer(i_long),
intent(in) :: file_ncdr_id
98 character(len=*),
intent(in) :: var_name
100 integer(i_long) :: var_index
104 do var_index = 1,
ncdr_files(file_ncdr_id)%nvars
105 if (
ncdr_files(file_ncdr_id)%vars(var_index)%var_name == var_name) &
114 character(len=*),
intent(in) :: var_name
116 integer(i_long) :: var_index
124 integer(i_long),
intent(in) :: file_ncdr_id
125 character(len=*),
intent(in) :: var_name
127 logical :: var_exists
140 character(len=*),
intent(in) :: var_name
142 logical :: var_exists
155 integer(i_long),
intent(in) :: file_ncdr_id
156 character(len=*),
intent(in) :: var_name
158 integer(i_long) :: var_index, var_ndims
164 var_ndims =
ncdr_files(file_ncdr_id)%vars(var_index)%var_ndims
168 character(len=*),
intent(in) :: var_name
170 integer(i_long) :: var_ndims
178 integer(i_long),
intent(in) :: file_ncdr_id
179 character(len=*),
intent(in) :: var_name
181 integer(i_long) :: var_index,
var_type 191 character(len=*),
intent(in) :: var_name
201 integer(i_long),
intent(in) :: file_ncdr_id
202 character(len=*),
intent(in) :: var_name
204 integer(i_long) :: var_index, var_ndims, i
205 integer(i_long),
dimension(:),
allocatable :: var_dims
213 allocate(var_dims(var_ndims))
218 ncdr_files(file_ncdr_id)%vars(var_index)%var_dim_inds(i) &
224 character(len=*),
intent(in) :: var_name
225 integer(i_long),
dimension(:),
allocatable :: var_dims
227 integer(i_long) :: var_ndims
233 allocate(var_dims(var_ndims))
239 integer(i_long),
intent(in) :: file_ncdr_id
240 character(len=*),
intent(in) :: var_name
241 integer(i_long),
intent(inout),
optional :: var_ndims
242 integer(i_long),
intent(inout),
dimension(:),
allocatable,
optional :: var_dims
244 integer(i_long) :: var_index, v_ndims, i
252 if (
present(var_ndims)) &
255 if (
present(var_dims))
then 256 if (.NOT.
allocated(var_dims))
then 257 allocate(var_dims(v_ndims))
259 if (
size(var_dims) /= v_ndims) &
260 call ncdr_error(
"Invalid allocated array size for variable dimensions size storage!")
266 ncdr_files(file_ncdr_id)%vars(var_index)%var_dim_inds(i) &
273 character(len=*),
intent(in) :: var_name
274 integer(i_long),
intent(inout),
optional :: var_ndims
275 integer(i_long),
intent(inout),
dimension(:),
allocatable,
optional :: var_dims
279 if (
present(var_ndims))
then 280 if (
present(var_dims))
then 286 if (
present(var_dims))
then 296 integer(i_long),
intent(in) :: file_ncdr_id
297 integer(i_long),
intent(out),
optional :: num_vars
298 integer(i_long),
intent(out),
optional :: var_name_mlen
299 character(len=:),
intent(inout),
dimension(:),
allocatable,
optional:: var_names
301 integer(i_long) :: var_index, nvars, max_var_name_len
309 if (
present(num_vars)) &
313 do var_index = 1, nvars
314 if (len(
ncdr_files(file_ncdr_id)%vars(var_index)%var_name) > max_var_name_len) &
315 max_var_name_len = len(
ncdr_files(file_ncdr_id)%vars(var_index)%var_name)
318 if (
present(var_name_mlen)) &
319 var_name_mlen = max_var_name_len
321 if (
present(var_names))
then 322 if (.NOT.
allocated(var_names))
then 323 allocate(
character(max_var_name_len) :: var_names(nvars))
325 if (
size(var_names) /= nvars) &
326 call ncdr_error(
"Invalid allocated array size for variable names storage!")
327 if (len(var_names) < max_var_name_len) &
328 call ncdr_error(
"Invalid allocated array size for variable names storage! (String length does not match!)")
331 do var_index = 1, nvars
332 var_names(var_index) =
ncdr_files(file_ncdr_id)%vars(var_index)%var_name
338 integer(i_long),
intent(out),
optional :: num_vars
339 integer(i_long),
intent(out),
optional :: var_name_mlen
340 character(len=:),
intent(inout),
dimension(:),
allocatable,
optional:: var_names
344 if (
present(num_vars))
then 345 if (
present(var_name_mlen))
then 346 if (
present(var_names))
then 352 if (
present(var_names))
then 359 if (
present(var_name_mlen))
then 360 if (
present(var_names))
then 362 var_names = var_names)
367 if (
present(var_names))
then subroutine nc_diag_read_noid_get_var_dims(var_name, var_ndims, var_dims)
integer(i_long) function, dimension(:), allocatable nc_diag_read_id_ret_var_dims(file_ncdr_id, var_name)
integer(i_long) function nc_diag_read_id_get_var_type(file_ncdr_id, var_name)
logical function nc_diag_read_noid_check_var(var_name)
integer(i_long) function nc_diag_read_noid_get_var_type(var_name)
subroutine nc_diag_read_id_get_var_dims(file_ncdr_id, var_name, var_ndims, var_dims)
integer, parameter, public i_long
subroutine nc_diag_read_parse_file_vars(file_ncid, file_index, num_vars)
subroutine ncdr_nc_check(status)
integer(i_long) current_ncdr_id
type(ncdr_file), dimension(:), allocatable ncdr_files
subroutine ncdr_check_current_ncdr_id
integer(i_long) function, dimension(:), allocatable nc_diag_read_noid_ret_var_dims(var_name)
integer(i_long) function nc_diag_read_id_lookup_var(file_ncdr_id, var_name)
integer(i_long) function nc_diag_read_noid_get_var_ndims(var_name)
integer(i_long) function nc_diag_read_noid_lookup_var(var_name)
integer(i_long) function nc_diag_read_id_assert_var(file_ncdr_id, var_name)
logical function nc_diag_read_id_check_var(file_ncdr_id, var_name)
subroutine ncdr_check_ncdr_id(file_ncdr_id)
subroutine ncdr_error(err)
integer(i_long) function nc_diag_read_id_get_var_ndims(file_ncdr_id, var_name)
subroutine nc_diag_read_id_get_var_names(file_ncdr_id, num_vars, var_name_mlen, var_names)