gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gtvarsliceauto.f90
Go to the documentation of this file.
1!> @file gtvarsliceauto.f90
2!>
3!> @author Eizi TOYODA, Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Automatic I/O range specification
9!>
10!> This subroutine is provided as gtdata_generic#Slice
11!> through gtdata_generic.
12!> @enden
13!>
14!> @ja
15!> @brief 入出力範囲の自動指定
16!>
17!> このサブルーチンは gtdata_generic から gtdata_generic#Slice
18!> として提供されます。
19!> @endja
20!>
21
22!>
23!> @en
24!> @brief Automatically specify I/O range
25!>
26!> Makes the I/O range of variable var "appropriately" small.
27!> If compatible is specified, sets it to the exact same I/O range
28!> as that variable.
29!>
30!> Slice is a generic name for multiple subroutines; there are also
31!> methods to specify by string or number.
32!>
33!> Related procedures to Slice include Get_Slice and Slice_Next.
34!> Get_Slice retrieves the set I/O range.
35!> Slice_Next is used to read the entire variable by moving the I/O range.
36!> @param[inout] var Variable handle
37!> @param[in] compatible Variable to match I/O range (optional)
38!> @enden
39!>
40!> @ja
41!> @brief 入出力範囲を自動指定
42!>
43!> 変数 var の入出力範囲を「適当に」小さくします。
44!> compatible を指定すると、その変数と全く同じ入出力範囲に指定します。
45!>
46!> Slice は複数のサブルーチンの総称名であり、
47!> 他にも文字列や番号で指定する方法があります。
48!>
49!> Slice に関連する手続きとして、Get_Slice と Slice_Next があります。
50!> Get_Slice は設定された入出力範囲を取得します。
51!> Slice_Next は入出力範囲を移動することによって、変数全体を読み取る
52!> ために利用するサブルーチンです。
53!> @param[inout] var 変数ハンドル
54!> @param[in] compatible 入出力範囲を合わせる変数 (省略可能)
55!> @endja
56!>
57subroutine gtvarsliceauto(var, compatible)
58 use gtdata_types, only: gt_variable
60 type(gt_variable), intent(inout):: var
61 type(gt_variable), intent(in), optional:: compatible
62 integer:: nd, i
63 integer, allocatable:: start(:), count(:), stride(:)
64 call inquire(var, alldims=nd)
65 if (nd <= 0) return
66 allocate(start(nd), count(nd), stride(nd))
67 if (present(compatible)) then
68 call get_slice(compatible, start, count, stride)
69 do, i = 1, nd
70 call gtvarslice(var, i, start(i), count(i), stride(i))
71 enddo
72 else
73 call get_slice(var, start, count, stride)
74 do, i = 1, nd
75 if (count(i) < 1) count(i) = 1
76 call gtvarslice(var, i, start(i), count(i), stride(i))
77 enddo
78 endif
79 deallocate(start, count, stride)
80end subroutine gtvarsliceauto
subroutine gtvarslice(var, dimord, start, count, stride)
subroutine gtvarsliceauto(var, compatible)