14
15
16
17
18
19
20
21
22
23
24
25
26
30 use dc_trace, only: beginsub, endsub, dbgmessage
31 implicit none
32 type(GT_VARIABLE), intent(in):: var
33 integer, intent(in):: dimord1, dimord2
34 logical, intent(in), optional:: count_compact
35 logical, intent(out):: err
36 type(gt_dimmap), allocatable:: map(:)
37 type(gt_dimmap):: tmpmap
38 integer:: ndimsp, stat, idim1, idim2
39 logical:: direct_mode
40 character(*), parameter:: subname = 'GTVarExchDim'
41continue
42 err = .true.
43 direct_mode = .false.
44 if (present(count_compact)) then
45 direct_mode = count_compact
46 endif
47 call beginsub(subname)
48 if (dimord1 < 1 .or. dimord2 < 1) then
49 call endsub(subname, "negative dimord=%d %d invalid", i=(/dimord1, dimord2/))
50 return
51 endif
53 if (ndimsp <= 0) then
54 call endsub(subname, "variable invalid")
55 return
56 else if (dimord1 > ndimsp .or. dimord2 > ndimsp) then
57 call endsub(subname, "dimord=%d %d not exist", i=(/dimord1, dimord2/))
58 return
59 endif
60
61 allocate(map(ndimsp))
63
64 if (.not. direct_mode) then
67 if (idim1 < 0 .or. idim2 < 0) then
68 call endsub(subname, "dimord=%d %d not found after compaction", &
69 & i=(/dimord1, dimord2/))
70 deallocate(map)
71 return
72 endif
73 else
74 idim1 = dimord1
75 idim2 = dimord2
76 endif
77
78 tmpmap = map(idim1)
79 map(idim1) = map(idim2)
80 map(idim2) = tmpmap
82 deallocate(map)
83
84 err = stat /= 0
85 call endsub(subname)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set_ndims(var, ndims, stat)
subroutine map_set(var, map, stat)
integer function dimord_skip_compact(dimord, map)