1 !--------------------------------------------------------------
3 ! BLAS/LAPACK-like subroutines used by the integration algorithms
4 ! It is recommended to replace them by calls to the optimized
5 ! BLAS/LAPACK library for your machine
7 ! (C) Adrian Sandu, Aug. 2004
8 ! Virginia Polytechnic Institute and State University
9 !--------------------------------------------------------------
12 !--------------------------------------------------------------
13 SUBROUTINE WCOPY(N
,X
,incX
,Y
,incY
)
14 !--------------------------------------------------------------
15 ! copies a vector, x, to a vector, y: y <- x
16 ! only for incX=incY=1
18 ! replace this by the function from the optimized BLAS implementation:
19 ! CALL SCOPY(N,X,1,Y,1) or CALL DCOPY(N,X,1,Y,1)
20 !--------------------------------------------------------------
21 ! USE KPP_ROOT_Precision
23 INTEGER i
,incX
,incY
,M
,MP1
,N
50 !--------------------------------------------------------------
51 SUBROUTINE WAXPY(N
,Alpha
,X
,incX
,Y
,incY
)
52 !--------------------------------------------------------------
53 ! constant times a vector plus a vector: y <- y + Alpha*x
54 ! only for incX=incY=1
56 ! replace this by the function from the optimized BLAS implementation:
57 ! CALL SAXPY(N,Alpha,X,1,Y,1) or CALL DAXPY(N,Alpha,X,1,Y,1)
58 !--------------------------------------------------------------
59 ! USE KPP_ROOT_Precision
61 INTEGER i
,incX
,incY
,M
,MP1
,N
62 KPP_REAL
X(N
),Y(N
),Alpha
64 PARAMETER( ZERO
= 0.0_dp
)
66 IF (Alpha
.EQ
. ZERO
) RETURN
72 Y(i
) = Y(i
) + Alpha
*X(i
)
78 Y(i
) = Y(i
) + Alpha
*X(i
)
79 Y(i
+ 1) = Y(i
+ 1) + Alpha
*X(i
+ 1)
80 Y(i
+ 2) = Y(i
+ 2) + Alpha
*X(i
+ 2)
81 Y(i
+ 3) = Y(i
+ 3) + Alpha
*X(i
+ 3)
88 !--------------------------------------------------------------
89 SUBROUTINE WSCAL(N
,Alpha
,X
,incX
)
90 !--------------------------------------------------------------
91 ! constant times a vector: x(1:N) <- Alpha*x(1:N)
92 ! only for incX=incY=1
94 ! replace this by the function from the optimized BLAS implementation:
95 ! CALL SSCAL(N,Alpha,X,1) or CALL DSCAL(N,Alpha,X,1)
96 !--------------------------------------------------------------
97 ! USE KPP_ROOT_Precision
99 INTEGER i
,incX
,M
,MP1
,N
102 PARAMETER( ZERO
= 0.0_dp
)
103 PARAMETER( ONE
= 1.0_dp
)
105 IF (Alpha
.EQ
. ONE
) RETURN
110 IF (Alpha
.EQ
. (-ONE
)) THEN
114 ELSEIF (Alpha
.EQ
. ZERO
) THEN
123 IF( N
.LT
. 5 ) RETURN
126 IF (Alpha
.EQ
. (-ONE
)) THEN
134 ELSEIF (Alpha
.EQ
. ZERO
) THEN
145 X(i
+ 1) = Alpha
*X(i
+ 1)
146 X(i
+ 2) = Alpha
*X(i
+ 2)
147 X(i
+ 3) = Alpha
*X(i
+ 3)
148 X(i
+ 4) = Alpha
*X(i
+ 4)
154 !--------------------------------------------------------------
155 KPP_REAL
FUNCTION WLAMCH( C
)
156 !--------------------------------------------------------------
157 ! returns epsilon machine
159 ! replace this by the function from the optimized LAPACK implementation:
160 ! CALL SLAMCH('E') or CALL DLAMCH('E')
161 !--------------------------------------------------------------
162 ! USE KPP_ROOT_Precision
166 KPP_REAL ONE
, HALF
, Eps
, Sum
167 PARAMETER (ONE
= 1.0_dp
)
168 PARAMETER (HALF
= 0.5_dp
)
178 CALL WLAMCH_ADD(ONE
,Eps
,Sum
)
179 IF (Sum
.LE
.ONE
) GOTO 10
181 PRINT*,'ERROR IN WLAMCH. EPS < ',Eps
191 SUBROUTINE WLAMCH_ADD( A
, B
, Sum
)
192 ! USE KPP_ROOT_Precision
197 END SUBROUTINE WLAMCH_ADD
198 !--------------------------------------------------------------
201 !--------------------------------------------------------------
202 SUBROUTINE SET2ZERO(N
,Y
)
203 !--------------------------------------------------------------
204 ! copies zeros into the vector y: y <- 0
206 !--------------------------------------------------------------
210 KPP_REAL
, PARAMETER :: ZERO
= 0.0d0
219 IF( N
.LT
. 8 ) RETURN
233 END SUBROUTINE SET2ZERO
236 !--------------------------------------------------------------
237 KPP_REAL
FUNCTION WDOT (N
, DX
, incX
, DY
, incY
)
238 !--------------------------------------------------------------
239 ! dot produce: wdot = x(1:N)*y(1:N)
240 ! only for incX=incY=1
242 ! replace this by the function from the optimized BLAS implementation:
243 ! CALL SDOT(N,X,1,Y,1) or CALL DDOT(N,X,1,Y,1)
244 !--------------------------------------------------------------
245 ! USE messy_mecca_kpp_Precision
246 !--------------------------------------------------------------
248 INTEGER :: N
, incX
, incY
249 KPP_REAL
:: DX(N
), DY(N
)
251 INTEGER :: i
, IX
, IY
, M
, MP1
, NS
255 IF (incX
.EQ
. incY
) IF (incX
-1) 5,20,60
257 ! Code for unequal or nonpositive increments.
261 IF (incX
.LT
. 0) IX
= (-N
+1)*incX
+ 1
262 IF (incY
.LT
. 0) IY
= (-N
+1)*incY
+ 1
264 WDOT
= WDOT
+ DX(IX
)*DY(IY
)
270 ! Code for both increments equal to 1.
272 ! Clean-up loop so remaining vector length is a multiple of 5.
275 IF (M
.EQ
. 0) GO
TO 40
277 WDOT
= WDOT
+ DX(i
)*DY(i
)
282 WDOT
= WDOT
+ DX(i
)*DY(i
) + DX(i
+1)*DY(i
+1) + DX(i
+2)*DY(i
+2) + &
283 DX(i
+3)*DY(i
+3) + DX(i
+4)*DY(i
+4)
287 ! Code for equal, positive, non-unit increments.
291 WDOT
= WDOT
+ DX(i
)*DY(i
)