Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forked version of removal of unused bug variables #99

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 26 additions & 64 deletions full/atm_land_ice_flux_exchange.F90
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ module atm_land_ice_flux_exchange_mod
!--- the following is from flux_exchange_nml
real :: z_ref_heat = 2. !< Reference height (meters) for temperature and relative humidity diagnostics (t_ref, rh_ref, del_h, del_q)
real :: z_ref_mom = 10. !< Reference height (meters) for mementum diagnostics (u_ref, v_ref, del_m)
logical :: ex_u_star_smooth_bug = .false. !< By default, the global exchange grid \c u_star will not be interpolated
!! from atmospheric grid, this is different from Jakarta behavior and will
!! change answers. So to preserve Jakarta behavior and reproduce answers
!! explicitly set this namelist variable to .true. in input.nml.
logical :: sw1way_bug = .false.
logical :: do_area_weighted_flux = .FALSE.
logical :: do_forecast = .false.
integer :: nblocks = 1
Expand Down Expand Up @@ -287,7 +282,7 @@ module atm_land_ice_flux_exchange_mod
!! The latitude from file grid_spec.nc is different from the latitude from atmosphere model.
subroutine atm_land_ice_flux_exchange_init(Time, Atm, Land, Ice, atmos_ice_boundary, land_ice_atmos_boundary, &
Dt_atm_in, Dt_cpl_in, z_ref_heat_in, z_ref_mom_in, &
ex_u_star_smooth_bug_in, sw1way_bug_in, do_area_weighted_flux_in, &
do_area_weighted_flux_in, &
do_forecast_in, partition_fprec_from_lprec_in, scale_precip_2d_in, &
nblocks_in, cplClock_in, ex_gas_fields_atm_in, &
ex_gas_fields_ice_in, ex_gas_fluxes_in)
Expand All @@ -301,8 +296,8 @@ subroutine atm_land_ice_flux_exchange_init(Time, Atm, Land, Ice, atmos_ice_bound
real, intent(in) :: Dt_atm_in !< Atmosphere time step in seconds
real, intent(in) :: Dt_cpl_in !< Coupled time step in seconds
real, intent(in) :: z_ref_heat_in, z_ref_mom_in
logical, intent(in) :: ex_u_star_smooth_bug_in, scale_precip_2d_in
logical, intent(in) :: sw1way_bug_in, do_area_weighted_flux_in
logical, intent(in) :: scale_precip_2d_in
logical, intent(in) :: do_area_weighted_flux_in
logical, intent(in) :: do_forecast_in, partition_fprec_from_lprec_in
integer, intent(in) :: nblocks_in
integer, intent(in) :: cplClock_in
Expand All @@ -325,8 +320,6 @@ subroutine atm_land_ice_flux_exchange_init(Time, Atm, Land, Ice, atmos_ice_bound
Dt_cpl = Dt_cpl_in
z_ref_heat = z_ref_heat_in
z_ref_mom = z_ref_mom_in
ex_u_star_smooth_bug = ex_u_star_smooth_bug_in
sw1way_bug = sw1way_bug_in
do_area_weighted_flux = do_area_weighted_flux_in
do_forecast = do_forecast_in
partition_fprec_from_lprec = partition_fprec_from_lprec_in
Expand Down Expand Up @@ -2046,10 +2039,6 @@ subroutine flux_down_from_atmos (Time, Atm, Land, Ice, Atmos_boundary, Land_boun

!---- put atmosphere quantities onto exchange grid ----

if(sw1way_bug) then
call fms_xgrid_put_to_xgrid (Atm%flux_sw, 'ATM', ex_flux_sw, xmap_sfc, complete=.false.)
call fms_xgrid_put_to_xgrid (Atm%flux_sw_vis, 'ATM', ex_flux_sw_vis, xmap_sfc, complete=.false.)
end if
!$OMP parallel do default(none) shared(my_nblocks,block_start,block_end,ex_flux_sw_dir, &
!$OMP ex_flux_sw_vis_dir,ex_flux_sw_dif,ex_delta_u, &
!$OMP ex_flux_sw_vis_dif,ex_flux_lwd,ex_delta_v ) &
Expand Down Expand Up @@ -2091,10 +2080,6 @@ subroutine flux_down_from_atmos (Time, Atm, Land, Ice, Atmos_boundary, Land_boun
call fms_xgrid_put_to_xgrid (Atm%coszen, 'ATM', ex_coszen, xmap_sfc, complete=.true.)

call fms_xgrid_put_to_xgrid (Atm%flux_lw, 'ATM', ex_flux_lwd, xmap_sfc, remap_method=remap_method, complete=.false.)
if(ex_u_star_smooth_bug) then
call fms_xgrid_put_to_xgrid (Atmos_boundary%u_star, 'ATM', ex_u_star_smooth, xmap_sfc, remap_method=remap_method, complete=.false.)
ex_u_star = ex_u_star_smooth
endif


! MOD changed the following two lines to put Atmos%surf_diff%delta_u and v
Expand All @@ -2120,53 +2105,30 @@ subroutine flux_down_from_atmos (Time, Atm, Land, Ice, Atmos_boundary, Land_boun
!-----------------------------------------------------------------------
!---- adjust sw flux for albedo variations on exch grid ----
!---- adjust 4 categories (vis/nir dir/dif) separately ----
if( sw1way_bug ) then ! to reproduce old results, may remove in the next major release.
!-----------------------------------------------------------------------
!---- adjust sw flux for albedo variations on exch grid ----
!$OMP parallel do default(none) shared(my_nblocks,block_start,block_end,ex_flux_sw,ex_albedo_fix, &
!$OMP ex_flux_sw_vis,ex_albedo_vis_dir_fix,ex_flux_sw_dir, &
!$OMP ex_albedo_vis_dif_fix,ex_flux_sw_vis_dir,ex_flux_sw_dif, &
!$OMP ex_flux_sw_vis_dif) &
!$OMP private(is,ie)
do l = 1, my_nblocks
is=block_start(l)
ie=block_end(l)
do i = is, ie
ex_flux_sw(i) = ex_flux_sw(i) * ex_albedo_fix(i)

ex_flux_sw_vis(i) = ex_flux_sw_vis(i) * ex_albedo_vis_dir_fix(i)
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) * ex_albedo_vis_dir_fix(i)
ex_flux_sw_dif(i) = ex_flux_sw_dif(i) * ex_albedo_vis_dif_fix(i)
ex_flux_sw_vis_dir(i) = ex_flux_sw_vis_dir(i) * ex_albedo_vis_dir_fix(i)
ex_flux_sw_vis_dif(i) = ex_flux_sw_vis_dif(i) * ex_albedo_vis_dif_fix(i)
enddo
enddo
else
!$OMP parallel do default(none) shared(my_nblocks,block_start,block_end,ex_flux_sw_dir, &
!$OMP ex_flux_sw_vis_dir,ex_albedo_nir_dir_fix, &
!$OMP ex_albedo_vis_dir_fix,ex_flux_sw_dif, &
!$OMP ex_flux_sw_vis_dif,ex_flux_sw_vis,ex_flux_sw, &
!$OMP ex_albedo_nir_dif_fix,ex_albedo_vis_dif_fix ) &
!$OMP private(is,ie)
do l = 1, my_nblocks
is=block_start(l)
ie=block_end(l)
do i = is, ie
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) - ex_flux_sw_vis_dir(i) ! temporarily nir/dir
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) * ex_albedo_nir_dir_fix(i) ! fix nir/dir
ex_flux_sw_vis_dir(i) = ex_flux_sw_vis_dir(i) * ex_albedo_vis_dir_fix(i) ! fix vis/dir
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) + ex_flux_sw_vis_dir(i) ! back to total dir

ex_flux_sw_dif(i) = ex_flux_sw_dif(i) - ex_flux_sw_vis_dif(i) ! temporarily nir/dif
ex_flux_sw_dif(i) = ex_flux_sw_dif(i) * ex_albedo_nir_dif_fix(i) ! fix nir/dif
ex_flux_sw_vis_dif(i) = ex_flux_sw_vis_dif(i) * ex_albedo_vis_dif_fix(i) ! fix vis/dif
ex_flux_sw_dif(i) = ex_flux_sw_dif(i) + ex_flux_sw_vis_dif(i) ! back to total dif

ex_flux_sw_vis(i) = ex_flux_sw_vis_dir(i) + ex_flux_sw_vis_dif(i) ! legacy, remove later
ex_flux_sw(i) = ex_flux_sw_dir(i) + ex_flux_sw_dif(i) ! legacy, remove later
enddo
!$OMP parallel do default(none) shared(my_nblocks,block_start,block_end,ex_flux_sw_dir, &
!$OMP ex_flux_sw_vis_dir,ex_albedo_nir_dir_fix, &
!$OMP ex_albedo_vis_dir_fix,ex_flux_sw_dif, &
!$OMP ex_flux_sw_vis_dif,ex_flux_sw_vis,ex_flux_sw, &
!$OMP ex_albedo_nir_dif_fix,ex_albedo_vis_dif_fix ) &
!$OMP private(is,ie)
do l = 1, my_nblocks
is=block_start(l)
ie=block_end(l)
do i = is, ie
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) - ex_flux_sw_vis_dir(i) ! temporarily nir/dir
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) * ex_albedo_nir_dir_fix(i) ! fix nir/dir
ex_flux_sw_vis_dir(i) = ex_flux_sw_vis_dir(i) * ex_albedo_vis_dir_fix(i) ! fix vis/dir
ex_flux_sw_dir(i) = ex_flux_sw_dir(i) + ex_flux_sw_vis_dir(i) ! back to total dir

ex_flux_sw_dif(i) = ex_flux_sw_dif(i) - ex_flux_sw_vis_dif(i) ! temporarily nir/dif
ex_flux_sw_dif(i) = ex_flux_sw_dif(i) * ex_albedo_nir_dif_fix(i) ! fix nir/dif
ex_flux_sw_vis_dif(i) = ex_flux_sw_vis_dif(i) * ex_albedo_vis_dif_fix(i) ! fix vis/dif
ex_flux_sw_dif(i) = ex_flux_sw_dif(i) + ex_flux_sw_vis_dif(i) ! back to total dif

ex_flux_sw_vis(i) = ex_flux_sw_vis_dir(i) + ex_flux_sw_vis_dif(i) ! legacy, remove later
ex_flux_sw(i) = ex_flux_sw_dir(i) + ex_flux_sw_dif(i) ! legacy, remove later
enddo
end if
enddo

!!$ ex_flux_sw_dir = ex_flux_sw_dir - ex_flux_sw_vis_dir ! temporarily nir/dir
!!$ ex_flux_sw_dir = ex_flux_sw_dir * ex_albedo_nir_dir_fix ! fix nir/dir
Expand Down
26 changes: 3 additions & 23 deletions full/flux_exchange.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@
!! del_m).</td>
!! </tr>
!! <tr>
!! <td>ex_u_start_smooth_bug</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td>By default, the global exchange grid `u_star` will not be interpolated
!! from atmospheric grid, this is different from Jakarta behavior and will
!! change answers. So to preserve Jakarta behavior and reproduce answers
!! explicitly set this namelist variable to .true. in input.nml.</td>
!! </tr>
!! <tr>
!! <td>sw1way_bug</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
!! <td></td>
!! </tr>
!! <tr>
!! <td>do_area_weighted_flux</td>
!! <td>logical</td>
!! <td>.FALSE.</td>
Expand Down Expand Up @@ -568,11 +553,6 @@ module flux_exchange_mod

real :: z_ref_heat = 2. !< Reference height (meters) for temperature and relative humidity diagnostics (t_ref, rh_ref, del_h, del_q)
real :: z_ref_mom = 10. !< Reference height (meters) for mementum diagnostics (u_ref, v_ref, del_m)
logical :: ex_u_star_smooth_bug = .false. !< By default, the global exchange grid \c u_star will not be interpolated
!! from atmospheric grid, this is different from Jakarta behavior and will
!! change answers. So to preserve Jakarta behavior and reproduce answers
!! explicitly set this namelist variable to .true. in input.nml.
logical :: sw1way_bug = .false.
logical :: do_area_weighted_flux = .FALSE.
logical :: debug_stocks = .FALSE.
logical :: divert_stocks_report = .FALSE.
Expand All @@ -586,7 +566,7 @@ module flux_exchange_mod
real, parameter :: tfreeze = 273.15
logical :: scale_precip_2d = .false.

namelist /flux_exchange_nml/ z_ref_heat, z_ref_mom, ex_u_star_smooth_bug, sw1way_bug,&
namelist /flux_exchange_nml/ z_ref_heat, z_ref_mom,&
& do_area_weighted_flux, debug_stocks, divert_stocks_report, do_runoff, do_forecast, nblocks,&
& partition_fprec_from_lprec, scale_precip_2d

Expand Down Expand Up @@ -755,8 +735,8 @@ subroutine flux_exchange_init ( Time, Atm, Land, Ice, Ocean, Ocean_state,&
cplClock = fms_mpp_clock_id( 'Land-ice-atm coupler', flags=fms_clock_flag_default, grain=CLOCK_COMPONENT )
call check_atm_grid(Atm, grid_file)
call atm_land_ice_flux_exchange_init(Time, Atm, Land, Ice, atmos_ice_boundary, land_ice_atmos_boundary, &
Dt_atm, Dt_cpl, z_ref_heat, z_ref_mom, ex_u_star_smooth_bug, &
sw1way_bug, do_area_weighted_flux, do_forecast, &
Dt_atm, Dt_cpl, z_ref_heat, z_ref_mom, &
do_area_weighted_flux, do_forecast, &
partition_fprec_from_lprec, scale_precip_2d, nblocks, cplClock, &
ex_gas_fields_atm, ex_gas_fields_ice, ex_gas_fluxes)

Expand Down
Loading