@@ -70,6 +70,7 @@ module ocn_comp_mct
70
70
use ocn_submesoscale_eddies
71
71
use ocn_eddy_parameterization_helpers
72
72
use ocn_scaled_dismf
73
+ use ocn_scaled_sfwf
73
74
!
74
75
! !PUBLIC MEMBER FUNCTIONS:
75
76
implicit none
@@ -121,6 +122,8 @@ module ocn_comp_mct
121
122
integer :: itimestep, & ! time step number for MPAS
122
123
ocn_cpl_dt ! length of coupling interval in seconds - set by coupler/ ESMF
123
124
125
+ real (kind= RKIND) :: precFactor
126
+
124
127
!=======================================================================
125
128
126
129
contains
@@ -235,6 +238,12 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )!{{{
235
238
real (kind= RKIND), pointer :: &
236
239
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean
237
240
241
+ ! freshwater balance adjustment
242
+ logical , pointer :: config_use_precip_scaling
243
+ character (len= StrKIND), pointer :: config_precip_scaling_mode
244
+ real (kind= RKIND), pointer :: SFWFScalingFactor ! scaling factor on freshwater fluxes
245
+ real (kind= RKIND), pointer :: scalingFactor
246
+
238
247
#ifdef HAVE_MOAB
239
248
character * 100 outfile, wopts
240
249
integer :: ierrmb, numco, tagtype, tagindex, ent_type
@@ -833,6 +842,25 @@ end subroutine xml_stream_get_attributes
833
842
834
843
! initialize scaled data ice- shelf melt fluxes based on remove ice runoff
835
844
call ocn_init_scaled_dismf(domain)
845
+
846
+ ! Initialize the precipitation scaling scheme
847
+ call ocn_scaled_sfwf_init(domain)
848
+ ! Ensure a valid first guess at the initial time
849
+ call mpas_pool_get_config(domain % configs, ' config_use_precip_scaling' , config_use_precip_scaling)
850
+ if (config_use_precip_scaling) then
851
+ call mpas_pool_get_config(domain % configs, ' config_precip_scaling_mode' , config_precip_scaling_mode)
852
+ ! independent of space so should be no need to loop over blocks
853
+ block_ptr = > domain % blocklist
854
+ call mpas_pool_get_subpool(block_ptr % structs, ' forcing' , forcingPool)
855
+ call mpas_pool_get_array(forcingPool, " SFWFScalingFactor" , SFWFScalingFactor)
856
+ if (trim (config_precip_scaling_mode) == ' time-dependent' ) then
857
+ call mpas_pool_get_config(domain % configs, ' config_precip_scaling_initial_factor' , scalingFactor)
858
+ else if (trim (config_precip_scaling_mode) == ' constant' ) then
859
+ call mpas_pool_get_config(domain % configs, ' config_precip_scaling_constant_factor' , scalingFactor)
860
+ end if
861
+ ! Broadcast the scalar to the field
862
+ SFWFScalingFactor = scalingFactor
863
+ end if
836
864
end if
837
865
838
866
!-----------------------------------------------------------------------
@@ -881,6 +909,10 @@ end subroutine xml_stream_get_attributes
881
909
882
910
! initialize scaled data ice- shelf melt fluxes based on remove ice runoff
883
911
call ocn_init_scaled_dismf(domain)
912
+
913
+ ! initialize scaled data freshwater fluxes based on water balance relationship
914
+ call ocn_scaled_sfwf_init(domain)
915
+
884
916
end if
885
917
886
918
call t_stopf (' mpaso_mct_init' )
@@ -915,6 +947,16 @@ end subroutine xml_stream_get_attributes
915
947
call init_glc_z_levels(domain, ierr_local)
916
948
ierr = ior (ierr, ierr_local)
917
949
950
+ !configuration for freshwater conservation
951
+ call mpas_pool_get_config(domain % configs, ' config_use_precip_scaling' , config_use_precip_scaling)
952
+ if (config_use_precip_scaling) then
953
+ ! independent of space so should be no need to loop over blocks
954
+ block_ptr = > domain % blocklist
955
+ call mpas_pool_get_subpool(block_ptr % structs, ' forcing' , forcingPool)
956
+ call mpas_pool_get_array(forcingPool, " SFWFScalingFactor" , SFWFScalingFactor)
957
+ call seq_infodata_PutData(infodata, precip_fact= SFWFScalingFactor)
958
+ end if
959
+
918
960
!-----------------------------------------------------------------------
919
961
!
920
962
! get initial state from driver
@@ -1038,6 +1080,10 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
1038
1080
real (kind=RKIND), pointer :: &
1039
1081
runningMeanRemovedIceRunoff ! the area integrated, running mean of removed ice runoff from the ocean
1040
1082
1083
+ ! freshwater balance adjustment
1084
+ logical, pointer :: config_use_precip_scaling
1085
+ real (kind=RKIND), pointer :: SFWFScalingFactor ! scaling factor on freshwater fluxes
1086
+
1041
1087
#ifdef HAVE_MOAB
1042
1088
#ifdef MOABCOMP
1043
1089
real(r8) :: difference
@@ -1286,6 +1332,9 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
1286
1332
call mpas_log_write(' Validating ocean state' )
1287
1333
endif
1288
1334
1335
+ ! update scalling factors for freshwater fluxes
1336
+ call ocn_update_scaling_factor(domain, timeLevel= 1 )
1337
+
1289
1338
call ocn_validate_state(domain, timeLevel= 1 )
1290
1339
if (debugOn) call mpas_log_write(' Completed validating ocean state' )
1291
1340
@@ -1356,6 +1405,16 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{
1356
1405
call seq_infodata_PutData(infodata, rmean_rmv_ice_runoff= runningMeanRemovedIceRunoff)
1357
1406
end if
1358
1407
1408
+ !configuration for freshwater conservation
1409
+ call mpas_pool_get_config(domain % configs, ' config_use_precip_scaling' , config_use_precip_scaling)
1410
+ if (config_use_precip_scaling) then
1411
+ ! independent of space so should be no need to loop over blocks
1412
+ block_ptr = > domain % blocklist
1413
+ call mpas_pool_get_subpool(block_ptr % structs, ' forcing' , forcingPool)
1414
+ call mpas_pool_get_array(forcingPool, " SFWFScalingFactor" , SFWFScalingFactor)
1415
+ call seq_infodata_PutData(infodata, precip_fact= SFWFScalingFactor)
1416
+ end if
1417
+
1359
1418
! Reset I/ O logs
1360
1419
call shr_file_setLogUnit (shrlogunit)
1361
1420
call shr_file_setLogLevel(shrloglev)
@@ -1980,7 +2039,11 @@ subroutine ocn_import_mct(x2o_o, errorCode)!{{{
1980
2039
ecosysSeaIceCoupling, &
1981
2040
DMSSeaIceCoupling, &
1982
2041
MacroMoleculesSeaIceCoupling, &
1983
- CFCAuxiliary
2042
+ CFCAuxiliary, &
2043
+ conservationCheckEnergyAMPool, &
2044
+ conservationCheckMassAMPool, &
2045
+ conservationCheckSaltAMPool, &
2046
+ conservationCheckCarbonAMPool
1984
2047
1985
2048
integer , pointer :: nCellsSolve
1986
2049
@@ -2092,6 +2155,9 @@ subroutine ocn_import_mct(x2o_o, errorCode)!{{{
2092
2155
2093
2156
real (kind= RKIND) :: riverFactor
2094
2157
2158
+ ! freshwater balance adjustment
2159
+ logical , pointer :: config_use_precip_scaling
2160
+
2095
2161
!-----------------------------------------------------------------------
2096
2162
!
2097
2163
! zero out padded cells
@@ -2123,6 +2189,14 @@ subroutine ocn_import_mct(x2o_o, errorCode)!{{{
2123
2189
call mpas_pool_get_config(domain % configs, ' config_remove_ais_ice_runoff' , config_remove_ais_ice_runoff)
2124
2190
call mpas_pool_get_config(domain % configs, ' config_cvmix_kpp_use_theory_wave' , config_cvmix_kpp_use_theory_wave)
2125
2191
2192
+ precFactor = 1.0_RKIND ! Default to no scaling
2193
+ !configuration for freshwater balance constrains
2194
+ call mpas_pool_get_config(domain % configs, ' config_use_precip_scaling' , config_use_precip_scaling)
2195
+ if (config_use_precip_scaling) then
2196
+ !extract scaling factors
2197
+ call seq_infodata_GetData(infodata, precip_fact= precFactor)
2198
+ end if
2199
+
2126
2200
n = 0
2127
2201
removedRiverRunoffFluxThisProc = 0.0_RKIND
2128
2202
removedIceRunoffFluxThisProc = 0.0_RKIND
@@ -2379,7 +2453,7 @@ subroutine ocn_import_mct(x2o_o, errorCode)!{{{
2379
2453
end if
2380
2454
2381
2455
if ( rainFluxField % isActive ) then
2382
- rainFlux(i) = x2o_o % rAttr(index_x2o_Faxa_rain, n)
2456
+ rainFlux(i) = x2o_o % rAttr(index_x2o_Faxa_rain, n) * precFactor
2383
2457
end if
2384
2458
if ( atmosphericPressureField % isActive ) then
2385
2459
atmosphericPressure(i) = x2o_o % rAttr(index_x2o_Sa_pslv, n)
@@ -3955,7 +4029,7 @@ subroutine ocn_import_moab(Eclock, errorCode)!{{{
3955
4029
icebergHeatFlux(i) = x2o_om(n, index_x2o_Fioi_bergh)
3956
4030
end if
3957
4031
if ( snowFluxField % isActive ) then
3958
- snowFlux(i) = x2o_om(n, index_x2o_Faxa_snow)
4032
+ snowFlux(i) = x2o_om(n, index_x2o_Faxa_snow) * precFactor
3959
4033
end if
3960
4034
if ( seaIceFreshWaterFluxField % isActive ) then
3961
4035
seaIceFreshWaterFlux(i) = x2o_om(n, index_x2o_Fioi_meltw)
0 commit comments