@@ -340,8 +340,8 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
340
340
real :: areaTm(SZI_(G),SZJ_(G)) ! A masked version of areaT [L2 ~> m2].
341
341
real :: KE(SZK_(GV)) ! The total kinetic energy of a layer [J].
342
342
real :: PE(SZK_(GV)+ 1 )! The available potential energy of an interface [J].
343
- real :: KE_tot ! The total kinetic energy [J].
344
- real :: PE_tot ! The total available potential energy [J].
343
+ real :: KE_tot ! The total kinetic energy [R Z L4 T-2 ~> J].
344
+ real :: PE_tot ! The total available potential energy [R Z L4 T-2 ~> J].
345
345
real :: Z_0APE(SZK_(GV)+ 1 ) ! The uniform depth which overlies the same
346
346
! volume as is below an interface [Z ~> m].
347
347
real :: H_0APE(SZK_(GV)+ 1 ) ! A version of Z_0APE, converted to m, usually positive [m].
@@ -351,9 +351,10 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
351
351
! the total mass of the ocean [m2 s-2].
352
352
real :: vol_lay(SZK_(GV)) ! The volume of fluid in a layer [Z L2 ~> m3].
353
353
real :: volbelow ! The volume of all layers beneath an interface [Z L2 ~> m3].
354
- real :: mass_lay(SZK_(GV)) ! The mass of fluid in a layer [kg].
354
+ real :: mass_lay(SZK_(GV)) ! The mass of fluid in a layer [R Z L2 ~> kg].
355
+ real :: mass_tot_RZL2 ! The total mass of the ocean [R Z L2 ~> kg].
355
356
real :: mass_tot ! The total mass of the ocean [kg].
356
- real :: vol_tot ! The total ocean volume [m3].
357
+ real :: vol_tot ! The total ocean volume [Z L2 ~> m3].
357
358
real :: mass_chg ! The change in total ocean mass of fresh water since
358
359
! the last call to this subroutine [kg].
359
360
real :: mass_anom ! The change in fresh water that cannot be accounted for
@@ -399,14 +400,11 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
399
400
real , dimension (SZI_(G),SZJ_(G),SZK_(GV)) :: &
400
401
tmp1 ! A temporary array used in reproducing sums [various]
401
402
real , dimension (SZI_(G),SZJ_(G),SZK_(GV)+ 1 ) :: &
402
- PE_pt ! The potential energy at each point [J].
403
+ PE_pt ! The potential energy at each point [R Z L4 T-2 ~> J].
403
404
real , dimension (SZI_(G),SZJ_(G)) :: &
404
- Temp_int, Salt_int ! Layer and cell integrated heat and salt [J] and [g Salt].
405
- real :: HL2_to_kg ! A conversion factor from a thickness-volume to mass [kg H-1 L-2 ~> kg m-3 or 1]
406
- real :: KE_scale_factor ! The combination of unit rescaling factors in the kinetic energy
407
- ! calculation [kg T2 H-1 L-2 s-2 ~> kg m-3 or 1]
408
- real :: PE_scale_factor ! The combination of unit rescaling factors in the potential energy
409
- ! calculation [kg T2 R-1 Z-1 L-2 s-2 ~> 1]
405
+ Temp_int, Salt_int ! Layer and cell integrated heat and salt [Q R Z L2 ~> J] and [g Salt].
406
+ real :: RZL4_to_J ! The combination of unit rescaling factors to convert the spatially integrated
407
+ ! kinetic or potential energies into mks units [T2 kg m2 R-1 Z-1 L-4 s-2 ~> 1]
410
408
integer :: num_nc_fields ! The number of fields that will actually go into
411
409
! the NetCDF file.
412
410
integer :: i, j, k, is, ie, js, je, nz, m, Isq, Ieq, Jsq, Jeq, isr, ier, jsr, jer
@@ -532,7 +530,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
532
530
Isq = G% IscB ; Ieq = G% IecB ; Jsq = G% JscB ; Jeq = G% JecB
533
531
isr = is - (G% isd-1 ) ; ier = ie - (G% isd-1 ) ; jsr = js - (G% jsd-1 ) ; jer = je - (G% jsd-1 )
534
532
535
- HL2_to_kg = GV % H_to_kg_m2 * US% L_to_m ** 2
533
+ RZL4_to_J = US % RZL2_to_kg * US% L_T_to_m_s ** 2 ! Used to unscale energies
536
534
537
535
if (.not. associated (CS)) call MOM_error(FATAL, &
538
536
" write_energy: Module must be initialized before it is used." )
@@ -544,28 +542,21 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
544
542
areaTm(i,j) = G% mask2dT(i,j)* G% areaT(i,j)
545
543
enddo ; enddo
546
544
547
- if (GV % Boussinesq) then
548
- tmp1(:,:,:) = 0.0
549
- do k = 1 ,nz ; do j = js,je ; do i = is,ie
550
- tmp1(i,j,k) = h(i,j,k) * (HL2_to_kg * areaTm(i,j))
551
- enddo ; enddo ; enddo
545
+ tmp1(:,:,:) = 0.0
546
+ do k = 1 ,nz ; do j = js,je ; do i = is,ie
547
+ tmp1(i,j,k) = h(i,j,k) * (GV % H_to_RZ * areaTm(i,j))
548
+ enddo ; enddo ; enddo
549
+ mass_tot_RZL2 = reproducing_sum(tmp1, isr, ier, jsr, jer, sums = mass_lay, EFP_sum = mass_EFP, unscale = US % RZL2_to_kg)
552
550
553
- mass_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums = mass_lay, EFP_sum = mass_EFP)
554
- do k= 1 ,nz ; vol_lay(k) = (US % m_to_L ** 2 * GV % H_to_Z / GV% H_to_kg_m2) * mass_lay(k) ; enddo
551
+ if (GV % Boussinesq) then
552
+ do k= 1 ,nz ; vol_lay(k) = (1.0 / GV% Rho0) * mass_lay(k) ; enddo
555
553
else
556
- tmp1(:,:,:) = 0.0
557
- do k= 1 ,nz ; do j= js,je ; do i= is,ie
558
- tmp1(i,j,k) = HL2_to_kg * h(i,j,k) * areaTm(i,j)
559
- enddo ; enddo ; enddo
560
- mass_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums= mass_lay, EFP_sum= mass_EFP)
561
-
562
554
if (CS% do_APE_calc) then
563
555
call find_eta(h, tv, G, GV, US, eta, dZref= G% Z_ref)
564
556
do k= 1 ,nz ; do j= js,je ; do i= is,ie
565
- tmp1(i,j,k) = US % Z_to_m * US % L_to_m ** 2 * (eta(i,j,K)- eta(i,j,K+1 )) * areaTm(i,j)
557
+ tmp1(i,j,k) = (eta(i,j,K)- eta(i,j,K+1 )) * areaTm(i,j)
566
558
enddo ; enddo ; enddo
567
- vol_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums= vol_lay)
568
- do k= 1 ,nz ; vol_lay(k) = US% m_to_Z* US% m_to_L** 2 * vol_lay(k) ; enddo
559
+ vol_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums= vol_lay, unscale= US% Z_to_m* US% L_to_m** 2 )
569
560
endif
570
561
endif ! Boussinesq
571
562
@@ -692,7 +683,6 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
692
683
! Calculate the Available Potential Energy integrated over each interface. With a nonlinear
693
684
! equation of state or with a bulk mixed layer this calculation is only approximate.
694
685
! With an ALE model this does not make sense and should be revisited.
695
- PE_scale_factor = US% RZ_to_kg_m2* US% L_to_m** 2 * US% L_T_to_m_s** 2
696
686
PE_pt(:,:,:) = 0.0
697
687
if (GV% Boussinesq) then
698
688
do j= js,je ; do i= is,ie
@@ -702,7 +692,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
702
692
hint = Z_0APE(K) + (hbelow - (G% bathyT(i,j) + G% Z_ref))
703
693
hbot = Z_0APE(K) - (G% bathyT(i,j) + G% Z_ref)
704
694
hbot = (hbot + ABS (hbot)) * 0.5
705
- PE_pt(i,j,K) = (0.5 * PE_scale_factor * areaTm(i,j)) * (GV% Rho0* GV% g_prime(K)) * &
695
+ PE_pt(i,j,K) = (0.5 * areaTm(i,j)) * (GV% Rho0* GV% g_prime(K)) * &
706
696
(hint * hint - hbot * hbot)
707
697
enddo
708
698
enddo ; enddo
@@ -711,7 +701,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
711
701
do K= nz,1 ,- 1
712
702
hint = Z_0APE(K) + eta(i,j,K) ! eta and H_0 have opposite signs.
713
703
hbot = max (Z_0APE(K) - (G% bathyT(i,j) + G% Z_ref), 0.0 )
714
- PE_pt(i,j,K) = (0.5 * PE_scale_factor * areaTm(i,j) * (GV% Rho0* GV% g_prime(K))) * &
704
+ PE_pt(i,j,K) = (0.5 * areaTm(i,j) * (GV% Rho0* GV% g_prime(K))) * &
715
705
(hint * hint - hbot * hbot)
716
706
enddo
717
707
enddo ; enddo
@@ -720,47 +710,44 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
720
710
do K= nz,2 ,- 1
721
711
hint = Z_0APE(K) + eta(i,j,K) ! eta and H_0 have opposite signs.
722
712
hbot = max (Z_0APE(K) - (G% bathyT(i,j) + G% Z_ref), 0.0 )
723
- PE_pt(i,j,K) = (0.25 * PE_scale_factor * areaTm(i,j) * &
713
+ PE_pt(i,j,K) = (0.25 * areaTm(i,j) * &
724
714
((GV% Rlay(k)+ GV% Rlay(k-1 ))* GV% g_prime(K))) * &
725
715
(hint * hint - hbot * hbot)
726
716
enddo
727
717
hint = Z_0APE(1 ) + eta(i,j,1 ) ! eta and H_0 have opposite signs.
728
718
hbot = max (Z_0APE(1 ) - (G% bathyT(i,j) + G% Z_ref), 0.0 )
729
- PE_pt(i,j,1 ) = (0.5 * PE_scale_factor * areaTm(i,j) * (GV% Rlay(1 )* GV% g_prime(1 ))) * &
719
+ PE_pt(i,j,1 ) = (0.5 * areaTm(i,j) * (GV% Rlay(1 )* GV% g_prime(1 ))) * &
730
720
(hint * hint - hbot * hbot)
731
721
enddo ; enddo
732
722
endif
733
723
734
- PE_tot = reproducing_sum(PE_pt, isr, ier, jsr, jer, sums= PE)
724
+ PE_tot = reproducing_sum(PE_pt, isr, ier, jsr, jer, sums= PE, unscale = RZL4_to_J )
735
725
do k= 1 ,nz+1 ; H_0APE(K) = US% Z_to_m* Z_0APE(K) ; enddo
736
726
else
737
727
PE_tot = 0.0
738
728
do k= 1 ,nz+1 ; PE(K) = 0.0 ; H_0APE(K) = 0.0 ; enddo
739
729
endif
740
730
741
- ! Calculate the Kinetic Energy integrated over each layer.
742
- KE_scale_factor = HL2_to_kg* US% L_T_to_m_s** 2
731
+ ! Calculate the Kinetic Energy integrated over each layer.
743
732
tmp1(:,:,:) = 0.0
744
733
do k= 1 ,nz ; do j= js,je ; do i= is,ie
745
- tmp1(i,j,k) = (0.25 * KE_scale_factor * (areaTm(i,j) * h(i,j,k))) * &
734
+ tmp1(i,j,k) = (0.25 * GV % H_to_RZ * (areaTm(i,j) * h(i,j,k))) * &
746
735
(((u(I-1 ,j,k)** 2 ) + (u(I,j,k)** 2 )) + ((v(i,J-1 ,k)** 2 ) + (v(i,J,k)** 2 )))
747
736
enddo ; enddo ; enddo
748
737
749
- KE_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums= KE)
738
+ KE_tot = reproducing_sum(tmp1, isr, ier, jsr, jer, sums= KE, unscale = RZL4_to_J )
750
739
751
- toten = KE_tot + PE_tot
752
-
753
- Salt = 0.0 ; Heat = 0.0
740
+ ! Use reproducing sums to do global integrals relate to the heat, salinity and water budgets.
754
741
if (CS% use_temperature) then
755
742
Temp_int(:,:) = 0.0 ; Salt_int(:,:) = 0.0
756
743
do k= 1 ,nz ; do j= js,je ; do i= is,ie
757
- Salt_int(i,j) = Salt_int(i,j) + US% S_to_ppt* tv% S(i,j,k) * &
758
- (h(i,j,k)* (HL2_to_kg * areaTm(i,j)))
759
- Temp_int(i,j) = Temp_int(i,j) + (US% Q_to_J_kg* tv% C_p * tv% T(i,j,k)) * &
760
- (h(i,j,k)* (HL2_to_kg * areaTm(i,j)))
744
+ Salt_int(i,j) = Salt_int(i,j) + tv% S(i,j,k) * (h(i,j,k)* (GV% H_to_RZ * areaTm(i,j)))
745
+ Temp_int(i,j) = Temp_int(i,j) + (tv% C_p * tv% T(i,j,k)) * (h(i,j,k)* (GV% H_to_RZ * areaTm(i,j)))
761
746
enddo ; enddo ; enddo
762
- salt_EFP = reproducing_sum_EFP(Salt_int, isr, ier, jsr, jer, only_on_PE= .true. )
763
- heat_EFP = reproducing_sum_EFP(Temp_int, isr, ier, jsr, jer, only_on_PE= .true. )
747
+ salt_EFP = reproducing_sum_EFP(Salt_int, isr, ier, jsr, jer, only_on_PE= .true. , &
748
+ unscale= US% RZL2_to_kg* US% S_to_ppt)
749
+ heat_EFP = reproducing_sum_EFP(Temp_int, isr, ier, jsr, jer, only_on_PE= .true. , &
750
+ unscale= US% RZL2_to_kg* US% Q_to_J_kg)
764
751
765
752
! Combining the sums avoids multiple blocking all-PE updates.
766
753
EFP_list(1 ) = salt_EFP ; EFP_list(2 ) = heat_EFP ; EFP_list(3 ) = CS% fresh_water_in_EFP
@@ -770,13 +757,11 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
770
757
salt_EFP = EFP_list(1 ) ; heat_EFP = EFP_list(2 ) ; CS% fresh_water_in_EFP = EFP_list(3 )
771
758
CS% net_salt_in_EFP = EFP_list(4 ) ; CS% net_heat_in_EFP = EFP_list(5 )
772
759
773
- Salt = EFP_to_real(salt_EFP)
774
- Heat = EFP_to_real(heat_EFP)
775
760
else
776
761
call EFP_sum_across_PEs(CS% fresh_water_in_EFP)
777
762
endif
778
763
779
- ! Calculate the maximum CFL numbers.
764
+ ! Calculate the maximum CFL numbers.
780
765
max_CFL(1 :2 ) = 0.0
781
766
do k= 1 ,nz ; do j= js,je ; do I= Isq,Ieq
782
767
CFL_Iarea = G% IareaT(i,j)
@@ -803,7 +788,12 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
803
788
804
789
call max_across_PEs(max_CFL, 2 )
805
790
791
+ ! From this point onward, many of the calculations set or use variables in unscaled (mks) units.
792
+
793
+ Salt = 0.0 ; Heat = 0.0
806
794
if (CS% use_temperature) then
795
+ Salt = EFP_to_real(salt_EFP)
796
+ Heat = EFP_to_real(heat_EFP)
807
797
if (CS% previous_calls == 0 ) then
808
798
CS% salt_prev_EFP = salt_EFP ; CS% heat_prev_EFP = heat_EFP
809
799
endif
@@ -826,13 +816,15 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
826
816
endif
827
817
mass_chg = EFP_to_real(mass_chg_EFP)
828
818
819
+ mass_tot = US% RZL2_to_kg * mass_tot_RZL2
829
820
if (CS% use_temperature) then
830
821
salin = Salt / mass_tot
831
822
salin_anom = Salt_anom / mass_tot
832
823
! salin_chg = Salt_chg / mass_tot
833
824
temp = heat / (mass_tot* US% Q_to_J_kg* US% degC_to_C* tv% C_p)
834
825
temp_anom = Heat_anom / (mass_tot* US% Q_to_J_kg* US% degC_to_C* tv% C_p)
835
826
endif
827
+ toten = RZL4_to_J * (KE_tot + PE_tot)
836
828
En_mass = toten / mass_tot
837
829
838
830
call get_time(day, start_of_day, num_days)
@@ -952,9 +944,12 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
952
944
953
945
call CS% fileenergy_nc% write_field(CS% fields(1 ), real (CS% ntrunc), reday)
954
946
call CS% fileenergy_nc% write_field(CS% fields(2 ), toten, reday)
947
+ do k= 1 ,nz+1 ; PE(K) = RZL4_to_J* PE(K) ; enddo
955
948
call CS% fileenergy_nc% write_field(CS% fields(3 ), PE, reday)
949
+ do k= 1 ,nz ; KE(k) = RZL4_to_J* KE(k) ; enddo
956
950
call CS% fileenergy_nc% write_field(CS% fields(4 ), KE, reday)
957
951
call CS% fileenergy_nc% write_field(CS% fields(5 ), H_0APE, reday)
952
+ do k= 1 ,nz ; mass_lay(k) = US% RZL2_to_kg* mass_lay(k) ; enddo
958
953
call CS% fileenergy_nc% write_field(CS% fields(6 ), mass_lay, reday)
959
954
960
955
call CS% fileenergy_nc% write_field(CS% fields(7 ), mass_tot, reday)
@@ -1018,34 +1013,29 @@ subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS)
1018
1013
! ! to MOM_sum_output_init.
1019
1014
! Local variables
1020
1015
real , dimension (SZI_(G),SZJ_(G)) :: &
1021
- FW_in, & ! The net fresh water input, integrated over a timestep [kg].
1016
+ FW_in, & ! The net fresh water input, integrated over a timestep [R Z L2 ~> kg].
1022
1017
salt_in, & ! The total salt added by surface fluxes, integrated
1023
1018
! over a time step [ppt kg].
1024
1019
heat_in ! The total heat added by surface fluxes, integrated
1025
- ! over a time step [J].
1026
- real :: RZL2_to_kg ! A combination of scaling factors for mass [kg R-1 Z-1 L-2 ~> 1]
1027
- real :: QRZL2_to_J ! A combination of scaling factors for heat [J Q-1 R-1 Z-1 L-2 ~> 1]
1020
+ ! over a time step [Q R Z L2 ~> J].
1028
1021
1029
1022
type (EFP_type) :: &
1030
1023
FW_in_EFP, & ! The net fresh water input, integrated over a timestep
1031
1024
! and summed over space [kg].
1032
1025
salt_in_EFP, & ! The total salt added by surface fluxes, integrated
1033
- ! over a time step and summed over space [ppt kg].
1026
+ ! over a time step and summed over space [R Z L2 ~> ppt kg].
1034
1027
heat_in_EFP ! The total heat added by boundary fluxes, integrated
1035
1028
! over a time step and summed over space [J].
1036
1029
1037
1030
integer :: i, j, is, ie, js, je, isr, ier, jsr, jer
1038
1031
1039
1032
is = G% isc ; ie = G% iec ; js = G% jsc ; je = G% jec
1040
1033
1041
- RZL2_to_kg = US% L_to_m** 2 * US% RZ_to_kg_m2
1042
- QRZL2_to_J = RZL2_to_kg* US% Q_to_J_kg
1043
-
1044
1034
FW_in(:,:) = 0.0
1045
1035
if (associated (fluxes% evap)) then
1046
1036
if (associated (fluxes% lprec) .and. associated (fluxes% fprec)) then
1047
1037
do j= js,je ; do i= is,ie
1048
- FW_in(i,j) = RZL2_to_kg * dt* G% areaT(i,j)* (fluxes% evap(i,j) + &
1038
+ FW_in(i,j) = dt* G% areaT(i,j)* (fluxes% evap(i,j) + &
1049
1039
(((fluxes% lprec(i,j) + fluxes% vprec(i,j)) + fluxes% lrunoff(i,j)) + &
1050
1040
(fluxes% fprec(i,j) + fluxes% frunoff(i,j))))
1051
1041
enddo ; enddo
@@ -1056,27 +1046,26 @@ subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS)
1056
1046
endif
1057
1047
1058
1048
if (associated (fluxes% seaice_melt)) then ; do j= js,je ; do i= is,ie
1059
- FW_in(i,j) = FW_in(i,j) + RZL2_to_kg* dt * &
1060
- G% areaT(i,j) * fluxes% seaice_melt(i,j)
1049
+ FW_in(i,j) = FW_in(i,j) + dt * G% areaT(i,j) * fluxes% seaice_melt(i,j)
1061
1050
enddo ; enddo ; endif
1062
1051
1063
1052
salt_in(:,:) = 0.0 ; heat_in(:,:) = 0.0
1064
1053
if (CS% use_temperature) then
1065
1054
1066
1055
if (associated (fluxes% sw)) then ; do j= js,je ; do i= is,ie
1067
- heat_in(i,j) = heat_in(i,j) + dt * QRZL2_to_J * G% areaT(i,j) * (fluxes% sw(i,j) + &
1056
+ heat_in(i,j) = heat_in(i,j) + dt * G% areaT(i,j) * (fluxes% sw(i,j) + &
1068
1057
(fluxes% lw(i,j) + (fluxes% latent(i,j) + fluxes% sens(i,j))))
1069
1058
enddo ; enddo ; endif
1070
1059
1071
1060
if (associated (fluxes% seaice_melt_heat)) then ; do j= js,je ; do i= is,ie
1072
- heat_in(i,j) = heat_in(i,j) + dt * QRZL2_to_J * G% areaT(i,j) * &
1061
+ heat_in(i,j) = heat_in(i,j) + dt * G% areaT(i,j) * &
1073
1062
fluxes% seaice_melt_heat(i,j)
1074
1063
enddo ; enddo ; endif
1075
1064
1076
1065
! smg: new code
1077
1066
! include heat content from water transport across ocean surface
1078
1067
! if (associated(fluxes%heat_content_lprec)) then ; do j=js,je ; do i=is,ie
1079
- ! heat_in(i,j) = heat_in(i,j) + dt * QRZL2_to_J * G%areaT(i,j) * &
1068
+ ! heat_in(i,j) = heat_in(i,j) + dt * G%areaT(i,j) * &
1080
1069
! (fluxes%heat_content_lprec(i,j) + (fluxes%heat_content_fprec(i,j) &
1081
1070
! + (fluxes%heat_content_lrunoff(i,j) + (fluxes%heat_content_frunoff(i,j) &
1082
1071
! + (fluxes%heat_content_cond(i,j) + (fluxes%heat_content_vprec(i,j) &
@@ -1086,41 +1075,41 @@ subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS)
1086
1075
! smg: old code
1087
1076
if (associated (fluxes% heat_content_evap)) then
1088
1077
do j= js,je ; do i= is,ie
1089
- heat_in(i,j) = heat_in(i,j) + dt * QRZL2_to_J * G% areaT(i,j) * &
1078
+ heat_in(i,j) = heat_in(i,j) + dt * G% areaT(i,j) * &
1090
1079
(fluxes% heat_content_evap(i,j) + fluxes% heat_content_lprec(i,j) + &
1091
1080
fluxes% heat_content_cond(i,j) + fluxes% heat_content_fprec(i,j) + &
1092
1081
fluxes% heat_content_lrunoff(i,j) + fluxes% heat_content_frunoff(i,j))
1093
1082
enddo ; enddo
1094
1083
elseif (associated (tv% TempxPmE)) then
1095
1084
do j= js,je ; do i= is,ie
1096
- heat_in(i,j) = heat_in(i,j) + (tv% C_p * QRZL2_to_J * G% areaT(i,j)) * tv% TempxPmE(i,j)
1085
+ heat_in(i,j) = heat_in(i,j) + (tv% C_p * G% areaT(i,j)) * tv% TempxPmE(i,j)
1097
1086
enddo ; enddo
1098
1087
elseif (associated (fluxes% evap)) then
1099
1088
do j= js,je ; do i= is,ie
1100
- heat_in(i,j) = heat_in(i,j) + (US % Q_to_J_kg * tv% C_p * sfc_state% SST(i,j)) * FW_in(i,j)
1089
+ heat_in(i,j) = heat_in(i,j) + (tv% C_p * sfc_state% SST(i,j)) * FW_in(i,j)
1101
1090
enddo ; enddo
1102
1091
endif
1103
1092
1104
1093
! The following heat sources may or may not be used.
1105
1094
if (associated (tv% internal_heat)) then
1106
1095
do j= js,je ; do i= is,ie
1107
- heat_in(i,j) = heat_in(i,j) + (tv% C_p * QRZL2_to_J * G% areaT(i,j)) * tv% internal_heat(i,j)
1096
+ heat_in(i,j) = heat_in(i,j) + (tv% C_p * G% areaT(i,j)) * tv% internal_heat(i,j)
1108
1097
enddo ; enddo
1109
1098
endif
1110
1099
if (associated (tv% frazil)) then ; do j= js,je ; do i= is,ie
1111
- heat_in(i,j) = heat_in(i,j) + QRZL2_to_J * G% areaT(i,j) * tv% frazil(i,j)
1100
+ heat_in(i,j) = heat_in(i,j) + G% areaT(i,j) * tv% frazil(i,j)
1112
1101
enddo ; enddo ; endif
1113
1102
if (associated (fluxes% heat_added)) then ; do j= js,je ; do i= is,ie
1114
- heat_in(i,j) = heat_in(i,j) + QRZL2_to_J * dt* G% areaT(i,j) * fluxes% heat_added(i,j)
1103
+ heat_in(i,j) = heat_in(i,j) + dt* G% areaT(i,j) * fluxes% heat_added(i,j)
1115
1104
enddo ; enddo ; endif
1116
1105
! if (associated(sfc_state%sw_lost)) then ; do j=js,je ; do i=is,ie
1117
- ! heat_in(i,j) = heat_in(i,j) - US%L_to_m**2*G%areaT(i,j) * sfc_state%sw_lost(i,j)
1106
+ ! sfc_state%sw_lost must be in units of [Q R Z ~> J m-2]
1107
+ ! heat_in(i,j) = heat_in(i,j) - G%areaT(i,j) * sfc_state%sw_lost(i,j)
1118
1108
! enddo ; enddo ; endif
1119
1109
1120
1110
if (associated (fluxes% salt_flux)) then ; do j= js,je ; do i= is,ie
1121
1111
! integrate salt_flux in [R Z T-1 ~> kgSalt m-2 s-1] to give [ppt kg]
1122
- salt_in(i,j) = RZL2_to_kg * dt * &
1123
- G% areaT(i,j)* (1000.0 * fluxes% salt_flux(i,j))
1112
+ salt_in(i,j) = dt * G% areaT(i,j)* (1000.0 * fluxes% salt_flux(i,j))
1124
1113
enddo ; enddo ; endif
1125
1114
endif
1126
1115
@@ -1129,9 +1118,12 @@ subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS)
1129
1118
! The on-PE sums are stored here, but the sums across PEs are deferred to
1130
1119
! the next call to write_energy to avoid extra barriers.
1131
1120
isr = is - (G% isd-1 ) ; ier = ie - (G% isd-1 ) ; jsr = js - (G% jsd-1 ) ; jer = je - (G% jsd-1 )
1132
- FW_in_EFP = reproducing_sum_EFP(FW_in, isr, ier, jsr, jer, only_on_PE= .true. )
1133
- heat_in_EFP = reproducing_sum_EFP(heat_in, isr, ier, jsr, jer, only_on_PE= .true. )
1134
- salt_in_EFP = reproducing_sum_EFP(salt_in, isr, ier, jsr, jer, only_on_PE= .true. )
1121
+ FW_in_EFP = reproducing_sum_EFP(FW_in, isr, ier, jsr, jer, only_on_PE= .true. , &
1122
+ unscale= US% RZL2_to_kg)
1123
+ heat_in_EFP = reproducing_sum_EFP(heat_in, isr, ier, jsr, jer, only_on_PE= .true. , &
1124
+ unscale= US% RZL2_to_kg* US% Q_to_J_kg)
1125
+ salt_in_EFP = reproducing_sum_EFP(salt_in, isr, ier, jsr, jer, only_on_PE= .true. , &
1126
+ unscale= US% RZL2_to_kg)
1135
1127
1136
1128
CS% fresh_water_in_EFP = CS% fresh_water_in_EFP + FW_in_EFP
1137
1129
CS% net_salt_in_EFP = CS% net_salt_in_EFP + salt_in_EFP
0 commit comments