Skip to content

Commit

Permalink
CHG: trying to add MATLAB tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuMorlighem committed Jul 12, 2024
1 parent c4ee45e commit 031c116
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 109 deletions.
108 changes: 16 additions & 92 deletions .github/ci_scripts/ci_ISSM.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

# Get configuration
# Source config file
if [ $# -ne 1 ]; then
#no config file specified: exit
Expand All @@ -13,21 +12,12 @@ if [ ! -f "$1" ]; then
fi

# Initialize test suite variables (to avoid "-eq: unary operator expected")
MATLAB_TEST=0
PYTHON_TEST=0
JAVASCRIPT_TEST=0
EXAMPLES_TEST=0

# Initialize resource variables (to avoid "i<=: syntax error: operand expected" in for loops)
NUMCPUS_INSTALL=1
NUMCPUS_RUN=1

# Source configuration script
source $1;


## External Packages

# Number of packages
NUMPACKAGES=$(($(echo ${EXTERNALPACKAGES} | wc -w ) / 2))
source ${ISSM_DIR}/etc/environment.sh
Expand Down Expand Up @@ -81,93 +71,27 @@ fi
echo "======================================================"
echo " Compiling ISSM "
echo "======================================================"
if [ $NUMCPUS_INSTALL -gt 1 ]; then
echo "Making with ${NUMCPUS_INSTALL} CPUs"
make -j $NUMCPUS_INSTALL install
else
make install
fi
make -j $NUMCPUS_INSTALL install
if [ $? -ne 0 ]; then
echo "ISSM_COMPILATION failed!"
exit 1
fi

#Make nightlylog dir
mkdir $ISSM_DIR/nightlylog/

# MATLAB tests {{{
if [ $MATLAB_TEST -eq 1 ]; then

# Launch MATLAB and the nightly run script
cat > ${ISSM_DIR}/nightlylog/matlab_run$i.m << EOF
warning off %necessary to avoid a log of several Go for parallel runs
try,
$(if [ "${MATLAB_NROPTIONS}" = "" ]; then
echo "runme('output','nightly','rank',${i},'numprocs',${NUMCPUS_RUN},'quionerror',1);"
else
echo "runme(${MATLAB_NROPTIONS},'output','nightly','rank',${i},'numprocs',${NUMCPUS_RUN},'quionerror',1);"
fi)
catch me,
%An error occured, get report and exit
message=getReport(me)
directory=strsplit(pwd,'/');
fid=fopen([issmdir '/nightlylog/matlaberror.log'], 'at');
fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
fprintf(fid,'%s',message);
fclose(fid);
quit(1);
end
disp('MATLABEXITEDCORRECTLY');
quit(0);
EOF
cd $ISSM_DIR/test/NightlyRun
ls $MATLAB_PATH/bin/
which matlab
$MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath ${ISSM_DIR}/src/m/dev; devpath; addpath ${ISSM_DIR}/nightlylog; matlab_run$i"
if [ $? -ne 0 ]; then
echo "MATLAB returned an error message!"
exit 1
fi
fi
# }}}

# Python tests # {{{
#
# TODO: Figure out why "Running Python test for Rank $i" is printed twice for each CPU
#
if [ $PYTHON_TEST -eq 1 ]; then
# Launch all tests on different CPUs
if [ -z $PYTHONPATH ]; then
export PYTHONPATH="${ISSM_DIR}/src/m/dev"
else
export PYTHONPATH="${ISSM_DIR}/src/m/dev:${PYTHONPATH}"
fi
export PYTHONSTARTUP="${PYTHONPATH}/devpath.py"
export PYTHONUNBUFFERED=1 # We don't want Python to buffer otherwise issm.exe output is not captured
for (( i=1;i<=$NUMCPUS_RUN;i++ ))
do
cd $ISSM_DIR/test/NightlyRun
echo "--------------Running Python test for Rank $i---------------------"
./runme.py --output=nightly --rank=$i --numprocs=$NUMCPUS_RUN $PYTHON_NROPTIONS &> $ISSM_DIR/nightlylog/python_log$i.log &
echo "--------------Running Python test for Rank $i---------------------"
done
echo "======================================================"
echo " Preparing Test scripts "
echo "======================================================"

# Concatenate logs
cd $ISSM_DIR/nightlylog
if [ -f python_log.log ]; then
rm python_log.log
fi
#Prepare MATLAB tests
cat > ${ISSM_DIR}/matlab_ci.m << EOF
% Go to the test directory
cd $ISSM_DIR/test/NightlyRun/
for job in `jobs -p`
do
echo "Waiting on: ${job}"
wait $job
done
% Add ISSM tools to path
addpath('${ISSM_DIR}/src/m/dev');
devpath;
for (( i=1;i<=$NUMCPUS_RUN;i++ ))
do
echo "This is the concatenation phase for rank: python_log$i.log"
cat python_log$i.log >> python_log.log
done
fi
# }}}
% Run tests
echo "runme(${MATLAB_NROPTIONS},'quionerror',1);"
disp('MATLABEXITEDCORRECTLY');
quit(0);
EOF
20 changes: 3 additions & 17 deletions .github/ci_scripts/github_linux_basic
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#--------------------#
# ISSM Configuration #
#--------------------#

ISSM_CONFIG='\
--prefix=${ISSM_DIR} \
--disable-static \
Expand All @@ -26,32 +25,19 @@ ISSM_CONFIG='\
#-------------------#
# External Packages #
#-------------------#
#
#autotools install-linux.sh
#cmake install.sh

EXTERNALPACKAGES="
petsc install-3.21-linux.sh
triangle install-linux.sh
m1qn3 install-linux.sh
semic install.sh
"

#---------#
# Testing #
#---------#

# Test suites
MATLAB_TEST=1
PYTHON_TEST=0
JAVASCRIPT_TEST=0
EXAMPLES_TEST=0

# Number of CPUs used in ISSM compilation
NUMCPUS_INSTALL=8

# Number of CPUs used in the nightly runs
NUMCPUS_RUN=1
#---------#
# Testing #
#---------#

# Nightly run options
MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota')],'id',101:110"
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ jobs:
MATLAB_PATH: ${{ steps.setup-matlab.outputs.matlabroot }}
run: cd .github/ci_scripts && ./ci_ISSM.sh github_linux_basic

- name: Run ISSM MATLAB test
uses: matlab-actions/run-command@v2
with:
command: matlab_ci

- run: echo "This job's status is ${{ job.status }}."

0 comments on commit 031c116

Please sign in to comment.