-
Notifications
You must be signed in to change notification settings - Fork 2
/
gen.esmf.grid.ncl
33 lines (23 loc) · 904 Bytes
/
gen.esmf.grid.ncl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
;; create SCRIP gridfile for use in patch regridding
;; Specify arguments to script via command-line:
;; ncl gen.esmf.grid.ncl infile=\"$in\" outfile=\"$out\" maskvar=\"sftlf\"
fin = addfile(infile,"r")
lat = fin->lat
lon = fin->lon
lon = where(lon.lt.0, lon+360, lon)
opt = True
opt@ForceOverwrite = True
if(isvar("maskvar")) then
; https://www.ncl.ucar.edu/Document/Functions/ESMF/curvilinear_to_SCRIP.shtml
landmask = fin->$maskvar$
opt@GridMask = where(landmask.le.0,0,1) ; use "Mask2D" in NCL V6.2.1 and earlier
end if
if(dimsizes(dimsizes(lat)) .lt. 2) then
rectilinear_to_SCRIP(outfile,lat,lon,opt)
else
curvilinear_to_SCRIP(outfile,lat,lon,opt)
end if
;; Copyright 2016 Univ. Corp. for Atmos. Research
;; Author: Seth McGinnis, [email protected]