The main documentation of the Valid_State_Status Procedure contains additional explanation of this code listing.
function Valid_State_Status (S) result(Valid)
! Input variable.
type(Status_type), intent(in) :: S ! Status to be checked.
! Output variable.
type(logical) :: Valid ! Logical state.
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! Start out true.
Valid = .true.
! Make sure the status variable is in range.
Valid = Valid .and. S%status <= NFlags
Valid = Valid .and. S%status >= 1
return
end function Valid_State_Status