initialize First_guess (prior) and Analysis grid information for all ensemble members
116 type(time_type),
intent(in) :: time
117 type(ocean_grid_type),
pointer :: g
118 type(verticalgrid_type),
intent(in) :: gv
119 type(oda_cs),
pointer,
intent(inout) :: cs
122 type(thermo_var_ptrs) :: tv_dummy
123 type(dyn_horgrid_type),
pointer :: dg=> null()
124 type(hor_index_type),
pointer :: hi=> null()
125 type(directories) :: dirs
127 type(grid_type),
pointer :: t_grid
128 real,
dimension(:,:),
allocatable :: global2d, global2d_old
129 real,
dimension(:),
allocatable :: lon1d, lat1d, glon1d, glat1d
130 type(param_file_type) :: pf
131 integer :: n, m, k, i, j, nk
132 integer :: is,ie,js,je,isd,ied,jsd,jed
133 integer :: stdout_unit
134 character(len=32) :: assim_method
135 integer :: npes_pm, ens_info(6), ni, nj
136 character(len=128) :: mesg
137 character(len=32) :: fldnam
138 character(len=30) :: coord_mode
139 character(len=200) :: inputdir, basin_file
140 logical :: reentrant_x, reentrant_y, tripolar_n, symmetric
142 if (
associated(cs))
call mpp_error(fatal,
'Calling oda_init with associated control structure')
147 call get_mom_input(pf,dirs,ensemble_num=0)
149 call unit_scaling_init(pf, cs%US)
151 call get_param(pf,
"MOM",
"ASSIM_METHOD", assim_method, &
152 "String which determines the data assimilation method "//&
153 "Valid methods are: \'EAKF\',\'OI\', and \'NO_ASSIM\'", default=
'NO_ASSIM')
154 call get_param(pf,
"MOM",
"ASSIM_FREQUENCY", cs%assim_frequency, &
155 "data assimilation frequency in hours")
156 call get_param(pf,
"MOM",
"USE_REGRIDDING", cs%use_ALE_algorithm , &
157 "If True, use the ALE algorithm (regridding/remapping).\n"//&
158 "If False, use the layered isopycnal algorithm.", default=.false. )
159 call get_param(pf,
"MOM",
"REENTRANT_X", cs%reentrant_x, &
160 "If true, the domain is zonally reentrant.", default=.true.)
161 call get_param(pf,
"MOM",
"REENTRANT_Y", cs%reentrant_y, &
162 "If true, the domain is meridionally reentrant.", &
164 call get_param(pf,
"MOM",
"TRIPOLAR_N", cs%tripolar_N, &
165 "Use tripolar connectivity at the northern edge of the "//&
166 "domain. With TRIPOLAR_N, NIGLOBAL must be even.", &
168 call get_param(pf,
"MOM",
"NIGLOBAL", cs%ni, &
169 "The total number of thickness grid points in the "//&
170 "x-direction in the physical domain.")
171 call get_param(pf,
"MOM",
"NJGLOBAL", cs%nj, &
172 "The total number of thickness grid points in the "//&
173 "y-direction in the physical domain.")
174 call get_param(pf,
'MOM',
"INPUTDIR", inputdir)
175 inputdir = slasher(inputdir)
177 select case(lowercase(trim(assim_method)))
179 cs%assim_method = eakf_assim
181 cs%assim_method = oi_assim
183 cs%assim_method = no_assim
185 call mpp_error(fatal,
'Invalid assimilation method provided')
188 ens_info = get_ensemble_size()
189 cs%ensemble_size = ens_info(1)
191 cs%ensemble_id = get_ensemble_id()
193 allocate(cs%ensemble_pelist(cs%ensemble_size,npes_pm))
194 allocate(cs%filter_pelist(cs%ensemble_size*npes_pm))
195 call get_ensemble_pelist(cs%ensemble_pelist,
'ocean')
196 call get_ensemble_filter_pelist(cs%filter_pelist,
'ocean')
198 call set_current_pelist(cs%filter_pelist)
200 allocate(cs%domains(cs%ensemble_size))
201 cs%domains(cs%ensemble_id)%mpp_domain => g%Domain%mpp_domain
202 do n=1,cs%ensemble_size
203 if (.not.
associated(cs%domains(n)%mpp_domain))
allocate(cs%domains(n)%mpp_domain)
204 call set_root_pe(cs%ensemble_pelist(n,1))
205 call mpp_broadcast_domain(cs%domains(n)%mpp_domain)
207 call set_root_pe(cs%filter_pelist(1))
210 call mom_domains_init(cs%Grid%Domain,pf,param_suffix=
'_ODA')
212 call hor_index_init(cs%Grid%Domain, hi, pf, &
213 local_indexing=.false.)
214 call verticalgridinit( pf, cs%GV, cs%US )
216 call create_dyn_horgrid(dg, hi)
217 call clone_mom_domain(cs%Grid%Domain, dg%Domain,symmetric=.false.)
218 call set_grid_metrics(dg,pf)
219 call mom_initialize_topography(dg%bathyT,dg%max_depth,dg,pf)
220 call mom_initialize_coord(cs%GV, cs%US, pf, .false., &
221 dirs%output_directory, tv_dummy, dg%max_depth)
222 call ale_init(pf, cs%GV, cs%US, dg%max_depth, cs%ALE_CS)
223 call mom_grid_init(cs%Grid, pf, global_indexing=.true.)
224 call ale_updateverticalgridtype(cs%ALE_CS, cs%GV)
225 call copy_dyngrid_to_mom_grid(dg, cs%Grid, cs%US)
226 cs%mpp_domain => cs%Grid%Domain%mpp_domain
227 cs%Grid%ke = cs%GV%ke
230 allocate(cs%Ocean_prior)
231 call init_ocean_ensemble(cs%Ocean_prior,cs%Grid,cs%GV,cs%ensemble_size)
232 allocate(cs%Ocean_posterior)
233 call init_ocean_ensemble(cs%Ocean_posterior,cs%Grid,cs%GV,cs%ensemble_size)
236 call get_param(pf,
'oda_driver',
"REGRIDDING_COORDINATE_MODE", coord_mode, &
237 "Coordinate mode for vertical regridding.", &
238 default=
"ZSTAR", fail_if_missing=.false.)
239 call initialize_regridding(cs%regridCS, cs%GV, cs%US, dg%max_depth,pf,
'oda_driver',coord_mode,
'',
'')
240 call initialize_remapping(cs%remapCS,
'PLM')
241 call set_regrid_params(cs%regridCS, min_thickness=0.)
242 call mpp_get_data_domain(g%Domain%mpp_domain,isd,ied,jsd,jed)
243 if (.not.
associated(cs%h))
then 244 allocate(cs%h(isd:ied,jsd:jed,cs%GV%ke)); cs%h(:,:,:)=0.0
246 call ale_initthicknesstocoord(cs%ALE_CS,g,cs%GV,cs%h)
248 allocate(cs%tv%T(isd:ied,jsd:jed,cs%GV%ke)); cs%tv%T(:,:,:)=0.0
249 allocate(cs%tv%S(isd:ied,jsd:jed,cs%GV%ke)); cs%tv%S(:,:,:)=0.0
251 call set_axes_info(cs%Grid, cs%GV, cs%US, pf, cs%diag_cs, set_vertical=.true.)
253 call mpp_get_data_domain(cs%mpp_domain,isd,ied,jsd,jed)
254 allocate(cs%oda_grid)
255 cs%oda_grid%x => cs%Grid%geolonT
256 cs%oda_grid%y => cs%Grid%geolatT
258 call get_param(pf,
'oda_driver',
"BASIN_FILE", basin_file, &
259 "A file in which to find the basin masks, in variable 'basin'.", &
261 basin_file = trim(inputdir) // trim(basin_file)
262 allocate(cs%oda_grid%basin_mask(isd:ied,jsd:jed))
263 cs%oda_grid%basin_mask(:,:) = 0.0
264 call mom_read_data(basin_file,
'basin',cs%oda_grid%basin_mask,cs%Grid%domain, timelevel=1)
268 allocate(t_grid%x(cs%ni,cs%nj))
269 allocate(t_grid%y(cs%ni,cs%nj))
270 allocate(t_grid%basin_mask(cs%ni,cs%nj))
271 call mpp_global_field(cs%mpp_domain, cs%Grid%geolonT, t_grid%x)
272 call mpp_global_field(cs%mpp_domain, cs%Grid%geolatT, t_grid%y)
273 call mpp_global_field(cs%mpp_domain, cs%oda_grid%basin_mask, t_grid%basin_mask)
277 allocate(t_grid%mask(cs%ni,cs%nj,cs%nk))
278 allocate(t_grid%z(cs%ni,cs%nj,cs%nk))
279 allocate(global2d(cs%ni,cs%nj))
280 allocate(global2d_old(cs%ni,cs%nj))
281 t_grid%mask(:,:,:) = 0.0
282 t_grid%z(:,:,:) = 0.0
285 call mpp_global_field(g%Domain%mpp_domain, cs%h(:,:,k), global2d)
286 do i=1, cs%ni;
do j=1, cs%nj
287 if ( global2d(i,j) > 1 )
then 288 t_grid%mask(i,j,k) = 1.0
292 t_grid%z(:,:,k) = global2d/2
294 t_grid%z(:,:,k) = t_grid%z(:,:,k-1) + (global2d + global2d_old)/2
296 global2d_old = global2d
299 call ocean_da_core_init(cs%mpp_domain, t_grid, cs%Profiles, time)
303 call set_current_pelist(cs%ensemble_pelist(cs%ensemble_id,:))