>
> Hi, I have a Fortran 90 problem. It's defined in three separate files as
> follows:
>
> ! arr.f90
> !
> MODULE arr
> INTEGER, Parameter, DIMENSION(4) :: arr1 = (/ 1, 2, 3, 4 /)
> END MODULE arr
>
> ! modb.f90
> !
> MODULE modb
> USE arr
> IMPLICIT NONE
> CONTAINS
> SUBROUTINE subA()
> IMPLICIT NONE
> PRINT*, 'subA: arr1 = ', arr1
> END SUBROUTINE subA
> SUBROUTINE subB()
> USE arr
> IMPLICIT NONE
> PRINT*, 'subB: arr1 = ', arr1
> END SUBROUTINE subB
> END MODULE modb
>
> testarr.f90
> !
> PROGRAM testarr
> USE modB
> IMPLICIT NONE
> !
> CALL subA()
> CALL subB()
> END PROGRAM testarr
>
> I have tried on the SUN Worksop Compiler 5.0 Fortran 2.0, which does not
> display values of array arr1 through subroutine subA. But it works if an
> explicit USE statement is used, as in subB. Could somebody guide me for
> the scope of variables defined in a module?
The SUN compiler has a bug. subA should access the variables of its
host by host association, including the variables that the host
accesses by use association.
Cheers,
John Reid.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|