22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
56 use dc_trace, only: beginsub, endsub
57 use dc_string, only: putline, printf, split, strinclude, stoa, joinchar
59 use dc_present, only: present_and_not_empty, present_and_true, present_select
60 use dc_message, only: messagenotify
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
73
74 character(*), intent(in), optional:: interval_unit
75
76
77 character(*), intent(in), optional:: precision
78
79
80 logical, intent(in), optional:: time_average
81
82
83 logical, intent(in), optional:: average
84
85
86 character(*), intent(in), optional:: fileprefix
87
88
89 real(DP), intent(in), optional:: origin_value
90
91
92 character(*), intent(in), optional:: origin_unit
93
94
95 real(DP), intent(in), optional:: terminus_value
96
97
98 character(*), intent(in), optional:: terminus_unit
99
100
101 integer, intent(in), optional:: slice_start(:)
102
103
104 integer, intent(in), optional:: slice_end(:)
105
106
107 integer, intent(in), optional:: slice_stride(:)
108
109
110 logical, intent(in), optional:: space_average(:)
111
112
113 integer, intent(in), optional:: newfile_intvalue
114
115
116 character(*), intent(in), optional:: newfile_intunit
117
118
119 logical, intent(out), optional:: err
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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) ), &
151 cause_c = ''
152
153
154
155
156
157 if ( gthstnml % initialized ) then
159 cause_c = 'GTHST_NMLINFO'
160 goto 999
161 end if
162
163
164
165
166
167 allocate( gthstnml % gthstnml_list )
168 nullify( gthstnml % gthstnml_list % next )
169
170
171
172
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
246
247 call dcdifftimecreate( &
248 & diff = interval_time, &
249 & value = &
250 & real( gthstnml % gthstnml_list % interval_value,
dp ), &
251 & unit = gthstnml % gthstnml_list % interval_unit, &
252 & err = err )
253 if ( present_and_true( err ) ) then
255 goto 999
256 end if
257
258
259
260
261
262 gthstnml % initialized = .true.
263 gthstnml % define_mode = .true.
264999 continue
265 call storeerror( stat, subname, err, cause_c )
266 call endsub( subname )
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public usr_errno
integer, parameter, public dc_ealreadyinit
integer, parameter, public dc_earglack
integer, parameter, public dc_noerr
integer, parameter, public dc_enegative
integer, parameter, public dc_enofileread
Provides kind type parameter values.
integer, parameter, public stdout
Unit number for Standard OUTPUT
integer, parameter, public token
Character length for word, token
integer, parameter, public dp
Double Precision Real number
integer, parameter, public string
Character length for string
character(*), parameter, public version