MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const PROGRAM test ! ! Program to compute the area of a triangle using a subroutine ! USE const IMPLICIT NONE REAL(KIND=dp) :: area, base, height ! Read in values for base and height WRITE(*,*) 'Input base, height' READ(*,*) base, height ! Call the subroutine to compute the triangle area CALL tri_area(base,height,area) ! Print out the area WRITE(*,*) 'Area = ',area END PROGRAM test !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE tri_area(base,height,area) USE const IMPLICIT NONE REAL(KIND=dp),INTENT(IN) :: base,height REAL(KIND=dp),INTENT(OUT) :: area area = base*height/2 RETURN END SUBROUTINE tri_area !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! The subroutine below is functionally equivalent to the ! first one. ! ! If you abstract out what the routine is doing, both of ! these routines say: ! set the third number equal to the product of the the first 2 numbers ! divided by 2 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE evil_steve(chair,apple,bike) USE const IMPLICIT NONE REAL(KIND=dp),INTENT(IN) :: chair,apple REAL(KIND=dp),INTENT(OUT) :: bike bike = chair*apple/2 RETURN END SUBROUTINE evil_steve