validate_cutoffs Subroutine

subroutine validate_cutoffs(config, error)

Validate that fragment cutoffs are monotonically decreasing For n-mer level N, cutoff(N) must be <= cutoff(N-1)

Arguments

Type IntentOptional Attributes Name
type(mqc_config_t), intent(in) :: config
type(error_t), intent(out) :: error

Calls

proc~~validate_cutoffs~~CallsGraph proc~validate_cutoffs validate_cutoffs proc~error_set error_t%error_set proc~validate_cutoffs->proc~error_set

Called by

proc~~validate_cutoffs~~CalledByGraph proc~validate_cutoffs validate_cutoffs proc~parse_fragmentation_section parse_fragmentation_section proc~parse_fragmentation_section->proc~validate_cutoffs interface~parse_fragmentation_section parse_fragmentation_section interface~parse_fragmentation_section->proc~parse_fragmentation_section proc~read_mqc_file read_mqc_file proc~read_mqc_file->interface~parse_fragmentation_section program~main main program~main->proc~read_mqc_file

Variables

Type Visibility Attributes Name Initial
real(kind=dp), private :: cutoff_high
real(kind=dp), private :: cutoff_low
integer, private :: i
integer, private :: level_high
integer, private :: level_low
character(len=256), private :: msg

Source Code

   subroutine validate_cutoffs(config, error)
      !! Validate that fragment cutoffs are monotonically decreasing
      !! For n-mer level N, cutoff(N) must be <= cutoff(N-1)
      type(mqc_config_t), intent(in) :: config
      type(error_t), intent(out) :: error

      integer :: i, level_low, level_high
      real(dp) :: cutoff_low, cutoff_high
      character(len=256) :: msg

      if (.not. allocated(config%fragment_cutoffs)) return

      ! Check monotonicity for consecutive levels with defined cutoffs
      do i = 2, size(config%fragment_cutoffs)
         level_low = i - 1
         level_high = i

         cutoff_low = config%fragment_cutoffs(level_low)
         cutoff_high = config%fragment_cutoffs(level_high)

         ! Skip if either cutoff is not defined (negative or zero sentinel value)
         if (cutoff_low <= 0.0_dp .or. cutoff_high <= 0.0_dp) cycle

         ! Validate monotonic decreasing
         if (cutoff_high > cutoff_low) then
            write (msg, '(a,i0,a,f0.2,a,i0,a,f0.2,a)') &
               "Fragment cutoffs must be monotonically decreasing: ", &
               level_high, "-mer cutoff (", cutoff_high, ") cannot be larger than ", &
               level_low, "-mer cutoff (", cutoff_low, "). Check %cutoffs section."
            call error%set(ERROR_PARSE, trim(msg))
            return
         end if
      end do

   end subroutine validate_cutoffs