Skip to content

Commit

Permalink
Made modifications to codebase and compile.sh so that single precisio…
Browse files Browse the repository at this point in the history
…n can be requested through the codebase object, but double is default. This does not properly work yet though, as -r8 must be removed from the mkmf.template file to get single-precision reals. Have yet to figure out how to do that with the front-end, but manual tests with held-suarez work fine.
  • Loading branch information
sit23 committed Feb 11, 2020
1 parent 6b608ea commit efd0195
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/extra/python/isca/codebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(self, repo=None, commit=None, directory=None, storedir=P(GFDL_WORK,
self.path_names = []
self.path_names_to_append = [] #Adding option so that individual path names can be appended to existing lists
self.compile_flags = [] # users can append to this to add additional compiler options
self.precision_compile_flags = ['-DOVERLOAD_C8'] #Default is to use double precision. User can change to single precision using cb.use_single_precision() before compile step

@property
def code_is_available(self):
Expand Down Expand Up @@ -232,6 +233,7 @@ def compile(self, debug=False, optimisation=None):
# compile_flags.append('-O%d' % optimisation)

compile_flags.extend(self.compile_flags)
compile_flags.extend(self.precision_compile_flags)
compile_flags_str = ' '.join(compile_flags)

# get path_names from the directory
Expand Down Expand Up @@ -267,6 +269,15 @@ def enable_fftw3(self):
self.executable_name = self.executable_name.strip('.x')+'_fftw.x'
self.builddir = P(self.workdir, 'build', self.executable_name.split('.')[0])

def use_single_precision(self):
self.log.info('Going to use single_precision')
self.precision_compile_flags = ['-DOVERLOAD_C4', '-DOVERLOAD_R4']
self.executable_name = self.executable_name.strip('.x')+'_single.x'
self.builddir = P(self.workdir, 'build', self.executable_name.split('.')[0])




class IscaCodeBase(CodeBase):
"""The Full Isca Stack.
This includes moist dynamics and the RRTM radiation scheme.
Expand Down
4 changes: 2 additions & 2 deletions src/extra/python/isca/templates/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ if [ $debug == True ]; then
echo "Compiling in debug mode"

# execute mkmf to create makefile
cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 {{compile_flags}}"
cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML {{compile_flags}}"
$mkmf -a $sourcedir -t $template_debug -p $executable -c "$cppDefs" $pathnames $sourcedir/shared/include $sourcedir/shared/mpp/include

else

# execute mkmf to create makefile
cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML -DOVERLOAD_C8 {{compile_flags}}"
cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DINTERNAL_FILE_NML {{compile_flags}}"

$mkmf -a $sourcedir -t $template -p $executable -c "$cppDefs" $pathnames $sourcedir/shared/include $sourcedir/shared/mpp/include

Expand Down

0 comments on commit efd0195

Please sign in to comment.