NCL Home > Documentation > Functions > CESM


Calculates the pressure layer thicknesses of a hybrid coordinate system.


	function dpres_hybrid_ccm (
		ps       : numeric,  
		p0   [1] : numeric,  
		hyai [*] : numeric,  
		hybi [*] : numeric   

	return_val  :  numeric



An array of at least 2 dimensions containing surface pressure data in Pa or hPa (mb). The two rightmost dimensions must be latitude and longitude.


A scalar value equal to the surface reference pressure. Must have the same units as ps.


A one-dimensional array equal to the hybrid A interface coefficients.

Return value

If ps is two-dimensional [e.g. (lat,lon)] or three-dimensional [e.g. (time,lat,lon)] then the return array will have an additional level dimension: (lev,lat,lon) or (time,lev,lat,lon), respectively. The size of the lev dimension is one less then the size of hyai. The returned type will be double if ps is double, float otherwise.


Calculates the pressure layer thicknesses of a hybrid coordinate system. This equates to the absolute value of the pressure difference between adjacent hybrid levels at each grid point. Replaces a deprecated function called dpres_hybrid.

See Also

dpres_plevel, dpres_plevel_Wrap, pres_hybrid_ccm, dpres_hybrid_ccm_se, pres_hybrid_ccm_se


Example 1

hyai and hybi are one-dimensional arrays of length klvl, ps is a three-dimensional array of size (ntim,nlat,nlon) in units of pascals. The returned array is four-dimensional with dimension sizes (ntim,klvl-1,nlat,mlon).

  hyai = f->hyai ; read from a file the interface hybrid coefficients
  hybi = f->hybi ; read from a file
  ps   = f->PS   ; surface pressure [Pa]
  p0   = 100000. ; since ps is in Pa 

  dph = dpres_hybrid_ccm(ps,p0,hyai,hybi)   
Example 2

The same as example 1, but calculated in a loop. At each iteration the returned variable, dph, will be size (klvl-1,nlat,mlon)

  do nt=0,ntim-1
     dph = dpres_hybrid_ccm(ps(nt,:,:),p0,hyai,hybi)  
  end do
Example 3

Perform vertical integration of T to determine the internal energy. Note that dimension reordering is used to make "lev" the rightmost dimension.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

  f = addfile("....", "r")
  hyai = f->hyai
  hybi = f->hybi
  p0   = f->P0
  ps   = f->PS

  dp   = dpres_hybrid_ccm (ps,p0,hyai,hybi)  ; Pa [kg/(m s2)]   

  T    = f->T                                ; K  (time,lev,lat,lon)
  cp   = 1004.                               ; J/(K kg)     [ m2/(K s2) ]
  g    = 9.81                                ; m/s

  Tdp  = T*dp                                ; [K kg/(m s2)]   (temporary variable)
  copy_VarCoords(T, Tdp)
                   ; vertical sum [ie integrate]
                   ; must make "lev" rightmost dimension
;;IE   = dim_sum_Wrap( Tdp(time|:,lat|:,lon|:,lev|:) ; pre 5.1.1 
  IE   = dim_sum_n_Wrap( Tdp, 1)  
                   ; Internal Energy (time,lat,lon)
  IE   = cp*IE/g                             ; kg/s2  
  IE@long_name = "Vertically Integrated Internal Energy"
  IE@units     = "kg/s2"

;;IE_tavg = dim_avg_Wrap( IE(lat|:,lon|:,time|:))   ; pre 5.1.1
  IE_tavg = dim_avg_n_Wrap( IE, 0)
  IE@long_name = "Time Average: Vertically Integrated Internal Energy"

  printMinMax(IE, True)
  printMinMax(IE_tavg, True)

  delete(Tdp)    ; no longer needed