Adding ability to compile Isca in single-precision at the python-script level - #309
Draft
sit23 wants to merge 10 commits into
Draft
Adding ability to compile Isca in single-precision at the python-script level#309sit23 wants to merge 10 commits into
sit23 wants to merge 10 commits into
Conversation
…ses a combination of Iscas in-built macros with overload_c4 etc, whilst maintaining other default flags. (cherry picked from commit d04d164)
(cherry picked from commit 5751b16)
…ountered with the simple cloud fortran files, which had missed a few file-exists imports from fms-mod. Also lcl.f90 explicitly defined variables as double precision, which caused problems when variables were inputted to its functions as single. Now changed to real so that compiler chooses the representation of real. (cherry picked from commit ec5992a)
… precision, but should not be there for single precision. Do not currently have a dynamic way of editing that mkmf template file, so added feature to choose different mkmf template file for single precision. Format is just same name as current mkmf template file with _simple added at the end. (cherry picked from commit 8fa14bb)
(cherry picked from commit 03d555a)
single_prec's own final commit ("Needs new env file to point to new
mkmf file") never actually delivered one - cb.use_single_precision()
appends '_single' to whatever GFDL_ENV file is loaded, but no
src/extra/env/maths2_single ever existed, so the feature wasn't
actually runnable even on the branch's own target machine (maths2).
Adding it now, mirroring the existing maths2 env file.
Also adding an equivalent ubuntu_conda_single/mkmf.template pair,
needed to exercise this locally on this machine's GFDL_ENV
(ubuntu_conda uses gfortran, which needs the same -fdefault-real-8/
-fdefault-double-8 removal for single precision as maths2's -r8) -
and generically useful given ubuntu_conda is the common dev
environment, not just this machine.
Documents trip_test bit-reproducibility confirmation of the lcl.F90/cloud_simple changes on the default double-precision build (held_suarez, and socrates_aquaplanet_cloud which actually exercises the simple-cloud scheme at runtime), plus a real 5-day held_suarez run confirming cb.use_single_precision() compiles, links, and runs to completion with physically sane output. Companion to PHYSICS_PORT_VALIDATION.md and NUMERICS_PORT_VALIDATION.md on the unrelated uob_fftw_sit23_*_2026 branches.
SINGLE_PREC_PORT_VALIDATION.md's content belongs in the PR discussion, not committed alongside the source.
…rison Documents cb.use_single_precision(), how to use it, and confirms via the existing trip_test validation that it doesn't change the default double-precision build. Adds a 10-year Held-Suarez comparison (T42L25, 32 cores, single vs double precision, run sequentially for a fair timing comparison): single precision was about 21% faster (6558s vs 8255s integration time), and produced a statistically indistinguishable long-term climate - zonal-mean T/U plots and grid-point difference statistics included.
Socrates defines its own real kind (r_def) throughout its radiative transfer code, independent of the rest of Isca. This is invisible in the default double-precision build (r_def is also double, so nothing needs converting at the socrates_interface.F90 boundary), but use_single_precision() only changes the rest of Isca - Socrates' r_def stays double, so the interface ends up mixing single- and double-precision reals in the same argument lists and fails to compile. Confirmed empirically: SocratesCodeBase + use_single_precision() fails with real type-mismatch errors in socrates_interface.o.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #265.
Adds
cb.use_single_precision()— aCodeBasemethod to compile Iscawith single-precision (4-byte) reals instead of the default double
precision, needed because e.g. Intel's
-r8/gfortran's-fdefault-real-8must be present for double precision and absentfor single, so a separate mkmf template + env file is selected rather
than just adding a compile flag.
Rebased from the original
single_precbranch (#265, April 2024) ontocurrent master, with two fixes:
-DINTERNAL_FILE_NMLto
-DINTERNAL_FILE_NMwhile removing a now-redundant hardcoded-DOVERLOAD_C8fromcompile.sh- fixed.use_single_precision()needs asrc/extra/env/<GFDL_ENV>_singlefile, but none was ever added (not even for Intel/maths2, the
original target) - added
maths2_single, plus a gfortran/ubuntu_conda_singlevariant so this isn't Intel-only anymore.Also fixes a real, still-present bug in current master: all 4
cloud_simple/*.F90files callfile_exist('input.nml')in their#else(non-INTERNAL_FILE_NML) branch without importing it -currently invisible only because
compile.shalways hardcodes-DINTERNAL_FILE_NML.See
SINGLE_PREC_PORT_VALIDATION.mdfor full validation:trip_testconfirms the default double-precision build is unaffected
(
held_suarez,socrates_aquaplanet_cloud- the latter chosen becauseit actually exercises the changed
cloud_simple/lcl.F90code atruntime), and a real 5-day single-vs-double precision run confirms
use_single_precision()compiles, links, and runs to completion withphysically sane output.