! This is a basic starting shell for your programs MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const ! PROGRAM prog USE const IMPLICIT NONE ! Program to evaluate the piecewise function from the notes ! using nested IF-THEN-ELSE logic and compound IF-THEN-ELSEIF ! logic ! REAL(kind=dp) :: x,y,f WRITE(*,*) 'Input x,y' READ(*,*) x,y IF( x >= 0) THEN IF(y >= 0) THEN f = cos(x)*sin(y) ELSE f = sin(x)*cos(y) ENDIF ELSE IF(y >= 0) THEN f = cos(x)*cos(y) ELSE f = sin(x)*sin(y) ENDIF ENDIF WRITE(*,*) 'f = ',f ! Using compound logic IF((x >= 0).AND.(y >=0)) THEN f = COS(x)*SIN(y) ELSEIF((x >= 0).AND.(y < 0)) THEN f = SIN(x)*COS(y) ELSEIF((x < 0).AND.(y >= 0)) THEN f = COS(x)*COS(y) ELSEIF((x < 0).AND.(y < 0)) THEN f = SIN(x)*SIN(y) ENDIF WRITE(*,*) 'f = ',f END PROGRAM prog