1 SUBROUTINE QUADIN(Y,N,H,ANS) 2C ** 3C ** NUMERICAL INTEGRATION BY FIVE POINT QUADRATURE, THE TWO 4C ** POINT FORMULA, SIMPSON"S RULE OR NEWTON"S 3/8"S RULE 5C ** 6C ** INPUTS 7C ** Y = ARRAY TO BE INTEGRATED 8C ** N = NUMBER OF POINTS IN ARRAY Y 9C ** H = COMMON STEPSIZE BETWEEN SUCESSIVE ELEMENTS OF Y 10C ** OUTPUT 11C ** ANS= RESULT OF THE INTEGRATION 12C ** 13 DIMENSION Y(N) 14 K=N 15 ANS= 0. 16 IF(H.LE.0. .OR. N.LE.0) RETURN 17C ** 18C ** OMIT QUADRATURE METHOD IF LESS THAN FIVE POINTS 19C ** 20 IF(N.LT.4)GO TO 1010 21 DO 1000 I=1,N,4 22 K=N-I+1 23 IF(K.LT.5)GO TO 1000 24 ANS=ANS+7.*Y(I)+32.*Y(I+1)+12.*Y(I+2)+32.*Y(I+3)+7.*Y(I+4) 25 1000 CONTINUE 26 ANS=ANS*H/22.5 27 1010 CONTINUE 28C ** 29C ** IF K = 1 STOP THE INTEGRATION PROCESS 30C ** IF K = 2 USE THE TWO POINT FORMULA 31C ** IF K = 3 USE SIMPSON"S RULE 32C ** IF K = 4 USE NEWTON"S 3/8"S RULE 33C ** 34 GO TO (1020,1030,1040,1050),K 35 1020 CONTINUE 36 RETURN 37 1030 ANS=ANS+H*(Y(N)+Y(N-1))/2. 38 RETURN 39 1040 ANS=ANS+H*(Y(N-2)+4.*Y(N-1)+Y(N))/3. 40 RETURN 41 1050 ANS=ANS+3.*H*(Y(N-3)+3.*Y(N-2)+3.*Y(N-1)+Y(N))/8. 42 RETURN 43 END 44