Loading...
Searching...
No Matches
gtvardeldim.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine gtvardeldim (var, dimord, err)

Function/Subroutine Documentation

◆ gtvardeldim()

subroutine gtvardeldim ( type(gt_variable), intent(in) var,
integer, intent(in) dimord,
logical, intent(out) err )

Definition at line 13 of file gtvardeldim.f90.

14 !
15 !== 次元の削除
16 !
17 ! 変数 *var* の次元 *dimord* を削除します。
18 ! 次元対応表の順位を下げ有効次元数をデクリメントするだけなので、
19 ! 当該次元がすでに縮退していれば、この操作のあとでも入出力が可能です。
20 !
21 ! エラーが生じた場合、メッセージを出力
22 ! してプログラムは強制終了します。*err* を与えてある場合には
23 ! の引数に .true. が返り、プログラムは終了しません。
24 !
25 !--
26 ! 実際には、次元対応表の順位を下げ有効次元数をデクリメント
27 ! するだけなので、入出力に支障はない。
28 !
29 ! NetCDF 実装においては、変数は削除されず、
30 ! 別の名称に改名されるだけです。
31 ! これは netCDF API に変数の削除が欠けているためです。
32 !++
33 use gtdata_types, only: gt_variable
35 use dc_trace, only: beginsub, endsub, dbgmessage
36 implicit none
37 type(gt_variable), intent(in):: var
38 integer, intent(in):: dimord
39 logical, intent(out):: err
40 type(gt_dimmap), allocatable:: map(:)
41 type(gt_dimmap):: tmpmap
42 integer:: ndimsp, stat
43 character(*), parameter:: subname = 'GTVarDelDim'
44continue
45 err = .true.
46 call beginsub(subname)
47 if (dimord < 1) then
48 call endsub(subname, "negative dimord=%d invalid", i=(/dimord/))
49 return
50 endif
51 call map_lookup(var, ndims=ndimsp)
52 if (ndimsp <= 0) then
53 call endsub(subname, "variable invalid")
54 return
55 else if (dimord > ndimsp) then
56 call endsub(subname, "dimord=%d not exist", i=(/dimord/))
57 return
58 endif
59
60 allocate(map(ndimsp))
61 call map_lookup(var, map=map)
62 tmpmap = map(dimord)
63 map(dimord: ndimsp-1) = map(dimord+1: ndimsp)
64 map(ndimsp) = tmpmap
65 call map_set(var, map, stat)
66 deallocate(map)
67
68 call map_set_ndims(var, ndims = ndimsp - 1, stat=stat)
69 err = stat /= 0
70 call endsub(subname)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set_ndims(var, ndims, stat)
subroutine map_set(var, map, stat)

References 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: