gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
Functions/Subroutines
gtvarexchdim.f90 File Reference

次元順序番号の交換 More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarexchdim (var, dimord1, dimord2, count_compact, err)
 

Detailed Description

次元順序番号の交換

Author
Eizi TOYODA, Yasuhiro MORIKAWA

Definition in file gtvarexchdim.f90.

Function/Subroutine Documentation

◆ gtvarexchdim()

subroutine gtvarexchdim ( type(gt_variable), intent(in)  var,
integer, intent(in)  dimord1,
integer, intent(in)  dimord2,
logical, intent(in), optional  count_compact,
logical, intent(out)  err 
)

指定順序番号の次元を交換

変数 var の次元順序番号 dimord1, dimord2 のそれぞれに対応する次元を入れ替えます。

count_compact に .true. を渡すと、縮退した次元も含めて動作します。

エラーが生じた場合、メッセージを出力してプログラムは強制終了します。 err を与えてある場合にはの引数に .true. が返り、プログラムは終了しません。

Parameters
[in]var変数ハンドル
[in]dimord11番目の次元順序番号
[in]dimord22番目の次元順序番号
[in]count_compact縮退次元を含むか (省略可能)
[out]errエラーフラグ

Definition at line 56 of file gtvarexchdim.f90.

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)
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
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)

References dc_trace::beginsub(), dc_trace::dbgmessage(), gtdata_internal_map::dimord_skip_compact(), dc_trace::endsub(), gtdata_internal_map::map_lookup(), gtdata_internal_map::map_set(), and gtdata_internal_map::map_set_ndims().

Here is the call graph for this function: