Skip to content

Commit 83ad1f1

Browse files
author
Henri Drake
committed
Added more parentheses to preserve order of operations
Continues to address @Hallberg-NOAA's [concern](NOAA-GFDL/SIS2#214 (comment)) that these diagnostics could change with the level of compiler optimization by adding parentheses to preserve the order in which fluxes are added together. However, there are some locations where I did not see how this was possible, as in this comment: NOAA-GFDL/SIS2#214 (comment)
1 parent 37d1385 commit 83ad1f1

File tree

10 files changed

+64
-66
lines changed

10 files changed

+64
-66
lines changed

config_src/drivers/STALE_mct_cap/mom_surface_forcing_mct.F90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
424424
if (associated(IOB%lprec)) &
425425
fluxes%lprec(i,j) = kg_m2_s_conversion * IOB%lprec(i-i0,j-j0) * G%mask2dT(i,j)
426426

427+
! water flux due to sea ice and snow melt [kg/m2/s]
428+
if (associated(IOB%seaice_melt)) &
429+
fluxes%seaice_melt(i,j) = kg_m2_s_conversion * IOB%seaice_melt(i-i0,j-j0) * G%mask2dT(i,j)
430+
427431
! frozen precipitation (snow)
428432
if (associated(IOB%fprec)) &
429433
fluxes%fprec(i,j) = kg_m2_s_conversion * IOB%fprec(i-i0,j-j0) * G%mask2dT(i,j)
@@ -477,10 +481,6 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
477481
if (associated(IOB%seaice_melt_heat)) &
478482
fluxes%seaice_melt_heat(i,j) = G%mask2dT(i,j) * US%W_m2_to_QRZ_T * IOB%seaice_melt_heat(i-i0,j-j0)
479483

480-
! water flux due to sea ice and snow melt [kg/m2/s]
481-
if (associated(IOB%seaice_melt)) &
482-
fluxes%seaice_melt(i,j) = G%mask2dT(i,j) * kg_m2_s_conversion * IOB%seaice_melt(i-i0,j-j0)
483-
484484
! latent heat flux (W/m^2)
485485
fluxes%latent(i,j) = 0.0
486486
! contribution from frozen ppt (notice minus sign since fprec is positive into the ocean)
@@ -550,7 +550,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
550550
if (CS%use_net_FW_adjustment_sign_bug) sign_for_net_FW_bug = -1.
551551
do j=js,je ; do i=is,ie
552552
net_FW(i,j) = US%RZ_T_to_kg_m2s * &
553-
(((fluxes%lprec(i,j) + fluxes%fprec(i,j) + fluxes%seaice_melt(i,j)) + &
553+
((((fluxes%lprec(i,j) + fluxes%seaice_melt(i,j)) + fluxes%fprec(i,j)) + &
554554
(fluxes%lrunoff(i,j) + fluxes%frunoff(i,j))) + &
555555
(fluxes%evap(i,j) + fluxes%vprec(i,j)) ) * US%L_to_m**2*G%areaT(i,j)
556556

config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
456456
if (associated(IOB%lprec)) &
457457
fluxes%lprec(i,j) = kg_m2_s_conversion * IOB%lprec(i-i0,j-j0) * G%mask2dT(i,j)
458458

459+
! water flux due to sea ice and snow melt [kg/m2/s]
460+
if (associated(IOB%seaice_melt)) &
461+
fluxes%seaice_melt(i,j) = kg_m2_s_conversion * G%mask2dT(i,j) * IOB%seaice_melt(i-i0,j-j0)
462+
459463
if (associated(IOB%fprec)) &
460464
fluxes%fprec(i,j) = kg_m2_s_conversion * IOB%fprec(i-i0,j-j0) * G%mask2dT(i,j)
461465

@@ -491,10 +495,6 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
491495
if (associated(IOB%seaice_melt_heat)) &
492496
fluxes%seaice_melt_heat(i,j) = US%W_m2_to_QRZ_T * G%mask2dT(i,j) * IOB%seaice_melt_heat(i-i0,j-j0)
493497

494-
! water flux due to sea ice and snow melt [kg/m2/s]
495-
if (associated(IOB%seaice_melt)) &
496-
fluxes%seaice_melt(i,j) = kg_m2_s_conversion * G%mask2dT(i,j) * IOB%seaice_melt(i-i0,j-j0)
497-
498498
fluxes%latent(i,j) = 0.0
499499
! notice minus sign since fprec is positive into the ocean
500500
if (associated(IOB%fprec)) then

config_src/drivers/solo_driver/MESO_surface_forcing.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
7474
! can be simply set to zero. The net fresh water flux should probably be
7575
! set in fluxes%evap and fluxes%lprec, with any salinity restoring
7676
! appearing in fluxes%vprec, and the other water flux components
77-
! (fprec, lrunoff and frunoff) left as arrays full of zeros.
77+
! (fprec, lrunoff and frunoff, seaice_melt) left as arrays full of zeros.
7878
! Evap is usually negative and precip is usually positive. All heat fluxes
7979
! are in W m-2 and positive for heat going into the ocean. All fresh water
8080
! fluxes are in kg m-2 s-1 and positive for water moving into the ocean.
@@ -98,8 +98,8 @@ subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
9898
if (CS%use_temperature) then
9999
call safe_alloc_ptr(fluxes%evap, isd, ied, jsd, jed)
100100
call safe_alloc_ptr(fluxes%lprec, isd, ied, jsd, jed)
101-
call safe_alloc_ptr(fluxes%fprec, isd, ied, jsd, jed)
102101
call safe_alloc_ptr(fluxes%seaice_melt, isd, ied, jsd, jed)
102+
call safe_alloc_ptr(fluxes%fprec, isd, ied, jsd, jed)
103103
call safe_alloc_ptr(fluxes%lrunoff, isd, ied, jsd, jed)
104104
call safe_alloc_ptr(fluxes%frunoff, isd, ied, jsd, jed)
105105
call safe_alloc_ptr(fluxes%vprec, isd, ied, jsd, jed)

config_src/drivers/solo_driver/MOM_surface_forcing.F90

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,8 @@ subroutine buoyancy_forcing_from_files(sfc_state, fluxes, day, dt, G, US, CS)
11501150
do j=js,je ; do i=is,ie
11511151
fluxes%evap(i,j) = fluxes%evap(i,j) * G%mask2dT(i,j)
11521152
fluxes%lprec(i,j) = fluxes%lprec(i,j) * G%mask2dT(i,j)
1153-
fluxes%fprec(i,j) = fluxes%fprec(i,j) * G%mask2dT(i,j)
11541153
fluxes%seaice_melt(i,j) = fluxes%seaice_melt(i,j) * G%mask2dT(i,j)
1154+
fluxes%fprec(i,j) = fluxes%fprec(i,j) * G%mask2dT(i,j)
11551155
fluxes%lrunoff(i,j) = fluxes%lrunoff(i,j) * G%mask2dT(i,j)
11561156
fluxes%frunoff(i,j) = fluxes%frunoff(i,j) * G%mask2dT(i,j)
11571157
fluxes%lw(i,j) = fluxes%lw(i,j) * G%mask2dT(i,j)
@@ -1309,15 +1309,16 @@ subroutine buoyancy_forcing_from_data_override(sfc_state, fluxes, day, dt, G, US
13091309

13101310
! mask out land points and compute heat content of water fluxes
13111311
! assume liquid precip enters ocean at SST
1312+
! assume sea ice melt enters ocean at SST
13121313
! assume frozen precip enters ocean at 0degC
13131314
! assume liquid runoff enters ocean at SST
13141315
! assume solid runoff (calving) enters ocean at 0degC
13151316
! mass leaving ocean has heat_content determined in MOM_diabatic_driver.F90
13161317
do j=js,je ; do i=is,ie
13171318
fluxes%evap(i,j) = fluxes%evap(i,j) * G%mask2dT(i,j)
13181319
fluxes%lprec(i,j) = fluxes%lprec(i,j) * G%mask2dT(i,j)
1319-
fluxes%fprec(i,j) = fluxes%fprec(i,j) * G%mask2dT(i,j)
13201320
fluxes%seaice_melt(i,j) = fluxes%seaice_melt(i,j) * G%mask2dT(i,j)
1321+
fluxes%fprec(i,j) = fluxes%fprec(i,j) * G%mask2dT(i,j)
13211322
fluxes%lrunoff(i,j) = fluxes%lrunoff(i,j) * G%mask2dT(i,j)
13221323
fluxes%frunoff(i,j) = fluxes%frunoff(i,j) * G%mask2dT(i,j)
13231324
fluxes%lw(i,j) = fluxes%lw(i,j) * G%mask2dT(i,j)
@@ -1364,8 +1365,8 @@ subroutine buoyancy_forcing_zero(sfc_state, fluxes, day, dt, G, CS)
13641365
do j=js,je ; do i=is,ie
13651366
fluxes%evap(i,j) = 0.0
13661367
fluxes%lprec(i,j) = 0.0
1367-
fluxes%fprec(i,j) = 0.0
13681368
fluxes%seaice_melt(i,j) = 0.0
1369+
fluxes%fprec(i,j) = 0.0
13691370
fluxes%vprec(i,j) = 0.0
13701371
fluxes%lrunoff(i,j) = 0.0
13711372
fluxes%frunoff(i,j) = 0.0
@@ -1408,8 +1409,8 @@ subroutine buoyancy_forcing_const(sfc_state, fluxes, day, dt, G, US, CS)
14081409
do j=js,je ; do i=is,ie
14091410
fluxes%evap(i,j) = 0.0
14101411
fluxes%lprec(i,j) = 0.0
1411-
fluxes%fprec(i,j) = 0.0
14121412
fluxes%seaice_melt(i,j) = 0.0
1413+
fluxes%fprec(i,j) = 0.0
14131414
fluxes%vprec(i,j) = 0.0
14141415
fluxes%lrunoff(i,j) = 0.0
14151416
fluxes%frunoff(i,j) = 0.0
@@ -1457,8 +1458,8 @@ subroutine buoyancy_forcing_linear(sfc_state, fluxes, day, dt, G, US, CS)
14571458
do j=js,je ; do i=is,ie
14581459
fluxes%evap(i,j) = 0.0
14591460
fluxes%lprec(i,j) = 0.0
1460-
fluxes%fprec(i,j) = 0.0
14611461
fluxes%seaice_melt(i,j) = 0.0
1462+
fluxes%fprec(i,j) = 0.0
14621463
fluxes%vprec(i,j) = 0.0
14631464
fluxes%lrunoff(i,j) = 0.0
14641465
fluxes%frunoff(i,j) = 0.0

config_src/drivers/solo_driver/user_surface_forcing.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
123123
! can be simply set to zero. The net fresh water flux should probably be
124124
! set in fluxes%evap and fluxes%lprec, with any salinity restoring
125125
! appearing in fluxes%vprec, and the other water flux components
126-
! (fprec, lrunoff and frunoff) left as arrays full of zeros.
126+
! (fprec, lrunoff, frunoff, seaice_melt) left as arrays full of zeros.
127127
! Evap is usually negative and precip is usually positive. All heat fluxes
128128
! are in W m-2 and positive for heat going into the ocean. All fresh water
129129
! fluxes are in [R Z T-1 ~> kg m-2 s-1] and positive for water moving into the ocean.
@@ -153,8 +153,8 @@ subroutine USER_buoyancy_forcing(sfc_state, fluxes, day, dt, G, US, CS)
153153
if (CS%use_temperature) then
154154
call safe_alloc_ptr(fluxes%evap, isd, ied, jsd, jed)
155155
call safe_alloc_ptr(fluxes%lprec, isd, ied, jsd, jed)
156-
call safe_alloc_ptr(fluxes%fprec, isd, ied, jsd, jed)
157156
call safe_alloc_ptr(fluxes%seaice_melt, isd, ied, jsd, jed)
157+
call safe_alloc_ptr(fluxes%fprec, isd, ied, jsd, jed)
158158
call safe_alloc_ptr(fluxes%lrunoff, isd, ied, jsd, jed)
159159
call safe_alloc_ptr(fluxes%frunoff, isd, ied, jsd, jed)
160160
call safe_alloc_ptr(fluxes%vprec, isd, ied, jsd, jed)

0 commit comments

Comments
 (0)