<p><b>duda</b> 2009-07-30 11:31:22 -0600 (Thu, 30 Jul 2009)</p><p>Modifications to divert the stdout and stderr streams for each<br>
MPI task to separate files. For example, the stdout and stderr<br>
streams for task 5 will now go to log.0005.out and log.0005.err,<br>
respectively.<br>
<br>
M    swmodel/module_dmpar.F<br>
A    swmodel/streams.c<br>
M    swmodel/Makefile<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/swmodel/Makefile
===================================================================
--- trunk/swmodel/Makefile        2009-07-30 16:35:35 UTC (rev 9)
+++ trunk/swmodel/Makefile        2009-07-30 17:31:22 UTC (rev 10)
@@ -15,7 +15,7 @@
 CFLAGS = -O3
 LDFLAGS = -O3
 
-CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI
+CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE
 INCLUDES = -I$(NETCDF)/include
 LIBS = -L$(NETCDF)/lib -lnetcdf
 
@@ -34,7 +34,8 @@
        module_dmpar.o \
        module_io_input.o \
        module_io_output.o \
-       module_time_integration.o
+       module_time_integration.o \
+       streams.o
 
 all: swmodel
 
@@ -42,7 +43,7 @@
 
 module_grid_types.o: module_dmpar.o
 
-module_dmpar.o: module_sort.o
+module_dmpar.o: module_sort.o streams.o
 
 module_block_decomp.o: module_grid_types.o module_hash.o
 
@@ -67,3 +68,7 @@
         $(CPP) $(CPPFLAGS) $&lt; &gt; $*.f90
         $(FC) $(FFLAGS) -c $*.f90 $(INCLUDES)
         $(RM) $*.f90
+
+.c.o:
+        $(RM) $@
+        $(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c $(INCLUDES)

Modified: trunk/swmodel/module_dmpar.F
===================================================================
--- trunk/swmodel/module_dmpar.F        2009-07-30 16:35:35 UTC (rev 9)
+++ trunk/swmodel/module_dmpar.F        2009-07-30 17:31:22 UTC (rev 10)
@@ -55,6 +55,10 @@
       dminfo % nprocs = mpi_size
       dminfo % my_proc_id = mpi_rank
 
+      write(0,'(a,i5,a,i5,a)') 'task ', mpi_rank, ' of ', mpi_size, ' is running'
+
+      call open_streams(dminfo % my_proc_id)
+
 #else
       dminfo % comm = 0
       dminfo % my_proc_id = IO_NODE

Added: trunk/swmodel/streams.c
===================================================================
--- trunk/swmodel/streams.c                                (rev 0)
+++ trunk/swmodel/streams.c        2009-07-30 17:31:22 UTC (rev 10)
@@ -0,0 +1,39 @@
+#include &lt;stdio.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;unistd.h&gt;
+
+#ifdef UNDERSCORE
+#define open_streams open_streams_
+#define close_streams close_streams_
+#else
+#ifdef DOUBLEUNDERSCORE
+#define open_streams open_streams__
+#define close_streams close_streams__
+#endif
+#endif
+
+int fd_out, fd_err;
+
+void open_streams(int * id)
+{
+   char fname[128];
+
+   sprintf(fname, &quot;log.%4.4i.err&quot;, *id);
+   fd_err = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+   if (dup2(fd_err, 2) &lt; 0) {
+      printf(&quot;Error duplicating STDERR</font>
<font color="blue">&quot;);
+      return;
+   }
+
+   sprintf(fname, &quot;log.%4.4i.out&quot;, *id);
+   fd_out = open(fname,O_CREAT|O_WRONLY|O_TRUNC,0644);
+   if (dup2(fd_out, 1) &lt; 0) {
+      printf(&quot;Error duplicating STDOUT</font>
<font color="blue">&quot;);
+      return;
+   }
+}
+
+void close_streams()
+{
+
+}

</font>
</pre>