13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
47 use gtdata_generic,
only: gt_open =>
open
48 use dc_present, only: present_and_true
49 use dc_trace, only: beginsub, endsub, dbgmessage
50 use dc_string, only: cprintf
54 implicit none
55 type(GT_VARIABLE), intent(out):: var
56 type(GT_VARIABLE), intent(in):: source_var
57 integer, intent(in):: dimord
58 logical, intent(in), optional:: count_compact
59 logical, intent(out), optional:: err
60 integer:: sclass, scid, ld, sndims, stat, udimord, idimord, cause_i
61 type(GD_NC_VARIABLE):: gdnc
62 type(GT_DIMMAP), allocatable:: map_src(:)
63 type(GT_DIMMAP):: map_result(1)
64 logical:: cnt_compact
65 character(STRING) :: endsub_msg
66 character(len = *), parameter:: subname = "GTVarOpen-By-Dimord"
67 character(len = *), parameter:: version = &
68 & '$Name: $' // &
69 & '$Id: gtvaropenbydimord.f90,v 1.5 2009-07-04 04:58:06 morikawa Exp $'
70continue
71 call beginsub(subname, 'var.mapid=%d dimord=%d ', &
72 & i=(/source_var%mapid, dimord/), version=version)
74 cause_i = dimord
75 endsub_msg = ''
76
77
78 if (dimord == 0) then
80 if (present(err)) err = .false.
81 endsub_msg = 'dup'
82 goto 999
83 endif
84
85
86
88 if (sndims <= 0 .or. dimord > sndims) then
90 goto 999
91 endif
92 allocate(map_src(sndims))
94 cnt_compact = .false.
95 if (present_and_true(count_compact)) then
96 cnt_compact = .true.
97 else
98 cnt_compact = .false.
99 end if
100 call dbgmessage('count_compact=%y', l=(/cnt_compact/))
101
102 if (cnt_compact) then
103 udimord = dimord
104 else
106 endif
107 if (udimord <= 0 .or. udimord > size(map_src)) then
109 goto 999
110 endif
111
112 idimord = map_src(udimord)%dimno
113 if (idimord < 1) then
114 call gt_open(var, map_src(udimord)%url, err=err)
115
116 deallocate(map_src)
117 goto 999
118 endif
119
120
122 if (sclass == vtb_class_netcdf) then
125 call map_create(var, vtb_class_netcdf, gdnc%id, 1, (/ld/), stat)
127 cause_i = 1
128 goto 999
129 end if
131 map_result(1)%offset = map_src(udimord)%offset
132 map_result(1)%step = map_src(udimord)%step
133 map_result(1)%allcount = map_src(udimord)%allcount
134 map_result(1)%start = map_src(udimord)%start
135 map_result(1)%count = map_src(udimord)%count
136 map_result(1)%stride = map_src(udimord)%stride
137 call map_set(var, map=map_result, stat=stat)
138 else
140 endif
141
142 deallocate(map_src)
143 endsub_msg = cprintf('result_var=%d', i=(/var%mapid/))
144999 continue
145 call storeerror(stat, subname, cause_i=cause_i, err=err)
146 call endsub(subname, '%c', c1=trim(endsub_msg))
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public gt_efake
integer, parameter, public dc_noerr
integer, parameter, public gt_enomoredims
Provides kind type parameter values.
integer, parameter, public string
Character length for string
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set(var, map, stat)
integer function dimord_skip_compact(dimord, map)
subroutine, public var_class(var, class, cid)
subroutine, public map_create(var, class, cid, ndims, allcount, stat)
subroutine map_dup(var, source_var)