-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy-file.ncl
43 lines (26 loc) · 928 Bytes
/
copy-file.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
34
35
36
37
38
39
40
41
42
43
;;; NCL template script; copies infile to outfile
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/csm/contributed.ncl"
;; Note: infile and outfile should be specified as command-line arguments to NCL:
;; ncl -x infile=\"$infile\" outfile=\"$outfile\" copy-file.ncl
infile = "tas_CRCM_1979010103.nc"
outfile = "tas_fixed.nc"
system("rm "+outfile)
fin = addfile(infile, "r")
fout = addfile(outfile, "c")
filedimdef(fout,"time",-1,True) ;; make time dimension unlimited
; copy global attributes
att_names = getvaratts(fin)
do i = 0,dimsizes(att_names)-1
fout@$att_names(i)$ = fin@$att_names(i)$
end do
; copy variables
var_names = getfilevarnames (fin) ;
do i = 0,dimsizes(var_names)-1
fout->$var_names(i)$ = fin->$var_names(i)$
end do
delete(fin)
delete(fout)
delete(var_names)
delete(att_names)