hstnmlinfodelete.f90
Go to the documentation of this file.
1 != 変数の出力情報の削除
2 != Delete output information of a variable
3 !
4 ! Authors:: Yasuhiro MORIKAWA
5 ! Version:: $Id: hstnmlinfodelete.f90,v 1.1 2009-05-11 15:15:15 morikawa Exp $
6 ! Tag Name:: $Name: $
7 ! Copyright:: Copyright (C) GFD Dennou Club, 2007-2009. All rights reserved.
8 ! License:: See COPYRIGHT[link:../../../COPYRIGHT]
9 !
10  recursive subroutine hstnmlinfodelete( gthstnml, &
11  & name, &
12  & err )
13  !
14  ! 変数の出力情報を削除します.
15  !
16  ! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
17  ! されていない場合, プログラムはエラーを発生させます.
18  !
19  ! Delete output information of a variable.
20  !
21  ! If *gthstnml* is not initialized by "HstNmlInfoCreate" yet,
22  ! error is occurred.
23  !
27  use dc_trace, only: beginsub, endsub, dbgmessage
30  use dc_types, only: dp, string, token, stdout
32  implicit none
33  type(gthst_nmlinfo), intent(inout):: gthstnml
34  character(*), intent(in):: name
35  ! 変数名.
36  !
37  ! 先頭の空白は無視されます.
38  !
39  ! "Data1,Data2" のようにカンマで区切って複数
40  ! の変数を指定することが可能です.
41  !
42  ! Variable identifier.
43  !
44  ! Blanks at the head of the name are ignored.
45  !
46  ! Multiple variables can be specified
47  ! as "Data1,Data2". Delimiter is comma.
48  !
49  logical, intent(out), optional:: err
50  ! 例外処理用フラグ.
51  ! デフォルトでは, この手続き内でエラーが
52  ! 生じた場合, プログラムは強制終了します.
53  ! 引数 *err* が与えられる場合,
54  ! プログラムは強制終了せず, 代わりに
55  ! *err* に .true. が代入されます.
56  !
57  ! Exception handling flag.
58  ! By default, when error occur in
59  ! this procedure, the program aborts.
60  ! If this *err* argument is given,
61  ! .true. is substituted to *err* and
62  ! the program does not abort.
63 
64  !-----------------------------------
65  ! 作業変数
66  ! Work variables
67  type(gthst_nmlinfo_entry), pointer:: hptr =>null()
68  type(gthst_nmlinfo_entry), pointer:: hptr_prev =>null()
69  type(gthst_nmlinfo_entry), pointer:: hptr_next =>null()
70  character(TOKEN), pointer:: varnames_array(:) =>null()
71  integer:: i, vnmax
72  integer:: stat
73  character(STRING):: cause_c
74  character(*), parameter:: subname = 'HstNmlInfoDelete'
75  continue
76  call beginsub( subname, &
77  & fmt = '@name=%c', &
78  & c1 = trim( name ) )
79  stat = dc_noerr
80  cause_c = ''
81 
82  !-----------------------------------------------------------------
83  ! 初期設定のチェック
84  ! Check initialization
85  !-----------------------------------------------------------------
86  if ( .not. gthstnml % initialized ) then
87  stat = dc_enotinit
88  cause_c = 'GTHST_NMLINFO'
89  goto 999
90  end if
91 
92  if ( .not. gthstnml % define_mode ) then
93  stat = hst_enotindefine
94  cause_c = 'Delete'
95  goto 999
96  end if
97 
98  !-----------------------------------------------------------------
99  ! 複数の変数を削除する場合
100  ! Delete multiple variables
101  !-----------------------------------------------------------------
102  if ( present_and_not_empty(name) ) then
103  if ( index(name, name_delimiter) > 0 ) then
104  call dbgmessage( 'multiple entries (%c) will be deleted', c1 = trim(name) )
105  call split( str = name, sep = name_delimiter, & ! (in)
106  & carray = varnames_array ) ! (out)
107  vnmax = size( varnames_array )
108 
109  do i = 1, vnmax
110  call hstnmlinfodelete( &
111  & gthstnml = gthstnml, & ! (inout)
112  & name = varnames_array(i), & ! (in)
113  & err = err ) ! (out)
114  if ( present_and_true( err ) ) then
115  deallocate( varnames_array )
116  stat = usr_errno
117  goto 999
118  end if
119  end do
120  deallocate( varnames_array )
121  goto 999
122  end if
123  end if
124 
125  !-----------------------------------------------------------------
126  ! *gthstnml* の情報を削除.
127  ! Delete information in *gthstnml*
128  !-----------------------------------------------------------------
129  hptr => gthstnml % gthstnml_list
130  call listsearch( gthstnml_list = hptr, & ! (inout)
131  & name = name, & ! (in)
132  & previous = hptr_prev, & ! (out)
133  & next = hptr_next ) ! (out)
134 
135  if ( .not. associated( hptr ) ) goto 999
136  if ( ( trim(hptr % name) /= '' ) .and. associated( hptr_prev ) ) then
137  call dbgmessage( 'entry (%c) is deleted', c1 = trim( adjustl( name ) ) )
138  hptr_prev % next => hptr_next
139  deallocate( hptr )
140  end if
141 
142  !-----------------------------------------------------------------
143  ! 終了処理, 例外処理
144  ! Termination and Exception handling
145  !-----------------------------------------------------------------
146 999 continue
147  call storeerror( stat, subname, err, cause_c )
148  call endsub( subname )
149  end subroutine hstnmlinfodelete
integer, parameter, public dc_earglack
Definition: dc_error.f90:569
integer, parameter, public usr_errno
Definition: dc_error.f90:604
integer, parameter, public hst_enotindefine
Definition: dc_error.f90:581
integer, parameter, public dc_enotinit
Definition: dc_error.f90:557
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
logical function, public present_and_true(arg)
Definition: dc_present.f90:80
character(1), parameter, public name_delimiter
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
character(string) function, public joinchar(carray, expr)
Definition: dc_string.f90:861
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:509
recursive subroutine hstnmlinfodelete(gthstnml, name, err)
logical function, public present_and_not_empty(arg)
Definition: dc_present.f90:276
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
integer, parameter, public stdout
標準出力の装置番号
Definition: dc_types.f90:98
文字型変数の操作.
Definition: dc_string.f90:24
種別型パラメタを提供します。
Definition: dc_types.f90:49
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118