42 |
|
module switcheroo |
43 |
|
|
44 |
|
use definitions |
45 |
+ |
use interpolation |
46 |
|
|
47 |
|
implicit none |
48 |
|
PRIVATE |
59 |
|
|
60 |
|
logical, dimension(NSWITCHTYPES) :: isOK |
61 |
|
logical, save :: haveFunctionType = .false. |
62 |
+ |
logical, save :: haveSqrtSpline = .false. |
63 |
+ |
logical, save :: useSpline = .true. |
64 |
|
integer, save :: functionType = CUBIC |
65 |
|
|
66 |
|
|
67 |
+ |
! spline variables |
68 |
+ |
type(cubicSpline), save :: scoef |
69 |
+ |
real ( kind = dp ), dimension(SPLINE_SEGMENTS) :: xValues |
70 |
+ |
real ( kind = dp ), dimension(SPLINE_SEGMENTS) :: yValues |
71 |
+ |
real ( kind = dp ), save :: dSqrt1, dSqrtN, range, dX |
72 |
+ |
real ( kind = dp ), save :: lowerBound |
73 |
+ |
logical, save :: uniformSpline = .true. |
74 |
+ |
|
75 |
|
public::set_switch |
76 |
|
public::set_function_type |
77 |
|
public::get_switch |
82 |
|
|
83 |
|
real ( kind = dp ), intent(in):: rinner, router |
84 |
|
integer, intent(in) :: SwitchType |
85 |
+ |
integer :: i |
86 |
|
|
87 |
|
if (SwitchType .gt. NSWITCHTYPES) then |
88 |
|
write(default_error, *) & |
110 |
|
rout2(SwitchType) = router * router |
111 |
|
isOK(SwitchType) = .true. |
112 |
|
|
113 |
+ |
if (.not.haveSqrtSpline) then |
114 |
+ |
! fill arrays for building the spline |
115 |
+ |
lowerBound = 1.0d0 ! the smallest value expected for r2 |
116 |
+ |
range = rout2(SwitchType) - lowerBound |
117 |
+ |
dX = range / (SPLINE_SEGMENTS - 1) |
118 |
+ |
|
119 |
+ |
! the spline is bracketed by lowerBound and rout2 endpoints |
120 |
+ |
xValues(1) = lowerBound |
121 |
+ |
yValues(1) = dsqrt(lowerBound) |
122 |
+ |
do i = 1, SPLINE_SEGMENTS-1 |
123 |
+ |
xValues(i+1) = i * dX |
124 |
+ |
yValues(i+1) = dsqrt( i * dX ) |
125 |
+ |
enddo |
126 |
+ |
|
127 |
+ |
! set the endpoint derivatives |
128 |
+ |
dSqrt1 = 1 / ( 2.0d0 * dsqrt( xValues(1) ) ) |
129 |
+ |
dSqrtN = 1 / ( 2.0d0 * dsqrt( xValues(SPLINE_SEGMENTS) ) ) |
130 |
+ |
|
131 |
+ |
! call newSpline to fill the coefficient array |
132 |
+ |
call newSpline(scoef, xValues, yValues, dSqrt1, dSqrtN, uniformSpline) |
133 |
+ |
|
134 |
+ |
endif |
135 |
+ |
|
136 |
|
end subroutine set_switch |
137 |
|
|
138 |
|
subroutine set_function_type(functionForm) |
177 |
|
return |
178 |
|
|
179 |
|
else |
180 |
+ |
if (useSpline) then |
181 |
+ |
call lookup_uniform_spline(scoef, r2, r) |
182 |
+ |
else |
183 |
+ |
r = dsqrt(r2) |
184 |
+ |
endif |
185 |
|
|
146 |
– |
r = dsqrt(r2) |
147 |
– |
|
186 |
|
ron = rin(SwitchType) |
187 |
|
roff = rout(SwitchType) |
188 |
|
|