Loading...
Searching...
No Matches
hstnmlinfoclose.f90
Go to the documentation of this file.
1!= GTHST_NMLINFO 型の変数の終了処理
2!= Deconstructor of "GTHST_NMLINFO"
3!
4! Authors:: Yasuhiro MORIKAWA
5! Version:: $Id: hstnmlinfoclose.f90,v 1.2 2009-06-01 15:17:18 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 subroutine hstnmlinfoclose( gthstnml, err )
11 !
12 ! GTHST_NMLINFO 型の変数の終了処理を行います.
13 !
14 ! このサブルーチンを使用する前に, *gthstnml* に格納されている
15 ! gtool_history_types#GT_HISTORY 型の全ての変数に対して,
16 ! gtool_history_generic#HistoryClose を用いて終了処理を行ってください.
17 ! 終了処理されていないものがある場合,
18 ! プログラムはエラーを発生させます.
19 !
20 ! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
21 ! されていない場合, プログラムはエラーを発生させます.
22 !
23 ! Deconstructor of "GTHST_NMLINFO".
24 !
25 ! Terminate all "gtool_history_types#GT_HISTORY" variables in *gthstnml*
26 ! by "gtool_history_generic#HistoryClose" before this subroutine is used.
27 ! If unterminated variables remain,
28 ! error is occurred.
29 !
30 ! Note that if *gthstnml* is not initialized by "HstNmlInfoCreate" yet,
31 ! error is occurred.
32 !
35 use gtool_history, only: historyinitialized
36 use dc_trace, only: beginsub, endsub, dbgmessage
37 use dc_string, only: putline, printf, split, strinclude, stoa, joinchar
38 use dc_types, only: dp, string, token, stdout
40 implicit none
41 type(gthst_nmlinfo), intent(inout):: gthstnml
42 logical, intent(out), optional:: err
43 ! 例外処理用フラグ.
44 ! デフォルトでは, この手続き内でエラーが
45 ! 生じた場合, プログラムは強制終了します.
46 ! 引数 *err* が与えられる場合,
47 ! プログラムは強制終了せず, 代わりに
48 ! *err* に .true. が代入されます.
49 !
50 ! Exception handling flag.
51 ! By default, when error occur in
52 ! this procedure, the program aborts.
53 ! If this *err* argument is given,
54 ! .true. is substituted to *err* and
55 ! the program does not abort.
56
57 !-----------------------------------
58 ! 作業変数
59 ! Work variables
60 type(gthst_nmlinfo_entry), pointer:: hptr =>null()
61 type(gthst_nmlinfo_entry), pointer:: hptr_prev =>null()
62 integer:: stat
63 character(STRING):: cause_c
64 character(*), parameter:: subname = 'HstNmlInfoClose'
65 continue
66 call beginsub( subname )
67 stat = dc_noerr
68 cause_c = ''
69
70 !-----------------------------------------------------------------
71 ! 初期設定のチェック
72 ! Check initialization
73 !-----------------------------------------------------------------
74 if ( .not. gthstnml % initialized ) then
75 stat = dc_enotinit
76 cause_c = 'GTHST_NMLINFO'
77 goto 999
78 end if
79
80 !-----------------------------------------------------------------
81 ! "GTHST_NMLINFO" の設定の消去
82 ! Clear the settings for "GTHST_NMLINFO"
83 !-----------------------------------------------------------------
84 do
85 hptr => gthstnml % gthstnml_list
86 call listlast( gthstnml_list = hptr, & ! (inout)
87 & previous = hptr_prev ) ! (out)
88 call dbgmessage( 'remove entry (%c)', c1 = trim(hptr % name) )
89 if ( trim( hptr % name ) == '' ) exit
90 if ( .not. gthstnml % define_mode ) then
91 if ( historyinitialized( hptr % history ) ) then
93 cause_c = hptr % name
94 goto 999
95 end if
96 end if
97 deallocate( hptr )
98 nullify( hptr_prev % next )
99 end do
100 deallocate( gthstnml % gthstnml_list )
101
102 !-----------------------------------------------------------------
103 ! 終了処理, 例外処理
104 ! Termination and Exception handling
105 !-----------------------------------------------------------------
106 gthstnml % initialized = .false.
107 gthstnml % define_mode = .true.
108999 continue
109 nullify( hptr )
110 call storeerror( stat, subname, err, cause_c )
111 call endsub( subname )
112 end subroutine hstnmlinfoclose
subroutine hstnmlinfoclose(gthstnml, err)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public hst_enottermgthist
Definition dc_error.f90:585
integer, parameter, public dc_enotinit
Definition dc_error.f90:557
integer, parameter, public dc_noerr
Definition dc_error.f90:509
Provides kind type parameter values.
Definition dc_types.f90:49
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:109
integer, parameter, public string
Character length for string
Definition dc_types.f90:118
integer, parameter, public stdout
Unit number for Standard OUTPUT
Definition dc_types.f90:98
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:83