<div dir="ltr"><div>I copied your script and ran it with a few print statements added:<br></div><div><br></div><div>/glade/work/shea/test.mem_leak.ncl</div><div><br></div><div>%> ncl test.mem_leak.ncl</div><div><br></div><div>==================</div><div>/glade/work/shea>ncl test.mem_leak.ncl<br> Copyright (C) 1995-2019 - All Rights Reserved<br> University Corporation for Atmospheric Research<br> NCAR Command Language Version 6.6.2<br> The use of this software is governed by a License Agreement.<br> See <a href="http://www.ncl.ucar.edu/">http://www.ncl.ucar.edu/</a> for more details.<br>(0)    /glade/scratch/srahimi/interp/meta2/wrfinput_d01<br><br>Variable: var_wrf<br>Type: float<br>Total Size: 16550560 bytes<br>            4137640 values<br>Number of Dimensions: 3<br>Dimensions and sizes:        [365] x [104] x [109]<br>Coordinates: <br>Number Of Attributes: 1<br>  _FillValue :  9.96921e+36<br>(0)        ------------------<br>(0) /glade/scratch/srahimi/ucla/downscale/test/WRF-4.1.3/test/MPI_r8_1980/d01/<br>(0) iyear=1980: iday=0<br>(0) iyear=1980: iday=1<br>(0) iyear=1980: iday=2</div><div>[SNIP]</div><div>0)        iyear=1980: iday=362<br>(0)       iyear=1980: iday=363<br>(0)       iyear=1980: iday=364<br>(0)       ====================<br>(0)       ===EXIT IDAY LOOP===<br>(0)       ====================<br><br>Variable: var_wrf<br>Type: float<br>Total Size: 16550560 bytes<br>            4137640 values<br>Number of Dimensions: 3<br>Dimensions and sizes:    [day | 365] x [lat2d | 104] x [lon2d | 109]<br>Coordinates: <br>            day: [19800901..19810831]<br>Number Of Attributes: 2<br>  units :    mm/d<br>  _FillValue :   9.96921e+36<br>(0)         <br>(0)  min=0   max=4.89127<br>(0)       ====================</div><div><br></div><div>/bin/rm: cannot remove 'files/<a href="http://etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc">etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc</a>': No such file or directory<br>fatal:Could not create (files/<a href="http://etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc">etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc</a>)<br>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 113 in file test.mem_leak.ncl</div><div><br></div><div>+++++++++++++++++++++++++++++</div><div>The 'iday'  loop has <br></div><div><br></div><div> 63  do iday = 0, ndays - 1<br> 64 <br> 65   files = filei(4*(day_count-1):4*day_count-1)<br> 66 ;;print (files) ;each is a string</div><div><br></div><div>The following is after the loop. 'files' is a 1D array of strings. If so,  the following looks incorrect.<br></div><div><br></div><div>/bin/rm: cannot remove 'files/<a href="http://etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc">etrans_sfc.daily.mpi-esm1-2-lr_ssp370_r8i1p1f1_d01_1980.nc</a>': No such file or directory</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 8, 2020 at 9:24 AM STEFAN RAHIMI-ESFARJANI 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:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">Greetings,</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">I spent a lot of time developing post-processing software for my research, which are written in NCL. The code here creates single-year files of daily evapotranspiration values on a lat/lon grid f(time,lat,lon). I am experiencing a memory leak that is affecting my ability to run these jobs using Cheyenne compute nodes.</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">In short, I have traced the memory leak to the following line (70) in /glade/scratch/srahimi/interp/</span><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">mpi_r8/test.ncl on Cheyenne or see below:</span><div><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">ff = addfiles(dir_x+files,"r")</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">The files are wrfout .nc files. Variable "ff" should be deleted 2 lines later, and that space should be re-used throughout each iteration of the loop. What seems to be happening however is that new memory is being allocated for ff in each iteration of the loop, eventually overpowering the core and the node.</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">I know ways around this in python, but I really do not want to rewrite these scripts at present. Any suggestions?</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">Thanks,</span><br style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px">-Stefan Rahimi, UCLA</span><br></div><div><span style="color:rgb(23,43,77);font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen,Ubuntu,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:14px"><br></span></div><div><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;Created by S. Rahimi on 15 Jan. 2020</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;to interpolate WRF fields toa common</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;0.03 rectilinear grid</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;Daily averages from 6-h data</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;For a 2-D variable</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;f = f(year,day,ny,nx)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">begin</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">var = "etrans_sfc"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">model  = "mpi-esm1-2-lr"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">variant  = "r8i1p1f1"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">ssp  = "ssp370"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">freq = "daily"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">domain  = "d01"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">startyear  = 1980</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">endyear  = 1989</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">year0 = 1980</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">dir  = "/glade/scratch/srahimi/ucla/downscale/test/WRF-4.1.3/test/"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">dir_inp  = "/glade/scratch/srahimi/interp/meta2/"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">file_wrfinput  = "/glade/scratch/srahimi/interp/meta2/wrfinput_d01"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">s2d = 86400.</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">ndays = 365</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">nyears = endyear - startyear + 1</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">nx  = 109</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">ny  = 104</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">;lat/lon from wrfinput</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">print (file_wrfinput+"")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">f = addfile(file_wrfinput,"r")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">lat_wrf = f->XLAT(0,:,:)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">lon_wrf = f->XLONG(0,:,:)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">delete(f)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">years = ispan(startyear,endyear,1)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">days = new((/ndays/),"integer")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">var_wrf = new((/ndays,ny,nx/),"float")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">do iyear = startyear, endyear</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">if (iyear .eq. 2014 ) then</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">        continue</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">end if</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> dir_x =  dir + "MPI_r8_" + iyear + "/" + domain + "/"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> print (dir_x+"")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> file_str = "wrfout*"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> filei = systemfunc("cd " + dir_x + " ; ls " + file_str)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> day_count = 1</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> do iday = 0, ndays - 1</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  files = filei(4*(day_count-1):4*day_count-1)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  print (files) ;each is a string</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  date_str = stringtochar(files(0))</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  date = tostring(date_str(11:14)) + tostring(date_str(16:17)) + tostring(date_str(19:20))</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  days(iday) = stringtointeger(date)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  ff = addfiles(dir_x+files,"r")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  var_wrf(iday,:,:) =  dim_avg_n_Wrap(ff[0:dimsizes(files)-1]->ETRAN,0) * s2d</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  delete(ff)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  var_wrf(iday,:,:) = where(abs(var_wrf(iday,:,:)).gt.1e20,0., var_wrf(iday,:,:))</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  day_count = day_count + 1</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  delete(files)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> end do         ;end day loop</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> var_wrf!0 = "day"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> var_wrf!1 = "lat2d"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> var_wrf!2 = "lon2d"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> var_wrf&day = days</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> var_wrf@units = "mm/d"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> ;Write to .nc files</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> dirout = "files/"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> fil_out = var + "." + freq + "." + \</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  model + "_" + ssp + "_" + variant + "_" + \</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">  domain + "_" + iyear + ".nc"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> outfile = dirout+fil_out</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> system("/bin/rm " +outfile)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> ncdf = addfile(outfile ,"c")  ; open output netCDF file</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> ;setfileoption(outfile,"DefineMode",True)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> fAtt               = True            ; assign file attributes</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> fAtt@title         = var+ " for  "+iyear</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> fAtt@Conventions   = "None"</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> fAtt@creation_date = systemfunc("date")</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> ;fileattdef(ncdf,f[0])            ; copy file attributes</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> filedimdef(ncdf,"region",-1,True)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> ncdf->$var$ = var_wrf</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures"> delete(ncdf)</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">end do          ;end year loop</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9);min-height:6px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:5px;line-height:normal;font-family:"Andale Mono";margin:0px;color:rgb(47,255,18);background-color:rgba(0,0,0,0.9)"><span style="font-variant-ligatures:no-common-ligatures">end</span></p><br></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>