Skip to content

Commit 3f3e31d

Browse files
committed
Bug fixes to enable ML inference in the ODA module
Skip first day of ML/DA in MOM.F90 Add latitude limits for ML inference in MOM_oda_driver.F90
1 parent c8da4e8 commit 3f3e31d

File tree

3 files changed

+371
-342
lines changed

3 files changed

+371
-342
lines changed

src/core/MOM.F90

+1
Original file line numberDiff line numberDiff line change
@@ -3383,6 +3383,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, &
33833383

33843384
if (CS%ensemble_ocean) then
33853385
call init_oda(Time, G, GV, US, CS%diag, CS%odaCS)
3386+
call set_analysis_time(CS%Time,CS%odaCS)
33863387
endif
33873388

33883389
! initialize stochastic physics

src/ocean_data_assim/MOM_oda_driver.F90

+38-33
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ module MOM_oda_driver_mod
160160
type(INC_CS) :: INC_CS !< A Structure containing integer file handles for bias adjustment
161161
integer :: id_inc_t !< A diagnostic handle for the temperature climatological adjustment
162162
integer :: id_inc_s !< A diagnostic handle for the salinity climatological adjustment
163-
integer :: id_inc_ml_t !< A diagnostic handle for the temperature climatological adjustment
164-
integer :: id_inc_ml_s !< A diagnostic handle for the salinity climatological adjustment
163+
! integer :: id_inc_ml_t !< A diagnostic handle for the temperature climatological adjustment
164+
! integer :: id_inc_ml_s !< A diagnostic handle for the salinity climatological adjustment
165165
integer :: answer_date !< The vintage of the order of arithmetic and expressions in the
166166
!! remapping invoked by the ODA driver. Values below 20190101 recover
167167
!! the answers from the end of 2018, while higher values use updated
@@ -442,10 +442,10 @@ subroutine init_oda(Time, G, GV, US, diag_CS, CS)
442442
allocate(CS%ml_config)
443443
call oda_ml_init(CS%ml_config, CS%ml_data, CS%GV)
444444

445-
CS%id_inc_ml_t = register_diag_field('ocean_model', 'temp_ml_increment', diag_CS%axesTL, &
446-
Time, 'ocean potential temperature increments predicted by ML', 'degC', conversion=US%C_to_degC)
447-
CS%id_inc_ml_s = register_diag_field('ocean_model', 'salt_ml_increment', diag_CS%axesTL, &
448-
Time, 'ocean salinity increments predicted by ML', 'psu', conversion=US%S_to_ppt)
445+
! CS%id_inc_ml_t = register_diag_field('ocean_model', 'temp_ml_increment', diag_CS%axesTL, &
446+
! Time, 'ocean potential temperature increments predicted by ML', 'degC', conversion=US%C_to_degC)
447+
! CS%id_inc_ml_s = register_diag_field('ocean_model', 'salt_ml_increment', diag_CS%axesTL, &
448+
! Time, 'ocean salinity increments predicted by ML', 'psu', conversion=US%S_to_ppt)
449449

450450
allocate(CS%T_ml_tend(G%isd:G%ied,G%jsd:G%jed,CS%GV%ke), source=0.0)
451451
allocate(CS%S_ml_tend(G%isd:G%ied,G%jsd:G%jed,CS%GV%ke), source=0.0)
@@ -790,33 +790,38 @@ subroutine get_ML_bias_correction(Time, US, CS)
790790
!! Loop through all local gridpoints
791791
do j=CS%model_G%jsc,CS%model_G%jec ; do i=CS%model_G%isc,CS%model_G%iec
792792

793-
!! put local variables into ml_data
794-
CS%ml_data%T = CS%Ocean_background_ave%T(i,j,:)
795-
CS%ml_data%S = CS%Ocean_background_ave%S(i,j,:)
796-
CS%ml_data%U_left = CS%Ocean_background_ave%U(i-1,j,:)
797-
CS%ml_data%U_right = CS%Ocean_background_ave%U(i,j,:)
798-
CS%ml_data%V_north = CS%Ocean_background_ave%V(i,j,:)
799-
CS%ml_data%V_south = CS%Ocean_background_ave%V(i,j-1,:)
800-
CS%ml_data%latent = CS%Ocean_background_ave%latent(i,j)
801-
CS%ml_data%sensible = CS%Ocean_background_ave%sensible(i,j)
802-
CS%ml_data%lw = CS%Ocean_background_ave%lw(i,j)
803-
CS%ml_data%sw = CS%Ocean_background_ave%sw(i,j)
804-
CS%ml_data%taux_left = CS%Ocean_background_ave%taux(i-1,j)
805-
CS%ml_data%taux_right = CS%Ocean_background_ave%taux(i,j)
806-
CS%ml_data%tauy_north = CS%Ocean_background_ave%tauy(i,j)
807-
CS%ml_data%tauy_south = CS%Ocean_background_ave%tauy(i,j-1)
808-
809-
CS%ml_data%dyCu_left = CS%model_G%dyCu(i-1,j)
810-
CS%ml_data%dyCu_right = CS%model_G%dyCu(i,j)
811-
CS%ml_data%dxCv_north = CS%model_G%dxCv(i,j)
812-
CS%ml_data%dxCv_south = CS%model_G%dxCv(i,j-1)
813-
CS%ml_data%areacello = CS%model_G%areaT(i,j)
814-
815-
!! Call inference subroutine with the concatenated vector
816-
call oda_ml_inference(CS%ml_config, CS%ml_data)
817-
818-
CS%T_ml_tend(i,j,:) = CS%ml_data%T_inc
819-
CS%S_ml_tend(i,j,:) = CS%ml_data%S_inc
793+
if (CS%model_G%geolatT(i,j) > 60.0 .or. CS%model_G%geolatT(i,j) < -60.0) then
794+
CS%T_ml_tend(i,j,:) = 0.0
795+
CS%S_ml_tend(i,j,:) = 0.0
796+
else
797+
!! put local variables into ml_data
798+
CS%ml_data%T = CS%Ocean_background_ave%T(i,j,:)
799+
CS%ml_data%S = CS%Ocean_background_ave%S(i,j,:)
800+
CS%ml_data%U_left = CS%Ocean_background_ave%U(i-1,j,:)
801+
CS%ml_data%U_right = CS%Ocean_background_ave%U(i,j,:)
802+
CS%ml_data%V_north = CS%Ocean_background_ave%V(i,j,:)
803+
CS%ml_data%V_south = CS%Ocean_background_ave%V(i,j-1,:)
804+
CS%ml_data%latent = CS%Ocean_background_ave%latent(i,j)
805+
CS%ml_data%sensible = CS%Ocean_background_ave%sensible(i,j)
806+
CS%ml_data%lw = CS%Ocean_background_ave%lw(i,j)
807+
CS%ml_data%sw = CS%Ocean_background_ave%sw(i,j)
808+
CS%ml_data%taux_left = CS%Ocean_background_ave%taux(i-1,j)
809+
CS%ml_data%taux_right = CS%Ocean_background_ave%taux(i,j)
810+
CS%ml_data%tauy_north = CS%Ocean_background_ave%tauy(i,j)
811+
CS%ml_data%tauy_south = CS%Ocean_background_ave%tauy(i,j-1)
812+
813+
CS%ml_data%dyCu_left = CS%model_G%dyCu(i-1,j)
814+
CS%ml_data%dyCu_right = CS%model_G%dyCu(i,j)
815+
CS%ml_data%dxCv_north = CS%model_G%dxCv(i,j)
816+
CS%ml_data%dxCv_south = CS%model_G%dxCv(i,j-1)
817+
CS%ml_data%areacello = CS%model_G%areaT(i,j)
818+
819+
!! Call inference subroutine with the concatenated vector
820+
call oda_ml_inference(CS%ml_config, CS%ml_data)
821+
822+
CS%T_ml_tend(i,j,:) = CS%ml_data%T_inc
823+
CS%S_ml_tend(i,j,:) = CS%ml_data%S_inc
824+
endif
820825
enddo; enddo
821826

822827
CS%T_ml_tend = CS%T_ml_tend * CS%ml_bias_adjustment_multiplier

0 commit comments

Comments
 (0)