dyed_obcs_initialization.F90
1! This file is part of MOM6, the Modular Ocean Model version 6.
2! See the LICENSE file for licensing information.
3! SPDX-License-Identifier: Apache-2.0
4
5!> Dyed open boundary conditions; OBC_USER_CONFIG="dyed_obcs"
6module dyed_obcs_initialization
7
8use mom_dyn_horgrid, only : dyn_horgrid_type
9use mom_error_handler, only : mom_mesg, mom_error, fatal, warning, is_root_pe
10use mom_file_parser, only : get_param, log_version, param_file_type
11use mom_get_input, only : directories
12use mom_grid, only : ocean_grid_type
13use mom_open_boundary, only : ocean_obc_type, obc_none
14use mom_open_boundary, only : obc_segment_type, register_segment_tracer
15use mom_tracer_registry, only : tracer_registry_type, tracer_name_lookup
16use mom_tracer_registry, only : tracer_type
17use mom_variables, only : thermo_var_ptrs
18use mom_verticalgrid, only : verticalgrid_type
19
20implicit none ; private
21
22#include <MOM_memory.h>
23
24public dyed_obcs_set_obc_data
25
26integer :: ntr = 0 !< Number of dye tracers
27 !! \todo This is a module variable. Move this variable into the control structure.
28real :: dye_obc_inflow = 0.0 !< Inflow value of obc dye concentration
29
30contains
31
32!> This subroutine sets the dye properties at open boundary conditions.
33subroutine dyed_obcs_set_obc_data(OBC, G, GV, param_file, tr_Reg)
34 type(ocean_obc_type), pointer :: obc !< This open boundary condition type specifies
35 !! whether, where, and what open boundary
36 !! conditions are used.
37 type(ocean_grid_type), intent(in) :: g !< The ocean's grid structure.
38 type(verticalgrid_type), intent(in) :: gv !< The ocean's vertical grid structure.
39 type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
40 !! to parse for model parameter values.
41 type(tracer_registry_type), pointer :: tr_reg !< Tracer registry.
42
43 ! Local variables
44 character(len=40) :: mdl = "dyed_obcs_set_OBC_data" ! This subroutine's name.
45 character(len=80) :: name, longname
46 integer :: is, ie, js, je, isd, ied, jsd, jed, m, n, nz, ntr_id
47 integer :: isdb, iedb, jsdb, jedb
48 integer :: n_dye ! Number of regionsl dye tracers
49 real :: dye ! Inflow dye concentration [arbitrary]
50 type(tracer_type), pointer :: tr_ptr => null()
51
52 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
53 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
54 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
55
56 if (.not.associated(obc)) return
57
58 call get_param(param_file, mdl, "NUM_DYED_TRACERS", ntr, &
59 "The number of dyed_obc tracers in this run. Each tracer "//&
60 "should have a separate boundary segment. "//&
61 "If not present, use NUM_DYE_TRACERS.", default=-1, do_not_log=.true.)
62 if (ntr == -1) then
63 !for backward compatibility
64 call get_param(param_file, mdl, "NUM_DYE_TRACERS", ntr, &
65 "The number of dye tracers in this run. Each tracer "//&
66 "should have a separate boundary segment.", default=0, do_not_log=.true.)
67 n_dye = 0
68 else
69 call get_param(param_file, mdl, "NUM_DYE_TRACERS", n_dye, &
70 "The number of dye tracers in this run. Each tracer "//&
71 "should have a separate region.", default=0, do_not_log=.true.)
72 endif
73
74 call get_param(param_file, mdl, "DYE_OBC_INFLOW", dye_obc_inflow, &
75 "The OBC inflow value of dye tracers.", units="kg kg-1", &
76 default=1.0)
77
78 if (obc%number_of_segments < ntr) then
79 call mom_error(warning, "Error in dyed_obc segment setup")
80 return !!! Need a better error message here
81 endif
82
83! ! Set the inflow values of the dyes, one per segment.
84! ! We know the order: north, south, east, west
85 do m=1,ntr
86 write(name,'("dye_",I2.2)') m+n_dye !after regional dye tracers
87 write(longname,'("Concentration of dyed_obc Tracer ",I2.2, " on segment ",I2.2)') m, m
88 call tracer_name_lookup(tr_reg, ntr_id, tr_ptr, name)
89
90 do n=1,obc%number_of_segments
91 if (n == m) then
92 dye = dye_obc_inflow
93 else
94 dye = 0.0
95 endif
96 call register_segment_tracer(tr_ptr, ntr_id, param_file, gv, &
97 obc%segment(n), obc_scalar=dye)
98 enddo
99 enddo
100
101end subroutine dyed_obcs_set_obc_data
102
103!> \namespace dyed_obcs_initialization
104!!
105!! Setting dyes, one for painting the inflow on each side.
106end module dyed_obcs_initialization