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

Fb matrix divider #328

Merged
merged 26 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
98c5702
Added boundary checks to the SMC grid input files for ww3_grid,
UKMO-lsampson Jun 8, 2020
71b9ba9
Fb 360 calendar (#8)
ukmo-juan-castillo Jul 16, 2020
6c42d17
RTD support for ww3_boun[dc] (#10)
ukmo-ccbunney Jul 28, 2020
5c361aa
Fb coupling time (#9)
ukmo-juan-castillo Jul 30, 2020
cc34122
Merge remote-tracking branch 'upstream/staging' into develop
Aug 7, 2020
33a7af3
bug fix for ukmet development
Aug 7, 2020
68c3c96
Merge remote-tracking branch 'upstream/develop' into develop
Oct 19, 2020
663d983
Merge remote-tracking branch 'upstream/develop' into develop
Oct 26, 2020
d4887f5
Merge remote-tracking branch 'upstream/develop' into develop
Jan 11, 2021
dc0cea9
Merge remote-tracking branch 'upstream/develop' into develop
Mar 4, 2021
832a6ea
add the matrix subsetter
Mar 9, 2021
115ceb1
clean-up
Mar 9, 2021
4427883
clean up
Mar 9, 2021
8b498e8
add another script which separate serial and parallel jobs and divide…
Mar 9, 2021
e1cb650
modify the script to remove ../model? after test completion.
Mar 10, 2021
88ee4f0
bug fixes and adding ww3_tp2.17 to list_heavy
Mar 11, 2021
3c74387
add if statement to remove matrix? and model?
Mar 19, 2021
073e47d
Update matrix_divider_p.sh
aliabdolali Mar 19, 2021
b07cfbb
Merge remote-tracking branch 'upstream/develop' into fb_matrix_divider
Mar 19, 2021
cf02516
Merge remote-tracking branch 'upstream/develop' into fb_matrix_divider
Mar 19, 2021
6578878
Merge remote-tracking branch 'upstream/develop' into fb_matrix_divider
Mar 19, 2021
799a8c4
Merge remote-tracking branch 'upstream/develop' into fb_matrix_divider
Mar 22, 2021
5c5bbff
put if check for ../model? inside matrix? loop
Mar 22, 2021
62b756b
fix the bug for sed for model?
Mar 22, 2021
8d7107a
final fix for extra model? removal
Mar 22, 2021
2e5216e
add 2.21 to the list_heavy
Mar 22, 2021
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ manual/*.toc
manual/*.out
manual/*.dvi
manual/*.pdf
model?
model??
regtests/list*
regtests/before
regtests/matrix*
regtests/*/work*
regtests/*/input*/*.nc
Expand Down
128 changes: 128 additions & 0 deletions regtests/bin/matrix_divider_p.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash
# --------------------------------------------------------------------------- #
# matrix_divider simply divides the main matrix into subsets with a given #
# number of test (i.e. maxlist1 for mpi tests and maxlist2 for serial tests) #
# #
# Remarks: #
# - Once the matrix is generated, this script can be execute. The user should #
# define the maxlist and this script divide the matrix into matrix? and #
# submit the job using sbatch. #
# #
# Ali Abdolali #
# August 2018 #
# March 2021 #
# #
# Copyright 2013 National Weather Service (NWS), #
# National Oceanic and Atmospheric Administration. All rights #
# reserved. WAVEWATCH III is a trademark of the NWS. #
# No unauthorized use without permission. #
# #
# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
# 1. clean up and definitions #
# --------------------------------------------------------------------------- #
cp matrix matrix.tmp
HOME=${PWD%/*}

maxlist1=48
maxlist2=92

#Put the job requirement/spec in "before"
sed -e "/run_test/,\$d" matrix.tmp > before
#Put the list of tests in "list"
command egrep 'ww3_tp2.14|ww3_tp2.17|ww3_tp2.21' matrix.tmp | cat >> list_heavy
awk '!/ww3_tp2.14/' matrix.tmp > tmpfile && mv tmpfile matrix.tmp
awk '!/ww3_tp2.17/' matrix.tmp > tmpfile && mv tmpfile matrix.tmp
awk '!/ww3_tp2.21/' matrix.tmp > tmpfile && mv tmpfile matrix.tmp
command egrep 'mpirun|mpiexec|MPI_LAUNCH' matrix.tmp | cat >> list_mpi
awk '!/mpirun|mpiexec|MPI_LAUNCH/' matrix.tmp > tmpfile && mv tmpfile matrix.tmp
split -dl $maxlist1 list_mpi list_mpi_
rm list_mpi
matrixno1=$(ls list_mpi_* | wc -l)
echo "Total nummber of matrix with parallel tests = $(($matrixno1 + 1)); each includes $maxlist1 tests"
command egrep 'run_test' matrix.tmp | cat >> list_serial
split -dl $maxlist2 list_serial list_serial_
rm list_serial
matrixno2=$(ls list_serial_* | wc -l)
echo "Total nummber of matrix with serial test = $matrixno2; each includes $maxlist2 tests"
rm matrix.tmp

# -------------------------------|ww3_tp2.21|ww3_tp2.21-------------------------------------------- #
# 2. Divide and dump in subsets #
# --------------------------------------------------------------------------- #
# parallel jobs
count=0
for i in `seq -f '%02g' 0 "$((matrixno1 - 1))"`; do
#echo $i
#Replace matrix.out > matrix?.out, model > model?
(( count = count + 1 ))
if [ -f "matrix${count}" ]; then rm -f matrix${count}; fi
cat before >> matrix$count
cat list_mpi_$i >> matrix$count
sed -i 's/'matrix.out'/'matrix${count}.out'/gI' matrix$count
sed -i 's/'model'/'model${count}'/gI' matrix$count
echo " echo ' '" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' * end of WAVEWATCH III matrix$count of regression tests *'" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' '" >> matrix$count
echo "rm -rf ${HOME}/model${count}" >> matrix$count
#make sure ../model$count does not exist and copy a fresh copy
awk '1;/cd/ && !x {print " cp -r ../model ../model'$count'"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count
awk '1;/cd/ && !x {print " if [ -d ../model'${count}' ]; then rm -rf ../model'${count}'; fi"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count

echo " matrix$count prepared"
done

#serial jobs
for i in `seq -f '%02g' 0 "$((matrixno2 - 1))"`; do
#echo $i
#Replace matrix.out > matrix?.out, model > model?
(( count = count + 1 ))
if [ -f "matrix${count}" ]; then rm -f matrix${count}; fi
cat before >> matrix$count
cat list_serial_$i >> matrix$count
sed -i 's/'matrix.out'/'matrix${count}.out'/gI' matrix$count
sed -i 's/'model'/'model${count}'/gI' matrix$count
echo " echo ' '" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' * end of WAVEWATCH III matrix$count of regression tests *'" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' '" >> matrix$count
echo "rm -rf ${HOME}/model${count}" >> matrix$count
#make sure ../model$count does not exist and copy a fresh copy
awk '1;/cd/ && !x {print " cp -r ../model ../model'$count'"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count
awk '1;/cd/ && !x {print " if [ -d ../model'${count}' ]; then rm -rf ../model'${count}'; fi"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count
echo " matrix$count prepared"
done

#ww3_tp2.14 is separated, as it has dependency.
#ww3_tp2.17 and ww3_tp2.21 is separated, as it takes a long time to finish
(( count = count + 1 ))
if [ -f "matrix${count}" ]; then rm -f matrix${count}; fi
cat before >> matrix$count
cat list_heavy >> matrix$count
sed -i 's/'matrix.out'/'matrix${count}.out'/gI' matrix$count
sed -i 's/'model'/'model${count}'/gI' matrix$count
echo " echo ' '" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' * end of WAVEWATCH III matrix$count of regression tests *'" >> matrix$count
echo " echo ' **************************************************************'" >> matrix$count
echo " echo ' '" >> matrix$count
echo "rm -rf ${HOME}/model${count}" >> matrix$count
#make sure ../model$count does not exist and copy a fresh copy
awk '1;/cd/ && !x {print " cp -r ../model ../model'$count'"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count
awk '1;/cd/ && !x {print " if [ -d ../model'${count}' ]; then rm -rf ../model'${count}'; fi"; x=1;}' matrix$count > tmpfile && mv tmpfile matrix$count
echo " matrix$count prepared"



rm before
rm list*

echo "file matrix is divided into $count subsets ...."

# --------------------------------------------------------------------------- #
# End to matrix_divider #
# --------------------------------------------------------------------------- #