Index: /issm/trunk-jpl/etc/environment.sh
===================================================================
--- /issm/trunk-jpl/etc/environment.sh	(revision 26038)
+++ /issm/trunk-jpl/etc/environment.sh	(revision 26039)
@@ -168,27 +168,4 @@
 } #}}}
 
-#######################
-# OS-specific handling
-#######################
-
-OS=$(uname -s)
-
-if [[ "${OS}" == MINGW* || "${OS}" == MSYS* ]]; then
-	# If this is a Windows build, we need to copy MSMPI to working $ISSM_DIR
-	MSMPI_ROOT="${ISSM_DIR}/MSMPI"
-	if [ ! -d "${MSMPI_ROOT}" ]; then
-		${ISSM_DIR}/scripts/win-msys2-create_local_msmpi_dir.sh
-	fi
-	export MSMPI_ROOT # Used in installation of ParMETIS, ScaLAPACK
-	path_prepend "${ISSM_DIR}/bin" # Lets dynamic linker find DLLs
-	cpath_prepend "${MSMPI_ROOT}/include"
-	library_path_prepend "${MSMPI_ROOT}/lib"
-fi
-
-# Windows compilers
-if [[ "${ISSM_ARCH}" == "cygwin-intel" ]]; then
-	source ${ISSM_DIR}/externalpackages/windows/windows_environment.sh
-fi
-
 path_append "${ISSM_DIR}/aux-config"
 path_append "${ISSM_DIR}/scripts"
@@ -201,4 +178,33 @@
 if [ -z "${ISSM_EXT_DIR+x}" ]; then
 	export ISSM_EXT_DIR="${ISSM_DIR}/externalpackages"
+fi
+
+#######################
+# OS-specific handling
+#######################
+
+OS=$(uname -s)
+
+if [[ "${OS}" == MINGW* ]]; then
+	MSMPI_ROOT="${ISSM_EXT_DIR}/msmpi/install"
+	if [ -d "${MSMPI_ROOT}" ]; then
+		export MSMPI_ROOT # Used in installation of ParMETIS, ScaLAPACK
+		path_prepend "${ISSM_DIR}/bin" # Allows dynamic loaded to find DLLs
+		cpath_prepend "${MSMPI_ROOT}/include"
+		library_path_prepend "${MSMPI_ROOT}/lib"
+	fi
+
+	MPIEXEC_DIR=$(cygpath -u $(cygpath -ms "/c/Program Files/Microsoft MPI/Bin"))
+	if [ -d "${MPIEXEC_DIR}" ]; then
+		export MPIEXEC_DIR
+		path_append "${MPIEXEC_DIR}"
+	fi
+
+	path_prepend "${ISSM_DIR}/bin" # Allows dynamic loader to find DLLs
+fi
+
+# Windows compilers
+if [[ "${ISSM_ARCH}" == "cygwin-intel" ]]; then
+	source ${ISSM_DIR}/externalpackages/windows/windows_environment.sh
 fi
 
@@ -284,7 +290,10 @@
 if [ -d "${BLAS_ROOT}" ]; then
 	export BLAS_ROOT # Used in installation of LAPACK, ScaLAPACK, PETSc
-	path_append "${BLAS_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_append "${BLAS_ROOT}/lib"
 	ld_library_path_append "${BLAS_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${BLAS_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -292,7 +301,10 @@
 if [ -d "${LAPACK_ROOT}" ]; then
 	export LAPACK_ROOT # Used in installation of ScaLAPACK, MUMPS, PETSc
-	path_append "${LAPACK_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_append "${LAPACK_ROOT}/lib"
 	ld_library_path_append "${LAPACK_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${LAPACK_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -300,7 +312,10 @@
 if [ -d "${METIS_ROOT}" ]; then
 	export METIS_ROOT # Used in installation of ParMETIS, Gmsh, PETSc
-	path_append "${METIS_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_prepend "${METIS_ROOT}/lib"
 	ld_library_path_prepend "${METIS_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${METIS_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -308,6 +323,9 @@
 if [ -d "${MUMPS_ROOT}" ]; then
 	export MUMPS_ROOT # Used in installation of PETSc
-	path_append "${MUMPS_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_append "${MUMPS_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${MUMPS_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -315,7 +333,10 @@
 if [ -d "${PARMETIS_ROOT}" ]; then
 	export PARMETIS_ROOT # Used in installation of MUMPS, PETSc
-	path_append "${PARMETIS_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_prepend "${PARMETIS_ROOT}/lib"
 	ld_library_path_prepend "${PARMETIS_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${PARMETIS_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -323,6 +344,9 @@
 if [ -d "${SCALAPACK_ROOT}" ]; then
 	export SCALAPACK_ROOT # Used in installation of MUMPS, PETSc
-	path_append "${SCALAPACK_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_append "${SCALAPACK_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${SCALAPACK_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
@@ -336,7 +360,10 @@
 if [ -d "${PETSC_ROOT}" ]; then
 	export PETSC_ROOT # Used in installation of Gmsh
-	path_append "${PETSC_ROOT}/lib" # Lets dynamic linker find DLLs
 	library_path_prepend "${PETSC_ROOT}/lib"
 	ld_library_path_prepend "${PETSC_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${PETSC_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 
 	# In case we have installed certain external packages via PETSc
@@ -511,7 +538,10 @@
 TRIANGLE_ROOT="${ISSM_EXT_DIR}/triangle/install"
 if [ -d "${TRIANGLE_ROOT}" ]; then
-	path_append "${TRIANGLE_ROOT}/lib" # Lets dynamic linker find DLLs
 	ld_library_path_append "${TRIANGLE_ROOT}/lib"
 	dyld_library_path_append "${TRIANGLE_ROOT}/lib"
+
+	if [[ "${OS}" == MINGW* ]]; then
+		path_append "${TRIANGLE_ROOT}/lib" # Allows dynamic loaded to find DLLs
+	fi
 fi
 
Index: /issm/trunk-jpl/externalpackages/mingw-mex/README
===================================================================
--- /issm/trunk-jpl/externalpackages/mingw-mex/README	(revision 26039)
+++ /issm/trunk-jpl/externalpackages/mingw-mex/README	(revision 26039)
@@ -0,0 +1,55 @@
+This directory contains instructions (this file) and supporting files for 
+setting up mex to use MinGW compilers to produce MEX-files.
+
+NOTE: This does not apply to the 'MATLAB Support for MinGW-w64 C/C++ Compiler' 
+Add-On: what we are concerned with here is setting mex to use external MinGW 
+compilers.
+
+==========================================
+Setup MinGW compilers to produce MEX files
+==========================================
+- Start an instance of MATLAB
+- Navigate to $ISSM_DIR/externalpackages/mingw-mex
+- In the MATLAB Command Window run,
+
+	>> configuremingw
+
+- In the resulting prompt, navigate to the root MinGW gcc directory (if you 
+have followed the Windows installation instructions on our Web site, 
+https://issm.jpl.nasa.gov/download/windows, this should be 
+'C:\msys64\mingw64').
+- Verify that configuration was successful,
+
+	>> mex -setup C
+	MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
+	>> mex -setup C++
+	MEX configured to use 'MinGW64 Compiler (C++)' for C++ language compilation.
+
+If configuration was unsuccessful, see if a new version of configuremingw.p is 
+available at,
+
+	https://www.mathworks.com/matlabcentral/answers/313298-i-already-have-mingw-on-my-computer-how-do-i-configure-it-to-work-with-matlab
+
+If so, please notify us on the ISSM Forum at https://issm.ess.uci.edu/forum so 
+that we can update the file in our repository.
+
+=========================
+Building yprime.c Example
+=========================
+- Start an instance of MATLAB
+- Navigate to $ISSM_DIR/externalpackages/mingw-mex
+- In the MATLAB Command Window run,
+
+	>> copyfile(fullfile(matlabroot,'extern','examples','mex','yprime.c'),'.','f')
+	>> mex yprime.c
+
+- Test the generate MEX file with,
+
+	>> yprime(1,1:4)
+
+	ans =
+
+	    2.0000    8.9685    4.0000   -1.0947
+
+Sources:
+- https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html
Index: /issm/trunk-jpl/externalpackages/msmpi/install.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/msmpi/install.sh	(revision 26039)
+++ /issm/trunk-jpl/externalpackages/msmpi/install.sh	(revision 26039)
@@ -0,0 +1,55 @@
+#!/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_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
+
+# 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
+
+# Copy MS-MPI library to 'lib' directory
+cp ${MSMPI_LIB} ${PREFIX}/lib
+
+# Create link to shared library so that libtool can find it
+cd ${PREFIX}/lib
+ln -s msmpi.dll libmsmpi.dll
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 26038)
+++ /issm/trunk-jpl/externalpackages/petsc/install-3.14-win-msys2-mingw-msmpi.sh	(revision 26039)
@@ -5,7 +5,7 @@
 # - You must install various needed packages with,
 #
-#		pacman -S autoconf make automake-wrapper bison git mingw-w64-x86_64-freeglut mingw-w64-x86_64-toolchain patch python perl pkg-config pkgfile rebase tar time tzcode unzip which mingw-w64-x86_64-libmicroutils
+#		pacman -S git mingw-w64-x86_64-freeglut mingw-w64-x86_64-toolchain python pkg-config mingw-w64-x86_64-libmicroutils
 #
-# then remove the MinGW 64-bit version of Python (and depdendent packages) with,
+# then remove the MinGW 64-bit version of Python (and dependent packages) with,
 #
 #		pacman -R mingw-w64-x86_64-gdb-multiarch mingw-w64-x86_64-gdb mingw-w64-x86_64-python
@@ -69,5 +69,5 @@
 	--with-ssl=0 \
 	--with-proc-filesystem=0 \
-	--with-mpiexec="/c/PROGRA~1/MICROS~1/Bin/mpiexec.exe" \
+	--with-mpiexec="${MPIEXEC_DIR}/mpiexec.exe" \
 	--with-mpi-lib="-L${MSMPI_ROOT}/lib -lmsmpi" \
 	--with-mpi-include="${MSMPI_ROOT}/include" \
Index: /issm/trunk-jpl/jenkins/ross-win-msys2-mingw-msmpi-basic
===================================================================
--- /issm/trunk-jpl/jenkins/ross-win-msys2-mingw-msmpi-basic	(revision 26038)
+++ /issm/trunk-jpl/jenkins/ross-win-msys2-mingw-msmpi-basic	(revision 26039)
@@ -1,2 +1,4 @@
+MATLAB_PATH=$(cygpath -u $(cygpath -ms "/c/Program Files/MATLAB/R2019b"))
+
 ISSM_CONFIG='\
 	--prefix=${ISSM_DIR} \
@@ -25,4 +27,5 @@
 #List of external pakages to be installed and their installation scripts
 EXTERNALPACKAGES="
+	msmpi		install.sh
 	petsc		install-3.14-win-msys2-mingw-msmpi.sh
 	triangle	install-win-msys2-mingw.sh
@@ -48,5 +51,5 @@
 
 # Number of CPUs used in the nightly runs
-NUMCPUS_RUN=1
+NUMCPUS_RUN=2
 
 # Nightly run options
Index: /issm/trunk-jpl/src/m/classes/clusters/generic.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/clusters/generic.m	(revision 26038)
+++ /issm/trunk-jpl/src/m/classes/clusters/generic.m	(revision 26039)
@@ -139,14 +139,14 @@
 				fprintf(fid,'@echo off\n');
 
-				if IssmConfig('_HAVE_PETSC_MPI_'),
-					warning('parallel runs not allowed yet in Windows. Defaulting to 1 cpus');
-					cluster.np=1;
-				end
+				% if IssmConfig('_HAVE_PETSC_MPI_'),
+				% 	warning('parallel runs not allowed yet in Windows. Defaulting to 1 cpus');
+				% 	cluster.np=1;
+				% end
 
 				if cluster.np>1,
-					% fprintf(fid,'"C:\\Program Files\\MPICH2\\bin\\mpiexec.exe" -n %i "%s/%s" %s ./ %s ',cluster.np,cluster.codepath,executable,solution,modelname);
-					fprintf(fid,'"C:\\PROGRA~1\\MICROS~1\\Bin\\mpiexec.exe" -n %i "%s/%s" %s ./ %s ',cluster.np,cluster.codepath,executable,solution,modelname);
-				else
-					fprintf(fid,'"%s/%s" %s ./ %s ',cluster.codepath,executable,solution,modelname);
+					% fprintf(fid,'"C:\\Program Files\\MPICH2\\bin\\mpiexec.exe" -n %i "%s/%s" %s ./ %s',cluster.np,cluster.codepath,executable,solution,modelname);
+					fprintf(fid,'"C:\\Program Files\\Microsoft MPI\\Bin\\mpiexec.exe" -n %i "%s/%s" %s ./ %s',cluster.np,cluster.codepath,executable,solution,modelname);
+				else
+					fprintf(fid,'"%s/%s" %s ./ %s',cluster.codepath,executable,solution,modelname);
 				end
 				fclose(fid);
@@ -305,5 +305,4 @@
 
 			if ~ispc,
-
 				%figure out what shell extension we will use:
 				if isempty(strfind(cluster.shell,'csh')),
@@ -319,8 +318,8 @@
 				else
 					if ~batch,
-					launchcommand=['source ' cluster.etcpath '/environment.' shellext ' && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+						launchcommand=['source ' cluster.etcpath '/environment.' shellext ' && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
 						' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && source  ' modelname '.queue '];
 					else
-					launchcommand=['source ' cluster.etcpath '/environment.' shellext ' && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+						launchcommand=['source ' cluster.etcpath '/environment.' shellext ' && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
 						' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz '];
 					end
Index: /issm/trunk-jpl/src/m/solve/waitonlock.m
===================================================================
--- /issm/trunk-jpl/src/m/solve/waitonlock.m	(revision 26038)
+++ /issm/trunk-jpl/src/m/solve/waitonlock.m	(revision 26039)
@@ -2,7 +2,7 @@
 %WAITONLOCK - wait for a file
 %
-%   This routine will return when a file named 'lockfilename' is written to disk.
-%   Also check for outlog file be cause it might bewritten several seconds
-%   after the lock file.
+%   This routine will return when a file named 'lockfilename' is written to 
+%   disk. Also check for outlog file be cause it might be written several 
+%   seconds after the lock file.
 %   If the time limit given in input is exceeded, return 0
 %
