[Swift-commit] r8147 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Wed Aug 13 16:19:54 CDT 2014


Author: wozniak
Date: 2014-08-13 16:19:54 -0500 (Wed, 13 Aug 2014)
New Revision: 8147

Added:
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh
Modified:
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c
   SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h
Log:
Copy back from xsede demo


Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile	2014-08-13 20:17:50 UTC (rev 8146)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile	2014-08-13 21:19:54 UTC (rev 8147)
@@ -24,20 +24,30 @@
 
 TCL_HOME = $(HOME)/sfw/tcl-8.6.0
 INCLUDES += -I $(TCL_HOME)/include
+TCLSH = $(TCL_HOME)/bin/tclsh8.6
 
-swift-pkg: libtclmd.so
+swift-pkg: pkgIndex.tcl
 
-md_wrap.c: md.i
+md_wrap.c: md.i md.h
 	swig $(<)
+	sed -i s/Md_Init/Tclmd_Init/ $(@)
 
 libtclmd.so: md_wrap.o $(OBJ)
 	gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 
 
-endif
+pkgIndex.tcl: libtclmd.so
+	LEAF_PKG=md LEAF_VERSION=0.0 \
+	LEAF_SO=$(<) LEAF_TCL=md.tcl \
+	$(TCLSH) ./make-package.tcl > $(@)
 
+clean:: 
+	rm -fv pkgIndex.tcl libtclmd.so md_wrap.c
+
+endif # Swift/T
+
 .PHONY: clean
-clean:
-	rm -f $(OBJ) $(bin)
+clean::
+	rm -fv $(OBJ) $(bin)
 
 .PHONY: install
 install:

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,2 @@
+#! /bin/sh
+rm -f md??.trj md.dat


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh
___________________________________________________________________
Added: svn:executable
   + *

Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c	2014-08-13 20:17:50 UTC (rev 8146)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c	2014-08-13 21:19:54 UTC (rev 8147)
@@ -12,7 +12,7 @@
 
 
 char *outfile = "md.dat";
-char *trjfile = "md.trj.tgz";
+char *trjfile = "md.trj";
 
 
 /******************************************************************************/
@@ -71,16 +71,12 @@
   double ctime1;
   double ctime2;
   double dt = 0.0001;
-  double e0;
-  double *force;
   int i;
   int id;
-  double kinetic;
   double mass = 1.0 * .0001;
   int nd;
   int np;
 
-  double potential;
   int seed = 123456789;
   int step;
   int step_num;
@@ -193,8 +189,8 @@
   ctime1 = cpu_time ( );
 
   simulate (step_num, step_print_num, step_print, step_print_index,
-            np, nd, mass, potential, kinetic, e0,
-            dt, seed, outfile);
+            np, nd, mass,
+            dt, seed, outfile, trjfile);
 
   ctime2 = cpu_time ( );
   ctime = ctime2 - ctime1;
@@ -203,10 +199,12 @@
   printf ( "  Elapsed cpu time for main computation:\n" );
   printf ( "  %f seconds.\n", ctime );
 
-
+#ifdef NOTDEF
   char tarcmd[2000];
   sprintf(tarcmd,"tar zcf %s md??.trj",trjfile);
   system(tarcmd);
+#endif
+
 /*
   Terminate.
 */

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,9 @@
+
+set name     $env(LEAF_PKG)
+set version  $env(LEAF_VERSION)
+set leaf_so  $env(LEAF_SO)
+set leaf_tcl $env(LEAF_TCL)
+
+puts [ ::pkg::create -name $name -version $version \
+           -load $leaf_so -source $leaf_tcl ]
+


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl
___________________________________________________________________
Added: svn:executable
   + *

Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c	2014-08-13 20:17:50 UTC (rev 8146)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c	2014-08-13 21:19:54 UTC (rev 8147)
@@ -18,17 +18,17 @@
 void snap ( int np, int nd, int t, double pos[], double vel[], double f[],
   double acc[], double mass, double dt );
 
-static void snap_file_open(void);
-static void snap_file_close(void);
+static void trj_file_open(char *trjfile);
+static void trj_file_close(void);
 
 void simulate (int step_num, int step_print_num,
                int step_print, int step_print_index,
                int np, int nd,
                double mass,
-               double potential, double kinetic, double e0,
                double dt,
                int seed,
-               char* outfile)
+               char* outfile,
+               char* trjfile)
 {
   /*
     Allocate memory.
@@ -49,7 +49,7 @@
     printf ( "\n" );
     printf ( "  Initializing positions, velocities, and accelerations.\n" );
 
-    snap_file_open();
+    trj_file_open(trjfile);
 
   /*
     Set initial positions, velocities, and accelerations.
@@ -61,9 +61,9 @@
     printf ( "\n" );
     printf ( "  Computing initial forces and energies.\n" );
 
+    double potential, kinetic;
     compute ( np, nd, pos, vel, mass, force, &potential, &kinetic );
-
-    e0 = potential + kinetic;
+    double e0 = potential + kinetic;
   /*
     This is the main time stepping loop:
       Compute forces and energies,
@@ -115,7 +115,7 @@
   free ( vel );
 
   fclose(ofile);
-  snap_file_close();
+  trj_file_close();
 }
 
 /******************************************************************************/
@@ -580,20 +580,22 @@
 }
 
 static int snapid = 0;
-static FILE *snap_file = NULL;
+static FILE *trj_file = NULL;
 
-static void snap_file_open()
+static void trj_file_open(char *trjfile)
 {
+#ifdef NOTDEF
   char snapfile[100];
   sprintf(snapfile, "md%02d.trj", snapid);
-  snap_file = fopen(snapfile, "w");
-  assert(snap_file != NULL);
+#endif
+  trj_file = fopen(trjfile, "w");
+  assert(trj_file != NULL);
 }
 
-static void snap_file_close()
+static void trj_file_close()
 {
-  fclose(snap_file);
-  snap_file = NULL;
+  fclose(trj_file);
+  trj_file = NULL;
 }
 
 void snap ( int np, int nd, int t, double pos[], double vel[], double f[],
@@ -603,8 +605,8 @@
 
   for ( j = 0; j < np; j++ )
   {
-    fprintf(snap_file, "%i s %f %f %f %s\n",
-            t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo);
+    fprintf(trj_file, "%d s %f %f %f %s\n",
+            snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo);
   }
 
   snapid++;

Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h	2014-08-13 20:17:50 UTC (rev 8146)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h	2014-08-13 21:19:54 UTC (rev 8147)
@@ -25,9 +25,9 @@
                int step_print, int step_print_index,
                int np, int nd,
                double mass,
-               double potential, double kinetic, double e0,
                double dt,
                int seed,
-               char* outfile);
+               char* outfile,
+               char* trjfile);
 
 #endif

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,6 @@
+
+%module md
+%include "md.h"
+%{
+  #include "md.h"
+%}

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,4 @@
+
+namespace eval md { 
+    # Nothing 
+}

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,21 @@
+#!/usr/bin/env tclsh8.6
+
+lappend auto_path $env(PWD)
+package require md 0.0
+
+set cmds [ info commands ]
+
+set L [list]
+
+foreach cmd $cmds {
+    puts $cmd
+    if { [ regexp .*.* $cmd ] || \
+         [ regexp .*.* $cmd ] } {
+        lappend L $cmd
+    }
+}
+
+set L [ lsort $L ]
+foreach cmd $L {
+    puts $cmd
+}


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,8 @@
+#!/usr/bin/env tclsh8.6
+
+lappend auto_path $env(PWD)
+package require md 0.0
+
+simulate 4 2 0 0 10 2 1  0.1 9 out.txt out.trj
+
+


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh	                        (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh	2014-08-13 21:19:54 UTC (rev 8147)
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+./md 3 50 1000


Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh
___________________________________________________________________
Added: svn:executable
   + *




More information about the Swift-commit mailing list