[Swift-commit] r4394 - trunk/tests/mpi

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Thu Apr 21 11:19:57 CDT 2011


Author: wozniak
Date: 2011-04-21 11:19:57 -0500 (Thu, 21 Apr 2011)
New Revision: 4394

Modified:
   trunk/tests/mpi/100-mpi-cp.c
Log:
Minor improvements to MPI test case


Modified: trunk/tests/mpi/100-mpi-cp.c
===================================================================
--- trunk/tests/mpi/100-mpi-cp.c	2011-04-20 22:13:51 UTC (rev 4393)
+++ trunk/tests/mpi/100-mpi-cp.c	2011-04-21 16:19:57 UTC (rev 4394)
@@ -19,6 +19,7 @@
 #define max(a, b) (((a) > (b)) ? (a) : (b))
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 
+void print_help(void);
 void read_input(const char *restrict filename, char** data, int* size);
 void write_output(const char *restrict filename, char* data, int size);
 void startup(void);
@@ -43,7 +44,11 @@
   char* data;
   int size;
 
-  assert(argc == 3);
+  if (argc != 3)
+  {
+    print_help();
+    return 1;
+  }
 
   if (mpi_rank == 0)
   {
@@ -69,6 +74,7 @@
 
     write_output(argv[2], data, size);
   }
+  free(data);
 
   MPI_Finalize();
   return EXIT_SUCCESS;
@@ -84,6 +90,9 @@
   fflush(NULL);
 }
 
+/**
+   Allocates memory for *data
+*/
 void read_input(const char* restrict filename, char** data, int* size)
 {
   char* result;
@@ -139,3 +148,8 @@
 
   fclose(file);
 }
+
+void print_help()
+{
+  printf("usage: <input> <output>\n");
+}




More information about the Swift-commit mailing list