[cig-commits] r18884 - in seismo/3D/SPECFEM3D_GEOTECH/trunk: . doc input src utilities

homnath at geodynamics.org homnath at geodynamics.org
Fri Sep 9 00:06:02 PDT 2011


Author: homnath
Date: 2011-09-09 00:06:01 -0700 (Fri, 09 Sep 2011)
New Revision: 18884

Added:
   seismo/3D/SPECFEM3D_GEOTECH/trunk/CMakeLists.txt
Modified:
   seismo/3D/SPECFEM3D_GEOTECH/trunk/README
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example1_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_left_fixed_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation1_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation2_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation3_material_list
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/Makefile
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mpi_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/README_exodus2sem
   seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c
   seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c
   seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/write_sos.f90
Log:
update to beta 1.1

Added: seismo/3D/SPECFEM3D_GEOTECH/trunk/CMakeLists.txt
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/CMakeLists.txt	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/CMakeLists.txt	2011-09-09 07:06:01 UTC (rev 18884)
@@ -0,0 +1,106 @@
+# cmake file for the cross-platform configure of the
+# software package SPECFEM3D_GEOTECH
+# REVISION:
+#   HNG, Sep 06,2011;
+
+# required cmake version
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4 FATAL_ERROR)
+
+# define project
+PROJECT(semgeotech Fortran C)
+
+# Disallow in-source build
+IF("${semgeotech_SOURCE_DIR}"  STREQUAL "${semgeotech_BINARY_DIR}")
+  MESSAGE(FATAL_ERROR "SPECFEM3D_GEOTECH requires an out-of-source build. Please create a separate binary directory and run CMake there.")
+ENDIF("${semgeotech_SOURCE_DIR}"  STREQUAL "${semgeotech_BINARY_DIR}")
+
+# Test Fortran compiler
+TRY_COMPILE(TEST_F90 ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/testf90.f90)
+IF(NOT TEST_F90)
+  MESSAGE(FATAL_ERROR "Fortran compiler: ${CMAKE_Fortran_COMPILER} doesn't work! Please set working CMAKE_Fortran_COMPILER!")
+ENDIF(NOT TEST_F90)
+
+# build directories
+SET(BDIR ${CMAKE_BINARY_DIR}/bin)
+SET(DDIR ${CMAKE_BINARY_DIR}/doc)
+SET(IDIR ${CMAKE_BINARY_DIR}/input)
+SET(LDIR ${CMAKE_BINARY_DIR}/lib)
+SET(ODIR ${CMAKE_BINARY_DIR}/output)
+SET(PDIR ${CMAKE_BINARY_DIR}/partition)
+SET(SDIR ${CMAKE_SOURCE_DIR})
+FILE(MAKE_DIRECTORY ${BDIR})
+#FILE(MAKE_DIRECTORY ${DDIR})
+FILE(MAKE_DIRECTORY ${IDIR}) 
+FILE(MAKE_DIRECTORY ${ODIR}) 
+FILE(MAKE_DIRECTORY ${PDIR}) 
+
+# set paths to executable and libraries
+SET(EXECUTABLE_OUTPUT_PATH ${BDIR})
+SET(LIBRARY_OUTPUT_PATH ${LDIR})
+
+# set internal default logical variables
+SET(ISDOCUMENTATION OFF)
+SET(ISPARTMESH OFF)
+SET(ISPARALLEL OFF)
+
+# build documentation option
+SET(BUILD_DOCUMENTATION OFF CACHE BOOL "Build documentation for
+SPECFEM3D_GEOTECH")
+IF(BUILD_DOCUMENTATION)
+  SET(ISDOCUMENTATION ON)
+  FIND_PACKAGE(LATEX REQUIRED)
+  IF(NOT PDFLATEX_COMPILER OR NOT BIBTEX_COMPILER)
+    MESSAGE(WARNING "LaTeX compiler/s not found! DOCUMENTATION cannot be built!"    )
+  SET(ISDOCUMENTATION OFF)
+  ENDIF(NOT PDFLATEX_COMPILER OR NOT BIBTEX_COMPILER)
+ENDIF(BUILD_DOCUMENTATION)
+
+#SET(BUILD_SLOPE ON CACHE BOOL "Build slope stability program")
+#SET(BUILD_EXCAVATION ON CACHE BOOL "Build excavation program")
+
+# build partmesh option
+SET(BUILD_PARTMESH OFF CACHE BOOL "Build mesh partitioning program")
+IF(BUILD_PARTMESH)
+  SET(ISPARTMESH ON)
+  FIND_PATH(SCOTCH_LIBRARY_PATH NAMES libscotch.a libscotcherr.a
+  PATHS /usr/lib /usr/local/lib ENV LD_LIBRARY_PATH)
+  IF(NOT SCOTCH_LIBRARY_PATH)
+    MESSAGE(WARNING "SCOTCH library not found! Please set correct SCOTCH_LIBRARY_PATH manually!")
+    SET(ISPARTMESH OFF)
+  ENDIF(NOT SCOTCH_LIBRARY_PATH)
+ENDIF(BUILD_PARTMESH)
+SET(BUILD_UTILITIES_EXODUS2SEM OFF CACHE BOOL "Build exodus2sem program")
+SET(BUILD_UTILITIES_WRITE_SOS OFF CACHE BOOL "Build write_sos program")
+
+# MPI for parallel processing
+SET(ENABLE_MPI OFF CACHE BOOL "Build semgeotech with MPI support")
+IF(ENABLE_MPI)
+  SET(ISPARALLEL ON)
+  FIND_PACKAGE(MPI COMPONENTS Fortran REQUIRED)
+  IF(NOT MPI_FOUND)
+    MESSAGE(WARNING "MPI Fortran compiler not found! Parallel semgeotech cannot be built!")
+    SET(ISPARALLEL OFF)
+  ENDIF(NOT MPI_FOUND)
+  
+  # Test MPI Fortran compiler
+  #include_directories(${MPI_Fortran_INCLUDE_PATH})
+  TRY_COMPILE(TEST_MPI ${CMAKE_BINARY_DIR}/CMakeTmp ${CMAKE_SOURCE_DIR}/src/testmpi.f90
+  COMPILE_DEFINITIONS ${MPI_Fortran_LINK_FLAGS}
+  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${MPI_Fortran_INCLUDE_PATH}"
+  "-DLINK_LIBRARIES=${MPI_Fortran_LIBRARIES}"
+  OUTPUT_VARIABLE test)
+  IF(NOT TEST_MPI)
+    MESSAGE(WARNING "MPI Fortran compiler: ${CMAKE_Fortran_COMPILER} doesn't work! Parallel semgeotech cannot be built!")
+    SET(ISPARALLEL OFF)
+  ENDIF(NOT TEST_MPI) 
+INCLUDE_DIRECTORIES(${MPI_Fortran_INCLUDE_PATH}) 
+ENDIF(ENABLE_MPI)
+
+# process CMakeLists.txt in other subdirectories
+ADD_SUBDIRECTORY(doc)
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(utilities)
+
+# notes
+#SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES LANGUAGE "C")
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/README
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/README	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/README	2011-09-09 07:06:01 UTC (rev 18884)
@@ -2,4 +2,4 @@
   HNG, July 08,2011
   
 For license see COPYING.
-For detail on the software package see SPECFEM3D_SLOPE.pdf.
+For detail on the software package see SPECFEM3D_GEOTECH.pdf.

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib	2011-09-09 07:06:01 UTC (rev 18884)
@@ -133,6 +133,17 @@
   timestamp = {2011.06.01}
 }
 
+ at ARTICLE{gharti2011b,
+  author = {Gharti, H. N. and Oye, V. and Komatitsch, D.  and Tromp, J.},
+  title = {Simulation of multistage excavation based on a {3D} spectral-element
+	method},
+  journal = {Computers \& Structures},
+  year = {2011},
+  volume = {submitted},
+  owner = {homnath},
+  timestamp = {2011.06.01}
+}
+
 @BOOK{gropp1994,
   title = {Using {MPI}, portable parallel programming with the {M}essage-{P}assing
 	{I}nterface},
@@ -239,16 +250,17 @@
 	and Blitz, C. and Nissen-Meyer, T. and Basini, P. and Tromp, J.},
   title = {Forward and adjoint simulations of seismic wave propagation on fully
 	unstructured hexahedral meshes},
-  journal = gji,
+  journal = {Geophysical Journal International},
   year = {2011},
-  pages = {},
-  note = {accepted},
+  volume = {186},
+  pages = {721--739},
+  number = {2},
   doi = {10.1111/j.1365-246X.2011.05044.x},
   issn = {1365-246X},
   keywords = {Tomography, Interferometry, Computational seismology, Wave propagation},
   publisher = {Blackwell Publishing Ltd},
   url = {http://dx.doi.org/10.1111/j.1365-246X.2011.05044.x}
-}
+}
 
 @ARTICLE{patera1984,
   author = {Patera, A. T.},
@@ -283,7 +295,6 @@
   timestamp = {2010.08.26}
 }
 
-
 @BOOK{smith2004,
   title = {Programming the finite element method},
   publisher = {John Wiley \& Sons},

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex	2011-09-09 07:06:01 UTC (rev 18884)
@@ -2,15 +2,18 @@
 \documentclass[12pt,a4paper]{report}
 \usepackage[T1]{fontenc}
 \usepackage[latin1]{inputenc}
-\usepackage{geometry}
-\geometry{verbose,a4paper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
+\usepackage{color,geometry,graphicx}
+\usepackage[absolute]{textpos}
+\usepackage{pdfpages}
 \usepackage{float,textcomp,amsmath,paralist,calc}
 \usepackage{natbib}
-
+\geometry{verbose,a4paper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
 \newcommand{\ap}{\textquotesingle}
 \newcommand{\sq}[1]{\textquotesingle{#1}\textquotesingle}
 \setlength\parindent{0pt}
 
+\definecolor{gray}{rgb}{0.8,0.8,0.8}
+
 \newcommand{\frontmatter}{\cleardoublepage
   \pagenumbering{roman}}
 \newcommand{\mainmatter}{\cleardoublepage
@@ -39,12 +42,19 @@
 
 % Package name and version
 \def\pack{SPECFEM3D\_GEOTECH}
-\def\packver{\pack\ 1.0 Beta}
+\def\packver{\pack\ 1.1 Beta}
 
 \begin{document}
 %\thispagestyle{empty}\textbf{}%
+\includepdf[fitpaper]{cover}
+%\begin{textblock*}{297mm}(0mm,0mm)
+%   \includegraphics[width=\paperwidth]{cover}
+%\end{textblock*}
+
 %\begin{figure}[H]
-%\noindent \includegraphics[width=0.75\paperwidth]{figures/specfem_3d_sesame-cover.pdf}
+%\centering
+%\noindent\includegraphics[width=0.8\paperwidth]{cover}
+%\noindent\includegraphics[scale=1.0]{cover}
 %\end{figure}
 
 \thispagestyle{empty} % no page number
@@ -88,6 +98,7 @@
 \chapter*{Acknowledgments}
 This work was funded in part by the Research Council of Norway,
 and supported by industry partners BP, Statoil, and Total. Some of the routines were imported and modified from the ``Programming the finite element method''~\citep{smith2004} and the original ``SPECFEM3D'' package~\citep[e.g.,][]{komatitsch1998,komatitsch1999,peter2011}.
+
 \clearpage
 
 \tableofcontents
@@ -97,26 +108,28 @@
 \chapter{Introduction}
 \section{Background}
 
-\pack\ is a free and open-source command-driven software for 3D slope stability analysis~\citep[For more detail see][]{gharti2011} based on the spectral-element method~\citep[e.g.,][]{patera1984,canuto1988,seriani1994,faccioli1997,komatitsch1998,komatitsch1999,peter2011}. The software can run on a single processor as well as multi-core machines or large clusters. It is written mainly in FORTRAN 90, and parallelized using
+\pack\ is a free and open-source command-driven software for 3D slope stability analysis~\citep[For more detail see][]{gharti2011} and simulation of 3D multistage excavation~\citep[For more detail see][]{gharti2011b} based on the spectral-element method~\citep[e.g.,][]{patera1984,canuto1988,seriani1994,faccioli1997,komatitsch1998,komatitsch1999,peter2011}. The software can run on a single processor as well as multi-core machines or large clusters. It is written mainly in FORTRAN 90, and parallelized using
 MPI~\citep{gropp1994,pacheco1997} based on domain decomposition. For the domain decomposition, an open-source graph partitioning library SCOTCH~\citep{pellegrini1996} is used. The element-by-element preconditioned conjugate-gradient method~\citep[e.g.,][]{hughes1983,law1986,king1987,barragy1988} is implemented to solve the linear equations. For elastoplastic failure, 
 Mohr-coulomb failure criterion is used with viscoplastic strain method~ \citep{zienkiewicz1974}.\\ 
 
-This program does not automatically determine the factor of safety of the slope stability. Simulation can be performed for a series of safety factors. After plotting the safety factor vs maximum displacement curve, one can determine the factor of safety of the given slope. Although, the software is optimized for slope stability analysis, other relevant simulations of static problems in solid (geo)mechanics can also be performed with this software.\\
+This program does not automatically determine the factor of safety of the slope stability. Simulation can be performed for a series of safety factors. After plotting the safety factor vs maximum displacement curve, one can determine the factor of safety of the given slope. Although, the software is optimized for slope stability analysis and multistage excavation, other relevant simulations of static problems in solid (geo)mechanics can also be performed with this software.\\
 
 The software currently does not include the inbuilt mesher. Existing tools such as Gmsh~\citep{geuzaine2009}, CUBIT~\citep{cubit2011}, TrueGrid~\citep{truegrid2006}, etc. can be used for the hexahedral meshing, and the resulting mesh file can be converted to the input files required by the \pack. Output data can be visualized and processed using an open-source visualization application ParaView (\texttt{www.paraview.org}).  
 
 \section{Status summary}
 \begin{desclist}{Pseudo-static earthquake loading}                             
+\item[Slope stability analysis]        : Yes
+\item[Multistage excavation]           : Yes
 \item[Gravity loading]                 : Yes
 \item[Surface loading]                 : Yes (point load, uniformly distributed load, linearly distributed load) [Experimental]
 \item[Water table]                     : Yes [Experimental]
-\item[Pseudo-static earthquake loading]   : Yes [Experimental]
+\item[Pseudo-static earthquake loading]: Yes [Experimental]
 \item[Automatic factor of safety]      : No
 \end{desclist}
 
 \section*{Revision}
 
-HNG, Jul 12, 2011; HNG, May 20, 2011; HNG, Jan 17, 2011
+HNG, Sep 08, 2011; HNG, Jul 12, 2011; HNG, May 20, 2011; HNG, Jan 17, 2011
 
 
 \chapter{Getting started}
@@ -132,11 +145,12 @@
 
  
 \texttt{\pack/}
-\begin{adescription}{~~partition/}
+\begin{adescription}{~~CMakeLists.txt}
 \item[~~COPYING]               : License.
 \item[~~README]                : brief description of the package.
+\item[~~CMakeLists.txt]        : CMake configuration file.
 \item[~~bin/]                  : all object files and executables are stored in this folder.
-\item[~~doc/]                   : documentation (including this file) of the \pack\ package.
+\item[~~doc/]                  : documentation files for the \pack\ package. If built this file is created.
 \item[~~input/]                : contains input files.
 \item[~~partition/]            : contains partition files for parallel processing.
 \item[~~output/]               : default output folder. All output files are stored in this folder unless the different output path is defined in the main input file.
@@ -145,80 +159,120 @@
    
 \section{Prerequisites}
 \begin{itemize}[-]
-  \item \underline{GNU make utility}. The make utility is necessary to build the software using Makefile. This utility is usually installed by default in most of the LINUX systems. In WINDOWS, one can use Cygwin (\texttt{www.cygwin.com}) or MinGW (\texttt{www.mingw.org}) to install the make utility. 
+  \item \underline{CMake build system}. The CMake version >= 2.8.4 is necessary to configure the software. It is free and open-source, and can be downloaded from \texttt{www.cmake.org}.
+  \item \underline{Make utility}. The make utility is necessary to build the software using Makefile. This utility is usually installed by default in most of the LINUX systems. In WINDOWS, one can use Cygwin (\texttt{www.cygwin.com}) or MinGW (\texttt{www.mingw.org}) to install the make utility. 
   \item \underline{A recent FORTRAN compiler}. The software is written mainly in FORTRAN 90, but it also uses a few FORTRAN 2003 features (e.g., streaming IO). These features are already available in most of the FORTRAN compilers, e.g., gfortran version >= 4.2 (\texttt{gcc.gnu.org/wiki/GFortran}) and g95 (\texttt{www.g95.org}).
 \end{itemize}
-  Additionally, following libraries are necessary for parallel processing:
+  Following libraries are necessary for parallel processing.
 \begin{itemize}[-]
   \item \underline{A recent MPI library}. It should be built with same FORTRAN compiler which will be used to compile the software. Please see \texttt{www.open-mpi.org} or \linebreak\texttt{www.mcs.anl.gov/research/projects/mpich2} for detail on how to install MPI library and how to run MPI programs.
   \item \underline{SCOTCH graph partitioning library}. This library should be compiled with same\linebreak FORTRAN compiler which will be used to compile the software. Please see\linebreak \texttt{www.labri.fr/perso/pelegrin/scotch} for detail on how to install SCOTCH. Version 5.1.7 was successfully tested with \pack.
 \end{itemize}
-
-\section{Compile}
-\subsubsection{Serial program}
+  
+  Finally, following compiler is necessary to build the documentation (this file).
 \begin{itemize}[-]
-  \item Go to \texttt{src/} folder
-  \item Open \texttt{Makefile} and edit if necessary. Check the compiler and compiler flags defined in the variables \sq{FC} and \sq{FFLAGS}, respectively. Please note that the compiler flags may be different depending on the compiler.  
-	  
-  \item To build the serial program, type\\
-	  \texttt{make semgeotech}
-  \item To clean, type\\
-	  \texttt{make clean}
+  \item \underline{\LaTeX\ compiler}. This is necessary to compile the documentation files.
 \end{itemize}
 
-\subsubsection{Parallel program}
-\begin{itemize}[-]
-  \item Go to \texttt{src/} folder
-  \item Open \texttt{Makefile} and edit if necessary. Check the compiler and compiler flags defined in the variables \sq{FC} and \sq{FFLAGS}, respectively. Please note that the compiler flags may be different depending on the compiler. An appropriate MPI fortran compiler, e.g., \texttt{mpif90} should be defined in \sq{FC}. Additionally, check the MPI library and SCOTCH library defined in the variables \sq{LIBMPI} and \sq{LIBSCOTCH}, respectively. The SCOTCH library is necessary only for the mesh partitioning.
-	  
-  \item To build the parallel program, type\\
-	  \texttt{make psemgeotech}  
-	 
-  \item To build mesh partitioning program, type\\
-	  \texttt{make partmesh}
-	  
-  \item To build all programs, i.e., serial program, parallel program, and mesh partitioning program at once, type\\
-	  \texttt{make all}
-	  
+\section{Configure}
+\label{sec:configure}
+
+Software package \pack\ is configured using CMake, and the package uses out-of-source build. Hence, \underline{DO NOT} build in the same source directory. Let's say the full path to the package (source directory) is \texttt{\$HOME/download/\pack}.  
+
+\begin{itemize}
+\item Create a separate build directory, e.g.,\\
+\texttt{mkdir \$HOME/work/\pack}
+
+\item Go to build directory \\
+\texttt{cd \$HOME/work/\pack}
+
+\item Type cmake command \\
+\texttt{ccmake \$HOME/projects/\pack}
+\end{itemize}
+
+\begin{figure}[ht]
+\centering
+\includegraphics[scale=1.0]{cmake}
+\caption{CMake configuration of \pack\ .}
+\label{fig:cmake}
+\end{figure}
+
+CMake configuration is an iterative process (See Figure~\ref{fig:cmake}):
+\begin{itemize}
+\item Configure (c key or Configure button)
+\item Change variables' values if necessary
+\item Configure (c key or Configure button)
+\end{itemize}
+
+If WARNINGS or ERRORS occur, press e key (or OK button) to return to configuration. These steps have to be repeated until successful configuration. Then, press g key (or Generate button) to generate build files. Check carefully that all necessary variables are set properly. Unless configuration is successful, generate is not enabled. Sometimes, c key (or Configure button) has to be pressed repeatedly until generate is enabled. Initially, all variables may not be visible. To see all variables, toggle advanced mode pressing t key (or Advanced button).
+To set or change a variable, move the cursor to the variable and press Enter key. If the variable is a boolean (ON/OFF), it will flip the value on pressing the Enter key. If the variable is a string or a file, it can be edited. For more detail, please see the CMake documentation (\texttt{www.cmake.org}).
+\\
+
+Following are the main CMake variables for the \pack\ (See Figure~\ref{fig:cmake})
+
+\colorbox{gray}{
+\parbox{15.5cm}{
+\begin{adescription}{BUILD\_UTILITIES\_EXODUS2SEM}
+\item[BUILD\_DOCUMENTATION]           : If \texttt{ON}, user manual (this file) is created. The default is \texttt{OFF}.
+\item[BUILD\_PARTMESH]                : If \texttt{ON}, \texttt{partmesh} program is built. The default is \texttt{OFF}. The \texttt{partmesh} program is necessary to partition the mesh for parallel processing.
+\item[BUILD\_UTILITIES\_EXODUS2SEM]   : If \texttt{ON}, \texttt{exodus2sem} program is built. The default is \texttt{OFF}. The \texttt{exodus2sem} program convert exodus mesh file to input files required by the \pack\ package (see also Chapter~\ref{chap:utilities}).
+\item[BUILD\_UTILITIES\_WRITE\_SOS]   : If \texttt{ON}, \texttt{write\_sos} program is built. The default is \texttt{OFF}. The \texttt{write\_sos} program writes a EnSight SOS file necessary for the parallel visualization (see also Chapter~\ref{chap:utilities}).
+\item[ENABLE\_MPI]                    : If \texttt{ON}, main parallel program \texttt{psemgeotech} is built otherwise main serial program \texttt{semgeotech} is built. The default is \texttt{OFF}.
+\item[SCOTCH\_LIBRARY\_PATH]          : This is required if \texttt{BUILD\_PARTMESH} is \texttt{ON}. If not found automatically, it can be set manually.
+\item[CMAKE\_Fortran\_COMPILER]       : This defines the Fortran compiler. If not found automatically or automatically found compiler is not correct, it can be set manually.
+\end{adescription}
+}}\\
+
+{\emph{Note 1: If}} \texttt{CMAKE\_Fortran\_COMPILER} {\emph{has to be changed, first change this and configure, and then change other variables if necessary and configure.}}\\
+{\emph{Note 2: Even if some of the above variables are set }} \texttt{ON}{\emph{, if appropriate working compilers are not found, corresponding variables are internally set}} \texttt{OFF} {\emph{with WARNING message.}}
+
+\section{Compile}
+\begin{itemize}[]
+  \item Once configuration and generation are successful, necessary build files are created. Now to build the main program, type: \\
+  \texttt{make}
+  
+  \item On the multi-processor system (let's say eight processor), type:\\
+  \texttt{make -j 8}
+  
   \item To clean, type\\
-	  \texttt{make clean}
+  \texttt{make clean}
+  \item{\emph{Note: If reconfiguration is necessary, it is better to delete all Cache files of the build directory.}}
 \end{itemize}
-{\emph{Note: serial program can be compiled with the same MPI fortran compiler used for the parallel program, but the other way around is not always true.}}
 
 \section{Run}
 \subsubsection{Serial run}
 \begin{itemize}[-]
 \item To run serial program, type \\
-	  \texttt{../bin/semgeotech} \emph{input\_file\_name}
+	  \texttt{./bin/semgeotech} \emph{input\_file\_name}
 	  
 	  Example:
 	  
-	  \texttt{../bin/semgeotech ../input/validation1.sem}
+	  \texttt{./bin/semgeotech ./input/validation1.sem}
 	  
 \end{itemize}
 
 \subsubsection{Parallel run} 
 \begin{itemize}[-]
 \item To partition the mesh, type \\
-	  \texttt{../bin/partmesh} \emph{input\_file\_name}
+	  \texttt{./bin/partmesh} \emph{input\_file\_name}
 	  
 	  Example:
 	  
-	  \texttt{../bin/partmesh ../input/validation1.psem}
+	  \texttt{./bin/partmesh ./input/validation1.psem}
 	  
 \item To run parallel program, type \\
-	  \texttt{mpirun -n} \emph{number\_of\_nodes} \texttt{../bin/psemgeotech} \emph{input\_file\_name} \\
+	  \texttt{mpirun -n} \emph{number\_of\_nodes} \texttt{./bin/psemgeotech} \emph{input\_file\_name} \\
 	  
 	  OR
 	  
-	  \texttt{mpirun -n} \emph{number\_of\_nodes} \texttt{-{}-hostfile} \emph{host\_file} \texttt{../bin/psemgeotech} \emph{input\_file\_name}
+	  \texttt{mpirun -n} \emph{number\_of\_nodes} \texttt{-{}-hostfile} \emph{host\_file} \texttt{./bin/psemgeotech} \emph{input\_file\_name}
 	  
 	  Example:
 	  
-	  \texttt{mpirun -n 8 ../bin/psemgeotech ../input/validation1.psem}
+	  \texttt{mpirun -n 8 ./bin/psemgeotech ./input/validation1.psem}
 \end{itemize}
 
-{\emph{Note: see Chapter~\ref{chap:input} for detail on input and input files. Try to run one or more examples included in} \texttt{input/}.
+{\emph{Note: see Chapter~\ref{chap:input} for detail on input and input files. Try to run one or more examples included in}} \texttt{input/}{\emph{. By default, example files included in the package are not copied to build directory during build process. If necessary, copy files within}} \texttt{input/} {\emph{folder of source directory to the}} \texttt{input/} {\emph{folder of build directory.}}
 
 \chapter{Input}
 \label{chap:input}
@@ -245,6 +299,7 @@
 \item[mesh:]     mesh information
 \item[bc:]      boundary conditions information
 \item[traction:] traction information [optional]
+\item[stress0:] initial stress information [optional]. It is generally necessary for multistage excavation.
 \item[material:] material properties
 \item[eqload:]   pseudo-static earthquake loading [optional]
 \item[water:]    water table information [optional]
@@ -292,6 +347,15 @@
   \item[trfile]: file name of traction specification [string].\\ 
 \end{adescription}
 
+\texttt{\underline{stress0:}}
+\begin{adescription}{nl\_maxiter}
+  \item[type]: type of initial stress [integer, optional, 0 = compute using SEM itself, 1 = compute using simple vertical lithostatic relation, default $\Rightarrow$ 0].
+  \item[z0]: datum (free surface) coordinate [real, m]. Only required if \texttt{type}=1.
+  \item[s0]: datum (free surface) vertical stress [real, kN/m\tsup{2}]. Only required if \texttt{type}=1.
+  \item[k0]: lateral earth pressure coefficient [real].
+  \\
+\end{adescription}
+
 \texttt{\underline{material:}}
 \begin{adescription}{nl\_maxiter}
   \item[matfile]: file name of material list [string].
@@ -320,23 +384,56 @@
   \item[cg\_maxiter]: maximum iterations for conjugate gradient method [integer > 0].
   \item[nl\_tol]: tolerance for nonlinear iterations [real].
   \item[nl\_maxiter]: maximum iterations for nonlinear iterations [integer > 0].
-  \item[nsrf]: number of strength reducing factors to try [integer > 0, optional, default $\Rightarrow$ 1].
+  \item[ninc]: number of load increments for the plastic iterations [integer>0  default $\Rightarrow$ 1].This is currently not used for slope stability analysis.
+  \item[Arguments specific to slope stability analysis:]
+  \item[nsrf]: number of strength reduction factors to try [integer > 0, optional, default $\Rightarrow$ 1].
   \item[srf]: values of strength reduction factors [real vector, optional, default $\Rightarrow$ 1.0]. Number of \texttt{srf}s must be equal to \texttt{nsrf}.
-  \item[phinu]: force $\phi-\nu$ (Friction angle - Poisson's ratio) inequality: $\sin\phi\geq 1-2\,\nu$ \citep[see][]{zheng2005} [integer, 0 = No, 1 = Yes, default $\Rightarrow$ 0]. Only for \underline{TESTING} purpose. \\
+  \item[phinu]: force $\phi-\nu$ (Friction angle - Poisson's ratio) inequality: $\sin\phi\geq 1-2\,\nu$ \citep[see][]{zheng2005} [integer, 0 = No, 1 = Yes, default $\Rightarrow$ 0]. Only for \underline{TESTING} purpose. 
+  \item[Arguments specific to multistage excavation:]  
+  \item[nexcav]: number of excavation stages [integer > 0, optional, default $\Rightarrow$ 1].
+  \item[nexcavid]: number of excavation IDs in each excavation stage [integer vector, default $\Rightarrow$ {1}].
+  \item[excavid]: IDs of blocks/regions in the mesh to be excavated in each stage [integer vector, default $\Rightarrow$ {1}].
+  \\\\
+  {\emph{Note: Do not mix arguments for slope stability and excavation.}} \\
 \end{adescription}
 
 \texttt{\underline{save:}}
 \begin{adescription}{porep}
-  \item[disp]: displacement field [integer, 0 = No, 1 = Yes].
-  \item[porep]: pore water pressure [integer, 0 = No, 1 = Yes].\\
+  \item[disp]: displacement field [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 0].
+  \item[porep]: pore water pressure [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 0].\\
 \end{adescription}
   
 \subsection{Examples of main input file}
 
-\subsubsection*{Serial input file:}
+\subsubsection*{Input file for a simple elastic simulation}
 
+\colorbox{gray}{
+\parbox{16cm}{
+\noindent{\texttt{\#-----------------------------------------------------------------\\
+\#input file elastic.sem\\ 
+\#pre information\\
+preinfo: ngllx=3, nglly=3, ngllz=3, nenod=8, ngnod=8, \& \\
+inp\_path=\sq{../input}, out\_path=\sq{../output/}\\\\
+\#mesh information \\
+mesh: xfile=\sq{validation1\_coord\_x}, yfile=\sq{validation1\_coord\_y}, \& \\
+zfile=\sq{validation1\_coord\_z}, confile=\sq{validation1\_connectivity}, \& \\
+idfile=\sq{validation1\_material\_id}\\\\
+\#boundary conditions\\
+bc: uxfile=\sq{validation1\_ssbcux}, uyfile=\sq{validation1\_ssbcuy}, \& \\
+uzfile=\sq{validation1\_ssbcuz}\\\\
+\#material list\\
+material: matfile=\sq{validation1\_material\_list}, allelastic=1\\\\
+\#control parameters\\
+control: cg\_tol=1e-8, cg\_maxiter=5000\\
+\#-----------------------------------------------------------------}}\\\\
+}}
 
+\subsubsection*{Serial input file for slope stability}
+
+\colorbox{gray}{
+\parbox{16cm}{
 \noindent{\texttt{\#-----------------------------------------------------------------\\
+\#input file validation1.sem\\
 \#pre information\\
 preinfo: ngllx=3, nglly=3, ngllz=3, nenod=8, ngnod=8, \& \\
 inp\_path=\sq{../input}, out\_path=\sq{../output/}\\\\
@@ -353,10 +450,14 @@
 control: cg\_tol=1e-8, cg\_maxiter=5000, nl\_tol=0.0005, nl\_maxiter=3000, \& \\
 nsrf=9, srf=1.0 1.5 2.0 2.15 2.16 2.17 2.18 2.19 2.20\\
 \#-----------------------------------------------------------------}}\\\\
+}}
 
-\subsubsection*{Parallel input file:}
+\subsubsection*{Parallel input file for slope stability}
 
+\colorbox{gray}{
+\parbox{16cm}{
 \noindent{\texttt{\#-----------------------------------------------------------------\\
+\#input file validation1.psem\\
 \#pre information\\
 preinfo: nproc=8, ngllx=3, nglly=3, ngllz=3, nenod=8, \& \\
 ngnod=8, inp\_path=\sq{../input}, out\_path=\sq{../output/}\\\\
@@ -373,30 +474,65 @@
 control: cg\_tol=1e-8, cg\_maxiter=5000, nl\_tol=0.0005, nl\_maxiter=3000, \& \\
 nsrf=9, srf=1.0 1.5 2.0 2.15 2.16 2.17 2.18 2.19 2.20\\
 \#-----------------------------------------------------------------\\}}
+}}
 
+\subsubsection*{Serial input file for excavation}
 
-There are only two additional informations, i.e., number of processors \texttt{\sq{nproc}} in line \texttt{\sq{preinfo}} and file name for ghost partition interfaces \texttt{\sq{gfile}} in line \texttt{\sq{mesh}} in parallel input file.
-
-\subsubsection*{Input file for a simple elastic simulation}
-
+\colorbox{gray}{
+\parbox{16cm}{
 \noindent{\texttt{\#-----------------------------------------------------------------\\
+\#input file excavation\_3d.sem\\
 \#pre information\\
 preinfo: ngllx=3, nglly=3, ngllz=3, nenod=8, ngnod=8, \& \\
 inp\_path=\sq{../input}, out\_path=\sq{../output/}\\\\
 \#mesh information \\
-mesh: xfile=\sq{validation1\_coord\_x}, yfile=\sq{validation1\_coord\_y}, \& \\
-zfile=\sq{validation1\_coord\_z}, confile=\sq{validation1\_connectivity}, \& \\
-idfile=\sq{validation1\_material\_id}\\\\
+mesh: xfile=\sq{excavation\_3d\_coord\_x}, yfile=\sq{excavation\_3d\_coord\_y}, \& \\
+zfile=\sq{excavation\_3d\_coord\_z}, confile=\sq{excavation\_3d\_connectivity}, \& \\
+idfile=\sq{excavation\_3d\_material\_id}\\\\
 \#boundary conditions\\
-bc: uxfile=\sq{validation1\_ssbcux}, uyfile=\sq{validation1\_ssbcuy}, \& \\
-uzfile=\sq{validation1\_ssbcuz}\\\\
+bc: uxfile=\sq{excavation\_3d\_ssbcux}, uyfile=\sq{excavation\_3d\_ssbcuy}, \& \\
+uzfile=\sq{excavation\_3d\_ssbcuz}\\\\
+\#initial stress
+stress0: type=0, z0=0, s0=0, k0=0.5, usek0=1\\\\
 \#material list\\
-material: matfile=\sq{validation1\_material\_list}, allelastic=1\\\\
+material: matfile=\sq{excavation\_3d\_material\_list}\\\\
 \#control parameters\\
-control: cg\_tol=1e-8, cg\_maxiter=5000\\
+control: cg\_tol=1e-8, cg\_maxiter=5000, nl\_tol=0.0005, nl\_maxiter=3000, \& \\
+nexcav=3, excavid=2 3 4, ninc=10\\
 \#-----------------------------------------------------------------}}\\\\
+}}
 
+\subsubsection*{Parallel input file for excavation}
+
+\colorbox{gray}{
+\parbox{16cm}{
+\noindent{\texttt{\#-----------------------------------------------------------------\\
+\#input file excavation\_3d.psem\\
+\#pre information\\
+preinfo: nproc=8, ngllx=3, nglly=3, ngllz=3, nenod=8, \& \\
+ngnod=8, inp\_path=\sq{../input}, out\_path=\sq{../output/}\\\\
+\#mesh information \\
+mesh: xfile=\sq{excavation\_3d\_coord\_x}, yfile=\sq{excavation\_3d\_coord\_y}, \& \\
+zfile=\sq{excavation\_3d\_coord\_z}, confile=\sq{excavation\_3d\_connectivity}, \& \\
+idfile=\sq{excavation\_3d\_material\_id}, gfile=\sq{excavation\_3d\_ghost}\\\\
+\#boundary conditions\\
+bc: uxfile=\sq{excavation\_3d\_ssbcux}, uyfile=\sq{excavation\_3d\_ssbcuy}, \& \\
+uzfile=\sq{excavation\_3d\_ssbcuz}\\\\
+\#initial stress
+stress0: type=0, z0=0, s0=0, k0=0.5, usek0=1\\\\
+\#material list\\
+material: matfile=\sq{excavation\_3d\_material\_list}\\\\
+\#control parameters\\
+control: cg\_tol=1e-8, cg\_maxiter=5000, nl\_tol=0.0005, nl\_maxiter=3000, \& \\
+nexcav=3, excavid=2 3 4, ninc=10\\
+\#-----------------------------------------------------------------\\}}
+}}
+\\
+
+There are only two additional informations, i.e., number of processors \texttt{\sq{nproc}} in line \texttt{\sq{preinfo}} and file name for ghost partition interfaces \texttt{\sq{gfile}} in line \texttt{\sq{mesh}} in parallel input file.
+
 \section{Input files detail}
+All local element/face/edge/node numbering follows the EXODUS II convention.\\
 
 \subsection{Coordinates files: \texttt{xfile, yfile, zfile}}
 Each of the coordinates files contains list of corresponding coordinates in following format:\\
@@ -434,7 +570,6 @@
 ..\\
 ..}\\
 
-Note: local node numbering follows the EXODUS II convention.\\
 
 Example:\\\\
 1800\\
@@ -454,7 +589,7 @@
 ...\\
 ...\\}
 
-\subsection{Element IDs file: \texttt{idfile}}
+\subsection{Element IDs (or Material IDs) file: \texttt{idfile}}
 
 
 This file contains the IDs of elements. This ID will be used in the program mainly to identify the material regions. This file has a following format: \\
@@ -488,10 +623,33 @@
 
 This file will be generated automatically by a program \texttt{partmesh}.\\
 
+\subsection{Displacement boundary conditions files: \texttt{uxfile, uyfile, uzfile}}
 
+This file contains information on the displacement boundary conditions (currently only the zero-displacement is implemented), and has following format:\\
+ 
+\emph{number of element faces}\\
+\emph{elementID faceID \\
+elementID faceID \\
+elementID faceID \\
+...\\
+...\\}
+
+Example:\\
+\\
+\texttt{849\\
+2 2\\
+3 4\\
+5 1\\
+6 1\\
+7 1\\
+8 1\\
+9 1\\
+...\\
+...}\\
+
 \subsection{Traction file: \texttt{trfile}}
 
-This file contains the traction information on the model in the format as\\
+This file contains the traction information on the model in the following format:\\
 
 \emph{traction type} (integer, 0 = point, 1 = uniformly distributed, 2 = linearly distributed)\\
 if \emph{traction type} = 0\\
@@ -538,16 +696,54 @@
 44 1\\
 45 1\\
 46 1\\
-47 1\\
-48 1\\
-49 1\\
-50 1\\
-51 1\\
-52 1\\
-53 1\\
 ...\\
 ...}\\
 
+\subsection{Material list file: \texttt{matfile}}
+
+This file contains material properties of each material regions. Material properties must be listed in a sequential order of the unique material IDs. In addition, this data file optionally contains the information on the water condition of material regions. Material regions or material IDs must be consistent with the Material IDs (Element IDs) defined in \texttt{idfile}. The \texttt{matfile} has following format:\\\\
+
+\emph{comment line}\\
+\emph{number of material regions (unique material IDs)\\
+materialID, domainID, $\gamma$, $E$, $\nu$, $\phi$, $c$, $\psi$ \\
+materialID, domainID, $\gamma$, $E$, $\nu$, $\phi$, $c$, $\psi$ \\
+materialID, domainID, $\gamma$, $E$, $\nu$, $\phi$, $c$, $\psi$ \\
+...\\
+...\\
+number of submerged material regions\\
+submerged materialID\\
+submerged materialID\\
+...\\
+...\\}
+
+The \emph{materilID} must be in a sequential order starting from 1. The \emph{doaminID} represents the material domain (e.g., isotropic or anisotropic), and it is currently irrelevant, therefore, always use 1. Similarly, $\gamma$ represents the unit weight in kN/m\tsup{3}, $E$ the Young's modulus of elasticity in kN/m\tsup{2}, $\phi$ the angle of internal friction in degrees, $c$ the cohesion in kN/m\tsup{2}, and $\psi$ the angle of dilation in degrees.\\
+
+Example:\\
+\\
+Following data defines four material regions. No region is submerged in water.\\
+
+\texttt{\# material properties (id, domain, gamma, ym, nu, phi, coh, psi)\\
+4\\
+1 1 18.8 1e5 0.3 20.0 29.0 0.0\\
+2 1 19.0 1e5 0.3 20.0 27.0 0.0\\
+3 1 18.1 1e5 0.3 20.0 20.0 0.0\\
+4 1 18.5 1e5 0.3 20.0 29.0 0.0\\
+}\\
+
+Following data defines four material regions with two of them submerged.\\
+
+\texttt{\# material properties (id, domain, gamma, ym, nu, phi, coh, psi)\\
+4\\
+1 1 18.8 1e5 0.3 20.0 0.0 0.0\\
+2 1 19.0 1e5 0.3 20.0 27.0 0.0\\
+3 1 18.1 1e5 0.3 20.0 0.0 0.0\\
+4 1 18.5 1e5 0.3 20.0 29.0 0.0\\
+2\\
+1\\
+3\\
+}\\
+
+
 \subsection{Water surface file: \texttt{wsfile}}
 
 This file contains the water table information on the model in the format as
@@ -560,11 +756,11 @@
   \emph{relevant-axis $x_1$ $x_2$ $z_1$ $z_2$}\\
 if \emph{wstype}=2 (meshed surface attached to the model)\\
   \emph{number of faces\\
-  elelemet ID, face ID\\
-  elelemet ID, face ID\\
-  elelemet ID, face ID\\
-  ...           ...\\
-  ...           ...}\\
+  elelemetID, faceID\\
+  elelemetID, faceID\\
+  elelemetID, faceID\\
+  ...\\
+  ...}\\
   
 The \emph{relevant-axis} denotes the axis along which the line is defined, and it is taken as 1 = $x$-axis, 2 = $y$-axis, and 3 = $z$-axis. The variables $x_1$ and $x_2$ denote the coordinates (only \emph{relevant-axis}) of point 1 and 2 that define the line. Similarly, $z$ denotes a $z$-coordinate of a horizontal water surface, and $z_1$ and $z_2$ denote the $z$-coordinates of the two points (that define the line) on the water surface.\\
   
@@ -644,13 +840,13 @@
 \label{chap:utilities}
 \section{Convert EXODUS mesh into SEM files}
 
-The program \texttt{exodus2sem.c} contained in the utilities directory can be used to convert the mesh file in EXODUS II format to input files required by the SPECFEM3D\_SLOPE.
+The program \texttt{exodus2sem.c} contained in the utilities directory can be used to convert the mesh file in EXODUS II format to input files required by the \pack\ .
 
 \subsubsection*{Compile}
 \texttt{gcc -o exodus2sem exodus2sem.c}
 \subsubsection*{Run}
  \texttt{exodus2sem} {\emph{EXODUS\_mesh\_file}} {\emph{OPTIONS}}\\
- For more detail, see \texttt{/utilities/README\_exodus2sem}.
+ For more detail, see \texttt{/utilities/README\_exodus2sem}. It can also be compiled automatically during the build process of main package \pack\ (see Section~\ref{sec:configure}).
 
 \section{Generate SOS file}
 \label{sec:sos}
@@ -661,7 +857,7 @@
 \subsubsection*{Run}
 \texttt{exodus2sem} {\it{input\_file}}\\
 
-For more detail, see \texttt{/utilities/README\_write\_sos}.
+For more detail, see \texttt{/utilities/README\_write\_sos}. It can also be compiled automatically during the build process of main package \pack\ (see Section~\ref{sec:configure}).
 
 \bibliographystyle{chicago}
 \bibliography{SPECFEM3D_GEOTECH}

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example1_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example1_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example1_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 1
 1, 1, 18.2, 1e5, 0.3, 37.0, 13.8, 0.0
 1

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_left_fixed_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_left_fixed_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_left_fixed_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 1
 1, 1, 26.86, 40e9, 0.13, 27.6, 200, 13.8
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/example2_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 1
 1, 1, 26.86, 40e9, 0.13, 27.6, 200, 13.8
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation1_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation1_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation1_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 1
 1, 1, 18.8, 1e5, 0.3, 20.0, 29.0, 0.0
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation2_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation2_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation2_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 2
 1, 1, 18.8, 1e5, 0.3, 20.0, 29.0, 0.0
 2, 1, 18.8, 1e5, 0.3, 10.0, 0.0, 0.0

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation3_material_list
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation3_material_list	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/input/validation3_material_list	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,4 +1,4 @@
-# material properties (domain,id,gamma,ym,nu,phi,coh,psi)
+# material properties (id,domain,gamma,ym,nu,phi,coh,psi)
 3
 1, 1, 18.8, 1e5, 0.3, 20.0, 29.0, 0.0
 2, 1, 18.8, 1e5, 0.3, 20.0, 29.0, 0.0

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/Makefile
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/Makefile	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/Makefile	2011-09-09 07:06:01 UTC (rev 18884)
@@ -4,11 +4,14 @@
 # binary directory
 BIN = ../bin
 
-# fortran compiler
+# serial fortran compiler
 #FC = gfortran
 #FFLAGS = -g -std=f2003 -fbounds-check -fimplicit-none -O5 -pedantic -pedantic-errors -Wline-truncation -fno-trapping-math -fno-backslash
-FC = mpif90 # OR path to appropriate MPI forrtan compiler
+
+# parallel fortran compiler
+FC = ~/openmpi-1.4.3/bin/mpif90 # OR path to appropriate MPI forrtan compiler
 FFLAGS = -g -std=f2003 -fbounds-check -fimplicit-none -O5 -pedantic -pedantic-errors -Wline-truncation -fno-trapping-math -fno-backslash
+
 FC_COMPILE = $(FC) $(FFLAGS)
 
 # C compiler
@@ -17,7 +20,7 @@
 CC_COMPILE = $(CC) $(CFLAGS)
 
 LIB = 
-LIBMPI = -lmpi # OR path to appropriate MPI library
+LIBMPI = -L/~/openmpi-1.4.3/lib/lmpi # OR path to appropriate MPI library
 LIBSCOTCH = -L/staff/homnath/lsoft/scotch_5.1.7/lib -lscotch -lscotcherr
 
 # object tree
@@ -27,40 +30,47 @@
       $(BIN)/shape_library.o    \
       $(BIN)/compute_bmat.o     \
       $(BIN)/compute_cmat.o     \
-      $(BIN)/read_input.o   \
+      $(BIN)/read_input.o       \
       $(BIN)/gll_library.o      \
       $(BIN)/mesh_spec.o        \
       $(BIN)/apply_bc.o         \
-      $(BIN)/preprocess.o \
+      $(BIN)/preprocess.o       \
       $(BIN)/apply_traction.o   \
       $(BIN)/compute_pressure.o \
-      $(BIN)/plastic_library.o \
-      $(BIN)/visual.o \
+      $(BIN)/plastic_library.o  \
+      $(BIN)/visual.o           \
       $(BIN)/postprocess.o
 
-# object files for SEM
-OBJ_SEM = $(BIN)/serial_library.o \
+# object tree for SEM
+OBJ_SEM = $(BIN)/serial_library.o      \
+          $(BIN)/math_library_serial.o \
           $(BIN)/solver.o
 
 # object tree for SEMMPI parallel
 OBJ_SEMMPI = $(BIN)/set_precision_mpi.o \
-          $(BIN)/mpi_library.o      \
-          $(BIN)/math_library_mpi.o \
-          $(BIN)/ghost_library_mpi.o\
-          $(BIN)/solver_mpi.o
-          
+             $(BIN)/mpi_library.o       \
+             $(BIN)/math_library_mpi.o  \
+             $(BIN)/ghost_library_mpi.o \
+             $(BIN)/solver_mpi.o
+
+# object tree for EXCAVATION
+OBJ_EXCAV = $(BIN)/excavation.o 
+
+# object tree for SEM
+OBJ_SEM = $(BIN)/serial_library.o      \
+          $(BIN)/math_library_serial.o \
+          $(BIN)/solver.o
+         
+# object tree for PARTMESH
 OBJ_PARTMESH = $(BIN)/global.o           \
-        $(BIN)/string_library.o \
-				$(BIN)/partmesh_library.o \
-				$(BIN)/partmesh_scotch.o \
-				$(BIN)/partmesh.o
+               $(BIN)/string_library.o   \
+               $(BIN)/partmesh_library.o \
+	       $(BIN)/partmesh_scotch.o  \
+               $(BIN)/partmesh.o
 				
-OBJ_semdlope3d = 
-     
-OBJ_semgeotech = $(OBJ) $(OBJ_SEM) $(BIN)/semslope3d.o $(BIN)/semgeotech.o
-OBJ_psemgeotech = $(OBJ) $(OBJ_SEMMPI) $(BIN)/psemslope3d.o  $(BIN)/psemgeotech.o
+OBJ_semgeotech = $(OBJ) $(OBJ_SEM) $(BIN)/semslope3d.o $(OBJ_EXCAV) $(BIN)/semexcav3d.o $(BIN)/semgeotech.o
+OBJ_psemgeotech = $(OBJ) $(OBJ_SEMMPI) $(BIN)/psemslope3d.o $(OBJ_EXCAV) $(BIN)/psemexcav3d.o $(BIN)/psemgeotech.o
 
-
 # main executable for spectral-element method
 semgeotech = $(BIN)/semgeotech
 psemgeotech = $(BIN)/psemgeotech
@@ -103,7 +113,10 @@
 	
 $(BIN)/serial_library.o: serial_library.f90
 	$(FC_COMPILE) -c -o $(BIN)/serial_library.o serial_library.f90
-	
+
+$(BIN)/math_library_serial.o: math_library_serial.f90
+	$(FC_COMPILE) -c -o $(BIN)/math_library_serial.o math_library_serial.f90
+
 $(BIN)/math_library_mpi.o: math_library_mpi.f90
 	$(FC_COMPILE) -c -o $(BIN)/math_library_mpi.o math_library_mpi.f90
 
@@ -160,25 +173,36 @@
 
 # following objective files are compiled from the same file but with 
 # different compiler preprocessing directives options.
-# -cpp enables the compiler preprocessing.
 # -DUSE_MPI provides the flag to use the MPI library for the compilation.
 # the flag -DUSE_MPI is equivalent to #define USE_MPI 1.
-$(BIN)/semslope3d.o: semslope3d.f90
-	$(FC_COMPILE) -cpp -c -o $(BIN)/semslope3d.o semslope3d.f90
+$(BIN)/semslope3d.o: semslope3d.F90
+	$(FC_COMPILE) -c -o $(BIN)/semslope3d.o semslope3d.F90
 	
-$(BIN)/psemslope3d.o: semslope3d.f90
-	$(FC_COMPILE) -cpp -DUSE_MPI -c -o $(BIN)/psemslope3d.o semslope3d.f90
+$(BIN)/psemslope3d.o: semslope3d.F90
+	$(FC_COMPILE) -DUSE_MPI -c -o $(BIN)/psemslope3d.o semslope3d.F90
+
+$(BIN)/excavation.o: excavation.f90
+	$(FC_COMPILE) -c -o $(BIN)/excavation.o excavation.f90
+
+# following objective files are compiled from the same file but with 
+# different compiler preprocessing directives options.
+# -DUSE_MPI provides the flag to use the MPI library for the compilation.
+# the flag -DUSE_MPI is equivalent to #define USE_MPI 1.
+$(BIN)/semexcav3d.o: semexcav3d.F90
+	$(FC_COMPILE) -c -o $(BIN)/semexcav3d.o semexcav3d.F90
 	
+$(BIN)/psemexcav3d.o: semexcav3d.F90
+	$(FC_COMPILE) -DUSE_MPI -c -o $(BIN)/psemexcav3d.o semexcav3d.F90
+	
 # following objective files are compiled from the same file but with 
 # different compiler preprocessing directives options.
-$(BIN)/semgeotech.o: semgeotech.f90
-	$(FC_COMPILE) -cpp -c -o $(BIN)/semgeotech.o semgeotech.f90
+$(BIN)/semgeotech.o: semgeotech.F90
+	$(FC_COMPILE) -c -o $(BIN)/semgeotech.o semgeotech.F90
 	
-$(BIN)/psemgeotech.o: semgeotech.f90
-	$(FC_COMPILE) -cpp -DUSE_MPI -c -o $(BIN)/psemgeotech.o semgeotech.f90
+$(BIN)/psemgeotech.o: semgeotech.F90
+	$(FC_COMPILE) -DUSE_MPI -c -o $(BIN)/psemgeotech.o semgeotech.F90
 	
 # mesh partition
-	
 $(BIN)/partmesh_library.o: partmesh_library.f90
 	$(FC_COMPILE) -c -o $(BIN)/partmesh_library.o partmesh_library.f90
 
@@ -187,3 +211,5 @@
 
 $(BIN)/partmesh.o: partmesh.f90
 	$(FC_COMPILE) -c -o $(BIN)/partmesh.o partmesh.f90
+
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,5 +1,9 @@
 ! this module contains the routines to process parallel communications across 
 ! the ghost partitions
+! TODO:
+!   - better to avoid using allocatable component of derived type variable which
+!     is fortran 95 standard? How much influence will be on the performance with
+!     repeated allocate and deallocate
 ! REVISION:
 !   HNG, APR 15,2011; HNG, Apr 09,2010
 module ghost_library_mpi
@@ -24,7 +28,7 @@
 use global,only:ndim,nnode,nndof,ngllx,nglly,ngllz,g_num,g_coord,gfile,        &
 part_path,stdout
 use math_library, only : quick_sort
-use math_library_mpi, only : maxvec_par
+use math_library_mpi, only : maxvec
 
 implicit none
 integer,intent(in) :: myid,nproc
@@ -231,7 +235,7 @@
 enddo ! do i_gpart
 close(11)
 !stop
-maxngnode=maxvec_par(gpart(1:ngpart)%nnode)
+maxngnode=maxvec(gpart(1:ngpart)%nnode)
 
 return
 end subroutine prepare_ghost
@@ -559,6 +563,19 @@
 end subroutine distribute2ghosts
 !===========================================
 
+! deallocate ghost variables
+subroutine free_ghost(ngpart)
+implicit none
+integer,intent(in) :: ngpart
+integer :: i
+do i=1,ngpart
+  deallocate(gpart(i)%node,gpart(i)%gdof)
+enddo
+deallocate(gpart)
+return
+end subroutine free_ghost
+!===========================================
+
 ! routines below are imported and modified from SPECFEM3D 
 
 ! subroutines to sort MPI buffers to assemble between chunks
@@ -775,3 +792,4 @@
 
 end module ghost_library_mpi
 
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -81,3 +81,4 @@
 
 end module global
 !============================================
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -3,47 +3,48 @@
 use math_constants
 use set_precision_mpi
 
-private :: iminvec_par,fminvec_par
-private :: isumscal_par,fsumscal_par
-private :: imaxscal_par,fmaxscal_par
-private :: imaxvec_par,fmaxvec_par
+private :: iminscal,fminscal
+private :: iminvec,fminvec
+private :: isumscal,fsumscal
+private :: imaxscal,fmaxscal
+private :: imaxvec,fmaxvec
 
 ! global sum of a scalar in all processors
-interface sumscal_par
-  module procedure isumscal_par
-  module procedure fsumscal_par
+interface sumscal
+  module procedure isumscal
+  module procedure fsumscal
 end interface
 
 ! global maximum of a scalar in all processors
-interface minscal_par
-  module procedure iminscal_par
-  module procedure fminscal_par
+interface minscal
+  module procedure iminscal
+  module procedure fminscal
 end interface
 
 ! global maximum of a scalar in all processors
-interface maxscal_par
-  module procedure imaxscal_par
-  module procedure fmaxscal_par
+interface maxscal
+  module procedure imaxscal
+  module procedure fmaxscal
 end interface
 
 ! global maximum of a vector in all processors
-interface maxvec_par
-  module procedure imaxvec_par
-  module procedure fmaxvec_par
+interface maxvec
+  module procedure imaxvec
+  module procedure fmaxvec
 end interface
 
 ! global minimum of a scalar in all processors
-interface minvec_par
-  module procedure iminvec_par
-  module procedure fminvec_par
+interface minvec
+  module procedure iminvec
+  module procedure fminvec
 end interface
 contains
 !=======================================================
 !=======================================================
 
-function iminscal_par(scal) result(gmin)
+function iminscal(scal) result(gmin)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global minimum of a scalar across the processors
 !
 implicit none 
 integer,intent(in)::scal 
@@ -53,12 +54,12 @@
 call MPI_ALLREDUCE(scal,gmin,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ierr)
  
 return
-end function iminscal_par
+end function iminscal
 !=======================================================
 
-function fminscal_par(scal) result(gmin)
+function fminscal(scal) result(gmin)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global minimum of a scalar across the processors
 !
 implicit none 
 real(kind=kreal),intent(in)::scal 
@@ -68,12 +69,12 @@
 call MPI_ALLREDUCE(scal,gmin,1,MPI_KREAL,MPI_MIN,MPI_COMM_WORLD,ierr)
  
 return
-end function fminscal_par
+end function fminscal
 !=======================================================
 
-function imaxscal_par(scal) result(gmax)
+function imaxscal(scal) result(gmax)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global maximum of a scalar across the processors
 !
 implicit none 
 integer,intent(in)::scal 
@@ -83,12 +84,12 @@
 call MPI_ALLREDUCE(scal,gmax,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ierr)
  
 return
-end function imaxscal_par
+end function imaxscal
 !=======================================================
 
-function fmaxscal_par(scal) result(gmax)
+function fmaxscal(scal) result(gmax)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global maximum of a scalar across the processors
 !
 implicit none 
 real(kind=kreal),intent(in)::scal 
@@ -98,10 +99,10 @@
 call MPI_ALLREDUCE(scal,gmax,1,MPI_KREAL,MPI_MAX,MPI_COMM_WORLD,ierr)
  
 return
-end function fmaxscal_par
+end function fmaxscal
 !=======================================================
 
-function imaxvec_par(vec) result(gmax)
+function imaxvec(vec) result(gmax)
 implicit none
 integer,intent(in)::vec(:)
 integer :: lmax,gmax ! local and global
@@ -112,10 +113,10 @@
 call MPI_ALLREDUCE(lmax,gmax,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ierr)
 
 return
-end function imaxvec_par
+end function imaxvec
 !=======================================================
 
-function fmaxvec_par(vec) result(gmax)
+function fmaxvec(vec) result(gmax)
 implicit none
 real(kind=kreal),intent(in)::vec(:)
 real(kind=kreal) :: lmax,gmax ! local and global
@@ -126,10 +127,10 @@
 call MPI_ALLREDUCE(lmax,gmax,1,MPI_KREAL,MPI_MAX,MPI_COMM_WORLD,ierr)
 
 return
-end function fmaxvec_par
+end function fmaxvec
 !=======================================================
 
-function iminvec_par(vec) result(gmin)
+function iminvec(vec) result(gmin)
 implicit none
 integer,intent(in)::vec(:)
 integer :: lmin,gmin ! local and global
@@ -140,10 +141,10 @@
 call MPI_ALLREDUCE(lmin,gmin,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ierr)
 
 return
-end function iminvec_par
+end function iminvec
 !=======================================================
 
-function fminvec_par(vec) result(gmin)
+function fminvec(vec) result(gmin)
 implicit none
 real(kind=kreal),intent(in)::vec(:)
 real(kind=kreal) :: lmin,gmin ! local and global
@@ -154,12 +155,12 @@
 call MPI_ALLREDUCE(lmin,gmin,1,MPI_KREAL,MPI_MIN,MPI_COMM_WORLD,ierr)
 
 return
-end function fminvec_par
+end function fminvec
 !=======================================================
 
-function isumscal_par(scal) result(gsum)
+function isumscal(scal) result(gsum)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global summation of a scalar across the processors
 !
 implicit none 
 integer,intent(in)::scal 
@@ -169,12 +170,12 @@
 call MPI_ALLREDUCE(scal,gsum,1,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr)
  
 return
-end function isumscal_par
+end function isumscal
 !=======================================================
 
-function fsumscal_par(scal) result(gsum)
+function fsumscal(scal) result(gsum)
 !
-! this finds a summation of a scalar across the processors
+! this finds a global summation of a scalar across the processors
 !
 implicit none 
 real(kind=kreal),intent(in)::scal 
@@ -184,12 +185,12 @@
 call MPI_ALLREDUCE(scal,gsum,1,MPI_KREAL,MPI_SUM,MPI_COMM_WORLD,ierr)
  
 return
-end function fsumscal_par
+end function fsumscal
 !=======================================================
 
 function dot_product_par(vec1,vec2) result(gdot)
 !
-! this finds dot product of two vectors across the processors
+! this finds global dot product of two vectors across the processors
 !
 implicit none
 real(kind=kreal),intent(in)::vec1(:),vec2(:) 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mpi_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mpi_library.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mpi_library.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -6,12 +6,13 @@
 contains
 
 ! start MPI processes
-subroutine start_process(myid,nproc,ounit)
+subroutine start_process(ismpi,myid,nproc,ounit)
 implicit none
+logical,intent(out) :: ismpi
 integer,intent(out) :: myid,nproc
 integer,intent(in) :: ounit
 integer :: errcode
-
+ismpi=.true. ! parallel
 call MPI_INIT(errcode)
 if(errcode /= 0) call mpierror('ERROR: cannot initialize MPI!',errcode,ounit)
 call MPI_COMM_RANK(MPI_COMM_WORLD,myid,errcode)
@@ -66,5 +67,21 @@
 call MPI_ABORT(MPI_COMM_WORLD,errcode,ierr)
 stop
 end subroutine error_stop
+!=======================================================
 
+! get processor tag
+function proc_tag(myid,nproc) result(ptag)
+implicit none
+integer,intent(in) :: myid,nproc
+character(len=20) :: format_str,ptag
+
+write(format_str,*)ceiling(log10(real(nproc)+1.))
+format_str='(a,i'//trim(adjustl(format_str))//'.'//trim(adjustl(format_str))//')'
+
+write(ptag,fmt=format_str)'_proc',myid-1
+
+return
+end function
+!=======================================================
+
 end module mpi_library

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -9,19 +9,23 @@
 contains
 ! this function computes the stable pseudo-time step 
 ! for viscoplastic algorithm (Cormeau 1975, Smith and Griffiths 2003)
-function dt_viscoplas(nmat,nuf,phif,ymf) result(dt_min)
+function dt_viscoplas(nmat,nuf,phif,ymf,ismat) result(dt_min)
 implicit none
 integer,intent(in) :: nmat
 ! friction angle,Poisson's ratio, strength reduction factor
 real(kind=kreal),intent(in) :: ymf(nmat),phif(nmat),nuf(nmat) ! phif in degrees
+logical,optional,intent(in) :: ismat(nmat)
 real(kind=kreal) :: dt_min
 real(kind=kreal) :: dt,snphi
 real(kind=kreal),parameter :: r4=4.0_kreal
 integer :: i_mat
-
+logical :: ismat_on(nmat)
+ismat_on=.true.
+if(present(ismat))ismat_on=ismat
 ! compute minimum pseudo-time step for viscoplasticity
 dt_min=inftol
 do i_mat=1,nmat
+  if(.not.ismat_on(i_mat))cycle
   snphi=sin(phif(i_mat)*deg2rad)
   dt=r4*(one+nuf(i_mat))*(one-two*nuf(i_mat))/(ymf(i_mat)*(one-two*nuf(i_mat)+ &
   snphi**2))
@@ -242,3 +246,4 @@
 !=======================================================
 
 end module plastic_library
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -97,3 +97,4 @@
 if(present(extload))extload(0)=zero
 end subroutine stiffness_bodyload
 end module preprocess
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -60,6 +60,7 @@
 water_stat=0
 mesh_stat=-1
 material_stat=-1
+stress0_stat=-1
 control_stat=-1
 save_stat=0
 
@@ -223,7 +224,7 @@
     cycle      
   endif
   
-  ! read bc information
+  ! read initial stress information
   if (trim(token)=='stress0:')then
     if(stress0_stat==1)then
       write(errtag,*)'ERROR: copy of line type stress0: not permitted!'
@@ -234,8 +235,8 @@
     call seek_integer('type',ival,args,narg,istat)
     if(istat==0)s0_type=ival
     if(s0_type==1)then
-      z_datum=get_integer('z0',args,narg)
-      s0_datum=get_integer('s0',args,narg)
+      z_datum=get_real('z0',args,narg)
+      s0_datum=get_real('s0',args,narg)
     endif
     call seek_real('k0',rval,args,narg,istat)
     if(istat==0)epk0=rval
@@ -368,6 +369,10 @@
       allocate(excavid(nexcavid_all))    
       excavid=get_integer_vect('excavid',nexcavid_all,args,narg)
     endif
+    if(nsrf>1 .and. nexcav>1)then
+      write(errtag,'(a)')'ERROR: cannot run slope stabiliy and excavation simultaneously!'
+      return
+    endif
     !---------------------------
      
     call seek_integer('ninc',ival,args,narg,istat)
@@ -571,6 +576,10 @@
 do i=1,nmat
   read(11,*)imat,mat_domain,gam(i),ym(i),nu(i),phi(i),coh(i),psi(i)
 enddo
+if(minval(mat_id)<1 .or. maxval(mat_id)>nmat)then
+  write(errtag,'(a)')'ERROR: material IDs must be consistent with the defined material regions!'
+  return
+endif 
 water=.false.
 if(iswater)then
   read(11,*,iostat=ios)nwmat
@@ -590,3 +599,4 @@
 if(myid==1)write(*,*)'complete!'
 
 end subroutine read_input
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,14 +1,18 @@
-! routines requied to mimic similar MPI routines found in mpi_library.f90
+! routines requied to mimic similar MPI routines found in mpi_library.f90 and
+! others
 ! REVISION:
 !   HNG, Jul 11,2011; Apr 09,2010
 module serial_library
+use set_precision
 contains
 
-subroutine start_process(myid,nproc,ounit)
+subroutine start_process(ismpi,myid,nproc,ounit)
 implicit none
+logical,intent(out) :: ismpi
 integer,intent(out) :: myid,nproc
 integer,intent(in) :: ounit
 integer :: errcode
+ismpi=.false. ! serial
 myid=1; nproc=1
 return
 end subroutine start_process
@@ -39,4 +43,121 @@
 end subroutine error_stop
 !=======================================================
 
+! get processor tag
+function proc_tag(myid,nproc) result(ptag)
+integer,intent(in) :: myid,nproc
+character(len=20) :: format_str,ptag
+
+ptag=''
+
+return
+end function
+!=======================================================
+
+subroutine prepare_ghost(myid,nproc,gdof,ngpart,maxngnode)
+use global,only:nnode,nndof
+implicit none
+integer,intent(in) :: myid,nproc
+integer,dimension(nndof,nnode),intent(in) :: gdof ! global degree of freedom
+integer,intent(out) :: ngpart,maxngnode
+ngpart=0; maxngnode=0
+return
+end subroutine prepare_ghost
+!=======================================================
+
+subroutine modify_ghost(myid,nproc,gdof,ngpart,isnode)
+use global,only:nnode,nndof
+implicit none
+integer,intent(in) :: myid,nproc
+integer,dimension(nndof,nnode),intent(in) :: gdof ! global degree of freedom
+integer,intent(in) :: ngpart
+logical,intent(in) :: isnode(nnode)
+return
+end subroutine modify_ghost
+!=======================================================
+
+subroutine assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,array,array_g)
+implicit none
+integer,intent(in) :: myid,ngpart,maxngnode
+integer,intent(in) :: nndof,neq
+real(kind=kreal),dimension(0:neq),intent(in) :: array
+real(kind=kreal),dimension(0:neq),intent(out) :: array_g
+array_g=array
+return
+end subroutine assemble_ghosts
+!=======================================================
+
+! this subroutine assembles the contributions of all ghost partitions
+! at gdof locations
+subroutine assemble_ghosts_nodal(myid,gdof,ngpart,maxngnode,nndof,neq,         &
+ngpart_node,array,array_g)
+use global,only:nnode
+implicit none
+integer,intent(in) :: myid,ngpart,maxngnode
+integer,intent(in) :: nndof,neq
+integer,dimension(nndof,nnode),intent(in) :: gdof ! global degree of freedom
+! number of active ghost partitions for a node
+integer,dimension(nnode),intent(in) :: ngpart_node
+real(kind=kreal),dimension(nndof,nnode),intent(in) :: array
+real(kind=kreal),dimension(nndof,nnode),intent(out) :: array_g
+array_g=array
+return
+end subroutine assemble_ghosts_nodal
+!===========================================
+
+! this subroutine counts the active ghost partitions for each node on the 
+! interfaces. 
+! logical flag representing whether the nodes in the interfaces are intact or 
+! void has to be communicated across the processors
+subroutine count_active_nghosts(myid,ngpart,maxngnode,nndof,ngpart_node)
+use global,only:nnode
+implicit none
+integer,intent(in) :: myid,ngpart,maxngnode,nndof
+! number of active ghost partitions for a node
+integer,dimension(nnode),intent(out) :: ngpart_node
+! only the interfacial nodes can be saved for the storage (TODO)
+ngpart_node=0
+return
+end subroutine count_active_nghosts
+!===========================================
+
+! this subroutine distributes the excavation loads discarded by a processors due
+! to the special geoemtry partition. it will not distribute if the load is used 
+! within the partition
+subroutine distribute2ghosts(myid,gdof,ngpart,maxngnode,nndof,neq,ngpart_node, &
+array,array_g)
+use global,only:nnode
+implicit none
+integer,intent(in) :: myid,ngpart,maxngnode
+integer,intent(in) :: nndof,neq
+integer,dimension(nndof,nnode),intent(in) :: gdof ! global degree of freedom
+! number of active ghost partitions for a node
+integer,dimension(nnode),intent(in) :: ngpart_node
+real(kind=kreal),dimension(nndof,nnode),intent(in) :: array
+real(kind=kreal),dimension(0:neq),intent(out) :: array_g
+
+integer :: i,j,igdof
+real(kind=kreal),parameter :: zero=0.0_kreal
+! store nodal values to gdof locations
+do j=1,nnode
+  do i=1,nndof
+    igdof=gdof(i,j)
+    array_g(igdof)=array(i,j)
+  enddo
+enddo
+array_g(0)=zero
+return
+end subroutine distribute2ghosts
+!===========================================
+
+! deallocate ghost variables
+subroutine free_ghost(ngpart)
+implicit none
+integer,intent(in) :: ngpart
+integer :: i
+return
+end subroutine free_ghost
+!===========================================
+
 end module serial_library
+

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -8,10 +8,10 @@
 
 contains
 
-! diagonally preconditioned conjuate gradient solver
-subroutine pcg_solver(neq,nelmt,k,u,f,dprecon,gdof_elmt,cg_iter,errcode,errtag)
+! diagonally preconditioned conjuate-gradient solver
+subroutine pcg_solver(myid,ngpart,maxngnode,neq,nelmt,k,u,f,dprecon,gdof_elmt,cg_iter,errcode,errtag)
 implicit none
-integer,intent(in) :: neq,nelmt ! nelmt (for intact) may not be same as global nelmt 
+integer,intent(in) :: myid,ngpart,maxngnode,neq,nelmt ! nelmt (for intact) may not be same as global nelmt 
 real(kind=kreal),dimension(nedof,nedof,nelmt),intent(in) :: k ! only for intact elements
 real(kind=kreal),dimension(0:neq),intent(inout) :: u
 real(kind=kreal),dimension(0:neq),intent(in) :: f,dprecon

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -5,15 +5,15 @@
 use set_precision
 use global, only : cg_maxiter,cg_tol,g_num,nedof,nndof,nnode
 use math_constants, only : zero
-!use math_library !, only : dot_product_par,maxvec_par
+!use math_library !, only : dot_product_par,maxvec
 use math_library_mpi
 use ghost_library_mpi
 
 contains
 
-! diagonally preconditioned conjuate gradient solver
-subroutine pcg_solver_par(myid,ngpart,maxngnode,neq,nelmt,k,u_g,f, &
-dprecon_g,gdof_elmt,cg_iter,errcode,errtag)
+! diagonally preconditioned conjuate-gradient solver
+subroutine pcg_solver(myid,ngpart,maxngnode,neq,nelmt,k,u_g,f,dprecon_g,       &
+gdof_elmt,cg_iter,errcode,errtag)
 !use math_library
 implicit none
 integer,intent(in) :: myid,ngpart,maxngnode,neq,nelmt ! nelmt (for intact) may not be same as global nelmt
@@ -66,11 +66,11 @@
   alpha=rz/dot_product_par(p_g,kp)
   u_g=u_g+alpha*p_g
   
-  if(abs(alpha)*maxvec_par(abs(p_g))/maxvec_par(abs(u_g)).le.cg_tol)then
+  if(abs(alpha)*maxvec(abs(p_g))/maxvec(abs(u_g)).le.cg_tol)then
     errcode=0
     return
   endif
-  !if(myid==1)print*,abs(alpha)*maxvec_par(abs(p_g))/maxvec_par(abs(u_g))
+  !if(myid==1)print*,abs(alpha)*maxvec(abs(p_g))/maxvec(abs(u_g))
   r=r-alpha*kp  
   z=dprecon_g*r
   call assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,z,z_g) !,gdof)
@@ -80,7 +80,7 @@
 end do pcg
 write(errtag,'(a)')'ERROR: PCG solver doesn''t converge!'
 return
-end subroutine pcg_solver_par
+end subroutine pcg_solver
 !============================================
 
 end module solver_mpi

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/README_exodus2sem
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/README_exodus2sem	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/README_exodus2sem	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,6 +1,6 @@
 /*This program converts the Binary (provided that ncdump command exists)
 or ASCII exodus file exported from the CUBIT to several mesh files required
-by the fem3d and sem3d_solid packages. Basic steps starting from the CUBIT:
+by the SPECFEM3D_GEOTECH package. Basic steps starting from the CUBIT:
 in CUBIT:
 - blocks defines only the material regions
   -> actual material properties should not be defined within the CUBIT.
@@ -53,5 +53,4 @@
 HISTORY: 
   HNG,Apr 23,2010;HNG,Apr 17,2010;HNG,Feb 08,2009
 TODO:
-  - add support to side sets,i.e., surface boundary conditions
 -------------------------------------------------------*/

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,6 +1,6 @@
 /* This program converts the Binary (provided that ncdump command exists)
 or ASCII exodus file exported from the CUBIT to several mesh files required
-by the fem3d and sem3d_solid packages. Basic steps starting from the CUBIT:
+by the SPECFEM3D_GEOTECH package. Basic steps starting from the CUBIT:
 in CUBIT:
 - blocks defines only the material regions
   -> actual material properties should not be defined within the CUBIT.
@@ -53,7 +53,6 @@
 HISTORY: 
   HNG,Apr 23,2010;HNG,Apr 17,2010;HNG,Feb 08,2009
 TODO:
-  - add support to side sets,i.e., surface boundary conditions
 -------------------------------------------------------*/
 #include <stdio.h>
 #include <stdlib.h>

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c	2011-09-09 07:06:01 UTC (rev 18884)
@@ -1,512 +1,512 @@
-/* 	Collection of string manipulation functions
-	Hom Nath Gharti, NORSAR
-	History:
-	Apr 23,2010 (NORSAR)
-	Mar 18, 2009 (Princeton University)
-	Mar 13, 2008; Mar 19, 2008; HNG (NORSAR) */
-#include <stdio.h>	
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-void extractFileonly(char *filename, char *fileonly)
-{
-	int i, nchar, nslash;
-	/* Extract file name without directory path */
-	nchar=strlen(filename);
-	nslash=0; /* Default value */
-	for(i=0; i<nchar; i++){
-		if(filename[nchar-i]=='/' || filename[nchar-i]=='\\'){ /* Integer epression! */
-			nslash=nchar-i+1;
-			break;
-		}
-	}
-
-	strcpy(fileonly,&filename[nslash]);
-}
-/*======================================*/
-
-/* 	This function returns the file name removing the extension if any
-	In case of more than one '.' it will remove only last extension */
-void removeExtension(char *filename, char *noextfile)
-{
-	int i, nchar, ndot;
-	/* Extract file name without directory path */
-	nchar=strlen(filename);/*printf("%s\n",filename);*//*printf("%s\n",noextfile);*/
-	ndot=nchar; /* Default value */
-	for(i=0; i<nchar; i++){
-		if(filename[nchar-i]=='.'){ /* Integer epression! */
-			ndot=nchar-i;
-			break;
-		}
-	}
-	/* printf("%d %d\n",nchar,ndot); */
-	strncpy(noextfile,filename,ndot);
-	noextfile[ndot]='\0'; /* This is usually requred for srncpy and srncat */
-	/* printf("%s\n",noextfile); */
-}
-/*======================================*/
-
-/* This function had been imported from e3d by shawn larsen */
-void getFileName(filename, head, tail, number, max)
-char *filename, *head, *tail; 
-int number, max;
-{
-	int digits;
-	char ext[10], format[20];
-	
-	/* printf("Hi\n"); */
-	/* determine number of digits */
-	digits = 1;
-	if (max < 1) max = 1;
-	while(max /= 10) digits++;
-
-	/* determine format of number */
-	/* sprintf(format, "%%0%dd\0", digits);
-	following two lines are equivalent to previous line */
-	sprintf(format, "%%0%dd", digits);
-	strcat(format,"\0");
-	sprintf(ext, format, number);
-
-	/* get file name */
-	strcpy(filename, head);
-	strcat(filename,  ".");
-	strcat(filename,  ext);
-	strcat(filename,  ".");
-	strcat(filename, tail);
-
-}
-/*======================================*/
-
-/* This function had been imported from e3d by shawn larsen */
-/* Function to open file name inputted through command line */
-FILE *
-getFile(argc, argv) 
-int    argc;
-char **argv;
-{
-	FILE *file;
-	if (argc == 1) return(stdin);
-	file = fopen(argv[1], "r");
-	if (file == NULL) {
-		fprintf(stderr, "Error: Can't open input file \"%s\"\n", argv[1]);
-		exit(-1);
-		}
-	return(file);
-}
-/*======================================*/
-
-/*	This function returns the position of last character of string s2 if s2 is found in string s1 */
-int stringpos(char *s1, char *s2)
-{
-	int nchar1,nchar2,i1,i2,ipos,spos,stat;
-	nchar1=strlen(s1);
-	nchar2=strlen(s2);
-	ipos=0;spos=0;
-	if(nchar2>nchar1)return (spos);
-	for (i1=0; i1<nchar1; i1++){
-		if(i1+nchar2>nchar1)break;
-		if(s1[i1]==s2[0]){
-			ipos=i1;			
-			stat=1;
-			for (i2=0; i2<nchar2; i2++){
-				if(s1[i2+ipos] != s2[i2]){
-					stat=0;
-					break;
-				}
-			}
-			if(stat==1){
-				spos=ipos+nchar2;
-				break;
-			}
-		}
-	}
-	return(spos);
-}
-/*======================================*/
-
-/* 	This function returns 1 if string s contains '#' as the first non-white space character
-	otherwise 0 */ 
-int commentline(char *s)
-{
-	int i,nchar,stat; /* stat = 1:yes, 0: No */
-	nchar=strlen(s);
-	stat=0; /* Default initialization to No */
-	for(i=0; i<nchar; i++){
-		if(s[i] != ' ' && s[i] != '\0' && s[i] != '\n' && s[i] != '\t'){
-			if(s[i]=='#'){
-				stat=1;
-			}else{
-				stat=0;
-			}
-			break;
-		}
-	}
-	return(stat);
-}
-/*======================================*/
-
-/* This function returns 1 if line s is blank, 0 if not blank */
-int blankline(char *s)
-{
-	int i,nchar,stat; /* stat = 1:yes, 0: No */
-	
-	nchar=strlen(s);
-
-	stat=1; /* Default is yes */
-	for(i=0; i<nchar; i++){
-		if(s[i] != ' ' && s[i] != '\t' && s[i] != '\n' && s[i] != '\0'){
-			stat=0;
-			break;
-		}
-	}	
-	return(stat);
-}
-
-/* get integer value from the bulk string */
-int get_int(int *var, char *arg, char *src)
-{
-int pos; /* position of matched string */
-
-pos=stringpos(src,arg);
-
-if(pos == 0){
-  printf("ERROR: variable \"%s\" not found!\n",arg);
-  exit(-1);
-}
-
-*var = atoi(&src[pos]); /* convert to integer value */
-return(0);
-}
-/*======================================*/
-
-/* look for integer value. if found return intger value and 
-function value as 0 otherwise return -1 as a function value */
-int look_int(int *var, char *arg, char *src)
-{
-int pos; /* position of matched string */
-
-pos=stringpos(src,arg);
-
-if(pos == 0){		
-  return(-1);
-}
-
-*var = atoi(&src[pos]); /* convert to integer value */
-return(0);
-}
-/*======================================*/
-
-/* look for float value. if found return float value and 
-function value as 0 otherwise return -1 as a function value */
-int look_float(float *var, char *arg, char *src)
-{
-int pos; /* position of matched string */
-
-pos=stringpos(src,arg);
-
-if(pos == 0){		
-  return(-1);
-}
-
-*var = atof(&src[pos]); /* convert to float value */
-return(0);
-}
-/*======================================*/
-
-/* look for double value. if found return double value and 
-function value as 0 otherwise return -1 as a function value */
-int look_double(double *var, char *arg, char *src)
-{
-int pos; /* position of matched string */
-
-pos=stringpos(src,arg);
-
-if(pos == 0){		
-  return(-1);
-}
-
-*var = atof(&src[pos]); /* convert to float value */
-return(0);
-}
-/*======================================*/
-
-/* 	This function assigns the corresponding value immediately after the '=' or ':' sign following 
-	the string arg to var, and exits the execution if no such arg is found in string s 
-
-	May 16,2008,HNG: Now the argument name can be a part of other word in the line
-	for eg vfile and file can not be problem!*/
-#define nsymb 4
-int getvalue(char *s, char *arg, char *type, int *var)
-{
-	int pos,inum; /* i,nchar,apos */
-	double *dbl;
-	float  *flt;
-	char argt[10],*str,*symb[nsymb];
-	
-	symb[0]="="; /* x= */
-	symb[1]=":"; /* x: */
-	symb[2]=" ="; /* x = */
-	symb[3]=" :"; /* x : */
-	
-	pos=0;inum=0;
-	while(pos==0 && inum<nsymb){
-		strcpy(argt,arg);
-		strcat(argt,symb[inum]);
-		pos=stringpos(s,argt);
-		inum++;
-	}
-	
-	if(pos == 0){
-		printf("Variable \"%s\" not found!\n",arg);
-		exit(-1);
-	}
-	
-	/*nchar=strlen(s);
-	for(i=pos; i<nchar; i++){
-		if(s[i] == '=' || s[i] == ':'){
-			apos=i+1;
-			break;
-		}
-	}
-	apos=pos;*/
-	switch(type[0]){
-		case 'd':
-			*var = atoi(&s[pos]);
-			return (0);
-		case 'f':
-			flt = (float *) var;
-			*flt = atof(&s[pos]);
-			return(0);
-		case 'F':
-			dbl = (double *) var;
-			*dbl = atof(&s[pos]);
-			return(0);
-		case 's':
-			str = (char *) var;
-			strcpy(str, &s[pos]);
-			return(0);
-		default :
-			printf("WARNING: bad argument type \"%s\" found!\n",type);
-			exit(-1);
-	}
-}
-/*======================================*/
-
-/* 	This function assigns the corresponding value immediately after the '=' or ':' sign following 
-	the string arg to var, and returns (-1) if no such arg is found in string s, otherwise this 
-	function is exactly same as getvalue */
-#define nsymb 4
-int getvaluestat(char *s, char *arg, char *type, int *var)
-{
-	int pos,inum; /* i,nchar,apos */
-	double *dbl;
-	float  *flt;
-	char argt[10],*str,*symb[nsymb];
-	
-	symb[0]="="; /* x= */
-	symb[1]=":"; /* x: */
-	symb[2]=" ="; /* x = */
-	symb[3]=" :"; /* x : */
-	
-	pos=0;inum=0;
-	while(pos==0 && inum<nsymb){
-		strcpy(argt,arg);
-		strcat(argt,symb[inum]);
-		pos=stringpos(s,argt);
-		inum++;
-	}
-	
-	if(pos == 0){
-		/* Variable not found */
-		/* printf("Variable \"%s\" not found!\n",arg); */
-		return(-1);
-	}
-	
-	/*nchar=strlen(s);
-	for(i=pos; i<nchar; i++){
-		if(s[i] == '=' || s[i] == ':'){
-			apos=i+1;
-			break;
-		}
-	}
-	apos=pos;*/
-	switch(type[0]){
-		case 'd':
-			*var = atoi(&s[pos]);
-			return (0);
-		case 'f':
-			flt = (float *) var;
-			*flt = atof(&s[pos]);
-			return(0);
-		case 'F':
-			dbl = (double *) var;
-			*dbl = atof(&s[pos]);
-			return(0);
-		case 's':
-			str = (char *) var;
-			strcpy(str, &s[pos]);
-			return(0);
-		default :
-			printf("WARNING: bad argument type \"%s\" found!\n",type);
-			exit(-1);
-	}
-}
-/*======================================*/
-
-/*	This function returns the position of last character of string s2 in s1 if s2 is found in string s1 */
-int matchfirstword(char *s1, char *s2)
-{
-	int nchar1,nchar2,i1,i2,ipos,stat,match;
-	nchar1=strlen(s1);
-	nchar2=strlen(s2);
-	/*printf("%d %d\n",nchar1,nchar2);*/
-	match=0;
-	if(nchar2>nchar1)return(match); /* No match */
-	
-	for (i1=0; i1<nchar1; i1++){
-		if(s1[i1] != ' ' && s1[i1] != '\0' && s1[i1] != '\n' && s1[i1] != '\t'){
-			if(i1+nchar2>nchar1)break;
-			if(s1[i1]==s2[0]){
-				ipos=i1;			
-				stat=1;
-				for (i2=0; i2<nchar2; i2++){
-					if(s1[i2+ipos] != s2[i2]){
-						stat=0;
-						break;
-					}
-				}
-				if(stat==1)match=1;
-			}
-			break;
-		}
-	}
-	return(match);
-}
-/*======================================*/
-
-/* 	This function extracts and returns the string in the first quotes */
-int getfirstquote(char *s1, char *s2)
-{
-	int i, nchar, ipos1,ipos2,nquote,num;
-	char temp[62];
-
-	nchar=strlen(s1);
-	nquote=0; /* Default value */
-	num=0;
-	ipos1=ipos2=0;
-	for(i=0; i<nchar; i++){
-		if(s1[i]=='"'){ /* Integer exression! */
-			nquote=i;
-			num=num+1;
-			if(num==1){
-				ipos1=i;
-			}
-			else if(num==2){
-				ipos2=i;
-				break;
-			}	
-		}	
-	}
-	num=0;
-	for(i=ipos1+1; i<ipos2;i++){
-		temp[num]=s1[i];
-		num=num+1;
-	}
-	
-	temp[ipos2-1]='\0';
-	strcpy(s2,temp);
-	return(0);
-}
-/*======================================*/
-
-/* 	This function extracts and returns the string after the given string */
-int getintegervect(char *s1, char *arg, int n, int ivect[n])
-{
-	int i,nchar,slen;
-	char temp[62];
-
-	int pos; /* position of matched string */
-
-    pos=stringpos(s1,arg);
-   
-	stringafterstring(s1,"=",temp);	
-	for(i=0;i<n;i++){		
-		slen=strlen(temp);
-		if(sscanf(temp,"%d%n",&ivect[i],&nchar)!= 1){
-			printf("ERROR: wrong values for -xmat option!\n");
-			exit(-1);
-		}		
-		strncpy(temp,temp+nchar+1,slen);		
-	}
-	return(0);
-}
-/*======================================*/
-
-/* 	This function extracts and returns the string after the given string */
-int stringafterstring(char *s1, char *arg, char *s2)
-{
-	int i,nchar,num;
-	char temp[62];
-
-	int pos; /* position of matched string */
-
-    pos=stringpos(s1,arg);
-
-	nchar=strlen(s1);
-	
-	num=0;
-	for(i=pos; i<nchar;i++){
-		temp[num]=s1[i];
-		num=num+1;
-	}
-	
-	temp[nchar-pos]='\0';
-	strcpy(s2,temp);
-	return(0);
-}
-/*======================================*/
-
-/* 	This function converts all the letters of string to lower case
-	HNG,May 23,2008 */
-int lowercase(char *s){
-	int i,nchar;
-	nchar=strlen(s);
-	for(i=0;i<nchar;i++){
-		s[i]=tolower(s[i]);
-	}
-	return(0);
-}
-
-/* 	This function converts all the letters of string to upper case
-	HNG,May 23,2008 */
-int uppercase(char *s){
-	int i,nchar;
-	nchar=strlen(s);
-	for(i=0;i<nchar;i++){
-		s[i]=toupper(s[i]);
-	}
-	return(0);
-}
-/*======================================*/
-
-/* This function determines the byte order of the processor architecture
-source: http://www.ibm.com/developerworks/aix/library/au-endianc/index.html?ca=drs-
-Use a character pointer to the bytes of an int and then check its first byte to see if it is 0 or 1.
-Mar 18,2009 (Princeton University) */
-#define LE 0 /* Little Endian */
-#define BE 1 /* Big Endian */
-
-int getEndian() {
-    int i = 1;
-    char *p = (char *)&i;
-
-    if (p[0] == 1)
-        return LE;
-    else
-        return BE;
-}
-/*======================================*/
-
-
-	
+/* 	Collection of string manipulation functions
+	Hom Nath Gharti, NORSAR
+	History:
+	Apr 23,2010 (NORSAR)
+	Mar 18, 2009 (Princeton University)
+	Mar 13, 2008; Mar 19, 2008; HNG (NORSAR) */
+#include <stdio.h>	
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+void extractFileonly(char *filename, char *fileonly)
+{
+	int i, nchar, nslash;
+	/* Extract file name without directory path */
+	nchar=strlen(filename);
+	nslash=0; /* Default value */
+	for(i=0; i<nchar; i++){
+		if(filename[nchar-i]=='/' || filename[nchar-i]=='\\'){ /* Integer epression! */
+			nslash=nchar-i+1;
+			break;
+		}
+	}
+
+	strcpy(fileonly,&filename[nslash]);
+}
+/*======================================*/
+
+/* 	This function returns the file name removing the extension if any
+	In case of more than one '.' it will remove only last extension */
+void removeExtension(char *filename, char *noextfile)
+{
+	int i, nchar, ndot;
+	/* Extract file name without directory path */
+	nchar=strlen(filename);/*printf("%s\n",filename);*//*printf("%s\n",noextfile);*/
+	ndot=nchar; /* Default value */
+	for(i=0; i<nchar; i++){
+		if(filename[nchar-i]=='.'){ /* Integer epression! */
+			ndot=nchar-i;
+			break;
+		}
+	}
+	/* printf("%d %d\n",nchar,ndot); */
+	strncpy(noextfile,filename,ndot);
+	noextfile[ndot]='\0'; /* This is usually requred for srncpy and srncat */
+	/* printf("%s\n",noextfile); */
+}
+/*======================================*/
+
+/* This function had been imported from e3d by shawn larsen */
+void getFileName(filename, head, tail, number, max)
+char *filename, *head, *tail; 
+int number, max;
+{
+	int digits;
+	char ext[10], format[20];
+	
+	/* printf("Hi\n"); */
+	/* determine number of digits */
+	digits = 1;
+	if (max < 1) max = 1;
+	while(max /= 10) digits++;
+
+	/* determine format of number */
+	/* sprintf(format, "%%0%dd\0", digits);
+	following two lines are equivalent to previous line */
+	sprintf(format, "%%0%dd", digits);
+	strcat(format,"\0");
+	sprintf(ext, format, number);
+
+	/* get file name */
+	strcpy(filename, head);
+	strcat(filename,  ".");
+	strcat(filename,  ext);
+	strcat(filename,  ".");
+	strcat(filename, tail);
+
+}
+/*======================================*/
+
+/* This function had been imported from e3d by shawn larsen */
+/* Function to open file name inputted through command line */
+FILE *
+getFile(argc, argv) 
+int    argc;
+char **argv;
+{
+	FILE *file;
+	if (argc == 1) return(stdin);
+	file = fopen(argv[1], "r");
+	if (file == NULL) {
+		fprintf(stderr, "Error: Can't open input file \"%s\"\n", argv[1]);
+		exit(-1);
+		}
+	return(file);
+}
+/*======================================*/
+
+/*	This function returns the position of last character of string s2 if s2 is found in string s1 */
+int stringpos(char *s1, char *s2)
+{
+	int nchar1,nchar2,i1,i2,ipos,spos,stat;
+	nchar1=strlen(s1);
+	nchar2=strlen(s2);
+	ipos=0;spos=0;
+	if(nchar2>nchar1)return (spos);
+	for (i1=0; i1<nchar1; i1++){
+		if(i1+nchar2>nchar1)break;
+		if(s1[i1]==s2[0]){
+			ipos=i1;			
+			stat=1;
+			for (i2=0; i2<nchar2; i2++){
+				if(s1[i2+ipos] != s2[i2]){
+					stat=0;
+					break;
+				}
+			}
+			if(stat==1){
+				spos=ipos+nchar2;
+				break;
+			}
+		}
+	}
+	return(spos);
+}
+/*======================================*/
+
+/* 	This function returns 1 if string s contains '#' as the first non-white space character
+	otherwise 0 */ 
+int commentline(char *s)
+{
+	int i,nchar,stat; /* stat = 1:yes, 0: No */
+	nchar=strlen(s);
+	stat=0; /* Default initialization to No */
+	for(i=0; i<nchar; i++){
+		if(s[i] != ' ' && s[i] != '\0' && s[i] != '\n' && s[i] != '\t'){
+			if(s[i]=='#'){
+				stat=1;
+			}else{
+				stat=0;
+			}
+			break;
+		}
+	}
+	return(stat);
+}
+/*======================================*/
+
+/* This function returns 1 if line s is blank, 0 if not blank */
+int blankline(char *s)
+{
+	int i,nchar,stat; /* stat = 1:yes, 0: No */
+	
+	nchar=strlen(s);
+
+	stat=1; /* Default is yes */
+	for(i=0; i<nchar; i++){
+		if(s[i] != ' ' && s[i] != '\t' && s[i] != '\n' && s[i] != '\0'){
+			stat=0;
+			break;
+		}
+	}	
+	return(stat);
+}
+
+/* get integer value from the bulk string */
+int get_int(int *var, char *arg, char *src)
+{
+int pos; /* position of matched string */
+
+pos=stringpos(src,arg);
+
+if(pos == 0){
+  printf("ERROR: variable \"%s\" not found!\n",arg);
+  exit(-1);
+}
+
+*var = atoi(&src[pos]); /* convert to integer value */
+return(0);
+}
+/*======================================*/
+
+/* look for integer value. if found return intger value and 
+function value as 0 otherwise return -1 as a function value */
+int look_int(int *var, char *arg, char *src)
+{
+int pos; /* position of matched string */
+
+pos=stringpos(src,arg);
+
+if(pos == 0){		
+  return(-1);
+}
+
+*var = atoi(&src[pos]); /* convert to integer value */
+return(0);
+}
+/*======================================*/
+
+/* look for float value. if found return float value and 
+function value as 0 otherwise return -1 as a function value */
+int look_float(float *var, char *arg, char *src)
+{
+int pos; /* position of matched string */
+
+pos=stringpos(src,arg);
+
+if(pos == 0){		
+  return(-1);
+}
+
+*var = atof(&src[pos]); /* convert to float value */
+return(0);
+}
+/*======================================*/
+
+/* look for double value. if found return double value and 
+function value as 0 otherwise return -1 as a function value */
+int look_double(double *var, char *arg, char *src)
+{
+int pos; /* position of matched string */
+
+pos=stringpos(src,arg);
+
+if(pos == 0){		
+  return(-1);
+}
+
+*var = atof(&src[pos]); /* convert to float value */
+return(0);
+}
+/*======================================*/
+
+/* 	This function assigns the corresponding value immediately after the '=' or ':' sign following 
+	the string arg to var, and exits the execution if no such arg is found in string s 
+
+	May 16,2008,HNG: Now the argument name can be a part of other word in the line
+	for eg vfile and file can not be problem!*/
+#define nsymb 4
+int getvalue(char *s, char *arg, char *type, int *var)
+{
+	int pos,inum; /* i,nchar,apos */
+	double *dbl;
+	float  *flt;
+	char argt[10],*str,*symb[nsymb];
+	
+	symb[0]="="; /* x= */
+	symb[1]=":"; /* x: */
+	symb[2]=" ="; /* x = */
+	symb[3]=" :"; /* x : */
+	
+	pos=0;inum=0;
+	while(pos==0 && inum<nsymb){
+		strcpy(argt,arg);
+		strcat(argt,symb[inum]);
+		pos=stringpos(s,argt);
+		inum++;
+	}
+	
+	if(pos == 0){
+		printf("Variable \"%s\" not found!\n",arg);
+		exit(-1);
+	}
+	
+	/*nchar=strlen(s);
+	for(i=pos; i<nchar; i++){
+		if(s[i] == '=' || s[i] == ':'){
+			apos=i+1;
+			break;
+		}
+	}
+	apos=pos;*/
+	switch(type[0]){
+		case 'd':
+			*var = atoi(&s[pos]);
+			return (0);
+		case 'f':
+			flt = (float *) var;
+			*flt = atof(&s[pos]);
+			return(0);
+		case 'F':
+			dbl = (double *) var;
+			*dbl = atof(&s[pos]);
+			return(0);
+		case 's':
+			str = (char *) var;
+			strcpy(str, &s[pos]);
+			return(0);
+		default :
+			printf("WARNING: bad argument type \"%s\" found!\n",type);
+			exit(-1);
+	}
+}
+/*======================================*/
+
+/* 	This function assigns the corresponding value immediately after the '=' or ':' sign following 
+	the string arg to var, and returns (-1) if no such arg is found in string s, otherwise this 
+	function is exactly same as getvalue */
+#define nsymb 4
+int getvaluestat(char *s, char *arg, char *type, int *var)
+{
+	int pos,inum; /* i,nchar,apos */
+	double *dbl;
+	float  *flt;
+	char argt[10],*str,*symb[nsymb];
+	
+	symb[0]="="; /* x= */
+	symb[1]=":"; /* x: */
+	symb[2]=" ="; /* x = */
+	symb[3]=" :"; /* x : */
+	
+	pos=0;inum=0;
+	while(pos==0 && inum<nsymb){
+		strcpy(argt,arg);
+		strcat(argt,symb[inum]);
+		pos=stringpos(s,argt);
+		inum++;
+	}
+	
+	if(pos == 0){
+		/* Variable not found */
+		/* printf("Variable \"%s\" not found!\n",arg); */
+		return(-1);
+	}
+	
+	/*nchar=strlen(s);
+	for(i=pos; i<nchar; i++){
+		if(s[i] == '=' || s[i] == ':'){
+			apos=i+1;
+			break;
+		}
+	}
+	apos=pos;*/
+	switch(type[0]){
+		case 'd':
+			*var = atoi(&s[pos]);
+			return (0);
+		case 'f':
+			flt = (float *) var;
+			*flt = atof(&s[pos]);
+			return(0);
+		case 'F':
+			dbl = (double *) var;
+			*dbl = atof(&s[pos]);
+			return(0);
+		case 's':
+			str = (char *) var;
+			strcpy(str, &s[pos]);
+			return(0);
+		default :
+			printf("WARNING: bad argument type \"%s\" found!\n",type);
+			exit(-1);
+	}
+}
+/*======================================*/
+
+/*	This function returns the position of last character of string s2 in s1 if s2 is found in string s1 */
+int matchfirstword(char *s1, char *s2)
+{
+	int nchar1,nchar2,i1,i2,ipos,stat,match;
+	nchar1=strlen(s1);
+	nchar2=strlen(s2);
+	/*printf("%d %d\n",nchar1,nchar2);*/
+	match=0;
+	if(nchar2>nchar1)return(match); /* No match */
+	
+	for (i1=0; i1<nchar1; i1++){
+		if(s1[i1] != ' ' && s1[i1] != '\0' && s1[i1] != '\n' && s1[i1] != '\t'){
+			if(i1+nchar2>nchar1)break;
+			if(s1[i1]==s2[0]){
+				ipos=i1;			
+				stat=1;
+				for (i2=0; i2<nchar2; i2++){
+					if(s1[i2+ipos] != s2[i2]){
+						stat=0;
+						break;
+					}
+				}
+				if(stat==1)match=1;
+			}
+			break;
+		}
+	}
+	return(match);
+}
+/*======================================*/
+
+/* 	This function extracts and returns the string in the first quotes */
+int getfirstquote(char *s1, char *s2)
+{
+	int i, nchar, ipos1,ipos2,nquote,num;
+	char temp[62];
+
+	nchar=strlen(s1);
+	nquote=0; /* Default value */
+	num=0;
+	ipos1=ipos2=0;
+	for(i=0; i<nchar; i++){
+		if(s1[i]=='"'){ /* Integer exression! */
+			nquote=i;
+			num=num+1;
+			if(num==1){
+				ipos1=i;
+			}
+			else if(num==2){
+				ipos2=i;
+				break;
+			}	
+		}	
+	}
+	num=0;
+	for(i=ipos1+1; i<ipos2;i++){
+		temp[num]=s1[i];
+		num=num+1;
+	}
+	
+	temp[ipos2-1]='\0';
+	strcpy(s2,temp);
+	return(0);
+}
+/*======================================*/
+
+/* 	This function extracts and returns the string after the given string */
+int getintegervect(char *s1, char *arg, int n, int ivect[n])
+{
+	int i,nchar,slen;
+	char temp[62];
+
+	int pos; /* position of matched string */
+
+    pos=stringpos(s1,arg);
+   
+	stringafterstring(s1,"=",temp);	
+	for(i=0;i<n;i++){		
+		slen=strlen(temp);
+		if(sscanf(temp,"%d%n",&ivect[i],&nchar)!= 1){
+			printf("ERROR: wrong values for -xmat option!\n");
+			exit(-1);
+		}		
+		strncpy(temp,temp+nchar+1,slen);		
+	}
+	return(0);
+}
+/*======================================*/
+
+/* 	This function extracts and returns the string after the given string */
+int stringafterstring(char *s1, char *arg, char *s2)
+{
+	int i,nchar,num;
+	char temp[62];
+
+	int pos; /* position of matched string */
+
+    pos=stringpos(s1,arg);
+
+	nchar=strlen(s1);
+	
+	num=0;
+	for(i=pos; i<nchar;i++){
+		temp[num]=s1[i];
+		num=num+1;
+	}
+	
+	temp[nchar-pos]='\0';
+	strcpy(s2,temp);
+	return(0);
+}
+/*======================================*/
+
+/* 	This function converts all the letters of string to lower case
+	HNG,May 23,2008 */
+int lowercase(char *s){
+	int i,nchar;
+	nchar=strlen(s);
+	for(i=0;i<nchar;i++){
+		s[i]=tolower(s[i]);
+	}
+	return(0);
+}
+
+/* 	This function converts all the letters of string to upper case
+	HNG,May 23,2008 */
+int uppercase(char *s){
+	int i,nchar;
+	nchar=strlen(s);
+	for(i=0;i<nchar;i++){
+		s[i]=toupper(s[i]);
+	}
+	return(0);
+}
+/*======================================*/
+
+/* This function determines the byte order of the processor architecture
+source: http://www.ibm.com/developerworks/aix/library/au-endianc/index.html?ca=drs-
+Use a character pointer to the bytes of an int and then check its first byte to see if it is 0 or 1.
+Mar 18,2009 (Princeton University) */
+#define LE 0 /* Little Endian */
+#define BE 1 /* Big Endian */
+
+int getEndian() {
+    int i = 1;
+    char *p = (char *)&i;
+
+    if (p[0] == 1)
+        return LE;
+    else
+        return BE;
+}
+/*======================================*/
+
+
+	

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/write_sos.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/write_sos.f90	2011-09-09 05:13:11 UTC (rev 18883)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/write_sos.f90	2011-09-09 07:06:01 UTC (rev 18884)
@@ -13,15 +13,15 @@
 character(len=20) :: format_str
 integer :: i_proc,ios,nproc,proc_count,slen
 
-! input and initialisation
-if (command_argument_count() <= 0) then
-  write(*,'(/,a)')'ERROR: no input file!'
-  stop
+! input and initialisation
+if (command_argument_count() <= 0) then
+  write(*,'(/,a)')'ERROR: no input file!'
+  stop
 endif
 
-write(*,'(a)',advance='no')'running...'
-
-! get input file name
+write(*,'(a)',advance='no')'running...'
+
+! get input file name
 call get_command_argument(1, inp_fname)
 
 ! open file to read
@@ -63,7 +63,7 @@
   data_path(2:nproc)=data_path(1)
 endif
 
-write(format_str,*)ceiling(log10(real(nproc)+1))
+write(format_str,*)ceiling(log10(real(nproc)+1))
 format_str='(a,i'//trim(adjustl(format_str))//'.'//trim(adjustl(format_str))//')'
 
 ! open SOS file for original data



More information about the CIG-COMMITS mailing list