-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpypowder.for
231 lines (217 loc) · 6.52 KB
/
pypowder.for
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
SUBROUTINE PYPSVFCJ(NPTS,DTT,TTHETA,SIG,GAM,SPH,PRFUNC)
C DTT in degrees
C TTHETA in degrees
C SPH is S/L + H/L
C RETURNS FUNCTION ONLY
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) TTHETA
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(in) SPH
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
REAL*4 DTT(0:NPTS-1),PRFUNC(0:NPTS-1)
REAL*4 TTHETA,SIG,GAM,SPH
INTEGER*4 NPTS,I
DO I=0,NPTS-1
CALL PSVFCJ(DTT(I)*100.,TTHETA*100.,SIG,GAM,SPH,
1 PRFUNC(I),DPRDT,SIGPART,GAMPART,SLPART)
END DO
RETURN
END
SUBROUTINE PYDPSVFCJ(NPTS,DTT,TTHETA,SIG,GAM,SPH,PRFUNC,
1 DPRDT,SIGPART,GAMPART,SLPART)
C DTT in degrees
C TTHETA in degrees
C SPH is S/L + H/L
C RETURNS FUNCTION & DERIVATIVES
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) TTHETA
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(in) SPH
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
Cf2py intent(out) DPRDT
Cf2py depend(NPTS) DPRDT
Cf2py intent(out) SIGPART
Cf2py depend(NPTS) SIGPART
Cf2py intent(out) GAMPART
Cf2py depend(NPTS) GAMPART
Cf2py intent(out) SLPART
Cf2py depend(NPTS) SLPART
INTEGER*4 NPTS
REAL*4 TTHETA,SIG,GAM,SPH
REAL*4 DTT(0:NPTS-1),DPRDT(0:NPTS-1),SIGPART(0:NPTS-1),
1 GAMPART(0:NPTS-1),SLPART(0:NPTS-1),PRFUNC(0:NPTS-1)
DO I=0,NPTS-1
CALL PSVFCJ(DTT(I)*100.,TTHETA*100.,SIG,GAM,SPH,
1 PRFUNC(I),DPRDT(I),SIGPART(I),GAMPART(I),SLPART(I))
DPRDT(I) = DPRDT(I)*100.
END DO
RETURN
END
SUBROUTINE PYPSVFCJO(NPTS,DTT,TTHETA,SIG,GAM,SPH,PRFUNC)
C DTT in degrees
C TTHETA in degrees
C SPH is S/L + H/L
C RETURNS FUNCTION ONLY
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) TTHETA
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(in) SPH
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
INTEGER*4 NPTS
REAL*4 TTHETA,SIG,GAM,SPH
REAL*4 DTT(0:NPTS-1),PRFUNC(0:NPTS-1)
DO I=0,NPTS-1
CALL PSVFCJO(DTT(I)*100.,TTHETA*100.,SIG,GAM,SPH/2.0,SPH/2.0,
1 PRFUNC(I),DPRDT,SIGPART,GAMPART,SLPART,HLPART)
END DO
RETURN
END
SUBROUTINE PYDPSVFCJO(NPTS,DTT,TTHETA,SIG,GAM,SHL,PRFUNC,
1 DPRDT,SIGPART,GAMPART,SLPART)
C DTT in degrees
C TTHETA in degrees
C SPH is S/L + H/L
C RETURNS FUNCTION & DERIVATIVES
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) TTHETA
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(in) SHL
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
Cf2py intent(out) DPRDT
Cf2py depend(NPTS) DPRDT
Cf2py intent(out) SIGPART
Cf2py depend(NPTS) SIGPART
Cf2py intent(out) GAMPART
Cf2py depend(NPTS) GAMPART
Cf2py intent(out) SLPART
Cf2py depend(NPTS) SLPART
INTEGER*4 NPTS
REAL*4 TTHETA,SIG,GAM,SHL
REAL*4 DTT(0:NPTS-1),DPRDT(0:NPTS-1),SIGPART(0:NPTS-1),
1 GAMPART(0:NPTS-1),SLPART(0:NPTS-1),PRFUNC(0:NPTS-1)
DO I=0,NPTS-1
CALL PSVFCJO(DTT(I)*100.,TTHETA*100.,SIG,GAM,SHL/2.,SHL/2.,
1 PRFUNC(I),DPRDT(I),SIGPART(I),GAMPART(I),SPART,HPART)
SLPART(I) = SPART
DPRDT(I) = DPRDT(I)*100.
END DO
RETURN
END
SUBROUTINE PYEPSVOIGT(NPTS,DTT,ALP,BET,SIG,GAM,PRFUNC)
C DTT in microsec
C RETURNS FUNCTION
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) ALP
Cf2py intent(in) BET
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
INTEGER*4 NPTS
REAL*4 ALP,BET,SIG,GAM,SHL
REAL*4 DTT(0:NPTS-1),PRFUNC(0:NPTS-1),DPRDT,ALPPART,
1 BETPART,SIGPART,GAMPART
DO I=0,NPTS-1
CALL EPSVOIGT(DTT(I),ALP,BET,SIG,GAM,PRFUNC(I),DPRDT,
1 ALPPART,BETPART,SIGPART,GAMPART)
END DO
RETURN
END
SUBROUTINE PYDEPSVOIGT(NPTS,DTT,ALP,BET,SIG,GAM,PRFUNC,
1 DPRDT,ALPPART,BETPART,SIGPART,GAMPART)
C DTT in microsec
C RETURNS FUNCTION & DERIVATIVES
Cf2py intent(in) NPTS
Cf2py intent(in) DTT
cf2py depend(NPTS) DTT
Cf2py intent(in) ALP
Cf2py intent(in) BET
Cf2py intent(in) SIG
Cf2py intent(in) GAM
Cf2py intent(out) PRFUNC
Cf2py depend(NPTS) PRFUNC
Cf2py intent(out) DPRDT
Cf2py depend(NPTS) DPRDT
Cf2py intent(out) ALPPART
Cf2py depend(NPTS) ALPPART
Cf2py intent(out) BETPART
Cf2py depend(NPTS) BETPART
Cf2py intent(out) SIGPART
Cf2py depend(NPTS) SIGPART
Cf2py intent(out) GAMPART
Cf2py depend(NPTS) GAMPART
INTEGER*4 NPTS
REAL*4 ALP,BET,SIG,GAM,SHL
REAL*4 DTT(0:NPTS-1),DPRDT(0:NPTS-1),ALPPART(0:NPTS-1),
1 BETPART(0:NPTS-1),SIGPART(0:NPTS-1),
1 GAMPART(0:NPTS-1),PRFUNC(0:NPTS-1)
DO I=0,NPTS-1
CALL EPSVOIGT(DTT(I),ALP,BET,SIG,GAM,PRFUNC(I),DPRDT(I),
1 ALPPART(I),BETPART(I),SIGPART(I),GAMPART(I))
END DO
RETURN
END
C Fortran (fast) linear interpolation -- B.H. Toby 9/2011
SUBROUTINE PYFINTERP(NIN,XIN,YIN,NOUT,XOUT,YOUT)
C XIN(1:NIN) and YIN(1:NIN) are arrays of (x,y) points to be interpolated
C Values must be sorted increasing in XIN
C XOUT(1:NOUT) is an array of x values, must also be sorted increasing in x
C XOUT may contain values smaller than XIN(1) or larger than XIN(NIN)
C RETURNS interpolated y values corresponding to XOUT. Values outside the
C range of XIN are set to zero.
C Needs a way to signal an error if XIN or XOUT is not sorted -- for now stops
Cf2py intent(in) NIN
Cf2py intent(in) XIN
cf2py depend(NIN) XIN
Cf2py intent(in) YIN
cf2py depend(NIN) YIN
Cf2py intent(in) NOUT
Cf2py intent(in) XOUT
cf2py depend(NOUT) XOUT
Cf2py intent(out) YOUT
cf2py depend(NOUT) YOUT
INTEGER NIN,NOUT
REAL XIN(NIN),YIN(NIN)
REAL XOUT(NOUT),YOUT(NOUT)
INTEGER IERROR
REAL X,F
INTEGER IIN,I
IERROR = 1
IIN = 1
X = XOUT(1)
DO I=1,NOUT
IF (X .GT. XOUT(I)) STOP ! test if Xout not sorted
X = XOUT(I)
IF (X .LT. XIN(1) .OR. X .GT. XIN(NIN) ) THEN
YOUT(I) = 0.0
ELSE
DO WHILE (X .GT. XIN(IIN+1))
IF (XIN(IIN) .GT. XIN(IIN+1)) STOP ! test if Xin not sorted
IIN = IIN + 1
ENDDO
F = (X - XIN(IIN)) / (XIN(IIN+1) - XIN(IIN))
YOUT(I) = (1.-F)*YIN(IIN) + F*YIN(IIN+1)
ENDIF
!write (*,*) xout(i),iin,f,yout(i)
END DO
IERROR = 0
RETURN
END