Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "obl_def.fi"
!> @brief ocean boundary layer model config subroutines
module obl_config
! modules used
! --------------------------------------------------------------------------------
#ifdef USE_CONFIG_PARSER
use iso_c_binding, only: C_NULL_CHAR
use config_parser
#endif
! --------------------------------------------------------------------------------
! directives list
! --------------------------------------------------------------------------------
implicit none
! --------------------------------------------------------------------------------
public
!> @brief setup enum def.
integer, parameter :: setup_kato = 0 !< Kato-Phillips setup
integer, parameter :: setup_papa_fluxes = 1 !< Papa-station (fluxes) setup
integer, parameter :: setup_papa_meteo = 2 !< Papa-station (meteo) setup
character(len = 16), parameter :: setup_kato_tag = 'kato'
character(len = 16), parameter :: setup_papa_fluxes_tag = 'papa-fluxes'
character(len = 16), parameter :: setup_papa_meteo_tag = 'papa-meteo'
contains
function get_setup_id(tag) result(id)
implicit none
character(len=*), intent(in) :: tag
integer :: id
id = - 1
if (trim(tag) == trim(setup_kato_tag)) then
id = setup_kato
else if (trim(tag) == trim(setup_papa_fluxes_tag)) then
id = setup_papa_fluxes
else if (trim(tag) == trim(setup_papa_meteo_tag)) then
id = setup_papa_meteo
end if
end function
function get_setup_tag(id) result(tag)
implicit none
integer :: id
character(len=:), allocatable :: tag
tag = 'undefined'
if (id == setup_kato) then
tag = setup_kato_tag
else if (id == setup_papa_fluxes) then
tag = setup_papa_fluxes_tag
else if (id == setup_papa_meteo) then
tag = setup_papa_meteo_tag
end if
end function
! --------------------------------------------------------------------------------
subroutine set_grid(grid, setup_id, ierr)
!> @brief grid parameters setup
! ----------------------------------------------------------------------------
use obl_grid
use obl_run_kato, only : set_grid_kato => set_grid
use obl_run_papa_fluxes, only : set_grid_papa_fluxes => set_grid
use obl_run_papa_meteo, only : set_grid_papa_meteo => set_grid
type (gridDataType), intent(inout) :: grid
integer, intent(in) :: setup_id
integer, intent(out) :: ierr
! ----------------------------------------------------------------------------
ierr = 0 ! = OK
if (setup_id == setup_kato) then
call set_grid_kato(grid)
return
endif
if (setup_id == setup_papa_fluxes) then
call set_grid_papa_fluxes(grid)
return
endif
if (setup_id == setup_papa_meteo) then
call set_grid_papa_meteo(grid)
return
endif
#ifdef USE_CONFIG_PARSER
block
real :: depth
integer :: cz
integer :: status
call c_config_get_float("domain.depth"//C_NULL_CHAR, depth, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_int("grid.cz"//C_NULL_CHAR, cz, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call set_uniform_grid(grid, -depth, depth, cz)
end block
#else
!> unable to define without config
ierr = 1
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#endif
end subroutine set_grid
! --------------------------------------------------------------------------------
subroutine set_time(time_begin, time_end, dt, setup_id, ierr)
!> @brief time parameters setup
! ----------------------------------------------------------------------------
use obl_run_kato, only : set_time_kato => set_time
use obl_run_papa_fluxes, only : set_time_papa_fluxes => set_time
use obl_run_papa_meteo, only : set_time_papa_meteo => set_time
real, intent(out) :: time_begin, time_end, dt
integer, intent(in) :: setup_id
integer, intent(out) :: ierr
! ----------------------------------------------------------------------------
ierr = 0 ! = OK
if (setup_id == setup_kato) then
call set_time_kato(time_begin, time_end, dt)
return
endif
if (setup_id == setup_papa_fluxes) then
call set_time_papa_fluxes(time_begin, time_end, dt)
return
endif
if (setup_id == setup_papa_meteo) then
call set_time_papa_meteo(time_begin, time_end, dt)
return
endif
#ifdef USE_CONFIG_PARSER
block
integer :: status
call c_config_get_float("time.begin"//C_NULL_CHAR, time_begin, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("time.end"//C_NULL_CHAR, time_end, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("time.dt"//C_NULL_CHAR, dt, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
end block
#else
!> unable to define without config
ierr = 1
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#endif
end subroutine set_time
! --------------------------------------------------------------------------------
subroutine set_phys(setup_id, ierr)
!> @brief phys parameters setup
! ----------------------------------------------------------------------------
use obl_scm
use obl_run_kato, only : set_phys_kato => set_phys
use obl_run_papa_fluxes, only : set_phys_papa_fluxes => set_phys
use obl_run_papa_meteo, only : set_phys_papa_meteo => set_phys
integer, intent(in) :: setup_id
integer, intent(out) :: ierr
! ----------------------------------------------------------------------------
ierr = 0 ! = OK
if (setup_id == setup_kato) then
call set_phys_kato
return
endif
if (setup_id == setup_papa_fluxes) then
call set_phys_papa_fluxes
return
endif
if (setup_id == setup_papa_meteo) then
call set_phys_papa_meteo
return
endif
#ifdef USE_CONFIG_PARSER
block
integer :: status
call c_config_get_float("phys.f"//C_NULL_CHAR, f, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("phys.a_band_ratio"//C_NULL_CHAR, a_band_ratio, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("phys.a_extinction_coeff"//C_NULL_CHAR, a_extinction_coeff, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("phys.b_extinction_coeff"//C_NULL_CHAR, b_extinction_coeff, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
call c_config_get_float("phys.sw_albedo"//C_NULL_CHAR, sw_albedo, status)
if (status == 0) then
ierr = 1 ! signal ERROR
return
end if
end block
#else
!> unable to define without config
ierr = 1
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#endif
end subroutine set_phys
! --------------------------------------------------------------------------------
subroutine set_forcing(setup_id, ierr)
!> @brief phys parameters setup
! ----------------------------------------------------------------------------
use obl_fluxes
use obl_tforcing
use obl_math !< using char_array2str()
use obl_run_kato, only : set_forcing_kato => set_forcing
use obl_run_papa_fluxes, only : set_forcing_papa_fluxes => set_forcing
use obl_run_papa_meteo, only : set_forcing_papa_meteo => set_forcing
integer, intent(in) :: setup_id
integer, intent(out) :: ierr
! ----------------------------------------------------------------------------
ierr = 0 ! = OK
if (setup_id == setup_kato) then
call set_forcing_kato
return
endif
if (setup_id == setup_papa_fluxes) then
call set_forcing_papa_fluxes
return
endif
if (setup_id == setup_papa_meteo) then
call set_forcing_papa_meteo
return
endif
block
call set_config_tforcing(tau_x_surf, "atm.tau_x", ierr)
if (ierr /= 0) return
call set_config_tforcing(tau_y_surf, "atm.tau_y", ierr)
if (ierr /= 0) return
call set_config_tforcing(sensible_hflux_surf, "atm.sensible_hflux", ierr)
if (ierr /= 0) return
call set_config_tforcing(latent_hflux_surf, "atm.latent_hflux", ierr)
if (ierr /= 0) return
call set_config_tforcing(salin_flux_surf, "atm.salin_flux", ierr)
if (ierr /= 0) return
call set_config_tforcing(Ua, "atm.Ua", ierr)
if (ierr /= 0) return
call set_config_tforcing(Va, "atm.Va", ierr)
if (ierr /= 0) return
call set_config_tforcing(Ta, "atm.Ta", ierr)
if (ierr /= 0) return
call set_config_tforcing(Pa, "atm.Pa", ierr)
if (ierr /= 0) return
call set_config_tforcing(Qa, "atm.Qa", ierr)
if (ierr /= 0) return
call set_config_tforcing(RHa, "atm.RHa", ierr)
if (ierr /= 0) return
call set_config_tforcing(sw_flux_surf, "atm.sw_in", ierr)
if (ierr /= 0) return
call set_config_tforcing(lw_net_surf, "atm.lw_net", ierr)
if (ierr /= 0) return
call set_config_tforcing(lw_in_surf, "atm.lw_in", ierr)
if (ierr /= 0) return
!< default: using 'flux' mode
is_meteo_setup = 0
if ((Ua%num > 0).OR.(Va%num > 0).OR.(Ta%num > 0).OR.&
(Pa%num > 0).OR.(Qa%num > 0).OR.(RHa%num > 0)) then
is_meteo_setup = 1
endif
! ----------------------------------------------------------------------------
!< setting bottom forcing
! ----------------------------------------------------------------------------
call set_const_tforcing(hflux_bot, 0.0)
call set_const_tforcing(salin_flux_bot, 0.0)
call set_const_tforcing(tau_x_bot, 0.0)
call set_const_tforcing(tau_y_bot, 0.0)
! ----------------------------------------------------------------------------
!< check consistency
! *: not implemented
! ----------------------------------------------------------------------------
end block
!> assuming that surface fluxes could be not set
!> *: this will use LW[in] and calculate LW[out]
!> *: probably to better set = 0 in all explicitly
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
end subroutine set_forcing
! --------------------------------------------------------------------------------
subroutine set_initial_conditions(grid, setup_id, ierr)
!> @brief initial conditions setup
! ----------------------------------------------------------------------------
use obl_state
use obl_init
use obl_grid
use obl_run_kato, only : set_initial_conditions_kato => set_initial_conditions
use obl_run_papa_fluxes, only : set_initial_conditions_papa_fluxes => set_initial_conditions
use obl_run_papa_meteo, only : set_initial_conditions_papa_meteo => set_initial_conditions
type (gridDataType), intent(in) :: grid
integer, intent(in) :: setup_id
integer, intent(out) :: ierr
! ----------------------------------------------------------------------------
ierr = 0 ! = OK
if (setup_id == setup_kato) then
call set_initial_conditions_kato(grid)
return
endif
if (setup_id == setup_papa_fluxes) then
call set_initial_conditions_papa_fluxes(grid)
return
endif
if (setup_id == setup_papa_meteo) then
call set_initial_conditions_papa_meteo(grid)
return
endif
block
call set_config_profile(Theta, "initial_conditions.Theta", grid, ierr)
if (ierr /= 0) then
return
endif
call set_config_profile(Salin, "initial_conditions.Salin", grid, ierr)
if (ierr /= 0) then
return
endif
call set_config_profile(U, "initial_conditions.U", grid, ierr)
if (ierr /= 0) then
return
endif
call set_config_profile(V, "initial_conditions.V", grid, ierr)
if (ierr /= 0) then
return
endif
end block
end subroutine set_initial_conditions
end module obl_config