<p><b>dwj07@fsu.edu</b> 2012-03-14 19:42:47 -0600 (Wed, 14 Mar 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Updating makefile system, to be compatible with other versions of make (like gmake).<br>
        Forcing serial make (suppressing any calls with -jN where N &gt; 1) beacuse parallel builds don't work yet.<br>
        Updating makefile to support netcdf4 as well as netcdf3. <br>
<br>
        Editing streams.c to only write log.*.out and log.*.err for master process unless built in debug mode.<br>
        Adding a MPAS_DEBUG flag, to enable debug only sections of code.<br>
<br>
        If build in debug mode, all log.*.out and log.*.err files are written, as is the current behavior.<br>
        If you want to edit this, you can add -DMPAS_DEBUG to the _OPT flags for the compiler you are interested in.<br>
<br>
        This is currently the only section of code that has MPAS_DEBUG around it in MPAS, so you won't affect any other<br>
        parts of MPAS.<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/mpas/Makefile
===================================================================
--- trunk/mpas/Makefile        2012-03-14 22:07:00 UTC (rev 1643)
+++ trunk/mpas/Makefile        2012-03-15 01:42:47 UTC (rev 1644)
@@ -14,10 +14,10 @@
 
 
 dummy:
-        ( make error )
+        ( $(MAKE) error )
 
 xlf:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpxlf90&quot; \
         &quot;CC_PARALLEL = mpcc&quot; \
         &quot;FC_SERIAL = xlf90&quot; \
@@ -32,7 +32,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
  
 ftn:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = ftn&quot; \
         &quot;CC_PARALLEL = cc&quot; \
         &quot;FC_SERIAL = ftn&quot; \
@@ -47,7 +47,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 pgi:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpif90&quot; \
         &quot;CC_PARALLEL = mpicc&quot; \
         &quot;FC_SERIAL = pgf90&quot; \
@@ -65,7 +65,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 pgi-nersc:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = ftn&quot; \
         &quot;CC_PARALLEL = cc&quot; \
         &quot;FC_SERIAL = ftn&quot; \
@@ -80,7 +80,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 pgi-llnl:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpipgf90&quot; \
         &quot;CC_PARALLEL = pgcc&quot; \
         &quot;FC_SERIAL = pgf90&quot; \
@@ -95,7 +95,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 ifort:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpif90&quot; \
         &quot;CC_PARALLEL = gcc&quot; \
         &quot;FC_SERIAL = ifort&quot; \
@@ -113,7 +113,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 gfortran:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpif90&quot; \
         &quot;CC_PARALLEL = mpicc&quot; \
         &quot;FC_SERIAL = gfortran&quot; \
@@ -131,7 +131,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 g95:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = mpif90&quot; \
         &quot;CC_PARALLEL = mpicc&quot; \
         &quot;FC_SERIAL = g95&quot; \
@@ -146,7 +146,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 pathscale-nersc:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = ftn&quot; \
         &quot;CC_PARALLEL = cc&quot; \
         &quot;FC_SERIAL = ftn&quot; \
@@ -161,7 +161,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 cray-nersc:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = ftn&quot; \
         &quot;CC_PARALLEL = cc&quot; \
         &quot;FC_SERIAL = ftn&quot; \
@@ -176,7 +176,7 @@
         &quot;CPPFLAGS = $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)&quot; )
 
 intel-nersc:
-        ( make all \
+        ( $(MAKE) all \
         &quot;FC_PARALLEL = ftn&quot; \
         &quot;CC_PARALLEL = cc&quot; \
         &quot;FC_SERIAL = ftn&quot; \
@@ -227,9 +227,9 @@
         LDFLAGS=$(LDFLAGS_OPT)
         DEBUG_MESSAGE=&quot;Debug flags are not defined for this compile group. Defaulting to Optimized flags&quot;
 else # FFLAGS_DEBUG IF
-        FFLAGS=$(FFLAGS_DEBUG)
-        CFLAGS=$(CFLAGS_DEBUG)
-        LDFLAGS=$(LDFLAGS_DEBUG)
+        FFLAGS=$(FFLAGS_DEBUG) -DMPAS_DEBUG
+        CFLAGS=$(CFLAGS_DEBUG) -DMPAS_DEBUG
+        LDFLAGS=$(LDFLAGS_DEBUG) -DMPAS_DEBUG
         DEBUG_MESSAGE=&quot;Debugging is on.&quot;
 endif # FFLAGS_DEBUG IF
 
@@ -264,10 +264,14 @@
         PAPI_MESSAGE=&quot;Papi libraries are off.&quot;
 endif # USE_PAPI IF
 
+ifneq ($(wildcard $(NETCDF)/lib/libnetcdff.*), ) # CHECK FOR NETCDF4
+        LIBS += -lnetcdff
+endif # CHECK FOR NETCDF4
+
 all: mpas_main
 
 mpas_main: 
-        cd src; make FC=&quot;$(FC)&quot; \
+        cd src; $(MAKE) -j1 FC=&quot;$(FC)&quot; \
                  CC=&quot;$(CC)&quot; \
                  SFC=&quot;$(SFC)&quot; \
                  SCC=&quot;$(SCC)&quot; \
@@ -287,7 +291,7 @@
         @echo $(SERIAL_MESSAGE)
         @echo $(PAPI_MESSAGE)
 clean:
-        cd src; make clean RM=&quot;$(RM)&quot; CORE=&quot;$(CORE)&quot;
+        cd src; $(MAKE) clean RM=&quot;$(RM)&quot; CORE=&quot;$(CORE)&quot;
         $(RM) $(CORE)_model.exe
 error: errmsg
 
@@ -305,7 +309,7 @@
 
 errmsg:
         @echo &quot;&quot;
-        @echo &quot;Usage: make target CORE=[core] [options]&quot;
+        @echo &quot;Usage: $(MAKE) target CORE=[core] [options]&quot;
         @echo &quot;&quot;
         @echo &quot;Example targets:&quot;
         @echo &quot;    ifort&quot;

Modified: trunk/mpas/src/Makefile
===================================================================
--- trunk/mpas/src/Makefile        2012-03-14 22:07:00 UTC (rev 1643)
+++ trunk/mpas/src/Makefile        2012-03-15 01:42:47 UTC (rev 1644)
@@ -6,35 +6,35 @@
         $(FC) $(LDFLAGS) -o $(CORE)_model.exe driver/*.o -L. -ldycore -lops -lframework $(LIBS) -I./external/esmf_time_f90 -L./external/esmf_time_f90 -lesmf_time
 
 reg_includes: 
-        ( cd registry; make CC=&quot;$(SCC)&quot; )
+        ( cd registry; $(MAKE) CC=&quot;$(SCC)&quot; )
         ( cd inc; $(CPP) ../core_$(CORE)/Registry | ../registry/parse &gt; Registry.processed)
 
-externals:
-        ( cd external; make FC=&quot;$(FC)&quot; SFC=&quot;$(SFC)&quot; CC=&quot;$(CC)&quot; SCC=&quot;$(SCC)&quot; FFLAGS=&quot;$(FFLAGS)&quot; CFLAGS=&quot;$(CFLAGS)&quot; CPP=&quot;$(CPP)&quot; NETCDF=&quot;$(NETCDF)&quot; CORE=&quot;$(CORE)&quot; )
+externals: reg_includes
+        ( cd external; $(MAKE) FC=&quot;$(FC)&quot; SFC=&quot;$(SFC)&quot; CC=&quot;$(CC)&quot; SCC=&quot;$(SCC)&quot; FFLAGS=&quot;$(FFLAGS)&quot; CFLAGS=&quot;$(CFLAGS)&quot; CPP=&quot;$(CPP)&quot; NETCDF=&quot;$(NETCDF)&quot; CORE=&quot;$(CORE)&quot; )
 
-frame: 
-        ( cd framework; make all ) 
+frame: reg_includes externals
+        ( cd framework; $(MAKE) all ) 
         ln -sf framework/libframework.a libframework.a
 
-ops: 
-        ( cd operators; make all ) 
+ops: reg_includes externals frame
+        ( cd operators; $(MAKE) all ) 
         ln -sf operators/libops.a libops.a
 
-dycore: 
-        ( cd core_$(CORE); make all ) 
+dycore: reg_includes externals frame ops
+        ( cd core_$(CORE); $(MAKE) all ) 
         ln -sf core_$(CORE)/libdycore.a libdycore.a
 
-drver: 
-        ( cd driver; make all ) 
+drver:  reg_includes externals frame ops dycore
+        ( cd driver; $(MAKE) all ) 
 
 clean:
         $(RM) $(CORE)_model.exe libframework.a libops.a libdycore.a
-        ( cd registry; make clean )
-        ( cd external; make clean )
-        ( cd framework; make clean )
-        ( cd operators; make clean )
+        ( cd registry; $(MAKE) clean )
+        ( cd external; $(MAKE) clean )
+        ( cd framework; $(MAKE) clean )
+        ( cd operators; $(MAKE) clean )
         ( cd inc; rm -f *.inc Registry.processed )
         if [ -d core_$(CORE) ] ; then \
-           ( cd core_$(CORE); make clean ) \
+           ( cd core_$(CORE); $(MAKE) clean ) \
         fi;
-        ( cd driver; make clean )
+        ( cd driver; $(MAKE) clean )

Modified: trunk/mpas/src/external/Makefile
===================================================================
--- trunk/mpas/src/external/Makefile        2012-03-14 22:07:00 UTC (rev 1643)
+++ trunk/mpas/src/external/Makefile        2012-03-15 01:42:47 UTC (rev 1644)
@@ -3,7 +3,7 @@
 all: esmf_time
 
 esmf_time:
-        ( cd esmf_time_f90; make FC=&quot;$(FC) $(FFLAGS)&quot; CPP=&quot;$(CPP)&quot; )
+        ( cd esmf_time_f90; $(MAKE) FC=&quot;$(FC) $(FFLAGS)&quot; CPP=&quot;$(CPP)&quot; )
 
 clean:
-        ( cd esmf_time_f90; make clean )
+        ( cd esmf_time_f90; $(MAKE) clean )

Modified: trunk/mpas/src/framework/streams.c
===================================================================
--- trunk/mpas/src/framework/streams.c        2012-03-14 22:07:00 UTC (rev 1643)
+++ trunk/mpas/src/framework/streams.c        2012-03-15 01:42:47 UTC (rev 1644)
@@ -18,6 +18,37 @@
 {
    char fname[128];
 
+#ifndef MPAS_DEBUG
+   if(*id == 0){
+           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;
+           }
+   } else {
+           sprintf(fname, &quot;/dev/null&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;/dev/null&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="gray">&quot;);
+                   return;
+           }
+   }
+#else
    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) {
@@ -31,6 +62,7 @@
       printf(&quot;Error duplicating STDOUT</font>
<font color="blue">&quot;);
       return;
    }
+#endif
 }
 
 void close_streams()

</font>
</pre>