!======================================================================= ! FILE: TEST11.F90 ! DATE: 21 July 2003 ! ! TEST: Whether use of INTENT(OUT) variable in a subprogram will ! be diagnosed at compile or run time. ! ! Contact: Arnaud Desitter ! !======================================================================= MODULE all_sub PRIVATE PUBLIC :: test1,test2 CONTAINS SUBROUTINE test1(a,n) IMPLICIT NONE INTEGER,INTENT(in) :: n REAL,INTENT(out), DIMENSION(n) :: a REAL :: b WRITE(*,*) 'Problem with intent(out) checkable at compile time' !---Elements of array, a, have not yet been "defined within Subroutine ! test1." The following line violates Fortran 90 Standard 5.1.2.3 ! Intent Attribute. b=a(2) WRITE(*,*) b a(:)=4. END SUBROUTINE test1 SUBROUTINE test2(a,n,code) IMPLICIT NONE INTEGER,INTENT(in) :: n REAL, INTENT(out), DIMENSION(n) :: a LOGICAL, INTENT(in) :: code REAL :: b IF (code) THEN WRITE(*,*) 'Problem with intent(out) checkable at run time' !---Elements of array, a, have not yet been "defined within Subroutine ! test1." The following line violates Fortran 90 Standard 5.1.2.3 ! Intent Attribute. b=a(2) WRITE(*,*) b END IF a(:)=4. END SUBROUTINE test2 END MODULE all_sub PROGRAM tintent2 USE all_sub, ONLY : test1, test2 IMPLICIT NONE INTEGER, PARAMETER :: n=7 REAL, DIMENSION(n) :: a a(:)=10. CALL test1(a,n) CALL test2(a,n,.TRUE.) END PROGRAM tintent2