Skip to content
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

Consistent double precision definitions #2099

Open
wants to merge 22 commits into
base: release-v4.6.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5b024c0
Force fail on genexp in defines
islas May 31, 2024
7c6e773
Rewrite the defines to not use genexp
islas May 31, 2024
980aca8
Move internal flags and compile definitions to variables rather than …
islas Apr 24, 2024
6b9d27e
Make sure hydro gets all the flags similar to original cmake build
islas Jul 30, 2024
4dda109
Prepare cmake build to not have core selection
islas Aug 1, 2024
bee8ddd
Make sure appropriate selection of option for non-ARW cores
islas Aug 1, 2024
4e30de1
Shortcut selections for other cores
islas Aug 1, 2024
5598e7c
Generalize the sanitization logic for stanzas
islas Aug 1, 2024
96930f5
Create properties for flag and defines organization
islas Jul 30, 2024
0203d61
Fine-tuned control of compile flags
islas Aug 1, 2024
86c3707
Don't force specific define able to come from stanza
islas Aug 1, 2024
1769477
Allow for regular defines to be passed in
islas Aug 1, 2024
6d75b15
Create configuration define for double precision
islas Aug 23, 2024
1823bc5
Replace all instances of #if (RWORDSIZE == 4) with equivalent #ifndef…
islas Aug 23, 2024
ab44106
Replace all instances of #if (RWORDSIZE == 8) with equivalent #ifdef …
islas Aug 23, 2024
1b5b1d7
Replace other less common contructs of querying double precision
islas Aug 23, 2024
eaf8ace
Replace all #if ( RWORDSIZE == DWORDSIZE ) with equivalend #ifdef DOU…
islas Aug 23, 2024
ef76c68
Change usage of RWORDSIZE in build to use DOUBLE_PRECISION definition
islas Aug 23, 2024
8fc1022
Updates to ensure CMake build works
islas Aug 26, 2024
18b7eba
Ensure old behavior is adhered to
islas Aug 27, 2024
0d4a21a
Remove sed rewrite of io flags
islas Aug 27, 2024
aab97e9
Wrap string expansion to evaluate properly
islas Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
646 changes: 430 additions & 216 deletions CMakeLists.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ em_real : wrf
ln -sf ../../run/ishmael-qi-qr.bin . ; \
ln -sf ../../run/BROADBAND_CLOUD_GODDARD.bin . ; \
ln -sf ../../run/STOCHPERT.TBL . ; \
if [ $(RWORDSIZE) -eq 8 ] ; then \
if [ -n "$(DOUBLE_PRECISION)" ] ; then \
ln -sf ../../run/ETAMPNEW_DATA_DBL ETAMPNEW_DATA ; \
ln -sf ../../run/ETAMPNEW_DATA.expanded_rain_DBL ETAMPNEW_DATA.expanded_rain ; \
ln -sf ../../run/RRTM_DATA_DBL RRTM_DATA ; \
Expand Down Expand Up @@ -677,7 +677,7 @@ em_real : wrf
ln -sf ../../run/ishmael-qi-qr.bin . ; \
ln -sf ../../run/BROADBAND_CLOUD_GODDARD.bin . ; \
ln -sf ../../run/STOCHPERT.TBL . ; \
if [ $(RWORDSIZE) -eq 8 ] ; then \
if [ -n "$(DOUBLE_PRECISION)" ] ; then \
ln -sf ../../run/ETAMPNEW_DATA_DBL ETAMPNEW_DATA ; \
ln -sf ../../run/ETAMPNEW_DATA.expanded_rain_DBL ETAMPNEW_DATA.expanded_rain ; \
ln -sf ../../run/RRTM_DATA_DBL RRTM_DATA ; \
Expand Down
10 changes: 10 additions & 0 deletions arch/Config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$sw_compileflags="";
$sw_opt_level="";
$sw_rwordsize="\$\(NATIVE_RWORDSIZE\)";
$sw_promotion="";
$sw_rttov_flag = "" ;
$sw_rttov_inc = "" ;
$sw_rttov_path = "" ;
Expand Down Expand Up @@ -228,6 +229,10 @@
{
$sw_config_line=substr( $ARGV[0], 13 ) ;
}
if ( substr( $ARGV[0], 1, 6 ) eq "rword=" )
{
$sw_rwordsize=substr( $ARGV[0], 7 ) ;
}
shift @ARGV ;
}

Expand Down Expand Up @@ -316,6 +321,10 @@
}

$sw_rwordsize = "8" if ( $sw_wrfplus_core eq "-DWRFPLUS=1" );
if ( $sw_rwordsize eq "8" )
{
$sw_promotion = "-DDOUBLE_PRECISION" ;
}

# A separately-installed ESMF library is required to build the ESMF
# implementation of WRF IOAPI in external/io_esmf. This is needed
Expand Down Expand Up @@ -634,6 +643,7 @@
$_ =~ s/CONFIGURE_LDFLAGS/$sw_ldflags/g ;
$_ =~ s/CONFIGURE_COMPILEFLAGS/$sw_compileflags/g ;
$_ =~ s/CONFIGURE_RWORDSIZE/$sw_rwordsize/g ;
$_ =~ s/CONFIGURE_PROMOTION/$sw_promotion/g ;
$_ =~ s/CONFIGURE_FC/$sw_time $sw_fc/g ;
$_ =~ s/CONFIGURE_CC/$sw_cc/g ;
$_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ;
Expand Down
63 changes: 13 additions & 50 deletions arch/configure_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I )

referenceVar = re.compile( r"[$]([(])?(\w+)(?(1)[)])", re.I )
compileObject = re.compile( r"(\W)-c(\W)" )
compileObject = re.compile( r"(\W|^)-c(\W|$)" )
configureRepl = re.compile( r"(\W|^)CONFIGURE_\w+(\W|$)" )

class Stanza():

Expand Down Expand Up @@ -160,52 +161,9 @@ def sanitize( self ) :
self.dereference( "FCBASEOPTS" )

# Remove rogue compile commands that should *NOT* even be here
keysToSanitize = [
"ARFLAGS","ARFLAGS",
"CC",
"CFLAGS_LOCAL",
"CFLAGS",
"COMPRESSION_INC",
"COMPRESSION_LIBS",
"CPP",
"CPPFLAGS",
"DM_CC",
"DM_FC",
"ESMF_LDFLAG",
"F77FLAGS",
"FC",
"FCBASEOPTS_NO_G",
"FCBASEOPTS",
"FCOPTIM",
"FCSUFFIX",
"FDEFS",
"FFLAGS",
"FNGFLAGS",
"FORMAT_FIXED",
"FORMAT_FREE",
"LD",
"LDFLAGS_LOCAL",
"LDFLAGS",
"MODULE_SRCH_FLAG",
"RLFLAGS",
"SCC",
"SFC",
"TRADFLAG",
]

for keyToSan in keysToSanitize :
if keyToSan in self.kvPairs_ :
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_L", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMP_I", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FC", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CC", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_FDEFS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_MPI", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_COMPAT_FLAGS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_CPPFLAGS", "" )
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "CONFIGURE_TRADFLAG", "" )

self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
for keyToSan in self.kvPairs_.keys() :
self.kvPairs_[ keyToSan ] = configureRepl.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()


# Now fix certain ones that are mixing programs with flags all mashed into one option
Expand Down Expand Up @@ -546,6 +504,7 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD

configStanza = cmakeToolChainTemplateLines.format(
ARCH_LOCAL=stanza.kvPairs_["ARCH_LOCAL"],
LDFLAGS_LOCAL=stanza.kvPairs_["LDFLAGS_LOCAL"],
BYTESWAPIO=stanza.kvPairs_["BYTESWAPIO"],
CFLAGS_LOCAL=stanza.kvPairs_["CFLAGS_LOCAL"],
DM_CC=stanza.kvPairs_["DM_CC"],
Expand Down Expand Up @@ -575,8 +534,12 @@ def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsD

def projectSpecificOptions( options, stanzaCfg ) :
coreOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CORE_OPTIONS", "WRF_CORE" )
nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 )
caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" )
if coreOption == "ARW" :
nestingOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_NESTING_OPTIONS", "WRF_NESTING", 1 )
caseOption = getStringOptionSelection( options.sourceCMakeFile, "WRF_CASE_OPTIONS", "WRF_CASE" )
else :
nestingOption = "NONE"
caseOption = "NONE"

# These are yes
yesValues = [ "yes", "y", "true", "1" ]
Expand Down Expand Up @@ -625,4 +588,4 @@ def projectSpecificOptions( options, stanzaCfg ) :
return additionalOptions

if __name__ == '__main__' :
main()
main()
Loading