PROGRAM FROG
CHARACTER*18, TARGET :: BUFFER
CHARACTER*3, POINTER :: ONE, TWO
ONE => BUFFER(7:9)
TWO => BUFFER(16:18)
BUFFER = 'Green Eggs and Ham'
PRINT *, ONE
PRINT *, TWO
END
I'm getting 'Gre' and 'Gre'. Is there a way to get 'Egg' and 'Ham'?
FWIW, I _think_ that the above should yield 'Egg' and 'Ham'. Here's
what happens with IBM's compiler under AIX:
poseidon1.hook 85 % cat samIam.f
PROGRAM FROG
CHARACTER*18, TARGET :: BUFFER
CHARACTER*3, POINTER :: ONE, TWO
ONE => BUFFER(7:9)
TWO => BUFFER(16:18)
BUFFER = 'Green Eggs and Ham'
PRINT *, ONE
PRINT *, TWO
END
poseidon1.hook 86 % xlf90 -o samIam samIam.f
** frog === End of Compilation 1 ===
1501-510 Compilation successful for file samIam.f.
poseidon1.hook 87 % ./samIam
Egg
Ham
poseidon1.hook 88 %
--
Ed Hook | Copula eam, se non posit
Computer Sciences Corporation | acceptera jocularum.
NASA Langley Research Center | Me? Speak for my employer?...<*snort*>
Internet: ho...@cscsun3.larc.nasa.gov | ... Get a _clue_ !!! ...
A POINTER’s target must have the same type, kind, and shape as the POINTER.
I don't believe you have met this criterion.
Michael Sanborn <mic...@graphion.com> wrote in article
<33B015FD...@graphion.com>...
> I'm trying to convert a very old Fortran program to Digital Visual
> Fortran. It had used EQUIVALENCE statements to create aliases ...
Why not. The type is CHARACTER, the kind is default, the rank (not shape) is
zero. So the code is valid. Looks like a compiler bug that you should report
to Digital.
Mike Metcalf
In article <33B015FD...@graphion.com>, Michael Sanborn
<mic...@graphion.com> writes:
|>I'm trying to convert a very old Fortran program to Digital Visual
|>Fortran. It had used EQUIVALENCE statements to create aliases within
|>Integer arrays that contained character data. I'd like to declare the
|>character data as Character type, and I had thought that I might be able
|>to use pointers to substrings to replace the EQUIVALENCE statments. But
|>I'm not having any luck yet. As a scaled down version of what I'm trying
|>to do:
|>
|> PROGRAM FROG
|> CHARACTER*18, TARGET :: BUFFER
|> CHARACTER*3, POINTER :: ONE, TWO
|> ONE => BUFFER(7:9)
|> TWO => BUFFER(16:18)
|> BUFFER = 'Green Eggs and Ham'
|> PRINT *, ONE
|> PRINT *, TWO
|> END
|>
|>I'm getting 'Gre' and 'Gre'. Is there a way to get 'Egg' and 'Ham'?
This does indeed look like a bug in DVF. We'll take a look at it. The
following alternative does work, but it uses an extension.
PROGRAM FROG
CHARACTER*18, TARGET :: BUFFER
CHARACTER*3 :: ONE, TWO
POINTER (P_ONE, ONE)
POINTER (P_TWO, TWO)
P_ONE = %LOC(BUFFER(7:9))
P_TWO = %LOC(BUFFER(16:18))
BUFFER = 'Green Eggs and Ham'
PRINT *, ONE
PRINT *, TWO
END
--
Please send DIGITAL Visual Fortran support requests to dvf-s...@digital.com
Steve Lionel mailto:lio...@mail.dec.com
Fortran Development http://www.digital.com/info/slionel.html
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For information on DIGITAL Fortran, see http://www.digital.com/fortran
This was my first reaction too but the F90 Handbook states
"The type, type parameters, (kind and length, if character), and
rank of the target must be the same as the pointer object"
(Your F book says the same! :-) In this example the lengths differ.
Neil
---------------------------------------------------------------------------
Neil N. Carlson car...@math.purdue.edu
Department of Mathematics 765-494-1920 (Fax: 4-0548)
Purdue University
---------------------------------------------------------------------------
Arghhh! I spoke too quickly; you're absolutely correct.
Neil
The lengths doesn't differ, since the SUBSTRINGS of the variables have a
length of 3 (Check it with LEN). The pointer assignments are done to
substrings of the original variables.
Regards,
Jean Vezina