# vertical modes

```Hello,

Sometime back, I had trouble with the output of a model in which the
variables were decomposed into vertical modes.  Steve Hankin solved the
problem and the solution is given below.  But given that some time has
elapsed since the question was posed (and answered; sorry, Steve), here is
the Q first.

*************************************
The FERRET manual says that ferret cannot handle more than 4 dimensional data
sets.  I'd like to use ferret to look at the output of a model in which the
variables are decomposed into vertical modes.  The net value of any model
variable at a given depth then is the result of a summation of var_n (where n
is the vertical mode number) over the N vertical modes.  Since var_n is
therefore a function of x,y,t, and n, and the mode shape psi_n is a function
of mode number n and depth z, there are 5 independent "axes" for ferret to
handle.

I'd like to keep var_n in the netCDF file, using ferret to compute the sums.
This way I can sum over any combination of modes and also compute those
model variables that can be derived from the primary dependent variables.
In this case, u_n, v_n, and p_n are the variables that are solved for, it
being possible to derive w and rho (density) from these 3.

I tried defining u,v, and p as functions of (n,x,y,t) and psi as a function
of (n,z), but this did not work.

So what I have now are u,v, and p as functions of (x,y,z, and t), after
summing over the N modes.  So, when I want to compare the contributions
of different modes, I have to create a new dataset.
This is not a problem, except that the files are huge.  Also, to view the w
and rho fields, I have do the computation outside of ferret, generating
another dataset.  Seems a pity, given the powerful analysis tools ferret
provides.

Is there some way that ferret can be tricked into accepting the 5 "axes"?
*************************************

The solution was to define var_n as functions of (x,y,n,t), switching x and n
from the earlier netCDF file.

yes? sh data
currently SET data sets:
1> /user6/datasets/data/eicc2.nc  (default)
name     title                             I         J         K         L
PN       PN                               1:162     1:110     1:10      1:12
UN       UN                               1:162     1:110     1:10      1:12
VN       VN                               1:162     1:110     1:10      1:12
PSIN     PSIN                             1:10      1:1       1:49      1:1

There are 10 vertical modes and PSIN is defined at 49 depths in the file.
To compute a variable, say u, just sum over the required modes.
This may be done with a GO script.

! begin eicc2.jnl
let u1  = un[k=1]*psin[i=1]
let u2  = un[k=2]*psin[i=2]

```