Routine that checks whether a real variable lies within the desired range author: P J Knight, CCFE, Culham Science Centre cvar : input string : name of variable varval : input real : value of variable min_value : input real : minimum allowed value of variable max_value : input real : maximum allowed value of variable This routine checks whether a real variable lies within the range predetermined by the user, and reports an error and stops if it doesn't. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | cvar | |||
real(kind=dp), | intent(in) | :: | varval | |||
real(kind=dp), | intent(in) | :: | min_value | |||
real(kind=dp), | intent(in) | :: | max_value |
subroutine check_range_real(cvar,varval,min_value,max_value)
!! Routine that checks whether a real variable lies within
!! the desired range
!! author: P J Knight, CCFE, Culham Science Centre
!! cvar : input string : name of variable
!! varval : input real : value of variable
!! min_value : input real : minimum allowed value of variable
!! max_value : input real : maximum allowed value of variable
!! This routine checks whether a real variable lies within
!! the range predetermined by the user, and reports an error
!! and stops if it doesn't.
!! None
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
! Arguments
character(len=*), intent(in) :: cvar
real(dp), intent(in) :: varval,min_value,max_value
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (min_value > max_value) then
write(outfile,*) 'Illegal relative values of min_value and max_value'
write(outfile,*) 'for variable ',cvar
write(*,*) 'Illegal relative values of min_value and max_value'
write(*,*) 'for variable ',cvar
error = .True.
end if
if ((varval < min_value).or.(varval > max_value)) then
write(outfile,*) cvar,' lies outside its allowed range :'
write(outfile,*) 'Minimum value = ',min_value
write(outfile,*) 'Maximum value = ',max_value
write(outfile,*) ' Actual value = ',varval
write(*,*) cvar,' lies outside its allowed range :'
write(*,*) 'Minimum value = ',min_value
write(*,*) 'Maximum value = ',max_value
write(*,*) ' Actual value = ',varval
error = .True.
end if
end subroutine check_range_real