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

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Fri Sep 9 05:18:10 PDT 2011


Author: dkomati1
Date: 2011-09-09 05:18:10 -0700 (Fri, 09 Sep 2011)
New Revision: 18889

Added:
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/compile_LaTeX_manual.sh
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.bib
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.pdf
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.tex
Removed:
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib
   seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex
   seismo/3D/SPECFEM3D_GEOTECH/trunk/svn-commit.tmp
Modified:
   seismo/3D/SPECFEM3D_GEOTECH/trunk/README
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/apply_traction.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_bmat.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_cmat.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_pressure.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/excavation.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/gll_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_serial.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mesh_spec.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_scotch.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/postprocess.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/scotchf.h
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semexcav3d.F90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semgeotech.F90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semslope3d.F90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/shape_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/string_library.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/testf90.f90
   seismo/3D/SPECFEM3D_GEOTECH/trunk/src/visual.f90
   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:
renamed the manual and added a script to compile it.
Also cleaned the Fortran source codes to remove all CTRL-M characters and white spaces at the end of lines


Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/README
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/README	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/README	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,5 +1,5 @@
 REVISION:
   HNG, July 08,2011
-  
+
 For license see COPYING.
 For detail on the software package see SPECFEM3D_GEOTECH.pdf.

Deleted: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,339 +0,0 @@
-# Abbreviated names
- at STRING{aes = {Advances in Engineering Software}}
- at STRING{ag = {Acta Geotechnica}}
- at STRING{anm = {Applied Numerical Mathematics}}
- at STRING{bssa = {Bulletin of the Seismological Society of America}}
- at STRING{ccp = {Communications in Computational Physics}}
- at STRING{cgj = {Canadian Geotechnical Journal}}
- at STRING{cg = {Computers \& Geosciences}}
- at STRING{cgeot = {Computers and Geotechnics}}
- at STRING{cmame = {Computer Methods in Applied Mechanics and Engineering}}
- at STRING{cmes = {Computer Modeling in Engineering and Sciences}}
- at STRING{cpc = {Computer Physics Communications}}
- at STRING{cs = {Computers \& Structures}}
- at STRING{eesd = {Earthquake Engineering \& Structural Dynamics}}
- at STRING{ec = {Engineering Computations}}
- at STRING{ewithc = {Engineering with Computers}}
- at STRING{eg = {Engineering Geology}}
- at STRING{eos = {Eos Transactions AGU}}
- at STRING{epsl = {Earth and Planetary Science Letters}}
- at STRING{fead = {Finite Elements in Analysis and Design}}
- at STRING{geophysics = {Geophysics}}
- at STRING{gji = {Geophysical Journal International}}
- at STRING{gjras = {Geophysical Journal of the Royal Astronomical Society }}
- at STRING{gp = {Geophysical Prospecting.}}
- at STRING{grl = {Geophysical Research Letters}}
- at STRING{geot = {G\'eotechnique}}
- at STRING{ijnamg = {International Journal for Numerical and Analytical Methods in Geomechanics}}
- at STRING{ijnme = {International Journal for Numerical Methods in Engineering}}
- at STRING{ijcfd = {International Journal of Computational Fluid Dynamics}}
- at STRING{jap = {Journal of Applied Physics}}
- at STRING{jasa = {Journal of the Acoustical Society of America}}
- at STRING{jbsce = {Journal of Boston Society of Civil Engineers}}
- at STRING{jca = {Journal of Computational Acoustics}}
- at STRING{jcp = {Journal of Computational Physics}}
- at STRING{jge = {Journal of Geotechnical Engineering}}
- at STRING{jged = {Journal of Geotechnical Engineering Division}}
- at STRING{jgr = {Journal of Geophysical Research}}
- at STRING{jmps = {Journal of the Mechanics and Physics of Solids}}
- at STRING{jpdc = {Journal of Parallel and Distributed Computing}}
- at STRING{jsmfd = {Journal of the Soil Mechanics and Foundations Division}}
- at STRING{js = {The Journal of Supercomputing}}
- at STRING{landslides = {Landslides}}
- at STRING{lncs = {Lecture Notes in Computer Science}}
- at STRING{mm = {Mechanics of Material}}
- at STRING{nmpde = {Numerical Methods for Partial Differential Equations}}
- at STRING{pc = {Parallel Computing}}
- at STRING{pageoph = {Pure and Applied Geophysics}}
- at STRING{pepi = {Physics of the Earth and Planetary Interiors}}
- at STRING{rmre = {Rock mechanics and rock engineering}}
- at STRING{sf = {Soils and Foundations}}
- at STRING{siamjsc = {SIAM Journal on Scientific Computing}}
-
-# Entries
-
- at ARTICLE{barragy1988,
-  author = {Barragy, E. and Carey, G. F.},
-  title = {A parallel element-by-element solution scheme},
-  journal = ijnme,
-  year = {1988},
-  volume = {26},
-  pages = {2367--2382},
-  owner = {homnath},
-  timestamp = {2011.05.27}
-}
-
- at BOOK{canuto1988,
-  title = {Spectral methods in fluid dynamics},
-  publisher = {Springer},
-  year = {1988},
-  author = {Canuto, C. and Hussaini, M. Y. and Quarteroni, A. and Zang, T. A.}
-}
-
- at MANUAL{cubit2011,
-  title = {CUBIT 13.0 User Documentation},
-  author = {{CUBIT}},
-  organization = {Sandia National Laboratories},
-  year = {2011},
-  note = {[Online; accessed 27-May-2011]},
-  owner = {homnath},
-  timestamp = {2011.05.27},
-  url = {http://cubit.sandia.gov/}
-}
-
-
- at MANUAL{ensight2008,
-  title = {EnSight User Manual},
-  author = {EnSight},
-  organization = {Computational Engineering International, Inc.},
-  address = {Salem Street, Suite 101, Apex, NC 27523 USA},
-  edition = {Version 9.0},
-  year = {2008},
-  note = {[Online; accessed 11-July-2011]},
-  owner = {homnath},
-  timestamp = {2011.07.11}
-}
-
- at ARTICLE{faccioli1997,
-  author = {Faccioli, E. and Maggio, F. and Paolucci, R. and Quarteroni, A.},
-  title = {{2D} and {3D} elastic wave propagation by a pseudo-spectral domain decomposition
-	method},
-  journal = {Journal of Seismology},
-  year = {1997},
-  volume = {1},
-  pages = {237--251}, 
-  issn = {1383-4649},
-  issue = {3},
-  keyword = {Earth and Environmental Science},
-  publisher = {Springer Netherlands}  
-}
-
- at ARTICLE{geuzaine2009,
-  author = {C. Geuzaine and J. F. Remacle},
-  title = {Gmsh: a three-dimensional finite element mesh generator with built-in
-	pre- and post-processing facilities},
-  journal = ijnme,
-  year = {2009},
-  volume = {79},
-  pages = {1309--1331},
-  number = {11},
-  owner = {komatits},
-  timestamp = {2011.01.23}
-}
-
- at ARTICLE{gharti2011,
-  author = {Gharti, H. N. and Komatitsch, D. and Oye, V. and Martin, R. and Tromp,
-	J.},
-  title = {Application of an elastoplastic spectral-element method to {3D} slope
-	stability analysis},
-  journal = ijnme,
-  year = {2011},
-  volume = {submitted},
-  owner = {homnath},
-  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}
-}
-
- at BOOK{gropp1994,
-  title = {Using {MPI}, portable parallel programming with the {M}essage-{P}assing
-	{I}nterface},
-  publisher = {MIT Press},
-  year = {1994},
-  author = {W. Gropp and E. Lusk and A. Skjellum},
-  address = {Cambridge, USA}
-}
-
- at ARTICLE{hughes1983,
-  author = {Hughes, T. J. R and Levit, I. and Winget, J.},
-  title = {An element-by-element solution algorithm for problems of structural
-	and solid mechanics},
-  journal = cmame,
-  year = {1983},
-  volume = {36},
-  pages = {241--254},
-  number = {2},
-  doi = {10.1016/0045-7825(83)90115-9},
-  issn = {0045-7825},
-}
-
- at ARTICLE{khan1996,
-  author = {Khan, A. I. and Topping, B. H. V.},
-  title = {Parallel finite element analysis using {J}acobi-conditioned conjugate
-	gradient algorithm},
-  journal = aes,
-  year = {1996},
-  volume = {25},
-  pages = {309--319},
-
-}
-
- at ARTICLE{king1987,
-  author = {King, R. B. and Sonnad, V.},
-  title = {Implementation of an element-by-element solution algorithm for the
-	finite element method on a coarse-grained parallel computer},
-  journal = cmame,
-  year = {1987},
-  volume = {65},
-  pages = {47--59},
-  number = {1},
-  doi = {10.1016/0045-7825(87)90182-4},
-  issn = {0045-7825},
-}
-
- at ARTICLE{komatitsch1998,
-  author = {Komatitsch, D. and Vilotte, J. P.},
-  title = {The spectral element method: An efficient tool to simulate the seismic
-	response of {2D} and {3D} geological structures},
-  journal = bssa,
-  year = {1998},
-  volume = {88},
-  pages = {368--392},
-  number = {2},
-}
-
- at ARTICLE{komatitsch1999,
-  author = {Komatitsch, D. and Tromp, J.},
-  title = {Introduction to the spectral element method for three-dimensional	
-	seismic wave propagation},
-  journal = gji,
-  year = {1999},
-  volume = {139},
-  pages = {806--822},
-  keywords = {attenuation, finite element methods, numerical techniques, seismic
-	
-	modelling, seismic wave propagation, topography.},
-  owner = {homnath},
-  timestamp = {2009.07.22}
-}
-
- at TECHREPORT{larsen1995,
-  author = {Larsen, S. and Schultz, C. A.},
-  title = {{ELAS3D: 2D/3D elastic finite difference wave propagation code: Technical
-	Report No. UCRL-MA-121792}},
-  year = {1995},
-  owner = {homnath},
-  timestamp = {2008.04.08}
-}
-
- at ARTICLE{law1986,
-  author = {Law, K. H.},
-  title = {A parallel finite element solution method},
-  journal = cs,
-  year = {1986},
-  volume = {23},
-  pages = {845--858},
-  number = {6},
-  doi = {10.1016/0045-7949(86)90254-3},
-  issn = {0045-7949},
-}
-
- at BOOK{pacheco1997,
-  title = {Parallel Programming with {MPI}},
-  publisher = {Morgan Kaufmann},
-  year = {1997},
-  author = {Pacheco, P.},
-}
-
- at ARTICLE{peter2011,
-  author = {Peter, D. and Komatitsch, D. and Luo, Y. and Martin, R. and Le Goff,
-	N. and Casarotti, E. and Le Loher, P. and Magnoni, F. and Liu, Q.
-	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 = {Geophysical Journal International},
-  year = {2011},
-  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}
-}
-
- at ARTICLE{patera1984,
-  author = {Patera, A. T.},
-  title = {A spectral element method for fluid dynamics: laminar flow in a channel
-	expansion},
-  journal = jcp,
-  year = {1984},
-  volume = {54},
-  pages = {468--488},
-}
-
-
- at ARTICLE{pellegrini1996,
-  author = {F. Pellegrini and J. Roman},
-  title = {{SCOTCH}: A Software Package for Static Mapping by Dual Recursive
-	Bipartitioning of Process and Architecture Graphs},
-  journal = lncs,
-  year = {1996},
-  volume = {1067},
-  pages = {493--498}
-}
-
- at ARTICLE{seriani1994,
-  author = {Seriani, G.},
-  title = {{3-D} large-scale wave propagation modeling by spectral element method
-	on {Cray T3E} multiprocessor},
-  journal = cmame,
-  year = {1994},
-  volume = {164},
-  pages = {235--247},
-  owner = {homnath},
-  timestamp = {2010.08.26}
-}
-
- at BOOK{smith2004,
-  title = {Programming the finite element method},
-  publisher = {John Wiley \& Sons},
-  year = {2004},
-  author = {Smith, I. M. and Griffiths, D. V.},
-  owner = {homnath},
-  timestamp = {2010.08.26}
-}
-
- at MANUAL{truegrid2006,
-  title = {TrueGrid User's Manual},
-  author = {Rainsberger, R.},
-  organization = {XYZ Scientific Applications, Inc.},
-  address = {Livermore, CA},
-  edition = {version 2.3.0},
-  year = {2006},
-  owner = {homnath},
-  timestamp = {2011.05.12},
-  url = {www.truegrid.com}
-}
-
- at ARTICLE{zheng2005,
-  author = {Zheng, H. and Liu, D. F. and Li, C. G.},
-  title = {Slope stability analysis based on elasto-plastic finite element method},
-  journal = ijnme,
-  year = {2005},
-  volume = {64},
-  pages = {1871--1888},
-  owner = {homnath},
-  timestamp = {2011.01.11}
-}
-
- at article{zienkiewicz1974,
-title={Visco-plasticity--plasticity and creep in elastic solids --- a unified numerical solution approach}, 
-volume={8},
-number={4}, 
-journal=ijnme, 
-author={Zienkiewicz, O. and Cormeau, I.}, 
-year={1974}, 
-pages={821--845}
-}
-

Deleted: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,865 +0,0 @@
-%% Do not edit unless you really know what you are doing.
-\documentclass[12pt,a4paper]{report}
-\usepackage[T1]{fontenc}
-\usepackage[latin1]{inputenc}
-\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
-  \pagenumbering{arabic}}
-\newcommand{\backmatter}{\cleardoublepage}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
-%\renewcommand{\baselinestretch}{1.5}
-
-% hyperlinks to sections and references
-%\usepackage[pdftex,bookmarks=true,bookmarksnumbered=true,pdfpagemode=None,pdfstartview=FitH,pdfpagelayout=SinglePage,pdfborder={0 0 0}]{hyperref}
-\newcommand{\tsup}[1]{\textsuperscript{#1}}
-\newenvironment{desclist}[1]
-{\begin{list}{}
-{\renewcommand\makelabel[1]{{##1}\hfill}
-\settowidth\labelwidth{\makelabel{#1}}
-\setlength\leftmargin{\labelwidth+\labelsep}}}
-{\end{list}}
-
-\newenvironment{adescription}[1]
-{\begin{list}{}
-{\renewcommand\makelabel[1]{\texttt{##1}\hfill}
-\settowidth\labelwidth{\makelabel{#1}}
-\setlength\leftmargin{\labelwidth+\labelsep}}}
-{\end{list}}
-
-% Package name and version
-\def\pack{SPECFEM3D\_GEOTECH}
-\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]
-%\centering
-%\noindent\includegraphics[width=0.8\paperwidth]{cover}
-%\noindent\includegraphics[scale=1.0]{cover}
-%\end{figure}
-
-\thispagestyle{empty} % no page number
-\title{\textbf{\packver \\
-User Manual}}
-
-
-\author{Hom Nath Gharti, NORSAR, Norway \\
-Dimitri Komatitsch, University of Toulouse, France \\
-Volker Oye, NORSAR, Norway \\
-Roland Martin, University of Toulouse, France \\
-Jeroen Tromp, Princeton University, USA}
-
-\maketitle
-
-\frontmatter
-\addcontentsline{toc}{chapter}{Licensing}
-\chapter*{Licensing}
-%
-%\packver\ \\
-%Copyright 2010-2011 Hom Nath Gharti\\
-%
-%This file is part of \packver.\\
-%
-\packver\ is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.\\
-
-\packver\ is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.\\
-
-You should have received a copy of the GNU General Public License
-along with \linebreak\packver.  If not, see <\texttt{http://www.gnu.org/licenses/}>.\\
-
-\clearpage
-
-\addcontentsline{toc}{chapter}{Acknowledgments}
-\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
-\clearpage
-
-\mainmatter
-\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} 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 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[Automatic factor of safety]      : No
-\end{desclist}
-
-\section*{Revision}
-
-HNG, Sep 08, 2011; HNG, Jul 12, 2011; HNG, May 20, 2011; HNG, Jan 17, 2011
-
-
-\chapter{Getting started}
-\section{Package structure}
-Original \pack\ package comes in a single compressed file \linebreak\texttt{\pack.tar.gz}, which can be extracted using \texttt{tar} command:\\
-
-\texttt{tar -zxvf \pack.tar.gz}\\
-
-Or\\
-
-using, for example, \texttt{7-zip (www.7-zip.org)} in WINDOWS. The package has a following structure.\\
-
-
- 
-\texttt{\pack/}
-\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 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.
-\item[~~src/]                  : contains all source files.
-\end{adescription}  
-   
-\section{Prerequisites}
-\begin{itemize}[-]
-  \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}
-  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}
-  
-  Finally, following compiler is necessary to build the documentation (this file).
-\begin{itemize}[-]
-  \item \underline{\LaTeX\ compiler}. This is necessary to compile the documentation files.
-\end{itemize}
-
-\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}
-  \item{\emph{Note: If reconfiguration is necessary, it is better to delete all Cache files of the build directory.}}
-\end{itemize}
-
-\section{Run}
-\subsubsection{Serial run}
-\begin{itemize}[-]
-\item To run serial program, type \\
-	  \texttt{./bin/semgeotech} \emph{input\_file\_name}
-	  
-	  Example:
-	  
-	  \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}
-	  
-	  Example:
-	  
-	  \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} \\
-	  
-	  OR
-	  
-	  \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}
-\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{. 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}
-\section{Main input file}
-
-Main input file structure is motivated by the ``E3D''~\citep{larsen1995} software package. The main input file consists of legitimate input lines defined in the specified formats. Any number of blank lines or comment lines can be placed for user friendly input structure. The blank lines contain no or only white-space characters, and the comment lines contain "\#" as the first character. \\
-
-Each legitimate input line consists of a line type, and list of arguments and corresponding values. All argument-value pair are separated by comma (,). If necessary, any legitimate input line can be continued to next line using FORTRAN 90 continuation  character "\&" as an absolute last character of a line to be continued. Repetition of same line type is not allowed.\\
-
-Legitimate input lines have the format\\
-{\it{line\_type}} $arg_1=val_1$, $arg_2=val_2$, ......., $arg_n=val_n$\\
-
-Example:\\
-\texttt{preinfo: nproc=8, ngllx=3, nglly=3, ngllz=3, nenod=8, ngnod=8, \& \\
-inp\_path=\sq{../input}, part\_path=\sq{../partition}, out\_path=\sq{../output/}}\\
-
-All legitimate input lines should be written in lower case. Line type and argument-value pairs must be separated by space. Each argument-value pair must be separated by comma(,) and space/s. No space/s are recommended before line type and in between argument name and "=" or "=" and argument value. If argument value is a string, the FORTRAN 90 string (i.e., enclosed within the single quotes) should be used, for example, \texttt{inp\_path=\sq{../input}}. If the argument value is a vector (i.e., multi-valued), a list of values separated by space (no comma!) shoud be used, e.g, \texttt{srf=1.0 1.2 1.3 1.4}.
-
-\subsection{Line types}
-
-Only the following line types are permitted.
-\begin{adescription}{traction:} 
-\item[preinfo:]  preliminary information of the simulation
-\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]
-\item[control:]  control of the simulation
-\item[save:]  options to save data
-\end{adescription}
-
-\subsection{Arguments}
-
-Only the following arguments under the specified line types are permitted.\\
-
-\texttt{\underline{preinfo:}}
-
-\begin{adescription}{nl\_maxiter} 
-  \item[nproc] : number of processors to be used for the parallel processing [integer > 1]. Only required for parallel processing.
-  \item[ngllx] : number of Gauss-Lobatto-Legendre (GLL) points along $x$-axis [integer > 1].
-  \item[nglly] : number of GLL points along $y$-axis [integer > 1].
-  \item[ngllz] : number of GLL points along $z$-axis [integer > 1]. \\\\
-  {\emph{Note: Although the program can use different values of}} \texttt{ngllx}, \texttt{nglly}, {\emph{and}} \texttt{ngllz}, {\emph{it is recommended to use same number of GLL points along all axes.}}
-  \item[inp\_path]	: input path where the input data are located [string, optional, default $\Rightarrow$ \texttt{\sq{../input}}].
-  \item[part\_path]	: partition path where the partitioned data will be or are located [string, optional, default $\Rightarrow$ \texttt{\sq{../partition}}]. Only required for parallel processing.
-  \item[out\_path]	: output path where the output data will be stored [string, optional, default $\Rightarrow$ \texttt{\sq{../output}}].\\
-\end{adescription}
-
-
-\texttt{\underline{mesh:}}
-\begin{adescription}{nl\_maxiter}
-  \item[xfile] : file name of $x$-coordinates [string].
-  \item[yfile] : file name of $y$-coordinates [string].
-  \item[zfile] : file name of $z$-coordinates [string].
-  \item[confile]: file name of mesh connectivity [string].
-  \item[idfile]: file name of element IDs [string].
-  \item[gfile]: file name of ghost interfaces, i.e., partition interfaces [string]. Only required for parallel processing.\\
-\end{adescription}
-
-\texttt{\underline{bc:}}
-\begin{adescription}{nl\_maxiter}
-  \item[uxfile]: file name of displacement boundary conditions along $x$-axis [string].
-  \item[uyfile]: file name of displacement boundary conditions along $y$-axis [string].
-  \item[uzfile]: file name of displacement boundary conditions along $z$-axis [string].\\
-\end{adescription}
-  
-\texttt{\underline{traction:}}
-\begin{adescription}{nl\_maxiter}
-  \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].
-  \item[ispart]: flag to indicate whether the material file is partitioned [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 1]. Only required for parallel processing.
-  \item[matpath]: path to material file [string, optional, default $\Rightarrow$ \texttt{\sq{../input}} for serial or unpartitioned material file in parallel and \texttt{\sq{../partition}} for partitioned material file in parallel].
-  \item[allelastic]: assume all entire domain as elastic [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 0].\\
-\end{adescription}
-
-\texttt{\underline{eqload:}}
-\begin{adescription}{nl\_maxiter}
-  \item[eqkx]: pseudo-static earthquake loading coefficient along $x$-axis [real, 0 <= \texttt{eqkx} <= 1.0, default $\Rightarrow$ 0.0].
-  \item[eqky]: pseudo-static earthquake loading coefficient along $y$-axis [real, 0 <= \texttt{eqky} <= 1.0, default $\Rightarrow$ 0.0].
-  \item[eqkz]: pseudo-static earthquake loading coefficient along $z$-axis [real, 0 <= \texttt{eqkz} <= 1.0, default $\Rightarrow$ 0.0].
-  \\\\
-  {\emph{Note: For the stability analysis purpose, these coefficients should be chosen carefully. For example, if the slope face is pointing towards the negative $x$-axis, value of}} \texttt{eqkx} {\emph{is taken negative.}} \\
-\end{adescription}
-  
-\texttt{\underline{water:}}
-\begin{adescription}{nl\_maxiter}
-  \item[wsfile]: file name of water surface file.\\
-\end{adescription}
-  
-\texttt{\underline{control:}}
-\begin{adescription}{nl\_maxiter}
-  \item[cg\_tol]: tolerance for conjugate gradient method [real].
-  \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[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[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, 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*{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/}\\\\
-\#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}\\\\
-\#control parameters\\
-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 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/}\\\\
-\#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}, gfile=\sq{validation1\_ghost}\\\\
-\#boundary conditions\\
-bc: uxfile=\sq{validation1\_ssbcux}, uyfile=\sq{validation1\_ssbcuy}, \& \\
-uzfile=\sq{validation1\_ssbcuz}\\\\
-\#material list\\
-material: matfile=\sq{validation1\_material\_list}\\\\
-\#control parameters\\
-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}
-
-\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{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{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\\
-\#-----------------------------------------------------------------}}\\\\
-}}
-
-\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:\\
-
-\emph{number of points \\
-coordinate of point  1\\
-coordinate of point  2\\
-coordinate of point  3\\
-..\\
-..\\
-..}\\
-
-Example:\\\\
-{\texttt{2354\\
-40.230394465164999\\
-40.759090909090901\\
-42.700000000000003\\
-40.957142857142898\\
-40.230394465164999\\
-40.759090909090901\\
-42.700000000000003\\
-40.957142857142898\\
-...\\
-...\\}}
-
-\subsection{Connectivity file: \texttt{confile}}
-
-The connectivity file contains the connectivity lists of elements in following format:\\
-
-\emph{number of elements\\
-$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 1\\
-$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 2\\
-$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 3\\
-$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 4\\
-..\\
-..}\\
-
-
-Example:\\\\
-1800\\
-\texttt{1 2 3 4 5 6 7 8 \\
-9 10 2 1 11 12 6 5 \\
-9 1 4 13 11 5 8 14 \\
-15 16 10 9 17 18 12 11 \\
-15 9 13 19 17 11 14 20 \\
-21 22 16 15 23 24 18 17 \\
-21 15 19 25 23 17 20 26 \\
-27 28 22 21 29 30 24 23 \\
-27 21 25 31 29 23 26 32 \\
-33 34 28 27 35 36 30 29 \\
-33 27 31 37 35 29 32 38 \\
-34 33 39 40 36 35 41 42 \\
-33 37 43 39 35 38 44 41 \\
-...\\
-...\\}
-
-\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: \\
-
-\emph{number of elements\\
-ID of element 1\\
-ID of element 2\\
-ID of element 3\\
-ID of element 4\\
-...\\
-...}\\
-
-Example:\\
-
-\texttt{1800\\
-1\\
-1\\
-1\\
-1\\
-1\\
-1\\
-1\\
-1\\
-1\\
-1\\
-...\\
-...\\}
-
-\subsection{Ghost partition interfaces file: \texttt{gfile}}
-
-
-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 following format:\\
-
-\emph{traction type} (integer, 0 = point, 1 = uniformly distributed, 2 = linearly distributed)\\
-if \emph{traction type} = 0\\
-  \emph{$q_x$ $q_y$ $q_z$} (load vector in kN)\\
-if \emph{traction type} = 1\\
-  \emph{$q_x$ $q_y$ $q_z$} (load vector in kN/m\tsup{2})\\
-if \emph{traction type} = 2\\
-  \emph{relevant-axis $x_1$ $x_2$ $q_{x1}$ $q_{y1}$ $q_{z1}$ $q_{x2}$ $q_{y2}$ $q_{z2}$}\\  
-\emph{number of entities} (points for point load or faces for distributed load)\\
-\emph{elementID entityID \\
-elementID entityID \\
-elementID entityID \\
-...\\
-...\\}
-
-This can be repeated as many times as many tractions.\\
-
-The \emph{relevant-axis} denotes the axis along which the load is varying, and it is represented by an integer as 1 = $x$-axis, 2 = $y$-axis, and 3 = $z$-axis. The variables $x_1$ and $x_2$ denote the coordinates (only the \emph{relevant-axis}) of two points between which the linearly distributed load is applied. Similarly, $q_{x1}$, $q_{y1}$ and $q_{z1}$, and $q_{x2}$, $q_{y2}$ and $q_{z2}$ denote the load vectors in kN/m\tsup{2} at the point 1 and 2, respectively.\\
-
-Example:\\
-Following data specify the two tractions: a uniformly distributed traction and a linearly distributed traction.\\\\
-
-\texttt{1\\
-0.0 0.0 -167.751\\
-363\\
-56 1\\
-57 1\\
-58 1\\
-59 1\\
-60 1\\
-61 1\\
-62 1\\
-...\\
-...\\
-2\\
-3 7.3 24.4 51.8379 0.0 -159.5407 0.0 0.0 0.0\\
-594\\
-38 1\\
-39 1\\
-40 1\\
-41 1\\
-42 1\\
-43 1\\
-44 1\\
-45 1\\
-46 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
-
-\emph{number of water surfaces}\\
-\emph{water surface type} (integer, 0 = horizontal surface, 1 = inclined surface, 2 = meshed surface)\\
-if \emph{wstype}=0 (can be reconstructed by sweeping a horizontal line)\\
-  \emph{relevant-axis $x_1$ $x_2$ $z$}\\
-if \emph{wstype}=1 (can be reconstructed by sweeping a inclined line)\\
-  \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\\
-  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.\\
-  
-
-Example:\\
-Following data specify the two water surfaces: a horizontal surface and an inclined surface.\\\\
-\texttt{2\\
-0\\
-1 42.7 50.0 6.1\\
-1\\
-1 0.0 42.7 12.2 6.1}\\
-
-\chapter{Output and Visualization}
-
-\section{Output files}
-
-\subsection{Summary file}
-
-This file is self explanatory and it contains the summary of the result including control parameters, maximum displacement at each step, and elapsed time. The file is written in ASCII format and its name follows the convention \emph{input\_file\_name\_header}\texttt{\_summary} for serial run and \emph{input\_file\_name\_header}\texttt{\_summary\_proc}\emph{processor\_ID} for parallel run.
-
-\subsection{Mesh files}
-
-This file contains the mesh information of the model including coordinates, connectivity, element types etc. in EnSight Gold binary format~\citep[see][]{ensight2008}. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_summary} for serial run and \emph{input\_file\_name\_header}\texttt{\_summary\_proc}\emph{processor\_ID} for parallel run.
-
-\subsection{Displacement field file}
-
-This file contains the nodal displacement field in the model written in EnSight Gold binary format. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{.dis} for serial run and \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{\_proc}\emph{processor\_ID}\texttt{.dis} for parallel run.
-
-\subsection{Pore pressure file}
-
-This file contains the hydrostatic pore pressure field in the model written in EnSight Gold binary format. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{.por} for serial run and \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{\_proc}\emph{processor\_ID}\texttt{.por} for parallel run.
-
-\subsection{CASE file}
-
-This is an EnSight Gold CASE file written in ASCII format. This file contain the information on the mesh files, other files, time steps etc. The file name follows the format \emph{input\_file\_name\_header}\texttt{.case} for serial run and \emph{input\_file\_name\_header}{\_proc}\emph{processor\_ID}\texttt{.case} for parallel run.
-
-\subsection{SOS file}
-
-This is an EnSight Gold server-of-server file for parallel visualization. The \texttt{write\_sos.f90} program provided in the \texttt{/utilities/} may be used to generate this file. See Chapter~\ref{chap:utilities}, Section~\ref{sec:sos} for more detail.
-
-All above EnSight Gold files correspond to the model with spectral-element mesh. Additionally, the CASE file/s and mesh file/s are written for the original model. These file names follow the similar conventions and they have the tag \texttt{\sq{original}} in the file name headers.
-
-\section{Visualization}
-\subsection{Serial visualization}
-
-Requirement: ParaView version later than 3.7. Precompiled binaries available from ParaView web (\texttt{www.paraview.org}) may be installed directly or it can be build from the source. 
-
-\begin{itemize}
-\item open a session
-\item open paraview client \\
-\texttt{paraview}
-\item In ParaView client: $\Rightarrow$ File $\Rightarrow$ Open\\
-   select appropriate serial CASE file (.case file)\\
-   see ParaView wiki \texttt{paraview.org/Wiki/ParaView} for more detail. 
-\end{itemize}
-   
-\subsection{Parallel visualization}
-
-Requirement: ParaView version later than 3.7. It should be built enabling MPI. An appropriate MPI library is necessary.
-
-\begin{itemize}
-\item open a session
-\item open paraview client \\
-\texttt{paraview}
-\item start ParaView server \\
-mpirun -np 8 pvserver -display :0
-\item In ParaView client: $\Rightarrow$ File $\Rightarrow$ Connect and connect to the appropriate server
-\item In ParaView client: $\Rightarrow$ Open\\
-   select appropriate SOS file (.sos file)\\
-   see ParaView wiki (\texttt{paraview.org/Wiki/ParaView} for more detail. 
-\end{itemize}
-
-\emph{Note: Each CASE file obtained from the parallel processing can also be visualized in a serial.}
-
-
-\chapter{Utilities}
-\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 \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}. 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}
-
-The program \texttt{write\_sos.f90} contained in the utilities directory can be used to write EnSight Gold server-of-server file (.sos file, see~\citep{ensight2008}) to visualize the multi-processors data in parallel. This file does not contain the actual data, but only the information on the data location and parallel processing. 
-\subsubsection*{Compile}
-\texttt{gfortran -o write\_sos write\_sos.f90}
-\subsubsection*{Run}
-\texttt{exodus2sem} {\it{input\_file}}\\
-
-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}
-
-\end{document}

Added: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/compile_LaTeX_manual.sh
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/compile_LaTeX_manual.sh	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/compile_LaTeX_manual.sh	2011-09-09 12:18:10 UTC (rev 18889)
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+/bin/rm -rf *.dvi >  /dev/null
+/bin/rm -rf *.log >  /dev/null
+/bin/rm -rf *.out >  /dev/null
+/bin/rm -rf *.aux >  /dev/null
+/bin/rm -rf *.toc >  /dev/null
+/bin/rm -rf *.blg >  /dev/null
+/bin/rm -rf *.bbl >  /dev/null
+/bin/rm -rf *.lof >  /dev/null
+/bin/rm -rf *.lot >  /dev/null
+/bin/rm -rf *.plt >  /dev/null
+/bin/rm -rf *.fff >  /dev/null
+/bin/rm -rf *.ttt >  /dev/null
+/bin/rm -rf *.tit >  /dev/null
+/bin/rm -rf *.spl >  /dev/null
+
+	pdflatex manual_SPECFEM3D_GEOTECH
+	bibtex manual_SPECFEM3D_GEOTECH
+	pdflatex manual_SPECFEM3D_GEOTECH
+	pdflatex manual_SPECFEM3D_GEOTECH
+	pdflatex manual_SPECFEM3D_GEOTECH
+	pdflatex manual_SPECFEM3D_GEOTECH
+
+/bin/rm -rf *.dvi >  /dev/null
+/bin/rm -rf *.log >  /dev/null
+/bin/rm -rf *.out >  /dev/null
+/bin/rm -rf *.aux >  /dev/null
+/bin/rm -rf *.toc >  /dev/null
+/bin/rm -rf *.blg >  /dev/null
+/bin/rm -rf *.bbl >  /dev/null
+/bin/rm -rf *.lof >  /dev/null
+/bin/rm -rf *.lot >  /dev/null
+/bin/rm -rf *.plt >  /dev/null
+/bin/rm -rf *.fff >  /dev/null
+/bin/rm -rf *.ttt >  /dev/null
+/bin/rm -rf *.tit >  /dev/null
+/bin/rm -rf *.spl >  /dev/null
+


Property changes on: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/compile_LaTeX_manual.sh
___________________________________________________________________
Name: svn:executable
   + *

Copied: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.bib (from rev 18887, seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.bib)
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.bib	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.bib	2011-09-09 12:18:10 UTC (rev 18889)
@@ -0,0 +1,339 @@
+# Abbreviated names
+ at STRING{aes = {Advances in Engineering Software}}
+ at STRING{ag = {Acta Geotechnica}}
+ at STRING{anm = {Applied Numerical Mathematics}}
+ at STRING{bssa = {Bulletin of the Seismological Society of America}}
+ at STRING{ccp = {Communications in Computational Physics}}
+ at STRING{cgj = {Canadian Geotechnical Journal}}
+ at STRING{cg = {Computers \& Geosciences}}
+ at STRING{cgeot = {Computers and Geotechnics}}
+ at STRING{cmame = {Computer Methods in Applied Mechanics and Engineering}}
+ at STRING{cmes = {Computer Modeling in Engineering and Sciences}}
+ at STRING{cpc = {Computer Physics Communications}}
+ at STRING{cs = {Computers \& Structures}}
+ at STRING{eesd = {Earthquake Engineering \& Structural Dynamics}}
+ at STRING{ec = {Engineering Computations}}
+ at STRING{ewithc = {Engineering with Computers}}
+ at STRING{eg = {Engineering Geology}}
+ at STRING{eos = {Eos Transactions AGU}}
+ at STRING{epsl = {Earth and Planetary Science Letters}}
+ at STRING{fead = {Finite Elements in Analysis and Design}}
+ at STRING{geophysics = {Geophysics}}
+ at STRING{gji = {Geophysical Journal International}}
+ at STRING{gjras = {Geophysical Journal of the Royal Astronomical Society }}
+ at STRING{gp = {Geophysical Prospecting.}}
+ at STRING{grl = {Geophysical Research Letters}}
+ at STRING{geot = {G\'eotechnique}}
+ at STRING{ijnamg = {International Journal for Numerical and Analytical Methods in Geomechanics}}
+ at STRING{ijnme = {International Journal for Numerical Methods in Engineering}}
+ at STRING{ijcfd = {International Journal of Computational Fluid Dynamics}}
+ at STRING{jap = {Journal of Applied Physics}}
+ at STRING{jasa = {Journal of the Acoustical Society of America}}
+ at STRING{jbsce = {Journal of Boston Society of Civil Engineers}}
+ at STRING{jca = {Journal of Computational Acoustics}}
+ at STRING{jcp = {Journal of Computational Physics}}
+ at STRING{jge = {Journal of Geotechnical Engineering}}
+ at STRING{jged = {Journal of Geotechnical Engineering Division}}
+ at STRING{jgr = {Journal of Geophysical Research}}
+ at STRING{jmps = {Journal of the Mechanics and Physics of Solids}}
+ at STRING{jpdc = {Journal of Parallel and Distributed Computing}}
+ at STRING{jsmfd = {Journal of the Soil Mechanics and Foundations Division}}
+ at STRING{js = {The Journal of Supercomputing}}
+ at STRING{landslides = {Landslides}}
+ at STRING{lncs = {Lecture Notes in Computer Science}}
+ at STRING{mm = {Mechanics of Material}}
+ at STRING{nmpde = {Numerical Methods for Partial Differential Equations}}
+ at STRING{pc = {Parallel Computing}}
+ at STRING{pageoph = {Pure and Applied Geophysics}}
+ at STRING{pepi = {Physics of the Earth and Planetary Interiors}}
+ at STRING{rmre = {Rock mechanics and rock engineering}}
+ at STRING{sf = {Soils and Foundations}}
+ at STRING{siamjsc = {SIAM Journal on Scientific Computing}}
+
+# Entries
+
+ at ARTICLE{barragy1988,
+  author = {Barragy, E. and Carey, G. F.},
+  title = {A parallel element-by-element solution scheme},
+  journal = ijnme,
+  year = {1988},
+  volume = {26},
+  pages = {2367--2382},
+  owner = {homnath},
+  timestamp = {2011.05.27}
+}
+
+ at BOOK{canuto1988,
+  title = {Spectral methods in fluid dynamics},
+  publisher = {Springer},
+  year = {1988},
+  author = {Canuto, C. and Hussaini, M. Y. and Quarteroni, A. and Zang, T. A.}
+}
+
+ at MANUAL{cubit2011,
+  title = {CUBIT 13.0 User Documentation},
+  author = {{CUBIT}},
+  organization = {Sandia National Laboratories},
+  year = {2011},
+  note = {[Online; accessed 27-May-2011]},
+  owner = {homnath},
+  timestamp = {2011.05.27},
+  url = {http://cubit.sandia.gov/}
+}
+
+
+ at MANUAL{ensight2008,
+  title = {EnSight User Manual},
+  author = {EnSight},
+  organization = {Computational Engineering International, Inc.},
+  address = {Salem Street, Suite 101, Apex, NC 27523 USA},
+  edition = {Version 9.0},
+  year = {2008},
+  note = {[Online; accessed 11-July-2011]},
+  owner = {homnath},
+  timestamp = {2011.07.11}
+}
+
+ at ARTICLE{faccioli1997,
+  author = {Faccioli, E. and Maggio, F. and Paolucci, R. and Quarteroni, A.},
+  title = {{2D} and {3D} elastic wave propagation by a pseudo-spectral domain decomposition
+	method},
+  journal = {Journal of Seismology},
+  year = {1997},
+  volume = {1},
+  pages = {237--251}, 
+  issn = {1383-4649},
+  issue = {3},
+  keyword = {Earth and Environmental Science},
+  publisher = {Springer Netherlands}  
+}
+
+ at ARTICLE{geuzaine2009,
+  author = {C. Geuzaine and J. F. Remacle},
+  title = {Gmsh: a three-dimensional finite element mesh generator with built-in
+	pre- and post-processing facilities},
+  journal = ijnme,
+  year = {2009},
+  volume = {79},
+  pages = {1309--1331},
+  number = {11},
+  owner = {komatits},
+  timestamp = {2011.01.23}
+}
+
+ at ARTICLE{gharti2011,
+  author = {Gharti, H. N. and Komatitsch, D. and Oye, V. and Martin, R. and Tromp,
+	J.},
+  title = {Application of an elastoplastic spectral-element method to {3D} slope
+	stability analysis},
+  journal = ijnme,
+  year = {2011},
+  volume = {submitted},
+  owner = {homnath},
+  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}
+}
+
+ at BOOK{gropp1994,
+  title = {Using {MPI}, portable parallel programming with the {M}essage-{P}assing
+	{I}nterface},
+  publisher = {MIT Press},
+  year = {1994},
+  author = {W. Gropp and E. Lusk and A. Skjellum},
+  address = {Cambridge, USA}
+}
+
+ at ARTICLE{hughes1983,
+  author = {Hughes, T. J. R and Levit, I. and Winget, J.},
+  title = {An element-by-element solution algorithm for problems of structural
+	and solid mechanics},
+  journal = cmame,
+  year = {1983},
+  volume = {36},
+  pages = {241--254},
+  number = {2},
+  doi = {10.1016/0045-7825(83)90115-9},
+  issn = {0045-7825},
+}
+
+ at ARTICLE{khan1996,
+  author = {Khan, A. I. and Topping, B. H. V.},
+  title = {Parallel finite element analysis using {J}acobi-conditioned conjugate
+	gradient algorithm},
+  journal = aes,
+  year = {1996},
+  volume = {25},
+  pages = {309--319},
+
+}
+
+ at ARTICLE{king1987,
+  author = {King, R. B. and Sonnad, V.},
+  title = {Implementation of an element-by-element solution algorithm for the
+	finite element method on a coarse-grained parallel computer},
+  journal = cmame,
+  year = {1987},
+  volume = {65},
+  pages = {47--59},
+  number = {1},
+  doi = {10.1016/0045-7825(87)90182-4},
+  issn = {0045-7825},
+}
+
+ at ARTICLE{komatitsch1998,
+  author = {Komatitsch, D. and Vilotte, J. P.},
+  title = {The spectral element method: An efficient tool to simulate the seismic
+	response of {2D} and {3D} geological structures},
+  journal = bssa,
+  year = {1998},
+  volume = {88},
+  pages = {368--392},
+  number = {2},
+}
+
+ at ARTICLE{komatitsch1999,
+  author = {Komatitsch, D. and Tromp, J.},
+  title = {Introduction to the spectral element method for three-dimensional	
+	seismic wave propagation},
+  journal = gji,
+  year = {1999},
+  volume = {139},
+  pages = {806--822},
+  keywords = {attenuation, finite element methods, numerical techniques, seismic
+	
+	modelling, seismic wave propagation, topography.},
+  owner = {homnath},
+  timestamp = {2009.07.22}
+}
+
+ at TECHREPORT{larsen1995,
+  author = {Larsen, S. and Schultz, C. A.},
+  title = {{ELAS3D: 2D/3D elastic finite difference wave propagation code: Technical
+	Report No. UCRL-MA-121792}},
+  year = {1995},
+  owner = {homnath},
+  timestamp = {2008.04.08}
+}
+
+ at ARTICLE{law1986,
+  author = {Law, K. H.},
+  title = {A parallel finite element solution method},
+  journal = cs,
+  year = {1986},
+  volume = {23},
+  pages = {845--858},
+  number = {6},
+  doi = {10.1016/0045-7949(86)90254-3},
+  issn = {0045-7949},
+}
+
+ at BOOK{pacheco1997,
+  title = {Parallel Programming with {MPI}},
+  publisher = {Morgan Kaufmann},
+  year = {1997},
+  author = {Pacheco, P.},
+}
+
+ at ARTICLE{peter2011,
+  author = {Peter, D. and Komatitsch, D. and Luo, Y. and Martin, R. and Le Goff,
+	N. and Casarotti, E. and Le Loher, P. and Magnoni, F. and Liu, Q.
+	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 = {Geophysical Journal International},
+  year = {2011},
+  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}
+}
+
+ at ARTICLE{patera1984,
+  author = {Patera, A. T.},
+  title = {A spectral element method for fluid dynamics: laminar flow in a channel
+	expansion},
+  journal = jcp,
+  year = {1984},
+  volume = {54},
+  pages = {468--488},
+}
+
+
+ at ARTICLE{pellegrini1996,
+  author = {F. Pellegrini and J. Roman},
+  title = {{SCOTCH}: A Software Package for Static Mapping by Dual Recursive
+	Bipartitioning of Process and Architecture Graphs},
+  journal = lncs,
+  year = {1996},
+  volume = {1067},
+  pages = {493--498}
+}
+
+ at ARTICLE{seriani1994,
+  author = {Seriani, G.},
+  title = {{3-D} large-scale wave propagation modeling by spectral element method
+	on {Cray T3E} multiprocessor},
+  journal = cmame,
+  year = {1994},
+  volume = {164},
+  pages = {235--247},
+  owner = {homnath},
+  timestamp = {2010.08.26}
+}
+
+ at BOOK{smith2004,
+  title = {Programming the finite element method},
+  publisher = {John Wiley \& Sons},
+  year = {2004},
+  author = {Smith, I. M. and Griffiths, D. V.},
+  owner = {homnath},
+  timestamp = {2010.08.26}
+}
+
+ at MANUAL{truegrid2006,
+  title = {TrueGrid User's Manual},
+  author = {Rainsberger, R.},
+  organization = {XYZ Scientific Applications, Inc.},
+  address = {Livermore, CA},
+  edition = {version 2.3.0},
+  year = {2006},
+  owner = {homnath},
+  timestamp = {2011.05.12},
+  url = {www.truegrid.com}
+}
+
+ at ARTICLE{zheng2005,
+  author = {Zheng, H. and Liu, D. F. and Li, C. G.},
+  title = {Slope stability analysis based on elasto-plastic finite element method},
+  journal = ijnme,
+  year = {2005},
+  volume = {64},
+  pages = {1871--1888},
+  owner = {homnath},
+  timestamp = {2011.01.11}
+}
+
+ at article{zienkiewicz1974,
+title={Visco-plasticity--plasticity and creep in elastic solids --- a unified numerical solution approach}, 
+volume={8},
+number={4}, 
+journal=ijnme, 
+author={Zienkiewicz, O. and Cormeau, I.}, 
+year={1974}, 
+pages={821--845}
+}
+

Added: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.pdf
===================================================================
(Binary files differ)


Property changes on: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.pdf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Copied: seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.tex (from rev 18887, seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/SPECFEM3D_GEOTECH.tex)
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.tex	                        (rev 0)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/doc/manual_SPECFEM3D_GEOTECH.tex	2011-09-09 12:18:10 UTC (rev 18889)
@@ -0,0 +1,865 @@
+%% Do not edit unless you really know what you are doing.
+\documentclass[12pt,a4paper]{report}
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+\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
+  \pagenumbering{arabic}}
+\newcommand{\backmatter}{\cleardoublepage}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
+%\renewcommand{\baselinestretch}{1.5}
+
+% hyperlinks to sections and references
+%\usepackage[pdftex,bookmarks=true,bookmarksnumbered=true,pdfpagemode=None,pdfstartview=FitH,pdfpagelayout=SinglePage,pdfborder={0 0 0}]{hyperref}
+\newcommand{\tsup}[1]{\textsuperscript{#1}}
+\newenvironment{desclist}[1]
+{\begin{list}{}
+{\renewcommand\makelabel[1]{{##1}\hfill}
+\settowidth\labelwidth{\makelabel{#1}}
+\setlength\leftmargin{\labelwidth+\labelsep}}}
+{\end{list}}
+
+\newenvironment{adescription}[1]
+{\begin{list}{}
+{\renewcommand\makelabel[1]{\texttt{##1}\hfill}
+\settowidth\labelwidth{\makelabel{#1}}
+\setlength\leftmargin{\labelwidth+\labelsep}}}
+{\end{list}}
+
+% Package name and version
+\def\pack{SPECFEM3D\_GEOTECH}
+\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]
+%\centering
+%\noindent\includegraphics[width=0.8\paperwidth]{cover}
+%\noindent\includegraphics[scale=1.0]{cover}
+%\end{figure}
+
+\thispagestyle{empty} % no page number
+\title{\textbf{\packver \\
+User Manual}}
+
+
+\author{Hom Nath Gharti, NORSAR, Norway \\
+Dimitri Komatitsch, University of Toulouse, France \\
+Volker Oye, NORSAR, Norway \\
+Roland Martin, University of Toulouse, France \\
+Jeroen Tromp, Princeton University, USA}
+
+\maketitle
+
+\frontmatter
+\addcontentsline{toc}{chapter}{Licensing}
+\chapter*{Licensing}
+%
+%\packver\ \\
+%Copyright 2010-2011 Hom Nath Gharti\\
+%
+%This file is part of \packver.\\
+%
+\packver\ is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.\\
+
+\packver\ is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.\\
+
+You should have received a copy of the GNU General Public License
+along with \linebreak\packver.  If not, see <\texttt{http://www.gnu.org/licenses/}>.\\
+
+\clearpage
+
+\addcontentsline{toc}{chapter}{Acknowledgments}
+\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
+\clearpage
+
+\mainmatter
+\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} 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 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[Automatic factor of safety]      : No
+\end{desclist}
+
+\section*{Revision}
+
+HNG, Sep 08, 2011; HNG, Jul 12, 2011; HNG, May 20, 2011; HNG, Jan 17, 2011
+
+
+\chapter{Getting started}
+\section{Package structure}
+Original \pack\ package comes in a single compressed file \linebreak\texttt{\pack.tar.gz}, which can be extracted using \texttt{tar} command:\\
+
+\texttt{tar -zxvf \pack.tar.gz}\\
+
+Or\\
+
+using, for example, \texttt{7-zip (www.7-zip.org)} in WINDOWS. The package has a following structure.\\
+
+
+
+\texttt{\pack/}
+\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 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.
+\item[~~src/]                  : contains all source files.
+\end{adescription}
+
+\section{Prerequisites}
+\begin{itemize}[-]
+  \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}
+  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}
+
+  Finally, following compiler is necessary to build the documentation (this file).
+\begin{itemize}[-]
+  \item \underline{\LaTeX\ compiler}. This is necessary to compile the documentation files.
+\end{itemize}
+
+\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}
+  \item{\emph{Note: If reconfiguration is necessary, it is better to delete all Cache files of the build directory.}}
+\end{itemize}
+
+\section{Run}
+\subsubsection{Serial run}
+\begin{itemize}[-]
+\item To run serial program, type \\
+    \texttt{./bin/semgeotech} \emph{input\_file\_name}
+
+    Example:
+
+    \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}
+
+    Example:
+
+    \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} \\
+
+    OR
+
+    \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}
+\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{. 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}
+\section{Main input file}
+
+Main input file structure is motivated by the ``E3D''~\citep{larsen1995} software package. The main input file consists of legitimate input lines defined in the specified formats. Any number of blank lines or comment lines can be placed for user friendly input structure. The blank lines contain no or only white-space characters, and the comment lines contain "\#" as the first character. \\
+
+Each legitimate input line consists of a line type, and list of arguments and corresponding values. All argument-value pair are separated by comma (,). If necessary, any legitimate input line can be continued to next line using FORTRAN 90 continuation  character "\&" as an absolute last character of a line to be continued. Repetition of same line type is not allowed.\\
+
+Legitimate input lines have the format\\
+{\it{line\_type}} $arg_1=val_1$, $arg_2=val_2$, ......., $arg_n=val_n$\\
+
+Example:\\
+\texttt{preinfo: nproc=8, ngllx=3, nglly=3, ngllz=3, nenod=8, ngnod=8, \& \\
+inp\_path=\sq{../input}, part\_path=\sq{../partition}, out\_path=\sq{../output/}}\\
+
+All legitimate input lines should be written in lower case. Line type and argument-value pairs must be separated by space. Each argument-value pair must be separated by comma(,) and space/s. No space/s are recommended before line type and in between argument name and "=" or "=" and argument value. If argument value is a string, the FORTRAN 90 string (i.e., enclosed within the single quotes) should be used, for example, \texttt{inp\_path=\sq{../input}}. If the argument value is a vector (i.e., multi-valued), a list of values separated by space (no comma!) shoud be used, e.g, \texttt{srf=1.0 1.2 1.3 1.4}.
+
+\subsection{Line types}
+
+Only the following line types are permitted.
+\begin{adescription}{traction:}
+\item[preinfo:]  preliminary information of the simulation
+\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]
+\item[control:]  control of the simulation
+\item[save:]  options to save data
+\end{adescription}
+
+\subsection{Arguments}
+
+Only the following arguments under the specified line types are permitted.\\
+
+\texttt{\underline{preinfo:}}
+
+\begin{adescription}{nl\_maxiter}
+  \item[nproc] : number of processors to be used for the parallel processing [integer > 1]. Only required for parallel processing.
+  \item[ngllx] : number of Gauss-Lobatto-Legendre (GLL) points along $x$-axis [integer > 1].
+  \item[nglly] : number of GLL points along $y$-axis [integer > 1].
+  \item[ngllz] : number of GLL points along $z$-axis [integer > 1]. \\\\
+  {\emph{Note: Although the program can use different values of}} \texttt{ngllx}, \texttt{nglly}, {\emph{and}} \texttt{ngllz}, {\emph{it is recommended to use same number of GLL points along all axes.}}
+  \item[inp\_path]  : input path where the input data are located [string, optional, default $\Rightarrow$ \texttt{\sq{../input}}].
+  \item[part\_path] : partition path where the partitioned data will be or are located [string, optional, default $\Rightarrow$ \texttt{\sq{../partition}}]. Only required for parallel processing.
+  \item[out\_path]  : output path where the output data will be stored [string, optional, default $\Rightarrow$ \texttt{\sq{../output}}].\\
+\end{adescription}
+
+
+\texttt{\underline{mesh:}}
+\begin{adescription}{nl\_maxiter}
+  \item[xfile] : file name of $x$-coordinates [string].
+  \item[yfile] : file name of $y$-coordinates [string].
+  \item[zfile] : file name of $z$-coordinates [string].
+  \item[confile]: file name of mesh connectivity [string].
+  \item[idfile]: file name of element IDs [string].
+  \item[gfile]: file name of ghost interfaces, i.e., partition interfaces [string]. Only required for parallel processing.\\
+\end{adescription}
+
+\texttt{\underline{bc:}}
+\begin{adescription}{nl\_maxiter}
+  \item[uxfile]: file name of displacement boundary conditions along $x$-axis [string].
+  \item[uyfile]: file name of displacement boundary conditions along $y$-axis [string].
+  \item[uzfile]: file name of displacement boundary conditions along $z$-axis [string].\\
+\end{adescription}
+
+\texttt{\underline{traction:}}
+\begin{adescription}{nl\_maxiter}
+  \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].
+  \item[ispart]: flag to indicate whether the material file is partitioned [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 1]. Only required for parallel processing.
+  \item[matpath]: path to material file [string, optional, default $\Rightarrow$ \texttt{\sq{../input}} for serial or unpartitioned material file in parallel and \texttt{\sq{../partition}} for partitioned material file in parallel].
+  \item[allelastic]: assume all entire domain as elastic [integer, optional, 0 = No, 1 = Yes, default $\Rightarrow$ 0].\\
+\end{adescription}
+
+\texttt{\underline{eqload:}}
+\begin{adescription}{nl\_maxiter}
+  \item[eqkx]: pseudo-static earthquake loading coefficient along $x$-axis [real, 0 <= \texttt{eqkx} <= 1.0, default $\Rightarrow$ 0.0].
+  \item[eqky]: pseudo-static earthquake loading coefficient along $y$-axis [real, 0 <= \texttt{eqky} <= 1.0, default $\Rightarrow$ 0.0].
+  \item[eqkz]: pseudo-static earthquake loading coefficient along $z$-axis [real, 0 <= \texttt{eqkz} <= 1.0, default $\Rightarrow$ 0.0].
+  \\\\
+  {\emph{Note: For the stability analysis purpose, these coefficients should be chosen carefully. For example, if the slope face is pointing towards the negative $x$-axis, value of}} \texttt{eqkx} {\emph{is taken negative.}} \\
+\end{adescription}
+
+\texttt{\underline{water:}}
+\begin{adescription}{nl\_maxiter}
+  \item[wsfile]: file name of water surface file.\\
+\end{adescription}
+
+\texttt{\underline{control:}}
+\begin{adescription}{nl\_maxiter}
+  \item[cg\_tol]: tolerance for conjugate gradient method [real].
+  \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[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[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, 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*{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/}\\\\
+\#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}\\\\
+\#control parameters\\
+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 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/}\\\\
+\#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}, gfile=\sq{validation1\_ghost}\\\\
+\#boundary conditions\\
+bc: uxfile=\sq{validation1\_ssbcux}, uyfile=\sq{validation1\_ssbcuy}, \& \\
+uzfile=\sq{validation1\_ssbcuz}\\\\
+\#material list\\
+material: matfile=\sq{validation1\_material\_list}\\\\
+\#control parameters\\
+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}
+
+\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{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{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\\
+\#-----------------------------------------------------------------}}\\\\
+}}
+
+\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:\\
+
+\emph{number of points \\
+coordinate of point  1\\
+coordinate of point  2\\
+coordinate of point  3\\
+..\\
+..\\
+..}\\
+
+Example:\\\\
+{\texttt{2354\\
+40.230394465164999\\
+40.759090909090901\\
+42.700000000000003\\
+40.957142857142898\\
+40.230394465164999\\
+40.759090909090901\\
+42.700000000000003\\
+40.957142857142898\\
+...\\
+...\\}}
+
+\subsection{Connectivity file: \texttt{confile}}
+
+The connectivity file contains the connectivity lists of elements in following format:\\
+
+\emph{number of elements\\
+$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 1\\
+$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 2\\
+$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 3\\
+$n_1$ $n_2$ $n_3$ $n_4$ $n_5$ $n_6$ $n_7$ $n_8$ of element 4\\
+..\\
+..}\\
+
+
+Example:\\\\
+1800\\
+\texttt{1 2 3 4 5 6 7 8 \\
+9 10 2 1 11 12 6 5 \\
+9 1 4 13 11 5 8 14 \\
+15 16 10 9 17 18 12 11 \\
+15 9 13 19 17 11 14 20 \\
+21 22 16 15 23 24 18 17 \\
+21 15 19 25 23 17 20 26 \\
+27 28 22 21 29 30 24 23 \\
+27 21 25 31 29 23 26 32 \\
+33 34 28 27 35 36 30 29 \\
+33 27 31 37 35 29 32 38 \\
+34 33 39 40 36 35 41 42 \\
+33 37 43 39 35 38 44 41 \\
+...\\
+...\\}
+
+\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: \\
+
+\emph{number of elements\\
+ID of element 1\\
+ID of element 2\\
+ID of element 3\\
+ID of element 4\\
+...\\
+...}\\
+
+Example:\\
+
+\texttt{1800\\
+1\\
+1\\
+1\\
+1\\
+1\\
+1\\
+1\\
+1\\
+1\\
+1\\
+...\\
+...\\}
+
+\subsection{Ghost partition interfaces file: \texttt{gfile}}
+
+
+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 following format:\\
+
+\emph{traction type} (integer, 0 = point, 1 = uniformly distributed, 2 = linearly distributed)\\
+if \emph{traction type} = 0\\
+  \emph{$q_x$ $q_y$ $q_z$} (load vector in kN)\\
+if \emph{traction type} = 1\\
+  \emph{$q_x$ $q_y$ $q_z$} (load vector in kN/m\tsup{2})\\
+if \emph{traction type} = 2\\
+  \emph{relevant-axis $x_1$ $x_2$ $q_{x1}$ $q_{y1}$ $q_{z1}$ $q_{x2}$ $q_{y2}$ $q_{z2}$}\\
+\emph{number of entities} (points for point load or faces for distributed load)\\
+\emph{elementID entityID \\
+elementID entityID \\
+elementID entityID \\
+...\\
+...\\}
+
+This can be repeated as many times as many tractions.\\
+
+The \emph{relevant-axis} denotes the axis along which the load is varying, and it is represented by an integer as 1 = $x$-axis, 2 = $y$-axis, and 3 = $z$-axis. The variables $x_1$ and $x_2$ denote the coordinates (only the \emph{relevant-axis}) of two points between which the linearly distributed load is applied. Similarly, $q_{x1}$, $q_{y1}$ and $q_{z1}$, and $q_{x2}$, $q_{y2}$ and $q_{z2}$ denote the load vectors in kN/m\tsup{2} at the point 1 and 2, respectively.\\
+
+Example:\\
+Following data specify the two tractions: a uniformly distributed traction and a linearly distributed traction.\\\\
+
+\texttt{1\\
+0.0 0.0 -167.751\\
+363\\
+56 1\\
+57 1\\
+58 1\\
+59 1\\
+60 1\\
+61 1\\
+62 1\\
+...\\
+...\\
+2\\
+3 7.3 24.4 51.8379 0.0 -159.5407 0.0 0.0 0.0\\
+594\\
+38 1\\
+39 1\\
+40 1\\
+41 1\\
+42 1\\
+43 1\\
+44 1\\
+45 1\\
+46 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
+
+\emph{number of water surfaces}\\
+\emph{water surface type} (integer, 0 = horizontal surface, 1 = inclined surface, 2 = meshed surface)\\
+if \emph{wstype}=0 (can be reconstructed by sweeping a horizontal line)\\
+  \emph{relevant-axis $x_1$ $x_2$ $z$}\\
+if \emph{wstype}=1 (can be reconstructed by sweeping a inclined line)\\
+  \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\\
+  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.\\
+
+
+Example:\\
+Following data specify the two water surfaces: a horizontal surface and an inclined surface.\\\\
+\texttt{2\\
+0\\
+1 42.7 50.0 6.1\\
+1\\
+1 0.0 42.7 12.2 6.1}\\
+
+\chapter{Output and Visualization}
+
+\section{Output files}
+
+\subsection{Summary file}
+
+This file is self explanatory and it contains the summary of the result including control parameters, maximum displacement at each step, and elapsed time. The file is written in ASCII format and its name follows the convention \emph{input\_file\_name\_header}\texttt{\_summary} for serial run and \emph{input\_file\_name\_header}\texttt{\_summary\_proc}\emph{processor\_ID} for parallel run.
+
+\subsection{Mesh files}
+
+This file contains the mesh information of the model including coordinates, connectivity, element types etc. in EnSight Gold binary format~\citep[see][]{ensight2008}. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_summary} for serial run and \emph{input\_file\_name\_header}\texttt{\_summary\_proc}\emph{processor\_ID} for parallel run.
+
+\subsection{Displacement field file}
+
+This file contains the nodal displacement field in the model written in EnSight Gold binary format. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{.dis} for serial run and \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{\_proc}\emph{processor\_ID}\texttt{.dis} for parallel run.
+
+\subsection{Pore pressure file}
+
+This file contains the hydrostatic pore pressure field in the model written in EnSight Gold binary format. The file name follows the format \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{.por} for serial run and \emph{input\_file\_name\_header}\texttt{\_step}\emph{step}\texttt{\_proc}\emph{processor\_ID}\texttt{.por} for parallel run.
+
+\subsection{CASE file}
+
+This is an EnSight Gold CASE file written in ASCII format. This file contain the information on the mesh files, other files, time steps etc. The file name follows the format \emph{input\_file\_name\_header}\texttt{.case} for serial run and \emph{input\_file\_name\_header}{\_proc}\emph{processor\_ID}\texttt{.case} for parallel run.
+
+\subsection{SOS file}
+
+This is an EnSight Gold server-of-server file for parallel visualization. The \texttt{write\_sos.f90} program provided in the \texttt{/utilities/} may be used to generate this file. See Chapter~\ref{chap:utilities}, Section~\ref{sec:sos} for more detail.
+
+All above EnSight Gold files correspond to the model with spectral-element mesh. Additionally, the CASE file/s and mesh file/s are written for the original model. These file names follow the similar conventions and they have the tag \texttt{\sq{original}} in the file name headers.
+
+\section{Visualization}
+\subsection{Serial visualization}
+
+Requirement: ParaView version later than 3.7. Precompiled binaries available from ParaView web (\texttt{www.paraview.org}) may be installed directly or it can be build from the source.
+
+\begin{itemize}
+\item open a session
+\item open paraview client \\
+\texttt{paraview}
+\item In ParaView client: $\Rightarrow$ File $\Rightarrow$ Open\\
+   select appropriate serial CASE file (.case file)\\
+   see ParaView wiki \texttt{paraview.org/Wiki/ParaView} for more detail.
+\end{itemize}
+
+\subsection{Parallel visualization}
+
+Requirement: ParaView version later than 3.7. It should be built enabling MPI. An appropriate MPI library is necessary.
+
+\begin{itemize}
+\item open a session
+\item open paraview client \\
+\texttt{paraview}
+\item start ParaView server \\
+mpirun -np 8 pvserver -display :0
+\item In ParaView client: $\Rightarrow$ File $\Rightarrow$ Connect and connect to the appropriate server
+\item In ParaView client: $\Rightarrow$ Open\\
+   select appropriate SOS file (.sos file)\\
+   see ParaView wiki (\texttt{paraview.org/Wiki/ParaView} for more detail.
+\end{itemize}
+
+\emph{Note: Each CASE file obtained from the parallel processing can also be visualized in a serial.}
+
+
+\chapter{Utilities}
+\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 \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}. 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}
+
+The program \texttt{write\_sos.f90} contained in the utilities directory can be used to write EnSight Gold server-of-server file (.sos file, see~\citep{ensight2008}) to visualize the multi-processors data in parallel. This file does not contain the actual data, but only the information on the data location and parallel processing.
+\subsubsection*{Compile}
+\texttt{gfortran -o write\_sos write\_sos.f90}
+\subsubsection*{Run}
+\texttt{exodus2sem} {\it{input\_file}}\\
+
+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{manual_SPECFEM3D_GEOTECH}
+
+\end{document}

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/apply_traction.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/apply_traction.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/apply_traction.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -134,17 +134,17 @@
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(ngllx)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllzx)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllzx-ngllx+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllzx-ngllx+1)
   elseif(i_face==2 .or. i_face==4)then ! YZ plane
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(nglly)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllyz)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllyz-nglly+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllyz-nglly+1)
   elseif(i_face==5 .or. i_face==6)then ! XY plane
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(ngllx)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllxy)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllxy-ngllx+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllxy-ngllx+1)
   else
     write(errtag,'(a)')'ERROR: wrong face ID for traction!'
     return
@@ -188,23 +188,23 @@
   if(ios/=0)exit traction
   count_trac=count_trac+1
   trac_stat=.false.
-  
+
   if(tractype==0)then ! point loading
     read(11,*)q ! vector
     read(11,*)nface ! number of points
     do i_face=1,nface
-      
+
       read(11,*)ielmt,inode
       ngdof=gdof(:,g_num(gnod(inode),ielmt))
-      load(ngdof)=load(ngdof)+q      
+      load(ngdof)=load(ngdof)+q
     enddo
     trac_stat=.true.
   elseif(tractype==1)then ! uniform loading
     !print*,tractype
     read(11,*)q ! vector
     read(11,*)nface
-    do i_face=1,nface      
-      read(11,*)ielmt,iface      
+    do i_face=1,nface
+      read(11,*)ielmt,iface
       if(iface==1 .or. iface==3)then
         nfgll=ngllzx
         lagrange_gll(1:nfgll,1:nfgll)=lagrange_gll_zx
@@ -224,15 +224,15 @@
         write(errtag,'(a)')'ERROR: wrong face ID for traction!'
         exit traction
       endif
-      nfdof=nfgll*ndim      
-            
+      nfdof=nfgll*ndim
+
       num=g_num(:,ielmt)
       coord=g_coord(:,num(face(iface)%gnod)) !transpose(g_coord(:,num(face(iface)%gnod)))
       fgdof(1:nfdof)=reshape(gdof(:,g_num(face(iface)%nod,ielmt)),(/nfdof/)) !g=g_g(:,ielmt)
 
       ftracload=zero
       ! compute numerical integration
-      do i_gll=1,nfgll        
+      do i_gll=1,nfgll
         ! compute d(area)
         dx_dxi=matmul(coord,dshape_quad4(1,:,i_gll))
         dx_deta=matmul(coord,dshape_quad4(2,:,i_gll))
@@ -242,12 +242,12 @@
         face_normal(1)=dx_dxi(2)*dx_deta(3)-dx_deta(2)*dx_dxi(3)
         face_normal(2)=dx_deta(1)*dx_dxi(3)-dx_dxi(1)*dx_deta(3)
         face_normal(3)=dx_dxi(1)*dx_deta(2)-dx_deta(1)*dx_dxi(2)
-        
+
         detjac=sqrt(dot_product(face_normal,face_normal))
         face_normal=fsign(iface)*face_normal/detjac
         !print*,face_normal
-        !stop      
-        
+        !stop
+
         ! TODO:for constant q this can be computed only once!!
         ftracload(1:nfdof:3)=ftracload(1:nfdof:3)+ &
         q(1)*lagrange_gll(i_gll,:)*detjac*gll_weights(i_gll) ! *face_normal(1) !only in X direction
@@ -256,7 +256,7 @@
         ftracload(3:nfdof:3)=ftracload(3:nfdof:3)+ &
         q(3)*lagrange_gll(i_gll,:)*detjac*gll_weights(i_gll) ! *face_normal(3) !only in Z direction
       enddo
-      load(fgdof(1:nfdof))=load(fgdof(1:nfdof))+ftracload(1:nfdof)     
+      load(fgdof(1:nfdof))=load(fgdof(1:nfdof))+ftracload(1:nfdof)
     enddo
     trac_stat=.true.
   elseif(tractype==2)then ! linearly distributed loading
@@ -285,7 +285,7 @@
         exit traction
       endif
       nfdof=nfgll*ndim
-            
+
       num=g_num(:,ielmt)
       coord=g_coord(:,num(face(iface)%gnod)) !coord=transpose(g_coord(:,num(face(iface)%gnod)))
       fgdof(1:nfdof)=reshape(gdof(:,g_num(face(iface)%nod,ielmt)),(/nfdof/)) !g=g_g(:,ielmt)
@@ -294,21 +294,21 @@
       do i_gll=1,nfgll
         x=g_coord(iaxis,num(face(iface)%nod(i_gll)))
         q=q1+dq_dx*(x-x1) ! vector of nodal values
-        
+
         ! compute two vectors dx_dxi and dx_deta
         dx_dxi=matmul(coord,dshape_quad4(1,:,i_gll))
         dx_deta=matmul(coord,dshape_quad4(2,:,i_gll))
-        
+
         ! Normal = (dx_sxi x dx_deta)
         face_normal(1)=dx_dxi(2)*dx_deta(3)-dx_deta(2)*dx_dxi(3)
         face_normal(2)=dx_deta(1)*dx_dxi(3)-dx_dxi(1)*dx_deta(3)
         face_normal(3)=dx_dxi(1)*dx_deta(2)-dx_deta(1)*dx_dxi(2)
-        
+
         detjac=sqrt(dot_product(face_normal,face_normal))
         face_normal=fsign(iface)*face_normal/detjac
         !print*,face_normal
-        !stop      
-        
+        !stop
+
         ftracload(1:nfdof:3)=ftracload(1:nfdof:3)+ &
         q(1)*lagrange_gll(i_gll,:)*detjac*gll_weights(i_gll) ! *face_normal(1) !only in X direction
         ftracload(2:nfdof:3)=ftracload(2:nfdof:3)+ &
@@ -318,12 +318,12 @@
      enddo
      load(fgdof(1:nfdof))=load(fgdof(1:nfdof))+ftracload(1:nfdof)
    enddo
-   trac_stat=.true. 
+   trac_stat=.true.
   else
     write(errtag,'(a)')'ERROR: traction type ',tractype,' not supported!'
     exit traction
-  endif  
-    
+  endif
+
 enddo traction
 close(11)
 
@@ -340,7 +340,7 @@
 if(.not.trac_stat)then
   write(errtag,'(a)')'ERROR: all tractions cannot be read!'
   return
-endif  
+endif
 
 errcode=0
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_bmat.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_bmat.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_bmat.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,13 +1,13 @@
 ! This subroutine forms the strain-displacement matrix (bmat)
 ! in 2D (ih=3 or 4) or 3D (ih=6)
-! REFERENCE: 
-!  copied and modified from 
+! REFERENCE:
+!  copied and modified from
 !  Smith and Griffiths (2004): Programming the finite element method
 ! REVISION
 !   HNG, Jul 12,2011; HNG, Apr 09,2010
 SUBROUTINE compute_bmat(bmat,deriv)
 use set_precision
- IMPLICIT NONE 
+ IMPLICIT NONE
  REAL(kind=kreal),INTENT(IN)::deriv(:,:)
  REAL(kind=kreal),INTENT(OUT)::bmat(:,:)
  INTEGER::k,l,m,n,ih,nod
@@ -46,8 +46,8 @@
      bmat(6,l)=z
    END DO
  CASE DEFAULT
-   WRITE(*,*)'ERROR: wrong dimension for "nst" in bmat matrix!'        
- END SELECT   
+   WRITE(*,*)'ERROR: wrong dimension for "nst" in bmat matrix!'
+ END SELECT
 RETURN
 END SUBROUTINE compute_bmat
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_cmat.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_cmat.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_cmat.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,7 +1,7 @@
 ! this subroutine returns the elastic matrix for ih=3 (plane strain),
 ! ih=4 (axisymmetry or plane strain elastoplasticity) or ih=6 (3D)
-! REFERENCE: 
-!  copied and modified from 
+! REFERENCE:
+!  copied and modified from
 !  Smith and Griffiths (2004): Programming the finite element method
 ! REVISION
 !   HNG, Jul 12,2011; HNG, Apr 09,2010
@@ -12,7 +12,7 @@
  real(kind=kreal),intent(out)::cmat(:,:)
  real(kind=kreal)::v1,v2,c,vv,zero=0.0_kreal,pt5=0.5_kreal,one=1.0_kreal,two=2.0_kreal
  integer::i,ih
- cmat=zero  
+ cmat=zero
  ih=ubound(cmat,1)
  v1=one-v
  c=e/((one+v)*(one-two*v))
@@ -27,7 +27,7 @@
    cmat(1,1)=v1*c
    cmat(2,2)=v1*c
    cmat(4,4)=v1*c
-   cmat(3,3)=pt5*c*(one-two*v) 
+   cmat(3,3)=pt5*c*(one-two*v)
    cmat(1,2)=v*c
    cmat(2,1)=v*c
    cmat(1,4)=v*c
@@ -54,4 +54,4 @@
    write(*,*)'ERROR: wrong size for "cmat" matrix!'
  end select
 return
-end subroutine compute_cmat    
+end subroutine compute_cmat

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_pressure.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_pressure.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/compute_pressure.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -33,7 +33,7 @@
 logical :: wsurf_mesh
 
 type water_surface
-  integer :: rdir,stype  
+  integer :: rdir,stype
   real(kind=kreal) :: rx1,rx2,z1,z2 ! z-coordinates of water surface
   integer :: nface
   integer,allocatable :: ielmt(:),iface(:)
@@ -123,17 +123,17 @@
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(ngllx)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllzx)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllzx-ngllx+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllzx-ngllx+1)
   elseif(i_face==2 .or. i_face==4)then ! YZ plane
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(nglly)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllyz)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllyz-nglly+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllyz-nglly+1)
   elseif(i_face==5 .or. i_face==6)then ! XY plane
     face(i_face)%gnod(1)=face(i_face)%nod(1)
     face(i_face)%gnod(2)=face(i_face)%nod(ngllx)
     face(i_face)%gnod(3)=face(i_face)%nod(ngllxy)
-    face(i_face)%gnod(4)=face(i_face)%nod(ngllxy-ngllx+1)  
+    face(i_face)%gnod(4)=face(i_face)%nod(ngllxy-ngllx+1)
   else
     write(errtag,'(a)')'ERROR: wrong face ID for traction!'
     return
@@ -173,23 +173,23 @@
   endif
 enddo
 close(11)
-    
+
 ! compute distance to the free surface
 wpressure=zero
 nodal: do i_node=1,nnode
   if(submerged_node(i_node))then
     xp=g_coord(:,i_node) ! coordinates of the node
-    
+
     do i_wsurf=1,nwsurf
       if(wsurf(i_wsurf)%stype==0)then ! sweep horizontal line all across (z=constant)
         rdir=wsurf(i_wsurf)%rdir
         rx1=wsurf(i_wsurf)%rx1
         rx2=wsurf(i_wsurf)%rx2
-        z=wsurf(i_wsurf)%z1        
+        z=wsurf(i_wsurf)%z1
         !print*,rdir,rx1,rx2,z,xp(3)
         !stop
         if(xp(rdir)>=rx1 .and. xp(rdir)<=rx2 .and. xp(3)<=z)then
-          ! point lies below this water surface          
+          ! point lies below this water surface
           ! compute pressure
           if(z>xp(3))then
             wpressure(i_node)=gamw*(z-xp(3))
@@ -200,15 +200,15 @@
         rdir=wsurf(i_wsurf)%rdir
         rx1=wsurf(i_wsurf)%rx1
         rx2=wsurf(i_wsurf)%rx2
-        z1=wsurf(i_wsurf)%z1  
-        z2=wsurf(i_wsurf)%z2             
-        
+        z1=wsurf(i_wsurf)%z1
+        z2=wsurf(i_wsurf)%z2
+
         if(xp(rdir)>=min(rx1,rx2) .and. xp(rdir)<=max(rx1,rx2) .and. xp(3)<=max(z1,z2))then
           ! point lies below this water surface
           !compute z
-          z=z1+(z2-z1)*(xp(rdir)-rx1)/(rx2-rx1)    
+          z=z1+(z2-z1)*(xp(rdir)-rx1)/(rx2-rx1)
           !print*,rdir,rx1,rx2,z1,z2,z,xp(rdir),xp(3)
-          !stop      
+          !stop
           ! compute pressure
           if(z>xp(3))then
             wpressure(i_node)=gamw*(z-xp(3))
@@ -216,13 +216,13 @@
           cycle nodal
         endif
       elseif(wsurf(i_wsurf)%stype==2)then ! meshed surface in the model
- 
+
         do i_face=1,wsurf(i_wsurf)%nface
           xf=g_coord(:,g_num(face(wsurf(i_wsurf)%iface(i_face))%gnod,wsurf(i_wsurf)%ielmt(i_face))) ! coordinates vector of the face
           xmin=minval(xf(1,:)); xmax=maxval(xf(1,:))
           ymin=minval(xf(2,:)); ymax=maxval(xf(2,:))
           zmin=minval(xf(3,:)); zmax=maxval(xf(3,:))
-          
+
           if(xp(1)>=xmin .and. xp(1)<=xmax .and. xp(2)>=ymin .and. xp(2)<=ymax .and. xp(3)<=zmax)then
             ! find equation of the plane
             ! Ax+By+Cz+D=0
@@ -234,7 +234,7 @@
             B=v2(1)*v1(3)-v1(1)*v2(3)
             C=v1(1)*v2(2)-v2(1)*v1(2)
             D=determinant(xf(:,1:3))
-            
+
             ! find Z-coordinates on the plane just above the point (xp)
             if (C==zero)then
               write(*,*)'WARNING: free surface face is vertical!'
@@ -245,8 +245,8 @@
             if (z>maxval(xf(3,:)) .or. z<minval(xf(3,:)))then
               write(errtag,'(a)')'ERROR: free surface cannot be determined!'
               return
-            endif          
-            
+            endif
+
             ! compute pressure
             if(z>xp(3))then
               wpressure(i_node)=gamw*(z-xp(3))
@@ -258,7 +258,7 @@
     enddo
   endif
 enddo nodal
-! deallocate variables  
+! deallocate variables
 do i=1,6
   deallocate(face(i)%nod)
 enddo

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/excavation.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/excavation.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/excavation.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -39,7 +39,7 @@
 if(ielmt_void/=nelmt_void .or. ielmt_intact/=nelmt_intact)then
   write(*,'(/,a)')'ERROR: counted intact/void elements mismatch!'
   stop
-endif 
+endif
 
 ! find intact and void nodes
 isnode=.false.
@@ -50,7 +50,7 @@
 end subroutine intact_void_elmt
 !===========================================
 
-! this subroutine analyzes the excavation and determines the nodes 
+! this subroutine analyzes the excavation and determines the nodes
 ! in the intact and void regions
 subroutine intact_void_node(isnode,nnode_intact,nnode_void,node_intact,node_void,nmir)
 use global,only:nnode
@@ -80,7 +80,7 @@
 end subroutine intact_void_node
 !===========================================
 
-! this subroutine modifies the gdof array setting all the freedoms corresponding 
+! this subroutine modifies the gdof array setting all the freedoms corresponding
 ! to the dead nodes as fixed
 subroutine modify_gdof(gdof,nnode_void,node_void,neq)
 use global,only:nndof,nnode
@@ -115,7 +115,7 @@
 integer,intent(in) :: gnum_void(ngll,nelmt_void)
 integer :: i_elmt,num(ngll)
 
-! correct node valency subtracting dead-element nodes  
+! correct node valency subtracting dead-element nodes
 do i_elmt=1,nelmt_void
   !ielmt=elmt_void(i_elmt)
   num=gnum_void(:,i_elmt)
@@ -125,7 +125,7 @@
 end subroutine correct_nvalency
 !===========================================
 
-! this subroutine computes the excavation loads. this load consists of both 
+! this subroutine computes the excavation loads. this load consists of both
 ! gravity and stress load
 subroutine excavation_load(nelmt,neq,gnod,g_num,gdof_elmt,mat_id,dshape_hex8, &
 lagrange_gll,dlagrange_gll,gll_weights,stress_local,extload)
@@ -148,33 +148,33 @@
 integer :: i,i_elmt
 
 ! compute excavation load
-do i_elmt=1,nelmt  
+do i_elmt=1,nelmt
   bload=zero; eld=zero
   num=g_num(:,i_elmt)
   coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
   egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,ielmt)),(/nndof*nenod/))
-  
+
   do i=1,ngll
     !call shape_function(fun,gll_points(i))
     ! compute Jacobian at GLL point using 20 noded element
-    !call shape_derivative(der,gll_points(:,i)) 
-    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord) 
-    detjac=determinant(jac)      
-    call invert(jac)      
+    !call shape_derivative(der,gll_points(:,i))
+    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)
+    detjac=determinant(jac)
+    call invert(jac)
     deriv=matmul(jac,dlagrange_gll(:,i,:)) ! use der for gll
     call compute_bmat(bmat,deriv) !!! gll bmat matrix
     sigma=stress_local(:,i,i_elmt)
     eload=MATMUL(sigma,bmat)
-    bload=bload+eload*detjac*gll_weights(i)    
-    eld(3:nedof:3)=eld(3:nedof:3)+lagrange_gll(i,:)*detjac*gll_weights(i)    
+    bload=bload+eload*detjac*gll_weights(i)
+    eld(3:nedof:3)=eld(3:nedof:3)+lagrange_gll(i,:)*detjac*gll_weights(i)
   end do ! i=1,ngll
-  extload(egdof)=extload(egdof)+eld*gam(mat_id(i_elmt))+bload    
+  extload(egdof)=extload(egdof)+eld*gam(mat_id(i_elmt))+bload
 enddo
 extload(0)=zero
 return
 end subroutine excavation_load
 
-! this subroutine computes the excavation loads. this load consists of both 
+! this subroutine computes the excavation loads. this load consists of both
 ! gravity and stress load
 subroutine excavation_load_nodal(nelmt,neq,gnod,g_num,mat_id,dshape_hex8, &
 lagrange_gll,dlagrange_gll,gll_weights,stress_local,excavload)
@@ -198,32 +198,32 @@
 
 excavload=zero
 ! compute excavation load
-do i_elmt=1,nelmt  
+do i_elmt=1,nelmt
   bload=zero; eld=zero; tload=zero
   num=g_num(:,i_elmt)
   coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
   !egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,ielmt)),(/nndof*nenod/))
-  
+
   do i=1,ngll
     !call shape_function(fun,gll_points(i))
     ! compute Jacobian at GLL point using 20 noded element
-    !call shape_derivative(der,gll_points(:,i)) 
-    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord) 
-    detjac=determinant(jac)      
-    call invert(jac)      
+    !call shape_derivative(der,gll_points(:,i))
+    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)
+    detjac=determinant(jac)
+    call invert(jac)
     deriv=matmul(jac,dlagrange_gll(:,i,:)) ! use der for gll
     call compute_bmat(bmat,deriv) !!! gll bmat matrix
     sigma=stress_local(:,i,i_elmt)
     eload=MATMUL(sigma,bmat)
-    bload=bload+eload*detjac*gll_weights(i)    
-    eld(3:nedof:3)=eld(3:nedof:3)+lagrange_gll(i,:)*detjac*gll_weights(i)    
+    bload=bload+eload*detjac*gll_weights(i)
+    eld(3:nedof:3)=eld(3:nedof:3)+lagrange_gll(i,:)*detjac*gll_weights(i)
   end do ! i=1,ngll
   tload=eld*gam(mat_id(i_elmt))+bload
   !excavload(:,num)=excavload(:,num)+reshape(tload,(/nndof,ngll/))
   do i=1,nndof
     excavload(i,num)=excavload(i,num)+tload(i:nedof:nndof)
-  enddo  
-  !extload(egdof)=extload(egdof)+eld*gam(mat_id(i_elmt))+bload    
+  enddo
+  !extload(egdof)=extload(egdof)+eld*gam(mat_id(i_elmt))+bload
 enddo
 !extload(0)=zero
 return

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/ghost_library_mpi.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,4 +1,4 @@
-! this module contains the routines to process parallel communications across 
+! 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
@@ -33,7 +33,7 @@
 implicit none
 integer,intent(in) :: myid,nproc
 integer,dimension(nndof,nnode),intent(in) :: gdof ! global degree of freedom
-integer,intent(out) :: ngpart,maxngnode 
+integer,intent(out) :: ngpart,maxngnode
 integer :: istat
 
 integer,dimension(8) :: ign,jgn,kgn ! ith, jth, and kth GLL indices of node
@@ -64,14 +64,14 @@
 ngll_vec=quick_sort((/ngllx,nglly,ngllz/),3)
 maxngll_face=ngll_vec(3)*ngll_vec(2)
 
-! local node numbering in each face CUBIT/EXODUS convention  
+! local node numbering in each face CUBIT/EXODUS convention
 node_face(1,:)=(/1,2,6,5/) ! front
 node_face(2,:)=(/2,3,7,6/) ! right
 node_face(3,:)=(/4,3,7,8/) ! back
 node_face(4,:)=(/1,4,8,5/) ! left
 node_face(5,:)=(/1,2,3,4/) ! bottom
 node_face(6,:)=(/5,6,7,8/) ! top
-  
+
 ! local node numbering in each edge CUBIT/EXODUS convention
 ! bottom edges
 node_edge(1,:)=(/1,2/);  node_edge(2,:)=(/2,3/)
@@ -128,7 +128,7 @@
 
 do i_gpart=1,ngpart ! ghost partitions loop
   read(11,*) ! skip 1 line
-  read(11,*)gpartid,gpart(i_gpart)%mindex !gpart_mindex(i_gpart) 
+  read(11,*)gpartid,gpart(i_gpart)%mindex !gpart_mindex(i_gpart)
   gpartid=gpartid+1 ! index coarray starts from 1
 
   read(11,*) ! skip 1 line
@@ -138,11 +138,11 @@
   !print*,ngelmt,ngelmt*maxngll_face,'istat=',istat
   switch_node=.false.
   ncount=0
-  !call error_stop(errtag,stdout) 
+  !call error_stop(errtag,stdout)
   !if(this_image()==6)print*,'what0!',i_gpart,' of ',ngpart
   do i_elmt=1,ngelmt ! ghost elements loop
     read(11,*)melmt,etype,eid; !print*,'melmt',melmt,etype,eid
-    
+
     ! initialize
     ig0=-1; ig1=-1
     jg0=-1; jg1=-1
@@ -161,10 +161,10 @@
       jg0=minval(jgn(node_face(eid,:))); jg1=maxval(jgn(node_face(eid,:)))
       kg0=minval(kgn(node_face(eid,:))); kg1=maxval(kgn(node_face(eid,:)))
     else
-      write(errtag,*)'ERROR: wrong etype:',etype,' for ghost partition ',mpartid,'!'      
+      write(errtag,*)'ERROR: wrong etype:',etype,' for ghost partition ',mpartid,'!'
       call error_stop(errtag,stdout,myid)
-    endif    
-    
+    endif
+
     !print*,ig0,ig1,jg0,jg1,kg0,kg1
     !sync all
     !call error_stop(errtag,stdout)
@@ -181,8 +181,8 @@
         enddo
       enddo
     enddo
-  enddo ! do i_elmt 
-  
+  enddo ! do i_elmt
+
   gpart(i_gpart)%nnode=ncount
   gpart(i_gpart)%id=gpartid
   allocate(gpart(i_gpart)%node(ncount),gpart(i_gpart)%isnode(ncount))
@@ -198,8 +198,8 @@
   !  print*,itmp_array
   !  call error_stop(errtag,stdout)
   !endif
-  
-  gpart(i_gpart)%node=itmp_array(1:ncount) 
+
+  gpart(i_gpart)%node=itmp_array(1:ncount)
   !if (mypart==2 .and. i_gpart==1)then
   !  print*,gpart_nnode(1)
   !  print*,gpart_node(1,:)
@@ -207,10 +207,10 @@
   !  call error_stop(errtag,stdout)
   !endif
   !print*,'myid',myid,ncount,size(gpart(i_gpart)%order)
-  
+
   !order nodal array to match with ghost partitions
-  !extract coordinates  
-  allocate(xp(ncount),yp(ncount),zp(ncount))  
+  !extract coordinates
+  allocate(xp(ncount),yp(ncount),zp(ncount))
 
   xp=g_coord(1,itmp_array(1:ncount))
   yp=g_coord(2,itmp_array(1:ncount))
@@ -228,7 +228,7 @@
   endif
 
   ! find ghost gdof
-  gpart(i_gpart)%gdof=reshape(gdof(:,gpart(i_gpart)%node),(/ncount*nndof/)) 
+  gpart(i_gpart)%gdof=reshape(gdof(:,gpart(i_gpart)%node),(/ncount*nndof/))
   !print*,gpart(i_gpart)%gdof
   !print*,'Total 0s:',myid,ncount,count(gpart(i_gpart)%gdof==0)
 
@@ -272,7 +272,7 @@
 end subroutine modify_ghost
 !=======================================================
 
-! this subroutine assembles the contributions of all ghost partitions 
+! this subroutine assembles the contributions of all ghost partitions
 ! at gdof locations
 subroutine assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,array,array_g)
 !use math_library, only : maxscal_par
@@ -298,13 +298,13 @@
 !do i_gpart=1,ngpart
 !  ncount=gpart(i_gpart)%nnode*nndof
   ! array to send
-!  send_array(1:ncount,i_gpart)=array(gpart(i_gpart)%gdof)  
+!  send_array(1:ncount,i_gpart)=array(gpart(i_gpart)%gdof)
 !enddo
 !call sync_process()
 do i_gpart=1,ngpart
   ncount=gpart(i_gpart)%nnode*nndof
   ! array to send
-  send_array(1:ncount,i_gpart)=array(gpart(i_gpart)%gdof)  
+  send_array(1:ncount,i_gpart)=array(gpart(i_gpart)%gdof)
   ! send
   call MPI_ISSEND(send_array(1,i_gpart),ncount,MPI_KREAL,gpart(i_gpart)%id-1,  &
   tag,MPI_COMM_WORLD,send_req(i_gpart),ierr)
@@ -315,7 +315,7 @@
 
 ! wait for receive-communications completion (recv)
 do i_gpart=1,ngpart
-  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)  
+  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)
 enddo
 
 ! adding contributions of all ghost neighbours
@@ -359,7 +359,7 @@
 integer,parameter :: tag=0
 integer, dimension(MPI_STATUS_SIZE) :: mpi_status
 integer,dimension(ngpart) :: send_req,recv_req
-!integer,dimension(nnode) :: ngpart_node ! number of ghost partition for a node 
+!integer,dimension(nnode) :: ngpart_node ! number of ghost partition for a node
 real(kind=kreal),parameter :: zero=0.0_kreal
 integer :: i,j,ierr,i_gpart,igdof,ignode,ncount,ngnode
 
@@ -370,7 +370,7 @@
   ncount=ngnode*nndof
   ! store array-to-send in a garray
   send_array(1:ncount,i_gpart)=reshape(array(:,gpart(i_gpart)%node),(/ncount/))
-  
+
   ! send
   call MPI_ISSEND(send_array(1,i_gpart),ncount,MPI_KREAL,gpart(i_gpart)%id-1,  &
   tag,MPI_COMM_WORLD,send_req(i_gpart),ierr)
@@ -381,7 +381,7 @@
 
 ! wait for receive-communications completion (recv)
 do i_gpart=1,ngpart
-  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)  
+  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)
 enddo
 
 ! adding contributions of all ghost neighbours
@@ -390,7 +390,7 @@
   ncount=ngnode*nndof
   array_g(:,gpart(i_gpart)%node)=array_g(:,gpart(i_gpart)%node)+ &
   reshape(recv_array(1:ncount,i_gpart),(/nndof,ngnode/))
-  !print*,recv_array(1:ncount,i_gpart)  
+  !print*,recv_array(1:ncount,i_gpart)
 enddo
 
 ! wait for send communications completion (send)
@@ -402,9 +402,9 @@
 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 
+! 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 mpi
@@ -425,10 +425,10 @@
 lsend_array=.true.; lrecv_array=.true.
 do i_gpart=1,ngpart
   ngnode=gpart(i_gpart)%nnode
-  
+
   ! store array-to-send
   lsend_array(1:ngnode,i_gpart)=gpart(i_gpart)%isnode(1:ngnode)
-  
+
   ! send
   call MPI_ISSEND(lsend_array(1,i_gpart),ngnode,MPI_LOGICAL,gpart(i_gpart)%id-1,&
   tag,MPI_COMM_WORLD,send_req(i_gpart),ierr)
@@ -439,11 +439,11 @@
 
 ! wait for receive-communications completion (recv)
 do i_gpart=1,ngpart
-  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)  
+  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)
 enddo
 
 ! count active partitons along the interfaces
-do i_gpart=1,ngpart  
+do i_gpart=1,ngpart
   do i=1,gpart(i_gpart)%nnode
     ignode=gpart(i_gpart)%node(i)
     if(lrecv_array(i,i_gpart))ngpart_node(ignode)=ngpart_node(ignode)+1
@@ -461,7 +461,7 @@
 !=======================================================
 
 ! 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 
+! 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)
@@ -483,7 +483,7 @@
 integer,parameter :: tag=0
 integer, dimension(MPI_STATUS_SIZE) :: mpi_status
 integer,dimension(ngpart) :: send_req,recv_req
-!integer,dimension(nnode) :: ngpart_node ! number of ghost partition for a node 
+!integer,dimension(nnode) :: ngpart_node ! number of ghost partition for a node
 real(kind=kreal),parameter :: zero=0.0_kreal
 integer :: i,j,ierr,i_gpart,igdof,ignode,ncount,ngnode
 
@@ -520,7 +520,7 @@
   enddo
   !print*,'ID:',myid,minval(garray),maxval(garray)
   send_array(1:ncount,i_gpart)=reshape(garray(:,1:ngnode),(/ncount/))
-  
+
   ! send
   call MPI_ISSEND(send_array(1,i_gpart),ncount,MPI_KREAL,gpart(i_gpart)%id-1,  &
   tag,MPI_COMM_WORLD,send_req(i_gpart),ierr)
@@ -531,7 +531,7 @@
 
 ! wait for receive-communications completion (recv)
 do i_gpart=1,ngpart
-  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)  
+  call MPI_WAIT(recv_req(i_gpart),mpi_status,ierr)
 enddo
 
 ! adding contributions of all ghost neighbours
@@ -540,7 +540,7 @@
   ncount=ngnode*nndof
   tarray(:,gpart(i_gpart)%node)=tarray(:,gpart(i_gpart)%node)+ &
   reshape(recv_array(1:ncount,i_gpart),(/nndof,ngnode/))
-  !print*,recv_array(1:ncount,i_gpart)  
+  !print*,recv_array(1:ncount,i_gpart)
 enddo
 
 ! wait for send communications completion (send)
@@ -576,7 +576,7 @@
 end subroutine free_ghost
 !===========================================
 
-! routines below are imported and modified from SPECFEM3D 
+! routines below are imported and modified from SPECFEM3D
 
 ! subroutines to sort MPI buffers to assemble between chunks
 subroutine sort_array_coord(ndim,npoint,x,y,z,ibool,nglob)
@@ -584,27 +584,27 @@
 ! this routine MUST be in double precision to avoid sensitivity
 ! to roundoff errors in the coordinates of the points
 !
-! returns: sorted indexing array (ibool),  reordering array (iglob) & 
-! number of global points (nglob)  
-  
+! returns: sorted indexing array (ibool),  reordering array (iglob) &
+! number of global points (nglob)
+
  use math_constants, only : zerotol
  implicit none
 
  integer,intent(in) :: ndim,npoint
  double precision,dimension(npoint),intent(in) :: x,y,z
  integer,dimension(npoint),intent(inout) :: ibool
- integer,intent(out) :: nglob 
-  
+ integer,intent(out) :: nglob
+
  integer,dimension(npoint) :: iglob
  integer,dimension(npoint) :: iloc,ind,ninseg
  logical,dimension(npoint) :: ifseg
-  
+
  integer,dimension(npoint) :: iwork(npoint)
  double precision,dimension(npoint) :: work(npoint)
 
  integer :: i,j
  integer :: nseg,ioff,iseg,ig
- double precision :: xtol  
+ double precision :: xtol
 
 ! establish initial pointers
  do i=1,npoint

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/gll_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/gll_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/gll_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -28,9 +28,9 @@
 
 ! compute everything in indexed order
 
-! get gll points 
+! get gll points
 ! for alpha=beta=0, jacobi polynomial is legendre polynomial
-! for ngllx=nglly=ngllz=ngll, need to call only once 
+! for ngllx=nglly=ngllz=ngll, need to call only once
 call zwgljd(gllpx,gllwx,ngllx,jacobi_alpha,jacobi_beta)
 call zwgljd(gllpy,gllwy,nglly,jacobi_alpha,jacobi_beta)
 call zwgljd(gllpz,gllwz,ngllz,jacobi_alpha,jacobi_beta)
@@ -96,16 +96,16 @@
 real(kind=kreal),dimension(ngllx) :: lagrange_x,lagrange_dx
 real(kind=kreal),dimension(nglly) :: lagrange_y,lagrange_dy
 
-! compute everything in indexed order 
+! compute everything in indexed order
 
 ! gll points and weights (source: http://mathworld.wolfram.com/lobattoquadrature.html)
 !gllp(1)=-1.0_kreal   ; gllw(1)=1.0_kreal/3.0_kreal
 !gllp(2)= 0.0_kreal   ; gllw(2)=4.0_kreal/3.0_kreal
 !gllp(3)= 1.0_kreal   ; gllw(3)=gllw(1)
 
-! get gll points 
+! get gll points
 ! for alpha=beta=0, jacobi polynomial is legendre polynomial
-! for ngllx=nglly=ngllz=ngll, need to call only once 
+! for ngllx=nglly=ngllz=ngll, need to call only once
 call zwgljd(gllpx,gllwx,ngllx,jacobi_alpha,jacobi_beta)
 call zwgljd(gllpy,gllwy,nglly,jacobi_alpha,jacobi_beta)
 
@@ -115,7 +115,7 @@
     n=n+1
     ! integration points
     gll_points2d(1,n)=gllpx(i)
-    gll_points2d(2,n)=gllpy(j)      
+    gll_points2d(2,n)=gllpy(j)
 
     ! integration weights
     gll_weights2d(n)=gllwx(i)*gllwy(j)
@@ -124,19 +124,19 @@
 
 do ii=1,ngll ! ngllx*nglly
   xi=gll_points2d(1,ii)
-  eta=gll_points2d(2,ii)  
+  eta=gll_points2d(2,ii)
 
   ! compute 1d lagrange polynomials
   call lagrange1d(ngllx,xi,lagrange_x,lagrange_dx)
   call lagrange1d(nglly,eta,lagrange_y,lagrange_dy)
-  
-  n=0  
+
+  n=0
   do j=1,nglly
     do i=1,ngllx
       n=n+1
       lagrange_gll2d(ii,n)=lagrange_x(i)*lagrange_y(j)
       dlagrange_gll2d(1,ii,n)=lagrange_dx(i)*lagrange_y(j)
-      dlagrange_gll2d(2,ii,n)=lagrange_x(i)*lagrange_dy(j)        
+      dlagrange_gll2d(2,ii,n)=lagrange_x(i)*lagrange_dy(j)
     enddo
   enddo
 enddo
@@ -167,41 +167,41 @@
 !gllp(2)= 0.0_kreal   ; gllw(2)=4.0_kreal/3.0_kreal
 !gllp(3)= 1.0_kreal   ; gllw(3)=gllw(1)
 
-! get gll points 
+! get gll points
 ! for alpha=beta=0, jacobi polynomial is legendre polynomial
-! for ngllx=nglly=ngllz=ngll, need to call only once 
+! for ngllx=nglly=ngllz=ngll, need to call only once
 call zwgljd(gllpx,gllwx,ngllx,jacobi_alpha,jacobi_beta)
 
 n=0
 do i=1,ngllx
   n=n+1
   ! integration points
-  gll_points1d(1,n)=gllpx(i)      
+  gll_points1d(1,n)=gllpx(i)
 
   ! integration weights
   gll_weights1d(n)=gllwx(i)
 enddo
 
 do ii=1,ngll ! ngllx
-  xi=gll_points1d(1,ii)  
+  xi=gll_points1d(1,ii)
 
   ! compute 1d lagrange polynomials
   call lagrange1d(ngllx,xi,lagrange_x,lagrange_dx)
 
-  n=0    
+  n=0
   do i=1,ngllx
     n=n+1
     lagrange_gll1d(ii,n)=lagrange_x(i)
-    dlagrange_gll1d(1,ii,n)=lagrange_dx(i)           
-  enddo  
-enddo  
+    dlagrange_gll1d(1,ii,n)=lagrange_dx(i)
+  enddo
+enddo
 
 return
 end subroutine gll_quadrature1d
 !===========================================
 
 ! this subroutine computes the 1d lagrange interpolation functions and their
-! derivatives at a given point xi.  
+! derivatives at a given point xi.
 subroutine lagrange1d(nenod,xi,phi,dphi_dxi)
 implicit none
 integer,intent(in) :: nenod ! number of nodes in an 1d element
@@ -230,7 +230,7 @@
       k=k+1
       term(k)=(xi-xii(j))/(xii(i)-xii(j))
       dterm(k)=1.0_kreal/(xii(i)-xii(j)) ! derivative of the term wrt xi
-      
+
       phi(i)=phi(i)*(xi-xii(j))/(xii(i)-xii(j))
     endif
   enddo
@@ -244,7 +244,7 @@
         sum_term(j)=sum_term(j)*term(k)
       endif
     enddo
-  enddo 
+  enddo
   dphi_dxi(i)=0.0_kreal
   do j=1,nenod-1
     dphi_dxi(i)=dphi_dxi(i)+sum_term(j)
@@ -610,7 +610,7 @@
 real(kind=kreal) function pnormj (n,alpha,beta) !double precision
 
 implicit none
- 
+
 real(kind=kreal) alpha,beta !double precision
 integer n
 
@@ -684,7 +684,7 @@
 p    = zero
 pdm1 = zero
 
-if(np <= 0)then  
+if(np <= 0)then
   write(*,*)'ERROR: number of Gauss points < 1!'
   stop
 endif
@@ -759,13 +759,13 @@
 nm1 = n-1
 pd  = zero
 
-if(np <= 1)then  
+if(np <= 1)then
   write(*,*)'ERROR: number of Gauss-Lobatto points < 2!'
   stop
 endif
 
 ! with spectral elements, use at least 3 points
-if(np < 3)then  
+if(np < 3)then
   write(*,*)'WARNING: number of Gauss-Lobatto points < 3!'
   !stop
 endif

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/global.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -48,7 +48,7 @@
 
 character(len=150) :: file_head,inp_path,out_path,part_path
 ! displacement BC, ghost, traction, and water surface files
-character(len=150) :: uxfile,uyfile,uzfile,gfile,trfile,wsfile 
+character(len=150) :: uxfile,uyfile,uzfile,gfile,trfile,wsfile
 integer :: cg_maxiter,nl_maxiter,nexcav,ninc,nsrf,ntstep
 real(kind=kreal) :: cg_tol,nl_tol
 integer,allocatable :: excavid(:),nexcavid(:) ! Excavation ID (regions), nunber of excavation IDs (regions) in each stage
@@ -56,10 +56,10 @@
 
 ! initial stress
 logical :: isstress0,usek0 ! use k0 to compute horizontal stress also for
-! s0_type=0 
+! s0_type=0
 real(kind=kreal) :: s0_type ! initial stress type
 ! 0: by default compute by SEM,
-! 1: simple overburden pressure use s0+gamma*z 
+! 1: simple overburden pressure use s0+gamma*z
 !    only for horizontal and homogeneous, and
 ! 2: read from file
 real(kind=kreal) :: z_datum,s0_datum,epk0
@@ -70,7 +70,7 @@
 type savedata_options
   logical :: disp,stress,porep,psigma,maxtau,nsigma,scf,vmeps
 end type savedata_options
-type(savedata_options) :: savedata 
+type(savedata_options) :: savedata
 
 ! others
 character(len=1),parameter :: CR=achar(13) ! carriage return to overwrite

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -77,14 +77,14 @@
 
 ! this function returns the determinant of a 1x1, 2x2 or 3x3
 ! jacobian matrix.
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 function determinant(jac)result(det)
-implicit none    
+implicit none
 real(kind=kreal),intent(in)::jac(:,:)
 real(kind=kreal)::det
-integer::it 
-it=ubound(jac,1)  
+integer::it
+it=ubound(jac,1)
 select case(it)
 case(1)
   det=1.0_kreal
@@ -102,7 +102,7 @@
 !=======================================================
 
 ! this subroutine inverts a small square matrix onto itself.
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 subroutine invert(matrix)
 implicit none
@@ -160,7 +160,7 @@
 !=======================================================
 
 ! this subroutine forms the stress invariants in 2- or 3-d.
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 subroutine stress_invariant(stress,sigm,dsbar,theta)
 implicit none
@@ -169,7 +169,7 @@
 real(kind=kreal)::sx,sy,sz,txy,dx,dy,dz,xj3,sine,s1,s2,s3,s4,s5,s6,ds1,ds2,ds3,&
   d2,d3,sq3,zero=0.0_kreal,small=1.e-12_kreal,one=1.0_kreal,two=2.0_kreal,     &
   three=3.0_kreal,six=6.0_kreal,thpt5=13.5_kreal
-integer::nst 
+integer::nst
 nst=ubound(stress,1)
 select case(nst)
 case(4)
@@ -193,28 +193,28 @@
   end if
 case(6)
   sq3=sqrt(three)
-  s1=stress(1)  
+  s1=stress(1)
   s2=stress(2)
-  s3=stress(3) 
+  s3=stress(3)
   s4=stress(4)
   s5=stress(5)
   s6=stress(6)
   sigm=(s1+s2+s3)/three
   d2=((s1-s2)**2+(s2-s3)**2+(s3-s1)**2)/six+s4*s4+s5*s5+s6*s6
-  
+
   if(d2<small)d2=small ! special case of hydrostatic pressure or just at the tip
-  
-  ds1=s1-sigm 
-  ds2=s2-sigm  
+
+  ds1=s1-sigm
+  ds2=s2-sigm
   ds3=s3-sigm
   d3=ds1*ds2*ds3-ds1*s5*s5-ds2*s6*s6-ds3*s4*s4+two*s4*s5*s6
   dsbar=sq3*sqrt(d2)
-  if(dsbar<small)then     
+  if(dsbar<small)then
     theta=zero
   else
     sine=-three*sq3*d3/(two*sqrt(d2)**3)
-    if(sine>=one)sine=one 
-    if(sine<-one)sine=-one 
+    if(sine>=one)sine=one
+    if(sine<-one)sine=-one
     theta=asin(sine)/three
   end if
 case default
@@ -231,7 +231,7 @@
 integer :: temp
 integer :: i,j
 integer,dimension(n) :: xnew
- 
+
 do i = 2, n
   j = i - 1
   temp = x(i)
@@ -252,7 +252,7 @@
 real(kind=kreal) :: temp
 integer :: i,j
 real(kind=kreal),dimension(n) :: xnew
- 
+
 do i = 2, n
   j = i - 1
   temp = x(i)
@@ -272,7 +272,7 @@
 real, intent(inout), dimension(n) :: x ! data vector to sort
 real :: temp
 integer :: i, j
- 
+
 do i = 2, n
   j = i - 1
   temp = x(i)

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_mpi.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -46,13 +46,13 @@
 !
 ! this finds a global minimum of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gmin
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gmin,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function iminscal
 !=======================================================
@@ -61,13 +61,13 @@
 !
 ! this finds a global minimum of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gmin
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gmin,1,MPI_KREAL,MPI_MIN,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function fminscal
 !=======================================================
@@ -76,13 +76,13 @@
 !
 ! this finds a global maximum of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gmax
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gmax,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function imaxscal
 !=======================================================
@@ -91,13 +91,13 @@
 !
 ! this finds a global maximum of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gmax
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gmax,1,MPI_KREAL,MPI_MAX,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function fmaxscal
 !=======================================================
@@ -162,13 +162,13 @@
 !
 ! this finds a global summation of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gsum
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gsum,1,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function isumscal
 !=======================================================
@@ -177,13 +177,13 @@
 !
 ! this finds a global summation of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gsum
 integer :: ierr
-  
+
 call MPI_ALLREDUCE(scal,gsum,1,MPI_KREAL,MPI_SUM,MPI_COMM_WORLD,ierr)
- 
+
 return
 end function fsumscal
 !=======================================================
@@ -193,14 +193,14 @@
 ! this finds global dot product of two vectors across the processors
 !
 implicit none
-real(kind=kreal),intent(in)::vec1(:),vec2(:) 
+real(kind=kreal),intent(in)::vec1(:),vec2(:)
 real(kind=kreal) :: ldot,gdot
 integer :: ierr
- 
+
 ! find local dot
 ldot=dot_product(vec1,vec2)
-call MPI_ALLREDUCE(ldot,gdot,1,MPI_KREAL,MPI_SUM,MPI_COMM_WORLD,ierr) 
-  
+call MPI_ALLREDUCE(ldot,gdot,1,MPI_KREAL,MPI_SUM,MPI_COMM_WORLD,ierr)
+
 return
 end function dot_product_par
 !=======================================================

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_serial.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_serial.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/math_library_serial.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -45,13 +45,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gmin
 integer :: ierr
-  
+
 gmin=scal
- 
+
 return
 end function iminscal
 !=======================================================
@@ -60,13 +60,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gmin
 integer :: ierr
-  
+
 gmin=scal
- 
+
 return
 end function fminscal
 !=======================================================
@@ -75,13 +75,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gmax
 integer :: ierr
-  
+
 gmax=scal
- 
+
 return
 end function imaxscal
 !=======================================================
@@ -90,13 +90,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gmax
 integer :: ierr
-  
+
 gmax=scal
- 
+
 return
 end function fmaxscal
 !=======================================================
@@ -161,13 +161,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-integer,intent(in)::scal 
+implicit none
+integer,intent(in)::scal
 integer :: gsum
 integer :: ierr
-  
+
 gsum=scal
- 
+
 return
 end function isumscal
 !=======================================================
@@ -176,13 +176,13 @@
 !
 ! this finds a summation of a scalar across the processors
 !
-implicit none 
-real(kind=kreal),intent(in)::scal 
+implicit none
+real(kind=kreal),intent(in)::scal
 real(kind=kreal) :: gsum
 integer :: ierr
-  
+
 gsum=scal
- 
+
 return
 end function fsumscal
 !=======================================================
@@ -192,15 +192,15 @@
 ! this finds dot product of two vectors across the processors
 !
 implicit none
-real(kind=kreal),intent(in)::vec1(:),vec2(:) 
+real(kind=kreal),intent(in)::vec1(:),vec2(:)
 real(kind=kreal) :: ldot,gdot
 integer :: ierr
- 
+
 ! find local dot
 ldot=dot_product(vec1,vec2)
 
-gdot=ldot 
-  
+gdot=ldot
+
 return
 end function dot_product_par
 !=======================================================

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mesh_spec.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mesh_spec.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/mesh_spec.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -76,14 +76,14 @@
 zstore=zero
 
 ipoint=0
-do i_elmt=1,nelmt  
+do i_elmt=1,nelmt
   do k=1,ngllz
     do j=1,nglly
       do i=1,ngllx
         xgll = zero
         ygll = zero
         zgll = zero
-        
+
         do i_gnod=1,ngnod
           xgll = xgll + shape_hex8(i_gnod,i,j,k)*g_coord(1,g_num(i_gnod,i_elmt))
           ygll = ygll + shape_hex8(i_gnod,i,j,k)*g_coord(2,g_num(i_gnod,i_elmt))
@@ -387,15 +387,15 @@
 ! (put into this subroutine but compiler keeps on complaining that it can't vectorize loops...)
 
 implicit none
-  
+
 integer :: nelmt,nnode,npoint
 integer, dimension(npoint) :: ibool
-  
+
 ! mask to sort ibool
 integer, dimension(nnode) :: mask_ibool
-integer, dimension(npoint) :: copy_ibool_ori  
+integer, dimension(npoint) :: copy_ibool_ori
 integer :: inumber
-integer:: i_point  
+integer:: i_point
 
 mask_ibool = -1
 copy_ibool_ori = ibool

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -57,8 +57,8 @@
   read(11,'(a)',iostat=ios)line ! This will read a line and proceed to next line
   if (ios/=0)exit
   ! check for blank and comment line
-  if (isblank(line) .or. iscomment(line,'#'))cycle 
-   
+  if (isblank(line) .or. iscomment(line,'#'))cycle
+
   ! look for line continuation
   tag=trim(line)
   call last_char(line,tmp_char,ind)
@@ -66,7 +66,7 @@
     slen=len(line)
     tag=trim(line(1:ind-1))
     read(11,'(a)',iostat=ios)line ! This will read a line and proceed to next line
-    tag=trim(tag)//trim(line)         
+    tag=trim(tag)//trim(line)
   endif
   call first_token(tag,token)
 
@@ -78,7 +78,7 @@
     if(npart<=1)then
       write(*,*)'ERROR: number of processors should be greater than 1!'
       stop
-    endif        
+    endif
     call seek_string('inp_path',strval,args,narg)
     if (.not. isblank(strval))inp_path=trim(strval)
     slen=len_trim(inp_path)
@@ -86,11 +86,11 @@
     call seek_string('part_path',strval,args,narg)
     if (.not. isblank(strval))out_path=trim(strval)
     slen=len_trim(out_path)
-    if(out_path(slen:slen)/='/')out_path=trim(out_path)//'/'    
+    if(out_path(slen:slen)/='/')out_path=trim(out_path)//'/'
     out_phead=trim(out_path)//trim(file_head)//'_'
 
-    preinfo_stat=0      
-    cycle      
+    preinfo_stat=0
+    cycle
   endif
   ! read mesh information
   if (trim(token)=='mesh:')then
@@ -99,12 +99,12 @@
     yfile=get_string('yfile',args,narg)
     zfile=get_string('zfile',args,narg)
     confile=get_string('confile',args,narg)
-    idfile=get_string('idfile',args,narg)    
-   
-    mesh_stat=0      
-    cycle      
+    idfile=get_string('idfile',args,narg)
+
+    mesh_stat=0
+    cycle
   endif
-  
+
   ! read bc information
   if (trim(token)=='bc:')then
     call split_string(tag,',',args,narg)
@@ -113,9 +113,9 @@
     uzfile=get_string('uzfile',args,narg)
 
     bc_stat=0
-    cycle      
+    cycle
   endif
-  
+
   ! read traction information
   if (trim(token)=='traction:')then
     call split_string(tag,',',args,narg)
@@ -123,18 +123,18 @@
     traction_stat=0
     istraction=.true.
     !print*,trfile
-    cycle      
+    cycle
   endif
-  
+
   ! read material list
   if (trim(token)=='material:')then
     material_stat=-1
-    call split_string(tag,',',args,narg)    
-    matfile=get_string('matfile',args,narg)           
-                
+    call split_string(tag,',',args,narg)
+    matfile=get_string('matfile',args,narg)
+
     material_stat=0
-    cycle      
-  endif  
+    cycle
+  endif
 enddo ! do
 close(11)
 
@@ -175,24 +175,24 @@
 call cpu_time(cpu_tstart)
 
 ! reads in (CUBIT) mesh files: mesh_file,nodes_coord_file, ...
-  call read_mesh_files()  
-  
+  call read_mesh_files()
+
 ! checks valence of nodes
   call check_valence()
-  
-! partitions mesh 
-  call scotch_partitioning()  
-  
-! writes out database files  
+
+! partitions mesh
+  call scotch_partitioning()
+
+! writes out database files
   call write_mesh_databases()
-  
+
   write(*,*)'mesh partitioning finished successfully!'
-  
-! elapsed time  
+
+! elapsed time
   call cpu_time(cpu_tend)
   write(*,*)'total elapsed time: ',cpu_tend-cpu_tstart,'s'
   write(*,*)'-----------------------------------------'
- 
+
 end program partmesh
 !=======================================================
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -49,7 +49,7 @@
 integer,intent(in) :: nnodes
 integer,intent(in) :: nsize !integer(long)
 integer,intent(in) :: sup_neighbour !integer(long)
-integer,dimension(0:esize*nelmnts-1),intent(in) :: elmnts    
+integer,dimension(0:esize*nelmnts-1),intent(in) :: elmnts
 
 integer,dimension(0:nelmnts) :: xadj
 integer,dimension(0:sup_neighbour*nelmnts-1) :: adjncy
@@ -110,7 +110,7 @@
             end do
             if ( .not.is_neighbour ) then
                 adjncy(nodes_elmnts(k+j*nsize)*sup_neighbour+xadj(nodes_elmnts(k+j*nsize))) = nodes_elmnts(l+j*nsize)
-                
+
                 xadj(nodes_elmnts(k+j*nsize)) = xadj(nodes_elmnts(k+j*nsize)) + 1
                 if (xadj(nodes_elmnts(k+j*nsize))>sup_neighbour) stop 'ERROR : too much neighbours per element, modify the mesh.'
 
@@ -267,12 +267,12 @@
 character(len=80) :: out_fname
 
 integer,dimension(npart) :: mpart_icount,mpart_nelmt
-integer :: bc_nelmt ! number of BC elements 
+integer :: bc_nelmt ! number of BC elements
 integer,dimension(:,:),allocatable :: bc_elmt ! fist row = element ID, second row = face ID
 integer :: i_elmt,i_part,ipart,istat
 
 type master_partition
-integer,dimension(:),allocatable :: iloc ! index location of element in the partition 
+integer,dimension(:),allocatable :: iloc ! index location of element in the partition
 end type master_partition
 type(master_partition),dimension(npart) :: mpart
 
@@ -305,7 +305,7 @@
 ! partition BC
 do i_elmt=1,bc_nelmt
 ipart=part(bc_elmt(1,i_elmt)) ! partion
-mpart_icount(ipart)=mpart_icount(ipart)+1  
+mpart_icount(ipart)=mpart_icount(ipart)+1
 mpart(ipart)%iloc(mpart_icount(ipart))=i_elmt
 enddo
 
@@ -317,7 +317,7 @@
 
 ! format string for element ID and face ID
 write(format_str1,*)ceiling(log10(real(maxval(bc_elmt(1,:)))+1.))
-format_str1='(i'//trim(adjustl(format_str1))//'i2)' ! i2 is sufficient for face id or node id 
+format_str1='(i'//trim(adjustl(format_str1))//'i2)' ! i2 is sufficient for face id or node id
 
 ! write BCs in each partition
 do i_part=1,npart
@@ -355,7 +355,7 @@
 
 
 integer,dimension(npart) :: mpart_icount,mpart_nelmt
-integer :: tr_nelmt ! number of traction elements 
+integer :: tr_nelmt ! number of traction elements
 integer,dimension(:,:),allocatable :: tr_elmt ! fist row = element ID, second row = entity ID
 integer :: ios,i_elmt,i_part,itrac,ipart,istat,ntrac,tractype
 
@@ -364,7 +364,7 @@
 logical :: ispart(npart)
 
 type master_partition
-integer,dimension(:),allocatable :: iloc ! index location of element in the partition 
+integer,dimension(:),allocatable :: iloc ! index location of element in the partition
 end type master_partition
 type(master_partition),dimension(npart) :: mpart
 
@@ -377,7 +377,7 @@
 !read(16,*)ntrac
 itrac=0
 do ! itrac=1,ntrac
-read(16,*,iostat=ios)tractype  
+read(16,*,iostat=ios)tractype
 if(ios/=0)exit
 itrac=itrac+1
 if(tractype==0)then ! point loading
@@ -417,7 +417,7 @@
 ! partition BC
 do i_elmt=1,tr_nelmt
   ipart=part(tr_elmt(1,i_elmt)) ! partion
-  mpart_icount(ipart)=mpart_icount(ipart)+1  
+  mpart_icount(ipart)=mpart_icount(ipart)+1
   mpart(ipart)%iloc(mpart_icount(ipart))=i_elmt
 enddo
 
@@ -429,10 +429,10 @@
 
 ! format string for element ID and face ID
 write(format_str1,*)ceiling(log10(real(maxval(tr_elmt(1,:)))+1.))
-format_str1='(i'//trim(adjustl(format_str1))//'i2)' ! i2 is sufficient for face id or node id 
-  
+format_str1='(i'//trim(adjustl(format_str1))//'i2)' ! i2 is sufficient for face id or node id
+
 ! write BCs in each partition
-do i_part=1,npart    
+do i_part=1,npart
   ! open output file
   write(out_fname, fmt=format_str)trim(out_path)//trim(trfile)//'_proc',i_part-1
   if(itrac==1)then
@@ -462,7 +462,7 @@
 ! deallocate derived type variables
 do i_part=1,npart
   deallocate(mpart(i_part)%iloc)
-enddo  
+enddo
 enddo ! itrac
 close(16)
 
@@ -478,12 +478,12 @@
 !   HNG, Jul 12,2011; HNG, Apr 09,2010
 !TODO
 ! - some optimization is possible
-! - after finding interfacial elements we can only store/process the information 
+! - after finding interfacial elements we can only store/process the information
 !   only for those elements
 implicit none
 integer,intent(in) :: nelmt,nnode
 integer,dimension(nelmt),intent(in) :: part ! numbering starts from 1 only in this routine
-integer,dimension(esize,nelmt),intent(in) :: connect    
+integer,dimension(esize,nelmt),intent(in) :: connect
 integer,intent(in) :: npart
 
 integer :: i,icount,istat,j
@@ -492,7 +492,7 @@
 allocate(node_part(nnode,npart))
 allocate(node_npart(nnode))
 
-node_part=.false.  
+node_part=.false.
 do i=1,nelmt
 node_part(connect(:,i),part(i))=.true.
 enddo
@@ -500,7 +500,7 @@
 ! determine the number of partitions for all nodes
 node_npart=0
 allocate(node(nnode))
-do i=1,nnode 
+do i=1,nnode
 node_npart(i)=count(node_part(i,:))
 allocate(node(i)%part(node_npart(i)))
 icount=0
@@ -510,12 +510,12 @@
     node(i)%part(icount)=j
   endif
 enddo
-enddo 
+enddo
 !print*,'hello:',maxval(node_part)
 !stop
 deallocate(node_part)
 
-! count the number of elements in the interface  
+! count the number of elements in the interface
 nelmt_interface=0
 do i=1,nelmt
 if(maxval(node_npart(connect(:,i)))>1)nelmt_interface=nelmt_interface+1
@@ -553,15 +553,15 @@
 !TODO
 ! - why there is error for 2 partitions? See the explanation in max_nelmt in the code below
 ! - some optimization is possible
-! - after finding interfacial elements we can only store/process the information 
+! - after finding interfacial elements we can only store/process the information
 !   only for those elements
 implicit none
-integer,parameter :: nenode=8,nedge=12,nface=6 ! number of nodes, edges, and faces per element 
+integer,parameter :: nenode=8,nedge=12,nface=6 ! number of nodes, edges, and faces per element
 integer,parameter :: nnode_face=4,nnode_edge=2 ! number of nodes per face and per edge
 
 integer,intent(in) :: nelmt,nnode
 !integer,dimension(nelmt),intent(in) :: part ! numbering starts from 1 only in this routine
-!integer,dimension(esize,nelmt),intent(in) :: connect    
+!integer,dimension(esize,nelmt),intent(in) :: connect
 integer,intent(in) :: npart,max_neighbour
 integer,dimension(:),intent(in) :: glob2loc_elmt
 
@@ -572,10 +572,10 @@
 integer,dimension(6,4) :: node_face ! local node numbers in each face
 integer,dimension(6,4) :: edge_face ! local edge numbers in each face
 integer,dimension(12,2) :: node_edge ! local node numbers in each edge
-integer :: ielmt,inode,ipart,jelmt,ie,je  
+integer :: ielmt,inode,ipart,jelmt,ie,je
 character(len=256),intent(in) :: out_phead
 character(len=20) :: format_str
-character(len=80) :: out_fname  
+character(len=80) :: out_fname
 
 integer :: istat
 integer,dimension(:),allocatable :: list_gpart
@@ -594,7 +594,7 @@
 integer,allocatable :: gelmt(:),ginterface(:),gadjid(:),adj_iface(:),adj_iedge(:),adj_inode(:)
 integer :: adj_nface,adj_nedge,adj_nnode,ia
 
-! ghost partition  
+! ghost partition
 type ghost_partition
 integer :: nelmt
 !integer,dimension(4) :: gorder,morder
@@ -602,7 +602,7 @@
 integer,dimension(:),pointer :: gelmt,geid ! ghost element,ghost element's entity id
 end type ghost_partition
 
-! master partition  
+! master partition
 type partition
 integer :: ielmt,nelmt
 integer,dimension(:),pointer :: elmt
@@ -618,7 +618,7 @@
 !end type nodes
 !type(nodes),dimension(:),allocatable :: node
 
-! local node numbering in each face CUBIT/EXODUS convention  
+! local node numbering in each face CUBIT/EXODUS convention
 node_face(1,:)=(/1,2,6,5/)
 node_face(2,:)=(/2,3,7,6/)
 node_face(3,:)=(/4,3,7,8/)
@@ -649,16 +649,16 @@
 edge_face(6,1)=9; edge_face(6,2)=10; edge_face(6,3)=11; edge_face(6,4)=12;
 
 !  allocate(node_part(nnode,npart))
-!  
-!  node_part=.false.  
+!
+!  node_part=.false.
 !  do i=1,nelmt
 !    node_part(connect(:,i),part(i))=.true.
 !  enddo
-!  
+!
 !  ! determine the number of partitions for all nodes
 !  node_npart=0
 !  allocate(node(nnode))
-!  do i=1,nnode 
+!  do i=1,nnode
 !    node_npart(i)=count(node_part(i,:))
 !    allocate(node(i)%part(node_npart(i)))
 !    icount=0
@@ -668,8 +668,8 @@
 !        node(i)%part(icount)=j
 !      endif
 !    enddo
-!  enddo 
-  
+!  enddo
+
 !  deallocate(node_part)
 !  !print*,minval(node_npart),maxval(node_npart)
 !  !stop
@@ -682,7 +682,7 @@
 !  !  enddo
 !  !enddo
 
-!  ! count the number of elements in the interface  
+!  ! count the number of elements in the interface
 !  nelmt_interface=0
 !  do i=1,nelmt
 !    if(maxval(node_npart(connect(:,i)))>1)nelmt_interface=nelmt_interface+1
@@ -711,16 +711,16 @@
 if(istat/=0)then
   print*,'ERROR: insufficient memory!'
   stop
-endif  
+endif
 !adj_elmt=0
 indadj=0 ! adjacency indicator, an element value = 2 indicates the adjacency
 adj_nelmt=0; adj_elmt=0
 adj_ind=0; adj_id1=0; adj_id2=0
-do i=1,nelmt_interface-1   
-  !ielmt=elmt_interface(i) 
-  do j=i+1,nelmt_interface          
+do i=1,nelmt_interface-1
+  !ielmt=elmt_interface(i)
+  do j=i+1,nelmt_interface
     !jelmt=elmt_interface(j)
-    
+
     ! sorting 2 array using the rank as index we can use very small array instead of indadj(nnode)
     ! test
     ! connect_adj(1:nenode)=connect_interface(:,i);
@@ -728,14 +728,14 @@
     ! print*,connect_adj
     ! stop
     ! test
-    
+
     ! we are only interested in the part of i and j
     indadj(connect_interface(:,i))=0
-    indadj(connect_interface(:,j))=0      
+    indadj(connect_interface(:,j))=0
     indadj(connect_interface(:,i))=indadj(connect_interface(:,i))+1
     indadj(connect_interface(:,j))=indadj(connect_interface(:,j))+1
-    ncom=sum(indadj(connect_interface(:,i)))-nenode ! number of common nodes 
-          
+    ncom=sum(indadj(connect_interface(:,i)))-nenode ! number of common nodes
+
     if(ncom==0)then
       ! no common node
       cycle
@@ -745,15 +745,15 @@
       !adj_elmt(j,i)=1
       !adj1(i,j)=get_nodeid(indadj(connect_interface(:,i))==2)
       !adj2(i,j)=get_nodeid(indadj(connect_interface(:,j))==2)
-      
+
       adj_nelmt(i)=adj_nelmt(i)+1
-      
+
       adj_id1(i,adj_nelmt(i))=get_nodeid(indadj(connect_interface(:,i))==2)
       adj_id2(i,adj_nelmt(i))=get_nodeid(indadj(connect_interface(:,j))==2)
-      
+
       adj_ind(i,adj_nelmt(i))=1
       adj_elmt(i,adj_nelmt(i))=j
-      
+
       adj_nelmt(j)=adj_nelmt(j)+1
       adj_ind(j,adj_nelmt(j))=1
       adj_elmt(j,adj_nelmt(j))=i
@@ -763,15 +763,15 @@
       !adj_elmt(j,i)=2
       !adj1(i,j)=get_edgeid(indadj(connect_interface(:,i))==2,node_edge)
       !adj2(i,j)=get_edgeid(indadj(connect_interface(:,j))==2,node_edge)
-      
+
       adj_nelmt(i)=adj_nelmt(i)+1
-      
+
       adj_id1(i,adj_nelmt(i))=get_edgeid(indadj(connect_interface(:,i))==2,node_edge)
       adj_id2(i,adj_nelmt(i))=get_edgeid(indadj(connect_interface(:,j))==2,node_edge)
-      
+
       adj_ind(i,adj_nelmt(i))=2
       adj_elmt(i,adj_nelmt(i))=j
-      
+
       adj_nelmt(j)=adj_nelmt(j)+1
       adj_ind(j,adj_nelmt(j))=2
       adj_elmt(j,adj_nelmt(j))=i
@@ -779,27 +779,27 @@
       ! common face
       !adj_elmt(i,j)=4
       !adj_elmt(j,i)=4
-      !adj1(i,j)=get_faceid(indadj(connect_interface(:,i))==2,node_face)        
+      !adj1(i,j)=get_faceid(indadj(connect_interface(:,i))==2,node_face)
       !adj2(i,j)=get_faceid(indadj(connect_interface(:,j))==2,node_face)
-      
+
       adj_nelmt(i)=adj_nelmt(i)+1
-      
-      adj_id1(i,adj_nelmt(i))=get_faceid(indadj(connect_interface(:,i))==2,node_face)        
+
+      adj_id1(i,adj_nelmt(i))=get_faceid(indadj(connect_interface(:,i))==2,node_face)
       adj_id2(i,adj_nelmt(i))=get_faceid(indadj(connect_interface(:,j))==2,node_face)
-      
+
       adj_ind(i,adj_nelmt(i))=4
       adj_elmt(i,adj_nelmt(i))=j
-      
+
       adj_nelmt(j)=adj_nelmt(j)+1
-      adj_ind(j,adj_nelmt(j))=4 
-      adj_elmt(j,adj_nelmt(j))=i         
+      adj_ind(j,adj_nelmt(j))=4
+      adj_elmt(j,adj_nelmt(j))=i
     else
       write(*,*)'ERROR: wrong number of common nodes!',ncom
       stop
-    endif      
+    endif
   enddo
   !print*,i,nelmt_interface
-enddo 
+enddo
 write(*,*)'complete!'
 
 allocate(mpart_gpart(npart,npart))
@@ -807,7 +807,7 @@
 do i=1,nelmt_interface
   !ielmt=elmt_interface(i)
   do j=1,nenode
-    inode=connect_interface(j,i)    
+    inode=connect_interface(j,i)
     do k=1,node_npart(inode)
       mpart_gpart(part_interface(i),node(inode)%part(k))=.true.
     enddo
@@ -829,15 +829,15 @@
   nghost(i_part)=mpart(i_part)%ngpart
 enddo
 max_ngpart=maxval(mpart(1:npart)%ngpart) ! maximum number of ghost partitions
-  
+
 deallocate(mpart_gpart) ! mpart_gpart seems that this can be utilized for efficiency later, but I don't know how to.
 ! count interfacial elements of each partition
-mpart(1:npart)%nelmt=0  
+mpart(1:npart)%nelmt=0
 !mpart(1:npart)%ngpart=0
 do i=1,nelmt_interface
   !ielmt=elmt_interface(i)
   ipart=part_interface(i)
-  ! count elements   
+  ! count elements
   mpart(ipart)%nelmt=mpart(ipart)%nelmt+1
 enddo
 
@@ -852,7 +852,7 @@
 allocate(adj_iface(max_nelmt),adj_iedge(max_nelmt),adj_inode(max_nelmt))
 
 ! allocate type variable gpart
-do i_part=1,npart    
+do i_part=1,npart
   allocate(mpart(i_part)%elmt(mpart(i_part)%nelmt))
   allocate(mpart(i_part)%eid_interface(mpart(i_part)%nelmt))
 enddo
@@ -874,10 +874,10 @@
 endif
 
 ! allocate type variable gpart
-do i_part=1,npart    
+do i_part=1,npart
   allocate(mpart(i_part)%gpart(mpart(i_part)%ngpart))
   allocate(mpart(i_part)%gpartid(mpart(i_part)%ngpart))
-  mpart(i_part)%gpartid=0    
+  mpart(i_part)%gpartid=0
   do j_part=1,mpart(i_part)%ngpart
     ! obviously max_nelmt is a waste of memory. there should be some other ways,
     ! but this should not be a problem, because this routine can be run after deallocating
@@ -891,7 +891,7 @@
     allocate(mpart(i_part)%gpart(j_part)%meid(max_nelmt))
     allocate(mpart(i_part)%gpart(j_part)%geid(max_nelmt))
     mpart(i_part)%gpart(j_part)%nelmt=0
-  enddo  
+  enddo
 enddo
 !print*,max_nelmt
 allocate(list_gpart(max_ngpart),stat=istat)
@@ -906,7 +906,7 @@
 !write(*,*)' '
 allocate(eadjid(nelmt_interface))
 !inorder=(/1,2,3,4/) ! default local node ordering
-mpart(1:npart)%igpart=0 ! counter for unique gpart  
+mpart(1:npart)%igpart=0 ! counter for unique gpart
 !ipart=0
 ! find neighbouring entities lying on the different partition
 ipart_loop: do i_part=1,npart-1
@@ -917,13 +917,13 @@
     do i=1,mpart(i_part)%nelmt
       ielmt=mpart(i_part)%elmt(i)
       ie_interface=mpart(i_part)%eid_interface(i)
-      elmt_face=.false.; elmt_edge=.false.; elmt_node=.false. 
-      
+      elmt_face=.false.; elmt_edge=.false.; elmt_node=.false.
+
       !print*,adj_elmt(ie_interface,
       ngelmt=mpart(j_part)%nelmt
       gelmt(1:ngelmt)=mpart(j_part)%elmt(:)
       ginterface(1:ngelmt)=mpart(j_part)%eid_interface(:)
-      
+
       gadjid=0
       !print*,size(adjid),ie_interface,minval(ginterface(1:ngelmt)),maxval(ginterface(1:ngelmt))
       eadjid=0 ! elemental adjacency indicators
@@ -960,8 +960,8 @@
       ! list jpart elements
       ! print*,'hi',adj_nface,adj_nedge,adj_nnode
       ! print*,'hi'
-      
-      ! we check in the order face, edge, and node to exclude redundant sharing (low level repeating) 
+
+      ! we check in the order face, edge, and node to exclude redundant sharing (low level repeating)
       ! check for face/s
       do ia=1,adj_nface
         je_interface=ginterface(adj_iface(ia))
@@ -986,20 +986,20 @@
         !elmt_face(ie)=.true.
         !elmt_edge(abs(edge_face(ie,:)))=.true.
         !elmt_node(node_face(ie,:))=.true.
-        
-        ! ielmt is the ghost of jelmt                
+
+        ! ielmt is the ghost of jelmt
         call set_partition(j_part,i_part,jelmt,ielmt,ecomp,je,ie) !,jnorder,inorder)
         elmt_face(ie)=.true.
         elmt_edge(abs(edge_face(ie,:)))=.true.
         elmt_node(node_face(ie,:))=.true.
       enddo
-      
+
       ! chek for edge/s
       do ia=1,adj_nedge
         je_interface=ginterface(adj_iedge(ia))
         jelmt=gelmt(adj_iedge(ia))
         ecomp=2
-        if(ie_interface<je_interface)then          
+        if(ie_interface<je_interface)then
           !ecomp=adj_elmt(ie_interface,je_interface)
           ind=find(adj_elmt(ie_interface,:)==je_interface)
           ie=adj_id1(ie_interface,ind) !adj1(ie_interface,je_interface)
@@ -1018,15 +1018,15 @@
         !elmt_face(ie)=.true.
         !elmt_edge(abs(edge_face(ie,:)))=.true.
         !elmt_node(node_face(ie,:))=.true.
-        
-        ! ielmt is the ghost of jelmt                
+
+        ! ielmt is the ghost of jelmt
         call set_partition(j_part,i_part,jelmt,ielmt,ecomp,je,ie) !,jnorder,inorder)
         elmt_edge(ie)=.true.
         elmt_node(node_edge(ie,:))=.true.
       enddo
-      
+
       ! check for node/s
-      do ia=1,adj_nnode  
+      do ia=1,adj_nnode
         je_interface=ginterface(adj_inode(ia))
         jelmt=gelmt(adj_inode(ia))
         ecomp=1
@@ -1046,8 +1046,8 @@
         endif
         if(elmt_node(ie))cycle
         call set_partition(i_part,j_part,ielmt,jelmt,ecomp,ie,je) !,inorder,jnorder)
-                  
-        ! ielmt is the ghost of jelmt                
+
+        ! ielmt is the ghost of jelmt
         call set_partition(j_part,i_part,jelmt,ielmt,ecomp,je,ie) !,jnorder,inorder)
         elmt_node(ie)=.true.
       enddo
@@ -1056,10 +1056,10 @@
     !print*,mpart(i_part)%nelmt,mpart(j_part)%nelmt
     !stop
   enddo jpart_loop ! j_part
-enddo ipart_loop ! i_part  
+enddo ipart_loop ! i_part
 !print*,'total',ipart
 if(.not.all(mpart(1:npart)%igpart==mpart(1:npart)%ngpart))then
-  print*,'ERROR: total number of ghost partitions mismatched!'    
+  print*,'ERROR: total number of ghost partitions mismatched!'
   print*,'Total number of ghost partitions'
   print*,mpart(1:npart)%ngpart
   print*,'Counted number of ghost partitions'
@@ -1075,10 +1075,10 @@
 
 ! write master and ghost partitions
 write(format_str,*)ceiling(log10(real(npart)+1.))
-format_str='(a,i'//trim(adjustl(format_str))//'.'//trim(adjustl(format_str))//')'  
+format_str='(a,i'//trim(adjustl(format_str))//'.'//trim(adjustl(format_str))//')'
 
 ! write interfaces in each partition
-do i_part=1,npart    
+do i_part=1,npart
 
   ! open output file
   write(out_fname, fmt=format_str)trim(out_phead)//'ghost_proc',i_part-1
@@ -1101,35 +1101,35 @@
       stop
     endif
     write(16,*)'ghost partition ',j_part,' , my index there'
-    write(16,*)mpart(i_part)%gpartid(j_part)-1,myindex(1)   
-    write(16,*)'number of ghost elements in this ghost partition'     
+    write(16,*)mpart(i_part)%gpartid(j_part)-1,myindex(1)
+    write(16,*)'number of ghost elements in this ghost partition'
     !ngelmt=mpart(i_part)%gpart(j_part)%nelmt
     write(16,*)mpart(i_part)%gpart(j_part)%nelmt !,sum(mpart(i_part)%gpart(j_part)%ecomp(1:ngelmt))
     do i=1,mpart(i_part)%gpart(j_part)%nelmt
-      ecomp=mpart(i_part)%gpart(j_part)%ecomp(i)        
+      ecomp=mpart(i_part)%gpart(j_part)%ecomp(i)
       write(16,*)glob2loc_elmt(mpart(i_part)%gpart(j_part)%melmt(i)),mpart(i_part)%gpart(j_part)%ecomp(i), &
         mpart(i_part)%gpart(j_part)%meid(i) !,mpart(i_part)%gpart(j_part)%morder(1:ecomp), &
         !glob2loc_elmt(mpart(i_part)%gpart(j_part)%gelmt(i)), &
         !mpart(i_part)%gpart(j_part)%geid(i),mpart(i_part)%gpart(j_part)%gorder(1:ecomp)
-    enddo      
+    enddo
   enddo
   close(16)
 
 enddo
-write(*,*)' complete!' 
+write(*,*)' complete!'
 
 ! deallocate type variable gpart
-do i_part=1,npart       
+do i_part=1,npart
   do j_part=1,mpart(i_part)%ngpart
     deallocate(mpart(i_part)%gpart(j_part)%melmt)
     deallocate(mpart(i_part)%gpart(j_part)%gelmt)
     deallocate(mpart(i_part)%gpart(j_part)%ecomp)
     deallocate(mpart(i_part)%gpart(j_part)%meid)
     deallocate(mpart(i_part)%gpart(j_part)%geid)
-    
-  enddo  
+
+  enddo
 enddo
-do i_part=1,npart    
+do i_part=1,npart
   deallocate(mpart(i_part)%gpart)
   deallocate(mpart(i_part)%gpartid)
   deallocate(mpart(i_part)%elmt)
@@ -1137,7 +1137,7 @@
 enddo
 !deallocate(mpart)
 !=======================================================
-  
+
 contains
 !--------------------------------------------------
 ! this function finds the node ID of a true node in isnode
@@ -1152,7 +1152,7 @@
     ind=i
     return
   endif
-enddo  
+enddo
 end function find
 !--------------------------------------------------
 
@@ -1168,7 +1168,7 @@
   endif
 enddo
 write(*,*)'ERROR: no common node for node ID!'
-stop   
+stop
 end function get_nodeid
 !--------------------------------------------------
 
@@ -1186,9 +1186,9 @@
   endif
 enddo
 write(*,*)'ERROR: no common node for edge ID!'
-stop   
+stop
 end function get_edgeid
-!-------------------------------------------------- 
+!--------------------------------------------------
 ! this function finds the face ID according to node_face of a set of true nodes in isnode
 function get_faceid(isnode,node_face) result(id)
 implicit none
@@ -1203,9 +1203,9 @@
   endif
 enddo
 write(*,*)'ERROR: no common node for face ID!'
-stop   
+stop
 end function get_faceid
-!--------------------------------------------------   
+!--------------------------------------------------
 
 ! this subroutine set all the members of each master-ghost partition pair
 subroutine set_partition(master,ghost,melmt,gelmt,ecomp,meid,geid) !,morder,gorder)
@@ -1219,26 +1219,26 @@
 if (mpart(master)%igpart==0)then ! first time count
   mpart(master)%igpart=1
   ind_gpart(1)=1
-  mpart(master)%gpartid(1)=ghost        
+  mpart(master)%gpartid(1)=ghost
 else ! already counted
-  list_gpart=-1    
-  list_gpart(1:mpart(master)%igpart)=mpart(master)%gpartid(1:mpart(master)%igpart) ! list of existing ghost partitions        
+  list_gpart=-1
+  list_gpart(1:mpart(master)%igpart)=mpart(master)%gpartid(1:mpart(master)%igpart) ! list of existing ghost partitions
   ind_gpart=maxloc(list_gpart,logical(list_gpart==ghost,1)) ! search if this ghost partion is already in the list and find the index
-  
-  if(ind_gpart(1)==0)then ! not found, i.e., this is a new gpart         
+
+  if(ind_gpart(1)==0)then ! not found, i.e., this is a new gpart
     mpart(master)%igpart=mpart(master)%igpart+1
     ind_gpart(1)=mpart(master)%igpart
-    mpart(master)%gpartid(ind_gpart(1))=ghost                
+    mpart(master)%gpartid(ind_gpart(1))=ghost
   endif
 endif
 
 ! count ghost elements in the ghost partition
-  
+
 !if(master==1 .and. ghost==2 )print*,'first0 nelmt: ',mpart(master)%gpart(ind_gpart(1))%nelmt,ind_gpart(1), &
 !mpart(master)%gpartid(ind_gpart(1))
 !print*,'hi0',mpart(master)%gpart(ind_gpart(1))%nelmt
 !stop
-mpart(master)%gpart(ind_gpart(1))%nelmt=mpart(master)%gpart(ind_gpart(1))%nelmt+1         
+mpart(master)%gpart(ind_gpart(1))%nelmt=mpart(master)%gpart(ind_gpart(1))%nelmt+1
 ind=mpart(master)%gpart(ind_gpart(1))%nelmt
 !if(master==1 .and. ghost==2 )print*,'first1 nelmt: ',mpart(master)%gpart(ind_gpart(1))%nelmt,ind_gpart(1), &
 !mpart(master)%gpartid(ind_gpart(1))
@@ -1253,7 +1253,7 @@
 !mpart(master)%gpart(ind_gpart(1))%morder=morder
 !mpart(master)%gpart(ind_gpart(1))%gorder=gorder
 end subroutine set_partition
-!--------------------------------------------------  
+!--------------------------------------------------
 
 end subroutine detect_ghost
 !=======================================================
@@ -1264,7 +1264,7 @@
 ! 1/ first element, 2/ second element, 3/ number of common nodes, 4/ first node,
 ! 5/ second node, if relevant.
 
-! interface ignores acoustic and elastic elements 
+! interface ignores acoustic and elastic elements
 
 ! Elements with undefined material are considered as elastic elements.
 !--------------------------------------------------
@@ -1282,7 +1282,7 @@
 
 integer,intent(in) :: npart
 
-! local parameters  
+! local parameters
 integer :: num_part,num_part_bis,el,el_adj,num_interface, &
 num_edge,ncommon_nodes,num_node, num_node_bis
 integer :: i,j
@@ -1308,8 +1308,8 @@
 do num_part = 0, npart-1
     do num_part_bis = num_part+1, npart-1
       do el = 0, nelmnts-1
-          if ( part(el) == num_part ) then                
-            ! looks at all neighbor elements 
+          if ( part(el) == num_part ) then
+            ! looks at all neighbor elements
             do el_adj = xadj(el), xadj(el+1)-1
                 ! adds element if neighbor element lies in next partition
                 if ( part(adjncy(el_adj)) == num_part_bis ) then
@@ -1340,7 +1340,7 @@
       do el = 0, nelmnts-1
           if ( part(el) == num_part ) then
             do el_adj = xadj(el), xadj(el+1)-1
-                ! adds element if in adjacent partition                    
+                ! adds element if in adjacent partition
                 if ( part(adjncy(el_adj)) == num_part_bis ) then
                   tab_interfaces(tab_size_interfaces(num_interface)*7+num_edge*7+0) = el
                   tab_interfaces(tab_size_interfaces(num_interface)*7+num_edge*7+1) = adjncy(el_adj)
@@ -1402,7 +1402,7 @@
 
 
 
-! local parameters  
+! local parameters
 integer :: num_part,num_part_bis,el,el_adj,num_interface, &
 num_edge,ncommon_nodes,num_node,num_node_bis
 integer :: i,j
@@ -1438,7 +1438,7 @@
             else
                 is_acoustic_el = .false.
             end if
-            ! looks at all neighbor elements 
+            ! looks at all neighbor elements
             do el_adj = xadj(el), xadj(el+1)-1
                 ! determines whether neighbor element is acoustic or not
                 if(num_material(adjncy(el_adj)+1) > 0) then
@@ -1632,7 +1632,7 @@
 !--------------------------------------------------
 subroutine write_material_properties_database(out_path,matfile, &
 count_def_mat,count_undef_mat,mat_domain,mat_prop, &
-undef_mat_domain,undef_mat_prop,nwmat,waterid,iproc,npart) 
+undef_mat_domain,undef_mat_prop,nwmat,waterid,iproc,npart)
 
 integer,intent(in) :: count_def_mat,count_undef_mat,iproc,npart
 integer,dimension(count_def_mat) :: mat_domain
@@ -1659,12 +1659,12 @@
   stop
 endif
 
-write(16,*)'# material properties (domain,id,gamma,ym,nu,phi,coh,psi)'   
-write(16,*)  count_def_mat !,count_undef_mat 
+write(16,*)'# material properties (domain,id,gamma,ym,nu,phi,coh,psi)'
+write(16,*)  count_def_mat !,count_undef_mat
 do i = 1, count_def_mat
   ! database material definition
   !
-  ! format:  #rho  #vp  #vs  #Q_flag  #anisotropy_flag #domain_id     
+  ! format:  #rho  #vp  #vs  #Q_flag  #anisotropy_flag #domain_id
   !
   ! (note that this order of the properties is different than the input in nummaterial_velocity_file)
   !
@@ -1679,8 +1679,8 @@
 ! write water properties if any
 write(16,*)nwmat
 do i=1,nwmat
-  !print*,nwmat,i,waterid(i)      
-  write(16,*)waterid(i) 
+  !print*,nwmat,i,waterid(i)
+  write(16,*)waterid(i)
 enddo
 close(16)
 
@@ -1695,10 +1695,10 @@
                       ibelm_xmin, ibelm_xmax, ibelm_ymin, &
                       ibelm_ymax, ibelm_bottom, ibelm_top, &
                       nodes_ibelm_xmin, nodes_ibelm_xmax, nodes_ibelm_ymin, &
-                      nodes_ibelm_ymax, nodes_ibelm_bottom, nodes_ibelm_top, & 
+                      nodes_ibelm_ymax, nodes_ibelm_bottom, nodes_ibelm_top, &
                       glob2loc_elmnts, glob2loc_nodes_npart, &
                       glob2loc_nodes_parts, glob2loc_nodes, part,npart )
-    
+
 integer,intent(in) :: iproc,npart
 integer,intent(in) :: nelmnts !integer(long)
 integer,intent(in) :: nspec2D_xmin,nspec2D_xmax,nspec2D_ymin, nspec2D_ymax,nspec2D_bottom,nspec2D_top
@@ -1707,21 +1707,21 @@
 integer,dimension(nspec2D_ymin),intent(in) :: ibelm_ymin
 integer,dimension(nspec2D_ymax),intent(in) :: ibelm_ymax
 integer,dimension(nspec2D_bottom),intent(in) :: ibelm_bottom
-integer,dimension(nspec2D_top),intent(in) :: ibelm_top 
+integer,dimension(nspec2D_top),intent(in) :: ibelm_top
 
 integer,dimension(nspec2D_xmin),intent(in) :: nodes_ibelm_xmin
 integer,dimension(nspec2D_xmax),intent(in) :: nodes_ibelm_xmax
 integer,dimension(nspec2D_ymin),intent(in) :: nodes_ibelm_ymin
 integer,dimension(4,nspec2D_ymax),intent(in) :: nodes_ibelm_ymax
 integer,dimension(4,nspec2D_bottom),intent(in) :: nodes_ibelm_bottom
-integer,dimension(4,nspec2D_top),intent(in) :: nodes_ibelm_top    
+integer,dimension(4,nspec2D_top),intent(in) :: nodes_ibelm_top
 integer,dimension(:),pointer :: glob2loc_elmnts
 integer,dimension(:),pointer :: glob2loc_nodes_npart
 integer,dimension(:),pointer :: glob2loc_nodes_parts
 integer,dimension(:),pointer :: glob2loc_nodes
 integer,dimension(1:nelmnts) :: part
 
-! local parameters  
+! local parameters
 integer :: i
 integer :: loc_node1,loc_node2,loc_node3,loc_node4
 integer :: loc_nspec2D_xmin,loc_nspec2D_xmax,loc_nspec2D_ymin, &
@@ -1747,7 +1747,7 @@
 
 ! counts number of elements for boundary at xmin, xmax, ymin, ymax, bottom, top in this partition
 loc_nspec2D_xmin = 0
-do i=1,nspec2D_xmin  
+do i=1,nspec2D_xmin
     if(part(ibelm_xmin(i)) == iproc) then
       loc_nspec2D_xmin = loc_nspec2D_xmin + 1
     end if
@@ -1757,11 +1757,11 @@
 ! outputs element index and element node indices
 ! note: assumes that element indices in ibelm_* arrays are in the range from 1 to nspec
 !          (this is assigned by CUBIT, if this changes the following indexing must be changed as well)
-!          while glob2loc_elmnts(.) is shifted from 0 to nspec-1  thus 
+!          while glob2loc_elmnts(.) is shifted from 0 to nspec-1  thus
 !          we need to have the arg of glob2loc_elmnts start at 0 ==> glob2loc_nodes(ibelm_** -1 )
-do i=1,nspec2D_xmin  
+do i=1,nspec2D_xmin
     if(part(ibelm_xmin(i)) == iproc) then
-      write(16,*) glob2loc_elmnts(ibelm_xmin(i)-1)+1, nodes_ibelm_xmin(i)  
+      write(16,*) glob2loc_elmnts(ibelm_xmin(i)-1)+1, nodes_ibelm_xmin(i)
     end if
 end do
 close(16)
@@ -1776,16 +1776,16 @@
 endif
 
 loc_nspec2D_xmax = 0
-do i=1,nspec2D_xmax  
+do i=1,nspec2D_xmax
     if(part(ibelm_xmax(i)) == iproc) then
       loc_nspec2D_xmax = loc_nspec2D_xmax + 1
     end if
 end do
 write(16,*)loc_nspec2D_xmax
 
-do i=1,nspec2D_xmax     
-    if(part(ibelm_xmax(i)) == iproc) then         
-      write(16,*) glob2loc_elmnts(ibelm_xmax(i)-1)+1, nodes_ibelm_xmax(i)  
+do i=1,nspec2D_xmax
+    if(part(ibelm_xmax(i)) == iproc) then
+      write(16,*) glob2loc_elmnts(ibelm_xmax(i)-1)+1, nodes_ibelm_xmax(i)
     end if
 end do
 close(16)
@@ -1799,19 +1799,19 @@
   stop
 endif
 loc_nspec2D_ymin = 0
-do i=1,nspec2D_ymin  
+do i=1,nspec2D_ymin
     if(part(ibelm_ymin(i)) == iproc) then
       loc_nspec2D_ymin = loc_nspec2D_ymin + 1
     end if
 end do
-write(16,*)loc_nspec2D_ymin   
+write(16,*)loc_nspec2D_ymin
 
-do i=1,nspec2D_ymin     
-    if(part(ibelm_ymin(i)) == iproc) then          
-      write(16,*) glob2loc_elmnts(ibelm_ymin(i)-1)+1, nodes_ibelm_ymin(i)  
+do i=1,nspec2D_ymin
+    if(part(ibelm_ymin(i)) == iproc) then
+      write(16,*) glob2loc_elmnts(ibelm_ymin(i)-1)+1, nodes_ibelm_ymin(i)
     end if
 end do
-close(16)   
+close(16)
 
 end subroutine write_boundaries_database
 !===========================================
@@ -1878,7 +1878,7 @@
     end do
     write(16,*)nspec
     write(17,*)nspec
-    
+
     !write(out_fname, fmt=format_str)trim(out_phead)//'elmt_proc',iproc
     ! open(unit=19,file=trim(out_fname),&
     !   status='unknown', action='write', form='formatted', iostat = istat)
@@ -1902,7 +1902,7 @@
             end do
 
           end do
-          
+
           ! format:
           ! # ispec_local # material_index_1 # material_index_2 # corner_id1 # corner_id2 # ... # corner_id8
           !write(16,*) glob2loc_elmnts(i)+1, matid(1,i+1), matid(2,i+1),(loc_nodes(k)+1, k=0,ngnod-1)
@@ -1953,7 +1953,7 @@
 !character(len=80) :: prname
 character(len=256) :: out_phead
 character(len=20) :: format_str
-character(len=80) :: out_fname    
+character(len=80) :: out_fname
 
 write(format_str,*)ceiling(log10(real(npart)+1.))
 format_str='(a,i'//trim(adjustl(format_str))//'.'//trim(adjustl(format_str))//')'
@@ -1973,14 +1973,14 @@
 ! counts number of interfaces to neighbouring partitions
     my_interfaces(:) = 0
     my_nb_interfaces(:) = 0
-  
+
     ! double loops over all partitions
-    do i = 0, npart-1       
+    do i = 0, npart-1
       do j = i+1, npart-1
           ! only counts if specified partition (iproc) appears and interface elements increment
           if ( (tab_size_interfaces(num_interface) < tab_size_interfaces(num_interface+1)) .and. &
               (i == iproc .or. j == iproc) ) then
-            ! sets flag  
+            ! sets flag
             my_interfaces(num_interface) = 1
             ! sets number of elements on interface
             my_nb_interfaces(num_interface) = tab_size_interfaces(num_interface+1) - tab_size_interfaces(num_interface)
@@ -2004,7 +2004,7 @@
             else
               write(16,*) i, my_nb_interfaces(num_interface)
             end if
-            
+
             count_faces = 0
             do k = tab_size_interfaces(num_interface), tab_size_interfaces(num_interface+1)-1
               !print*,'hello',i,iproc
@@ -2018,7 +2018,7 @@
                   !print*,tab_interfaces(k*7+1),size(glob2loc_elmnts)
                   !stop
                   local_elmnt = glob2loc_elmnts(tab_interfaces(k*7+1))+1
-                  
+
               end if
 
 !!$                  if ( tab_interfaces(k*7+2) == 1 ) then
@@ -2109,7 +2109,7 @@
                   print *, "error in write_interfaces_database!", tab_interfaces(k*7+2), iproc
               end select
             end do
-      
+
             ! outputs infos
             !print*,'  partition MPI interface:',iproc,num_interface
             !print*,'    element faces: ',count_faces
@@ -2126,14 +2126,14 @@
 !=======================================================
 
 !--------------------------------------------------
-! Write elements on surface boundaries (and their four nodes on boundaries) 
+! Write elements on surface boundaries (and their four nodes on boundaries)
 ! pertaining to iproc partition in the corresponding Database
 !--------------------------------------------------
-subroutine write_moho_surface_database(IIN_database, iproc, nelmnts, & 
+subroutine write_moho_surface_database(IIN_database, iproc, nelmnts, &
                       glob2loc_elmnts, glob2loc_nodes_npart, &
                       glob2loc_nodes_parts, glob2loc_nodes, part, &
                       nspec2D_moho,ibelm_moho,nodes_ibelm_moho)
-    
+
 integer,intent(in) :: IIN_database
 integer,intent(in) :: iproc
 integer,intent(in) :: nelmnts !integer(long)
@@ -2151,7 +2151,7 @@
 integer :: i,j
 integer :: loc_node1,loc_node2,loc_node3,loc_node4
 integer :: loc_nspec2D_moho
-  
+
 ! counts number of elements for moho surface in this partition
 ! optional moho
 loc_nspec2D_moho = 0
@@ -2169,11 +2169,11 @@
 ! outputs element index and element node indices
 ! note: assumes that element indices in ibelm_* arrays are in the range from 1 to nspec
 !          (this is assigned by CUBIT, if this changes the following indexing must be changed as well)
-!          while glob2loc_elmnts(.) is shifted from 0 to nspec-1  thus 
+!          while glob2loc_elmnts(.) is shifted from 0 to nspec-1  thus
 !          we need to have the arg of glob2loc_elmnts start at 0 ==> glob2loc_nodes(ibelm_** -1 )
 
 ! optional moho
-do i=1,nspec2D_moho    
+do i=1,nspec2D_moho
     if(part(ibelm_moho(i)) == iproc) then
       do j = glob2loc_nodes_npart(nodes_ibelm_moho(1,i)-1), glob2loc_nodes_npart(nodes_ibelm_moho(1,i))-1
           if (glob2loc_nodes_parts(j) == iproc ) then
@@ -2195,7 +2195,7 @@
             loc_node4 = glob2loc_nodes(j)+1
           end if
       end do
-      write(IIN_database,*) glob2loc_elmnts(ibelm_moho(i)-1)+1, loc_node1, loc_node2, loc_node3, loc_node4  
+      write(IIN_database,*) glob2loc_elmnts(ibelm_moho(i)-1)+1, loc_node1, loc_node2, loc_node3, loc_node4
     end if
 
 end do
@@ -2204,13 +2204,13 @@
 
 
 !--------------------------------------------------
-! loading : sets weights for acoustic/elastic elements to account for different 
+! loading : sets weights for acoustic/elastic elements to account for different
 !               expensive calculations in specfem simulations
 !--------------------------------------------------
 
 subroutine acoustic_elastic_load (elmnts_load,nelmnts,nb_materials,num_material,mat_prop)
 !
-! note: 
+! note:
 !   acoustic material = domainID 1  (stored in mat_prop(6,..) )
 !   elastic material    = domainID 2
 !
@@ -2222,12 +2222,12 @@
 ! load weights
 integer,dimension(1:nelmnts),intent(out) :: elmnts_load
 
-! materials  
+! materials
 integer,dimension(1:nelmnts),intent(in) :: num_material
 real(kind=kreal),dimension(6,nb_materials),intent(in) :: mat_prop !double precision
 
 ! local parameters
-logical,dimension(nb_materials) :: is_acoustic,is_elastic    
+logical,dimension(nb_materials) :: is_acoustic,is_elastic
 integer :: i,el
 
 ! sets acoustic/elastic flags for materials
@@ -2291,7 +2291,7 @@
 integer,dimension(:),allocatable :: adjncy
 integer,dimension(:),allocatable :: nnodes_elmnts
 integer,dimension(:),allocatable :: nodes_elmnts
-integer :: max_neighbour        
+integer :: max_neighbour
 
 integer :: i,iface
 integer :: el,el_adj
@@ -2381,11 +2381,11 @@
 integer,intent(in) :: nelmnts !integer(long)
 
 ! number of (global) nodes, number or processes
-integer,intent(in) :: nnodes,nproc 
+integer,intent(in) :: nnodes,nproc
 
 ! maximum number of neighours and max number of elements-that-contain-the-same-node
 integer,intent(in) :: sup_neighbour,nsize !integer(long)
-    
+
 ! partition index on each element
 integer,dimension(0:nelmnts-1) :: part
 
@@ -2409,7 +2409,7 @@
 integer,dimension(:),allocatable :: adjncy
 integer,dimension(:),allocatable :: nnodes_elmnts
 integer,dimension(:),allocatable :: nodes_elmnts
-integer :: max_neighbour        
+integer :: max_neighbour
 
 integer :: i,j,iface,inode,ispec2D,counter
 integer :: el,el_adj
@@ -2420,14 +2420,14 @@
 allocate( node_is_moho(0:nnodes-1) ) ! node ids start from 0
 is_moho(:) = .false.
 node_is_moho(:) = .false.
-    
+
 ! sets moho flags for known elements
 do ispec2D = 1, nspec2D_moho
   ! note: assumes that element indices in ibelm_* arrays are in the range from 1 to nspec
   el = ibelm_moho(ispec2D) - 1
-  is_moho(el) = .true.  
-  
-  ! sets node flags      
+  is_moho(el) = .true.
+
+  ! sets node flags
   do j=1,4
     ! note: assumes that node indices in nodes_ibelm_* arrays are in the range from 1 to nodes
     inode = nodes_ibelm_moho(j,ispec2D) - 1
@@ -2435,18 +2435,18 @@
   enddo
 enddo
 
-! checks if element has moho surface 
+! checks if element has moho surface
 do el = 0, nelmnts-1
   if( is_moho(el) ) cycle
-  
-  ! loops over all element corners         
-  counter = 0   
+
+  ! loops over all element corners
+  counter = 0
   do i=0,esize-1
     ! note: assumes that node indices in elmnts array are in the range from 0 to nodes-1
     inode = elmnts(el*esize+i)
-    if( node_is_moho(inode) ) counter = counter + 1  
+    if( node_is_moho(inode) ) counter = counter + 1
   enddo
-  
+
   ! sets flag if it has a surface
   if( counter == 4 ) is_moho(el) = .true.
 enddo
@@ -2587,7 +2587,7 @@
 integer,dimension(n),intent(in) :: x1,x2 ! data vectors to compare
 logical :: flag
 integer :: i
-flag=.true. 
+flag=.true.
 do i = 1,n
 if(x1(i)/=x2(i))then
   flag=.false.

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_scotch.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_scotch.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/partmesh_scotch.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -22,7 +22,7 @@
 
 integer :: inode,nnodes
 real(kind=kreal),dimension(:,:),allocatable  :: nodes_coords !double precision
-  
+
 integer,dimension(:),allocatable  :: xadj
 integer,dimension(:),allocatable  :: adjncy
 integer,dimension(:),allocatable  :: nnodes_elmnts
@@ -61,7 +61,7 @@
 integer,dimension(:),allocatable :: nodes_ibelm_xmin,nodes_ibelm_xmax,         &
 nodes_ibelm_ymin
 integer,dimension(:,:),allocatable :: nodes_ibelm_ymax,nodes_ibelm_bottom,     &
-nodes_ibelm_top 
+nodes_ibelm_top
 
 ! moho surface (optional)
 integer :: nspec2D_moho
@@ -85,7 +85,7 @@
 character (len=30),dimension(:,:),allocatable :: undef_mat_prop
 
 ! default mesh file directory
-character(len=256) :: inp_path,out_path  
+character(len=256) :: inp_path,out_path
 character(len=256) :: out_phead ! output path and header
 
 integer :: idomain_id
@@ -146,11 +146,11 @@
 read(98,*)nodes_coords(3,:)
 close(98)
 
-print*, 'total nodes:', nnodes 
+print*, 'total nodes:', nnodes
 
-! reads mesh elements indexing 
+! reads mesh elements indexing
 !(CUBIT calls this the connectivity, guess in the sense that it connects with
-! the points index in the global coordinate file "nodes_coords_file"; it doesn't 
+! the points index in the global coordinate file "nodes_coords_file"; it doesn't
 ! tell you which point is connected with others)
 ! open file to read
 inp_fname=trim(inp_path)//trim(confile)
@@ -168,28 +168,28 @@
 
   ! note: be aware that here we can have different node ordering for a cube element;
   !          the ordering from Cubit files might not be consistent for multiple volumes, or uneven, unstructured grids
-  !         
-  !          guess here it assumes that spectral elements ordering is like first at the bottom of the element, anticlock-wise, i.e. 
+  !
+  !          guess here it assumes that spectral elements ordering is like first at the bottom of the element, anticlock-wise, i.e.
   !             point 1 = (0,0,0), point 2 = (0,1,0), point 3 = (1,1,0), point 4 = (1,0,0)
-  !          then top (positive z-direction) of element 
+  !          then top (positive z-direction) of element
   !             point 5 = (0,0,1), point 6 = (0,1,1), point 7 = (1,1,1), point 8 = (1,0,1)
 
   !read(98,*) num_elmnt, elmnts(5,num_elmnt), elmnts(1,num_elmnt),elmnts(4,num_elmnt), elmnts(8,num_elmnt), &
   !      elmnts(6,num_elmnt), elmnts(2,num_elmnt), elmnts(3,num_elmnt), elmnts(7,num_elmnt)
 
   read(98,*)elmnts(:,ispec)
-        
+
   !outputs info for each element to see ordering
   !print*,'ispec: ',ispec
   !print*,'  ',num_elmnt, elmnts(5,num_elmnt), elmnts(1,num_elmnt),elmnts(4,num_elmnt), elmnts(8,num_elmnt), &
-  !      elmnts(6,num_elmnt), elmnts(2,num_elmnt), elmnts(3,num_elmnt), elmnts(7,num_elmnt)    
+  !      elmnts(6,num_elmnt), elmnts(2,num_elmnt), elmnts(3,num_elmnt), elmnts(7,num_elmnt)
   !print*,'elem:',num_elmnt
   !do i=1,8
   !  print*,' i ',i,'val :',elmnts(i,num_elmnt),&
   !    nodes_coords(1,elmnts(i,num_elmnt)),nodes_coords(2,elmnts(i,num_elmnt)),nodes_coords(3,elmnts(i,num_elmnt))
   !enddo
   !print*
-      
+
 end do
 close(98)
 print*, 'total elements:', nspec
@@ -212,10 +212,10 @@
   ! format: # id_element #flag
   ! note: we assume elements are sorted in materials_file
   matid(1,ispec)=ispec
-  read(98,*)matid(2,ispec);  
+  read(98,*)matid(2,ispec);
 end do
 close(98)
-  
+
 ! reads material definitions
 !
 ! note: format of nummaterial_velocity_file must be
@@ -242,14 +242,14 @@
 endif
 
 ! note: format #material_domain_id #material_id #...
-!read(98,*) ! skip line      
+!read(98,*) ! skip line
 !read(98,*,iostat=istat) idummy,num_mat
 !print *,'materials:'
 ! counts materials (defined/undefined)
 !do while (istat == 0)
 !   print*, '  num_mat = ',num_mat
-!   if(num_mat /= -1) then 
-!      count_def_mat = count_def_mat + 1        
+!   if(num_mat /= -1) then
+!      count_def_mat = count_def_mat + 1
 !   else
 !      count_undef_mat = count_undef_mat + 1
 !   end if
@@ -268,16 +268,16 @@
 endif
 allocate(mat_prop(6,count_def_mat),mat_domain(count_def_mat))
 allocate(undef_mat_prop(6,count_undef_mat),undef_mat_domain(count_def_mat))
-! reads in defined material properties    
+! reads in defined material properties
 !open(unit=98, file=inp_path(1:len_trim(inp_path))//trim(matfile), &
 !      status='old', form='formatted')
 !read(98,*) ! skip one line
 do imat=1,count_def_mat
     ! material definitions
     !
-    ! format: note that we save the arguments in a slightly different order in  
+    ! format: note that we save the arguments in a slightly different order in
     ! mat_prop(:,:)
-    ! #(6) material_domain_id #(0) material_id  #(1) gam #(2) ym #(3) nu #(4) 
+    ! #(6) material_domain_id #(0) material_id  #(1) gam #(2) ym #(3) nu #(4)
     ! phi #(5) anisotropy_flag
     !
     ! idomain_id,gam,ym,nu,phi,coh,psi
@@ -291,7 +291,7 @@
     !mat_prop(4,num_mat) = phi
     !mat_prop(5,num_mat) = coh
     !mat_prop(6,num_mat) = psi
-          
+
     if(num_mat < 0 .or. num_mat > count_def_mat)then
       print*,"ERROR: Invalid nummaterial_velocity_file file."
       stop
@@ -306,11 +306,11 @@
   !undef_mat_prop(2,imat),undef_mat_prop(3,imat),undef_mat_prop(4,imat),       &
   !undef_mat_prop(5,imat)
 end do
-read(98,*,iostat=ios)nwmat    
+read(98,*,iostat=ios)nwmat
 if(ios==0)then
   allocate(waterid(nwmat))
   do i=1,nwmat
-    read(98,*)waterid(i)  
+    read(98,*)waterid(i)
   enddo
 endif
 close(98)
@@ -332,20 +332,20 @@
 endif
 allocate(ibelm_xmin(nspec2D_xmin))
 allocate(nodes_ibelm_xmin(nspec2D_xmin))
-do ispec2D = 1,nspec2D_xmin 
+do ispec2D = 1,nspec2D_xmin
   ! format: #id_(element containing the face) #id_node1_face .. #id_node4_face
   ! note: ordering for CUBIT seems such that the normal of the face points outward of the element the face belongs to;
-  !         in other words, nodes are in increasing order such that when looking from within the element outwards, 
+  !         in other words, nodes are in increasing order such that when looking from within the element outwards,
   !         they are ordered clockwise
   !
-  !          doesn't necessarily have to start on top-rear, then bottom-rear, bottom-front, and finally top-front i.e.: 
+  !          doesn't necessarily have to start on top-rear, then bottom-rear, bottom-front, and finally top-front i.e.:
   !          point 1 = (0,1,1), point 2 = (0,1,0), point 3 = (0,0,0), point 4 = (0,0,1)
   read(98,*) ibelm_xmin(ispec2D), nodes_ibelm_xmin(ispec2D)
 
-  !outputs info for each element for check of ordering          
+  !outputs info for each element for check of ordering
   !print*,'ispec2d:',ispec2d
   !print*,'  xmin:', ibelm_xmin(ispec2D), nodes_ibelm_xmin(1,ispec2D), nodes_ibelm_xmin(2,ispec2D), &
-  !      nodes_ibelm_xmin(3,ispec2D), nodes_ibelm_xmin(4,ispec2D)     
+  !      nodes_ibelm_xmin(3,ispec2D), nodes_ibelm_xmin(4,ispec2D)
   !do i=1,4
   !  print*,'i',i,'val:',ibelm_xmin(ispec2d),nodes_coords(1,nodes_ibelm_xmin(i,ispec2D)), &
   !      nodes_coords(2,nodes_ibelm_xmin(i,ispec2D)),nodes_coords(3,nodes_ibelm_xmin(i,ispec2D))
@@ -354,7 +354,7 @@
 end do
 close(98)
 print*, 'absorbing boundaries:'
-print*, '  nspec2D_xmin = ', nspec2D_xmin 
+print*, '  nspec2D_xmin = ', nspec2D_xmin
 
 ! reads in absorbing boundary files
 inp_fname=trim(inp_path)//trim(uyfile)
@@ -395,8 +395,8 @@
 endif
 allocate(ibelm_ymin(nspec2D_ymin))
 allocate(nodes_ibelm_ymin(nspec2D_ymin))
-do ispec2D = 1,nspec2D_ymin 
-  ! format: #id_(element containing the face) #id_node1_face .. #id_node4_face   
+do ispec2D = 1,nspec2D_ymin
+  ! format: #id_(element containing the face) #id_node1_face .. #id_node4_face
   read(98,*) ibelm_ymin(ispec2D), nodes_ibelm_ymin(ispec2D)
 end do
 close(98)
@@ -446,7 +446,7 @@
 allocate(xadj(1:nspec+1))
 allocate(adjncy(1:sup_neighbour*nspec))
 allocate(nnodes_elmnts(1:nnodes))
-allocate(nodes_elmnts(1:nsize*nnodes))    
+allocate(nodes_elmnts(1:nsize*nnodes))
 call mesh2dual_ncommonnodes(nspec,nnodes,nsize,sup_neighbour,elmnts,xadj,      &
 adjncy,nnodes_elmnts,nodes_elmnts,max_neighbour,1)
 print*, 'mesh2dual: '
@@ -464,7 +464,7 @@
 allocate(elmnts_load(1:nspec))
 
 ! uniform load
-elmnts_load(:) = 1 
+elmnts_load(:) = 1
 
 ! in case of acoustic/elastic simulation, weights elements accordingly
 call acoustic_elastic_load(elmnts_load,nspec,count_def_mat,matid(2,:),mat_prop)
@@ -489,7 +489,7 @@
 ! arguments: #(1) graph_structure       #(2) baseval(either 0/1)    #(3) number_of_vertices
 !                    #(4) adjacency_index_array         #(5) adjacency_end_index_array (optional)
 !                    #(6) vertex_load_array (optional) #(7) vertex_label_array
-!                    #(7) number_of_arcs                    #(8) adjacency_array 
+!                    #(7) number_of_arcs                    #(8) adjacency_array
 !                    #(9) arc_load_array (optional)      #(10) istator
 call scotchfgraphbuild (scotchgraph(1), 0, nspec, &
                       xadj(1), xadj(1), &
@@ -503,8 +503,8 @@
 !                      xadj (1), xadj (1), &
 !                      nb_edges, adjncy (1), &
 !                      adjncy (1), istat)
-                      
-                      
+
+
 if (istat /= 0) then
     stop 'ERROR : MAIN : Cannot build graph'
 endif
@@ -586,21 +586,21 @@
   !if( istat /= 0 ) then
   ! print*,'error file open:',trim(out_fname)
   ! stop
-  !endif       
+  !endif
 
-  ! gets number of nodes 
+  ! gets number of nodes
   call write_glob2loc_nodes_database(out_path,xfile,yfile,zfile,ipart,         &
   nnodes_loc,nodes_coords,glob2loc_nodes_npart,glob2loc_nodes_parts,           &
   glob2loc_nodes,nnodes,npart)
 
-  ! gets number of spectral elements                           
+  ! gets number of spectral elements
   call write_partition_database(out_path,confile,idfile,ipart,nspec_loc,nspec, &
   elmnts,glob2loc_elmnts,glob2loc_nodes_npart,glob2loc_nodes_parts,            &
   glob2loc_nodes,part,matid,ngnod,npart)
 
-  ! writes out node coordinate locations 
+  ! writes out node coordinate locations
   !write(15,*) nnodes_loc
-  
+
   !call write_glob2loc_nodes_database(15, ipart, nnodes_loc, nodes_coords,&
   !  glob2loc_nodes_npart, glob2loc_nodes_parts, &
   !  glob2loc_nodes, nnodes, 2)
@@ -608,16 +608,16 @@
   call write_material_properties_database(out_path,matfile,count_def_mat,      &
   count_undef_mat,mat_domain,mat_prop,undef_mat_domain,undef_mat_prop,nwmat,   &
   waterid,ipart,npart)
-  
-  
-  
-  ! writes out spectral element indices 
+
+
+
+  ! writes out spectral element indices
   !write(15,*) nspec_loc
-  
+
   !call write_partition_database(15, ipart, nspec_loc, nspec, elmnts, &
   !  glob2loc_elmnts, glob2loc_nodes_npart, &
   !  glob2loc_nodes_parts, glob2loc_nodes, part, matid, ngnod, 2)
-  
+
   ! writes out absorbing/free-surface boundaries
   !call write_boundaries_database(out_phead,ipart, nspec, nspec2D_xmin, nspec2D_xmax, nspec2D_ymin, &
   !  nspec2D_ymax, nspec2D_bottom, nspec2D_top, &
@@ -628,14 +628,14 @@
   !  glob2loc_elmnts, glob2loc_nodes_npart, &
   !  glob2loc_nodes_parts, glob2loc_nodes, part,npart)
 
-  ! write MPI interfaces                           
+  ! write MPI interfaces
   !call Write_interfaces_database(out_phead,tab_interfaces, tab_size_interfaces, ipart, ninterfaces, &
   !  my_ninterface, my_interfaces, my_nb_interfaces, &
   !  glob2loc_elmnts, glob2loc_nodes_npart, glob2loc_nodes_parts, &
   !  glob2loc_nodes, npart)
 end do
 
-deallocate(matid,nodes_coords,xadj,adjncy,nnodes_elmnts,nodes_elmnts,elmnts_load)    
+deallocate(matid,nodes_coords,xadj,adjncy,nnodes_elmnts,nodes_elmnts,elmnts_load)
 deallocate(tab_size_interfaces,tab_interfaces,my_interfaces,my_nb_interfaces)
 
 deallocate(mat_prop,mat_domain)
@@ -659,17 +659,17 @@
 deallocate(ibelm_xmin,nodes_ibelm_xmin)
 deallocate(ibelm_xmax,nodes_ibelm_xmax)
 deallocate(ibelm_ymin,nodes_ibelm_ymin)
-  
+
 write(*,'(a)',advance='yes')'finding interfaces...'
 call find_interface(nspec,nnodes,part+1,elmnts+1,npart) ! I need all indices starting from 1 not 0
 write(*,'(a)')'complete!'
-deallocate(elmnts,part)    
+deallocate(elmnts,part)
 write(*,'(a)',advance='yes')'writing interfaces...'
 call detect_ghost(out_phead,nspec,nnodes,npart,max_neighbour,glob2loc_elmnts(0:nspec-1)+1) ! I need all indices starting from 1 not 0
 write(*,'(a)')'complete!'
 deallocate(glob2loc_elmnts)
-    
-write(*,*)'number of partitions: ',npart     
+
+write(*,*)'number of partitions: ',npart
 !print*, 'finished successfully'
 !write(*,*)'-----------------------------------'
 end subroutine write_mesh_databases

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/plastic_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,5 +1,5 @@
 ! this module contains the routine for Mohr-Coulomb plasticity, Viscoplastic
-! algorithm, and strength reduction techniques 
+! algorithm, and strength reduction techniques
 ! REVISION
 !   HNG, Jul 07,2011; HNG, Apr 09,2010
 module plastic_library
@@ -7,7 +7,7 @@
 use math_constants
 
 contains
-! this function computes the stable pseudo-time step 
+! this function computes the stable pseudo-time step
 ! for viscoplastic algorithm (Cormeau 1975, Smith and Griffiths 2003)
 function dt_viscoplas(nmat,nuf,phif,ymf,ismat) result(dt_min)
 implicit none
@@ -54,9 +54,9 @@
 istat=0
 
 ! strength reduction
-if(srf/=one)then  
+if(srf/=one)then
   do i_mat=1,nmat
-    tnphi=tan(phi(i_mat)*deg2rad)      
+    tnphi=tan(phi(i_mat)*deg2rad)
     phif(i_mat)=atan(tnphi/srf)*rad2deg
     tnpsi=tan(psi(i_mat)*deg2rad)
     psif(i_mat)=atan(tnpsi/srf)*rad2deg
@@ -67,8 +67,8 @@
 if(.not.phinu)return
 ! correction for phi-nu inequality sin(phi)>=1-2*nu
 ! Reference: Zheng et al 2005, IJNME
-! currently only the Poisson's ratio is corrected 
-do i_mat=1,nmat  
+! currently only the Poisson's ratio is corrected
+do i_mat=1,nmat
   omtnu=one-two*nu(i_mat)
   snphif=sin(phif(i_mat)*deg2rad)
   if(snphif<omtnu)then
@@ -90,17 +90,17 @@
 
 ! this subroutine calculates the value of the yield function
 ! for a mohr-coulomb material (phi in degrees, theta in radians).
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 subroutine mohcouf(phi,c,sigm,dsbar,theta,f)
-implicit none 
-real(kind=kreal),intent(in)::phi,c,sigm,dsbar,theta   
+implicit none
+real(kind=kreal),intent(in)::phi,c,sigm,dsbar,theta
 real(kind=kreal),intent(out)::f
 real(kind=kreal)::phir,snph,csph,csth,snth,r3=3.0_kreal
 
 phir=phi*deg2rad
-snph=sin(phir) 
-csph=cos(phir) 
+snph=sin(phir)
+csph=cos(phir)
 csth=cos(theta)
 snth=sin(theta)
 f=snph*sigm+dsbar*(csth/sqrt(r3)-snth*snph/r3)-c*csph
@@ -109,27 +109,27 @@
 !=======================================================
 
 ! this subroutine forms the derivatives of a mohr-coulomb potential
-! function with respect to the three stress invariants 
+! function with respect to the three stress invariants
 ! (psi in degrees, theta in radians).
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 subroutine mohcouq(psi,dsbar,theta,dq1,dq2,dq3)
-implicit none 
+implicit none
  real(kind=kreal),intent(in)::psi,dsbar,theta
  real(kind=kreal),intent(out)::dq1,dq2,dq3
  real(kind=kreal)::psir,snth,snps,sq3,c1,csth,cs3th,tn3th,tnth,pt49=0.49_kreal,&
  pt5=0.5_kreal,r3=3.0_kreal
-   
- psir=psi*deg2rad 
- snth=sin(theta) 
+
+ psir=psi*deg2rad
+ snth=sin(theta)
  snps=sin(psir)
- sq3=sqrt(r3)  
+ sq3=sqrt(r3)
  dq1=snps
- 
+
  if(abs(snth).gt.pt49)then
    c1=one
    if(snth.lt.zero)c1=-one
-   dq2=(sq3*pt5-c1*snps*pt5/sq3)*sq3*pt5/dsbar 
+   dq2=(sq3*pt5-c1*snps*pt5/sq3)*sq3*pt5/dsbar
    dq3=zero
  else
    csth=cos(theta)
@@ -145,10 +145,10 @@
 
 ! this subroutine forms the derivatives of the invariants with respect to
 ! stress in 2- or 3-d.
-! this routine was copied and modified from 
+! this routine was copied and modified from
 ! Smith and Griffiths (2004): Programming the finite element method
 subroutine formm(stress,m1,m2,m3)
- implicit none 
+ implicit none
  real(kind=kreal),intent(in)::stress(:)
  real(kind=kreal),intent(out)::m1(:,:),m2(:,:),m3(:,:)
  real(kind=kreal)::sx,sy,txy,tyz,tzx,sz,dx,dy,dz,sigm,  &
@@ -159,7 +159,7 @@
  case(4)
    sx=stress(1); sy=stress(2); sz=stress(4)
    txy=stress(3)
-   
+
    dx=(two*sx-sy-sz)/r3; dy=(two*sy-sz-sx)/r3; dz=(two*sz-sx-sy)/r3
    sigm=(sx+sy+sz)/r3
    m1=zero; m2=zero; m3=zero
@@ -197,42 +197,42 @@
  case(6)
    sx=stress(1);  sy=stress(2);  sz=stress(3)
    txy=stress(4); tyz=stress(5); tzx=stress(6)
-   sigm=(sx+sy+sz)/r3   
+   sigm=(sx+sy+sz)/r3
    dx=sx-sigm; dy=sy-sigm; dz=sz-sigm
    m1=zero; m2=zero
    m1(1:3,1:3)=one/(r3*sigm)
-   do i=1,3 
-     m2(i,i)=two 
-     m2(i+3,i+3)=r6 
+   do i=1,3
+     m2(i,i)=two
+     m2(i+3,i+3)=r6
    end do
    m2(1,2)=-one
-   m2(1,3)=-one 
+   m2(1,3)=-one
    m2(2,3)=-one
    m3(1,1)=dx
-   m3(1,2)=dz 
-   m3(1,3)=dy 
-   m3(1,4)=txy  
+   m3(1,2)=dz
+   m3(1,3)=dy
+   m3(1,4)=txy
    m3(1,5)=-two*tyz
-   m3(1,6)=tzx 
-   m3(2,2)=dy 
-   m3(2,3)=dx 
+   m3(1,6)=tzx
+   m3(2,2)=dy
+   m3(2,3)=dx
    m3(2,4)=txy
-   m3(2,5)=tyz 
-   m3(2,6)=-two*tzx 
+   m3(2,5)=tyz
+   m3(2,6)=-two*tzx
    m3(3,3)=dz
    m3(3,4)=-two*txy
-   m3(3,5)=tyz 
+   m3(3,5)=tyz
    m3(3,6)=tzx
-   m3(4,4)=-r3*dz 
+   m3(4,4)=-r3*dz
    m3(4,5)=r3*tzx
    m3(4,6)=r3*tyz
    m3(5,5)=-r3*dx
-   m3(5,6)=r3*txy 
+   m3(5,6)=r3*txy
    m3(6,6)=-r3*dy
-   do i=1,6 
+   do i=1,6
      do j=i+1,6
-       m1(j,i)=m1(i,j) 
-       m2(j,i)=m2(i,j)   
+       m1(j,i)=m1(i,j)
+       m2(j,i)=m2(i,j)
        m3(j,i)=m3(i,j)
      end do
    end do
@@ -241,7 +241,7 @@
    write(*,*)"ERROR: nst size not recognized in formm!"
    stop
  end select
-return   
+return
 end subroutine formm
 !=======================================================
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/postprocess.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/postprocess.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/postprocess.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -13,9 +13,9 @@
 real(kind=kreal) :: z,szz
 integer :: i,i_elmt,num(nenod)
 
-do i_elmt=1,nelmt 
-  num=g_num(:,i_elmt)      
-  
+do i_elmt=1,nelmt
+  num=g_num(:,i_elmt)
+
   do i=1,ngll ! loop over integration points
     z=g_coord(3,num(i))
     szz=p0-gam(mat_id(i_elmt))*abs(z-z0) ! compression -
@@ -29,7 +29,7 @@
 !===========================================
 
 ! TODO: is it possible to compute stress_local only for intact elements just in case?
-! it seems that the subarray cannot be a receiving array 
+! it seems that the subarray cannot be a receiving array
 ! this subroutine computes elastic stress from the known displacement
 subroutine elastic_stress(nelmt,neq,gnod,g_num,gdof_elmt,mat_id,dshape_hex8,dlagrange_gll,x,stress_local)
 use global,only:ndim,nedof,nenod,ngnod,ngll,nst,g_coord,ym,nu
@@ -47,22 +47,22 @@
 integer :: egdof(nedof),num(nenod)
 integer :: i,i_elmt
 
-do i_elmt=1,nelmt      
+do i_elmt=1,nelmt
   call compute_cmat(cmat,ym(mat_id(i_elmt)),nu(mat_id(i_elmt)))
   num=g_num(:,i_elmt)
   coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
   egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) !g=g_g(:,i_elmt)
-  eld=x(egdof)         
-  
+  eld=x(egdof)
+
   do i=1,ngll ! loop over integration points
-    !call shape_derivative(der,gll_points(:,i)) 
-    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)        
+    !call shape_derivative(der,gll_points(:,i))
+    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)
     detjac=determinant(jac)
     call invert(jac)!
 
-    deriv=matmul(jac,dlagrange_gll(:,i,:)) 
+    deriv=matmul(jac,dlagrange_gll(:,i,:))
     call compute_bmat(bmat,deriv)
-    eps=matmul(bmat,eld)        
+    eps=matmul(bmat,eld)
     sigma=matmul(cmat,eps)
     stress_local(:,i,i_elmt)=sigma
   end do ! i GLL
@@ -90,23 +90,23 @@
 integer :: i,i_elmt,ielmt
 
 do i_elmt=1,nelmt_intact
-  ielmt=elmt_intact(i_elmt)      
+  ielmt=elmt_intact(i_elmt)
   call compute_cmat(cmat,ym(mat_id(i_elmt)),nu(mat_id(i_elmt)))
   num=g_num(:,i_elmt)
   coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
   egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) !g=g_g(:,i_elmt)
-  eld=x(egdof)         
+  eld=x(egdof)
   !print*,egdof
   !stop
   do i=1,ngll ! loop over integration points
-    !call shape_derivative(der,gll_points(:,i)) 
-    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)        
+    !call shape_derivative(der,gll_points(:,i))
+    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)
     detjac=determinant(jac)
     call invert(jac)!
 
-    deriv=matmul(jac,dlagrange_gll(:,i,:)) 
+    deriv=matmul(jac,dlagrange_gll(:,i,:))
     call compute_bmat(bmat,deriv)
-    eps=matmul(bmat,eld)        
+    eps=matmul(bmat,eld)
     sigma=matmul(cmat,eps)
     stress_local(:,i,ielmt)=stress_local(:,i,ielmt)+sigma
     !if(i_elmt==1.and.i==1)then
@@ -143,7 +143,7 @@
 if(savedata%psigma.or.savedata%nsigma.or.savedata%maxtau)then
   ! compute principal stresses
   psigma=zero
-  do i_node=1,nnode  
+  do i_node=1,nnode
     call stress_invariant(stress_global(:,i_node),sigm,dsbar,lode_theta)
     psigma(:,i_node)=sigm+two_third*dsbar* &
           sin((/ lode_theta-two_third*pi,lode_theta,lode_theta+two_third*pi /))
@@ -160,76 +160,76 @@
 !    scf=inftol
 !  elsewhere
 !      scf=psigma(1,:)/psigma0(1,:)
-!  end where 
+!  end where
 !endif
 
 if(savedata%maxtau)then
   ! compute maximum shear stress
   taumax=zero
-  do i_node=1,nnode  
-    taumax(i_node)=half*abs(psigma(1,i_node)-psigma(3,i_node))  
+  do i_node=1,nnode
+    taumax(i_node)=half*abs(psigma(1,i_node)-psigma(3,i_node))
   enddo
 endif
 
 if(savedata%nsigma)then
   ! compute normal stress
   nsigma=zero
-  do i_node=1,nnode   
+  do i_node=1,nnode
     nsigma(i_node)=half*(psigma(1,i_node)+psigma(3,i_node))
   enddo
 endif
 
 if(savedata%disp)then
-  ! write displacement vector  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.dis'  
+  ! write displacement vector
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.dis'
   npart=1;
   destag='Displacement field'
-  call write_ensight_pernode(out_fname,destag,npart,3,nnode,real(nodalu)) 
+  call write_ensight_pernode(out_fname,destag,npart,3,nnode,real(nodalu))
 endif
 
 if(savedata%stress)then
-  ! write stress tensor  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.sig'  
+  ! write stress tensor
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.sig'
   npart=1;
   destag='Effective stress tensor'
   call write_ensight_pernode(out_fname,destag,npart,6,nnode,real(stress_global))
-endif  
+endif
 
 if(savedata%psigma)then
   ! write principal stress
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.psig'  
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.psig'
   npart=1;
   destag='principal stresses'
   call write_ensight_pernode(out_fname,destag,npart,3,nnode,real(psigma))
 endif
 
 if(savedata%scf)then
-  ! write stress concentration factor  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.scf'    
+  ! write stress concentration factor
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.scf'
   npart=1;
   destag='principal stress concentration factor'
   call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(scf))
 endif
-  
+
 if(savedata%maxtau)then
-  ! write maximum shear stress  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.mtau'    
+  ! write maximum shear stress
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.mtau'
   npart=1;
   destag='maximum shear stress'
   call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(taumax))
-endif    
+endif
 
 if(savedata%nsigma)then
-  ! write normal stress on maximum-shear-stress plane  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.nsig'    
+  ! write normal stress on maximum-shear-stress plane
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.nsig'
   npart=1;
   destag='normal stress'
   call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(nsigma))
 endif
 
-if(savedata%vmeps)then  
-  ! write accumulated effective plastic strain  
-  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.eps'    
+if(savedata%vmeps)then
+  ! write accumulated effective plastic strain
+  write(out_fname,fmt=format_str)trim(out_path)//trim(file_head)//'_step',istep,trim(ptail)//'.eps'
   npart=1;
   destag='von Mises effective plastic strain'
   call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(vmeps))

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/preprocess.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -7,7 +7,7 @@
 ! this subroutine computes B matrix
 subroutine compute_bmat(bmat,deriv)
  use set_precision
- implicit none 
+ implicit none
  real(kind=kreal),intent(in)::deriv(:,:)
  real(kind=kreal),intent(out)::bmat(:,:)
 end subroutine compute_bmat
@@ -15,10 +15,10 @@
 ! this subroutine computes C matrix (elasticity matrix)
 subroutine compute_cmat(cmat,e,v)
  use set_precision
- implicit none 
+ implicit none
  real(kind=kreal),intent(in)::e,v
  real(kind=kreal),intent(out)::cmat(:,:)
-end subroutine compute_cmat 
+end subroutine compute_cmat
 end interface
 
 contains
@@ -53,8 +53,8 @@
 
 ! compute stiffness matrices
 storkm=zero; dprecon=zero
-!----element stiffness integration, storage and preconditioner---- 
-do i_elmt=1,nelmt  
+!----element stiffness integration, storage and preconditioner----
+do i_elmt=1,nelmt
   call compute_cmat(cmat,ym(mat_id(i_elmt)),nu(mat_id(i_elmt)))
   num=g_num(:,i_elmt)
   coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
@@ -64,27 +64,27 @@
   do i=1,ngll
     !call shape_function(fun,gll_points(i))
     ! compute Jacobian at GLL point using 20 noded element
-    !call shape_derivative(der,gll_points(:,i)) 
-    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord) 
-    detjac=determinant(jac) 
+    !call shape_derivative(der,gll_points(:,i))
+    jac=matmul(dshape_hex8(:,:,i),coord) !jac=matmul(der,coord)
+    detjac=determinant(jac)
     call invert(jac)
-    
+
     deriv=matmul(jac,dlagrange_gll(:,i,:)) ! use der for gll
-    call compute_bmat(bmat,deriv) !!! gll bmat matrix          
+    call compute_bmat(bmat,deriv) !!! gll bmat matrix
     km=km+matmul(matmul(transpose(bmat),cmat),bmat)*detjac*gll_weights(i)
     eld(3:nedof:3)=eld(3:nedof:3)+lagrange_gll(i,:)*detjac*gll_weights(i)
     !eld(2:nedof-1:3)=eld(2:nedof-1:3)+fun(:)*detjac*weights(i)
-  end do ! i=1,ngll  
+  end do ! i=1,ngll
   storkm(:,:,i_elmt)=km
   do k=1,nedof
     dprecon(egdof(k))=dprecon(egdof(k))+km(k,k)
-  end do  
-  
+  end do
+
   if(.not.present(extload))cycle
   ! compute body loads
   ! gravity load and add to extload
   if(gravity)extload(egdof)=extload(egdof)-eld*gam(mat_id(i_elmt))
-  if(pseudoeq)then  
+  if(pseudoeq)then
     ! compute pseudostatic earthquake loads and add to extload
     eqload(1:nedof:3)=eqkx*eld(3:nedof:3)
     eqload(2:nedof:3)=eqky*eld(3:nedof:3)

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/read_input.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -50,7 +50,7 @@
 else
   ptail=""
 endif
-   
+
 ! reading main input information
 if(myid==1)write(*,'(a)',advance='no')'reading main input file...'
 preinfo_stat=-1
@@ -120,8 +120,8 @@
   read(11,'(a)',iostat=ios)line ! This will read a line and proceed to next line
   if (ios/=0)exit
   ! check for blank and comment line
-  if (isblank(line) .or. iscomment(line,'#'))cycle 
-   
+  if (isblank(line) .or. iscomment(line,'#'))cycle
+
   ! look for line continuation
   tag=trim(line)
   call last_char(line,tmp_char,ind)
@@ -129,7 +129,7 @@
     slen=len(line)
     tag=trim(line(1:ind-1))
     read(11,'(a)',iostat=ios)line ! This will read a line and proceed to next line
-    tag=trim(tag)//trim(line)         
+    tag=trim(tag)//trim(line)
   endif
   call first_token(tag,token)
 
@@ -158,7 +158,7 @@
       ngllx=get_integer('ngllx',args,narg);
       nglly=get_integer('nglly',args,narg);
       ngllz=get_integer('ngllz',args,narg);
-      ngll=ngllx*nglly*ngllz ! total GLL points 
+      ngll=ngllx*nglly*ngllz ! total GLL points
     endif
     nenod=get_integer('nenod',args,narg);
     ! number of elemental degrees of freedom
@@ -187,8 +187,8 @@
     slen=len_trim(out_path)
     if(out_path(slen:slen)/='/')out_path=trim(out_path)//'/'
 
-    preinfo_stat=1      
-    cycle      
+    preinfo_stat=1
+    cycle
   endif
   ! read mesh information
   if (trim(token)=='mesh:')then
@@ -201,14 +201,14 @@
     coordfile(2)=get_string('yfile',args,narg)
     coordfile(3)=get_string('zfile',args,narg)
     confile=get_string('confile',args,narg)
-    idfile=get_string('idfile',args,narg)    
-    if(ismpi)gfile=get_string('gfile',args,narg)   
-    !nmat=get_integer('nmat',args,narg)  
-   
-    mesh_stat=1      
-    cycle      
+    idfile=get_string('idfile',args,narg)
+    if(ismpi)gfile=get_string('gfile',args,narg)
+    !nmat=get_integer('nmat',args,narg)
+
+    mesh_stat=1
+    cycle
   endif
-  
+
   ! read bc information
   if (trim(token)=='bc:')then
     if(bc_stat==1)then
@@ -221,9 +221,9 @@
     uzfile=get_string('uzfile',args,narg)
 
     bc_stat=1
-    cycle      
+    cycle
   endif
-  
+
   ! read initial stress information
   if (trim(token)=='stress0:')then
     if(stress0_stat==1)then
@@ -243,9 +243,9 @@
     call seek_integer('usek0',ival,args,narg,istat)
     if(istat==0)usek0=.true.
     stress0_stat=1
-    cycle      
+    cycle
   endif
-  
+
   ! read traction information
   if (trim(token)=='traction:')then
     if(traction_stat==1)then
@@ -257,9 +257,9 @@
     traction_stat=1
     istraction=.true.
     !print*,trfile
-    cycle      
+    cycle
   endif
-  
+
   ! read material list
   if (trim(token)=='material:')then
     if(material_stat==1)then
@@ -278,7 +278,7 @@
     if(mat_path(slen:slen)/='/')mat_path=trim(mat_path)//'/'
     matfile=get_string('matfile',args,narg)
     call seek_integer('allelastic',iselastic,args,narg,istat)
-    if(istat==0 .and. iselastic==1)allelastic=.true.    
+    if(istat==0 .and. iselastic==1)allelastic=.true.
     !print*,matfile
     !mat_count=mat_count+1
     !id=get_integer('id',args,narg)
@@ -287,12 +287,12 @@
     !nu(id)=get_real('nu',args,narg)
     !phi(id)=get_real('phi',args,narg)
     !coh(id)=get_real('coh',args,narg)
-    !psi(id)=get_real('psi',args,narg)                
-                
+    !psi(id)=get_real('psi',args,narg)
+
     material_stat=1
-    cycle      
+    cycle
   endif
-  
+
   ! read earthquake loading information
   if (trim(token)=='eqload:')then
     if(eqload_stat==1)then
@@ -305,9 +305,9 @@
     eqkz=get_real('eqkz',args,narg)
     eqload_stat=1
     iseqload=.true.
-    cycle      
+    cycle
   endif
-  
+
   ! read water surface information
   if (trim(token)=='water:')then
     if(water_stat==1)then
@@ -318,7 +318,7 @@
     wsfile=get_string('wsfile',args,narg)
     water_stat=1
     iswater=.true.
-    cycle      
+    cycle
   endif
 
   ! read control information
@@ -327,7 +327,7 @@
       write(errtag,*)'ERROR: copy of line type control: not permitted!'
       return
     endif
-    call split_string(tag,',',args,narg)    
+    call split_string(tag,',',args,narg)
     !cg_tol=get_real('cg_tol',args,narg)
     !cg_maxiter=get_integer('cg_maxiter',args,narg)
     !nl_tol=get_real('nl_tol',args,narg)
@@ -366,7 +366,7 @@
       if(istat==0)nexcavid=ivect
       deallocate(ivect)
       nexcavid_all=sum(nexcavid)
-      allocate(excavid(nexcavid_all))    
+      allocate(excavid(nexcavid_all))
       excavid=get_integer_vect('excavid',nexcavid_all,args,narg)
     endif
     if(nsrf>1 .and. nexcav>1)then
@@ -374,15 +374,15 @@
       return
     endif
     !---------------------------
-     
+
     call seek_integer('ninc',ival,args,narg,istat)
     if(istat==0)ninc=ival
     call seek_integer('phinu',ival,args,narg,istat)
     if(istat==0.and.ival==1)phinu=.true.
     control_stat=1
-    cycle      
+    cycle
   endif
-  
+
   ! read save options
   if (trim(token)=='save:')then
     if(save_stat==1)then
@@ -390,12 +390,12 @@
       return
     endif
     save_stat=-1
-    call split_string(tag,',',args,narg)    
+    call split_string(tag,',',args,narg)
     call seek_integer('disp',issave,args,narg,istat)
     if(istat==0 .and. issave==1)savedata%disp=.true.
     call seek_integer('stress',issave,args,narg,istat)
     if(istat==0 .and. issave==1)savedata%stress=.true.
-    call seek_integer('porep',issave,args,narg,istat)    
+    call seek_integer('porep',issave,args,narg,istat)
     if(istat==0 .and. issave==1)savedata%porep=.true.
     call seek_integer('psigma',issave,args,narg,istat)
     if(istat==0 .and. issave==1)savedata%psigma=.true.
@@ -404,16 +404,16 @@
     call seek_integer('scf',issave,args,narg,istat)
     if(istat==0 .and. issave==1)savedata%scf=.true.
     call seek_integer('vmeps',issave,args,narg,istat)
-    if(istat==0 .and. issave==1)savedata%vmeps=.true.     
-                
+    if(istat==0 .and. issave==1)savedata%vmeps=.true.
+
     save_stat=1
-    cycle      
+    cycle
   endif
-  
+
   write(errtag,'(a)')'ERROR: invalid line type: "'//trim(token)//'"!'
   return
-  
- 
+
+
 enddo ! do
 if(.not.iswater)savedata%porep=.false.
 ! check for material list
@@ -487,11 +487,11 @@
   endif
   if(ismpi)then
     do i_node=1,nnode
-      read(11,*)inode,g_coord(i,inode)    
+      read(11,*)inode,g_coord(i,inode)
     enddo
   else
     do i_node=1,nnode
-      read(11,*)g_coord(i,i_node)    
+      read(11,*)g_coord(i,i_node)
     enddo
   endif
 enddo
@@ -579,7 +579,7 @@
 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 
+endif
 water=.false.
 if(iswater)then
   read(11,*,iostat=ios)nwmat

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/scotchf.h
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/scotchf.h	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/scotchf.h	2011-09-09 12:18:10 UTC (rev 18889)
@@ -8,13 +8,13 @@
 ! ** use, modify and/or redistribute the software under the terms of the
 ! ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
 ! ** URL: "http://www.cecill.info".
-! ** 
+! **
 ! ** As a counterpart to the access to the source code and rights to copy,
 ! ** modify and redistribute granted by the license, users are provided
 ! ** only with a limited warranty and the software's author, the holder of
 ! ** the economic rights, and the successive licensors have only limited
 ! ** liability.
-! ** 
+! **
 ! ** In this respect, the user's attention is drawn to the risks associated
 ! ** with loading, using, modifying and/or developing or reproducing the
 ! ** software by the user in light of its specific status of free software,
@@ -25,7 +25,7 @@
 ! ** their requirements in conditions enabling the security of their
 ! ** systems and/or data to be ensured and, more generally, to use and
 ! ** operate it in the same conditions as regards security.
-! ** 
+! **
 ! ** The fact that you are presently reading this means that you have had
 ! ** knowledge of the CeCILL-C license and that you accept its terms.
 ! **

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semexcav3d.F90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semexcav3d.F90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semexcav3d.F90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -166,7 +166,7 @@
 ! this removes the repeated use of reshape later but it has larger size than gdof!!!
 allocate(gdof_elmt(nedof,nelmt))
 gdof_elmt=0
-do i_elmt=1,nelmt 
+do i_elmt=1,nelmt
   gdof_elmt(:,i_elmt)=reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) !g=g_g(:,i_elmt)
 enddo
 !-------------------------------
@@ -186,7 +186,7 @@
 
 if(s0_type==0)then
   ! compute initial stress using SEM itself
-  
+
   allocate(extload(0:neq),x(0:neq),dprecon(0:neq),storkm(nedof,nedof,          &
   nelmt_intact),stat=istat) ! elastic(0:neq),
   if (istat/=0)then
@@ -209,7 +209,7 @@
   ! apply traction boundary conditions
   if(istraction)then
     if(myid==1)write(*,'(a)',advance='no')'applying traction...'
-    call apply_traction(ismpi,myid,nproc,gnod,gdof,neq,extload,errcode,errtag)  
+    call apply_traction(ismpi,myid,nproc,gnod,gdof,neq,extload,errcode,errtag)
     if(errcode/=0)call error_stop(errtag,stdout,myid)
     if(myid==1)write(*,*)'complete!'
   endif
@@ -218,15 +218,15 @@
   ! compute water pressure
   if(iswater)then
     if(myid==1)write(stdout,'(a)',advance='no')'computing water pressure...'
-    allocate(wpressure(nnode),submerged_node(nnode))  
+    allocate(wpressure(nnode),submerged_node(nnode))
     call compute_pressure(ismpi,myid,nproc,wpressure,submerged_node,errcode,   &
     errtag)
     if(errcode/=0)call error_stop(errtag,stdout,myid)
     ! write pore pressure file
-  
+
     ! open Ensight Gold data file to store data
-    out_fname=trim(out_path)//trim(file_head)//trim(ptail)//'.por'    
-    npart=1;  
+    out_fname=trim(out_path)//trim(file_head)//trim(ptail)//'.por'
+    npart=1;
     destag='Pore pressure'
     call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(wpressure))
     if(myid==1)write(stdout,*)'complete!'
@@ -258,7 +258,7 @@
 elseif(s0_type==1)then
   ! compute initial stress using simple relation for overburden pressure
   call overburden_stress(nelmt,g_num,mat_id,z_datum,s0_datum,epk0,stress_local)
-else  
+else
   write(stdout,*)'ERROR: s0_type:',s0_type,' not supported!'
   stop
 endif
@@ -313,15 +313,15 @@
 ! excavation-stage loop
 nodalu=zero
 excavation_stage: do i_excav=0,nexcav
-  
+
   vmeps=zero; scf=inftol
   if(i_excav>0)then
   !deallocate(load,bodyload,oldx,extload,x,dprecon,stat=istat)
   if(myid==1)write(stdout,'(/,a,i4)')'excavation stage:',i_excav
-  
+
   ! find appropriate indices in excavid
   id0=(i_excav-1)*nexcavid(i_excav)+1; id1=id0+nexcavid(i_excav)-1
-  
+
   ! disable excavated material id
   ismat(excavid(id0:id1))=off !ismat(excavid(i_excav))=off
   !print*,id0,id1
@@ -338,18 +338,18 @@
     exit excavation_stage
   endif
   allocate(elmt_intact(nelmt_intact),elmt_void(nelmt_void))
-  ! find intact and void elements after excavation  
+  ! find intact and void elements after excavation
   call intact_void_elmt(nexcavid(i_excav),excavid(id0:id1),ismat,nelmt_intact, &
-  nelmt_void,elmt_intact,elmt_void,isnode)   
-   
+  nelmt_void,elmt_intact,elmt_void,isnode)
+
   ! count intact and void nodes after excavation
   nnode_intact=count(isnode)
   nnode_void=nnode-nnode_intact
   allocate(node_intact(nnode_intact),node_void(nnode_void))
   ! find intact and void nodes after excavation
   call intact_void_node(isnode,nnode_intact,nnode_void,node_intact,node_void,  &
-  nmir)   
-  
+  nmir)
+
   tot_nelmt=sumscal(nelmt_intact); tot_nnode=sumscal(nnode_intact)
   max_nelmt=maxscal(nelmt_intact); max_nnode=maxscal(nnode_intact)
   min_nelmt=minscal(nelmt_intact); min_nnode=minscal(nnode_intact)
@@ -360,32 +360,32 @@
 
   !write(stdout,'(a,i10)')' total intact nodes:',nnode_intact
   !write(stdout,'(a,i10)')' total intact elements:',nelmt_intact
-  
+
   ! correct node valency subtracting dead element-nodes
   call correct_nvalency(node_valency,nelmt_void,g_num(:,elmt_void))
-  
+
   ! modify global-degrees-of-freedom (gdof)
   call modify_gdof(gdof,nnode_void,node_void,neq)
-  
+
   tot_neq=sumscal(neq); max_neq=maxscal(neq); min_neq=minscal(neq)
   if(myid==1)then
     write(stdout,*)'degrees of freedoms => total:',tot_neq,' max:',max_neq,' min:',min_neq
   endif
   !write(stdout,'(a,i10)')' total degrees of freedoms:',neq
-   
+
   ! store elemental global degrees of freedoms from nodal gdof
   ! this removes the repeated use of reshape later but it has larger size than gdof!!!
   gdof_elmt=0
   do i_elmt=1,nelmt
     gdof_elmt(:,i_elmt)=reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) !g=g_g(:,i_elmt)
   enddo
-  
+
   ! write geo file for this stage
   ! open Ensight Gold geo file to store mesh data
   write(geo_file,fmt=format_str)trim(out_path)//trim(file_head)//'_step',i_excav,trim(ptail)//'.geo'
   npart=1
   destag='unstructured meshes'
-  call write_ensight_geocoord(geo_file,destag,npart,nnode_intact,real(g_coord(:,node_intact)),funit) 
+  call write_ensight_geocoord(geo_file,destag,npart,nnode_intact,real(g_coord(:,node_intact)),funit)
 
   ! writes element information
   buffer=ensight_etype
@@ -416,38 +416,38 @@
       enddo
     enddo
   enddo
-  close(funit)  
-  
-  ! reallocate those arrays whose size depend on the neq  
+  close(funit)
+
+  ! reallocate those arrays whose size depend on the neq
   allocate(load(0:neq),bodyload(0:neq),extload(0:neq),oldx(0:neq),x(0:neq), & !,extload1(0:neq)
   dprecon(0:neq),storkm(nedof,nedof,nelmt_intact),stat=istat) ! elastic(0:neq),
   if (istat/=0)then
     write(stdout,*)'ERROR: cannot allocate memory!'
     stop
   endif
-  
-  ! modify ghost partitions after excavation 
+
+  ! modify ghost partitions after excavation
   !call prepare_ghost(myid,nproc,gdof,ngpart,maxngnode)
   call modify_ghost(myid,nproc,gdof,ngpart,isnode)
   call count_active_nghosts(myid,ngpart,maxngnode,nndof,ngpart_node)
- 
+
   excavload=zero; extload=zero; ! extload1=zero
-  
+
   ! compute excavation load at gdofs
   !call excavation_load(nelmt_void,neq,gnod,g_num(:,elmt_void),gdof_elmt(:,elmt_void), &
   !mat_id(elmt_void),dshape_hex8,lagrange_gll,dlagrange_gll,gll_weights, &
   !stress_local(:,:,elmt_void),extload)
-  
+
   ! compute excavation load at nodes
   call excavation_load_nodal(nelmt_void,neq,gnod,g_num(:,elmt_void), &
   mat_id(elmt_void),dshape_hex8,lagrange_gll,dlagrange_gll,gll_weights, &
   stress_local(:,:,elmt_void),excavload)
-    
-  ! if the excavation load is discarded by the partition (it can happens due to 
-  ! the special combination of partition geometry and excavation geoemtry) it 
+
+  ! if the excavation load is discarded by the partition (it can happens due to
+  ! the special combination of partition geometry and excavation geoemtry) it
   ! should be distributed equally to the active sharing partitions.
   call distribute2ghosts(myid,gdof,ngpart,maxngnode,nndof,neq,ngpart_node,excavload,extload)
-!#else 
+!#else
 !  ! store nodal values to gdof locations
 !  do j=1,nnode
 !    do i=1,nndof
@@ -462,57 +462,57 @@
   ! strength reduction
   call strength_reduction(srf(i_srf),phinu,nmat,coh,nu,phi,psi,cohf,nuf,phif,  &
   psif,istat)
-  
+
   ! compute minimum pseudo-time step for viscoplasticity
   dt=dt_viscoplas(nmat,nuf,phif,ym,ismat)
-  
+
   ! compute stiffness matrix
   gravity=.false.; pseudoeq=.false.
   call stiffness_bodyload(nelmt_intact,neq,gnod,g_num(:,elmt_intact),          &
   gdof_elmt(:,elmt_intact),mat_id(elmt_intact),gam,nuf,ym,dshape_hex8,         &
   lagrange_gll,dlagrange_gll,gll_weights,storkm,dprecon)!,extload,gravity,pseudoeq)
-   
+
   ! assemble from ghost partitions
   call assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,dprecon,dprecon)
   dprecon(0)=zero; dprecon(1:)=one/dprecon(1:)
-  
+
   ! find global dt
-  dt=minscal(dt) 
-  
+  dt=minscal(dt)
+
   cg_tot=0; nl_tot=0
   ! load incremental loop
   if(myid==1)write(stdout,'(a,i10)')' total load increments:',ninc
   extload=extload/ninc
   load_increment: do i_inc=1,ninc
   !stress_local(:,:,elmt_void)=zero
-  
-  bodyload=zero; evpt=zero  
-  
+
+  bodyload=zero; evpt=zero
+
   x=zero; oldx=zero
   ! plastic iteration loop
-  plastic: do nl_iter=1,nl_maxiter  
+  plastic: do nl_iter=1,nl_maxiter
     fmax=zero
-    
-    load=extload+bodyload    
-    load(0)=zero      
-    
+
+    load=extload+bodyload
+    load(0)=zero
+
     ! pcg solver
     !x=zero
     call pcg_solver(myid,ngpart,maxngnode,neq,nelmt_intact,storkm,x,load,      &
     dprecon,gdof_elmt(:,elmt_intact),cg_iter,errcode,errtag)
     if(errcode/=0)call error_stop(errtag,stdout,myid)
-    cg_tot=cg_tot+cg_iter    
+    cg_tot=cg_tot+cg_iter
     x(0)=zero
-    
+
     if(allelastic)then
       !print*,size(stress_local)
       call elastic_stress_intact(nelmt_intact,neq,gnod,elmt_intact,            &
       g_num(:,elmt_intact),gdof_elmt(:,elmt_intact),mat_id(elmt_intact),       &
-      dshape_hex8,dlagrange_gll,x,stress_local(:,:,:))      
-            
+      dshape_hex8,dlagrange_gll,x,stress_local(:,:,:))
+
       exit plastic
     endif
-    
+
     ! check plastic convergence
     uerr=maxvec(abs(x-oldx))/maxvec(abs(x))
     oldx=x
@@ -523,7 +523,7 @@
       ielmt=elmt_intact(i_elmt)
 
       imat=mat_id(ielmt)
-      !tnph=tan(phi(mat_id(ielmt))*pi/r180)      
+      !tnph=tan(phi(mat_id(ielmt))*pi/r180)
       !phif=atan(tnph/srf(i_srf))*r180/pi
       !tnps=tan(psi(mat_id(ielmt))*pi/r180)
       !psif=atan(tnps/srf(i_srf))*r180/pi
@@ -532,16 +532,16 @@
       num=g_num(:,ielmt)
       coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
       egdof=gdof_elmt(:,ielmt) !reshape(gdof(:,g_num(:,ielmt)),(/nedof/))
-      eld=x(egdof)  
+      eld=x(egdof)
       !print*,egdof
-      !stop       
+      !stop
       bload=zero
       do i=1,ngll ! loop over integration points
-        jac=matmul(dshape_hex8(:,:,i),coord)        
+        jac=matmul(dshape_hex8(:,:,i),coord)
         detjac=determinant(jac)
         call invert(jac)
 
-        deriv=matmul(jac,dlagrange_gll(:,i,:)) 
+        deriv=matmul(jac,dlagrange_gll(:,i,:))
         call compute_bmat(bmat,deriv)
         eps=matmul(bmat,eld)
         eps=eps-evpt(:,i,ielmt)
@@ -561,17 +561,17 @@
         ! check whether yield is violated
         call mohcouf(phif(imat),cohf(imat),sigm,dsbar,lode_theta,f)
         if(f>fmax)fmax=f
-        
+
         if(f>=zero)then !.or.(nl_isconv.or.nl_iter==nl_maxiter))then
           call mohcouq(psif(imat),dsbar,lode_theta,dq1,dq2,dq3)
           call formm(effsigma,m1,m2,m3)
           !if(dsbar<=zerotol)print*,m1*dq1+m2*dq2+m3*dq3
-          flow=f*(m1*dq1+m2*dq2+m3*dq3) 
-          
+          flow=f*(m1*dq1+m2*dq2+m3*dq3)
+
           erate=matmul(flow,effsigma)
           evp=erate*dt
           evpt(:,i,ielmt)=evpt(:,i,ielmt)+evp
-          devp=matmul(cmat,evp)          
+          devp=matmul(cmat,evp)
           ! if not converged we need body load for next iteration
           if(.not.nl_isconv .and. nl_iter/=nl_maxiter)then
             !devp(1:3)=devp(1:3)-wpressure(num(i))
@@ -597,10 +597,10 @@
         !  stop
         !endif
       end do ! i_gll
-      
+
       if(nl_isconv .or. nl_iter==nl_maxiter)cycle
       ! compute total body load vector
-      bodyload(egdof)=bodyload(egdof)+bload      
+      bodyload(egdof)=bodyload(egdof)+bload
     end do ! i_elmt
     bodyload(0)=zero
     fmax=maxscal(fmax)
@@ -614,12 +614,12 @@
     if(nl_isconv.or.nl_iter==nl_maxiter)exit
   end do plastic ! plastic iteration
   if(nl_iter>=nl_maxiter .and. .not.nl_isconv)then
-    write(stdout,*)'WARNING: nonconvergence in nonlinear iterations!' 
-    write(stdout,*)'desired tolerance:',nl_tol,' achieved tolerance:',uerr  
+    write(stdout,*)'WARNING: nonconvergence in nonlinear iterations!'
+    write(stdout,*)'desired tolerance:',nl_tol,' achieved tolerance:',uerr
   endif
   nl_tot=nl_tot+nl_iter
   !if(myid==1)print*,cg_tot,nl_tot
-  ! nodal displacement  
+  ! nodal displacement
   do i=1,nndof
     do j=1,nnode
       if(gdof(i,j)/=0)then
@@ -632,30 +632,30 @@
   if (istat/=0)then
     write(stdout,*)'ERROR: cannot deallocate memory!'
     stop
-  endif   
-  
+  endif
+
   ! write summary
   uxmax=maxvec(abs(reshape(nodalu(:,node_intact),(/nndof*nnode_intact/))))
   umax=maxvec(sqrt(nodalu(1,node_intact)*nodalu(1,node_intact)+ &
   nodalu(2,node_intact)*nodalu(2,node_intact)+nodalu(3,node_intact)*           &
   nodalu(3,node_intact)))
-  open(10,file=trim(sum_file),status='old',position='append',action='write')  
+  open(10,file=trim(sum_file),status='old',position='append',action='write')
   write(10,*)i_excav,cg_tot,nl_tot,uxmax,umax,fmax
   close(10)
-  
+
   ! compute average effective strain
   do i_node=1,nnode_intact
     inode=node_intact(i_node)
     vmeps(inode)=vmeps(inode)/real(node_valency(inode),kreal)
   enddo
-  
-  endif ! if(i_excav>0)  
-  
+
+  endif ! if(i_excav>0)
+
   ! compute stress_global
-  stress_global=zero  
+  stress_global=zero
   do i_elmt=1,nelmt_intact
     ielmt=elmt_intact(i_elmt)
-    num=g_num(:,ielmt)    
+    num=g_num(:,ielmt)
     stress_global(:,num)=stress_global(:,num)+stress_local(:,:,ielmt)
   enddo
 
@@ -665,20 +665,20 @@
     stress_global(:,inode)=stress_global(:,inode)/real(node_valency(inode),    &
     kreal)
   enddo
-  
+
   call save_data(ptail,format_str,i_excav,nnode_intact,nelmt_intact,           &
   g_num(:,elmt_intact),nodalu(:,node_intact),scf(node_intact),                 &
   vmeps(node_intact),stress_global(:,node_intact))
-  
+
   ! deallocate those variables whose size depend on changing geometry
-  deallocate(elmt_intact,node_intact,stat=istat) 
-  if(i_excav>0)deallocate(elmt_void,node_void)  
-  
+  deallocate(elmt_intact,node_intact,stat=istat)
+  if(i_excav>0)deallocate(elmt_void,node_void)
+
   !call sync_process
   if(nl_iter==nl_maxiter)exit
-  
+
 enddo excavation_stage ! i_excav time stepping loop
-enddo srf_loop ! i_srf safety factor loop 
+enddo srf_loop ! i_srf safety factor loop
 deallocate(mat_id,gam,ym,coh,nu,phi,psi,srf)
 deallocate(excavload,g_coord,g_num,isnode,nmir)
 call free_ghost(ngpart)

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semgeotech.F90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semgeotech.F90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semgeotech.F90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -41,7 +41,7 @@
 integer :: errcode
 logical :: isopen ! flag to check whether the file is opened
 
-myid=1; nproc=1; 
+myid=1; nproc=1;
 errtag=""; errcode=-1
 
 call start_process(ismpi,myid,nproc,stdout)
@@ -49,8 +49,8 @@
 
 call get_command_argument(0, prog)
 !----input and initialisation----
-if (command_argument_count() <= 0) then  
-  call error_stop('ERROR: no input file!',stdout,myid)    
+if (command_argument_count() <= 0) then
+  call error_stop('ERROR: no input file!',stdout,myid)
 endif
 
 call get_command_argument(1, arg1)
@@ -62,14 +62,14 @@
     write(stdout,'(a)')'    --version     : Display version information.'
   endif
   !call sync_process
-  call close_process()  
-elseif(trim(arg1)==('--version'))then  
+  call close_process()
+elseif(trim(arg1)==('--version'))then
   if(myid==1)then
     write(stdout,'(a)')'SPECFEM3D_GEOTECH 1.0 Beta'
     write(stdout,'(a)')'This is free software; see the source for copying '
     write(stdout,'(a)')'conditions.  There is NO warranty; not even for '
     write(stdout,'(a)')'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'
-  endif 
+  endif
   !call sync_process
   call close_process()
 endif
@@ -94,8 +94,8 @@
 endif
 
 if (trim(method)/='sem')then
-  write(errtag,'(a)')'ERROR: wrong input for sem3d!' 
-  call error_stop(errtag,stdout,myid)  
+  write(errtag,'(a)')'ERROR: wrong input for sem3d!'
+  call error_stop(errtag,stdout,myid)
 endif
 
 call parse_file(inp_fname,path,file_head,ext)
@@ -121,7 +121,7 @@
 
 open(unit=11,file=trim(case_file),status='replace',action='write',iostat = ios)
 if( ios /= 0 ) then
-  write(errtag,'(a)')'ERROR: file "'//trim(case_file)//'" cannot be opened!'  
+  write(errtag,'(a)')'ERROR: file "'//trim(case_file)//'" cannot be opened!'
   call error_stop(errtag,stdout,myid)
 endif
 
@@ -166,14 +166,14 @@
 
 ! geometrical nodes (corner nodes) in EXODUS/CUBIT order
 ! bottom nodes
-gnod(1)=1;      
+gnod(1)=1;
 gnod(2)=ngllx
-gnod(3)=ngllxy; 
+gnod(3)=ngllxy;
 gnod(4)=gnod(3)-ngllx+1
 ! top nodes
-gnod(5)=(ngllz-1)*ngllxy+1; 
+gnod(5)=(ngllz-1)*ngllxy+1;
 gnod(6)=gnod(5)+ngllx-1
-gnod(7)=ngll;               
+gnod(7)=ngll;
 gnod(8)=gnod(7)-ngllx+1
 
 ! map sequential node numbering to exodus/cubit order for 8-noded hexahedra
@@ -210,7 +210,7 @@
 if(savedata%stress)then
   write(11,'(a,i10,a,a,a,a,/)')'tensor symm per node: ',ts,' ','stress',' ',   &
   trim(file_head)//'_step'//wild_char(1:twidth)//trim(ptail)//'.sig'
-endif  
+endif
 if(savedata%psigma)then
   write(11,'(a,i10,a,a,a,a,/)')'vector per node: ',ts,' ','principal_stress',' ', &
   trim(file_head)//'_step'//wild_char(1:twidth)//trim(ptail)//'.psig'
@@ -291,7 +291,7 @@
         node_hex8(7)=node_hex8(5)+ngllx
         node_hex8(8)=node_hex8(7)+1
         ! map to exodus/cubit numbering and write
-        write(funit)g_num(node_hex8(map2exodus),i_elmt) 
+        write(funit)g_num(node_hex8(map2exodus),i_elmt)
       enddo
     enddo
   enddo
@@ -324,7 +324,7 @@
 max_telap=maxscal(telap)
 mean_telap=sumscal(telap)/real(nproc,kreal)
 
-write(format_str,*)ceiling(log10(real(max_telap)+1.))+5 ! 1 . and 4 decimals 
+write(format_str,*)ceiling(log10(real(max_telap)+1.))+5 ! 1 . and 4 decimals
 format_str='(3(f'//trim(adjustl(format_str))//'.4,1X))'
 open(10,file=trim(sum_file),status='old',position='append',action='write')
 write(10,*)'ELAPSED TIME, MAX ELAPSED TIME, MEAN ELAPSED TIME'

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semslope3d.F90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semslope3d.F90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/semslope3d.F90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -37,7 +37,7 @@
 integer :: funit,i,ios,istat,j,k,neq
 integer :: i_elmt,i_node,i_inc,i_srf,ielmt,igdof,imat,inode
 !real(kind=kreal),parameter :: two_third=two/r3
-real(kind=kreal) :: detjac,dq1,dq2,dq3,dsbar,dt,f,fmax,h1,h2,lode_theta,sf,sigm 
+real(kind=kreal) :: detjac,dq1,dq2,dq3,dsbar,dt,f,fmax,h1,h2,lode_theta,sf,sigm
 
 real(kind=kreal) :: uerr,umax,uxmax
 integer :: cg_iter,cg_tot,nl_iter,nl_tot
@@ -88,7 +88,7 @@
 integer :: tot_neq,max_neq,min_neq
 integer :: ngpart,maxngnode
 ! number of active ghost partitions for a node
-integer,allocatable :: ngpart_node(:) 
+integer,allocatable :: ngpart_node(:)
 character(len=250) :: errtag ! error message
 integer :: errcode
 logical :: isopen ! flag to check whether the file is opened
@@ -147,7 +147,7 @@
 ! this removes the repeated use of reshape later but it has larger size than gdof!!!
 allocate(gdof_elmt(nedof,nelmt))
 gdof_elmt=0
-do i_elmt=1,nelmt 
+do i_elmt=1,nelmt
   gdof_elmt(:,i_elmt)=reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) !g=g_g(:,i_elmt)
 enddo
 !-------------------------------
@@ -180,7 +180,7 @@
 ! apply traction boundary conditions
 if(istraction)then
   if(myid==1)write(*,'(a)',advance='no')'applying traction...'
-  call apply_traction(ismpi,myid,nproc,gnod,gdof,neq,extload,errcode,errtag)  
+  call apply_traction(ismpi,myid,nproc,gnod,gdof,neq,extload,errcode,errtag)
   if(errcode/=0)call error_stop(errtag,stdout,myid)
   if(myid==1)write(*,*)'complete!'
 endif
@@ -189,16 +189,16 @@
 ! compute water pressure
 if(iswater)then
   if(myid==1)write(stdout,'(a)',advance='no')'computing water pressure...'
-  allocate(wpressure(nnode),submerged_node(nnode))  
+  allocate(wpressure(nnode),submerged_node(nnode))
   call compute_pressure(ismpi,myid,nproc,wpressure,submerged_node,errcode,errtag)
   if(errcode/=0)call error_stop(errtag,stdout,myid)
   ! write pore pressure file
-  
+
   ! open Ensight Gold data file to store data
-  out_fname=trim(out_path)//trim(file_head)//trim(ptail)//'.por'    
-  npart=1;  
+  out_fname=trim(out_path)//trim(file_head)//trim(ptail)//'.por'
+  npart=1;
   destag='Pore pressure'
-  call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(wpressure))  
+  call write_ensight_pernode(out_fname,destag,npart,1,nnode,real(wpressure))
   if(myid==1)write(stdout,*)'complete!'
 endif
 !-------------------------------
@@ -258,21 +258,21 @@
 ! strength reduction (factor of safety) loop
 srf_loop: do i_srf=1,nsrf
   if(myid==1)write(stdout,'(/,a,f7.4)')'SRF:',srf(i_srf)
-  
+
    ! initialize
   nodalu=zero; vmeps=zero
   stress_local=zero; scf=inftol
-  
+
   ! strength reduction
   call strength_reduction(srf(i_srf),phinu,nmat,coh,nu,phi,psi,cohf,nuf,phif,  &
   psif,istat)
-  
+
   ! compute minimum pseudo-time step for viscoplasticity
   dt=dt_viscoplas(nmat,nuf,phif,ym)
-  
+
   ! recompute stiffness if either of nu and ym has changed
-  if(istat==1)then    
-    ! in future this should be changed so that only the elements with changed 
+  if(istat==1)then
+    ! in future this should be changed so that only the elements with changed
     ! material properties are involved
     dprecon=zero
     call stiffness_bodyload(nelmt,neq,gnod,g_num,gdof_elmt,mat_id,gam,nuf,ym,  &
@@ -282,46 +282,46 @@
     call assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,dprecon,dprecon)
     dprecon(1:)=one/dprecon(1:); dprecon(0)=zero
   endif
-  
+
   !print*,nsrf,srf(i_srf),nuf,phif,dt
   !print*,sin(phif*deg2rad),one-two*nuf
- 
+
   ! find global dt
-  dt=minscal(dt) 
-  
+  dt=minscal(dt)
+
   cg_tot=0; nl_tot=0
   ! load incremental loop
   !if(myid==1)write(stdout,'(a,i10)')' total load increments:',ninc
   !extload=extload/ninc
-  !load_increment: do i_inc=1,ninc  
-  
-  bodyload=zero; evpt=zero  
+  !load_increment: do i_inc=1,ninc
+
+  bodyload=zero; evpt=zero
   x=zero; oldx=zero
-  
+
   !print*,maxval(abs(bodyload)),maxval(abs(extload)),maxval(abs(dprecon))
-  
+
   ! plastic iteration loop
-  plastic: do nl_iter=1,nl_maxiter  
+  plastic: do nl_iter=1,nl_maxiter
     fmax=zero
-    
-    load=extload+bodyload    
-    load(0)=zero      
-    
+
+    load=extload+bodyload
+    load(0)=zero
+
     ! pcg solver
     !x=zero
     call pcg_solver(myid,ngpart,maxngnode,neq,nelmt,storkm,x,load,dprecon, &
     gdof_elmt,cg_iter,errcode,errtag)
     if(errcode/=0)call error_stop(errtag,stdout,myid)
-    cg_tot=cg_tot+cg_iter    
+    cg_tot=cg_tot+cg_iter
     x(0)=zero
-    
-    if(allelastic)then      
+
+    if(allelastic)then
       call elastic_stress(nelmt,neq,gnod,g_num,gdof_elmt,mat_id,dshape_hex8,   &
-      dlagrange_gll,x,stress_local)           
-            
+      dlagrange_gll,x,stress_local)
+
       exit plastic
     endif
-    
+
     ! check plastic convergence
     uerr=maxvec(abs(x-oldx))/maxvec(abs(x))
     oldx=x
@@ -330,27 +330,27 @@
     ! compute stress and check failure
     do i_elmt=1,nelmt
       ielmt=i_elmt
-      imat=mat_id(ielmt)      
-   
+      imat=mat_id(ielmt)
+
       call compute_cmat(cmat,ym(imat),nuf(imat))
       num=g_num(:,ielmt)
       coord=transpose(g_coord(:,num(gnod))) !transpose(g_coord(:,num(1:ngnod)))
-      egdof=gdof_elmt(:,ielmt) 
+      egdof=gdof_elmt(:,ielmt)
       !reshape(gdof(:,g_num(:,ielmt)),(/nedof/)) !g=g_g(:,i_elmt)
-      eld=x(egdof)  
-     
+      eld=x(egdof)
+
       bload=zero
-      do i=1,ngll ! loop over integration points        
-        jac=matmul(dshape_hex8(:,:,i),coord)        
+      do i=1,ngll ! loop over integration points
+        jac=matmul(dshape_hex8(:,:,i),coord)
         detjac=determinant(jac)
         call invert(jac)
 
-        deriv=matmul(jac,dlagrange_gll(:,i,:)) 
+        deriv=matmul(jac,dlagrange_gll(:,i,:))
         call compute_bmat(bmat,deriv)
         eps=matmul(bmat,eld)
         eps=eps-evpt(:,i,ielmt)
         sigma=matmul(cmat,eps)
-        
+
         ! compute effective stress
         effsigma=sigma+stress_local(:,i,ielmt)
         if(iswater)then
@@ -358,23 +358,23 @@
              ! water pressure is compressive (negative)
             effsigma(1:3)=effsigma(1:3)+wpressure(num(i))
           endif
-        endif           
-        
+        endif
+
         !effsigma=effsigma+stress_local(:,i,ielmt)
         call stress_invariant(effsigma,sigm,dsbar,lode_theta)
         ! check whether yield is violated
         call mohcouf(phif(imat),cohf(imat),sigm,dsbar,lode_theta,f)
         if(f>fmax)fmax=f
-        
+
         if(f>=zero)then !.or.(nl_isconv.or.nl_iter==nl_maxiter))then
           call mohcouq(psif(imat),dsbar,lode_theta,dq1,dq2,dq3)
-          call formm(effsigma,m1,m2,m3)          
-          flow=f*(m1*dq1+m2*dq2+m3*dq3) 
-          
+          call formm(effsigma,m1,m2,m3)
+          flow=f*(m1*dq1+m2*dq2+m3*dq3)
+
           erate=matmul(flow,effsigma)
           evp=erate*dt
           evpt(:,i,ielmt)=evpt(:,i,ielmt)+evp
-          devp=matmul(cmat,evp)          
+          devp=matmul(cmat,evp)
           ! if not converged we need body load for next iteration
           if(.not.nl_isconv .and. nl_iter/=nl_maxiter)then
             !devp(1:3)=devp(1:3)-wpressure(num(i))
@@ -395,10 +395,10 @@
           !if(sf<scf(num(i)))scf(num(i))=sf
         endif
       end do ! i_gll
-      
+
       if(nl_isconv .or. nl_iter==nl_maxiter)cycle
       ! compute total body load vector
-      bodyload(egdof)=bodyload(egdof)+bload      
+      bodyload(egdof)=bodyload(egdof)+bload
     end do ! i_elmt
     bodyload(0)=zero
     fmax=maxscal(fmax)
@@ -411,13 +411,13 @@
   end do plastic ! plastic iteration
   ! check if the plastic iteration did not converge
   if(nl_iter>=nl_maxiter .and. .not.nl_isconv)then
-    write(stdout,*)'WARNING: nonconvergence in nonlinear iterations!' 
-    write(stdout,*)'desired tolerance:',nl_tol,' achieved tolerance:',uerr  
+    write(stdout,*)'WARNING: nonconvergence in nonlinear iterations!'
+    write(stdout,*)'desired tolerance:',nl_tol,' achieved tolerance:',uerr
   endif
-  
+
   nl_tot=nl_tot+nl_iter
   !if(myid==1)print*,cg_tot,nl_tot
-  ! nodal displacement  
+  ! nodal displacement
   do i=1,nndof
     do j=1,nnode
       if(gdof(i,j)/=0)then
@@ -426,26 +426,26 @@
     enddo
   enddo
   !enddo load_increment ! load increment loop
-  
+
   ! write summary
   uxmax=maxvec(abs(reshape(nodalu,(/nndof*nnode/))))
   umax=maxvec(sqrt(nodalu(1,:)*nodalu(1,:)+ &
   nodalu(2,:)*nodalu(2,:)+nodalu(3,:)*nodalu(3,:)))
-  open(10,file=trim(sum_file),status='old',position='append',action='write')  
+  open(10,file=trim(sum_file),status='old',position='append',action='write')
   write(10,*)srf(i_srf),cg_tot,nl_tot,uxmax,umax,fmax
   close(10)
-  
+
   ! compute average effective strain
   do i_node=1,nnode
     inode=i_node
     vmeps(inode)=vmeps(inode)/real(node_valency(inode),kreal)
-  enddo  
+  enddo
 
   ! compute stress_global
-  stress_global=zero  
+  stress_global=zero
   do i_elmt=1,nelmt
     ielmt=i_elmt
-    num=g_num(:,ielmt)    
+    num=g_num(:,ielmt)
     stress_global(:,num)=stress_global(:,num)+stress_local(:,:,ielmt)
   enddo
 
@@ -453,14 +453,14 @@
   do i_node=1,nnode
     inode=i_node
     stress_global(:,inode)=stress_global(:,inode)/real(node_valency(inode),kreal)
-  enddo  
-  
+  enddo
+
   call save_data(ptail,format_str,i_srf,nnode,nelmt,g_num, &
-  nodalu,scf,vmeps,stress_global)  
-  
+  nodalu,scf,vmeps,stress_global)
+
   if(nl_iter==nl_maxiter)exit
-  
-enddo srf_loop ! i_srf safety factor loop 
+
+enddo srf_loop ! i_srf safety factor loop
 deallocate(mat_id,gam,ym,coh,nu,phi,psi,srf)
 deallocate(g_coord,g_num)
 deallocate(load,bodyload,extload,oldx,x,dprecon,storkm,stat=istat)

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/serial_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -105,9 +105,9 @@
 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 
+! 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
@@ -122,7 +122,7 @@
 !===========================================
 
 ! 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 
+! 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)

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/shape_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/shape_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/shape_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -81,14 +81,14 @@
       sum_shape = zero
 
       do i_gnod=1,ngnod
-        sum_shape = sum_shape + shape_hex8(i_gnod,i,j,k)        
+        sum_shape = sum_shape + shape_hex8(i_gnod,i,j,k)
       enddo
 
       ! sum of shape functions should be one
       if(abs(sum_shape-one) >  zerotol)then
         write(*,*)'ERROR: error shape functions!'
         stop
-      endif      
+      endif
     enddo
   enddo
 enddo
@@ -150,7 +150,7 @@
       !gamma = zetagll(k)
 
       xip = one + xigll(i)
-      xim = one - xigll(i)      
+      xim = one - xigll(i)
 
       dshape_hex8(1,1,igll) = - one_eighth*etam*zetam
       dshape_hex8(1,2,igll) = one_eighth*etam*zetam
@@ -185,18 +185,18 @@
 
 ! check the shape functions and their derivatives
 
-do i=1,ngll   
+do i=1,ngll
       sum_dshapexi = zero
       sum_dshapeeta = zero
       sum_dshapezeta = zero
 
-      do i_gnod=1,ngnod        
+      do i_gnod=1,ngnod
         sum_dshapexi = sum_dshapexi + dshape_hex8(1,i_gnod,i)
         sum_dshapeeta = sum_dshapeeta + dshape_hex8(2,i_gnod,i)
         sum_dshapezeta = sum_dshapezeta + dshape_hex8(3,i_gnod,i)
       enddo
-      
-      ! sum of derivative of shape functions should be zero     
+
+      ! sum of derivative of shape functions should be zero
       if(abs(sum_dshapexi) >  zerotol)then
         write(*,*)'ERROR: derivative xi shape functions!'
         stop
@@ -257,10 +257,10 @@
   etam = one - etagll(j)
   do i=1,ngllx
     igll=igll+1
-    
+
     xip = one + xigll(i)
-    xim = one - xigll(i)        
- 
+    xim = one - xigll(i)
+
     ! corner nodes
     !shape_quad4(1,igll) = one_fourth*xim*etam
     !shape_quad4(2,igll) = one_fourth*xip*etam
@@ -271,26 +271,26 @@
     dshape_quad4(1,2,igll) = one_fourth*etam
     dshape_quad4(1,3,igll) = one_fourth*etap
     dshape_quad4(1,4,igll) = -one_fourth*etap
-    
-    dshape_quad4(2,1,igll) = -one_fourth*xim    
-    dshape_quad4(2,2,igll) = -one_fourth*xip    
-    dshape_quad4(2,3,igll) = one_fourth*xip    
+
+    dshape_quad4(2,1,igll) = -one_fourth*xim
+    dshape_quad4(2,2,igll) = -one_fourth*xip
+    dshape_quad4(2,3,igll) = one_fourth*xip
     dshape_quad4(2,4,igll) = one_fourth*xim
 
     enddo
   enddo
-  
+
   ! check the shape functions and their derivatives
-  do i=1,ngll   
+  do i=1,ngll
     sum_dshapexi = zero
-    sum_dshapeeta = zero        
+    sum_dshapeeta = zero
 
-    do i_gnod=1,ngnod2d        
+    do i_gnod=1,ngnod2d
       sum_dshapexi = sum_dshapexi + dshape_quad4(1,i_gnod,i)
       sum_dshapeeta = sum_dshapeeta + dshape_quad4(2,i_gnod,i)
     enddo
-    
-    ! sum of derivative of shape functions should be zero     
+
+    ! sum of derivative of shape functions should be zero
     if(abs(sum_dshapexi) >  zerotol)then
       write(*,*)'ERROR: derivative xi shape functions!'
       stop

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -11,7 +11,7 @@
 ! 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) :: myid,ngpart,maxngnode,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
@@ -32,9 +32,9 @@
 
 !---PCG solver
 kp=zero
-if(maxval(abs(u)).gt.zero)then 
-  do i_elmt=1,nelmt   
-    egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) 
+if(maxval(abs(u)).gt.zero)then
+  do i_elmt=1,nelmt
+    egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/))
     km=k(:,:,i_elmt)
     kp(egdof)=kp(egdof)+matmul(km,u(egdof))
   end do
@@ -47,28 +47,28 @@
 !----pcg iteration----
 pcg: do cg_iter=1,cg_maxiter
   kp=zero
-  do i_elmt=1,nelmt      
+  do i_elmt=1,nelmt
     egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/))
-    km=k(:,:,i_elmt)   
+    km=k(:,:,i_elmt)
     kp(egdof)=kp(egdof)+matmul(km,p(egdof))
   end do
   kp(0)=zero
-  
+
   rz=dot_product(r,z)
   alpha=rz/dot_product(p,kp)
   u=u+alpha*p
-  
+
   if(abs(alpha)*maxval(abs(p))/maxval(abs(u)).le.cg_tol)then
     errcode=0
     return
   endif
-  
-  r=r-alpha*kp  
+
+  r=r-alpha*kp
   z=dprecon*r
   beta=dot_product(r,z)/rz
   p=z+beta*p
   !write(*,'(i3,f25.18,f25.18,f25.18)')cg_iter,alpha,beta,rz
-  
+
 end do pcg
 write(errtag,'(a)')'ERROR: PCG solver doesn''t converge!'
 return

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/solver_mpi.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -37,9 +37,9 @@
 
 !---PCG solver
 kp=zero
-if(maxval(abs(u_g)).gt.zero)then 
-  do i_elmt=1,nelmt     
-    egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/)) 
+if(maxval(abs(u_g)).gt.zero)then
+  do i_elmt=1,nelmt
+    egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/))
     km=k(:,:,i_elmt)
     kp(egdof)=kp(egdof)+matmul(km,u_g(egdof))
   end do
@@ -55,28 +55,28 @@
 pcg: do cg_iter=1,cg_maxiter
   call assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,p,p_g) !,gdof)
   kp=zero
-  do i_elmt=1,nelmt       
+  do i_elmt=1,nelmt
     egdof=gdof_elmt(:,i_elmt) !reshape(gdof(:,g_num(:,i_elmt)),(/nedof/))
-    km=k(:,:,i_elmt)   
+    km=k(:,:,i_elmt)
     kp(egdof)=kp(egdof)+matmul(km,p_g(egdof))
   end do
   kp(0)=zero
-  
+
   rz=dot_product_par(r,z_g)
   alpha=rz/dot_product_par(p_g,kp)
   u_g=u_g+alpha*p_g
-  
+
   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(abs(p_g))/maxvec(abs(u_g))
-  r=r-alpha*kp  
+  r=r-alpha*kp
   z=dprecon_g*r
   call assemble_ghosts(myid,ngpart,maxngnode,nndof,neq,z,z_g) !,gdof)
   beta=dot_product_par(r,z_g)/rz
   p=z+beta*p
-  !if(myid==1)write(*,'(i3,f25.18,f25.18,f25.18)')cg_iter,alpha,beta,rz  
+  !if(myid==1)write(*,'(i3,f25.18,f25.18,f25.18)')cg_iter,alpha,beta,rz
 end do pcg
 write(errtag,'(a)')'ERROR: PCG solver doesn''t converge!'
 return

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/string_library.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/string_library.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/string_library.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -169,7 +169,7 @@
 slen=len_trim(str)
 tmp_str=trim(str)
 
-! find and count indices of all delimeters 
+! find and count indices of all delimeters
 narg=0
 do i=1,slen
   if(tmp_str(i:i)==delm)then
@@ -192,19 +192,19 @@
 !=====================================================
 
 ! get string value from string list which contain a character '=' that separates
-! variable name and variable vlue 
+! variable name and variable vlue
 character(len=80) function get_string(vname,slist,nvar)
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 do i=1,nvar
   call split_string(slist(i),'=',args,narg)
   if (narg/=2)cycle
   if (vname==trim(adjustl(args(1))))then
-     read(args(2),*)get_string     
+     read(args(2),*)get_string
      return
   endif
 enddo
@@ -221,7 +221,7 @@
 character(len=*),intent(out) :: strval
 character(len=*),dimension(*) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 strval=''
@@ -249,7 +249,7 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 do i=1,nvar
@@ -272,7 +272,7 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 do i=1,nvar
@@ -296,7 +296,7 @@
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
 integer,intent(out) :: ival,istat
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 ival=0
 istat=-1
@@ -325,13 +325,13 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,ios,narg
 
 do i=1,nvar
   call split_string(slist(i),'=',args,narg)
   if (narg/=2)cycle
-  if (vname==trim(adjustl(args(1))))then     
+  if (vname==trim(adjustl(args(1))))then
      read(args(2),*,iostat=ios)get_integer_vect(1:n)
      if(ios/=0)exit
      return
@@ -353,18 +353,18 @@
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
 integer,intent(out) :: istat
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,ios,narg
 ivect=0
 istat=-1
 do i=1,nvar
   !print*,'hi',index(slist(1),vname,.true.)
   call split_string(slist(i),'=',args,narg)
-  if (narg/=2)cycle  
-  if (vname==trim(adjustl(args(1))))then  
+  if (narg/=2)cycle
+  if (vname==trim(adjustl(args(1))))then
      read(args(2),*,iostat=ios)ivect(1:n)
      if(ios/=0)exit
-     istat=0   
+     istat=0
      return
   endif
 enddo
@@ -379,7 +379,7 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 do i=1,nvar
@@ -404,7 +404,7 @@
 integer,intent(in) :: nvar
 integer,intent(out) :: istat
 real(kind=kreal),intent(out) :: rval
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 rval=0_kreal
 istat=-1
@@ -428,7 +428,7 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,narg
 
 do i=1,nvar
@@ -454,16 +454,16 @@
 character(len=*),intent(in) :: vname
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,ios,narg
 
 do i=1,nvar
   !print*,'hi',index(slist(1),vname,.true.)
   call split_string(slist(i),'=',args,narg)
-  if (narg/=2)cycle  
-  if (vname==trim(adjustl(args(1))))then  
+  if (narg/=2)cycle
+  if (vname==trim(adjustl(args(1))))then
      read(args(2),*,iostat=ios)get_real_vect(1:n)
-     if(ios/=0)exit     
+     if(ios/=0)exit
      return
   endif
 enddo
@@ -483,18 +483,18 @@
 character(len=*),dimension(*),intent(in) :: slist
 integer,intent(in) :: nvar
 integer,intent(out) :: istat
-character(len=80),dimension(2) :: args 
+character(len=80),dimension(2) :: args
 integer :: i,ios,narg
 rvect=0.0_kreal
 istat=-1
 do i=1,nvar
   !print*,'hi',index(slist(1),vname,.true.)
   call split_string(slist(i),'=',args,narg)
-  if (narg/=2)cycle  
-  if (vname==trim(adjustl(args(1))))then  
+  if (narg/=2)cycle
+  if (vname==trim(adjustl(args(1))))then
      read(args(2),*,iostat=ios)rvect(1:n)
      if(ios/=0)exit
-     istat=0   
+     istat=0
      return
   endif
 enddo
@@ -505,7 +505,7 @@
 end subroutine seek_real_vect
 !=====================================================
 
-! get format string for intger 
+! get format string for intger
 character(len=80) function form4int(n)
 integer,intent(in) :: n
 
@@ -536,16 +536,16 @@
 
 do i=1,slen
   c = s(i:i)
-  if(c /= ' ')then 
+  if(c /= ' ')then
     itemp = iachar(c)
     if(.not.(65 <= itemp .and. itemp <= 90))then
       if(.not.(97 <= itemp .and. itemp <= 122))then
         return
       endif
     endif
-  endif 
-enddo 
-ind = .true. 
+  endif
+enddo
+ind = .true.
 end function isalphabet
 !=====================================================
 

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/testf90.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/testf90.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/testf90.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -5,15 +5,15 @@
 integer :: i,ios
 
 ! ghost partitions
-type derived_type  
-  integer,dimension(:),allocatable :: acomp 
+type derived_type
+  integer,dimension(:),allocatable :: acomp
 end type derived_type
 type(derived_type),dimension(:),allocatable :: derived
 
 call get_command_argument(0, prog)
 !----input and initialisation----
-if (command_argument_count() <= 0) then  
-  write(*,*)'ERROR: no input file!'    
+if (command_argument_count() <= 0) then
+  write(*,*)'ERROR: no input file!'
 endif
 
 allocate(derived(10))

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/src/visual.f90
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/src/visual.f90	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/src/visual.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,19 +1,19 @@
 ! this module contains visualization routines
 ! REVISION:
 !  HNG, Mar 11,2011; HNG, Apr 09,2010
-! TODO: 
-!  define the array in main program such that entire array can be written 
+! TODO:
+!  define the array in main program such that entire array can be written
 !  without transpose in this routine (done!)
 module visual
 contains
-! this subroutine writes an ensight geofile only upto coordinates and returns 
+! this subroutine writes an ensight geofile only upto coordinates and returns
 ! the file unit to the calling program so that the calling program can writes
 ! the remaining part (connectivity) of the geo file and close it.
 subroutine write_ensight_geocoord(out_fname,destag,npart,nnode,coord,funit)
-character(len=250),intent(in) :: out_fname  
+character(len=250),intent(in) :: out_fname
 character(len=80),intent(in) :: destag
 integer,intent(in) :: npart,nnode
-real,dimension(3,nnode),intent(in) :: coord !3D  
+real,dimension(3,nnode),intent(in) :: coord !3D
 integer,intent(out) :: funit
 
 character(len=80) :: buffer ! this must be 80 characters long
@@ -25,15 +25,15 @@
 if (ios /= 0)then
   write(*,'(/,a)')'ERROR: output file "'//out_fname//'" cannot be opened!'
   stop
-endif     
+endif
 
 buffer='C Binary'
 write(funit)buffer
 buffer='Created by write_ensight Routine'
 write(funit)buffer
-buffer='semfem3d'   
+buffer='semfem3d'
 write(funit)buffer
-buffer='node id off'     
+buffer='node id off'
 write(funit)buffer
 buffer='element id off'
 write(funit)buffer
@@ -43,12 +43,12 @@
 !    call write_float(real(extent(i,j)),fd)
 !  enddo
 !enddo
-buffer='part' 
+buffer='part'
 write(funit)buffer
 write(funit)npart
 buffer=destag !'unstructured meshes'
 write(funit)buffer
-buffer='coordinates' 
+buffer='coordinates'
 write(funit)buffer
 write(funit)nnode
 do i=1,3
@@ -76,15 +76,15 @@
 if (ios /= 0)then
   write(*,'(/,a)')'ERROR: output file "'//out_fname//'" cannot be opened!'
   stop
-endif     
+endif
 
 buffer='C Binary'
 write(11)buffer
 buffer='Created by write_ensight Routine'
 write(11)buffer
-buffer='semfem3d'   
+buffer='semfem3d'
 write(11)buffer
-buffer='node id off'     
+buffer='node id off'
 write(11)buffer
 buffer='element id off'
 write(11)buffer
@@ -94,12 +94,12 @@
 !    call write_float(real(extent(i,j)),fd)
 !  enddo
 !enddo
-buffer='part' 
+buffer='part'
 write(11)buffer
 write(11)npart
 buffer=destag !'unstructured meshes'
 write(11)buffer
-buffer='coordinates' 
+buffer='coordinates'
 write(11)buffer
 write(11)nnode
 do i=1,3
@@ -111,7 +111,7 @@
 write(11)nelmt
 
 ! do not substract 1 for ensight file
-write(11)connect 
+write(11)connect
 close(11)
 return
 end subroutine write_ensight_geo
@@ -142,16 +142,16 @@
 endif
 
 buffer=destag
-write(11)buffer  
+write(11)buffer
 buffer='part'
 write(11)buffer
-write(11)npart  
+write(11)npart
 buffer='coordinates'
-write(11)buffer  
-do i=1,ncomp   
+write(11)buffer
+do i=1,ncomp
   write(11)var(i,:)
 enddo
-  
+
 close(11)
 return
 end subroutine write_ensight_pernode

Deleted: seismo/3D/SPECFEM3D_GEOTECH/trunk/svn-commit.tmp
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/svn-commit.tmp	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/svn-commit.tmp	2011-09-09 12:18:10 UTC (rev 18889)
@@ -1,4 +0,0 @@
-
---This line, and those below, will be ignored--
-
-A    .

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/exodus2sem.c	2011-09-09 12:18:10 UTC (rev 18889)
@@ -4,14 +4,14 @@
 in CUBIT:
 - blocks defines only the material regions
   -> actual material properties should not be defined within the CUBIT.
-  actual material properties can be listed later corresponding to each block 
+  actual material properties can be listed later corresponding to each block
   (i.e., material region).
 - nodal boundary conditions must be defined using node set
-  -> each node set name must contain the corresponding BC names as defined in 
+  -> each node set name must contain the corresponding BC names as defined in
   char *ns_bcname[] below
   e.g., node set name can be front_nsbcux or front_nsbcux_nsbcuy etc.
 - surface boundary conditions must be defined using side set
-  -> each side set name must contain the corresponding BC names as defined in 
+  -> each side set name must contain the corresponding BC names as defined in
   char *ss_bcname[] below
   e.g., side set name can be front_ssbcux or front_ssbcux_ssbcuy etc.
 
@@ -27,7 +27,7 @@
 *_coord_? : total number of nodes followed by nodal coordinate ? (? -> x, y, z)
 *_connectivity : total number of elements followed by connectivity list
 *_material_id : total number of elements followed by material IDs
-*_??bcu? : node IDs which have u? = 0 as the boundary conditions (?? -> ns or ss, ? -> x, y, z) 
+*_??bcu? : node IDs which have u? = 0 as the boundary conditions (?? -> ns or ss, ? -> x, y, z)
 ------------------------------------------------------
 DEVELOPER:
   Hom Nath Gharti
@@ -37,20 +37,20 @@
   stringmanip.c: string manipulation routines
 COMPILE:
   gcc exodus2sem.c -o exodus2sem
-USAGE: 
+USAGE:
   exodus2sem <inputfile> <OPTIONS>
   Example: exodus2sem sloep3d_mest.txt
   or
   exodus2sem slope3d_mesh.e -fac=0.001 -bin=1
 OPTIONS:
-  -fac: use this option to multiply coordinates. this is importantn for unit 
+  -fac: use this option to multiply coordinates. this is importantn for unit
         conversion, e.g., to convert m to km use -fac=0.001
   -bin: use this option if you want to convert exodus binary directly, provided
         that the command ncdump is in the path. ncdump is a part of netCDF library
-        that can be downloaded freely from 
-        http://www.unidata.ucar.edu/downloads/netcdf/index.jsp. use -bin=1 for binary 
+        that can be downloaded freely from
+        http://www.unidata.ucar.edu/downloads/netcdf/index.jsp. use -bin=1 for binary
         or -bin=0 for ascii file.
-HISTORY: 
+HISTORY:
   HNG,Apr 23,2010;HNG,Apr 17,2010;HNG,Feb 08,2009
 TODO:
 -------------------------------------------------------*/
@@ -74,7 +74,7 @@
 /* main routine */
 int main(int argc,char **argv){
 int i,itmp,j,k;
-int ndim;	/* geometry dimension */ 
+int ndim; /* geometry dimension */
 int nnode,nelmt; /* number of nodes, number of elements */
 int nblk,nns,nss; /* number of blocks, number of node sets */
 int elmt_count,node_count; /* element, node count */
@@ -111,7 +111,7 @@
 
 FILE *inf,*outf_dum,*outf_mat,*outf_con,*outf_coord[3],**outf_nsbc,**outf_ssbc;
 
-/* default factor and binary switch*/    
+/* default factor and binary switch*/
 fac=1.0; isbin=OFF;
 
 if(argc<2){
@@ -123,17 +123,17 @@
 if(argc>2){
   for(i=2;i<argc;i++){
     if(look_double(&ftmp,"-fac=",argv[i])==0){
-	  fac=ftmp;		  
-	  continue;
-	}
-	else if(look_int(&itmp,"-bin=",argv[i])==0){
-	  isbin=itmp;
-	  continue;
-	}else{
-	  printf("ERROR: unrecognized option \"%s\"",argv[i]);
-	  exit(-1);
-	}
+    fac=ftmp;
+    continue;
   }
+  else if(look_int(&itmp,"-bin=",argv[i])==0){
+    isbin=itmp;
+    continue;
+  }else{
+    printf("ERROR: unrecognized option \"%s\"",argv[i]);
+    exit(-1);
+  }
+  }
 }
 
 printf("input file: %s\n",argv[1]);
@@ -150,10 +150,10 @@
   sprintf(infname,"%s.txt",fonly);
 
   /* convert binary netCDF file to ascii file */
-  sprintf(dumc,"ncdump %s > %s.txt",argv[1],fonly);  
+  sprintf(dumc,"ncdump %s > %s.txt",argv[1],fonly);
   if (system(dumc)!=0){
-	printf("ERROR: command \"%s\" cannot be executed! use -bin=0 or no option for ascii input file! \n",dumc);
-	exit(-1);
+  printf("ERROR: command \"%s\" cannot be executed! use -bin=0 or no option for ascii input file! \n",dumc);
+  exit(-1);
   }
   printf("complete!\n");
 }
@@ -167,12 +167,12 @@
 /*printf("--------------------------------\n");*/
 
 bulk=malloc(1000); /* bulk string */
-      
+
 /* initialize some variables to 0 */
 ndim=0; nns=0; nblk=0; nnode=0; nelmt=0; nss=0;
 
 /* intialize count to 0 */
-blk_count=0; ns_count=0; ss_count=0; node_count=0; elmt_count=0;	
+blk_count=0; ns_count=0; ss_count=0; node_count=0; elmt_count=0;
 
 /* set default status to OFF */
 dim_stat=OFF; ns_stat=OFF; ss_stat=OFF; con_stat=OFF; coord_stat=OFF;
@@ -183,7 +183,7 @@
 ns_bcfilestat=malloc(ns_maxnbc*sizeof(int));
 for(i=0;i<ns_maxnbc;i++)ns_bcfilestat[i]=0;
 ns_bc_nnode=malloc(ns_maxnbc*sizeof(int));
-for(j=0;j<ns_maxnbc;j++){	    
+for(j=0;j<ns_maxnbc;j++){
   ns_bc_nnode[j]=0;
 }
 
@@ -193,7 +193,7 @@
 ss_bcfilestat=malloc(ss_maxnbc*sizeof(int));
 for(i=0;i<ss_maxnbc;i++)ss_bcfilestat[i]=0;
 ss_bc_nside=malloc(ss_maxnbc*sizeof(int));
-for(j=0;j<ss_maxnbc;j++){	    
+for(j=0;j<ss_maxnbc;j++){
   ss_bc_nside[j]=0;
 }
 fscanf(inf,"%s",token);
@@ -208,16 +208,16 @@
   /* read dimensions */
   if(dim_stat!=ON && strcmp(token,"dimensions:")==0){
     printf("reading dimensions...");
-    while(strstr(fgets(line,100,inf),"variables:") == NULL){		
-      strncat(bulk,line,strcspn(line,";")+1);              
-    }    
+    while(strstr(fgets(line,100,inf),"variables:") == NULL){
+      strncat(bulk,line,strcspn(line,";")+1);
+    }
     get_int(&ndim,"num_dim =",bulk);
-    if(ndim>0){	  
+    if(ndim>0){
       /* allocate memory */
       coord_name=malloc(ndim*sizeof(char *));
-      for(i=0;i<ndim;i++){	    
-      coord_name[i]=malloc(62*sizeof(char)); /* each name has maximum of 62 characters */		
-      }	  
+      for(i=0;i<ndim;i++){
+      coord_name[i]=malloc(62*sizeof(char)); /* each name has maximum of 62 characters */
+      }
     }else{
       printf("ERROR: illegal value of dimension!\n");
       exit(-1);
@@ -225,7 +225,7 @@
     get_int(&nnode,"num_nodes =",bulk);
     get_int(&nelmt,"num_elem =",bulk);
     get_int(&nblk,"num_el_blk =",bulk);
-    
+
     /* allocate memory */
     blk_nelmt=malloc(nblk*sizeof(int));
     blk_nenod=malloc(nblk*sizeof(int));
@@ -234,20 +234,20 @@
       nns=0;
     }else{
       /* allocate memory */
-	  ns_name=malloc(nns*sizeof(char *));
+    ns_name=malloc(nns*sizeof(char *));
       for(i=0;i<nns;i++){
         ns_name[i]=malloc(62*sizeof(char)); /* each name has maximum of 62 characters */
       }
       ns_nnode=malloc(nns*sizeof(int));
     }
-    
+
     if(nns>0){ /* This segment has a significance only if nns has legitimate value */
       for(i=0;i<nns;i++){
         sprintf(stag,"num_nod_ns%d =",i+1);
-        get_int(&ns_nnode[i],stag,bulk);					
+        get_int(&ns_nnode[i],stag,bulk);
       }
     }
-	
+
     /* sideset information */
     if (look_int(&nss,"num_side_sets =",bulk)!=0){
       nss=0;
@@ -259,99 +259,99 @@
       }
       ss_nside=malloc(nss*sizeof(int));
     }
-    
+
     if(nss>0){ /* This segment has a significance only if nss has legitimate value */
       for(i=0;i<nss;i++){
         sprintf(stag,"num_side_ss%d =",i+1);
-        get_int(&ss_nside[i],stag,bulk);					
+        get_int(&ss_nside[i],stag,bulk);
       }
     }
 
-    /* block information */        
+    /* block information */
     for(i=0;i<nblk;i++){
       sprintf(stag,"num_el_in_blk%d =",i+1);
-      get_int(&blk_nelmt[i],stag,bulk); 
-      
+      get_int(&blk_nelmt[i],stag,bulk);
+
       sprintf(stag,"num_nod_per_el%d =",i+1);
       get_int(&blk_nenod[i],stag,bulk);
-    }    
-    	
+    }
+
     dim_stat=ON;
     free(bulk);
     printf("complete!\n");
-    printf(" geometry dimension: %d\n",ndim);    
+    printf(" geometry dimension: %d\n",ndim);
     printf(" number of nodes: %d\n",nnode);
     printf(" number of elements: %d\n",nelmt);
     printf(" number of blocks: %d\n",nblk);
     continue;
-  }  
-  
+  }
+
   /* read coordinate names */
-  if(strcmp(token,"coor_names")==0){    
-    fscanf(inf,"%s",dumc); /* = */			
+  if(strcmp(token,"coor_names")==0){
+    fscanf(inf,"%s",dumc); /* = */
     for (i=0; i<ndim; i++){
-      fscanf(inf,"%s",dumc);	  
-	  getfirstquote(dumc,coord_name[i]);	  
-    }	
+      fscanf(inf,"%s",dumc);
+    getfirstquote(dumc,coord_name[i]);
+    }
     continue;
   }
-  
+
   /* read and write nodal boundary conditions */
-  if(strcmp(token,"ns_names")==0){  
+  if(strcmp(token,"ns_names")==0){
     printf("saving nodal BCs...");
-    fscanf(inf,"%s",dumc); /* = */			
-    for (i=0; i<nns; i++){  
-	  fscanf(inf,"%s",dumc);	  
-	  getfirstquote(dumc,ns_name[i]);
+    fscanf(inf,"%s",dumc); /* = */
+    for (i=0; i<nns; i++){
+    fscanf(inf,"%s",dumc);
+    getfirstquote(dumc,ns_name[i]);
 
-	  /* count sides in each side BC */
-	  for(j=0;j<ns_maxnbc;j++){		  
-	    if (strstr(ns_name[i],ns_bcname[j])!=NULL){
-	      ns_bc_nnode[j]+=ns_nnode[i];
-		}
-	  }
+    /* count sides in each side BC */
+    for(j=0;j<ns_maxnbc;j++){
+      if (strstr(ns_name[i],ns_bcname[j])!=NULL){
+        ns_bc_nnode[j]+=ns_nnode[i];
     }
-   
+    }
+    }
+
     /* open bc nodal files */
     /*sprintf(outfname,"%s_bcux",fonly);
     outf_nsbc[0]=fopen(outfname,"w");
     sprintf(outfname,"%s_bcuy",fonly);
     outf_nsbc[1]=fopen(outfname,"w");
     sprintf(outfname,"%s_bcuz",fonly);
-    outf_nsbc[2]=fopen(outfname,"w");*/      
+    outf_nsbc[2]=fopen(outfname,"w");*/
     continue;
   }
-  
+
   if(ns_stat!=ON){
-    for(i=0;i<nns;i++){		
-      sprintf(stag,"node_ns%d",i+1);	  
-      if(strcmp(token,stag)==0){		  
+    for(i=0;i<nns;i++){
+      sprintf(stag,"node_ns%d",i+1);
+      if(strcmp(token,stag)==0){
         ns_nbc=0;
-		for(j=0;j<ns_maxnbc;j++){		  
-		  if (strstr(ns_name[i],ns_bcname[j])!=NULL){	
-		    sprintf(outfname,"%s_%s",fonly,ns_bcname[j]);			  
-			if(ns_bcfilestat[j]==1){
-			  /* already opened */
-			  outf_nsbc[ns_nbc]=fopen(outfname,"a");
-			}else{
-			  /* create new */
-			  outf_nsbc[ns_nbc]=fopen(outfname,"w");
-			  fprintf(outf_nsbc[ns_nbc],"%d\n",ns_bc_nnode[j]);
-			}
+    for(j=0;j<ns_maxnbc;j++){
+      if (strstr(ns_name[i],ns_bcname[j])!=NULL){
+        sprintf(outfname,"%s_%s",fonly,ns_bcname[j]);
+      if(ns_bcfilestat[j]==1){
+        /* already opened */
+        outf_nsbc[ns_nbc]=fopen(outfname,"a");
+      }else{
+        /* create new */
+        outf_nsbc[ns_nbc]=fopen(outfname,"w");
+        fprintf(outf_nsbc[ns_nbc],"%d\n",ns_bc_nnode[j]);
+      }
 
-			ns_bcfilestat[j]=1; /* this file is now opened */ 
-			ns_nbc+=1;
-		  }
-		}
-		
+      ns_bcfilestat[j]=1; /* this file is now opened */
+      ns_nbc+=1;
+      }
+    }
+
         if(ns_nbc==0){
           printf("WARNING: no BC name found in node side \"%s\"!\n",ns_name[i]);
         }
 
         fscanf(inf,"%s",dumc); /* = */
-        for(j=0;j<ns_nnode[i]; j++){				
+        for(j=0;j<ns_nnode[i]; j++){
           fscanf(inf,"%d,",&itmp); /* read comma separated data */
-          for(k=0;k<ns_nbc;k++){			  
+          for(k=0;k<ns_nbc;k++){
             fprintf(outf_nsbc[k],"%d\n",itmp);
           }
         }
@@ -373,7 +373,7 @@
           ns_nbc+=1;
         }
         fscanf(inf,"%s",dumc);
-        for(j=0; j<ns_nnode[i]; j++){				
+        for(j=0; j<ns_nnode[i]; j++){
           fscanf(inf,"%d,",&itmp);
           for(k=0;k<ns_nbc;k++){
             fprintf(outf_nsbc[ind_outf[k]],"%d\n",itmp);
@@ -390,106 +390,106 @@
           free(ns_bcfilestat);
           free(ns_nnode);
           ns_stat=ON;
-            
+
           /*fclose(outf_nsbc[0]);
           fclose(outf_nsbc[1]);
           fclose(outf_nsbc[2]);*/
-          printf("complete!\n");          
-        }	
+          printf("complete!\n");
+        }
         continue;
-      }          
+      }
     }
   }
 
   /* read and write side boundary conditions */
   if(strcmp(token,"ss_names")==0){
     printf("saving side BCs...");
-    fscanf(inf,"%s",dumc); /* = */			
-    for (i=0; i<nss; i++){  
-	  fscanf(inf,"%s",dumc);	  
-	  getfirstquote(dumc,ss_name[i]);
-      
-	  /* count sides in each side BC */
-	  for(j=0;j<ss_maxnbc;j++){		  
-	    if (strstr(ss_name[i],ss_bcname[j])!=NULL){
-	      ss_bc_nside[j]+=ss_nside[i];
-		}
-	  }
+    fscanf(inf,"%s",dumc); /* = */
+    for (i=0; i<nss; i++){
+    fscanf(inf,"%s",dumc);
+    getfirstquote(dumc,ss_name[i]);
+
+    /* count sides in each side BC */
+    for(j=0;j<ss_maxnbc;j++){
+      if (strstr(ss_name[i],ss_bcname[j])!=NULL){
+        ss_bc_nside[j]+=ss_nside[i];
     }
- 
+    }
+    }
+
     /* open bc nodal files */
     /*sprintf(outfname,"%s_bcux",fonly);
     outf_nsbc[0]=fopen(outfname,"w");
     sprintf(outfname,"%s_bcuy",fonly);
     outf_nsbc[1]=fopen(outfname,"w");
     sprintf(outfname,"%s_bcuz",fonly);
-    outf_nsbc[2]=fopen(outfname,"w");*/      
+    outf_nsbc[2]=fopen(outfname,"w");*/
     continue;
   }
- 
+
   if(ss_stat!=ON){
-    for(i=0;i<nss;i++){	  
-      sprintf(stag,"elem_ss%d",i+1);	  
-      if(strcmp(token,stag)==0){		  
+    for(i=0;i<nss;i++){
+      sprintf(stag,"elem_ss%d",i+1);
+      if(strcmp(token,stag)==0){
         ss_nbc=0;
-	      for(j=0;j<ss_maxnbc;j++){		  
-	        if (strstr(ss_name[i],ss_bcname[j])!=NULL){	
-	          sprintf(outfname,"%s_%s",fonly,ss_bcname[j]);			  
-	          if(ss_bcfilestat[j]==1){
-	            /* already opened */
-		          outf_ssbc[ss_nbc]=fopen(outfname,"a");
-		        }else{
-		          /* create new */
-		          outf_ssbc[ss_nbc]=fopen(outfname,"w");
-		          fprintf(outf_ssbc[ss_nbc],"%d\n",ss_bc_nside[j]);
-		        }
+        for(j=0;j<ss_maxnbc;j++){
+          if (strstr(ss_name[i],ss_bcname[j])!=NULL){
+            sprintf(outfname,"%s_%s",fonly,ss_bcname[j]);
+            if(ss_bcfilestat[j]==1){
+              /* already opened */
+              outf_ssbc[ss_nbc]=fopen(outfname,"a");
+            }else{
+              /* create new */
+              outf_ssbc[ss_nbc]=fopen(outfname,"w");
+              fprintf(outf_ssbc[ss_nbc],"%d\n",ss_bc_nside[j]);
+            }
 
-		        ss_bcfilestat[j]=1; /* this file is now opened */ 
-		        ss_nbc+=1;
-	        }
-	      }
-		
+            ss_bcfilestat[j]=1; /* this file is now opened */
+            ss_nbc+=1;
+          }
+        }
+
         /*if(ss_nbc==0){
           printf("WARNING: no BC name found in sideset name \"%s\"!\n",ss_name[i]);
-          // Open a filename with a name of sideset name 
+          // Open a filename with a name of sideset name
           outf_dum=fopen(ss_name[i],"w");
         }*/
 
-	      ss_elmt=malloc(ss_nside[i]*sizeof(int));
+        ss_elmt=malloc(ss_nside[i]*sizeof(int));
         fscanf(inf,"%s",dumc); /* = */
-        for(j=0;j<ss_nside[i]; j++){				
+        for(j=0;j<ss_nside[i]; j++){
           fscanf(inf,"%d,",&ss_elmt[j]); /* read comma separated data */
-          /*for(k=0;k<ns_nbc;k++){			  
+          /*for(k=0;k<ns_nbc;k++){
             fprintf(outf_nsbc[k],"%d\n",itmp);
           }*/
         }
-        
-		    fscanf(inf,"%s",dumc); /* ; */		
-		    fscanf(inf,"%s",token);
-		    /*printf("%s\n",token);
-		    exit(-1)*/
-		    sprintf(stag,"side_ss%d",i+1);	  
-		    if(strcmp(token,stag)==0){
-		      ss_side=malloc(ss_nside[i]*sizeof(int));
-		      fscanf(inf,"%s",dumc); /* = */
-	        for(j=0;j<ss_nside[i]; j++){				
-		        fscanf(inf,"%d,",&ss_side[j]); /* read comma separated data */
-			      /*for(k=0;k<ns_nbc;k++){			  
-			      fprintf(outf_nsbc[k],"%d\n",itmp);
-			      }*/
-	        }
-		    }
+
+        fscanf(inf,"%s",dumc); /* ; */
+        fscanf(inf,"%s",token);
+        /*printf("%s\n",token);
+        exit(-1)*/
+        sprintf(stag,"side_ss%d",i+1);
+        if(strcmp(token,stag)==0){
+          ss_side=malloc(ss_nside[i]*sizeof(int));
+          fscanf(inf,"%s",dumc); /* = */
+          for(j=0;j<ss_nside[i]; j++){
+            fscanf(inf,"%d,",&ss_side[j]); /* read comma separated data */
+            /*for(k=0;k<ns_nbc;k++){
+            fprintf(outf_nsbc[k],"%d\n",itmp);
+            }*/
+          }
+        }
         if(ss_nbc>0){
           /* write to appropriate BC files */
           for(k=0;k<ss_nbc;k++){
             for(j=0;j<ss_nside[i];j++){
               fprintf(outf_ssbc[k],"%d %d\n",ss_elmt[j],ss_side[j]);
-            } 
+            }
           }
         }else{
           /* write to a dummy file with a name of ss_name */
           printf("WARNING: no BC name found in sideset name \"%s\"!\n",ss_name[i]);
-          /* Open a filename with a name of sideset name */ 
+          /* Open a filename with a name of sideset name */
           outf_dum=fopen(ss_name[i],"w");
           fprintf(outf_dum,"%d\n",ss_nside[i]);
           for(j=0;j<ss_nside[i];j++){
@@ -498,8 +498,8 @@
           fclose(outf_dum);
         }
 
-		    free(ss_elmt);
-		    free(ss_side);
+        free(ss_elmt);
+        free(ss_side);
 
         for(j=0;j<ss_nbc;j++){
           fclose(outf_ssbc[j]);
@@ -518,7 +518,7 @@
           ns_nbc+=1;
         }
         fscanf(inf,"%s",dumc);
-        for(j=0; j<ns_nnode[i]; j++){				
+        for(j=0; j<ns_nnode[i]; j++){
           fscanf(inf,"%d,",&itmp);
           for(k=0;k<ns_nbc;k++){
             fprintf(outf_nsbc[ind_outf[k]],"%d\n",itmp);
@@ -532,52 +532,52 @@
           for(i=0;i<nss;i++){
             free(ss_name[i]);
           }
-          free(ss_bcfilestat);		  
+          free(ss_bcfilestat);
           free(ss_nside);
           ss_stat=ON;
-            
+
           /*fclose(outf_nsbc[0]);
           fclose(outf_nsbc[1]);
           fclose(outf_nsbc[2]);*/
-          printf("complete!\n");          
-        }	
+          printf("complete!\n");
+        }
         continue;
-      }          
+      }
     }
   }
- 
+
   /* Connectivity */
-  if(nblk>0 && con_stat!=ON){   
-   
-    /* write connectivity and material id */  
+  if(nblk>0 && con_stat!=ON){
+
+    /* write connectivity and material id */
     for(i=0;i<nblk;i++){
       sprintf(stag,"connect%d",i+1);
       if(strcmp(token,stag)==0){
         blk_count++;
-        
+
         /* open connectivity and material files */
-        if(blk_count==1){          
-          printf("saving connectivity and materials..."); 
+        if(blk_count==1){
+          printf("saving connectivity and materials...");
           sprintf(outfname,"%s_connectivity",fonly);
-          outf_con=fopen(outfname,"w");          
+          outf_con=fopen(outfname,"w");
           fprintf(outf_con,"%d\n",nelmt);
-          
+
           sprintf(outfname,"%s_material_id",fonly);
-          outf_mat=fopen(outfname,"w");				
+          outf_mat=fopen(outfname,"w");
           fprintf(outf_mat,"%d\n",nelmt);
         }
-        
+
         fscanf(inf,"%s",dumc); /* = */
         for(j=0;j<blk_nelmt[i];j++){
           for(k=0;k<blk_nenod[i];k++){
             fscanf(inf,"%d,",&itmp);
-            fprintf(outf_con,"%d ",itmp);				
-          }          
+            fprintf(outf_con,"%d ",itmp);
+          }
           elmt_count++;
           fprintf(outf_con,"\n");/* new line */
           fprintf(outf_mat,"%d\n",i+1);
-        }        
-        
+        }
+
         if(blk_count==nblk){
           con_stat=ON;
           mat_stat=ON;
@@ -586,16 +586,16 @@
           printf("complete!\n");
           fclose(outf_con);
           fclose(outf_mat);
-        }        
+        }
         continue;
-      }        
+      }
     }
-  }		
-  
+  }
+
   /* Coordinates */
   if(strcmp(token,"coord")==0){
     printf("saving coordinates...");
-    fscanf(inf,"%s",dumc);			
+    fscanf(inf,"%s",dumc);
     for(i=0;i<ndim;i++){
       sprintf(outfname,"%s_coord_%s",fonly,coord_name[i]);
       outf_coord[i]=fopen(outfname,"w");
@@ -607,14 +607,14 @@
       }
       fclose(outf_coord[i]);
     }
-	  for(i=0;i<ndim;i++){
+    for(i=0;i<ndim;i++){
       free(coord_name[i]);
     }
-	
+
     coord_stat=ON;
     printf("complete!\n");
     continue;
-  }  
+  }
 }
 
 /* check status */

Modified: seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c
===================================================================
--- seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c	2011-09-09 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/stringmanip.c	2011-09-09 12:18:10 UTC (rev 18889)
@@ -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 12:08:52 UTC (rev 18888)
+++ seismo/3D/SPECFEM3D_GEOTECH/trunk/utilities/write_sos.f90	2011-09-09 12:18:10 UTC (rev 18889)
@@ -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
@@ -92,7 +92,7 @@
 
 write(12,'(a)')'SERVERS'
 write(12,'(a,i2,/)')'number of servers:    ',nproc
-    
+
 ! loop over output slices
 do i_proc=1,nproc
   ! original data
@@ -101,21 +101,21 @@
   write(11,'(a)')'executable: '//trim(server_exec(i_proc))
   write(11,'(a)')'#login id: '
   write(11,'(a)')'data_path: '//trim(data_path(i_proc))
-  
-  ! new data  
+
+  ! new data
   write(12,'(a,i2)')'#Server ',i_proc
   write(12,'(a)')'machine id: '//trim(server_name(i_proc))
   write(12,'(a)')'executable: '//trim(server_exec(i_proc))
   write(12,'(a)')'#login id: '
   write(12,'(a)')'data_path: '//trim(data_path(i_proc))
-  
+
   ! file header
   write(case_head,fmt=format_str)trim(file_head)//'_proc',i_proc
-  
-  write(11,'(a,/)')'casefile: '//trim(case_head)//'_original.case'  
-  
+
+  write(11,'(a,/)')'casefile: '//trim(case_head)//'_original.case'
+
   write(12,'(a,/)')'casefile: '//trim(case_head)//'.case'
-  
+
 enddo
 close(11)
 close(12)



More information about the CIG-COMMITS mailing list