1 subroutine cubint ( ntab, xtab, ftab, ia_in, ib_in, result, error )
2 USE itm_types
, only : r8
103 write ( *,
'(a)' )
' '
104 write ( *,
'(a)' )
'CUBINT - Fatal error!'
105 write ( *,
'(a,i8)' )
' NTAB must be at least 4, but input NTAB = ', ntab
110 write ( *,
'(a)' )
' '
111 write ( *,
'(a)' )
'CUBINT - Fatal error!'
112 write ( *,
'(a,i8)' )
' IA must be at least 1, but input IA = ', ia
116 if ( ntab < ia )
then
117 write ( *,
'(a)' )
' '
118 write ( *,
'(a)' )
'CUBINT - Fatal error!'
119 write ( *,
'(a,i8)' )
' IA must be <= NTAB, but input IA = ', ia
124 write ( *,
'(a)' )
' '
125 write ( *,
'(a)' )
'CUBINT - Fatal error!'
126 write ( *,
'(a,i8)' )
' IB must be at least 1, but input IB = ', ib
130 if ( ntab < ib )
then
131 write ( *,
'(a)' )
' '
132 write ( *,
'(a)' )
'CUBINT - Fatal error!'
133 write ( *,
'(a,i8)' )
' IB must be <= NTAB, but input IB = ', ib
154 if ( ia < ntab-1 .or. ntab == 4 )
then
159 if ( 2 < ib .or. ntab == 4 )
then
160 k = min( ntab, ib + 2 ) - 1
167 h2 = xtab(j-1) - xtab(j-2)
168 d3 = ( ftab(j-1) - ftab(j-2) ) / h2
169 h3 = xtab(j) - xtab(j-1)
170 d1 = ( ftab(j) - ftab(j-1) ) / h3
172 d2 = ( d1 - d3 ) / h1
173 h4 = xtab(j+1) - xtab(j)
174 r1 = ( ftab(j+1) - ftab(j) ) / h4
175 r2 = ( r1 - d1 ) / ( h4 + h3 )
180 result = h2 * ( ftab(1) + h2 * ( 0.5_r8 * d3 - h2 &
181 * ( d2 / 6.0_r8 -(h2+h3+h3)*r3/12.0_r8)))
182 s = -h2**3 * (h2*(3.0_r8*h2+5.0_r8*h4)+10.0_r8*h3*h1) / 60.0_r8
187 h4 = xtab(i+1) - xtab(i)
188 r1 = ( ftab(i+1) - ftab(i) ) / h4
190 r2 = ( r1 - d1 ) / r4
192 r3 = (
r2 - d2 ) / r4
193 r4 = ( r3 - d3 ) / ( r4 + h1 )
197 if ( ia < i .and. i <= ib )
then
199 term = h3 * ( ( ftab(i) + ftab(i-1) ) * 0.5_r8 &
200 -h3 * h3 * ( d2 +
r2 + ( h2 - h4 ) * r3 ) / 12.0_r8 )
201 result = result + term
202 c = h3**3 * ( 2.0_r8 * h3 * h3 &
203 + 5.0_r8 * ( h3 * ( h4 + h2 ) + 2.0_r8 * h2 * h4 ) ) / 120.0_r8
204 error = error + (c+s)*r4
214 error = error + r4 * s
220 if ( ntab <= ib )
then
221 term = h4 * ( ftab(ntab) - h4 * ( 0.5 * r1 &
222 + h4 * (
r2 / 6.0_r8 + ( h3 + h3 + h4 ) * r3 / 12.0_r8 )))
223 result = result + term
224 error = error - h4**3 * r4 * &
225 ( h4 * ( 3.0_r8 * h4 + 5.0_r8 * h2 ) &
226 + 10.0_r8 * h3 * ( h2 + h3 + h4 ) ) / 60.0_r8
229 if ( ntab-1 <= ib )
then
230 error = error + s * r4
real(r8) function r2(a, x, xr, xs, yr, ys, psi, psir, F_dia)
subroutine cubint(ntab, xtab, ftab, ia_in, ib_in, result, error)