<div dir="ltr"><div>Laura, I am not sure that will work. But if it does, assign the result to a new variable, not a predefined one. Or else use the replacement operator. Try this, see if you get the expected result dimensions:<br><br> pp = pres(:,kpbl(:))</div><div><br></div><div>Also, it is simply <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>.<br><br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 11, 2022 at 7:06 PM Laura Fowler via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-size:small"><font face="arial, sans-serif" size="1">Hello:</font></div><div style="font-size:small"><font face="arial, sans-serif" size="1">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:</font></div><div style="font-size:small"><br></div><div style="font-size:small"><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Variable: kpbl</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Type: integer</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Total Size: 10485768 bytes</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> 2621442 values</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Number of Dimensions: 1</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[nCells | 2621442]</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Coordinates: </font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Number Of Attributes: 2</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> units :<span style="white-space:pre-wrap"> </span>unitless</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> long_name :<span style="white-space:pre-wrap"> </span>index level of PBL top</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Variable: pres</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Type: float</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Total Size: 576717240 bytes</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> 144179310 values</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Number of Dimensions: 2</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[nCells | 2621442] x [nVertLevels | 55]</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Coordinates: </font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">Number Of Attributes: 3</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> _FillValue :<span style="white-space:pre-wrap"> </span>9.96921e+36</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> units :<span style="white-space:pre-wrap"> </span>hPa</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"></font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"> long_name :<span style="white-space:pre-wrap"> </span>Pressure at layer midpoint</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><br></font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif"><font size="1">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:</font><font size="1"><br></font></font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif"><br></font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif" size="1">do n = 0,nCells-1</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif" size="1"> pp(n) = pres(n,kpbl(n))</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif" size="1"> print("--- n = "+n +" "+kpbl(n) +" "+pres(n,kpbl(n)) +" "+pp(n))</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, sans-serif" size="1">end do</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font size="1" face="arial, sans-serif">When I convert the loop above to the following array syntax (see below), I unfortunately get a "Segmentation Fault".</font></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">pp(:) = pres(:,kpbl(:))</font></span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Courier;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p></div><div><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">fatal:VarVarWrite: Number of dimensions on left hand side does not match right hand side</font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1">fatal:["Execute.c":8637]:Execute: Error occurred at or near line 207 in file plot.pressure.ncl</font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><br></font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><br></font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><span class="gmail_default" style="font-size:small"></span><span class="gmail_default">Can somebody help me figure this out. I would really appreciate it.</span></font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><span class="gmail_default">Thanks,</span></font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><span class="gmail_default">Laura</span></font></span></p><p style="font-size:small;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;font-family:Courier;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font size="1"><span class="gmail_default"><br></span></font></span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;margin:0px;color:rgb(0,0,0)"><font face="arial, sans-serif" size="1"><span style="font-variant-ligatures:no-common-ligatures"><span class="gmail_default">note: I posted the same email this morning, but to the address </span></span><a href="mailto:ncl-talk-request@ucar.edu" aria-label="ncl-talk-request@ucar.edu (From your Google Contacts)" style="text-decoration-line:none;color:rgb(60,64,67);overflow:hidden;text-overflow:ellipsis;white-space:nowrap" target="_blank">ncl-talk-request@ucar.edu</a>. Not sure which email to use for posts. Sorry about the double email message.</font></p></div></div><div><br></div><div dir="ltr"><div dir="ltr"><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">!-------------------------------------------------------------------------------------------------------------</font><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">Laura D. Fowler </font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">Mesoscale and Microscale Meteorology Division (MMM) </font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">National Center for Atmospheric Research<br></font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">P.O. Box 3000, Boulder CO 80307-3000</font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)"><br></font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">e-mail: <a href="mailto:laura@ucar.edu" target="_blank">laura@ucar.edu</a></font></div><div><font face="arial, helvetica, sans-serif" color="#0000ff" style="background-color:rgb(255,255,255)">phone: 303-497-1628</font></div></div></div></div>
</blockquote></div></div>