42 logical,
intent(out),
optional:: err
43 integer:: ndim1, ndim2, ndimo
44 integer,
allocatable:: map1(:), map2(:)
47 character(*),
parameter:: subnam =
"GTVarXformBinary" 49 call beginsub(subnam,
'mapid=[%d, %d]', i=(/var1%mapid, var2%mapid/))
55 if (
present(err)) err = .false.
56 call inquire(var1, alldims=ndim1)
57 call inquire(var2, alldims=ndim2)
58 ndimo = max(ndim1, ndim2, 0)
59 allocate(map1(1:ndim1), map2(1:ndim2))
60 call getmatch(var1, var2, ndim1, ndim2, map1, map2)
61 call dbgmessage(
'map1=%*d map2=%*d', i=(/map1(1:ndim1), map2(1:ndim2)/), n=(/ndim1, ndim2/))
62 if (all(map2(1:ndim2) == 0))
then 69 ndimo = ndim2 + count(map1(1:ndim1) == 0)
74 newmap(1:ndim2)%dimno = map2(1:ndim2)
75 call inquire(var2, allcount=newmap(1:ndim2)%allcount)
76 call get_slice(var2, count=newmap(1:ndim2)%count)
78 if (map2(j) == 0)
then 81 call inquire(var2, j, url=newmap(j)%url)
85 & newmap(j)%start, newmap(j)%stride)
92 loop1:
do, i = ndim2 + 1, ndimo
95 if (j > ndim1)
exit loop1
96 if (map1(j) <= 0)
exit 99 call inquire(var1, dimord=j, allcount=newmap(i)%allcount)
100 call get_slice(var1, dimord=j, start=newmap(i)%start, &
101 & count=newmap(i)%count, stride=newmap(i)%stride)
109 call endsub(subnam,
'stat=%d', i=(/stat/))
110 deallocate(map1, map2)
118 subroutine adjust_slice(var1, var2, idim1, idim2, offset, stepfact)
121 integer,
intent(in):: idim1, idim2
122 integer,
intent(out):: offset, stepfact
125 real,
allocatable:: val1(:), val2(:)
128 call open(var_d, source_var=var1, dimord=idim1, count_compact=.true.)
131 call get(var_d, val1, n)
134 call open(var_d, source_var=var2, dimord=idim2, count_compact=.true.)
137 call get(var_d, val2, n)
140 buf(1:1) = minloc(abs(val1(:) - val2(1)))
142 if (
size(val2) < 2 .or.
size(val1) < 2)
then 145 buf(1:1) = minloc(abs(val1(:) - val2(2)))
146 stepfact = buf(1) - (offset + 1)
149 deallocate(val1, val2)
150 call endsub(
'adjust_slice')
157 subroutine getmatch(var1, var2, ndim1, ndim2, map1, map2)
162 integer,
intent(in):: ndim1, ndim2
163 integer,
intent(out):: map1(:), map2(:)
165 integer,
allocatable:: map(:, :)
167 character(STRING):: su1, su2
168 type(
units),
allocatable:: u1(:), u2(:)
175 allocate(map(ndim1, ndim2))
180 allocate(u1(ndim1), u2(ndim2))
182 call open(var_d, var1, i, count_compact=.true.)
189 call open(var_d, var2, j, count_compact=.true.)
214 call endsub(
'getmatch',
'fail')
219 call dbgmessage(
'map(%d, :)=%*d', i=(/i, map(i,:)/), n=(/ndim2/))
222 if (all(map(i, :) <= 0))
then 225 map1(i:i) = maxloc(map(i, :))
229 if (all(map(:, j) <= 0))
then 232 map2(j:j) = maxloc(map(:, j), dim=1)
235 call endsub(
'getmatch',
'okay')
243 ni =
size(map, dim=1)
245 if (count(map(i, :) > 0) > 1)
then 251 if (count(map(j, :) > 0) > 1)
then 258 call endsub(
'map_finished')
logical function map_finished(map)
subroutine map_apply(var, map)
subroutine gtvar_dump(var)
subroutine getmatch(var1, var2, ndim1, ndim2, map1, map2)
integer, parameter, public gt_efake
integer, parameter, public gt_enomatchdim
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_noerr
subroutine adjust_slice(var1, var2, idim1, idim2, offset, stepfact)
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
logical function, public add_okay(u1, u2)
Provides kind type parameter values.
subroutine gtvarxformbinary(var1, var2, err)
subroutine map_allocate(map, ndims)
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
integer, parameter, public string
Character length for string.