Skip to content

Commit

Permalink
Be explicit about floating point literals
Browse files Browse the repository at this point in the history
Floating point literals that include a decimal without explicit
precision, i.e. `1.`, are dangerous because we do not know what
precision the literal will be interpreted as, and expressions like
`1.+bpm`, where `bpm` has explicit precision `wp` caused Intel to throw
errors when compiled with the `-r8` flag. Adding precision to the
literals fixes this problem. That is, replacing `1.+bpm` with
`1._wp+bpm`. Fixes #28.
  • Loading branch information
brhillman committed Aug 22, 2019
1 parent 70d27da commit 047567b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ subroutine calc_Re(Q,Np,rho_a,dtype,apm,bpm,rho_c,p1,p2,p3,Re)
if((abs(p1+1) > 1E-8) ) then ! N0 has been specified, determine ld
N0 = p1
tmp1 = 1._wp/(1._wp+bpm)
ld = ((apm*gamma(1.+bpm)*N0)/(rho_a*Q*1E-3))**tmp1
ld = ((apm*gamma(1._wp+bpm)*N0)/(rho_a*Q*1E-3))**tmp1
ld = ld/1E6 ! set units to microns^-1
elseif (abs(p2+1) > 1E-8) then ! lambda=ld has been specified as default
ld = p2 ! should have units of microns^-1
Expand Down Expand Up @@ -710,23 +710,23 @@ subroutine dsd(Q,Re,Np,D,N,nsizes,dtype,rho_a,tk,dmin,dmax,apm,bpm,rho_c,p1,p2,p

if(Re>0) then
ld = 1.5_wp/Re ! units 1/um
fc = (ld*1E6)**(1.+bpm)/(apm*gamma(1+bpm))*exp(-1._wp*(ld*1E6)*(D*1E-6))*1E-12
fc = (ld*1E6)**(1.+bpm)/(apm*gamma(1._wp+bpm))*exp(-1._wp*(ld*1E6)*(D*1E-6))*1E-12
N = fc*rho_a*(Q*1E-3)
elseif (abs(p1+1) > 1E-8) then
! Use N0 default value
N0 = p1
tmp1 = 1._wp/(1._wp+bpm)
fc = ((apm*gamma(1.+bpm)*N0)**tmp1)*(D*1E-6)
fc = ((apm*gamma(1._wp+bpm)*N0)**tmp1)*(D*1E-6)
N = (N0*exp(-1._wp*fc*(1._wp/(rho_a*Q*1E-3))**tmp1)) * 1E-12
elseif (abs(p2+1) > 1E-8) then
! Use default value for lambda
ld = p2
fc = (ld*1E6)**(1._wp+bpm)/(apm*gamma(1+bpm))*exp(-1._wp*(ld*1E6)*(D*1E-6))*1E-12
fc = (ld*1E6)**(1._wp+bpm)/(apm*gamma(1._wp+bpm))*exp(-1._wp*(ld*1E6)*(D*1E-6))*1E-12
N = fc*rho_a*(Q*1E-3)
else
! ld "parameterized" from temperature (carry over from original Quickbeam).
ld = 1220._wp*10._wp**(-0.0245_wp*tc)*1E-6
N0 = ((ld*1E6)**(1._wp+bpm)*Q*1E-3*rho_a)/(apm*gamma(1+bpm))
N0 = ((ld*1E6)**(1._wp+bpm)*Q*1E-3*rho_a)/(apm*gamma(1._wp+bpm))
N = (N0*exp(-ld*D)) * 1E-12
endif

Expand Down

0 comments on commit 047567b

Please sign in to comment.