Commit 8fcb13c8 authored by Joubert, Wayne's avatar Joubert, Wayne
Browse files

Modifications to uptime_monitor, now runs correctly on crest, titan.

parent aa9869dc
CXX = mpCC
ifeq ($(CRAYPE_VERSION),)
CXX = mpCC
else
CXX = CC
endif
CFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK CFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
LFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK LFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
......
#!/usr/bin/env python #!/usr/bin/env python
"""
-------------------------------------------------------------------------------
File: build_executable.x
Author: Arnold Tharrington (arnoldt@ornl.gov)
Modified: Veronica G. Vergara Larrea, Wayne Joubert
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import getopt
import sys
import os import os
import argparse
import shutil import shutil
#import popen2 #import subprocess
import subprocess
# #------------------------------------------------------------------------------
# Author: Arnold Tharrington
# Email: arnoldt@ornl.gov def process_command_line_args():
# National Center for Computational Sciences, Scientific Computing Group. """Get the command line arguments."""
#
# Modified by: Veronica G. Vergara Larrea command_description = (
# National Center for Computational Sciences, User Assistance Group. 'A driver program that builds the binary for the test.')
# p_help = (
# This build the simple fortran program. 'The absolute path to the workspace. This path must have the '
# 'appropiate permissions to permit the user of the test to r, w, and x.')
i_help = (
'The test id string. The build program uses this string to make a '
'unique directory within path_to_workspace. We don\'t want concurrent '
'builds to clobber each other. The submit program uses this string '
'to write the job schedule id to Status/<test_id_string>/job_id.txt')
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main(): def main():
"""Main program for building the executable."""
#
# Get the command line arguments. # Get the command line arguments.
#
try: args = process_command_line_args()
opts,args = getopt.getopt(sys.argv[1:],"hi:p:") path_to_workspace = args.p
#test_id = args.i
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
if opts == []:
usage()
sys.exit()
for o, a in opts:
if o == "-p":
path_to_workspace = a
elif o == "-i":
test_id_string = a
elif o in ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
# Create the temporary workspace. # Create the temporary workspace.
# Save the tempoary workspace for the submit executable. # Save the tempoary workspace for the submit executable.
#
create_tmp_workspace(path_to_workspace) create_tmp_workspace(path_to_workspace)
#
#--Making the binary. # Make the binary.
#
make_exit_status = make_binary(path_to_workspace) make_exit_status = make_binary(path_to_workspace)
if make_exit_status == 0: if make_exit_status == 0:
make_exit_value = 0 make_exit_value = 0
else: else:
...@@ -67,67 +69,52 @@ def main(): ...@@ -67,67 +69,52 @@ def main():
return make_exit_value return make_exit_value
#------------------------------------------------------------------------------
def make_binary(path_to_workspace): def make_binary(path_to_workspace):
"""Execute the make."""
#
# Get the current working directory. # Get the current working directory.
#
cwd = os.getcwd() cwd = os.getcwd()
#
# Get the 2 tail paths in the cwd. # Get the 2 tail paths in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
(dir_head2, dir_tail2) = os.path.split(dir_head1)
# dir_head1, dir_tail1 = os.path.split(cwd)
dir_head2, dir_tail2 = os.path.split(dir_head1)
# Get the path to the Source directory for the application. # Get the path to the Source directory for the application.
#
path_to_source = os.path.join(dir_head2,"Source")
# path_to_source = os.path.join(dir_head2, "Source")
# Now make the path to the build directory. # Now make the path to the build directory.
#
path_to_build_directory = os.path.join(path_to_workspace,"build_directory")
# path_to_build_directory = os.path.join(path_to_workspace, "build_directory")
#Copy Source to build directory.
# # Copy Source to build directory.
shutil.copytree(path_to_source,path_to_build_directory)
shutil.copytree(path_to_source, path_to_build_directory)
#
# Change back to build directory. # Change back to build directory.
#
os.chdir(path_to_build_directory) os.chdir(path_to_build_directory)
# Make executable. # Make executable.
make_command = "./make.sh" make_command = "./make.sh"
make_exit_status = os.system(make_command) make_exit_status = os.system(make_command)
return make_exit_status return make_exit_status
#------------------------------------------------------------------------------
def usage():
print("Usage: build_executable.x [-h|--help] -p <path_to_worspace> -i <test_id_string>")
print("A driver program that the build the binary for the test.")
print()
print("-h, --help Prints usage information.")
print("-p The absolute path to the workspace. This path ")
print(" must have the appropiate permissions to permit ")
print(" the user of the test to r,w, and x. ")
print("-i The test id string. The build program ")
print(" uses this string to make a unique directory ")
print(" within path_to_workspace. We don't want ")
print(" concurrent builds to clobber each other. ")
def create_tmp_workspace(path1): def create_tmp_workspace(path1):
# """Create the workspace dir."""
# Fisrt check to see if the path1 does not already exist.
#
os.makedirs(path1) os.makedirs(path1)
if __name__ == "__main__" : #------------------------------------------------------------------------------
if __name__ == '__main__':
main() main()
#------------------------------------------------------------------------------
#! /usr/bin/env python #! /usr/bin/env python
"""
-------------------------------------------------------------------------------
File: check_executable.x
Author: Arnold Tharrington (arnoldt@ornl.gov)
Modified: Veronica G. Vergara Larrea, Wayne Joubert
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import sys
import os import os
import getopt import argparse
import filecmp
import re import re
#------------------------------------------------------------------------------
def process_command_line_args():
"""Get the command line arguments."""
command_description = (
'A program that checks the results located at <path_to_results>. '
'The check executable must write the status of the results to the '
'file Status/<test_id_string>/job_status.txt')
p_help = 'The absoulte path to the results of a test.'
i_help = 'The test id string.'
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main(): def main():
"""Main program for check operation. Check the correctness of
# the run results and report back.
"""
# Get the command line arguments. # Get the command line arguments.
#
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
for o, a in opts:
if o == "-p":
path_to_results = a
elif o == "-i":
test_id_string = a
elif o == ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
# Get path to the correct results.
#
path_to_correct_results = get_path_to_correct_results()
#
# Compare the results.
#
jstatus = check_results(path_to_results)
# args = process_command_line_args()
# Write the statis of the results to job data file. path_to_results = args.p
# #test_id = args.i
write_to_job_data(path_to_results,jstatus)
# Compare the results.
def get_path_to_correct_results():
cwd = os.getcwd()
# is_passing = check_results(path_to_results)
# Get the head path in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
# # Write the status of the results to job data file.
# This is the path to the correct results.
#
crslts = os.path.join(dir_head1,"Correct_Results")
return crslts
write_to_job_status_file(path_to_results, is_passing)
#------------------------------------------------------------------------------
def check_results(path_to_results): def check_results(path_to_results):
#----------------------------------------------------- """
#Define good and bad results. """
# -
#----------------------------------------------------- # Define good and bad results.
GOOD_RESULTS=1
BAD_RESULTS=0 passing_yes = 1
passing_no = 0
#
# Make the file name paths to numbers squared. # Make the file name paths to numbers squared.
#
file1 = os.path.join(path_to_results,"std.out.txt")
file_obj = open(file1,"r")
alllines = file_obj.readlines()
file_obj.close()
num_failures = -1 file_path = os.path.join(path_to_results, "std.out.txt")
lastline = alllines[-1] if not os.path.exists(file_path):
return passing_no
# Check to make sure job completed file_ = open(file_path, "r")
match = re.search('FINAL',lastline) lines = file_.readlines()
file_.close()
# And if it did, retrieve the number of failures for line in lines:
if match: match = re.search('^Success$', line)
match_failures = re.search('num_failures (\d+)',lastline) if match:
if match_failures: return passing_yes
num_failures = int(match_failures.group(1))
if num_failures == 0: return passing_no
ival = GOOD_RESULTS
else:
ival = BAD_RESULTS
return ival
def write_to_job_data(path_to_results,jstatus): #------------------------------------------------------------------------------
(dir_head1, dir_tail1) = os.path.split(path_to_results) def write_to_job_status_file(path_to_results, is_passing):
(dir_head2, dir_tail2) = os.path.split(dir_head1) """Write the status of the results to job data file."""
file1 = os.path.join(dir_head2,"Status",dir_tail1,"job_status.txt") # Get path.
file1_obj = open(file1,"w")
# Set the string to write to the job_status.txt file. dir_head1, dir_tail1 = os.path.split(path_to_results)
if jstatus == 0: dir_head2, dir_tail2 = os.path.split(dir_head1)
pf = "1" file_path = os.path.join(dir_head2, 'Status', dir_tail1, 'job_status.txt')
elif jstatus == 1:
pf = "0"
elif jstatus >= 2:
pf = "2"
string1 = "%s\n" % (pf)
file1_obj.write(string1) file_ = open(file_path, 'w')
file1_obj.close()
# Create the the string to write.
if is_passing == 0:
indicator = '1'
elif is_passing == 1:
indicator = '0'
elif is_passing >= 2:
indicator = '2'
string_ = '%s\n' % (indicator)
def usage(): # Write the string.
print("Usage: check_executable.x [-h|--help] [-i <test_id_string>] [-p <path_to_results>]")
print("A program that checks the results located at <path_to_results>")
print("The check executable must write the status of the results to the file")
print("Status/<test_id_string>/job_status.txt'.")
print("")
print("-h, --help Prints usage information.")
print("-p <path_to_results> The absoulte path to the results of a test.")
print("-i <test_id_string> The test string unique id.")
file_.write(string_)
file_.close()
#------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == '__main__':
main() main()
#------------------------------------------------------------------------------
#! /bin/bash -l #! /bin/bash -l
#------------------------------------------------------------------------------
#BSUB -q __batchqueue__ #BSUB -q __batchqueue__
#BSUB -J __jobname__ #BSUB -J __jobname__
#BSUB -o __jobname__.o%J #BSUB -o __jobname__.o%J
...@@ -84,13 +85,15 @@ cd $STARTINGDIRECTORY ...@@ -84,13 +85,15 @@ cd $STARTINGDIRECTORY
# Copy the results back to the $RESULTSDIR - # Copy the results back to the $RESULTSDIR -
# - # -
#----------------------------------------------------- #-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR cp -rf $WORKDIR"/"* $RESULTSDIR ### && rm -rf $WORKDIR
#----------------------------------------------------- #-----------------------------------------------------
# Move the batch file name to $RESULTSDIR - # Move the batch file name to $RESULTSDIR -
# - # -
#----------------------------------------------------- #-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR if [ -e __batchfilename__ ] ; then
mv __batchfilename__ $RESULTSDIR
fi
#----------------------------------------------------- #-----------------------------------------------------
# Check the final results. - # Check the final results. -
...@@ -111,3 +114,4 @@ case __resubmitme__ in ...@@ -111,3 +114,4 @@ case __resubmitme__ in
echo "No resubmit";; echo "No resubmit";;
esac esac
#------------------------------------------------------------------------------
#! /bin/bash -l #! /bin/bash -l
#------------------------------------------------------------------------------
#PBS -e __resultsdir__ #PBS -e __resultsdir__
#PBS -o __resultsdir__ #PBS -o __resultsdir__
...@@ -27,7 +28,7 @@ RESULTSDIR="__resultsdir__" ...@@ -27,7 +28,7 @@ RESULTSDIR="__resultsdir__"
UNIQUE_ID_STRING="__unique_id_string__" UNIQUE_ID_STRING="__unique_id_string__"
#----------------------------------------------------- #-----------------------------------------------------
# Enusre that we are in the correct starting - # Ensure that we are in the correct starting -
# directory. - # directory. -
# - # -
#----------------------------------------------------- #-----------------------------------------------------
...@@ -78,13 +79,15 @@ cd $STARTINGDIRECTORY ...@@ -78,13 +79,15 @@ cd $STARTINGDIRECTORY
# Copy the results back to the $RESULTSDIR - # Copy the results back to the $RESULTSDIR -
# - # -
#----------------------------------------------------- #-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR cp -rf $WORKDIR"/"* $RESULTSDIR ### && rm -rf $WORKDIR
#----------------------------------------------------- #-----------------------------------------------------
# Move the batch file name to $RESULTSDIR - # Move the batch file name to $RESULTSDIR -
# - # -
#----------------------------------------------------- #-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR if [ -e __batchfilename__ ] ; then
mv __batchfilename__ $RESULTSDIR
fi
#----------------------------------------------------- #-----------------------------------------------------
# Check the final results. - # Check the final results. -
...@@ -104,3 +107,5 @@ case __resubmitme__ in ...@@ -104,3 +107,5 @@ case __resubmitme__ in
1) 1)
echo "No resubmit";; echo "No resubmit";;
esac esac
#------------------------------------------------------------------------------
#!/usr/bin/env python #!/usr/bin/env python
#============================================================================== """