I have a code with a bunch of physics variables.
In some cases, I want to refer to these variables by name.
In some other routines, I just want to apply the same treatment
to all of them, so only the number of these variables
is relevant. Of course, this number differs along with the
physics I use, it can be anywhere between 5 and 50, maybe more.
At first I had an array defined like this :
Phys_vars(1:nx, 1:ny, 1:nz, 1:nb_vars)
With a series of parameters (in the range 1:nb_vars)
ro_var, ux_var, uy_var, etc
so that I would refer to velocities in the x direction by
Phys_vars(:,:,:,ro_var)
I find this clumsy, and inconvenient at times.
I am trying to put my physics variables inside a derived type,
which could look like :
type :: Phys_vars
real, dimension(4) :: r
real :: ro
real :: ux
real :: uy
real :: uz
equivalence (ro, r(1))
equivalence (ux, r(2))
equivalence (uy, r(3))
equivalence (uz, r(4))
end type Phys_vars
This looks perfect, but it is not allowed by the standard.
Anybody has an idea how I can combine the convenience of a derived
type, with the convenience of an array?
Bertrand Meltz
Commissariat a lŽEnergie Atomique | e-mail : [log in to unmask]
CEA / DIF , BP 12 | Tel : (33) [0] 1 69 26 57 83
91680 Bruyeres-le-Chatel , FRANCE | Fax : (33) [0] 1 69 26 70 93
|