Replacing this line by :
myPoint%x = 2.3 ; myPoint%y = 4.2
everything works.
Does someone here see a problem with the code ?
Marc
module pointModule
implicit none
type, abstract :: pointGen
contains
procedure ( compDistToOProto ) , deferred :: compDistToO
end type pointGen
type, extends( pointGen) :: point2d
real :: x
real :: y
contains
procedure :: compDistToO => compDist2dToO
end type point2d
abstract interface
function compDistToOProto( self ) result(distance)
import :: pointGen
class(pointGen) :: self
real :: distance
end function compDistToOProto
end interface
contains
function compDist2dToO( self ) result(distance)
class(point2d) :: self
real :: distance
distance = sqrt( self%x*self%x + self%y*self%y )
end function compDist2dToO
end module pointModule
program letest
use pointModule
implicit none
real :: distance
type(point2d) :: myPoint
myPoint = point2d(2.3, 4.2) ! The problem is here
! myPoint%x = 2.3 ; myPoint%y = 4.2 ! ok with that
distance = myPoint%compDistToO()
print *, "Distance = ", distance
end program letest
Not off-hand, though I admit to not having studied it very carefully.
That strikes me as a strange error message for the context anyway. It
might almost make me suspicious of something like nonprinting characters
making their way into the source code. I don't have gfortran installed
here to handily test with. I do have g95, but it doesn't (yet?) support
the features used in the code.
Nag compiles and runs the posted code without complaint (assuming I use
the f2003 switch to turn off the warnings about f2003 features being
extensions to f95.)
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
What happen if you replace the line with
myPoint = point2d(x=2.3, y=4.2)
?
Bob Corbett
> On Sep 7, 1:54 pm, AT <"gtitus(AT)wanadoo.fr"> wrote:
> > Using gfortran I have an error:
> > myPoint = point2d(2.3, 4.2)
> > 1
> > Error: Invalid character in name at (1)
...
> What happen if you replace the line with
>
> myPoint = point2d(x=2.3, y=4.2)
Hmm. Good point (so to speak). If the compiler were expecting a keyword
form, it might think that the 2 in 2.3 was an invalid initial character
for a keyword. It would still be a compiler bug, but I begin to see how
a plausible compiler bug might generate an error message like that.
P.S. I just noticed your new email domain, Bob. I suppose it figures,
but I hadn't noticed before.
It will work; I have now filled a bug report* against gfortran.
Tobias
> What happen if you replace the line with
>
> myPoint = point2d(x=2.3, y=4.2)
>
> ?
>
> Bob Corbett
If I do so, it is fine for gfortran, and I still have the ICE using
intel fortran. As Richard Maine points out it looks like a compiler bug
( in both cases ), I will learn how to do a gfortran bug report - I am
not very familiar with that ...
Anyway your idea gives me now a workaround. Thanks.
Marc
Le 08/09/10 07:27, Tobias Burnus a écrit :