[cig-commits] r4118 - in mc/3D/CitcomS/trunk: CitcomS CitcomS/Solver bin lib module

tan2 at geodynamics.org tan2 at geodynamics.org
Thu Jul 27 15:02:42 PDT 2006


Author: tan2
Date: 2006-07-27 15:02:42 -0700 (Thu, 27 Jul 2006)
New Revision: 4118

Modified:
   mc/3D/CitcomS/trunk/CitcomS/Controller.py
   mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
   mc/3D/CitcomS/trunk/bin/Citcom.c
   mc/3D/CitcomS/trunk/lib/Instructions.c
   mc/3D/CitcomS/trunk/lib/Output.c
   mc/3D/CitcomS/trunk/lib/global_defs.h
   mc/3D/CitcomS/trunk/module/mesher.cc
Log:
Moved the responsibility of time output from Citcom.c and Solver.py to Output.c, which includes the following changes
   * open .time file at either mesher.cc (for pyre run) or Instructions.c (for C run)
   * .time file is opened and closed only by the rank-0 processor. This will avoid multiple processors opening/writing/closing on the same file. Similar modification is necessary for the .log file.
   * created two variables E->monitor.cpu_time_at_start and E->monitor.cpu_time_at_last_cycles for storing the wall clock time at startup and last timestep, respectively
   * output .time file in output_time() in Output.c


Modified: mc/3D/CitcomS/trunk/CitcomS/Controller.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Controller.py	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/CitcomS/Controller.py	2006-07-27 22:02:42 UTC (rev 4118)
@@ -134,7 +134,6 @@
 
     def save(self):
         step = self.step
-        self.solver.timesave(self.clock, self.dt, step)
         self.solver.save(step, self.inventory.monitoringFrequency)
         return
 

Modified: mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py
===================================================================
--- mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/CitcomS/Solver/Solver.py	2006-07-27 22:02:42 UTC (rev 4118)
@@ -71,7 +71,7 @@
         self.fptime = open("%s.time" % self.inventory.datafile, "w")
 
 	inv = self.inventory
-        
+
         inv.mesher.initialize(all_variables)
         inv.tsolver.initialize(all_variables)
         inv.vsolver.initialize(all_variables)
@@ -256,27 +256,10 @@
         return
 
 
-    def timesave(self, t, dt, steps):
-        '''output time information
-        '''
-
-        time = CPU_time()
-        msg = "%d %.4e %.4e %.4e %.4e" % (steps,
-                                          t,
-                                          dt,
-                                          time - self.start_cpu_time,
-                                          time - self.cpu_time)
-        print >> self.fptime, msg
-        self.fptime.flush()
-
-        self.cpu_time = time
-        return
-
-
     def setProperties(self):
- 
+
         from CitcomSLib import Solver_set_properties
-        
+
         Solver_set_properties(self.all_variables, self.inventory)
 
 	inv = self.inventory

Modified: mc/3D/CitcomS/trunk/bin/Citcom.c
===================================================================
--- mc/3D/CitcomS/trunk/bin/Citcom.c	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/bin/Citcom.c	2006-07-27 22:02:42 UTC (rev 4118)
@@ -1,6 +1,6 @@
 /*
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
+ *
  *<LicenseText>
  *
  * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *</LicenseText>
- * 
+ *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #include <mpi.h>
@@ -76,7 +76,7 @@
 
   world = MPI_COMM_WORLD;
   E = citcom_init(&world);             /* allocate global E and do initializaion here */
-  
+
 #ifdef CITCOMS_SOLVER_FULL
   full_solver_init(E);
 #else
@@ -85,7 +85,6 @@
 
   start_time = time = CPU_time0();
   read_instructions(E, argv[1]);
-  open_time(E);
 
   cpu_time_on_vp_it = CPU_time0();
   initial_time = cpu_time_on_vp_it - time;
@@ -182,9 +181,7 @@
 
     if (E->parallel.me == 0)  {
       fprintf(E->fp,"CPU total = %g & CPU = %g for step %d time = %.4e dt = %.4e  maxT = %.4e sub_iteration%d\n",CPU_time0()-start_time,CPU_time0()-time,E->monitor.solution_cycles,E->monitor.elapsed_time,E->advection.timestep,E->monitor.T_interior,E->advection.last_sub_iterations);
-      /* added a time output CPC 6/18/00 */
-      fprintf(E->fptime,"%d %.4e %.4e %.4e %.4e\n",E->monitor.solution_cycles,E->monitor.elapsed_time,E->advection.timestep,CPU_time0()-start_time,CPU_time0()-time);
-/*       fprintf(stderr,"%d %.4e %.4e %.4e %.4e\n",E->monitor.solution_cycles,E->monitor.elapsed_time,E->advection.timestep,CPU_time0()-start_time,CPU_time0()-time); */
+
       time = CPU_time0();
     }
 
@@ -204,8 +201,10 @@
   }
 
   fclose(E->fp);
-  fclose(E->fptime);
 
+  if (E->fptime)
+    fclose(E->fptime);
+
   parallel_process_termination();
 
   return(0);

Modified: mc/3D/CitcomS/trunk/lib/Instructions.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Instructions.c	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/lib/Instructions.c	2006-07-27 22:02:42 UTC (rev 4118)
@@ -1,6 +1,6 @@
 /*
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
+ *
  *<LicenseText>
  *
  * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *</LicenseText>
- * 
+ *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 /* Set up the finite element problem to suit: returns with all memory */
@@ -83,14 +83,15 @@
     void set_elapsed_time();
 
 
-    double start_time, CPU_time0();
+    double CPU_time0();
     double global_vdot();
 
     /* =====================================================
        Global interuption handling routine defined once here
        =====================================================  */
 
-    if (E->parallel.me==0) start_time=CPU_time0();
+    E->monitor.cpu_time_at_last_cycle =
+        E->monitor.cpu_time_at_start = CPU_time0();
 
     set_signal();
 
@@ -107,6 +108,7 @@
     read_initial_settings(E);
 
     open_log(E);
+    open_time(E);
     if (E->control.verbose)
       open_info(E);
 
@@ -163,7 +165,8 @@
 
     general_stokes_solver_setup(E);
 
-    if (E->parallel.me==0) fprintf(stderr,"time=%f\n",CPU_time0()-start_time);
+    if (E->parallel.me==0) fprintf(stderr,"time=%f\n",
+				   CPU_time0()-E->monitor.cpu_time_at_start);
 
     construct_surf_det (E);
     construct_bdry_det (E);
@@ -937,8 +940,12 @@
 {
   char timeoutput[255];
 
-  sprintf(timeoutput,"%s.time",E->control.data_file);
-  E->fptime = output_open(timeoutput);
+  if (E->parallel.me == 0) {
+    sprintf(timeoutput,"%s.time",E->control.data_file);
+    E->fptime = output_open(timeoutput);
+  }
+  else
+    E->fptime = NULL;
 
   return;
 }

Modified: mc/3D/CitcomS/trunk/lib/Output.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Output.c	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/lib/Output.c	2006-07-27 22:02:42 UTC (rev 4118)
@@ -1,6 +1,6 @@
 /*
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
+ *
  *<LicenseText>
  *
  * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *</LicenseText>
- * 
+ *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 /* Routine to process the output of the finite element cycles
@@ -45,6 +45,7 @@
 void output_stress(struct All_variables *, int);
 void output_ave_r(struct All_variables *, int);
 void output_tracer(struct All_variables *, int);
+void output_time(struct All_variables *, int);
 
 extern void parallel_process_termination();
 extern void heat_flux(struct All_variables *);
@@ -81,6 +82,9 @@
   /* disable horizontal average output   by Tan2 */
   /* output_ave_r(E, cycles); */
 
+  /* information about simulation time and wall clock time */
+  output_time(E, cycles);
+
   return;
 }
 
@@ -431,3 +435,22 @@
 }
 
 
+void output_time(struct All_variables *E, int cycles)
+{
+  double CPU_time0();
+
+  double current_time = CPU_time0();
+
+  if (E->parallel.me == 0) {
+    fprintf(E->fptime,"%d %.4e %.4e %.4e %.4e\n",
+	    cycles,
+	    E->monitor.elapsed_time,
+	    E->advection.timestep,
+	    current_time - E->monitor.cpu_time_at_start,
+	    current_time - E->monitor.cpu_time_at_last_cycle);
+  }
+
+  E->monitor.cpu_time_at_last_cycle = current_time;
+
+  return;
+}

Modified: mc/3D/CitcomS/trunk/lib/global_defs.h
===================================================================
--- mc/3D/CitcomS/trunk/lib/global_defs.h	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/lib/global_defs.h	2006-07-27 22:02:42 UTC (rev 4118)
@@ -1,6 +1,6 @@
 /*
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
+ *
  *<LicenseText>
  *
  * CitcomS by Louis Moresi, Shijie Zhong, Lijie Han, Eh Tan,
@@ -22,7 +22,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *</LicenseText>
- * 
+ *
  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #if !defined(CitcomS_global_defs_h)
@@ -580,6 +580,8 @@
     float  vdotv;
     float  nond_av_heat_fl;
     float  nond_av_adv_hfl;
+    float  cpu_time_at_start;
+    float  cpu_time_at_last_cycle;
     float  cpu_time_elapsed;
     float  cpu_time_on_vp_it;
     float  cpu_time_on_forces;
@@ -637,20 +639,20 @@
     int CART2pt5D;
     int CART3D;
     int AXI;
-    
+
     char SOLVER_TYPE[20]; /* one of ... */
     int DIRECT;
     int CONJ_GRAD;
     int NMULTIGRID;
     int EMULTIGRID;
     int DIRECTII;
-    
+
     char NODE_SPACING[20]; /* turns into ... */
     int GRID_TYPE;
     int COMPRESS;
     int AVS;
     int CONMAN;
-    
+
     int read_density;
     int read_slab;
     int read_slabgeoid;

Modified: mc/3D/CitcomS/trunk/module/mesher.cc
===================================================================
--- mc/3D/CitcomS/trunk/module/mesher.cc	2006-07-27 21:09:26 UTC (rev 4117)
+++ mc/3D/CitcomS/trunk/module/mesher.cc	2006-07-27 22:02:42 UTC (rev 4118)
@@ -56,11 +56,13 @@
     void mass_matrix(struct All_variables*);
     void open_info(struct All_variables*);
     void open_log(struct All_variables*);
+    void open_time(struct All_variables*);
     void read_mat_from_file(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*);
+    double CPU_time0();
 
 }
 
@@ -71,9 +73,13 @@
     // copied from read_instructions()
 {
 
+    E->monitor.cpu_time_at_last_cycle =
+        E->monitor.cpu_time_at_start = CPU_time0();
+
     E->control.PID = get_process_identifier();
 
     open_log(E);
+    open_time(E);
     if (E->control.verbose)
       open_info(E);
 



More information about the cig-commits mailing list