[cig-commits] r3922 - in mc/3D/CitcomS/trunk: . drivers etc lib lib/Common lib/Full lib/Regional module module/Exchanger module/Full module/PyxMPI module/Regional pyre pyre/Components pyre/Components/Advection_diffusion pyre/Components/Sphere pyre/Components/Stokes_solver pyre/Solver tests

leif at geodynamics.org leif at geodynamics.org
Wed Jul 5 19:16:44 PDT 2006


Author: leif
Date: 2006-07-05 19:16:42 -0700 (Wed, 05 Jul 2006)
New Revision: 3922

Added:
   mc/3D/CitcomS/trunk/drivers/citcoms.in
   mc/3D/CitcomS/trunk/drivers/pycitcoms.cc
   mc/3D/CitcomS/trunk/lib/Common/BC_util.c
   mc/3D/CitcomS/trunk/lib/Common/Lith_age.c
   mc/3D/CitcomS/trunk/lib/Common/Parallel_util.c
   mc/3D/CitcomS/trunk/lib/Common/Sphere_util.c
   mc/3D/CitcomS/trunk/lib/Common/solver.h
   mc/3D/CitcomS/trunk/lib/Full/Lith_age_read_files.c
   mc/3D/CitcomS/trunk/lib/Full/Solver.c
   mc/3D/CitcomS/trunk/lib/Regional/Lith_age_read_files.c
   mc/3D/CitcomS/trunk/lib/Regional/Solver.c
   mc/3D/CitcomS/trunk/module/CitcomSmodule.cc
   mc/3D/CitcomS/trunk/module/CitcomSmodule.h
   mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.h
   mc/3D/CitcomS/trunk/module/PyxMPI/
   mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.c
   mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.pyx
   mc/3D/CitcomS/trunk/module/PyxMPI/cmpi.pxd
Removed:
   mc/3D/CitcomS/trunk/lib/Common/Makefile.am
   mc/3D/CitcomS/trunk/lib/Full/Lith_age.c
   mc/3D/CitcomS/trunk/lib/Full/Makefile.am
   mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c
   mc/3D/CitcomS/trunk/lib/Regional/Makefile.am
   mc/3D/CitcomS/trunk/module/Full/Makefile.am
   mc/3D/CitcomS/trunk/module/Regional/Makefile.am
Modified:
   mc/3D/CitcomS/trunk/Makefile.am
   mc/3D/CitcomS/trunk/configure.ac
   mc/3D/CitcomS/trunk/drivers/Citcom.c
   mc/3D/CitcomS/trunk/drivers/Makefile.am
   mc/3D/CitcomS/trunk/etc/CitcomS.pml.in
   mc/3D/CitcomS/trunk/etc/Makefile.am
   mc/3D/CitcomS/trunk/lib/Common/Advection_diffusion.c
   mc/3D/CitcomS/trunk/lib/Common/Construct_arrays.c
   mc/3D/CitcomS/trunk/lib/Common/Convection.c
   mc/3D/CitcomS/trunk/lib/Common/Element_calculations.c
   mc/3D/CitcomS/trunk/lib/Common/General_matrix_functions.c
   mc/3D/CitcomS/trunk/lib/Common/Initial_temperature.c
   mc/3D/CitcomS/trunk/lib/Common/Instructions.c
   mc/3D/CitcomS/trunk/lib/Common/Nodal_mesh.c
   mc/3D/CitcomS/trunk/lib/Common/Problem_related.c
   mc/3D/CitcomS/trunk/lib/Common/Process_buoyancy.c
   mc/3D/CitcomS/trunk/lib/Common/Size_does_matter.c
   mc/3D/CitcomS/trunk/lib/Common/Solver_multigrid.c
   mc/3D/CitcomS/trunk/lib/Common/global_defs.h
   mc/3D/CitcomS/trunk/lib/Common/lith_age.h
   mc/3D/CitcomS/trunk/lib/Common/parallel_related.h
   mc/3D/CitcomS/trunk/lib/Full/Boundary_conditions.c
   mc/3D/CitcomS/trunk/lib/Full/Geometry_cartesian.c
   mc/3D/CitcomS/trunk/lib/Full/Parallel_related.c
   mc/3D/CitcomS/trunk/lib/Full/Read_input_from_files.c
   mc/3D/CitcomS/trunk/lib/Full/Sphere_related.c
   mc/3D/CitcomS/trunk/lib/Full/Version_dependent.c
   mc/3D/CitcomS/trunk/lib/Makefile.am
   mc/3D/CitcomS/trunk/lib/Regional/Boundary_conditions.c
   mc/3D/CitcomS/trunk/lib/Regional/Geometry_cartesian.c
   mc/3D/CitcomS/trunk/lib/Regional/Parallel_related.c
   mc/3D/CitcomS/trunk/lib/Regional/Read_input_from_files.c
   mc/3D/CitcomS/trunk/lib/Regional/Sphere_related.c
   mc/3D/CitcomS/trunk/lib/Regional/Version_dependent.c
   mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.cc
   mc/3D/CitcomS/trunk/module/Exchanger/Makefile.am
   mc/3D/CitcomS/trunk/module/Makefile.am
   mc/3D/CitcomS/trunk/module/Regional/bindings.cc
   mc/3D/CitcomS/trunk/module/Regional/mesher.cc
   mc/3D/CitcomS/trunk/module/Regional/misc.cc
   mc/3D/CitcomS/trunk/module/Regional/misc.h
   mc/3D/CitcomS/trunk/pyre/Components/Advection_diffusion/Advection_diffusion.py
   mc/3D/CitcomS/trunk/pyre/Components/BC.py
   mc/3D/CitcomS/trunk/pyre/Components/CitcomComponent.py
   mc/3D/CitcomS/trunk/pyre/Components/Const.py
   mc/3D/CitcomS/trunk/pyre/Components/IC.py
   mc/3D/CitcomS/trunk/pyre/Components/Launchers.py
   mc/3D/CitcomS/trunk/pyre/Components/Param.py
   mc/3D/CitcomS/trunk/pyre/Components/Phase.py
   mc/3D/CitcomS/trunk/pyre/Components/Sphere/FullSphere.py
   mc/3D/CitcomS/trunk/pyre/Components/Sphere/RegionalSphere.py
   mc/3D/CitcomS/trunk/pyre/Components/Sphere/Sphere.py
   mc/3D/CitcomS/trunk/pyre/Components/Stokes_solver/Incompressible.py
   mc/3D/CitcomS/trunk/pyre/Components/Tracer.py
   mc/3D/CitcomS/trunk/pyre/Components/Visc.py
   mc/3D/CitcomS/trunk/pyre/SimpleApp.py
   mc/3D/CitcomS/trunk/pyre/Solver/FullSolver.py
   mc/3D/CitcomS/trunk/pyre/Solver/RegionalSolver.py
   mc/3D/CitcomS/trunk/pyre/Solver/Solver.py
   mc/3D/CitcomS/trunk/tests/Makefile.am
   mc/3D/CitcomS/trunk/tests/citcomsfull.sh.in
   mc/3D/CitcomS/trunk/tests/citcomsregional.sh.in
   mc/3D/CitcomS/trunk/tests/coupledcitcoms.sh.in
Log:
Added the capability to embed Python instead of extending it.  This
creates one, big monolithic executable, 'pycitcoms', which contains
all CitcomS code and an embedded Python interpreter.  Embedding
works-around MPI portability issues.  (See issue15 for details.)
Embed by default.

Configure with '--disable-embedding' to build the old way with ".so"
extension modules.  This is *NOT* guaranteed to work unless you have a
shared MPI library.  The ugly hacks which made it work in the past
(even with a static "libmpich.a", for example) are no longer
supported.

Merged "Full" and "Regional" into a single library to cut down on
redundancy, both in the source code and in the amount of object code
which is produced.  (I performed this merge so that I would only need
a single 'pycitcoms' intepreter, instead of two.)


Modified: mc/3D/CitcomS/trunk/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -29,7 +29,7 @@
     MAYBE_PYRE = etc examples module pyre tests visual
 endif
 
-SUBDIRS = $(MAYBE_PYTHIA) $(MAYBE_EXCHANGER) lib drivers $(MAYBE_PYRE)
+SUBDIRS = $(MAYBE_PYTHIA) $(MAYBE_EXCHANGER) lib $(MAYBE_PYRE) drivers
 DIST_SUBDIRS = \
 	$(MAYBE_DIST_PYTHIA) $(MAYBE_DIST_EXCHANGER) \
 	lib drivers \

Modified: mc/3D/CitcomS/trunk/configure.ac
===================================================================
--- mc/3D/CitcomS/trunk/configure.ac	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/configure.ac	2006-07-06 02:16:42 UTC (rev 3922)
@@ -46,11 +46,17 @@
     [want_pyre="$withval"],
     [want_pyre=yes])
 AM_CONDITIONAL([COND_PYRE], [test "$want_pyre" = yes])
+AC_ARG_ENABLE([embedding],
+    [AC_HELP_STRING([--enable-embedding],
+        [embed Python with CitcomS in a single executable @<:@default=yes@:>@])],
+    [want_embedding="$enableval"],
+    [want_embedding=yes])
+AM_CONDITIONAL([COND_EMBEDDING], [test "$want_embedding" = yes])
 
 # Checks for programs.
 if test "$want_pyre" = yes; then
     AM_PATH_PYTHON([2.3])
-    CIT_PYTHON_INCDIR
+    CIT_PYTHON_SYSCONFIG
     AC_PATH_PROG([MPIRUN], [mpirun])
     if test -z "$MPIRUN"; then
         AC_MSG_ERROR([program 'mpirun' not found])
@@ -85,6 +91,8 @@
 fi
 CIT_PROG_MPICC
 CIT_PROG_MPICXX
+CC=$MPICXX
+CXX=$MPICXX
 if test "$want_pyre" = yes; then
     CIT_PROG_PYCONFIG
     AC_SUBST([pkgsysconfdir], [\${sysconfdir}/$PACKAGE])
@@ -136,13 +144,8 @@
                  etc/Makefile
                  examples/Makefile
                  lib/Makefile
-                 lib/Common/Makefile
-                 lib/Full/Makefile
-                 lib/Regional/Makefile
                  module/Makefile
                  module/Exchanger/Makefile
-                 module/Full/Makefile
-                 module/Regional/Makefile
                  pyre/Makefile
                  tests/Makefile
                  visual/Makefile])

Modified: mc/3D/CitcomS/trunk/drivers/Citcom.c
===================================================================
--- mc/3D/CitcomS/trunk/drivers/Citcom.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/drivers/Citcom.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -75,7 +75,13 @@
   }
 
   world = MPI_COMM_WORLD;
-  E = citcom_init(&world); /* allocate global E and do initializaion here */
+  E = citcom_init(&world);             /* allocate global E and do initializaion here */
+  
+#ifdef CITCOMS_SOLVER_FULL
+  full_solver_init(E);
+#else
+  regional_solver_init(E);
+#endif
 
   start_time = time = CPU_time0();
   read_instructions(E, argv[1]);

Modified: mc/3D/CitcomS/trunk/drivers/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/drivers/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/drivers/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -24,12 +24,70 @@
 
 # $Id$
 
+bin_PROGRAMS = CitcomSFull CitcomSRegional
+nodist_bin_SCRIPTS =
+
+if COND_PYRE
+
+nodist_bin_SCRIPTS += citcoms
+
+if COND_EMBEDDING
+    bin_PROGRAMS += pycitcoms
+    INTERPRETER = $(bindir)/pycitcoms
+else
+    INTERPRETER = $(PYTHON)
+endif
+
+endif
+
 CC = $(MPICC)
-INCLUDES = -I$(top_srcdir)/lib/Common $(MPIINCLUDES)
-bin_PROGRAMS = CitcomSFull CitcomSRegional
+CXX = $(MPICXX)
+INCLUDES = \
+	-I$(top_srcdir)/lib/Common \
+	$(MPIINCLUDES)
+
+if COND_PYRE
+INCLUDES += \
+	-I$(top_srcdir)/module \
+	-I$(top_srcdir)/module/Exchanger \
+	-I$(PYTHON_INCDIR)
+endif
+
+# legacy drivers
 CitcomSFull_SOURCES = Citcom.c
-CitcomSFull_LDADD = $(top_builddir)/lib/Full/libCitcomSFull.la $(MPILIBS)
+CitcomSFull_CPPFLAGS = -DCITCOMS_SOLVER_FULL
+CitcomSFull_LDADD = $(top_builddir)/lib/libCitcomS.la $(MPILIBS)
 CitcomSRegional_SOURCES = Citcom.c
-CitcomSRegional_LDADD = $(top_builddir)/lib/Regional/libCitcomSRegional.la $(MPILIBS)
+CitcomSRegional_CPPFLAGS =
+CitcomSRegional_LDADD = $(top_builddir)/lib/libCitcomS.la $(MPILIBS)
 
+# citcoms (top-level Python script)
+do_subst = sed \
+	-e 's|[@]INTERPRETER[@]|$(INTERPRETER)|g' \
+	-e 's|[@]PYTHONPATH[@]|$(PYTHONPATH)|g'
+citcoms: $(srcdir)/citcoms.in
+	$(do_subst) < $(srcdir)/citcoms.in > $@ || (rm -f $@ && exit 1)
+CLEANFILES = $(nodist_bin_SCRIPTS)
+EXTRA_DIST = citcoms.in
+
+# pycitcoms (libCitcomS + CitcomSmodule + libExchanger +
+# Exchangermodule + embedded Python interpreter)
+pycitcoms_SOURCES = pycitcoms.cc
+pycitcoms_LDADD = \
+	$(top_builddir)/module/libPyxMPImodule.a \
+	$(top_builddir)/module/Exchanger/libExchangermodule.a \
+	$(top_builddir)/module/libCitcomSmodule.a \
+	$(top_builddir)/lib/libCitcomS.la
+pycitcoms$(EXEEXT): $(pycitcoms_OBJECTS) $(pycitcoms_DEPENDENCIES) 
+	@rm -f pycitcoms$(EXEEXT)
+	$(CXXLINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) \
+		$(pycitcoms_LDFLAGS) $(pycitcoms_OBJECTS) $(pycitcoms_LDADD) \
+		-lExchanger -l_mpimodule -ljournal \
+		$(PYTHON_BLDLIBRARY) \
+		$(MPILIBS) \
+		$(FCLIBS) \
+		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+		$(LIBS) \
+		$(PYTHON_LDLAST)
+
 ## end of Makefile.am

Added: mc/3D/CitcomS/trunk/drivers/citcoms.in
===================================================================
--- mc/3D/CitcomS/trunk/drivers/citcoms.in	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/drivers/citcoms.in	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,69 @@
+#!@INTERPRETER@
+# -*- Python -*-
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#<LicenseText>
+#
+# CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+# Copyright (C) 2002-2005, California Institute of Technology.
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#</LicenseText>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+# re-create the PYTHONPATH at 'configure' time
+import sys
+path = '@PYTHONPATH@'.split(':')
+path.reverse()
+for directory in path:
+    if directory:
+        sys.path.insert(1, directory)
+
+try:
+    # if we are embedding, insert the extension module in the
+    # 'CitcomS' package...
+    import builtin_Exchanger, builtin_CitcomS
+    sys.modules['CitcomS.Exchanger'] = builtin_Exchanger
+    sys.modules['CitcomS.CitcomS'] = builtin_CitcomS
+    from PyxMPI import MPI_Init, MPI_Finalize
+except ImportError:
+    from CitcomS.PyxMPI import MPI_Init, MPI_Finalize
+
+inParallel = False
+for arg in sys.argv:
+    if arg == "--mode=worker":
+        inParallel = True
+        MPI_Init(sys.argv)
+        break
+
+if len(sys.argv) > 1 and sys.argv[1] == "--coupled":
+    del sys.argv[1]
+    from CitcomS.CoupledApp import CoupledApp
+    app = CoupledApp()
+    app.run()
+else:
+    from CitcomS.SimpleApp import SimpleApp
+    app = SimpleApp()
+    app.run()
+
+if inParallel:
+    MPI_Finalize()
+
+#  end of file 

Added: mc/3D/CitcomS/trunk/drivers/pycitcoms.cc
===================================================================
--- mc/3D/CitcomS/trunk/drivers/pycitcoms.cc	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/drivers/pycitcoms.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//<LicenseText>
+//
+// CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+// Copyright (C) 2002-2005, California Institute of Technology.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//</LicenseText>
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#include <Python.h>
+#include <stdio.h>
+#include "CitcomSmodule.h"
+#include "Exchangermodule.h"
+
+PyMODINIT_FUNC initPyxMPI(void);
+static void init_builtin_Exchanger() { PyCitcomSExchanger_init("builtin_Exchanger"); }
+static void init_builtin_CitcomS()   { pyCitcom_init("builtin_CitcomS"); }
+
+struct _inittab inittab[] = {
+    { "PyxMPI", initPyxMPI },
+    { "builtin_Exchanger", init_builtin_Exchanger },
+    { "builtin_CitcomS", init_builtin_CitcomS },
+    { 0, 0 }
+};
+
+int main(int argc, char **argv)
+{
+    /* add our extension module */
+    if (PyImport_ExtendInittab(inittab) == -1) {
+        fprintf(stderr, "%s: PyImport_ExtendInittab failed! Exiting...\n", argv[0]);
+        return 1;
+    }
+    return Py_Main(argc, argv);
+}
+
+// End of file

Modified: mc/3D/CitcomS/trunk/etc/CitcomS.pml.in
===================================================================
--- mc/3D/CitcomS/trunk/etc/CitcomS.pml.in	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/etc/CitcomS.pml.in	2006-07-06 02:16:42 UTC (rev 3922)
@@ -24,10 +24,6 @@
 
         <property name="launcher">@LAUNCHER@</property>
 
-        <component name="launcher">
-            <property name="python-mpi">@PYTHIA_MPIPYTHON@</property>
-        </component>
-
         <component name="mpich">
             <property name="command">@MPIRUN@</property>
         </component>

Modified: mc/3D/CitcomS/trunk/etc/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/etc/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/etc/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -46,7 +46,6 @@
 	-e 's|[@]LAUNCHER[@]|$(LAUNCHER)|g' \
 	-e 's|[@]LAUNCHERS_PY[@]|$(pkgpyexecdir)/Components/Launchers.py|g' \
 	-e 's|[@]MPIRUN[@]|$(MPIRUN)|g' \
-	-e 's|[@]PYTHIA_MPIPYTHON[@]|$(PYTHIA_MPIPYTHON)|g' \
 	-e 's|[@]QSUB[@]|$(QSUB)|g'
 CitcomS.pml: $(srcdir)/CitcomS.pml.in
 	$(do_subst) < $(srcdir)/CitcomS.pml.in > $@ || (rm -f $@ && exit 1)

Modified: mc/3D/CitcomS/trunk/lib/Common/Advection_diffusion.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Advection_diffusion.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Advection_diffusion.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -305,8 +305,6 @@
     void get_global_shape_fn();
     void pg_shape_fn();
     void element_residual();
-    void exchange_node_f();
-    void exchange_node_d();
     void velo_from_element();
 
     int el,e,a,i,a1,m;
@@ -344,7 +342,7 @@
 
         } /* next element */
 
-    exchange_node_d(E,DTdot,E->mesh.levmax);
+    (E->exchange_node_d)(E,DTdot,E->mesh.levmax);
 
     for (m=1;m<=E->sphere.caps_per_proc;m++)
       for(i=1;i<=E->lmesh.nno;i++) {

Added: mc/3D/CitcomS/trunk/lib/Common/BC_util.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/BC_util.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/BC_util.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,138 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include "global_defs.h"
+
+
+void strip_bcs_from_residual(E,Res,level)
+    struct All_variables *E;
+    double **Res;
+    int level;
+{
+    int m,i;
+
+  for (m=1;m<=E->sphere.caps_per_proc;m++)
+    if (E->num_zero_resid[level][m])
+      for(i=1;i<=E->num_zero_resid[level][m];i++)
+         Res[m][E->zero_resid[level][m][i]] = 0.0;
+
+    return;
+}
+
+
+void temperatures_conform_bcs(E)
+     struct All_variables *E;
+{
+  void temperatures_conform_bcs2(struct All_variables *);
+  void assimilate_lith_conform_bcs2(struct All_variables *);
+
+  if(E->control.lith_age) {
+    lith_age_conform_tbc(E);
+    assimilate_lith_conform_bcs(E);
+    }
+  else
+    temperatures_conform_bcs2(E);
+  return;
+}
+
+
+void temperatures_conform_bcs2(E)
+     struct All_variables *E;
+{
+  int j,node;
+  unsigned int type;
+
+  for(j=1;j<=E->sphere.caps_per_proc;j++)
+    for(node=1;node<=E->lmesh.nno;node++)  {
+
+        type = (E->node[j][node] & (TBX | TBZ | TBY));
+
+        switch (type) {
+        case 0:  /* no match, next node */
+            break;
+        case TBX:
+            E->T[j][node] = E->sphere.cap[j].TB[1][node];
+            break;
+        case TBZ:
+            E->T[j][node] = E->sphere.cap[j].TB[3][node];
+            break;
+        case TBY:
+            E->T[j][node] = E->sphere.cap[j].TB[2][node];
+            break;
+        case (TBX | TBZ):     /* clashes ! */
+            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
+            break;
+        case (TBX | TBY):     /* clashes ! */
+            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
+            break;
+        case (TBZ | TBY):     /* clashes ! */
+            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
+            break;
+        case (TBZ | TBY | TBX):     /* clashes ! */
+            E->T[j][node] = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
+            break;
+        }
+
+        /* next node */
+    }
+
+  return;
+
+}
+
+
+void velocities_conform_bcs(E,U)
+    struct All_variables *E;
+    double **U;
+{
+    int node,m;
+
+    const unsigned int typex = VBX;
+    const unsigned int typez = VBZ;
+    const unsigned int typey = VBY;
+
+    const int nno = E->lmesh.nno;
+
+    for(m=1;m<=E->sphere.caps_per_proc;m++)   {
+      for(node=1;node<=nno;node++) {
+
+        if (E->node[m][node] & typex)
+	      U[m][E->id[m][node].doff[1]] = E->sphere.cap[m].VB[1][node];
+ 	if (E->node[m][node] & typey)
+	      U[m][E->id[m][node].doff[2]] = E->sphere.cap[m].VB[2][node];
+	if (E->node[m][node] & typez)
+	      U[m][E->id[m][node].doff[3]] = E->sphere.cap[m].VB[3][node];
+        }
+      }
+
+    return;
+}
+
+
+/* End of file  */
+

Modified: mc/3D/CitcomS/trunk/lib/Common/Construct_arrays.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Construct_arrays.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Construct_arrays.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -315,7 +315,6 @@
     void get_elt_k();
     void get_aug_k();
     void build_diagonal_of_K();
-    void exchange_id_d();
     void parallel_process_termination();
 
     const int dims=E->mesh.nsd,dofs=E->mesh.dof;
@@ -431,7 +430,7 @@
 	    }            /* end for element */
 	}           /* end for m */
 
-     exchange_id_d(E, E->BI[level], level);
+     (E->solver.exchange_id_d)(E, E->BI[level], level);
 
      for(m=1;m<=E->sphere.caps_per_proc;m++)     {
         neq=E->lmesh.NEQ[level];
@@ -458,8 +457,6 @@
     higher_precision *B1,*B2,*B3;
     int *C;
 
-    void exchange_id_d();
-
     const int dims=E->mesh.nsd,dofs=E->mesh.dof;
 
     const int max_eqn = dims*14;
@@ -491,7 +488,7 @@
             }
         }
 
-     exchange_id_d(E, E->temp, level);
+     (E->solver.exchange_id_d)(E, E->temp, level);
 
      for (m=1;m<=E->sphere.caps_per_proc;m++)  {
         for(i=0;i<E->lmesh.NEQ[level];i++)  {
@@ -624,8 +621,6 @@
     void get_aug_k();
     void build_diagonal_of_K();
 
-    void exchange_id_d();
-
     const int dims=E->mesh.nsd;
     const int n=loc_mat_size[E->mesh.nsd];
 
@@ -648,7 +643,7 @@
 	    }
 	}        /* end for m */
 
-      exchange_id_d(E, E->BI[lev], lev);    /*correct BI   */
+      (E->solver.exchange_id_d)(E, E->BI[lev], lev);    /*correct BI   */
 
       for(m=1;m<=E->sphere.caps_per_proc;m++)
 

Modified: mc/3D/CitcomS/trunk/lib/Common/Convection.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Convection.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Convection.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -45,7 +45,6 @@
     void convection_derived_values();
     void convection_allocate_memory();
     void convection_boundary_conditions();
-    void node_locations();
     void convection_initial_fields();
     void twiddle_thumbs();
 
@@ -56,7 +55,6 @@
     E->problem_allocate_vars = convection_allocate_memory;
     E->problem_boundary_conds = convection_boundary_conditions;
     E->problem_initial_fields = convection_initial_fields;
-    E->problem_node_positions = node_locations;
     E->problem_update_node_positions = twiddle_thumbs;
     E->problem_update_bcs = twiddle_thumbs;
 
@@ -121,12 +119,8 @@
      struct All_variables *E;
 
 {
-    void velocity_boundary_conditions();
-    void temperature_boundary_conditions();
-
-    velocity_boundary_conditions(E);      /* universal */
-    temperature_boundary_conditions(E);
-
+    (E->solver.velocity_boundary_conditions)(E);      /* universal */
+    (E->solver.temperature_boundary_conditions)(E);
     return;
 }
 

Modified: mc/3D/CitcomS/trunk/lib/Common/Element_calculations.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Element_calculations.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Element_calculations.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -71,7 +71,6 @@
   void get_elt_f();
   void get_elt_tr();
   void strip_bcs_from_residual();
-  void exchange_id_d();
   void thermal_buoyancy();
 
   const int neq=E->lmesh.neq;
@@ -102,7 +101,7 @@
     }
   }       /* end for m */
 
-  exchange_id_d(E, E->F, lev);
+  (E->solver.exchange_id_d)(E, E->F, lev);
   strip_bcs_from_residual(E,E->F,lev);
   return;
 }
@@ -118,7 +117,6 @@
   void get_elt_f();
   void get_elt_tr_pseudo_surf();
   void strip_bcs_from_residual();
-  void exchange_id_d();
   void thermal_buoyancy();
 
   const int neq=E->lmesh.neq;
@@ -149,7 +147,7 @@
     }
   }       /* end for m */
 
-  exchange_id_d(E, E->F, lev);
+  (E->solver.exchange_id_d)(E, E->F, lev);
   strip_bcs_from_residual(E,E->F,lev);
   return;
 }
@@ -323,7 +321,6 @@
 {
   int  e,i,a,b,a1,a2,a3,ii,m,nodeb;
   void strip_bcs_from_residual();
-  void exchange_id_d();
 
   const int n=loc_mat_size[E->mesh.nsd];
   const int ends=enodes[E->mesh.nsd];
@@ -376,7 +373,7 @@
        }          /* end for e */
      }         /* end for m  */
 
-    exchange_id_d(E, Au, level);
+    (E->solver.exchange_id_d)(E, Au, level);
 
   if(strip_bcs)
      strip_bcs_from_residual(E,Au,level);
@@ -400,8 +397,6 @@
     double UU,U1,U2,U3;
     void strip_bcs_from_residual();
 
-    void exchange_id_d();
-
     int *C;
     higher_precision *B1,*B2,*B3;
 
@@ -448,7 +443,7 @@
        }     /* end for e */
      }     /* end for m */
 
-     exchange_id_d(E, Au, level);
+     (E->solver.exchange_id_d)(E, Au, level);
 
     if (strip_bcs)
 	strip_bcs_from_residual(E,Au,level);
@@ -574,7 +569,6 @@
 {
   int m,e,i,j1,j2,j3,p,a,b,nel,neq;
   void strip_bcs_from_residual();
-  void exchange_id_d();
 
   const int ends=enodes[E->mesh.nsd];
   const int dims=E->mesh.nsd;
@@ -606,7 +600,7 @@
         }       /* end for el */
      }       /* end for m */
 
-  exchange_id_d(E, gradP,  lev); /*  correct gradP   */
+  (E->solver.exchange_id_d)(E, gradP,  lev); /*  correct gradP   */
 
 
   strip_bcs_from_residual(E,gradP,lev);

Modified: mc/3D/CitcomS/trunk/lib/Common/General_matrix_functions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/General_matrix_functions.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/General_matrix_functions.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -582,7 +582,6 @@
     void e_assemble_del2_u();
     void n_assemble_del2_u();
     void strip_bcs_from_residual();
-    void exchange_id_d();
 
     double U1[24],AD1[24],F1[24];
     double w1,w2,w3;
@@ -710,8 +709,8 @@
 	    }          /* end for el  */
 	 }               /* end for m */
 
-        exchange_id_d(E, Ad, level);
-        exchange_id_d(E, d0, level);
+        (E->solver.exchange_id_d)(E, Ad, level);
+        (E->solver.exchange_id_d)(E, d0, level);
 
 	/* completed cycle */
 
@@ -743,7 +742,6 @@
     int eqn1,eqn2,eqn3,gneq;
 
     void n_assemble_del2_u();
-    void exchange_id_d();
 
     double sum1,sum2,sum3,residual,global_vdot(),U1,U2,U3;
 
@@ -827,7 +825,7 @@
 		}
 	    }       /* end for i and m */
 
-      exchange_id_d(E, Ad, level);
+      (E->solver.exchange_id_d)(E, Ad, level);
 
       for (m=1;m<=E->sphere.caps_per_proc;m++)
 	for(i=0;i<neq;i++)
@@ -873,7 +871,6 @@
     void parallel_process_termination();
     void n_assemble_del2_u();
 
-    void exchange_id_d();
     double U1,U2,U3,UU;
     double sor,residual,global_vdot();
 
@@ -980,7 +977,7 @@
 	    Ad[m][eqn3] -= E->temp1[m][eqn3];
 	    }
 
-      exchange_id_d(E, Ad, level);
+      (E->solver.exchange_id_d)(E, Ad, level);
 
       for (m=1;m<=E->sphere.caps_per_proc;m++)
  	for(i=1;i<=E->lmesh.NNO[level];i++)

Modified: mc/3D/CitcomS/trunk/lib/Common/Initial_temperature.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Initial_temperature.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Initial_temperature.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -38,7 +38,6 @@
 
 #include "initial_temperature.h"
 void debug_tic(struct All_variables *);
-void construct_tic_from_input(struct All_variables *);
 void restart_tic_from_file(struct All_variables *);
 
 
@@ -174,7 +173,7 @@
   if (E->control.lith_age)
     lith_age_construct_tic(E);
   else
-    construct_tic_from_input(E);
+    (E->solver.construct_tic_from_input)(E);
 
   return;
 }

Modified: mc/3D/CitcomS/trunk/lib/Common/Instructions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Instructions.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Instructions.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -52,10 +52,8 @@
     void read_initial_settings();
     void tracer_initial_settings();
     void global_default_values();
-    void global_derived_values();
     void construct_ien();
     void construct_surface();
-    void construct_boundary();
     void construct_masks();
     void construct_shape_functions();
     void construct_id();
@@ -68,7 +66,6 @@
     void construct_mat_group();
     void set_up_nonmg_aliases();
     void check_bc_consistency();
-    void node_locations();
     void allocate_velocity_vars();
     void construct_c3x3matrix();
     void construct_surf_det ();
@@ -114,10 +111,10 @@
       open_info(E);
 
     (E->problem_derived_values)(E);   /* call this before global_derived_  */
-    global_derived_values(E);
+    (E->solver.global_derived_values)(E);
 
-    parallel_processor_setup(E);   /* get # of proc in x,y,z */
-    parallel_domain_decomp0(E);  /* get local nel, nno, elx, nox et al */
+    (E->solver.parallel_processor_setup)(E);   /* get # of proc in x,y,z */
+    (E->solver.parallel_domain_decomp0)(E);  /* get local nel, nno, elx, nox et al */
 
     allocate_common_vars(E);
     (E->problem_allocate_vars)(E);
@@ -126,11 +123,11 @@
            /* logical domain */
     construct_ien(E);
     construct_surface(E);
-    construct_boundary(E);
-    parallel_domain_boundary_nodes(E);
+    (E->solver.construct_boundary)(E);
+    (E->solver.parallel_domain_boundary_nodes)(E);
 
            /* physical domain */
-    node_locations (E);
+    (E->solver.node_locations)(E);
 
     if(E->control.tracer==1) {
       tracer_initial_settings(E);
@@ -155,8 +152,8 @@
     construct_id(E);
     construct_lm(E);
 
-    parallel_communication_routs_v(E);
-    parallel_communication_routs_s(E);
+    (E->solver.parallel_communication_routs_v)(E);
+    (E->solver.parallel_communication_routs_s)(E);
 
     construct_sub_element(E);
     construct_shape_functions(E);
@@ -192,9 +189,6 @@
 void read_initial_settings(struct All_variables *E)
 {
   void set_convection_defaults();
-  void set_2dc_defaults();
-  void set_3dc_defaults();
-  void set_3dsphere_defaults();
   void set_cg_defaults();
   void set_mg_defaults();
   int m=E->parallel.me;
@@ -222,23 +216,23 @@
   input_string("Geometry",E->control.GEOMETRY,NULL,m);
   if ( strcmp(E->control.GEOMETRY,"cart2d") == 0)
     { E->control.CART2D = 1;
-    set_2dc_defaults(E);}
+    (E->solver.set_2dc_defaults)(E);}
   else if ( strcmp(E->control.GEOMETRY,"axi") == 0)
     { E->control.AXI = 1;
     }
   else if ( strcmp(E->control.GEOMETRY,"cart2pt5d") == 0)
     { E->control.CART2pt5D = 1;
-    set_2pt5dc_defaults(E);}
+    (E->solver.set_2pt5dc_defaults)(E);}
   else if ( strcmp(E->control.GEOMETRY,"cart3d") == 0)
     { E->control.CART3D = 1;
-    set_3dc_defaults(E);}
+    (E->solver.set_3dc_defaults)(E);}
   else if ( strcmp(E->control.GEOMETRY,"sphere") == 0)
     {
-      set_3dsphere_defaults(E);}
+      (E->solver.set_3dsphere_defaults)(E);}
   else
     { fprintf(E->fp,"Unable to determine geometry, assuming cartesian 2d ... \n");
     E->control.CART2D = 1;
-    set_2dc_defaults(E); }
+    (E->solver.set_2dc_defaults)(E); }
 
   input_string("Solver",E->control.SOLVER_TYPE,NULL,m);
   if ( strcmp(E->control.SOLVER_TYPE,"cgrad") == 0)

Copied: mc/3D/CitcomS/trunk/lib/Common/Lith_age.c (from rev 3905, mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c)
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c	2006-06-28 17:58:12 UTC (rev 3905)
+++ mc/3D/CitcomS/trunk/lib/Common/Lith_age.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,435 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <math.h>
+
+#include "global_defs.h"
+
+//#include "age_related.h"
+#include "parallel_related.h"
+#include "parsing.h"
+#include "lith_age.h"
+
+float find_age_in_MY();
+void lith_age_restart_conform_tbc(struct All_variables *E);
+
+
+void lith_age_input(struct All_variables *E)
+{
+  int m = E->parallel.me;
+
+  E->control.lith_age = 0;
+  E->control.lith_age_time = 0;
+  E->control.temperature_bound_adj = 0;
+
+  input_int("lith_age",&(E->control.lith_age),"0",m);
+  input_float("mantle_temp",&(E->control.lith_age_mantle_temp),"1.0",m);
+
+  if (E->control.lith_age) {
+    input_int("lith_age_time",&(E->control.lith_age_time),"0",m);
+    input_string("lith_age_file",E->control.lith_age_file,"",m);
+    input_float("lith_age_depth",&(E->control.lith_age_depth),"0.0471",m);
+
+    input_int("temperature_bound_adj",&(E->control.temperature_bound_adj),"0",m);
+    if (E->control.temperature_bound_adj) {
+      input_float("depth_bound_adj",&(E->control.depth_bound_adj),"0.1570",m);
+      input_float("width_bound_adj",&(E->control.width_bound_adj),"0.08727",m);
+    }
+  }
+  return;
+}
+
+
+void lith_age_init(struct All_variables *E)
+{
+  char output_file[255];
+  FILE *fp1;
+  int node, i, j, output;
+
+  int gnox, gnoy;
+  gnox=E->mesh.nox;
+  gnoy=E->mesh.noy;
+
+  E->age_t=(float*) malloc((gnox*gnoy+1)*sizeof(float));
+
+  if(E->control.lith_age_time==1)   {
+    /* to open files every timestep */
+    E->control.lith_age_old_cycles = E->monitor.solution_cycles;
+    output = 1;
+    (E->solver.lith_age_read_files)(E,output);
+  }
+  else {
+    /* otherwise, just open for the first timestep */
+    /* NOTE: This is only used if we are adjusting the boundaries */
+    sprintf(output_file,"%s",E->control.lith_age_file);
+    fp1=fopen(output_file,"r");
+    if (fp1 == NULL) {
+      fprintf(E->fp,"(Boundary_conditions #1) Can't open %s\n",output_file);
+      parallel_process_termination();
+    }
+    for(i=1;i<=gnoy;i++)
+      for(j=1;j<=gnox;j++) {
+	node=j+(i-1)*gnox;
+	fscanf(fp1,"%f",&(E->age_t[node]));
+	E->age_t[node]=E->age_t[node]*E->data.scalet;
+      }
+    fclose(fp1);
+  } /* end E->control.lith_age_time == false */
+}
+
+
+void lith_age_restart_tic(struct All_variables *E)
+{
+  int i, j, k, m, node, nodeg;
+  int nox, noy, noz, gnox, gnoy, gnoz;
+  double r1, temp;
+  float age;
+
+  noy=E->lmesh.noy;
+  nox=E->lmesh.nox;
+  noz=E->lmesh.noz;
+
+  gnox=E->mesh.nox;
+  gnoy=E->mesh.noy;
+  gnoz=E->mesh.noz;
+
+  for(m=1;m<=E->sphere.caps_per_proc;m++)
+    for(i=1;i<=noy;i++)
+      for(j=1;j<=nox;j++)
+	for(k=1;k<=noz;k++)  {
+	  nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
+	  node=k+(j-1)*noz+(i-1)*nox*noz;
+	  r1=E->sx[m][3][node];
+	  E->T[m][node] = E->control.lith_age_mantle_temp;
+	  if( r1 >= E->sphere.ro-E->control.lith_age_depth )
+	    { /* if closer than (lith_age_depth) from top */
+	      temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
+	      E->T[m][node] = E->control.lith_age_mantle_temp * erf(temp);
+	    }
+	}
+
+  /* modify temperature BC to be concorded with restarted T */
+  lith_age_restart_conform_tbc(E);
+  temperatures_conform_bcs(E);
+
+  return;
+}
+
+
+void lith_age_restart_conform_tbc(struct All_variables *E)
+{
+  int i, j, k, m, node;
+  int nox, noy, noz;
+  double r1, rout, rin;
+  const float e_4=1.e-4;
+
+  noy = E->lmesh.noy;
+  nox = E->lmesh.nox;
+  noz = E->lmesh.noz;
+  rout = E->sphere.ro;
+  rin = E->sphere.ri;
+
+  for(m=1;m<=E->sphere.caps_per_proc;m++)
+    for(i=1;i<=noy;i++)
+      for(j=1;j<=nox;j++)
+	for(k=1;k<=noz;k++)  {
+	  node=k+(j-1)*noz+(i-1)*nox*noz;
+	  r1=E->sx[m][3][node];
+
+	  if(fabs(r1-rout)>=e_4 && fabs(r1-rin)>=e_4)  {
+	    E->sphere.cap[m].TB[1][node]=E->T[m][node];
+	    E->sphere.cap[m].TB[2][node]=E->T[m][node];
+	    E->sphere.cap[m].TB[3][node]=E->T[m][node];
+	  }
+	}
+
+  return;
+}
+
+
+
+void lith_age_construct_tic(struct All_variables *E)
+{
+  lith_age_restart_tic(E);
+  return;
+}
+
+
+void lith_age_temperature_bound_adj(struct All_variables *E, int lv)
+{
+  int j,node,nno;
+  float ttt2,ttt3,fff2,fff3;
+
+  nno=E->lmesh.nno;
+
+/* NOTE: To start, the relevent bits of "node" are zero. Thus, they only
+get set to TBX/TBY/TBZ if the node is in one of the bounding regions.
+Also note that right now, no matter which bounding region you are in,
+all three get set to true. CPC 6/20/00 */
+
+  if (E->control.temperature_bound_adj) {
+    ttt2=E->control.theta_min + E->control.width_bound_adj;
+    ttt3=E->control.theta_max - E->control.width_bound_adj;
+    fff2=E->control.fi_min + E->control.width_bound_adj;
+    fff3=E->control.fi_max - E->control.width_bound_adj;
+
+    if(lv==E->mesh.gridmax)
+      for(j=1;j<=E->sphere.caps_per_proc;j++)
+	for(node=1;node<=E->lmesh.nno;node++)  {
+	  if( ((E->sx[j][1][node]<=ttt2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[j][1][node]>=ttt3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
+	    /* if < (width) from x bounds AND (depth) from top */
+	    {
+	      E->node[j][node]=E->node[j][node] | TBX;
+	      E->node[j][node]=E->node[j][node] & (~FBX);
+	      E->node[j][node]=E->node[j][node] | TBY;
+	      E->node[j][node]=E->node[j][node] & (~FBY);
+	      E->node[j][node]=E->node[j][node] | TBZ;
+	      E->node[j][node]=E->node[j][node] & (~FBZ);
+	    }
+
+	  if( ((E->sx[j][2][node]<=fff2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
+	    /* if fi is < (width) from side AND z is < (depth) from top */
+	    {
+	      E->node[j][node]=E->node[j][node] | TBX;
+	      E->node[j][node]=E->node[j][node] & (~FBX);
+	      E->node[j][node]=E->node[j][node] | TBY;
+	      E->node[j][node]=E->node[j][node] & (~FBY);
+	      E->node[j][node]=E->node[j][node] | TBZ;
+	      E->node[j][node]=E->node[j][node] & (~FBZ);
+	    }
+
+	  if( ((E->sx[j][2][node]>=fff3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
+	    /* if fi is < (width) from side AND z is < (depth) from top */
+	    {
+	      E->node[j][node]=E->node[j][node] | TBX;
+	      E->node[j][node]=E->node[j][node] & (~FBX);
+	      E->node[j][node]=E->node[j][node] | TBY;
+	      E->node[j][node]=E->node[j][node] & (~FBY);
+	      E->node[j][node]=E->node[j][node] | TBZ;
+	      E->node[j][node]=E->node[j][node] & (~FBZ);
+	    }
+
+	}
+  } /* end E->control.temperature_bound_adj */
+
+  if (E->control.lith_age_time) {
+    if(lv==E->mesh.gridmax)
+      for(j=1;j<=E->sphere.caps_per_proc;j++)
+	for(node=1;node<=E->lmesh.nno;node++)  {
+	  if(E->sx[j][3][node]>=E->sphere.ro-E->control.lith_age_depth)
+	    { /* if closer than (lith_age_depth) from top */
+	      E->node[j][node]=E->node[j][node] | TBX;
+	      E->node[j][node]=E->node[j][node] & (~FBX);
+	      E->node[j][node]=E->node[j][node] | TBY;
+	      E->node[j][node]=E->node[j][node] & (~FBY);
+	      E->node[j][node]=E->node[j][node] | TBZ;
+	      E->node[j][node]=E->node[j][node] & (~FBZ);
+	    }
+
+	}
+  } /* end E->control.lith_age_time */
+
+  return;
+}
+
+
+void lith_age_conform_tbc(struct All_variables *E)
+{
+  int m,j,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,i,k;
+  float ttt2,ttt3,fff2,fff3;
+  float r1,t1,f1,t0,temp;
+  float e_4;
+  FILE *fp1;
+  char output_file[255];
+  int output;
+
+  e_4=1.e-4;
+  output = 0;
+
+  gnox=E->mesh.nox;
+  gnoy=E->mesh.noy;
+  gnoz=E->mesh.noz;
+  nox=E->lmesh.nox;
+  noy=E->lmesh.noy;
+  noz=E->lmesh.noz;
+
+  if(E->control.lith_age_time==1)   {
+    /* to open files every timestep */
+    if (E->control.lith_age_old_cycles != E->monitor.solution_cycles) {
+      /*update so that output only happens once*/
+      output = 1;
+      E->control.lith_age_old_cycles = E->monitor.solution_cycles;
+    }
+    (E->solver.lith_age_read_files)(E,output);
+  }
+
+  /* NOW SET THE TEMPERATURES IN THE BOUNDARY REGIONS */
+  if(E->monitor.solution_cycles>1 && E->control.temperature_bound_adj) {
+    ttt2=E->control.theta_min + E->control.width_bound_adj;
+    ttt3=E->control.theta_max - E->control.width_bound_adj;
+    fff2=E->control.fi_min + E->control.width_bound_adj;
+    fff3=E->control.fi_max - E->control.width_bound_adj;
+
+    for(m=1;m<=E->sphere.caps_per_proc;m++)
+      for(i=1;i<=noy;i++)
+	for(j=1;j<=nox;j++)
+	  for(k=1;k<=noz;k++)  {
+	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
+	    node=k+(j-1)*noz+(i-1)*nox*noz;
+	    t1=E->sx[m][1][node];
+	    f1=E->sx[m][2][node];
+	    r1=E->sx[m][3][node];
+
+	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
+	      if( ((E->sx[m][1][node]<=ttt2) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[m][1][node]>=ttt3) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) ) {
+		/* if < (width) from x bounds AND (depth) from top */
+		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
+		t0 = E->control.lith_age_mantle_temp * erf(temp);
+
+		/* keep the age the same! */
+		E->sphere.cap[m].TB[1][node]=t0;
+		E->sphere.cap[m].TB[2][node]=t0;
+		E->sphere.cap[m].TB[3][node]=t0;
+	      }
+
+	      if( ((E->sx[m][2][node]<=fff2) || (E->sx[m][2][node]>=fff3)) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj) ) {
+		/* if < (width) from y bounds AND (depth) from top */
+
+		/* keep the age the same! */
+		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
+		t0 = E->control.lith_age_mantle_temp * erf(temp);
+
+		E->sphere.cap[m].TB[1][node]=t0;
+		E->sphere.cap[m].TB[2][node]=t0;
+		E->sphere.cap[m].TB[3][node]=t0;
+
+	      }
+
+	    }
+
+	  } /* end k   */
+
+  }   /*  end of solution cycles  && temperature_bound_adj */
+
+
+  /* NOW SET THE TEMPERATURES IN THE LITHOSPHERE IF CHANGING EVERY TIME STEP */
+  if(E->monitor.solution_cycles>1 && E->control.lith_age_time)   {
+    for(m=1;m<=E->sphere.caps_per_proc;m++)
+      for(i=1;i<=noy;i++)
+	for(j=1;j<=nox;j++)
+	  for(k=1;k<=noz;k++)  {
+	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
+	    node=k+(j-1)*noz+(i-1)*nox*noz;
+	    t1=E->sx[m][1][node];
+	    f1=E->sx[m][2][node];
+	    r1=E->sx[m][3][node];
+
+	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
+	      if(  E->sx[m][3][node]>=E->sphere.ro-E->control.lith_age_depth ) {
+		/* if closer than (lith_age_depth) from top */
+
+		/* set a new age from the file */
+		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
+		t0 = E->control.lith_age_mantle_temp * erf(temp);
+
+             
+		E->sphere.cap[m].TB[1][node]=t0;
+		E->sphere.cap[m].TB[2][node]=t0;
+		E->sphere.cap[m].TB[3][node]=t0;
+	      }
+	    }
+	  }     /* end k   */
+  }   /*  end of solution cycles  && lith_age_time */
+
+  return;
+}
+
+
+void assimilate_lith_conform_bcs(struct All_variables *E)
+{
+  float depth, daf, assimilate_new_temp;
+  int m,j,nno,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,ii,i,k;
+  unsigned int type;
+
+  nno=E->lmesh.nno;
+  gnox=E->mesh.nox;
+  gnoy=E->mesh.noy;
+  gnoz=E->mesh.noz;
+  nox=E->lmesh.nox;
+  noy=E->lmesh.noy;
+  noz=E->lmesh.noz;
+
+  for(j=1;j<=E->sphere.caps_per_proc;j++)
+    for(node=1;node<=E->lmesh.nno;node++)  {
+
+        type = (E->node[j][node] & (TBX | TBZ | TBY));
+
+        switch (type) {
+        case 0:  /* no match, next node */
+            break;
+        case TBX:
+            assimilate_new_temp = E->sphere.cap[j].TB[1][node];
+            break;
+        case TBZ:
+            assimilate_new_temp = E->sphere.cap[j].TB[3][node];
+            break;
+        case TBY:
+            assimilate_new_temp = E->sphere.cap[j].TB[2][node];
+            break;
+        case (TBX | TBZ):     /* clashes ! */
+            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
+            break;
+        case (TBX | TBY):     /* clashes ! */
+            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
+            break;
+        case (TBZ | TBY):     /* clashes ! */
+            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
+            break;
+        case (TBZ | TBY | TBX):     /* clashes ! */
+            assimilate_new_temp = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
+            break;
+        } /* end switch */
+
+        switch (type) {
+        case 0:  /* no match, next node */
+            break;
+        default:
+            depth = E->sphere.ro - E->sx[j][3][node];
+            if(depth <= E->control.lith_age_depth) {
+                /* daf == depth_assimilation_factor */
+                daf = 0.5*depth/E->control.lith_age_depth;
+                E->T[j][node] = daf*E->T[j][node] + (1.0-daf)*assimilate_new_temp;
+               }
+            else
+                E->T[j][node] = assimilate_new_temp;
+        } /* end switch */
+
+    } /* next node */
+
+return;
+}

Deleted: mc/3D/CitcomS/trunk/lib/Common/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,81 +0,0 @@
-## Process this file with automake to produce Makefile.in
-##
-##<LicenseText>
-##
-## CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
-## Clint Conrad, Michael Gurnis, and Eun-seo Choi.
-## Copyright (C) 1994-2005, California Institute of Technology.
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-##
-## This program 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 this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-##
-##</LicenseText>
-
-# $Id$
-
-CC = $(MPICC)
-INCLUDES = $(MPIINCLUDES)
-lib_LTLIBRARIES = libCitcomSCommon.la
-libCitcomSCommon_la_SOURCES = \
-	Advection_diffusion.c \
-	advection_diffusion.h \
-	advection.h \
-	Citcom_init.c \
-	citcom_init.h \
-	Construct_arrays.c \
-	Convection.c \
-	convection_variables.h \
-	Drive_solvers.c \
-	drive_solvers.h \
-	Element_calculations.c \
-	element_definitions.h \
-	General_matrix_functions.c \
-	global_defs.h \
-	Global_operations.c \
-	Initial_temperature.c \
-	initial_temperature.h \
-	Instructions.c \
-	Interuption.c \
-	interuption.h \
-	lith_age.h \
-	Nodal_mesh.c \
-	Output.c \
-	output.h \
-	Pan_problem_misc_functions.c \
-	parallel_related.h \
-	Parsing.c \
-	parsing.h \
-	Phase_change.c \
-	phase_change.h \
-	Problem_related.c \
-	Process_buoyancy.c \
-	Shape_functions.c \
-	Size_does_matter.c \
-	Solver_conj_grad.c \
-	Solver_multigrid.c \
-	sphere_communication.h \
-	Sphere_harmonics.c \
-	Stokes_flow_Incomp.c \
-	temperature_descriptions.h \
-	Topo_gravity.c \
-	Tracer_advection.c \
-	tracer_defs.h \
-	viscosity_descriptions.h \
-	Viscosity_structures.c
-libCitcomSCommon_la_LIBADD = $(LIBM)
-libCitcomSCommon_la_LDFLAGS = -release $(VERSION)
-EXTRA_DIST = \
-	Obsolete.c
-
-## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/lib/Common/Nodal_mesh.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Nodal_mesh.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Nodal_mesh.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -54,7 +54,6 @@
      int lev;
 
 { int e,element,node,j,m;
-  void exchange_node_f();
 
   for (m=1;m<=E->sphere.caps_per_proc;m++)
     for(node=1;node<=E->lmesh.NNO[lev];node++)
@@ -67,7 +66,7 @@
     	  PN[m][node] += P[m][element] * E->TWW[lev][m][element].node[j] ; 
     	  }
  
-   exchange_node_f (E,PN,lev);
+   (E->exchange_node_f)(E,PN,lev);
 
    for(m=1;m<=E->sphere.caps_per_proc;m++)
      for(node=1;node<=E->lmesh.NNO[lev];node++)
@@ -160,7 +159,6 @@
   const int vpts=vpoints[nsd];
   const int ends=enodes[nsd];
   double temp_visc;
-  void exchange_node_f();
 
  for (m=1;m<=E->sphere.caps_per_proc;m++)
    for(i=1;i<=E->lmesh.NNO[lev];i++)
@@ -179,7 +177,7 @@
        }
     }
  
-   exchange_node_f (E,VN,lev);
+   (E->exchange_node_f)(E,VN,lev);
 
    for(m=1;m<=E->sphere.caps_per_proc;m++)
      for(n=1;n<=E->lmesh.NNO[lev];n++) 

Added: mc/3D/CitcomS/trunk/lib/Common/Parallel_util.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Parallel_util.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Parallel_util.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,66 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#include <mpi.h>
+#include <stdlib.h>
+#include "global_defs.h"
+
+/* ============================================ */
+/* ============================================ */
+
+void parallel_process_termination()
+{
+
+  MPI_Finalize();
+  exit(8);
+  return;
+  }
+
+/* ============================================ */
+/* ============================================ */
+
+void parallel_process_sync(struct All_variables *E)
+{
+
+  MPI_Barrier(E->parallel.world);
+  return;
+  }
+
+
+/* ==========================   */
+
+ double CPU_time0()
+{
+ double time, MPI_Wtime();
+ time = MPI_Wtime();
+ return (time);
+}
+
+
+/* End of file */

Modified: mc/3D/CitcomS/trunk/lib/Common/Problem_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Problem_related.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Problem_related.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -37,10 +37,7 @@
 void read_velocity_boundary_from_file(E)
      struct All_variables *E;
 {
-    void read_input_files_for_timesteps();
-
-    read_input_files_for_timesteps(E,1,1); /* read velocity(1) and output(1) */
-
+    (E->solver.read_input_files_for_timesteps)(E,1,1); /* read velocity(1) and output(1) */
     return;
 }
 

Modified: mc/3D/CitcomS/trunk/lib/Common/Process_buoyancy.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Process_buoyancy.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Process_buoyancy.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -62,7 +62,6 @@
     struct Shape_function_dA dOmega;
     struct Shape_function_dx GNx;
     void get_global_shape_fn();
-    void exchange_node_f();
     void velo_from_element();
     void sum_across_surface();
     void return_horiz_ave();
@@ -120,7 +119,7 @@
     }             /* end of m */
 
 
-  exchange_node_f(E,flux,lev);
+  (E->exchange_node_f)(E,flux,lev);
 
   for(m=1;m<=E->sphere.caps_per_proc;m++)
      for(i=1;i<=nno;i++)

Modified: mc/3D/CitcomS/trunk/lib/Common/Size_does_matter.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Size_does_matter.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Size_does_matter.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -873,7 +873,6 @@
 { int m,node,i,nint,e,lev;
   int n[9];
   void get_global_shape_fn();
-  void exchange_node_f();
   double myatan(),rtf[4][9],area,centre[4],temp[9],dx1,dx2,dx3;
   struct Shape_function GN;
   struct Shape_function_dA dOmega;
@@ -964,7 +963,7 @@
     }        /* m */
 
   if (E->control.NMULTIGRID||E->control.EMULTIGRID||E->mesh.levmax==lev)
-     exchange_node_f(E,E->MASS[lev],lev);
+     (E->exchange_node_f)(E,E->MASS[lev],lev);
 
   for (m=1;m<=E->sphere.caps_per_proc;m++)
     for(node=1;node<=E->lmesh.NNO[lev];node++)

Modified: mc/3D/CitcomS/trunk/lib/Common/Solver_multigrid.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Solver_multigrid.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Solver_multigrid.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -392,8 +392,6 @@
     float average,w;
     void gather_to_1layer_node ();
 
-    void exchange_node_f();
-
     const int sl_minus = start_lev-1;
     const int nno_minus=E->lmesh.NNO[start_lev-1];
     const int nels_minus=E->lmesh.NEL[start_lev-1];
@@ -423,7 +421,7 @@
                 AD[m][node] += w * E->TWW[sl_minus][m][el].node[i];
          }
 
-   exchange_node_f(E,AD,sl_minus);
+   (E->exchange_node_f)(E,AD,sl_minus);
 
    for(m=1;m<=E->sphere.caps_per_proc;m++)
      for(i=1;i<=nno_minus;i++)  {
@@ -450,8 +448,6 @@
     double average1,average2,average3,w,weight;
     float CPU_time(),time;
 
-    void exchange_id_d();
-
     void from_rtf_to_xyz();
     void from_xyz_to_rtf();
     void gather_to_1layer_id ();
@@ -499,7 +495,7 @@
                 }
 
 
-   exchange_id_d(E, E->temp1, sl_minus);
+   (E->solver.exchange_id_d)(E, E->temp1, sl_minus);
 
    for(m=1;m<=E->sphere.caps_per_proc;m++)
      for(i=1;i<=nno_minus;i++)  {

Added: mc/3D/CitcomS/trunk/lib/Common/Sphere_util.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/Sphere_util.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/Sphere_util.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,96 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+/* Common functions relating to the building and use of mesh locations ... */
+
+#include <math.h>
+#include "global_defs.h"
+
+/* =================================================
+  this routine evenly divides the arc between points
+  1 and 2 in a great cicle. The word "evenly" means
+  anglewise evenly.
+ =================================================*/
+
+void even_divide_arc12(elx,x1,y1,z1,x2,y2,z2,theta,fi)
+ double x1,y1,z1,x2,y2,z2,*theta,*fi;
+ int elx;
+{
+  double dx,dy,dz,xx,yy,zz,myatan();
+  int j, nox;
+
+  nox = elx+1;
+
+  dx = (x2 - x1)/elx;
+  dy = (y2 - y1)/elx;
+  dz = (z2 - z1)/elx;
+  for (j=1;j<=nox;j++)   {
+      xx = x1 + dx*(j-1) + 5.0e-32;
+      yy = y1 + dy*(j-1);
+      zz = z1 + dz*(j-1);
+      theta[j] = acos(zz/sqrt(xx*xx+yy*yy+zz*zz));
+      fi[j]    = myatan(yy,xx);
+      }
+
+   return;
+  }
+
+
+/* =================================================
+  rotate the mesh
+ =================================================*/
+void rotate_mesh(E,m,icap)
+   struct All_variables *E;
+   int icap,m;
+  {
+
+  int i,lev;
+  double t[4],myatan();
+
+  for (lev=E->mesh.levmin;lev<=E->mesh.levmax;lev++)  {
+    for (i=1;i<=E->lmesh.NNO[lev];i++)  {
+      t[0] = E->X[lev][m][1][i]*E->sphere.dircos[1][1]+
+             E->X[lev][m][2][i]*E->sphere.dircos[1][2]+
+             E->X[lev][m][3][i]*E->sphere.dircos[1][3];
+      t[1] = E->X[lev][m][1][i]*E->sphere.dircos[2][1]+
+             E->X[lev][m][2][i]*E->sphere.dircos[2][2]+
+             E->X[lev][m][3][i]*E->sphere.dircos[2][3];
+      t[2] = E->X[lev][m][1][i]*E->sphere.dircos[3][1]+
+             E->X[lev][m][2][i]*E->sphere.dircos[3][2]+
+             E->X[lev][m][3][i]*E->sphere.dircos[3][3];
+
+      E->X[lev][m][1][i] = t[0];
+      E->X[lev][m][2][i] = t[1];
+      E->X[lev][m][3][i] = t[2];
+      E->SX[lev][m][1][i] = acos(t[2]/E->SX[lev][m][3][i]);
+      E->SX[lev][m][2][i] = myatan(t[1],t[0]);
+      }
+    }    /* lev */
+
+  return;
+  }

Modified: mc/3D/CitcomS/trunk/lib/Common/global_defs.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/global_defs.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/global_defs.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -781,6 +781,7 @@
 };
 
 struct All_variables {
+#include "solver.h"
 #include "convection_variables.h"
 #include "viscosity_descriptions.h"
 #include "temperature_descriptions.h"
@@ -889,7 +890,6 @@
     void (* problem_derived_values)(void*);
     void (* problem_allocate_vars)(void*);
     void (* problem_boundary_conds)(void*);
-    void (* problem_node_positions)(void*);
     void (* problem_update_node_positions)(void*);
     void (* problem_initial_fields)(void*);
     void (* problem_tracer_setup)(void*);
@@ -905,8 +905,8 @@
     float (* node_space_function[3])(void*);
 
   /* the following function pointers are for exchanger */
-  void (* exchange_node_d)(void*, double**, int);
-  void (* exchange_node_f)(void*, float**, int);
+  void (* exchange_node_d)(struct All_variables *, double**, int);
+  void (* exchange_node_f)(struct All_variables *, float**, int);
   void (* temperatures_conform_bcs)(void*);
 
 };

Modified: mc/3D/CitcomS/trunk/lib/Common/lith_age.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/lith_age.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/lith_age.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -29,6 +29,5 @@
 void lith_age_init(struct All_variables *E);
 void lith_age_restart_tic(struct All_variables *E);
 void lith_age_construct_tic(struct All_variables *E) ;
-void lith_age_read_files(struct All_variables *E, int output);
 void lith_age_temperature_bound_adj(struct All_variables *E, int lv);
 void lith_age_conform_tbc(struct All_variables *E);

Modified: mc/3D/CitcomS/trunk/lib/Common/parallel_related.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/parallel_related.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/parallel_related.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -36,16 +36,7 @@
 void parallel_process_termination();
 void parallel_process_sync(struct All_variables *E);
 double CPU_time0();
-void parallel_processor_setup(struct All_variables *E);
-void parallel_domain_decomp0(struct All_variables *E);
-void parallel_domain_boundary_nodes(struct All_variables *E);
-void parallel_communication_routs_v(struct All_variables *E);
-void parallel_communication_routs_s(struct All_variables *E);
 void set_communication_sphereh(struct All_variables *E);
-void exchange_id_d(struct All_variables *E, double **U, int lev);
-void exchange_node_d(struct All_variables *E, double **U, int lev);
-void exchange_node_f(struct All_variables *E, float **U, int lev);
-void exchange_snode_f(struct All_variables *E, float **U1, float **U2, int lev);
 
 #ifdef __cplusplus
 }

Added: mc/3D/CitcomS/trunk/lib/Common/solver.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/Common/solver.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Common/solver.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,67 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+/* 
+ * This struct parameterizes those functions which are different
+ * between the full and regional solvers.
+ */
+
+struct Solver {
+
+    /* Boundary_conditions.c */
+    void (*velocity_boundary_conditions)(struct All_variables *);
+    void (*temperature_boundary_conditions)(struct All_variables *);
+
+    /* Geometry_cartesian.c */
+    void (*set_2dc_defaults)(struct All_variables *);
+    void (*set_2pt5dc_defaults)(struct All_variables *);
+    void (*set_3dc_defaults)(struct All_variables *);
+    void (*set_3dsphere_defaults)(struct All_variables *);
+
+    /* Lith_age.c */
+    void (*lith_age_read_files)(struct All_variables *, int);
+
+    /* Parallel_related.c */
+    void (*parallel_processor_setup)(struct All_variables *);
+    void (*parallel_domain_decomp0)(struct All_variables *);
+    void (*parallel_domain_boundary_nodes)(struct All_variables *);
+    void (*parallel_communication_routs_v)(struct All_variables *);
+    void (*parallel_communication_routs_s)(struct All_variables *);
+    void (*exchange_id_d)(struct All_variables *, double **, int);
+
+    /* Read_input_from_files.c */
+    void (*read_input_files_for_timesteps)(struct All_variables *, int, int);
+
+    /* Version_dependent.c */
+    void (*global_derived_values)(struct All_variables *);
+    void (*node_locations)(struct All_variables *);
+    void (*construct_tic_from_input)(struct All_variables *);
+    void (*construct_boundary)(struct All_variables *);
+
+} solver;

Modified: mc/3D/CitcomS/trunk/lib/Full/Boundary_conditions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Boundary_conditions.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Boundary_conditions.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -30,14 +30,19 @@
 #include <math.h>
 
 #include "lith_age.h"
+
 /* ========================================== */
 
-void velocity_boundary_conditions(E)
+static void horizontal_bc();
+static void velocity_apply_periodic_bcs();
+static void temperature_apply_periodic_bcs();
+
+/* ========================================== */
+
+void full_velocity_boundary_conditions(E)
      struct All_variables *E;
 {
   void velocity_imp_vert_bc();
-  void velocity_refl_vert_bc();
-  void horizontal_bc();
   void velocity_apply_periodicapply_periodic_bcs();
   void read_velocity_boundary_from_file();
   void apply_side_sbc();
@@ -101,12 +106,10 @@
 
 /* ========================================== */
 
-void temperature_boundary_conditions(E)
+void full_temperature_boundary_conditions(E)
      struct All_variables *E;
 {
   void temperatures_conform_bcs();
-  void horizontal_bc();
-  void temperature_apply_periodic_bcs();
   void temperature_imposed_vert_bcs();
   int j,lev,noz;
 
@@ -138,27 +141,11 @@
 
    return; }
 
-/* ========================================== */
 
-void velocity_refl_vert_bc(E)
-     struct All_variables *E;
-{
-
-  return;
-}
-
-void temperature_refl_vert_bc(E)
-     struct All_variables *E;
-{
-
-  return;
-}
-
-
 /*  =========================================================  */
 
 
-void horizontal_bc(E,BC,ROW,dirn,value,mask,onoff,level,m)
+static void horizontal_bc(E,BC,ROW,dirn,value,mask,onoff,level,m)
      struct All_variables *E;
      float *BC[];
      int ROW;
@@ -209,7 +196,7 @@
 }
 
 
-void velocity_apply_periodic_bcs(E)
+static void velocity_apply_periodic_bcs(E)
     struct All_variables *E;
 {
   fprintf(E->fp,"Periodic boundary conditions\n");
@@ -217,7 +204,7 @@
   return;
   }
 
-void temperature_apply_periodic_bcs(E)
+static void temperature_apply_periodic_bcs(E)
     struct All_variables *E;
 {
  fprintf(E->fp,"Periodic temperature boundary conditions\n");
@@ -227,111 +214,6 @@
 
 
 
-void strip_bcs_from_residual(E,Res,level)
-    struct All_variables *E;
-    double **Res;
-    int level;
-{
-    int m,i;
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)
-    if (E->num_zero_resid[level][m])
-      for(i=1;i<=E->num_zero_resid[level][m];i++)
-         Res[m][E->zero_resid[level][m][i]] = 0.0;
-
-    return;
-    }
-
-
-void temperatures_conform_bcs(E)
-     struct All_variables *E;
-{
-  void temperatures_conform_bcs2(struct All_variables *);
-  void assimilate_lith_conform_bcs2(struct All_variables *);
-
-  if(E->control.lith_age) {
-    lith_age_conform_tbc(E);
-    assimilate_lith_conform_bcs(E);
-    }
-  else
-    temperatures_conform_bcs2(E);
-  return;
-}
-
-
-void temperatures_conform_bcs2(E)
-     struct All_variables *E;
-{
-    int j,node;
-    unsigned int type;
-
-  for(j=1;j<=E->sphere.caps_per_proc;j++)
-    for(node=1;node<=E->lmesh.nno;node++)  {
-
-	type = (E->node[j][node] & (TBX | TBZ | TBY));
-
-	switch (type) {
-	case 0:  /* no match, next node */
-	    break;
-	case TBX:
-	    E->T[j][node] = E->sphere.cap[j].TB[1][node];
-	    break;
-	case TBZ:
-	    E->T[j][node] = E->sphere.cap[j].TB[3][node];
-	    break;
-	case TBY:
-	    E->T[j][node] = E->sphere.cap[j].TB[2][node];
-	    break;
-	case (TBX | TBZ):     /* clashes ! */
-	    E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
-	    break;
-	case (TBX | TBY):     /* clashes ! */
-	    E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
-	    break;
-	case (TBZ | TBY):     /* clashes ! */
-	    E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
-	    break;
-	case (TBZ | TBY | TBX):     /* clashes ! */
-	    E->T[j][node] = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
-	    break;
-	}
-
-	/* next node */
-    }
-
-return;
-
- }
-
-
-void velocities_conform_bcs(E,U)
-    struct All_variables *E;
-    double **U;
-{
-    int node,m;
-
-    const unsigned int typex = VBX;
-    const unsigned int typez = VBZ;
-    const unsigned int typey = VBY;
-
-    const int nno = E->lmesh.nno;
-
-    for(m=1;m<=E->sphere.caps_per_proc;m++)   {
-      for(node=1;node<=nno;node++) {
-
-        if (E->node[m][node] & typex)
-	      U[m][E->id[m][node].doff[1]] = E->sphere.cap[m].VB[1][node];
- 	if (E->node[m][node] & typey)
-	      U[m][E->id[m][node].doff[2]] = E->sphere.cap[m].VB[2][node];
-	if (E->node[m][node] & typez)
-	      U[m][E->id[m][node].doff[3]] = E->sphere.cap[m].VB[3][node];
-        }
-      }
-
-    return;
-}
-
-
 /* version */
 /* $Id$ */
 

Modified: mc/3D/CitcomS/trunk/lib/Full/Geometry_cartesian.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Geometry_cartesian.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Geometry_cartesian.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -31,7 +31,7 @@
 
 
 
-void set_2dc_defaults(E)
+void full_set_2dc_defaults(E)
      struct All_variables *E;
 { 
 
@@ -41,7 +41,7 @@
 }
 
 
-void set_2pt5dc_defaults(E)  
+void full_set_2pt5dc_defaults(E)  
     struct All_variables *E;
 { 
 
@@ -50,7 +50,7 @@
  
 }
 
-void set_3dc_defaults(E)
+void full_set_3dc_defaults(E)
      struct All_variables *E;
 { 
 
@@ -59,7 +59,7 @@
  
 }
 
-void set_3dsphere_defaults(E)
+void full_set_3dsphere_defaults(E)
      struct All_variables *E;
 { 
   int i,j;

Deleted: mc/3D/CitcomS/trunk/lib/Full/Lith_age.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Lith_age.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Lith_age.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,513 +0,0 @@
-/*
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
- *<LicenseText>
- *
- * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
- * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
- * Copyright (C) 1994-2005, California Institute of Technology.
- *
- * This program 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *</LicenseText>
- * 
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#include <math.h>
-
-#include "global_defs.h"
-
-//#include "age_related.h"
-#include "parallel_related.h"
-#include "parsing.h"
-#include "lith_age.h"
-
-float find_age_in_MY();
-void lith_age_restart_conform_tbc(struct All_variables *E);
-
-
-void lith_age_input(struct All_variables *E)
-{
-  int m = E->parallel.me;
-
-  E->control.lith_age = 0;
-  E->control.lith_age_time = 0;
-  E->control.temperature_bound_adj = 0;
-
-  input_int("lith_age",&(E->control.lith_age),"0",m);
-  input_float("mantle_temp",&(E->control.lith_age_mantle_temp),"1.0",m);
-
-  if (E->control.lith_age) {
-    input_int("lith_age_time",&(E->control.lith_age_time),"0",m);
-    input_string("lith_age_file",E->control.lith_age_file,"",m);
-    input_float("lith_age_depth",&(E->control.lith_age_depth),"0.0471",m);
-
-    input_int("temperature_bound_adj",&(E->control.temperature_bound_adj),"0",m);
-    if (E->control.temperature_bound_adj) {
-      input_float("depth_bound_adj",&(E->control.depth_bound_adj),"0.1570",m);
-      input_float("width_bound_adj",&(E->control.width_bound_adj),"0.08727",m);
-    }
-  }
-  return;
-}
-
-
-void lith_age_init(struct All_variables *E)
-{
-  char output_file[255];
-  FILE *fp1;
-  int node, i, j, output;
-
-  int gnox, gnoy;
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-
-  E->age_t=(float*) malloc((gnox*gnoy+1)*sizeof(float));
-
-  if(E->control.lith_age_time==1)   {
-    /* to open files every timestep */
-    E->control.lith_age_old_cycles = E->monitor.solution_cycles;
-    output = 1;
-    /* lith_age_read_files(E,output); */
-    read_input_files_for_timesteps(E,2,output); /*2 (=action) is for lith_age*/
-  }
-  else {
-    /* otherwise, just open for the first timestep */
-    /* NOTE: This is only used if we are adjusting the boundaries */
-    sprintf(output_file,"%s",E->control.lith_age_file);
-    fp1=fopen(output_file,"r");
-    if (fp1 == NULL) {
-      fprintf(E->fp,"(Boundary_conditions #1) Can't open %s\n",output_file);
-      parallel_process_termination();
-    }
-    for(i=1;i<=gnoy;i++)
-      for(j=1;j<=gnox;j++) {
-	node=j+(i-1)*gnox;
-	fscanf(fp1,"%f",&(E->age_t[node]));
-	E->age_t[node]=E->age_t[node]*E->data.scalet;
-      }
-    fclose(fp1);
-  } /* end E->control.lith_age_time == false */
-}
-
-
-void lith_age_restart_tic(struct All_variables *E)
-{
-  int i, j, k, m, node, nodeg;
-  int nox, noy, noz, gnox, gnoy, gnoz;
-  double r1, temp;
-  float age;
-
-  noy=E->lmesh.noy;
-  nox=E->lmesh.nox;
-  noz=E->lmesh.noz;
-
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for(i=1;i<=noy;i++)
-      for(j=1;j<=nox;j++)
-	for(k=1;k<=noz;k++)  {
-	  nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	  node=k+(j-1)*noz+(i-1)*nox*noz;
-	  r1=E->sx[m][3][node];
-	  E->T[m][node] = E->control.lith_age_mantle_temp;
-	  if( r1 >= E->sphere.ro-E->control.lith_age_depth )
-	    { /* if closer than (lith_age_depth) from top */
-	      temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-	      E->T[m][node] = E->control.lith_age_mantle_temp * erf(temp);
-	    }
-	}
-
-  /* modify temperature BC to be concorded with restarted T */
-  lith_age_restart_conform_tbc(E);
-  temperatures_conform_bcs(E);
-
-  return;
-}
-
-
-void lith_age_restart_conform_tbc(struct All_variables *E)
-{
-  int i, j, k, m, node;
-  int nox, noy, noz;
-  double r1, rout, rin;
-  const float e_4=1.e-4;
-
-  noy = E->lmesh.noy;
-  nox = E->lmesh.nox;
-  noz = E->lmesh.noz;
-  rout = E->sphere.ro;
-  rin = E->sphere.ri;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for(i=1;i<=noy;i++)
-      for(j=1;j<=nox;j++)
-	for(k=1;k<=noz;k++)  {
-	  node=k+(j-1)*noz+(i-1)*nox*noz;
-	  r1=E->sx[m][3][node];
-
-	  if(fabs(r1-rout)>=e_4 && fabs(r1-rin)>=e_4)  {
-	    E->sphere.cap[m].TB[1][node]=E->T[m][node];
-	    E->sphere.cap[m].TB[2][node]=E->T[m][node];
-	    E->sphere.cap[m].TB[3][node]=E->T[m][node];
-	  }
-	}
-
-  return;
-}
-
-
-
-void lith_age_construct_tic(struct All_variables *E)
-{
-  lith_age_restart_tic(E);
-  return;
-}
-
-
-void lith_age_read_files(struct All_variables *E, int output)
-{
-  FILE *fp1, *fp2;
-  float age, newage1, newage2;
-  char output_file1[255],output_file2[255];
-  float inputage1, inputage2;
-  int nox,noz,noy,nox1,noz1,noy1,lev;
-  int i,j,node;
-  int intage, pos_age;
-
-  nox=E->mesh.nox;
-  noy=E->mesh.noy;
-  noz=E->mesh.noz;
-  nox1=E->lmesh.nox;
-  noz1=E->lmesh.noz;
-  noy1=E->lmesh.noy;
-  lev=E->mesh.levmax;
-
-  age=find_age_in_MY(E);
-
-  if (age < 0.0) { /* age is negative -> use age=0 for input files */
-    intage = 0;
-    newage2 = newage1 = 0.0;
-    pos_age = 0;
-  }
-  else {
-    intage = age;
-    newage1 = 1.0*intage;
-    newage2 = 1.0*intage + 1.0;
-    pos_age = 1;
-  }
-
-  /* read ages for lithosphere tempperature boundary conditions */
-  sprintf(output_file1,"%s%0.0f",E->control.lith_age_file,newage1);
-  sprintf(output_file2,"%s%0.0f",E->control.lith_age_file,newage2);
-  fp1=fopen(output_file1,"r");
-  if (fp1 == NULL) {
-    fprintf(E->fp,"(Problem_related #6) Cannot open %s\n",output_file1);
-    parallel_process_termination();
-  }
-  if (pos_age) {
-    fp2=fopen(output_file2,"r");
-    if (fp2 == NULL) {
-      fprintf(E->fp,"(Problem_related #7) Cannot open %s\n",output_file2);
-    parallel_process_termination();
-    }
-  }
-  if((E->parallel.me==0) && output) {
-    fprintf(E->fp,"Age: Starting Age = %g, Elapsed time = %g, Current Age = %g\n",E->control.start_age,E->monitor.elapsed_time,age);
-    fprintf(E->fp,"Age: File1 = %s\n",output_file1);
-    if (pos_age)
-      fprintf(E->fp,"Age: File2 = %s\n",output_file2);
-    else
-      fprintf(E->fp,"Age: File2 = No file inputted (negative age)\n");
-  }
-
-  for(i=1;i<=noy;i++)
-    for(j=1;j<=nox;j++) {
-      node=j+(i-1)*nox;
-      fscanf(fp1,"%f",&inputage1);
-      if (pos_age) { /* positive ages - we must interpolate */
-	fscanf(fp2,"%f",&inputage2);
-	E->age_t[node] = (inputage1 + (inputage2-inputage1)/(newage2-newage1)*(age-newage1))/E->data.scalet;
-      }
-      else { /* negative ages - don't do the interpolation */
-	E->age_t[node] = inputage1;
-      }
-    }
-  fclose(fp1);
-  if (pos_age) fclose(fp2);
-
-  return;
-}
-
-
-void lith_age_temperature_bound_adj(struct All_variables *E, int lv)
-{
-  int j,node,nno;
-  float ttt2,ttt3,fff2,fff3;
-
-  nno=E->lmesh.nno;
-
-  ttt2=E->control.theta_min + E->control.width_bound_adj;
-  ttt3=E->control.theta_max - E->control.width_bound_adj;
-  fff2=E->control.fi_min + E->control.width_bound_adj;
-  fff3=E->control.fi_max - E->control.width_bound_adj;
-
-
-/* NOTE: To start, the relevent bits of "node" are zero. Thus, they only
-get set to TBX/TBY/TBZ if the node is in one of the bounding regions.
-Also note that right now, no matter which bounding region you are in,
-all three get set to true. CPC 6/20/00 */
-
-  if (E->control.temperature_bound_adj) {
-    if(lv==E->mesh.gridmax)
-      for(j=1;j<=E->sphere.caps_per_proc;j++)
-	for(node=1;node<=E->lmesh.nno;node++)  {
-	  if( ((E->sx[j][1][node]<=ttt2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[j][1][node]>=ttt3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if < (width) from x bounds AND (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	  if( ((E->sx[j][2][node]<=fff2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if fi is < (width) from side AND z is < (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	  if( ((E->sx[j][2][node]>=fff3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if fi is < (width) from side AND z is < (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	}
-  } /* end E->control.temperature_bound_adj */
-
-  if (E->control.lith_age_time) {
-    if(lv==E->mesh.gridmax)
-      for(j=1;j<=E->sphere.caps_per_proc;j++)
-	for(node=1;node<=E->lmesh.nno;node++)  {
-	  if(E->sx[j][3][node]>=E->sphere.ro-E->control.lith_age_depth)
-	    { /* if closer than (lith_age_depth) from top */
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	}
-  } /* end E->control.lith_age_time */
-
-  return;
-}
-
-
-void lith_age_conform_tbc(struct All_variables *E)
-{
-  int m,j,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,i,k;
-  float ttt2,ttt3,fff2,fff3;
-  float r1,t1,f1,t0,temp;
-  float e_4;
-  FILE *fp1;
-  char output_file[255];
-  int output;
-
-  e_4=1.e-4;
-  output = 0;
-
-  ttt2=E->control.theta_min + E->control.width_bound_adj;
-  ttt3=E->control.theta_max - E->control.width_bound_adj;
-  fff2=E->control.fi_min + E->control.width_bound_adj;
-  fff3=E->control.fi_max - E->control.width_bound_adj;
-
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-  nox=E->lmesh.nox;
-  noy=E->lmesh.noy;
-  noz=E->lmesh.noz;
-
-  if(E->control.lith_age_time==1)   {
-    /* to open files every timestep */
-    if (E->control.lith_age_old_cycles != E->monitor.solution_cycles) {
-      /*update so that output only happens once*/
-      output = 1;
-      E->control.lith_age_old_cycles = E->monitor.solution_cycles;
-    }
-    /* lith_age_read_files(E,output);a*/
-    read_input_files_for_timesteps(E,2,output); /*2 (=action) is for lith_age*/
-  }
-
-  /* NOW SET THE TEMPERATURES IN THE BOUNDARY REGIONS */
-  if(E->monitor.solution_cycles>1 && E->control.temperature_bound_adj) {
-    for(m=1;m<=E->sphere.caps_per_proc;m++)
-      for(i=1;i<=noy;i++)
-	for(j=1;j<=nox;j++)
-	  for(k=1;k<=noz;k++)  {
-	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	    node=k+(j-1)*noz+(i-1)*nox*noz;
-	    t1=E->sx[m][1][node];
-	    f1=E->sx[m][2][node];
-	    r1=E->sx[m][3][node];
-
-	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
-	      if( ((E->sx[m][1][node]<=ttt2) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[m][1][node]>=ttt3) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) ) {
-		/* if < (width) from x bounds AND (depth) from top */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-		/* keep the age the same! */
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-	      }
-
-	      if( ((E->sx[m][2][node]<=fff2) || (E->sx[m][2][node]>=fff3)) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj) ) {
-		/* if < (width) from y bounds AND (depth) from top */
-
-		/* keep the age the same! */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-
-	      }
-
-	    }
-
-	  } /* end k   */
-
-  }   /*  end of solution cycles  && temperature_bound_adj */
-
-
-  /* NOW SET THE TEMPERATURES IN THE LITHOSPHERE IF CHANGING EVERY TIME STEP */
-  if(E->monitor.solution_cycles>1 && E->control.lith_age_time)   {
-    for(m=1;m<=E->sphere.caps_per_proc;m++)
-      for(i=1;i<=noy;i++)
-	for(j=1;j<=nox;j++)
-	  for(k=1;k<=noz;k++)  {
-	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	    node=k+(j-1)*noz+(i-1)*nox*noz;
-	    t1=E->sx[m][1][node];
-	    f1=E->sx[m][2][node];
-	    r1=E->sx[m][3][node];
-
-	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
-	      if(  E->sx[m][3][node]>=E->sphere.ro-E->control.lith_age_depth ) {
-		/* if closer than (lith_age_depth) from top */
-
-		/* set a new age from the file */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-	      }
-	    }
-	  }     /* end k   */
-  }   /*  end of solution cycles  && lith_age_time */
-
-  return;
-}
-
-
-
-void assimilate_lith_conform_bcs(struct All_variables *E)
-{
-  float depth, daf, assimilate_new_temp;
-  int m,j,nno,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,ii,i,k;
-  unsigned int type;
-
-  nno=E->lmesh.nno;
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-  nox=E->lmesh.nox;
-  noy=E->lmesh.noy;
-  noz=E->lmesh.noz;
-
-  for(j=1;j<=E->sphere.caps_per_proc;j++)
-    for(node=1;node<=E->lmesh.nno;node++)  {
-
-        type = (E->node[j][node] & (TBX | TBZ | TBY));
-
-        switch (type) {
-        case 0:  /* no match, next node */
-            break;
-        case TBX:
-            assimilate_new_temp = E->sphere.cap[j].TB[1][node];
-            break;
-        case TBZ:
-            assimilate_new_temp = E->sphere.cap[j].TB[3][node];
-            break;
-        case TBY:
-            assimilate_new_temp = E->sphere.cap[j].TB[2][node];
-            break;
-        case (TBX | TBZ):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        case (TBX | TBY):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY | TBX):     /* clashes ! */
-            assimilate_new_temp = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        } /* end switch */
-
-        switch (type) {
-        case 0:  /* no match, next node */
-            break;
-        default:
-            depth = E->sphere.ro - E->sx[j][3][node];
-            if(depth <= E->control.lith_age_depth) {
-                /* daf == depth_assimilation_factor */
-                daf = 0.5*depth/E->control.lith_age_depth;
-                E->T[j][node] = daf*E->T[j][node] + (1.0-daf)*assimilate_new_temp;
-               }
-            else
-                E->T[j][node] = assimilate_new_temp;
-        } /* end switch */
-
-    } /* next node */
-
-return;
-}

Added: mc/3D/CitcomS/trunk/lib/Full/Lith_age_read_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Lith_age_read_files.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Lith_age_read_files.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,40 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#include "global_defs.h"
+
+
+void full_lith_age_read_files(struct All_variables *E, int output)
+{
+    full_read_input_files_for_timesteps(E,2,output); /*2 (=action) is for lith_age*/
+    return;
+}
+
+
+/* End of file */

Deleted: mc/3D/CitcomS/trunk/lib/Full/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,45 +0,0 @@
-## Process this file with automake to produce Makefile.in
-##
-##<LicenseText>
-##
-## CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
-## Clint Conrad, Michael Gurnis, and Eun-seo Choi.
-## Copyright (C) 1994-2005, California Institute of Technology.
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-##
-## This program 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 this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-##
-##</LicenseText>
-
-# $Id$
-
-CC = $(MPICC)
-INCLUDES = -I$(top_srcdir)/lib/Common $(MPIINCLUDES)
-lib_LTLIBRARIES = libCitcomSFull.la
-libCitcomSFull_la_SOURCES = \
-	Boundary_conditions.c \
-	Geometry_cartesian.c \
-	Lith_age.c \
-	Parallel_related.c \
-	Read_input_from_files.c \
-	Sphere_related.c \
-	Version_dependent.c
-libCitcomSFull_la_LIBADD = \
-	$(top_builddir)/lib/Common/libCitcomSCommon.la \
-	$(LIBM)
-libCitcomSFull_la_LDFLAGS = -release $(VERSION)
-EXTRA_DIST = \
-	Obsolete.c
-
-## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/lib/Full/Parallel_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Parallel_related.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Parallel_related.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -36,46 +36,18 @@
 
 #include "parallel_related.h"
 
-void set_horizontal_communicator(struct All_variables*);
-void set_vertical_communicator(struct All_variables*);
 
+static void set_horizontal_communicator(struct All_variables*);
+static void set_vertical_communicator(struct All_variables*);
 
+static void exchange_node_d(struct All_variables *, double**, int);
+static void exchange_node_f(struct All_variables *, float**, int);
 
-/* ============================================ */
-/* ============================================ */
 
-void parallel_process_termination()
-{
-
-  MPI_Finalize();
-  exit(8);
-  return;
-  }
-
 /* ============================================ */
 /* ============================================ */
 
-void parallel_process_sync(struct All_variables *E)
-{
-
-  MPI_Barrier(E->parallel.world);
-  return;
-  }
-
-
-/* ==========================   */
-
- double CPU_time0()
-{
- double time, MPI_Wtime();
- time = MPI_Wtime();
- return (time);
-}
-
-/* ============================================ */
-/* ============================================ */
-
-void parallel_processor_setup(struct All_variables *E)
+void full_parallel_processor_setup(struct All_variables *E)
   {
 
   int i,j,k,m,me,temp,pid_surf;
@@ -198,7 +170,7 @@
 
 
 
-void set_horizontal_communicator(struct All_variables *E)
+static void set_horizontal_communicator(struct All_variables *E)
 {
   MPI_Group world_g, horizon_g;
   int i,j,k,m,n;
@@ -235,7 +207,7 @@
 }
 
 
-void set_vertical_communicator(struct All_variables *E)
+static void set_vertical_communicator(struct All_variables *E)
 {
   MPI_Group world_g, vertical_g;
   int i,j,k,m;
@@ -273,7 +245,7 @@
 get element information for each processor.
  ========================================================================= */
 
-void parallel_domain_decomp0(struct All_variables *E)
+void full_parallel_domain_decomp0(struct All_variables *E)
   {
 
   int i,nox,noz,noy,me;
@@ -379,7 +351,7 @@
  exchange info across the boundaries
  ============================================ */
 
-void parallel_domain_boundary_nodes(E)
+void full_parallel_domain_boundary_nodes(E)
   struct All_variables *E;
   {
 
@@ -560,7 +532,10 @@
  assuming fault nodes are in the top row of processors
  ============================================ */
 
-void parallel_communication_routs_v(E)
+static void face_eqn_node_to_pass(struct All_variables *, int, int, int, int);
+static void line_eqn_node_to_pass(struct All_variables *, int, int, int, int, int, int);
+
+void full_parallel_communication_routs_v(E)
   struct All_variables *E;
   {
 
@@ -569,9 +544,6 @@
   int me, nprocx,nprocy,nprocz,nprocxz;
   int tscaps,cap,scap,large,npass,lx,ly,lz,temp,layer;
 
-  void face_eqn_node_to_pass(struct All_variables *, int, int, int, int);
-  void line_eqn_node_to_pass(struct All_variables *, int, int, int, int, int, int);
-
   const int dims=E->mesh.nsd;
 
   me = E->parallel.me;
@@ -820,7 +792,7 @@
  assuming fault nodes are in the top row of processors
  ============================================ */
 
-void parallel_communication_routs_s(E)
+void full_parallel_communication_routs_s(E)
   struct All_variables *E;
   {
 
@@ -912,7 +884,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void face_eqn_node_to_pass(E,lev,m,npass,bd)
+static void face_eqn_node_to_pass(E,lev,m,npass,bd)
   struct All_variables *E;
   int lev,m,npass,bd;
 {
@@ -937,7 +909,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void line_eqn_node_to_pass(E,lev,m,npass,num_node,offset,stride)
+static void line_eqn_node_to_pass(E,lev,m,npass,num_node,offset,stride)
   struct All_variables *E;
   int lev,m,npass,num_node,offset,stride;
 {
@@ -980,7 +952,7 @@
 by Tan2 7/21, 2003
 ================================================ */
 
-void exchange_id_d(E, U, lev)
+void full_exchange_id_d(E, U, lev)
  struct All_variables *E;
  double **U;
  int lev;
@@ -1096,7 +1068,7 @@
 
 /* ================================================ */
 /* ================================================ */
-void exchange_node_d(E, U, lev)
+static void exchange_node_d(E, U, lev)
  struct All_variables *E;
  double **U;
  int lev;
@@ -1220,7 +1192,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void exchange_node_f(E, U, lev)
+static void exchange_node_f(E, U, lev)
  struct All_variables *E;
  float **U;
  int lev;
@@ -1344,7 +1316,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void exchange_snode_f(E, U1, U2, lev)
+static void exchange_snode_f(E, U1, U2, lev)
  struct All_variables *E;
  float **U1,**U2;
  int lev;

Modified: mc/3D/CitcomS/trunk/lib/Full/Read_input_from_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Read_input_from_files.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Read_input_from_files.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -35,7 +35,7 @@
   Open these files, read in results, and average if necessary
 =========================================================================*/
 
-void read_input_files_for_timesteps(E,action,output)
+void full_read_input_files_for_timesteps(E,action,output)
     struct All_variables *E;
     int action, output;
 {

Added: mc/3D/CitcomS/trunk/lib/Full/Solver.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Solver.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Solver.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,100 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#include "global_defs.h"
+
+
+/* Boundary_conditions.c */
+void full_velocity_boundary_conditions(struct All_variables *);
+void full_temperature_boundary_conditions(struct All_variables *);
+
+/* Geometry_cartesian.c */
+void full_set_2dc_defaults(struct All_variables *);
+void full_set_2pt5dc_defaults(struct All_variables *);
+void full_set_3dc_defaults(struct All_variables *);
+void full_set_3dsphere_defaults(struct All_variables *);
+
+/* Lith_age.c */
+void full_lith_age_read_files(struct All_variables *, int);
+
+/* Parallel_related.c */
+void full_parallel_processor_setup(struct All_variables *);
+void full_parallel_domain_decomp0(struct All_variables *);
+void full_parallel_domain_boundary_nodes(struct All_variables *);
+void full_parallel_communication_routs_v(struct All_variables *);
+void full_parallel_communication_routs_s(struct All_variables *);
+void full_exchange_id_d(struct All_variables *, double **, int);
+
+/* Read_input_from_files.c */
+void full_read_input_files_for_timesteps(struct All_variables *, int, int);
+
+/* Version_dependent.c */
+void full_global_derived_values(struct All_variables *);
+void full_node_locations(struct All_variables *);
+void full_construct_tic_from_input(struct All_variables *);
+void full_construct_boundary(struct All_variables *);
+
+
+void full_solver_init(struct All_variables *E)
+{
+    /* Boundary_conditions.c */
+    E->solver.velocity_boundary_conditions = full_velocity_boundary_conditions;
+    E->solver.temperature_boundary_conditions = full_temperature_boundary_conditions;
+
+    /* Geometry_cartesian.c */
+    E->solver.set_2dc_defaults = full_set_2dc_defaults;
+    E->solver.set_2pt5dc_defaults = full_set_2pt5dc_defaults;
+    E->solver.set_3dc_defaults = full_set_3dc_defaults;
+    E->solver.set_3dsphere_defaults = full_set_3dsphere_defaults;
+
+    /* Lith_age.c */
+    E->solver.lith_age_read_files = full_lith_age_read_files;
+
+    /* Parallel_related.c */
+    E->solver.parallel_processor_setup = full_parallel_processor_setup;
+    E->solver.parallel_domain_decomp0 = full_parallel_domain_decomp0;
+    E->solver.parallel_domain_boundary_nodes = full_parallel_domain_boundary_nodes;
+    E->solver.parallel_communication_routs_v = full_parallel_communication_routs_v;
+    E->solver.parallel_communication_routs_s = full_parallel_communication_routs_s;
+    E->solver.exchange_id_d = full_exchange_id_d;
+
+    /* Read_input_from_files.c */
+    E->solver.read_input_files_for_timesteps = full_read_input_files_for_timesteps;
+
+    /* Version_dependent.c */
+    E->solver.global_derived_values = full_global_derived_values;
+    E->solver.node_locations = full_node_locations;
+    E->solver.construct_tic_from_input = full_construct_tic_from_input;
+    E->solver.construct_boundary = full_construct_boundary;
+    
+    return;
+}
+
+
+/* End of file */

Modified: mc/3D/CitcomS/trunk/lib/Full/Sphere_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Sphere_related.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Sphere_related.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -33,7 +33,7 @@
 #include "element_definitions.h"
 #include "global_defs.h"
 
-void coord_of_cap(E,m,icap)
+void full_coord_of_cap(E,m,icap)
    struct All_variables *E;
    int icap,m;
   {
@@ -142,66 +142,3 @@
   return;
   }
 
-/* =================================================
-  this routine evenly divides the arc between points
-  1 and 2 in a great cicle. The word "evenly" means 
-  anglewise evenly.
- =================================================*/
-
-void even_divide_arc12(elx,x1,y1,z1,x2,y2,z2,theta,fi)
- double x1,y1,z1,x2,y2,z2,*theta,*fi;
- int elx;
-{
-  double dx,dy,dz,xx,yy,zz,myatan();
-  int j, nox;
-
-  nox = elx+1;
-
-  dx = (x2 - x1)/elx;
-  dy = (y2 - y1)/elx;
-  dz = (z2 - z1)/elx;
-  for (j=1;j<=nox;j++)   {
-      xx = x1 + dx*(j-1) + 5.0e-32;
-      yy = y1 + dy*(j-1);
-      zz = z1 + dz*(j-1);
-      theta[j] = acos(zz/sqrt(xx*xx+yy*yy+zz*zz));
-      fi[j]    = myatan(yy,xx);
-      }
-
-   return;
-  }
-
-
-/* =================================================
-  rotate the mesh 
- =================================================*/
-void rotate_mesh(E,m,icap)
-   struct All_variables *E;
-   int icap,m;
-  {
-
-  int i,lev;
-  double t[4],myatan();
-
-  for (lev=E->mesh.levmin;lev<=E->mesh.levmax;lev++)  {
-    for (i=1;i<=E->lmesh.NNO[lev];i++)  {
-      t[0] = E->X[lev][m][1][i]*E->sphere.dircos[1][1]+ 
-             E->X[lev][m][2][i]*E->sphere.dircos[1][2]+ 
-             E->X[lev][m][3][i]*E->sphere.dircos[1][3]; 
-      t[1] = E->X[lev][m][1][i]*E->sphere.dircos[2][1]+ 
-             E->X[lev][m][2][i]*E->sphere.dircos[2][2]+ 
-             E->X[lev][m][3][i]*E->sphere.dircos[2][3]; 
-      t[2] = E->X[lev][m][1][i]*E->sphere.dircos[3][1]+ 
-             E->X[lev][m][2][i]*E->sphere.dircos[3][2]+ 
-             E->X[lev][m][3][i]*E->sphere.dircos[3][3]; 
-
-      E->X[lev][m][1][i] = t[0];
-      E->X[lev][m][2][i] = t[1];
-      E->X[lev][m][3][i] = t[2];
-      E->SX[lev][m][1][i] = acos(t[2]/E->SX[lev][m][3][i]);
-      E->SX[lev][m][2][i] = myatan(t[1],t[0]);
-      }
-    }    /* lev */
-
-  return;
-  }

Modified: mc/3D/CitcomS/trunk/lib/Full/Version_dependent.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full/Version_dependent.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Full/Version_dependent.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -32,7 +32,7 @@
 
 // Setup global mesh parameters
 //
-void global_derived_values(E)
+void full_global_derived_values(E)
   struct All_variables *E;
 {
   int d,i,nox,noz,noy;
@@ -134,7 +134,7 @@
 
    =================================================  */
 
-void node_locations(E)
+void full_node_locations(E)
      struct All_variables *E;
 {
   int i,j,k,ii,lev;
@@ -144,7 +144,7 @@
   char output_file[255], a[255];
   FILE *fp1;
 
-  void coord_of_cap();
+  void full_coord_of_cap();
   void rotate_mesh ();
   void compute_angle_surf_area ();
 
@@ -214,7 +214,7 @@
 
   for (j=1;j<=E->sphere.caps_per_proc;j++)   {
      ii = E->sphere.capid[j];
-     coord_of_cap(E,j,ii);
+     full_coord_of_cap(E,j,ii);
      }
 
   /* rotate the mesh to avoid two poles on mesh points */
@@ -252,7 +252,7 @@
 
 
 
-void construct_tic_from_input(struct All_variables *E)
+void full_construct_tic_from_input(struct All_variables *E)
 {
   int i, j, k, kk, m, p, node;
   int nox, noy, noz, gnoz;
@@ -322,7 +322,7 @@
 
 /* setup boundary node and element arrays for bookkeeping */
 
-void construct_boundary( struct All_variables *E)
+void full_construct_boundary( struct All_variables *E)
 {
 
   const int dims=E->mesh.nsd;

Modified: mc/3D/CitcomS/trunk/lib/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/lib/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -24,6 +24,90 @@
 
 # $Id$
 
-SUBDIRS = Common Full Regional
+lib_LTLIBRARIES = libCitcomS.la
+noinst_LTLIBRARIES = libFull.la libRegional.la
 
+CC = $(MPICC)
+INCLUDES = -I$(top_srcdir)/lib/Common $(MPIINCLUDES)
+
+libCitcomS_la_SOURCES = \
+	Common/Advection_diffusion.c \
+	Common/advection_diffusion.h \
+	Common/advection.h \
+	Common/BC_util.c \
+	Common/Citcom_init.c \
+	Common/citcom_init.h \
+	Common/Construct_arrays.c \
+	Common/Convection.c \
+	Common/convection_variables.h \
+	Common/Drive_solvers.c \
+	Common/drive_solvers.h \
+	Common/Element_calculations.c \
+	Common/element_definitions.h \
+	Common/General_matrix_functions.c \
+	Common/global_defs.h \
+	Common/Global_operations.c \
+	Common/Initial_temperature.c \
+	Common/initial_temperature.h \
+	Common/Instructions.c \
+	Common/Interuption.c \
+	Common/interuption.h \
+	Common/lith_age.h \
+	Common/Lith_age.c \
+	Common/Nodal_mesh.c \
+	Common/Output.c \
+	Common/output.h \
+	Common/Pan_problem_misc_functions.c \
+	Common/parallel_related.h \
+	Common/Parallel_util.c \
+	Common/Parsing.c \
+	Common/parsing.h \
+	Common/Phase_change.c \
+	Common/phase_change.h \
+	Common/Problem_related.c \
+	Common/Process_buoyancy.c \
+	Common/Shape_functions.c \
+	Common/Size_does_matter.c \
+	Common/Solver_conj_grad.c \
+	Common/Solver_multigrid.c \
+	Common/sphere_communication.h \
+	Common/Sphere_harmonics.c \
+	Common/Sphere_util.c \
+	Common/Stokes_flow_Incomp.c \
+	Common/temperature_descriptions.h \
+	Common/Topo_gravity.c \
+	Common/Tracer_advection.c \
+	Common/tracer_defs.h \
+	Common/viscosity_descriptions.h \
+	Common/Viscosity_structures.c
+libCitcomS_la_LIBADD = libFull.la libRegional.la $(LIBM)
+libCitcomS_la_LDFLAGS = -release $(VERSION)
+
+libFull_la_CFLAGS = $(AM_CFLAGS) # hack for automake
+libFull_la_SOURCES = \
+	Full/Boundary_conditions.c \
+	Full/Geometry_cartesian.c \
+	Full/Lith_age_read_files.c \
+	Full/Parallel_related.c \
+	Full/Read_input_from_files.c \
+	Full/Solver.c \
+	Full/Sphere_related.c \
+	Full/Version_dependent.c
+
+libRegional_la_CFLAGS = $(AM_CFLAGS) # hack for automake
+libRegional_la_SOURCES = \
+	Regional/Boundary_conditions.c \
+	Regional/Geometry_cartesian.c \
+	Regional/Lith_age_read_files.c \
+	Regional/Parallel_related.c \
+	Regional/Read_input_from_files.c \
+	Regional/Solver.c \
+	Regional/Sphere_related.c \
+	Regional/Version_dependent.c
+
+EXTRA_DIST = \
+	Common/Obsolete.c \
+	Full/Obsolete.c \
+	Regional/Obsolete.c
+
 ## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/lib/Regional/Boundary_conditions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Boundary_conditions.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Boundary_conditions.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -30,15 +30,21 @@
 #include <math.h>
 
 #include "lith_age.h"
+
 /* ========================================== */
 
-void velocity_boundary_conditions(E)
+static void horizontal_bc();
+static void velocity_apply_periodic_bcs();
+static void temperature_apply_periodic_bcs();
+static void velocity_refl_vert_bc();
+static void temperature_refl_vert_bc();
+
+/* ========================================== */
+
+void regional_velocity_boundary_conditions(E)
      struct All_variables *E;
 {
   void velocity_imp_vert_bc();
-  void velocity_refl_vert_bc();
-  void horizontal_bc();
-  void velocity_apply_periodic_bcs();
   void read_velocity_boundary_from_file();
   void renew_top_velocity_boundary();
   void apply_side_sbc();
@@ -118,13 +124,10 @@
 
 /* ========================================== */
 
-void temperature_boundary_conditions(E)
+void regional_temperature_boundary_conditions(E)
      struct All_variables *E;
 {
-  void horizontal_bc();
-  void temperature_apply_periodic_bcs();
   void temperature_imposed_vert_bcs();
-  void temperature_refl_vert_bc();
   void temperature_lith_adj();
   void temperatures_conform_bcs();
   int j,lev,noz;
@@ -170,7 +173,7 @@
 
 /* ========================================== */
 
-void velocity_refl_vert_bc(E)
+static void velocity_refl_vert_bc(E)
      struct All_variables *E;
 {
   int m,i,j,ii,jj;
@@ -313,7 +316,7 @@
   return;
 }
 
-void temperature_refl_vert_bc(E)
+static void temperature_refl_vert_bc(E)
      struct All_variables *E;
 {
   int i,j,m;
@@ -367,7 +370,7 @@
 /*  =========================================================  */
 
 
-void horizontal_bc(E,BC,ROW,dirn,value,mask,onoff,level,m)
+static void horizontal_bc(E,BC,ROW,dirn,value,mask,onoff,level,m)
      struct All_variables *E;
      float *BC[];
      int ROW;
@@ -379,7 +382,6 @@
 
 {
   int i,j,node,rowl;
-  const int dims=E->mesh.nsd;
 
     /* safety feature */
   if(dirn > E->mesh.nsd)
@@ -420,7 +422,7 @@
 }
 
 
-void velocity_apply_periodic_bcs(E)
+static void velocity_apply_periodic_bcs(E)
     struct All_variables *E;
 {
   int n1,n2,level;
@@ -432,7 +434,7 @@
   return;
   }
 
-void temperature_apply_periodic_bcs(E)
+static void temperature_apply_periodic_bcs(E)
     struct All_variables *E;
 {
  const int dims=E->mesh.nsd;
@@ -444,112 +446,6 @@
 
 
 
-void strip_bcs_from_residual(E,Res,level)
-    struct All_variables *E;
-    double **Res;
-    int level;
-{
-    int m,i;
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)
-    if (E->num_zero_resid[level][m])
-      for(i=1;i<=E->num_zero_resid[level][m];i++)
-         Res[m][E->zero_resid[level][m][i]] = 0.0;
-
-    return;
-    }
-
-
-void temperatures_conform_bcs(struct All_variables *E)
-{
-  void temperatures_conform_bcs2(struct All_variables *);
-  void assimilate_lith_conform_bcs2(struct All_variables *);
-
-  if(E->control.lith_age) {
-    lith_age_conform_tbc(E);
-    assimilate_lith_conform_bcs(E);
-    }
-  else
-    temperatures_conform_bcs2(E);
-  return;
-}
-
-
-void temperatures_conform_bcs2(struct All_variables *E)
-{
-  /* int m,j,nno,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,ii,i,k; */
-  int j,node;
-  unsigned int type;
-
-  for(j=1;j<=E->sphere.caps_per_proc;j++)
-    for(node=1;node<=E->lmesh.nno;node++)  {
-
-        type = (E->node[j][node] & (TBX | TBZ | TBY));
-
-        switch (type) {
-        case 0:  /* no match, next node */
-            break;
-        case TBX:
-            E->T[j][node] = E->sphere.cap[j].TB[1][node];
-            break;
-        case TBZ:
-            E->T[j][node] = E->sphere.cap[j].TB[3][node];
-            break;
-        case TBY:
-            E->T[j][node] = E->sphere.cap[j].TB[2][node];
-            break;
-        case (TBX | TBZ):     /* clashes ! */
-            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        case (TBX | TBY):     /* clashes ! */
-            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY):     /* clashes ! */
-            E->T[j][node] = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY | TBX):     /* clashes ! */
-            E->T[j][node] = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        } /* end switch */
-
-
-    } /* next node */
-
-return;
-
- }
-
-
-void velocities_conform_bcs(E,U)
-    struct All_variables *E;
-    double **U;
-{
-    int node,d,m;
-
-    const unsigned int typex = VBX;
-    const unsigned int typez = VBZ;
-    const unsigned int typey = VBY;
-    const int addi_dof = additional_dof[E->mesh.nsd];
-
-    const int dofs = E->mesh.dof;
-    const int nno = E->lmesh.nno;
-
-    for(m=1;m<=E->sphere.caps_per_proc;m++)   {
-      for(node=1;node<=nno;node++) {
-
-        if (E->node[m][node] & typex)
-	      U[m][E->id[m][node].doff[1]] = E->sphere.cap[m].VB[1][node];
- 	if (E->node[m][node] & typey)
-	      U[m][E->id[m][node].doff[2]] = E->sphere.cap[m].VB[2][node];
-	if (E->node[m][node] & typez)
-	      U[m][E->id[m][node].doff[3]] = E->sphere.cap[m].VB[3][node];
-        }
-      }
-
-    return;
-}
-
-
 /* version */
 /* $Id$ */
 

Modified: mc/3D/CitcomS/trunk/lib/Regional/Geometry_cartesian.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Geometry_cartesian.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Geometry_cartesian.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -29,7 +29,7 @@
 #include "parsing.h"
 
 
-void set_2dc_defaults(E)
+void regional_set_2dc_defaults(E)
      struct All_variables *E;
 {
 
@@ -39,7 +39,7 @@
 }
 
 
-void set_2pt5dc_defaults(E)
+void regional_set_2pt5dc_defaults(E)
     struct All_variables *E;
 {
 
@@ -48,7 +48,7 @@
 
 }
 
-void set_3dc_defaults(E)
+void regional_set_3dc_defaults(E)
      struct All_variables *E;
 {
 
@@ -57,7 +57,7 @@
 
 }
 
-void set_3dsphere_defaults(E)
+void regional_set_3dsphere_defaults(E)
      struct All_variables *E;
 {
   int m = E->parallel.me;

Deleted: mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Lith_age.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,514 +0,0 @@
-/*
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
- *<LicenseText>
- *
- * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
- * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
- * Copyright (C) 1994-2005, California Institute of Technology.
- *
- * This program 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *</LicenseText>
- * 
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#include <math.h>
-
-#include "global_defs.h"
-
-//#include "age_related.h"
-#include "parallel_related.h"
-#include "parsing.h"
-#include "lith_age.h"
-
-float find_age_in_MY();
-void lith_age_restart_conform_tbc(struct All_variables *E);
-
-
-void lith_age_input(struct All_variables *E)
-{
-  int m = E->parallel.me;
-
-  E->control.lith_age = 0;
-  E->control.lith_age_time = 0;
-  E->control.temperature_bound_adj = 0;
-
-  input_int("lith_age",&(E->control.lith_age),"0",m);
-  input_float("mantle_temp",&(E->control.lith_age_mantle_temp),"1.0",m);
-
-  if (E->control.lith_age) {
-    input_int("lith_age_time",&(E->control.lith_age_time),"0",m);
-    input_string("lith_age_file",E->control.lith_age_file,"",m);
-    input_float("lith_age_depth",&(E->control.lith_age_depth),"0.0471",m);
-
-    input_int("temperature_bound_adj",&(E->control.temperature_bound_adj),"0",m);
-    if (E->control.temperature_bound_adj) {
-      input_float("depth_bound_adj",&(E->control.depth_bound_adj),"0.1570",m);
-      input_float("width_bound_adj",&(E->control.width_bound_adj),"0.08727",m);
-    }
-  }
-  return;
-}
-
-
-void lith_age_init(struct All_variables *E)
-{
-  char output_file[255];
-  FILE *fp1;
-  int node, i, j, output;
-
-  int gnox, gnoy;
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-
-  E->age_t=(float*) malloc((gnox*gnoy+1)*sizeof(float));
-
-  if(E->control.lith_age_time==1)   {
-    /* to open files every timestep */
-    E->control.lith_age_old_cycles = E->monitor.solution_cycles;
-    output = 1;
-    lith_age_read_files(E,output);
-  }
-  else {
-    /* otherwise, just open for the first timestep */
-    /* NOTE: This is only used if we are adjusting the boundaries */
-    sprintf(output_file,"%s",E->control.lith_age_file);
-    fp1=fopen(output_file,"r");
-    if (fp1 == NULL) {
-      fprintf(E->fp,"(Boundary_conditions #1) Can't open %s\n",output_file);
-      parallel_process_termination();
-    }
-    for(i=1;i<=gnoy;i++)
-      for(j=1;j<=gnox;j++) {
-	node=j+(i-1)*gnox;
-	fscanf(fp1,"%f",&(E->age_t[node]));
-	E->age_t[node]=E->age_t[node]*E->data.scalet;
-      }
-    fclose(fp1);
-  } /* end E->control.lith_age_time == false */
-}
-
-
-void lith_age_restart_tic(struct All_variables *E)
-{
-  int i, j, k, m, node, nodeg;
-  int nox, noy, noz, gnox, gnoy, gnoz;
-  double r1, temp;
-  float age;
-
-  char output_file[255];
-  FILE *fp1;
-
-  noy=E->lmesh.noy;
-  nox=E->lmesh.nox;
-  noz=E->lmesh.noz;
-
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for(i=1;i<=noy;i++)
-      for(j=1;j<=nox;j++)
-	for(k=1;k<=noz;k++)  {
-	  nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	  node=k+(j-1)*noz+(i-1)*nox*noz;
-	  r1=E->sx[m][3][node];
-	  E->T[m][node] = E->control.lith_age_mantle_temp;
-	  if( r1 >= E->sphere.ro-E->control.lith_age_depth )
-	    { /* if closer than (lith_age_depth) from top */
-	      temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-	      E->T[m][node] = E->control.lith_age_mantle_temp * erf(temp);
-	    }
-	}
-
-  /* modify temperature BC to be concorded with restarted T */
-  lith_age_restart_conform_tbc(E);
-  temperatures_conform_bcs(E);
-
-  return;
-}
-
-
-void lith_age_restart_conform_tbc(struct All_variables *E)
-{
-  int i, j, k, m, node;
-  int nox, noy, noz;
-  double r1, rout, rin;
-  const float e_4=1.e-4;
-
-  noy = E->lmesh.noy;
-  nox = E->lmesh.nox;
-  noz = E->lmesh.noz;
-  rout = E->sphere.ro;
-  rin = E->sphere.ri;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for(i=1;i<=noy;i++)
-      for(j=1;j<=nox;j++)
-	for(k=1;k<=noz;k++)  {
-	  node=k+(j-1)*noz+(i-1)*nox*noz;
-	  r1=E->sx[m][3][node];
-
-	  if(fabs(r1-rout)>=e_4 && fabs(r1-rin)>=e_4)  {
-	    E->sphere.cap[m].TB[1][node]=E->T[m][node];
-	    E->sphere.cap[m].TB[2][node]=E->T[m][node];
-	    E->sphere.cap[m].TB[3][node]=E->T[m][node];
-	  }
-	}
-
-  return;
-}
-
-
-
-void lith_age_construct_tic(struct All_variables *E)
-{
-  lith_age_restart_tic(E);
-  return;
-}
-
-
-void lith_age_read_files(struct All_variables *E, int output)
-{
-  FILE *fp1, *fp2;
-  float age, newage1, newage2;
-  char output_file1[255],output_file2[255];
-  float inputage1, inputage2;
-  int nox,noz,noy,nox1,noz1,noy1,lev;
-  int i,j,node;
-  int intage, pos_age;
-
-  nox=E->mesh.nox;
-  noy=E->mesh.noy;
-  noz=E->mesh.noz;
-  nox1=E->lmesh.nox;
-  noz1=E->lmesh.noz;
-  noy1=E->lmesh.noy;
-  lev=E->mesh.levmax;
-
-  age=find_age_in_MY(E);
-
-  if (age < 0.0) { /* age is negative -> use age=0 for input files */
-    intage = 0;
-    newage2 = newage1 = 0.0;
-    pos_age = 0;
-  }
-  else {
-    intage = age;
-    newage1 = 1.0*intage;
-    newage2 = 1.0*intage + 1.0;
-    pos_age = 1;
-  }
-
-  /* read ages for lithosphere tempperature boundary conditions */
-  sprintf(output_file1,"%s%0.0f",E->control.lith_age_file,newage1);
-  sprintf(output_file2,"%s%0.0f",E->control.lith_age_file,newage2);
-  fflush(stdout);
-  fp1=fopen(output_file1,"r");
-  if (fp1 == NULL) {
-    fprintf(E->fp,"(Problem_related #6) Cannot open %s\n",output_file1);
-    parallel_process_termination();
-  }
-  if (pos_age) {
-    fp2=fopen(output_file2,"r");
-    if (fp2 == NULL) {
-      fprintf(E->fp,"(Problem_related #7) Cannot open %s\n",output_file2);
-    parallel_process_termination();
-    }
-  }
-  if((E->parallel.me==0) && output) {
-    fprintf(E->fp,"Lith_Age: Starting Age = %g, Elapsed time = %g, Current Age = %g\n",E->control.start_age,E->monitor.elapsed_time,age);
-    fprintf(E->fp,"Lith_Age: File1 = %s\n",output_file1);
-    if (pos_age)
-      fprintf(E->fp,"Lith_Age: File2 = %s\n",output_file2);
-    else
-      fprintf(E->fp,"Lith_Age: File2 = No file inputted (negative age)\n");
-  }
-
-  for(i=1;i<=noy;i++)
-    for(j=1;j<=nox;j++) {
-      node=j+(i-1)*nox;
-      fscanf(fp1,"%f",&inputage1);
-      if (pos_age) { /* positive ages - we must interpolate */
-	fscanf(fp2,"%f",&inputage2);
-	E->age_t[node] = (inputage1 + (inputage2-inputage1)/(newage2-newage1)*(age-newage1))/E->data.scalet;
-      }
-      else { /* negative ages - don't do the interpolation */
-	E->age_t[node] = inputage1;
-      }
-    }
-  fclose(fp1);
-  if (pos_age) fclose(fp2);
-
-  return;
-}
-
-
-void lith_age_temperature_bound_adj(struct All_variables *E, int lv)
-{
-  int j,node,nno;
-  float ttt2,ttt3,fff2,fff3;
-
-  nno=E->lmesh.nno;
-
-/* NOTE: To start, the relevent bits of "node" are zero. Thus, they only
-get set to TBX/TBY/TBZ if the node is in one of the bounding regions.
-Also note that right now, no matter which bounding region you are in,
-all three get set to true. CPC 6/20/00 */
-
-  if (E->control.temperature_bound_adj) {
-    ttt2=E->control.theta_min + E->control.width_bound_adj;
-    ttt3=E->control.theta_max - E->control.width_bound_adj;
-    fff2=E->control.fi_min + E->control.width_bound_adj;
-    fff3=E->control.fi_max - E->control.width_bound_adj;
-
-    if(lv==E->mesh.gridmax)
-      for(j=1;j<=E->sphere.caps_per_proc;j++)
-	for(node=1;node<=E->lmesh.nno;node++)  {
-	  if( ((E->sx[j][1][node]<=ttt2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[j][1][node]>=ttt3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if < (width) from x bounds AND (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	  if( ((E->sx[j][2][node]<=fff2) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if fi is < (width) from side AND z is < (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	  if( ((E->sx[j][2][node]>=fff3) && (E->sx[j][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) )
-	    /* if fi is < (width) from side AND z is < (depth) from top */
-	    {
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	}
-  } /* end E->control.temperature_bound_adj */
-
-  if (E->control.lith_age_time) {
-    if(lv==E->mesh.gridmax)
-      for(j=1;j<=E->sphere.caps_per_proc;j++)
-	for(node=1;node<=E->lmesh.nno;node++)  {
-	  if(E->sx[j][3][node]>=E->sphere.ro-E->control.lith_age_depth)
-	    { /* if closer than (lith_age_depth) from top */
-	      E->node[j][node]=E->node[j][node] | TBX;
-	      E->node[j][node]=E->node[j][node] & (~FBX);
-	      E->node[j][node]=E->node[j][node] | TBY;
-	      E->node[j][node]=E->node[j][node] & (~FBY);
-	      E->node[j][node]=E->node[j][node] | TBZ;
-	      E->node[j][node]=E->node[j][node] & (~FBZ);
-	    }
-
-	}
-  } /* end E->control.lith_age_time */
-
-  return;
-}
-
-
-void lith_age_conform_tbc(struct All_variables *E)
-{
-  int m,j,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,i,k;
-  float ttt2,ttt3,fff2,fff3;
-  float r1,t1,f1,t0,temp;
-  float e_4;
-  FILE *fp1;
-  char output_file[255];
-  int output;
-
-  e_4=1.e-4;
-  output = 0;
-
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-  nox=E->lmesh.nox;
-  noy=E->lmesh.noy;
-  noz=E->lmesh.noz;
-
-  if(E->control.lith_age_time==1)   {
-    /* to open files every timestep */
-    if (E->control.lith_age_old_cycles != E->monitor.solution_cycles) {
-      /*update so that output only happens once*/
-      output = 1;
-      E->control.lith_age_old_cycles = E->monitor.solution_cycles;
-    }
-    lith_age_read_files(E,output);
-  }
-
-  /* NOW SET THE TEMPERATURES IN THE BOUNDARY REGIONS */
-  if(E->monitor.solution_cycles>1 && E->control.temperature_bound_adj) {
-    ttt2=E->control.theta_min + E->control.width_bound_adj;
-    ttt3=E->control.theta_max - E->control.width_bound_adj;
-    fff2=E->control.fi_min + E->control.width_bound_adj;
-    fff3=E->control.fi_max - E->control.width_bound_adj;
-
-    for(m=1;m<=E->sphere.caps_per_proc;m++)
-      for(i=1;i<=noy;i++)
-	for(j=1;j<=nox;j++)
-	  for(k=1;k<=noz;k++)  {
-	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	    node=k+(j-1)*noz+(i-1)*nox*noz;
-	    t1=E->sx[m][1][node];
-	    f1=E->sx[m][2][node];
-	    r1=E->sx[m][3][node];
-
-	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
-	      if( ((E->sx[m][1][node]<=ttt2) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) || ((E->sx[m][1][node]>=ttt3) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj)) ) {
-		/* if < (width) from x bounds AND (depth) from top */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-		/* keep the age the same! */
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-	      }
-
-	      if( ((E->sx[m][2][node]<=fff2) || (E->sx[m][2][node]>=fff3)) && (E->sx[m][3][node]>=E->sphere.ro-E->control.depth_bound_adj) ) {
-		/* if < (width) from y bounds AND (depth) from top */
-
-		/* keep the age the same! */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-
-	      }
-
-	    }
-
-	  } /* end k   */
-
-  }   /*  end of solution cycles  && temperature_bound_adj */
-
-
-  /* NOW SET THE TEMPERATURES IN THE LITHOSPHERE IF CHANGING EVERY TIME STEP */
-  if(E->monitor.solution_cycles>1 && E->control.lith_age_time)   {
-    for(m=1;m<=E->sphere.caps_per_proc;m++)
-      for(i=1;i<=noy;i++)
-	for(j=1;j<=nox;j++)
-	  for(k=1;k<=noz;k++)  {
-	    nodeg=E->lmesh.nxs-1+j+(E->lmesh.nys+i-2)*gnox;
-	    node=k+(j-1)*noz+(i-1)*nox*noz;
-	    t1=E->sx[m][1][node];
-	    f1=E->sx[m][2][node];
-	    r1=E->sx[m][3][node];
-
-	    if(fabs(r1-E->sphere.ro)>=e_4 && fabs(r1-E->sphere.ri)>=e_4)  { /* if NOT right on the boundary */
-	      if(  E->sx[m][3][node]>=E->sphere.ro-E->control.lith_age_depth ) {
-		/* if closer than (lith_age_depth) from top */
-
-		/* set a new age from the file */
-		temp = (E->sphere.ro-r1) *0.5 /sqrt(E->age_t[nodeg]);
-		t0 = E->control.lith_age_mantle_temp * erf(temp);
-
-             
-		E->sphere.cap[m].TB[1][node]=t0;
-		E->sphere.cap[m].TB[2][node]=t0;
-		E->sphere.cap[m].TB[3][node]=t0;
-	      }
-	    }
-	  }     /* end k   */
-  }   /*  end of solution cycles  && lith_age_time */
-
-  return;
-}
-
-
-void assimilate_lith_conform_bcs(struct All_variables *E)
-{
-  float depth, daf, assimilate_new_temp;
-  int m,j,nno,node,nox,noz,noy,gnox,gnoy,gnoz,nodeg,ii,i,k;
-  unsigned int type;
-
-  nno=E->lmesh.nno;
-  gnox=E->mesh.nox;
-  gnoy=E->mesh.noy;
-  gnoz=E->mesh.noz;
-  nox=E->lmesh.nox;
-  noy=E->lmesh.noy;
-  noz=E->lmesh.noz;
-
-  for(j=1;j<=E->sphere.caps_per_proc;j++)
-    for(node=1;node<=E->lmesh.nno;node++)  {
-
-        type = (E->node[j][node] & (TBX | TBZ | TBY));
-
-        switch (type) {
-        case 0:  /* no match, next node */
-            break;
-        case TBX:
-            assimilate_new_temp = E->sphere.cap[j].TB[1][node];
-            break;
-        case TBZ:
-            assimilate_new_temp = E->sphere.cap[j].TB[3][node];
-            break;
-        case TBY:
-            assimilate_new_temp = E->sphere.cap[j].TB[2][node];
-            break;
-        case (TBX | TBZ):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        case (TBX | TBY):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY):     /* clashes ! */
-            assimilate_new_temp = 0.5 * (E->sphere.cap[j].TB[3][node] + E->sphere.cap[j].TB[2][node]);
-            break;
-        case (TBZ | TBY | TBX):     /* clashes ! */
-            assimilate_new_temp = 0.3333333 * (E->sphere.cap[j].TB[1][node] + E->sphere.cap[j].TB[2][node] + E->sphere.cap[j].TB[3][node]);
-            break;
-        } /* end switch */
-
-        switch (type) {
-        case 0:  /* no match, next node */
-            break;
-        default:
-            depth = E->sphere.ro - E->sx[j][3][node];
-            if(depth <= E->control.lith_age_depth) {
-                /* daf == depth_assimilation_factor */
-                daf = 0.5*depth/E->control.lith_age_depth;
-                E->T[j][node] = daf*E->T[j][node] + (1.0-daf)*assimilate_new_temp;
-               }
-            else
-                E->T[j][node] = assimilate_new_temp;
-        } /* end switch */
-
-    } /* next node */
-
-return;
-}

Added: mc/3D/CitcomS/trunk/lib/Regional/Lith_age_read_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Lith_age_read_files.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Lith_age_read_files.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,108 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#include "global_defs.h"
+
+
+void regional_lith_age_read_files(struct All_variables *E, int output)
+{
+  FILE *fp1, *fp2;
+  float age, newage1, newage2;
+  char output_file1[255],output_file2[255];
+  float inputage1, inputage2;
+  int nox,noz,noy,nox1,noz1,noy1,lev;
+  int i,j,node;
+  int intage, pos_age;
+
+  nox=E->mesh.nox;
+  noy=E->mesh.noy;
+  noz=E->mesh.noz;
+  nox1=E->lmesh.nox;
+  noz1=E->lmesh.noz;
+  noy1=E->lmesh.noy;
+  lev=E->mesh.levmax;
+
+  age=find_age_in_MY(E);
+
+  if (age < 0.0) { /* age is negative -> use age=0 for input files */
+    intage = 0;
+    newage2 = newage1 = 0.0;
+    pos_age = 0;
+  }
+  else {
+    intage = age;
+    newage1 = 1.0*intage;
+    newage2 = 1.0*intage + 1.0;
+    pos_age = 1;
+  }
+
+  /* read ages for lithosphere tempperature boundary conditions */
+  sprintf(output_file1,"%s%0.0f",E->control.lith_age_file,newage1);
+  sprintf(output_file2,"%s%0.0f",E->control.lith_age_file,newage2);
+  fp1=fopen(output_file1,"r");
+  if (fp1 == NULL) {
+    fprintf(E->fp,"(Problem_related #6) Cannot open %s\n",output_file1);
+    parallel_process_termination();
+  }
+  if (pos_age) {
+    fp2=fopen(output_file2,"r");
+    if (fp2 == NULL) {
+      fprintf(E->fp,"(Problem_related #7) Cannot open %s\n",output_file2);
+    parallel_process_termination();
+    }
+  }
+  if((E->parallel.me==0) && output) {
+    fprintf(E->fp,"Lith_Age: Starting Age = %g, Elapsed time = %g, Current Age = %g\n",E->control.start_age,E->monitor.elapsed_time,age);
+    fprintf(E->fp,"Lith_Age: File1 = %s\n",output_file1);
+    if (pos_age)
+      fprintf(E->fp,"Lith_Age: File2 = %s\n",output_file2);
+    else
+      fprintf(E->fp,"Lith_Age: File2 = No file inputted (negative age)\n");
+  }
+
+  for(i=1;i<=noy;i++)
+    for(j=1;j<=nox;j++) {
+      node=j+(i-1)*nox;
+      fscanf(fp1,"%f",&inputage1);
+      if (pos_age) { /* positive ages - we must interpolate */
+	fscanf(fp2,"%f",&inputage2);
+	E->age_t[node] = (inputage1 + (inputage2-inputage1)/(newage2-newage1)*(age-newage1))/E->data.scalet;
+      }
+      else { /* negative ages - don't do the interpolation */
+	E->age_t[node] = inputage1;
+      }
+    }
+  fclose(fp1);
+  if (pos_age) fclose(fp2);
+
+  return;
+}
+
+
+/* End of file */

Deleted: mc/3D/CitcomS/trunk/lib/Regional/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,45 +0,0 @@
-## Process this file with automake to produce Makefile.in
-##
-##<LicenseText>
-##
-## CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
-## Clint Conrad, Michael Gurnis, and Eun-seo Choi.
-## Copyright (C) 1994-2005, California Institute of Technology.
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-##
-## This program 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 this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-##
-##</LicenseText>
-
-# $Id$
-
-CC = $(MPICC)
-INCLUDES = -I$(top_srcdir)/lib/Common $(MPIINCLUDES)
-lib_LTLIBRARIES = libCitcomSRegional.la
-libCitcomSRegional_la_SOURCES = \
-	Boundary_conditions.c \
-	Geometry_cartesian.c \
-	Lith_age.c \
-	Parallel_related.c \
-	Read_input_from_files.c \
-	Sphere_related.c \
-	Version_dependent.c
-libCitcomSRegional_la_LIBADD = \
-	$(top_builddir)/lib/Common/libCitcomSCommon.la \
-	$(LIBM)
-libCitcomSRegional_la_LDFLAGS = -release $(VERSION)
-EXTRA_DIST = \
-	Obsolete.c
-
-## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/lib/Regional/Parallel_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Parallel_related.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Parallel_related.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -34,46 +34,18 @@
 
 #include "parallel_related.h"
 
-void set_horizontal_communicator(struct All_variables*);
-void set_vertical_communicator(struct All_variables*);
 
+static void set_horizontal_communicator(struct All_variables*);
+static void set_vertical_communicator(struct All_variables*);
 
+static void exchange_node_d(struct All_variables *, double**, int);
+static void exchange_node_f(struct All_variables *, float**, int);
 
-/* ============================================ */
-/* ============================================ */
 
-void parallel_process_termination()
-{
-
-  MPI_Finalize();
-  exit(8);
-  return;
-  }
-
 /* ============================================ */
 /* ============================================ */
 
-void parallel_process_sync(struct All_variables *E)
-{
-
-  MPI_Barrier(E->parallel.world);
-  return;
-  }
-
-
-/* ==========================   */
-
- double CPU_time0()
-{
- double time, MPI_Wtime();
- time = MPI_Wtime();
- return (time);
-}
-
-/* ============================================ */
-/* ============================================ */
-
-void parallel_processor_setup(struct All_variables *E)
+void regional_parallel_processor_setup(struct All_variables *E)
   {
 
   int i,j,k,m,me,temp,pid_surf;
@@ -159,7 +131,7 @@
   }
 
 
-void set_horizontal_communicator(struct All_variables *E)
+static void set_horizontal_communicator(struct All_variables *E)
 {
   MPI_Group world_g, horizon_g;
   int i,j,k,m,n;
@@ -197,7 +169,7 @@
 }
 
 
-void set_vertical_communicator(struct All_variables *E)
+static void set_vertical_communicator(struct All_variables *E)
 {
   MPI_Group world_g, vertical_g;
   int i,j,k,m;
@@ -238,7 +210,7 @@
 get element information for each processor.
  ========================================================================= */
 
-void parallel_domain_decomp0(struct All_variables *E)
+void regional_parallel_domain_decomp0(struct All_variables *E)
   {
 
   int i,nox,noz,noy,me;
@@ -343,7 +315,7 @@
  exchange info across the boundaries
  ============================================ */
 
-void parallel_domain_boundary_nodes(E)
+void regional_parallel_domain_boundary_nodes(E)
   struct All_variables *E;
   {
 
@@ -503,7 +475,7 @@
  assuming fault nodes are in the top row of processors
  ============================================ */
 
-void parallel_communication_routs_v(E)
+void regional_parallel_communication_routs_v(E)
   struct All_variables *E;
   {
 
@@ -659,7 +631,7 @@
  assuming fault nodes are in the top row of processors
  ============================================ */
 
-void parallel_communication_routs_s(E)
+void regional_parallel_communication_routs_s(E)
   struct All_variables *E;
   {
 
@@ -781,7 +753,7 @@
 by Tan2 7/21, 2003
 ================================================ */
 
-void exchange_id_d(E, U, lev)
+void regional_exchange_id_d(E, U, lev)
  struct All_variables *E;
  double **U;
  int lev;
@@ -831,7 +803,7 @@
 
 /* ================================================ */
 /* ================================================ */
-void exchange_node_d(E, U, lev)
+static void exchange_node_d(E, U, lev)
  struct All_variables *E;
  double **U;
  int lev;
@@ -880,7 +852,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void exchange_node_f(E, U, lev)
+static void exchange_node_f(E, U, lev)
  struct All_variables *E;
  float **U;
  int lev;
@@ -931,7 +903,7 @@
 /* ================================================ */
 /* ================================================ */
 
-void exchange_snode_f(E, U1, U2, lev)
+static void exchange_snode_f(E, U1, U2, lev)
  struct All_variables *E;
  float **U1,**U2;
  int lev;

Modified: mc/3D/CitcomS/trunk/lib/Regional/Read_input_from_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Read_input_from_files.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Read_input_from_files.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -35,7 +35,7 @@
   Open these files, read in results, and average if necessary
 =========================================================================*/
 
-void read_input_files_for_timesteps(E,action,output)
+void regional_read_input_files_for_timesteps(E,action,output)
     struct All_variables *E;
     int action, output;
 {

Added: mc/3D/CitcomS/trunk/lib/Regional/Solver.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Solver.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Solver.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,100 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<LicenseText>
+ *
+ * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
+ * Clint Conrad, Michael Gurnis, and Eun-seo Choi.
+ * Copyright (C) 1994-2005, California Institute of Technology.
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *</LicenseText>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+
+#include "global_defs.h"
+
+
+/* Boundary_conditions.c */
+void regional_velocity_boundary_conditions(struct All_variables *);
+void regional_temperature_boundary_conditions(struct All_variables *);
+
+/* Geometry_cartesian.c */
+void regional_set_2dc_defaults(struct All_variables *);
+void regional_set_2pt5dc_defaults(struct All_variables *);
+void regional_set_3dc_defaults(struct All_variables *);
+void regional_set_3dsphere_defaults(struct All_variables *);
+
+/* Lith_age.c */
+void regional_lith_age_read_files(struct All_variables *, int);
+
+/* Parallel_related.c */
+void regional_parallel_processor_setup(struct All_variables *);
+void regional_parallel_domain_decomp0(struct All_variables *);
+void regional_parallel_domain_boundary_nodes(struct All_variables *);
+void regional_parallel_communication_routs_v(struct All_variables *);
+void regional_parallel_communication_routs_s(struct All_variables *);
+void regional_exchange_id_d(struct All_variables *, double **, int);
+
+/* Read_input_from_files.c */
+void regional_read_input_files_for_timesteps(struct All_variables *, int, int);
+
+/* Version_dependent.c */
+void regional_global_derived_values(struct All_variables *);
+void regional_node_locations(struct All_variables *);
+void regional_construct_tic_from_input(struct All_variables *);
+void regional_construct_boundary(struct All_variables *);
+
+
+void regional_solver_init(struct All_variables *E)
+{
+    /* Boundary_conditions.c */
+    E->solver.velocity_boundary_conditions = regional_velocity_boundary_conditions;
+    E->solver.temperature_boundary_conditions = regional_temperature_boundary_conditions;
+
+    /* Geometry_cartesian.c */
+    E->solver.set_2dc_defaults = regional_set_2dc_defaults;
+    E->solver.set_2pt5dc_defaults = regional_set_2pt5dc_defaults;
+    E->solver.set_3dc_defaults = regional_set_3dc_defaults;
+    E->solver.set_3dsphere_defaults = regional_set_3dsphere_defaults;
+
+    /* Lith_age.c */
+    E->solver.lith_age_read_files = regional_lith_age_read_files;
+
+    /* Parallel_related.c */
+    E->solver.parallel_processor_setup = regional_parallel_processor_setup;
+    E->solver.parallel_domain_decomp0 = regional_parallel_domain_decomp0;
+    E->solver.parallel_domain_boundary_nodes = regional_parallel_domain_boundary_nodes;
+    E->solver.parallel_communication_routs_v = regional_parallel_communication_routs_v;
+    E->solver.parallel_communication_routs_s = regional_parallel_communication_routs_s;
+    E->solver.exchange_id_d = regional_exchange_id_d;
+
+    /* Read_input_from_files.c */
+    E->solver.read_input_files_for_timesteps = regional_read_input_files_for_timesteps;
+
+    /* Version_dependent.c */
+    E->solver.global_derived_values = regional_global_derived_values;
+    E->solver.node_locations = regional_node_locations;
+    E->solver.construct_tic_from_input = regional_construct_tic_from_input;
+    E->solver.construct_boundary = regional_construct_boundary;
+    
+    return;
+}
+
+
+/* End of file */

Modified: mc/3D/CitcomS/trunk/lib/Regional/Sphere_related.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Sphere_related.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Sphere_related.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -32,7 +32,7 @@
 #include "element_definitions.h"
 #include "global_defs.h"
 
-void coord_of_cap(E,m,icap)
+void regional_coord_of_cap(E,m,icap)
    struct All_variables *E;
    int icap,m;
   {
@@ -248,66 +248,3 @@
   return;
   }
 
-/* =================================================
-  this routine evenly divides the arc between points
-  1 and 2 in a great cicle. The word "evenly" means
-  anglewise evenly.
- =================================================*/
-
-void even_divide_arc12(elx,x1,y1,z1,x2,y2,z2,theta,fi)
- double x1,y1,z1,x2,y2,z2,*theta,*fi;
- int elx;
-{
-  double dx,dy,dz,xx,yy,zz,myatan();
-  int j, nox;
-
-  nox = elx+1;
-
-  dx = (x2 - x1)/elx;
-  dy = (y2 - y1)/elx;
-  dz = (z2 - z1)/elx;
-  for (j=1;j<=nox;j++)   {
-      xx = x1 + dx*(j-1) + 5.0e-32;
-      yy = y1 + dy*(j-1);
-      zz = z1 + dz*(j-1);
-      theta[j] = acos(zz/sqrt(xx*xx+yy*yy+zz*zz));
-      fi[j]    = myatan(yy,xx);
-      }
-
-   return;
-  }
-
-
-/* =================================================
-  rotate the mesh
- =================================================*/
-void rotate_mesh(E,m,icap)
-   struct All_variables *E;
-   int icap,m;
-  {
-
-  int i,lev;
-  double t[4],myatan();
-
-  for (lev=E->mesh.levmin;lev<=E->mesh.levmax;lev++)  {
-    for (i=1;i<=E->lmesh.NNO[lev];i++)  {
-      t[0] = E->X[lev][m][1][i]*E->sphere.dircos[1][1]+
-             E->X[lev][m][2][i]*E->sphere.dircos[1][2]+
-             E->X[lev][m][3][i]*E->sphere.dircos[1][3];
-      t[1] = E->X[lev][m][1][i]*E->sphere.dircos[2][1]+
-             E->X[lev][m][2][i]*E->sphere.dircos[2][2]+
-             E->X[lev][m][3][i]*E->sphere.dircos[2][3];
-      t[2] = E->X[lev][m][1][i]*E->sphere.dircos[3][1]+
-             E->X[lev][m][2][i]*E->sphere.dircos[3][2]+
-             E->X[lev][m][3][i]*E->sphere.dircos[3][3];
-
-      E->X[lev][m][1][i] = t[0];
-      E->X[lev][m][2][i] = t[1];
-      E->X[lev][m][3][i] = t[2];
-      E->SX[lev][m][1][i] = acos(t[2]/E->SX[lev][m][3][i]);
-      E->SX[lev][m][2][i] = myatan(t[1],t[0]);
-      }
-    }    /* lev */
-
-  return;
-  }

Modified: mc/3D/CitcomS/trunk/lib/Regional/Version_dependent.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional/Version_dependent.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/lib/Regional/Version_dependent.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -32,7 +32,7 @@
 
 // Setup global mesh parameters
 //
-void global_derived_values(E)
+void regional_global_derived_values(E)
      struct All_variables *E;
 
 {
@@ -143,7 +143,7 @@
 
    =================================================  */
 
-void node_locations(E)
+void regional_node_locations(E)
   struct All_variables *E;
 {
   int i,j,k,lev;
@@ -155,7 +155,7 @@
   char a[100];
   FILE *fp1;
 
-  void coord_of_cap();
+  void regional_coord_of_cap();
   void rotate_mesh ();
   void compute_angle_surf_area ();
   void parallel_process_termination();
@@ -240,7 +240,7 @@
   E->sphere.dircos[3][3] = cos(ro);
 
   for (j=1;j<=E->sphere.caps_per_proc;j++)   {
-     coord_of_cap(E,j,0);
+     regional_coord_of_cap(E,j,0);
      }
 
 
@@ -324,7 +324,7 @@
 
 
 
-void construct_tic_from_input(struct All_variables *E)
+void regional_construct_tic_from_input(struct All_variables *E)
 {
   double modified_plgndr_a(int, int, double);
   void temperatures_conform_bcs();
@@ -448,7 +448,7 @@
 
 /* setup boundary node and element arrays for bookkeeping */
 
-void construct_boundary( struct All_variables *E)
+void regional_construct_boundary( struct All_variables *E)
 {
   const int dims=E->mesh.nsd;
 

Copied: mc/3D/CitcomS/trunk/module/CitcomSmodule.cc (from rev 3905, mc/3D/CitcomS/trunk/module/Regional/Regionalmodule.cc)
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/Regionalmodule.cc	2006-06-28 17:58:12 UTC (rev 3905)
+++ mc/3D/CitcomS/trunk/module/CitcomSmodule.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//<LicenseText>
+//
+// CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+// Copyright (C) 2002-2005, California Institute of Technology.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//</LicenseText>
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#include <portinfo>
+#include <Python.h>
+
+#include "CitcomSmodule.h"
+#include "exceptions.h"
+#include "bindings.h"
+
+
+char pyCitcomS_module__doc__[] = "";
+
+void pyCitcom_init(const char *name)
+{
+    // create the module and add the functions
+    PyObject * m = Py_InitModule4(
+        (char *)name, pyCitcom_methods,
+        pyCitcomS_module__doc__, 0, PYTHON_API_VERSION);
+
+    // get its dictionary
+    PyObject * d = PyModule_GetDict(m);
+
+    // check for errors
+    if (PyErr_Occurred()) {
+        Py_FatalError("can't initialize module CitcomS");
+    }
+
+    // install the module exceptions
+    pyCitcom_runtimeError = PyErr_NewException("CitcomS.runtime", 0, 0);
+    PyDict_SetItemString(d, "RuntimeException", pyCitcom_runtimeError);
+
+    return;
+}
+
+// Initialization function for the module (*must* be called initCitcomS)
+extern "C"
+void
+initCitcomS()
+{
+    pyCitcom_init("CitcomS");
+}
+
+// version
+// $Id$
+
+// End of file

Added: mc/3D/CitcomS/trunk/module/CitcomSmodule.h
===================================================================
--- mc/3D/CitcomS/trunk/module/CitcomSmodule.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/CitcomSmodule.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//<LicenseText>
+//
+// CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+// Copyright (C) 2002-2005, California Institute of Technology.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//</LicenseText>
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#ifndef pyCitcom_CitcomSmodule_h
+#define pyCitcom_CitcomSmodule_h
+
+void pyCitcom_init(const char *name);
+
+#endif // pyCitcom_CitcomSmodule_h
+
+// End of file

Modified: mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.cc
===================================================================
--- mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.cc	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -30,20 +30,18 @@
 
 #include <Python.h>
 
+#include "Exchangermodule.h"
 #include "exceptions.h"
 #include "bindings.h"
 
 
 char pyExchanger_module__doc__[] = "";
 
-// Initialization function for the module (*must* be called initExchanger)
-extern "C"
-void
-initExchanger()
+void PyCitcomSExchanger_init(const char *name)
 {
     // create the module and add the functions
     PyObject * m = Py_InitModule4(
-        "Exchanger", pyExchanger_methods,
+        (char *)name, pyExchanger_methods,
         pyExchanger_module__doc__, 0, PYTHON_API_VERSION);
 
     // get its dictionary
@@ -61,6 +59,14 @@
     return;
 }
 
+// Initialization function for the module (*must* be called initExchanger)
+extern "C"
+void
+initExchanger()
+{
+    PyCitcomSExchanger_init("Exchanger");
+}
+
 // version
 // $Id$
 

Added: mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.h
===================================================================
--- mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Exchanger/Exchangermodule.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+//<LicenseText>
+//
+// CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
+// Copyright (C) 2002-2005, California Institute of Technology.
+//
+// This program 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 2 of the License, or
+// (at your option) any later version.
+//
+// This program 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//</LicenseText>
+// 
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// 
+
+#ifndef pyCitcom_Exchangermodule_h
+#define pyCitcom_Exchangermodule_h
+
+void PyCitcomSExchanger_init(const char *name);
+
+#endif // pyCitcom_Exchangermodule_h
+
+// End of file

Modified: mc/3D/CitcomS/trunk/module/Exchanger/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/module/Exchanger/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Exchanger/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -23,14 +23,37 @@
 
 # $Id$
 
-pkgpyexec_LTLIBRARIES = Exchangermodule.la
+noinst_LIBRARIES =
+pkgpyexec_LTLIBRARIES =
+
+if COND_EMBEDDING
+    # static library
+    noinst_LIBRARIES += libExchangermodule.a
+else
+    # extension module (libtool)
+    pkgpyexec_LTLIBRARIES += Exchangermodule.la
+endif
+
+# static library
+libExchangermodule_a_CXXFLAGS = $(AM_CXXFLAGS) # hack for automake
+libExchangermodule_a_SOURCES = $(sources)
+
+# extension module (libtool)
+Exchangermodule_la_LDFLAGS = -module -release $(VERSION)
+Exchangermodule_la_LIBADD = \
+	$(top_builddir)/lib/libCitcomS.la \
+	-lExchanger \
+	-l_mpimodule -ljournal
+Exchangermodule_la_SOURCES = $(sources)
+
 CXX = $(MPICXX)
 CXXLD = @CXX@
 INCLUDES = \
 	-I$(top_srcdir)/lib/Common \
 	-I$(PYTHON_INCDIR) \
 	$(MPIINCLUDES)
-Exchangermodule_la_SOURCES = \
+
+sources = \
 	AreaWeightedNormal.cc \
 	AreaWeightedNormal.h \
 	bindings.cc \
@@ -79,10 +102,5 @@
 EXTRA_DIST = \
 	BoundaryVTInlet.cc \
 	BoundaryVTInlet.h
-Exchangermodule_la_LDFLAGS = -module -release $(VERSION)
-Exchangermodule_la_LIBADD = \
-	$(top_builddir)/lib/Regional/libCitcomSRegional.la \
-	-lExchanger \
-	-l_mpimodule -ljournal
 
 ## end of Makefile.am

Deleted: mc/3D/CitcomS/trunk/module/Full/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/module/Full/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Full/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,38 +0,0 @@
-## Process this file with automake to produce Makefile.in
-##
-##<LicenseText>
-##
-## CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
-## Copyright (C) 2002-2005, California Institute of Technology.
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-##
-## This program 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 this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-##
-##</LicenseText>
-
-# $Id$
-
-# Fullmodule is identical to Regionalmodule, except that it is linked
-# against libCitcomSFull instead of libCitcomSRegional.
-
-pkgpyexec_LTLIBRARIES = Fullmodule.la
-INCLUDES = -I$(top_srcdir)/module/Regional -I$(PYTHON_INCDIR)
-Fullmodule_la_SOURCES = Fullmodule.cc
-Fullmodule_la_LDFLAGS = -module -release $(VERSION)
-Fullmodule_la_LIBADD = \
-	$(top_builddir)/module/Regional/libModuleCommon.la \
-	$(top_builddir)/lib/Full/libCitcomSFull.la \
-	-l_mpimodule -ljournal
-
-## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/module/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/module/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -23,6 +23,70 @@
 
 # $Id$
 
-SUBDIRS = Regional Full Exchanger
+SUBDIRS = Exchanger
 
+noinst_LIBRARIES =
+pkgpyexec_LTLIBRARIES =
+
+if COND_EMBEDDING
+    # static library
+    noinst_LIBRARIES += libCitcomSmodule.a libPyxMPImodule.a
+else
+    # extension module (libtool)
+    pkgpyexec_LTLIBRARIES += CitcomSmodule.la PyxMPImodule.la
+endif
+
+# static libraries
+
+libCitcomSmodule_a_CXXFLAGS = $(AM_CXXFLAGS) # hack for automake
+libCitcomSmodule_a_SOURCES = $(sources)
+
+libPyxMPImodule_a_CFLAGS = $(AM_CXXFLAGS) # hack for automake
+libPyxMPImodule_a_SOURCES = PyxMPI/PyxMPI.c
+
+# extension modules (libtool)
+
+CitcomSmodule_la_LDFLAGS = -module -release $(VERSION)
+CitcomSmodule_la_LIBADD = \
+	$(top_builddir)/lib/libCitcomS.la \
+	-l_mpimodule -ljournal $(MPILIBS)
+CitcomSmodule_la_SOURCES = $(sources)
+
+PyxMPImodule_la_LDFLAGS = -module -release $(VERSION)
+PyxMPImodule_la_LIBADD =
+PyxMPImodule_la_SOURCES = PyxMPI/PyxMPI.c
+
+# compiler settings
+
+CC = $(MPICC)
+CXX = $(MPICXX)
+INCLUDES = \
+	-I$(top_srcdir)/module/Regional \
+	-I$(top_srcdir)/lib/Common \
+	-I$(PYTHON_INCDIR) \
+	$(MPIINCLUDES)
+
+# sources
+
+sources = \
+	CitcomSmodule.cc \
+	Regional/advdiffu.cc \
+	Regional/advdiffu.h \
+	Regional/bindings.cc \
+	Regional/bindings.h \
+	Regional/exceptions.cc \
+	Regional/exceptions.h \
+	Regional/initial_conditions.cc \
+	Regional/initial_conditions.h \
+	Regional/mesher.cc \
+	Regional/mesher.h \
+	Regional/misc.cc \
+	Regional/misc.h \
+	Regional/outputs.cc \
+	Regional/outputs.h \
+	Regional/setProperties.cc \
+	Regional/setProperties.h \
+	Regional/stokes_solver.cc \
+	Regional/stokes_solver.h
+
 ## end of Makefile.am

Added: mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.c
===================================================================
--- mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.c	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.c	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,709 @@
+/* Generated by Pyrex 0.9.3 on Wed Jul  5 18:14:01 2006 */
+
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#include "stdlib.h"
+#include "mpi.h"
+
+
+typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
+typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
+static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/
+static int __Pyx_EndUnpack(PyObject *, int); /*proto*/
+static int __Pyx_PrintItem(PyObject *); /*proto*/
+static int __Pyx_PrintNewline(void); /*proto*/
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static void __Pyx_ReRaise(void); /*proto*/
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+static PyObject *__Pyx_GetExcValue(void); /*proto*/
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
+static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/
+static void __Pyx_WriteUnraisable(char *name); /*proto*/
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/
+static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
+static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static int __pyx_lineno;
+static char *__pyx_filename;
+staticforward char **__pyx_f;
+
+/* Declarations from cmpi */
+
+
+/* Declarations from PyxMPI */
+
+staticforward PyTypeObject __pyx_type_6PyxMPI_MPI_Comm;
+
+struct __pyx_obj_6PyxMPI_MPI_Comm {
+  PyObject_HEAD
+  MPI_Comm comm;
+};
+
+static PyTypeObject *__pyx_ptype_6PyxMPI_MPI_Comm = 0;
+
+/* Implementation of PyxMPI */
+
+
+static PyObject *__pyx_n_cmpi;
+static PyObject *__pyx_n_MPI_COMM_WORLD;
+static PyObject *__pyx_n_MPI_Error;
+static PyObject *__pyx_n_MPI_Init;
+static PyObject *__pyx_n_MPI_Finalize;
+static PyObject *__pyx_n_MPI_Comm_rank;
+static PyObject *__pyx_n_EnvironmentError;
+
+static int __pyx_f_6PyxMPI_8MPI_Comm___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_f_6PyxMPI_8MPI_Comm___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  static char *__pyx_argnames[] = {0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
+  Py_INCREF(__pyx_v_self);
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":17 */
+  ((struct __pyx_obj_6PyxMPI_MPI_Comm *)__pyx_v_self)->comm = MPI_COMM_WORLD;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1:;
+  __Pyx_AddTraceback("PyxMPI.MPI_Comm.__init__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_self);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_n_len;
+static PyObject *__pyx_n_append;
+
+static PyObject *__pyx_f_6PyxMPI_MPI_Init(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_6PyxMPI_MPI_Init(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_argv = 0;
+  int __pyx_v_error;
+  int __pyx_v_cargc;
+  int __pyx_v_i;
+  char (*(*__pyx_v_cargv));
+  char (*(*__pyx_v_mycargv));
+  PyObject *__pyx_v_myargv;
+  PyObject *__pyx_v_arg;
+  PyObject *__pyx_r;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  int __pyx_4;
+  char (*__pyx_5);
+  static char *__pyx_argnames[] = {"argv",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_argv)) return 0;
+  Py_INCREF(__pyx_v_argv);
+  __pyx_v_myargv = Py_None; Py_INCREF(__pyx_v_myargv);
+  __pyx_v_arg = Py_None; Py_INCREF(__pyx_v_arg);
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":30 */
+  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;}
+  Py_DECREF(__pyx_v_myargv);
+  __pyx_v_myargv = __pyx_1;
+  __pyx_1 = 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":33 */
+  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_len); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
+  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
+  Py_INCREF(__pyx_v_argv);
+  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_argv);
+  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_v_cargc = __pyx_4;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":34 */
+  __pyx_v_cargv = ((char (*(*)))malloc(((__pyx_v_cargc + 1) * (sizeof(char (*))))));
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":35 */
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_cargc; ++__pyx_v_i) {
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":36 */
+    __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
+    __pyx_2 = PyObject_GetItem(__pyx_v_argv, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_v_arg);
+    __pyx_v_arg = __pyx_2;
+    __pyx_2 = 0;
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":37 */
+    __pyx_3 = PyObject_GetAttr(__pyx_v_myargv, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
+    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
+    Py_INCREF(__pyx_v_arg);
+    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_arg);
+    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":38 */
+    __pyx_5 = PyString_AsString(__pyx_v_arg); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;}
+    (__pyx_v_cargv[__pyx_v_i]) = __pyx_5;
+    __pyx_L2:;
+  }
+  __pyx_L3:;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":39 */
+  (__pyx_v_cargv[__pyx_v_cargc]) = 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":42 */
+  __pyx_v_mycargv = __pyx_v_cargv;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":43 */
+  __pyx_v_error = MPI_Init((&__pyx_v_cargc),(&__pyx_v_cargv));
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":44 */
+  __pyx_4 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_4) {
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":45 */
+    free(__pyx_v_mycargv);
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":46 */
+    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;}
+    __pyx_1 = PyInt_FromLong(__pyx_v_error); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;}
+    __Pyx_Raise(__pyx_3, __pyx_1, 0);
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;}
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":49 */
+  if (PySequence_DelSlice(__pyx_v_argv, 0, 0x7fffffff) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":50 */
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_cargc; ++__pyx_v_i) {
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":51 */
+    __pyx_2 = PyObject_GetAttr(__pyx_v_argv, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+    __pyx_3 = PyString_FromString((__pyx_v_cargv[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
+    __pyx_3 = 0;
+    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_1); __pyx_1 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    __pyx_L5:;
+  }
+  __pyx_L6:;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":52 */
+  free(__pyx_v_mycargv);
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":54 */
+  __pyx_r = Py_None; Py_INCREF(__pyx_r);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(__pyx_r);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("PyxMPI.MPI_Init");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_myargv);
+  Py_DECREF(__pyx_v_arg);
+  Py_DECREF(__pyx_v_argv);
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_6PyxMPI_MPI_Finalize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_6PyxMPI_MPI_Finalize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_v_error;
+  PyObject *__pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  static char *__pyx_argnames[] = {0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":59 */
+  __pyx_v_error = MPI_Finalize();
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":60 */
+  __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":61 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
+    __Pyx_Raise(__pyx_2, __pyx_3, 0);
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":62 */
+  __pyx_r = Py_None; Py_INCREF(__pyx_r);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(__pyx_r);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("PyxMPI.MPI_Finalize");
+  __pyx_r = 0;
+  __pyx_L0:;
+  return __pyx_r;
+}
+
+static PyObject *__pyx_f_6PyxMPI_MPI_Comm_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_f_6PyxMPI_MPI_Comm_rank(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_comm = 0;
+  int __pyx_v_error;
+  int __pyx_v_rank;
+  struct __pyx_obj_6PyxMPI_MPI_Comm *__pyx_v_c_comm;
+  PyObject *__pyx_r;
+  int __pyx_1;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  static char *__pyx_argnames[] = {"comm",0};
+  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_comm)) return 0;
+  Py_INCREF(__pyx_v_comm);
+  ((PyObject*)__pyx_v_c_comm) = Py_None; Py_INCREF(((PyObject*)__pyx_v_c_comm));
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":69 */
+  if (!__Pyx_TypeTest(__pyx_v_comm, __pyx_ptype_6PyxMPI_MPI_Comm)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;}
+  Py_INCREF(__pyx_v_comm);
+  Py_DECREF(((PyObject *)__pyx_v_c_comm));
+  ((PyObject *)__pyx_v_c_comm) = __pyx_v_comm;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":70 */
+  __pyx_v_error = MPI_Comm_rank(__pyx_v_c_comm->comm,(&__pyx_v_rank));
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":71 */
+  __pyx_1 = (__pyx_v_error != MPI_SUCCESS);
+  if (__pyx_1) {
+
+    /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":72 */
+    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MPI_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+    __pyx_3 = PyInt_FromLong(__pyx_v_error); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+    __Pyx_Raise(__pyx_2, __pyx_3, 0);
+    Py_DECREF(__pyx_2); __pyx_2 = 0;
+    Py_DECREF(__pyx_3); __pyx_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":73 */
+  __pyx_2 = PyInt_FromLong(__pyx_v_rank); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
+  __pyx_r = __pyx_2;
+  __pyx_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; Py_INCREF(__pyx_r);
+  goto __pyx_L0;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("PyxMPI.MPI_Comm_rank");
+  __pyx_r = 0;
+  __pyx_L0:;
+  Py_DECREF(__pyx_v_c_comm);
+  Py_DECREF(__pyx_v_comm);
+  return __pyx_r;
+}
+
+static __Pyx_InternTabEntry __pyx_intern_tab[] = {
+  {&__pyx_n_EnvironmentError, "EnvironmentError"},
+  {&__pyx_n_MPI_COMM_WORLD, "MPI_COMM_WORLD"},
+  {&__pyx_n_MPI_Comm_rank, "MPI_Comm_rank"},
+  {&__pyx_n_MPI_Error, "MPI_Error"},
+  {&__pyx_n_MPI_Finalize, "MPI_Finalize"},
+  {&__pyx_n_MPI_Init, "MPI_Init"},
+  {&__pyx_n_append, "append"},
+  {&__pyx_n_cmpi, "cmpi"},
+  {&__pyx_n_len, "len"},
+  {0, 0}
+};
+
+static PyObject *__pyx_tp_new_6PyxMPI_MPI_Comm(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  struct __pyx_obj_6PyxMPI_MPI_Comm *p = (struct __pyx_obj_6PyxMPI_MPI_Comm *)o;
+  return o;
+}
+
+static void __pyx_tp_dealloc_6PyxMPI_MPI_Comm(PyObject *o) {
+  struct __pyx_obj_6PyxMPI_MPI_Comm *p = (struct __pyx_obj_6PyxMPI_MPI_Comm *)o;
+  (*o->ob_type->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_6PyxMPI_MPI_Comm(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_6PyxMPI_MPI_Comm *p = (struct __pyx_obj_6PyxMPI_MPI_Comm *)o;
+  return 0;
+}
+
+static int __pyx_tp_clear_6PyxMPI_MPI_Comm(PyObject *o) {
+  struct __pyx_obj_6PyxMPI_MPI_Comm *p = (struct __pyx_obj_6PyxMPI_MPI_Comm *)o;
+  return 0;
+}
+
+static struct PyMethodDef __pyx_methods_6PyxMPI_MPI_Comm[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_MPI_Comm = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  0, /*nb_divide*/
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  0, /*nb_coerce*/
+  0, /*nb_int*/
+  0, /*nb_long*/
+  0, /*nb_float*/
+  0, /*nb_oct*/
+  0, /*nb_hex*/
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  0, /*nb_inplace_divide*/
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_MPI_Comm = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_MPI_Comm = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_MPI_Comm = {
+  0, /*bf_getreadbuffer*/
+  0, /*bf_getwritebuffer*/
+  0, /*bf_getsegcount*/
+  0, /*bf_getcharbuffer*/
+};
+
+statichere PyTypeObject __pyx_type_6PyxMPI_MPI_Comm = {
+  PyObject_HEAD_INIT(0)
+  0, /*ob_size*/
+  "PyxMPI.MPI_Comm", /*tp_name*/
+  sizeof(struct __pyx_obj_6PyxMPI_MPI_Comm), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_6PyxMPI_MPI_Comm, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  0, /*tp_compare*/
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_MPI_Comm, /*tp_as_number*/
+  &__pyx_tp_as_sequence_MPI_Comm, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_MPI_Comm, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_MPI_Comm, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_6PyxMPI_MPI_Comm, /*tp_traverse*/
+  __pyx_tp_clear_6PyxMPI_MPI_Comm, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_6PyxMPI_MPI_Comm, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_f_6PyxMPI_8MPI_Comm___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_6PyxMPI_MPI_Comm, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+};
+
+static struct PyMethodDef __pyx_methods[] = {
+  {"MPI_Init", (PyCFunction)__pyx_f_6PyxMPI_MPI_Init, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Finalize", (PyCFunction)__pyx_f_6PyxMPI_MPI_Finalize, METH_VARARGS|METH_KEYWORDS, 0},
+  {"MPI_Comm_rank", (PyCFunction)__pyx_f_6PyxMPI_MPI_Comm_rank, METH_VARARGS|METH_KEYWORDS, 0},
+  {0, 0, 0, 0}
+};
+
+DL_EXPORT(void) initPyxMPI(void); /*proto*/
+DL_EXPORT(void) initPyxMPI(void) {
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  __pyx_m = Py_InitModule4("PyxMPI", __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
+  __pyx_b = PyImport_AddModule("__builtin__");
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
+  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
+  if (PyType_Ready(&__pyx_type_6PyxMPI_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
+  if (PyObject_SetAttrString(__pyx_m, "MPI_Comm", (PyObject *)&__pyx_type_6PyxMPI_MPI_Comm) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
+  __pyx_ptype_6PyxMPI_MPI_Comm = &__pyx_type_6PyxMPI_MPI_Comm;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":20 */
+  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_6PyxMPI_MPI_Comm), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_COMM_WORLD, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":23 */
+  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
+  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_EnvironmentError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
+  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
+  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
+  __pyx_2 = 0;
+  __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_MPI_Error, "PyxMPI"); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
+  Py_DECREF(__pyx_3); __pyx_3 = 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":24 */
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_MPI_Error, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; goto __pyx_L1;}
+  Py_DECREF(__pyx_2); __pyx_2 = 0;
+  Py_DECREF(__pyx_1); __pyx_1 = 0;
+
+  /* "/home/leif/dv/CitcomS/module/PyxMPI/PyxMPI.pyx":65 */
+  return;
+  __pyx_L1:;
+  Py_XDECREF(__pyx_1);
+  Py_XDECREF(__pyx_2);
+  Py_XDECREF(__pyx_3);
+  __Pyx_AddTraceback("PyxMPI");
+}
+
+static char *__pyx_filenames[] = {
+  "PyxMPI.pyx",
+};
+statichere char **__pyx_f = __pyx_filenames;
+
+/* Runtime support code */
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
+    PyObject *result;
+    result = PyObject_GetAttr(dict, name);
+    if (!result)
+        PyErr_SetObject(PyExc_NameError, name);
+    return result;
+}
+
+static PyObject *__Pyx_CreateClass(
+    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
+{
+    PyObject *py_modname;
+    PyObject *result = 0;
+    
+    py_modname = PyString_FromString(modname);
+    if (!py_modname)
+        goto bad;
+    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
+        goto bad;
+    result = PyClass_New(bases, dict, name);
+bad:
+    Py_XDECREF(py_modname);
+    return result;
+}
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    /* Next, repeatedly, replace a tuple exception with its first item */
+    while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {
+        PyObject *tmp = type;
+        type = PyTuple_GET_ITEM(type, 0);
+        Py_INCREF(type);
+        Py_DECREF(tmp);
+    }
+    if (PyString_Check(type))
+        ;
+    else if (PyClass_Check(type))
+        ; /*PyErr_NormalizeException(&type, &value, &tb);*/
+    else if (PyInstance_Check(type)) {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+              "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        else {
+            /* Normalize to raise <class>, <instance> */
+            Py_DECREF(value);
+            value = type;
+            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+            Py_INCREF(type);
+        }
+    }
+    else {
+        /* Not something you can raise.  You get an exception
+           anyway, just not what you specified :-) */
+        PyErr_Format(PyExc_TypeError,
+                 "exceptions must be strings, classes, or "
+                 "instances, not %s", type->ob_type->tp_name);
+        goto raise_error;
+    }
+    PyErr_Restore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
+    if (!type) {
+        PyErr_Format(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (obj == Py_None || PyObject_TypeCheck(obj, type))
+        return 1;
+    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
+        obj->ob_type->tp_name, type->tp_name);
+    return 0;
+}
+
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
+    while (t->p) {
+        *t->p = PyString_InternFromString(t->s);
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    PyObject *py_globals = 0;
+    PyObject *empty_tuple = 0;
+    PyObject *empty_string = 0;
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+    
+    py_srcfile = PyString_FromString(__pyx_filename);
+    if (!py_srcfile) goto bad;
+    py_funcname = PyString_FromString(funcname);
+    if (!py_funcname) goto bad;
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    empty_tuple = PyTuple_New(0);
+    if (!empty_tuple) goto bad;
+    empty_string = PyString_FromString("");
+    if (!empty_string) goto bad;
+    py_code = PyCode_New(
+        0,            /*int argcount,*/
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        empty_string, /*PyObject *code,*/
+        empty_tuple,  /*PyObject *consts,*/
+        empty_tuple,  /*PyObject *names,*/
+        empty_tuple,  /*PyObject *varnames,*/
+        empty_tuple,  /*PyObject *freevars,*/
+        empty_tuple,  /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        __pyx_lineno,   /*int firstlineno,*/
+        empty_string  /*PyObject *lnotab*/
+    );
+    if (!py_code) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_Get(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = __pyx_lineno;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    Py_XDECREF(empty_tuple);
+    Py_XDECREF(empty_string);
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}

Added: mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.pyx
===================================================================
--- mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.pyx	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/PyxMPI/PyxMPI.pyx	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,76 @@
+# Process this file with Pyrex to produce mpi.c
+
+
+cimport cmpi
+
+
+cdef extern from "stdlib.h":
+    void *malloc(int)
+    void free(void *)
+
+
+cdef class MPI_Comm:
+
+    cdef cmpi.MPI_Comm comm
+
+    def __init__(MPI_Comm self):
+        self.comm = cmpi.MPI_COMM_WORLD
+
+
+MPI_COMM_WORLD = MPI_Comm()
+
+
+class MPI_Error(EnvironmentError):
+    pass
+
+
+def MPI_Init(argv):
+    cdef int error, cargc, i
+    cdef char **cargv, **mycargv
+    myargv = []
+
+    # Construct a C char** argument vector from 'argv'.
+    cargc = len(argv)
+    cargv = <char **>malloc((cargc + 1) * sizeof(char *))
+    for i from 0 <= i < cargc:
+        arg = argv[i]
+        myargv.append(arg) # add ref
+        cargv[i] = arg
+    cargv[cargc] = NULL
+
+    # Call MPI_Init().
+    mycargv = cargv; # MPI might allocate & return its own.
+    error = cmpi.MPI_Init(&cargc, &cargv)
+    if error != cmpi.MPI_SUCCESS:
+        free(mycargv)
+        raise MPI_Error, error
+
+    # Reconstruct Python's 'argv' from the modified 'cargv'.
+    del argv[:]
+    for i from 0 <= i < cargc:
+        argv.append(cargv[i])
+    free(mycargv)
+    
+    return
+
+
+def MPI_Finalize():
+    cdef int error
+    error = cmpi.MPI_Finalize()
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error, error
+    return
+
+
+def MPI_Comm_rank(comm):
+    cdef int error
+    cdef int rank
+    cdef MPI_Comm c_comm
+    c_comm = comm
+    error = cmpi.MPI_Comm_rank(c_comm.comm, &rank)
+    if error != cmpi.MPI_SUCCESS:
+        raise MPI_Error, error
+    return rank
+    
+
+# end of file

Added: mc/3D/CitcomS/trunk/module/PyxMPI/cmpi.pxd
===================================================================
--- mc/3D/CitcomS/trunk/module/PyxMPI/cmpi.pxd	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/PyxMPI/cmpi.pxd	2006-07-06 02:16:42 UTC (rev 3922)
@@ -0,0 +1,17 @@
+# Pyrex module for MPI
+
+cdef extern from "mpi.h":
+
+    enum MPI_Error:
+        MPI_SUCCESS
+
+    ctypedef struct MPI_Comm_Imp:
+        pass
+    ctypedef MPI_Comm_Imp *MPI_Comm
+    MPI_Comm MPI_COMM_WORLD
+
+    int MPI_Init(int *, char ***)
+    int MPI_Finalize()
+    int MPI_Comm_rank(MPI_Comm, int *)
+
+# end of file

Deleted: mc/3D/CitcomS/trunk/module/Regional/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Regional/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -1,64 +0,0 @@
-## Process this file with automake to produce Makefile.in
-##
-##<LicenseText>
-##
-## CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
-## Copyright (C) 2002-2005, California Institute of Technology.
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-##
-## This program 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 this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-##
-##</LicenseText>
-
-# $Id$
-
-pkgpyexec_LTLIBRARIES = Regionalmodule.la
-noinst_LTLIBRARIES = libModuleCommon.la
-CXX = $(MPICXX)
-CXXLD = @CXX@
-INCLUDES = \
-	-I$(top_srcdir)/lib/Common \
-	-I$(PYTHON_INCDIR) \
-	$(MPIINCLUDES)
-
-# libModuleCommon
-libModuleCommon_la_SOURCES = \
-	advdiffu.cc \
-	advdiffu.h \
-	bindings.cc \
-	bindings.h \
-	exceptions.cc \
-	exceptions.h \
-	initial_conditions.cc \
-	initial_conditions.h \
-	mesher.cc \
-	mesher.h \
-	misc.cc \
-	misc.h \
-	outputs.cc \
-	outputs.h \
-	setProperties.cc \
-	setProperties.h \
-	stokes_solver.cc \
-	stokes_solver.h
-
-# Regionalmodule
-Regionalmodule_la_SOURCES = Regionalmodule.cc
-Regionalmodule_la_LDFLAGS = -module -release $(VERSION)
-Regionalmodule_la_LIBADD = \
-	libModuleCommon.la \
-	$(top_builddir)/lib/Regional/libCitcomSRegional.la \
-	-l_mpimodule -ljournal
-
-## end of Makefile.am

Modified: mc/3D/CitcomS/trunk/module/Regional/bindings.cc
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/bindings.cc	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Regional/bindings.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -82,6 +82,16 @@
      METH_VARARGS,
      pyCitcom_citcom_init__doc__},
 
+    {pyCitcom_full_solver_init__name__,
+     pyCitcom_full_solver_init,
+     METH_VARARGS,
+     pyCitcom_full_solver_init__doc__},
+
+    {pyCitcom_regional_solver_init__name__,
+     pyCitcom_regional_solver_init,
+     METH_VARARGS,
+     pyCitcom_regional_solver_init__doc__},
+
     {pyCitcom_global_default_values__name__,
      pyCitcom_global_default_values,
      METH_VARARGS,

Modified: mc/3D/CitcomS/trunk/module/Regional/mesher.cc
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/mesher.cc	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Regional/mesher.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -40,7 +40,6 @@
     void allocate_common_vars(struct All_variables*);
     void allocate_velocity_vars(struct All_variables*);
     void check_bc_consistency(struct All_variables*);
-    void construct_boundary(struct All_variables*);
     void construct_id(struct All_variables*);
     void construct_ien(struct All_variables*);
     void construct_lm(struct All_variables*);
@@ -53,10 +52,8 @@
     void construct_surface (struct All_variables*);
     void get_initial_elapsed_time(struct All_variables*);
     int get_process_identifier();
-    void global_derived_values(struct All_variables*);
     void lith_age_init(struct All_variables *E);
     void mass_matrix(struct All_variables*);
-    void node_locations(struct All_variables*);
     void open_info(struct All_variables*);
     void open_log(struct All_variables*);
     void read_mat_from_file(struct All_variables*);
@@ -81,10 +78,10 @@
       open_info(E);
 
     (E->problem_derived_values)(E);   /* call this before global_derived_  */
-    global_derived_values(E);
+    (E->solver.global_derived_values)(E);
 
-    parallel_processor_setup(E);   /* get # of proc in x,y,z */
-    parallel_domain_decomp0(E);  /* get local nel, nno, elx, nox et al */
+    (E->solver.parallel_processor_setup)(E);   /* get # of proc in x,y,z */
+    (E->solver.parallel_domain_decomp0)(E);  /* get local nel, nno, elx, nox et al */
 
     allocate_common_vars(E);
     (E->problem_allocate_vars)(E);
@@ -93,11 +90,11 @@
            /* logical domain */
     construct_ien(E);
     construct_surface(E);
-    construct_boundary(E);
-    parallel_domain_boundary_nodes(E);
+    (E->solver.construct_boundary)(E);
+    (E->solver.parallel_domain_boundary_nodes)(E);
 
            /* physical domain */
-    node_locations (E);
+    (E->solver.node_locations)(E);
 
     if(E->control.tracer==1) {
 	tracer_initial_settings(E);
@@ -121,8 +118,8 @@
     construct_id(E);
     construct_lm(E);
 
-    parallel_communication_routs_v(E);
-    parallel_communication_routs_s(E);
+    (E->solver.parallel_communication_routs_v)(E);
+    (E->solver.parallel_communication_routs_s)(E);
 
     construct_sub_element(E);
     construct_shape_functions(E);

Modified: mc/3D/CitcomS/trunk/module/Regional/misc.cc
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/misc.cc	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Regional/misc.cc	2006-07-06 02:16:42 UTC (rev 3922)
@@ -40,6 +40,9 @@
 
 extern "C" {
 
+    void full_solver_init(struct All_variables*);
+    void regional_solver_init(struct All_variables*);
+
     double return1_test();
     void read_instructions(struct All_variables*, char*);
     double CPU_time0();
@@ -157,6 +160,44 @@
 }
 
 
+char pyCitcom_full_solver_init__doc__[] = "";
+char pyCitcom_full_solver_init__name__[] = "full_solver_init";
+
+PyObject * pyCitcom_full_solver_init(PyObject *, PyObject *args)
+{
+    PyObject *obj;
+
+    if (!PyArg_ParseTuple(args, "O:full_solver_init", &obj))
+        return NULL;
+
+    struct All_variables* E = static_cast<struct All_variables*>(PyCObject_AsVoidPtr(obj));
+
+    full_solver_init(E);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
+char pyCitcom_regional_solver_init__doc__[] = "";
+char pyCitcom_regional_solver_init__name__[] = "regional_solver_init";
+
+PyObject * pyCitcom_regional_solver_init(PyObject *, PyObject *args)
+{
+    PyObject *obj;
+
+    if (!PyArg_ParseTuple(args, "O:regional_solver_init", &obj))
+        return NULL;
+
+    struct All_variables* E = static_cast<struct All_variables*>(PyCObject_AsVoidPtr(obj));
+
+    regional_solver_init(E);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
 char pyCitcom_global_default_values__doc__[] = "";
 char pyCitcom_global_default_values__name__[] = "global_default_values";
 

Modified: mc/3D/CitcomS/trunk/module/Regional/misc.h
===================================================================
--- mc/3D/CitcomS/trunk/module/Regional/misc.h	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/module/Regional/misc.h	2006-07-06 02:16:42 UTC (rev 3922)
@@ -63,6 +63,18 @@
 PyObject * pyCitcom_citcom_init(PyObject *, PyObject *);
 
 
+extern char pyCitcom_full_solver_init__doc__[];
+extern char pyCitcom_full_solver_init__name__[];
+extern "C"
+PyObject * pyCitcom_full_solver_init(PyObject *, PyObject *);
+
+
+extern char pyCitcom_regional_solver_init__doc__[];
+extern char pyCitcom_regional_solver_init__name__[];
+extern "C"
+PyObject * pyCitcom_regional_solver_init(PyObject *, PyObject *);
+
+
 extern char pyCitcom_global_default_values__name__[];
 extern char pyCitcom_global_default_values__doc__[];
 extern "C"

Modified: mc/3D/CitcomS/trunk/pyre/Components/Advection_diffusion/Advection_diffusion.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Advection_diffusion/Advection_diffusion.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Advection_diffusion/Advection_diffusion.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -46,7 +46,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Advection_diffusion_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Advection_diffusion_set_properties
+        Advection_diffusion_set_properties(self.all_variables, self.inventory)
         return
 
 
@@ -58,13 +59,15 @@
 
 
     def setup(self):
-        self.CitcomModule.set_convection_defaults(self.all_variables)
+        from CitcomS.CitcomS import set_convection_defaults
+        set_convection_defaults(self.all_variables)
 	self._been_here = False
 	return
 
 
     def launch(self):
-        self.CitcomModule.PG_timestep_init(self.all_variables)
+        from CitcomS.CitcomS import PG_timestep_init
+        PG_timestep_init(self.all_variables)
         return
 
     #def fini(self):
@@ -73,13 +76,15 @@
 
 
     def _solve(self,dt):
-        self.CitcomModule.PG_timestep_solve(self.all_variables, dt)
+        from CitcomS.CitcomS import PG_timestep_solve
+        PG_timestep_solve(self.all_variables, dt)
 	return
 
 
 
     def stable_timestep(self):
-        dt = self.CitcomModule.stable_timestep(self.all_variables)
+        from CitcomS.CitcomS import stable_timestep
+        dt = stable_timestep(self.all_variables)
         return dt
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/BC.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/BC.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/BC.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -38,13 +38,15 @@
 
 
     def setProperties(self):
-        self.CitcomModule.BC_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import BC_set_properties
+        BC_set_properties(self.all_variables, self.inventory)
         return
 
 
 
     def updatePlateVelocity(self):
-        self.CitcomModule.BC_update_plate_velocity(self.all_variables)
+        from CitcomS.CitcomS import BC_update_plate_velocity
+        BC_update_plate_velocity(self.all_variables)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/CitcomComponent.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/CitcomComponent.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/CitcomComponent.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -31,8 +31,7 @@
 class CitcomComponent(Component):
 
 
-    def initialize(self, Module, all_variables):
-        self.CitcomModule = Module
+    def initialize(self, all_variables):
         self.all_variables = all_variables
         return
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Const.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Const.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Const.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -39,7 +39,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Const_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Const_set_properties
+        Const_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/IC.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/IC.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/IC.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -38,13 +38,17 @@
 
 
     def setProperties(self):
+
+        from CitcomS.CitcomS import IC_set_properties
+        
         inv = self.inventory
         inv.perturbmag = map(float, inv.perturbmag)
         inv.perturbl = map(float, inv.perturbl)
         inv.perturbm = map(float, inv.perturbm)
         inv.blob_center = map(float, inv.blob_center)
 
-        self.CitcomModule.IC_set_properties(self.all_variables, inv)
+        IC_set_properties(self.all_variables, inv)
+        
         return
 
 
@@ -59,28 +63,32 @@
 
 
     def initTemperature(self):
+        from CitcomS.CitcomS import constructTemperature, restartTemperature
         if self.inventory.restart:
-            self.CitcomModule.restartTemperature(self.all_variables)
+            restartTemperature(self.all_variables)
         else:
-            self.CitcomModule.constructTemperature(self.all_variables)
+            constructTemperature(self.all_variables)
         return
 
 
 
     def initPressure(self):
-        self.CitcomModule.initPressure(self.all_variables)
+        from CitcomS.CitcomS import initPressure
+        initPressure(self.all_variables)
         return
 
 
 
     def initVelocity(self):
-        self.CitcomModule.initVelocity(self.all_variables)
+        from CitcomS.CitcomS import initVelocity
+        initVelocity(self.all_variables)
         return
 
 
 
     def initViscosity(self):
-        self.CitcomModule.initViscosity(self.all_variables)
+        from CitcomS.CitcomS import initViscosity
+        initViscosity(self.all_variables)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Launchers.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Launchers.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Launchers.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -27,6 +27,7 @@
 #
 
 
+import sys
 from mpi.Launcher import Launcher
 from pyre.util import expandMacros
 
@@ -36,17 +37,6 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
-def which(filename):
-    from os.path import abspath, exists, join
-    from os import environ, pathsep
-    dirs = environ['PATH'].split(pathsep)
-    for dir in dirs:
-       pathname = join(dir, filename)
-       if exists(pathname):
-           return abspath(pathname)
-    return filename
-
-
 def hms(t):
     return (int(t / 3600), int((t % 3600) / 60), int(t % 60))
 
@@ -82,8 +72,7 @@
         extra.meta['tip'] = "extra arguments to pass to mpirun"
         
         command = pyre.inventory.str("command", default="mpirun")
-        python_mpi = pyre.inventory.str("python-mpi", default=which("mpipython.exe"))
-        re_exec = pyre.inventory.bool("re-exec", default=True)
+        interpreter = pyre.inventory.str("interpreter", default=sys.executable)
 
 
     def launch(self):
@@ -106,37 +95,18 @@
     def _buildArgumentList(self):
         import sys
 
-        python_mpi = self.inventory.python_mpi
+        interpreter = self.inventory.interpreter
 
         if not self.nodes:
             self.nodes = len(self.nodelist)
 
-        if self.nodes < 2:
-            import mpi
-            if mpi.world().handle():
-                self.inventory.nodes = 1
-                return []
-            elif self.inventory.re_exec:
-                # re-exec under mpipython.exe
-                args = []
-                args.append(python_mpi)
-                args += sys.argv
-                args.append("--launcher.re-exec=False") # protect against infinite regress
-                return args
-            else:
-                # We are under the 'mpipython.exe' interpreter,
-                # yet the 'mpi' module is non-functional.  Attempt to
-                # re-raise the exception that may have caused this.
-                import mpi._mpi
-                return []
-        
         # build the command
         args = []
         args.append(self.inventory.command)
         self._appendMpiRunArgs(args)
 
         # add the parallel version of the interpreter on the command line
-        args.append(python_mpi)
+        args.append(interpreter)
 
         args += sys.argv
         args.append("--mode=worker")
@@ -230,7 +200,7 @@
         dry = pyre.inventory.bool("dry", default=False)
         debug = pyre.inventory.bool("debug", default=False)
 
-        python_mpi = pyre.inventory.str("python-mpi", default=which("mpipython.exe"))
+        interpreter = pyre.inventory.str("interpreter", default=sys.executable)
         task = pyre.inventory.str("task")
 
         # Ignore 'nodegen' so that the examples will work without modification.
@@ -299,7 +269,7 @@
             expandMacros('''\
 
 cd ${directory}
-${command} ${python-mpi} ${argv} --mode=worker
+${command} ${interpreter} ${argv} --mode=worker
 ''', self.inv)
             ]
         script = "\n".join(script) + "\n"
@@ -443,7 +413,7 @@
         script = [
             expandMacros('''\
 &   (jobType=mpi)
-    (executable="${python-mpi}")
+    (executable="${interpreter}")
     (count=${nodes})
     (directory="${directory}")
     (stdout="${stdout}")

Modified: mc/3D/CitcomS/trunk/pyre/Components/Param.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Param.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Param.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -38,7 +38,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Param_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Param_set_properties
+        Param_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Phase.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Phase.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Phase.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -38,7 +38,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Phase_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Phase_set_properties
+        Phase_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Sphere/FullSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Sphere/FullSphere.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Sphere/FullSphere.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -39,7 +39,8 @@
 
 
     def launch(self):
-        self.CitcomModule.full_sphere_launch(self.all_variables)
+        from CitcomS.CitcomS import full_sphere_launch
+        full_sphere_launch(self.all_variables)
 	return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Sphere/RegionalSphere.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Sphere/RegionalSphere.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Sphere/RegionalSphere.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -39,7 +39,8 @@
 
 
     def launch(self):
-        self.CitcomModule.regional_sphere_launch(self.all_variables)
+        from CitcomS.CitcomS import regional_sphere_launch
+        regional_sphere_launch(self.all_variables)
 	return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Sphere/Sphere.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Sphere/Sphere.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Sphere/Sphere.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -26,6 +26,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 
+from CitcomS.CitcomS import CPU_time
 from CitcomS.Components.CitcomComponent import CitcomComponent
 
 class Sphere(CitcomComponent):
@@ -38,14 +39,14 @@
 
 
     def run(self):
-        start_time = self.CitcomModule.CPU_time()
+        start_time = CPU_time()
         self.launch()
 
         import mpi
         if not mpi.world().rank:
             import sys
             print >> sys.stderr, "initialization time = %f" % \
-                  (self.CitcomModule.CPU_time() - start_time)
+                  (CPU_time() - start_time)
 
 	return
 
@@ -58,7 +59,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Sphere_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Sphere_set_properties
+        Sphere_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Stokes_solver/Incompressible.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Stokes_solver/Incompressible.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Stokes_solver/Incompressible.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -40,24 +40,27 @@
 
 
     def run(self):
-        self.CitcomModule.general_stokes_solver(self.all_variables)
+        from CitcomS.CitcomS import general_stokes_solver
+        general_stokes_solver(self.all_variables)
 	return
 
 
 
     def setup(self):
+        from CitcomS.CitcomS import set_cg_defaults, set_mg_defaults, set_mg_el_defaults
         if self.inventory.Solver == "cgrad":
-            self.CitcomModule.set_cg_defaults(self.all_variables)
+            set_cg_defaults(self.all_variables)
         elif self.inventory.Solver == "multigrid":
-            self.CitcomModule.set_mg_defaults(self.all_variables)
+            set_mg_defaults(self.all_variables)
         elif self.inventory.Solver == "multigrid-el":
-            self.CitcomModule.set_mg_el_defaults(self.all_variables)
+            set_mg_el_defaults(self.all_variables)
         return
 
 
 
     def launch(self):
-        self.CitcomModule.general_stokes_solver_setup(self.all_variables)
+        from CitcomS.CitcomS import general_stokes_solver_setup
+        general_stokes_solver_setup(self.all_variables)
         return
 
 
@@ -68,7 +71,8 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Incompressible_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Incompressible_set_properties
+        Incompressible_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Tracer.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Tracer.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Tracer.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -39,13 +39,15 @@
 
 
     def run(self):
-        self.CitcomModule.Tracer_tracer_advection(self.all_variables)
+        from CitcomS.CitcomS import Tracer_tracer_advection
+        Tracer_tracer_advection(self.all_variables)
         return
 
 
 
     def setProperties(self):
-        self.CitcomModule.Tracer_set_properties(self.all_variables, self.inventory)
+        from CitcomS.CitcomS import Tracer_set_properties
+        Tracer_set_properties(self.all_variables, self.inventory)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Components/Visc.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Components/Visc.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Components/Visc.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -41,6 +41,9 @@
 
 
     def setProperties(self):
+
+        from CitcomS.CitcomS import Visc_set_properties
+        
         inv = self.inventory
         inv.visc0 = map(float, inv.visc0)
         inv.viscE = map(float, inv.viscE)
@@ -48,13 +51,15 @@
         inv.viscZ = map(float, inv.viscZ)
         inv.sdepv_expt = map(float, inv.sdepv_expt)
 
-        self.CitcomModule.Visc_set_properties(self.all_variables, inv)
+        Visc_set_properties(self.all_variables, inv)
+        
         return
 
 
 
     def updateMaterial(self):
-        self.CitcomModule.Visc_update_material(self.all_variables)
+        from CitcomS.CitcomS import Visc_update_material
+        Visc_update_material(self.all_variables)
         return
 
 

Modified: mc/3D/CitcomS/trunk/pyre/SimpleApp.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/SimpleApp.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/SimpleApp.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -27,14 +27,6 @@
 #
 
 
-# re-create the PYTHONPATH at 'configure' time
-import sys
-from config import makefile
-path = makefile['PYTHONPATH'].split(':')
-for dir in path:
-    sys.path.insert(1, dir)
-
-
 from mpi.Application import Application
 import journal
 

Modified: mc/3D/CitcomS/trunk/pyre/Solver/FullSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Solver/FullSolver.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Solver/FullSolver.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -27,21 +27,15 @@
 #
 
 from Solver import Solver
+from CitcomS.CitcomS import full_solver_init
 import journal
 
 
 class FullSolver(Solver):
 
 
-    def __init__(self, name, facility="solver"):
-	Solver.__init__(self, name, facility)
-        import mpi
-        if mpi.world().handle():
-            import CitcomS.Full as CitcomModule
-            self.CitcomModule = CitcomModule
-        else:
-            self.CitcomModule = None
-        return
+    def initializeSolver(self):
+        full_solver_init(self.all_variables)
 
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Solver/RegionalSolver.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Solver/RegionalSolver.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Solver/RegionalSolver.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -27,21 +27,15 @@
 #
 
 from Solver import Solver
+from CitcomS.CitcomS import regional_solver_init
 import journal
 
 
 class RegionalSolver(Solver):
 
 
-    def __init__(self, name, facility="solver"):
-	Solver.__init__(self, name, facility)
-        import mpi
-        if mpi.world().handle():
-            import CitcomS.Regional as CitcomModule
-            self.CitcomModule = CitcomModule
-        else:
-            self.CitcomModule = None
-        return
+    def initializeSolver(self):
+        regional_solver_init(self.all_variables)
 
 
 

Modified: mc/3D/CitcomS/trunk/pyre/Solver/Solver.py
===================================================================
--- mc/3D/CitcomS/trunk/pyre/Solver/Solver.py	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/pyre/Solver/Solver.py	2006-07-06 02:16:42 UTC (rev 3922)
@@ -26,6 +26,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 
+from CitcomS.CitcomS import CPU_time, output
 from pyre.simulations.Solver import Solver as BaseSolver
 import journal
 
@@ -36,7 +37,6 @@
     def __init__(self, name, facility="solver"):
         BaseSolver.__init__(self, name, facility)
 
-        self.CitcomModule = None
         self.all_variables = None
         self.communicator = None
 
@@ -54,36 +54,40 @@
 
 
     def initialize(self, application):
+
+        from CitcomS.CitcomS import citcom_init, global_default_values, set_signal
+
         BaseSolver.initialize(self, application)
 
         comm = application.solverCommunicator
-        self.all_variables = self.CitcomModule.citcom_init(comm.handle())
+        all_variables = citcom_init(comm.handle())
 	self.communicator = comm
+        self.all_variables = all_variables
 
+        self.initializeSolver()
+
         # information about clock time
-	self.start_cpu_time = self.CitcomModule.CPU_time()
+	self.start_cpu_time = CPU_time()
         self.cpu_time = self.start_cpu_time
         self.fptime = open("%s.time" % self.inventory.datafile, "w")
 
 	inv = self.inventory
-        CitcomModule = self.CitcomModule
-        all_variables = self.all_variables
+        
+        inv.mesher.initialize(all_variables)
+        inv.tsolver.initialize(all_variables)
+        inv.vsolver.initialize(all_variables)
 
-        inv.mesher.initialize(CitcomModule, all_variables)
-        inv.tsolver.initialize(CitcomModule, all_variables)
-        inv.vsolver.initialize(CitcomModule, all_variables)
+        inv.bc.initialize(all_variables)
+        inv.const.initialize(all_variables)
+        inv.ic.initialize(all_variables)
+        inv.param.initialize(all_variables)
+        inv.phase.initialize(all_variables)
+        inv.tracer.initialize(all_variables)
+        inv.visc.initialize(all_variables)
 
-        inv.bc.initialize(CitcomModule, all_variables)
-        inv.const.initialize(CitcomModule, all_variables)
-        inv.ic.initialize(CitcomModule, all_variables)
-        inv.param.initialize(CitcomModule, all_variables)
-        inv.phase.initialize(CitcomModule, all_variables)
-        inv.tracer.initialize(CitcomModule, all_variables)
-        inv.visc.initialize(CitcomModule, all_variables)
+        global_default_values(self.all_variables)
+        set_signal()
 
-        CitcomModule.global_default_values(self.all_variables)
-        CitcomModule.set_signal()
-
         self.setProperties()
 
         self.restart = self.inventory.ic.inventory.restart
@@ -226,7 +230,7 @@
     def endSimulation(self, step):
         BaseSolver.endSimulation(self, step, self.t)
 
-        total_cpu_time = self.CitcomModule.CPU_time() - self.start_cpu_time
+        total_cpu_time = CPU_time() - self.start_cpu_time
 
         rank = self.communicator.rank
         if not rank:
@@ -235,9 +239,9 @@
                 total_cpu_time / step )
 
         if self.coupler:
-            self.CitcomModule.output(self.all_variables, step)
+            output(self.all_variables, step)
 
-	#self.CitcomModule.finalize()
+	#finalize()
         return
 
 
@@ -245,17 +249,17 @@
     def save(self, step, monitoringFrequency):
         # for non-coupled run, output spacing is 'monitoringFrequency'
         if not (step % monitoringFrequency):
-            self.CitcomModule.output(self.all_variables, step)
+            output(self.all_variables, step)
         elif self.coupler and not (self.coupler.exchanger.coupled_steps % monitoringFrequency):
             print self.coupler.exchanger.coupled_steps, monitoringFrequency
-            self.CitcomModule.output(self.all_variables, step)
+            output(self.all_variables, step)
 
         return
 
 
     def timesave(self, t, steps):
         # output time information
-        time = self.CitcomModule.CPU_time()
+        time = CPU_time()
         msg = "%d %.4e %.4e %.4e %.4e" % (steps,
                                           t,
                                           t - self.model_time,
@@ -270,8 +274,10 @@
 
 
     def setProperties(self):
-        self.CitcomModule.Solver_set_properties(self.all_variables,
-                                                self.inventory)
+ 
+        from CitcomS.CitcomS import Solver_set_properties
+        
+        Solver_set_properties(self.all_variables, self.inventory)
 
 	inv = self.inventory
         inv.mesher.setProperties()

Modified: mc/3D/CitcomS/trunk/tests/Makefile.am
===================================================================
--- mc/3D/CitcomS/trunk/tests/Makefile.am	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/tests/Makefile.am	2006-07-06 02:16:42 UTC (rev 3922)
@@ -28,8 +28,7 @@
 	citcomsregional.sh \
 	coupledcitcoms.sh
 do_subst = sed \
-	-e 's|[@]pkgpyexecdir[@]|$(pkgpyexecdir)|g' \
-	-e 's|[@]PYTHON[@]|$(PYTHON)|g'
+	-e 's|[@]CITCOMS[@]|$(bindir)/citcoms|g'
 citcomsfull.sh: $(srcdir)/citcomsfull.sh.in
 	$(do_subst) < $(srcdir)/citcomsfull.sh.in > $@ || (rm -f $@ && exit 1)
 citcomsregional.sh: $(srcdir)/citcomsregional.sh.in

Modified: mc/3D/CitcomS/trunk/tests/citcomsfull.sh.in
===================================================================
--- mc/3D/CitcomS/trunk/tests/citcomsfull.sh.in	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/tests/citcomsfull.sh.in	2006-07-06 02:16:42 UTC (rev 3922)
@@ -26,7 +26,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
 
 
- at PYTHON@ @pkgpyexecdir@/SimpleApp.pyc --solver=full $*
+ at CITCOMS@ --solver=full $*
 
 
 # version

Modified: mc/3D/CitcomS/trunk/tests/citcomsregional.sh.in
===================================================================
--- mc/3D/CitcomS/trunk/tests/citcomsregional.sh.in	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/tests/citcomsregional.sh.in	2006-07-06 02:16:42 UTC (rev 3922)
@@ -26,7 +26,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
 
 
- at PYTHON@ @pkgpyexecdir@/SimpleApp.pyc $*
+ at CITCOMS@ $*
 
 
 # version

Modified: mc/3D/CitcomS/trunk/tests/coupledcitcoms.sh.in
===================================================================
--- mc/3D/CitcomS/trunk/tests/coupledcitcoms.sh.in	2006-07-05 23:40:26 UTC (rev 3921)
+++ mc/3D/CitcomS/trunk/tests/coupledcitcoms.sh.in	2006-07-06 02:16:42 UTC (rev 3922)
@@ -26,7 +26,7 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
 
 
- at PYTHON@ @pkgpyexecdir@/CoupledApp.pyc $*
+ at CITCOMS@ --coupled $*
 
 
 # version



More information about the cig-commits mailing list