gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtvarexchdim.f90
Go to the documentation of this file.
1
21
56subroutine gtvarexchdim(var, dimord1, dimord2, count_compact, err)
57 use gtdata_types, only: gt_variable
61 implicit none
62 type(gt_variable), intent(in):: var
63 integer, intent(in):: dimord1, dimord2
64 logical, intent(in), optional:: count_compact
65 logical, intent(out):: err
66 type(gt_dimmap), allocatable:: map(:)
67 type(gt_dimmap):: tmpmap
68 integer:: ndimsp, stat, idim1, idim2
69 logical:: direct_mode
70 character(*), parameter:: subname = 'GTVarExchDim'
71continue
72 err = .true.
73 direct_mode = .false.
74 if (present(count_compact)) then
75 direct_mode = count_compact
76 endif
77 call beginsub(subname)
78 if (dimord1 < 1 .or. dimord2 < 1) then
79 call endsub(subname, "negative dimord=%d %d invalid", i=(/dimord1, dimord2/))
80 return
81 endif
82 call map_lookup(var, ndims=ndimsp)
83 if (ndimsp <= 0) then
84 call endsub(subname, "variable invalid")
85 return
86 else if (dimord1 > ndimsp .or. dimord2 > ndimsp) then
87 call endsub(subname, "dimord=%d %d not exist", i=(/dimord1, dimord2/))
88 return
89 endif
90
91 allocate(map(ndimsp))
92 call map_lookup(var, map=map)
93
94 if (.not. direct_mode) then
95 idim1 = dimord_skip_compact(dimord1, map)
96 idim2 = dimord_skip_compact(dimord2, map)
97 if (idim1 < 0 .or. idim2 < 0) then
98 call endsub(subname, "dimord=%d %d not found after compaction", &
99 & i=(/dimord1, dimord2/))
100 deallocate(map)
101 return
102 endif
103 else
104 idim1 = dimord1
105 idim2 = dimord2
106 endif
107
108 tmpmap = map(idim1)
109 map(idim1) = map(idim2)
110 map(idim2) = tmpmap
111 call map_set(var, map, stat)
112 deallocate(map)
113
114 err = stat /= 0
115 call endsub(subname)
116end subroutine gtvarexchdim
subroutine gtvarexchdim(var, dimord1, dimord2, count_compact, err)
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
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)