Skip to content

Commit

Permalink
Merge branch 'trhille/mali/remove_extra_fct_mask_updates' into MALI-D…
Browse files Browse the repository at this point in the history
…ev/develop

Do not update FCT masks between RK stages. The masking for FCT is now
calculated in the first RK stage and not updated again in the time step.

* trhille/mali/remove_extra_fct_mask_updates:
  Clean up after code review
  Do not update FCT masks between RK stages
  • Loading branch information
matthewhoffman committed Aug 20, 2024
2 parents 9bc55d4 + c0f079e commit 06eec9c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,7 @@ subroutine li_advection_thickness_tracers(&
! Deallocate arrays for fct
if ( (trim(config_thickness_advection) .eq. 'fct') .or. &
(trim(config_tracer_advection) .eq. 'fct') ) then
deallocate( nAdvCellsForEdge, &
advCellsForEdge, &
advCoefs, &
advCoefs3rd, &
advMaskHighOrder, &
advMask2ndOrder, &
tend)
deallocate(tend)
endif
! clean up
Expand Down Expand Up @@ -1093,7 +1087,6 @@ subroutine tracer_setup(&
nTracers)
use li_thermal, only: li_temperature_to_enthalpy_kelvin
use li_tracer_advection_fct_shared
use li_tracer_advection_fct
!-----------------------------------------------------------------
!
Expand Down Expand Up @@ -1168,11 +1161,9 @@ subroutine tracer_setup(&
real (kind=RKIND), pointer :: &
config_ice_density ! ice density
integer :: iCell, iTracer, k, err, err1, err2
integer :: iCell, iTracer, k, err
err = 0
err1 = 0
err2 = 0
! get dimensions
call mpas_pool_get_dimension(meshPool, 'nCells', nCells)
Expand Down Expand Up @@ -1301,14 +1292,12 @@ subroutine tracer_setup(&
! May need to increase maxTracers in the Registry.
if ( (trim(config_tracer_advection) == 'fct') .or. &
(trim(config_thickness_advection) == 'fct') ) then
call li_tracer_advection_fct_shared_init(geometryPool, err1)
call li_tracer_advection_fct_init(err2)
call li_tracer_advection_fct_init(err)
if (err1 /= 0 .or. err2 /= 0) then
err = 1
if (err /= 0) then
call mpas_log_write( &
'Error encountered during fct tracer advection init', &
MPAS_LOG_ERR, masterOnly=.true.)
MPAS_LOG_ERR)
endif
endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module li_time_integration_fe_rk
use li_constants
use li_mesh
use li_mask
use li_tracer_advection_fct_shared

implicit none
private
Expand Down Expand Up @@ -114,7 +115,8 @@ subroutine li_time_integrator_forwardeuler_rungekutta(domain, err)
logical, pointer :: config_calculate_damage
logical, pointer :: config_finalize_damage_after_advection
logical, pointer :: config_update_velocity_before_calving
character (len=StrKIND), pointer :: config_thickness_advection
character (len=StrKIND), pointer :: config_thickness_advection, &
config_tracer_advection
character (len=StrKIND), pointer :: config_thermal_solver
character (len=StrKIND), pointer :: config_time_integration
integer, pointer :: config_rk_order, config_rk3_stages
Expand Down Expand Up @@ -166,9 +168,10 @@ subroutine li_time_integrator_forwardeuler_rungekutta(domain, err)

call mpas_pool_get_config(liConfigs, 'config_restore_calving_front', config_restore_calving_front)
call mpas_pool_get_config(liConfigs, 'config_restore_calving_front_prevent_retreat', config_restore_calving_front_prevent_retreat)
call mpas_pool_get_config(liConfigs, 'config_calculate_damage',config_calculate_damage)
call mpas_pool_get_config(liConfigs, 'config_calculate_damage', config_calculate_damage)
call mpas_pool_get_config(liConfigs, 'config_finalize_damage_after_advection', config_finalize_damage_after_advection)
call mpas_pool_get_config(liConfigs, 'config_thickness_advection', config_thickness_advection)
call mpas_pool_get_config(liConfigs, 'config_tracer_advection', config_tracer_advection)
call mpas_pool_get_config(liConfigs, 'config_thermal_solver', config_thermal_solver)
call mpas_pool_get_config(liConfigs, 'config_rk_order', config_rk_order)
call mpas_pool_get_config(liConfigs, 'config_rk3_stages', config_rk3_stages)
Expand Down Expand Up @@ -281,6 +284,17 @@ subroutine li_time_integrator_forwardeuler_rungekutta(domain, err)
enddo
deltatFull = deltat ! Save deltat in order to reset it at end of RK loop

if ( (trim(config_tracer_advection) == 'fct') .or. &
(trim(config_thickness_advection) == 'fct') ) then
call li_tracer_advection_fct_shared_init(geometryPool, err_tmp)
if (err_tmp /= 0) then
err = 1
call mpas_log_write( &
'Error encountered during fct tracer advection shared init', &
MPAS_LOG_ERR)
endif
endif

! Set RK weights based on desired time integration method. Note
! that rkSubstepWeights are used to update at each sub-step, and
! are thus offset from the typical writing of the coefficients
Expand Down Expand Up @@ -521,6 +535,17 @@ subroutine li_time_integrator_forwardeuler_rungekutta(domain, err)
fluxAcrossGroundingLine(:) = fluxAcrossGroundingLineAccum(:)
fluxAcrossGroundingLineOnCells(:) = fluxAcrossGroundingLineOnCellsAccum(:)

! Deallocate arrays for fct
if ( (trim(config_thickness_advection) .eq. 'fct') .or. &
(trim(config_tracer_advection) .eq. 'fct') ) then
deallocate( nAdvCellsForEdge, &
advCellsForEdge, &
advCoefs, &
advCoefs3rd, &
advMaskHighOrder, &
advMask2ndOrder)
endif

! Reset time step to full length after RK loop
deltat = deltatFull

Expand Down

0 comments on commit 06eec9c

Please sign in to comment.