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

Fix for Sh > 2.* issue, and new environment files and template for running on maths2 (Exeter) #255

Merged
merged 7 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
6 changes: 6 additions & 0 deletions src/extra/env/maths2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
echo loadmodules for maths2 machines

export F90=mpiifort
export CC=mpiicc

export GFDL_MKMF_TEMPLATE=maths2
10 changes: 5 additions & 5 deletions src/extra/python/isca/codebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from isca import GFDL_WORK, GFDL_BASE, GFDL_SOC, _module_directory, get_env_file
from .loghandler import Logger
from .helpers import url_to_folder, destructive, useworkdir, mkdir, cd, git, P, git_run_in_directory
from .helpers import url_to_folder, destructive, useworkdir, mkdir, cd, git, P, git_run_in_directory, check_for_sh_stdout

import pdb

Expand Down Expand Up @@ -137,7 +137,7 @@ def is_clean(self):

@property
def git_commit(self):
return self.git.log('-1', '--format="%H"').stdout.decode('utf8')
return check_for_sh_stdout(self.git.log('-1', '--format="%H"'))

# @property
# def git_diff(self):
Expand All @@ -162,11 +162,11 @@ def write_source_control_status(self, outfile):

# write out the git commit id of GFDL_BASE
file.write("\n\n*---commit hash used for code in GFDL_BASE, including this python module---*:\n")
file.write(gfdl_git.log('-1', '--format="%H"').stdout.decode('utf8'))
check_for_sh_stdout(file.write(gfdl_git.log('-1', '--format="%H"')))

# if there are any uncommited changes in the working directory,
# add those to the file too
source_status = self.git.status("-b", "--porcelain").stdout.decode('utf8')
source_status = check_for_sh_stdout(self.git.status("-b", "--porcelain"))
# filter the source status for changes in specific files
filetypes = ('.f90', '.inc', '.c')
source_status = [line for line in source_status.split('\n')
Expand All @@ -178,7 +178,7 @@ def write_source_control_status(self, outfile):
file.write("*---git status output (only f90 and inc files)---*:\n")
file.write('\n'.join(source_status))
file.write('\n\n*---git diff output---*\n')
source_diff = self.git.diff('--no-color').stdout.decode('utf8')
source_diff = check_for_sh_stdout(self.git.diff('--no-color'))
file.write(source_diff)

def read_path_names(self, path_names_file):
Expand Down
14 changes: 11 additions & 3 deletions src/extra/python/isca/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ def git_run_in_directory(GFDL_BASE_DIR, dir_in):

try:
codedir_git = git.bake('-C', GFDL_BASE_DIR)
git_test = codedir_git.log('-1', '--format="%H"').stdout
git_test = check_for_sh_stdout(codedir_git.log('-1', '--format="%H"'))
baked_git_fn = git.bake('-C', dir_in)
except:
codedir_git = git.bake('--git-dir='+GFDL_BASE_DIR+'/.git', '--work-tree='+GFDL_BASE_DIR)
git_test = codedir_git.log('-1', '--format="%H"').stdout
git_test = check_for_sh_stdout(codedir_git.log('-1', '--format="%H"'))
baked_git_fn = git.bake('--git-dir='+dir_in+'/.git', '--work-tree='+dir_in)

return baked_git_fn
return baked_git_fn

def check_for_sh_stdout(input_exp):
"""Versions of sh>2.* have started returning str types rather than a sh.RunningCommand type. To distinguish these possibilites, this function looks at the output of a sh expression, and asks for stdout and decodes it only if the type is a sh.RunningCommand."""

if type(input_exp)==sh.RunningCommand:
input_exp=input_exp.stdout.decode('utf8')

return input_exp
28 changes: 28 additions & 0 deletions src/extra/python/isca/templates/mkmf.template.maths2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# template for the Intel fortran compiler
# typical use with mkmf
# mkmf -t template.ifc -c"-Duse_libMPI -Duse_netCDF" path_names /usr/local/include
CPPFLAGS = `nc-config --cflags`
NETCDF_LIBS = `nc-config --libs`

# FFLAGS:
# -fpp: Use the fortran preprocessor
# -stack_temps: Put temporary runtime arrays on the stack, not heap.
# -safe_cray_ptr: Cray pointers don't alias other variables.
# -ftz: Denormal numbers are flushed to zero.
# -assume byterecl: Specifies the units for the OPEN statement as bytes.
# -shared-intel: Load intel libraries dynamically
# -i4: 4 byte integers
# -r8: 8 byte reals
# -g: Generate symbolic debugging info in code
# -O2: Level 2 speed optimisations
# -diag-disable 6843:
# This suppresses the warning: `warning #6843: A dummy argument with an explicit INTENT(OUT) declaration is not given an explicit value.` of which
# there are a lot of instances in the GFDL codebase.
FFLAGS = $(CPPFLAGS) -fpp -stack_temps -safe_cray_ptr -ftz -assume byterecl -shared-intel -i4 -r8 -g -O2 -diag-disable 6843 -mcmodel large
#FFLAGS = $(CPPFLAGS) -fltconsistency -stack_temps -safe_cray_ptr -ftz -shared-intel -assume byterecl -g -O0 -i4 -r8 -check -warn -warn noerrors -debug variable_locations -inline_debug_info -traceback
FC = $(F90)
LD = $(F90) $(NETCDF_LIBS)
#CC = mpicc

LDFLAGS = -lnetcdff -lnetcdf -lmpi -shared-intel -lhdf5_hl -lhdf5 -lm -lz -lsz -lbz2 -lxml2 -lcurl
CFLAGS = -D__IFC
4 changes: 2 additions & 2 deletions src/extra/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sh
jinja2
git+git://github.com/marshallward/f90nml.git#egg=f90nml
f90nml
numpy
pandas
xarray
tqdm
tqdm