Skip to content

Commit

Permalink
Fixe real equality comparison error
Browse files Browse the repository at this point in the history
Changed the real equality comparison to an abs comparison
  • Loading branch information
krvajal committed Oct 11, 2016
1 parent c85dc10 commit 63ad9b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.cmake
*.mod
*.o
*.make
*.marks
*.link
*.stamp
*.build
link.txt
Makefile
7 changes: 4 additions & 3 deletions src/mesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function meshexp(rmin, rmax, a, N) result(mesh)
real(dp) :: alpha, beta
if (a < 0) then
call stop_error("meshexp: a > 0 required")
else if (a == 1) then
else if (abs(a - 1) < tiny(1.0_dp)) then
alpha = (rmax - rmin) / N
do i = 1, N+1
mesh(i) = alpha * (i-1.0_dp) + rmin
Expand Down Expand Up @@ -89,7 +89,8 @@ function meshexp_der(rmin, rmax, a, N) result(Rp)
real(dp) :: alpha, beta
if (a < 0) then
call stop_error("meshexp_der: a > 0 required")
else if (a == 1) then
else if (abs(a - 1) < tiny(1.0_dp)) then

call stop_error("meshexp_der: a == 1 not implemented")
else
if (N > 1) then
Expand Down Expand Up @@ -124,7 +125,7 @@ function meshexp_der2(rmin, rmax, a, N) result(Rpp)
real(dp) :: alpha, beta
if (a < 0) then
call stop_error("meshexp_der2: a > 0 required")
else if (a == 1) then
else if (abs(a - 1) < tiny(1.0_dp)) then
call stop_error("meshexp_der2: a == 1 not implemented")
else
if (N > 1) then
Expand Down
2 changes: 1 addition & 1 deletion src/optimize.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ real(dp) function bisect(f, a, b, tol) result(c)
do while (b_ - a_ > tol)
c = (a_ + b_) / 2
fc = f(c)
if (fc == 0) return ! We need to make sure f(c) is not zero below
if (abs(fc) < tiny(1.0_dp)) return ! We need to make sure f(c) is not zero below
if (fa * fc < 0) then
b_ = c
fb = fc
Expand Down

0 comments on commit 63ad9b5

Please sign in to comment.