forked from NOAA-PSL/stochastic_physics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gozrineo_stochy.f
179 lines (176 loc) · 5.36 KB
/
gozrineo_stochy.f
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
!>@brief The module 'gozrineo_a_stochy_mod' contains the subroutine 'gozrineo_a_stochy'
module gozrineo_a_stochy_mod
implicit none
contains
!>@brief The subroutine 'gozrineo_a_stochy' calculates the deriviates of assoicate legendre polynomials
!>@details This code is taken from the legacy spectral GFS
subroutine gozrineo_a_stochy(plnev_a,plnod_a,
& pddev_a,pddod_a,
& plnew_a,plnow_a,
& epse,epso,ls_node,num_lat)
cc
use spectral_layout_mod
use kinddef
implicit none
cc
real(kind=kind_dbl_prec) plnev_a(len_trie_ls,latg2)
real(kind=kind_dbl_prec) plnod_a(len_trio_ls,latg2)
real(kind=kind_dbl_prec) pddev_a(len_trie_ls,latg2)
real(kind=kind_dbl_prec) pddod_a(len_trio_ls,latg2)
real(kind=kind_dbl_prec) plnew_a(len_trie_ls,latg2)
real(kind=kind_dbl_prec) plnow_a(len_trio_ls,latg2)
cc
real(kind=kind_dbl_prec) epse(len_trie_ls)
real(kind=kind_dbl_prec) epso(len_trio_ls)
cc
cc
integer ls_node(ls_dim,3)
cc
integer num_lat
cc
!cmr ls_node(1,1) ... ls_node(ls_max_node,1) : values of L
!cmr ls_node(1,2) ... ls_node(ls_max_node,2) : values of jbasev
!cmr ls_node(1,3) ... ls_node(ls_max_node,3) : values of jbasod
cc
integer l,lat,locl,n
cc
integer indev,indev1,indev2
integer indod,indod1,indod2
integer inddif
cc
real(kind=kind_dbl_prec) rn,rnp1,wcsa
cc
real(kind=kind_dbl_prec) cons0 !constant
real(kind=kind_dbl_prec) cons2 !constant
real rerth
cc
integer indlsev,jbasev
integer indlsod,jbasod
cc
include 'function2'
cc
cc
cons0 = 0.d0 !constant
cons2 = 2.d0 !constant
rerth =6.3712e+6 ! radius of earth (m)
cc
cc
do lat=1,num_lat
cc
do locl=1,ls_max_node
l=ls_node(locl,1)
jbasev=ls_node(locl,2)
jbasod=ls_node(locl,3)
cc
rn=l
cc
cc
pddev_a(indlsev(l,l),lat) = -epso(indlsod(l+1,l))
& * plnod_a(indlsod(l+1,l),lat) * rn
indev1 = indlsev(L,L) + 1
if (mod(L,2).eq.mod(jcap+1,2)) then
indev2 = indlsev(jcap-1,L)
else
indev2 = indlsev(jcap ,L)
endif
indod1 = indlsod(l+1,l)
inddif = indev1 - indod1
cc
rn =l+2
rnp1=l+2+1
do indev = indev1 , indev2
cc
pddev_a(indev,lat) = epse(indev)
& * plnod_a(indev-inddif ,lat) * rnp1
& - epso(indev-inddif+1)
& * plnod_a(indev-inddif+1,lat) * rn
cc
rn = rn + cons2 !constant
rnp1 = rnp1 + cons2 !constant
enddo
cc
cc......................................................................
indev1 = indlsev(L,L)
if (mod(L,2).eq.mod(jcap+1,2)) then
indev2 = indlsev(jcap+1,L) - 1
else
indev2 = indlsev(jcap ,L) - 1
endif
indod1 = indlsod(l+1,l)
inddif = indev1 - indod1
cc
rn =l+1
rnp1=l+1+1
do indev = indev1 , indev2
cc
pddod_a(indev-inddif,lat) = epso(indev-inddif)
& * plnev_a(indev ,lat) * rnp1
& - epse(indev+1)
& * plnev_a(indev+1,lat) * rn
cc
rn = rn + cons2 !constant
rnp1 = rnp1 + cons2 !constant
enddo
cc
enddo
cc
cc......................................................................
cc
do locl=1,ls_max_node
l=ls_node(locl,1)
jbasev=ls_node(locl,2)
jbasod=ls_node(locl,3)
cc
if (mod(L,2).eq.mod(jcap+1,2)) then
cc
cc set the even (n-l) terms of the top row to zero
pddev_a(indlsev(jcap+1,l),lat) = cons0 !constant
cc
else
cc
cc set the odd (n-l) terms of the top row to zero
pddod_a(indlsod(jcap+1,l),lat) = cons0 !constant
cc
endif
cc
enddo
cc
cc......................................................................
cc
wcsa=rcs2_a(lat)/rerth
cc
cc
do locl=1,ls_max_node
l=ls_node(locl,1)
jbasev=ls_node(locl,2)
jbasod=ls_node(locl,3)
indev1 = indlsev(L,L)
indod1 = indlsod(L+1,L)
if (mod(L,2).eq.mod(jcap+1,2)) then
indev2 = indlsev(jcap+1,L)
indod2 = indlsod(jcap ,L)
else
indev2 = indlsev(jcap ,L)
indod2 = indlsod(jcap+1,L)
endif
do indev = indev1 , indev2
cc
pddev_a(indev,lat) = pddev_a(indev,lat) * wcsa
plnew_a(indev,lat) = plnev_a(indev,lat) * wgt_a(lat)
cc
enddo
cc
do indod = indod1 , indod2
cc
pddod_a(indod,lat) = pddod_a(indod,lat) * wcsa
plnow_a(indod,lat) = plnod_a(indod,lat) * wgt_a(lat)
cc
enddo
cc
enddo
cc
enddo
cc
return
end
end module gozrineo_a_stochy_mod