I just tried this with the Early Access version of Sun's f9x compiler,
and the bug appears to be fixed:
ursine1% f95 ahmad.f95
ursine1% a.out
subA: arr1 = 1 2 3 4
subB: arr1 = 1 2 3 4
The Early Access version is still available at
"http://access1.sun.com/workshop6ea/".
> The behavior described below is a bug in Sun f90 5.0 and 6.0. It
> worked correctly in earlier versions. I reported this to Sun in
> January, and they assigned it Bug ID 4304893. I have not heard from
> them yet about a fix.
Looks like your bug is fixed too, Ron:
ursine1% f95 -V parm_array.f95
f95: Sun WorkShop 6 2000/01/09 FORTRAN 95 6.0 Dev
f90comp: Sun WorkShop 6 2000/01/09 FORTRAN 95 6.0 Dev
f90: Cray CF90 Version 3.x.x.x (f41pXXgXXXa48) Mon Mar 27, 2000 10:56:58
f90: COMPILE TIME 0.160000 SECONDS
f90: MAXIMUM FIELD LENGTH 4063358 DECIMAL WORDS
f90: 21 SOURCE LINES
f90: 0 ERRORS, 0 WARNINGS, 0 OTHER MESSAGES, 0 ANSI
ld: Software Generation Utilities - Solaris/ELF (3.0)
ursine1% a.out
3
5
7
ursine1%
> Any one of the following changes will make the program run correctly
> with all versions of the Sun compiler:
>
> Put a "use mod" statement inside the subroutine (as you did
> in subb).
>
> Remove the "parameter" attribute from the declaration of arr1.
>
> Use a literal constant subscript for i in subroutine suba to
> print an element of of arr1, e.g. print *,arr1(3). Note that
> a loop with a variable subscript does not work.
>
> Make arr1 a scalar parameter instead of an array.
>
> Make suba an internal subroutine of the main program and
> have "use mod" at the top level of the main program.
>
>
> Ronald Sverdlove Computing Systems Research
> [log in to unmask] Sarnoff Corporation
> Tel. 609-734-2517 CN 5300
> FAX 609-734-2662 Princeton, NJ 08543-5300
>
>
>
>
> > Date: Mon, 27 Mar 2000 19:09:59 +0100
> > Subject: Scope of variables in a module USEd inside a module
> > From: "M. Ahmad" <[log in to unmask]>
> > To: [log in to unmask]
> >
> > 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?
> > On other compilers like The NAGWare f90 compiler Version 2.2, and The
> > SGI MIPSpro 7 Fortran 90 compiler, this problem does not arise.
> >
> > There is a sentence in the book 'Fortran 90/95 explained', which says:
> >
> > The scope of a label is a main program or a subprogram, excluding any
> > internal subprograms that it contains. (5.14, Page 88)
> >
> > Does this apply to my problem, if the label is arr1?
> >
> >
> >
> > Thanks,
> > M. Ahmad
> >
> > --
> > Mahmood Ahmad (MSc by Research Student)
> > AMOR Group,
> > Department of Informatics and Simulation (DOIS),
> > RMCS, Cranfield University,
> > Shrivenham, Swindon, Wilts., UK
> > Tel: 00-44-01793-785889
> > Email: [log in to unmask]
> > [log in to unmask]
> >
> >
>
Chuck
--
Chuck Fisher +1-650-786-9317
Product Manager, Forte Fortran & HPC Products
[log in to unmask] | [log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|