Index: issm/trunk/m4/issm_options.m4
===================================================================
--- issm/trunk/m4/issm_options.m4	(revision 2042)
+++ issm/trunk/m4/issm_options.m4	(revision 2047)
@@ -2,13 +2,21 @@
 
 AC_DEFUN([ISSM_OPTIONS],[
-	dnl Debugging option check.
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%debugging-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_ENABLE([debugging],AS_HELP_STRING([--enable-debugging],
 					 [turn debug support on]),
 		[enable_debugging=$enableval],[enable_debugging=no])
 	if test "x$enable_debugging" = xyes; then
-	 AC_DEFINE([_DEBUG_],[1],[Macro to enable debugging in Dakota.])
-	fi
-
-	dnl serial build?
+	 AC_DEFINE([_ISSM_DEBUG_],[1],[Macro to enable debugging in ISSM.])
+	fi
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Debuggin-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%serial build-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([serial],
 			  AS_HELP_STRING([--with-serial = value],
@@ -18,7 +26,8 @@
 	AM_CONDITIONAL([NOSERIAL], [test $SERIAL_VALUE = no])
 	AC_MSG_RESULT($SERIAL_VALUE) 
-	
-
-	dnl parallel build?
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%serial build-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%parallel build-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([parallel],
 			  AS_HELP_STRING([--with-parallel = value],
@@ -28,5 +37,8 @@
 	AM_CONDITIONAL([NOPARALLEL], [test $PARALLEL_VALUE = no])
 	AC_MSG_RESULT($PARALLEL_VALUE) 
-
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%parallel build-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+	
+	
 	dnl: check that at least serial or parallel builds have been requested!
 	if test "$SERIAL_VALUE" != "yes" ; then
@@ -37,5 +49,5 @@
 
 
-	dnl Matlab directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%matlab-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([matlab-dir],
 			  AS_HELP_STRING([--with-matlab-dir = DIR],
@@ -50,36 +62,32 @@
 		HAVE_MATLAB=yes
 		MATLABINCL=-I"$MATLAB_ROOT/extern/include";
-		dnl  use matlab provided mexext routine to test for extension
-				
-		MEX=$MATLAB_ROOT/bin/mex
-
+		
 		dnl OS-dependent variables and checks
 		case "${host_os}" in
 			*linux*)
-			if test "${host_cpu}" = "x86_64";
-			then
-				MEXLIB=-L"$MATLAB_ROOT/bin/glnxa64/ -lmex"
-				MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnxa64/mexFunction.map";
-			else
-				MEXLIB=-L"$MATLAB_ROOT/bin/glnx86/ -lmex"
-				MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnx86/mexFunction.map";
-			fi
-			MEXEXT=`$MATLAB_ROOT/bin/mexext`
-			MEXEXT=".$MEXEXT"
+				if test "${host_cpu}" = "x86_64";
+				then
+					MEXLIB=-L"$MATLAB_ROOT/bin/glnxa64/ -lmex"
+					MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnxa64/mexFunction.map";
+				else
+					MEXLIB=-L"$MATLAB_ROOT/bin/glnx86/ -lmex"
+					MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnx86/mexFunction.map";
+				fi
+				MEXEXT=`$MATLAB_ROOT/bin/mexext`
+				MEXEXT=".$MEXEXT"
 			;;
 			*darwin9.6.0*)
-			MEXLIB=-L"$MATLAB_ROOT/bin/maci/ -lmex -lmx"
-			MEXLINK="-Wl,-twolevel_namespace -undefined error -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
-			MEXEXT=`$MATLAB_ROOT/bin/mexext`
-			MEXEXT=".$MEXEXT"
+				MEXLIB=-L"$MATLAB_ROOT/bin/maci/ -lmex -lmx"
+				MEXLINK="-Wl,-twolevel_namespace -undefined error -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
+				MEXEXT=`$MATLAB_ROOT/bin/mexext`
+				MEXEXT=".$MEXEXT"
 			;;
 			*cygwin*)
-			MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win32\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO"
-
-
-			MEXEXT=`$MATLAB_ROOT/bin/mexext.bat`
-			MEXEXT=".$MEXEXT"
-			;;
-
+				MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win32\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO"
+
+
+				MEXEXT=`$MATLAB_ROOT/bin/mexext.bat`
+				MEXEXT=".$MEXEXT"
+			;;
 		esac
 
@@ -103,5 +111,5 @@
 	fi
 
-	dnl get version number
+	dnl should we use large arrays compilation (Matlab 7.5 and upper?)
 	if test $HAVE_MATLAB = yes; then
 
@@ -121,11 +129,15 @@
 	AM_CONDITIONAL(LARGEARRAYS, test x$largearrays = xyes)
 	
-	dnl Triangle directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%matlab-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%triangle-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([triangle-dir],
 			  AS_HELP_STRING([--with-triangle-dir = DIR], [triangle root directory. necessary for serial build]),
 			 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT=""]) 
 	AC_MSG_CHECKING(for Triangle headers and libraries )
+
 	if test -d "$TRIANGLE_ROOT"; then
-
 
 		dnl defaults
@@ -150,6 +162,9 @@
 	fi
 	AC_MSG_RESULT(ok)
-
-	dnl Dakota directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%triangle-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%dakota-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([dakota-dir],
 			  AS_HELP_STRING([--with-dakota-dir = DIR], [dakota root directory. necessary for serial build]),
@@ -172,7 +187,10 @@
 	fi
 	AC_MSG_RESULT($HAVE_DAKOTA)
-
-		
-	dnl Metis directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%dakota-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%metis-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([metis-dir],
 			  AS_HELP_STRING([--with-metis-dir = DIR],
@@ -213,6 +231,10 @@
 	AC_MSG_RESULT($HAVE_METIS)
 	fi
-
-	dnl Mpi options!
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%metis-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mpi-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_MSG_CHECKING(for mpi...)
 	AC_ARG_WITH([mpi-lib],
@@ -247,6 +269,9 @@
 	fi
 	AC_MSG_RESULT(done)
-
-	dnl Petsc directory and architecture
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mpi-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%petsc-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([petsc-dir],
 			  AS_HELP_STRING([--with-petsc-dir = DIR],
@@ -279,11 +304,11 @@
 		case "${host_os}" in
 			*cygwin*)
-			PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetscksp.lib  libpetscdm.lib  libpetscmat.lib  libpetscvec.lib libpetsc.lib  libpetscsnes.lib libpetscts.lib libmpiuni.lib"
+			PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetscksp.lib  libpetscdm.lib  libpetscmat.lib  libpetscvec.lib libpetsc.lib  libpetscsnes.lib libpetscts.lib libmpiuni.lib"
 			;;
 			*linux*)
-			PETSCLIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
+			PETSCLIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
 			;;
 			*darwin9.6.0*)
-			PETSCLIB="-L$PETSC_ROOT/lib/$PETSC_ARCH -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
+			PETSCLIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
 			;;
 		esac
@@ -305,6 +330,12 @@
 		AC_MSG_RESULT($HAVE_PETSC)
 	fi
-
-	dnl: when running in serial mode, MPI must be ignored, and set to internal petsc mpiuni: 
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%petsc-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mpiuni-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	dnl when running in serial mode, MPI must be ignored, and set to internal petsc mpiuni: 
 	if test "$PARALLEL_VALUE" = "no" ; then
 		HAVE_MPI=yes
@@ -313,17 +344,14 @@
 		case "${host_os}" in
 			*cygwin*)
-			MPILIB="-link -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libmpiuni.lib"
+			MPILIB="-link -LIBPATH:\"$PETSC_ROOT/$PETSC_ARCH/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libmpiuni.lib"
 			;;
 			*linux*)
-			MPILIB="-L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
+			MPILIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
 			;;
 			*darwin9.6.0*)
-			MPILIB="-L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
+			MPILIB="-L$PETSC_ROOT/$PETSC_ARCH/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lmpiuni"
 			;;
 		esac
 								  
-
-
-			
 		AC_DEFINE([_HAVE_MPI_],[1],[with Mpi in ISSM src])
 		AC_DEFINE([HAVE_MPI],[1],[with Mpi in ISSM src])
@@ -331,7 +359,8 @@
 		AC_SUBST([MPILIB])
 	fi
-	
-
-	dnl Slepc directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mpiuni-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%slepc-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([slepc-dir],
 			  AS_HELP_STRING([--with-slepc-dir = DIR],
@@ -355,6 +384,9 @@
 	fi
 	AC_MSG_RESULT($HAVE_SLEPC)
-	
-	dnl Scalapack directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%slepc-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%scalapack-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([scalapack-dir],
 			  AS_HELP_STRING([--with-scalapack-dir = DIR],
@@ -376,6 +408,10 @@
 	fi
 	AC_MSG_RESULT($HAVE_SCALAPACK)
-
-	dnl Blas-lapack directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%scalapack-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%blas-lapack-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([blas-lapack-dir],
 			  AS_HELP_STRING([--with-blas-lapack-dir = DIR],
@@ -413,6 +449,9 @@
 	fi
 	AC_MSG_RESULT($HAVE_BLASLAPACK)
-
-	dnl mkl directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%blas-lapack-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mkl-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([mkl-dir],
 			  AS_HELP_STRING([--with-mkl-dir = DIR],
@@ -458,4 +497,11 @@
 	fi
 	AC_MSG_RESULT($HAVE_PLAPACK)
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mkl-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mumps-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 	dnl Mumps directory
@@ -480,6 +526,9 @@
 	fi
 	AC_MSG_RESULT($HAVE_MUMPS)
-
-	dnl Blacs directory
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mumps-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%blacs-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([blacs-dir],
 			  AS_HELP_STRING([--with-blacs-dir = DIR],
@@ -502,6 +551,10 @@
 	fi
 	AC_MSG_RESULT($HAVE_BLACS)
-
-	dnl math library  option
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%blacs-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%math-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_MSG_CHECKING(for math library...)
 	AC_ARG_WITH([math-lib],
@@ -519,5 +572,9 @@
 	fi
 	AC_MSG_RESULT(done)
-
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%math-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fortran-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	dnl fortran library  option
 	AC_MSG_CHECKING(for fortran library...)
@@ -536,6 +593,10 @@
 	fi
 	AC_MSG_RESULT(done)
-
-	dnl graphics library  option
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fortran-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%graphics-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_MSG_CHECKING(for graphics library...)
 	AC_ARG_WITH([graphics-lib],
@@ -553,6 +614,9 @@
 	fi
 	AC_MSG_RESULT(done)
-
-	dnl vendor?
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%graphics-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%vendor-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 	AC_ARG_WITH([vendor],
 			  AS_HELP_STRING([--with-vendor = VENDOR], [vendor name, ex: intel]),
@@ -569,3 +633,20 @@
 		fi
 	fi
+	AC_MSG_RESULT(done)
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%vendor-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%optimization-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+	dnl bypass standard optimization -g -O2 ? 
+	AC_ARG_WITH([cxxoptflags],
+			  AS_HELP_STRING([--with-cxxoptflags = CXXOPTFLAGS], [optimization using CXX flags, ex: --with-cxxoptflags=-march=opteron -O3]),
+			 [CXXOPTFLAGS=$withval],[CXXOPTFLAGS="-g -O2"]) 
+	AC_MSG_CHECKING(for C++ optimization flags )
+	AC_SUBST([CXXOPTFLAGS])
+	AC_MSG_RESULT(done)
+
+	dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%optimization-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
 ])
