[cig-commits] r14643 - in mc/3D/CitcomS/branches/cxx: bin lib module

leif at geodynamics.org leif at geodynamics.org
Wed Apr 8 20:05:13 PDT 2009


Author: leif
Date: 2009-04-08 20:05:05 -0700 (Wed, 08 Apr 2009)
New Revision: 14643

Added:
   mc/3D/CitcomS/branches/cxx/lib/bc_util.h
   mc/3D/CitcomS/branches/cxx/lib/construct_arrays.h
   mc/3D/CitcomS/branches/cxx/lib/convection.h
   mc/3D/CitcomS/branches/cxx/lib/determine_net_rotation.h
   mc/3D/CitcomS/branches/cxx/lib/element_calculations.h
   mc/3D/CitcomS/branches/cxx/lib/full_boundary_conditions.h
   mc/3D/CitcomS/branches/cxx/lib/full_geometry_cartesian.h
   mc/3D/CitcomS/branches/cxx/lib/full_lith_age_read_files.h
   mc/3D/CitcomS/branches/cxx/lib/full_parallel_related.h
   mc/3D/CitcomS/branches/cxx/lib/full_read_input_from_files.h
   mc/3D/CitcomS/branches/cxx/lib/full_solver.h
   mc/3D/CitcomS/branches/cxx/lib/full_sphere_related.h
   mc/3D/CitcomS/branches/cxx/lib/full_tracer_advection.h
   mc/3D/CitcomS/branches/cxx/lib/full_version_dependent.h
   mc/3D/CitcomS/branches/cxx/lib/general_matrix_functions.h
   mc/3D/CitcomS/branches/cxx/lib/global_operations.h
   mc/3D/CitcomS/branches/cxx/lib/instructions.h
   mc/3D/CitcomS/branches/cxx/lib/nodal_mesh.h
   mc/3D/CitcomS/branches/cxx/lib/output_gzdir.h
   mc/3D/CitcomS/branches/cxx/lib/output_vtk.h
   mc/3D/CitcomS/branches/cxx/lib/pan_problem_misc_functions.h
   mc/3D/CitcomS/branches/cxx/lib/parallel_util.h
   mc/3D/CitcomS/branches/cxx/lib/problem_related.h
   mc/3D/CitcomS/branches/cxx/lib/process_buoyancy.h
   mc/3D/CitcomS/branches/cxx/lib/regional_boundary_conditions.h
   mc/3D/CitcomS/branches/cxx/lib/regional_geometry_cartesian.h
   mc/3D/CitcomS/branches/cxx/lib/regional_lith_age_read_files.h
   mc/3D/CitcomS/branches/cxx/lib/regional_parallel_related.h
   mc/3D/CitcomS/branches/cxx/lib/regional_read_input_from_files.h
   mc/3D/CitcomS/branches/cxx/lib/regional_solver.h
   mc/3D/CitcomS/branches/cxx/lib/regional_sphere_related.h
   mc/3D/CitcomS/branches/cxx/lib/regional_tracer_advection.h
   mc/3D/CitcomS/branches/cxx/lib/regional_version_dependent.h
   mc/3D/CitcomS/branches/cxx/lib/shape_functions.h
   mc/3D/CitcomS/branches/cxx/lib/size_does_matter.h
   mc/3D/CitcomS/branches/cxx/lib/solver_conj_grad.h
   mc/3D/CitcomS/branches/cxx/lib/solver_multigrid.h
   mc/3D/CitcomS/branches/cxx/lib/sphere_harmonics.h
   mc/3D/CitcomS/branches/cxx/lib/sphere_util.h
   mc/3D/CitcomS/branches/cxx/lib/stokes_flow_incomp.h
   mc/3D/CitcomS/branches/cxx/lib/topo_gravity.h
   mc/3D/CitcomS/branches/cxx/lib/tracer_setup.h
   mc/3D/CitcomS/branches/cxx/lib/viscosity_structures.h
Removed:
   mc/3D/CitcomS/branches/cxx/lib/Full_obsolete.cc
   mc/3D/CitcomS/branches/cxx/lib/Obsolete.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_obsolete.cc
   mc/3D/CitcomS/branches/cxx/lib/cproto.h
   mc/3D/CitcomS/branches/cxx/lib/parallel_related.h
Modified:
   mc/3D/CitcomS/branches/cxx/bin/Citcom.cc
   mc/3D/CitcomS/branches/cxx/bin/CitcomSFull.cc
   mc/3D/CitcomS/branches/cxx/bin/CitcomSRegional.cc
   mc/3D/CitcomS/branches/cxx/lib/Advection_diffusion.cc
   mc/3D/CitcomS/branches/cxx/lib/BC_util.cc
   mc/3D/CitcomS/branches/cxx/lib/Checkpoints.cc
   mc/3D/CitcomS/branches/cxx/lib/Citcom_init.cc
   mc/3D/CitcomS/branches/cxx/lib/Composition_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Construct_arrays.cc
   mc/3D/CitcomS/branches/cxx/lib/Convection.cc
   mc/3D/CitcomS/branches/cxx/lib/Determine_net_rotation.cc
   mc/3D/CitcomS/branches/cxx/lib/Drive_solvers.cc
   mc/3D/CitcomS/branches/cxx/lib/Element_calculations.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_boundary_conditions.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_geometry_cartesian.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_lith_age_read_files.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_parallel_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_read_input_from_files.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_solver.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_sphere_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_tracer_advection.cc
   mc/3D/CitcomS/branches/cxx/lib/Full_version_dependent.cc
   mc/3D/CitcomS/branches/cxx/lib/General_matrix_functions.cc
   mc/3D/CitcomS/branches/cxx/lib/Ggrd_handling.cc
   mc/3D/CitcomS/branches/cxx/lib/Global_operations.cc
   mc/3D/CitcomS/branches/cxx/lib/Initial_temperature.cc
   mc/3D/CitcomS/branches/cxx/lib/Instructions.cc
   mc/3D/CitcomS/branches/cxx/lib/Interuption.cc
   mc/3D/CitcomS/branches/cxx/lib/Lith_age.cc
   mc/3D/CitcomS/branches/cxx/lib/Makefile.am
   mc/3D/CitcomS/branches/cxx/lib/Material_properties.cc
   mc/3D/CitcomS/branches/cxx/lib/Nodal_mesh.cc
   mc/3D/CitcomS/branches/cxx/lib/Output.cc
   mc/3D/CitcomS/branches/cxx/lib/Output_gzdir.cc
   mc/3D/CitcomS/branches/cxx/lib/Output_h5.cc
   mc/3D/CitcomS/branches/cxx/lib/Output_vtk.cc
   mc/3D/CitcomS/branches/cxx/lib/Pan_problem_misc_functions.cc
   mc/3D/CitcomS/branches/cxx/lib/Parallel_util.cc
   mc/3D/CitcomS/branches/cxx/lib/Parsing.cc
   mc/3D/CitcomS/branches/cxx/lib/Phase_change.cc
   mc/3D/CitcomS/branches/cxx/lib/Problem_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Process_buoyancy.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_boundary_conditions.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_geometry_cartesian.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_lith_age_read_files.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_parallel_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_read_input_from_files.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_solver.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_sphere_related.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_tracer_advection.cc
   mc/3D/CitcomS/branches/cxx/lib/Regional_version_dependent.cc
   mc/3D/CitcomS/branches/cxx/lib/Shape_functions.cc
   mc/3D/CitcomS/branches/cxx/lib/Size_does_matter.cc
   mc/3D/CitcomS/branches/cxx/lib/Solver_conj_grad.cc
   mc/3D/CitcomS/branches/cxx/lib/Solver_multigrid.cc
   mc/3D/CitcomS/branches/cxx/lib/Sphere_harmonics.cc
   mc/3D/CitcomS/branches/cxx/lib/Sphere_util.cc
   mc/3D/CitcomS/branches/cxx/lib/Stokes_flow_Incomp.cc
   mc/3D/CitcomS/branches/cxx/lib/Topo_gravity.cc
   mc/3D/CitcomS/branches/cxx/lib/Tracer_setup.cc
   mc/3D/CitcomS/branches/cxx/lib/Viscosity_structures.cc
   mc/3D/CitcomS/branches/cxx/lib/advection_diffusion.h
   mc/3D/CitcomS/branches/cxx/lib/checkpoints.h
   mc/3D/CitcomS/branches/cxx/lib/citcom_init.h
   mc/3D/CitcomS/branches/cxx/lib/composition_related.h
   mc/3D/CitcomS/branches/cxx/lib/drive_solvers.h
   mc/3D/CitcomS/branches/cxx/lib/ggrd_handling.h
   mc/3D/CitcomS/branches/cxx/lib/initial_temperature.h
   mc/3D/CitcomS/branches/cxx/lib/interuption.h
   mc/3D/CitcomS/branches/cxx/lib/lith_age.h
   mc/3D/CitcomS/branches/cxx/lib/material_properties.h
   mc/3D/CitcomS/branches/cxx/lib/output.h
   mc/3D/CitcomS/branches/cxx/lib/output_h5.h
   mc/3D/CitcomS/branches/cxx/lib/parsing.h
   mc/3D/CitcomS/branches/cxx/lib/phase_change.h
   mc/3D/CitcomS/branches/cxx/module/advdiffu.cc
   mc/3D/CitcomS/branches/cxx/module/initial_conditions.cc
   mc/3D/CitcomS/branches/cxx/module/mesher.cc
   mc/3D/CitcomS/branches/cxx/module/misc.cc
   mc/3D/CitcomS/branches/cxx/module/outputs.cc
   mc/3D/CitcomS/branches/cxx/module/setProperties.cc
   mc/3D/CitcomS/branches/cxx/module/stokes_solver.cc
Log:
For each function, place a unique prototype in a header file which
corresponds to the source file in which the function is defined.
Declare functions as "static" wherever possible.  Removed "obsolete"
source files.


Modified: mc/3D/CitcomS/branches/cxx/bin/Citcom.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/bin/Citcom.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/bin/Citcom.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -34,15 +34,20 @@
 #include "global_defs.h"
 #include "citcom_init.h"
 #include "output.h"
-#include "parallel_related.h"
+#include "parallel_util.h"
 #include "checkpoints.h"
 
-#include "cproto.h"
+#include "drive_solvers.h"
+#include "instructions.h"
+#include "interuption.h"
+#include "problem_related.h"
+#include "process_buoyancy.h"
+#include "tracer_setup.h"
 
-extern int Emergency_stop;
 
 void solver_init(struct All_variables *E);
 
+
 int main(int argc, char **argv)
 {	/* Functions called by main*/
   float cpu_time_on_vp_it;

Modified: mc/3D/CitcomS/branches/cxx/bin/CitcomSFull.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/bin/CitcomSFull.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/bin/CitcomSFull.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,10 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-struct All_variables;
+#include "full_solver.h"
 
-void full_solver_init(struct All_variables *E);
-
 void solver_init(struct All_variables *E)
 {
   full_solver_init(E);

Modified: mc/3D/CitcomS/branches/cxx/bin/CitcomSRegional.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/bin/CitcomSRegional.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/bin/CitcomSRegional.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,10 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-struct All_variables;
+#include "regional_solver.h"
 
-void regional_solver_init(struct All_variables *E);
-
 void solver_init(struct All_variables *E)
 {
   regional_solver_init(E);

Modified: mc/3D/CitcomS/branches/cxx/lib/Advection_diffusion.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Advection_diffusion.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Advection_diffusion.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,15 +29,21 @@
      streamline-upwind methods. The process is basically as described in Alex
      Brooks PhD thesis (Caltech) which refers back to Hughes, Liu and Brooks.  */
 
+#include "advection_diffusion.h"
+
 #include <sys/types.h>
 
 #include "element_definitions.h"
 #include "global_defs.h"
 #include <math.h>
-#include "advection_diffusion.h"
 #include "parsing.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "global_operations.h"
+#include "lith_age.h"
+#include "nodal_mesh.h"
+#include "size_does_matter.h"
+#include "viscosity_structures.h"
 
 
 static void set_diffusion_timestep(struct All_variables *E);

Modified: mc/3D/CitcomS/branches/cxx/lib/BC_util.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/BC_util.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/BC_util.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,9 +26,14 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "bc_util.h"
+
 #include "global_defs.h"
 
 
+static void temperatures_conform_bcs2(struct All_variables *);
+
+
 void strip_bcs_from_residual(struct All_variables *E, double **Res, int level)
 {
     int m,i;
@@ -44,9 +49,6 @@
 
 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) {
     /*
     This sequence now moved to end of PG_time_step_solve
@@ -60,7 +62,7 @@
 }
 
 
-void temperatures_conform_bcs2(struct All_variables *E)
+static void temperatures_conform_bcs2(struct All_variables *E)
 {
   int j,node;
   unsigned int type;

Modified: mc/3D/CitcomS/branches/cxx/lib/Checkpoints.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Checkpoints.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Checkpoints.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,13 +26,21 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "checkpoints.h"
+
 #include <sys/file.h>
 #include <unistd.h>
 #include "global_defs.h"
 #include "composition_related.h"
 
-#include "cproto.h"
+#include "global_operations.h"
+#include "instructions.h"
+#include "nodal_mesh.h"
+#include "pan_problem_misc_functions.h"
+#include "tracer_setup.h"
+#include "viscosity_structures.h"
 
+
 /* Private function prototypes */
 static void backup_file(const char *output_file);
 static void write_sentinel(FILE *fp);
@@ -88,9 +96,6 @@
 
 void read_checkpoint(struct All_variables *E)
 {
-    void initialize_material(struct All_variables *E);
-    void initial_viscosity(struct All_variables *E);
-
     char output_file[255];
     FILE *fp;
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Citcom_init.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Citcom_init.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Citcom_init.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,13 +26,15 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
-#include "global_defs.h"
 #include "citcom_init.h"
 
+#include "global_defs.h"
+
+#include "pan_problem_misc_functions.h"
+
+
 struct All_variables* citcom_init(MPI_Comm *world)
 {
-  int get_process_identifier();
-
   struct All_variables *E;
   int rank, nproc;
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Composition_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Composition_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Composition_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,13 +26,15 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+
+#include "composition_related.h"
+
 #include <math.h>
 #include "global_defs.h"
 #include "parsing.h"
-#include "parallel_related.h"
-#include "composition_related.h"
 
-#include "cproto.h"
+#include "global_operations.h"
+#include "parallel_util.h"
 
 
 static void allocate_composition_memory(struct All_variables *E);

Modified: mc/3D/CitcomS/branches/cxx/lib/Construct_arrays.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Construct_arrays.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Construct_arrays.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,16 +25,22 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "construct_arrays.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "element_calculations.h"
+#include "solver_multigrid.h"
 
 
-int layers_r(struct All_variables *,float );
-int layers(struct All_variables *,int ,int );
+static void get_bcs_id_for_residual(struct All_variables *E, int level, int m);
+static void construct_node_ks(struct All_variables *E);
+static void rebuild_BI_on_boundary(struct All_variables *E);
+static void construct_elt_ks(struct All_variables *E);
 
 
 /*========================================================
@@ -199,7 +205,7 @@
 
 
 
-void get_bcs_id_for_residual(struct All_variables *E, int level, int m)
+static void get_bcs_id_for_residual(struct All_variables *E, int level, int m)
 {
 
     int i,j;
@@ -324,7 +330,7 @@
 }
 
 
-void construct_node_ks(struct All_variables *E)
+static void construct_node_ks(struct All_variables *E)
 {
     int m,level,i,j,k,e;
     int node,node1,eqn1,eqn2,eqn3,loc0,loc1,loc2,loc3,found,element,index,pp,qq;
@@ -335,11 +341,6 @@
 
     higher_precision *B1,*B2,*B3;
 
-    void get_elt_k();
-    void get_aug_k();
-    void build_diagonal_of_K();
-    void parallel_process_termination();
-
     const int dims=E->mesh.nsd,dofs=E->mesh.dof;
     const int ends=enodes[dims];
     const int lms=loc_mat_size[E->mesh.nsd];
@@ -471,7 +472,7 @@
     return;
 }
 
-void rebuild_BI_on_boundary(struct All_variables *E)
+static void rebuild_BI_on_boundary(struct All_variables *E)
 {
     int m,level,i,j;
     int eqn1,eqn2,eqn3;
@@ -633,12 +634,9 @@
    }
 
 
-void construct_elt_ks(struct All_variables *E)
+static void construct_elt_ks(struct All_variables *E)
 {
     int e,el,lev,j,k,ii,m;
-    void get_elt_k();
-    void get_aug_k();
-    void build_diagonal_of_K();
 
     const int dims=E->mesh.nsd;
     const int n=loc_mat_size[E->mesh.nsd];
@@ -681,7 +679,6 @@
 
 void construct_elt_gs(struct All_variables *E)
 { int m,el,lev,a;
-  void get_elt_g();
 
   const int dims=E->mesh.nsd,dofs=E->mesh.dof;
   const int ends=enodes[dims];
@@ -707,7 +704,6 @@
 void construct_elt_cs(struct All_variables *E)
 {
     int m, el, lev;
-    void get_elt_c();
 
 /*     if(E->control.verbose && E->parallel.me==0) */
 /*         fprintf(stderr,"storing elt c matrices\n"); */
@@ -729,14 +725,6 @@
 
 void construct_stiffness_B_matrix(struct All_variables *E)
 {
-  void build_diagonal_of_K();
-  void build_diagonal_of_Ahat();
-  void project_viscosity();
-  void construct_node_maps();
-  void construct_node_ks();
-  void construct_elt_ks();
-  void rebuild_BI_on_boundary();
-
   if (E->control.NMULTIGRID)
     project_viscosity(E);
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Convection.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Convection.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Convection.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -28,6 +28,7 @@
 /* Assumes parameter list is opened and reads the things it needs.
    Variables are initialized etc, default values are set */
 
+#include "convection.h"
 
 #include <math.h>
 #include <sys/types.h>
@@ -36,9 +37,18 @@
 #include <stdlib.h> /* for "system" command */
 #include <strings.h>
 
-#include "cproto.h"
+#include "advection_diffusion.h"
+#include "initial_temperature.h"
+#include "size_does_matter.h"
 
 
+static void read_convection_settings(struct All_variables *E);
+static void convection_derived_values(struct All_variables *E);
+static void convection_allocate_memory(struct All_variables *E);
+static void convection_initial_fields(struct All_variables *E);
+static void convection_boundary_conditions(struct All_variables *E);
+
+
 void set_convection_defaults(struct All_variables *E)
 {
     E->advection.timestep = 0.0;
@@ -66,7 +76,7 @@
     return;
 }
 
-void read_convection_settings(struct All_variables *E)
+static void read_convection_settings(struct All_variables *E)
 {
     /* parameters */
 
@@ -79,13 +89,13 @@
    Any setup which relates only to the convection stuff goes in here
    ================================================================= */
 
-void convection_derived_values(struct All_variables *E)
+static void convection_derived_values(struct All_variables *E)
 {
 
   return;
 }
 
-void convection_allocate_memory(struct All_variables *E)
+static void convection_allocate_memory(struct All_variables *E)
 {
 
   advection_diffusion_allocate_memory(E);
@@ -95,7 +105,7 @@
 
 /* ============================================ */
 
-void convection_initial_fields(struct All_variables *E)
+static void convection_initial_fields(struct All_variables *E)
 {
     convection_initial_temperature(E);
 
@@ -103,7 +113,7 @@
 
 /* =========================================== */
 
-void convection_boundary_conditions(struct All_variables *E)
+static void convection_boundary_conditions(struct All_variables *E)
 {
     (E->solver.velocity_boundary_conditions)(E);      /* universal */
     (E->solver.temperature_boundary_conditions)(E);

Modified: mc/3D/CitcomS/branches/cxx/lib/Determine_net_rotation.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Determine_net_rotation.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Determine_net_rotation.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -37,25 +37,25 @@
 
 */
 
+#include "determine_net_rotation.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
-#include "parallel_related.h"
 #include "parsing.h"
 #include "output.h"
 
-#include "cproto.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "size_does_matter.h"
 
-double determine_netr_tp(float, float, float, float, float, int, double *, double *);
-void sub_netr(float, float, float, float *, float *, double *);
-void hc_ludcmp_3x3(double [3][3], int *);
-void hc_lubksb_3x3(double [3][3], int *, double *);
-void xyz2rtp(float ,float ,float ,float *);
-void *safe_malloc (size_t );
-double determine_model_net_rotation(struct All_variables *,double *);
-void myerror(struct All_variables *,char *);
+
+static double determine_netr_tp(float r, float theta, float phi, float velt, float velp, int mode, double *c9, double *omega);
+static void hc_ludcmp_3x3(double a[3][3], int *indx);
+static void hc_lubksb_3x3(double a[3][3], int *indx, double *b);
+
 /*
 
 determine the mean net rotation of the velocities at all layers
@@ -215,9 +215,9 @@
 */
 
 
-double determine_netr_tp(float r,float theta,float phi,
-			 float velt,float velp,int mode,
-			 double *c9,double *omega)
+static double determine_netr_tp(float r,float theta,float phi,
+                                float velt,float velp,int mode,
+                                double *c9,double *omega)
 {
   float coslat,coslon,sinlat,sinlon,rx,ry,rz,rate,rzu,a,b,c,d,e,f;
   int i,j,ind[3];
@@ -379,7 +379,7 @@
  */
 #define NR_TINY 1.0e-20;
 
-void hc_ludcmp_3x3(double a[3][3],int *indx)
+static void hc_ludcmp_3x3(double a[3][3],int *indx)
 {
   int i,imax=0,j,k;
   double big,dum,sum,temp;
@@ -437,7 +437,7 @@
   }
 }
 #undef NR_TINY
-void hc_lubksb_3x3(double a[3][3], int *indx, double *b)
+static void hc_lubksb_3x3(double a[3][3], int *indx, double *b)
 {
   int i,ii=0,ip,j;
   double sum;

Modified: mc/3D/CitcomS/branches/cxx/lib/Drive_solvers.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Drive_solvers.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Drive_solvers.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,18 +25,25 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "drive_solvers.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
-#include "drive_solvers.h"
 
-#include "cproto.h"
+#include "advection_diffusion.h"
+#include "bc_util.h"
+#include "construct_arrays.h"
+#include "element_calculations.h"
+#include "global_operations.h"
+#include "stokes_flow_incomp.h"
+#include "topo_gravity.h"
+#include "viscosity_structures.h"
 
-double global_vdot();
-double vnorm_nonnewt();
-int need_visc_update(struct All_variables *);
 
+static int need_visc_update(struct All_variables *);
 
 
 /************************************************************/

Modified: mc/3D/CitcomS/branches/cxx/lib/Element_calculations.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Element_calculations.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Element_calculations.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,28 +29,27 @@
    Note that for the regular grid case the calculation of k becomes repetitive
    to the point of redundancy. */
 
+#include "element_calculations.h"
+
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "material_properties.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "global_operations.h"
+#include "pan_problem_misc_functions.h"
+#include "size_does_matter.h"
 
 
-/* else, PGI would complain */
-void construct_side_c3x3matrix_el(struct All_variables *,int ,
-				  struct CC *,struct CCX *,
-				  int ,int ,int ,int );
-void construct_c3x3matrix(struct All_variables *);
-void construct_c3x3matrix_el (struct All_variables *,int ,struct CC *,
-			      struct CCX *,int ,int ,int );
-void assemble_div_u(struct All_variables *,
-                    double **, double **, int );
-void get_elt_tr(struct All_variables *, int , int , double [24], int );
-void get_elt_tr_pseudo_surf(struct All_variables *, int , int , double [24], int );
+static void add_force(struct All_variables *E, int e, double elt_f[24], int m);
+static void get_ba(struct Shape_function *N, struct Shape_function_dx *GNx, struct CC *cc, struct CCX *ccx, double rtf[4][9], int dims, double ba[9][9][4][7]);
+static double assemble_dAhatp_entry(struct All_variables *E, int e, int level, int m);
+static void get_elt_tr(struct All_variables *E, int bel, int side, double elt_tr[24], int m);
+static void get_elt_tr_pseudo_surf(struct All_variables *E, int bel, int side, double elt_tr[24], int m);
 
 
-void add_force(struct All_variables *E, int e, double elt_f[24], int m)
+static void add_force(struct All_variables *E, int e, double elt_f[24], int m)
 {
   const int dims=E->mesh.nsd;
   const int ends=enodes[E->mesh.nsd];
@@ -170,9 +169,9 @@
   quadrature points, which is used to compute element stiffness matrix
   ==============================================================  */
 
-void get_ba(struct Shape_function *N, struct Shape_function_dx *GNx,
-       struct CC *cc, struct CCX *ccx, double rtf[4][9],
-       int dims, double ba[9][9][4][7])
+static void get_ba(struct Shape_function *N, struct Shape_function_dx *GNx,
+                   struct CC *cc, struct CCX *ccx, double rtf[4][9],
+                   int dims, double ba[9][9][4][7])
 {
     int k, a, n;
     const int vpts = VPOINTS3D;
@@ -323,8 +322,6 @@
     const double two = 2.0;
     const double two_thirds = 2.0/3.0;
 
-    void get_rtf_at_vpts();
-
     double ba[9][9][4][7]; /* integration points,node,3x6 matrix */
 
     const int nn=loc_mat_size[E->mesh.nsd];
@@ -728,7 +725,6 @@
     )
 {
   int m,e,i,j1,j2,j3,p,a,b,nel,neq;
-  void strip_bcs_from_residual();
 
   const int ends=enodes[E->mesh.nsd];
   const int dims=E->mesh.nsd;
@@ -769,7 +765,7 @@
 }
 
 
-double assemble_dAhatp_entry(
+static double assemble_dAhatp_entry(
     struct All_variables *E,
     int e, int level, int m
     )
@@ -903,7 +899,6 @@
     )
 
 {
-   void get_rtf_at_ppts();
    int p,a,i;
    double ra,ct,si,x[4],rtf[4][9];
    double temp;
@@ -1033,7 +1028,7 @@
   Function to create the element force vector due to stress b.c.
   ================================================================= */
 
-void get_elt_tr(struct All_variables *E, int bel, int side, double elt_tr[24], int m)
+static void get_elt_tr(struct All_variables *E, int bel, int side, double elt_tr[24], int m)
 {
 
 	const int dims=E->mesh.nsd;
@@ -1116,7 +1111,7 @@
 	}
 }
 
-void get_elt_tr_pseudo_surf(struct All_variables *E, int bel, int side, double elt_tr[24], int m)
+static void get_elt_tr_pseudo_surf(struct All_variables *E, int bel, int side, double elt_tr[24], int m)
 {
 
 	const int dims=E->mesh.nsd;

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_boundary_conditions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_boundary_conditions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_boundary_conditions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,14 +25,20 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "full_boundary_conditions.h"
+
 #include "element_definitions.h"
 #include "global_defs.h"
 #include <math.h>
 
 #include "lith_age.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "pan_problem_misc_functions.h"
+#include "problem_related.h"
 
+
 /* ========================================== */
 
 static void horizontal_bc(
@@ -47,8 +53,6 @@
     );
 static void velocity_apply_periodic_bcs(struct All_variables *E);
 static void temperature_apply_periodic_bcs(struct All_variables *E);
-void read_temperature_boundary_from_file(struct All_variables *);
-void read_velocity_boundary_from_file(struct All_variables *);
 
 /* ========================================== */
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_geometry_cartesian.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_geometry_cartesian.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_geometry_cartesian.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,14 +25,15 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "full_geometry_cartesian.h"
+
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "parsing.h"
 
-#include "cproto.h"
 
-
 void full_set_2dc_defaults(struct All_variables *E)
 {
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_lith_age_read_files.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_lith_age_read_files.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_lith_age_read_files.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -27,10 +27,11 @@
  */
 
 
-#include "global_defs.h"
+#include "full_lith_age_read_files.h"
 
-#include "cproto.h"
+#include "full_read_input_from_files.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*/

Deleted: mc/3D/CitcomS/branches/cxx/lib/Full_obsolete.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_obsolete.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_obsolete.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,1069 +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>
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-/*
-  This file contains functions that are no longer used in this version of
-  CitcomS. To reduce compilation time and maintenance effort, these functions
-  are removed from its original location to here.
-*/
-
-
-
-/*************************************************************************/
-/* from Parallel_related.c                                               */
-/*************************************************************************/
-
-void parallel_process_initilization(E,argc,argv)
-  struct All_variables *E;
-  int argc;
-  char **argv;
-  {
-
-  E->parallel.me = 0;
-  E->parallel.nproc = 1;
-  E->parallel.me_loc[1] = 0;
-  E->parallel.me_loc[2] = 0;
-  E->parallel.me_loc[3] = 0;
-
-  /*  MPI_Init(&argc,&argv); moved to main{} in Citcom.c, CPC 6/16/00 */
-  MPI_Comm_rank(E->parallel.world, &(E->parallel.me) );
-  MPI_Comm_size(E->parallel.world, &(E->parallel.nproc) );
-
-  return;
-  }
-
-/* get numerical grid coordinates for each relevant processor */
-
-void parallel_domain_decomp2(E,GX)
-  struct All_variables *E;
-  float *GX[4];
-  {
-
-  return;
-  }
-
-
- void scatter_to_nlayer_id (E,AUi,AUo,lev)
- struct All_variables *E;
- double **AUi,**AUo;
- int lev;
- {
-
- int i,j,k,k1,m,node1,node,eqn1,eqn,d;
-
- const int dims = E->mesh.nsd;
-
- static double *SD;
- static int been_here=0;
- static int *processors,rootid,nproc,NOZ;
-
- MPI_Status status;
-
- if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"scatter_to_nlayer should not be called\n");
-    return;
-    }
-
- if (been_here==0)   {
-   NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-
-   processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-
-   SD = (double *)malloc((E->lmesh.NEQ[lev])*sizeof(double));
-
-
-   rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-   nproc = 0;
-   for (j=0;j<E->parallel.nprocz;j++) {
-     d = rootid + j;
-     processors[nproc] =  d;
-     nproc ++;
-     }
-
-   been_here++;
-   }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me==rootid)
-      for (d=0;d<E->parallel.nprocz;d++)  {
-
-        for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-          k1 = k + d*E->lmesh.ELZ[lev];
-          for (j=1;j<=E->lmesh.NOY[lev];j++)
-            for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-              node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-              node1= k1+ (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-              SD[dims*(node-1)] = AUi[m][dims*(node1-1)];
-              SD[dims*(node-1)+1] = AUi[m][dims*(node1-1)+1];
-              SD[dims*(node-1)+2] = AUi[m][dims*(node1-1)+2];
-              }
-          }
-
-        if (processors[d]!=rootid)  {
-           MPI_Send(SD,E->lmesh.NEQ[lev],MPI_DOUBLE,processors[d],rootid,E->parallel.world);
-	   }
-        else
-           for (i=0;i<E->lmesh.NEQ[lev];i++)
-	      AUo[m][i] = SD[i];
-        }
-    else
-        MPI_Recv(AUo[m],E->lmesh.NEQ[lev],MPI_DOUBLE,rootid,rootid,E->parallel.world,&status);
-    }
-
- return;
- }
-
-
- void gather_to_1layer_id (E,AUi,AUo,lev)
- struct All_variables *E;
- double **AUi,**AUo;
- int lev;
- {
-
- int i,j,k,k1,m,node1,node,eqn1,eqn,d;
-
- const int dims = E->mesh.nsd;
-
- MPI_Status status;
-
- static double *RV;
- static int been_here=0;
- static int *processors,rootid,nproc,NOZ;
-
- if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-    }
-
- if (been_here==0)   {
-   NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-
-   processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-
-   RV = (double *)malloc((E->lmesh.NEQ[lev])*sizeof(double));
-
-
-   rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-   nproc = 0;
-   for (j=0;j<E->parallel.nprocz;j++) {
-     d = rootid + j;
-     processors[nproc] =  d;
-     nproc ++;
-     }
-
-   been_here++;
-   }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid)
-       MPI_Send(AUi[m],E->lmesh.NEQ[lev],MPI_DOUBLE,rootid,E->parallel.me,E->parallel.world);
-    else
-       for (d=0;d<E->parallel.nprocz;d++) {
-         if (processors[d]!=rootid)
-	   MPI_Recv(RV,E->lmesh.NEQ[lev],MPI_DOUBLE,processors[d],processors[d],E->parallel.world,&status);
-         else
-           for (node=0;node<E->lmesh.NEQ[lev];node++)
-	      RV[node] = AUi[m][node];
-
-         for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-           k1 = k + d*E->lmesh.ELZ[lev];
-           for (j=1;j<=E->lmesh.NOY[lev];j++)
-             for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-               node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-               node1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-
-               AUo[m][dims*(node1-1)] = RV[dims*(node-1)];
-               AUo[m][dims*(node1-1)+1] = RV[dims*(node-1)+1];
-               AUo[m][dims*(node1-1)+2] = RV[dims*(node-1)+2];
-	       }
-	   }
-	 }
-       }
-
- return;
- }
-
-
- void gather_to_1layer_node (E,AUi,AUo,lev)
- struct All_variables *E;
- float **AUi,**AUo;
- int lev;
- {
-
- int i,j,k,k1,m,node1,node,d;
-
- MPI_Status status;
-
- static float *RV;
- static int been_here=0;
- static int *processors,rootid,nproc,NOZ,NNO;
-
- if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-    }
-
- if (been_here==0)   {
-   NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-   NNO = NOZ*E->lmesh.NOX[lev]*E->lmesh.NOY[lev];
-
-   processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-   RV = (float *)malloc((E->lmesh.NNO[lev]+2)*sizeof(float));
-
-
-   rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-   nproc = 0;
-   for (j=0;j<E->parallel.nprocz;j++) {
-     d = rootid + j;
-     processors[nproc] =  d;
-     nproc ++;
-     }
-
-   been_here++;
-   }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid) {
-       MPI_Send(AUi[m],E->lmesh.NNO[lev]+1,MPI_FLOAT,rootid,E->parallel.me,E->parallel.world);
-         for (node=1;node<=NNO;node++)
-           AUo[m][node] = 1.0;
-       }
-    else
-       for (d=0;d<E->parallel.nprocz;d++) {
-	 if (processors[d]!=rootid)
-           MPI_Recv(RV,E->lmesh.NNO[lev]+1,MPI_FLOAT,processors[d],processors[d],E->parallel.world,&status);
-         else
-	   for (node=1;node<=E->lmesh.NNO[lev];node++)
-	      RV[node] = AUi[m][node];
-
-         for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-           k1 = k + d*E->lmesh.ELZ[lev];
-           for (j=1;j<=E->lmesh.NOY[lev];j++)
-             for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-               node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-               node1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-               AUo[m][node1] = RV[node];
-               }
-           }
-         }
-    }
-
- return;
- }
-
-
- void gather_to_1layer_ele (E,AUi,AUo,lev)
- struct All_variables *E;
- float **AUi,**AUo;
- int lev;
- {
-
- int i,j,k,k1,m,e,d,e1;
-
- MPI_Status status;
-
- static float *RV;
- static int been_here=0;
- static int *processors,rootid,nproc,NOZ,NNO;
-
- if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-    }
-
- if (been_here==0)   {
-   NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz;
-   NNO = NOZ*E->lmesh.ELX[lev]*E->lmesh.ELY[lev];
-
-   processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-   RV = (float *)malloc((E->lmesh.NEL[lev]+2)*sizeof(float));
-
-
-   rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-   nproc = 0;
-   for (j=0;j<E->parallel.nprocz;j++) {
-     d = rootid + j;
-     processors[nproc] =  d;
-     nproc ++;
-     }
-
-   been_here++;
-   }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid) {
-       MPI_Send(AUi[m],E->lmesh.NEL[lev]+1,MPI_FLOAT,rootid,E->parallel.me,E->parallel.world);
-         for (e=1;e<=NNO;e++)
-           AUo[m][e] = 1.0;
-       }
-    else
-       for (d=0;d<E->parallel.nprocz;d++) {
-	 if (processors[d]!=rootid)
-           MPI_Recv(RV,E->lmesh.NEL[lev]+1,MPI_FLOAT,processors[d],processors[d],E->parallel.world,&status);
-         else
-	   for (e=1;e<=E->lmesh.NEL[lev];e++)
-	      RV[e] = AUi[m][e];
-
-         for (k=1;k<=E->lmesh.ELZ[lev];k++)   {
-           k1 = k + d*E->lmesh.ELZ[lev];
-           for (j=1;j<=E->lmesh.ELY[lev];j++)
-             for (i=1;i<=E->lmesh.ELX[lev];i++)   {
-               e = k + (i-1)*E->lmesh.ELZ[lev] + (j-1)*E->lmesh.ELZ[lev]*E->lmesh.ELX[lev];
-               e1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.ELX[lev];
-               AUo[m][e1] = RV[e];
-               }
-           }
-         }
-    }
-
- return;
- }
-
-
-
-void gather_TG_to_me0(E,TG)
- struct All_variables *E;
- float *TG;
- {
-
- int i,j,nsl,idb,to_everyone,from_proc,mst,me;
-
- static float *RG[20];
- static int been_here=0;
- const float e_16=1.e-16;
-
- MPI_Status status[100];
- MPI_Status status1;
- MPI_Request request[100];
-
- if (E->parallel.nprocxy==1)   return;
-
- nsl = E->sphere.nsf+1;
- me = E->parallel.me;
-
- if (been_here==0)   {
-   been_here++;
-   for (i=1;i<E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)
-     RG[i] = ( float *)malloc((E->sphere.nsf+1)*sizeof(float));
-   }
-
-
- idb=0;
- for (i=1;i<=E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)  {
-   to_everyone = E->parallel.nprocz*(i-1) + E->parallel.me_loc[3];
-
-   if (me!=to_everyone)    {  /* send TG */
-     idb++;
-     mst = me;
-     MPI_Isend(TG,nsl,MPI_FLOAT,to_everyone,mst,E->parallel.world,&request[idb-1]);
-     }
-   }
-
-
- idb=0;
- for (i=1;i<=E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)  {
-   from_proc = E->parallel.nprocz*(i-1) + E->parallel.me_loc[3];
-   if (me!=from_proc)   {    /* me==0 receive all TG and add them up */
-      mst = from_proc;
-      idb++;
-      MPI_Irecv(RG[idb],nsl,MPI_FLOAT,from_proc,mst,E->parallel.world,&request[idb-1]);
-      }
-   }
-
- MPI_Waitall(idb,request,status);
-
- for (i=1;i<E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)
-   for (j=1;j<=E->sphere.nsf; j++)  {
-        if (fabs(TG[j]) < e_16) TG[j] += RG[i][j];
-        }
-
- return;
- }
-
-
-
-void sum_across_depth_sph(E,sphc,sphs,dest_proc)
- struct All_variables *E;
- int dest_proc;
- float *sphc,*sphs;
- {
-
- int jumpp,i,j,nsl,idb,to_proc,from_proc,mst,me;
-
- float *RG,*TG;
-
- MPI_Status status[100];
- MPI_Status status1;
- MPI_Request request[100];
-
- if (E->parallel.nprocz==1)   return;
-
- jumpp = E->sphere.hindice;
- nsl = E->sphere.hindice*2;
- me = E->parallel.me;
-
- TG = ( float *)malloc(nsl*sizeof(float));
- if (E->parallel.me_loc[3]==dest_proc)
-      RG = ( float *)malloc(nsl*sizeof(float));
-
- for (i=0;i<E->sphere.hindice;i++)   {
-    TG[i] = sphc[i];
-    TG[i+jumpp] = sphs[i];
-    }
-
-
- if (E->parallel.me_loc[3]!=dest_proc)    {  /* send TG */
-     to_proc = E->parallel.me_sph*E->parallel.nprocz+E->parallel.nprocz-1;
-     mst = me;
-     MPI_Send(TG,nsl,MPI_FLOAT,to_proc,mst,E->parallel.world);
-     }
-
- parallel_process_sync(E);
-
- if (E->parallel.me_loc[3]==dest_proc)  {
-   for (i=1;i<E->parallel.nprocz;i++) {
-      from_proc = me - i;
-      mst = from_proc;
-      MPI_Recv(RG,nsl,MPI_FLOAT,from_proc,mst,E->parallel.world,&status1);
-
-      for (j=0;j<E->sphere.hindice;j++)   {
-        sphc[j] += RG[j];
-        sphs[j] += RG[j+jumpp];
-        }
-      }
-   }
-
- free((void *) TG);
- if (E->parallel.me_loc[3]==dest_proc)
-   free((void *) RG);
-
- return;
- }
-
-
-void sum_across_surf_sph(E,TG,loc_proc)
-  struct All_variables *E;
- int loc_proc;
- float *TG;
- {
-
- int i,j,nsl,idb,to_everyone,from_proc,mst,me;
-
- float *RG[20];
-
- MPI_Status status[100];
- MPI_Status status1;
- MPI_Request request[100];
-
- if (E->parallel.nprocxy==1)   return;
-
- nsl = E->sphere.hindice*2;
- me = E->parallel.me;
-
- for (i=1;i<E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)
-    RG[i] = ( float *)malloc(nsl*sizeof(float));
-
-
- idb=0;
- for (i=1;i<=E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)  {
-   to_everyone = E->parallel.nprocz*(i-1) + loc_proc;
-
-   if (me!=to_everyone)    {  /* send TG */
-     idb++;
-     mst = me;
-     MPI_Isend(TG,nsl,MPI_FLOAT,to_everyone,mst,E->parallel.world,&request[idb-1]);
-     }
-   }
-
-
- idb=0;
- for (i=1;i<=E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)  {
-   from_proc = E->parallel.nprocz*(i-1) + loc_proc;
-   if (me!=from_proc)   {    /* me==0 receive all TG and add them up */
-      mst = from_proc;
-      idb++;
-      MPI_Irecv(RG[idb],nsl,MPI_FLOAT,from_proc,mst,E->parallel.world,&request[idb-1]);
-      }
-   }
-
- MPI_Waitall(idb,request,status);
-
- for (i=1;i<E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)
-   for (j=0;j<nsl; j++)  {
-        TG[j] += RG[i][j];
-        }
-
-
- for (i=1;i<E->parallel.nprocxy*E->parallel.surf_proc_per_cap;i++)
-       free((void *) RG[i]);
-
- return;
- }
-
-
-
-
-
-void set_communication_sphereh(E)
- struct All_variables *E;
- {
-  int i;
-
-  i = cases[E->sphere.caps_per_proc];
-
-  E->parallel.nproc_sph[1] = incases3[i].xy[0];
-  E->parallel.nproc_sph[2] = incases3[i].xy[1];
-
-  E->sphere.lelx = E->sphere.elx/E->parallel.nproc_sph[1];
-  E->sphere.lely = E->sphere.ely/E->parallel.nproc_sph[2];
-  E->sphere.lsnel = E->sphere.lely*E->sphere.lelx;
-  E->sphere.lnox = E->sphere.lelx + 1;
-  E->sphere.lnoy = E->sphere.lely + 1;
-  E->sphere.lnsf = E->sphere.lnox*E->sphere.lnoy;
-
-  for (i=0;i<=E->parallel.nprocz-1;i++)
-    if (E->parallel.me_loc[3] == i)    {
-      E->parallel.me_sph = (E->parallel.me-i)/E->parallel.nprocz;
-      E->parallel.me_loc_sph[1] = E->parallel.me_sph%E->parallel.nproc_sph[1];
-      E->parallel.me_loc_sph[2] = E->parallel.me_sph/E->parallel.nproc_sph[1];
-      }
-
-  E->sphere.lexs = E->sphere.lelx * E->parallel.me_loc_sph[1];
-  E->sphere.leys = E->sphere.lely * E->parallel.me_loc_sph[2];
-
- return;
- }
-
-
-
-/*************************************************************************/
-/* from Process_buoyancy.c                                               */
-/*************************************************************************/
-
-
-void process_temp_field(E,ii)
- struct All_variables *E;
-    int ii;
-{
-    void heat_flux();
-    void output_temp();
-    void process_output_field();
-    int record_h;
-
-    record_h = E->control.record_every;
-
-    if ( (ii == 0) || ((ii % record_h) == 0) || E->control.DIRECTII)    {
-      heat_flux(E);
-      parallel_process_sync(E);
-/*      output_temp(E,ii);  */
-    }
-
-    if ( ((ii == 0) || ((ii % E->control.record_every) == 0))
-	 || E->control.DIRECTII)     {
-       process_output_field(E,ii);
-    }
-
-    return;
-}
-
-
-/*************************************************************************/
-/* from Output.h                                                         */
-/*************************************************************************/
-
-void output_velo_related(E,file_number)
-  struct All_variables *E;
-  int file_number;
-{
-  int el,els,i,j,k,ii,m,node,fd;
-  int s,nox,noz,noy,size1,size2,size3;
-
-  char output_file[255];
-  FILE *fp1,*fp2,*fp3,*fp4,*fp5,*fp6,*fp7,*fp8;
-/*   static float *SV,*EV; */
-/*   float *VE[NCS],*VIN[NCS],*VN[NCS]; */
-  static int been_here=0;
-  int lev = E->mesh.levmax;
-
-  void get_surface_velo ();
-  void get_ele_visc ();
-  void visc_from_ele_to_gint();
-  void visc_from_gint_to_nodes();
-  const int nno = E->lmesh.nno;
-  const int nsd = E->mesh.nsd;
-  const int vpts = vpoints[nsd];
-
-
-  if (been_here==0)  {
-/*       ii = E->lmesh.nsf; */
-/*       m = (E->parallel.me_loc[3]==0)?ii:0; */
-/*       SV = (float *) malloc ((2*m+2)*sizeof(float)); */
-
-      /* size2 = (E->lmesh.nel+1)*sizeof(float); */
-      /* use the line from the original CitcomS   */
-
-  sprintf(output_file,"%s.coord.%d",E->control.data_file,E->parallel.me);
-  fp1=fopen(output_file,"w");
-  if (fp1 == NULL) {
-     fprintf(E->fp,"(Output.c #1) Cannot open %s\n",output_file);
-     exit(8);
-  }
-  for(j=1;j<=E->sphere.caps_per_proc;j++)     {
-    fprintf(fp1,"%3d %7d\n",j,E->lmesh.nno);
-    for(i=1;i<=E->lmesh.nno;i++)
-      fprintf(fp1,"%.3e %.3e %.3e\n",E->sx[j][1][i],E->sx[j][2][i],E->sx[j][3][i]);
-    }
-  fclose(fp1);
-
-   been_here++;
-    }
-
-
-  sprintf(output_file,"%s.visc.%d.%d",E->control.data_file,E->parallel.me,file_number);
-  fp1=fopen(output_file,"w");
-  for(j=1;j<=E->sphere.caps_per_proc;j++)     {
-    fprintf(fp1,"%3d %7d\n",j,E->lmesh.nno);
-    for(i=1;i<=E->lmesh.nno;i++)
-      fprintf(fp1,"%.3e\n",E->VI[lev][j][i]);
-
-    }
-  fclose(fp1);
-
-  sprintf(output_file,"%s.velo.%d.%d",E->control.data_file,E->parallel.me,file_number);
-  fp1=fopen(output_file,"w");
-  fprintf(fp1,"%d %d %.5e\n",file_number,E->lmesh.nno,E->monitor.elapsed_time);
-  for(j=1;j<=E->sphere.caps_per_proc;j++)     {
-    fprintf(fp1,"%3d %7d\n",j,E->lmesh.nno);
-     for(i=1;i<=E->lmesh.nno;i++)
-       fprintf(fp1,"%.6e %.6e %.6e %.6e\n",E->sphere.cap[j].V[1][i],E->sphere.cap[j].V[2][i],E->sphere.cap[j].V[3][i],E->T[j][i]);
-     /* for(i=1;i<=E->lmesh.nno;i++)
-	fprintf(fp1,"%.6e\n",E->T[j][i]); */
-    }
-
-  fclose(fp1);
-
-  if (E->parallel.me_loc[3]==E->parallel.nprocz-1)      {
-    sprintf(output_file,"%s.surf.%d.%d",E->control.data_file,E->parallel.me,file_number);
-    fp2=fopen(output_file,"w");
-    for(j=1;j<=E->sphere.caps_per_proc;j++)  {
-      fprintf(fp2,"%3d %7d\n",j,E->lmesh.nsf);
-      for(i=1;i<=E->lmesh.nsf;i++)   {
-	s = i*E->lmesh.noz;
-        fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->slice.tpg[j][i],E->slice.shflux[j][i],E->sphere.cap[j].V[1][s],E->sphere.cap[j].V[2][s]);
-	}
-      }
-    fclose(fp2);
-
-    }
-
-  if (E->parallel.me_loc[3]==0)      {
-    sprintf(output_file,"%s.botm.%d.%d",E->control.data_file,E->parallel.me,file_number);
-    fp2=fopen(output_file,"w");
-    for(j=1;j<=E->sphere.caps_per_proc;j++)  {
-      fprintf(fp2,"%3d %7d\n",j,E->lmesh.nsf);
-      for(i=1;i<=E->lmesh.nsf;i++)  {
-	s = (i-1)*E->lmesh.noz + 1;
-        fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->slice.tpgb[j][i],E->slice.bhflux[j][i],E->sphere.cap[j].V[1][s],E->sphere.cap[j].V[2][s]);
-	}
-      }
-    fclose(fp2);
-    }
-
-  /* remove horizontal average output   by Tan2 Mar. 1 2002  */
-
-/*   if (E->parallel.me<E->parallel.nprocz)  { */
-/*     sprintf(output_file,"%s.ave_r.%d.%d",E->control.data_file,E->parallel.me,file_number); */
-/*     fp2=fopen(output_file,"w"); */
-/*     for(j=1;j<=E->lmesh.noz;j++)  { */
-/*         fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->sx[1][3][j],E->Have.T[j],E->Have.V[1][j],E->Have.V[2][j]); */
-/* 	} */
-/*     fclose(fp2); */
-/*     } */
-
-  return;
-  }
-
-
-
-void output_temp(E,file_number)
-  struct All_variables *E;
-  int file_number;
-{
-  int m,nno,i,j,fd;
-  static int *temp1;
-  static int been_here=0;
-  static int size2,size1;
-  char output_file[255];
-
-  return;
-}
-
-
-
-void output_stress(E,file_number,SXX,SYY,SZZ,SXY,SXZ,SZY)
-    struct All_variables *E;
-    int file_number;
-    float *SXX,*SYY,*SZZ,*SXY,*SXZ,*SZY;
-{
-    int i,j,k,ii,m,fd,size2;
-    int nox,noz,noy;
-    char output_file[255];
-
-  size2= (E->lmesh.nno+1)*sizeof(float);
-
-  sprintf(output_file,"%s.%05d.SZZ",E->control.data_file,file_number);
-  fd=open(output_file,O_RDWR | O_CREAT, 0644);
-  write(fd,SZZ,size2);
-  close (fd);
-
-  return;
-  }
-
-
-
-void print_field_spectral_regular(E,TG,sphc,sphs,proc_loc,filen)
-   struct All_variables *E;
-   float *TG,*sphc,*sphs;
-   int proc_loc;
-   char * filen;
- {
-  FILE *fp,*fp1;
-  char output_file[255];
-  int i,node,j,ll,mm;
-  float minx,maxx,t,f,rad;
-  rad = 180.0/M_PI;
-
-  maxx=-1.e26;
-  minx=1.e26;
-  if (E->parallel.me==proc_loc)  {
-
-     sprintf(output_file,"%s.%s_intp",E->control.data_file,filen);
-     fp=fopen(output_file,"w");
-     for (i=E->sphere.nox;i>=1;i--)
-     for (j=1;j<=E->sphere.noy;j++)  {
-        node = i + (j-1)*E->sphere.nox;
-        t = 90-E->sphere.sx[1][node]*rad;
-        f = E->sphere.sx[2][node]*rad;
-        fprintf (fp,"%.3e %.3e %.4e\n",f,t,TG[node]);
-        if(TG[node]>maxx)maxx=TG[node];
-        if(TG[node]<minx)minx=TG[node];
-        }
-     fprintf(stderr,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-     fprintf(E->fp,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-     fclose(fp);
-
-     sprintf(output_file,"%s.%s_sharm",E->control.data_file,filen);
-     fp1=fopen(output_file,"w");
-     fprintf(fp1,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-     fprintf(fp1," ll   mm     cos      sin \n");
-     for (ll=0;ll<=E->output.llmax;ll++)
-     for(mm=0;mm<=ll;mm++)  {
-        i = E->sphere.hindex[ll][mm];
-        fprintf(fp1,"%3d %3d %.4e %.4e \n",ll,mm,sphc[i],sphs[i]);
-        }
-
-     fclose(fp1);
-     }
-
-
-  return;
-  }
-
-
-
-/*************************************************************************/
-/* from Full_tracer_advection.c                                          */
-/*************************************************************************/
-
-
-
-/*                                                                      */
-/* This function writes the radial distribution of tracers              */
-/* (horizontally averaged)                                              */
-
-void write_radial_horizontal_averages(E)
-     struct All_variables *E;
-{
-
-    char output_file[200];
-
-    int j;
-    int kk;
-    double halfpoint;
-    double *reltrac[13];
-
-    static int been_here=0;
-
-    void return_horiz_ave();
-    void return_elementwise_horiz_ave();
-
-    FILE *fp2;
-
-    if (been_here==0)
-	{
-	    E->trace.Have_C=(double *)malloc((E->lmesh.noz+2)*sizeof(double));
-	    E->trace.Havel_tracers=(double *)malloc((E->lmesh.elz+2)*sizeof(double));
-	}
-
-    /* Tracers */
-
-    /* first, change from int to double */
-
-    for (j=1;j<=E->sphere.caps_per_proc;j++)
-	{
-	    reltrac[j]=(double *) malloc((E->lmesh.nel+1)*sizeof(double));
-	    for (kk=1;kk<=E->lmesh.nel;kk++)
-		{
-		    reltrac[j][kk]=(1.0*E->composition.ieltrac[j][kk]);
-		}
-	}
-
-    return_elementwise_horiz_ave(E,reltrac,E->trace.Havel_tracers);
-
-    for (j=1;j<=E->sphere.caps_per_proc;j++)
-	{
-	    free(reltrac[j]);
-	}
-
-    if (E->parallel.me<E->parallel.nprocz)
-	{
-	    sprintf(output_file,"%s.ave_tracers.%d.%d",E->control.data_file,E->parallel.me,E->monitor.solution_cycles);
-	    fp2=fopen(output_file,"w");
-	    for(kk=1;kk<=E->lmesh.elz;kk++)
-		{
-		    halfpoint=0.5*(E->sx[1][3][kk+1]+E->sx[1][3][kk]);
-		    fprintf(fp2,"%.4e %.4e\n",halfpoint,E->trace.Havel_tracers[kk]);
-		}
-	    fclose(fp2);
-	}
-
-    /* Composition */
-
-    if (E->composition.chemical_buoyancy==1)
-	{
-	    return_horiz_ave(E,E->composition.comp_node,E->trace.Have_C);
-
-
-	    if (E->parallel.me<E->parallel.nprocz)
-		{
-		    sprintf(output_file,"%s.ave_c.%d.%d",E->control.data_file,E->parallel.me,E->monitor.solution_cycles);
-		    fp2=fopen(output_file,"w");
-		    for(kk=1;kk<=E->lmesh.noz;kk++)
-			{
-			    fprintf(fp2,"%.4e %.4e\n",E->sx[1][3][kk],E->trace.Have_C[kk]);
-			}
-		    fclose(fp2);
-
-		}
-	}
-
-    been_here++;
-
-    return;
-}
-
-
-/****** ICHECK REGULAR NEIGHBORS *****************************/
-/*                                                           */
-/* This function searches the regular element neighborhood.  */
-
-/* This function is no longer used!                          */
-
-int icheck_regular_neighbors(E,j,ntheta,nphi,x,y,z,theta,phi,rad)
-     struct All_variables *E;
-     int j,ntheta,nphi;
-     double x,y,z;
-     double theta,phi,rad;
-{
-
-    int new_ntheta,new_nphi;
-    int kk,pp;
-    int iregel;
-    int ival;
-    int imap[5];
-    int ichoice;
-    int irange;
-
-    int iquick_element_column_search();
-
-    fprintf(E->trace.fpt,"ERROR(icheck_regular_neighbors)-this subroutine is no longer used !\n");
-    fflush(E->trace.fpt);
-    exit(10);
-
-    irange=2;
-
-    for (kk=-irange;kk<=irange;kk++)
-        {
-            for (pp=-irange;pp<=irange;pp++)
-                {
-                    new_ntheta=ntheta+kk;
-                    new_nphi=nphi+pp;
-                    if ( (new_ntheta>0)&&(new_ntheta<=E->trace.numtheta[j])&&(new_nphi>0)&&(new_nphi<=E->trace.numphi[j]) )
-                        {
-                            iregel=new_ntheta+(new_nphi-1)*E->trace.numtheta[j];
-                            if ((iregel>0) && (iregel<=E->trace.numregel[j]))
-                                {
-                                    ival=iquick_element_column_search(E,j,iregel,new_ntheta,new_nphi,x,y,z,theta,phi,rad,imap,&ichoice);
-                                    if (ival>0) return ival;
-                                }
-                        }
-                }
-        }
-
-
-    return -99;
-}
-
-
-/****** IQUICK ELEMENT SEARCH *****************************/
-/*                                                        */
-/* This function does a quick regular to real element     */
-/* map check. Element number, if found, is returned.      */
-/* Otherwise, -99 is returned.                            */
-/* Pointers to imap and ichoice are used because they may */
-/* prove to be convenient.                                */
-/* This routine is no longer used                         */
-
-int iquick_element_column_search(E,j,iregel,ntheta,nphi,x,y,z,theta,phi,rad,imap,ich)
-     struct All_variables *E;
-     int j,iregel;
-     int ntheta,nphi;
-     double x,y,z,theta,phi,rad;
-     int *imap;
-     int *ich;
-{
-
-    int iregnode[5];
-    int kk,pp;
-    int nel,ival;
-    int ichoice;
-    int icount;
-    int itemp1;
-    int itemp2;
-
-    int icheck_element_column();
-
-    fprintf(E->trace.fpt,"ERROR(iquick element)-this routine is no longer used!\n");
-    fflush(E->trace.fpt);
-    exit(10);
-
-    /* REMOVE*/
-    /*
-      ichoice=*ich;
-
-      fprintf(E->trace.fpt,"AA: ichoice: %d\n",ichoice);
-      fflush(E->trace.fpt);
-    */
-
-    /* find regular nodes on regular element */
-
-    /*
-      iregnode[1]=iregel+(nphi-1);
-      iregnode[2]=iregel+nphi;
-      iregnode[3]=iregel+nphi+E->trace.numtheta[j]+1;
-      iregnode[4]=iregel+nphi+E->trace.numtheta[j];
-    */
-
-    itemp1=iregel+nphi;
-    itemp2=itemp1+E->trace.numtheta[j];
-
-    iregnode[1]=itemp1-1;
-    iregnode[2]=itemp1;
-    iregnode[3]=itemp2+1;
-    iregnode[4]=itemp2;
-
-    for (kk=1;kk<=4;kk++)
-        {
-            if ((iregnode[kk]<1) || (iregnode[kk]>E->trace.numregnodes[j]) )
-                {
-                    fprintf(E->trace.fpt,"ERROR(iquick)-weird regnode %d\n",iregnode[kk]);
-                    fflush(E->trace.fpt);
-                    exit(10);
-                }
-        }
-
-    /* find number of choices */
-
-    ichoice=0;
-    icount=0;
-    for (kk=1;kk<=4;kk++)
-        {
-            if (E->trace.regnodetoel[j][iregnode[kk]]<=0) goto next_corner;
-
-            icount++;
-            for (pp=1;pp<=(kk-1);pp++)
-                {
-                    if (E->trace.regnodetoel[j][iregnode[kk]]==E->trace.regnodetoel[j][iregnode[pp]]) goto next_corner;
-                }
-            ichoice++;
-            imap[ichoice]=E->trace.regnodetoel[j][iregnode[kk]];
-
-
-        next_corner:
-            ;
-        } /* end kk */
-
-    *ich=ichoice;
-
-    /* statistical counter */
-
-    E->trace.istat_ichoice[j][ichoice]++;
-
-    if (ichoice==0) return -99;
-
-    /* Here, no check is performed if all 4 corners */
-    /* lie within a given element.                  */
-    /* It may be possible (not sure) but unlikely   */
-    /* that the tracer is still not in that element */
-
-    /* Decided to comment this out. */
-    /* May not be valid for large regular grids. */
-    /*
-     */
-    /* AKMA */
-
-    if ((ichoice==1)&&(icount==4)) return imap[1];
-
-    /* check others */
-
-    for (kk=1;kk<=ichoice;kk++)
-        {
-            nel=imap[kk];
-            ival=icheck_element_column(E,j,nel,x,y,z,rad);
-            if (ival>0) return nel;
-        }
-
-    /* if still here, no element was found */
-
-    return -99;
-}
-
-
-/*************************************************************************/
-/* from                                                                  */
-/*************************************************************************/
-

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_parallel_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_parallel_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_parallel_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -27,6 +27,8 @@
  */
 /* Routines here are for intel paragon with MPI */
 
+#include "full_parallel_related.h"
+
 #include <mpi.h>
 #include <math.h>
 
@@ -34,11 +36,9 @@
 #include "global_defs.h"
 #include "sphere_communication.h"
 
-#include "parallel_related.h"
+#include "parallel_util.h"
 
-#include "cproto.h"
 
-
 static void set_horizontal_communicator(struct All_variables*);
 static void set_vertical_communicator(struct All_variables*);
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_read_input_from_files.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_read_input_from_files.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_read_input_from_files.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,9 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "full_read_input_from_files.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
@@ -33,7 +36,9 @@
 #include "ggrd_handling.h"
 #endif
 
-#include "cproto.h"
+#include "construct_arrays.h"
+#include "pan_problem_misc_functions.h"
+#include "problem_related.h"
 
 /*=======================================================================
   Calculate ages (MY) for opening input files -> material, ages, velocities

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_solver.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_solver.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_solver.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,39 +26,18 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "full_solver.h"
 
 #include "global_defs.h"
 
+#include "full_boundary_conditions.h"
+#include "full_geometry_cartesian.h"
+#include "full_lith_age_read_files.h"
+#include "full_parallel_related.h"
+#include "full_read_input_from_files.h"
+#include "full_version_dependent.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_node_locations(struct All_variables *);
-void full_construct_boundary(struct All_variables *);
-
-
 void full_solver_init(struct All_variables *E)
 {
     /* Boundary_conditions.c */

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_sphere_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_sphere_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_sphere_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,12 +29,15 @@
 
 /* Functions relating to the building and use of mesh locations ... */
 
+#include "full_sphere_related.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "pan_problem_misc_functions.h"
+#include "sphere_util.h"
 
 
 /**************************************************************/

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_tracer_advection.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_tracer_advection.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_tracer_advection.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,15 +26,20 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "full_tracer_advection.h"
+
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "parsing.h"
-#include "parallel_related.h"
 #include "composition_related.h"
 
-#include "cproto.h"
+#include "nodal_mesh.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "tracer_setup.h"
 
+
 static void get_2dshape(struct All_variables *E,
                         int j, int nelem,
                         double u, double v,
@@ -90,10 +95,13 @@
 static void determine_shape_coefficients(struct All_variables *E);
 static void full_put_lost_tracers(struct All_variables *E,
                                   int isend[13][13], double *send[13][13]);
-void pdebug(struct All_variables *E, int i);
-int full_icheck_cap(struct All_variables *E, int icap,
-                    double x, double y, double z, double rad);
+static void pdebug(struct All_variables *E, int i);
 
+static void full_get_shape_functions(struct All_variables *E, double shp[9], int nelem, double theta, double phi, double rad);
+static double full_interpolate_data(struct All_variables *E, double shp[9], double data[9]);
+static void analytical_test(struct All_variables *E);
+static void analytical_runge_kutte(struct All_variables *E, int nsteps, double dt, double *x0_s, double *x0_c, double *xf_s, double *xf_c, double *vec);
+static void analytical_test_function(struct All_variables *E, double theta, double phi, double rad, double *vel_s, double *vel_c);
 
 
 /******* FULL TRACER INPUT *********************/
@@ -865,9 +873,9 @@
 /*         5        6               5            7                           */
 /*         6        7               6            8                           */
 
-void full_get_shape_functions(struct All_variables *E,
-                              double shp[9], int nelem,
-                              double theta, double phi, double rad)
+static void full_get_shape_functions(struct All_variables *E,
+                                     double shp[9], int nelem,
+                                     double theta, double phi, double rad)
 {
     const int j = 1;
 
@@ -981,8 +989,8 @@
 }
 
 
-double full_interpolate_data(struct All_variables *E,
-                             double shp[9], double data[9])
+static double full_interpolate_data(struct All_variables *E,
+                                    double shp[9], double data[9])
 {
     int iwedge = (int)shp[0];
 
@@ -3043,7 +3051,7 @@
 /* This function (and the 2 following) are used to test advection of tracers by assigning */
 /* a test function (in "analytical_test_function").                                       */
 
-void analytical_test(struct All_variables *E)
+static void analytical_test(struct All_variables *E)
 
 {
 #if 0
@@ -3294,7 +3302,7 @@
 
 /*************** ANALYTICAL RUNGE KUTTE ******************/
 /*                                                       */
-void analytical_runge_kutte(
+static void analytical_runge_kutte(
     struct All_variables *E,
     int nsteps,
     double dt,
@@ -3410,7 +3418,7 @@
 /* vel_c[2] => velocity in y direction                      */
 /* vel_c[3] => velocity in z direction                      */
 
-void analytical_test_function(
+static void analytical_test_function(
     struct All_variables *E,
     double theta, double phi, double rad,
     double *vel_s,

Modified: mc/3D/CitcomS/branches/cxx/lib/Full_version_dependent.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Full_version_dependent.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Full_version_dependent.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,24 +25,19 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "full_version_dependent.h"
+
 #include <math.h>
 
 #include "global_defs.h"
-#include "parallel_related.h"
-#ifdef USE_GGRD
-void ggrd_full_temp_init(struct All_variables *);
-#endif
 
-void get_r_spacing_fine(double *,struct All_variables *);
-void get_r_spacing_at_levels(double *,struct All_variables *);
-void myerror(struct All_variables *,char *);
-#ifdef ALLOW_ELLIPTICAL
-double theta_g(double , struct All_variables *);
-#endif
+#include "full_sphere_related.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "sphere_util.h"
 
-#include "cproto.h"
 
-
 /* =================================================
   rotate the mesh by a rotation matrix
  =================================================*/

Modified: mc/3D/CitcomS/branches/cxx/lib/General_matrix_functions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/General_matrix_functions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/General_matrix_functions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,17 +25,32 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "general_matrix_functions.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "element_calculations.h"
+#include "global_operations.h"
+#include "instructions.h"
+#include "solver_multigrid.h"
 
 #ifdef _UNICOS
 #include <fortran.h>
 #endif
 
+
+static double multi_grid(struct All_variables *E, double **d1, double **F, double acc, int hl);
+static double conj_grad(struct All_variables *E, double **d0, double **F, double acc, int *cycles, int level);
+static void element_gauss_seidel(struct All_variables *E, double **d0, double **F, double **Ad, double acc, int *cycles, int level, int guess);
+static void gauss_seidel(struct All_variables *E, double **d0, double **F, double **Ad, double acc, int *cycles, int level, int guess);
+static double gen_determinant(double **A, int n);
+
+
 int epsilon[4][4] = {   /* Levi-Cita epsilon */
   {0, 0, 0, 0},
   {0, 1,-1, 1},
@@ -141,7 +156,7 @@
    recursive multigrid function ....
    ================================= */
 
-double multi_grid(
+static double multi_grid(
     struct All_variables *E,
     double **d1,
     double **F,
@@ -287,7 +302,7 @@
     ===========================================================  */
 
 
-double conj_grad(
+static double conj_grad(
     struct All_variables *E,
     double **d0,
     double **F,
@@ -414,7 +429,7 @@
    versions
    =========================================================================================*/
 
-void element_gauss_seidel(
+static void element_gauss_seidel(
     struct All_variables *E,
     double **d0,
     double **F, double **Ad,
@@ -585,7 +600,7 @@
    time (Jacobi at a node). It does the job though.
    ============================================================================ */
 
-void gauss_seidel(
+static void gauss_seidel(
     struct All_variables *E,
     double **d0,
     double **F, double **Ad,
@@ -795,7 +810,7 @@
 /* recursive function to determine matrix determinant */
 
 #if 0
-double gen_determinant(
+static double gen_determinant(
     double **A,
     int n
     )

Modified: mc/3D/CitcomS/branches/cxx/lib/Ggrd_handling.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Ggrd_handling.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Ggrd_handling.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -31,29 +31,24 @@
 the ggrd subroutines of the hc package
 
 */
-#ifdef USE_GZDIR
-#include <zlib.h>
-gzFile *gzdir_output_open(char *,char *);
 
-#endif
+#include "ggrd_handling.h"
 
+#include "output_gzdir.h"
+
 #include <math.h>
 #include "global_defs.h"
 #include "parsing.h"
-#include "parallel_related.h"
 #include "composition_related.h"
 #include "element_definitions.h"
 
+#include "parallel_util.h"
+
 #ifdef USE_GGRD
 
 #include "hc.h"			/* ggrd and hc packages */
-#include "ggrd_handling.h"
 
-void report(struct All_variables *,char *);
-int layers_r(struct All_variables *,float );
-void construct_mat_group(struct All_variables *);
-void temperatures_conform_bcs(struct All_variables *);
-int layers(struct All_variables *,int ,int );
+static void ggrd_temp_init_general(struct All_variables *,int);
 
 /* 
 
@@ -165,7 +160,7 @@
 
 */
 
-void ggrd_temp_init_general(struct All_variables *E,int is_global)
+static void ggrd_temp_init_general(struct All_variables *E,int is_global)
 {
 
   MPI_Status mpi_stat;

Modified: mc/3D/CitcomS/branches/cxx/lib/Global_operations.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Global_operations.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Global_operations.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,9 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "global_operations.h"
+
 #include <mpi.h>
 
 #include <math.h>
@@ -32,21 +35,36 @@
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "nodal_mesh.h"
+#include "pan_problem_misc_functions.h"
+#include "size_does_matter.h"
 
+
 #ifdef ALLOW_ELLIPTICAL
 double theta_g(double , struct All_variables *);
 #endif
 
-void calc_cbase_at_tp(float , float , float *);
 
+static void remove_horiz_ave(struct All_variables *E, double **X, double *H, int store_or_not);
+static void return_horiz_ave(struct All_variables *E, double **X, double *H);
+static void return_elementwise_horiz_ave(struct All_variables *E, double **X, double *H);
+static float return_bulk_value(struct All_variables *E, float **Z, int average);
+static float find_max_horizontal(struct All_variables *E, double Tmax);
+static float global_fvdot(struct All_variables *E, float **A, float **B, int lev);
+static double kineticE_radial(struct All_variables *E, double **A, int lev);
+static double global_tdot_d(struct All_variables *E, double **A, double **B, int lev);
+static float global_tdot(struct All_variables *E, float **A, float **B, int lev);
+static double global_dmax(struct All_variables *E, double a);
+static float global_fmax(struct All_variables *E, double a);
+
+
 /* ===============================================
    strips horizontal average from nodal field X.
    Assumes orthogonal mesh, otherwise, horizontals
    aren't & another method is required.
    =============================================== */
 
-void remove_horiz_ave(
+static void remove_horiz_ave(
     struct All_variables *E,
     double **X, double *H,
     int store_or_not
@@ -84,7 +102,7 @@
 }
 
 
-void return_horiz_ave(
+static void return_horiz_ave(
     struct All_variables *E,
     double **X, double *H
     )
@@ -251,7 +269,7 @@
 /* however here, elemental horizontal averages are given rather than */
 /* nodal averages. Also note, here is average per element            */
 
-void return_elementwise_horiz_ave(
+static void return_elementwise_horiz_ave(
     struct All_variables *E,
     double **X, double *H
     )
@@ -314,7 +332,7 @@
   return;
 }
 
-float return_bulk_value(
+static float return_bulk_value(
     struct All_variables *E,
     float **Z,
     int average
@@ -396,7 +414,7 @@
 }
 
 /* ================================================== */
-float find_max_horizontal(
+static float find_max_horizontal(
     struct All_variables *E,
     float Tmax
     )
@@ -471,7 +489,7 @@
 /* ================================================== */
 
 
-float global_fvdot(
+static float global_fvdot(
     struct All_variables *E,
     float **A, float **B,
     int lev
@@ -504,7 +522,7 @@
 }
 
 
-double kineticE_radial(
+static double kineticE_radial(
     struct All_variables *E,
     double **A,
     int lev
@@ -661,7 +679,7 @@
 }
 
 
-double global_tdot_d(
+static double global_tdot_d(
     struct All_variables *E,
     double **A, double **B,
     int lev
@@ -686,7 +704,7 @@
   return (prod);
   }
 
-float global_tdot(
+static float global_tdot(
     struct All_variables *E,
     float **A, double **B,
     int lev
@@ -721,7 +739,7 @@
   return (temp);
   }
 
-double global_dmax(
+static double global_dmax(
     struct All_variables *E,
     double a
     )
@@ -732,7 +750,7 @@
   }
 
 
-float global_fmax(
+static float global_fmax(
     struct All_variables *E,
     float a
     )

Modified: mc/3D/CitcomS/branches/cxx/lib/Initial_temperature.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Initial_temperature.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Initial_temperature.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,6 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "initial_temperature.h"
+
 #include <math.h>
 #include <assert.h>
 #include <string.h>
@@ -34,13 +36,12 @@
 #include "lith_age.h"
 #include "parsing.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "instructions.h"
+#include "parallel_util.h"
+#include "sphere_harmonics.h"
 
-void parallel_process_termination();
-void temperatures_conform_bcs(struct All_variables *);
-double modified_plgndr_a(int, int, double);
 
-#include "initial_temperature.h"
 static void debug_tic(struct All_variables *);
 static void read_tic_from_file(struct All_variables *);
 static void construct_tic_from_input(struct All_variables *);

Modified: mc/3D/CitcomS/branches/cxx/lib/Instructions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Instructions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Instructions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,6 +29,8 @@
 /* allocated, temperature, viscosity, node locations and how to use */
 /* them all established. 8.29.92 or 29.8.92 depending on your nationality*/
 
+#include "instructions.h"
+
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
@@ -46,48 +48,39 @@
 #include "material_properties.h"
 #include "output.h"
 #include "output_h5.h"
-#include "parallel_related.h"
 #include "parsing.h"
 #include "phase_change.h"
 #include "interuption.h"
 
-#include "cproto.h"
+#include "composition_related.h"
+#include "construct_arrays.h"
+#include "convection.h"
+#include "drive_solvers.h"
+#include "output_gzdir.h"
+#include "output_vtk.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "problem_related.h"
+#include "shape_functions.h"
+#include "size_does_matter.h"
+#include "solver_conj_grad.h"
+#include "solver_multigrid.h"
+#include "sphere_harmonics.h"
+#include "tracer_setup.h"
+#include "viscosity_structures.h"
 
-void allocate_common_vars(struct All_variables*);
-void allocate_velocity_vars(struct All_variables*);
-void check_bc_consistency(struct All_variables*);
-void construct_elt_gs(struct All_variables*);
-void construct_elt_cs(struct All_variables*);
-void construct_shape_function_derivatives(struct All_variables *E);
-void construct_id(struct All_variables*);
-void construct_ien(struct All_variables*);
-void construct_lm(struct All_variables*);
-void construct_masks(struct All_variables*);
-void construct_shape_functions(struct All_variables*);
-void construct_sub_element(struct All_variables*);
-void construct_surf_det (struct All_variables*);
-void construct_bdry_det (struct All_variables*);
-void construct_surface (struct All_variables*);
-void get_initial_elapsed_time(struct All_variables*);
-void lith_age_init(struct All_variables *E);
-void mass_matrix(struct All_variables*);
-void output_init(struct All_variables*);
-void set_elapsed_time(struct All_variables*);
-void set_sphere_harmonics (struct All_variables*);
-void set_starting_age(struct All_variables*);
-void tracer_initial_settings(struct All_variables*);
-void tracer_input(struct All_variables*);
-void viscosity_input(struct All_variables*);
-void vtk_output(struct All_variables*, int);
-void get_vtk_filename(char *,int,struct All_variables *,int);
-void myerror(struct All_variables *,char *);
-void open_qfiles(struct All_variables *) ;
-void read_rayleigh_from_file(struct All_variables *);
-void read_initial_settings(struct All_variables *);
-void check_settings_consistency(struct All_variables *);
-void global_derived_values(struct All_variables *);
 
+static void read_initial_settings(struct All_variables *E);
+static void global_derived_values(struct All_variables *E);
+static void allocate_common_vars(struct All_variables *E);
+static void allocate_velocity_vars(struct All_variables *E);
+static void set_up_nonmg_aliases(struct All_variables *E, int j);
+static void common_initial_fields(struct All_variables *E);
+static void open_qfiles(struct All_variables *E);
+static void output_init(struct All_variables *E);
+static char *strip(char *input);
 
+
 void initial_mesh_solver_setup(struct All_variables *E)
 {
   int chatty;
@@ -262,7 +255,7 @@
 }
 
 
-void read_initial_settings(struct All_variables *E)
+static void read_initial_settings(struct All_variables *E)
 {
   float tmp;
   double ell_tmp;
@@ -771,7 +764,7 @@
 
 
 /* Setup global mesh parameters */
-void global_derived_values(struct All_variables *E)
+static void global_derived_values(struct All_variables *E)
 {
     int d,i,nox,noz,noy;
 
@@ -855,7 +848,7 @@
    common to all problems follow ...
    ===================================  */
 
-void allocate_common_vars(struct All_variables *E)
+static void allocate_common_vars(struct All_variables *E)
 {
     int m,n,snel,nsf,elx,ely,nox,noy,noz,nno,nel,npno;
     int k,i,j,d,l,nno_l,npno_l,nozl,nnov_l,nxyz;
@@ -1058,7 +1051,7 @@
 
 /*  =========================================================  */
 
-void allocate_velocity_vars(struct All_variables *E)
+static void allocate_velocity_vars(struct All_variables *E)
 {
     int m,n,i,j,k,l;
 
@@ -1257,7 +1250,7 @@
 
 }
 
-void set_up_nonmg_aliases(struct All_variables *E, int j)
+static void set_up_nonmg_aliases(struct All_variables *E, int j)
 { /* Aliases for functions only interested in the highest mg level */
 
   int i;
@@ -1309,7 +1302,7 @@
 
 
 /* This function is replaced by CitcomS.Components.IC.launch()*/
-void common_initial_fields(struct All_variables *E)
+static void common_initial_fields(struct All_variables *E)
 {
     report(E,"Initialize pressure field");
     initial_pressure(E);
@@ -1410,8 +1403,8 @@
   return;
 }
 
-void open_qfiles(struct All_variables *E) /* additional heat
-					     flux output */
+static void open_qfiles(struct All_variables *E) /* additional heat
+                                                    flux output */
 {
   char output_file[255];
 
@@ -1633,7 +1626,7 @@
 }
 
 
-void output_init(struct  All_variables *E)
+static void output_init(struct  All_variables *E)
 {
     chk_prefix(E);
     expand_datadir(E, E->control.data_dir);
@@ -1728,7 +1721,7 @@
 }
 
 
-char* strip(char *input)
+static char* strip(char *input)
 {
     int end;
     char *str;

Modified: mc/3D/CitcomS/branches/cxx/lib/Interuption.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Interuption.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Interuption.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,19 +25,20 @@
  * 
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "interuption.h"
+
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "interuption.h"
+#include "parallel_util.h"
 
-void parallel_process_termination();
 
 int Emergency_stop;
 
 
-
-void interuption(int signal_number)
+static void interuption(int signal_number)
 {
   if (Emergency_stop)
     parallel_process_termination();

Modified: mc/3D/CitcomS/branches/cxx/lib/Lith_age.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Lith_age.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Lith_age.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,21 +26,22 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "lith_age.h"
+
 #include <math.h>
 
 #include "global_defs.h"
 
 /*#include "age_related.h"*/
-#include "parallel_related.h"
 #include "parsing.h"
-#include "lith_age.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "parallel_util.h"
 
-float find_age_in_MY();
-void lith_age_update_tbc(struct All_variables *E);
 
+static void lith_age_update_tbc(struct All_variables *E);
 
+
 void lith_age_input(struct All_variables *E)
 {
   int m = E->parallel.me;
@@ -152,7 +153,7 @@
 }
 
 
-void lith_age_update_tbc(struct All_variables *E)
+static void lith_age_update_tbc(struct All_variables *E)
 {
   int i, j, k, m, node;
   int nox, noy, noz;

Modified: mc/3D/CitcomS/branches/cxx/lib/Makefile.am
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Makefile.am	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Makefile.am	2009-04-09 03:05:05 UTC (rev 14643)
@@ -137,9 +137,4 @@
 	Regional_tracer_advection.cc \
 	Regional_version_dependent.cc
 
-EXTRA_DIST = \
-	Obsolete.cc \
-	Full_obsolete.cc \
-	Regional_obsolete.cc
-
 ## end of Makefile.am

Modified: mc/3D/CitcomS/branches/cxx/lib/Material_properties.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Material_properties.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Material_properties.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,6 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "material_properties.h"
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -33,14 +35,14 @@
 #include <math.h>
 
 #include "global_defs.h"
-#include "material_properties.h"
-#include "parallel_related.h"
+#include "parallel_util.h"
 
+#include "construct_arrays.h"
+
+
 static void read_refstate(struct All_variables *E);
 static void adams_williamson_eos(struct All_variables *E);
 
-int layers_r(struct All_variables *,float);
-
 void mat_prop_allocate(struct All_variables *E)
 {
     int noz = E->lmesh.noz;

Modified: mc/3D/CitcomS/branches/cxx/lib/Nodal_mesh.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Nodal_mesh.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Nodal_mesh.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -27,6 +27,7 @@
  */
 /* Functions relating to the building and use of mesh locations ... */
 
+#include "nodal_mesh.h"
 
 #include <math.h>
 #include <sys/types.h>

Deleted: mc/3D/CitcomS/branches/cxx/lib/Obsolete.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Obsolete.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Obsolete.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,1532 +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>
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-/*
-  This file contains functions that are no longer used in this version of
-  CitcomS. To reduce compilantion time and maintanance effort, these functions
-  are removed from its original location to here.
-*/
-
-
-
-/* ==========================================================  */
-/* from Size_does_matter.c                                     */
-/* =========================================================== */
-
-
-
-/*	==================================================================================
-	Function to give the global shape function from the local: Assumes ORTHOGONAL MESH
-	==================================================================================      */
-
-void get_global_shape_fn(E,el,GN,GNx,dOmega,pressure,sphere,rtf,lev,m)
-     struct All_variables *E;
-     int el,m;
-     struct Shape_function *GN;
-     struct Shape_function_dx *GNx;
-     struct Shape_function_dA *dOmega;
-     int pressure,lev,sphere;
-     double rtf[4][9];
-{
-  int i,j,k,d,e;
-  double jacobian;
-  double determinant();
-  double cofactor(),myatan();
-  void   form_rtf_bc();
-
-  struct Shape_function_dx LGNx;
-
-  double dxda[4][4],cof[4][4],x[4],bc[4][4];
-
-
-  const int dims=E->mesh.nsd;
-  const int ends=enodes[dims];
-  const int vpts=vpoints[dims];
-  const int ppts=ppoints[dims];
-
-
-  if(pressure < 2) {
-    for(k=1;k<=vpts;k++) {       /* all of the vpoints */
-      for(d=1;d<=dims;d++)  {
-        x[d]=0.0;
-        for(e=1;e<=dims;e++)
-          dxda[d][e]=0.0;
-        }
-
-      for(d=1;d<=dims;d++)
-        for(i=1;i<=ends;i++)
-          x[d] += E->X[lev][m][d][E->IEN[lev][m][el].node[i]]*
-                E->N.vpt[GNVINDEX(i,k)];
-
-      for(d=1;d<=dims;d++)
-	for(e=1;e<=dims;e++)
-	  for(i=1;i<=ends;i++)
-            dxda[d][e] += E->X[lev][m][e][E->IEN[lev][m][el].node[i]]
-               * E->Nx.vpt[GNVXINDEX(d-1,i,k)];
-
-      jacobian = determinant(dxda,E->mesh.nsd);
-      dOmega->vpt[k] = jacobian;
-
-      for(d=1;d<=dims;d++)
-        for(e=1;e<=dims;e++)
-          cof[d][e]=cofactor(dxda,d,e,dims);
-
-      if (sphere)   {
-
-        form_rtf_bc(k,x,rtf,bc);
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)         {
-            LGNx.vpt[GNVXINDEX(d-1,j,k)] = 0.0;
-            for(e=1;e<=dims;e++)
-              LGNx.vpt[GNVXINDEX(d-1,j,k)] +=
-                 E->Nx.vpt[GNVXINDEX(e-1,j,k)] *cof[e][d];
-
-            LGNx.vpt[GNVXINDEX(d-1,j,k)] /= jacobian;
-            }
-
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)         {
-            GNx->vpt[GNVXINDEX(d-1,j,k)] =
-                bc[d][1]*LGNx.vpt[GNVXINDEX(0,j,k)]
-              + bc[d][2]*LGNx.vpt[GNVXINDEX(1,j,k)]
-              + bc[d][3]*LGNx.vpt[GNVXINDEX(2,j,k)];
-            }
-        }
-      else  {
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)         {
-            GNx->vpt[GNVXINDEX(d-1,j,k)] = 0.0;
-            for(e=1;e<=dims;e++)
-              GNx->vpt[GNVXINDEX(d-1,j,k)] +=
-                 E->Nx.vpt[GNVXINDEX(e-1,j,k)] *cof[e][d];
-
-            GNx->vpt[GNVXINDEX(d-1,j,k)] /= jacobian;
-            }
-        }
-      }     /* end for k */
-    }    /* end for pressure */
-
-  if(pressure > 0 && pressure < 3) {
-    for(k=1;k<=ppts;k++)         {   /* all of the ppoints */
-      for(d=1;d<=dims;d++) {
-        x[d]=0.0;
-        for(e=1;e<=dims;e++)
-          dxda[d][e]=0.0;
-        }
-
-      for(d=1;d<=dims;d++)
-        for(i=1;i<=ends;i++)
-          x[d] += E->X[lev][m][d][E->IEN[lev][m][el].node[i]]
-                 *E->N.ppt[GNPINDEX(i,k)];
-
-      for(d=1;d<=dims;d++)
-	for(e=1;e<=dims;e++)
-	  for(i=1;i<=ends;i++)
-            dxda[d][e] += E->X[lev][m][e][E->IEN[lev][m][el].node[i]]
-                     * E->Nx.ppt[GNPXINDEX(d-1,i,k)];
-
-      jacobian = determinant(dxda,E->mesh.nsd);
-      dOmega->ppt[k] = jacobian;
-
-      for(d=1;d<=dims;d++)
-        for(e=1;e<=dims;e++)
-          cof[d][e]=cofactor(dxda,d,e,E->mesh.nsd);
-
-      if (sphere)   {
-        form_rtf_bc(k,x,rtf,bc);
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)  {
-            LGNx.ppt[GNPXINDEX(d-1,j,k)]=0.0;
-            for(e=1;e<=dims;e++)
-              LGNx.ppt[GNPXINDEX(d-1,j,k)] +=
-                E->Nx.ppt[GNPXINDEX(e-1,j,k)]*cof[e][d];
-	    LGNx.ppt[GNPXINDEX(d-1,j,k)] /= jacobian;
-            }
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)         {
-            GNx->ppt[GNPXINDEX(d-1,j,k)]
-             = bc[d][1]*LGNx.ppt[GNPXINDEX(0,j,k)]
-             + bc[d][2]*LGNx.ppt[GNPXINDEX(1,j,k)]
-             + bc[d][3]*LGNx.ppt[GNPXINDEX(2,j,k)];
-          }
-        }
-
-      else  {
-        for(j=1;j<=ends;j++)
-          for(d=1;d<=dims;d++)  {
-            GNx->ppt[GNPXINDEX(d-1,j,k)]=0.0;
-            for(e=1;e<=dims;e++)
-              GNx->ppt[GNPXINDEX(d-1,j,k)] +=
-                E->Nx.ppt[GNPXINDEX(e-1,j,k)]*cof[e][d];
-	    GNx->ppt[GNPXINDEX(d-1,j,k)] /= jacobian;
-            }
-        }
-
-      }              /* end for k int */
-    }      /* end for pressure */
-
-
-  return;
-}
-
-
-void get_global_1d_shape_fn_1(E,el,GM,dGammax,nodal,m)
-     struct All_variables *E;
-     int el,nodal,m;
-     struct Shape_function *GM;
-     struct Shape_function_dA *dGammax;
-{
-  int i,k,d,e,h,l,kk;
-
-  double jacobian;
-  double determinant();
-  double cofactor();
-  double **dmatrix();
-
-  const int dims=E->mesh.nsd,dofs=E->mesh.dof;
-  const int ends=enodes[dims];
-
-  double dxda[4][4],cof[4][4];
-
-
-   for(k=1;k<=vpoints[E->mesh.nsd];k++)  {
-
-      for(d=1;d<=dims;d++)
-        for(e=1;e<=dims;e++)  {
-          dxda[d][e] = 0.0;
-          for(i=1;i<=ends;i++)
-            dxda[d][e] += E->NMx.vpt[GNVXINDEX(d-1,i,k)]
-                * E->x[m][e][E->ien[m][el].node[i]];
-          }
-
-      for(d=1;d<=dims;d++)
-        for(e=1;e<=dims;e++)   {
-          cof[d][e] = 0.0;
-          for(h=1;h<=dims;h++)
-            cof[d][e] += dxda[d][h]*dxda[e][h];
-          }
-
-      if (cof[3][3]!=0.0)
-        jacobian = sqrt(fabs(determinant(cof,E->mesh.nsd)))/cof[3][3];
-
-      dGammax->vpt[k] = jacobian;
-
-      }
-
-  return;
-}
-
-
-/*   ======================================================================
-     For calculating pressure boundary term --- Choi, 11/13/02
-     ======================================================================  */
-void get_global_side_1d_shape_fn(E,el,GM,GMx,dGamma,NS,far,m)
-     struct All_variables *E;
-     int el,far,m,NS;
-     struct Shape_function1 *GM;
-     struct Shape_function1_dx *GMx;
-     struct Shape_function_side_dA *dGamma;
-{
-  int ii,i,j,k,d,a,e,node;
-
-  double jacobian;
-  double determinant();
-  double cofactor();
-  void   form_rtf_bc();
-
-  struct Shape_function1 LGM;
-  struct Shape_function1_dx LGMx;
-
-  int dims[2][3];
-  int *elist[3];
-  const int oned = onedvpoints[E->mesh.nsd];
-  const int vpts = vpoints[E->mesh.nsd-1];
-  const int ppts = ppoints[E->mesh.nsd-1];
-  const int ends = enodes[E->mesh.nsd-1];
-  double to,fo,ro,xx[4][5],dxda[4][4],dxdy[4][4];
-
-  /******************************************/
-  elist[0] = (int *)malloc(9*sizeof(int));
-  elist[1] = (int *)malloc(9*sizeof(int));
-  elist[2] = (int *)malloc(9*sizeof(int));
-  /*for NS boundary elements */
-  elist[0][0]=0; elist[0][1]=1; elist[0][2]=4; elist[0][3]=8; elist[0][4]=5;
-  elist[0][5]=2; elist[0][6]=3; elist[0][7]=7; elist[0][8]=6;
-  /*for EW boundary elements */
-  elist[1][0]=0; elist[1][1]=1; elist[1][2]=2; elist[1][3]=6; elist[1][4]=5;
-  elist[1][5]=4; elist[1][6]=3; elist[1][7]=7; elist[1][8]=8;
-  /*for TB boundary elements */
-  elist[2][0]=0; elist[2][1]=1; elist[2][2]=2; elist[2][3]=3; elist[2][4]=4;
-  elist[2][5]=5; elist[2][6]=6; elist[2][7]=7; elist[2][8]=8;
-  /******************************************/
-
-  to = E->eco[m][el].centre[1];
-  fo = E->eco[m][el].centre[2];
-  ro = E->eco[m][el].centre[3];
-
-  dxdy[1][1] = cos(to)*cos(fo);
-  dxdy[1][2] = cos(to)*sin(fo);
-  dxdy[1][3] = -sin(to);
-  dxdy[2][1] = -sin(fo);
-  dxdy[2][2] = cos(fo);
-  dxdy[2][3] = 0.0;
-  dxdy[3][1] = sin(to)*cos(fo);
-  dxdy[3][2] = sin(to)*sin(fo);
-  dxdy[3][3] = cos(to);
-
-  /*for side elements*/
-  for(i=1;i<=ends;i++) {
-    a = elist[NS][i+far*ends];
-    node=E->ien[m][el].node[a];
-    xx[1][i] = E->x[m][1][node]*dxdy[1][1]
-      + E->x[m][2][node]*dxdy[1][2]
-      + E->x[m][3][node]*dxdy[1][3];
-    xx[2][i] = E->x[m][1][node]*dxdy[2][1]
-      + E->x[m][2][node]*dxdy[2][2]
-      + E->x[m][3][node]*dxdy[2][3];
-    xx[3][i] = E->x[m][1][node]*dxdy[3][1]
-      + E->x[m][2][node]*dxdy[3][2]
-      + E->x[m][3][node]*dxdy[3][3];
-  }
-
-  for(k=1;k<=oned;k++)    {
-    for(d=1;d<=E->mesh.nsd-1;d++)
-      for(e=1;e<=E->mesh.nsd-1;e++)
-	dxda[d][e]=0.0;
-
-    if(NS==0) {
-      for(i=1;i<=oned;i++) {
-	dims[NS][1]=2; dims[NS][2]=3;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++) {
-	    dxda[d][e] += xx[dims[NS][e]][i]*E->Mx.vpt[GMVXINDEX(d-1,i,k)];
-	  }
-      }
-    }
-    else if(NS==1) {
-      for(i=1;i<=oned;i++) {
-	dims[NS][1]=1; dims[NS][2]=3;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++) {
-	    dxda[d][e] += xx[dims[NS][e]][i]*E->Mx.vpt[GMVXINDEX(d-1,i,k)];
-	  }
-      }
-    }
-    else if(NS==2) {
-      for(i=1;i<=oned;i++) {
-	dims[NS][1]=1; dims[NS][2]=2;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++) {
-	    dxda[d][e] += xx[dims[NS][e]][i]*E->Mx.vpt[GMVXINDEX(d-1,i,k)];
-	  }
-      }
-    }
-
-    jacobian = determinant(dxda,E->mesh.nsd-1);
-    dGamma->vpt[k] = jacobian;
-  }
-
-  for(i=1;i<=ppts;i++)    { /* all of the ppoints*/
-    for(d=1;d<=E->mesh.nsd-1;d++)
-      for(e=1;e<=E->mesh.nsd-1;e++)
-	dxda[d][e]=0.0;
-
-    if(NS==0) {
-      for(k=1;k<=ends;k++) {
-	dims[NS][1]=2; dims[NS][2]=3;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++)
-	    dxda[d][e] += xx[dims[NS][e]][k]*E->Mx.ppt[GMPXINDEX(d-1,k,i)];
-      }
-    }
-    else if(NS==1) {
-      for(k=1;k<=ends;k++) {
-	dims[NS][1]=1; dims[NS][2]=3;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++) {
-	    a = elist[NS][k+far*ends];
-	    node=E->ien[m][el].node[a];
-	    dxda[d][e] += xx[dims[NS][e]][k]*E->Mx.ppt[GMPXINDEX(d-1,k,i)];
-	  }
-      }
-    }
-    else if(NS==2) {
-      for(k=1;k<=ends;k++) {
-	dims[NS][1]=1; dims[NS][2]=2;
-	for(d=1;d<=E->mesh.nsd-1;d++)
-	  for(e=1;e<=E->mesh.nsd-1;e++) {
-	    a = elist[NS][k+far*ends];
-	    node=E->ien[m][el].node[a];
-	    dxda[d][e] += xx[dims[NS][e]][k]*E->Mx.ppt[GMPXINDEX(d-1,k,i)];
-	  }
-      }
-    }
-
-    jacobian = determinant(dxda,E->mesh.nsd-1);
-    dGamma->ppt[i] = jacobian;
-  }
-
-  for(i=0;i<3;i++)
-    free((void *) elist[i]);
-
-  return;
-}
-
-
-
-/* ==========================================================  */
-/* from Element_calculations.c                                 */
-/* =========================================================== */
-
-/* ===============================================================
-   Function to create the element pressure-forcing vector (due
-   to imposed velocity boundary conditions, mixed method).
-   =============================================================== */
-
-void get_elt_h(E,el,elt_h,m)
-     struct All_variables *E;
-     int el,m;
-     double elt_h[1];
-{
-    int i,p,a,b,q,got_g;
-    unsigned int type;
-    higher_precision elt_g[24][1];
-    void get_elt_g();
-
-    for(p=0;p<1;p++) elt_h[p] = 0.0;
-
-    got_g = 0;
-
-  type=VBX;
-  for(i=1;i<=E->mesh.nsd;i++)
-    { for(a=1;a<=enodes[E->mesh.nsd];a++)
-	{ if (E->node[m][E->ien[m][el].node[a]] & type)
-	    { if(!got_g)
-		{  get_elt_g(E,el,elt_g,E->mesh.levmax,m);
-		   got_g++;
-		 }
-
-	      p=E->mesh.nsd*(a-1) + i - 1;
-	      for(b=1;b<=pnodes[E->mesh.nsd];b++)
-		{ q = b-1;
-		  elt_h[q] -= elt_g[p][q] * E->sphere.cap[m].VB[i][E->ien[m][el].node[a]];
-		}
-	    }
-	}
-      type *= (unsigned int) 2;
-    }
-   return;
-}
-
-/* ==========================================================  */
-/* from Process_velocity.c                                     */
-/* =========================================================== */
-
-void get_ele_visc(E, EV,m)
-  struct All_variables *E;
-  float *EV;
-  int m;
-  {
-
-  int el,j,lev;
-
-  const int nel=E->lmesh.nel;
-  const int vpts=vpoints[E->mesh.nsd];
-
-  lev = E->mesh.levmax;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for (el=1;el<=nel;el++)   {
-      EV[el] = 0.0;
-      for (j=1;j<=vpts;j++)   {
-        EV[el] +=  E->EVI[lev][m][(el-1)*vpts+j];
-      }
-
-      EV[el] /= vpts;
-      }
-
-  return;
-  }
-
-
-/* ==========================================================  */
-/*  From Sphere_harmonics.c                                    */
-/* =========================================================== */
-
-
-
-/* This function construct sph harm tables on a regular grid */
-/* for inverse interpolation                                 */
-
-static void  compute_sphereh_int_table(E)
-     struct All_variables *E;
-{
-    int i,j;
-    double t,f;
-    double dth,dfi,sqrt_multis();
-
-    E->sphere.con = (double *)malloc(E->sphere.hindice*sizeof(double));
-    for (ll=0;ll<=E->output.llmax;ll++)
-	for (mm=0;mm<=ll;mm++)   {
-	    E->sphere.con[E->sphere.hindex[ll][mm]] =
-		sqrt( (2.0-((mm==0)?1.0:0.0))*(2*ll+1)/(4.0*M_PI) )
-		*sqrt_multis(ll+mm,ll-mm);  /* which is sqrt((ll-mm)!/(ll+mm)!) */
-	}
-
-    E->sphere.tablenplm   = (double **) malloc((E->sphere.nox+1)
-					       *sizeof(double*));
-    for (i=1;i<=E->sphere.nox;i++)
-	E->sphere.tablenplm[i]= (double *)malloc(E->sphere.hindice
-						 *sizeof(double));
-
-    E->sphere.tablencosf  = (double **) malloc((E->sphere.noy+1)
-					       *sizeof(double*));
-    E->sphere.tablensinf  = (double **) malloc((E->sphere.noy+1)
-					       *sizeof(double*));
-    for (i=1;i<=E->sphere.noy;i++)   {
-	E->sphere.tablencosf[i]= (double *)malloc((E->output.llmax+3)
-						  *sizeof(double));
-	E->sphere.tablensinf[i]= (double *)malloc((E->output.llmax+3)
-						  *sizeof(double));
-    }
-
-    E->sphere.sx[1] = (double *) malloc((E->sphere.nsf+1)*sizeof(double));
-    E->sphere.sx[2] = (double *) malloc((E->sphere.nsf+1)*sizeof(double));
-
-    dth = M_PI/E->sphere.elx;
-    dfi = 2.0*M_PI/E->sphere.ely;
-
-    for (j=1;j<=E->sphere.noy;j++)
-	for (i=1;i<=E->sphere.nox;i++) {
-	    node = i+(j-1)*E->sphere.nox;
-	    E->sphere.sx[1][node] = dth*(i-1);
-	    E->sphere.sx[2][node] = dfi*(j-1);
-	}
-
-    for (j=1;j<=E->sphere.nox;j++)  {
-	t=E->sphere.sx[1][j];
-	for (ll=0;ll<=E->output.llmax;ll++)
-	    for (mm=0;mm<=ll;mm++)  {
-		p = E->sphere.hindex[ll][mm];
-		E->sphere.tablenplm[j][p] = modified_plgndr_a(ll,mm,t) ;
-	    }
-    }
-    for (j=1;j<=E->sphere.noy;j++)  {
-	node = 1+(j-1)*E->sphere.nox;
-	f=E->sphere.sx[2][node];
-	for (mm=0;mm<=E->output.llmax;mm++)   {
-	    E->sphere.tablencosf[j][mm] = cos( (double)(mm)*f );
-	    E->sphere.tablensinf[j][mm] = sin( (double)(mm)*f );
-	}
-    }
-}
-
-
-/* ================================================
-   for a given node, this routine gives which cap and element
-   the node is in.
-   ================================================*/
-void construct_interp_net(E)
-     struct All_variables *E;
-{
-
-    void parallel_process_termination();
-    void parallel_process_sync();
-    int ii,jj,es,i,j,m,el,node;
-    int locate_cap(),locate_element();
-    double x[4],t,f;
-
-    const int ends=4;
-
-    for (i=1;i<=E->sphere.nox;i++)
-	for (j=1;j<=E->sphere.noy;j++)   {
-	    node = i+(j-1)*E->sphere.nox;
-	    E->sphere.int_cap[node]=0;
-	    E->sphere.int_ele[node]=0;
-	}
-
-
-    for (i=1;i<=E->sphere.nox;i++)
-	for (j=1;j<=E->sphere.noy;j++)   {
-	    node = i+(j-1)*E->sphere.nox;
-
-	    /* first find which cap this node (i,j) is in  */
-	    t = E->sphere.sx[1][node];
-	    f = E->sphere.sx[2][node];
-
-	    x[1] = sin(t)*cos(f);  /* radius does not matter */
-	    x[2] = sin(t)*sin(f);
-	    x[3] = cos(t);
-
-
-	    fprintf(E->fp,"mmm0=%d\n",node);
-
-	    m = locate_cap(E,x);
-
-	    fprintf(E->fp,"mmm=%d\n",m);
-
-	    if (m>0)  {
-		el = locate_element(E,m,x,node);        /* bottom element */
-
-		if (el<=0)    {
-		    fprintf(stderr,"!!! Processor %d cannot find the right element in cap %d\n",E->parallel.me,m);
-		    parallel_process_termination();
-		}
-
-		E->sphere.int_cap[node]=m;
-		E->sphere.int_ele[node]=el;
-
-	    }
-	}        /* end for i and j */
-
-    parallel_process_sync(E);
-
-    return;
-}
-
-/* ================================================
-   locate the cap for node (i,j)
-   ================================================*/
-
-int locate_cap(E,x)
-     struct All_variables *E;
-     double x[4];
-{
-
-    int ia[5],i,m,mm;
-    double xx[4],angle[5],angle1[5];
-    double get_angle();
-    double area1,rr;
-    const double e_7=1.e-7;
-    static int been_here=0;
-
-    mm = 0;
-
-    for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-	ia[1] = 1;
-	ia[2] = E->lmesh.noz*E->lmesh.nox-E->lmesh.noz+1;
-	ia[3] = E->lmesh.nno-E->lmesh.noz+1;
-	ia[4] = ia[3]-E->lmesh.noz*(E->lmesh.nox-1);
-
-	for (i=1;i<=4;i++)  {
-	    xx[1] = E->x[m][1][ia[i]]/E->sx[m][3][ia[1]];
-	    xx[2] = E->x[m][2][ia[i]]/E->sx[m][3][ia[1]];
-	    xx[3] = E->x[m][3][ia[i]]/E->sx[m][3][ia[1]];
-	    angle[i] = get_angle(x,xx);    /* get angle between (i,j) and other four*/
-	    angle1[i]=E->sphere.angle[m][i];
-	}
-
-	area1 = area_of_sphere_triag(angle[1],angle[2],angle1[1])
-	    + area_of_sphere_triag(angle[2],angle[3],angle1[2])
-	    + area_of_sphere_triag(angle[3],angle[4],angle1[3])
-	    + area_of_sphere_triag(angle[4],angle[1],angle1[4]);
-
-	if ( fabs ((area1-E->sphere.area[m])/E->sphere.area[m]) <e_7 ) {
-	    mm = m;
-	    return (mm);
-        }
-    }
-
-    return (mm);
-}
-
-/* ================================================
-   locate the element containing the node (i,j) with coord x.
-   The radius is assumed to be 1 in computing the areas.
-   NOTE:  The returned element el is for the bottom layer.
-   ================================================*/
-
-int locate_element(E,m,x,ne)
-     struct All_variables *E;
-     double x[4];
-int m,ne;
-{
-
-    int el_temp,el,es,el_located,level,lev,lev_plus,el_plus,es_plus,i,j,node;
-    double area,area1,areamin;
-    double area_of_5points();
-    const double e_7=1.e-7;
-    const double e_6=1.e6;
-
-    el_located = 0;
-
-
-    level=E->mesh.levmin;
-    for (es=1;es<=E->lmesh.SNEL[level];es++)              {
-
-	el = (es-1)*E->lmesh.ELZ[level]+1;
-	area1 = area_of_5points (E,level,m,el,x,ne);
-	area = E->sphere.area1[level][m][es];
-
-	if(fabs ((area1-area)/area) <e_7 ) {
-	    for (lev=E->mesh.levmin;lev<E->mesh.levmax;lev++)  {
-		lev_plus = lev + 1;
-		j=1;
-		areamin = e_6;
-		do {
-		    el_plus = E->EL[lev][m][el].sub[j];
-
-		    es_plus = (el_plus-1)/E->lmesh.ELZ[lev_plus]+1;
-
-		    area1 = area_of_5points(E,lev_plus,m,el_plus,x,ne);
-		    area = E->sphere.area1[lev_plus][m][es_plus];
-
-		    if(fabs(area1-area)<areamin) {
-			areamin=fabs(area1-area);
-			el_temp = el_plus;
-		    }
-		    j++;
-		}  while (j<5 && fabs((area1-area)/area) > e_7);
-		el = el_plus;
-		/* if exit with ..>e_7, pick the best one*/
-		if (fabs((area1-area)/area) > e_7) el = el_temp;
-	    }      /* end for loop lev         */
-	    el_located = el;
-	}    /* end for if */
-
-	if(el_located)  break;
-    }    /* end for es at the coarsest level  */
-
-    return (el_located);
-}
-
-/* ===============================================================
-   interpolate nodal T's within cap m and element el onto node with
-   coordinate x[3] which is derived from a regular mesh and within
-   the element el. NOTE the radius of x[3] is the inner radius.
-   =============================================================== */
-
-float sphere_interpolate_point(E,T,m,el,x,ne)
-     struct All_variables *E;
-     float **T;
-     double x[4];
-int m,el,ne;
-{
-    double to,fo,y[4],yy[4][5],dxdy[4][4];
-    double a1,b1,c1,d1,a2,b2,c2,d2,a,b,c,xx1,yy1,y1,y2;
-    float ta,t[5];
-    int es,snode,i,j,node;
-
-    const int oned=4;
-    const double e_7=1.e-7;
-    const double four=4.0;
-    const double two=2.0;
-    const double one=1.0;
-    const double pt25=0.25;
-
-    /* first rotate the coord such that the center of element is
-       the pole   */
-
-    es = (el-1)/E->lmesh.elz+1;
-
-    to = E->eco[m][el].centre[1];
-    fo = E->eco[m][el].centre[2];
-
-    dxdy[1][1] = cos(to)*cos(fo);
-    dxdy[1][2] = cos(to)*sin(fo);
-    dxdy[1][3] = -sin(to);
-    dxdy[2][1] = -sin(fo);
-    dxdy[2][2] = cos(fo);
-    dxdy[2][3] = 0.0;
-    dxdy[3][1] = sin(to)*cos(fo);
-    dxdy[3][2] = sin(to)*sin(fo);
-    dxdy[3][3] = cos(to);
-
-    for(i=1;i<=oned;i++) {         /* nodes */
-	node = E->ien[m][el].node[i];
-	snode = E->sien[m][es].node[i];
-	t[i] = T[m][snode];
-	for (j=1;j<=E->mesh.nsd;j++)
-	    yy[j][i] = E->x[m][1][node]*dxdy[j][1]
-                + E->x[m][2][node]*dxdy[j][2]
-                + E->x[m][3][node]*dxdy[j][3];
-    }
-
-    for (j=1;j<=E->mesh.nsd;j++)
-	y[j] = x[1]*dxdy[j][1] + x[2]*dxdy[j][2] + x[3]*dxdy[j][3];
-
-    /* then for node y, determine its coordinates xx1,yy1
-       in the parental element in the isoparametric element system*/
-
-    a1 = yy[1][1] + yy[1][2] + yy[1][3] + yy[1][4];
-    b1 = yy[1][3] + yy[1][2] - yy[1][1] - yy[1][4];
-    c1 = yy[1][3] + yy[1][1] - yy[1][2] - yy[1][4];
-    d1 = yy[1][3] + yy[1][4] - yy[1][1] - yy[1][2];
-    a2 = yy[2][1] + yy[2][2] + yy[2][3] + yy[2][4];
-    b2 = yy[2][3] + yy[2][2] - yy[2][1] - yy[2][4];
-    c2 = yy[2][3] + yy[2][1] - yy[2][2] - yy[2][4];
-    d2 = yy[2][3] + yy[2][4] - yy[2][1] - yy[2][2];
-
-    a = d2*c1;
-    b = a2*c1+b1*d2-d1*c2-d1*b2-four*c1*y[2];
-    c=four*c2*y[1]-c2*a1-a1*b2+four*b2*y[1]-four*b1*y[2]+a2*b1;
-
-    if (fabs(a)<e_7)  {
-	yy1 = -c/b;
-	xx1 = (four*y[1]-a1-d1*yy1)/(b1+c1*yy1);
-    }
-    else  {
-	y1= (-b+sqrt(b*b-four*a*c))/(two*a);
-	y2= (-b-sqrt(b*b-four*a*c))/(two*a);
-	if (fabs(y1)>fabs(y2))
-	    yy1 = y2;
-	else
-	    yy1 = y1;
-	xx1 = (four*y[1]-a1-d1*yy1)/(b1+c1*yy1);
-    }
-
-    /* now we can calculate T at x[4] using shape function */
-
-    ta = ((one-xx1)*(one-yy1)*t[1]+(one+xx1)*(one-yy1)*t[2]+
-          (one+xx1)*(one+yy1)*t[3]+(one-xx1)*(one+yy1)*t[4])*pt25;
-
-    /*if(fabs(xx1)>1.5 || fabs(yy1)>1.5)fprintf(E->fp_out,"ME= %d %d %d %g %g %g %g %g %g %g\n",ne,m,es,t[1],t[2],t[3],t[4],ta,xx1,yy1);
-     */
-    return (ta);
-}
-
-/* ===================================================================
-   do the interpolation on sphere for data T, which is needed for both
-   spherical harmonic expansion and graphics
-   =================================================================== */
-
-void sphere_interpolate(E,T,TG)
-     struct All_variables *E;
-     float **T,*TG;
-{
-
-    float sphere_interpolate_point();
-    void gather_TG_to_me0();
-    void parallel_process_termination();
-
-    int ii,jj,es,i,j,m,el,node;
-    double x[4],t,f;
-
-    const int ends=4;
-
-    TG[0] = 0.0;
-    for (i=1;i<=E->sphere.nox;i++)
-	for (j=1;j<=E->sphere.noy;j++)   {
-	    node = i+(j-1)*E->sphere.nox;
-	    TG[node] = 0.0;
-	    /* first find which cap this node (i,j) is in  */
-
-	    m = E->sphere.int_cap[node];
-	    el = E->sphere.int_ele[node];
-
-	    if (m>0 && el>0)   {
-		t = E->sphere.sx[1][node];
-		f = E->sphere.sx[2][node];
-
-		x[1] = E->sx[1][3][1]*sin(t)*cos(f);
-		x[2] = E->sx[1][3][1]*sin(t)*sin(f);
-		x[3] = E->sx[1][3][1]*cos(t);
-
-		TG[node] = sphere_interpolate_point(E,T,m,el,x,node);
-
-	    }
-
-	}        /* end for i and j */
-
-    gather_TG_to_me0(E,TG);
-
-    return;
-}
-
-
-
-/* ==========================================================  */
-/*  From Phase_change.c                                        */
-/* =========================================================== */
-
-
-void phase_change_410(E,B,B_b)
-  struct All_variables *E;
-  float **B,**B_b;
-{
-  int i,j,k,n,ns,m;
-  float e_pressure,pt5,one;
-
-  pt5 = 0.5; one=1.0;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)     {
-    for(i=1;i<=E->lmesh.nno;i++)  {
-      e_pressure = (E->sphere.ro-E->sx[m][3][i])-E->viscosity.z410-
-            E->control.clapeyron410*(E->T[m][i]-E->control.transT410);
-
-      B[m][i] = pt5*(one+tanh(E->control.width410*e_pressure));
-      }
-
-    ns = 0;
-    for (k=1;k<=E->lmesh.noy;k++)
-      for (j=1;j<=E->lmesh.nox;j++)  {
-        ns = ns + 1;
-        B_b[m][ns]=0.0;
-        for (i=1;i<E->lmesh.noz;i++)   {
-          n = (k-1)*E->lmesh.noz*E->lmesh.nox + (j-1)*E->lmesh.noz + i;
-          if (B[m][n]>=pt5&&B[m][n+1]<=pt5)
-            B_b[m][ns]=(E->sx[m][3][n+1]-E->sx[m][3][n])*(pt5-B[m][n])/(B[m][n+1]-B[m][n])+E->sx[m][3][n];
-          }
-        }
-    }
-
-
-  return;
-  }
-
-
-void phase_change_670(E,B,B_b)
-  struct All_variables *E;
-  float **B,**B_b;
-{
-  int i,j,k,n,ns,m;
-  float e_pressure,pt5,one;
-
-  pt5 = 0.5; one=1.0;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)     {
-    for(i=1;i<=E->lmesh.nno;i++)  {
-      e_pressure = (E->sphere.ro-E->sx[m][3][i])-E->viscosity.zlm-
-            E->control.clapeyron670*(E->T[m][i]-E->control.transT670);
-
-      B[m][i] = pt5*(one+tanh(E->control.width670*e_pressure));
-      }
-
-    ns = 0;
-    for (k=1;k<=E->lmesh.noy;k++)
-      for (j=1;j<=E->lmesh.nox;j++)  {
-        ns = ns + 1;
-        B_b[m][ns]=0.0;
-        for (i=1;i<E->lmesh.noz;i++)   {
-          n = (k-1)*E->lmesh.noz*E->lmesh.nox + (j-1)*E->lmesh.noz + i;
-          if (B[m][n]>=pt5&&B[m][n+1]<=pt5)
-            B_b[m][ns]=(E->sx[m][3][n+1]-E->sx[m][3][n])*(pt5-B[m][n])/(B[m][n+1]-B[m][n])+E->sx[m][3][n];
-          }
-        }
-    }
-
-
-  return;
-  }
-
-
-void phase_change_cmb(E,B,B_b)
-  struct All_variables *E;
-  float **B,**B_b;
-{
-  int i,j,k,n,ns,m;
-  float e_pressure,pt5,one;
-
-  pt5 = 0.5; one=1.0;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)     {
-    for(i=1;i<=E->lmesh.nno;i++)  {
-      e_pressure = (E->sphere.ro-E->sx[m][3][i])-E->viscosity.zcmb-
-            E->control.clapeyroncmb*(E->T[m][i]-E->control.transTcmb);
-
-      B[m][i] = pt5*(one+tanh(E->control.widthcmb*e_pressure));
-      }
-
-    ns = 0;
-    for (k=1;k<=E->lmesh.noy;k++)
-      for (j=1;j<=E->lmesh.nox;j++)  {
-        ns = ns + 1;
-        B_b[m][ns]=0.0;
-        for (i=1;i<E->lmesh.noz;i++)   {
-          n = (k-1)*E->lmesh.noz*E->lmesh.nox + (j-1)*E->lmesh.noz + i;
-          if (B[m][n]>=pt5&&B[m][n+1]<=pt5)
-            B_b[m][ns]=(E->sx[m][3][n+1]-E->sx[m][3][n])*(pt5-B[m][n])/(B[m][n+1]-B[m][n])+E->sx[m][3][n];
-          }
-        }
-    }
-
-  return;
-}
-
-
-/* ==========================================================  */
-/*  From Nodal_mesh.c                                          */
-/* =========================================================== */
-
-void flogical_mesh_to_real(E,data,level)
-     struct All_variables *E;
-     float *data;
-     int level;
-
-{ int i,j,n1,n2;
-
-  return;
-}
-
-
-void p_to_centres(E,PN,P,lev)
-     struct All_variables *E;
-     float **PN;
-     double **P;
-     int lev;
-
-{  int p,element,node,j,m;
-   double weight;
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)
-    for(p=1;p<=E->lmesh.NEL[lev];p++)
-      P[m][p] = 0.0;
-
-   weight=1.0/((double)enodes[E->mesh.nsd]) ;
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)
-    for(p=1;p<=E->lmesh.NEL[lev];p++)
-      for(j=1;j<=enodes[E->mesh.nsd];j++)
-        P[m][p] += PN[m][E->IEN[lev][m][p].node[j]] * weight;
-
-   return;
-   }
-
-
-void v_to_intpts(E,VN,VE,lev)
-  struct All_variables *E;
-  float **VN,**VE;
-  int lev;
-  {
-
-   int m,e,i,j,k;
-   const int nsd=E->mesh.nsd;
-   const int vpts=vpoints[nsd];
-   const int ends=enodes[nsd];
-
- for (m=1;m<=E->sphere.caps_per_proc;m++)
-   for(e=1;e<=E->lmesh.NEL[lev];e++)
-     for(i=1;i<=vpts;i++)                 {
-        VE[m][(e-1)*vpts + i] = 0.0;
-        for(j=1;j<=ends;j++)
-          VE[m][(e-1)*vpts + i] += VN[m][E->IEN[lev][m][e].node[j]]*E->N.vpt[GNVINDEX(j,i)];
-        }
-
-   return;
-  }
-
-
-void visc_to_intpts(E,VN,VE,lev)
-   struct All_variables *E;
-   float **VN,**VE;
-   int lev;
-   {
-
-   int m,e,i,j,k;
-   const int nsd=E->mesh.nsd;
-   const int vpts=vpoints[nsd];
-   const int ends=enodes[nsd];
-
- for (m=1;m<=E->sphere.caps_per_proc;m++)
-   for(e=1;e<=E->lmesh.NEL[lev];e++)
-     for(i=1;i<=vpts;i++) {
-        VE[m][(e-1)*vpts + i] = 0.0;
-	for(j=1;j<=ends;j++)
-          VE[m][(e-1)*vpts + i] += log(VN[m][E->IEN[lev][m][e].node[j]]) *  E->N.vpt[GNVINDEX(j,i)];
-        VE[m][(e-1)*vpts + i] = exp(VE[m][(e-1)*vpts + i]);
-        }
-
-  }
-
-
-/* ==========================================================  */
-/*  From Pan_problem_misc_functions.c                          */
-/* =========================================================== */
-
-double SIN_D(x)
-     double x;
-{
-#if defined(__osf__)
-  return sind(x);
-#else
-  return sin((x/180.0) * M_PI);
-#endif
-
-}
-
-double COT_D(x)
-     double x;
-{
-#if defined(__osf__)
-  return cotd(x);
-#else
-  return tan(((90.0-x)/180.0) * M_PI);
-#endif
-
-}
-
-
-/* non-runaway malloc */
-
-void * Malloc1(bytes,file,line)
-    int bytes;
-    char *file;
-    int line;
-{
-    void *ptr;
-
-    ptr = malloc((size_t)bytes);
-    if (ptr == (void *)NULL) {
-	fprintf(stderr,"Memory: cannot allocate another %d bytes \n(line %d of file %s)\n",bytes,line,file);
-	parallel_process_termination();
-    }
-
-    return(ptr);
-}
-
-
-/* returns the out of plane component of the cross product of
-   the two vectors assuming that one is looking AGAINST the
-   direction of the axis of D, anti-clockwise angles
-   are positive (are you sure ?), and the axes are ordered 2,3 or 1,3 or 1,2 */
-
-
-float cross2d(x11,x12,x21,x22,D)
-    float x11,x12,x21,x22;
-    int D;
-{
-  float temp;
-   if(1==D)
-       temp = ( x11*x22-x12*x21);
-   if(2==D)
-       temp = (-x11*x22+x12*x21);
-   if(3==D)
-       temp = ( x11*x22-x12*x21);
-
-   return(temp);
-}
-
-
-/* ==========================================================  */
-/*  From General_matrix_functions.c                            */
-/* =========================================================== */
-
-/*=====================================================================
-  Variable dimension matrix allocation  function from numerical recipes
-  Note: ANSII consistency requires some additional features !
-  =====================================================================  */
-
-double **dmatrix(nrl,nrh,ncl,nch)
-     int nrl,nrh,ncl,nch;
-{
-  int i,nrow = nrh-nrl+1,ncol=nch-ncl+1;
-  double **m;
-
-  /* allocate pointer to rows  */
-  m=(double **) malloc((nrow+1)* sizeof(double *));
-  m+=1;
-  m-= nrl;
-
-  /*  allocate rows and set the pointers accordingly   */
-  m[nrl] = (double *) malloc((nrow*ncol+1)* sizeof(double));
-  m[nrl] += 1;
-  m[nrl] -= ncl;
-
-  for(i=nrl+1;i<=nrh;i++)
-     m[i] = m[i-1] + ncol;
-
-  return(m);		}
-
-
-float **fmatrix(nrl,nrh,ncl,nch)
-     int nrl,nrh,ncl,nch;
-{
-  int i,nrow = nrh-nrl+1,ncol=nch-ncl+1;
-  float **m;
-
-  /* allocate pointer to rows  */
-  m=(float **) malloc((unsigned)((nrow+1)* sizeof(float *)));
-  m+=1;
-  m-= nrl;
-
-  /*  allocate rows and set the pointers accordingly   */
-  m[nrl] = (float *) malloc((unsigned)((nrow*ncol+1)* sizeof(float)));
-  m[nrl] += 1;
-  m[nrl] -= ncl;
-
-  for(i=nrl+1;i<=nrh;i++)
-     m[i] = m[i-1] + ncol;
-
-  return(m);		}
-
-
-void dfree_matrix(m,nrl,nrh,ncl,nch)
-     double **m;
-     int nrl,nrh,ncl,nch;
-{
-  int i;
-  for(i=nrh;i>=nrl;i--)
-    free((void *)(m[i] + ncl));
-  free((void *) (m+nrl));
-  return;
-}
-
-void ffree_matrix(m,nrl,nrh,ncl,nch)
-     float **m;
-     int nrl,nrh,ncl,nch;
-{
-  int i;
-  for(i=nrh;i>=nrl;i--)
-    free((void *)(m[i] + ncl));
-  free((void *) (m+nrl));
-  return;
-}
-
-/*=============================================================
-  Functions to allocate/remove space for variable sized vector.
-  =============================================================  */
-
-double *dvector(nl,nh)
-     int nl,nh;
-{
-  double *v;
-  v=(double *) malloc((unsigned) ( nh - nl +1)* sizeof(double));
-  return( v-nl );  }
-
-float *fvector(nl,nh)
-     int nl,nh;
-{
-  float *v;
-  v=(float *) malloc((unsigned) ( nh - nl +1)* sizeof(float));
-  return( v-nl );  }
-
-void dfree_vector(v,nl,nh)
-     double *v;
-     int nl,nh;
-{
-  free((char*) (v+nl));	}
-
-void ffree_vector(v,nl,nh)
-     float *v;
-     int nl,nh;
-{
-  free((char*) (v+nl));	}
-
-int *sivector(nl,nh)
-     int nl,nh;
-{
-  int *v;
-  v=(int*) malloc((unsigned)(nh-nl +1) * sizeof(int));
-  return (v-nl);
-}
-
-void sifree_vector(v,nl,nh)
-     int *v;
-     int nl,nh;
-{ free((char *) (v+nl));    }
-
-
-
-void dvcopy(E,A,B,a,b)
-     struct All_variables *E;
-     double **A,**B;
-     int a,b;
-
-{   int i,m;
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)
-    for(i=a;i<=b;i++)
-      A[m][i] = B[m][i];
-
-    return; }
-
-void vcopy(A,B,a,b)
-     float *A,*B;
-     int a,b;
-
-{   int i;
-
-    for(i=a;i<=b;i++)
-      A[i] = B[i];
-
-    return; }
-
-
-
-/* =====================================*/
- double sphere_h(l,m,t,f,ic)
- int l,m,ic;
- double t,f;
- {
-
- double plgndr_a(),sphere_hamonics;
-
- sphere_hamonics = 0.0;
- if (ic==0)
-    sphere_hamonics = cos(m*f)*plgndr_a(l,m,t);
- else if (m)
-    sphere_hamonics = sin(m*f)*plgndr_a(l,m,t);
-
- return sphere_hamonics;
- }
-
-/* =====================================*/
- double plgndr_a(l,m,t)
- int l,m;
- double t;
- {
-
-  int i,ll;
-  double x,fact,pll,pmm,pmmp1,somx2,plgndr;
-  const double two=2.0;
-  const double one=1.0;
-
-  x = cos(t);
-  pmm=one;
-  if(m>0) {
-    somx2=sqrt((one-x)*(one+x));
-    fact = one;
-    for (i=1;i<=m;i++)   {
-      pmm = -pmm*fact*somx2;
-      fact = fact + two;
-      }
-    }
-
-  if (l==m)
-     plgndr = pmm;
-  else  {
-     pmmp1 = x*(2*m+1)*pmm;
-     if(l==m+1)
-       plgndr = pmmp1;
-     else   {
-       for (ll=m+2;ll<=l;ll++)  {
-         pll = (x*(2*ll-1)*pmmp1-(ll+m-1)*pmm)/(ll-m);
-         pmm = pmmp1;
-         pmmp1 = pll;
-         }
-       plgndr = pll;
-       }
-     }
-
- return plgndr;
- }
-
- float area_of_4node(x1,y1,x2,y2,x3,y3,x4,y4)
- float x1,y1,x2,y2,x3,y3,x4,y4;
-
- {
- float area;
-
- area = fabs(0.5*(x1*(y2-y4)+x2*(y4-y1)+x4*(y1-y2)))
-      + fabs(0.5*(x2*(y3-y4)+x3*(y4-y2)+x4*(y2-y3)));
-
- return area;
- }
-
-void print_elt_k(E,a)
-     struct All_variables *E;
-     double a[24*24];
-
-{ int l,ll,n;
-
-  printf("elt k is ...\n");
-
-
-  n = loc_mat_size[E->mesh.nsd];
-
-  for(l=0;l<n;l++)
-    { fprintf(stderr,"\n");fflush(stderr);
-      for(ll=0;ll<n;ll++)
-	{ fprintf(stderr,"%s%.3e ",a[ll*n+l] >= 0.0 ? "+" : "",a[ll*n+l]);
-	  fflush(stderr);
-	}
-    }
-  fprintf(stderr,"\n"); fflush(stderr);
-
-  return; }
-
-
- /* ===================================  */
-  double sqrt_multis(jj,ii)
-  int ii,jj;
- {
-  int i;
-  double sqrt_multisa;
-
-  sqrt_multisa = 1.0;
-  if(jj>ii)
-    for (i=jj;i>ii;i--)
-      sqrt_multisa *= 1.0/sqrt((double)i);
-
-  return sqrt_multisa;
-  }
-
- /* ===================================  */
-  double multis(ii)
-  int ii;
- {
-  int i;
-  double multisa;
-
-  multisa = 1.0;
-  if (ii)
-    for (i=2;i<=ii;i++)
-      multisa *= (double)i;
-
-  return multisa;
-  }
-
-
- /* ===================================  */
- int int_multis(ii)
- int ii;
- {
- int i,multisa;
-
- multisa = 1;
- if (ii)
-   for (i=2;i<=ii;i++)
-     multisa *= i;
-
- return multisa;
- }
-
-
-void jacobi(E,d0,F,Ad,acc,cycles,level,guess)
-     struct All_variables *E;
-     double **d0;
-     double **F,**Ad;
-     double acc;
-     int *cycles;
-     int level;
-     int guess;
-{
-
-    int count,i,j,k,l,m,ns,steps;
-    int *C;
-    int eqn1,eqn2,eqn3,gneq;
-
-    void n_assemble_del2_u();
-
-    double sum1,sum2,sum3,residual,global_vdot(),U1,U2,U3;
-
-    double *r1[NCS];
-
-    higher_precision *B1,*B2,*B3;
-
-
-    const int dims=E->mesh.nsd;
-    const int ends=enodes[dims];
-    const int n=loc_mat_size[E->mesh.nsd];
-    const int neq=E->lmesh.NEQ[level];
-    const int num_nodes=E->lmesh.NNO[level];
-    const int nox=E->lmesh.NOX[level];
-    const int noz=E->lmesh.NOY[level];
-    const int noy=E->lmesh.NOZ[level];
-    const int max_eqn=14*dims;
-
-    gneq = E->mesh.NEQ[level];
-
-    steps=*cycles;
-
-    for (m=1;m<=E->sphere.caps_per_proc;m++)
-      r1[m] = (double *)malloc(E->lmesh.neq*sizeof(double));
-
-    if(guess) {
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
-          d0[m][neq]=0.0;
-      n_assemble_del2_u(E,d0,Ad,level,1);
-    }
-    else
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
-	for(i=0;i<=neq;i++) {
-	    d0[m][i]=Ad[m][i]=0.0;
-	}
-
-    for (m=1;m<=E->sphere.caps_per_proc;m++)
-      for(i=0;i<neq;i++)
-        r1[m][i]=F[m][i]-Ad[m][i];
-
-
-    count = 0;
-
-   while (count < steps)   {
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
- 	for(i=1;i<=E->lmesh.NNO[level];i++)  {
-	    eqn1=E->ID[level][m][i].doff[1];
-	    eqn2=E->ID[level][m][i].doff[2];
-	    eqn3=E->ID[level][m][i].doff[3];
-            d0[m][eqn1] += r1[m][eqn1]*E->BI[level][m][eqn1];
-            d0[m][eqn2] += r1[m][eqn2]*E->BI[level][m][eqn2];
-            d0[m][eqn3] += r1[m][eqn3]*E->BI[level][m][eqn3];
-            }
-
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
-	for(i=0;i<=neq;i++)
-	    Ad[m][i]=0.0;
-
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
- 	for(i=1;i<=E->lmesh.NNO[level];i++)  {
-	    eqn1=E->ID[level][m][i].doff[1];
-	    eqn2=E->ID[level][m][i].doff[2];
-	    eqn3=E->ID[level][m][i].doff[3];
-	    U1 = d0[m][eqn1];
-	    U2 = d0[m][eqn2];
-	    U3 = d0[m][eqn3];
-
-            C=E->Node_map[level][m]+(i-1)*max_eqn;
-	    B1=E->Eqn_k1[level][m]+(i-1)*max_eqn;
-	    B2=E->Eqn_k2[level][m]+(i-1)*max_eqn;
- 	    B3=E->Eqn_k3[level][m]+(i-1)*max_eqn;
-
-            for(j=3;j<max_eqn;j++)  {
-               Ad[m][eqn1] += B1[j]*d0[m][C[j]];
-               Ad[m][eqn2] += B2[j]*d0[m][C[j]];
-               Ad[m][eqn3] += B3[j]*d0[m][C[j]];
-               }
-
-	    for(j=0;j<max_eqn;j++) {
-		    Ad[m][C[j]]  += B1[j]*U1 +  B2[j]*U2 +  B3[j]*U3;
-		}
-	    }       /* end for i and m */
-
-      (E->solver.exchange_id_d)(E, Ad, level);
-
-      for (m=1;m<=E->sphere.caps_per_proc;m++)
-	for(i=0;i<neq;i++)
-	    r1[m][i] = F[m][i] - Ad[m][i];
-
-   /*   residual = sqrt(global_vdot(E,r1,r1,level))/gneq;
-
-   if(E->parallel.me==0)fprintf(stderr,"residuall =%.5e for %d\n",residual,count);
-*/	count++;
-    }
-
-   *cycles=count;
-
-    for (m=1;m<=E->sphere.caps_per_proc;m++)
-      free((double*) r1[m]);
-
-    return;
-
-    }
-
-
-/* version */
-/* $Id$ */
-
-/* End of file  */

Modified: mc/3D/CitcomS/branches/cxx/lib/Output.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Output.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Output.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,36 +29,33 @@
    and to turn them into a coherent suite  files  */
 
 
+#include "output.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "parsing.h"
-#include "output.h"
 
-#include "cproto.h"
+#include "parallel_util.h"
+#include "process_buoyancy.h"
+#include "topo_gravity.h"
 
-void output_comp_nd(struct All_variables *, int);
-void output_comp_el(struct All_variables *, int);
-void output_coord(struct All_variables *);
-void output_mat(struct All_variables *);
-void output_velo(struct All_variables *, int);
-void output_visc_prepare(struct All_variables *, float **);
-void output_visc(struct All_variables *, int);
-void output_surf_botm(struct All_variables *, int);
-void output_geoid(struct All_variables *, int);
-void output_stress(struct All_variables *, int);
-void output_horiz_avg(struct All_variables *, int);
-void output_tracer(struct All_variables *, int);
-void output_pressure(struct All_variables *, int);
-void output_heating(struct All_variables *, int);
 
-extern void parallel_process_termination();
-extern void heat_flux(struct All_variables *);
-extern void get_STD_topo(struct All_variables *, float**, float**,
-                         float**, float**, int);
-extern void get_CBF_topo(struct All_variables *, float**, float**);
+static void output_comp_nd(struct All_variables *, int);
+static void output_comp_el(struct All_variables *, int);
+static void output_coord(struct All_variables *);
+static void output_mat(struct All_variables *);
+static void output_velo(struct All_variables *, int);
+static void output_visc(struct All_variables *, int);
+static void output_surf_botm(struct All_variables *, int);
+static void output_geoid(struct All_variables *, int);
+static void output_stress(struct All_variables *, int);
+static void output_horiz_avg(struct All_variables *, int);
+static void output_tracer(struct All_variables *, int);
+static void output_pressure(struct All_variables *, int);
+static void output_heating(struct All_variables *, int);
 
 /**********************************************************************/
 
@@ -159,7 +156,7 @@
 }
 
 
-void output_coord(struct All_variables *E)
+static void output_coord(struct All_variables *E)
 {
   int i, j;
   char output_file[255];
@@ -180,7 +177,7 @@
 }
 
 
-void output_visc(struct All_variables *E, int cycles)
+static void output_visc(struct All_variables *E, int cycles)
 {
   int i, j;
   char output_file[255];
@@ -204,7 +201,7 @@
 }
 
 
-void output_velo(struct All_variables *E, int cycles)
+static void output_velo(struct All_variables *E, int cycles)
 {
   int i, j;
   char output_file[255];
@@ -229,7 +226,7 @@
 }
 
 
-void output_surf_botm(struct All_variables *E, int cycles)
+static void output_surf_botm(struct All_variables *E, int cycles)
 {
   int i, j, s;
   char output_file[255];
@@ -291,7 +288,7 @@
 }
 
 
-void output_geoid(struct All_variables *E, int cycles)
+static void output_geoid(struct All_variables *E, int cycles)
 {
     int ll, mm, p;
     char output_file[255];
@@ -330,7 +327,7 @@
 
 
 
-void output_stress(struct All_variables *E, int cycles)
+static void output_stress(struct All_variables *E, int cycles)
 {
   int m, node;
   char output_file[255];
@@ -366,7 +363,7 @@
 }
 
 
-void output_horiz_avg(struct All_variables *E, int cycles)
+static void output_horiz_avg(struct All_variables *E, int cycles)
 {
   /* horizontal average output of temperature, composition and rms velocity*/
 
@@ -402,7 +399,7 @@
 
 
 
-void output_mat(struct All_variables *E)
+static void output_mat(struct All_variables *E)
 {
   int m, el;
   char output_file[255];
@@ -422,7 +419,7 @@
 
 
 
-void output_pressure(struct All_variables *E, int cycles)
+static void output_pressure(struct All_variables *E, int cycles)
 {
   int i, j;
   char output_file[255];
@@ -447,7 +444,7 @@
 
 
 
-void output_tracer(struct All_variables *E, int cycles)
+static void output_tracer(struct All_variables *E, int cycles)
 {
   int i, j, n, ncolumns;
   char output_file[255];
@@ -484,7 +481,7 @@
 }
 
 
-void output_comp_nd(struct All_variables *E, int cycles)
+static void output_comp_nd(struct All_variables *E, int cycles)
 {
     int i, j, k;
     char output_file[255];
@@ -519,7 +516,7 @@
 }
 
 
-void output_comp_el(struct All_variables *E, int cycles)
+static void output_comp_el(struct All_variables *E, int cycles)
 {
     int i, j, k;
     char output_file[255];
@@ -554,7 +551,7 @@
 }
 
 
-void output_heating(struct All_variables *E, int cycles)
+static void output_heating(struct All_variables *E, int cycles)
 {
     int j, e;
     char output_file[255];

Modified: mc/3D/CitcomS/branches/cxx/lib/Output_gzdir.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Output_gzdir.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Output_gzdir.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -28,6 +28,7 @@
 /* Routine to process the output of the finite element cycles
    and to turn them into a coherent suite  files  */
 
+
 /*
 
 this version uses gzipped, ascii output to subdirectories for the
@@ -51,9 +52,10 @@
 TWB
 
 */
+#include "output_gzdir.h"
+
 #ifdef USE_GZDIR
 
-
 //#define ASCII_DEBUG
 
 #include <zlib.h>
@@ -65,7 +67,6 @@
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "parsing.h"
-#include "parallel_related.h"
 #include "output.h"
 /* Big endian crap */
 #include <string.h>
@@ -73,61 +74,39 @@
 #include <malloc.h>
 #endif
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "determine_net_rotation.h"
+#include "instructions.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "process_buoyancy.h"
+#include "topo_gravity.h"
 
 
-void be_flipit(void *, void *, size_t );
-void be_flip_byte_order(void *, size_t );
-int be_is_little_endian(void);
-int be_write_float_to_file(float *, int , FILE *);
-int be_write_int_to_file(int *, int , FILE *);
-void myfprintf(FILE *,char *);
-void calc_cbase_at_node(int , int , float *,struct All_variables *);
+static void be_flipit(void *, void *, size_t );
+static void be_flip_byte_order(void *, size_t );
+static int be_is_little_endian(void);
+static int be_write_float_to_file(float *, int , FILE *);
+static int be_write_int_to_file(int *, int , FILE *);
+static void myfprintf(FILE *,char *);
 
 /*  */
-void get_vtk_filename(char *,int,struct All_variables *,int);
 
-gzFile *gzdir_output_open(char *,char *);
-void gzdir_output(struct All_variables *, int );
-void gzdir_output_comp_nd(struct All_variables *, int);
-void gzdir_output_comp_el(struct All_variables *, int);
-void gzdir_output_coord(struct All_variables *);
-void gzdir_output_mat(struct All_variables *);
-void gzdir_output_velo_temp(struct All_variables *, int);
-void gzdir_output_visc_prepare(struct All_variables *, float **);
-void gzdir_output_visc(struct All_variables *, int);
-void gzdir_output_surf_botm(struct All_variables *, int);
-void gzdir_output_geoid(struct All_variables *, int);
-void gzdir_output_stress(struct All_variables *, int);
-void gzdir_output_horiz_avg(struct All_variables *, int);
-void gzdir_output_tracer(struct All_variables *, int);
-void gzdir_output_pressure(struct All_variables *, int);
-void gzdir_output_heating(struct All_variables *, int);
+static void gzdir_output_comp_nd(struct All_variables *, int);
+static void gzdir_output_comp_el(struct All_variables *, int);
+static void gzdir_output_coord(struct All_variables *);
+static void gzdir_output_mat(struct All_variables *);
+static void gzdir_output_velo_temp(struct All_variables *, int);
+static void gzdir_output_visc(struct All_variables *, int);
+static void gzdir_output_surf_botm(struct All_variables *, int);
+static void gzdir_output_geoid(struct All_variables *, int);
+static void gzdir_output_stress(struct All_variables *, int);
+static void gzdir_output_horiz_avg(struct All_variables *, int);
+static void gzdir_output_tracer(struct All_variables *, int);
+static void gzdir_output_pressure(struct All_variables *, int);
+static void gzdir_output_heating(struct All_variables *, int);
 
 
-void sub_netr(float, float, float, float *, float *, double *);
-double determine_model_net_rotation(struct All_variables *,double *);
-
-
-void restart_tic_from_gzdir_file(struct All_variables *);
-
-void calc_cbase_at_tp(float , float , float *);
-void rtp2xyz(float , float , float, float *);
-void convert_pvec_to_cvec(float ,float , float , float *,float *);
-void *safe_malloc (size_t );
-
-int open_file_zipped(char *, FILE **,struct All_variables *);
-void gzip_file(char *);
-
-
-extern void temperatures_conform_bcs(struct All_variables *);
-extern void myerror(struct All_variables *,char *);
-extern void mkdatadir(const char *);
-extern void heat_flux(struct All_variables *);
-extern void get_STD_topo(struct All_variables *, float**, float**,
-                         float**, float**, int);
-extern void get_CBF_topo(struct All_variables *, float**, float**);
-
 /**********************************************************************/
 
 
@@ -220,7 +199,7 @@
 
 
  */
-void gzdir_output_coord(struct All_variables *E)
+static void gzdir_output_coord(struct All_variables *E)
 {
   int i, j, offset,ix[9],out;
   char output_file[255],ostring[255],message[255];
@@ -443,7 +422,7 @@
 
 
 */
-void gzdir_output_velo_temp(struct All_variables *E, int cycles)
+static void gzdir_output_velo_temp(struct All_variables *E, int cycles)
 {
   int i, j, k,os;
   char output_file[255],output_file2[255],message[255],geo_file[255];
@@ -695,7 +674,7 @@
 /*
    viscosity
 */
-void gzdir_output_visc(struct All_variables *E, int cycles)
+static void gzdir_output_visc(struct All_variables *E, int cycles)
 {
   int i, j;
   char output_file[255];
@@ -753,7 +732,7 @@
 
 
 
-void gzdir_output_surf_botm(struct All_variables *E, int cycles)
+static void gzdir_output_surf_botm(struct All_variables *E, int cycles)
 {
   int i, j, s;
   char output_file[255];
@@ -815,7 +794,7 @@
 }
 
 
-void gzdir_output_geoid(struct All_variables *E, int cycles)
+static void gzdir_output_geoid(struct All_variables *E, int cycles)
 {
     int ll, mm, p;
     char output_file[255];
@@ -854,7 +833,7 @@
 
 
 
-void gzdir_output_stress(struct All_variables *E, int cycles)
+static void gzdir_output_stress(struct All_variables *E, int cycles)
 {
   int m, node;
   char output_file[255];
@@ -890,7 +869,7 @@
 }
 
 
-void gzdir_output_horiz_avg(struct All_variables *E, int cycles)
+static void gzdir_output_horiz_avg(struct All_variables *E, int cycles)
 {
   /* horizontal average output of temperature, composition and rms velocity*/
 
@@ -925,7 +904,7 @@
 
 
 /* only called once */
-void gzdir_output_mat(struct All_variables *E)
+static void gzdir_output_mat(struct All_variables *E)
 {
   int m, el;
   char output_file[255];
@@ -945,7 +924,7 @@
 
 
 
-void gzdir_output_pressure(struct All_variables *E, int cycles)
+static void gzdir_output_pressure(struct All_variables *E, int cycles)
 {
   int i, j;
   float ftmp;
@@ -996,7 +975,7 @@
 
 
 
-void gzdir_output_tracer(struct All_variables *E, int cycles)
+static void gzdir_output_tracer(struct All_variables *E, int cycles)
 {
   int i, j, n, ncolumns;
   char output_file[255];
@@ -1034,7 +1013,7 @@
 }
 
 
-void gzdir_output_comp_nd(struct All_variables *E, int cycles)
+static void gzdir_output_comp_nd(struct All_variables *E, int cycles)
 {
   int i, j, k;
   char output_file[255],message[255];
@@ -1096,7 +1075,7 @@
 }
 
 
-void gzdir_output_comp_el(struct All_variables *E, int cycles)
+static void gzdir_output_comp_el(struct All_variables *E, int cycles)
 {
     int i, j, k;
     char output_file[255];
@@ -1125,7 +1104,7 @@
 }
 
 
-void gzdir_output_heating(struct All_variables *E, int cycles)
+static void gzdir_output_heating(struct All_variables *E, int cycles)
 {
     int j, e;
     char output_file[255];
@@ -1337,7 +1316,7 @@
 write the x[n] array to file, making sure it is written big endian
 
 */
-int be_write_float_to_file(float *x, int n, FILE *out)
+static int be_write_float_to_file(float *x, int n, FILE *out)
 {
   int i,nout;
   static size_t len = sizeof(float);
@@ -1365,7 +1344,7 @@
 #endif
   return nout;
 }
-int be_write_int_to_file(int *x, int n, FILE *out)
+static int be_write_int_to_file(int *x, int n, FILE *out)
 {
   int i,nout;
   static size_t len = sizeof(int);
@@ -1396,7 +1375,7 @@
 
 
 /* does this make a difference? nope, didn't, and why would it */
-void myfprintf(FILE *out,char *string)
+static void myfprintf(FILE *out,char *string)
 {
 #ifdef ASCII_DEBUG
   fprintf(out,string);
@@ -1405,7 +1384,7 @@
 #endif
 }
 
-int be_is_little_endian(void)
+static int be_is_little_endian(void)
 {
   static const unsigned long a = 1;
   return *(const unsigned char *)&a;
@@ -1423,7 +1402,7 @@
 flip endianness of x
 
 */
-void be_flip_byte_order(void *x, size_t len)
+static void be_flip_byte_order(void *x, size_t len)
 {
   void *copy;
   int i;
@@ -1434,7 +1413,7 @@
 }
 
 /* this should not be called with (i,i,size i) */
-void be_flipit(void *d, void *s, size_t len)
+static void be_flipit(void *d, void *s, size_t len)
 {
   unsigned char *dest = (unsigned char *)d;
   unsigned char *src  = (unsigned char *)s;

Modified: mc/3D/CitcomS/branches/cxx/lib/Output_h5.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Output_h5.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Output_h5.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -22,12 +22,13 @@
  */
 
 
+#include "output_h5.h"
+
 #include <stdlib.h>
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "parsing.h"
-#include "output_h5.h"
 
 
 #ifdef USE_HDF5

Modified: mc/3D/CitcomS/branches/cxx/lib/Output_vtk.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Output_vtk.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Output_vtk.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -28,6 +28,7 @@
 /* Routine to process the output of the finite element cycles
    and to turn them into a coherent suite  files  */
 
+#include "output_vtk.h"
 
 #include <stdlib.h>
 #include <math.h>

Modified: mc/3D/CitcomS/branches/cxx/lib/Pan_problem_misc_functions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Pan_problem_misc_functions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Pan_problem_misc_functions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,6 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "pan_problem_misc_functions.h"
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -49,26 +51,12 @@
 #endif
 
 #include "phase_change.h"
-#include "parallel_related.h"
 
-#include "cproto.h"
+#include "ggrd_handling.h"
+#include "instructions.h"
+#include "parallel_util.h"
+#include "parsing.h"
 
-void calc_cbase_at_tp(float , float , float *);
-void rtp2xyz(float , float , float, float *);
-void convert_pvec_to_cvec(float ,float , float , float *,float *);
-void *safe_malloc (size_t );
-void myerror(struct All_variables *,char *);
-void xyz2rtp(float ,float ,float ,float *);
-void xyz2rtpd(float ,float ,float ,double *);
-void get_r_spacing_fine(double *,struct All_variables *);
-void get_r_spacing_at_levels(double *,struct All_variables *);
-void calc_cbase_at_node(int , int , float *,struct All_variables *);
-#ifdef ALLOW_ELLIPTICAL
-double theta_g(double , struct All_variables *);
-#endif
-#ifdef USE_GGRD
-void ggrd_adjust_tbl_rayleigh(struct All_variables *,double **);
-#endif
 
 int get_process_identifier()
 {
@@ -302,7 +290,7 @@
 
    */
 
-int read_previous_field(
+static int read_previous_field(
     struct All_variables *E,
     float **field,
     char *name, char *abbr
@@ -452,7 +440,7 @@
    sphere_to_cart
 
 */
-void rtp2xyz(float r, float theta, float phi, float *xout)
+static void rtp2xyz(float r, float theta, float phi, float *xout)
 {
   float rst;
   rst = r * sin(theta);
@@ -484,7 +472,7 @@
    base[9], i.e. those are the cartesian representation of the r,
    theta, and phi basis vectors at theta, phi
 */
-void calc_cbase_at_tp(float theta, float phi, float *base)
+static void calc_cbase_at_tp(float theta, float phi, float *base)
 {
 
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Parallel_util.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Parallel_util.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Parallel_util.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,6 +26,7 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "parallel_util.h"
 
 #include <mpi.h>
 #include <stdlib.h>

Modified: mc/3D/CitcomS/branches/cxx/lib/Parsing.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Parsing.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Parsing.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -28,13 +28,14 @@
 /* Routines which read filenames from the command line and
    then parse the contents as parameters for citcom */
 
+#include "parsing.h"
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <string.h>
 #include "global_defs.h"
-#include "parsing.h"
 
-#include "cproto.h"
+#include "pan_problem_misc_functions.h"
 
 #define MAXLINE		1024	/* max length of line in input file */
 #define MAXNAME		64	/* max length of name */
@@ -84,9 +85,12 @@
 int DESCRIBE = 0;
 int BEGINNER = 0;
 
-int interpret_control_string();
 
+static void add_to_parameter_list(char *name, char *value);
+static int compute_parameter_hash_table(char *s);
+static int interpret_control_string(char *interpret, int *essential, double *Default, double *minvalue, double *maxvalue);
 
+
 void setup_parser(
     struct All_variables *E,
     char *filename
@@ -187,7 +191,7 @@
 
 
 /* add an entry to arglist, expanding memory */
-void add_to_parameter_list(
+static void add_to_parameter_list(
     char *name, char *value /* if necessary */
     )
 {
@@ -232,7 +236,7 @@
   NLIST++;
 }
 
-int compute_parameter_hash_table(char *s)
+static int compute_parameter_hash_table(char *s)
 { int h;
 
   h= s[0];
@@ -786,7 +790,7 @@
    The function strtok does not work on linux machine
 */
 
-int interpret_control_string(
+static int interpret_control_string(
     char *interpret,
     int *essential,
     double *Default, double *minvalue, double *maxvalue

Modified: mc/3D/CitcomS/branches/cxx/lib/Phase_change.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Phase_change.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Phase_change.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,13 +25,15 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "phase_change.h"
+
 #include <stdio.h>
 #include <math.h>
 #include <sys/types.h>
 #include "global_defs.h"
 
 #include "parsing.h"
-#include "phase_change.h"
 
 static void phase_change_apply(struct All_variables *E, double **buoy,
 			       float **B, float **B_b,

Modified: mc/3D/CitcomS/branches/cxx/lib/Problem_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Problem_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Problem_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,16 +25,17 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "problem_related.h"
+
 #include <math.h>
 #include <string.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#ifdef USE_GZDIR
-int open_file_zipped(char *, FILE **,struct All_variables *);
-void gzip_file(char *);
-#endif
+#include "output_gzdir.h"
+
 /*=======================================================================
   read velocity vectors at the top surface from files
 =========================================================================*/

Modified: mc/3D/CitcomS/branches/cxx/lib/Process_buoyancy.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Process_buoyancy.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Process_buoyancy.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -33,16 +33,16 @@
     get output the next time around the velocity solver);
     */
 
+#include "process_buoyancy.h"
 
 #include "element_definitions.h"
 #include "global_defs.h"
 #include <math.h>		/* for sqrt */
 
-#include "cproto.h"
+#include "global_operations.h"
+#include "nodal_mesh.h"
 
-void parallel_process_termination(void);
 
-
 void post_processing(struct All_variables *E)
 {
     return;

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_boundary_conditions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_boundary_conditions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_boundary_conditions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,14 +25,20 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "regional_boundary_conditions.h"
+
 #include "element_definitions.h"
 #include "global_defs.h"
 #include <math.h>
 
 #include "lith_age.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "pan_problem_misc_functions.h"
+#include "problem_related.h"
 
+
 /* ========================================== */
 
 static void horizontal_bc(
@@ -50,8 +56,6 @@
 static void temperature_apply_periodic_bcs(struct All_variables *);
 static void velocity_refl_vert_bc(struct All_variables *);
 static void temperature_refl_vert_bc(struct All_variables *);
-void read_temperature_boundary_from_file(struct All_variables *);
-void read_velocity_boundary_from_file(struct All_variables *);
 
 /* ========================================== */
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_geometry_cartesian.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_geometry_cartesian.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_geometry_cartesian.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,11 +25,12 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "regional_geometry_cartesian.h"
+
 #include "global_defs.h"
 #include "parsing.h"
 
-#include "cproto.h"
-
 void regional_set_2dc_defaults(struct All_variables *E)
 {
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_lith_age_read_files.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_lith_age_read_files.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_lith_age_read_files.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,11 +26,10 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "regional_lith_age_read_files.h"
 
-#include "global_defs.h"
+#include "regional_read_input_from_files.h"
 
-#include "cproto.h"
-
 void regional_lith_age_read_files(struct All_variables *E, int output)
 {
     regional_read_input_files_for_timesteps(E,2,output); /*2 (=action) is for lith_age*/

Deleted: mc/3D/CitcomS/branches/cxx/lib/Regional_obsolete.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_obsolete.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_obsolete.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,820 +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>
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-/*
-  This file contains functions that are no longer used in this version of
-  CitcomS. To reduce compilantion time and maintanance effort, these functions
-  are removed from its original location to here.
-*/
-
-
-
-/* ==========================================================  */
-/* from Parallel_related.c                                     */
-/* =========================================================== */
-
-void parallel_process_initilization(E,argc,argv)
-  struct All_variables *E;
-  int argc;
-  char **argv;
-  {
-
-  E->parallel.me = 0;
-  E->parallel.nproc = 1;
-  E->parallel.me_loc[1] = 0;
-  E->parallel.me_loc[2] = 0;
-  E->parallel.me_loc[3] = 0;
-
-  /*  MPI_Init(&argc,&argv); moved to main{} in Citcom.c, cpc 12/24/00 */
-  MPI_Comm_rank(E->parallel.world, &(E->parallel.me) );
-  MPI_Comm_size(E->parallel.world, &(E->parallel.nproc) );
-
-  return;
-  }
-
-
-/* ============================================
- get numerical grid coordinates for each relevant processor
- ============================================ */
-
-void parallel_domain_decomp2(E,GX)
-  struct All_variables *E;
-  float *GX[4];
-  {
-
-  return;
-  }
-
-
-void scatter_to_nlayer_id (E,AUi,AUo,lev)
-  struct All_variables *E;
-double **AUi,**AUo;
-int lev;
-{
-
-  int i,j,k,k1,m,node1,node,eqn1,eqn,d;
-
-  const int dims = E->mesh.nsd;
-
-  static double *SD;
-  static int been_here=0;
-  static int *processors,rootid,nproc,NOZ;
-
-  MPI_Status status;
-
-  if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"scatter_to_nlayer should not be called\n");
-    return;
-  }
-
-  if (been_here==0)   {
-    NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-
-    processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-
-    SD = (double *)malloc((E->lmesh.NEQ[lev])*sizeof(double));
-
-
-    rootid = E->parallel.me_sph*E->parallel.nprocz; /* which is the bottom cpu */
-    nproc = 0;
-    for (j=0;j<E->parallel.nprocz;j++) {
-      d = rootid + j;
-      processors[nproc] =  d;
-      nproc ++;
-    }
-
-    been_here++;
-  }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me==rootid)
-      for (d=0;d<E->parallel.nprocz;d++)  {
-
-        for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-          k1 = k + d*E->lmesh.ELZ[lev];
-          for (j=1;j<=E->lmesh.NOY[lev];j++)
-            for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-              node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-              node1= k1+ (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-              SD[dims*(node-1)] = AUi[m][dims*(node1-1)];
-              SD[dims*(node-1)+1] = AUi[m][dims*(node1-1)+1];
-              SD[dims*(node-1)+2] = AUi[m][dims*(node1-1)+2];
-	    }
-	}
-
-        if (processors[d]!=rootid)  {
-	  MPI_Send(SD,E->lmesh.NEQ[lev],MPI_DOUBLE,processors[d],rootid,E->parallel.world);
-	}
-        else
-	  for (i=0;i<=E->lmesh.NEQ[lev];i++)
-	    AUo[m][i] = SD[i];
-      }
-    else
-      MPI_Recv(AUo[m],E->lmesh.NEQ[lev],MPI_DOUBLE,rootid,rootid,E->parallel.world,&status);
-  }
-
-  return;
-}
-
-
-
-void gather_to_1layer_id (E,AUi,AUo,lev)
-  struct All_variables *E;
-double **AUi,**AUo;
-int lev;
-{
-
-  int i,j,k,k1,m,node1,node,eqn1,eqn,d;
-
-  const int dims = E->mesh.nsd;
-
-  MPI_Status status;
-
-  static double *RV;
-  static int been_here=0;
-  static int *processors,rootid,nproc,NOZ;
-
-  if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-  }
-
-  if (been_here==0)   {
-    NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-
-    processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-
-    RV = (double *)malloc((E->lmesh.NEQ[lev])*sizeof(double));
-
-
-    rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-    nproc = 0;
-    for (j=0;j<E->parallel.nprocz;j++) {
-      d = rootid + j;
-      processors[nproc] =  d;
-      nproc ++;
-    }
-
-    been_here++;
-  }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid)
-      MPI_Send(AUi[m],E->lmesh.NEQ[lev],MPI_DOUBLE,rootid,E->parallel.me,E->parallel.world);
-    else
-      for (d=0;d<E->parallel.nprocz;d++) {
-	if (processors[d]!=rootid)
-	  MPI_Recv(RV,E->lmesh.NEQ[lev],MPI_DOUBLE,processors[d],processors[d],E->parallel.world,&status);
-	else
-	  for (node=0;node<E->lmesh.NEQ[lev];node++)
-	    RV[node] = AUi[m][node];
-
-	for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-	  k1 = k + d*E->lmesh.ELZ[lev];
-	  for (j=1;j<=E->lmesh.NOY[lev];j++)
-	    for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-	      node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-	      node1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-
-	      AUo[m][dims*(node1-1)] = RV[dims*(node-1)];
-	      AUo[m][dims*(node1-1)+1] = RV[dims*(node-1)+1];
-	      AUo[m][dims*(node1-1)+2] = RV[dims*(node-1)+2];
-	    }
-	}
-      }
-  }
-
-  return;
-}
-
-
-void gather_to_1layer_node (E,AUi,AUo,lev)
-  struct All_variables *E;
-float **AUi,**AUo;
-int lev;
-{
-
-  int i,j,k,k1,m,node1,node,d;
-
-  MPI_Status status;
-
-  static float *RV;
-  static int been_here=0;
-  static int *processors,rootid,nproc,NOZ,NNO;
-
-  if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-  }
-
-  if (been_here==0)   {
-    NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz + 1;
-    NNO = NOZ*E->lmesh.NOX[lev]*E->lmesh.NOY[lev];
-
-    processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-    RV = (float *)malloc((E->lmesh.NNO[lev]+2)*sizeof(float));
-
-
-    rootid = E->parallel.me_sph*E->parallel.nprocz; /* which is the bottom cpu */
-    nproc = 0;
-    for (j=0;j<E->parallel.nprocz;j++) {
-      d = rootid + j;
-      processors[nproc] =  d;
-      nproc ++;
-    }
-
-    been_here++;
-  }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid) {
-      MPI_Send(AUi[m],E->lmesh.NNO[lev]+1,MPI_FLOAT,rootid,E->parallel.me,E->parallel.world);
-      for (node=1;node<=NNO;node++)
-	AUo[m][node] = 1.0;
-    }
-    else
-      for (d=0;d<E->parallel.nprocz;d++) {
-	if (processors[d]!=rootid)
-	  MPI_Recv(RV,E->lmesh.NNO[lev]+1,MPI_FLOAT,processors[d],processors[d],E->parallel.world,&status);
-	else
-	  for (node=1;node<=E->lmesh.NNO[lev];node++)
-	    RV[node] = AUi[m][node];
-
-	for (k=1;k<=E->lmesh.NOZ[lev];k++)   {
-	  k1 = k + d*E->lmesh.ELZ[lev];
-	  for (j=1;j<=E->lmesh.NOY[lev];j++)
-	    for (i=1;i<=E->lmesh.NOX[lev];i++)   {
-	      node = k + (i-1)*E->lmesh.NOZ[lev] + (j-1)*E->lmesh.NOZ[lev]*E->lmesh.NOX[lev];
-	      node1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.NOX[lev];
-	      AUo[m][node1] = RV[node];
-	    }
-	}
-      }
-  }
-
-  return;
-}
-
-
-void gather_to_1layer_ele (E,AUi,AUo,lev)
-  struct All_variables *E;
-float **AUi,**AUo;
-int lev;
-{
-
-  int i,j,k,k1,m,e,d,e1;
-
-  MPI_Status status;
-
-  static float *RV;
-  static int been_here=0;
-  static int *processors,rootid,nproc,NOZ,NNO;
-
-  if (E->parallel.nprocz==1)  {
-    if (E->parallel.me==0) fprintf(stderr,"gather_to_1layer should not be called\n");
-    return;
-  }
-
-  if (been_here==0)   {
-    NOZ = E->lmesh.ELZ[lev]*E->parallel.nprocz;
-    NNO = NOZ*E->lmesh.ELX[lev]*E->lmesh.ELY[lev];
-
-    processors = (int *)malloc((E->parallel.nprocz+2)*sizeof(int));
-    RV = (float *)malloc((E->lmesh.NEL[lev]+2)*sizeof(float));
-
-
-    rootid = E->parallel.me_sph*E->parallel.nprocz;    /* which is the bottom cpu */
-    nproc = 0;
-    for (j=0;j<E->parallel.nprocz;j++) {
-      d = rootid + j;
-      processors[nproc] =  d;
-      nproc ++;
-    }
-
-    been_here++;
-  }
-
-  for (m=1;m<=E->sphere.caps_per_proc;m++)   {
-    if (E->parallel.me!=rootid) {
-      MPI_Send(AUi[m],E->lmesh.NEL[lev]+1,MPI_FLOAT,rootid,E->parallel.me,E->parallel.world);
-      for (e=1;e<=NNO;e++)
-	AUo[m][e] = 1.0;
-    }
-    else
-      for (d=0;d<E->parallel.nprocz;d++) {
-	if (processors[d]!=rootid)
-	  MPI_Recv(RV,E->lmesh.NEL[lev]+1,MPI_FLOAT,processors[d],processors[d],E->parallel.world,&status);
-	else
-	  for (e=1;e<=E->lmesh.NEL[lev];e++)
-	    RV[e] = AUi[m][e];
-
-	for (k=1;k<=E->lmesh.ELZ[lev];k++)   {
-	  k1 = k + d*E->lmesh.ELZ[lev];
-	  for (j=1;j<=E->lmesh.ELY[lev];j++)
-	    for (i=1;i<=E->lmesh.ELX[lev];i++)   {
-	      e = k + (i-1)*E->lmesh.ELZ[lev] + (j-1)*E->lmesh.ELZ[lev]*E->lmesh.ELX[lev];
-	      e1 = k1 + (i-1)*NOZ + (j-1)*NOZ*E->lmesh.ELX[lev];
-	      AUo[m][e1] = RV[e];
-	    }
-	}
-      }
-  }
-
-  return;
-}
-
-
-void gather_TG_to_me0(E,TG)
-  struct All_variables *E;
-float *TG;
-{
-
-  int i,j,nsl,idb,to_everyone,from_proc,mst,me;
-
-  static float *RG[20];
-  static int been_here=0;
-  const float e_16=1.e-16;
-
-  MPI_Status status[100];
-  MPI_Status status1;
-  MPI_Request request[100];
-
-  if (E->parallel.nprocxy==1)   return;
-
-  nsl = E->sphere.nsf+1;
-  me = E->parallel.me;
-
-  if (been_here==0)   {
-    been_here++;
-    for (i=1;i<E->parallel.nprocxy;i++)
-      RG[i] = ( float *)malloc((E->sphere.nsf+1)*sizeof(float));
-  }
-
-  idb=0;
-  for (i=1;i<=E->parallel.nprocxy;i++)  {
-    to_everyone = E->parallel.nprocz*(i-1) + E->parallel.me_loc[3];
-
-    if (me!=to_everyone)    {  /* send TG */
-      idb++;
-      mst = me;
-      MPI_Isend(TG,nsl,MPI_FLOAT,to_everyone,mst,E->parallel.world,&request[idb-1]);
-    }
-  }
-
-  /* parallel_process_sync(E); */
-
-  idb=0;
-  for (i=1;i<=E->parallel.nprocxy;i++)  {
-    from_proc = E->parallel.nprocz*(i-1) + E->parallel.me_loc[3];
-    if (me!=from_proc)   {    /* me==0 receive all TG and add them up */
-      mst = from_proc;
-      idb++;
-      MPI_Irecv(RG[idb],nsl,MPI_FLOAT,from_proc,mst,E->parallel.world,&request[idb-1]);
-    }
-  }
-
-  MPI_Waitall(idb,request,status);
-
-  for (i=1;i<E->parallel.nprocxy;i++)
-    for (j=1;j<=E->sphere.nsf; j++)  {
-      if (fabs(TG[j]) < e_16) TG[j] += RG[i][j];
-    }
-
-  /* parallel_process_sync(E); */
-
-  return;
-}
-
-
-
-/* ==========================================================  */
-/* from Boundary_conditions.c                                  */
-/* =========================================================== */
-
-
-void renew_top_velocity_boundary(E)
-  struct All_variables *E;
-{
-  int i,k,lev;
-  int nox,noz,noy,nodel;
-  float fxx10,fxx20,fyy1,fyy2,fxx0,fxx,fyy;
-  float vxx1,vxx2,vxx,vvo,vvc;
-  float fslope,vslope;
-  static float fxx1,fxx2;
-
-  FILE *fp;
-  char output_file[255];
-  nox=E->lmesh.nox;
-  noz=E->lmesh.noz;
-  noy=E->lmesh.noy;
-  lev=E->mesh.levmax;
-
-  fxx10=1.0;
-  fyy1=0.76;
-  fxx20=1.0;   /* (fxx1,fyy1), (fxx2,fyy2) the initial coordinates of the trench position */
-  fyy2=0.81;
-
-  vxx1=-2.*2.018e0;
-
-  vvo=6.*2.018e0;
-  vvc=-2.*2.018e0;     /* vvo--oceanic plate velocity; vvc--continental plate velocity      */
-
-  if(E->advection.timesteps>1)  {
-    fxx1=fxx1+E->advection.timestep*vxx1;
-    fxx2=fxx2+E->advection.timestep*vxx1;
-  }
-
-  else  {
-    fxx1=fxx10;
-    fxx2=fxx20;
-  }
-
-  fprintf(stderr,"%f %f\n",fxx1,fxx2);
-
-  if (E->parallel.me_loc[3] == E->parallel.nprocz-1 ) {
-    for(k=1;k<=noy;k++)
-      for(i=1;i<=nox;i++)   {
-	nodel = (k-1)*nox*noz + (i-1)*noz+noz;
-	fyy=E->SX[lev][1][1][nodel];
-	if (fyy < fyy1 || fyy >fyy2 )   {
-	  E->sphere.cap[1].VB[1][nodel]=0.0;
-	  E->sphere.cap[1].VB[2][nodel]=-vvc;
-	  E->sphere.cap[1].VB[3][nodel]=0.0;
-	}    /* the region outside of the domain bounded by the trench length  */
-	else if (fyy>=fyy1 && fyy <=fyy2)  {
-	  if (E->SX[lev][1][2][nodel]>=0.00 && E->SX[lev][1][2][nodel]<= fxx1) {
-	    E->sphere.cap[1].VB[1][nodel]=0.0;
-	    E->sphere.cap[1].VB[2][nodel]=vvo;
-	    E->sphere.cap[1].VB[3][nodel]=0.0;
-	  }
-	  else if ( E->SX[lev][1][2][nodel]>fxx1 && E->SX[lev][1][2][nodel]<fxx2) {
-	    E->sphere.cap[1].VB[1][nodel]=0.0;
-	    E->sphere.cap[1].VB[2][nodel]=vxx1;
-	    E->sphere.cap[1].VB[3][nodel]=0.0;
-	  }
-	  else if ( E->SX[lev][1][2][nodel]>=fxx2) {
-	    E->sphere.cap[1].VB[1][nodel]=0.0;
-	    E->sphere.cap[1].VB[2][nodel]=vvc;
-	    E->sphere.cap[1].VB[3][nodel]=0.0;
-	  }
-	}   /* end of else if (fyy>=fyy1 && fyy <=fyy2)  */
-
-      }  /* end if for(i=1;i<nox;i++)  */
-  }    /* end of E->parallel.me_loc[3]   */
-
-  return;
-}
-
-
-
-/* ==========================================================  */
-/* from Output.c                                               */
-/* =========================================================== */
-
-void output_stress(E,file_number,SXX,SYY,SZZ,SXY,SXZ,SZY)
-  struct All_variables *E;
-int file_number;
-float *SXX,*SYY,*SZZ,*SXY,*SXZ,*SZY;
-{
-  int i,j,k,ii,m,fd,size2;
-  int nox,noz,noy;
-  char output_file[255];
-
-  size2= (E->lmesh.nno+1)*sizeof(float);
-
-  sprintf(output_file,"%s.%05d.SZZ",E->control.data_file,file_number);
-  fd=open(output_file,O_RDWR | O_CREAT, 0644);
-  write(fd,SZZ,size2);
-  close (fd);
-
-  return;
-}
-
-
-void print_field_spectral_regular(E,TG,sphc,sphs,proc_loc,filen)
-  struct All_variables *E;
-float *TG,*sphc,*sphs;
-int proc_loc;
-char * filen;
-{
-  FILE *fp,*fp1;
-  char output_file[255];
-  int i,node,j,ll,mm;
-  float minx,maxx,t,f,rad;
-  rad = 180.0/M_PI;
-
-  maxx=-1.e26;
-  minx=1.e26;
-  if (E->parallel.me==proc_loc)  {
-
-    sprintf(output_file,"%s.%s_intp",E->control.data_file,filen);
-    fp=fopen(output_file,"w");
-    if (fp == NULL) {
-      fprintf(E->fp,"(Output.c #7) Cannot open %s\n",output_file);
-      exit(8);
-    }
-    for (i=E->sphere.nox;i>=1;i--)
-      for (j=1;j<=E->sphere.noy;j++)  {
-        node = i + (j-1)*E->sphere.nox;
-        t = 90-E->sphere.sx[1][node]*rad;
-        f = E->sphere.sx[2][node]*rad;
-        fprintf (fp,"%.3e %.3e %.4e\n",f,t,TG[node]);
-        if(TG[node]>maxx)maxx=TG[node];
-        if(TG[node]<minx)minx=TG[node];
-      }
-    fprintf(stderr,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-    fprintf(E->fp,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-    fclose(fp);
-
-    sprintf(output_file,"%s.%s_sharm",E->control.data_file,filen);
-    fp1=fopen(output_file,"w");
-    if (fp1 == NULL) {
-      fprintf(E->fp,"(Output.c #8) Cannot open %s\n",output_file);
-      exit(8);
-    }
-    fprintf(fp1,"lmaxx=%.4e lminx=%.4e for %s\n",maxx,minx,filen);
-    fprintf(fp1," ll   mm     cos      sin \n");
-    for (ll=0;ll<=E->output.llmax;ll++)
-      for(mm=0;mm<=ll;mm++)  {
-        i = E->sphere.hindex[ll][mm];
-        fprintf(fp1,"%3d %3d %.4e %.4e \n",ll,mm,sphc[i],sphs[i]);
-      }
-
-    fclose(fp1);
-  }
-
-
-  return;
-}
-
-
-
-void output_velo_related(E,file_number)
-  struct All_variables *E;
-  int file_number;
-{
-  int el,els,i,j,k,m,node,fd;
-  int s,nox,noz,noy,size1,size2,size3;
-  char output_file[255];
-  FILE *fp1,*fp2;
-
-
-  output_velo(E);
-  output_visc(E);
-
-
-  if (E->parallel.me_loc[3]==E->parallel.nprocz-1)      {
-    sprintf(output_file,"%s.surf.%d.%d",E->control.data_file,E->parallel.me,cycles);
-    fp2 = output_open(output_file, "w");
-
-    for(j=1;j<=E->sphere.caps_per_proc;j++)  {
-      fprintf(fp2,"%3d %7d\n",j,E->lmesh.nsf);
-      for(i=1;i<=E->lmesh.nsf;i++)   {
-	s = i*E->lmesh.noz;
-        fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->slice.tpg[j][i],E->slice.shflux[j][i],E->sphere.cap[j].V[1][s],E->sphere.cap[j].V[2][s]);
-	}
-      }
-    fclose(fp2);
-
-    }
-
-  if (E->parallel.me_loc[3]==0)      {
-    sprintf(output_file,"%s.botm.%d.%d",E->control.data_file,E->parallel.me,cycles);
-    fp2 = output_open(output_file, "w");
-
-    for(j=1;j<=E->sphere.caps_per_proc;j++)  {
-      fprintf(fp2,"%3d %7d\n",j,E->lmesh.nsf);
-      for(i=1;i<=E->lmesh.nsf;i++)  {
-	s = (i-1)*E->lmesh.noz + 1;
-        fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->slice.tpgb[j][i],E->slice.bhflux[j][i],E->sphere.cap[j].V[1][s],E->sphere.cap[j].V[2][s]);
-	}
-      }
-    fclose(fp2);
-    }
-
-  /* remove horizontal average output   by Tan2 Mar. 1 2002  */
-/*    if (E->parallel.me<E->parallel.nprocz)  { */
-/*      sprintf(output_file,"%s.ave_r.%d.%d",E->control.data_file,E->parallel.me,cycles); */
-/*      fp2 = output_open(output_file, "w"); */
-/*  	if (fp2 == NULL) { */
-/*            fprintf(E->fp,"(Output.c #6) Cannot open %s\n",output_file); */
-/*            exit(8); */
-/*  	} */
-/*      for(j=1;j<=E->lmesh.noz;j++)  { */
-/*          fprintf(fp2,"%.4e %.4e %.4e %.4e\n",E->sx[1][3][j],E->Have.T[j],E->Have.V[1][j],E->Have.V[2][j]); */
-/*  	} */
-/*      fclose(fp2); */
-/*      } */
-
-  return;
-  }
-
-
-
-void output_temp(E,file_number)
-  struct All_variables *E;
-  int file_number;
-{
-  int m,nno,i,j,fd;
-  char output_file[255];
-
-  return;
-}
-
-
-void output_visc_prepare(struct All_variables *E, float **VE)
-{
-  void get_ele_visc();
-  void visc_from_ele_to_gint();
-  void visc_from_gint_to_nodes();
-
-  float *EV, *VN[NCS];
-  const int lev = E->mesh.levmax;
-  const int nsd = E->mesh.nsd;
-  const int vpts = vpoints[nsd];
-  int i, m;
-
-
-  // Here is a bug in the original code. EV is not allocated for each
-  // E->sphere.caps_per_proc. Later, when elemental viscosity is written
-  // to it (in get_ele_visc()), viscosity in high cap number will overwrite
-  // that in a lower cap number.
-  //
-  // Since current CitcomS only support 1 cap per processor, this bug won't
-  // manifest itself. So, I will leave it here.
-  // by Tan2 5/22/2003
-  int size2 = (E->lmesh.nel+1)*sizeof(float);
-  EV = (float *) malloc (size2);
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++) {
-    VN[m]=(float *)malloc((1+E->lmesh.nel*vpts)*sizeof(float));
-  }
-
-  get_ele_visc(E,EV,1);
-
-  for(i=1;i<=E->lmesh.nel;i++)
-    VE[1][i]=EV[i];
-
-  visc_from_ele_to_gint(E, VE, VN, lev);
-  visc_from_gint_to_nodes(E, VN, VE, lev);
-
-  free((void *) EV);
-  for(m=1;m<=E->sphere.caps_per_proc;m++) {
-    free((void *) VN[m]);
-  }
-
-  return;
-}
-
-
-void output_visc(struct All_variables *E, int cycles)
-{
-  int i, j, m;
-  char output_file[255];
-  FILE *fp1;
-  float *VE[NCS];
-
-  sprintf(output_file,"%s.visc.%d.%d",E->control.data_file,E->parallel.me,cycles);
-  fp1 = output_open(output_file, "w");
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++) {
-    VE[m]=(float *)malloc((1+E->lmesh.nno)*sizeof(float));
-  }
-
-  output_visc_prepare(E, VE);
-
-  for(j=1;j<=E->sphere.caps_per_proc;j++) {
-    fprintf(fp1,"%3d %7d\n",j,E->lmesh.nno);
-    for(i=1;i<=E->lmesh.nno;i++)
-      fprintf(fp1,"%.3e\n",VE[1][i]);
-  }
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++) {
-    free((void*) VE[m]);
-  }
-
-  fclose(fp1);
-
-  return;
-}
-
-/* ==========================================================  */
-/* from Process_buoyancy.c                                     */
-/* =========================================================== */
-
-
-void process_temp_field(E,ii)
- struct All_variables *E;
-    int ii;
-{
-    void heat_flux();
-    void output_temp();
-    void process_output_field();
-    int record_h;
-
-/* This form prevented running for timesteps less than 10!!
-    record_h = E->control.record_every/10;  */
-    record_h = E->control.record_every;
-
-/* changed to allow 0th time step to be outputted CPC 6/18/00 */
-/*    if ( ((ii % record_h) == 0) || E->control.DIRECTII)    { */
-
-    if ( (ii == 0) || ((ii % record_h) == 0) || E->control.DIRECTII)    {
-      heat_flux(E);
-      parallel_process_sync(E);
-/*      output_temp(E,ii);  */
-    }
-
-/*    if ( ((ii % E->control.record_every) == 0) || E->control.DIRECTII)  { */
-    if ( ((ii == 0) || ((ii % E->control.record_every) == 0))
-		|| E->control.DIRECTII)     {
-       process_output_field(E,ii);
-    }
-
-    return;
-}
-
-
-/* ==========================================================  */
-/* from Process_velocity.c                                     */
-/* =========================================================== */
-
-void process_new_velocity(E,ii)
-    struct All_variables *E;
-    int ii;
-{
-    void output_velo_related();
-    void get_STD_topo();
-    void get_CBF_topo();
-
-    int m,i,it;
-
-
-    if ( (ii == 0) || ((ii % E->control.record_every) == 0)
-		|| E->control.DIRECTII)     {
-      get_STD_topo(E,E->slice.tpg,E->slice.tpgb,E->slice.divg,E->slice.vort,ii);
-      parallel_process_sync(E);
-      output_velo_related(E,ii);         /* also topo */
-    }
-
-    return;
-}
-
-
-void get_surface_velo(E, SV,m)
-  struct All_variables *E;
-  float *SV;
-  int m;
-  {
-
-  int el,els,i,node,lev;
-  char output_file[255];
-  FILE *fp;
-
-  const int dims=E->mesh.nsd;
-  const int ends=enodes[dims];
-  const int nno=E->lmesh.nno;
-
-  lev = E->mesh.levmax;
-
-  for(m=1;m<=E->sphere.caps_per_proc;m++)
-    for (node=1;node<=nno;node++)
-      if (node%E->lmesh.noz==0)   {
-        i = node/E->lmesh.noz;
-        SV[(i-1)*2+1] = E->sphere.cap[m].V[1][node];
-        SV[(i-1)*2+2] = E->sphere.cap[m].V[2][node];
-      }
-
-  return;
-  }
-
-
-
-/* ==========================================================  */
-/* from                                                        */
-/* =========================================================== */
-

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_parallel_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_parallel_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_parallel_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,9 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "regional_parallel_related.h"
+
 #include <mpi.h>
 #include <math.h>
 
@@ -32,7 +35,7 @@
 #include "global_defs.h"
 #include "sphere_communication.h"
 
-#include "parallel_related.h"
+#include "parallel_util.h"
 
 
 static void set_horizontal_communicator(struct All_variables*);

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_read_input_from_files.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_read_input_from_files.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_read_input_from_files.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,9 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "regional_read_input_from_files.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
@@ -33,8 +36,11 @@
 #include "ggrd_handling.h"
 #endif
 
-#include "cproto.h"
+#include "construct_arrays.h"
+#include "pan_problem_misc_functions.h"
+#include "problem_related.h"
 
+
 /*=======================================================================
   Calculate ages (MY) for opening input files -> material, ages, velocities
   Open these files, read in results, and average if necessary

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_solver.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_solver.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_solver.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,39 +26,18 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "regional_solver.h"
 
 #include "global_defs.h"
 
+#include "regional_boundary_conditions.h"
+#include "regional_geometry_cartesian.h"
 
-/* Boundary_conditions.c */
-void regional_velocity_boundary_conditions(struct All_variables *);
-void regional_temperature_boundary_conditions(struct All_variables *);
+#include "regional_lith_age_read_files.h"
+#include "regional_parallel_related.h"
+#include "regional_read_input_from_files.h"
+#include "regional_version_dependent.h"
 
-/* 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_node_locations(struct All_variables *);
-void regional_construct_boundary(struct All_variables *);
-
-
 void regional_solver_init(struct All_variables *E)
 {
     /* Boundary_conditions.c */

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_sphere_related.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_sphere_related.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_sphere_related.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -27,6 +27,8 @@
  */
 /* Functions relating to the building and use of mesh locations ... */
 
+#include "regional_sphere_related.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_tracer_advection.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_tracer_advection.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_tracer_advection.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,8 +26,8 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include "regional_tracer_advection.h"
 
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -42,9 +42,10 @@
 #include "element_definitions.h"
 #include "global_defs.h"
 #include "composition_related.h"
-#include "parallel_related.h"
 
-#include "cproto.h"
+#include "nodal_mesh.h"
+#include "parallel_util.h"
+#include "tracer_setup.h"
 
 
 static void write_trace_instructions(struct All_variables *E);
@@ -55,9 +56,11 @@
 static void put_found_tracers(struct All_variables *E,
                               int recv_size, double *recv,
                               int j);
-int isearch_neighbors(double *array, int nsize,
-                      double a, int hint);
-int isearch_all(double *array, int nsize, double a);
+static int isearch_neighbors(double *array, int nsize,
+                             double a, int hint);
+static int isearch_all(double *array, int nsize, double a);
+static void regional_get_shape_functions(struct All_variables *E, double shp[9], int nelem, double theta, double phi, double rad);
+static double regional_interpolate_data(struct All_variables *E, double shp[9], double data[9]);
 
 
 void regional_tracer_setup(struct All_variables *E)
@@ -346,7 +349,7 @@
 /* return an index i, such that array[i] <= a < array[i+1] */
 /* return -1 if not found.                                 */
 /* Note that -1 is returned if a == array[nsize-1]         */
-int isearch_all(double *array, int nsize, double a)
+static int isearch_all(double *array, int nsize, double a)
 {
     int high, i, low;
 
@@ -366,8 +369,8 @@
 
 
 /* Similar the isearch_all(), but with a hint */
-int isearch_neighbors(double *array, int nsize,
-                      double a, int hint)
+static int isearch_neighbors(double *array, int nsize,
+                             double a, int hint)
 {
     /* search the nearest neighbors only */
     const int number_of_neighbors = 3;
@@ -421,9 +424,9 @@
 }
 
 
-void regional_get_shape_functions(struct All_variables *E,
-                                  double shp[9], int nelem,
-                                  double theta, double phi, double rad)
+static void regional_get_shape_functions(struct All_variables *E,
+                                         double shp[9], int nelem,
+                                         double theta, double phi, double rad)
 {
     int e, i, j, k;
     int elx, ely, elz;
@@ -495,8 +498,8 @@
 }
 
 
-double regional_interpolate_data(struct All_variables *E,
-                                 double shp[9], double data[9])
+static double regional_interpolate_data(struct All_variables *E,
+                                        double shp[9], double data[9])
 {
     int n;
     double result = 0;

Modified: mc/3D/CitcomS/branches/cxx/lib/Regional_version_dependent.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Regional_version_dependent.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Regional_version_dependent.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,22 +25,20 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "regional_version_dependent.h"
+
 #include <math.h>
 
 #include "global_defs.h"
-#include "parallel_related.h"
 
-#include "cproto.h"
+#include "ggrd_handling.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "regional_sphere_related.h"
+#include "sphere_util.h"
 
 
-void get_r_spacing_fine(double *,struct All_variables *);
-void get_r_spacing_at_levels(double *,struct All_variables *);
- 
-#ifdef USE_GGRD
-void ggrd_reg_temp_init(struct All_variables *);
-#endif
-
-
 /* =================================================
    Standard node positions including mesh refinement
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Shape_functions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Shape_functions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Shape_functions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -33,11 +33,16 @@
     and the element-data header file : element_definitions.h  but it should not be
     necessary to change the main calculation/setup/solving machinery.		 */
 
+#include "shape_functions.h"
+
 #include <math.h>
 #include "element_definitions.h"				
 #include "global_defs.h"
 
-#include "cproto.h"
+
+static double lpoly(int p, double y);
+static double lpolydash(int p, double y);
+
  
 /*  =======================================================
     Function creating shape_fn data in form of a structure
@@ -169,10 +174,10 @@
       }	 
 
 
-  return; }
+  return;
+}	
 
-		
-double lpoly(
+static double lpoly(
     int p, /*   selects lagrange polynomial , 1d: node p */
     double y /*   coordinate in given direction to evaluate poly */
     )
@@ -193,8 +198,8 @@
 
   return(value);
 }
-	
-double lpolydash(
+
+static double lpolydash(
     int p,
     double y
     )

Modified: mc/3D/CitcomS/branches/cxx/lib/Size_does_matter.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Size_does_matter.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Size_does_matter.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,17 +25,30 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "size_does_matter.h"
+
 #include <math.h>
 #include <sys/types.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "general_matrix_functions.h"
+#include "pan_problem_misc_functions.h"
 
 #ifdef ALLOW_ELLIPTICAL
 double theta_g(double , struct All_variables *);
 #endif
 
+static void get_side_x_cart(struct All_variables *E, double xx[4][5], int el, int side, int m);
+static void get_global_side_1d_shape_fn(struct All_variables *E, int el,
+                                        struct Shape_function1 *GM,
+                                        struct Shape_function1_dx *GMx,
+                                        struct Shape_function_side_dA *dGamma,
+                                        int side, int m);
+static void construct_c3x3matrix(struct All_variables *E);
+
+
 void twiddle_thumbs(struct All_variables *yawn)
 
 { /* Do nothing, just sit back and relax.
@@ -254,8 +267,8 @@
 }
 
 
-void get_side_x_cart(struct All_variables *E, double xx[4][5],
-		     int el, int side, int m)
+static void get_side_x_cart(struct All_variables *E, double xx[4][5],
+                            int el, int side, int m)
 {
   double to,fo,dxdy[4][4];
   int i, node, s;
@@ -515,7 +528,7 @@
 /*   ======================================================================
      For calculating pressure boundary term --- Choi, 11/13/02
      ======================================================================  */
-void get_global_side_1d_shape_fn(
+static void get_global_side_1d_shape_fn(
     struct All_variables *E,
     int el,
     struct Shape_function1 *GM,
@@ -837,7 +850,7 @@
 
 
 /* ======================================= */
-void construct_c3x3matrix(struct All_variables *E)
+static void construct_c3x3matrix(struct All_variables *E)
 {
   int m,a,i,j,k,d,es,el,nel_surface,lev,lnode;
   double x[4],u[4][4],ux[3][4][4],ua[4][4];

Modified: mc/3D/CitcomS/branches/cxx/lib/Solver_conj_grad.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Solver_conj_grad.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Solver_conj_grad.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,11 +25,20 @@
  * 
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "solver_conj_grad.h"
+
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "element_calculations.h"
+#include "stokes_flow_incomp.h"
 
+
+static void cg_allocate_vars(struct All_variables *E);
+
+
 void set_cg_defaults(struct All_variables *E)
 {
   E->build_forcing_term =   assemble_forces_iterative;
@@ -40,7 +49,7 @@
   return;
 }
 
-void cg_allocate_vars(struct All_variables *E)
+static void cg_allocate_vars(struct All_variables *E)
 { 
   /* Nothing required ONLY by conj-grad stuff  */
  /* printf("here here\n"); */

Modified: mc/3D/CitcomS/branches/cxx/lib/Solver_multigrid.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Solver_multigrid.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Solver_multigrid.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,13 +25,30 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "solver_multigrid.h"
+
 #include "element_definitions.h"
 #include "global_defs.h"
 #include <math.h>
 
-#include "cproto.h"
+#include "nodal_mesh.h"
+#include "solver_conj_grad.h"
+#include "stokes_flow_incomp.h"
 
 
+static void mg_allocate_vars(struct All_variables *E);
+static void inject_scalar(struct All_variables *E, int start_lev, float **AU, float **AD);
+static void inject_vector(struct All_variables *E, int start_lev, double **AU, double **AD);
+static void un_inject_vector(struct All_variables *E, int start_lev, double **AD, double **AU);
+static void inject_scalar_e(struct All_variables *E, int start_lev, float **AU, float **AD);
+static void project_scalar_e(struct All_variables *E, int start_lev, float **AU, float **AD);
+static void project_scalar(struct All_variables *E, int start_lev, float **AU, float **AD);
+static void from_xyz_to_rtf(struct All_variables *E, int level, double **xyz, double **rtf);
+static void from_rtf_to_xyz(struct All_variables *E, int level, double **rtf, double **xyz);
+static void fill_in_gaps(struct All_variables *E, double **temp, int level);
+
+
 void set_mg_defaults(struct All_variables *E)
 {
   E->build_forcing_term =   assemble_forces_iterative;
@@ -54,7 +71,7 @@
    just dropping values at shared grid points.
    ===================================================== */
 
-void inject_scalar(
+static void inject_scalar(
     struct All_variables *E,
     int start_lev,
     float **AU, float **AD  /* data on upper/lower mesh  */
@@ -84,7 +101,7 @@
     return;
 }
 
-void inject_vector(
+static void inject_vector(
     struct All_variables *E,
     int start_lev,
     double **AU, double **AD /* data on upper/lower mesh  */
@@ -123,7 +140,7 @@
    just dropping values at shared grid points.
    ===================================================== */
 
-void un_inject_vector(
+static void un_inject_vector(
     struct All_variables *E,
     int start_lev,
     double **AD, double **AU  /* data on upper/lower mesh  */
@@ -276,7 +293,7 @@
 }
 
 /* ==================================================== */
-void inject_scalar_e(
+static void inject_scalar_e(
     struct All_variables *E,
     int start_lev,
     float **AU, float **AD /* data on upper/lower mesh  */
@@ -309,7 +326,7 @@
 }
 
 /* ==================================================== */
-void project_scalar_e(
+static void project_scalar_e(
     struct All_variables *E,
     int start_lev,
     float **AU, float **AD /* data on upper/lower mesh  */
@@ -347,7 +364,7 @@
 }
 
 /* ==================================================== */
-void project_scalar(
+static void project_scalar(
     struct All_variables *E,
     int start_lev,
     float **AU, float **AD /* data on upper/lower mesh  */
@@ -473,7 +490,7 @@
  }
 
 /* ================================================= */
- void from_xyz_to_rtf(
+static void from_xyz_to_rtf(
      struct All_variables *E,
      int level,
      double **xyz, double **rtf
@@ -506,7 +523,7 @@
  }
 
 /* ================================================= */
- void from_rtf_to_xyz(
+static void from_rtf_to_xyz(
      struct All_variables *E,
      int level,
      double **rtf, double **xyz
@@ -540,7 +557,7 @@
  }
 
  /* ========================================================== */
- void fill_in_gaps(
+static void fill_in_gaps(
      struct All_variables *E,
      double **temp,
      int level

Modified: mc/3D/CitcomS/branches/cxx/lib/Sphere_harmonics.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Sphere_harmonics.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Sphere_harmonics.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,5 +1,6 @@
 /* Functions relating to the building and use of mesh locations ... */
 
+#include "sphere_harmonics.h"
 
 #include <math.h>
 #include <sys/types.h>
@@ -7,10 +8,13 @@
 #include "global_defs.h"
 #include <stdlib.h>
 
-#include "cproto.h"
+#include "global_operations.h"
 
+
 static void compute_sphereh_table(struct All_variables *);
+static void debug_sphere_expansion(struct All_variables *E);
 
+
 /*   ======================================================================
      ======================================================================  */
 
@@ -146,7 +150,7 @@
 }
 
 
-void debug_sphere_expansion(struct All_variables *E)
+static void debug_sphere_expansion(struct All_variables *E)
 {
     /* expand temperature field (which should be a sph. harm. load)
      * and output the expansion coeff. to stderr

Modified: mc/3D/CitcomS/branches/cxx/lib/Sphere_util.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Sphere_util.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Sphere_util.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -28,10 +28,12 @@
 
 /* Common functions relating to the building and use of mesh locations ... */
 
+#include "sphere_util.h"
+
 #include <math.h>
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "pan_problem_misc_functions.h"
 
 /* =================================================
   this routine evenly divides the arc between points

Modified: mc/3D/CitcomS/branches/cxx/lib/Stokes_flow_Incomp.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Stokes_flow_Incomp.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Stokes_flow_Incomp.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,6 +29,8 @@
 
 /*   Functions which solve for the velocity and pressure fields using Uzawa-type iteration loop.  */
 
+#include "stokes_flow_incomp.h"
+
 #include <math.h>
 #include <string.h>
 #include <sys/types.h>
@@ -36,9 +38,14 @@
 #include "global_defs.h"
 #include <stdlib.h>
 
-#include "cproto.h"
+#include "bc_util.h"
+#include "element_calculations.h"
+#include "general_matrix_functions.h"
+#include "global_operations.h"
+#include "nodal_mesh.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
 
-void myerror(struct All_variables *,char *);
 
 static void solve_Ahat_p_fhat(struct All_variables *E,
                               double **V, double **P, double **F,

Modified: mc/3D/CitcomS/branches/cxx/lib/Topo_gravity.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Topo_gravity.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Topo_gravity.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,33 +25,27 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#include "topo_gravity.h"
+
 #include <stdio.h>
 #include <math.h>
 #include "element_definitions.h"
 #include "global_defs.h"
 
-#include "cproto.h"
+#include "element_calculations.h"
+#include "full_parallel_related.h"
+#include "general_matrix_functions.h"
+#include "global_operations.h"
+#include "nodal_mesh.h"
+#include "regional_parallel_related.h"
+#include "size_does_matter.h"
+#include "sphere_harmonics.h"
 
-void myerror(char *,struct All_variables *);
-void sphere_expansion(struct All_variables *, float **, float *, float *);
-void sphere_expansion();
-void sum_across_depth_sph1(struct All_variables *, float *, float *);
-void broadcast_vertical(struct All_variables *, float *, float *, int);
-long double lg_pow(long double, int);
-void allocate_STD_mem(struct All_variables *E,
-                      float** , float** , float** ,
-                      float** , float** , float** ,
-                      float** , float** );
-void free_STD_mem(struct All_variables *E,
-                  float** , float** , float** ,
-                  float** , float** , float** ,
-                  float** , float** );
-void compute_nodal_stress(struct All_variables *,
-                          float** , float** , float** ,
-                          float** , float** , float** ,
-                          float** , float** );
-void stress_conform_bcs(struct All_variables *);
 
+static void stress_conform_bcs(struct All_variables *E);
+
+
 /* 
 
 compute the full stress tensor and the dynamic topo
@@ -397,7 +391,7 @@
 
 
 
-void stress_conform_bcs(struct All_variables *E)
+static void stress_conform_bcs(struct All_variables *E)
 {
   int m, i, j, k, n, d;
   const unsigned sbc_flag[4] = {0, SBX, SBY, SBZ};

Modified: mc/3D/CitcomS/branches/cxx/lib/Tracer_setup.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Tracer_setup.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Tracer_setup.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -39,18 +39,23 @@
       merged the two versions of tracer codes together.
 */
 
+#include "tracer_setup.h"
+
 #include <math.h>
 #include <string.h>
 #include "global_defs.h"
 #include "parsing.h"
-#include "parallel_related.h"
 #include "composition_related.h"
 
 #ifdef USE_GGRD
 #include "ggrd_handling.h"
 #endif
 
-#include "cproto.h"
+#include "full_tracer_advection.h"
+#include "instructions.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "regional_tracer_advection.h"
 
 
 #ifdef USE_GZDIR
@@ -58,20 +63,6 @@
 void gzip_file(char *);
 #endif
 
-int icheck_that_processor_shell(struct All_variables *E,
-                                       int j, int nprocessor, double rad);
-void expand_later_array(struct All_variables *E, int j);
-void expand_tracer_arrays(struct All_variables *E, int j);
-void tracer_post_processing(struct All_variables *E);
-void allocate_tracer_arrays(struct All_variables *E,
-                            int j, int number_of_tracers);
-void count_tracers_of_flavors(struct All_variables *E);
-
-int full_icheck_cap(struct All_variables *E, int icap,
-                    double x, double y, double z, double rad);
-int regional_icheck_cap(struct All_variables *E, int icap,
-                        double x, double y, double z, double rad);
-
 static void find_tracers(struct All_variables *E);
 static void predict_tracers(struct All_variables *E);
 static void correct_tracers(struct All_variables *E);
@@ -86,18 +77,9 @@
 static void reduce_tracer_arrays(struct All_variables *E);
 static void put_away_later(struct All_variables *E, int j, int it);
 static void eject_tracer(struct All_variables *E, int j, int it);
-int read_double_vector(FILE *, int , double *);
-void cart_to_sphere(struct All_variables *,
-                    double , double , double ,
-                    double *, double *, double *);
-void sphere_to_cart(struct All_variables *,
-                    double , double , double ,
-                    double *, double *, double *);
-int icheck_processor_shell(struct All_variables *,
-                           int , double );
+static void tracer_post_processing(struct All_variables *E);
 
 
-
 void tracer_input(struct All_variables *E)
 {
     char message[100];
@@ -258,7 +240,7 @@
 
 /********* TRACER POST PROCESSING ****************************************/
 
-void tracer_post_processing(struct All_variables *E)
+static void tracer_post_processing(struct All_variables *E)
 {
     int i;
 

Modified: mc/3D/CitcomS/branches/cxx/lib/Viscosity_structures.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/Viscosity_structures.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/Viscosity_structures.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,6 +29,7 @@
    as a function of the run, as an initial condition or as specified from
    a previous file */
 
+#include "viscosity_structures.h"
 
 #include <math.h>
 #include <string.h>
@@ -37,18 +38,25 @@
 #include "global_defs.h"
 #include "parsing.h"
 
-#include "cproto.h"
+#include "element_calculations.h"
+#include "nodal_mesh.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "size_does_matter.h"
 
 
-void myerror(struct All_variables *,char *);
-
 static void apply_low_visc_wedge_channel(struct All_variables *E, float **evisc);
 static void low_viscosity_channel_factor(struct All_variables *E, float *F);
 static void low_viscosity_wedge_factor(struct All_variables *E, float *F);
-void parallel_process_termination();
+static void viscosity_system_input(struct All_variables *E);
+static void visc_from_mat(struct All_variables *E, float **EEta);
+static void visc_from_T(struct All_variables *E, float **EEta, int propogate);
+static void visc_from_S(struct All_variables *E, float **EEta, int propogate);
+static void visc_from_P(struct All_variables *E, float **EEta);
+static void visc_from_C(struct All_variables *E, float **EEta);
 
 
-void viscosity_system_input(struct All_variables *E)
+static void viscosity_system_input(struct All_variables *E)
 {
     int m=E->parallel.me;
     int i;
@@ -252,7 +260,7 @@
 }
 
 
-void visc_from_mat(
+static void visc_from_mat(
     struct All_variables *E,
     float **EEta
     )
@@ -268,7 +276,7 @@
     return;
 }
 
-void visc_from_T(
+static void visc_from_T(
     struct All_variables *E,
     float **EEta,
     int propogate
@@ -632,7 +640,7 @@
 }
 
 
-void visc_from_S(
+static void visc_from_S(
     struct All_variables *E,
     float **EEta,
     int propogate
@@ -678,7 +686,7 @@
     return;
 }
 
-void visc_from_P(     /* "plasticity" implementation
+static void visc_from_P(     /* "plasticity" implementation
 
 			 viscosity will be limited by a yield stress
 
@@ -788,7 +796,7 @@
 compositions between zero and unity
 
 */
-void visc_from_C(
+static void visc_from_C(
     struct All_variables *E,
     float **EEta
     )

Modified: mc/3D/CitcomS/branches/cxx/lib/advection_diffusion.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/advection_diffusion.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/advection_diffusion.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,8 +29,13 @@
 #if !defined(CitcomS_advection_diffusion_h)
 #define CitcomS_advection_diffusion_h
 
+struct All_variables;
+
 void PG_timestep_init(struct All_variables *);
 void PG_timestep_solve(struct All_variables *);
 void std_timestep(struct All_variables *);
+void advection_diffusion_parameters(struct All_variables *);
+void advection_diffusion_allocate_memory(struct All_variables *);
+void PG_timestep(struct All_variables *);
 
 #endif

Added: mc/3D/CitcomS/branches/cxx/lib/bc_util.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/bc_util.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/bc_util.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,38 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_bc_util_h)
+#define CitcomS_bc_util_h
+
+struct All_variables;
+
+void strip_bcs_from_residual(struct All_variables *, double **, int);
+void temperatures_conform_bcs(struct All_variables *);
+void velocities_conform_bcs(struct All_variables *, double **);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/checkpoints.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/checkpoints.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/checkpoints.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,6 +26,12 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#if !defined(CitcomS_checkpoints_h)
+#define CitcomS_checkpoints_h
 
+struct All_variables;
+
 void output_checkpoint(struct All_variables *E);
 void read_checkpoint(struct All_variables *E);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/citcom_init.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/citcom_init.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/citcom_init.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -31,7 +31,9 @@
 
 #include "mpi.h"
 
-extern struct All_variables* citcom_init(MPI_Comm *world);
+struct All_variables;
 
+struct All_variables* citcom_init(MPI_Comm *world);
+
 #endif
 

Modified: mc/3D/CitcomS/branches/cxx/lib/composition_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/composition_related.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/composition_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,10 +25,17 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 
 
+#if !defined(CitcomS_composition_related_h)
+#define CitcomS_composition_related_h
+
+struct All_variables;
+
 void composition_input(struct All_variables *E);
 void composition_setup(struct All_variables *E);
 void write_composition_instructions(struct All_variables *E);
 void fill_composition(struct All_variables *E);
 void get_bulk_composition(struct All_variables *E);
 void map_composition_to_nodes(struct All_variables *E);
+void init_composition(struct All_variables *E);
 
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/construct_arrays.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/construct_arrays.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/construct_arrays.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,48 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_construct_arrays_h)
+#define CitcomS_construct_arrays_h
+
+struct All_variables;
+
+void construct_ien(struct All_variables *E);
+void construct_surface(struct All_variables *E);
+void construct_id(struct All_variables *E);
+void construct_lm(struct All_variables *E);
+void construct_node_maps(struct All_variables *E);
+void construct_masks(struct All_variables *E);
+void construct_sub_element(struct All_variables *E);
+void construct_elt_gs(struct All_variables *E);
+void construct_elt_cs(struct All_variables *E);
+void construct_stiffness_B_matrix(struct All_variables *E);
+int layers_r(struct All_variables *E, float r);
+int layers(struct All_variables *E, int m, int node);
+void construct_mat_group(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/convection.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/convection.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/convection.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_convection_h)
+#define CitcomS_convection_h
+
+struct All_variables;
+
+void set_convection_defaults(struct All_variables *E);
+
+#endif

Deleted: mc/3D/CitcomS/branches/cxx/lib/cproto.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/cproto.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/cproto.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,507 +0,0 @@
-/* Advection_diffusion.c */
-void advection_diffusion_parameters(struct All_variables *E);
-void advection_diffusion_allocate_memory(struct All_variables *E);
-void PG_timestep_init(struct All_variables *E);
-void PG_timestep(struct All_variables *E);
-void std_timestep(struct All_variables *E);
-void PG_timestep_solve(struct All_variables *E);
-/* BC_util.c */
-void strip_bcs_from_residual(struct All_variables *E, double **Res, int level);
-void temperatures_conform_bcs(struct All_variables *E);
-void temperatures_conform_bcs2(struct All_variables *E);
-void velocities_conform_bcs(struct All_variables *E, double **U);
-/* Checkpoints.c */
-void output_checkpoint(struct All_variables *E);
-void read_checkpoint(struct All_variables *E);
-/* Citcom_init.c */
-/* Composition_related.c */
-void composition_input(struct All_variables *E);
-void composition_setup(struct All_variables *E);
-void write_composition_instructions(struct All_variables *E);
-void fill_composition(struct All_variables *E);
-void init_composition(struct All_variables *E);
-void map_composition_to_nodes(struct All_variables *E);
-void get_bulk_composition(struct All_variables *E);
-/* Construct_arrays.c */
-void construct_ien(struct All_variables *E);
-void construct_surface(struct All_variables *E);
-void construct_id(struct All_variables *E);
-void get_bcs_id_for_residual(struct All_variables *E, int level, int m);
-void construct_lm(struct All_variables *E);
-void construct_node_maps(struct All_variables *E);
-void construct_node_ks(struct All_variables *E);
-void rebuild_BI_on_boundary(struct All_variables *E);
-void construct_masks(struct All_variables *E);
-void construct_sub_element(struct All_variables *E);
-void construct_elt_ks(struct All_variables *E);
-void construct_elt_gs(struct All_variables *E);
-void construct_elt_cs(struct All_variables *E);
-void construct_stiffness_B_matrix(struct All_variables *E);
-int layers_r(struct All_variables *E, float r);
-int layers(struct All_variables *E, int m, int node);
-void construct_mat_group(struct All_variables *E);
-/* Convection.c */
-void set_convection_defaults(struct All_variables *E);
-void read_convection_settings(struct All_variables *E);
-void convection_derived_values(struct All_variables *E);
-void convection_allocate_memory(struct All_variables *E);
-void convection_initial_fields(struct All_variables *E);
-void convection_boundary_conditions(struct All_variables *E);
-/* Determine_net_rotation.c */
-double determine_model_net_rotation(struct All_variables *E, double *omega);
-double determine_netr_tp(float r, float theta, float phi, float velt, float velp, int mode, double *c9, double *omega);
-void sub_netr(float r, float theta, float phi, float *velt, float *velp, double *omega);
-void hc_ludcmp_3x3(double a[3][3], int *indx);
-void hc_lubksb_3x3(double a[3][3], int *indx, double *b);
-/* Drive_solvers.c */
-void general_stokes_solver_setup(struct All_variables *E);
-void general_stokes_solver(struct All_variables *E);
-int need_visc_update(struct All_variables *E);
-void general_stokes_solver_pseudo_surf(struct All_variables *E);
-/* Element_calculations.c */
-void add_force(struct All_variables *E, int e, double elt_f[24], int m);
-void assemble_forces(struct All_variables *E, int penalty);
-void assemble_forces_pseudo_surf(struct All_variables *E, int penalty);
-void get_ba(struct Shape_function *N, struct Shape_function_dx *GNx, struct CC *cc, struct CCX *ccx, double rtf[4][9], int dims, double ba[9][9][4][7]);
-void get_ba_p(struct Shape_function *N, struct Shape_function_dx *GNx, struct CC *cc, struct CCX *ccx, double rtf[4][9], int dims, double ba[9][9][4][7]);
-void get_elt_k(struct All_variables *E, int el, double elt_k[24*24], int lev, int m, int iconv);
-void assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
-void e_assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
-void n_assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
-void build_diagonal_of_K(struct All_variables *E, int el, double elt_k[24*24], int level, int m);
-void build_diagonal_of_Ahat(struct All_variables *E);
-void assemble_c_u(struct All_variables *E, double **U, double **result, int level);
-void assemble_div_rho_u(struct All_variables *E, double **U, double **result, int level);
-void assemble_div_u(struct All_variables *E, double **U, double **divU, int level);
-void assemble_grad_p(struct All_variables *E, double **P, double **gradP, int lev);
-double assemble_dAhatp_entry(struct All_variables *E, int e, int level, int m);
-void get_elt_c(struct All_variables *E, int el, higher_precision elt_c[24][1], int lev, int m);
-void get_elt_g(struct All_variables *E, int el, higher_precision elt_del[24][1], int lev, int m);
-void get_elt_f(struct All_variables *E, int el, double elt_f[24], int bcs, int m);
-void get_elt_tr(struct All_variables *E, int bel, int side, double elt_tr[24], int m);
-void get_elt_tr_pseudo_surf(struct All_variables *E, int bel, int side, double elt_tr[24], int m);
-void get_aug_k(struct All_variables *E, int el, double elt_k[24*24], int level, int m);
-/* Full_boundary_conditions.c */
-void full_velocity_boundary_conditions(struct All_variables *E);
-void full_temperature_boundary_conditions(struct All_variables *E);
-/* Full_geometry_cartesian.c */
-void full_set_2dc_defaults(struct All_variables *E);
-void full_set_2pt5dc_defaults(struct All_variables *E);
-void full_set_3dc_defaults(struct All_variables *E);
-void full_set_3dsphere_defaults(struct All_variables *E);
-void full_set_3dsphere_defaults2(struct All_variables *E);
-/* Full_lith_age_read_files.c */
-void full_lith_age_read_files(struct All_variables *E, int output);
-/* Full_obsolete.c */
-void parallel_process_initilization(struct All_variables *E, int argc, char **argv);
-void parallel_domain_decomp2(struct All_variables *E, float *GX[4]);
-void scatter_to_nlayer_id(struct All_variables *E, double **AUi, double **AUo, int lev);
-void gather_to_1layer_id(struct All_variables *E, double **AUi, double **AUo, int lev);
-void gather_to_1layer_node(struct All_variables *E, float **AUi, float **AUo, int lev);
-void gather_to_1layer_ele(struct All_variables *E, float **AUi, float **AUo, int lev);
-void gather_TG_to_me0(struct All_variables *E, float *TG);
-void sum_across_depth_sph(struct All_variables *E, float *sphc, float *sphs, int dest_proc);
-void sum_across_surf_sph(struct All_variables *E, float *TG, int loc_proc);
-void set_communication_sphereh(struct All_variables *E);
-void process_temp_field(struct All_variables *E, int ii);
-void output_velo_related(struct All_variables *E, int file_number);
-void output_temp(struct All_variables *E, int file_number);
-void output_stress(struct All_variables *E, int file_number, float *SXX, float *SYY, float *SZZ, float *SXY, float *SXZ, float *SZY);
-void print_field_spectral_regular(struct All_variables *E, float *TG, float *sphc, float *sphs, int proc_loc, char *filen);
-void write_radial_horizontal_averages(struct All_variables *E);
-int icheck_regular_neighbors(struct All_variables *E, int j, int ntheta, int nphi, double x, double y, double z, double theta, double phi, double rad);
-int iquick_element_column_search(struct All_variables *E, int j, int iregel, int ntheta, int nphi, double x, double y, double z, double theta, double phi, double rad, int *imap, int *ich);
-/* Full_parallel_related.c */
-void full_parallel_processor_setup(struct All_variables *E);
-void full_parallel_domain_decomp0(struct All_variables *E);
-void full_parallel_domain_boundary_nodes(struct All_variables *E);
-void full_parallel_communication_routs_v(struct All_variables *E);
-void full_parallel_communication_routs_s(struct All_variables *E);
-void full_exchange_id_d(struct All_variables *E, double **U, int lev);
-void full_exchange_snode_f(struct All_variables *E, float **U1, float **U2, int lev);
-/* Full_read_input_from_files.c */
-void full_read_input_files_for_timesteps(struct All_variables *E, int action, int output);
-/* Full_solver.c */
-void full_solver_init(struct All_variables *E);
-/* Full_sphere_related.c */
-void spherical_to_uv2(double center[2], int len, double *theta, double *phi, double *u, double *v);
-void uv_to_spherical(double center[2], int len, double *u, double *v, double *theta, double *phi);
-void full_coord_of_cap(struct All_variables *E, int m, int icap);
-/* Full_tracer_advection.c */
-void full_tracer_input(struct All_variables *E);
-void full_tracer_setup(struct All_variables *E);
-void full_lost_souls(struct All_variables *E);
-void full_get_shape_functions(struct All_variables *E, double shp[9], int nelem, double theta, double phi, double rad);
-double full_interpolate_data(struct All_variables *E, double shp[9], double data[9]);
-void full_get_velocity(struct All_variables *E, int j, int nelem, double theta, double phi, double rad, double *velocity_vector);
-int full_icheck_cap(struct All_variables *E, int icap, double x, double y, double z, double rad);
-int full_iget_element(struct All_variables *E, int j, int iprevious_element, double x, double y, double z, double theta, double phi, double rad);
-void full_keep_within_bounds(struct All_variables *E, double *x, double *y, double *z, double *theta, double *phi, double *rad);
-void analytical_test(struct All_variables *E);
-void analytical_runge_kutte(struct All_variables *E, int nsteps, double dt, double *x0_s, double *x0_c, double *xf_s, double *xf_c, double *vec);
-void analytical_test_function(struct All_variables *E, double theta, double phi, double rad, double *vel_s, double *vel_c);
-void pdebug(struct All_variables *E, int i);
-/* Full_version_dependent.c */
-void full_node_locations(struct All_variables *E);
-void full_construct_boundary(struct All_variables *E);
-/* General_matrix_functions.c */
-int solve_del2_u(struct All_variables *E, double **d0, double **F, double acc, int high_lev);
-double multi_grid(struct All_variables *E, double **d1, double **F, double acc, int hl);
-double conj_grad(struct All_variables *E, double **d0, double **F, double acc, int *cycles, int level);
-void element_gauss_seidel(struct All_variables *E, double **d0, double **F, double **Ad, double acc, int *cycles, int level, int guess);
-void gauss_seidel(struct All_variables *E, double **d0, double **F, double **Ad, double acc, int *cycles, int level, int guess);
-double cofactor(double A[4][4], int i, int j, int n);
-double determinant(double A[4][4], int n);
-double gen_determinant(double **A, int n);
-long double lg_pow(long double a, int n);
-/* Ggrd_handling.c */
-/* Global_operations.c */
-void remove_horiz_ave(struct All_variables *E, double **X, double *H, int store_or_not);
-void remove_horiz_ave2(struct All_variables *E, double **X);
-void return_horiz_ave(struct All_variables *E, double **X, double *H);
-void return_horiz_ave_f(struct All_variables *E, float **X, float *H);
-void return_elementwise_horiz_ave(struct All_variables *E, double **X, double *H);
-float return_bulk_value(struct All_variables *E, float **Z, int average);
-double return_bulk_value_d(struct All_variables *E, double **Z, int average);
-float find_max_horizontal(struct All_variables *E, double Tmax);
-void sum_across_surface(struct All_variables *E, float *data, int total);
-void sum_across_surf_sph1(struct All_variables *E, float *sphc, float *sphs);
-float global_fvdot(struct All_variables *E, float **A, float **B, int lev);
-double kineticE_radial(struct All_variables *E, double **A, int lev);
-double global_vdot(struct All_variables *E, double **A, double **B, int lev);
-double global_pdot(struct All_variables *E, double **A, double **B, int lev);
-double global_v_norm2(struct All_variables *E, double **V);
-double global_p_norm2(struct All_variables *E, double **P);
-double global_div_norm2(struct All_variables *E, double **A);
-double global_tdot_d(struct All_variables *E, double **A, double **B, int lev);
-float global_tdot(struct All_variables *E, float **A, float **B, int lev);
-float global_fmin(struct All_variables *E, float a);
-double global_dmax(struct All_variables *E, double a);
-float global_fmax(struct All_variables *E, double a);
-double Tmaxd(struct All_variables *E, double **T);
-float Tmax(struct All_variables *E, float **T);
-double vnorm_nonnewt(struct All_variables *E, double **dU, double **U, int lev);
-void sum_across_depth_sph1(struct All_variables *E, float *sphc, float *sphs);
-void broadcast_vertical(struct All_variables *E, float *sphc, float *sphs, int root);
-void remove_rigid_rot(struct All_variables *E);
-/* Initial_temperature.c */
-void tic_input(struct All_variables *E);
-void convection_initial_temperature(struct All_variables *E);
-/* Instructions.c */
-void initial_mesh_solver_setup(struct All_variables *E);
-void read_instructions(struct All_variables *E, char *filename);
-void initial_setup(struct All_variables *E);
-void initialize_material(struct All_variables *E);
-void initial_conditions(struct All_variables *E);
-void read_initial_settings(struct All_variables *E);
-void check_settings_consistency(struct All_variables *E);
-void global_derived_values(struct All_variables *E);
-void allocate_common_vars(struct All_variables *E);
-void allocate_velocity_vars(struct All_variables *E);
-void global_default_values(struct All_variables *E);
-void check_bc_consistency(struct All_variables *E);
-void set_up_nonmg_aliases(struct All_variables *E, int j);
-void report(struct All_variables *E, char *string);
-void record(struct All_variables *E, char *string);
-void common_initial_fields(struct All_variables *E);
-void initial_pressure(struct All_variables *E);
-void initial_velocity(struct All_variables *E);
-void open_qfiles(struct All_variables *E);
-void mkdatadir(const char *dir);
-void output_init(struct All_variables *E);
-void output_finalize(struct All_variables *E);
-char *strip(char *input);
-/* Interuption.c */
-void interuption(int signal_number);
-void set_signal(void);
-/* Lith_age.c */
-void lith_age_input(struct All_variables *E);
-void lith_age_init(struct All_variables *E);
-void lith_age_construct_tic(struct All_variables *E);
-void lith_age_update_tbc(struct All_variables *E);
-void lith_age_temperature_bound_adj(struct All_variables *E, int lv);
-void lith_age_conform_tbc(struct All_variables *E);
-void assimilate_lith_conform_bcs(struct All_variables *E);
-/* Material_properties.c */
-void mat_prop_allocate(struct All_variables *E);
-void reference_state(struct All_variables *E);
-/* Nodal_mesh.c */
-void v_from_vector(struct All_variables *E);
-void v_from_vector_pseudo_surf(struct All_variables *E);
-void velo_from_element(struct All_variables *E, float VV[4][9], int m, int el, int sphere_key);
-void velo_from_element_d(struct All_variables *E, double VV[4][9], int m, int el, int sphere_key);
-void p_to_nodes(struct All_variables *E, double **P, float **PN, int lev);
-void visc_from_gint_to_nodes(struct All_variables *E, float **VE, float **VN, int lev);
-void visc_from_nodes_to_gint(struct All_variables *E, float **VN, float **VE, int lev);
-void visc_from_gint_to_ele(struct All_variables *E, float **VE, float **VN, int lev);
-void visc_from_ele_to_gint(struct All_variables *E, float **VN, float **VE, int lev);
-/* Obsolete.c */
-void get_global_shape_fn(struct All_variables *E, int el, struct Shape_function *GN, struct Shape_function_dx *GNx, struct Shape_function_dA *dOmega, int pressure, int sphere, double rtf[4][9], int lev, int m);
-void get_global_1d_shape_fn_1(struct All_variables *E, int el, struct Shape_function *GM, struct Shape_function_dA *dGammax, int nodal, int m);
-void get_global_side_1d_shape_fn(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dx *GMx, struct Shape_function_side_dA *dGamma, int NS, int far, int m);
-void get_elt_h(struct All_variables *E, int el, double elt_h[1], int m);
-void get_ele_visc(struct All_variables *E, float *EV, int m);
-void construct_interp_net(struct All_variables *E);
-int locate_cap(struct All_variables *E, double x[4]);
-int locate_element(struct All_variables *E, int m, double x[4], int ne);
-float sphere_interpolate_point(struct All_variables *E, float **T, int m, int el, double x[4], int ne);
-void sphere_interpolate(struct All_variables *E, float **T, float *TG);
-void phase_change_410(struct All_variables *E, float **B, float **B_b);
-void phase_change_670(struct All_variables *E, float **B, float **B_b);
-void phase_change_cmb(struct All_variables *E, float **B, float **B_b);
-void flogical_mesh_to_real(struct All_variables *E, float *data, int level);
-void p_to_centres(struct All_variables *E, float **PN, double **P, int lev);
-void v_to_intpts(struct All_variables *E, float **VN, float **VE, int lev);
-void visc_to_intpts(struct All_variables *E, float **VN, float **VE, int lev);
-double SIN_D(double x);
-double COT_D(double x);
-void *Malloc1(int bytes, char *file, int line);
-float cross2d(double x11, double x12, double x21, double x22, int D);
-double **dmatrix(int nrl, int nrh, int ncl, int nch);
-float **fmatrix(int nrl, int nrh, int ncl, int nch);
-void dfree_matrix(double **m, int nrl, int nrh, int ncl, int nch);
-void ffree_matrix(float **m, int nrl, int nrh, int ncl, int nch);
-double *dvector(int nl, int nh);
-float *fvector(int nl, int nh);
-void dfree_vector(double *v, int nl, int nh);
-void ffree_vector(float *v, int nl, int nh);
-int *sivector(int nl, int nh);
-void sifree_vector(int *v, int nl, int nh);
-void dvcopy(struct All_variables *E, double **A, double **B, int a, int b);
-void vcopy(float *A, float *B, int a, int b);
-double sphere_h(int l, int m, double t, double f, int ic);
-double plgndr_a(int l, int m, double t);
-float area_of_4node(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
-void print_elt_k(struct All_variables *E, double a[24*24]);
-double sqrt_multis(int jj, int ii);
-double multis(int ii);
-int int_multis(int ii);
-void jacobi(struct All_variables *E, double **d0, double **F, double **Ad, double acc, int *cycles, int level, int guess);
-/* Output.c */
-void output_common_input(struct All_variables *E);
-void output(struct All_variables *E, int cycles);
-FILE *output_open(char *filename, char *mode);
-void output_coord(struct All_variables *E);
-void output_visc(struct All_variables *E, int cycles);
-void output_velo(struct All_variables *E, int cycles);
-void output_surf_botm(struct All_variables *E, int cycles);
-void output_geoid(struct All_variables *E, int cycles);
-void output_stress(struct All_variables *E, int cycles);
-void output_horiz_avg(struct All_variables *E, int cycles);
-void output_mat(struct All_variables *E);
-void output_pressure(struct All_variables *E, int cycles);
-void output_tracer(struct All_variables *E, int cycles);
-void output_comp_nd(struct All_variables *E, int cycles);
-void output_comp_el(struct All_variables *E, int cycles);
-void output_heating(struct All_variables *E, int cycles);
-void output_time(struct All_variables *E, int cycles);
-/* Output_gzdir.c */
-/* Output_h5.c */
-void h5output_allocate_memory(struct All_variables *E);
-void h5output(struct All_variables *E, int cycles);
-void h5input_params(struct All_variables *E);
-/* Output_vtk.c */
-void vtk_output(struct All_variables *E, int cycles);
-/* Pan_problem_misc_functions.c */
-int get_process_identifier(void);
-void unique_copy_file(struct All_variables *E, char *name, char *comment);
-void apply_side_sbc(struct All_variables *E);
-void get_buoyancy(struct All_variables *E, double **buoy);
-int read_double_vector(FILE *in, int num_columns, double *fields);
-int read_previous_field(struct All_variables *E, float **field, char *name, char *abbr);
-double myatan(double y, double x);
-double return1_test(void);
-void rtp2xyz(float r, float theta, float phi, float *xout);
-void xyz2rtp(float x, float y, float z, float *rout);
-void xyz2rtpd(float x, float y, float z, double *rout);
-void calc_cbase_at_tp(float theta, float phi, float *base);
-void calc_cbase_at_node(int cap, int node, float *base, struct All_variables *E);
-void convert_pvec_to_cvec(float vr, float vt, float vp, float *base, float *cvec);
-void *safe_malloc(size_t size);
-void myerror(struct All_variables *E, char *message);
-void get_r_spacing_fine(double *rr, struct All_variables *E);
-void get_r_spacing_at_levels(double *rr, struct All_variables *E);
-/* Parallel_util.c */
-void parallel_process_termination(void);
-void parallel_process_sync(struct All_variables *E);
-double CPU_time0(void);
-/* Parsing.c */
-void setup_parser(struct All_variables *E, char *filename);
-void shutdown_parser(struct All_variables *E);
-void add_to_parameter_list(char *name, char *value);
-int compute_parameter_hash_table(char *s);
-int input_int(char *name, int *value, char *interpret, int m);
-int input_string(char *name, char *value, char *Default, int m);
-int input_boolean(char *name, int *value, char *interpret, int m);
-int input_float(char *name, float *value, char *interpret, int m);
-int input_double(char *name, double *value, char *interpret, int m);
-int input_int_vector(char *name, int number, int *value, int m);
-int input_char_vector(char *name, int number, char *value, int m);
-int input_float_vector(char *name, int number, float *value, int m);
-int input_double_vector(char *name, int number, double *value, int m);
-int interpret_control_string(char *interpret, int *essential, double *Default, double *minvalue, double *maxvalue);
-/* Phase_change.c */
-void phase_change_allocate(struct All_variables *E);
-void phase_change_input(struct All_variables *E);
-void phase_change_apply_410(struct All_variables *E, double **buoy);
-void phase_change_apply_670(struct All_variables *E, double **buoy);
-void phase_change_apply_cmb(struct All_variables *E, double **buoy);
-/* Problem_related.c */
-void read_velocity_boundary_from_file(struct All_variables *E);
-void read_mat_from_file(struct All_variables *E);
-void read_temperature_boundary_from_file(struct All_variables *E);
-void get_initial_elapsed_time(struct All_variables *E);
-void set_elapsed_time(struct All_variables *E);
-void set_starting_age(struct All_variables *E);
-float find_age_in_MY(struct All_variables *E);
-/* Process_buoyancy.c */
-void post_processing(struct All_variables *E);
-void heat_flux(struct All_variables *E);
-void compute_horiz_avg(struct All_variables *E);
-/* Regional_boundary_conditions.c */
-void regional_velocity_boundary_conditions(struct All_variables *E);
-void regional_temperature_boundary_conditions(struct All_variables *E);
-/* Regional_geometry_cartesian.c */
-void regional_set_2dc_defaults(struct All_variables *E);
-void regional_set_2pt5dc_defaults(struct All_variables *E);
-void regional_set_3dc_defaults(struct All_variables *E);
-void regional_set_3dsphere_defaults(struct All_variables *E);
-void regional_set_3dsphere_defaults2(struct All_variables *E);
-/* Regional_lith_age_read_files.c */
-void regional_lith_age_read_files(struct All_variables *E, int output);
-/* Regional_obsolete.c */
-void parallel_process_initilization(struct All_variables *E, int argc, char **argv);
-void parallel_domain_decomp2(struct All_variables *E, float *GX[4]);
-void scatter_to_nlayer_id(struct All_variables *E, double **AUi, double **AUo, int lev);
-void gather_to_1layer_id(struct All_variables *E, double **AUi, double **AUo, int lev);
-void gather_to_1layer_node(struct All_variables *E, float **AUi, float **AUo, int lev);
-void gather_to_1layer_ele(struct All_variables *E, float **AUi, float **AUo, int lev);
-void gather_TG_to_me0(struct All_variables *E, float *TG);
-void renew_top_velocity_boundary(struct All_variables *E);
-void output_stress(struct All_variables *E, int file_number, float *SXX, float *SYY, float *SZZ, float *SXY, float *SXZ, float *SZY);
-void print_field_spectral_regular(struct All_variables *E, float *TG, float *sphc, float *sphs, int proc_loc, char *filen);
-void output_velo_related(struct All_variables *E, int file_number);
-void output_temp(struct All_variables *E, int file_number);
-void output_visc_prepare(struct All_variables *E, float **VE);
-void output_visc(struct All_variables *E, int cycles);
-void process_temp_field(struct All_variables *E, int ii);
-void process_new_velocity(struct All_variables *E, int ii);
-void get_surface_velo(struct All_variables *E, float *SV, int m);
-/* Regional_parallel_related.c */
-void regional_parallel_processor_setup(struct All_variables *E);
-void regional_parallel_domain_decomp0(struct All_variables *E);
-void regional_parallel_domain_boundary_nodes(struct All_variables *E);
-void regional_parallel_communication_routs_v(struct All_variables *E);
-void regional_parallel_communication_routs_s(struct All_variables *E);
-void regional_exchange_id_d(struct All_variables *E, double **U, int lev);
-void regional_exchange_snode_f(struct All_variables *E, float **U1, float **U2, int lev);
-/* Regional_read_input_from_files.c */
-void regional_read_input_files_for_timesteps(struct All_variables *E, int action, int output);
-/* Regional_solver.c */
-void regional_solver_init(struct All_variables *E);
-/* Regional_sphere_related.c */
-void regional_coord_of_cap(struct All_variables *E, int m, int icap);
-/* Regional_tracer_advection.c */
-void regional_tracer_setup(struct All_variables *E);
-int regional_iget_element(struct All_variables *E, int m, int iprevious_element, double dummy1, double dummy2, double dummy3, double theta, double phi, double rad);
-int isearch_all(double *array, int nsize, double a);
-int isearch_neighbors(double *array, int nsize, double a, int hint);
-int regional_icheck_cap(struct All_variables *E, int icap, double theta, double phi, double rad, double junk);
-void regional_get_shape_functions(struct All_variables *E, double shp[9], int nelem, double theta, double phi, double rad);
-double regional_interpolate_data(struct All_variables *E, double shp[9], double data[9]);
-void regional_get_velocity(struct All_variables *E, int m, int nelem, double theta, double phi, double rad, double *velocity_vector);
-void regional_keep_within_bounds(struct All_variables *E, double *x, double *y, double *z, double *theta, double *phi, double *rad);
-void regional_lost_souls(struct All_variables *E);
-/* Regional_version_dependent.c */
-void regional_node_locations(struct All_variables *E);
-void regional_construct_boundary(struct All_variables *E);
-/* Shape_functions.c */
-void construct_shape_functions(struct All_variables *E);
-double lpoly(int p, double y);
-double lpolydash(int p, double y);
-/* Size_does_matter.c */
-void twiddle_thumbs(struct All_variables *yawn);
-void construct_shape_function_derivatives(struct All_variables *E);
-void get_rtf_at_vpts(struct All_variables *E, int m, int lev, int el, double rtf[4][9]);
-void get_rtf_at_ppts(struct All_variables *E, int m, int lev, int el, double rtf[4][9]);
-void get_side_x_cart(struct All_variables *E, double xx[4][5], int el, int side, int m);
-void construct_surf_det(struct All_variables *E);
-void construct_bdry_det(struct All_variables *E);
-void get_global_1d_shape_fn(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dA *dGammax, int top, int m);
-void get_global_1d_shape_fn_L(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dA *dGammax, int top, int m);
-void get_global_side_1d_shape_fn(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dx *GMx, struct Shape_function_side_dA *dGamma, int side, int m);
-void construct_c3x3matrix_el(struct All_variables *E, int el, struct CC *cc, struct CCX *ccx, int lev, int m, int pressure);
-void construct_side_c3x3matrix_el(struct All_variables *E, int el, struct CC *cc, struct CCX *ccx, int lev, int m, int pressure, int side);
-void construct_c3x3matrix(struct All_variables *E);
-void mass_matrix(struct All_variables *E);
-/* Solver_conj_grad.c */
-void set_cg_defaults(struct All_variables *E);
-void cg_allocate_vars(struct All_variables *E);
-void assemble_forces_iterative(struct All_variables *E);
-/* Solver_multigrid.c */
-void set_mg_defaults(struct All_variables *E);
-void mg_allocate_vars(struct All_variables *E);
-void inject_scalar(struct All_variables *E, int start_lev, float **AU, float **AD);
-void inject_vector(struct All_variables *E, int start_lev, double **AU, double **AD);
-void un_inject_vector(struct All_variables *E, int start_lev, double **AD, double **AU);
-void interp_vector(struct All_variables *E, int start_lev, double **AD, double **AU);
-void project_viscosity(struct All_variables *E);
-void inject_scalar_e(struct All_variables *E, int start_lev, float **AU, float **AD);
-void project_scalar_e(struct All_variables *E, int start_lev, float **AU, float **AD);
-void project_scalar(struct All_variables *E, int start_lev, float **AU, float **AD);
-void project_vector(struct All_variables *E, int start_lev, double **AU, double **AD, int ic);
-void from_xyz_to_rtf(struct All_variables *E, int level, double **xyz, double **rtf);
-void from_rtf_to_xyz(struct All_variables *E, int level, double **rtf, double **xyz);
-void fill_in_gaps(struct All_variables *E, double **temp, int level);
-/* Sphere_harmonics.c */
-void set_sphere_harmonics(struct All_variables *E);
-double modified_plgndr_a(int l, int m, double t);
-void sphere_expansion(struct All_variables *E, float **TG, float *sphc, float *sphs);
-void debug_sphere_expansion(struct All_variables *E);
-/* Sphere_util.c */
-void even_divide_arc12(int elx, double x1, double y1, double z1, double x2, double y2, double z2, double *theta, double *fi);
-void compute_angle_surf_area(struct All_variables *E);
-double area_sphere_cap(double angle[6]);
-double area_of_sphere_triag(double a, double b, double c);
-double area_of_5points(struct All_variables *E, int lev, int m, int el, double x[4], int ne);
-void get_angle_sphere_cap(double xx[4][5], double angle[6]);
-double get_angle(double x[4], double xx[4]);
-/* Stokes_flow_Incomp.c */
-void solve_constrained_flow_iterative(struct All_variables *E);
-void solve_constrained_flow_iterative_pseudo_surf(struct All_variables *E);
-/* Topo_gravity.c */
-void get_STD_topo(struct All_variables *E, float **tpg, float **tpgb, float **divg, float **vort, int ii);
-void get_STD_freesurf(struct All_variables *E, float **freesurf);
-void allocate_STD_mem(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
-void free_STD_mem(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
-void compute_nodal_stress(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
-void stress_conform_bcs(struct All_variables *E);
-void compute_geoid(struct All_variables *E);
-void get_CBF_topo(struct All_variables *E, float **H, float **HB);
-/* Tracer_setup.c */
-void tracer_input(struct All_variables *E);
-void tracer_initial_settings(struct All_variables *E);
-void tracer_advection(struct All_variables *E);
-void tracer_post_processing(struct All_variables *E);
-void count_tracers_of_flavors(struct All_variables *E);
-void initialize_tracers(struct All_variables *E);
-void dump_and_get_new_tracers_to_interpolate_fields(struct All_variables *E);
-void cart_to_sphere(struct All_variables *E, double x, double y, double z, double *theta, double *phi, double *rad);
-void sphere_to_cart(struct All_variables *E, double theta, double phi, double rad, double *x, double *y, double *z);
-void get_neighboring_caps(struct All_variables *E);
-void allocate_tracer_arrays(struct All_variables *E, int j, int number_of_tracers);
-void expand_tracer_arrays(struct All_variables *E, int j);
-void expand_later_array(struct All_variables *E, int j);
-int icheck_processor_shell(struct All_variables *E, int j, double rad);
-int icheck_that_processor_shell(struct All_variables *E, int j, int nprocessor, double rad);
-/* Viscosity_structures.c */
-void viscosity_system_input(struct All_variables *E);
-void viscosity_input(struct All_variables *E);
-void get_system_viscosity(struct All_variables *E, int propogate, float **evisc, float **visc);
-void initial_viscosity(struct All_variables *E);
-void visc_from_mat(struct All_variables *E, float **EEta);
-void visc_from_T(struct All_variables *E, float **EEta, int propogate);
-void visc_from_S(struct All_variables *E, float **EEta, int propogate);
-void visc_from_P(struct All_variables *E, float **EEta);
-void visc_from_C(struct All_variables *E, float **EEta);
-void strain_rate_2_inv(struct All_variables *E, int m, float *EEDOT, int SQRT);

Added: mc/3D/CitcomS/branches/cxx/lib/determine_net_rotation.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/determine_net_rotation.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/determine_net_rotation.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_determine_net_rotation_h)
+#define CitcomS_determine_net_rotation_h
+
+struct All_variables;
+
+double determine_model_net_rotation(struct All_variables *E, double *omega);
+void sub_netr(float r, float theta, float phi, float *velt, float *velp, double *omega);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/drive_solvers.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/drive_solvers.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/drive_solvers.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -30,5 +30,6 @@
 
 void general_stokes_solver(struct All_variables*);
 void general_stokes_solver_setup(struct All_variables*);
+void general_stokes_solver_pseudo_surf(struct All_variables *);
 
 #endif

Added: mc/3D/CitcomS/branches/cxx/lib/element_calculations.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/element_calculations.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/element_calculations.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,57 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_element_calculations_h)
+#define CitcomS_element_calculations_h
+
+struct All_variables;
+struct Shape_function;
+struct CC;
+struct CCX;
+
+typedef float higher_precision; /*XXX*/
+
+void assemble_forces(struct All_variables *E, int penalty);
+void assemble_forces_pseudo_surf(struct All_variables *E, int penalty);
+void get_ba_p(struct Shape_function *N, struct Shape_function_dx *GNx, struct CC *cc, struct CCX *ccx, double rtf[4][9], int dims, double ba[9][9][4][7]);
+void get_elt_k(struct All_variables *E, int el, double elt_k[24*24], int lev, int m, int iconv);
+void assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
+void e_assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
+void n_assemble_del2_u(struct All_variables *E, double **u, double **Au, int level, int strip_bcs);
+void build_diagonal_of_K(struct All_variables *E, int el, double elt_k[24*24], int level, int m);
+void build_diagonal_of_Ahat(struct All_variables *E);
+void assemble_c_u(struct All_variables *E, double **U, double **result, int level);
+void assemble_div_rho_u(struct All_variables *E, double **U, double **result, int level);
+void assemble_div_u(struct All_variables *E, double **U, double **divU, int level);
+void assemble_grad_p(struct All_variables *E, double **P, double **gradP, int lev);
+void get_elt_c(struct All_variables *E, int el, higher_precision elt_c[24][1], int lev, int m);
+void get_elt_g(struct All_variables *E, int el, higher_precision elt_del[24][1], int lev, int m);
+void get_elt_f(struct All_variables *E, int el, double elt_f[24], int bcs, int m);
+void get_aug_k(struct All_variables *E, int el, double elt_k[24*24], int level, int m);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_boundary_conditions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_boundary_conditions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_boundary_conditions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_boundary_conditions_h)
+#define CitcomS_full_boundary_conditions_h
+
+struct All_variables;
+
+void full_velocity_boundary_conditions(struct All_variables *E);
+void full_temperature_boundary_conditions(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_geometry_cartesian.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_geometry_cartesian.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_geometry_cartesian.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_geometry_cartesian_h)
+#define CitcomS_full_geometry_cartesian_h
+
+struct All_variables;
+
+void full_set_2dc_defaults(struct All_variables *E);
+void full_set_2pt5dc_defaults(struct All_variables *E);
+void full_set_3dc_defaults(struct All_variables *E);
+void full_set_3dsphere_defaults(struct All_variables *E);
+void full_set_3dsphere_defaults2(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_lith_age_read_files.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_lith_age_read_files.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_lith_age_read_files.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_lith_age_read_files_h)
+#define CitcomS_full_lith_age_read_files_h
+
+struct All_variables;
+
+void full_lith_age_read_files(struct All_variables *E, int output);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_parallel_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_parallel_related.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_parallel_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_parallel_related_h)
+#define CitcomS_full_parallel_related_h
+
+struct All_variables;
+
+void full_parallel_processor_setup(struct All_variables *E);
+void full_parallel_domain_decomp0(struct All_variables *E);
+void full_parallel_domain_boundary_nodes(struct All_variables *E);
+void full_parallel_communication_routs_v(struct All_variables *E);
+void full_parallel_communication_routs_s(struct All_variables *E);
+void full_exchange_id_d(struct All_variables *E, double **U, int lev);
+void full_exchange_snode_f(struct All_variables *E, float **U1, float **U2, int lev);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_read_input_from_files.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_read_input_from_files.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_read_input_from_files.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_read_input_from_files_h)
+#define CitcomS_full_read_input_from_files_h
+
+struct All_variables;
+
+void full_read_input_files_for_timesteps(struct All_variables *E, int action, int output);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_solver.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_solver.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_solver.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_solver_h)
+#define CitcomS_full_solver_h
+
+struct All_variables;
+
+void full_solver_init(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_sphere_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_sphere_related.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_sphere_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,38 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_sphere_related_h)
+#define CitcomS_full_sphere_related_h
+
+struct All_variables;
+
+void spherical_to_uv2(double center[2], int len, double *theta, double *phi, double *u, double *v);
+void uv_to_spherical(double center[2], int len, double *u, double *v, double *theta, double *phi);
+void full_coord_of_cap(struct All_variables *E, int m, int icap);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_tracer_advection.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_tracer_advection.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_tracer_advection.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_tracer_advection_h)
+#define CitcomS_full_tracer_advection_h
+
+struct All_variables;
+
+void full_tracer_input(struct All_variables *E);
+void full_tracer_setup(struct All_variables *E);
+void full_lost_souls(struct All_variables *E);
+void full_get_velocity(struct All_variables *E, int j, int nelem, double theta, double phi, double rad, double *velocity_vector);
+int full_icheck_cap(struct All_variables *E, int icap, double x, double y, double z, double rad);
+int full_iget_element(struct All_variables *E, int j, int iprevious_element, double x, double y, double z, double theta, double phi, double rad);
+void full_keep_within_bounds(struct All_variables *E, double *x, double *y, double *z, double *theta, double *phi, double *rad);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/full_version_dependent.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/full_version_dependent.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/full_version_dependent.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_full_version_dependent_h)
+#define CitcomS_full_version_dependent_h
+
+struct All_variables;
+
+void full_node_locations(struct All_variables *E);
+void full_construct_boundary(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/general_matrix_functions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/general_matrix_functions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/general_matrix_functions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,39 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_general_matrix_functions_h)
+#define CitcomS_general_matrix_functions_h
+
+struct All_variables;
+
+int solve_del2_u(struct All_variables *E, double **d0, double **F, double acc, int high_lev);
+double cofactor(double A[4][4], int i, int j, int n);
+double determinant(double A[4][4], int n);
+long double lg_pow(long double a, int n);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/ggrd_handling.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/ggrd_handling.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/ggrd_handling.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,24 +25,26 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#if !defined(CitcomS_ggrd_handling_h)
+#define CitcomS_ggrd_handling_h
+
 /*
 
 routines that deal with GMT/netcdf grd I/O as supported through
 the ggrd subroutines of the hc package
 
 */
+
+struct All_variables;
+
 void ggrd_init_tracer_flavors(struct All_variables *);
-int layers_r(struct All_variables *,float );
-void myerror(struct All_variables *,char *);
 void ggrd_full_temp_init(struct All_variables *);
 void ggrd_reg_temp_init(struct All_variables *);
-void ggrd_temp_init_general(struct All_variables *,int);
 void ggrd_read_mat_from_file(struct All_variables *, int );
 void ggrd_read_ray_from_file(struct All_variables *, int );
 void ggrd_read_vtop_from_file(struct All_variables *, int );
 void ggrd_read_age_from_file(struct All_variables *, int );
-void xyz2rtp(float ,float ,float ,float *);
-void xyz2rtpd(float ,float ,float ,double *);
-float find_age_in_MY();
 void ggrd_adjust_tbl_rayleigh(struct All_variables *,double **);
 
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/global_operations.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/global_operations.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/global_operations.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,52 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_global_operations_h)
+#define CitcomS_global_operations_h
+
+struct All_variables;
+
+void remove_horiz_ave2(struct All_variables *E, double **X);
+void return_horiz_ave_f(struct All_variables *E, float **X, float *H);
+double return_bulk_value_d(struct All_variables *E, double **Z, int average);
+void sum_across_surface(struct All_variables *E, float *data, int total);
+void sum_across_surf_sph1(struct All_variables *E, float *sphc, float *sphs);
+double global_vdot(struct All_variables *E, double **A, double **B, int lev);
+double global_pdot(struct All_variables *E, double **A, double **B, int lev);
+double global_v_norm2(struct All_variables *E, double **V);
+double global_p_norm2(struct All_variables *E, double **P);
+double global_div_norm2(struct All_variables *E, double **A);
+float global_fmin(struct All_variables *E, float a);
+double Tmaxd(struct All_variables *E, double **T);
+float Tmax(struct All_variables *E, float **T);
+double vnorm_nonnewt(struct All_variables *E, double **dU, double **U, int lev);
+void sum_across_depth_sph1(struct All_variables *E, float *sphc, float *sphs);
+void broadcast_vertical(struct All_variables *E, float *sphc, float *sphs, int root);
+void remove_rigid_rot(struct All_variables *E);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/initial_temperature.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/initial_temperature.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/initial_temperature.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,13 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#if !defined(CitcomS_initial_temperature_h)
+#define CitcomS_initial_temperature_h
+
+struct All_variables;
+
 void convection_initial_temperature(struct All_variables *);
 void tic_input(struct All_variables *);
-void construct_tic(struct All_variables *);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/instructions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/instructions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/instructions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,49 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_instructions_h)
+#define CitcomS_instructions_h
+
+struct All_variables;
+
+void initial_mesh_solver_setup(struct All_variables *E);
+void read_instructions(struct All_variables *E, char *filename);
+void initial_setup(struct All_variables *E);
+void initialize_material(struct All_variables *E);
+void initial_conditions(struct All_variables *E);
+void check_settings_consistency(struct All_variables *E);
+void global_default_values(struct All_variables *E);
+void check_bc_consistency(struct All_variables *E);
+void report(struct All_variables *E, char *string);
+void record(struct All_variables *E, char *string);
+void initial_pressure(struct All_variables *E);
+void initial_velocity(struct All_variables *E);
+void mkdatadir(const char *dir);
+void output_finalize(struct All_variables *E);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/interuption.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/interuption.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/interuption.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,5 +26,10 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#if !defined(CitcomS_interuption_h)
+#define CitcomS_interuption_h
+
 extern int Emergency_stop;
-extern void set_signal();
+extern void set_signal(void);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/lith_age.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/lith_age.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/lith_age.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,8 +25,17 @@
  *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#if !defined(CitcomS_lith_age_h)
+#define CitcomS_lith_age_h
+
+struct All_variables;
+
 void lith_age_input(struct All_variables *E);
 void lith_age_init(struct All_variables *E);
 void lith_age_construct_tic(struct All_variables *E) ;
 void lith_age_temperature_bound_adj(struct All_variables *E, int lv);
 void lith_age_conform_tbc(struct All_variables *E);
+void assimilate_lith_conform_bcs(struct All_variables *E);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/material_properties.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/material_properties.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/material_properties.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -26,10 +26,12 @@
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#if !defined(CitcomS_material_properties_h)
+#define CitcomS_material_properties_h
 
+struct All_variables;
+
 void mat_prop_allocate(struct All_variables *E);
 void reference_state(struct All_variables *E);
 
-
-void density(struct All_variables *E, double *rho);
-
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/nodal_mesh.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/nodal_mesh.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/nodal_mesh.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,44 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_nodal_mesh_h)
+#define CitcomS_nodal_mesh_h
+
+struct All_variables;
+
+void v_from_vector(struct All_variables *E);
+void v_from_vector_pseudo_surf(struct All_variables *E);
+void velo_from_element(struct All_variables *E, float VV[4][9], int m, int el, int sphere_key);
+void velo_from_element_d(struct All_variables *E, double VV[4][9], int m, int el, int sphere_key);
+void p_to_nodes(struct All_variables *E, double **P, float **PN, int lev);
+void visc_from_gint_to_nodes(struct All_variables *E, float **VE, float **VN, int lev);
+void visc_from_nodes_to_gint(struct All_variables *E, float **VN, float **VE, int lev);
+void visc_from_gint_to_ele(struct All_variables *E, float **VE, float **VN, int lev);
+void visc_from_ele_to_gint(struct All_variables *E, float **VN, float **VE, int lev);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/output.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/output.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/output.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,14 +29,18 @@
 #if !defined(CitcomS_output_h)
 #define CitcomS_output_h
 
+#include <stdio.h>
+
+struct All_variables;
+
 void output_common_input(struct All_variables *);
 void output(struct All_variables *, int);
 void output_time(struct All_variables *, int);
-void output_checkpoint(struct All_variables *);
 
 FILE* output_open(char *, char *);
 
 #ifdef USE_GZDIR
 void gzdir_output(struct All_variables *, int );
 #endif
+
 #endif

Added: mc/3D/CitcomS/branches/cxx/lib/output_gzdir.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/output_gzdir.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/output_gzdir.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,50 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_output_gzdir_h)
+#define CitcomS_output_gzdir_h
+
+#ifdef USE_GZDIR
+
+#include <stdio.h>
+#include <zlib.h>
+
+struct All_variables;
+
+void gzdir_output(struct All_variables *E, int out_cycles);
+void restart_tic_from_gzdir_file(struct All_variables *E);
+void gzip_file(char *output_file);
+void get_vtk_filename(char *output_file, int geo, struct All_variables *E, int cycles);
+gzFile *gzdir_output_open(char *,char *);
+void restart_tic_from_gzdir_file(struct All_variables *);
+int open_file_zipped(char *, FILE **,struct All_variables *);
+void gzip_file(char *);
+
+#endif
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/output_h5.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/output_h5.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/output_h5.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -29,6 +29,8 @@
 #if !defined(CitcomS_output_h5_h)
 #define CitcomS_output_h5_h
 
+struct All_variables;
+
 void h5output_allocate_memory(struct All_variables *);
 void h5input_params(struct All_variables *);
 void h5output(struct All_variables *, int);

Added: mc/3D/CitcomS/branches/cxx/lib/output_vtk.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/output_vtk.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/output_vtk.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_output_vtk_h)
+#define CitcomS_output_vtk_h
+
+struct All_variables;
+
+void vtk_output(struct All_variables *E, int cycles);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/pan_problem_misc_functions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/pan_problem_misc_functions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/pan_problem_misc_functions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,57 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_pan_problem_misc_functions_h)
+#define CitcomS_pan_problem_misc_functions_h
+
+#include <stddef.h>
+#include <stdio.h>
+
+struct All_variables;
+
+int get_process_identifier(void);
+void unique_copy_file(struct All_variables *E, char *name, char *comment);
+void apply_side_sbc(struct All_variables *E);
+void get_buoyancy(struct All_variables *E, double **buoy);
+int read_double_vector(FILE *in, int num_columns, double *fields);
+double myatan(double y, double x);
+double return1_test(void);
+void xyz2rtp(float x, float y, float z, float *rout);
+void xyz2rtpd(float x, float y, float z, double *rout);
+void calc_cbase_at_node(int cap, int node, float *base, struct All_variables *E);
+void convert_pvec_to_cvec(float vr, float vt, float vp, float *base, float *cvec);
+void *safe_malloc(size_t size);
+void myerror(struct All_variables *E, char *message);
+void get_r_spacing_fine(double *rr, struct All_variables *E);
+void get_r_spacing_at_levels(double *rr, struct All_variables *E);
+
+#ifdef ALLOW_ELLIPTICAL
+double theta_g(double , struct All_variables *);
+#endif
+
+#endif

Deleted: mc/3D/CitcomS/branches/cxx/lib/parallel_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/parallel_related.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/parallel_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -1,37 +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>
- * 
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
-#if !defined(CitcomS_parallel_related_h)
-#define CitcomS_parallel_related_h
-
-void parallel_process_termination();
-void parallel_process_sync(struct All_variables *E);
-double CPU_time0();
-void set_communication_sphereh(struct All_variables *E);
-
-#endif

Copied: mc/3D/CitcomS/branches/cxx/lib/parallel_util.h (from rev 14169, mc/3D/CitcomS/branches/cxx/lib/parallel_related.h)
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/parallel_util.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/parallel_util.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_parallel_util_h)
+#define CitcomS_parallel_util_h
+
+void parallel_process_termination(void);
+void parallel_process_sync(struct All_variables *E);
+double CPU_time0(void);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/parsing.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/parsing.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/parsing.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,6 +25,12 @@
  * 
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#if !defined(CitcomS_parsing_h)
+#define CitcomS_parsing_h
+
+struct All_variables;
+
 void setup_parser(struct All_variables *E, char *filename);
 void shutdown_parser(struct All_variables *E);
 
@@ -37,3 +43,5 @@
 int input_char_vector(char *name, int number, char *value, int m);
 int input_float_vector(char *name,int number, float *value, int m);
 int input_double_vector(char *name, int number, double *value, int m);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/lib/phase_change.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/phase_change.h	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/lib/phase_change.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -25,9 +25,17 @@
  * 
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
+
+#if !defined(CitcomS_phase_change_h)
+#define CitcomS_phase_change_h
+
+struct All_variables;
+
 void phase_change_input(struct All_variables *E);
 void phase_change_allocate(struct All_variables *E);
 
 void phase_change_apply_410(struct All_variables *E, double **buoy);
 void phase_change_apply_670(struct All_variables *E, double **buoy);
 void phase_change_apply_cmb(struct All_variables *E, double **buoy);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/problem_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/problem_related.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/problem_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_problem_related_h)
+#define CitcomS_problem_related_h
+
+struct All_variables;
+
+void read_velocity_boundary_from_file(struct All_variables *E);
+void read_mat_from_file(struct All_variables *E);
+void read_temperature_boundary_from_file(struct All_variables *E);
+void get_initial_elapsed_time(struct All_variables *E);
+void set_elapsed_time(struct All_variables *E);
+void set_starting_age(struct All_variables *E);
+float find_age_in_MY(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/process_buoyancy.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/process_buoyancy.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/process_buoyancy.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,38 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_process_buoyancy_h)
+#define CitcomS_process_buoyancy_h
+
+struct All_variables;
+
+void post_processing(struct All_variables *E);
+void heat_flux(struct All_variables *E);
+void compute_horiz_avg(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_boundary_conditions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_boundary_conditions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_boundary_conditions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_boundary_conditions_h)
+#define CitcomS_regional_boundary_conditions_h
+
+struct All_variables;
+
+void regional_velocity_boundary_conditions(struct All_variables *E);
+void regional_temperature_boundary_conditions(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_geometry_cartesian.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_geometry_cartesian.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_geometry_cartesian.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_geometry_cartesian_h)
+#define CitcomS_regional_geometry_cartesian_h
+
+struct All_variables;
+
+void regional_set_2dc_defaults(struct All_variables *E);
+void regional_set_2pt5dc_defaults(struct All_variables *E);
+void regional_set_3dc_defaults(struct All_variables *E);
+void regional_set_3dsphere_defaults(struct All_variables *E);
+void regional_set_3dsphere_defaults2(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_lith_age_read_files.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_lith_age_read_files.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_lith_age_read_files.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_lith_age_read_files_h)
+#define CitcomS_regional_lith_age_read_files_h
+
+struct All_variables;
+
+void regional_lith_age_read_files(struct All_variables *E, int output);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_parallel_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_parallel_related.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_parallel_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_parallel_related_h)
+#define CitcomS_regional_parallel_related_h
+
+struct All_variables;
+
+void regional_parallel_processor_setup(struct All_variables *E);
+void regional_parallel_domain_decomp0(struct All_variables *E);
+void regional_parallel_domain_boundary_nodes(struct All_variables *E);
+void regional_parallel_communication_routs_v(struct All_variables *E);
+void regional_parallel_communication_routs_s(struct All_variables *E);
+void regional_exchange_id_d(struct All_variables *E, double **U, int lev);
+void regional_exchange_snode_f(struct All_variables *E, float **U1, float **U2, int lev);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_read_input_from_files.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_read_input_from_files.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_read_input_from_files.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_read_input_from_files_h)
+#define CitcomS_regional_read_input_from_files_h
+
+struct All_variables;
+
+void regional_read_input_files_for_timesteps(struct All_variables *E, int action, int output);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_solver.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_solver.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_solver.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_solver_h)
+#define CitcomS_regional_solver_h
+
+struct All_variables;
+
+void regional_solver_init(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_sphere_related.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_sphere_related.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_sphere_related.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_sphere_related_h)
+#define CitcomS_regional_sphere_related_h
+
+struct All_variables;
+
+void regional_coord_of_cap(struct All_variables *E, int m, int icap);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_tracer_advection.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_tracer_advection.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_tracer_advection.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,41 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_tracer_advection_h)
+#define CitcomS_regional_tracer_advection_h
+
+struct All_variables;
+
+void regional_tracer_setup(struct All_variables *E);
+int regional_iget_element(struct All_variables *E, int m, int iprevious_element, double dummy1, double dummy2, double dummy3, double theta, double phi, double rad);
+int regional_icheck_cap(struct All_variables *E, int icap, double theta, double phi, double rad, double junk);
+void regional_get_velocity(struct All_variables *E, int m, int nelem, double theta, double phi, double rad, double *velocity_vector);
+void regional_keep_within_bounds(struct All_variables *E, double *x, double *y, double *z, double *theta, double *phi, double *rad);
+void regional_lost_souls(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/regional_version_dependent.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/regional_version_dependent.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/regional_version_dependent.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_regional_version_dependent_h)
+#define CitcomS_regional_version_dependent_h
+
+struct All_variables;
+
+void regional_node_locations(struct All_variables *E);
+void regional_construct_boundary(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/shape_functions.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/shape_functions.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/shape_functions.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,36 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_shape_functions_h)
+#define CitcomS_shape_functions_h
+
+struct All_variables;
+
+void construct_shape_functions(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/size_does_matter.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/size_does_matter.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/size_does_matter.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,46 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_size_does_matter_h)
+#define CitcomS_size_does_matter_h
+
+struct All_variables;
+
+void twiddle_thumbs(struct All_variables *yawn);
+void construct_shape_function_derivatives(struct All_variables *E);
+void get_rtf_at_vpts(struct All_variables *E, int m, int lev, int el, double rtf[4][9]);
+void get_rtf_at_ppts(struct All_variables *E, int m, int lev, int el, double rtf[4][9]);
+void construct_surf_det(struct All_variables *E);
+void construct_bdry_det(struct All_variables *E);
+void get_global_1d_shape_fn(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dA *dGammax, int top, int m);
+void get_global_1d_shape_fn_L(struct All_variables *E, int el, struct Shape_function1 *GM, struct Shape_function1_dA *dGammax, int top, int m);
+void construct_c3x3matrix_el(struct All_variables *E, int el, struct CC *cc, struct CCX *ccx, int lev, int m, int pressure);
+void construct_side_c3x3matrix_el(struct All_variables *E, int el, struct CC *cc, struct CCX *ccx, int lev, int m, int pressure, int side);
+void mass_matrix(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/solver_conj_grad.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/solver_conj_grad.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/solver_conj_grad.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_solver_conj_grad_h)
+#define CitcomS_solver_conj_grad_h
+
+struct All_variables;
+
+void set_cg_defaults(struct All_variables *E);
+void assemble_forces_iterative(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/solver_multigrid.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/solver_multigrid.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/solver_multigrid.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,39 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_solver_multigrid_h)
+#define CitcomS_solver_multigrid_h
+
+struct All_variables;
+
+void set_mg_defaults(struct All_variables *E);
+void interp_vector(struct All_variables *E, int start_lev, double **AD, double **AU);
+void project_viscosity(struct All_variables *E);
+void project_vector(struct All_variables *E, int start_lev, double **AU, double **AD, int ic);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/sphere_harmonics.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/sphere_harmonics.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/sphere_harmonics.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,38 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_sphere_harmonics_h)
+#define CitcomS_sphere_harmonics_h
+
+struct All_variables;
+
+void set_sphere_harmonics(struct All_variables *E);
+double modified_plgndr_a(int l, int m, double t);
+void sphere_expansion(struct All_variables *E, float **TG, float *sphc, float *sphs);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/sphere_util.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/sphere_util.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/sphere_util.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_sphere_util_h)
+#define CitcomS_sphere_util_h
+
+struct All_variables;
+
+void even_divide_arc12(int elx, double x1, double y1, double z1, double x2, double y2, double z2, double *theta, double *fi);
+void compute_angle_surf_area(struct All_variables *E);
+double area_sphere_cap(double angle[6]);
+double area_of_sphere_triag(double a, double b, double c);
+double area_of_5points(struct All_variables *E, int lev, int m, int el, double x[4], int ne);
+void get_angle_sphere_cap(double xx[4][5], double angle[6]);
+double get_angle(double x[4], double xx[4]);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/stokes_flow_incomp.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/stokes_flow_incomp.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/stokes_flow_incomp.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,37 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_stokes_flow_incomp_h)
+#define CitcomS_stokes_flow_incomp_h
+
+struct All_variables;
+
+void solve_constrained_flow_iterative(struct All_variables *E);
+void solve_constrained_flow_iterative_pseudo_surf(struct All_variables *E);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/topo_gravity.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/topo_gravity.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/topo_gravity.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,42 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_topo_gravity_h)
+#define CitcomS_topo_gravity_h
+
+struct All_variables;
+
+void get_STD_topo(struct All_variables *E, float **tpg, float **tpgb, float **divg, float **vort, int ii);
+void get_STD_freesurf(struct All_variables *E, float **freesurf);
+void allocate_STD_mem(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
+void free_STD_mem(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
+void compute_nodal_stress(struct All_variables *E, float **SXX, float **SYY, float **SZZ, float **SXY, float **SXZ, float **SZY, float **divv, float **vorv);
+void compute_geoid(struct All_variables *E);
+void get_CBF_topo(struct All_variables *E, float **H, float **HB);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/tracer_setup.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/tracer_setup.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/tracer_setup.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,48 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_tracer_setup_h)
+#define CitcomS_tracer_setup_h
+
+struct All_variables;
+
+void tracer_input(struct All_variables *E);
+void tracer_initial_settings(struct All_variables *E);
+void tracer_advection(struct All_variables *E);
+void count_tracers_of_flavors(struct All_variables *E);
+void initialize_tracers(struct All_variables *E);
+void cart_to_sphere(struct All_variables *E, double x, double y, double z, double *theta, double *phi, double *rad);
+void sphere_to_cart(struct All_variables *E, double theta, double phi, double rad, double *x, double *y, double *z);
+void get_neighboring_caps(struct All_variables *E);
+void allocate_tracer_arrays(struct All_variables *E, int j, int number_of_tracers);
+void expand_tracer_arrays(struct All_variables *E, int j);
+void expand_later_array(struct All_variables *E, int j);
+int icheck_processor_shell(struct All_variables *E, int j, double rad);
+int icheck_that_processor_shell(struct All_variables *E, int j, int nprocessor, double rad);
+
+#endif

Added: mc/3D/CitcomS/branches/cxx/lib/viscosity_structures.h
===================================================================
--- mc/3D/CitcomS/branches/cxx/lib/viscosity_structures.h	                        (rev 0)
+++ mc/3D/CitcomS/branches/cxx/lib/viscosity_structures.h	2009-04-09 03:05:05 UTC (rev 14643)
@@ -0,0 +1,39 @@
+/*
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 
+ *<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>
+ * 
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#if !defined(CitcomS_viscosity_structures_h)
+#define CitcomS_viscosity_structures_h
+
+struct All_variables;
+
+void viscosity_input(struct All_variables *E);
+void get_system_viscosity(struct All_variables *E, int propogate, float **evisc, float **visc);
+void initial_viscosity(struct All_variables *E);
+void strain_rate_2_inv(struct All_variables *E, int m, float *EEDOT, int SQRT);
+
+#endif

Modified: mc/3D/CitcomS/branches/cxx/module/advdiffu.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/advdiffu.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/advdiffu.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -33,10 +33,9 @@
 #include "global_defs.h"
 #include "advection_diffusion.h"
 
+#include "convection.h"
 
-extern void set_convection_defaults(struct All_variables *);
 
-
 char pyCitcom_PG_timestep_init__doc__[] = "";
 char pyCitcom_PG_timestep_init__name__[] = "PG_timestep_init";
 PyObject * pyCitcom_PG_timestep_init(PyObject *self, PyObject *args)

Modified: mc/3D/CitcomS/branches/cxx/module/initial_conditions.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/initial_conditions.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/initial_conditions.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -31,17 +31,14 @@
 
 #include "global_defs.h"
 
+#include "checkpoints.h"
+#include "composition_related.h"
+#include "instructions.h"
+#include "parallel_util.h"
+#include "process_buoyancy.h"
+#include "tracer_setup.h"
+#include "viscosity_structures.h"
 
-void initialize_material(struct All_variables*);
-void initialize_tracers(struct All_variables*);
-void init_composition(struct All_variables*);
-void initial_pressure(struct All_variables*);
-void initial_velocity(struct All_variables*);
-void initial_viscosity(struct All_variables*);
-void parallel_process_termination();
-void post_processing(struct All_variables*);
-void report(struct All_variables*, char* str);
-void read_checkpoint(struct All_variables*);
 
 char pyCitcom_ic_initialize_material__doc__[] = "";
 char pyCitcom_ic_initialize_material__name__[] = "initialize_material";

Modified: mc/3D/CitcomS/branches/cxx/module/mesher.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/mesher.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/mesher.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -31,13 +31,10 @@
 #include "mesher.h"
 
 #include "global_defs.h"
-#include "parallel_related.h"
+#include "instructions.h"
+#include "parallel_util.h"
 
 
-extern void initial_mesh_solver_setup(struct All_variables *);
-
-
-
 char pyCitcom_full_sphere_launch__doc__[] = "";
 char pyCitcom_full_sphere_launch__name__[] = "full_sphere_launch";
 

Modified: mc/3D/CitcomS/branches/cxx/module/misc.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/misc.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/misc.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -36,27 +36,19 @@
 #include "citcom_init.h"
 #include "advection_diffusion.h"
 
+#include "mpi/pympi.h"
 
-void full_solver_init(struct All_variables*);
-void regional_solver_init(struct All_variables*);
+#include "bc_util.h"
+#include "full_solver.h"
+#include "instructions.h"
+#include "interuption.h"
+#include "pan_problem_misc_functions.h"
+#include "parallel_util.h"
+#include "problem_related.h"
+#include "regional_solver.h"
+#include "tracer_setup.h"
 
-double return1_test();
-void read_instructions(struct All_variables*, char*);
-double CPU_time0();
 
-void global_default_values(struct All_variables*);
-void parallel_process_termination();
-void read_mat_from_file(struct All_variables*);
-void read_temperature_boundary_from_file(struct All_variables*);
-void read_velocity_boundary_from_file(struct All_variables*);
-void set_signal();
-void check_settings_consistency(struct All_variables *);
-void tracer_advection(struct All_variables*);
-void velocities_conform_bcs(struct All_variables*, double **);
-
-
-#include "mpi/pympi.h"
-
 /* copyright */
 
 char pyCitcom_copyright__doc__[] = "";

Modified: mc/3D/CitcomS/branches/cxx/module/outputs.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/outputs.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/outputs.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -33,10 +33,10 @@
 #include "global_defs.h"
 #include "output.h"
 
+#include "checkpoints.h"
+#include "instructions.h"
 
-void output_finalize(struct  All_variables *E);
 
-
 char pyCitcom_output__doc__[] = "";
 char pyCitcom_output__name__[] = "output";
 

Modified: mc/3D/CitcomS/branches/cxx/module/setProperties.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/setProperties.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/setProperties.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -31,10 +31,13 @@
 #include <string.h>
 #include <math.h>
 #include "global_defs.h"
-#include "parallel_related.h"
+#include "parallel_util.h"
 #include "setProperties.h"
 
+#include "instructions.h"
+#include "pan_problem_misc_functions.h"
 
+
 /* See PEP 353. */
 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
 typedef int Py_ssize_t;
@@ -76,9 +79,6 @@
 #define getDoubleVectorProperty(p, a, v, l, o) if (-1 == _getDoubleVectorProperty(p, a, v, l, o)) return NULL
 
 
-void myerror(struct All_variables *,char *);
-void report(struct All_variables *,char *);
-
 /*==============================================================*/
 
 

Modified: mc/3D/CitcomS/branches/cxx/module/stokes_solver.cc
===================================================================
--- mc/3D/CitcomS/branches/cxx/module/stokes_solver.cc	2009-04-08 23:39:49 UTC (rev 14642)
+++ mc/3D/CitcomS/branches/cxx/module/stokes_solver.cc	2009-04-09 03:05:05 UTC (rev 14643)
@@ -34,22 +34,14 @@
 #include "global_defs.h"
 #include "drive_solvers.h"
 
+#include "construct_arrays.h"
+#include "element_calculations.h"
+#include "solver_conj_grad.h"
+#include "solver_multigrid.h"
+#include "stokes_flow_incomp.h"
+#include "viscosity_structures.h"
 
-void assemble_forces(struct All_variables*, int);
-void construct_stiffness_B_matrix(struct All_variables*);
-void general_stokes_solver(struct All_variables *);
-void general_stokes_solver_setup(struct All_variables*);
-void get_system_viscosity(struct All_variables*, int, float**, float**);
-void set_cg_defaults(struct All_variables*);
-void set_mg_defaults(struct All_variables*);
-void solve_constrained_flow_iterative(struct All_variables*);
 
-void assemble_forces_pseudo_surf(struct All_variables*, int);
-void general_stokes_solver_pseudo_surf(struct All_variables *);
-void solve_constrained_flow_iterative_pseudo_surf(struct All_variables*);
-
-
-
 char pyCitcom_assemble_forces__doc__[] = "";
 char pyCitcom_assemble_forces__name__[] = "assemble_forces";
 



More information about the CIG-COMMITS mailing list