Line data Source code
1 : ! $Id: m_netcdf_io_read.F90,v 1.1 2009/08/04 14:52:05 bmy Exp $
2 : !-------------------------------------------------------------------------
3 : ! NASA/GFSC, SIVO, Code 610.3
4 : !-------------------------------------------------------------------------
5 : !BOP
6 : !
7 : ! !MODULE: HCO_m_netcdf_io_read
8 : !
9 : ! !INTERFACE:
10 : !
11 : MODULE HCO_m_netcdf_io_read
12 : !
13 : ! !USES:
14 : !
15 : IMPLICIT NONE
16 : PRIVATE
17 : !
18 : ! !PUBLIC MEMBER FUNCTIONS:
19 : !
20 : ! Public interface
21 : PUBLIC :: NcRd
22 :
23 : ! Private methods overloaded by public interface
24 : ! (see below for info about these routines & the arguments they take)
25 : INTERFACE NcRd
26 : MODULE PROCEDURE Ncrd_Scal
27 : MODULE PROCEDURE Ncrd_Scal_Int
28 : MODULE PROCEDURE Ncrd_1d_R8
29 : MODULE PROCEDURE Ncrd_1d_R4
30 : MODULE PROCEDURE Ncrd_1d_Int
31 : MODULE PROCEDURE Ncrd_1d_Char
32 : MODULE PROCEDURE Ncrd_2d_R8
33 : MODULE PROCEDURE Ncrd_2d_R4
34 : MODULE PROCEDURE Ncrd_2d_Int
35 : MODULE PROCEDURE Ncrd_2d_Char
36 : MODULE PROCEDURE Ncrd_3d_R8
37 : MODULE PROCEDURE Ncrd_3d_R4
38 : MODULE PROCEDURE Ncrd_3d_Int
39 : MODULE PROCEDURE Ncrd_4d_R8
40 : MODULE PROCEDURE Ncrd_4d_R4
41 : MODULE PROCEDURE Ncrd_4d_Int
42 : MODULE PROCEDURE Ncrd_5d_R8
43 : MODULE PROCEDURE Ncrd_5d_R4
44 : MODULE PROCEDURE Ncrd_6d_R8
45 : MODULE PROCEDURE Ncrd_6d_R4
46 : MODULE PROCEDURE Ncrd_7d_R8
47 : MODULE PROCEDURE Ncrd_7d_R4
48 : END INTERFACE
49 : !
50 : ! !DESCRIPTION: Routines for reading variables in a netCDF file.
51 : !\\
52 : !\\
53 : ! !AUTHOR:
54 : ! Jules Kouatchou
55 : !
56 : ! !REVISION HISTORY:
57 : ! See https://github.com/geoschem/ncdfutil for complete history
58 : !EOP
59 : !-------------------------------------------------------------------------
60 : !BOC
61 : CONTAINS
62 : !EOC
63 : !-------------------------------------------------------------------------
64 : !BOP
65 : !
66 : ! !IROUTINE: Ncrd_Scal
67 : !
68 : ! !INTERFACE:
69 : !
70 0 : subroutine Ncrd_Scal (varrd_scal, ncid, varname)
71 : !
72 : ! !USES:
73 : !
74 : use m_do_err_out
75 : !
76 : implicit none
77 : !
78 : include "netcdf.inc"
79 : !
80 : ! !INPUT PARAMETERS:
81 : !! ncid : netCDF file id to read variable from
82 : !! varname : netCDF variable name
83 : integer , intent(in) :: ncid
84 : character (len=*), intent(in) :: varname
85 : !
86 : ! !OUTPUT PARAMETERS:
87 : !! varrd_scal : variable to fill
88 : real*8 , intent(out) :: varrd_scal
89 : !
90 : ! !DESCRIPTION: Reads in a netCDF scalar variable.
91 : !\\
92 : !\\
93 : ! !AUTHOR:
94 : ! John Tannahill (LLNL) and Jules Kouatchou
95 : !
96 : ! !REVISION HISTORY:
97 : ! See https://github.com/geoschem/ncdfutil for complete history
98 : !EOP
99 : !-------------------------------------------------------------------------
100 : !BOC
101 : !
102 : ! !LOCAL VARIABLES:
103 : character (len=512) :: err_msg
104 : integer :: ierr
105 : integer :: varid
106 : real*4 :: varrd_scal_tmp
107 : !
108 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
109 :
110 0 : if (ierr /= NF_NOERR) then
111 : err_msg = 'In Ncrd_Scal #1: ' // Trim (varname) // &
112 0 : ', ' // Nf_Strerror (ierr)
113 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
114 : end if
115 :
116 0 : ierr = Nf_Get_Var_Real (ncid, varid, varrd_scal_tmp)
117 :
118 0 : if (ierr /= NF_NOERR) then
119 0 : err_msg = 'In Ncrd_Scal #2: ' // Nf_Strerror (ierr)
120 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
121 : end if
122 :
123 0 : varrd_scal = varrd_scal_tmp
124 :
125 0 : return
126 :
127 : end subroutine Ncrd_Scal
128 : !EOC
129 : !-------------------------------------------------------------------------
130 : !BOP
131 : !
132 : ! !IROUTINE: Ncrd_Scal_Int
133 : !
134 : ! !INTERFACE:
135 : !
136 0 : subroutine Ncrd_Scal_Int (varrd_scali, ncid, varname)
137 : !
138 : ! !USES:
139 : !
140 : use m_do_err_out
141 : !
142 : implicit none
143 : !
144 : include "netcdf.inc"
145 : !
146 : ! !INPUT PARAMETERS:
147 : !! ncid : netCDF file id to read variable from
148 : !! varname : netCDF variable name
149 : integer , intent(in) :: ncid
150 : character (len=*), intent(in) :: varname
151 : !
152 : ! !OUTPUT PARAMETERS:
153 : !! varrd_scali : integer variable to fill
154 : integer , intent(out) :: varrd_scali
155 : !
156 : ! !DESCRIPTION: Reads in a netCDF integer scalar variable.
157 : !\\
158 : !\\
159 : ! !AUTHOR:
160 : ! John Tannahill (LLNL) and Jules Kouatchou
161 : !
162 : ! !REVISION HISTORY:
163 : ! See https://github.com/geoschem/ncdfutil for complete history
164 : !EOP
165 : !-------------------------------------------------------------------------
166 : !BOC
167 : !
168 : ! !LOCAL VARIABLES:
169 : character (len=512) :: err_msg
170 : integer :: ierr
171 : integer :: varid
172 : !
173 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
174 :
175 0 : if (ierr /= NF_NOERR) then
176 : err_msg = 'In Ncrd_Scal_Int #1: ' // Trim (varname) // &
177 0 : ', ' // Nf_Strerror (ierr)
178 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
179 : end if
180 :
181 0 : ierr = Nf_Get_Var_Int (ncid, varid, varrd_scali)
182 :
183 0 : if (ierr /= NF_NOERR) then
184 0 : err_msg = 'In Ncrd_Scal_Int #2: ' // Nf_Strerror (ierr)
185 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
186 : end if
187 :
188 0 : return
189 :
190 : end subroutine Ncrd_Scal_Int
191 : !EOC
192 : !-------------------------------------------------------------------------
193 : !BOP
194 : !
195 : ! !IROUTINE: Ncrd_1d_R8
196 : !
197 : ! !INTERFACE:
198 : !
199 0 : subroutine Ncrd_1d_R8 (varrd_1d, ncid, varname, strt1d, cnt1d, &
200 : err_stop, stat)
201 : !
202 : ! !USES:
203 : !
204 : use m_do_err_out
205 : !
206 : implicit none
207 : !
208 : include "netcdf.inc"
209 : !
210 : ! !INPUT PARAMETERS:
211 : !! ncid : netCDF file id to read array input data from
212 : !! varname : netCDF variable name for array
213 : !! strt1d : vector specifying the index in varrd_1d where
214 : !! the first of the data values will be read
215 : !! cnt1d : varrd_1d dimension
216 : integer , intent(in) :: ncid
217 : character (len=*), intent(in) :: varname
218 : integer , intent(in) :: strt1d(1)
219 : integer , intent(in) :: cnt1d (1)
220 : logical, optional, intent(in) :: err_stop
221 : !
222 : ! !OUTPUT PARAMETERS:
223 : !! varrd_1d : array to fill
224 : real*8 , intent(out) :: varrd_1d(cnt1d(1))
225 : integer, optional, intent(out) :: stat
226 : !
227 : ! !DESCRIPTION: Reads in a 1D netCDF real array and does some error checking.
228 : !\\
229 : !\\
230 : ! !AUTHOR:
231 : ! John Tannahill (LLNL) and Jules Kouatchou
232 : !
233 : ! !REVISION HISTORY:
234 : ! See https://github.com/geoschem/ncdfutil for complete history
235 : !EOP
236 : !-------------------------------------------------------------------------
237 : !BOC
238 : !
239 : ! !LOCAL VARIABLES:
240 : !
241 : character (len=512) :: err_msg
242 : integer :: ierr
243 : integer :: varid
244 : logical :: dostop
245 :
246 : ! set dostop flag
247 0 : if ( present ( err_stop ) ) then
248 0 : dostop = err_stop
249 : else
250 : dostop = .true.
251 : endif
252 :
253 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
254 :
255 0 : if (ierr /= NF_NOERR) then
256 0 : if ( dostop ) then
257 : err_msg = 'In Ncrd_1d_R8 #1: ' // Trim (varname) // &
258 0 : ', ' // Nf_Strerror (ierr)
259 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
260 : else
261 0 : varrd_1d(:) = -999d0
262 0 : if ( present ( stat ) ) stat = 1
263 0 : return
264 : end if
265 : end if
266 :
267 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt1d, cnt1d, varrd_1d)
268 :
269 0 : if (ierr /= NF_NOERR) then
270 0 : if ( dostop ) then
271 0 : err_msg = 'In Ncrd_1d_R8 #2: ' // Nf_Strerror (ierr)
272 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
273 : else
274 0 : varrd_1d(:) = -999d0
275 0 : if ( present ( stat ) ) stat = 2
276 0 : return
277 : endif
278 : end if
279 :
280 : ! set stat to 0 (= success)
281 0 : if ( present ( stat ) ) stat = 0
282 :
283 : end subroutine Ncrd_1d_R8
284 : !EOC
285 : !-------------------------------------------------------------------------
286 : !BOP
287 : !
288 : ! !IROUTINE: Ncrd_1d_R4
289 : !
290 : ! !INTERFACE:
291 : !
292 0 : subroutine Ncrd_1d_R4 (varrd_1d, ncid, varname, strt1d, cnt1d, &
293 : err_stop, stat)
294 : !
295 : ! !USES:
296 : !
297 : use m_do_err_out
298 : !
299 : implicit none
300 : !
301 : include "netcdf.inc"
302 : !
303 : ! !INPUT PARAMETERS:
304 : !! ncid : netCDF file id to read array input data from
305 : !! varname : netCDF variable name for array
306 : !! strt1d : vector specifying the index in varrd_1d where
307 : !! the first of the data values will be read
308 : !! cnt1d : varrd_1d dimension
309 : integer , intent(in) :: ncid
310 : character (len=*), intent(in) :: varname
311 : integer , intent(in) :: strt1d(1)
312 : integer , intent(in) :: cnt1d (1)
313 : logical, optional, intent(in) :: err_stop
314 : !
315 : ! !OUTPUT PARAMETERS:
316 : !! varrd_1d : array to fill
317 : real*4 , intent(out) :: varrd_1d(cnt1d(1))
318 : integer, optional, intent(out) :: stat
319 : !
320 : ! !DESCRIPTION: Reads in a 1D netCDF real array and does some error checking.
321 : !\\
322 : !\\
323 : ! !AUTHOR:
324 : ! John Tannahill (LLNL) and Jules Kouatchou
325 : !
326 : ! !REVISION HISTORY:
327 : ! See https://github.com/geoschem/ncdfutil for complete history
328 : !EOP
329 : !-------------------------------------------------------------------------
330 : !BOC
331 : !
332 : ! !LOCAL VARIABLES:
333 : !
334 : character (len=512) :: err_msg
335 : integer :: ierr
336 : integer :: varid
337 : logical :: dostop
338 :
339 : ! set dostop flag
340 0 : if ( present ( err_stop ) ) then
341 0 : dostop = err_stop
342 : else
343 : dostop = .true.
344 : endif
345 :
346 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
347 :
348 0 : if (ierr /= NF_NOERR) then
349 0 : if ( dostop ) then
350 : err_msg = 'In Ncrd_1d_R4 #1: ' // Trim (varname) // &
351 0 : ', ' // Nf_Strerror (ierr)
352 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
353 : else
354 0 : varrd_1d(:) = -999.0
355 0 : if ( present ( stat ) ) stat = 1
356 0 : return
357 : end if
358 : end if
359 :
360 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt1d, cnt1d, varrd_1d)
361 :
362 0 : if (ierr /= NF_NOERR) then
363 0 : if ( dostop ) then
364 0 : err_msg = 'In Ncrd_1d_R4 #2: ' // Nf_Strerror (ierr)
365 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
366 : else
367 0 : varrd_1d(:) = -999.0
368 0 : if ( present ( stat ) ) stat = 2
369 0 : return
370 : endif
371 : end if
372 :
373 : ! set stat to 0 (= success)
374 0 : if ( present ( stat ) ) stat = 0
375 : return
376 :
377 : end subroutine Ncrd_1d_R4
378 : !EOC
379 : !-------------------------------------------------------------------------
380 : !BOP
381 : !
382 : ! !IROUTINE: Ncrd_1d_Int
383 : !
384 : ! !INTERFACE:
385 : !
386 0 : subroutine Ncrd_1d_Int (varrd_1di, ncid, varname, strt1d, cnt1d, &
387 : err_stop, stat)
388 : !
389 : ! !USES:
390 : !
391 : use m_do_err_out
392 : !
393 : implicit none
394 : !
395 : include "netcdf.inc"
396 : !
397 : ! !INPUT PARAMETERS:
398 : !
399 : !! ncid : netCDF file id to read array input data from
400 : !! varname : netCDF variable name for array
401 : !! strt1d : vector specifying the index in varrd_1di where
402 : !! the first of the data values will be read
403 : !! cnt1d : varrd_1di dimension
404 : integer , intent(in) :: ncid
405 : character (len=*), intent(in) :: varname
406 : integer , intent(in) :: strt1d(1)
407 : integer , intent(in) :: cnt1d (1)
408 : logical, optional, intent(in) :: err_stop
409 : !
410 : ! !OUTPUT PARAMETERS:
411 : !! varrd_1di : intger array to fill
412 : integer , intent(out) :: varrd_1di(cnt1d(1))
413 : integer, optional, intent(out) :: stat
414 : !
415 : ! !DESCRIPTION: Reads in a 1D netCDF integer array and does some error
416 : ! checking.
417 : !\\
418 : !\\
419 : ! !AUTHOR:
420 : ! John Tannahill (LLNL) and Jules Kouatchou
421 : !
422 : ! !REVISION HISTORY:
423 : ! See https://github.com/geoschem/ncdfutil for complete history
424 : !EOP
425 : !-------------------------------------------------------------------------
426 : !BOC
427 : !
428 : ! !LOCAL VARIABLES:
429 : !
430 : character (len=512) :: err_msg
431 : integer :: ierr
432 : integer :: varid
433 : logical :: dostop
434 :
435 : ! set dostop flag
436 0 : if ( present ( err_stop ) ) then
437 0 : dostop = err_stop
438 : else
439 : dostop = .true.
440 : endif
441 :
442 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
443 :
444 0 : if (ierr /= NF_NOERR) then
445 0 : if ( dostop ) then
446 : err_msg = 'In Ncrd_1d_Int #1: ' // Trim (varname) // &
447 0 : ', ' // Nf_Strerror (ierr)
448 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
449 : else
450 0 : varrd_1di(:) = -999
451 0 : if ( present ( stat ) ) stat = 1
452 0 : return
453 : end if
454 : end if
455 :
456 0 : ierr = Nf_Get_Vara_Int (ncid, varid, strt1d, cnt1d, varrd_1di)
457 :
458 0 : if (ierr /= NF_NOERR) then
459 0 : if ( dostop ) then
460 0 : err_msg = 'In Ncrd_1d_Int #2: ' // Nf_Strerror (ierr)
461 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
462 : else
463 0 : varrd_1di(:) = -999
464 0 : if ( present ( stat ) ) stat = 2
465 0 : return
466 : endif
467 : end if
468 :
469 : ! set stat to 0 (= success)
470 0 : if ( present ( stat ) ) stat = 0
471 :
472 : return
473 :
474 : end subroutine Ncrd_1d_Int
475 : !EOC
476 : !-------------------------------------------------------------------------
477 : !BOP
478 : !
479 : ! !IROUTINE: Ncrd_2d_R8
480 : !
481 : ! !INTERFACE:
482 : !
483 0 : subroutine Ncrd_2d_R8 (varrd_2d, ncid, varname, strt2d, cnt2d)
484 : !
485 : ! !USES:
486 : !
487 : use m_do_err_out
488 : !
489 : implicit none
490 : !
491 : include "netcdf.inc"
492 : !
493 : ! !INPUT PARAMETERS:
494 : !! ncid : netCDF file id to read array input data from
495 : !! varname : netCDF variable name for array
496 : !! strt2d : vector specifying the index in varrd_2d where
497 : !! the first of the data values will be read
498 : !! cnt2d : varrd_2d dimensions
499 : integer , intent(in) :: ncid
500 : character (len=*), intent(in) :: varname
501 : integer , intent(in) :: strt2d(2)
502 : integer , intent(in) :: cnt2d (2)
503 : !
504 : ! !OUTPUT PARAMETERS:
505 : !! varrd_2d : array to fill
506 : real*8 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2))
507 : !
508 : ! !DESCRIPTION: Reads in a 2D netCDF real array and does some error checking.
509 : !\\
510 : !\\
511 : ! !AUTHOR:
512 : ! John Tannahill (LLNL) and Jules Kouatchou
513 : !
514 : ! !REVISION HISTORY:
515 : ! See https://github.com/geoschem/ncdfutil for complete history
516 : !EOP
517 : !-------------------------------------------------------------------------
518 : !BOC
519 : !
520 : ! !LOCAL VARIABLES:
521 : character (len=512) :: err_msg
522 : integer :: ierr
523 : integer :: varid
524 : !
525 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
526 :
527 0 : if (ierr /= NF_NOERR) then
528 : err_msg = 'In Ncrd_2d_R8 #1: ' // Trim (varname) // &
529 0 : ', ' // Nf_Strerror (ierr)
530 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
531 : end if
532 :
533 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt2d, cnt2d, varrd_2d)
534 :
535 0 : if (ierr /= NF_NOERR) then
536 0 : err_msg = 'In Ncrd_2d_R8 #2: ' // Nf_Strerror (ierr)
537 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
538 : end if
539 :
540 0 : end subroutine Ncrd_2d_R8
541 : !EOC
542 : !-------------------------------------------------------------------------
543 : !BOP
544 : !
545 : ! !IROUTINE: Ncrd_2d_R4
546 : !
547 : ! !INTERFACE:
548 : !
549 0 : subroutine Ncrd_2d_R4 (varrd_2d, ncid, varname, strt2d, cnt2d)
550 : !
551 : ! !USES:
552 : !
553 : use m_do_err_out
554 : !
555 : implicit none
556 : !
557 : include "netcdf.inc"
558 : !
559 : ! !INPUT PARAMETERS:
560 : !! ncid : netCDF file id to read array input data from
561 : !! varname : netCDF variable name for array
562 : !! strt2d : vector specifying the index in varrd_2d where
563 : !! the first of the data values will be read
564 : !! cnt2d : varrd_2d dimensions
565 : integer , intent(in) :: ncid
566 : character (len=*), intent(in) :: varname
567 : integer , intent(in) :: strt2d(2)
568 : integer , intent(in) :: cnt2d (2)
569 : !
570 : ! !OUTPUT PARAMETERS:
571 : !! varrd_2d : array to fill
572 : real*4 , intent(out) :: varrd_2d(cnt2d(1), cnt2d(2))
573 : !
574 : ! !DESCRIPTION: Reads in a 2D netCDF real array and does some error checking.
575 : !\\
576 : !\\
577 : ! !AUTHOR:
578 : ! John Tannahill (LLNL) and Jules Kouatchou
579 : !
580 : ! !REVISION HISTORY:
581 : ! See https://github.com/geoschem/ncdfutil for complete history
582 : !EOP
583 : !-------------------------------------------------------------------------
584 : !BOC
585 : !
586 : ! !LOCAL VARIABLES:
587 : character (len=512) :: err_msg
588 : integer :: ierr
589 : integer :: varid
590 : !
591 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
592 :
593 0 : if (ierr /= NF_NOERR) then
594 : err_msg = 'In Ncrd_2d_R4 #1: ' // Trim (varname) // &
595 0 : ', ' // Nf_Strerror (ierr)
596 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
597 : end if
598 :
599 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt2d, cnt2d, varrd_2d)
600 :
601 0 : if (ierr /= NF_NOERR) then
602 0 : err_msg = 'In Ncrd_2d_R4 #2: ' // Nf_Strerror (ierr)
603 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
604 : end if
605 :
606 0 : end subroutine Ncrd_2d_R4
607 : !EOC
608 : !-------------------------------------------------------------------------
609 : !BOP
610 : !
611 : ! !IROUTINE: Ncrd_2d_Int
612 : !
613 : ! !INTERFACE:
614 : !
615 0 : subroutine Ncrd_2d_Int (varrd_2di, ncid, varname, strt2d, cnt2d)
616 : !
617 : ! !USES:
618 : !
619 : use m_do_err_out
620 : !
621 : implicit none
622 : !
623 : include "netcdf.inc"
624 : !
625 : ! !INPUT PARAMETERS:
626 : !! ncid : netCDF file id to read array input data from
627 : !! varname : netCDF variable name for array
628 : !! strt2d : vector specifying the index in varrd_2d where
629 : !! the first of the data values will be read
630 : !! cnt2d : varrd_2di dimensions
631 : integer , intent(in) :: ncid
632 : character (len=*), intent(in) :: varname
633 : integer , intent(in) :: strt2d(2)
634 : integer , intent(in) :: cnt2d (2)
635 : !
636 : ! !OUTPUT PARAMETERS:
637 : !! varrd_2di : intger array to fill
638 : integer , intent(out) :: varrd_2di(cnt2d(1), cnt2d(2))
639 : !
640 : ! !DESCRIPTION: Reads in a 2D netCDF integer array and does some error
641 : ! checking.
642 : !\\
643 : !\\
644 : ! !AUTHOR:
645 : ! John Tannahill (LLNL) and Jules Kouatchou
646 : !
647 : ! !REVISION HISTORY:
648 : ! See https://github.com/geoschem/ncdfutil for complete history
649 : !EOP
650 : !-------------------------------------------------------------------------
651 : !BOC
652 : !
653 : ! !LOCAL VARIABLES:
654 : character (len=512) :: err_msg
655 : integer :: ierr
656 : integer :: varid
657 : !
658 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
659 :
660 0 : if (ierr /= NF_NOERR) then
661 : err_msg = 'In Ncrd_2d_Int #1: ' // Trim (varname) // &
662 0 : ', ' // Nf_Strerror (ierr)
663 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
664 : end if
665 :
666 0 : ierr = Nf_Get_Vara_Int (ncid, varid, strt2d, cnt2d, varrd_2di)
667 :
668 0 : if (ierr /= NF_NOERR) then
669 0 : err_msg = 'In Ncrd_2d_Int #2: ' // Nf_Strerror (ierr)
670 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
671 : end if
672 :
673 0 : end subroutine Ncrd_2d_Int
674 : !EOC
675 : !-------------------------------------------------------------------------
676 : !BOP
677 : !
678 : ! !IROUTINE: Ncrd_3d_R8
679 : !
680 : ! !INTERFACE:
681 : !
682 0 : subroutine Ncrd_3d_R8 (varrd_3d, ncid, varname, strt3d, cnt3d)
683 : !
684 : ! !USES:
685 : !
686 : use m_do_err_out
687 : !
688 : implicit none
689 : !
690 : include "netcdf.inc"
691 : !
692 : ! !INPUT PARAMETERS:
693 : !! ncid : netCDF file id to read array input data from
694 : !! varname : netCDF variable name for array
695 : !! strt3d : vector specifying the index in varrd_3d where
696 : !! the first of the data values will be read
697 : !! cnt3d : varrd_3d dimensions
698 : integer , intent(in) :: ncid
699 : character (len=*), intent(in) :: varname
700 : integer , intent(in) :: strt3d(3)
701 : integer , intent(in) :: cnt3d (3)
702 : !
703 : ! !OUTPUT PARAMETERS:
704 : !! varrd_3d : array to fill
705 : real*8 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), &
706 : cnt3d(3))
707 : !
708 : ! !DESCRIPTION: Reads in a 3D netCDF real array and does some error checking.
709 : !\\
710 : !\\
711 : ! !AUTHOR:
712 : ! John Tannahill (LLNL) and Jules Kouatchou
713 : !
714 : ! !REVISION HISTORY:
715 : ! See https://github.com/geoschem/ncdfutil for complete history
716 : !EOP
717 : !-------------------------------------------------------------------------
718 : !BOC
719 : !
720 : ! !LOCAL VARIABLES:
721 : character (len=512) :: err_msg
722 : integer :: ierr
723 : integer :: varid
724 : !
725 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
726 :
727 0 : if (ierr /= NF_NOERR) then
728 : err_msg = 'In Ncrd_3d_R8 #1: ' // Trim (varname) // &
729 0 : ', ' // Nf_Strerror (ierr)
730 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
731 : end if
732 :
733 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt3d, cnt3d, varrd_3d)
734 :
735 0 : if (ierr /= NF_NOERR) then
736 0 : err_msg = 'In Ncrd_3d_R8 #2: ' // Nf_Strerror (ierr)
737 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
738 : end if
739 :
740 0 : end subroutine Ncrd_3d_R8
741 : !EOC
742 : !-------------------------------------------------------------------------
743 : !BOP
744 : !
745 : ! !IROUTINE: Ncrd_3d_R4
746 : !
747 : ! !INTERFACE:
748 : !
749 0 : subroutine Ncrd_3d_R4 (varrd_3d, ncid, varname, strt3d, cnt3d)
750 : !
751 : ! !USES:
752 : !
753 : use m_do_err_out
754 : !
755 : implicit none
756 : !
757 : include "netcdf.inc"
758 : !
759 : ! !INPUT PARAMETERS:
760 : !! ncid : netCDF file id to read array input data from
761 : !! varname : netCDF variable name for array
762 : !! strt3d : vector specifying the index in varrd_3d where
763 : !! the first of the data values will be read
764 : !! cnt3d : varrd_3d dimensions
765 : integer , intent(in) :: ncid
766 : character (len=*), intent(in) :: varname
767 : integer , intent(in) :: strt3d(3)
768 : integer , intent(in) :: cnt3d (3)
769 : !
770 : ! !OUTPUT PARAMETERS:
771 : !! varrd_3d : array to fill
772 : real*4 , intent(out) :: varrd_3d(cnt3d(1), cnt3d(2), &
773 : cnt3d(3))
774 : !
775 : ! !DESCRIPTION: Reads in a 3D netCDF real array and does some error checking.
776 : !\\
777 : !\\
778 : ! !AUTHOR:
779 : ! John Tannahill (LLNL) and Jules Kouatchou
780 : !
781 : ! !REVISION HISTORY:
782 : ! See https://github.com/geoschem/ncdfutil for complete history
783 : !EOP
784 : !-------------------------------------------------------------------------
785 : !BOC
786 : !
787 : ! !LOCAL VARIABLES:
788 : character (len=512) :: err_msg
789 : integer :: ierr
790 : integer :: varid
791 : !
792 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
793 :
794 0 : if (ierr /= NF_NOERR) then
795 : err_msg = 'In Ncrd_3d_R4 #1: ' // Trim (varname) // &
796 0 : ', ' // Nf_Strerror (ierr)
797 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
798 : end if
799 :
800 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt3d, cnt3d, varrd_3d)
801 :
802 0 : if (ierr /= NF_NOERR) then
803 0 : err_msg = 'In Ncrd_3d_R4 #2: ' // Nf_Strerror (ierr)
804 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
805 : end if
806 :
807 0 : end subroutine Ncrd_3d_R4
808 : !EOC
809 : !-------------------------------------------------------------------------
810 : !BOP
811 : !
812 : ! !IROUTINE: Ncrd_3d_Int
813 : !
814 : ! !INTERFACE:
815 : !
816 0 : subroutine Ncrd_3d_Int (varrd_3di, ncid, varname, strt3d, cnt3d)
817 : !
818 : ! !USES:
819 : !
820 : use m_do_err_out
821 : !
822 : implicit none
823 : !
824 : include "netcdf.inc"
825 : !
826 : ! !INPUT PARAMETERS:
827 : !! ncid : netCDF file id to read array input data from
828 : !! varname : netCDF variable name for array
829 : !! strt3d : vector specifying the index in varrd_3d where
830 : !! the first of the data values will be read
831 : !! cnt3d : varrd_3di dimensions
832 : integer , intent(in) :: ncid
833 : character (len=*), intent(in) :: varname
834 : integer , intent(in) :: strt3d(3)
835 : integer , intent(in) :: cnt3d (3)
836 : !
837 : ! !OUTPUT PARAMETERS:
838 : !! varrd_3di : intger array to fill
839 : integer , intent(out) :: varrd_3di(cnt3d(1), cnt3d(2), &
840 : cnt3d(3))
841 : !
842 : ! !DESCRIPTION: Reads in a 3D netCDF integer array and does some error
843 : ! checking.
844 : !\\
845 : !\\
846 : ! !AUTHOR:
847 : ! John Tannahill (LLNL) and Jules Kouatchou
848 : !
849 : ! !REVISION HISTORY:
850 : ! See https://github.com/geoschem/ncdfutil for complete history
851 : !EOP
852 : !-------------------------------------------------------------------------
853 : !BOC
854 : !
855 : ! !LOCAL VARIABLES:
856 : character (len=512) :: err_msg
857 : integer :: ierr
858 : integer :: varid
859 : !
860 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
861 :
862 0 : if (ierr /= NF_NOERR) then
863 : err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // &
864 0 : ', ' // Nf_Strerror (ierr)
865 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
866 : end if
867 :
868 0 : ierr = Nf_Get_Vara_Int (ncid, varid, strt3d, cnt3d, varrd_3di)
869 :
870 0 : if (ierr /= NF_NOERR) then
871 0 : err_msg = 'In Ncrd_3d_Int #2: ' // Nf_Strerror (ierr)
872 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
873 : end if
874 :
875 0 : end subroutine Ncrd_3d_Int
876 : !EOC
877 : !-------------------------------------------------------------------------
878 : !BOP
879 : !
880 : ! !IROUTINE: Ncrd_4d_R8
881 : !
882 : ! !INTERFACE:
883 : !
884 0 : subroutine Ncrd_4d_R8 (varrd_4d, ncid, varname, strt4d, cnt4d)
885 : !
886 : ! !USES:
887 : !
888 : use m_do_err_out
889 : !
890 : implicit none
891 : !
892 : include "netcdf.inc"
893 : !
894 : ! !INPUT PARAMETERS:
895 : !! ncid : netCDF file id to read array input data from
896 : !! varname : netCDF variable name for array
897 : !! strt4d : vector specifying the index in varrd_4d where
898 : !! the first of the data values will be read
899 : !! cnt4d : varrd_4d dimensions
900 : integer , intent(in) :: ncid
901 : character (len=*), intent(in) :: varname
902 : integer , intent(in) :: strt4d(4)
903 : integer , intent(in) :: cnt4d (4)
904 : !
905 : ! !OUTPUT PARAMETERS:
906 : !! varrd_4d : array to fill
907 : real*8 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), &
908 : cnt4d(3), cnt4d(4))
909 : !
910 : ! !DESCRIPTION: Reads in a 4D netCDF real array and does some error checking.
911 : !\\
912 : !\\
913 : ! !AUTHOR:
914 : ! John Tannahill (LLNL) and Jules Kouatchou
915 : !
916 : ! !REVISION HISTORY:
917 : ! See https://github.com/geoschem/ncdfutil for complete history
918 : !EOP
919 : !-------------------------------------------------------------------------
920 : !BOC
921 : !
922 : ! !LOCAL VARIABLES:
923 : character (len=512) :: err_msg
924 : integer :: ierr
925 : integer :: varid
926 : !
927 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
928 :
929 0 : if (ierr /= NF_NOERR) then
930 : err_msg = 'In Ncrd_4d_R8 #1: ' // Trim (varname) // &
931 0 : ', ' // Nf_Strerror (ierr)
932 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
933 : end if
934 :
935 :
936 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt4d, cnt4d, varrd_4d)
937 :
938 0 : if (ierr /= NF_NOERR) then
939 0 : err_msg = 'In Ncrd_4d_R8 #2: ' // Nf_Strerror (ierr)
940 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
941 : end if
942 :
943 0 : end subroutine Ncrd_4d_R8
944 : !EOC
945 : !-------------------------------------------------------------------------
946 : !BOP
947 : !
948 : ! !IROUTINE: Ncrd_4d_R4
949 : !
950 : ! !INTERFACE:
951 : !
952 0 : subroutine Ncrd_4d_R4 (varrd_4d, ncid, varname, strt4d, cnt4d)
953 : !
954 : ! !USES:
955 : !
956 : use m_do_err_out
957 : !
958 : implicit none
959 : !
960 : include "netcdf.inc"
961 : !
962 : ! !INPUT PARAMETERS:
963 : !! ncid : netCDF file id to read array input data from
964 : !! varname : netCDF variable name for array
965 : !! strt4d : vector specifying the index in varrd_4d where
966 : !! the first of the data values will be read
967 : !! cnt4d : varrd_4d dimensions
968 : integer , intent(in) :: ncid
969 : character (len=*), intent(in) :: varname
970 : integer , intent(in) :: strt4d(4)
971 : integer , intent(in) :: cnt4d (4)
972 : !
973 : ! !OUTPUT PARAMETERS:
974 : !! varrd_4d : array to fill
975 : real*4 , intent(out) :: varrd_4d(cnt4d(1), cnt4d(2), &
976 : cnt4d(3), cnt4d(4))
977 : !
978 : ! !DESCRIPTION: Reads in a 4D netCDF real array and does some error checking.
979 : !\\
980 : !\\
981 : ! !AUTHOR:
982 : ! John Tannahill (LLNL) and Jules Kouatchou
983 : !
984 : ! !REVISION HISTORY:
985 : ! See https://github.com/geoschem/ncdfutil for complete history
986 : !EOP
987 : !-------------------------------------------------------------------------
988 : !BOC
989 : !
990 : ! !LOCAL VARIABLES:
991 : character (len=512) :: err_msg
992 : integer :: ierr
993 : integer :: varid
994 : !
995 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
996 :
997 0 : if (ierr /= NF_NOERR) then
998 : err_msg = 'In Ncrd_4d_R4 #1: ' // Trim (varname) // &
999 0 : ', ' // Nf_Strerror (ierr)
1000 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1001 : end if
1002 :
1003 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt4d, cnt4d, varrd_4d)
1004 :
1005 0 : if (ierr /= NF_NOERR) then
1006 0 : err_msg = 'In Ncrd_4d_R4 #2: ' // Nf_Strerror (ierr)
1007 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1008 : end if
1009 :
1010 0 : end subroutine Ncrd_4d_R4
1011 : !EOC
1012 : !-------------------------------------------------------------------------
1013 : !BOP
1014 : !
1015 : ! !IROUTINE: Ncrd_4d_Int
1016 : !
1017 : ! !INTERFACE:
1018 : !
1019 0 : subroutine Ncrd_4d_Int (varrd_4di, ncid, varname, strt4d, cnt4d)
1020 : !
1021 : ! !USES:
1022 : !
1023 : use m_do_err_out
1024 : !
1025 : implicit none
1026 : !
1027 : include "netcdf.inc"
1028 : !
1029 : ! !INPUT PARAMETERS:
1030 : !! ncid : netCDF file id to read array input data from
1031 : !! varname : netCDF variable name for array
1032 : !! strt3d : vector specifying the index in varrd_3d where
1033 : !! the first of the data values will be read
1034 : !! cnt3d : varrd_3di dimensions
1035 : integer , intent(in) :: ncid
1036 : character (len=*), intent(in) :: varname
1037 : integer , intent(in) :: strt4d(4)
1038 : integer , intent(in) :: cnt4d (4)
1039 : !
1040 : ! !OUTPUT PARAMETERS:
1041 : !! varrd_3di : intger array to fill
1042 : integer , intent(out) :: varrd_4di(cnt4d(1), cnt4d(2), &
1043 : cnt4d(3), cnt4d(4))
1044 : !
1045 : ! !DESCRIPTION: Reads in a 3D netCDF integer array and does some error
1046 : ! checking.
1047 : !\\
1048 : !\\
1049 : ! !AUTHOR:
1050 : ! John Tannahill (LLNL) and Jules Kouatchou
1051 : !
1052 : ! !REVISION HISTORY:
1053 : ! See https://github.com/geoschem/ncdfutil for complete history
1054 : !EOP
1055 : !-------------------------------------------------------------------------
1056 : !BOC
1057 : !
1058 : ! !LOCAL VARIABLES:
1059 : character (len=512) :: err_msg
1060 : integer :: ierr
1061 : integer :: varid
1062 : !
1063 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1064 :
1065 0 : if (ierr /= NF_NOERR) then
1066 : err_msg = 'In Ncrd_3d_Int #1: ' // Trim (varname) // &
1067 0 : ', ' // Nf_Strerror (ierr)
1068 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1069 : end if
1070 :
1071 0 : ierr = Nf_Get_Vara_Int (ncid, varid, strt4d, cnt4d, varrd_4di)
1072 :
1073 0 : if (ierr /= NF_NOERR) then
1074 0 : err_msg = 'In Ncrd_3d_Int #2: ' // Nf_Strerror (ierr)
1075 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1076 : end if
1077 :
1078 0 : end subroutine Ncrd_4d_Int
1079 : !EOC
1080 : !-------------------------------------------------------------------------
1081 : !BOP
1082 : !
1083 : ! !IROUTINE: Ncrd_5d_R8
1084 : !
1085 : ! !INTERFACE:
1086 : !
1087 0 : subroutine Ncrd_5d_R8 (varrd_5d, ncid, varname, strt5d, cnt5d)
1088 : !
1089 : ! !USES:
1090 : !
1091 : use m_do_err_out
1092 : !
1093 : implicit none
1094 : !
1095 : include "netcdf.inc"
1096 : !
1097 : ! !INPUT PARAMETERS:
1098 : !! ncid : netCDF file id to read array input data from
1099 : !! varname : netCDF variable name for array
1100 : !! strt5d : vector specifying the index in varrd_5d where
1101 : !! the first of the data values will be read
1102 : !! cnt5d : varrd_5d dimensions
1103 : integer , intent(in) :: ncid
1104 : character (len=*), intent(in) :: varname
1105 : integer , intent(in) :: strt5d(5)
1106 : integer , intent(in) :: cnt5d (5)
1107 : !
1108 : ! !OUTPUT PARAMETERS:
1109 : !! varrd_5d : array to fill
1110 : real*8 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), &
1111 : cnt5d(3), cnt5d(4), &
1112 : cnt5d(5))
1113 : !
1114 : ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking.
1115 : !\\
1116 : !\\
1117 : ! !AUTHOR:
1118 : ! John Tannahill (LLNL) and Jules Kouatchou
1119 : !
1120 : ! !REVISION HISTORY:
1121 : ! See https://github.com/geoschem/ncdfutil for complete history
1122 : !EOP
1123 : !-------------------------------------------------------------------------
1124 : !BOC
1125 : !
1126 : ! !LOCAL VARIABLES:
1127 : character (len=512) :: err_msg
1128 : integer :: ierr
1129 : integer :: varid
1130 : !
1131 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1132 :
1133 0 : if (ierr /= NF_NOERR) then
1134 : err_msg = 'In Ncrd_5d_R8 #1: ' // Trim (varname) // &
1135 0 : ', ' // Nf_Strerror (ierr)
1136 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1137 : end if
1138 :
1139 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt5d, cnt5d, varrd_5d)
1140 :
1141 0 : if (ierr /= NF_NOERR) then
1142 0 : err_msg = 'In Ncrd_5d_R8 #2: ' // Nf_Strerror (ierr)
1143 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1144 : end if
1145 :
1146 0 : end subroutine Ncrd_5d_R8
1147 : !EOC
1148 : !-------------------------------------------------------------------------
1149 : !BOP
1150 : !
1151 : ! !IROUTINE: Ncrd_5d_R4
1152 : !
1153 : ! !INTERFACE:
1154 : !
1155 0 : subroutine Ncrd_5d_R4 (varrd_5d, ncid, varname, strt5d, cnt5d)
1156 : !
1157 : ! !USES:
1158 : !
1159 : use m_do_err_out
1160 : !
1161 : implicit none
1162 : !
1163 : include "netcdf.inc"
1164 : !
1165 : ! !INPUT PARAMETERS:
1166 : !! ncid : netCDF file id to read array input data from
1167 : !! varname : netCDF variable name for array
1168 : !! strt5d : vector specifying the index in varrd_5d where
1169 : !! the first of the data values will be read
1170 : !! cnt5d : varrd_5d dimensions
1171 : integer , intent(in) :: ncid
1172 : character (len=*), intent(in) :: varname
1173 : integer , intent(in) :: strt5d(5)
1174 : integer , intent(in) :: cnt5d (5)
1175 : !
1176 : ! !OUTPUT PARAMETERS:
1177 : !! varrd_5d : array to fill
1178 : real*4 , intent(out) :: varrd_5d(cnt5d(1), cnt5d(2), &
1179 : cnt5d(3), cnt5d(4), &
1180 : cnt5d(5))
1181 : !
1182 : ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking.
1183 : !\\
1184 : !\\
1185 : ! !AUTHOR:
1186 : ! John Tannahill (LLNL) and Jules Kouatchou
1187 : !
1188 : ! !REVISION HISTORY:
1189 : ! See https://github.com/geoschem/ncdfutil for complete history
1190 : !EOP
1191 : !-------------------------------------------------------------------------
1192 : !BOC
1193 : !
1194 : ! !LOCAL VARIABLES:
1195 : character (len=512) :: err_msg
1196 : integer :: ierr
1197 : integer :: varid
1198 : !
1199 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1200 :
1201 0 : if (ierr /= NF_NOERR) then
1202 : err_msg = 'In Ncrd_5d_R4 #1: ' // Trim (varname) // &
1203 0 : ', ' // Nf_Strerror (ierr)
1204 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1205 : end if
1206 :
1207 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt5d, cnt5d, varrd_5d)
1208 :
1209 0 : if (ierr /= NF_NOERR) then
1210 0 : err_msg = 'In Ncrd_5d_R4 #2: ' // Nf_Strerror (ierr)
1211 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1212 : end if
1213 :
1214 0 : end subroutine Ncrd_5d_R4
1215 : !EOC
1216 : !-------------------------------------------------------------------------
1217 : !BOP
1218 : !
1219 : ! !IROUTINE: Ncrd_6d_R8
1220 : !
1221 : ! !INTERFACE:
1222 : !
1223 0 : subroutine Ncrd_6d_R8 (varrd_6d, ncid, varname, strt6d, cnt6d)
1224 : !
1225 : ! !USES:
1226 : !
1227 : use m_do_err_out
1228 : !
1229 : implicit none
1230 : !
1231 : include "netcdf.inc"
1232 : !
1233 : ! !INPUT PARAMETERS:
1234 : !! ncid : netCDF file id to read array input data from
1235 : !! varname : netCDF variable name for array
1236 : !! strt5d : vector specifying the index in varrd_5d where
1237 : !! the first of the data values will be read
1238 : !! cnt5d : varrd_5d dimensions
1239 : integer , intent(in) :: ncid
1240 : character (len=*), intent(in) :: varname
1241 : integer , intent(in) :: strt6d(6)
1242 : integer , intent(in) :: cnt6d (6)
1243 : !
1244 : ! !OUTPUT PARAMETERS:
1245 : !! varrd_5d : array to fill
1246 : real*8 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), &
1247 : cnt6d(3), cnt6d(4), &
1248 : cnt6d(5), cnt6d(6))
1249 : !
1250 : ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking.
1251 : !\\
1252 : !\\
1253 : ! !AUTHOR:
1254 : ! John Tannahill (LLNL) and Jules Kouatchou
1255 : !
1256 : ! !REVISION HISTORY:
1257 : ! 20 Dec 2011 - R. Yantosca - Initial version
1258 : ! See https://github.com/geoschem/ncdfutil for complete history
1259 : !EOP
1260 : !-------------------------------------------------------------------------
1261 : !BOC
1262 : !
1263 : ! !LOCAL VARIABLES:
1264 : character (len=512) :: err_msg
1265 : integer :: ierr
1266 : integer :: varid
1267 : !
1268 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1269 :
1270 0 : if (ierr /= NF_NOERR) then
1271 : err_msg = 'In Ncrd_6d_R8 #1: ' // Trim (varname) // &
1272 0 : ', ' // Nf_Strerror (ierr)
1273 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1274 : end if
1275 :
1276 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt6d, cnt6d, varrd_6d)
1277 :
1278 0 : if (ierr /= NF_NOERR) then
1279 0 : err_msg = 'In Ncrd_6d_R8 #2: ' // Nf_Strerror (ierr)
1280 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1281 : end if
1282 :
1283 0 : end subroutine Ncrd_6d_R8
1284 : !EOC
1285 : !-------------------------------------------------------------------------
1286 : !BOP
1287 : !
1288 : ! !IROUTINE: Ncrd_6d_R4
1289 : !
1290 : ! !INTERFACE:
1291 : !
1292 0 : subroutine Ncrd_6d_R4 (varrd_6d, ncid, varname, strt6d, cnt6d)
1293 : !
1294 : ! !USES:
1295 : !
1296 : use m_do_err_out
1297 : !
1298 : implicit none
1299 : !
1300 : include "netcdf.inc"
1301 : !
1302 : ! !INPUT PARAMETERS:
1303 : !! ncid : netCDF file id to read array input data from
1304 : !! varname : netCDF variable name for array
1305 : !! strt5d : vector specifying the index in varrd_5d where
1306 : !! the first of the data values will be read
1307 : !! cnt5d : varrd_5d dimensions
1308 : integer , intent(in) :: ncid
1309 : character (len=*), intent(in) :: varname
1310 : integer , intent(in) :: strt6d(6)
1311 : integer , intent(in) :: cnt6d (6)
1312 : !
1313 : ! !OUTPUT PARAMETERS:
1314 : !! varrd_5d : array to fill
1315 : real*4 , intent(out) :: varrd_6d(cnt6d(1), cnt6d(2), &
1316 : cnt6d(3), cnt6d(4), &
1317 : cnt6d(5), cnt6d(6))
1318 : !
1319 : ! !DESCRIPTION: Reads in a 5D netCDF real array and does some error checking.
1320 : !\\
1321 : !\\
1322 : ! !AUTHOR:
1323 : ! John Tannahill (LLNL) and Jules Kouatchou
1324 : !
1325 : ! !REVISION HISTORY:
1326 : ! See https://github.com/geoschem/ncdfutil for complete history
1327 : !EOP
1328 : !-------------------------------------------------------------------------
1329 : !BOC
1330 : !
1331 : ! !LOCAL VARIABLES:
1332 : character (len=512) :: err_msg
1333 : integer :: ierr
1334 : integer :: varid
1335 : !
1336 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1337 :
1338 0 : if (ierr /= NF_NOERR) then
1339 : err_msg = 'In Ncrd_6d_R4 #1: ' // Trim (varname) // &
1340 0 : ', ' // Nf_Strerror (ierr)
1341 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1342 : end if
1343 :
1344 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt6d, cnt6d, varrd_6d)
1345 :
1346 0 : if (ierr /= NF_NOERR) then
1347 0 : err_msg = 'In Ncrd_6d_R4 #2: ' // Nf_Strerror (ierr)
1348 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1349 : end if
1350 :
1351 0 : end subroutine Ncrd_6d_R4
1352 : !EOC
1353 : !-------------------------------------------------------------------------
1354 : !BOP
1355 : !
1356 : ! !IROUTINE: Ncrd_7d_R8
1357 : !
1358 : ! !INTERFACE:
1359 : !
1360 0 : subroutine Ncrd_7d_R8 (varrd_7d, ncid, varname, strt7d, cnt7d)
1361 : !
1362 : ! !USES:
1363 : !
1364 : use m_do_err_out
1365 : !
1366 : implicit none
1367 : !
1368 : include "netcdf.inc"
1369 : !
1370 : ! !INPUT PARAMETERS:
1371 : !! ncid : netCDF file id to read array input data from
1372 : !! varname : netCDF variable name for array
1373 : !! strt7d : vector specifying the index in varrd_7d where
1374 : !! the first of the data values will be read
1375 : !! cnt7d : varrd_7d dimensions
1376 : integer , intent(in) :: ncid
1377 : character (len=*), intent(in) :: varname
1378 : integer , intent(in) :: strt7d(7)
1379 : integer , intent(in) :: cnt7d (7)
1380 : !
1381 : ! !OUTPUT PARAMETERS:
1382 : !! varrd_5d : array to fill
1383 : real*8 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), &
1384 : cnt7d(3), cnt7d(4), &
1385 : cnt7d(5), cnt7d(6), &
1386 : cnt7d(7))
1387 : !
1388 : ! !DESCRIPTION: Reads in a 7D netCDF real array and does some error checking.
1389 : !\\
1390 : !\\
1391 : ! !AUTHOR:
1392 : ! John Tannahill (LLNL) and Jules Kouatchou
1393 : !
1394 : ! !REVISION HISTORY:
1395 : ! 20 Dec 2011 - R. Yantosca - Initial version
1396 : ! See https://github.com/geoschem/ncdfutil for complete history
1397 : !EOP
1398 : !-------------------------------------------------------------------------
1399 : !BOC
1400 : !
1401 : ! !LOCAL VARIABLES:
1402 : character (len=512) :: err_msg
1403 : integer :: ierr
1404 : integer :: varid
1405 : !
1406 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1407 :
1408 0 : if (ierr /= NF_NOERR) then
1409 : err_msg = 'In Ncrd_7d_R8 #1: ' // Trim (varname) // &
1410 0 : ', ' // Nf_Strerror (ierr)
1411 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1412 : end if
1413 :
1414 0 : ierr = Nf_Get_Vara_Double (ncid, varid, strt7d, cnt7d, varrd_7d)
1415 :
1416 0 : if (ierr /= NF_NOERR) then
1417 0 : err_msg = 'In Ncrd_7d_R8 #2: ' // Nf_Strerror (ierr)
1418 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1419 : end if
1420 :
1421 0 : end subroutine Ncrd_7d_R8
1422 : !EOC
1423 : !-------------------------------------------------------------------------
1424 : !BOP
1425 : !
1426 : ! !IROUTINE: Ncrd_7d_R4
1427 : !
1428 : ! !INTERFACE:
1429 : !
1430 0 : subroutine Ncrd_7d_R4 (varrd_7d, ncid, varname, strt7d, cnt7d)
1431 : !
1432 : ! !USES:
1433 : !
1434 : use m_do_err_out
1435 : !
1436 : implicit none
1437 : !
1438 : include "netcdf.inc"
1439 : !
1440 : ! !INPUT PARAMETERS:
1441 : !! ncid : netCDF file id to read array input data from
1442 : !! varname : netCDF variable name for array
1443 : !! strt7d : vector specifying the index in varrd_7d where
1444 : !! the first of the data values will be read
1445 : !! cnt7d : varrd_7d dimensions
1446 : integer , intent(in) :: ncid
1447 : character (len=*), intent(in) :: varname
1448 : integer , intent(in) :: strt7d(7)
1449 : integer , intent(in) :: cnt7d (7)
1450 : !
1451 : ! !OUTPUT PARAMETERS:
1452 : !! varrd_7d : array to fill
1453 : real*4 , intent(out) :: varrd_7d(cnt7d(1), cnt7d(2), &
1454 : cnt7d(3), cnt7d(4), &
1455 : cnt7d(5), cnt7d(6), &
1456 : cnt7d(7))
1457 : !
1458 : ! !DESCRIPTION: Reads in a 7D netCDF real array and does some error checking.
1459 : !\\
1460 : !\\
1461 : ! !AUTHOR:
1462 : ! John Tannahill (LLNL) and Jules Kouatchou
1463 : !
1464 : ! !REVISION HISTORY:
1465 : ! 20 Dec 2011 - R. Yantosca - Initial version
1466 : ! See https://github.com/geoschem/ncdfutil for complete history
1467 : !EOP
1468 : !-------------------------------------------------------------------------
1469 : !BOC
1470 : !
1471 : ! !LOCAL VARIABLES:
1472 : character (len=512) :: err_msg
1473 : integer :: ierr
1474 : integer :: varid
1475 : !
1476 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1477 :
1478 0 : if (ierr /= NF_NOERR) then
1479 : err_msg = 'In Ncrd_7d_R4 #1: ' // Trim (varname) // &
1480 0 : ', ' // Nf_Strerror (ierr)
1481 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1482 : end if
1483 :
1484 0 : ierr = Nf_Get_Vara_Real (ncid, varid, strt7d, cnt7d, varrd_7d)
1485 :
1486 0 : if (ierr /= NF_NOERR) then
1487 0 : err_msg = 'In Ncrd_7d_R4 #2: ' // Nf_Strerror (ierr)
1488 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1489 : end if
1490 :
1491 0 : end subroutine Ncrd_7d_R4
1492 : !EOC
1493 : !-------------------------------------------------------------------------
1494 : !BOP
1495 : !
1496 : ! !IROUTINE: Ncrd_1d_Char
1497 : !
1498 : ! !INTERFACE:
1499 : !
1500 0 : subroutine Ncrd_1d_Char (varrd_1dc, ncid, varname, strt1d, cnt1d)
1501 : !
1502 : ! !USES:
1503 : !
1504 : use m_do_err_out
1505 : !
1506 : implicit none
1507 : !
1508 : include "netcdf.inc"
1509 : !
1510 : ! !INPUT PARAMETERS:
1511 : !
1512 : !! ncid : netCDF file id to read array input data from
1513 : !! varname : netCDF variable name for array
1514 : !! strt1d : vector specifying the index in varrd_1dc where
1515 : !! the first of the data values will be read
1516 : !! cnt1d : varrd_1dc dimension
1517 : integer , intent(in) :: ncid
1518 : character (len=*), intent(in) :: varname
1519 : integer , intent(in) :: strt1d(1)
1520 : integer , intent(in) :: cnt1d (1)
1521 : !
1522 : ! !OUTPUT PARAMETERS:
1523 : !! varrd_1dc : intger array to fill
1524 : character (len=1), intent(out) :: varrd_1dc(cnt1d(1))
1525 : !
1526 : ! !DESCRIPTION: Reads in a 1D netCDF character array and does some error
1527 : ! checking.
1528 : !\\
1529 : !\\ !AUTHOR:
1530 : ! Jules Kouatchou
1531 : !
1532 : ! !REVISION HISTORY:
1533 : ! See https://github.com/geoschem/ncdfutil for complete history
1534 : !EOP
1535 : !-------------------------------------------------------------------------
1536 : !BOC
1537 : !
1538 : ! !LOCAL VARIABLES:
1539 : character (len=512) :: err_msg
1540 : integer :: ierr
1541 : integer :: varid
1542 : !
1543 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1544 :
1545 0 : if (ierr /= NF_NOERR) then
1546 : err_msg = 'In Ncrd_1d_Char #1: ' // Trim (varname) // &
1547 0 : ', ' // Nf_Strerror (ierr)
1548 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1549 : end if
1550 :
1551 0 : ierr = Nf_Get_Vara_Text (ncid, varid, strt1d, cnt1d, varrd_1dc)
1552 :
1553 0 : if (ierr /= NF_NOERR) then
1554 0 : err_msg = 'In Ncrd_1d_Char #2: ' // Nf_Strerror (ierr)
1555 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1556 : end if
1557 :
1558 0 : end subroutine Ncrd_1d_Char
1559 : !EOC
1560 : !-------------------------------------------------------------------------
1561 : !BOP
1562 : !
1563 : ! !IROUTINE: Ncrd_2d_Char
1564 : !
1565 : ! !INTERFACE:
1566 : !
1567 0 : subroutine Ncrd_2d_Char (varrd_2dc, ncid, varname, strt2d, cnt2d)
1568 : !
1569 : ! !USES:
1570 : !
1571 : use m_do_err_out
1572 : !
1573 : implicit none
1574 : !
1575 : include "netcdf.inc"
1576 : !
1577 : ! !INPUT PARAMETERS:
1578 : !! ncid : netCDF file id to read array input data from
1579 : !! varname : netCDF variable name for array
1580 : !! strt2d : vector specifying the index in varrd_2dc where
1581 : !! the first of the data values will be read
1582 : !! cnt2d : varrd_2dc dimensions
1583 : integer , intent(in) :: ncid
1584 : character (len=*), intent(in) :: varname
1585 : integer , intent(in) :: strt2d(2)
1586 : integer , intent(in) :: cnt2d (2)
1587 : !
1588 : ! !OUTPUT PARAMETERS:
1589 : !! varrd_2dc : charcter array to fill
1590 : character , intent(out) :: varrd_2dc(cnt2d(1), cnt2d(2))
1591 : !
1592 : ! !DESCRIPTION: Reads in a 2D netCDF character array and does some error
1593 : ! checking.
1594 : !\\
1595 : !\\
1596 : ! !AUTHOR:
1597 : ! Jules Kouatchou
1598 : !
1599 : ! !REVISION HISTORY:
1600 : ! See https://github.com/geoschem/ncdfutil for complete history
1601 : !EOP
1602 : !-------------------------------------------------------------------------
1603 : !BOC
1604 : !
1605 : ! !LOCAL VARIABLES:
1606 : character (len=512) :: err_msg
1607 : integer :: ierr
1608 : integer :: varid
1609 : !
1610 0 : ierr = Nf_Inq_Varid (ncid, varname, varid)
1611 :
1612 0 : if (ierr /= NF_NOERR) then
1613 : err_msg = 'In Ncrd_2d_Char #1: ' // Trim (varname) // &
1614 0 : ', ' // Nf_Strerror (ierr)
1615 0 : call Do_Err_Out (err_msg, .true., 1, ncid, 0, 0, 0.0d0, 0.0d0)
1616 : end if
1617 :
1618 0 : ierr = Nf_Get_Vara_Text (ncid, varid, strt2d, cnt2d, varrd_2dc)
1619 :
1620 0 : if (ierr /= NF_NOERR) then
1621 0 : err_msg = 'In Ncrd_2d_Char #2: ' // Nf_Strerror (ierr)
1622 0 : call Do_Err_Out (err_msg, .true., 2, ncid, varid, 0, 0.0d0, 0.0d0)
1623 : end if
1624 :
1625 0 : end subroutine Ncrd_2d_Char
1626 : !EOC
1627 : !------------------------------------------------------------------------
1628 : end module HCO_m_netcdf_io_read
1629 :
|