-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add quickbuild_tests to developer_tests #575
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
#!/usr/bin/env bash | ||
|
||
# DART software - Copyright UCAR. This open source software is provided | ||
# by UCAR, "as is", without charge, subject to all terms of use at | ||
# http://www.image.ucar.edu/DAReS/DART/DART_download | ||
|
||
|
||
# Email build results | ||
TO_EMAIL_ADDRESSES='[email protected]' | ||
# Log results of all quickbuilds and compilers | ||
LOGFILE="all_quickbuilds_results.log" | ||
# Log results of failed builds only | ||
FAILURE_LOGFILE="all_quickbuilds_failures.log" | ||
|
||
# Store compiler arguments in an array | ||
FCS=( $@ ) | ||
|
||
# Check if the script is running in a batch job or interactive session | ||
if [[ -z $PBS_ENVIRONMENT ]]; then | ||
echo "ERROR: You must run this in a batch job" | ||
echo " qsub submit_me.sh" | ||
echo " or an interactive session" | ||
exit 2 | ||
fi | ||
|
||
# If no argument is provided, run with all compilers as default | ||
if [[ "${#FCS[@]}" == 0 ]]; then | ||
FCS=( intel gnu cce nvhpc ) | ||
fi | ||
|
||
# Include current date/time to log files | ||
current_date="$(printf '\n%s\n' "$(date)")" | ||
echo "$current_date" > "$LOGFILE" | ||
echo "$current_date" > "$FAILURE_LOGFILE" | ||
|
||
# Function to run quickbuild.sh for specific compilers | ||
function compiler_operation { | ||
FC="$1" | ||
# Set up DART environment variable and do a cleanup in case DART already exists | ||
export DART="/glade/derecho/scratch/$USER/tmp/$FC/DART" | ||
if [[ -n $FC ]]; then | ||
rm -rf /glade/derecho/scratch/$USER/tmp/$FC | ||
fi | ||
# Create new tmp directory for a specific compiler and clone DART | ||
mkdir /glade/derecho/scratch/$USER/tmp/"$FC" | ||
git clone 'https://github.com/NCAR/DART.git' "$DART" | ||
|
||
# Check if DART directory exists. If not, return an error | ||
if [[ ! -d $DART ]]; then | ||
echo "No DART directory: $DART" | ||
return 1 | ||
fi | ||
|
||
# Specify the mkmf template for each compiler | ||
if [[ $FC == "intel" ]]; then | ||
template_name="mkmf.template.intel.linux" | ||
elif [[ $FC == "gnu" ]]; then | ||
template_name="mkmf.template.gfortran" | ||
elif [[ $FC == "cce" ]]; then | ||
template_name="mkmf.template.cce" | ||
elif [[ $FC == "nvhpc" ]]; then | ||
template_name="mkmf.template.nvhpc" | ||
else | ||
# Return an error for invalid arguments | ||
echo "$FC is not a valid argument. Compiler is not supported on Derecho." | ||
return 1 | ||
fi | ||
hkershaw-brown marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Log the compiler being processed | ||
printf '\nProcessing %s\n' "$FC" | ||
|
||
# Copy appropriate mkmf template to build_templates directory in DART | ||
cp "$DART/build_templates/$template_name" $DART/build_templates/mkmf.template | ||
|
||
# cd into DART. Note that fixsystem, preprocess, and modify input.nml were taken from the current version of build_everything/run_all_quickbuilds.sh | ||
cd $DART | ||
|
||
# Run fixsystem to avoid all make commands from altering mpi_*_utilities_mod.f90 simultaneously | ||
cd assimilation_code/modules/utilities; ./fixsystem $FC | ||
cd - | ||
|
||
# Build preprocess once for the given compiler | ||
pp_dir=$DART/assimilation_code/programs/preprocess | ||
cd $pp_dir | ||
$DART/build_templates/mkmf -x -p $pp_dir/preprocess \ | ||
-a $DART $pp_dir/path_names_preprocess | ||
cd - | ||
|
||
# Modify input.nml files to use local versions of obs_def_mod.f90 and obs_kind_mod.f90 | ||
find . -name input.nml -exec sed -i -e "/^[[:space:]]*#/! s|.*output_obs_def_mod_file.*|output_obs_def_mod_file = './obs_def_mod.f90'|g" \ | ||
-e "/^[[:space:]]*#/! s|.*output_obs_qty_mod_file.*|output_obs_qty_mod_file = './obs_kind_mod.f90'|g" \ | ||
-e "/^[[:space:]]*#/! s|.*output_obs_kind_mod_file.*|output_obs_qty_mod_file = './obs_kind_mod.f90'|g" {} \; | ||
|
||
# Store the current directory and initialize arrays to hold process IDs, directories, and status codes | ||
my_dir=$(pwd) | ||
pids=() | ||
dirs=() | ||
status=() | ||
|
||
# Find all quickbuild.sh executable files and remove './' and 'quickbuild.sh' | ||
files_to_process=( $(find $DART -executable -type f -name quickbuild.sh | sed -E 's#(\./|quickbuild\.sh)##g') ) | ||
|
||
# Iterate over each file to and run quickbuild.sh | ||
for f in "${files_to_process[@]}"; do | ||
# cd to */quickbuild.sh file and run quickbuild.sh in the background | ||
cd $f; ./quickbuild.sh & | ||
# Record the PID and directory of the each process then cd back to starting directory | ||
pids+=( "$!" ) | ||
dirs+=( "$f" ) | ||
cd $my_dir | ||
done | ||
|
||
# Wait for all background processes to finish and record their exit statuses | ||
for pid in ${pids[@]}; do | ||
wait ${pid} | ||
status+=( "$?" ) | ||
done | ||
|
||
# Check the status of each build process and log results | ||
OVERALL_EXIT=0 | ||
i=0 | ||
for st in ${status[@]}; do | ||
# Display failed vs. passed processes | ||
if [[ ${st} -ne 0 ]]; then | ||
log_msg=$(printf '%s\n' "$FC RESULT: $i ${dirs[$i]} FAILED") | ||
echo "$log_msg" | ||
# Indicate at least one failure | ||
OVERALL_EXIT=1 | ||
else | ||
echo "$FC RESULT: $i ${dirs[$i]} PASSED" | ||
fi | ||
((i+=1)) | ||
done | ||
|
||
return "$OVERALL_EXIT" | ||
} | ||
|
||
# Run compiler_operation for each compiler in the background and record each PID | ||
background_processes=( ) | ||
for FC in "${FCS[@]}"; do | ||
compiler_operation "$FC" & | ||
background_processes+=( "$!" ) | ||
done &>"$LOGFILE" | ||
|
||
# Wait for all compiler_operation to finish and record exit statuses | ||
exit_statuses=( ) | ||
for process in "${background_processes[@]}"; do | ||
wait "$process" | ||
exit_statuses+=( "$?" ) | ||
done &>"$LOGFILE" | ||
|
||
# Filter and append all failed builds to all_quickbuilds_failures.log | ||
grep -aE '[[:blank:]]+FAILED[[:blank:]]*$' "$LOGFILE" >> "$FAILURE_LOGFILE" | ||
|
||
# Email build results with 'all_quickbuilds_results.log' and 'all_quickbuilds_failures.log' as file attachments | ||
mail_subject=$(printf 'TEST: Run all quickbuilds results: %s' "$(date)") | ||
echo "$mail_subject" | mail -s "$mail_subject" -a "$LOGFILE" -a "$FAILURE_LOGFILE" $TO_EMAIL_ADDRESSES | ||
|
||
# Teardown: Remove DART directory | ||
for FC in "${FCS[@]}"; do | ||
if [[ -n $FC ]]; then | ||
rm -rf /glade/derecho/scratch/$USER/tmp/"$FC" | ||
fi | ||
done | ||
|
||
# For testing purposes, indicate when script is done | ||
echo "Done" | ||
|
||
# Check for any failed operations | ||
for exit_status in "${exit_statuses[@]}"; do | ||
if [[ $exit_status -ne 0 ]]; then | ||
exit 1 | ||
fi | ||
done | ||
|
||
|
||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to setting the template_name, you'll need to load the compiler module
module load gcc for gnu
module load intel for intel
module load nvhpc for nvhpc