Loading...
Searching...
No Matches
Functions/Subroutines
historyautoallvarfix.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine historyautoallvarfix
 

Function/Subroutine Documentation

◆ historyautoallvarfix()

subroutine historyautoallvarfix

Definition at line 10 of file historyautoallvarfix.f90.

11 !
12 ! このサブルーチンは以下の動作を行います.
13 !
14 ! * NAMELIST から読み込んだ変数名に無効なものが存在したかどうかをチェック.
15 ! * HistoryAutoAddVariable で登録した変数名を印字.
16 !
17 ! このサブルーチンを呼んだ後に HistoryAutoAddVariable を呼ぶと
18 ! エラーを生じます.
19 !
20 ! This subroutine performs following acts.
21 !
22 ! * Check that invalid variable names are loaded from NAMELIST or not.
23 ! * Print registered variable names by "HistoryAutoAddVariable".
24 !
25 ! If "HistoryAutoAddVariable" is called after this subroutine is called,
26 ! an error is occurred.
27 !
28 use gtool_historyauto_internal, only: initialized, numdims, numvars, &
29 & flag_allvarfixed, gthst_vars, gthstnml, save_mpi_gather, sub_sname
31 use gtool_history, only: historyvarinfoinquire
32 use dc_trace, only: beginsub, endsub
34 use dc_message, only: messagenotify
35 use dc_date, only: operator(*), operator(+)
36 use dc_string, only: joinchar
37 use dc_types, only: dp, string, token
38
39 implicit none
40 logical:: allvar_invalid
41 ! 無効な変数名のチェックフラグ.
42 ! Check flag of invalid variable names.
43
44 integer, parameter:: names_limit = 100
45 character(names_limit):: names_invalid
46 ! 無効な変数名.
47 ! Invalid variable names.
48
49 character(STRING):: name, units, longname, var_info_str
50 character(TOKEN), pointer:: dims(:) =>null()
51 integer:: msnot_rank
52 integer:: stat, i
53 character(STRING):: cause_c
54 character(*), parameter:: subname = "HistoryAutoAllVarFix"
55 continue
56 call beginsub(subname)
57 stat = dc_noerr
58 cause_c = ""
59
60 ! 初期設定チェック
61 ! Check initialization
62 !
63 if ( .not. initialized ) then
64 stat = dc_enotinit
65 cause_c = 'gtool_historyauto'
66 goto 999
67 end if
68
69 ! 既に確定後であれば何もせずに終了.
70 ! Nothing is done after fixed
71 !
72 if ( flag_allvarfixed ) goto 999
73
74
75 ! 無効な変数名のチェック (初回のみ)
76 ! Check invalid variable names (at only first time)
77 !
79 & gthstnml = gthstnml, & ! (inout)
80 & invalid = allvar_invalid, names = names_invalid ) ! (out)
81
82 if ( len_trim(names_invalid) > (names_limit - 5) ) then
83 names_invalid = names_invalid(1:names_limit - 5) // ' ....'
84 end if
85
86 if ( allvar_invalid ) then
87 stat = hst_ebadvarname
88 cause_c = names_invalid
89 call messagenotify( 'W', subname, &
90 & 'names "%c" from NAMELIST "gtool_historyauto_nml" are invalid.', &
91 & c1 = trim(names_invalid) )
92 goto 999
93 end if
94
95 ! 登録された変数の印字 (初回のみ)
96 ! Print registered variables (at only first time)
97 !
98 msnot_rank = -1
99 if ( save_mpi_gather ) msnot_rank = 0
100 call messagenotify( 'M', sub_sname, '-------------------------------------------', rank_mpi = msnot_rank )
101 call messagenotify( 'M', sub_sname, '----- Registered variables for output -----', rank_mpi = msnot_rank )
102 call messagenotify( 'M', sub_sname, '-------------------------------------------', rank_mpi = msnot_rank )
103
104 do i = 1, numvars
105 call historyvarinfoinquire( &
106 & varinfo = gthst_vars(i), & ! (in)
107 & name = name, & ! (out) optional
108 & dims = dims, & ! (out) optional
109 & longname = longname, & ! (out) optional
110 & units = units ) ! (out) optional
111
112 var_info_str = trim( longname ) // ' [' // &
113 & trim( units ) // '] {' // &
114 & trim( joinchar( dims, ',' ) ) // '}'
115 deallocate( dims )
116
117 call messagenotify( 'M', sub_sname, ' %c (%c)', &
118 & c1 = trim(name), c2 = trim(var_info_str), rank_mpi = msnot_rank )
119
120 end do
121 call messagenotify( 'M', sub_sname, '-----', rank_mpi = msnot_rank )
122
123 ! フラグの設定
124 ! Set a flag
125 !
126 if ( .not. flag_allvarfixed ) flag_allvarfixed = .true.
127
128999 continue
129 call storeerror(stat, subname, cause_c = cause_c)
130 call endsub(subname, 'stat=%d', i = (/stat/) )
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:830
integer, parameter, public hst_ebadvarname
Definition dc_error.f90:587
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 dp
Double Precision Real number
Definition dc_types.f90:83
integer, parameter, public string
Character length for string
Definition dc_types.f90:118

References dc_error::dc_enotinit, dc_error::dc_noerr, dc_types::dp, dc_error::hst_ebadvarname, dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function: