dfehl.f 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. *DECK DFEHL
  2. SUBROUTINE DFEHL (DF, NEQ, T, Y, H, YP, F1, F2, F3, F4, F5, YS,
  3. + RPAR, IPAR)
  4. C***BEGIN PROLOGUE DFEHL
  5. C***SUBSIDIARY
  6. C***PURPOSE Subsidiary to DDERKF
  7. C***LIBRARY SLATEC
  8. C***TYPE DOUBLE PRECISION (DEFEHL-S, DFEHL-D)
  9. C***AUTHOR Watts, H. A., (SNLA)
  10. C***DESCRIPTION
  11. C
  12. C Fehlberg Fourth-Fifth Order Runge-Kutta Method
  13. C **********************************************************************
  14. C
  15. C DFEHL integrates a system of NEQ first order
  16. C ordinary differential equations of the form
  17. C DU/DX = DF(X,U)
  18. C over one step when the vector Y(*) of initial values for U(*) and
  19. C the vector YP(*) of initial derivatives, satisfying YP = DF(T,Y),
  20. C are given at the starting point X=T.
  21. C
  22. C DFEHL advances the solution over the fixed step H and returns
  23. C the fifth order (sixth order accurate locally) solution
  24. C approximation at T+H in the array YS(*).
  25. C F1,---,F5 are arrays of dimension NEQ which are needed
  26. C for internal storage.
  27. C The formulas have been grouped to control loss of significance.
  28. C DFEHL should be called with an H not smaller than 13 units of
  29. C roundoff in T so that the various independent arguments can be
  30. C distinguished.
  31. C
  32. C This subroutine has been written with all variables and statement
  33. C numbers entirely compatible with DRKFS. For greater efficiency,
  34. C the call to DFEHL can be replaced by the module beginning with
  35. C line 222 and extending to the last line just before the return
  36. C statement.
  37. C
  38. C **********************************************************************
  39. C
  40. C***SEE ALSO DDERKF
  41. C***ROUTINES CALLED (NONE)
  42. C***REVISION HISTORY (YYMMDD)
  43. C 820301 DATE WRITTEN
  44. C 890831 Modified array declarations. (WRB)
  45. C 891214 Prologue converted to Version 4.0 format. (BAB)
  46. C 900328 Added TYPE section. (WRB)
  47. C 910722 Updated AUTHOR section. (ALS)
  48. C***END PROLOGUE DFEHL
  49. C
  50. INTEGER IPAR, K, NEQ
  51. DOUBLE PRECISION CH, F1, F2, F3, F4, F5, H, RPAR, T, Y, YP, YS
  52. DIMENSION Y(*),YP(*),F1(*),F2(*),F3(*),F4(*),F5(*),
  53. 1 YS(*),RPAR(*),IPAR(*)
  54. C
  55. C***FIRST EXECUTABLE STATEMENT DFEHL
  56. CH = H/4.0D0
  57. DO 10 K = 1, NEQ
  58. YS(K) = Y(K) + CH*YP(K)
  59. 10 CONTINUE
  60. CALL DF(T+CH,YS,F1,RPAR,IPAR)
  61. C
  62. CH = 3.0D0*H/32.0D0
  63. DO 20 K = 1, NEQ
  64. YS(K) = Y(K) + CH*(YP(K) + 3.0D0*F1(K))
  65. 20 CONTINUE
  66. CALL DF(T+3.0D0*H/8.0D0,YS,F2,RPAR,IPAR)
  67. C
  68. CH = H/2197.0D0
  69. DO 30 K = 1, NEQ
  70. YS(K) = Y(K)
  71. 1 + CH
  72. 2 *(1932.0D0*YP(K) + (7296.0D0*F2(K) - 7200.0D0*F1(K)))
  73. 30 CONTINUE
  74. CALL DF(T+12.0D0*H/13.0D0,YS,F3,RPAR,IPAR)
  75. C
  76. CH = H/4104.0D0
  77. DO 40 K = 1, NEQ
  78. YS(K) = Y(K)
  79. 1 + CH
  80. 2 *((8341.0D0*YP(K) - 845.0D0*F3(K))
  81. 3 + (29440.0D0*F2(K) - 32832.0D0*F1(K)))
  82. 40 CONTINUE
  83. CALL DF(T+H,YS,F4,RPAR,IPAR)
  84. C
  85. CH = H/20520.0D0
  86. DO 50 K = 1, NEQ
  87. YS(K) = Y(K)
  88. 1 + CH
  89. 2 *((-6080.0D0*YP(K)
  90. 3 + (9295.0D0*F3(K) - 5643.0D0*F4(K)))
  91. 4 + (41040.0D0*F1(K) - 28352.0D0*F2(K)))
  92. 50 CONTINUE
  93. CALL DF(T+H/2.0D0,YS,F5,RPAR,IPAR)
  94. C
  95. C COMPUTE APPROXIMATE SOLUTION AT T+H
  96. C
  97. CH = H/7618050.0D0
  98. DO 60 K = 1, NEQ
  99. YS(K) = Y(K)
  100. 1 + CH
  101. 2 *((902880.0D0*YP(K)
  102. 3 + (3855735.0D0*F3(K) - 1371249.0D0*F4(K)))
  103. 4 + (3953664.0D0*F2(K) + 277020.0D0*F5(K)))
  104. 60 CONTINUE
  105. C
  106. RETURN
  107. END