MODULE const INTEGER, PARAMETER :: dp = KIND(1.0d0), sp = KIND(1.0e0) REAL(KIND=dp), PARAMETER :: dpi = 3.141592653589793d0 END MODULE const !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PROGRAM printval USE const IMPLICIT NONE ! ! Program to demonstrate type mismatches in subroutines ! INTEGER :: i REAL(KIND=dp) :: a WRITE(*,*) 'Input an integer (i) ' READ(*,*) i WRITE(*,*) 'Input a double (a)' READ(*,*) a ! Print the value of i using printint WRITE(*,*) WRITE(*,*) 'Print value of (i) using printint' CALL printint(i) ! Print the value of a using printint WRITE(*,*) WRITE(*,*) 'Print value of (a) using printint' WRITE(*,*) 'Note that this is a type mismatch' WRITE(*,*) 'The value printed is garbage' CALL printint(a) ! Print the value of i using printdouble WRITE(*,*) WRITE(*,*) 'Print value of (i) using printdouble' WRITE(*,*) 'Note that this is a type mismatch' WRITE(*,*) 'The value printed is garbage' CALL printdouble(i) ! Print the value of a using printint WRITE(*,*) WRITE(*,*) 'Print value of (a) using printdouble' CALL printdouble(a) END PROGRAM printval !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE printdouble(a) ! ! Subroutine that will take in a double precision value and ! print it out ! USE const IMPLICIT NONE REAL(Kind=dp), INTENT(IN) :: a WRITE(*,*) a END SUBROUTINE printdouble !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBROUTINE printint(i) ! ! Subroutine that will take in an integer value and ! print it out ! USE const IMPLICIT NONE INTEGER, INTENT(IN) :: i WRITE(*,*) i END SUBROUTINE printint