[ncl-talk] Memory Error - Plotting Vertical Cross Sections

Nicholas Thomas Luchetti Nicholas.Luchetti at colorado.edu
Tue Aug 28 08:31:46 MDT 2018


Hi all,

I'm trying to plot vertical cross sections (time on x-axis, variable on
y-axis) from WRF data and I am getting some errors:

fatal:NclMalloc Failed:[errno=12]

fatal:Plus: Could not allocate memory for result type, can't continue

After scanning the NCL-talk archives it appears the only suggestion is to
use the delete function and delete variable arrays after they are used so
that the code can continue. I've attempted to delete all variables after
they are no longer needed, but this doesn't seem to work. I'm running this
on a super computer, so I'm certain that the computers probably have decent
memory allocation...

I just wanted to see if anyone would be willing to look at my code (see
attached) and see if there are any other suggestions that may make this
run?

I changed the WRF output of my simulations to every 2 minutes in my
inner-most domain. I used to have this set to every 5 minutes. When it was
set at 5 minutes, my vertical-cross section code ran fine. Do you think I
just don't have enough memory to handle plotting output every two minutes
in the way in which I have this coded?

Any help is greatly appreciated.

Thanks!

Nick Luchetti
-- 
Nicholas Luchetti
Graduate Student
Department of Atmospheric and Oceanic Sciences (ATOC)
CU Boulder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180828/0a3b89db/attachment.html>
-------------- next part --------------

;----------------------------------------------------------------------
; WRF_cn_4.ncl
;
; Concepts illustrated:
;   - Plotting WRF data
;   - Plotting a cross section
;----------------------------------------------------------------------
; WRF: time-z cross section.
;----------------------------------------------------------------------
; These files are loaded by default in NCL V6.2.0 and newer
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"   
 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"

begin
;---Open file; substitute your own WRF output file here
;f = addfile("/scratch/summit/nilu4970/WRFTEST/WRFV3_061315_wet_1000/test/em_real_061315_wet/wrfout_d03_2015-06-13_12:00:00.nc","r")
;  f = addfile("/scratch/summit/nilu4970/WRFTEST/WRFV3/test/em_real/wrfout_d03_2015-06-13_12:00:00.nc","r")
;

f = addfile("/gpfs/summit/scratch/nilu4970/WRFTEST_4/WRF_060715_reg_terr/test/em_real_060715_reg_terr/wrfout_d03_2015-06-07_12:00:00.nc","r")

   setvalues NhlGetWorkspaceObjectId()
     "wsMaximumSize" : 300000000
   end setvalues


; Read character variable Times 
; Convert to units of "hours since" for plotting purposes
;
  times = f->Times
  Time   = wrf_times_c(f->Times(330:420,:), 0)  ; convert to "hours since"
  print(Time)

  
   llres = True
   llres at returnInt = True
   locij = wrf_user_ll_to_ij(f, -105.003836,40.050028, llres)
   locij = locij -1
   locX = locij(0)
   locY = locij(1)
 
   
  PH = wrf_user_getvar(f,"PH",-1)
  PHB = wrf_user_getvar(f,"PHB",-1)
  HGT = wrf_user_getvar(f,"HGT",-1)  
  

  H = ((PH + PHB) /9.81) 
  
  

  printVarSummary(H)
 ; print(H)
 ; H_con = H(0,:10,locX,locY)
 
  ;For BAO 300m tower plots
  H_con = H(0,:5,locX,locY)
  HGT_con = HGT(0,locX,locY)

HGAL = (H_con - HGT_con)/1000
  
delete ([/PH,H,H_con,HGT_con/])

 printVarSummary(HGAL)
 print(HGAL)
;  print(H_con)
    
  ;nlat = 85
  ;nlon = 120
  tk       = wrf_user_getvar(f,"tk",-1)        
  tc = tk-273.16  
  printVarSummary(tc)
  delete(tk)  
   ;For BAO tower plots

   tc2 = tc(330:420,:5,locX,locY)


   ;tc2 = tc(72:,:10,locX,locY)




;---Use simple array syntax [like f90] to change units
  tc2         = tc2                    ; for demo change units
  tc2 at units   = "Temperature (C)"                                             

printVarSummary(tc2)
printMinMax(tc2,0)

;---Add/change meta data to conform to netCDF convention standards
  tc2!0       = "Time"
  tc2&Time    =  Time
  tc2!1       = "lev"                     ; name dimensions
  tc2&lev     =  HGAL                      ; assign values to named dimensions

printVarSummary(tc2)
print(tc2)
print(tc2&lev)

;---For plot purposes only, read the specific lat/lon point
  lat       = f->XLAT(0,locX,locY)
  lon       = f->XLONG(0,locX,locY)
;
; create plots  
; (1) A "BlWhRe" is often selected when plus/minus are of interest
; (2) The "symMinMaxPlt" procedure determines contour limits 
;     that are symmetric.
; (3) Use the "sprintf" function to format the title
; (4) Because the rightmost dimension will become the "x" axis
;     use NCL's "dimension reordering" to reshape
;
  wks = gsn_open_wks("pdf","plt_tc__300m_vertical.pdf")

  res                       = True            ; plot mods desired
  res at cnLevelSelectionMode = "ManualLevels"
  res at cnMinLevelValF   = 15 
  res at cnMaxLevelValF   = 36 
  res at cnLevelSpacingF = 1 
 
  restick = True
  restick at ttmFormat = "%N/%D~C~%H:%M"
  restick at ttmAxis = "XB"
  time_axis_labels(Time, res, restick)

  ;for full atmosphere:
  cmap = read_colormap_file("MPL_RdYlBu")
  
; res at gsnMaximize           = True            ; maximize plot size
  res at cnFillOn              = True            ; turn on color

 ;for full atmosphere: 
 ;res at cnFillPalette         = cmap(::-1,:)        ; set the color map
  
;for BAO tower:
 res at cnFillPalette = "MPL_YlOrRd" 

  res at cnLinesOn             = False           ; turn off contour lines
  res at lbOrientation         = "vertical"      ; vertical label bar
  res at trYReverse            = False            ; reverse y axis
  res at tiXAxisString         = "Time(UTC)"      ; label bottom axis with units attribute
  res at tiYAxisString         = "Height AGL (km)"
  res at gsnYAxisIrregular2Log = False 
  res at gsnYAxisIrregular2Linear = True   
 

  res at tiMainString          = "BAO Tower (40.05 N -105.00 W)" 
   plot                      = gsn_csm_contour(wks,tc2(lev|:,Time|:),res)

end



More information about the ncl-talk mailing list