16 use netcdf,
only : nf90_open, nf90_get_var, nf90_close, nf90_max_name, &
17 nf90_get_att, nf90_inq_varid, nf90_inquire_variable, &
18 nf90_inquire_dimension, nf90_nowrite, &
19 nf90_noerr, nf90_strerror, nf90_inquire_attribute
86 module procedure get_ncvar_0d_sp, get_ncvar_0d_dp, get_ncvar_1d_sp, &
87 get_ncvar_1d_dp, get_ncvar_2d_sp, get_ncvar_2d_dp, &
88 get_ncvar_3d_sp, get_ncvar_3d_dp, get_ncvar_4d_sp, &
89 get_ncvar_4d_dp, get_ncvar_5d_sp, get_ncvar_5d_dp, &
90 get_ncvar_0d_i4, get_ncvar_1d_i4, get_ncvar_2d_i4, &
91 get_ncvar_3d_i4, get_ncvar_4d_i4, get_ncvar_5d_i4, &
92 get_ncvar_0d_i1, get_ncvar_1d_i1, get_ncvar_2d_i1, &
93 get_ncvar_3d_i1, get_ncvar_4d_i1, get_ncvar_5d_i1
127 function get_ncdim(Filename, Variable, PrintInfo, ndims)
131 character(len = *),
intent(in) :: filename
132 character(len = *),
intent(in) :: variable
133 logical,
optional,
intent(in) :: printinfo
134 integer(i4),
optional,
intent(out) :: ndims
140 integer(i4) :: vartype
141 integer(i4) :: numdims
144 call check(nf90_open(filename, nf90_nowrite, ncid))
147 if (
present(printinfo)) printflag = printinfo
152 call get_info(variable, ncid, varid, vartype,
get_ncdim, info = printflag, ndims = numdims)
153 if (
present(ndims)) ndims = numdims
156 call check(nf90_close(ncid))
196 character(len = *),
intent(in) :: filename
197 character(len = *),
intent(in) :: variable
198 character(len = *),
dimension(:),
allocatable, &
199 intent(out) :: dimname
200 integer(i4),
dimension(:),
allocatable, &
201 optional,
intent(out) :: dimlen
207 integer(i4) :: vartype
208 integer(i4) :: numdims
213 call check(nf90_open(filename, nf90_nowrite, ncid))
218 call get_info(variable, ncid, varid, vartype,
get_ncdim, info = .false., ndims = numdims)
220 allocate(dimname(numdims))
221 if (
present(dimlen))
allocate(dimlen(numdims))
223 do dimid = 1, numdims
224 call check(nf90_inquire_dimension(ncid, dimid, dimname(dimid), len))
225 if (
present(dimlen)) dimlen(dimid) = len
228 call check(nf90_close(ncid))
270 subroutine get_ncvaratt(FileName, VarName, AttName, AttValues, fid, dtype)
274 character(len = *),
intent(in) :: filename
275 character(len = *),
intent(in) :: varname
276 character(len = *),
intent(in) :: attname
277 character(len = *),
intent(out) :: attvalues
278 integer(i4),
optional,
intent(in) :: fid
279 integer(i4),
optional,
intent(out) :: dtype
287 character(256) :: avchar
289 if (
present(fid))
then
292 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
296 call check(nf90_inq_varid(ncid, trim(varname), varid))
298 call check(nf90_inquire_attribute(ncid, varid, trim(attname), type))
303 call check(nf90_get_att(ncid, varid, trim(attname), avint))
304 write(attvalues,
'(i4)') avint
305 attvalues = adjustl(trim(attvalues))
306 if (
present(dtype)) dtype =
type
308 call check(nf90_get_att(ncid, varid, trim(attname), avchar))
309 attvalues = adjustl(trim(avchar))
310 if (
present(dtype)) dtype =
type
312 call check(nf90_get_att(ncid, varid, trim(attname), avint))
313 write(attvalues,
'(i6)') avint
314 attvalues = adjustl(trim(attvalues))
315 if (
present(dtype)) dtype =
type
317 call check(nf90_get_att(ncid, varid, trim(attname), avint))
318 write(attvalues,
'(i11)') avint
319 attvalues = adjustl(trim(attvalues))
320 if (
present(dtype)) dtype =
type
322 call check(nf90_get_att(ncid, varid, trim(attname), avfloat))
323 write(attvalues,
'(E15.7)') avfloat
324 attvalues = adjustl(trim(attvalues))
325 if (
present(dtype)) dtype =
type
327 call check(nf90_get_att(ncid, varid, trim(attname), avfloat))
328 write(attvalues,
'(E24.15)') avfloat
329 attvalues = adjustl(trim(attvalues))
330 if (
present(dtype)) dtype =
type
332 print*,
'***ERROR: mo_ncread: Mismatch in attribute datatype!'
335 if (.not.
present(fid))
call check(nf90_close(ncid))
341 subroutine get_ncvar_0d_sp(Filename, VarName, Dat, fid)
345 integer,
parameter :: itype = 5
347 character(len = *),
intent(in) :: filename
348 character(len = *),
intent(in) :: varname
349 real(
sp),
intent(inout) :: dat
350 integer(i4),
optional,
intent(in) :: fid
354 integer(i4) :: vartype
357 if (
present(fid))
then
360 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
364 call get_info(varname, ncid, varid, vartype)
366 if (vartype /= itype)
then
367 print *,
'Variable name: ', trim(varname)
368 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
373 call check(nf90_get_var(ncid, varid, dat))
376 if (.not.
present(fid))
call check(nf90_close(ncid))
378 end subroutine get_ncvar_0d_sp
380 subroutine get_ncvar_0d_dp(Filename, VarName, Dat, fid)
384 integer,
parameter :: itype = 6
386 character(len = *),
intent(in) :: filename
387 character(len = *),
intent(in) :: varname
388 real(
dp),
intent(inout) :: dat
389 integer(i4),
optional,
intent(in) :: fid
393 integer(i4) :: vartype
396 if (
present(fid))
then
399 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
403 call get_info(varname, ncid, varid, vartype)
405 if (vartype /= itype)
then
406 print *,
'Variable name: ', trim(varname)
407 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
412 call check(nf90_get_var(ncid, varid, dat))
415 if (.not.
present(fid))
call check(nf90_close(ncid))
417 end subroutine get_ncvar_0d_dp
419 subroutine get_ncvar_1d_sp(Filename, VarName, Dat, start, a_count, fid)
423 integer,
parameter :: idims = 1
424 integer,
parameter :: itype = 5
426 character(len = *),
intent(in) :: filename
427 character(len = *),
intent(in) :: varname
428 real(
sp),
dimension(:),
allocatable,
intent(inout) :: dat
429 integer(i4),
dimension(:),
optional,
intent(in) :: start
430 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
431 integer(i4),
optional,
intent(in) :: fid
433 integer(i4),
dimension(5) :: rstart
434 integer(i4),
dimension(5) :: rcount
437 integer(i4) :: vartype
445 if (.not.
allocated(dat))
then
446 if (.not.
present(a_count))
then
449 rcount(1 : idims) = a_count(1 : idims)
451 allocate(dat(rcount(1)))
453 rcount(1 : idims) = shape(dat)
457 if (
present(start))
then
458 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
459 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
460 rstart(1 :
size(start)) = start
463 if (
present(a_count))
then
464 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** count has less values than data has dimensions. GetNcVar'
465 if (
size(a_count) > 5) stop
'ERROR*** count has dimension greater than 5. GetNcVar'
466 rcount(1 :
size(a_count)) = a_count
468 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
473 if (
present(fid))
then
476 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
480 call get_info(varname, ncid, varid, vartype)
482 if (vartype /= itype)
then
483 print *,
'Variable name: ', trim(varname)
484 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
489 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
492 if (.not.
present(fid))
call check(nf90_close(ncid))
494 end subroutine get_ncvar_1d_sp
497 subroutine get_ncvar_1d_dp(Filename, VarName, Dat, start, a_count, fid)
501 integer,
parameter :: idims = 1
502 integer,
parameter :: itype = 6
504 character(len = *),
intent(in) :: filename
505 character(len = *),
intent(in) :: varname
506 real(
dp),
dimension(:),
allocatable,
intent(inout) :: dat
507 integer(i4),
dimension(:),
optional,
intent(in) :: start
508 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
509 integer(i4),
optional,
intent(in) :: fid
511 integer(i4),
dimension(5) :: rstart
512 integer(i4),
dimension(5) :: rcount
515 integer(i4) :: vartype
523 if (.not.
allocated(dat))
then
524 if (.not.
present(a_count))
then
527 rcount(1 : idims) = a_count(1 : idims)
529 allocate(dat(rcount(1)))
531 rcount(1 : idims) = shape(dat)
535 if (
present(start))
then
536 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
537 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
538 rstart(1 :
size(start)) = start
541 if (
present(a_count))
then
542 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** count has less values than data has dimensions. GetNcVar'
543 if (
size(a_count) > 5) stop
'ERROR*** count has dimension greater than 5. GetNcVar'
544 rcount(1 :
size(a_count)) = a_count
546 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
551 if (
present(fid))
then
554 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
558 call get_info(varname, ncid, varid, vartype)
560 if (vartype /= itype)
then
561 print *,
'Variable name: ', trim(varname)
562 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
567 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
570 if (.not.
present(fid))
call check(nf90_close(ncid))
572 end subroutine get_ncvar_1d_dp
575 subroutine get_ncvar_2d_sp(Filename, VarName, Dat, start, a_count, fid)
579 integer,
parameter :: idims = 2
580 integer,
parameter :: itype = 5
582 character(len = *),
intent(in) :: filename
583 character(len = *),
intent(in) :: varname
585 real(
sp),
dimension(:, :),
allocatable,
intent(inout) :: dat
586 integer(i4),
dimension(:),
optional,
intent(in) :: start
587 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
588 integer(i4),
optional,
intent(in) :: fid
590 integer(i4),
dimension(5) :: rstart
591 integer(i4),
dimension(5) :: rcount
594 integer(i4) :: vartype
602 if (.not.
allocated(dat))
then
603 if (.not.
present(a_count))
then
606 rcount(1 : idims) = a_count(1 : idims)
608 allocate(dat(rcount(1), rcount(2)))
610 rcount(1 : idims) = shape(dat)
614 if (
present(start))
then
615 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
616 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
617 rstart(1 :
size(start)) = start
620 if (
present(a_count))
then
621 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
622 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
623 rcount(1 :
size(a_count)) = a_count
625 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
630 if (
present(fid))
then
633 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
637 call get_info(varname, ncid, varid, vartype)
639 if (vartype /= itype)
then
640 print *,
'Variable name: ', trim(varname)
641 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
646 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
649 if (.not.
present(fid))
call check(nf90_close(ncid))
651 end subroutine get_ncvar_2d_sp
654 subroutine get_ncvar_2d_dp(Filename, VarName, Dat, start, a_count, fid)
658 integer,
parameter :: idims = 2
659 integer,
parameter :: itype = 6
661 character(len = *),
intent(in) :: filename
662 character(len = *),
intent(in) :: varname
663 real(
dp),
dimension(:, :),
allocatable,
intent(inout) :: dat
664 integer(i4),
dimension(:),
optional,
intent(in) :: start
665 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
666 integer(i4),
optional,
intent(in) :: fid
668 integer(i4),
dimension(5) :: rstart
669 integer(i4),
dimension(5) :: rcount
672 integer(i4) :: vartype
680 if (.not.
allocated(dat))
then
681 if (.not.
present(a_count))
then
684 rcount(1 : idims) = a_count(1 : idims)
686 allocate(dat(rcount(1), rcount(2)))
688 rcount(1 : idims) = shape(dat)
692 if (
present(start))
then
693 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
694 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
695 rstart(1 :
size(start)) = start
698 if (
present(a_count))
then
699 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
700 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
701 rcount(1 :
size(a_count)) = a_count
703 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
708 if (
present(fid))
then
711 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
715 call get_info(varname, ncid, varid, vartype)
717 if (vartype /= itype)
then
718 print *,
'Variable name: ', trim(varname)
719 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
724 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
727 if (.not.
present(fid))
call check(nf90_close(ncid))
729 end subroutine get_ncvar_2d_dp
732 subroutine get_ncvar_3d_sp(Filename, VarName, Dat, start, a_count, fid)
736 integer,
parameter :: idims = 3
737 integer,
parameter :: itype = 5
739 character(len = *),
intent(in) :: filename
740 character(len = *),
intent(in) :: varname
741 real(
sp),
dimension(:, :, :),
allocatable,
intent(inout) :: dat
742 integer(i4),
dimension(:),
optional,
intent(in) :: start
743 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
744 integer(i4),
optional,
intent(in) :: fid
746 integer(i4),
dimension(5) :: rstart
747 integer(i4),
dimension(5) :: rcount
750 integer(i4) :: vartype
759 if (.not.
allocated(dat))
then
760 if (.not.
present(a_count))
then
763 rcount(1 : idims) = a_count(1 : idims)
765 allocate(dat(rcount(1), rcount(2), rcount(3)))
767 rcount(1 : idims) = shape(dat)
771 if (
present(start))
then
772 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
773 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
774 rstart(1 :
size(start)) = start
777 if (
present(a_count))
then
778 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
779 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
780 rcount(1 :
size(a_count)) = a_count
782 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
788 if (
present(fid))
then
791 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
795 call get_info(varname, ncid, varid, vartype)
797 if (vartype /= itype)
then
798 print *,
'Variable name: ', trim(varname)
799 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
804 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
807 if (.not.
present(fid))
call check(nf90_close(ncid))
809 end subroutine get_ncvar_3d_sp
812 subroutine get_ncvar_3d_dp(Filename, VarName, Dat, start, a_count, fid)
816 integer,
parameter :: idims = 3
817 integer,
parameter :: itype = 6
819 character(len = *),
intent(in) :: filename
820 character(len = *),
intent(in) :: varname
821 real(
dp),
dimension(:, :, :),
allocatable,
intent(inout) :: dat
822 integer(i4),
dimension(:),
optional,
intent(in) :: start
823 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
824 integer(i4),
optional,
intent(in) :: fid
826 integer(i4),
dimension(5) :: rstart
827 integer(i4),
dimension(5) :: rcount
830 integer(i4) :: vartype
838 if (.not.
allocated(dat))
then
839 if (.not.
present(a_count))
then
842 rcount(1 : idims) = a_count(1 : idims)
844 allocate(dat(rcount(1), rcount(2), rcount(3)))
846 rcount(1 : idims) = shape(dat)
850 if (
present(start))
then
851 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
852 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
853 rstart(1 :
size(start)) = start
856 if (
present(a_count))
then
857 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
858 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
859 rcount(1 :
size(a_count)) = a_count
861 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
866 if (
present(fid))
then
869 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
873 call get_info(varname, ncid, varid, vartype)
875 if (vartype /= itype)
then
876 print *,
'Variable name: ', trim(varname)
877 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
882 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
885 if (.not.
present(fid))
call check(nf90_close(ncid))
887 end subroutine get_ncvar_3d_dp
890 subroutine get_ncvar_4d_sp(Filename, VarName, Dat, start, a_count, fid)
894 integer,
parameter :: idims = 4
895 integer,
parameter :: itype = 5
897 character(len = *),
intent(in) :: filename
898 character(len = *),
intent(in) :: varname
899 real(
sp),
dimension(:, :, :, :),
allocatable,
intent(inout) :: dat
900 integer(i4),
dimension(:),
optional,
intent(in) :: start
901 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
902 integer(i4),
optional,
intent(in) :: fid
904 integer(i4),
dimension(5) :: rstart
905 integer(i4),
dimension(5) :: rcount
908 integer(i4) :: vartype
916 if (.not.
allocated(dat))
then
917 if (.not.
present(a_count))
then
920 rcount(1 : idims) = a_count(1 : idims)
922 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4)))
924 rcount(1 : idims) = shape(dat)
928 if (
present(start))
then
929 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
930 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
931 rstart(1 :
size(start)) = start
934 if (
present(a_count))
then
935 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
936 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
937 rcount(1 :
size(a_count)) = a_count
939 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
944 if (
present(fid))
then
947 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
951 call get_info(varname, ncid, varid, vartype)
953 if (vartype /= itype)
then
954 print *,
'Variable name: ', trim(varname)
955 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
960 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
963 if (.not.
present(fid))
call check(nf90_close(ncid))
965 end subroutine get_ncvar_4d_sp
968 subroutine get_ncvar_4d_dp(Filename, VarName, Dat, start, a_count, fid)
972 integer,
parameter :: idims = 4
973 integer,
parameter :: itype = 6
975 character(len = *),
intent(in) :: filename
976 character(len = *),
intent(in) :: varname
977 real(
dp),
dimension(:, :, :, :),
allocatable,
intent(inout) :: dat
978 integer(i4),
dimension(:),
optional,
intent(in) :: start
979 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
980 integer(i4),
optional,
intent(in) :: fid
982 integer(i4),
dimension(5) :: rstart
983 integer(i4),
dimension(5) :: rcount
986 integer(i4) :: vartype
994 if (.not.
allocated(dat))
then
995 if (.not.
present(a_count))
then
998 rcount(1 : idims) = a_count(1 : idims)
1000 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4)))
1002 rcount(1 : idims) = shape(dat)
1006 if (
present(start))
then
1007 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
1008 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
1009 rstart(1 :
size(start)) = start
1012 if (
present(a_count))
then
1013 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
1014 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
1015 rcount(1 :
size(a_count)) = a_count
1017 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
1022 if (
present(fid))
then
1025 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1029 call get_info(varname, ncid, varid, vartype)
1031 if (vartype /= itype)
then
1032 print *,
'Variable name: ', trim(varname)
1033 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1038 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1041 if (.not.
present(fid))
call check(nf90_close(ncid))
1043 end subroutine get_ncvar_4d_dp
1046 subroutine get_ncvar_5d_sp(Filename, VarName, Dat, start, a_count, fid)
1050 integer,
parameter :: idims = 5
1051 integer,
parameter :: itype = 5
1053 character(len = *),
intent(in) :: filename
1054 character(len = *),
intent(in) :: varname
1055 real(
sp),
dimension(:, :, :, :, :),
allocatable,
intent(inout) :: dat
1056 integer(i4),
dimension(:),
optional,
intent(in) :: start
1057 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1058 integer(i4),
optional,
intent(in) :: fid
1060 integer(i4),
dimension(5) :: rstart
1061 integer(i4),
dimension(5) :: rcount
1063 integer(i4) :: varid
1064 integer(i4) :: vartype
1072 if (.not.
allocated(dat))
then
1073 if (.not.
present(a_count))
then
1076 rcount(1 : idims) = a_count(1 : idims)
1078 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4), rcount(5)))
1080 rcount(1 : idims) = shape(dat)
1084 if (
present(start))
then
1085 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
1086 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
1087 rstart(1 :
size(start)) = start
1090 if (
present(a_count))
then
1091 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
1092 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
1093 rcount(1 :
size(a_count)) = a_count
1095 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
1100 if (
present(fid))
then
1103 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1107 call get_info(varname, ncid, varid, vartype)
1109 if (vartype /= itype)
then
1110 print *,
'Variable name: ', trim(varname)
1111 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1116 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1119 if (.not.
present(fid))
call check(nf90_close(ncid))
1121 end subroutine get_ncvar_5d_sp
1124 subroutine get_ncvar_5d_dp(Filename, VarName, Dat, start, a_count, fid)
1128 integer,
parameter :: idims = 5
1129 integer,
parameter :: itype = 6
1131 character(len = *),
intent(in) :: filename
1132 character(len = *),
intent(in) :: varname
1133 real(
dp),
dimension(:, :, :, :, :),
allocatable,
intent(inout) :: dat
1134 integer(i4),
dimension(:),
optional,
intent(in) :: start
1135 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1136 integer(i4),
optional,
intent(in) :: fid
1138 integer(i4),
dimension(5) :: rstart
1139 integer(i4),
dimension(5) :: rcount
1141 integer(i4) :: varid
1142 integer(i4) :: vartype
1150 if (.not.
allocated(dat))
then
1151 if (.not.
present(a_count))
then
1154 rcount(1 : idims) = a_count(1 : idims)
1156 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4), rcount(5)))
1158 rcount(1 : idims) = shape(dat)
1162 if (
present(start))
then
1163 if (
size(start) <
size(shape(dat))) stop
'ERROR*** start has less values than data has dimensions. GetNcVar'
1164 if (
size(start) > 5) stop
'ERROR*** start has dimension greater than 5. GetNcVar'
1165 rstart(1 :
size(start)) = start
1168 if (
present(a_count))
then
1169 if (
size(a_count) <
size(shape(dat))) stop
'ERROR*** a_count has less values than data has dimensions. GetNcVar'
1170 if (
size(a_count) > 5) stop
'ERROR*** a_count has dimension greater than 5. GetNcVar'
1171 rcount(1 :
size(a_count)) = a_count
1173 if (
size(dat, i) < rcount(i)) stop
'ERROR*** try to read more data in dimension than there is. Get_NcVar'
1178 if (
present(fid))
then
1181 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1185 call get_info(varname, ncid, varid, vartype)
1187 if (vartype /= itype)
then
1188 print *,
'Variable name: ', trim(varname)
1189 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1194 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1197 if (.not.
present(fid))
call check(nf90_close(ncid))
1199 end subroutine get_ncvar_5d_dp
1202 subroutine get_ncvar_0d_i4(Filename, VarName, Dat, fid)
1206 integer,
parameter :: itype = 4
1208 character(len = *),
intent(in) :: filename
1209 character(len = *),
intent(in) :: varname
1210 integer(i4),
intent(inout) :: dat
1211 integer(i4),
optional,
intent(in) :: fid
1214 integer(i4) :: varid
1215 integer(i4) :: vartype
1218 if (
present(fid))
then
1221 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1225 call get_info(varname, ncid, varid, vartype)
1227 if (vartype /= itype)
then
1228 print *,
'Variable name: ', trim(varname)
1229 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1234 call check(nf90_get_var(ncid, varid, dat))
1237 if (.not.
present(fid))
call check(nf90_close(ncid))
1239 end subroutine get_ncvar_0d_i4
1242 subroutine get_ncvar_1d_i4(Filename, VarName, Dat, start, a_count, fid)
1246 integer,
parameter :: idims = 1
1247 integer,
parameter :: itype = 4
1249 character(len = *),
intent(in) :: filename
1250 character(len = *),
intent(in) :: varname
1251 integer(i4),
dimension(:),
allocatable,
intent(inout) :: dat
1252 integer(i4),
dimension(:),
optional,
intent(in) :: start
1253 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1254 integer(i4),
optional,
intent(in) :: fid
1256 integer(i4),
dimension(5) :: rstart
1257 integer(i4),
dimension(5) :: rcount
1259 integer(i4) :: varid
1260 integer(i4) :: vartype
1268 if (.not.
allocated(dat))
then
1269 if (.not.
present(a_count))
then
1272 rcount(1 : idims) = a_count(1 : idims)
1274 allocate(dat(rcount(1)))
1276 rcount(1 : idims) = shape(dat)
1280 if (
present(start))
then
1281 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1285 if (
present(a_count))
then
1286 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1289 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1294 if (
present(fid))
then
1297 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1301 call get_info(varname, ncid, varid, vartype)
1303 if (vartype /= itype)
then
1304 print *,
'Variable name: ', trim(varname)
1305 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1310 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1313 if (.not.
present(fid))
call check(nf90_close(ncid))
1315 end subroutine get_ncvar_1d_i4
1318 subroutine get_ncvar_2d_i4(Filename, VarName, Dat, start, a_count, fid)
1322 integer,
parameter :: idims = 2
1323 integer,
parameter :: itype = 4
1325 character(len = *),
intent(in) :: filename
1326 character(len = *),
intent(in) :: varname
1327 integer(i4),
dimension(:, :),
allocatable,
intent(inout) :: dat
1328 integer(i4),
dimension(:),
optional,
intent(in) :: start
1329 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1330 integer(i4),
optional,
intent(in) :: fid
1332 integer(i4),
dimension(5) :: rstart
1333 integer(i4),
dimension(5) :: rcount
1335 integer(i4) :: varid
1336 integer(i4) :: vartype
1344 if (.not.
allocated(dat))
then
1345 if (.not.
present(a_count))
then
1348 rcount(1 : idims) = a_count(1 : idims)
1350 allocate(dat(rcount(1), rcount(2)))
1352 rcount(1 : idims) = shape(dat)
1356 if (
present(start))
then
1357 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1361 if (
present(a_count))
then
1362 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1365 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1370 if (
present(fid))
then
1373 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1377 call get_info(varname, ncid, varid, vartype)
1379 if (vartype /= itype)
then
1380 print *,
'Variable name: ', trim(varname)
1381 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1386 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1389 if (.not.
present(fid))
call check(nf90_close(ncid))
1391 end subroutine get_ncvar_2d_i4
1394 subroutine get_ncvar_3d_i4(Filename, VarName, Dat, start, a_count, fid)
1398 integer,
parameter :: idims = 3
1399 integer,
parameter :: itype = 4
1401 character(len = *),
intent(in) :: filename
1402 character(len = *),
intent(in) :: varname
1403 integer(i4),
dimension(:, :, :),
allocatable,
intent(inout) :: dat
1404 integer(i4),
dimension(:),
optional,
intent(in) :: start
1405 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1406 integer(i4),
optional,
intent(in) :: fid
1408 integer(i4),
dimension(5) :: rstart
1409 integer(i4),
dimension(5) :: rcount
1411 integer(i4) :: varid
1412 integer(i4) :: vartype
1420 if (.not.
allocated(dat))
then
1421 if (.not.
present(a_count))
then
1424 rcount(1 : idims) = a_count(1 : idims)
1426 allocate(dat(rcount(1), rcount(2), rcount(3)))
1428 rcount(1 : idims) = shape(dat)
1432 if (
present(start))
then
1433 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1437 if (
present(a_count))
then
1438 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1441 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1446 if (
present(fid))
then
1449 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1453 call get_info(varname, ncid, varid, vartype)
1455 if (vartype /= itype)
then
1456 print *,
'Variable name: ', trim(varname)
1457 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1462 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1465 if (.not.
present(fid))
call check(nf90_close(ncid))
1467 end subroutine get_ncvar_3d_i4
1470 subroutine get_ncvar_4d_i4(Filename, VarName, Dat, start, a_count, fid)
1474 integer,
parameter :: idims = 4
1475 integer,
parameter :: itype = 4
1477 character(len = *),
intent(in) :: filename
1478 character(len = *),
intent(in) :: varname
1479 integer(i4),
dimension(:, :, :, :),
allocatable,
intent(inout) :: dat
1480 integer(i4),
dimension(:),
optional,
intent(in) :: start
1481 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1482 integer(i4),
optional,
intent(in) :: fid
1484 integer(i4),
dimension(5) :: rstart
1485 integer(i4),
dimension(5) :: rcount
1487 integer(i4) :: varid
1488 integer(i4) :: vartype
1496 if (.not.
allocated(dat))
then
1497 if (.not.
present(a_count))
then
1500 rcount(1 : idims) = a_count(1 : idims)
1502 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4)))
1504 rcount(1 : idims) = shape(dat)
1508 if (
present(start))
then
1509 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1513 if (
present(a_count))
then
1514 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1517 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1522 if (
present(fid))
then
1525 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1529 call get_info(varname, ncid, varid, vartype)
1531 if (vartype /= itype)
then
1532 print *,
'Variable name: ', trim(varname)
1533 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1538 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1541 if (.not.
present(fid))
call check(nf90_close(ncid))
1543 end subroutine get_ncvar_4d_i4
1546 subroutine get_ncvar_5d_i4(Filename, VarName, Dat, start, a_count, fid)
1550 integer,
parameter :: idims = 5
1551 integer,
parameter :: itype = 4
1553 character(len = *),
intent(in) :: filename
1554 character(len = *),
intent(in) :: varname
1555 integer(i4),
dimension(:, :, :, :, :),
allocatable,
intent(inout) :: dat
1556 integer(i4),
dimension(:),
optional,
intent(in) :: start
1557 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1558 integer(i4),
optional,
intent(in) :: fid
1560 integer(i4),
dimension(5) :: rstart
1561 integer(i4),
dimension(5) :: rcount
1563 integer(i4) :: varid
1564 integer(i4) :: vartype
1572 if (.not.
allocated(dat))
then
1573 if (.not.
present(a_count))
then
1576 rcount(1 : idims) = a_count(1 : idims)
1578 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4), rcount(5)))
1580 rcount(1 : idims) = shape(dat)
1584 if (
present(start))
then
1585 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1589 if (
present(a_count))
then
1590 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1593 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1598 if (
present(fid))
then
1601 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1605 call get_info(varname, ncid, varid, vartype)
1607 if (vartype /= itype)
then
1608 print *,
'Variable name: ', trim(varname)
1609 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1614 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1617 if (.not.
present(fid))
call check(nf90_close(ncid))
1619 end subroutine get_ncvar_5d_i4
1621 subroutine get_ncvar_0d_i1(Filename, VarName, Dat, fid)
1625 integer,
parameter :: itype = 1
1627 character(len = *),
intent(in) :: filename
1628 character(len = *),
intent(in) :: varname
1629 integer(1),
intent(inout) :: dat
1630 integer(i4),
optional,
intent(in) :: fid
1633 integer(i4) :: varid
1634 integer(i4) :: vartype
1637 if (
present(fid))
then
1640 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1644 call get_info(varname, ncid, varid, vartype)
1646 if (vartype /= itype)
then
1647 print *,
'Variable name: ', trim(varname)
1648 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1653 call check(nf90_get_var(ncid, varid, dat))
1656 if (.not.
present(fid))
call check(nf90_close(ncid))
1658 end subroutine get_ncvar_0d_i1
1661 subroutine get_ncvar_1d_i1(Filename, VarName, Dat, start, a_count, fid)
1665 integer,
parameter :: idims = 1
1666 integer,
parameter :: itype = 1
1668 character(len = *),
intent(in) :: filename
1669 character(len = *),
intent(in) :: varname
1670 integer(1),
dimension(:),
allocatable,
intent(inout) :: dat
1671 integer(i4),
dimension(:),
optional,
intent(in) :: start
1672 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1673 integer(i4),
optional,
intent(in) :: fid
1675 integer(i4),
dimension(5) :: rstart
1676 integer(i4),
dimension(5) :: rcount
1678 integer(i4) :: varid
1679 integer(i4) :: vartype
1687 if (.not.
allocated(dat))
then
1688 if (.not.
present(a_count))
then
1691 rcount(1 : idims) = a_count(1 : idims)
1693 allocate(dat(rcount(1)))
1695 rcount(1 : idims) = shape(dat)
1699 if (
present(start))
then
1700 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1704 if (
present(a_count))
then
1705 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1708 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1713 if (
present(fid))
then
1716 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1720 call get_info(varname, ncid, varid, vartype)
1722 if (vartype /= itype)
then
1723 print *,
'Variable name: ', trim(varname)
1724 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1729 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1732 if (.not.
present(fid))
call check(nf90_close(ncid))
1734 end subroutine get_ncvar_1d_i1
1737 subroutine get_ncvar_2d_i1(Filename, VarName, Dat, start, a_count, fid)
1741 integer,
parameter :: idims = 2
1742 integer,
parameter :: itype = 1
1744 character(len = *),
intent(in) :: filename
1745 character(len = *),
intent(in) :: varname
1746 integer(1),
dimension(:, :),
allocatable,
intent(inout) :: dat
1747 integer(i4),
dimension(:),
optional,
intent(in) :: start
1748 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1749 integer(i4),
optional,
intent(in) :: fid
1751 integer(i4),
dimension(5) :: rstart
1752 integer(i4),
dimension(5) :: rcount
1754 integer(i4) :: varid
1755 integer(i4) :: vartype
1763 if (.not.
allocated(dat))
then
1764 if (.not.
present(a_count))
then
1767 rcount(1 : idims) = a_count(1 : idims)
1769 allocate(dat(rcount(1), rcount(2)))
1771 rcount(1 : idims) = shape(dat)
1775 if (
present(start))
then
1776 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1780 if (
present(a_count))
then
1781 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1784 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1789 if (
present(fid))
then
1792 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1796 call get_info(varname, ncid, varid, vartype)
1798 if (vartype /= itype)
then
1799 print *,
'Variable name: ', trim(varname)
1800 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1805 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1808 if (.not.
present(fid))
call check(nf90_close(ncid))
1810 end subroutine get_ncvar_2d_i1
1813 subroutine get_ncvar_3d_i1(Filename, VarName, Dat, start, a_count, fid)
1817 integer,
parameter :: idims = 3
1818 integer,
parameter :: itype = 1
1820 character(len = *),
intent(in) :: filename
1821 character(len = *),
intent(in) :: varname
1822 integer(1),
dimension(:, :, :),
allocatable,
intent(inout) :: dat
1823 integer(i4),
dimension(:),
optional,
intent(in) :: start
1824 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1825 integer(i4),
optional,
intent(in) :: fid
1827 integer(i4),
dimension(5) :: rstart
1828 integer(i4),
dimension(5) :: rcount
1830 integer(i4) :: varid
1831 integer(i4) :: vartype
1839 if (.not.
allocated(dat))
then
1840 if (.not.
present(a_count))
then
1843 rcount(1 : idims) = a_count(1 : idims)
1845 allocate(dat(rcount(1), rcount(2), rcount(3)))
1847 rcount(1 : idims) = shape(dat)
1851 if (
present(start))
then
1852 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1856 if (
present(a_count))
then
1857 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1860 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1865 if (
present(fid))
then
1868 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1872 call get_info(varname, ncid, varid, vartype)
1874 if (vartype /= itype)
then
1875 print *,
'Variable name: ', trim(varname)
1876 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1881 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1884 if (.not.
present(fid))
call check(nf90_close(ncid))
1886 end subroutine get_ncvar_3d_i1
1889 subroutine get_ncvar_4d_i1(Filename, VarName, Dat, start, a_count, fid)
1893 integer,
parameter :: idims = 4
1894 integer,
parameter :: itype = 1
1896 character(len = *),
intent(in) :: filename
1897 character(len = *),
intent(in) :: varname
1898 integer(1),
dimension(:, :, :, :),
allocatable,
intent(inout) :: dat
1899 integer(i4),
dimension(:),
optional,
intent(in) :: start
1900 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1901 integer(i4),
optional,
intent(in) :: fid
1903 integer(i4),
dimension(5) :: rstart
1904 integer(i4),
dimension(5) :: rcount
1906 integer(i4) :: varid
1907 integer(i4) :: vartype
1915 if (.not.
allocated(dat))
then
1916 if (.not.
present(a_count))
then
1919 rcount(1 : idims) = a_count(1 : idims)
1921 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4)))
1923 rcount(1 : idims) = shape(dat)
1927 if (
present(start))
then
1928 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
1932 if (
present(a_count))
then
1933 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
1936 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
1941 if (
present(fid))
then
1944 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
1948 call get_info(varname, ncid, varid, vartype)
1950 if (vartype /= itype)
then
1951 print *,
'Variable name: ', trim(varname)
1952 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
1957 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
1960 if (.not.
present(fid))
call check(nf90_close(ncid))
1962 end subroutine get_ncvar_4d_i1
1965 subroutine get_ncvar_5d_i1(Filename, VarName, Dat, start, a_count, fid)
1969 integer,
parameter :: idims = 5
1970 integer,
parameter :: itype = 1
1972 character(len = *),
intent(in) :: filename
1973 character(len = *),
intent(in) :: varname
1974 integer(1),
dimension(:, :, :, :, :),
allocatable,
intent(inout) :: dat
1975 integer(i4),
dimension(:),
optional,
intent(in) :: start
1976 integer(i4),
dimension(:),
optional,
intent(in) :: a_count
1977 integer(i4),
optional,
intent(in) :: fid
1979 integer(i4),
dimension(5) :: rstart
1980 integer(i4),
dimension(5) :: rcount
1982 integer(i4) :: varid
1983 integer(i4) :: vartype
1991 if (.not.
allocated(dat))
then
1992 if (.not.
present(a_count))
then
1995 rcount(1 : idims) = a_count(1 : idims)
1997 allocate(dat(rcount(1), rcount(2), rcount(3), rcount(4), rcount(5)))
1999 rcount(1 : idims) = shape(dat)
2003 if (
present(start))
then
2004 if (
size(start) /= idims) stop
'ERROR*** size of start does not equal dimensions of data. GetNcVar'
2008 if (
present(a_count))
then
2009 if (
size(a_count) /= idims) stop
'ERROR*** size of a_count does not equal dimensions of data. GetNcVar'
2012 if (
size(dat, i) /= rcount(i)) stop
'ERROR*** size mismatch. Get_NcVar'
2017 if (
present(fid))
then
2020 call check(nf90_open(trim(filename), nf90_nowrite, ncid))
2024 call get_info(varname, ncid, varid, vartype)
2026 if (vartype /= itype)
then
2027 print *,
'Variable name: ', trim(varname)
2028 print *,
'ERROR*** type of variable does not match argument type. subroutine Get_NcVar'
2033 call check(nf90_get_var(ncid, varid, dat, rstart, rcount))
2036 if (.not.
present(fid))
call check(nf90_close(ncid))
2038 end subroutine get_ncvar_5d_i1
2065 character(len = *),
intent(in) :: fname
2068 call check(nf90_open(trim(fname), nf90_nowrite,
ncopen))
2097 integer(i4),
intent(in) :: ncid
2099 call check(nf90_close(ncid))
2119 subroutine get_info(Varname, ncid, varid, xtype, dl, Info, ndims)
2123 character(len = *),
intent(in) :: Varname
2124 integer(i4),
intent(in) :: ncid
2125 integer(i4),
intent(out) :: varid
2126 integer(i4),
intent(out) :: xtype
2127 integer(i4),
dimension(:),
optional,
intent(inout) :: dl
2128 logical,
optional,
intent(in) :: Info
2129 integer(i4),
optional,
intent(out) :: ndims
2131 integer(i4),
dimension(:),
allocatable :: DimID
2132 character(NF90_MAX_NAME) :: name
2133 integer(i4) :: NumDims
2135 character(256) :: form
2138 call check(nf90_inq_varid(ncid, varname, varid))
2139 call check(nf90_inquire_variable(ncid, varid, ndims = numdims))
2140 if (
present(ndims)) ndims = numdims
2143 allocate(dimid(numdims))
2144 call check(nf90_inquire_variable(ncid, varid, xtype = xtype, dimids = dimid))
2146 if (
present(dl))
then
2148 if (numdims >
size(dl)) &
2149 stop
'ERROR*** Dimension size of Variable is greater than dims of array. subroutine Get_Info'
2152 dimloop :
do n = 1, numdims
2153 call check(nf90_inquire_dimension(ncid, dimid(n), name, itmp))
2155 if (
present(info))
then
2157 write(form,
'(a12,I03.3,a1)')
"(a10,i1,a4,a", len(trim(name)),
")"
2158 write(*, form)
'Dimension ', n,
' is ', trim(name)
2159 write(*,
'(a14,i5.5)')
'The Length is ', dl(n)
2170 subroutine check(status)
2174 integer(i4),
intent(in) :: status
2176 if (status /= nf90_noerr)
then
2177 write(*, *) trim(nf90_strerror(status))
2181 end subroutine check
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 dp
Double Precision Real Kind.
subroutine, public get_ncvaratt(filename, varname, attname, attvalues, fid, dtype)
Get attribute of netcdf variable.
subroutine, public get_ncdimatt(filename, variable, dimname, dimlen)
Name and size of variable in netcdf.
integer(i4) function, public ncopen(fname)
Open netcdf file.
subroutine get_info(varname, ncid, varid, xtype, dl, info, ndims)
Get variable info from netcdf files.
subroutine, public ncclose(ncid)
Closes netcdf file.
integer(i4) function, dimension(5), public get_ncdim(filename, variable, printinfo, ndims)
Dimension of netcdf variable.