-
Notifications
You must be signed in to change notification settings - Fork 6
/
diag_integrals.gs
executable file
·187 lines (157 loc) · 3.61 KB
/
diag_integrals.gs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
* This script computes one of various diagnostic quantities using
* basic NCEP Reanalysis grids stored in a template netcdf file.
* An assumption is that the calculation domain of interest has been
* specified - RD, Feb `99
function ints()
* query file for dimensions of current viewing domain
"q dims"
rec = sublin(result,5)
if (subwrd(rec,3) = "varying")
tmin = subwrd(rec,11)
tmax = subwrd(rec,13)
tvar = "varying"
else
tval = subwrd(rec,9)
tvar = "fixed"
endif
rec = sublin(result,4)
if (subwrd(rec,3) = "varying")
zmin = subwrd(rec,11)
zmax = subwrd(rec,13)
zvar = "varying"
else
zval = subwrd(rec,9)
zvar = "fixed"
endif
rec = sublin(result,3)
if (subwrd(rec,3) = "varying")
ymin = subwrd(rec,11)
ymax = subwrd(rec,13)
yvar = "varying"
else
yval = subwrd(rec,9)
yvar = "fixed"
endif
rec = sublin(result,2)
if (subwrd(rec,3) = "varying")
xmin = subwrd(rec,11)
xmax = subwrd(rec,13)
xvar = "varying"
else
xval = subwrd(rec,9)
xvar = "fixed"
endif
* query file for dimensions of calculation domain
"d timemin"
rec = sublin(result,1)
timemin = subwrd(rec,4)
"d timemax"
rec = sublin(result,1)
timemax = subwrd(rec,4)
"d levmin"
rec = sublin(result,1)
levmin = subwrd(rec,4)
"d levmax"
rec = sublin(result,1)
levmax = subwrd(rec,4)
"d moistmax"
rec = sublin(result,1)
moistmax = subwrd(rec,4)
"d latmin"
rec = sublin(result,1)
latmin = subwrd(rec,4)
"d latmax"
rec = sublin(result,1)
latmax = subwrd(rec,4)
"d lonmin"
rec = sublin(result,1)
lonmin = subwrd(rec,4)
"d lonmax"
rec = sublin(result,1)
lonmax = subwrd(rec,4)
say ""
say "calculating integral terms, pointwise"
say ""
say "using the following calculation domain:"
say "time from "timemin" to "timemax
say "level from "levmin" to "levmax
say "lat from "latmin" to "latmax
say "lon from "lonmin" to "lonmax
say ""
say "defining temporary variables" ; say ""
defa = "EARTH = 6.371e6"
say " "defa
"define "defa
defa = "D2R = 3.141592654 / 180.0"
say " "defa
"define "defa
defa = "OMEG = 7.292e-5"
say " "defa
"define "defa
defa = "GRAV = 9.8"
say " "defa
"define "defa
say ""
say "computing over lat and lon:" ; say ""
"set t 1"
"set z 1"
"set lat "latmin" "latmax
"set lon "lonmin" "lonmax
defa = "delx = EARTH * cdiff(lon,x) * D2R * cos(lat*D2R)"
say " "defa ; say ""
"define "defa
defa = "dely = EARTH * cdiff(lat,y) * D2R"
say " "defa ; say ""
"define "defa
defa = "coriol = 2.0 * OMEG * sin(lat*D2R)"
say " "defa ; say ""
"define "defa
say "computing over time, level, lat, and lon:" ; say ""
"set t "timemin" "timemax
"set lev "levmin" "levmax
"set lat "latmin" "latmax
"set lon "lonmin" "lonmax
#defa = "ucal = -cdiff(strm,y) / dely + cdiff(velp,x) / delx"
#defa = "ucal = cdiff(velp,x) / delx"
defa = "ucal = -cdiff(strm,y) / dely"
say " "defa ; say ""
"define "defa
#defa = "vcal = cdiff(strm,x) / delx + cdiff(velp,y) / dely"
#defa = "vcal = cdiff(velp,y) / dely"
defa = "vcal = cdiff(strm,x) / delx"
say " "defa ; say ""
"define "defa
defa = "vortcal = hcurl(uwnd,vwnd)"
say " "defa ; say ""
"define "defa
defa = "divcal = hdivg(uwnd,vwnd)"
say " "defa ; say ""
"define "defa
say "undefining temporary variables" ; say ""
"undefine EARTH"
"undefine D2R"
"undefine OMEG"
"undefine GRAV"
say "resetting the original viewing domain" ; say ""
if (tvar = "varying")
"set t "tmin" "tmax
else
"set t "tval
endif
if (zvar = "varying")
"set z "zmin" "zmax
else
"set z "zval
endif
if (yvar = "varying")
"set y "ymin" "ymax
else
"set y "yval
endif
if (xvar = "varying")
"set x "xmin" "xmax
else
"set x "xval
endif
say "re-creating the display script" ; say ""
"run gui_list"