From 649d9bb1e98475cfd594aaf7fd32ab5d3014172a Mon Sep 17 00:00:00 2001
From: Stefen Guzik <guzik2@llnl.gov>
Date: Tue, 29 Jul 2008 20:04:49 +0000
Subject: [PATCH] Integration of Chaco into Gmsh

---
 contrib/Chaco/Makefile                   | 47 +++++++++++++++---------
 contrib/Chaco/README                     | 37 +++++++++++--------
 contrib/Chaco/assign/assign.c            |  1 +
 contrib/Chaco/bpmatch/checkbp.c          |  1 +
 contrib/Chaco/bpmatch/map2d.c            |  1 +
 contrib/Chaco/bpmatch/map3d.c            |  1 +
 contrib/Chaco/coarsen/coarsen.c          |  1 +
 contrib/Chaco/coarsen/makecgraph.c       |  1 +
 contrib/Chaco/coarsen/makecgraph2.c      |  1 +
 contrib/Chaco/coarsen/makefgraph.c       |  1 +
 contrib/Chaco/coarsen/maxmatch.c         |  1 +
 contrib/Chaco/connect/connected.c        |  1 +
 contrib/Chaco/eigen/bisect.c             |  1 +
 contrib/Chaco/eigen/checkeig_ext.c       |  1 +
 contrib/Chaco/eigen/checkorth.c          |  1 +
 contrib/Chaco/eigen/eigensolve.c         |  1 +
 contrib/Chaco/eigen/get_extval.c         |  1 +
 contrib/Chaco/eigen/get_ritzvals.c       |  1 +
 contrib/Chaco/eigen/lanczos_FO.c         |  1 +
 contrib/Chaco/eigen/lanczos_SO.c         |  1 +
 contrib/Chaco/eigen/lanczos_SO_float.c   |  1 +
 contrib/Chaco/eigen/lanczos_ext.c        |  1 +
 contrib/Chaco/eigen/lanczos_ext_float.c  |  1 +
 contrib/Chaco/eigen/lanpause.c           |  1 +
 contrib/Chaco/eigen/rqi.c                |  1 +
 contrib/Chaco/eigen/solistout.c          |  1 +
 contrib/Chaco/eigen/tri_solve.c          |  1 +
 contrib/Chaco/graph/check_graph.c        |  1 +
 contrib/Chaco/graph/reformat.c           |  1 +
 contrib/Chaco/inertial/inertial.c        |  1 +
 contrib/Chaco/inertial/inertial2d.c      |  1 +
 contrib/Chaco/inertial/inertial3d.c      |  1 +
 contrib/Chaco/input/check_input.c        |  1 +
 contrib/Chaco/input/input.c              |  1 +
 contrib/Chaco/input/input_assign.c       |  1 +
 contrib/Chaco/input/input_geom.c         |  1 +
 contrib/Chaco/input/input_graph.c        |  1 +
 contrib/Chaco/input/input_graph_normal.c |  1 +
 contrib/Chaco/input/input_graph_scotch.c |  1 +
 contrib/Chaco/input/input_graph_vis.c    |  1 +
 contrib/Chaco/input/read_params.c        |  1 +
 contrib/Chaco/input/reflect_input.c      |  1 +
 contrib/Chaco/internal/check_internal.c  |  1 +
 contrib/Chaco/internal/force_internal.c  |  1 +
 contrib/Chaco/klspiff/coarsen_kl.c       |  1 +
 contrib/Chaco/klspiff/compress_ewgts.c   |  1 +
 contrib/Chaco/klspiff/kl_output.c        |  1 +
 contrib/Chaco/klspiff/klspiff.c          |  1 +
 contrib/Chaco/klspiff/nway_kl.c          |  1 +
 contrib/Chaco/klvspiff/bpm_improve.c     |  1 +
 contrib/Chaco/klvspiff/coarsen_klv.c     |  1 +
 contrib/Chaco/klvspiff/countup_vtx_sep.c |  1 +
 contrib/Chaco/klvspiff/flow.c            |  1 +
 contrib/Chaco/klvspiff/klvspiff.c        |  1 +
 contrib/Chaco/klvspiff/make_bpgraph.c    |  1 +
 contrib/Chaco/klvspiff/matching.c        |  1 +
 contrib/Chaco/klvspiff/nway_klv.c        |  1 +
 contrib/Chaco/main/interface.c           | 47 +++++++++++++++++++-----
 contrib/Chaco/misc/count.c               |  1 +
 contrib/Chaco/misc/countup_cube.c        |  1 +
 contrib/Chaco/misc/countup_mesh.c        |  1 +
 contrib/Chaco/misc/sequence.c            |  1 +
 contrib/Chaco/misc/simple_part.c         |  1 +
 contrib/Chaco/misc/time_kernels.c        |  1 +
 contrib/Chaco/optimize/opt2d.c           |  1 +
 contrib/Chaco/optimize/opt3d.c           |  1 +
 contrib/Chaco/submain/balance.c          |  1 +
 contrib/Chaco/submain/divide.c           |  1 +
 contrib/Chaco/submain/submain.c          |  1 +
 contrib/Chaco/util/affirm.c              |  1 +
 contrib/Chaco/util/bail.c                |  5 ++-
 contrib/Chaco/util/checkpnt.c            |  1 +
 contrib/Chaco/util/doubleout.c           |  1 +
 contrib/Chaco/util/mergesort.c           |  1 +
 contrib/Chaco/util/smalloc.c             |  1 +
 contrib/Chaco/util/strout.c              |  1 +
 76 files changed, 165 insertions(+), 43 deletions(-)

diff --git a/contrib/Chaco/Makefile b/contrib/Chaco/Makefile
index 2c50e7a829..5dc3c1a411 100644
--- a/contrib/Chaco/Makefile
+++ b/contrib/Chaco/Makefile
@@ -1,11 +1,14 @@
-DEST_DIR = 	../exec
-DEST=		${DEST_DIR}/chaco
-CC = 		gcc
-IFLAG =		-Imain
-CFLAGS =	-O2
-OFLAGS =	-O2
 
-FILES.c=	main/user_params.c main/interface.c main/main.c \
+include ../../variables
+
+LIB = ../../lib/libGmshChaco${LIBEXT}
+
+INC = ${DASH}Imain
+
+CFLAGS  = ${OPTIM} ${FLAGS} ${INC} ${SYSINCLUDE}
+
+SRCX	 =	main/Gmsh_printf.cpp main/Gmsh_exit.cpp
+SRC =		main/user_params.c main/interface.c \
 		submain/balance.c submain/divide.c submain/submain.c \
 		input/input_assign.c \
 		input/check_input.c input/input.c input/input_geom.c \
@@ -87,20 +90,30 @@ FILES.c=	main/user_params.c main/interface.c main/main.c \
 		util/update.c  util/vecout.c util/vecran.c \
                 util/vecscale.c 
 
-FILES.o=	$(FILES.c:.c=.o) 
+OBJ = ${SRC:.c=${OBJEXT}}
+OBJX = ${SRCX:.cpp=${OBJEXT}}
 
+.SUFFIXES: ${OBJEXT} .c .cpp
 
-${DEST}:	${FILES.o} Makefile
-		${CC} ${OFLAGS} ${FILES.o} -lm -o ${DEST}
+${LIB}: ${OBJ} ${OBJX}
+	${AR} ${ARFLAGS}${LIB} ${OBJ} ${OBJX} 
+	${RANLIB} ${LIB}
 
-lint:
-		lint ${IFLAG} ${FILES.c} -lm
+.c${OBJEXT}:
+	${CC} ${CFLAGS} ${DASH}c $< ${DASH}o ${<:.c=${OBJEXT}}
 
-alint:
-		alint ${IFLAG} ${FILES.c} -lm
+.cpp${OBJEXT}:
+	${CXX} ${CFLAGS} ${DASH}c $< ${DASH}o ${<:.cpp=${OBJEXT}}
 
 clean:
-		rm -f */*.o ${DEST_DIR}/core
+	rm -f */*.o */*.obj
+
+depend:
+	(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
+	${CXX} -MM ${CFLAGS} ${SRC} \
+	) >Makefile.new
+	cp Makefile Makefile.bak
+	cp Makefile.new Makefile
+	rm -f Makefile.new
 
-.c.o:
-		${CC} -c ${IFLAG} ${CFLAGS} -o $*.o $*.c
+# DO NOT DELETE THIS LINE
diff --git a/contrib/Chaco/README b/contrib/Chaco/README
index 1b09eb26ba..ec51fb0cba 100644
--- a/contrib/Chaco/README
+++ b/contrib/Chaco/README
@@ -1,15 +1,22 @@
-This directory contains all the necessary source code files
-for Chaco.  Simply type "make", and the code will be compiled
-and the executable image placed in "../exec/chaco".  
-
-The default values for the user accessible parameters discussed 
-in the user's guide "doc/User_guide.ps" can be modified by 
-editing the file "main/user_params.c".  You must recompile for 
-these changes to take affect. 
-
-You can also change the code parameters at run time (i.e. without 
-recompiling) by including a file "User_Params" in whichever 
-directory you are running the code from (so in the file 
-"exec/User_Params" in our orignal set-up). Parameter changes 
-can be specified in a natural way in this file using the rules 
-described in the user's guide.
+Chaco version 2.2
+
+This software was developed by Bruce Hendrickson and Robert Leland
+at Sandia National Laboratories under US Department of Energy
+contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation.
+
+--------------------------------------------------------------------------------
+
+Chaco has been slightly modified for integration into the Gmsh program.  Most
+changes are to 'main/interface.c'.  Elsewhere, the 'printf' routine has been
+defined as Gmsh_printf to write through a Gmsh Msg::Info.  All other
+modifications are tagged by 'Gmsh' and 'Gmsh - end'
+
+Parameters explicitly set to false
+FREE_GRAPH
+
+Parameters that are read through Gmsh and overwrite the parameters file
+REFINE_PARTITION
+INTERNAL_VERTICES
+REFINE_MAP
+TERMINAL_PROPOGATION
+
diff --git a/contrib/Chaco/assign/assign.c b/contrib/Chaco/assign/assign.c
index 6c1e97f791..d70d2727ba 100644
--- a/contrib/Chaco/assign/assign.c
+++ b/contrib/Chaco/assign/assign.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"structs.h"
 
diff --git a/contrib/Chaco/bpmatch/checkbp.c b/contrib/Chaco/bpmatch/checkbp.c
index d3ff61968c..486e67a428 100644
--- a/contrib/Chaco/bpmatch/checkbp.c
+++ b/contrib/Chaco/bpmatch/checkbp.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/bpmatch/map2d.c b/contrib/Chaco/bpmatch/map2d.c
index 7d70aee2c5..5723106ef5 100644
--- a/contrib/Chaco/bpmatch/map2d.c
+++ b/contrib/Chaco/bpmatch/map2d.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"params.h"
 #include	"structs.h"
diff --git a/contrib/Chaco/bpmatch/map3d.c b/contrib/Chaco/bpmatch/map3d.c
index 3354f864af..b06fe80783 100644
--- a/contrib/Chaco/bpmatch/map3d.c
+++ b/contrib/Chaco/bpmatch/map3d.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"params.h"
 #include	"structs.h"
diff --git a/contrib/Chaco/coarsen/coarsen.c b/contrib/Chaco/coarsen/coarsen.c
index d9088af32e..92d845ec22 100644
--- a/contrib/Chaco/coarsen/coarsen.c
+++ b/contrib/Chaco/coarsen/coarsen.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/coarsen/makecgraph.c b/contrib/Chaco/coarsen/makecgraph.c
index a2f3971f9e..d3ae894880 100644
--- a/contrib/Chaco/coarsen/makecgraph.c
+++ b/contrib/Chaco/coarsen/makecgraph.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/coarsen/makecgraph2.c b/contrib/Chaco/coarsen/makecgraph2.c
index e66128b9cc..65e6d7fc72 100644
--- a/contrib/Chaco/coarsen/makecgraph2.c
+++ b/contrib/Chaco/coarsen/makecgraph2.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/coarsen/makefgraph.c b/contrib/Chaco/coarsen/makefgraph.c
index d557ab087b..7ae25d95f4 100644
--- a/contrib/Chaco/coarsen/makefgraph.c
+++ b/contrib/Chaco/coarsen/makefgraph.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/coarsen/maxmatch.c b/contrib/Chaco/coarsen/maxmatch.c
index 3daaedc668..9822c9d830 100644
--- a/contrib/Chaco/coarsen/maxmatch.c
+++ b/contrib/Chaco/coarsen/maxmatch.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/connect/connected.c b/contrib/Chaco/connect/connected.c
index 0e0301e1af..0eed3ee717 100644
--- a/contrib/Chaco/connect/connected.c
+++ b/contrib/Chaco/connect/connected.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"structs.h"
 
diff --git a/contrib/Chaco/eigen/bisect.c b/contrib/Chaco/eigen/bisect.c
index 8cb5033c03..885a142b20 100644
--- a/contrib/Chaco/eigen/bisect.c
+++ b/contrib/Chaco/eigen/bisect.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 
 /* Finds selected eigenvalues of T using Sturm sequence bisection. Based 
diff --git a/contrib/Chaco/eigen/checkeig_ext.c b/contrib/Chaco/eigen/checkeig_ext.c
index c706b8a7dd..25c95656f5 100644
--- a/contrib/Chaco/eigen/checkeig_ext.c
+++ b/contrib/Chaco/eigen/checkeig_ext.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/eigen/checkorth.c b/contrib/Chaco/eigen/checkorth.c
index d162ba46f2..8d4f875bfb 100644
--- a/contrib/Chaco/eigen/checkorth.c
+++ b/contrib/Chaco/eigen/checkorth.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/eigen/eigensolve.c b/contrib/Chaco/eigen/eigensolve.c
index 8f8fa9c1ce..5a9754565a 100644
--- a/contrib/Chaco/eigen/eigensolve.c
+++ b/contrib/Chaco/eigen/eigensolve.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/eigen/get_extval.c b/contrib/Chaco/eigen/get_extval.c
index 85b9429b9d..0d3f63988d 100644
--- a/contrib/Chaco/eigen/get_extval.c
+++ b/contrib/Chaco/eigen/get_extval.c
@@ -4,6 +4,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include "Gmsh_printf.h"
 
 /* Finds first extended eigenpair of system corresponding to
    tridiagonal T using using Rafael's bisection technique. */
diff --git a/contrib/Chaco/eigen/get_ritzvals.c b/contrib/Chaco/eigen/get_ritzvals.c
index 5093282258..4251fe8e52 100644
--- a/contrib/Chaco/eigen/get_ritzvals.c
+++ b/contrib/Chaco/eigen/get_ritzvals.c
@@ -4,6 +4,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 
 /* Finds needed eigenvalues of tridiagonal T using either the QL algorithm 
diff --git a/contrib/Chaco/eigen/lanczos_FO.c b/contrib/Chaco/eigen/lanczos_FO.c
index 73af15bf0f..00d0a2adb3 100644
--- a/contrib/Chaco/eigen/lanczos_FO.c
+++ b/contrib/Chaco/eigen/lanczos_FO.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/eigen/lanczos_SO.c b/contrib/Chaco/eigen/lanczos_SO.c
index 718aa26d97..d652eb432d 100644
--- a/contrib/Chaco/eigen/lanczos_SO.c
+++ b/contrib/Chaco/eigen/lanczos_SO.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 #include "params.h"
diff --git a/contrib/Chaco/eigen/lanczos_SO_float.c b/contrib/Chaco/eigen/lanczos_SO_float.c
index f74a2c3673..9c75dc46b0 100644
--- a/contrib/Chaco/eigen/lanczos_SO_float.c
+++ b/contrib/Chaco/eigen/lanczos_SO_float.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 #include "params.h"
diff --git a/contrib/Chaco/eigen/lanczos_ext.c b/contrib/Chaco/eigen/lanczos_ext.c
index fa3c68941a..113c1f7b9c 100644
--- a/contrib/Chaco/eigen/lanczos_ext.c
+++ b/contrib/Chaco/eigen/lanczos_ext.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "../main/structs.h"
 #include "../main/defs.h"
 
diff --git a/contrib/Chaco/eigen/lanczos_ext_float.c b/contrib/Chaco/eigen/lanczos_ext_float.c
index 1d4c257c85..2fd1cd96d2 100644
--- a/contrib/Chaco/eigen/lanczos_ext_float.c
+++ b/contrib/Chaco/eigen/lanczos_ext_float.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/eigen/lanpause.c b/contrib/Chaco/eigen/lanpause.c
index e865885fcd..130d2e142b 100644
--- a/contrib/Chaco/eigen/lanpause.c
+++ b/contrib/Chaco/eigen/lanpause.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/eigen/rqi.c b/contrib/Chaco/eigen/rqi.c
index 3147edcbdd..4eff28e291 100644
--- a/contrib/Chaco/eigen/rqi.c
+++ b/contrib/Chaco/eigen/rqi.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"structs.h"
 
diff --git a/contrib/Chaco/eigen/solistout.c b/contrib/Chaco/eigen/solistout.c
index c2cf1c5ebc..3a3a576156 100644
--- a/contrib/Chaco/eigen/solistout.c
+++ b/contrib/Chaco/eigen/solistout.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/eigen/tri_solve.c b/contrib/Chaco/eigen/tri_solve.c
index 031e33693f..e0dae712fe 100644
--- a/contrib/Chaco/eigen/tri_solve.c
+++ b/contrib/Chaco/eigen/tri_solve.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 
 /* Solve the shifted, symmetric tridiagonal linear system (T - lambda*I)v = b
diff --git a/contrib/Chaco/graph/check_graph.c b/contrib/Chaco/graph/check_graph.c
index 29c79e3d87..f8698fc3d4 100644
--- a/contrib/Chaco/graph/check_graph.c
+++ b/contrib/Chaco/graph/check_graph.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/graph/reformat.c b/contrib/Chaco/graph/reformat.c
index 0e67208597..ff7aa1baa9 100644
--- a/contrib/Chaco/graph/reformat.c
+++ b/contrib/Chaco/graph/reformat.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/inertial/inertial.c b/contrib/Chaco/inertial/inertial.c
index e40e98974c..803c4433cb 100644
--- a/contrib/Chaco/inertial/inertial.c
+++ b/contrib/Chaco/inertial/inertial.c
@@ -4,6 +4,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/inertial/inertial2d.c b/contrib/Chaco/inertial/inertial2d.c
index 2869856d0f..2c31699aeb 100644
--- a/contrib/Chaco/inertial/inertial2d.c
+++ b/contrib/Chaco/inertial/inertial2d.c
@@ -4,6 +4,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/inertial/inertial3d.c b/contrib/Chaco/inertial/inertial3d.c
index f94752b538..2d894c382c 100644
--- a/contrib/Chaco/inertial/inertial3d.c
+++ b/contrib/Chaco/inertial/inertial3d.c
@@ -4,6 +4,7 @@
 
 #include <math.h>
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "structs.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/input/check_input.c b/contrib/Chaco/input/check_input.c
index ba79a82daa..bbb8d35758 100644
--- a/contrib/Chaco/input/check_input.c
+++ b/contrib/Chaco/input/check_input.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/input/input.c b/contrib/Chaco/input/input.c
index 6ab7517795..23db3260fb 100644
--- a/contrib/Chaco/input/input.c
+++ b/contrib/Chaco/input/input.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"params.h"
 
diff --git a/contrib/Chaco/input/input_assign.c b/contrib/Chaco/input/input_assign.c
index 57eea91f21..0dbb14130d 100644
--- a/contrib/Chaco/input/input_assign.c
+++ b/contrib/Chaco/input/input_assign.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include        <string.h>
+#include        "Gmsh_printf.h"
 #include        "defs.h"
 
 static int input_assign_normal(), input_assign_inv();
diff --git a/contrib/Chaco/input/input_geom.c b/contrib/Chaco/input/input_geom.c
index 6dbcda0dd8..f0b1930440 100644
--- a/contrib/Chaco/input/input_geom.c
+++ b/contrib/Chaco/input/input_geom.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"params.h"
 
diff --git a/contrib/Chaco/input/input_graph.c b/contrib/Chaco/input/input_graph.c
index ef97167c76..4a3e161bbd 100644
--- a/contrib/Chaco/input/input_graph.c
+++ b/contrib/Chaco/input/input_graph.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 
 
diff --git a/contrib/Chaco/input/input_graph_normal.c b/contrib/Chaco/input/input_graph_normal.c
index ef97167c76..4a3e161bbd 100644
--- a/contrib/Chaco/input/input_graph_normal.c
+++ b/contrib/Chaco/input/input_graph_normal.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 
 
diff --git a/contrib/Chaco/input/input_graph_scotch.c b/contrib/Chaco/input/input_graph_scotch.c
index 8a9543bc84..dc95cbfaac 100644
--- a/contrib/Chaco/input/input_graph_scotch.c
+++ b/contrib/Chaco/input/input_graph_scotch.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 
 
diff --git a/contrib/Chaco/input/input_graph_vis.c b/contrib/Chaco/input/input_graph_vis.c
index 760c3769b0..394085f34d 100644
--- a/contrib/Chaco/input/input_graph_vis.c
+++ b/contrib/Chaco/input/input_graph_vis.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 
 
diff --git a/contrib/Chaco/input/read_params.c b/contrib/Chaco/input/read_params.c
index 9b0d4fe424..8be8b42432 100644
--- a/contrib/Chaco/input/read_params.c
+++ b/contrib/Chaco/input/read_params.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "params.h"
 
diff --git a/contrib/Chaco/input/reflect_input.c b/contrib/Chaco/input/reflect_input.c
index 3c1bc1f087..414fb74b44 100644
--- a/contrib/Chaco/input/reflect_input.c
+++ b/contrib/Chaco/input/reflect_input.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 
diff --git a/contrib/Chaco/internal/check_internal.c b/contrib/Chaco/internal/check_internal.c
index 3a088c6883..3c5488d661 100644
--- a/contrib/Chaco/internal/check_internal.c
+++ b/contrib/Chaco/internal/check_internal.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 #include	"internal.h"
diff --git a/contrib/Chaco/internal/force_internal.c b/contrib/Chaco/internal/force_internal.c
index 9734011e35..3e919277cc 100644
--- a/contrib/Chaco/internal/force_internal.c
+++ b/contrib/Chaco/internal/force_internal.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 #include	"internal.h"
diff --git a/contrib/Chaco/klspiff/coarsen_kl.c b/contrib/Chaco/klspiff/coarsen_kl.c
index ce3887b506..3292bffc91 100644
--- a/contrib/Chaco/klspiff/coarsen_kl.c
+++ b/contrib/Chaco/klspiff/coarsen_kl.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/klspiff/compress_ewgts.c b/contrib/Chaco/klspiff/compress_ewgts.c
index 00efc0f77d..0aa9417eec 100644
--- a/contrib/Chaco/klspiff/compress_ewgts.c
+++ b/contrib/Chaco/klspiff/compress_ewgts.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/klspiff/kl_output.c b/contrib/Chaco/klspiff/kl_output.c
index f3abe6025d..b86690d8fc 100644
--- a/contrib/Chaco/klspiff/kl_output.c
+++ b/contrib/Chaco/klspiff/kl_output.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 
diff --git a/contrib/Chaco/klspiff/klspiff.c b/contrib/Chaco/klspiff/klspiff.c
index 4492cdc2e9..a4be0ff500 100644
--- a/contrib/Chaco/klspiff/klspiff.c
+++ b/contrib/Chaco/klspiff/klspiff.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/klspiff/nway_kl.c b/contrib/Chaco/klspiff/nway_kl.c
index 483feb1d7f..450b0eaf69 100644
--- a/contrib/Chaco/klspiff/nway_kl.c
+++ b/contrib/Chaco/klspiff/nway_kl.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/klvspiff/bpm_improve.c b/contrib/Chaco/klvspiff/bpm_improve.c
index 3fec1de59a..8a4a024c98 100644
--- a/contrib/Chaco/klvspiff/bpm_improve.c
+++ b/contrib/Chaco/klvspiff/bpm_improve.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 
diff --git a/contrib/Chaco/klvspiff/coarsen_klv.c b/contrib/Chaco/klvspiff/coarsen_klv.c
index 7d59ad0fba..15d79e1e57 100644
--- a/contrib/Chaco/klvspiff/coarsen_klv.c
+++ b/contrib/Chaco/klvspiff/coarsen_klv.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/klvspiff/countup_vtx_sep.c b/contrib/Chaco/klvspiff/countup_vtx_sep.c
index be0a6f5290..b83d709ee1 100644
--- a/contrib/Chaco/klvspiff/countup_vtx_sep.c
+++ b/contrib/Chaco/klvspiff/countup_vtx_sep.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/klvspiff/flow.c b/contrib/Chaco/klvspiff/flow.c
index 64816485e8..bc9baa14c5 100644
--- a/contrib/Chaco/klvspiff/flow.c
+++ b/contrib/Chaco/klvspiff/flow.c
@@ -4,6 +4,7 @@
 
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 
 /* STATUS:
diff --git a/contrib/Chaco/klvspiff/klvspiff.c b/contrib/Chaco/klvspiff/klvspiff.c
index ebf7604c70..f1d560adaf 100644
--- a/contrib/Chaco/klvspiff/klvspiff.c
+++ b/contrib/Chaco/klvspiff/klvspiff.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"params.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/klvspiff/make_bpgraph.c b/contrib/Chaco/klvspiff/make_bpgraph.c
index 41c8c4cd25..d8b046d9b3 100644
--- a/contrib/Chaco/klvspiff/make_bpgraph.c
+++ b/contrib/Chaco/klvspiff/make_bpgraph.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 
diff --git a/contrib/Chaco/klvspiff/matching.c b/contrib/Chaco/klvspiff/matching.c
index c7c5972bd6..aad56c9dce 100644
--- a/contrib/Chaco/klvspiff/matching.c
+++ b/contrib/Chaco/klvspiff/matching.c
@@ -6,6 +6,7 @@
    code provided by Ed Rothberg at SGI. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 
 #define  TRUE  1
 #define  FALSE 0
diff --git a/contrib/Chaco/klvspiff/nway_klv.c b/contrib/Chaco/klvspiff/nway_klv.c
index 9b60e2cf98..8f7c938259 100644
--- a/contrib/Chaco/klvspiff/nway_klv.c
+++ b/contrib/Chaco/klvspiff/nway_klv.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 
diff --git a/contrib/Chaco/main/interface.c b/contrib/Chaco/main/interface.c
index 8b7125c271..6f6cac7f6a 100644
--- a/contrib/Chaco/main/interface.c
+++ b/contrib/Chaco/main/interface.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
@@ -13,7 +14,12 @@ int       interface(nvtxs, start, adjacency, vwgts, ewgts, x, y, z,
 		              assignment,
 		              architecture, ndims_tot, mesh_dims, goal,
 		              global_method, local_method, rqi_flag, vmax, ndims,
-		              eigtol, seed)
+		              eigtol, seed
+/* Gmsh - extra parameters in the interface */
+                    , refine_partition, internal_vertices, refine_map,
+                    terminal_propogation
+/* Gmsh - end */
+                                          )
 int       nvtxs;		/* number of vertices in full graph */
 int      *start;		/* start of edge list for each vertex */
 int      *adjacency;		/* edge list data */
@@ -34,6 +40,13 @@ int       vmax;			/* how many vertices to coarsen down to? */
 int       ndims;		/* number of eigenvectors (2^d sets) */
 double    eigtol;		/* tolerance on eigenvectors */
 long      seed;			/* for random graph mutations */
+/* Gmsh - get some extra parameters through the interface.  These are identical
+ * to those in the parameters file */
+int       refine_partition;
+int       internal_vertices;
+int       refine_map;
+int       terminal_propogation;
+/* Gmsh - end */
 {
     extern char *PARAMS_FILENAME;	/* name of file with parameter updates */
     extern int MAKE_VWGTS;	/* make vertex weights equal to degrees? */
@@ -41,6 +54,10 @@ long      seed;			/* for random graph mutations */
     extern int FREE_GRAPH;	/* free graph data structure after reformat? */
     extern int DEBUG_PARAMS;	/* debug flag for reading parameters */
     extern int DEBUG_TRACE;	/* trace main execution path */
+    extern int REFINE_PARTITION;  /* # passes post-processing KL */
+    extern int INTERNAL_VERTICES; /* post-process to increase internal nodes */
+    extern int REFINE_MAP;	  /* greedy post-processing to reduce hops? */
+    extern int TERM_PROP;	  /* perform terminal propagation */
     extern double start_time;	/* time routine is entered */
     extern double reformat_time;/* time spent reformatting graph */
     FILE     *params_file;	/* file for reading new parameters */
@@ -70,15 +87,25 @@ long      seed;			/* for random graph mutations */
     graph = NULL;
     coords = NULL;
 
-    if (!Using_Main) {		/* If not using main, need to read parameters file. */
-	start_time = seconds();
-	params_file = fopen(PARAMS_FILENAME, "r");
-	if (params_file == NULL && DEBUG_PARAMS > 1) {
-	    printf("Parameter file `%s' not found; using default parameters.\n",
-		   PARAMS_FILENAME);
-	}
-	read_params(params_file);
-    }
+/* Gmsh - disable this for now.  It would be interesting to let someone include
+ * it though */
+/*     if (!Using_Main) {		/\* If not using main, need to read parameters file. *\/ */
+/* 	start_time = seconds(); */
+/* 	params_file = fopen(PARAMS_FILENAME, "r"); */
+/* 	if (params_file == NULL && DEBUG_PARAMS > 1) { */
+/* 	    printf("Parameter file `%s' not found; using default parameters.\n", */
+/* 		   PARAMS_FILENAME); */
+/* 	} */
+/* 	read_params(params_file); */
+/*     } */
+/* Gmsh - end */
+/* Gmsh - override some parameters */
+    FREE_GRAPH = 0;
+    REFINE_PARTITION = refine_partition;
+    INTERNAL_VERTICES = internal_vertices;
+    REFINE_MAP = refine_map;
+    TERM_PROP = terminal_propogation;
+/* Gmsh - end */
 
     if (goal == NULL) {	/* If not passed in, default goals have equal set sizes. */
 	default_goal = TRUE;
diff --git a/contrib/Chaco/misc/count.c b/contrib/Chaco/misc/count.c
index 92f5c05892..d80269d2fe 100644
--- a/contrib/Chaco/misc/count.c
+++ b/contrib/Chaco/misc/count.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"params.h"
 #include	"structs.h"
 #include	"defs.h"
diff --git a/contrib/Chaco/misc/countup_cube.c b/contrib/Chaco/misc/countup_cube.c
index 4998c8d707..4148c1f3cc 100644
--- a/contrib/Chaco/misc/countup_cube.c
+++ b/contrib/Chaco/misc/countup_cube.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/misc/countup_mesh.c b/contrib/Chaco/misc/countup_mesh.c
index 9eb656256f..5d1ae7171a 100644
--- a/contrib/Chaco/misc/countup_mesh.c
+++ b/contrib/Chaco/misc/countup_mesh.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "structs.h"
 
diff --git a/contrib/Chaco/misc/sequence.c b/contrib/Chaco/misc/sequence.c
index 9e63c1c314..cb2dae3903 100644
--- a/contrib/Chaco/misc/sequence.c
+++ b/contrib/Chaco/misc/sequence.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/misc/simple_part.c b/contrib/Chaco/misc/simple_part.c
index 12479e39bd..264a35a150 100644
--- a/contrib/Chaco/misc/simple_part.c
+++ b/contrib/Chaco/misc/simple_part.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 #include	"params.h"
diff --git a/contrib/Chaco/misc/time_kernels.c b/contrib/Chaco/misc/time_kernels.c
index 4713ee42ff..cd176963ca 100644
--- a/contrib/Chaco/misc/time_kernels.c
+++ b/contrib/Chaco/misc/time_kernels.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"structs.h"
 
diff --git a/contrib/Chaco/optimize/opt2d.c b/contrib/Chaco/optimize/opt2d.c
index b1d829af05..1de8c0937b 100644
--- a/contrib/Chaco/optimize/opt2d.c
+++ b/contrib/Chaco/optimize/opt2d.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 #include	"structs.h"
 
diff --git a/contrib/Chaco/optimize/opt3d.c b/contrib/Chaco/optimize/opt3d.c
index 41f25b9019..eff8d7efed 100644
--- a/contrib/Chaco/optimize/opt3d.c
+++ b/contrib/Chaco/optimize/opt3d.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<math.h>
+#include        "Gmsh_printf.h"
 #include	"structs.h"
 #include	"defs.h"
 
diff --git a/contrib/Chaco/submain/balance.c b/contrib/Chaco/submain/balance.c
index dad4fe0904..20d2f6ff01 100644
--- a/contrib/Chaco/submain/balance.c
+++ b/contrib/Chaco/submain/balance.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/submain/divide.c b/contrib/Chaco/submain/divide.c
index 95adc1a062..732fd08b77 100644
--- a/contrib/Chaco/submain/divide.c
+++ b/contrib/Chaco/submain/divide.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include <stdio.h>
+#include "Gmsh_printf.h"
 #include "params.h"
 #include "defs.h"
 #include "structs.h"
diff --git a/contrib/Chaco/submain/submain.c b/contrib/Chaco/submain/submain.c
index d9d2ece0a8..24d9155c00 100644
--- a/contrib/Chaco/submain/submain.c
+++ b/contrib/Chaco/submain/submain.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 #include "params.h"
 #include "structs.h"
diff --git a/contrib/Chaco/util/affirm.c b/contrib/Chaco/util/affirm.c
index bd5f4173ed..c1b802ce29 100644
--- a/contrib/Chaco/util/affirm.c
+++ b/contrib/Chaco/util/affirm.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
+#include "Gmsh_printf.h"
 #include "defs.h"
 
 /* Record a return TRUE if answer is yes, FALSE if no. */
diff --git a/contrib/Chaco/util/bail.c b/contrib/Chaco/util/bail.c
index 2e27443144..42dab7911f 100644
--- a/contrib/Chaco/util/bail.c
+++ b/contrib/Chaco/util/bail.c
@@ -4,6 +4,8 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
+#include        "Gmsh_exit.h"
 
 /* Wrapper for exit() - print message and exit with status code. Exit code
    of 0 indicates normal termination. Exit code of 1 indicates early 
@@ -22,5 +24,6 @@ int       status;
             fprintf(Output_File, "%s\n", msg);
 	}
     }
-    exit(status);
+/*     exit(status); */
+    Gmsh_exit();
 }
diff --git a/contrib/Chaco/util/checkpnt.c b/contrib/Chaco/util/checkpnt.c
index 5b7a08f1c1..60fb5683bb 100644
--- a/contrib/Chaco/util/checkpnt.c
+++ b/contrib/Chaco/util/checkpnt.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 
 /* Debug break point. */
 void      checkpnt(tag)
diff --git a/contrib/Chaco/util/doubleout.c b/contrib/Chaco/util/doubleout.c
index ef94d9a668..dd1b6d1a66 100644
--- a/contrib/Chaco/util/doubleout.c
+++ b/contrib/Chaco/util/doubleout.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include  <stdio.h>
+#include  "Gmsh_printf.h"
 
 /* Print a double precision number with filtering format to screen. */
 void      doubleout(number, mode)
diff --git a/contrib/Chaco/util/mergesort.c b/contrib/Chaco/util/mergesort.c
index 11690259c8..1ecef03747 100644
--- a/contrib/Chaco/util/mergesort.c
+++ b/contrib/Chaco/util/mergesort.c
@@ -3,6 +3,7 @@
  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
 #include	<stdio.h>
+#include        "Gmsh_printf.h"
 #include	"defs.h"
 
 
diff --git a/contrib/Chaco/util/smalloc.c b/contrib/Chaco/util/smalloc.c
index 3edc1fb1bf..3d146a0aac 100644
--- a/contrib/Chaco/util/smalloc.c
+++ b/contrib/Chaco/util/smalloc.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <malloc.h>
+#include "Gmsh_printf.h"
 
 static int nmalloc = 0;		/* number of calls to malloc */
 static int nfree = 0;		/* number of calls to free */
diff --git a/contrib/Chaco/util/strout.c b/contrib/Chaco/util/strout.c
index 10ea5a4001..70665c13d7 100644
--- a/contrib/Chaco/util/strout.c
+++ b/contrib/Chaco/util/strout.c
@@ -4,6 +4,7 @@
 
 #include	<stdio.h>
 #include	<string.h>
+#include        "Gmsh_printf.h"
 
 /* Wrapper for a printf statement with a string as only arg.
    Prints to screen and to output file if there is one. */
-- 
GitLab