After upgrade to gcc 4.4.1 (Ubuntu Karmic) I get this kind of error
with
Gfortran for a data statment using type constructors:
w.f90:53.20:
data(dft_water_nuc(i), i=1,n_nuc) /
&
1
Error: non-constant array in DATA statement (1)
Is the code I attach below legal? If the code is legal then this might
be
a bug in Gfortran.
I can replace "data" with array constructor "[]" or remove
the conflicting entry to make it compile.
BTW what is the difference between "(/ /)" and "[]".
Alexei
=============== w.f90 =================
module w
implicit none
save
private
real, parameter :: zero = 0.0
type, public :: charge
real :: q
real :: C
real :: A
end type charge
type, public :: multpol
character*12 :: name
real :: coor(3) !!! COMMENT THIS TO MAKE IT COMPILE !!!
real :: mass
type(charge) :: z
end type multpol
integer, public, parameter :: n_nuc=3
type(multpol), public :: dft_water_nuc(n_nuc)
real, parameter :: C_i =zero
real, parameter :: A_i =zero
!names of multipole
character*12, parameter :: mname1="O1 "
character*12, parameter :: mname2="H2 "
character*12, parameter :: mname3="H3 "
!coordinates of multipole centers
real, parameter :: mcoor1(3)=(/ zero, zero, -0.119151/)
real, parameter :: mcoor2(3)=(/-1.431042, zero, 0.945510/)
real, parameter :: mcoor3(3)=(/ 1.431042, zero, 0.945510/)
!mass
real, parameter :: mass1=15.99491
real, parameter :: mass2=1.007825
real, parameter :: mass3=1.007825
!charges
real, parameter :: Zn1=8.0
real, parameter :: Zn2=1.0
real, parameter :: Zn3=1.0
integer :: i
!----------------------------------------------------------------
data(dft_water_nuc(i), i=1,n_nuc) /
&
multpol
( &
mname1, &
mcoor1, & !!! COMMENT THIS TO
MAKE IT COMPILE !!!
mass1, &
charge(Zn1,C_i,A_i)
&
),
&
multpol
( &
mname2, &
mcoor2, & !!! COMMENT THIS TO
MAKE IT COMPILE !!!
mass2, &
charge(Zn2,C_i,A_i)
&
),
&
multpol
( &
mname3, &
mcoor3, & !!! COMMENT THIS TO
MAKE IT COMPILE !!!
mass3, &
charge(Zn3,C_i,A_i)
&
)
&
/
end module w
> Is the code I attach below legal? If the code is legal then this might
> be a bug in Gfortran.
[code elided]
Looks ok to me. NAG f95 agrees. G95 gets an internal compiler error.
Andy here?
One slight caveat. The continuations and line breaks are all messed up,
at least as it shows in my newsreader. I'm assuming that this is just an
artifact of the news posting/reading, but it is at least possible that a
bad continuation could generate a misleading error like this. Check that
al the "&" characters are at the end of the line to be continued - not
at the beginning of the next one (yes, I know it is also ok to have one
at the beginning of the next line, but if so that is an additional one;
you still need the one on the end of the prior line). ALso check that
you don't have line breaks between the "multpol" and "(" as I'm seeing.
> BTW what is the difference between "(/ /)" and "[]".
Absolutely nothing in terms of meaning. When array constructors were
introduced in f90, the "[" and "]" characters were not in the Fortran
character set and there was some reluctance to add them. The ugly (in my
opinion) "(/ /)" thing was done as a substitute. The "[]" was not
standardized until f2003, so it is at least possible that an f95
compiler might not support it. But that's pretty trivial as f2003
features go; I suspect most compilers support it by now unless you are
using an old version.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
> Looks ok to me. NAG f95 agrees. G95 gets an internal compiler error.
> Andy here?
Indeed - it also worked for gfortran 4.4.0.
Could you file a bug report, please? Also, it needs to be marked in
the title line as a regression.
Thanks
Paul
It works for me with gfortran 4.5.0.
(To be exact: GNU Fortran (GCC) 4.5.0 20090421 (experimental) [trunk
revision 146519].)
Erik.
> It works for me with gfortran 4.5.0.
> (To be exact: GNU Fortran (GCC) 4.5.0 20090421 (experimental) [trunk
> revision 146519].)
It fails for me with 4.5.0 20091019 - I guess that something,
somewhere is not being initialized.
I'll do the honours with the bug report.
Thanks
Paul
This is now Bug report 41807 in Bugzilla.
Thanks for the report
Paul
Try using:
data dft_water_nuc(1:n_nuc) / etc
| Is the code I attach below legal? If the code is legal then this might
| be
| a bug in Gfortran.
|
| I can replace "data" with array constructor "[]" or remove
| the conflicting entry to make it compile.
|
| BTW what is the difference between "(/ /)" and "[]".
Nothng.