gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtvardeldim.f90
Go to the documentation of this file.
1!> @file gtvardeldim.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 Delete dimension
9!>
10!> This subroutine is provided as gtdata_generic#Del_dim
11!> through gtdata_generic.
12!> @enden
13!>
14!> @ja
15!> @brief 次元の削除
16!>
17!> このサブルーチンは gtdata_generic から gtdata_generic#Del_dim
18!> として提供されます。
19!> @endja
20!>
21
22!>
23!> @en
24!> @brief Delete dimension from variable
25!>
26!> Deletes dimension dimord from variable var.
27!> Since this only lowers the rank in the dimension correspondence table
28!> and decrements the valid dimension count, I/O is still possible
29!> after this operation if the dimension is already degenerate.
30!>
31!> If an error occurs, outputs a message and terminates the program.
32!> If err is provided, returns .true. and program does not terminate.
33!>
34!> @note In NetCDF implementation, variable is not deleted but renamed.
35!> This is because netCDF API lacks variable deletion.
36!> @param[in] var Variable handle
37!> @param[in] dimord Dimension order number to delete
38!> @param[out] err Error flag
39!> @enden
40!>
41!> @ja
42!> @brief 変数から次元を削除
43!>
44!> 変数 var の次元 dimord を削除します。
45!> 次元対応表の順位を下げ有効次元数をデクリメントするだけなので、
46!> 当該次元がすでに縮退していれば、この操作のあとでも入出力が可能です。
47!>
48!> エラーが生じた場合、メッセージを出力してプログラムは強制終了します。
49!> err を与えてある場合にはの引数に .true. が返り、プログラムは終了しません。
50!>
51!> @note NetCDF 実装においては、変数は削除されず別の名称に改名されるだけです。
52!> これは netCDF API に変数の削除が欠けているためです。
53!> @param[in] var 変数ハンドル
54!> @param[in] dimord 削除する次元順序番号
55!> @param[out] err エラーフラグ
56!> @endja
57!>
58subroutine gtvardeldim(var, dimord, err)
59 use gtdata_types, only: gt_variable
62 implicit none
63 type(gt_variable), intent(in):: var
64 integer, intent(in):: dimord
65 logical, intent(out):: err
66 type(gt_dimmap), allocatable:: map(:)
67 type(gt_dimmap):: tmpmap
68 integer:: ndimsp, stat
69 character(*), parameter:: subname = 'GTVarDelDim'
70continue
71 err = .true.
72 call beginsub(subname)
73 if (dimord < 1) then
74 call endsub(subname, "negative dimord=%d invalid", i=(/dimord/))
75 return
76 endif
77 call map_lookup(var, ndims=ndimsp)
78 if (ndimsp <= 0) then
79 call endsub(subname, "variable invalid")
80 return
81 else if (dimord > ndimsp) then
82 call endsub(subname, "dimord=%d not exist", i=(/dimord/))
83 return
84 endif
85
86 allocate(map(ndimsp))
87 call map_lookup(var, map=map)
88 tmpmap = map(dimord)
89 map(dimord: ndimsp-1) = map(dimord+1: ndimsp)
90 map(ndimsp) = tmpmap
91 call map_set(var, map, stat)
92 deallocate(map)
93
94 call map_set_ndims(var, ndims = ndimsp - 1, stat=stat)
95 err = stat /= 0
96 call endsub(subname)
97end subroutine gtvardeldim
subroutine gtvardeldim(var, dimord, 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)