Skip to main content

TESTIF.F95

	PROGRAM TESTIF
!
! Purpose: To demonstrate the use of an IF statement
!
!  This is the TESTIF program with the DO-loop --- see page 6 of the notes.
!
	IMPLICIT NONE
	INTEGER::I		! Index of the DO-loop
	REAL::A,B		! Real input
	LOGICAL::LVAR		! Logical input
!
	DO I=1,5
!
	  WRITE(*,*)'Enter a value for real number A'
	  READ(*,*)A
	  WRITE(*,*)'Enter a value for real number B'
	  READ(*,*)B
	  WRITE(*,*)'Enter .TRUE. or .FALSE. for value of LVAR'
	  READ(*,*)LVAR
	  IF(A.LE.B.AND..NOT.LVAR)THEN	! First option
	     WRITE(*,*)'A is less or equal to B and LVAR is .FALSE.'
	  ELSE				! Second option
	     WRITE(*,*)'A is greater than B or LVAR is .TRUE.'
  	  END IF 
!
	END DO
!
	STOP
	END PROGRAM TESTIF