Index: /issm/trunk-jpl/externalpackages/msmpi/install-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/msmpi/install-static.sh	(revision 27944)
+++ /issm/trunk-jpl/externalpackages/msmpi/install-static.sh	(revision 27944)
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Creates a local MS-MPI directory to be used for supplying MPI headers files 
+# and libraries to ISSM configuration and certain external packages.
+#
+# Assumes that Microsoft MPI and MPI SDK have been installed. To do so,
+# - Navigate to https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi
+# - Under the 'MS-MPI Downloads' heading, click the link for 
+#	'MS-MPI v<version>', where <version> is the latest version available (as of 
+#	this writing, 10.1.2)
+# - Click the 'Download' button
+# - Make sure both boxes are checked
+# - Click the 'Save File' button in each prompt
+# - When the downloads are complete, run each installer
+#
+# TODO:
+# - Commit Microsoft MPI and Microsoft SDK installers or source code to 
+#	external packages source repository, then update this documentation to note 
+#	that they are available
+# - Attempt to download Microsoft MPI and Microsoft SDK installers or source 
+#	code and (compile and) install with this script
+# - Alternatively, instruct users to install MSYS2 MinGW 64-bit MS-MPI package 
+#	with,
+#
+#		pacman -S mingw-w64-x86_64-msmpi
+#
+# remove this script, its parent directory, and references to it from 
+# configuration files in $ISSM_DIR/jenkins directory and documentation
+#
+
+
+## Constants
+#
+PREFIX="${ISSM_DIR}/externalpackages/msmpi/install"
+
+MSMPI_BIN_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files/Microsoft MPI/Bin"))
+MSMPI_INC_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files (x86)/Microsoft SDKs/MPI/Include"))
+MSMPI_LIB="/c/Windows/System32/msmpi.dll"
+MSMPI_LIC_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files (x86)/Microsoft SDKs/MPI/License"))
+
+# Cleanup
+rm -rf ${PREFIX}
+mkdir -p ${PREFIX} ${PREFIX}/bin ${PREFIX}/include ${PREFIX}/lib ${PREFIX}/license
+
+# Copy MS-MPI binaries to 'bin' directory
+cp -R ${MSMPI_BIN_DIR}/* ${PREFIX}/bin
+
+# Copy MS-MPI header files to 'include' directory
+cp ${MSMPI_INC_DIR}/mpi.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpi.f90 ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpif.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpio.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/x64/mpifptr.h ${PREFIX}/include
+
+# Generate static copy of MS-MPI library
+gendef ${MSMPI_LIB}
+dlltool -d msmpi.def -l libmsmpi.a -D ${MSMPI_LIB}
+
+# Copy MS-MPI library to 'lib' directory
+cp libmsmpi.a ${PREFIX}/lib
+cp libmsmpi.a ${PREFIX}/lib/msmpi.a
+cp libmsmpi.a ${PREFIX}/lib/msmpi.lib
+
+# Copy MS-MPI license files to 'license' directory
+cp -R ${MSMPI_LIC_DIR}/* ${PREFIX}/license
Index: /issm/trunk-jpl/externalpackages/msmpi/install.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/msmpi/install.sh	(revision 27943)
+++ /issm/trunk-jpl/externalpackages/msmpi/install.sh	(revision 27944)
@@ -34,17 +34,18 @@
 PREFIX="${ISSM_DIR}/externalpackages/msmpi/install"
 
+MSMPI_BIN_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files/Microsoft MPI/Bin"))
+MSMPI_INC_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files (x86)/Microsoft SDKs/MPI/Include"))
 MSMPI_LIB="/c/Windows/System32/msmpi.dll"
-MSMPI_INC=$(cygpath -u $(cygpath -ms "/c/Program Files (x86)/Microsoft SDKs/MPI/Include"))
 
 # Cleanup
 rm -rf ${PREFIX}
-mkdir -p ${PREFIX} ${PREFIX}/include ${PREFIX}/lib
+mkdir -p ${PREFIX} ${PREFIX}/bin ${PREFIX}/include ${PREFIX}/lib
 
 # Copy MS-MPI header files to 'include' directory
-cp ${MSMPI_INC}/mpi.h ${PREFIX}/include
-cp ${MSMPI_INC}/mpi.f90 ${PREFIX}/include
-cp ${MSMPI_INC}/mpif.h ${PREFIX}/include
-cp ${MSMPI_INC}/mpio.h ${PREFIX}/include
-cp ${MSMPI_INC}/x64/mpifptr.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpi.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpi.f90 ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpif.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/mpio.h ${PREFIX}/include
+cp ${MSMPI_INC_DIR}/x64/mpifptr.h ${PREFIX}/include
 
 # Copy MS-MPI library to 'lib' directory
Index: /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi-static.sh	(revision 27944)
+++ /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi-static.sh	(revision 27944)
@@ -0,0 +1,88 @@
+#!/bin/bash
+set -u # NOTE: Do not set -e as it will cause this script to fail when there are errors in underlying Python scripts
+
+# NOTE:
+# - You must install various needed packages with,
+#
+#		pacman -S mingw-w64-x86_64-toolchain python
+#
+# - You must use MSYS2 MinGW 64-bit version of cmake to be able to install 
+#	external packages correctly,
+#
+#		pacman -R mingw-w64-x86_64-cmake
+#
+# Sources:
+# - https://gitlab.com/petsc/petsc/-/issues/820#note_487483240
+#
+
+## Constants
+#
+VER="3.14.6"
+
+MAKEFILE_GENERATOR='-G "MSYS Makefiles"'
+PETSC_ARCH="arch-mswin-c-opt"
+PETSC_DIR="${ISSM_DIR}/externalpackages/petsc/src" # DO NOT CHANGE THIS
+PREFIX="${ISSM_DIR}/externalpackages/petsc/install" # Set to location where external package should be installed
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/petsc-lite-${VER}.tar.gz" "petsc-${VER}.tar.gz"
+
+# Unpack source
+tar -zxvf petsc-${VER}.tar.gz
+
+# Cleanup
+rm -rf ${PREFIX} ${PETSC_DIR}
+mkdir -p ${PETSC_DIR}
+
+# Move source to $PETSC_DIR
+mv petsc-${VER}/* ${PETSC_DIR}
+rm -rf petsc-${VER}
+
+# Patch source
+sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/python3|' ${PETSC_DIR}/config/configure.py
+sed -i 's|  chkusingwindowspython()|#  chkusingwindowspython()|' ${PETSC_DIR}/config/configure.py
+sed -i 's|(MAKEFLAGS)|(MAKEFLAGS:w=)|' ${PETSC_DIR}/makefile ${PETSC_DIR}/lib/petsc/conf/rules # Fix for issue with GNUMake 4.4.1 (https://gitlab.com/petsc/petsc/-/merge_requests/6140)
+
+# Configure
+# - Cannot use --with-fpic option when compiling static libs,
+#
+#		Cannot determine compiler PIC flags if shared libraries is turned off
+#		Either run using --with-shared-libraries or --with-pic=0 and supply the
+#		compiler PIC flag via CFLAGS, CXXXFLAGS, and FCFLAGS
+#
+# - Added -fallow-argument-mismatch option to FFLAGS in order to clear "Error: 
+#	Rank mismatch between actual argument at [...]"
+# - Added -fallow-invalid-boz option to FFLAGS in order to clear "Error: BOZ 
+#	literal constant at [...]"
+# - Argument to --with-mpi-include must be a list or it gets expanded 
+#	incorrectly
+#
+cd ${PETSC_DIR}
+./config/configure.py \
+	--prefix="${PREFIX}" \
+	--PETSC_DIR="${PETSC_DIR}" \
+	--PETSC_ARCH="${PETSC_ARCH}" \
+	--CFLAGS="-fPIC -Wl,-static -Wno-error=implicit-function-declaration" \
+	--CXXFLAGS="-fPIC -Wl,-static" \
+	--FFLAGS="-fPIC -Wl,-static -fallow-argument-mismatch -fallow-invalid-boz" \
+	--with-shared-libraries=0 \
+	--with-debugging=0 \
+	--with-valgrind=0 \
+	--with-x=0 \
+	--with-ssl=0 \
+	--with-proc-filesystem=0 \
+	--with-mpiexec="${MPIEXEC_DIR}/mpiexec.exe" \
+	--with-mpi-lib=["-L${MSMPI_ROOT}/lib","-lmsmpi"] \
+	--with-mpi-include=["${MSMPI_ROOT}/include"] \
+	--download-fblaslapack=1 \
+	--download-metis=1 \
+	--download-metis-cmake-arguments="${MAKEFILE_GENERATOR}" \
+	--download-parmetis=1 \
+	--download-parmetis-cmake-arguments="${MAKEFILE_GENERATOR}" \
+	--download-scalapack=1 \
+	--download-scalapack-cmake-arguments="${MAKEFILE_GENERATOR}" \
+	--download-mumps=1
+
+# Compile and install
+make PETSC_DIR="${PETSC_DIR}" PETSC_ARCH="${PETSC_ARCH}" all
+make PETSC_DIR="${PETSC_DIR}" PETSC_ARCH="${PETSC_ARCH}" install
Index: /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi.sh	(revision 27943)
+++ /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi.sh	(revision 27944)
@@ -21,4 +21,5 @@
 
 MAKEFILE_GENERATOR='-G "MSYS Makefiles"'
+PETSC_ARCH="arch-mswin-c-opt"
 PETSC_DIR="${ISSM_DIR}/externalpackages/petsc/src" # DO NOT CHANGE THIS
 PREFIX="${ISSM_DIR}/externalpackages/petsc/install" # Set to location where external package should be installed
@@ -38,6 +39,8 @@
 rm -rf petsc-${VER}
 
-# Copy customized source files to $PETSC_DIR
-cp configs/3.14/win/msys2/mingw64/config/configure.py ${PETSC_DIR}/config
+# Patch source
+sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/python3|' ${PETSC_DIR}/config/configure.py
+sed -i 's|  chkusingwindowspython()|#  chkusingwindowspython()|' ${PETSC_DIR}/config/configure.py
+sed -i 's|(MAKEFLAGS)|(MAKEFLAGS:w=)|' ${PETSC_DIR}/makefile ${PETSC_DIR}/lib/petsc/conf/rules # Fix for issue with GNUMake 4.4.1 (https://gitlab.com/petsc/petsc/-/merge_requests/6140)
 
 # Configure
@@ -69,6 +72,6 @@
 	--with-proc-filesystem=0 \
 	--with-mpiexec="${MPIEXEC_DIR}/mpiexec.exe" \
-	--with-mpi-lib="-L${MSMPI_ROOT}/lib -lmsmpi" \
-	--with-mpi-include="${MSMPI_ROOT}/include" \
+	--with-mpi-lib=["-L${MSMPI_ROOT}/lib","-lmsmpi"] \
+	--with-mpi-include=["${MSMPI_ROOT}/include"] \
 	--download-fblaslapack=1 \
 	--download-metis=1 \
@@ -81,4 +84,4 @@
 
 # Compile and install
-make
-make install
+make PETSC_DIR="${PETSC_DIR}" PETSC_ARCH="${PETSC_ARCH}" all
+make PETSC_DIR="${PETSC_DIR}" PETSC_ARCH="${PETSC_ARCH}" install
Index: /issm/trunk-jpl/externalpackages/triangle/install-win-msys2-mingw-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/triangle/install-win-msys2-mingw-static.sh	(revision 27944)
+++ /issm/trunk-jpl/externalpackages/triangle/install-win-msys2-mingw-static.sh	(revision 27944)
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -eu
+
+
+# Constants
+#
+export PREFIX="${ISSM_DIR}/externalpackages/triangle/install" # Set to location where external package should be installed
+
+# Cleanup
+rm -rf ${PREFIX} src
+mkdir -p ${PREFIX} ${PREFIX}/include ${PREFIX}/lib src
+
+# Download source
+$ISSM_DIR/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/triangle.zip" "triangle.zip"
+
+# Unpack source
+unzip triangle.zip -d src
+
+# Copy customized source files to 'src' directory
+cp configs/makefile src
+cp configs/triangle.h src
+cp configs/win/msys2/mingw64/configure.make src
+
+# Compile
+cd src
+make static
+
+# Install
+cd ..
+cp src/libtriangle.* ${PREFIX}/lib
+cp src/triangle.h ${PREFIX}/include
+
+# Cleanup
+rm -rf src
Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 27943)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 27944)
@@ -543,5 +543,5 @@
 					TRIANGLELIB=${TRIANGLE_ROOT}/share/triangle.o
 				else
-					TRIANGLELIB="-L${TRIANGLE_ROOT}/lib -ltriangle"
+					TRIANGLELIB="-Wl,-L${TRIANGLE_ROOT}/lib -Wl,-ltriangle"
 				fi
 			;;
@@ -1418,5 +1418,5 @@
 			;;
 			*mingw*)
-				PETSCLIB="-Wl,${PETSC_ROOT}/lib/libpetsc.a"
+				PETSCLIB="-Wl,-L${PETSC_ROOT}/lib -Wl,-lpetsc"
 			;;
 			*msys*)
@@ -1474,5 +1474,5 @@
 			MPILIB="${MPI_LIBFLAGS}"
 		else
-			MPILIB="-L${MPI_LIBDIR} ${MPI_LIBFLAGS}"
+			MPILIB="${MPI_LIBDIR} ${MPI_LIBFLAGS}"
 		fi
 
@@ -1568,5 +1568,5 @@
 				;;
 				*mingw*)
-					METISLIB="-Wl,${METIS_ROOT}/lib/libmetis.a"
+					METISLIB="-Wl,-L${METIS_ROOT}/lib -Wl,-lmetis"
 				;;
 				*msys*)
@@ -1587,5 +1587,5 @@
 				;;
 				*mingw*)
-					METISLIB="-Wl,${METIS_ROOT}/lib/libmetis.a"
+					METISLIB="-Wl,-L${METIS_ROOT}/lib -Wl,-lmetis"
 				;;
 				*msys*)
@@ -1644,5 +1644,5 @@
 				;;
 				*mingw*)
-					PARMETISLIB="-Wl,${PARMETIS_ROOT}/lib/libparmetis.a"
+					PARMETISLIB="-Wl,-L${PARMETIS_ROOT}/lib -Wl,-lparmetis"
 				;;
 			esac
@@ -1713,5 +1713,5 @@
 	if test "x${HAVE_M1QN3}" == "xyes"; then
 		if test "${IS_MSYS2}" == "yes"; then
-			M1QN3LIB="-Wl,${M1QN3_ROOT}/libm1qn3.a -Wl,${M1QN3_ROOT}/libddot.a"
+			M1QN3LIB="-Wl,-L${M1QN3_ROOT} -Wl,-lm1qn3 -Wl,-lddot"
 		else
 			M1QN3LIB="${M1QN3_ROOT}/libm1qn3.a ${M1QN3_ROOT}/libddot.a"
@@ -1833,5 +1833,5 @@
 		HAVE_SCALAPACK=yes
 		if test "${VENDOR}" == "win-msys2"; then
-			SCALAPACKLIB="-Wl,${SCALAPACK_ROOT}/lib/libscalapack.a"
+			SCALAPACKLIB="-Wl,-L${SCALAPACK_ROOT}/lib -Wl,-lscalapack"
 		else
 			SCALAPACKLIB="-L${SCALAPACK_ROOT}/lib -lscalapack"
@@ -1915,5 +1915,5 @@
 			*mingw*)
 				if test -d "${BLASLAPACK_ROOT}"; then
-					BLASLAPACKLIB="-L${BLASLAPACK_ROOT}/lib"
+					BLASLAPACKLIB="-Wl,-L${BLASLAPACK_ROOT}/lib"
 					if ls ${BLASLAPACK_ROOT}/lib/libopenblas.* 1> /dev/null 2>&1; then
 						BLASLAPACKLIB+=" -lopenblas"
@@ -1921,10 +1921,10 @@
 						BLASLAPACKLIB+=" -lf2clapack -lf2cblas"
 					elif ls ${BLASLAPACK_ROOT}/lib/libflapack.* 1> /dev/null 2>&1; then
-						BLASLAPACKLIB="-Wl,${BLASLAPACK_ROOT}/lib/libflapack.a -Wl,${BLASLAPACK_ROOT}/lib/libfblas.a"
+						BLASLAPACKLIB="-Wl,-L${BLASLAPACK_ROOT}/lib -Wl,-lflapack -Wl,-lfblas"
 					else
-						BLASLAPACKLIB+=" -llapack -lblas"
+						BLASLAPACKLIB+=" -Wl,-llapack -Wl,-lblas"
 					fi
 				else
-					BLASLAPACKLIB="-Wl,${LAPACK_ROOT}/lib/liblapack.a -Wl,${BLAS_ROOT}/lib/libblas.a"
+					BLASLAPACKLIB="${LAPACK_ROOT}/lib/liblapack.a ${BLAS_ROOT}/lib/libblas.a"
 				fi
 			;;
@@ -2053,5 +2053,5 @@
 		if test "x${MUMPS_ROOT}" == "x${PETSC_ROOT}"; then
 			if test "${VENDOR}" == "win-msys2"; then
-				MUMPSLIB="-Wl,${MUMPS_ROOT}/lib/libcmumps.a -Wl,${MUMPS_ROOT}/lib/libdmumps.a -Wl,${MUMPS_ROOT}/lib/libsmumps.a -Wl,${MUMPS_ROOT}/lib/libzmumps.a -Wl,${MUMPS_ROOT}/lib/libmumps_common.a -Wl,${MUMPS_ROOT}/lib/libpord.a"
+				MUMPSLIB="-Wl,-L${MUMPS_ROOT}/lib -Wl,-lcmumps -Wl,-ldmumps -Wl,-lsmumps -Wl,-lzmumps -Wl,-lmumps_common -Wl,-lpord"
 			else
 				MUMPSLIB="-L${MUMPS_ROOT}/lib -ldmumps -lcmumps -lmumps_common -lpord -lparmetis -lzmumps -lmetis"
Index: /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-matlab.sh
===================================================================
--- /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-matlab.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-matlab.sh	(revision 27944)
@@ -140,5 +140,5 @@
 
 	# Check that MATLAB did not exit in error
-	matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log`
+	matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log | wc -l`
 
 	if [ ${matlabExitedInError} -ne 0 ]; then
Index: /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-python-3.sh
===================================================================
--- /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-python-3.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/linux/package-issm-linux-binaries-python-3.sh	(revision 27944)
@@ -139,5 +139,5 @@
 	# Check that Python did not exit in error
 	pythonExitCode=`echo $?`
-	pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log`
+	pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log | wc -l`
 
 	if [[ ${pythonExitCode} -ne 0 || ${pythonExitedInError} -ne 0 ]]; then
Index: /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-matlab.sh
===================================================================
--- /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-matlab.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-matlab.sh	(revision 27944)
@@ -147,5 +147,5 @@
 
 	# Check that MATLAB did not exit in error
-	matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log`
+	matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log | wc -l`
 
 	if [ ${matlabExitedInError} -ne 0 ]; then
Index: /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-python-3.sh
===================================================================
--- /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-python-3.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/mac/package-issm-mac-binaries-python-3.sh	(revision 27944)
@@ -145,5 +145,5 @@
 	# Check that Python did not exit in error
 	pythonExitCode=`echo $?`
-	pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log`
+	pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log | wc -l`
 
 	if [[ ${pythonExitCode} -ne 0 || ${pythonExitedInError} -ne 0 ]]; then
Index: /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-matlab.sh
===================================================================
--- /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-matlab.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-matlab.sh	(revision 27944)
@@ -34,5 +34,5 @@
 # Check that MATLAB did not exit in error
 matlabExitCode=`echo $?`
-matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log`
+matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log | wc -l`
 
 if [[ ${matlabExitCode} -ne 0 || ${matlabExitedInError} -ne 0 ]]; then
Index: /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-python-3.sh
===================================================================
--- /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-python-3.sh	(revision 27943)
+++ /issm/trunk-jpl/packagers/mac/test-issm-mac-binaries-python-3.sh	(revision 27944)
@@ -34,5 +34,5 @@
 # Check that Python did not exit in error
 pythonExitCode=`echo $?`
-pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log`
+pythonExitedInError=`grep -c -E "Error|No such file or directory|Permission denied|Standard exception|Traceback|bad interpreter|syntax error" python.log | wc -l`
 
 if [[ ${pythonExitCode} -ne 0 || ${pythonExitedInError} -ne 0 ]]; then
Index: /issm/trunk-jpl/packagers/win/complete-issm-win-binaries-matlab.sh
===================================================================
--- /issm/trunk-jpl/packagers/win/complete-issm-win-binaries-matlab.sh	(revision 27944)
+++ /issm/trunk-jpl/packagers/win/complete-issm-win-binaries-matlab.sh	(revision 27944)
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+################################################################################
+# Wrapper script to build, package, and transfer to ISSM Web site ISSM 
+# distributable package for Windows with MATLAB API.
+#
+# Normally, we would put this directly into the project configuration under 
+# 'Build' -> 'Execute shell', but because it is a bit more involved, it is a 
+# good idea to version it.
+#
+# When no failures/errors occur, performs the following:
+# - Builds ISSM according to configuration.
+# - Packages executables and libraries.
+# - Runs test suite against package.
+# - Transmits package to ISSM Web site for distribution.
+#
+# Options:
+# -b/--skipbuild		Skip ISSM compilation.
+# -s/--skiptests		Skip ISSM compilation and testing during packaging 
+#						step. Use if packaging fails for some reason but build 
+#						is valid.
+# -t/--transferonly		Transfer package to ISSM Web site only. Use if transfer 
+#						fails for some reason to skip building, packaging, and 
+#						signing.
+#
+# NOTE:
+# - Use only *one* of the above options at a time, and make sure it is removed 
+#	again after a single run.
+# - Builds will fail when any of the above options are used on a clean 
+#	workspace. For example, if 'Source Code Management' -> 'Check-out Strategy' 
+#	select menu is set to "Always check out a fresh copy".
+################################################################################
+
+## Constants
+#
+PKG="ISSM-Windows-MATLAB" # Name of directory to copy distributable files to
+
+COMPRESSED_PKG="${PKG}.tar.gz"
+
+## Environment
+#
+export COMPRESSED_PKG
+export PKG
+
+## Parse options
+#
+if [ $# -gt 1 ]; then
+	echo "Can use only one option at a time"
+	exit 1
+fi
+
+# NOTE: We could do this with binary switching (i.e. 0011 to sign and transfer, 
+#		but the following is self-documenting).
+#
+build=1
+package=1
+transfer=1
+
+if [ $# -eq 1 ]; then
+	case $1 in
+		-b|--skipbuild)		build=0;				shift	;;
+		-s|--skiptests)		build=0;						;;
+		-t|--transferonly)	build=0;	package=0;			;;
+		*) echo "Unknown parameter passed: $1"; exit 1 		;;
+	esac
+fi
+
+# Build
+if [ ${build} -eq 1 ]; then
+	./jenkins/jenkins.sh ./jenkins/ross-win-msys2-mingw-msmpi-binaries-matlab
+
+	if [ $? -ne 0 ]; then 
+		exit 1
+	fi
+fi
+
+# Package
+if [ ${package} -eq 1 ]; then
+	./packagers/win/package-issm-win-binaries-matlab.sh $1
+
+	if [ $? -ne 0 ]; then 
+		exit 1
+	fi
+fi
+
+# Transfer distributable package to ISSM Web site
+if [ ${transfer} -eq 1 ]; then
+	./packagers/win/transfer-issm-win-binaries.sh
+
+	if [ $? -ne 0 ]; then 
+		exit 1
+	fi
+fi
+
Index: /issm/trunk-jpl/packagers/win/package-issm-win-binaries-matlab.sh
===================================================================
--- /issm/trunk-jpl/packagers/win/package-issm-win-binaries-matlab.sh	(revision 27944)
+++ /issm/trunk-jpl/packagers/win/package-issm-win-binaries-matlab.sh	(revision 27944)
@@ -0,0 +1,240 @@
+#!/bin/bash
+
+################################################################################
+# Packages and tests ISSM distributable package for Windows with MATLAB API.
+#
+# Options:
+# -s/--skiptests		Skip testing during packaging Use if packaging fails 
+#						for some reason but build is valid.
+#
+# NOTE:
+# - Assumes that the following constants are defined,
+#
+#		COMPRESSED_PKG
+#		ISSM_DIR
+#		PKG
+#
+# See also:
+# - packagers/win/complete-issm-win-binaries-matlab.sh
+################################################################################
+
+# Expand aliases within the context of this script
+shopt -s expand_aliases
+
+## Override certain aliases
+#
+alias grep=$(which grep)
+
+## Constants
+#
+#LIBGFORTRAN="/usr/lib/x86_64-win-gnu/libgfortran.so.5.0.0" # Important that this is the library itself
+#LIBGFORTRAN_DIST="${ISSM_DIR}/lib/libgfortran.so.5" # Important the file name matches the SONAME entry in the binaries and other shared libraries which link to it
+MATLAB_NROPTIONS="'exclude',[IdFromString('Dakota'),125,126,129,435,701,702,703]"
+#MATLAB_NROPTIONS="'benchmark','all','exclude',[125,126,129,234,235,418,420,435,444,445,701,702,703,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1201,1202,1203,1204,1205,1206,1207,1208,1301,1302,1303,1304,1401,1402,1601,1602,2002,2003,2004,2006,2007,2008,2010,2011,2012,2013,2020,2021,2051,2052,2053,2084,2085,2090,2091,2092,2101,2424,2425,3001:3300,3480,3481,4001:4100]" # NOTE: Combination of test suites from basic, Dakota, and Solid Earth builds, with tests that require a restart and those that require the JVM excluded
+MATLAB_PATH=$(cygpath -u $(cygpath -ms "/c/Program Files/MATLAB/R2019b"))
+MSMPI_ROOT="${ISSM_EXT_DIR}/static/msmpi/install"
+
+## Environment
+#
+export PATH="${ISSM_DIR}/bin:$(getconf PATH)" # Ensure that we pick up binaries from 'bin' directory rather than 'externalpackages'
+
+## Parse options
+#
+if [ $# -gt 1 ]; then
+	echo "Can use only one option at a time"
+	exit 1
+fi
+
+skip_tests=0
+
+if [ $# -eq 1 ]; then
+	case $1 in
+		-s|--skiptests) skip_tests=1;					;;
+		*) echo "Unknown parameter passed: $1"; exit 1	;;
+	esac
+fi
+
+# Check if MATLAB exists
+if ! [ -d ${MATLAB_PATH} ]; then
+	echo "${MATLAB_PATH} does not point to a MATLAB installation! Please modify MATLAB_PATH variable in $(basename $0) and try again."
+	exit 1
+fi
+
+# Clean up from previous packaging
+echo "Cleaning up existing assets"
+cd ${ISSM_DIR}
+rm -rf ${PKG} ${COMPRESSED_PKG}
+mkdir ${PKG}
+
+# Add required binaries and libraries to package and modify them where needed
+cd ${ISSM_DIR}/bin
+
+echo "Modify generic"
+cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
+
+echo "Moving system and MinGW libraries to bin/"
+cp /c/msys64/mingw64/bin/libgcc_s_seh-1.dll .
+cp /c/msys64/mingw64/bin/libstdc++-6.dll .
+cp /c/msys64/mingw64/bin/libwinpthread-1.dll .
+cp /c/msys64/mingw64/bin/libgfortran-5.dll .
+cp /c/msys64/mingw64/bin/libquadmath-0.dll .
+
+echo "Moving MSMPI binaries to bin/"
+if [ -f ${MSMPI_ROOT}/bin/mpiexec.exe ]; then
+	cp ${MSMPI_ROOT}/bin/mpiexec.exe .
+else
+	echo "MSMPI not found"
+	exit 1
+fi
+
+echo "Moving MEX-files to bin/"
+mv ${ISSM_DIR}/lib/*.mexw64 .
+
+# echo "Moving MPICH binaries to bin/"
+# if [ -f ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec ]; then
+# 	cp ${ISSM_DIR}/externalpackages/petsc/install/bin/mpiexec .
+# 	cp ${ISSM_DIR}/externalpackages/petsc/install/bin/hydra_pmi_proxy .
+# elif [ -f ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec ]; then
+# 	cp ${ISSM_DIR}/externalpackages/mpich/install/bin/mpiexec .
+# 	cp ${ISSM_DIR}/externalpackages/mpich/install/bin/hydra_pmi_proxy .
+# else
+# 	echo "MPICH not found"
+# 	exit 1
+# fi
+
+# echo "Moving GDAL binaries to bin/"
+# if [ -f ${ISSM_DIR}/externalpackages/gdal/install/bin/gdal-config ]; then
+# 	cp ${ISSM_DIR}/externalpackages/gdal/install/bin/gdalsrsinfo .
+# 	cp ${ISSM_DIR}/externalpackages/gdal/install/bin/gdaltransform .
+# else
+# 	echo "GDAL not found"
+# 	exit 1
+# fi
+
+# echo "Moving GMT binaries to bin/"
+# if [ -f ${ISSM_DIR}/externalpackages/gmt/install/bin/gmt-config ]; then
+# 	cp ${ISSM_DIR}/externalpackages/gmt/install/bin/gmt .
+# 	cp ${ISSM_DIR}/externalpackages/gmt/install/bin/gmtselect .
+# else
+# 	echo "GMT not found"
+# 	exit 1
+# fi
+
+# echo "Moving Gmsh binaries to bin/"
+# if [ -f ${ISSM_DIR}/externalpackages/gmsh/install/bin/gmsh ]; then
+# 	cp ${ISSM_DIR}/externalpackages/gmsh/install/bin/gmsh .
+# else
+# 	echo "Gmsh not found"
+# 	exit 1
+# fi
+
+cd ${ISSM_DIR}/lib
+
+# echo "Moving libgfortran to lib/"
+# cp ${LIBGFORTRAN} ${LIBGFORTRAN_DIST} 2> /dev/null
+
+# echo "Moving GSHHG assets to share/"
+# if [ -d ${ISSM_DIR}/externalpackages/gmt/install/share/coast ]; then
+# 	mkdir ${ISSM_DIR}/share 2> /dev/null
+# 	cp -R ${ISSM_DIR}/externalpackages/gmt/install/share/coast ${ISSM_DIR}/share
+# else
+# 	echo "GSHHG not found"
+# 	exit 1
+# fi
+
+# echo "Moving PROJ assets to share/"
+# if [ -d ${ISSM_DIR}/externalpackages/proj/install/share/proj ]; then
+# 	mkdir ${ISSM_DIR}/share 2> /dev/null
+# 	cp -R ${ISSM_DIR}/externalpackages/proj/install/share/proj ${ISSM_DIR}/share
+# else
+# 	echo "PROJ not found"
+# 	exit 1
+# fi
+
+# Run tests
+if [ ${skip_tests} -eq 0 ]; then
+	echo "Running tests"
+	cd ${ISSM_DIR}/test/NightlyRun
+	rm matlab.log 2> /dev/null
+
+	# Run tests, redirecting output to logfile and suppressing output to console
+	export ISSM_DIR_WIN=$(cygpath -w "${ISSM_DIR}")
+	${MATLAB_PATH}/bin/matlab -nodesktop -nosplash -nojvm -r "try, addpath ${ISSM_DIR_WIN}/bin ${ISSM_DIR_WIN}/lib; runme(${MATLAB_NROPTIONS}); exit; catch me,fprintf('%s',getReport(me)); exit; end" -logfile matlab.log &
+
+	# Wait for MATLAB to exit
+	#
+	# TODO:
+	# - Replace by adding -wait option to above calls to matlab?
+	#
+	sleep 5;
+	echo "Waiting for MATLAB to exit"
+	pid=$(ps -W | grep MATLAB | awk '{print $1}')
+	echo '-----------------------------'
+	echo "pid: ${pid}"
+	echo '-----------------------------'
+
+	# Time out after $max_time seconds because sometimes multiple MATLAB processes get locked in race condition
+	timer=0
+	max_time=7200
+	while [[ $timer -lt $max_time && -n "${pid}" ]]; do
+		pid=$(ps -W | grep MATLAB | awk '{print $1}')
+		timer=$((timer + 1))
+		sleep 1;
+	done
+
+	# Check if timer hit $max_time
+	if [ $timer -eq $max_time ]; then
+		echo "Testing timed out at ${timer} seconds"
+		# Kill MATLAB processes
+		pid=$(ps -W | grep MATLAB | awk '{print $1}')
+		echo "${pid}" | xargs /bin/kill -f
+		exit 1
+	fi
+
+	# Filter out Windows characters
+	cat matlab.log | tr -cd '\11\12\40-\176' > matlab.log2 && mv matlab.log2 matlab.log
+
+	# Check that MATLAB did not exit in error
+	matlabExitedInError=`grep -c -E "Activation cannot proceed|Error in|Illegal|Invalid MEX-file|license|Warning: Name is nonexistent or not a directory" matlab.log | wc -l`
+
+	if [ ${matlabExitedInError} -ne 0 ]; then
+		echo "----------MATLAB exited in error!----------"
+		cat matlab.log
+		echo "-----------End of matlab.log-----------"
+
+		# Clean up execution directory
+		rm -rf ${ISSM_DIR}/execution/*
+
+		exit 1
+	fi
+
+	# Check that all tests passed
+	sed -i "/FAILED TO establish the default connection to the WindowServer/d" matlab.log # First, need to remove WindowServer error message
+	numTestsFailed=`grep -c -E "FAILED|ERROR" matlab.log | wc -l`
+
+	if [ ${numTestsFailed} -ne 0 ]; then
+		echo "One or more tests FAILED"
+		cat matlab.log
+		exit 1
+	else
+		echo "All tests PASSED"
+	fi
+else
+	echo "Skipping tests"
+fi
+
+# Create package
+cd ${ISSM_DIR}
+svn cleanup --remove-ignored --remove-unversioned test # Clean up test directory (before copying to package)
+echo "Copying assets to package: ${PKG}"
+# NOTE: We do not copy lib directory to package as MATLAB seems to perform differently under Windows and so we package all DDL's and MEX-files in bin directory
+cp -rf bin examples scripts share test ${PKG}
+mkdir ${PKG}/execution
+
+echo "Cleaning up unneeded/unwanted files"
+rm -f ${PKG}/bin/generic_static.* # Remove static versions of generic cluster classes
+rm -rf ${PKG}/test/SandBox # Remove testing sandbox from package
+
+# Compress package
+echo "Compressing package"
+tar -czf ${COMPRESSED_PKG} ${PKG}
Index: /issm/trunk-jpl/packagers/win/transfer-issm-win-binaries.sh
===================================================================
--- /issm/trunk-jpl/packagers/win/transfer-issm-win-binaries.sh	(revision 27944)
+++ /issm/trunk-jpl/packagers/win/transfer-issm-win-binaries.sh	(revision 27944)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+################################################################################
+# Transfers ISSM distributable package for Windows to ISSM website.
+#
+# NOTE:
+# - Assumes that the following constants are defined,
+#
+#		COMPRESSED_PKG
+#
+# See also:
+# - packagers/win/complete-issm-win-binaries-matlab.sh
+# - packagers/win/complete-issm-win-binaries-python-2.sh
+# - packagers/win/complete-issm-win-binaries-python-3.sh
+################################################################################
+
+# Transfer package to ISSM Web site
+echo "Transferring package to ISSM Web site"
+scp -i ~/.ssh/windows_10-vm_to_ross ${COMPRESSED_PKG} jenkins@ross.ics.uci.edu:/var/www/html/${COMPRESSED_PKG}
+
+if [ $? -ne 0 ]; then
+	echo "Transfer failed! Verify connection then build this project again (with -t/--transferonly option to skip building and packaging)."
+	exit 1
+fi
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 27943)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 27944)
@@ -717,5 +717,4 @@
 libISSMCore_la_FFLAGS = $(AM_FFLAGS)
 
-if !STANDALONE_LIBRARIES
 libISSMCore_la_LIBADD = $(CHACOLIB) $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(MPLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(ADJOINTMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) 
 if FORTRAN
@@ -723,5 +722,4 @@
 endif
 libISSMCore_la_LIBADD += $(OSLIBS)
-endif
 
 if NEOPZ
@@ -740,9 +738,5 @@
 
 libISSMModules_la_CXXFLAGS = $(ALL_CXXFLAGS)
-if STANDALONE_LIBRARIES
-libISSMModules_la_LIBADD = ./libISSMCore.la
-else
 libISSMModules_la_LIBADD = ./libISSMCore.la $(TRIANGLELIB) $(CHACOLIB) $(BLASLAPACKLIB) $(OSLIBS)
-endif
 endif
 
@@ -765,7 +759,7 @@
 AM_LDFLAGS += -Wl,-rpath,'@loader_path/../lib'
 else
-AM_LDFLAGS += -Wl,-rpath,'$$ORIGIN/../lib'
+AM_LDFLAGS += -Wl,-static
 if !MSYS2
-AM_LDFLAGS += -static -Wl,--disable-new-dtags
+AM_LDFLAGS += -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN/../lib'
 endif
 endif
@@ -791,7 +785,9 @@
 
 if STANDALONE_LIBRARIES
+if !MSYS2
 libISSMCore_la_LDFLAGS += -static
 if WRAPPERS
 libISSMModules_la_LDFLAGS += -static
+endif
 endif
 endif
@@ -810,5 +806,7 @@
 
 if STANDALONE_LIBRARIES
+if !MSYS2
 libISSMOverload_la_LDFLAGS += -static
+endif
 endif
 endif
@@ -842,5 +840,4 @@
 # External packages
 LDADD += $(DAKOTALIB) $(SEMICLIB) $(M1QN3LIB) $(CHACOLIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(NEOPZLIB) $(TAOLIB) $(PLAPACKLIB) $(MPLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(BLACSLIB) $(HDF5LIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(AMPILIB) $(ADJOINTMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(ESMFLIB)
-
 if FORTRAN
 LDADD += $(FLIBS) $(FORTRANLIB)
Index: /issm/trunk-jpl/src/wrappers/javascript/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 27943)
+++ /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 27944)
@@ -4,16 +4,17 @@
 EXEEXT=$(JAVASCRIPTWRAPPEREXT)
 
-#define prefix (from http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Defining-Directories.html)
-AM_CPPFLAGS+=  -DISSM_PREFIX='"$(prefix)"'
+# Define prefix (from http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Defining-Directories.html)
+AM_CPPFLAGS += -DISSM_PREFIX='"$(prefix)"'
 
-js_scripts = ${ISSM_DIR}/src/wrappers/BamgMesher/BamgMesher.js \
-			 ${ISSM_DIR}/src/wrappers/Triangle/Triangle.js \
-			 ${ISSM_DIR}/src/wrappers/NodeConnectivity/NodeConnectivity.js\
-			 ${ISSM_DIR}/src/wrappers/ContourToMesh/ContourToMesh.js\
-			 ${ISSM_DIR}/src/wrappers/ElementConnectivity/ElementConnectivity.js\
-			 ${ISSM_DIR}/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.js\
-			 ${ISSM_DIR}/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.js\
-			 ${ISSM_DIR}/src/wrappers/IssmConfig/IssmConfig.js\
-			 ${ISSM_DIR}/src/wrappers/Issm/issm.js
+js_scripts = \
+	${ISSM_DIR}/src/wrappers/BamgMesher/BamgMesher.js \
+	${ISSM_DIR}/src/wrappers/Triangle/Triangle.js \
+	${ISSM_DIR}/src/wrappers/NodeConnectivity/NodeConnectivity.js \
+	${ISSM_DIR}/src/wrappers/ContourToMesh/ContourToMesh.js \
+	${ISSM_DIR}/src/wrappers/ElementConnectivity/ElementConnectivity.js \
+	${ISSM_DIR}/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.js \
+	${ISSM_DIR}/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.js \
+	${ISSM_DIR}/src/wrappers/IssmConfig/IssmConfig.js \
+	${ISSM_DIR}/src/wrappers/Issm/issm.js
 
 bin_SCRIPTS =  issm-prebin.js
@@ -21,27 +22,19 @@
 issm-prebin.js: ${js_scripts}
 	cat ${js_scripts}  > issm-prebin.js
-	
-#javascript io{{{
-if !WINDOWS
+
+# JavaScript I/O{{{
 lib_LTLIBRARIES = libISSMJavascript.la
-else
-noinst_LTLIBRARIES = libISSMJavascript.la
-lib_LTLIBRARIES = 
-endif
 
-io_sources=   ./io/WriteJavascriptData.cpp\
-				./io/FetchJavascriptData.cpp
+io_sources = \
+	./io/WriteJavascriptData.cpp \
+	./io/FetchJavascriptData.cpp
 
-ALLCXXFLAGS= -fPIC -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS) 
+ALLCXXFLAGS= -fPIC -D_WRAPPERS_ $(CXXFLAGS) $(CXXOPTFLAGS)
 
 libISSMJavascript_la_SOURCES = $(io_sources)
 libISSMJavascript_la_CXXFLAGS= $(ALLCXXFLAGS)
 #}}}
-#api io{{{
-if !WINDOWS
+# API I/O{{{
 lib_LTLIBRARIES += libISSMApi.la
-else
-noinst_LTLIBRARIES += libISSMApi.la
-endif
 
 api_sources= ./io/ApiPrintf.cpp
@@ -50,48 +43,44 @@
 libISSMApi_la_CXXFLAGS= $(ALLCXXFLAGS)
 #}}}
-#Wrappers {{{
-bin_PROGRAMS = 		 IssmModule
+# Wrappers {{{
+bin_PROGRAMS = IssmModule
 #}}}
 
 # Dependencies {{{
 
-#Triangle library
-AM_CXXFLAGS =  -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER -D_WRAPPERS_
-AM_CXXFLAGS +=  -D_HAVE_JAVASCRIPT_MODULES_ -fPIC
+# Triangle
+AM_CXXFLAGS = -DTRILIBRARY -DANSI_DECLARATORS -DNO_TIMER -D_WRAPPERS_
+AM_CXXFLAGS += -D_HAVE_JAVASCRIPT_MODULES_ -fPIC
 
 deps = ./libISSMJavascript.la ../../c/libISSMModules.la ../../c/libISSMCore.la ./libISSMApi.la
 
-#Optimization flags:
-AM_CXXFLAGS += $(CXXOPTFLAGS) 
+# Optimization flags
+AM_CXXFLAGS += $(CXXOPTFLAGS)
 #}}}
 # Module sources and dependencies {{{
-if !WINDOWS
 libISSMJavascript_la_LIBADD = ./../../c/libISSMCore.la ./../../c/libISSMModules.la $(MPILIB) $(PETSCLIB) $(MKLLIB) $(GSLLIB) $(MATHLIB)
+
+if STANDALONE_LIBRARIES
+if !MSYS2
+libISSMJavascript_la_LDFLAGS = -static
+libISSMApi_la_LDFLAGS += -static
+endif
+deps += $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(TRIANGLELIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(NEOPZLIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(OSLIBS)
 endif
 
-if STANDALONE_LIBRARIES
-libISSMJavascript_la_LDFLAGS = -static 
-deps += $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(TRIANGLELIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB)   $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB)
-endif
+libISSMApi_la_LIBADD = $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJLIB) $(MATHLIB)
 
-if !WINDOWS
-libISSMApi_la_LIBADD = $(MPILIB) $(PETSCLIB) $(GSLLIB) $(MATHLIB) $(MEXLIB)
-endif
+IssmModule_SOURCES = \
+	../BamgMesher/BamgMesher.cpp \
+	../Triangle/Triangle.cpp \
+	../NodeConnectivity/NodeConnectivity.cpp \
+	../ContourToMesh/ContourToMesh.cpp \
+	../ElementConnectivity/ElementConnectivity.cpp \
+	../InterpFromGridToMesh/InterpFromGridToMesh.cpp \
+	../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp \
+	../IssmConfig/IssmConfig.cpp \
+	../Issm/issm.cpp
 
-if STANDALONE_LIBRARIES
-libISSMApi_la_LDFLAGS = -static 
-endif
-
-IssmModule_SOURCES = ../BamgMesher/BamgMesher.cpp \
-                     ../Triangle/Triangle.cpp \
-					 ../NodeConnectivity/NodeConnectivity.cpp\
-					 ../ContourToMesh/ContourToMesh.cpp\
-					 ../ElementConnectivity/ElementConnectivity.cpp\
-					 ../InterpFromGridToMesh/InterpFromGridToMesh.cpp\
-					 ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
-					 ../IssmConfig/IssmConfig.cpp\
-					 ../Issm/issm.cpp
-
-IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_  --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_BamgMesherModule','_TriangleModule','_NodeConnectivityModule','_ContourToMeshModule','_ElementConnectivityModule','_InterpFromGridToMeshModule','_InterpFromMeshToMesh2dModule','_IssmConfigModule','_IssmModule']"  -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s INVOKE_RUN=0
-IssmModule_LDADD = ${deps} $(TRIANGLELIB)  $(GSLLIB)
+IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_  --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_BamgMesherModule','_TriangleModule','_NodeConnectivityModule','_ContourToMeshModule','_ElementConnectivityModule','_InterpFromGridToMeshModule','_InterpFromMeshToMesh2dModule','_IssmConfigModule','_IssmModule']" -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 -s INVOKE_RUN=0
+IssmModule_LDADD = ${deps} $(TRIANGLELIB) $(GSLLIB)
 #}}}
Index: /issm/trunk-jpl/src/wrappers/matlab/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 27943)
+++ /issm/trunk-jpl/src/wrappers/matlab/Makefile.am	(revision 27944)
@@ -8,10 +8,5 @@
 
 #matlab io{{{
-if !WINDOWS
 lib_LTLIBRARIES = libISSMMatlab.la
-else
-noinst_LTLIBRARIES = libISSMMatlab.la
-lib_LTLIBRARIES =
-endif
 
 io_sources = \
@@ -33,9 +28,5 @@
 #}}}
 #api io{{{
-if !WINDOWS
 lib_LTLIBRARIES += libISSMApi.la
-else
-noinst_LTLIBRARIES += libISSMApi.la
-endif
 
 if !MSYS2
@@ -122,5 +113,8 @@
 AM_LDFLAGS += -Wl,-rpath,'@rpath'
 else
-AM_LDFLAGS += -Wl,-static -Wl,-lbacktrace -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
+AM_LDFLAGS += -Wl,-lbacktrace
+if !MSYS2
+AM_LDFLAGS += -Wl,-static -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
+endif
 endif
 endif
@@ -133,8 +127,4 @@
 deps += ./libISSMApi.la
 endif
-
-# if WINDOWS
-# deps += $(METISLIB)
-# endif
 
 if ADOLC
@@ -152,7 +142,5 @@
 #}}}
 # Module sources and dependencies {{{
-if !WINDOWS
 libISSMMatlab_la_LIBADD = ./../../c/libISSMCore.la ./../../c/libISSMModules.la $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(MPILIB) $(NEOPZLIB) $(MKLLIB) $(GSLLIB) $(PROJLIB) $(MATHLIB) $(MEXLIB)
-endif
 
 if VERSION
@@ -165,12 +153,12 @@
 
 if STANDALONE_LIBRARIES
+if !MSYS2
 libISSMMatlab_la_LDFLAGS += -static
 libISSMApi_la_LDFLAGS += -static
+endif
 deps += $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(TRIANGLELIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(NEOPZLIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJLIB) $(OSLIBS) ${LIBADD_FOR_MEX}
 endif
 
-if !WINDOWS
 libISSMApi_la_LIBADD = $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJLIB) $(MATHLIB) $(MEXLIB)
-endif
 
 BamgConvertMesh_matlab_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp
Index: /issm/trunk-jpl/src/wrappers/python/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/python/Makefile.am	(revision 27943)
+++ /issm/trunk-jpl/src/wrappers/python/Makefile.am	(revision 27944)
@@ -6,10 +6,5 @@
 
 #python io{{{
-if !WINDOWS
 lib_LTLIBRARIES = libISSMPython.la
-else
-noinst_LTLIBRARIES = libISSMPython.la
-lib_LTLIBRARIES =
-endif
 
 io_sources = \
@@ -31,9 +26,5 @@
 #}}}
 #api io{{{
-if !WINDOWS
 lib_LTLIBRARIES += libISSMApi.la
-else
-noinst_LTLIBRARIES += libISSMApi.la
-endif
 
 if !MSYS2
@@ -105,6 +96,10 @@
 if STANDALONE_MODULES
 if MAC
+AM_LDFLAGS += -Wl,-rpath,'@rpath'
 else
-AM_LDFLAGS += -Wl,-static -Wl,-lbacktrace -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
+AM_LDFLAGS += -Wl,-lbacktrace
+if !MSYS2
+AM_LDFLAGS += -Wl,-static -Wl,--disable-new-dtags -Wl,-rpath,'$$ORIGIN'
+endif
 endif
 endif
@@ -133,10 +128,12 @@
 
 if STANDALONE_LIBRARIES
+if !MSYS2
 libISSMPython_la_LDFLAGS = -static
 libISSMApi_la_LDFLAGS = -static
+endif
 deps += $(DAKOTALIB) $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(TAOLIB) $(NEOPZLIB) $(M1QN3LIB) $(SEMICLIB) $(PLAPACKLIB) $(SUPERLULIB) $(SPOOLESLIB) $(TRIANGLELIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(CHACOLIB) $(SCOTCHLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(OSLIBS)
 endif
 
-libISSMApi_la_LIBADD = $(PETSCLIB) $(HDF5LIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(MATHLIB)
+libISSMApi_la_LIBADD = $(PETSCLIB) $(MUMPSLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(PARMETISLIB) $(METISLIB) $(HDF5LIB) $(MPILIB) $(NEOPZLIB) $(GSLLIB) $(PROJLIB) $(MATHLIB)
 
 BamgConvertMesh_python_la_SOURCES = ../BamgConvertMesh/BamgConvertMesh.cpp
