[ncl-talk] conversion from loop to array syntax
Laura Fowler
laura at ucar.edu
Fri Nov 11 17:05:49 MST 2022
Hello:
I have an integer array that includes the index of the PBL top (kpbl). I
would like to get the pressure (press) corresponding to the index of the
PBL top. A printVarSummary provides the following information:
Variable: kpbl
Type: integer
Total Size: 10485768 bytes
2621442 values
Number of Dimensions: 1
Dimensions and sizes: [nCells | 2621442]
Coordinates:
Number Of Attributes: 2
units : unitless
long_name : index level of PBL top
Variable: pres
Type: float
Total Size: 576717240 bytes
144179310 values
Number of Dimensions: 2
Dimensions and sizes: [nCells | 2621442] x [nVertLevels | 55]
Coordinates:
Number Of Attributes: 3
_FillValue : 9.96921e+36
units : hPa
long_name : Pressure at layer midpoint
where nCells is the number of grid columns and nVertLevels is the number of
vertical levels. Below is the loop that I would like to convert to a more
compact array syntax:
do n = 0,nCells-1
pp(n) = pres(n,kpbl(n))
print("--- n = "+n +" "+kpbl(n) +" "+pres(n,kpbl(n)) +" "+pp(n))
end do
When I convert the loop above to the following array syntax (see below), I
unfortunately get a "Segmentation Fault".
pp(:) = pres(:,kpbl(:))
fatal:VarVarWrite: Number of dimensions on left hand side does not match
right hand side
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 207 in
file plot.pressure.ncl
Can somebody help me figure this out. I would really appreciate it.
Thanks,
Laura
note: I posted the same email this morning, but to the address
ncl-talk-request at ucar.edu. Not sure which email to use for posts. Sorry
about the double email message.
--
!-------------------------------------------------------------------------------------------------------------
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: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221111/407c43bc/attachment.htm>
More information about the ncl-talk
mailing list