Loading...
Searching...
No Matches
gtvardeldim.f90
Go to the documentation of this file.
1!
2!= 次元の削除
3!
4! Authors:: Eizi TOYODA, Yasuhiro MORIKAWA
5! Version:: $Id: gtvardeldim.f90,v 1.3 2009-05-25 09:55:58 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
8! License:: See COPYRIGHT[link:../../COPYRIGHT]
9!
10! 以下のサブルーチン、関数は gtdata_generic から gtdata_generic#Del_dim
11! として提供されます。
12
13subroutine gtvardeldim(var, dimord, err)
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)
71end subroutine gtvardeldim
subroutine gtvardeldim(var, dimord, err)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set_ndims(var, ndims, stat)
subroutine map_set(var, map, stat)