5 * Revision 1.2 1997/12/15 16:18:35 mclareni
6 * Changes for the Portland Group f77 compiler inside cpp define CERNLIB_QFPGF77
8 * Revision 1.1.1.1 1996/04/01 15:02:01 mclareni
12 #include "gen/pilot.h"
13 #if defined(CERNLIB_DOUBLE)
14 SUBROUTINE WELFUN(W,AK2,SN,CN,DN)
16 #include "gen/imp64.inc"
19 PARAMETER(NAME='CELFUN/WELFUN')
21 #if !defined(CERNLIB_DOUBLE)
22 SUBROUTINE CELFUN(W,AK2,SN,CN,DN)
25 PARAMETER(NAME='CELFUN')
28 C Jacobian Elliptic Functions SN(W,M),CN(W,M),DN(W,M) for
29 C complex argument w = u+i*v.
30 C Iterates for parameter m = k**2 or mc= 1-m if mc < m to obtain
31 C fastest convergence and uses finally Jacobi's
32 C imaginary transformation to go back to sn, cn, dn of m.
34 #include "gen/defc64.inc"
38 C MACHINE-DEPENDENT: EPS1=2**-(MB/2), EPS2=2**-(MB+3)
39 C Where M = Number of bits in mantissa
42 PARAMETER (Z0 = 0, Z1 = 1, Z2 = 2, HF = Z1/2, QU = Z1/4)
43 #if !defined(CERNLIB_CRAY)
44 PARAMETER (I = (0D0,1D0))
46 #if defined(CERNLIB_CRAY)
47 PARAMETER (I = (0E0,1E0))
49 PARAMETER (PI = 3.14159 26535 89793 24D0, PIH = PI/2)
50 PARAMETER (EPS1 = Z2**(-MB/2), EPS2 = Z2**(-(MB+3)))
54 #if defined(CERNLIB_QFPGF77)
60 #if defined(CERNLIB_QF2C)
61 #include "gen/gcmpfun.inc"
64 #if ! defined(CERNLIB_QFPGF77)
70 #if !defined(CERNLIB_QF2C)
71 #include "gen/gcmpfun.inc"
77 CALL MTLPRT(NAME,'C320.1',ERRTXT)
83 IF(AM .EQ. AM0) GO TO 1
89 IF(AM .EQ. AM0) GO TO 1
99 C Gaussian arithmetic-geometric mean. Skipped if previous M.
101 2 IF(C(L) .GE. EPS1) THEN
112 C Descending Landen-Gauss Trafo for real U
115 IF(V .NE. 0 .OR. X .NE. 0) THEN
123 CU=SIGN(SQRT(ABS(1-SU**2)),BIGK-ABS(U))
135 CV=SIGN(SQRT((SV+Y)*SV),Y1)
137 C Evaluation of complex sn, cn, dn from real and imaginary ones and
138 C Jacobi's imaginary argument trafo if necessary
147 DN=GCMPLX(DD,XK2*SS*CC)
149 SN=GCMPLX(SU*CV*DV,SV*CU*DU)
171 101 FORMAT('MODULUS AK2 = ',1P,E15.6,' OUT OF RANGE')