Re: Assigning values to a derived type (structure constructor?)
- From: Janne Blomqvist <foo@xxxxxxxxxxx>
- Date: Fri, 27 Oct 2006 10:32:44 +0300 (EEST)
In article <1hnu0dk.1w7jpew1mdmb2yN%nospam@xxxxxxxxxxxxx>, Richard Maine wrote:
<andrew.mallner@xxxxxxxxxxx> wrote:
I have a derived type that has a number of properties:
TYPE Particle
REAL** :: X,Y,Z,U,V,W,E, ...
END TYPE
TYPE(Particle) :: Partcles(0:100)
After an interaction I want to adjust the U, V, W, and E values:
Particles(i)%U = NewU
Particles(i)%V = NewV
Particles(i)%W = NewW
Particles(i)%E = NewE
Yes. That's one way.
I know I can assign all the values at once like:
Particles(i) = Particle(InitX, InitY, InitZ, InitU, InitV, InitW,
InitE, ...)
And that's another, provided you want to assign to all the components.
Other languages have something like this (VB Example)
With Particles(I)
.E = NewE
.U = NewU
....
End With
Does Fortran have something similar?
F2003 (which has no compilers yet) has the associate construct, which is
similar. In f90/f95, the closest you can come is to have a pointer with
particles(i) as its target. That is
type(particle), pointer :: p
...
p => particles(i)
p.e = NewE
p.u = NewU
...
Oops? s/./%/ :-)
--
Janne Blomqvist
.
- Follow-Ups:
- Re: Assigning values to a derived type (structure constructor?)
- From: Richard Maine
- Re: Assigning values to a derived type (structure constructor?)
- References:
- Assigning values to a derived type (structure constructor?)
- From: andrew . mallner
- Re: Assigning values to a derived type (structure constructor?)
- From: Richard Maine
- Assigning values to a derived type (structure constructor?)
- Prev by Date: Re: Assigning values to a derived type (structure constructor?)
- Next by Date: How to deal with such ODE with fortran?
- Previous by thread: Re: Assigning values to a derived type (structure constructor?)
- Next by thread: Re: Assigning values to a derived type (structure constructor?)
- Index(es):
Relevant Pages
|