11
12
13
14
15
16
17
18
22 use netcdf, only: nf90_max_name, nf90_noerr, nf90_einval, nf90_enotvar, &
23 & nf90_inquire_dimension, nf90_inq_varid
25 implicit none
26 type(GD_NC_VARIABLE), intent(out):: var
27 type(GD_NC_VARIABLE), intent(in):: src_var
28 integer, intent(in):: dimord
29 logical, intent(out), optional:: err
30 type(GD_NC_VARIABLE_ENTRY):: src_ent
31 type(GD_NC_VARIABLE_SEARCH):: ent
32 character(len = NF90_MAX_NAME):: dimname
33 integer:: stat
34continue
36 if (stat /= nf90_noerr) goto 999
37
38 if (dimord <= 0) then
39
40
41
42
43
44 var = src_var
45 stat = nf90_einval
46 goto 999
47 endif
48 if (.not. associated(src_ent%dimids)) then
50 goto 999
51 else if (dimord > size(src_ent%dimids)) then
53 goto 999
54 endif
55
56
57
58 ent%fileid = src_ent%fileid
59 ent%dimid = src_ent%dimids(dimord)
60 stat = nf90_inquire_dimension(ent%fileid, ent%dimid, name = dimname)
61 if (stat /= nf90_noerr) goto 999
62 stat = nf90_inq_varid(ent%fileid, dimname, ent%varid)
63 if (stat == nf90_enotvar) then
64
65 ent%varid = 0
66 stat = nf90_noerr
67 else if (stat /= nf90_noerr) then
68 goto 999
69 endif
70
71
73
75 if (stat /= nf90_noerr) then
77 goto 999
78 endif
79
80999 continue
81 call storeerror(stat,
'GDNcVarOpenByDimOrd', err, cause_i=dimord)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public gt_enomoredims
integer function, public vtable_add(var, entry)
integer function, public vtable_lookup(var, entry)