Re: porting union, map to gfortran
- From: none <none@xxxxxxxx>
- Date: Tue, 30 Dec 2008 20:18:01 +0000
On Tue, 30 Dec 2008 10:02:34 -0800, dpb wrote:
On Dec 29, 8:11 pm, dpb <bozart...@xxxxxxxxx> wrote:
On Dec 29, 7:04 pm, raju <raju.mailingli...@xxxxxxxxx> wrote:> Consider the following code
...code snippet using extension UNION/MAP elided...
...> However, I do not know how to convert the union, map funtions to
fortran 90. Looking at the google archives, I believe this is an
extension provided by some commercial compilers.
Can someone help me in converting the union, map functions to standard-
compliant fortran 90/95?
...
Unfortunately, no. UNION/MAP _is_ an extension and is not
incorporated into F95 Standard. Only choice is to use a compiler
which supports the extension afaik.
The closest in syntax I can think of (although not sure I'd recommend
using it) would be something like
type name1
sequence
character*9 a1
byte a2
!!! some other variables declared here
end type
type name2
sequence
character*10 a3
!!! some other variables declared here
end type
type(name1) :: a
type(name2) :: b
equivalence(a,b)
Then could reference as
a%a1
b%a3
Don't see any way to be able to alias the names of the structures,
however, so much of the advantage is lost probably over the more
prosaic suggestions of Arjen or Thomas.
(It was this limitation that prompted the denial earlier, not that one
couldn't get storage association but there isn't afaict a way to avoid
two type names for the reference)
Which is a great shame, as I have code of the form
union
map
components(1:MAX_COMPONENTS)
end map
map
N2
O2
CO2
...
end map
end union
which makes it easier to write code that switches between generic
processing of the structure and retrieving named elements. I have, in
other languages, done
parameter (cN2 = 1, cO2 = 2, cCO2 = 3, ...)
but this is not as elegant, and more error prone when a new component is
inserted somewhere in the MIDDLE, rather than at the end.
Since Pascal and C support it I hope that one day it will become
standardised Fortran.
.
- Follow-Ups:
- Re: porting union, map to gfortran
- From: dpb
- Re: porting union, map to gfortran
- References:
- porting union, map to gfortran
- From: raju
- Re: porting union, map to gfortran
- From: dpb
- Re: porting union, map to gfortran
- From: dpb
- porting union, map to gfortran
- Prev by Date: Re: Is Co-Array the Future of Parallel Computing?
- Next by Date: Re: Is Co-Array the Future of Parallel Computing?
- Previous by thread: Re: porting union, map to gfortran
- Next by thread: Re: porting union, map to gfortran
- Index(es):
Relevant Pages
|