forked from NOAA-GFDL/NDSL
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
True mixed precision #55
Comments
Use case in subroutine conden(p,thl,qt,th,qv,ql,qi,rvls,id_check)
implicit none
real, intent(in) :: p
real, intent(in) :: thl
real, intent(in) :: qt
real, intent(out) :: th
real, intent(out) :: qv
real, intent(out) :: ql
real, intent(out) :: qi
real, intent(out) :: rvls
integer, intent(out) :: id_check
! Local
real*8 :: tc
real :: temps,ps
real*8 :: leff,nu,qc
integer :: iteration
real*8 :: qs ! Saturation specific humidity
tc = thl*exnerfn(p)
! nu = max(min((258._r8-tc)/20._r8,1.0_r8),0.0_r8) ! ice fraction of condensate
nu = ICE_FRACTION(real(tc),0.0,0.0)
leff = (1._r8- nu)*xlv + nu*xls ! effective latent heat
temps = tc
ps = p
qs = GEOS_QSAT(temps, ps/100.)
rvls = qs
if ( qs .ge. qt ) then ! no condensation
id_check = 0
qv = qt
qc = 0.
ql = 0.
qi = 0.
th = thl !tc/exnerfn(p)
else ! condensation
do iteration = 1,10
temps = temps + ( (tc-temps)*cp/leff + qt - rvls )/( cp/leff + ep2*leff*rvls/(r*temps*temps) )
qs = GEOS_QSAT(temps, ps/100.)
rvls = qs
end do
qc = max( qt-qs, 0._r8 )
qv = qt - qc
ql = qc*(1._r8 - nu)
qi = nu*qc
th = temps/exnerfn(p)
if ( abs((temps-(leff/cp)*qc)-tc) .ge. 1._r8 ) then
id_check = 1
else
id_check = 0
end if
end if
return
end subroutine conden |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Aer Activation port shows the usage of 64-bit literals in an otherwise 32-bit code
Until now we were operating under the assumption of a fully 32-bit or fully 64-bit precision calculation, with the exception of the occasional upcasting of a Field to keep precision up.
With this finding, we are back to the drawing board.
Fortran uses a "variable precision is the precision of the operation" technique to define ops precision between literals and variables. We could try to replicate this in GT4Py/DaCe to force "best precision" on single ops.
Another option is to work at NDSL level and have an override on a particular stencil to be at 64-bit, if GT4Py/DaCe allows for it.
Parent: GEOS-ESM/SMT-Nebulae#36
The text was updated successfully, but these errors were encountered: