@@ -41,7 +41,7 @@ module MOM
41
41
use MOM_io, only : slasher, file_exists, MOM_read_data
42
42
use MOM_obsolete_params, only : find_obsolete_params
43
43
use MOM_restart, only : register_restart_field, register_restart_pair
44
- use MOM_restart, only : query_initialized, save_restart
44
+ use MOM_restart, only : query_initialized, save_restart, restart_registry_lock
45
45
use MOM_restart, only : restart_init, is_new_run, determine_is_new_run, MOM_restart_CS
46
46
use MOM_spatial_means, only : global_mass_integral
47
47
use MOM_time_manager, only : time_type, real_to_time, time_type_to_real, operator (+ )
@@ -2145,8 +2145,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2145
2145
if (associated (OBC_in)) then
2146
2146
! TODO: General OBC index rotations is not yet supported.
2147
2147
if (modulo (turns, 4 ) /= 1 ) &
2148
- call MOM_error(FATAL, " OBC index rotation of 180 and 270 degrees is " &
2149
- // " not yet unsupported." )
2148
+ call MOM_error(FATAL, " OBC index rotation of 180 and 270 degrees is not yet supported." )
2150
2149
allocate (CS% OBC)
2151
2150
call rotate_OBC_config(OBC_in, dG_in, CS% OBC, dG, turns)
2152
2151
endif
@@ -2167,8 +2166,6 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2167
2166
2168
2167
call MOM_timing_init(CS)
2169
2168
2170
- if (associated (CS% OBC)) call call_OBC_register(param_file, CS% update_OBC_CSp, US, CS% OBC)
2171
-
2172
2169
call tracer_registry_init(param_file, CS% tracer_Reg)
2173
2170
2174
2171
! Allocate and initialize space for the primary time-varying MOM variables.
@@ -2222,21 +2219,8 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2222
2219
flux_scale= conv2salt, convergence_units= ' kg m-2 s-1' , &
2223
2220
convergence_scale= 0.001 * GV% H_to_kg_m2, CMOR_tendprefix= " osalt" , diag_form= 2 )
2224
2221
endif
2225
- ! NOTE: register_temp_salt_segments includes allocation of tracer fields
2226
- ! along segments. Bit reproducibility requires that MOM_initialize_state
2227
- ! be called on the input index map, so we must setup both OBC and OBC_in.
2228
- !
2229
- ! XXX: This call on OBC_in allocates the tracer fields on the unrotated
2230
- ! grid, but also incorrectly stores a pointer to a tracer_type for the
2231
- ! rotated registry (e.g. segment%tr_reg%Tr(n)%Tr) from CS%tracer_reg.
2232
- !
2233
- ! While incorrect and potentially dangerous, it does not seem that this
2234
- ! pointer is used during initialization, so we leave it for now.
2235
- if (CS% rotate_index .and. associated (OBC_in)) &
2236
- call register_temp_salt_segments(GV, OBC_in, CS% tracer_Reg, param_file)
2237
- if (associated (CS% OBC)) &
2238
- call register_temp_salt_segments(GV, CS% OBC, CS% tracer_Reg, param_file)
2239
2222
endif
2223
+
2240
2224
if (use_frazil) then
2241
2225
allocate (CS% tv% frazil(isd:ied,jsd:jed)) ; CS% tv% frazil(:,:) = 0.0
2242
2226
endif
@@ -2329,11 +2313,38 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2329
2313
call mixedlayer_restrat_register_restarts(dG% HI, param_file, &
2330
2314
CS% mixedlayer_restrat_CSp, restart_CSp)
2331
2315
2332
- if (associated (CS% OBC)) &
2316
+ if (CS% rotate_index .and. associated (OBC_in) .and. use_temperature) then
2317
+ ! NOTE: register_temp_salt_segments includes allocation of tracer fields
2318
+ ! along segments. Bit reproducibility requires that MOM_initialize_state
2319
+ ! be called on the input index map, so we must setup both OBC and OBC_in.
2320
+ !
2321
+ ! XXX: This call on OBC_in allocates the tracer fields on the unrotated
2322
+ ! grid, but also incorrectly stores a pointer to a tracer_type for the
2323
+ ! rotated registry (e.g. segment%tr_reg%Tr(n)%Tr) from CS%tracer_reg.
2324
+ !
2325
+ ! While incorrect and potentially dangerous, it does not seem that this
2326
+ ! pointer is used during initialization, so we leave it for now.
2327
+ call register_temp_salt_segments(GV, OBC_in, CS% tracer_Reg, param_file)
2328
+ endif
2329
+
2330
+ if (associated (CS% OBC)) then
2331
+ ! Set up remaining information about open boundary conditions that is needed for OBCs.
2332
+ call call_OBC_register(param_file, CS% update_OBC_CSp, US, CS% OBC, CS% tracer_Reg)
2333
+ ! ### Package specific changes to OBCs need to go here?
2334
+
2335
+ ! This is the equivalent to 2 calls to register_segment_tracer (per segment), which
2336
+ ! could occur with the call to update_OBC_data or after the main initialization.
2337
+ if (use_temperature) &
2338
+ call register_temp_salt_segments(GV, CS% OBC, CS% tracer_Reg, param_file)
2339
+
2340
+ ! This needs the number of tracers and to have called any code that sets whether
2341
+ ! reservoirs are used.
2333
2342
call open_boundary_register_restarts(dg% HI, GV, CS% OBC, CS% tracer_Reg, &
2334
2343
param_file, restart_CSp, use_temperature)
2344
+ endif
2335
2345
2336
2346
call callTree_waypoint(" restart registration complete (initialize_MOM)" )
2347
+ call restart_registry_lock(restart_CSp)
2337
2348
2338
2349
! Shift from using the temporary dynamic grid type to using the final
2339
2350
! (potentially static) ocean-specific grid type.
@@ -2431,7 +2442,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2431
2442
turns, CS% u, CS% v, CS% h, CS% T, CS% S)
2432
2443
2433
2444
if (associated (sponge_in_CSp)) then
2434
- ! TODO: Implementation and testing of non-ALE spong rotation
2445
+ ! TODO: Implementation and testing of non-ALE sponge rotation
2435
2446
call MOM_error(FATAL, " Index rotation of non-ALE sponge is not yet implemented." )
2436
2447
endif
2437
2448
@@ -2471,19 +2482,11 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
2471
2482
endif
2472
2483
2473
2484
if (use_ice_shelf .and. CS% debug) &
2474
- call hchksum(CS% frac_shelf_h, " MOM:frac_shelf_h" , G% HI, &
2475
- haloshift= 0 )
2485
+ call hchksum(CS% frac_shelf_h, " MOM:frac_shelf_h" , G% HI, haloshift= 0 )
2476
2486
2477
2487
call cpu_clock_end(id_clock_MOM_init)
2478
2488
call callTree_waypoint(" returned from MOM_initialize_state() (initialize_MOM)" )
2479
2489
2480
- ! ! Need this after MOM_initialize_state for DOME OBC stuff.
2481
- ! if (associated(CS%OBC)) &
2482
- ! call open_boundary_register_restarts(G%HI, GV, CS%OBC, CS%tracer_Reg, &
2483
- ! param_file, restart_CSp, use_temperature)
2484
-
2485
- ! call callTree_waypoint("restart registration complete (initialize_MOM)")
2486
-
2487
2490
! From this point, there may be pointers being set, so the final grid type
2488
2491
! that will persist throughout the run has to be used.
2489
2492
@@ -2838,6 +2841,7 @@ subroutine finish_MOM_initialization(Time, dirs, CS, restart_CSp)
2838
2841
if (CS% write_IC) then
2839
2842
allocate (restart_CSp_tmp)
2840
2843
restart_CSp_tmp = restart_CSp
2844
+ call restart_registry_lock(restart_CSp_tmp, unlocked= .true. )
2841
2845
allocate (z_interface(SZI_(G),SZJ_(G),SZK_(GV)+ 1 ))
2842
2846
call find_eta(CS% h, CS% tv, G, GV, US, z_interface, eta_to_m= 1.0 )
2843
2847
call register_restart_field(z_interface, " eta" , .true. , restart_CSp_tmp, &
0 commit comments