\hypertarget{gtvarexchdim_8f90}{}\section{gtdata/gtvarexchdim.f90 File Reference}
\label{gtvarexchdim_8f90}\index{gtdata/gtvarexchdim.\+f90@{gtdata/gtvarexchdim.\+f90}}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine \hyperlink{gtvarexchdim_8f90_af757c841161861824f37ae31bf2a2271}{gtvarexchdim} (var, dimord1, dimord2, count\+\_\+compact, err)
\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{gtvarexchdim_8f90_af757c841161861824f37ae31bf2a2271}\label{gtvarexchdim_8f90_af757c841161861824f37ae31bf2a2271}} 
\index{gtvarexchdim.\+f90@{gtvarexchdim.\+f90}!gtvarexchdim@{gtvarexchdim}}
\index{gtvarexchdim@{gtvarexchdim}!gtvarexchdim.\+f90@{gtvarexchdim.\+f90}}
\subsubsection{\texorpdfstring{gtvarexchdim()}{gtvarexchdim()}}
{\footnotesize\ttfamily subroutine gtvarexchdim (\begin{DoxyParamCaption}\item[{type(gt\+\_\+variable), intent(in)}]{var,  }\item[{integer, intent(in)}]{dimord1,  }\item[{integer, intent(in)}]{dimord2,  }\item[{logical, intent(in), optional}]{count\+\_\+compact,  }\item[{logical, intent(out)}]{err }\end{DoxyParamCaption})}



Definition at line 14 of file gtvarexchdim.\+f90.



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().


\begin{DoxyCode}
14   \textcolor{comment}{!}
15   \textcolor{comment}{!== 次元順序番号の交換}
16   \textcolor{comment}{!}
17   \textcolor{comment}{! 変数 *var* の次元順序番号 <b>dimord1</b>, <b>dimord2</b> のそれぞれに}
18   \textcolor{comment}{! 対応する次元を入れ替えます。}
19   \textcolor{comment}{!}
20   \textcolor{comment}{! *count\_compact* に .true. を渡すと、縮退した次元も含めて}
21   \textcolor{comment}{! 動作します。}
22   \textcolor{comment}{!}
23   \textcolor{comment}{! エラーが生じた場合、メッセージを出力}
24   \textcolor{comment}{! してプログラムは強制終了します。*err* を与えてある場合には}
25   \textcolor{comment}{! の引数に .true. が返り、プログラムは終了しません。}
26   \textcolor{comment}{!}
27   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__types}{gtdata\_types}\textcolor{keywordtype}{, only}: \hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}
28   \textcolor{keywordtype}{use }\hyperlink{namespacegtdata__internal__map}{gtdata\_internal\_map}\textcolor{keywordtype}{, only}: \hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}, 
      \hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}, \hyperlink{namespacegtdata__internal__map_a12dffe35d93120bca94db15c47818ae1}{map\_set\_ndims}, \hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}, &
29     & \hyperlink{namespacegtdata__internal__map_a44f4fb36cd72433854ba6bdc6634500f}{dimord\_skip\_compact}
30   \textcolor{keywordtype}{use }\hyperlink{namespacedc__trace}{dc\_trace}\textcolor{keywordtype}{, only}: \hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}, \hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}, \hyperlink{namespacedc__trace_a2a38fceb4cf9baf298d63456238c3fea}{dbgmessage}
31   \textcolor{keywordtype}{implicit none}
32   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__types_1_1gt__variable}{gt\_variable}), \textcolor{keywordtype}{intent(in)}:: var
33   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}:: dimord1, dimord2
34   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: count\_compact
35   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(out)}:: err
36   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}), \textcolor{keywordtype}{allocatable}:: map(:)
37   \textcolor{keywordtype}{type}(\hyperlink{structgtdata__internal__map_1_1gt__dimmap}{gt\_dimmap}):: tmpmap
38   \textcolor{keywordtype}{integer}:: ndimsp, stat, idim1, idim2
39   \textcolor{keywordtype}{logical}:: direct\_mode
40   \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{parameter}:: subname = \textcolor{stringliteral}{'GTVarExchDim'}
41 \textcolor{keywordflow}{continue}
42   err = .true.
43   direct\_mode = .false.
44   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(count\_compact)) \textcolor{keywordflow}{then}
45     direct\_mode = count\_compact
46 \textcolor{keywordflow}{  endif}
47   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_aca1efe8bae50b85f74980a8c4d704dd8}{beginsub}(subname)
48   \textcolor{keywordflow}{if} (dimord1 < 1 .or. dimord2 < 1) \textcolor{keywordflow}{then}
49     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname, \textcolor{stringliteral}{"negative dimord=%d %d invalid"}, i=(/dimord1, dimord2/))
50     \textcolor{keywordflow}{return}
51 \textcolor{keywordflow}{  endif}
52   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(var, ndims=ndimsp)
53   \textcolor{keywordflow}{if} (ndimsp <= 0) \textcolor{keywordflow}{then}
54     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname, \textcolor{stringliteral}{"variable invalid"})
55     \textcolor{keywordflow}{return}
56   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (dimord1 > ndimsp .or. dimord2 > ndimsp) \textcolor{keywordflow}{then}
57     \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname, \textcolor{stringliteral}{"dimord=%d %d not exist"}, i=(/dimord1, dimord2/))
58     \textcolor{keywordflow}{return}
59 \textcolor{keywordflow}{  endif}
60 
61   \textcolor{keyword}{allocate}(map(ndimsp))
62   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a076911f777be03f10a2c024dac7efdad}{map\_lookup}(var, map=map)
63 
64   \textcolor{keywordflow}{if} (.not. direct\_mode) \textcolor{keywordflow}{then}
65     idim1 = \hyperlink{namespacegtdata__internal__map_a44f4fb36cd72433854ba6bdc6634500f}{dimord\_skip\_compact}(dimord1, map)
66     idim2 = \hyperlink{namespacegtdata__internal__map_a44f4fb36cd72433854ba6bdc6634500f}{dimord\_skip\_compact}(dimord2, map)
67     \textcolor{keywordflow}{if} (idim1 < 0 .or. idim2 < 0) \textcolor{keywordflow}{then}
68       \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname, \textcolor{stringliteral}{"dimord=%d %d not found after compaction"}, &
69         & i=(/dimord1, dimord2/))
70       \textcolor{keyword}{deallocate}(map)
71       \textcolor{keywordflow}{return}
72 \textcolor{keywordflow}{    endif}
73   \textcolor{keywordflow}{else}
74     idim1 = dimord1
75     idim2 = dimord2
76 \textcolor{keywordflow}{  endif}
77 
78   tmpmap = map(idim1)
79   map(idim1) = map(idim2)
80   map(idim2) = tmpmap
81   \textcolor{keyword}{call }\hyperlink{namespacegtdata__internal__map_a2e6a789c1c8f4850421da11f10081cb7}{map\_set}(var, map, stat)
82   \textcolor{keyword}{deallocate}(map)
83 
84   err = stat /= 0
85   \textcolor{keyword}{call }\hyperlink{namespacedc__trace_ae44de97565a3bdd685789c7748b37e37}{endsub}(subname)
\end{DoxyCode}
Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{gtvarexchdim_8f90_af757c841161861824f37ae31bf2a2271_cgraph}
\end{center}
\end{figure}
