Re: porting union, map to gfortran



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.
.



Relevant Pages

  • Re: sort by extension
    ... Not a "fan" of map() and grep() or just don't understand them? ... looks for an extension and returns a two element array ... modified list of originals and extensions side-by-side is then handed ...
    (perl.beginners)
  • Re: Putney Green
    ... > The Bakerloo line station at Warwick Avenue used to (I think it's been ... > extension in south London. ... Liverpool Street already open as far as Mile End. ... or page 32 of "Mr Beck's Underground Map". ...
    (uk.transport.london)
  • Re: teminology
    ... to extend "naturally" to a set B which contains as a proper subset ... It means the "obvious" extension. ... way that a map defined on A has an extension which is, ... B can be an inner product space, A a dense linear subspace, and ...
    (sci.math)
  • Re: Uploaded document security in ASP.net
    ... I'd say you'd probably want to restrict the types of files to be uploaded, ... you could map all extensions to ASP.NET ... be viewed by the users unless i regsiter their extension with IIS. ... my asp.net page lets the users uploads documents up to a folder on the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: TYPE declarations with MAP and UNION
    ... >real killer is the UNION and MAP statements within a TYPE declaration ... My compiler supports TYPE declarations in modules just ... >fine but not UNION and MAP within the TYPE. ...
    (comp.lang.fortran)