Skip to content

Commit

Permalink
Merge remote-tracking branch 'fms/main' into coupler_flux_oceanice_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mlee03 committed May 31, 2024
2 parents 6055659 + 80def09 commit 75057b1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 42 deletions.
6 changes: 1 addition & 5 deletions full/coupler_main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ program coupler_main

call fms_mpp_init()

!this clock is on the global pelist
!these clocks are on the global pelist
coupler_clocks%initialization = fms_mpp_clock_id( 'Initialization' )
call fms_mpp_clock_begin(coupler_clocks%initialization)

Expand Down Expand Up @@ -443,8 +443,6 @@ program coupler_main
coupler_clocks, init_stocks=.True.)

do nc = 1, num_cpld_calls
if (do_chksum) call coupler_chksum('top_of_coupled_loop+', nc, Atm, Land, Ice)
call fms_mpp_set_current_pelist()

if (do_chksum) then
call coupler_chksum('top_of_coupled_loop+', nc, Atm, Land, Ice)
Expand Down Expand Up @@ -860,7 +858,6 @@ program coupler_main

if( check_stocks >=0 ) call coupler_flux_init_finish_stocks(Time, Atm, Land, Ice, Ocean_state, &
coupler_clocks, finish_stocks=.True.)

!-----------------------------------------------------------------------
call fms_mpp_set_current_pelist()
call fms_mpp_clock_end(coupler_clocks%main)
Expand All @@ -871,7 +868,6 @@ program coupler_main
Atmos_land_boundary, Ice_ocean_boundary, Ocean_ice_boundary, Ocn_bc_restart, Ice_bc_restart, &
Time, Time_start, Time_end, Time_restart_current)


call fms_mpp_clock_end(coupler_clocks%termination)

call fms_memutils_print_memuse_stats( 'Memory HiWaterMark', always=.TRUE. )
Expand Down
4 changes: 4 additions & 0 deletions full/flux_exchange.F90
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,11 @@ end subroutine flux_exchange_init
!! component.

subroutine flux_check_stocks(Time, Atm, Lnd, Ice, Ocn_state)
<<<<<<< HEAD

=======

>>>>>>> fms/main
type(FmsTime_type), intent(in) :: Time
type(atmos_data_type), intent(inout), optional :: Atm
type(land_data_type), intent(inout), optional :: Lnd
Expand Down
80 changes: 43 additions & 37 deletions full/full_coupler_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ module full_coupler_mod

public :: coupler_atmos_ice_land_ocean_chksum

public :: coupler_clock_type

public :: coupler_flux_init_finish_stocks, coupler_flux_check_stocks
public :: coupler_flux_ocean_to_ice, coupler_flux_ice_to_ocean

public :: coupler_clock_type

!-----------------------------------------------------------------------

#include <file_version.fh>
Expand Down Expand Up @@ -231,7 +231,9 @@ module full_coupler_mod
use_hyper_thread, concurrent_ice, slow_ice_with_ocean, &
do_endpoint_chksum, combined_ice_and_ocean

type coupler_clock_type
!> coupler_clock_type derived type consist of all clock ids that will be set and used
!! in full coupler_main.
type coupler_clock_type
integer :: initialization
integer :: main
integer :: generate_sfc_xgrid
Expand Down Expand Up @@ -311,7 +313,9 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary,
integer, intent(inout) :: conc_nthreads
integer, allocatable, dimension(:,:), intent(inout) :: ensemble_pelist
integer, allocatable, dimension(:), intent(inout) :: slow_ice_ocean_pelist

type(coupler_clock_type) :: coupler_clocks

type(FMSTime_type), intent(inout) :: Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean
type(FMSTime_type), intent(inout) :: Time, Time_start, Time_end, Time_restart, Time_restart_current

Expand Down Expand Up @@ -608,7 +612,6 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary,
endif
endif


!> The pelists need to be set before initializing the clocks
call coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble_pelist, &
slow_ice_ocean_pelist, ensemble_id)
Expand Down Expand Up @@ -871,8 +874,9 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary,
call fms_mpp_clock_begin(coupler_clocks%atmos_model_init)
call atmos_model_init( Atm, Time_init, Time, Time_step_atmos, &
do_concurrent_radiation)

call fms_mpp_clock_end(coupler_clocks%atmos_model_init)

if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then
call DATE_AND_TIME(walldate, walltime, wallzone, wallvalues)
write(errunit,*) 'Finished initializing atmospheric model at '&
Expand Down Expand Up @@ -1087,7 +1091,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary,

!-----------------------------------------------------------------------
if ( do_endpoint_chksum ) then
call coupler_atmos_ice_land_ocean_chksum('coupler_init+', 0, Atm, Land, Ice, &
call coupler_atmos_ice_land_ocean_chksum('coupler_init+', 0, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary, Ocean, Ice_ocean_boundary)
if (Ice%slow_ice_PE) then
call fms_mpp_set_current_pelist(Ice%slow_pelist)
Expand Down Expand Up @@ -1129,9 +1133,8 @@ subroutine coupler_end(Atm, Land, Ice, Ocean, Ocean_state, Land_ice_atmos_bounda
integer :: num_ice_bc_restart, num_ocn_bc_restart

if ( do_endpoint_chksum ) then
call coupler_atmos_ice_land_ocean_chksum('coupler_end', 0, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary, Ocean, &
Ice_ocean_boundary)
call coupler_atmos_ice_land_ocean_chksum('coupler_end', 0, Atm, Land, Ice, &
Land_ice_atmos_boundary, Atmos_ice_boundary, Atmos_land_boundary, Ocean, Ice_ocean_boundary)
if (Ice%slow_ice_PE) then
call fms_mpp_set_current_pelist(Ice%slow_pelist)
call slow_ice_chksum('coupler_end', 0, Ice, Ocean_ice_boundary)
Expand Down Expand Up @@ -1512,17 +1515,17 @@ end subroutine ocean_chksum
!> \brief This subroutine sets the ID for clocks used in coupler_main
subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble_pelist,&
slow_ice_ocean_pelist, ensemble_id)

implicit none

type(coupler_clock_type), intent(inout) :: coupler_clocks !< coupler_clocks
type(atmos_data_type), intent(in) :: Atm !< Atm
type(land_data_type), intent(in) :: Land !< Land
type(ocean_public_type), intent(in) :: Ocean !< Ocean
type(ice_data_type), intent(in) :: Ice !< Ice
integer, dimension(:), intent(in) :: slow_ice_ocean_pelist !< slow_ice_ocean_pelist
type(atmos_data_type), intent(in) :: Atm !< Atm, required to retrieve pe information
type(land_data_type), intent(in) :: Land !< Land, required to retrieve pe information
type(ocean_public_type), intent(in) :: Ocean !< Ocean, required to retrieve pe information
type(ice_data_type), intent(in) :: Ice !< Ice, required to retrieve pe information
integer, dimension(:), intent(in) :: slow_ice_ocean_pelist !< slow_ice_oean_pelist
integer, dimension(:,:), intent(in) :: ensemble_pelist !< ensemble_pelist
integer, intent(in) :: ensemble_id !< ensemble_id
integer, intent(in) :: ensemble_id !< ensemble_id used as index in ensemble_pelist

!> initialization clock
if (Atm%pe) then
Expand All @@ -1535,8 +1538,8 @@ subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble
endif
if (Ice%pe) then
if (Ice%shared_slow_fast_PEs) then ; call fms_mpp_set_current_pelist(Ice%pelist)
elseif (Ice%fast_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%fast_pelist)
elseif (Ice%slow_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%slow_pelist)
elseif (Ice%fast_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%fast_pelist)
elseif (Ice%slow_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%slow_pelist)
else ; call fms_mpp_error(FATAL, "All Ice%pes must be a part of Ice%fast_ice_pe or Ice%slow_ice_pe")
endif
coupler_clocks%ice_model_init = fms_mpp_clock_id( ' Init: ice_model_init ' )
Expand All @@ -1547,11 +1550,11 @@ subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble
endif
call fms_mpp_set_current_pelist(ensemble_pelist(ensemble_id,:))
coupler_clocks%flux_exchange_init = fms_mpp_clock_id( ' Init: flux_exchange_init' )

call fms_mpp_set_current_pelist()
coupler_clocks%main = fms_mpp_clock_id( 'Main loop' )
coupler_clocks%termination = fms_mpp_clock_id( 'Termination' )

If(Atm%pe) then
call fms_mpp_set_current_pelist(Atm%pelist)
coupler_clocks%generate_sfc_xgrid = fms_mpp_clock_id( 'generate_sfc_xgrid' )
Expand All @@ -1570,7 +1573,7 @@ subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble
coupler_clocks%sfc_boundary_layer = fms_mpp_clock_id( ' A-L: sfc_boundary_layer' )
coupler_clocks%update_atmos_model_dynamics = fms_mpp_clock_id( ' A-L: update_atmos_model_dynamics')
if (.not. do_concurrent_radiation) &
coupler_clocks%serial_radiation = fms_mpp_clock_id( ' A-L: serial radiation' )
coupler_clocks%serial_radiation = fms_mpp_clock_id( ' A-L: serial radiation' )
coupler_clocks%update_atmos_model_down = fms_mpp_clock_id( ' A-L: update_atmos_model_down' )
coupler_clocks%flux_down_from_atmos = fms_mpp_clock_id( ' A-L: flux_down_from_atmos' )
coupler_clocks%update_land_model_fast = fms_mpp_clock_id( ' A-L: update_land_model_fast' )
Expand All @@ -1589,33 +1592,33 @@ subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble
if (Ice%fast_ice_pe) call fms_mpp_set_current_pelist(Ice%fast_pelist)
coupler_clocks%set_ice_surface_fast = fms_mpp_clock_id( ' Ice: set_ice_surface fast' )
coupler_clocks%update_ice_model_slow_fast = fms_mpp_clock_id( ' Ice: update_ice_model_slow fast' )

if (Ice%slow_ice_pe) call fms_mpp_set_current_pelist(Ice%slow_pelist)
coupler_clocks%set_ice_surface_slow = fms_mpp_clock_id( ' Ice: set_ice_surface slow' )
coupler_clocks%update_ice_model_slow_slow = fms_mpp_clock_id( ' Ice: update_ice_model_slow slow' )
coupler_clocks%flux_ice_to_ocean_stocks = fms_mpp_clock_id( ' Ice: flux_ice_to_ocean_stocks' )

call fms_mpp_set_current_pelist(Ice%pelist)
coupler_clocks%set_ice_surface_exchange = fms_mpp_clock_id( ' Ice: set_ice_surface exchange' )
coupler_clocks%update_ice_model_slow_exchange = fms_mpp_clock_id( ' Ice: update_ice_model_slow exchange' )

endif
if (Ocean%is_ocean_pe) then
call fms_mpp_set_current_pelist(Ocean%pelist)
coupler_clocks%ocean = fms_mpp_clock_id( 'OCN' )
endif

call fms_mpp_set_current_pelist()
coupler_clocks%flux_check_stocks = fms_mpp_clock_id( 'flux_check_stocks' )
coupler_clocks%intermediate_restart = fms_mpp_clock_id( 'intermediate restart' )
coupler_clocks%final_flux_check_stocks = fms_mpp_clock_id( 'final flux_check_stocks' )

end subroutine coupler_set_clock_ids

!> \brief This subroutine calls coupler_chksum as well as atmos_ice_land_chksum and ocean_chksum
subroutine coupler_atmos_ice_land_ocean_chksum(id, timestep, Atm, Land, Ice, Land_ice_atmos_boundary,&
Atmos_ice_boundary, Atmos_land_boundary, Ocean, Ice_ocean_boundary, Ocean_ice_boundary)

implicit none

character(len=*), intent(in) :: id !< ID labelling the set of checksums
Expand All @@ -1641,12 +1644,12 @@ subroutine coupler_atmos_ice_land_ocean_chksum(id, timestep, Atm, Land, Ice, Lan
endif

call fms_mpp_set_current_pelist()

end subroutine coupler_atmos_ice_land_ocean_chksum

!> \brief This subroutine calls flux_init_stocks or does the final call to flux_check_stocks
subroutine coupler_flux_init_finish_stocks(Time, Atm, Land, Ice, Ocean_state, &
coupler_clocks, init_stocks, finish_stocks)
coupler_clocks, init_stocks, finish_stocks)

implicit none

Expand All @@ -1659,12 +1662,15 @@ subroutine coupler_flux_init_finish_stocks(Time, Atm, Land, Ice, Ocean_state, &
logical, optional, intent(in) :: init_stocks, finish_stocks !< control flags to either call flux_init_stocks or
!! the final flux_check_stocks

logical :: init, finish
logical :: init, finish !< control flags set to False. by default and takes on the value of init_stocks and
!! finish_stocks if these optional arguments are provided.
!! If true, either flux_init_stocks or
!! final flux_check_stocks will be called.

init=.False. ; if(present(init_stocks)) init=init_stocks
finish=.False. ; if(present(finish_stocks)) finish=finish_stocks

if(init) then
if(init) then
call fms_mpp_set_current_pelist()
call flux_init_stocks(Time, Atm, Land, Ice, Ocean_state)
else if(finish) then
Expand All @@ -1678,7 +1684,7 @@ subroutine coupler_flux_init_finish_stocks(Time, Atm, Land, Ice, Ocean_state, &
else
call fms_mpp_error(FATAL, 'coupler_flux_init_finish_stocks: either init or finish needs to be .True.')
end if

end subroutine coupler_flux_init_finish_stocks

!> \brief This subroutine calls flux_check_stocks
Expand All @@ -1695,14 +1701,14 @@ subroutine coupler_flux_check_stocks(nc, Time, Atm, Land, Ice, Ocean_state, coup
type(coupler_clock_type), intent(inout) :: coupler_clocks !< coupler_clocks

call fms_mpp_clock_begin(coupler_clocks%flux_check_stocks)
if (check_stocks*((nc-1)/check_stocks) == nc-1 .AND. nc > 1) then
if (check_stocks*((nc-1)/check_stocks) == nc-1 .AND. nc > 1) then
call fms_mpp_set_current_pelist()
call flux_check_stocks(Time=Time, Atm=Atm, Lnd=Land, Ice=Ice, Ocn_state=Ocean_state)
endif
call fms_mpp_clock_end(coupler_clocks%flux_check_stocks)

end subroutine coupler_flux_check_stocks

!> \brief This subroutine calls flux_ocean_to_ice
subroutine coupler_flux_ocean_to_ice(Ocean, Ice, Ocean_ice_boundary, coupler_clocks, slow_ice_ocean_pelist)

Expand Down Expand Up @@ -1739,7 +1745,7 @@ subroutine coupler_flux_ice_to_ocean(Ice, Ocean, Ice_ocean_boundary, coupler_clo
type(coupler_clock_type), intent(inout) :: coupler_clocks !< coupler_clocks
integer, dimension(:), optional, intent(in) :: slow_ice_ocean_pelist !< slow_ice_ocean_pelist
!> if true, will call mpp_set_current_pelist(slow_ice_ocean_pelist)
logical, optional, intent(in) :: set_current_slow_ice_ocean_pelist
logical, optional, intent(in) :: set_current_slow_ice_ocean_pelist

logical :: set_current_slow_ice_ocean_pelist_in !< .F. by default; set to equal set_current_slow_ice_ocean_pelist

Expand Down

0 comments on commit 75057b1

Please sign in to comment.