From c053fdcb063c0bc6cc08263c82fc11d30573185b Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Mon, 25 Oct 2021 10:18:17 -0400 Subject: [PATCH] cpu_clock_id: synchro_flag arg changed to logical This patch modifies the `cpu_clock_id` interface so that the `synchro_flag` argument is converted into a platform-agnostic logical flag. The current implementation requires the synchronization flag to be defined using FMS norms (zero-bit) and also would force users to follow FMS predefined flags for other values. This patch changes the sync flag to a logical, and modifies the default flag to enable synced clocks (based on `clock_flag_default`). `synchro_flag` is also renamed to `sync` for simplicity. --- config_src/infra/FMS1/MOM_cpu_clock_infra.F90 | 25 ++++++++++--------- config_src/infra/FMS2/MOM_cpu_clock_infra.F90 | 25 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/config_src/infra/FMS1/MOM_cpu_clock_infra.F90 b/config_src/infra/FMS1/MOM_cpu_clock_infra.F90 index 47d7bbedaa..62c21e5772 100644 --- a/config_src/infra/FMS1/MOM_cpu_clock_infra.F90 +++ b/config_src/infra/FMS1/MOM_cpu_clock_infra.F90 @@ -71,23 +71,24 @@ subroutine cpu_clock_end(id) end subroutine cpu_clock_end !> Returns the integer handle for a named CPU clock. -integer function cpu_clock_id( name, synchro_flag, grain ) +integer function cpu_clock_id(name, sync, grain) character(len=*), intent(in) :: name !< The unique name of the CPU clock - integer, optional, intent(in) :: synchro_flag !< An integer flag that controls whether the PEs - !! are synchronized before the cpu clocks start counting. - !! Synchronization occurs before the start of a clock if this - !! is odd, while additional (expensive) statistics can set - !! for other values. If absent, the default is taken from the - !! settings for FMS. + logical, optional, intent(in) :: sync !< A flag that controls whether the + !! PEs are synchronized before the cpu clocks start counting. + !! Synchronization occurs before the start of a clock if this + !! is enabled, while additional (expensive) statistics can + !! set for other values. + !! If absent, the default is taken from the settings for FMS. integer, optional, intent(in) :: grain !< The timing granularity for this clock, usually set to !! the values of CLOCK_COMPONENT, CLOCK_ROUTINE, CLOCK_LOOP, etc. - if (present(synchro_flag)) then - cpu_clock_id = mpp_clock_id(name, flags=synchro_flag, grain=grain) - else - cpu_clock_id = mpp_clock_id(name, flags=clock_flag_default, grain=grain) - endif + integer :: clock_flags + clock_flags = clock_flag_default + if (present(sync)) & + clock_flags = ibset(clock_flags, 0) + + cpu_clock_id = mpp_clock_id(name, flags=clock_flags, grain=grain) end function cpu_clock_id end module MOM_cpu_clock_infra diff --git a/config_src/infra/FMS2/MOM_cpu_clock_infra.F90 b/config_src/infra/FMS2/MOM_cpu_clock_infra.F90 index 47d7bbedaa..62c21e5772 100644 --- a/config_src/infra/FMS2/MOM_cpu_clock_infra.F90 +++ b/config_src/infra/FMS2/MOM_cpu_clock_infra.F90 @@ -71,23 +71,24 @@ subroutine cpu_clock_end(id) end subroutine cpu_clock_end !> Returns the integer handle for a named CPU clock. -integer function cpu_clock_id( name, synchro_flag, grain ) +integer function cpu_clock_id(name, sync, grain) character(len=*), intent(in) :: name !< The unique name of the CPU clock - integer, optional, intent(in) :: synchro_flag !< An integer flag that controls whether the PEs - !! are synchronized before the cpu clocks start counting. - !! Synchronization occurs before the start of a clock if this - !! is odd, while additional (expensive) statistics can set - !! for other values. If absent, the default is taken from the - !! settings for FMS. + logical, optional, intent(in) :: sync !< A flag that controls whether the + !! PEs are synchronized before the cpu clocks start counting. + !! Synchronization occurs before the start of a clock if this + !! is enabled, while additional (expensive) statistics can + !! set for other values. + !! If absent, the default is taken from the settings for FMS. integer, optional, intent(in) :: grain !< The timing granularity for this clock, usually set to !! the values of CLOCK_COMPONENT, CLOCK_ROUTINE, CLOCK_LOOP, etc. - if (present(synchro_flag)) then - cpu_clock_id = mpp_clock_id(name, flags=synchro_flag, grain=grain) - else - cpu_clock_id = mpp_clock_id(name, flags=clock_flag_default, grain=grain) - endif + integer :: clock_flags + clock_flags = clock_flag_default + if (present(sync)) & + clock_flags = ibset(clock_flags, 0) + + cpu_clock_id = mpp_clock_id(name, flags=clock_flags, grain=grain) end function cpu_clock_id end module MOM_cpu_clock_infra