Anthony Stone, and others
At 10:59 17-12-99 +0000, you wrote:
>I would appreciate advice as to whether I have encountered a bug or am
>doing something wrong.
You maight have done this yourself, but...
>I have a module,
>
> sizes.f90,
>
>which merely defines a couple of arrays,
>one of which is
>
> integer, parameter :: qsize(-1:8) = (/0,1,4,9,16,25,36,49,64,81/)
>
>This module is USEd in the main program and in the module header of
>another module autocor.f90. The array qsize is referenced in one of the
>module subroutines of autocor.f90:
>
> n = qsize(ll)
>
>ll is usually 4. However the value of n gets set to zero, unless I
>also USE sizes in the subroutine as well as in the module header.
>
>This second USE shouldn't be necessary, should it?
Here you are right.
> Don't USE
>statements in the module header make entities in the USEd module
>visible to the entire module containing the USE statement? The
>compiler doesn't complain about qsize when I leave out the second USE,
>so presumably it knows about it.
>
>I'm using Solaris 2.7. f90 -V gives
>f90: WorkShop Compilers 5.0 98/12/21 FORTRAN 90 2.0
I transformed your problem into a program, attached to this mail.
With Salford FTN95 and Absoft F90 it runs fine, result = 25 .
There seems to be a bug in your system.
module sizes
! sizes.f90,
!which merely defines a couple of arrays,
!one of which is
integer, parameter :: qsize(-1:8) = (/0,1,4,9,16,25,36,49,64,81/)
end module
module autocor
use sizes
contains
subroutine Sub1
integer :: n, LL = 4
n = qsize(LL)
print *, " Sub1: n = ", n
end subroutine Sub1
end module
! This module is USEd in the main program and in the module header
! of another module autocor.f90.
! The array qsize is referenced in one of the
! module subroutines of autocor.f90:
! n = qsize(ll)
! ll is usually 4. However the value of n gets set to zero, unless I
! also USE sizes in the subroutine as well as in the module header.
program main
use autocor
! This second USE shouldn't be necessary, should it? Don't USE
! statements in the module header make entities in the USEd module
! visible to the entire module containing the USE statement? The
! compiler doesn't complain about qsize when I leave out the second USE,
! so presumably it knows about it.
! I'm using Solaris 2.7. f90 -V gives
! f90: WorkShop Compilers 5.0 98/12/21 FORTRAN 90 2.0
! --
! Anthony Stone http://fandango.ch.cam.ac.uk/
! University Chemical Laboratory, Email: [log in to unmask]
! Lensfield Road, Phone: +44 1223 336375
! Cambridge CB2 1EW Fax: +44 1223 336362
call Sub1
end program main
---
Meilleures Salutations,
Best Greetings,
/---
Jan van Oosterwijk
Computing Centre
Delft University of Technology
Postbus 354
2600 AJ Delft
Netherlands / Pays-Bas
Phone: +31 15 278 50 17
Fax: +31 15 278 37 87
|