hstnmlinfocreate.f90
Go to the documentation of this file.
1 != GTHST_NMLINFO 型の変数の初期設定
2 != Constructor of "GTHST_NMLINFO"
3 !
4 ! Authors:: Yasuhiro MORIKAWA
5 ! Version:: $Id: hstnmlinfocreate.f90,v 1.2 2009-10-10 10:59:00 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 hstnmlinfocreate( gthstnml, &
11  & interval_value, &
12  & interval_unit, &
13  & precision, &
14  & time_average, average, &
15  & fileprefix, &
16  & origin_value, origin_unit, &
17  & terminus_value, terminus_unit, &
18  & slice_start, slice_end, slice_stride, &
19  & space_average, &
20  & newfile_intvalue, newfile_intunit, &
21  & err )
22  !
23  ! GTHST_NMLINFO 型の変数の初期設定を行います.
24  ! 他のサブルーチンを使用する前に必ずこのサブルーチンによって
25  ! GTHST_NMLINFO 型の変数を初期設定してください.
26  !
27  ! *interval_value*,
28  ! *interval_unit*,
29  ! *precision*,
30  ! *time_average* (旧 *average*) などの変数
31  ! はデフォルト値として設定されます.
32  ! *fileprefix* は各変数の出力ファイル名の接頭詞として
33  ! 使用されます.
34  !
35  ! なお, 与えられた *gthstnml* が既に初期設定されている場合,
36  ! プログラムはエラーを発生させます.
37  !
38  ! Constructor of "GTHST_NMLINFO".
39  ! Initialize *gthstnml* by this subroutine,
40  ! before other procedures are used,
41  !
42  ! *interval_value*,
43  ! *interval_unit*,
44  ! *precision*,
45  ! *time_average* (now-defunct *average*), etc.
46  ! are set as default values.
47  ! *fileprefix* is used as prefixes of output filenames of
48  ! each variable.
49  !
50  ! Note that if *gthstnml* is already initialized
51  ! by this procedure, error is occurred.
52  !
55  use gtool_history, only: gt_history
56  use dc_trace, only: beginsub, endsub
58  use dc_types, only: dp, string, token, stdout
60  use dc_message, only: messagenotify
63  use dc_date_types, only: dc_difftime
64  use dc_date, only: dcdifftimecreate
65  use netcdf, only: nf90_max_dims
66  implicit none
67  type(gthst_nmlinfo), intent(inout):: gthstnml
68  real(DP), intent(in), optional:: interval_value
69  ! ヒストリデータの出力間隔の数値.
70  ! 負の値を与えると, 出力を抑止します.
71  !
72  ! Numerical value for interval of history data output.
73  ! Negative values suppresses output.
74  character(*), intent(in), optional:: interval_unit
75  ! ヒストリデータの出力間隔の単位.
76  ! Unit for interval of history data output
77  character(*), intent(in), optional:: precision
78  ! ヒストリデータの精度.
79  ! Precision of history data
80  logical, intent(in), optional:: time_average
81  ! 出力データの時間平均化フラグ.
82  ! Flag for time average of output data.
83  logical, intent(in), optional:: average
84  ! time_average の旧版.
85  ! Old version of "time_average"
86  character(*), intent(in), optional:: fileprefix
87  ! ヒストリデータのファイル名の接頭詞.
88  ! Prefixes of history data filenames
89  real(DP), intent(in), optional:: origin_value
90  ! 出力開始時刻.
91  ! Start time of output.
92  character(*), intent(in), optional:: origin_unit
93  ! 出力開始時刻の単位.
94  ! Unit of start time of output.
95  real(DP), intent(in), optional:: terminus_value
96  ! 出力終了時刻.
97  ! End time of output.
98  character(*), intent(in), optional:: terminus_unit
99  ! 出力終了時刻の単位.
100  ! Unit of end time of output.
101  integer, intent(in), optional:: slice_start(:)
102  ! 空間方向の開始点.
103  ! Start points of spaces.
104  integer, intent(in), optional:: slice_end(:)
105  ! 空間方向の終了点.
106  ! End points of spaces.
107  integer, intent(in), optional:: slice_stride(:)
108  ! 空間方向の刻み幅.
109  ! Strides of spaces.
110  logical, intent(in), optional:: space_average(:)
111  ! 平均化のフラグ.
112  ! Flag of average.
113  integer, intent(in), optional:: newfile_intvalue
114  ! ファイル分割時間間隔.
115  ! Interval of time of separation of a file.
116  character(*), intent(in), optional:: newfile_intunit
117  ! ファイル分割時間間隔の単位.
118  ! Unit of interval of time of separation of a file.
119  logical, intent(out), optional:: err
120  ! 例外処理用フラグ.
121  ! デフォルトでは, この手続き内でエラーが
122  ! 生じた場合, プログラムは強制終了します.
123  ! 引数 *err* が与えられる場合,
124  ! プログラムは強制終了せず, 代わりに
125  ! *err* に .true. が代入されます.
126  !
127  ! Exception handling flag.
128  ! By default, when error occur in
129  ! this procedure, the program aborts.
130  ! If this *err* argument is given,
131  ! .true. is substituted to *err* and
132  ! the program does not abort.
133 
134  !-----------------------------------
135  ! 作業変数
136  ! Work variables
137  type(dc_difftime):: interval_time
138  integer:: stat, ary_size
139  character(STRING):: cause_c
140  character(*), parameter:: subname = 'HstNmlInfoCreate'
141  continue
142  call beginsub( subname, &
143  & fmt = '@interval_value=%r @interval_unit=%c @precision=%c @time_average=%y @fileprefix=%c', &
144  & d = (/ present_select(.true., -1.0_dp, interval_value) /), &
145  & c1 = trim( present_select(.true., '<no>', interval_unit) ), &
146  & c2 = trim( present_select(.true., '<no>', precision) ), &
147  & l = (/ present_and_true(time_average) /), &
148  & c3 = trim( present_select(.true., '<no>', fileprefix) ), &
149  & version = version )
150  stat = dc_noerr
151  cause_c = ''
152 
153  !-----------------------------------------------------------------
154  ! 初期設定のチェック
155  ! Check initialization
156  !-----------------------------------------------------------------
157  if ( gthstnml % initialized ) then
158  stat = dc_ealreadyinit
159  cause_c = 'GTHST_NMLINFO'
160  goto 999
161  end if
162 
163  !-----------------------------------------------------------------
164  ! 割付
165  ! Allocate
166  !-----------------------------------------------------------------
167  allocate( gthstnml % gthstnml_list )
168  nullify( gthstnml % gthstnml_list % next )
169 
170  !-----------------------------------------------------------------
171  ! デフォルト値の設定
172  ! Configure default values
173  !-----------------------------------------------------------------
174  gthstnml % gthstnml_list % name = ''
175  gthstnml % gthstnml_list % file = ''
176 
177  allocate( gthstnml % gthstnml_list % interval_value )
178  allocate( gthstnml % gthstnml_list % interval_unit )
179  allocate( gthstnml % gthstnml_list % precision )
180  allocate( gthstnml % gthstnml_list % time_average )
181  allocate( gthstnml % gthstnml_list % fileprefix )
182 
183  allocate( gthstnml % gthstnml_list % origin_value )
184  allocate( gthstnml % gthstnml_list % origin_unit )
185  allocate( gthstnml % gthstnml_list % terminus_value )
186  allocate( gthstnml % gthstnml_list % terminus_unit )
187  allocate( gthstnml % gthstnml_list % slice_start (1:nf90_max_dims) )
188  allocate( gthstnml % gthstnml_list % slice_end (1:nf90_max_dims) )
189  allocate( gthstnml % gthstnml_list % slice_stride (1:nf90_max_dims) )
190  allocate( gthstnml % gthstnml_list % space_average (1:nf90_max_dims) )
191  allocate( gthstnml % gthstnml_list % newfile_intvalue )
192  allocate( gthstnml % gthstnml_list % newfile_intunit )
193 
194 
195  gthstnml % gthstnml_list % interval_value = -1.0
196  gthstnml % gthstnml_list % interval_unit = 'sec'
197  gthstnml % gthstnml_list % precision = 'float'
198  gthstnml % gthstnml_list % time_average = .false.
199  gthstnml % gthstnml_list % fileprefix = ''
200 
201  gthstnml % gthstnml_list % origin_value = -1.0
202  gthstnml % gthstnml_list % origin_unit = 'sec'
203  gthstnml % gthstnml_list % terminus_value = -1.0
204  gthstnml % gthstnml_list % terminus_unit = 'sec'
205  gthstnml % gthstnml_list % slice_start = 1
206  gthstnml % gthstnml_list % slice_end = -1
207  gthstnml % gthstnml_list % slice_stride = 1
208  gthstnml % gthstnml_list % space_average = .false.
209  gthstnml % gthstnml_list % newfile_intvalue = -1
210  gthstnml % gthstnml_list % newfile_intunit = 'sec'
211 
212  if ( present(interval_value) ) gthstnml % gthstnml_list % interval_value = interval_value
213  if ( present(interval_unit) ) gthstnml % gthstnml_list % interval_unit = interval_unit
214  if ( present(precision) ) gthstnml % gthstnml_list % precision = precision
215 
216  if ( present(average) ) gthstnml % gthstnml_list % time_average = average
217  if ( present(time_average) ) gthstnml % gthstnml_list % time_average = time_average
218  if ( present(fileprefix) ) gthstnml % gthstnml_list % fileprefix = fileprefix
219 
220  if ( present(origin_value ) ) gthstnml % gthstnml_list % origin_value = origin_value
221  if ( present(origin_unit ) ) gthstnml % gthstnml_list % origin_unit = origin_unit
222  if ( present(terminus_value ) ) gthstnml % gthstnml_list % terminus_value = terminus_value
223  if ( present(terminus_unit ) ) gthstnml % gthstnml_list % terminus_unit = terminus_unit
224  if ( present(slice_start ) ) then
225  ary_size = size(slice_start)
226  gthstnml % gthstnml_list % slice_start(1:ary_size) = slice_start
227  end if
228  if ( present(slice_end ) ) then
229  ary_size = size(slice_end)
230  gthstnml % gthstnml_list % slice_end(1:ary_size) = slice_end
231  end if
232  if ( present(slice_stride ) ) then
233  ary_size = size(slice_stride)
234  gthstnml % gthstnml_list % slice_stride(1:ary_size) = slice_stride
235  end if
236  if ( present(space_average ) ) then
237  ary_size = size(space_average)
238  gthstnml % gthstnml_list % space_average(1:ary_size) = space_average
239  end if
240  if ( present(newfile_intvalue) ) gthstnml % gthstnml_list % newfile_intvalue = newfile_intvalue
241  if ( present(newfile_intunit ) ) gthstnml % gthstnml_list % newfile_intunit = newfile_intunit
242 
243  !-----------------------------------------------------------------
244  ! 時間の単位のチェック
245  ! Check unit of time
246  !-----------------------------------------------------------------
247  call dcdifftimecreate( &
248  & diff = interval_time, & ! (out)
249  & value = &
250  & real( gthstnml % gthstnml_list % interval_value, DP ), & ! (in)
251  & unit = gthstnml % gthstnml_list % interval_unit, & ! (in)
252  & err = err ) ! (out)
253  if ( present_and_true( err ) ) then
254  stat = usr_errno
255  goto 999
256  end if
257 
258  !-----------------------------------------------------------------
259  ! 終了処理, 例外処理
260  ! Termination and Exception handling
261  !-----------------------------------------------------------------
262  gthstnml % initialized = .true.
263  gthstnml % define_mode = .true.
264 999 continue
265  call storeerror( stat, subname, err, cause_c )
266  call endsub( subname )
267  end subroutine hstnmlinfocreate
integer, parameter, public dc_earglack
Definition: dc_error.f90:569
integer, parameter, public usr_errno
Definition: dc_error.f90:604
integer, parameter, public dc_enofileread
Definition: dc_error.f90:566
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
logical function, public present_and_true(arg)
Definition: dc_present.f90:80
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
character(*), parameter, public version
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
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
subroutine hstnmlinfocreate(gthstnml, interval_value, interval_unit, precision, time_average, average, fileprefix, origin_value, origin_unit, terminus_value, terminus_unit, slice_start, slice_end, slice_stride, space_average, newfile_intvalue, newfile_intunit, err)
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 dc_ealreadyinit
Definition: dc_error.f90:558
integer, parameter, public dc_enegative
Definition: dc_error.f90:568
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118