@@ -831,19 +831,17 @@ end subroutine mpas_print_alarm
831831 !> within the active start and stop times of the given alarm. If so,
832832 !> it returns `.true. `. An optional error code may also be returned.
833833 !-----------------------------------------------------------------------
834- logical function mpas_is_alarm_active (clock , alarm , ierr )
834+ logical function mpas_is_alarm_active (clock , alarm , time , ierr )
835835 implicit none
836836 type(MPAS_Clock_type), intent (in ) :: clock
837- type(MPAS_Alarm_type), pointer :: alarm
838- integer , intent (out ), optional :: ierr
839- type(MPAS_Time_type) :: now
837+ type(MPAS_Alarm_type), pointer :: alarm
838+ type(MPAS_Time_type) , intent (in ) :: time
839+ integer , intent ( out ), optional :: ierr
840840
841841 if (present (ierr)) ierr = 0
842842
843- now = mpas_get_clock_time(clock, MPAS_NOW, ierr= ierr)
844- mpas_is_alarm_active = mpas_time_in_interval( &
845- alarm%activeStartTime, alarm%activeStopTime, now)
846-
843+ mpas_is_alarm_active = (alarm % activeStartTime <= time &
844+ .and. time <= alarm % activeStopTime)
847845 end function mpas_is_alarm_active
848846
849847
@@ -866,48 +864,11 @@ logical function mpas_prev_ring_in_window(alarm)
866864 implicit none
867865 type(MPAS_Alarm_type), pointer :: alarm
868866
869- mpas_prev_ring_in_window = mpas_time_in_interval( &
870- alarm%activeStartTime, alarm%activeStopTime, &
871- alarm%prevRingTime, is_open_interval= .true. )
872-
867+ mpas_prev_ring_in_window = (alarm % activeStartTime <= alarm % prevRingTime &
868+ .and. alarm % prevRingTime < alarm % activeStopTime)
873869 end function mpas_prev_ring_in_window
874870
875871
876- !-----------------------------------------------------------------------
877- ! function mpas_time_in_interval
878- !
879- !> \brief Test if a time lies within a start/ stop interval.
880- !> \author Andy Stokely
881- !> \date 10 / 01 / 2025
882- !> \details Returns `.true. ` if `time` falls between `start_time` and
883- !> `end_time`. By default, the interval is closed `[start,end]`.
884- !> If the optional `is_open_interval` flag is present and `.true. `,
885- !> the interval is treated as open `(start,end)`, excluding the boundaries.
886- !-----------------------------------------------------------------------
887- logical function mpas_time_in_interval (start_time , end_time , time , is_open_interval )
888- implicit none
889- type(MPAS_Time_type), intent (in ) :: start_time
890- type(MPAS_Time_type), intent (in ) :: end_time
891- type(MPAS_Time_type), intent (in ) :: time
892- logical , intent (in ), optional :: is_open_interval
893- logical :: open_interval
894-
895- mpas_time_in_interval = .false.
896- open_interval = .false.
897- if (present (is_open_interval)) then
898- open_interval = is_open_interval
899- end if
900- if (time > start_time .and. time < end_time) then
901- mpas_time_in_interval = .true.
902- else if (.not. open_interval) then
903- if (time == start_time .or. time == end_time) then
904- mpas_time_in_interval = .true.
905- end if
906- end if
907-
908- end function mpas_time_in_interval
909-
910-
911872 logical function mpas_is_alarm_ringing (clock , alarmID , interval , ierr )
912873
913874 implicit none
@@ -997,7 +958,7 @@ logical function mpas_in_ringing_envelope(clock, alarmPtr, interval, ierr)
997958 end if
998959
999960 if (alarmThreshold <= alarmNow) then
1000- if (mpas_is_alarm_active(clock, alarmPtr, ierr) &
961+ if (mpas_is_alarm_active(clock, alarmPtr, alarmNow, ierr) &
1001962 .or. mpas_prev_ring_in_window(alarmPtr)) then
1002963 mpas_in_ringing_envelope = .true.
1003964 end if
@@ -1013,7 +974,7 @@ logical function mpas_in_ringing_envelope(clock, alarmPtr, interval, ierr)
1013974 end if
1014975
1015976 if (alarmThreshold >= alarmNow) then
1016- if (mpas_is_alarm_active(clock, alarmPtr, ierr) &
977+ if (mpas_is_alarm_active(clock, alarmPtr, alarmNow, ierr) &
1017978 .or. mpas_prev_ring_in_window(alarmPtr)) then
1018979 mpas_in_ringing_envelope = .true.
1019980 end if
0 commit comments