FV3 Bundle
ncdr_attrs_fetch.f90
Go to the documentation of this file.
9  use netcdf, only: nf90_get_att, nf90_byte, nf90_short, nf90_int, &
10  nf90_float, nf90_double, nf90_char
11 
12  implicit none
13 
15  ! Note that nc_diag_read_(no)id_get_attr_1d_string is not
16  ! included due to rare use + conflict with single_string.
17  module procedure &
40  end interface nc_diag_read_get_attr
41 
42  contains
43  subroutine nc_diag_read_id_get_attr_single_byte(file_ncdr_id, var_name, attr_name, attr_stor)
44  integer(i_long), intent(in) :: file_ncdr_id
45  character(len=*), intent(in) :: var_name
46  character(len=*), intent(in) :: attr_name
47  integer(i_byte), intent(out) :: attr_stor
48 
49  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
50 
51  call ncdr_check_ncdr_id(file_ncdr_id)
52 
53  file_ncid = ncdr_files(file_ncdr_id)%ncid
54  call ncdr_check_ncdr_id(file_ncdr_id)
55 
56  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
57  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
58 
59  call nc_diag_read_assert_attr_type(attr_type, nf90_byte)
60 
61  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
62 
63  call ncdr_nc_check(nf90_get_att(file_ncid, &
64  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
65  attr_name, &
66  attr_stor))
68 
69  subroutine nc_diag_read_noid_get_attr_single_byte(var_name, attr_name, attr_stor)
70  character(len=*), intent(in) :: var_name
71  character(len=*), intent(in) :: attr_name
72  integer(i_byte), intent(out) :: attr_stor
73 
75  call nc_diag_read_id_get_attr_single_byte(current_ncdr_id, var_name, attr_name, attr_stor)
77 
78  subroutine nc_diag_read_id_get_attr_single_short(file_ncdr_id, var_name, attr_name, attr_stor)
79  integer(i_long), intent(in) :: file_ncdr_id
80  character(len=*), intent(in) :: var_name
81  character(len=*), intent(in) :: attr_name
82  integer(i_short), intent(out) :: attr_stor
83 
84  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
85 
86  call ncdr_check_ncdr_id(file_ncdr_id)
87 
88  file_ncid = ncdr_files(file_ncdr_id)%ncid
89  call ncdr_check_ncid(file_ncid)
90 
91  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
92  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
93 
94  call nc_diag_read_assert_attr_type(attr_type, nf90_short)
95 
96  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
97 
98  call ncdr_nc_check(nf90_get_att(file_ncid, &
99  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
100  attr_name, &
101  attr_stor))
103 
104  subroutine nc_diag_read_noid_get_attr_single_short(var_name, attr_name, attr_stor)
105  character(len=*), intent(in) :: var_name
106  character(len=*), intent(in) :: attr_name
107  integer(i_short), intent(out) :: attr_stor
108 
110  call nc_diag_read_id_get_attr_single_short(current_ncdr_id, var_name, attr_name, attr_stor)
112 
113  subroutine nc_diag_read_id_get_attr_single_long(file_ncdr_id, var_name, attr_name, attr_stor)
114  integer(i_long), intent(in) :: file_ncdr_id
115  character(len=*), intent(in) :: var_name
116  character(len=*), intent(in) :: attr_name
117  integer(i_long), intent(out) :: attr_stor
118 
119  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
120 
121  call ncdr_check_ncdr_id(file_ncdr_id)
122 
123  file_ncid = ncdr_files(file_ncdr_id)%ncid
124  call ncdr_check_ncid(file_ncid)
125 
126  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
127  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
128 
129  call nc_diag_read_assert_attr_type(attr_type, nf90_int)
130 
131  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
132 
133  call ncdr_nc_check(nf90_get_att(file_ncid, &
134  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
135  attr_name, &
136  attr_stor))
138 
139  subroutine nc_diag_read_noid_get_attr_single_long(var_name, attr_name, attr_stor)
140  character(len=*), intent(in) :: var_name
141  character(len=*), intent(in) :: attr_name
142  integer(i_long), intent(out) :: attr_stor
143 
145  call nc_diag_read_id_get_attr_single_long(current_ncdr_id, var_name, attr_name, attr_stor)
147 
148  subroutine nc_diag_read_id_get_attr_single_float(file_ncdr_id, var_name, attr_name, attr_stor)
149  integer(i_long), intent(in) :: file_ncdr_id
150  character(len=*), intent(in) :: var_name
151  character(len=*), intent(in) :: attr_name
152  real(r_single), intent(out) :: attr_stor
153 
154  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
155 
156  call ncdr_check_ncdr_id(file_ncdr_id)
157 
158  file_ncid = ncdr_files(file_ncdr_id)%ncid
159  call ncdr_check_ncid(file_ncid)
160 
161  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
162  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
163 
164  call nc_diag_read_assert_attr_type(attr_type, nf90_float)
165 
166  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
167 
168  call ncdr_nc_check(nf90_get_att(file_ncid, &
169  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
170  attr_name, &
171  attr_stor))
173 
174  subroutine nc_diag_read_noid_get_attr_single_float(var_name, attr_name, attr_stor)
175  character(len=*), intent(in) :: var_name
176  character(len=*), intent(in) :: attr_name
177  real(r_single), intent(out) :: attr_stor
178 
180  call nc_diag_read_id_get_attr_single_float(current_ncdr_id, var_name, attr_name, attr_stor)
182 
183  subroutine nc_diag_read_id_get_attr_single_double(file_ncdr_id, var_name, attr_name, attr_stor)
184  integer(i_long), intent(in) :: file_ncdr_id
185  character(len=*), intent(in) :: var_name
186  character(len=*), intent(in) :: attr_name
187  real(r_double), intent(out) :: attr_stor
188 
189  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
190 
191  call ncdr_check_ncdr_id(file_ncdr_id)
192 
193  file_ncid = ncdr_files(file_ncdr_id)%ncid
194  call ncdr_check_ncid(file_ncid)
195 
196  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
197  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
198 
199  call nc_diag_read_assert_attr_type(attr_type, nf90_double)
200 
201  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
202 
203  call ncdr_nc_check(nf90_get_att(file_ncid, &
204  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
205  attr_name, &
206  attr_stor))
208 
209  subroutine nc_diag_read_noid_get_attr_single_double(var_name, attr_name, attr_stor)
210  character(len=*), intent(in) :: var_name
211  character(len=*), intent(in) :: attr_name
212  real(r_double), intent(out) :: attr_stor
213 
215  call nc_diag_read_id_get_attr_single_double(current_ncdr_id, var_name, attr_name, attr_stor)
217 
218  subroutine nc_diag_read_id_get_attr_single_string(file_ncdr_id, var_name, attr_name, attr_stor)
219  integer(i_long), intent(in) :: file_ncdr_id
220  character(len=*), intent(in) :: var_name
221  character(len=*), intent(in) :: attr_name
222  character(len=*), intent(out) :: attr_stor
223 
224  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
225 
226  call ncdr_check_ncdr_id(file_ncdr_id)
227 
228  file_ncid = ncdr_files(file_ncdr_id)%ncid
229  call ncdr_check_ncid(file_ncid)
230 
231  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
232  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
233 
234  call nc_diag_read_assert_attr_type(attr_type, nf90_char)
235 
236  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
237 
238  call ncdr_nc_check(nf90_get_att(file_ncid, &
239  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
240  attr_name, &
241  attr_stor))
243 
244  subroutine nc_diag_read_noid_get_attr_single_string(var_name, attr_name, attr_stor)
245  character(len=*), intent(in) :: var_name
246  character(len=*), intent(in) :: attr_name
247  character(len=*), intent(out) :: attr_stor
248 
250  call nc_diag_read_id_get_attr_single_string(current_ncdr_id, var_name, attr_name, attr_stor)
252 
253  subroutine nc_diag_read_id_get_attr_1d_byte(file_ncdr_id, var_name, attr_name, attr_stor)
254  integer(i_long), intent(in) :: file_ncdr_id
255  character(len=*), intent(in) :: var_name
256  character(len=*), intent(in) :: attr_name
257  integer(i_byte), dimension(:), allocatable, intent(inout) :: attr_stor
258 
259  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
260 
261  call ncdr_check_ncdr_id(file_ncdr_id)
262 
263  file_ncid = ncdr_files(file_ncdr_id)%ncid
264  call ncdr_check_ncdr_id(file_ncdr_id)
265 
266  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
267  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
268 
269  call nc_diag_read_assert_attr_type(attr_type, nf90_byte)
270 
271  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
272 
273  call ncdr_nc_check(nf90_get_att(file_ncid, &
274  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
275  attr_name, &
276  attr_stor))
277  end subroutine nc_diag_read_id_get_attr_1d_byte
278 
279  subroutine nc_diag_read_noid_get_attr_1d_byte(var_name, attr_name, attr_stor)
280  character(len=*), intent(in) :: var_name
281  character(len=*), intent(in) :: attr_name
282  integer(i_byte), dimension(:), allocatable, intent(inout) :: attr_stor
283 
285  call nc_diag_read_id_get_attr_1d_byte(current_ncdr_id, var_name, attr_name, attr_stor)
287 
288  subroutine nc_diag_read_id_get_attr_1d_short(file_ncdr_id, var_name, attr_name, attr_stor)
289  integer(i_long), intent(in) :: file_ncdr_id
290  character(len=*), intent(in) :: var_name
291  character(len=*), intent(in) :: attr_name
292  integer(i_short), dimension(:), allocatable, intent(inout) :: attr_stor
293 
294  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
295 
296  call ncdr_check_ncdr_id(file_ncdr_id)
297 
298  file_ncid = ncdr_files(file_ncdr_id)%ncid
299  call ncdr_check_ncid(file_ncid)
300 
301  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
302  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
303 
304  call nc_diag_read_assert_attr_type(attr_type, nf90_short)
305 
306  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
307 
308  call ncdr_nc_check(nf90_get_att(file_ncid, &
309  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
310  attr_name, &
311  attr_stor))
312  end subroutine nc_diag_read_id_get_attr_1d_short
313 
314  subroutine nc_diag_read_noid_get_attr_1d_short(var_name, attr_name, attr_stor)
315  character(len=*), intent(in) :: var_name
316  character(len=*), intent(in) :: attr_name
317  integer(i_short), dimension(:), allocatable, intent(inout) :: attr_stor
318 
320  call nc_diag_read_id_get_attr_1d_short(current_ncdr_id, var_name, attr_name, attr_stor)
322 
323  subroutine nc_diag_read_id_get_attr_1d_long(file_ncdr_id, var_name, attr_name, attr_stor)
324  integer(i_long), intent(in) :: file_ncdr_id
325  character(len=*), intent(in) :: var_name
326  character(len=*), intent(in) :: attr_name
327  integer(i_long), dimension(:), allocatable, intent(inout) :: attr_stor
328 
329  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
330 
331  call ncdr_check_ncdr_id(file_ncdr_id)
332 
333  file_ncid = ncdr_files(file_ncdr_id)%ncid
334  call ncdr_check_ncid(file_ncid)
335 
336  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
337  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
338 
339  call nc_diag_read_assert_attr_type(attr_type, nf90_int)
340 
341  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
342 
343  call ncdr_nc_check(nf90_get_att(file_ncid, &
344  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
345  attr_name, &
346  attr_stor))
347  end subroutine nc_diag_read_id_get_attr_1d_long
348 
349  subroutine nc_diag_read_noid_get_attr_1d_long(var_name, attr_name, attr_stor)
350  character(len=*), intent(in) :: var_name
351  character(len=*), intent(in) :: attr_name
352  integer(i_long), dimension(:), allocatable, intent(inout) :: attr_stor
353 
355  call nc_diag_read_id_get_attr_1d_long(current_ncdr_id, var_name, attr_name, attr_stor)
357 
358  subroutine nc_diag_read_id_get_attr_1d_float(file_ncdr_id, var_name, attr_name, attr_stor)
359  integer(i_long), intent(in) :: file_ncdr_id
360  character(len=*), intent(in) :: var_name
361  character(len=*), intent(in) :: attr_name
362  real(r_single), dimension(:), allocatable, intent(inout) :: attr_stor
363 
364  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
365 
366  call ncdr_check_ncdr_id(file_ncdr_id)
367 
368  file_ncid = ncdr_files(file_ncdr_id)%ncid
369  call ncdr_check_ncid(file_ncid)
370 
371  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
372  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
373 
374  call nc_diag_read_assert_attr_type(attr_type, nf90_float)
375 
376  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
377 
378  call ncdr_nc_check(nf90_get_att(file_ncid, &
379  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
380  attr_name, &
381  attr_stor))
382  end subroutine nc_diag_read_id_get_attr_1d_float
383 
384  subroutine nc_diag_read_noid_get_attr_1d_float(var_name, attr_name, attr_stor)
385  character(len=*), intent(in) :: var_name
386  character(len=*), intent(in) :: attr_name
387  real(r_single), dimension(:), allocatable, intent(inout) :: attr_stor
388 
390  call nc_diag_read_id_get_attr_1d_float(current_ncdr_id, var_name, attr_name, attr_stor)
392 
393  subroutine nc_diag_read_id_get_attr_1d_double(file_ncdr_id, var_name, attr_name, attr_stor)
394  integer(i_long), intent(in) :: file_ncdr_id
395  character(len=*), intent(in) :: var_name
396  character(len=*), intent(in) :: attr_name
397  real(r_double), dimension(:), allocatable, intent(inout) :: attr_stor
398 
399  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
400 
401  call ncdr_check_ncdr_id(file_ncdr_id)
402 
403  file_ncid = ncdr_files(file_ncdr_id)%ncid
404  call ncdr_check_ncid(file_ncid)
405 
406  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
407  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
408 
409  call nc_diag_read_assert_attr_type(attr_type, nf90_double)
410 
411  call nc_diag_read_assert_dims(attr_stor, (/ attr_len /))
412 
413  call ncdr_nc_check(nf90_get_att(file_ncid, &
414  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
415  attr_name, &
416  attr_stor))
418 
419  subroutine nc_diag_read_noid_get_attr_1d_double(var_name, attr_name, attr_stor)
420  character(len=*), intent(in) :: var_name
421  character(len=*), intent(in) :: attr_name
422  real(r_double), dimension(:), allocatable, intent(inout) :: attr_stor
423 
425  call nc_diag_read_id_get_attr_1d_double(current_ncdr_id, var_name, attr_name, attr_stor)
427 
428  subroutine nc_diag_read_id_get_attr_1d_string(file_ncdr_id, var_name, attr_name, attr_stor)
429  integer(i_long), intent(in) :: file_ncdr_id
430  character(len=*), intent(in) :: var_name
431  character(len=*), intent(in) :: attr_name
432  character(len=:),allocatable,intent(inout) :: attr_stor
433 
434  integer(i_long) :: var_index, attr_len, attr_type, file_ncid
435 
436  call ncdr_check_ncdr_id(file_ncdr_id)
437 
438  file_ncid = ncdr_files(file_ncdr_id)%ncid
439  call ncdr_check_ncid(file_ncid)
440 
441  var_index = nc_diag_read_id_assert_var(file_ncdr_id, var_name)
442  call nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
443 
444  call nc_diag_read_assert_attr_type(attr_type, nf90_char)
445 
446  call nc_diag_read_assert_dims_alloc_string(attr_stor, (/ attr_len /))
447 
448  call ncdr_nc_check(nf90_get_att(file_ncid, &
449  ncdr_files(file_ncdr_id)%vars(var_index)%var_id, &
450  attr_name, &
451  attr_stor))
453 
454  subroutine nc_diag_read_noid_get_attr_1d_string(var_name, attr_name, attr_stor)
455  character(len=*), intent(in) :: var_name
456  character(len=*), intent(in) :: attr_name
457  character(len=:),allocatable,intent(inout) :: attr_stor
458 
460  call nc_diag_read_id_get_attr_1d_string(current_ncdr_id, var_name, attr_name, attr_stor)
462 end module ncdr_attrs_fetch
subroutine nc_diag_read_id_get_attr_1d_string(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_single_string(file_ncdr_id, var_name, attr_name, attr_stor)
integer, parameter, public i_byte
Definition: ncd_kinds.F90:45
subroutine nc_diag_read_id_get_attr_single_float(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_1d_float(file_ncdr_id, var_name, attr_name, attr_stor)
integer, parameter, public i_long
Definition: ncd_kinds.F90:47
subroutine nc_diag_read_id_get_attr_1d_long(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_1d_double(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_single_long(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine ncdr_nc_check(status)
Definition: ncdr_check.f90:85
subroutine nc_diag_read_assert_dims_alloc_string(var_stor, correct_dims)
integer(i_long) current_ncdr_id
Definition: ncdr_state.f90:7
type(ncdr_file), dimension(:), allocatable ncdr_files
Definition: ncdr_state.f90:14
subroutine ncdr_check_current_ncdr_id
Definition: ncdr_check.f90:22
subroutine nc_diag_read_id_get_attr_single_byte(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine ncdr_check_ncid(file_ncid)
Definition: ncdr_check.f90:28
subroutine nc_diag_read_noid_get_attr_single_float(var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_single_short(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_single_string(var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_single_double(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_assert_attr(file_ncdr_id, var_name, attr_name, attr_type, attr_len)
subroutine nc_diag_read_noid_get_attr_1d_short(var_name, attr_name, attr_stor)
integer(i_long) function nc_diag_read_id_assert_var(file_ncdr_id, var_name)
subroutine nc_diag_read_noid_get_attr_single_long(var_name, attr_name, attr_stor)
subroutine ncdr_check_ncdr_id(file_ncdr_id)
Definition: ncdr_check.f90:12
subroutine nc_diag_read_id_get_attr_1d_byte(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_single_double(var_name, attr_name, attr_stor)
integer, parameter, public i_short
Definition: ncd_kinds.F90:46
subroutine nc_diag_read_noid_get_attr_1d_long(var_name, attr_name, attr_stor)
subroutine nc_diag_read_id_get_attr_1d_short(file_ncdr_id, var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_1d_float(var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_single_byte(var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_1d_double(var_name, attr_name, attr_stor)
subroutine nc_diag_read_assert_attr_type(attr_type, correct_attr_type)
integer, parameter, public r_double
Definition: ncd_kinds.F90:80
subroutine nc_diag_read_noid_get_attr_single_short(var_name, attr_name, attr_stor)
subroutine nc_diag_read_noid_get_attr_1d_string(var_name, attr_name, attr_stor)
integer, parameter, public r_single
Definition: ncd_kinds.F90:79
subroutine nc_diag_read_noid_get_attr_1d_byte(var_name, attr_name, attr_stor)