Skip to content

Move shared python code to a shared directory #18

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
60 changes: 7 additions & 53 deletions tests/higher-order/dome/runDome.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@

import os
import sys
import errno

_TESTS_LIB_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "lib")
sys.path.append(_TESTS_LIB_DIR)

import subprocess
import ConfigParser

import numpy
import netCDF
from math import sqrt

from cism_tests_lib import netCDF
from cism_tests_lib.utils import prep_commands, mkdir_p

# Parse the command line options
# ------------------------------
import argparse
Expand Down Expand Up @@ -57,56 +61,6 @@ def unsigned_int(x):
help="Scales the problem size by 2**SCALE. SCALE=0 creates a 31x31 grid, SCALE=1 "
+"creates a 62x62 grid, and SCALE=2 creates a 124x124 grid.")

# Some useful functions
# ---------------------

# function to make a directory, and not worry if it exists.
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise

# prep the command line functions
def prep_commands(args, config_name):
driver = os.path.abspath(args.executable)

quiet_mod = ''
if args.quiet:
quiet_mod = ' > '+config_name+'.oe'

commands = []
mkdir_p(args.output_dir)
commands.append("cd "+os.path.abspath(args.output_dir))

if args.hpc and (args.parallel > 0):
mpiexec = 'aprun -n ' + str(args.parallel)+" "
elif (args.parallel > 0):
# These calls to os.system will return the exit status: 0 for success (the command exists), some other integer for failure
if os.system('which openmpirun > /dev/null') == 0:
mpiexec = 'openmpirun -np ' + str(args.parallel)+" "
elif os.system('which mpirun > /dev/null') == 0:
mpiexec = 'mpirun -np ' + str(args.parallel)+" "
elif os.system('which aprun > /dev/null') == 0:
mpiexec = 'aprun -n ' + str(args.parallel)+" "
elif os.system('which mpirun.lsf > /dev/null') == 0:
# mpirun.lsf does NOT need the number of processors
mpiexec = 'mpirun.lsf '
else:
print("Unable to execute parallel run!")
print(" Please edit the script to use your MPI run command, or run the model manually with")
print(" something like: mpirun -np 4 ./cism_driver dome.config")
sys.exit(1)
else:
mpiexec = ''

commands.append(mpiexec+driver+" "+config_name+quiet_mod)

return commands


# the main script function
# ------------------------
def main():
Expand Down
Empty file.
File renamed without changes.
49 changes: 49 additions & 0 deletions tests/lib/cism_tests_lib/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import errno
import sys

# function to make a directory, and not worry if it exists.
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise

# prep the command line functions
def prep_commands(args, config_name):
driver = os.path.abspath(args.executable)

quiet_mod = ''
if args.quiet:
quiet_mod = ' > '+config_name+'.oe'

commands = []
mkdir_p(args.output_dir)
commands.append("cd "+os.path.abspath(args.output_dir))

if args.hpc and (args.parallel > 0):
mpiexec = 'aprun -n ' + str(args.parallel)+" "
elif (args.parallel > 0):
# These calls to os.system will return the exit status: 0 for success (the command exists), some other integer for failure
if os.system('which openmpirun > /dev/null') == 0:
mpiexec = 'openmpirun -np ' + str(args.parallel)+" "
elif os.system('which mpirun > /dev/null') == 0:
mpiexec = 'mpirun -np ' + str(args.parallel)+" "
elif os.system('which aprun > /dev/null') == 0:
mpiexec = 'aprun -n ' + str(args.parallel)+" "
elif os.system('which mpirun.lsf > /dev/null') == 0:
# mpirun.lsf does NOT need the number of processors
mpiexec = 'mpirun.lsf '
else:
print("Unable to execute parallel run!")
print(" Please edit the script to use your MPI run command, or run the model manually with")
print(" something like: mpirun -np 4 ./cism_driver dome.config")
sys.exit(1)
else:
mpiexec = ''

commands.append(mpiexec+driver+" "+config_name+quiet_mod)

return commands
124 changes: 0 additions & 124 deletions tests/netCDF.py

This file was deleted.