Index: /issm/trunk-jpl/m4/issm_options.m4
===================================================================
--- /issm/trunk-jpl/m4/issm_options.m4	(revision 25638)
+++ /issm/trunk-jpl/m4/issm_options.m4	(revision 25639)
@@ -192,7 +192,13 @@
 
 	AC_MSG_CHECKING([if this is a Mac build])
+	MAC_FMEMOPEN=0
 	case "${host_os}" in
 		*darwin*)
 			IS_MAC=yes
+			if [[ $(system_profiler SPSoftwareDataType | $(which grep) "System Version:" | sed -e "s/[[:space:]]*System Version: macOS //" | cut -d "." -f 2) -ge 13 ]]; then
+				MAC_FMEMOPEN=yes
+			else
+				MAC_FMEMOPEN=no
+			fi
 		;;
 		*)
@@ -201,4 +207,5 @@
 	esac
 	AM_CONDITIONAL([MAC], [test "${IS_MAC}" == "yes"])
+	AM_CONDITIONAL([MAC_FMEMOPEN], [test "${MAC_FMEMOPEN}" == "yes"])
 	AC_MSG_RESULT([${IS_MAC}])
 
@@ -2332,5 +2339,5 @@
 
 		AC_MSG_CHECKING(for Gmsh version)
-		GMSH_VERSION_MAJOR=`${GMSH_ROOT}/bin/gmsh -info | grep "Version" | sed -e "s/Version@<:@@<:@:blank:@:>@@:>@*:@<:@@<:@:blank:@:>@@:>@//" | cut -d "." -f1`
+		GMSH_VERSION_MAJOR=`${GMSH_ROOT}/bin/gmsh -info | grep "Version" | sed -e "s/Version@<:@@<:@:blank:@:>@@:>@*:@<:@@<:@:blank:@:>@@:>@//" | cut -d "." -f 1`
 		AC_MSG_RESULT([${GMSH_VERSION_MAJOR}])
 		AC_DEFINE_UNQUOTED(_GMSH_VERSION_MAJOR_, $GMSH_VERSION_MAJOR, [Gmsh major version])
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 25638)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 25639)
@@ -21,6 +21,16 @@
 
 #Core sources
+issm_sources =
+
+#GLIBC sources {{{
+if MAC
+if !MAC_FMEMOPEN
+issm_sources += \
+	./ext/fmemopen/fmemopen.c
+endif
+endif
+#}}}
+
 #BAMG sources  {{{
-issm_sources =
 if BAMG
 issm_sources += \
Index: /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp	(revision 25638)
+++ /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.cpp	(revision 25639)
@@ -174,12 +174,12 @@
 		/*figure out size of file, and read the whole thing:*/
 		_printf0_("    reading file:\n");
-		fseek (fid, 0, SEEK_END);
+		fseek(fid, 0, SEEK_END);
 		length = ftell (fid);
-		fseek (fid, 0, SEEK_SET);
+		fseek(fid, 0, SEEK_SET);
 		buffer = xNew<char>(length);
-		fread (buffer, sizeof(char), length, fid);
+		fread(buffer, sizeof(char), length, fid);
 
 		/*close file:*/
-		fclose (fid);
+		fclose(fid);
 
 		/*create a memory stream with this buffer:*/
Index: /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.h	(revision 25638)
+++ /issm/trunk-jpl/src/c/modules/QmuStatisticsx/QmuStatisticsx.h	(revision 25639)
@@ -6,4 +6,8 @@
 
 #include "../../classes/classes.h"
+
+#if MAC && !MAC_FMEMOPEN
+#include "../../ext/fmemopen/fmemopen.h"
+#endif
 
 int ComputeMeanVariance(Parameters* parameters,Results* results,int color, ISSM_MPI_Comm statcomm);
