[ncl-talk] how to fill an array with an other

Laura Fowler laura at ucar.edu
Tue May 5 09:37:08 MDT 2020


Hello:
I cannot figure out how to do the following and would love to get some help:

I have an array kpbl which contains the vertical index of the PBL top:
printVarSummary gives:

Variable: kpbl

Type: integer

Total Size: 15728832 bytes

            3932208 values

Number of Dimensions: 2

Dimensions and sizes: [Time | 13] x [cells | 163842]

Coordinates:

Number Of Attributes: 2

  units : unitless

  long_name : index level of PBL top



I have a second array p which contains the 3D pressure: print VarSummary
gives:


Variable: p

Type: float

Total Size: 865085760 bytes

            216271440 values

Number of Dimensions: 3

Dimensions and sizes: [Time | 13] x [cells | 163842] x [nVertLevels | 55]

Coordinates:

Number Of Attributes: 2

  units : hPa

  long_name : Pressure



What I would like to get is the pressure at the index level kpbl, i.e.
pressure at the PBL top. In fortran and for one time-level (itime), I would
have a loop like:

do icell = 0, cells-1
     ppbl(itime,icell) = p(itime,icell,kpbl(iCell))
end do

In NCL, I tried the following (for one time-level):
ppbl = new((/cells/),typeof(p))
ppbl(0:cells-1) = p(0:cells-1,kpbl(0:cells-1))

but this does not work. I get an error message that the left and right side
do not have the same dimensions. I am definitely running out of ideas on
how to solve this and would appreciate a hint.

Many thanks,
Laura

-- 
!-------------------------------------------------------------------------------------------------------------
Laura D. Fowler

Mesoscale and Microscale Meteorology Division (MMM)
National Center for Atmospheric Research
P.O. Box 3000, Boulder CO 80307-3000

e-mail: laura at ucar.edu
phone: 303-497-1628

!-------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200505/9b471120/attachment.html>


More information about the ncl-talk mailing list