14
15
16
17
18
19
20
21
22
23
24
25
27 use gtdata_generic, only: inquire
29 use dc_trace, only: beginsub, endsub, dbgmessage
30 implicit none
31 type(GT_VARIABLE), intent(in):: var
32 type(GT_VARIABLE), intent(in):: dimvar
33 integer, intent(in):: dimord
34 logical, intent(out):: err
35 type(gt_dimmap), pointer:: map(:)
36 type(gt_dimmap):: tmpmap
37 integer:: id, nd, ndimsp, stat, vid
38 character(*), parameter:: subname = 'GTVarAddDim'
39continue
40 err = .true.
41 call beginsub(subname)
42
43 if (dimord < 1) then
44 call endsub(subname, "negative dimord=%d invalid", i=(/dimord/))
45 return
46 endif
47
48
50 if (vid < 0) then
51 call endsub(subname, "dimvar invalid")
52 return
53 endif
54 if (nd <= 0) then
55 call endsub(subname, "dimvar nondimensional")
56 return
57 else if (nd > 1) then
58 call endsub(subname, "dimvar multidimensional")
59 return
60 endif
61 allocate(map(nd))
63 tmpmap = map(1)
64 deallocate(map)
65
66
68 if (dimord > ndimsp + 1) then
69 id = ndimsp + 1
70 else
71 id = dimord
72 endif
73 allocate(map(nd + 1))
76 map(id+1: nd+1) = map(id: nd)
77
78
79 map(id)%dimno = -1
80 call inquire(dimvar, url=map(id)%url)
81 map(id)%allcount = tmpmap%allcount
82 map(id)%offset = tmpmap%offset
83 map(id)%step = tmpmap%step
84 map(id)%start = tmpmap%start
85 map(id)%count = tmpmap%count
86 map(id)%stride = tmpmap%stride
87
88
89 call map_set(var, map=map, stat=stat)
90 if (stat /= 0) goto 999
92
93999 continue
94 err = (stat /= 0)
95 call endsub(subname)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set_ndims(var, ndims, stat)
subroutine map_set(var, map, stat)
subroutine map_resize(var, ndims)