checsqrt
C CHECSQRT SOURCE AM 12/02/28 21:15:08 7291 Subroutine check_sqrt(x,Name_of_x,Name_of_subr,lerror) c This subroutine checks the value of the variable x c (because x will be used in a sqrt in the calling subroutine after the return). c If (x.lt.0) or if (x is a NaN (Not a Number)), c then a message is printed and lerror = .true. is returned logical lerror real*8 x character*20 Name_of_subr,Name_of_x lerror = .false. if (x.lt.0.d0) then ** write(2,1)Name_of_subr,Name_of_x,x write(*,1)Name_of_subr,Name_of_x,x 1 format(/' ERROR in subroutine ',A20/ . ' The variable "',A20,'" is negative.'/ . ' This would create problems because its square . root will be calculated.'/ . ' The value of this variable is:',g10.3/) lerror = .true. c elseif (isnan(x)) then c write(2,2)Name_of_subr,Name_of_x c write(*,2)Name_of_subr,Name_of_x c2 format(/' ERROR in subroutine ',A20,'.'/ c . ' The variable "',A20,'" is a NaN (Not a Number).'/ c . ' This would create problems because its square c . root will be calculated.'/) c lerror = .true. else lerror = .false. endif return end
© Cast3M 2003 - Tous droits réservés.
Mentions légales