Index: branches/ipp-magic-v0/Ohana/src/gophot/Makefile
===================================================================
--- branches/elixir/Ohana/src/gophot/Makefile	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/Makefile	(revision 21062)
@@ -1,68 +1,46 @@
-include ../../Configure
+default: gophot
+help:
+	@echo "make options: gophot (default)"
+
+include ../../Makefile.System
 HOME    =       $(ROOT)/src/gophot
-PROGRAM =       gophot
-
-CC      =       gcc -g
 BIN	=	$(HOME)/bin
-INC	= 	$(HOME)/include
+LIB	=	$(HOME)/lib
 SRC	=	$(HOME)/src
 MAN	=	$(HOME)/doc
-DESTBIN	=	$(LBIN)
-DESTLIB	=	$(LLIB)
-DESTINC	=	$(LINC)
-DESTMAN	=	$(LMAN)
+INC	= 	$(HOME)/include
+include ../../Makefile.Common
 
-#  
-INCS	= 	-I$(INC) -I$(LINC) -I$(XINC) -I$(LINC)/$(ARCH)
-LIBS	= 	-L$(LLIB) -lFITS -lohana -lm 
-CFLAGS	=	-o $*.$(ARCH).o $(INCS) 
-CCFLAGS	=	$(INCS) $(LIBS) 
+# programs may add their own internal requirements here
+FULL_CFLAGS   = $(BASE_CFLAGS)
+FULL_CPPFLAGS = $(BASE_CPPFLAGS)
+FULL_LDFLAGS  = -ldvo -lFITS -lohana $(BASE_LDFLAGS)
 
-default: $(PROGRAM)
+gophot: $(BIN)/gophot.$(ARCH)
+install: $(DESTBIN)/gophot
 
-OBJ = \
-           $(SRC)/gophot.$(ARCH).o 	   $(SRC)/ConfigInit.$(ARCH).o \
-	   $(SRC)/message.$(ARCH).o	   $(SRC)/dophot.$(ARCH).o \
-	   $(SRC)/makenoise.$(ARCH).o      $(SRC)/findsky.$(ARCH).o \
-           $(SRC)/makemask.$(ARCH).o       $(SRC)/paravg.$(ARCH).o \
-           $(SRC)/objout.$(ARCH).o         $(SRC)/addstar.$(ARCH).o \
-	   $(SRC)/ellipse.$(ARCH).o        $(SRC)/improve.$(ARCH).o \
-           $(SRC)/fillerup.$(ARCH).o       $(SRC)/parinterp.$(ARCH).o \
-           $(SRC)/guess.$(ARCH).o          $(SRC)/offpic.$(ARCH).o \
-           $(SRC)/addlims.$(ARCH).o        $(SRC)/parupd.$(ARCH).o \
-           $(SRC)/toofaint.$(ARCH).o       $(SRC)/isearch.$(ARCH).o \
-           $(SRC)/shape.$(ARCH).o          $(SRC)/galaxy.$(ARCH).o \
-           $(SRC)/transmask.$(ARCH).o      $(SRC)/cosmic.$(ARCH).o \
-           $(SRC)/impaper2.$(ARCH).o       $(SRC)/sort.$(ARCH).o \
-           $(SRC)/oblit.$(ARCH).o          $(SRC)/toobright.$(ARCH).o \
-           $(SRC)/Chisq.$(ARCH).o          $(SRC)/oblims.$(ARCH).o \
-           $(SRC)/ludcmp.$(ARCH).o         $(SRC)/lubksb.$(ARCH).o \
-           $(SRC)/pseud2d.$(ARCH).o        $(SRC)/twofit.$(ARCH).o \
-           $(SRC)/skyfun_plane.$(ARCH).o   $(SRC)/pseud4d.$(ARCH).o \
-	   $(SRC)/large_features.$(ARCH).o $(SRC)/set_thresholds.$(ARCH).o \
-           $(SRC)/outline.$(ARCH).o        $(SRC)/delete_ellipse.$(ARCH).o \
-	   $(SRC)/feature_fluxes.$(ARCH).o $(SRC)/mediansky.$(ARCH).o
+GOPHOT = \
+$(SRC)/gophot.$(ARCH).o 	$(SRC)/ConfigInit.$(ARCH).o \
+$(SRC)/message.$(ARCH).o	$(SRC)/dophot.$(ARCH).o \
+$(SRC)/makenoise.$(ARCH).o      $(SRC)/findsky.$(ARCH).o \
+$(SRC)/makemask.$(ARCH).o       $(SRC)/paravg.$(ARCH).o \
+$(SRC)/objout.$(ARCH).o         $(SRC)/addstar.$(ARCH).o \
+$(SRC)/ellipse.$(ARCH).o        $(SRC)/improve.$(ARCH).o \
+$(SRC)/fillerup.$(ARCH).o       $(SRC)/parinterp.$(ARCH).o \
+$(SRC)/guess.$(ARCH).o          $(SRC)/offpic.$(ARCH).o \
+$(SRC)/addlims.$(ARCH).o        $(SRC)/parupd.$(ARCH).o \
+$(SRC)/toofaint.$(ARCH).o       $(SRC)/isearch.$(ARCH).o \
+$(SRC)/shape.$(ARCH).o          $(SRC)/galaxy.$(ARCH).o \
+$(SRC)/transmask.$(ARCH).o      $(SRC)/cosmic.$(ARCH).o \
+$(SRC)/impaper2.$(ARCH).o       \
+$(SRC)/oblit.$(ARCH).o          $(SRC)/toobright.$(ARCH).o \
+$(SRC)/Chisq.$(ARCH).o          $(SRC)/oblims.$(ARCH).o \
+$(SRC)/ludcmp.$(ARCH).o         $(SRC)/lubksb.$(ARCH).o \
+$(SRC)/pseud2d.$(ARCH).o        $(SRC)/twofit.$(ARCH).o \
+$(SRC)/skyfun_plane.$(ARCH).o   $(SRC)/pseud4d.$(ARCH).o \
+$(SRC)/large_features.$(ARCH).o $(SRC)/set_thresholds.$(ARCH).o \
+$(SRC)/outline.$(ARCH).o        $(SRC)/delete_ellipse.$(ARCH).o \
+$(SRC)/feature_fluxes.$(ARCH).o $(SRC)/mediansky.$(ARCH).o
 
-# dependancy rules for binary code ##########################
-$(PROGRAM): $(BIN)/$(PROGRAM).$(ARCH)
-
-$(BIN)/$(PROGRAM).$(ARCH): $(OBJ)
-	$(CC) $(OBJ) -o $(BIN)/$(PROGRAM).$(ARCH) $(CCFLAGS)
-
-install: $(DESTBIN)/$(PROGRAM)
-
-$(DESTBIN)/$(PROGRAM): $(BIN)/$(PROGRAM).$(ARCH)
-	rm -f $(DESTBIN)/$(PROGRAM)
-	cp $(BIN)/$(PROGRAM).$(ARCH) $(DESTBIN)/$(PROGRAM)
-
-# utilities #################################################
-clean:	
-	rm -f $(BIN)/*.$(ARCH)
-	rm -f `find . -name "*.o"`
-	rm -f `find . -name "*~"`
-	rm -f `find . -name "#*"`
-
-.SUFFIXES: .$(ARCH).o
-
-.c.$(ARCH).o:
-	$(CC) $(CFLAGS) -c $<
+$(GOPHOT): $(INC)/gophot.h $(INC)/prototypes.h
+$(BIN)/gophot.$(ARCH): $(GOPHOT)
Index: branches/ipp-magic-v0/Ohana/src/gophot/bin/.cvsignore
===================================================================
--- branches/ipp-magic-v0/Ohana/src/gophot/bin/.cvsignore	(revision 21062)
+++ branches/ipp-magic-v0/Ohana/src/gophot/bin/.cvsignore	(revision 21062)
@@ -0,0 +1,4 @@
+*.linux *.lin64 *.sol *.sun *.sid *.hp *.irix
+*.linrh
+*.darwin
+*.darwin_x86
Index: branches/ipp-magic-v0/Ohana/src/gophot/doc/ChangeLog.txt
===================================================================
--- branches/ipp-magic-v0/Ohana/src/gophot/doc/ChangeLog.txt	(revision 21062)
+++ branches/ipp-magic-v0/Ohana/src/gophot/doc/ChangeLog.txt	(revision 21062)
@@ -0,0 +1,4 @@
+
+- gophot-1-2 : 2006.08.23
+  * converted to gfits APIs (forces libfits 1.6)
+  * cleaned up Makefile, -Wall compilation errors
Index: branches/ipp-magic-v0/Ohana/src/gophot/doc/Notes
===================================================================
--- branches/elixir/Ohana/src/gophot/doc/Notes	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/doc/Notes	(revision 21062)
@@ -1,2 +1,8 @@
+
+2005.10.20 : gophot v1.1
+
+  minor changes to use new libohana (v1.5) / libfits (v1.4)
+
+Old Notes
 
 Converting dophot to C: (I use dophot.f and dophot.c to refer to the
Index: branches/ipp-magic-v0/Ohana/src/gophot/include/gophot.h
===================================================================
--- branches/elixir/Ohana/src/gophot/include/gophot.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/include/gophot.h	(revision 21062)
@@ -2,4 +2,5 @@
 
 # include <ohana.h>
+# include <gfitsio.h>
 
 typedef char bool;
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/ConfigInit.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/ConfigInit.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/ConfigInit.c	(revision 21062)
@@ -3,5 +3,5 @@
 # define TestConfig(A,B,C,D,E) { if (!ScanConfig (A,B,C,D,E)) { fprintf (stderr, B); exit (1); }}
 
-ConfigInit (int *argc, char **argv) {
+int ConfigInit (int *argc, char **argv) {
 
   char *config, *file;
@@ -207,4 +207,5 @@
   /* free (file); */
 
+  return 1;
 }
 
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/dophot.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/dophot.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/dophot.c	(revision 21062)
@@ -5,5 +5,5 @@
 float get_mediansky (int, int);
 
-dophot () {
+int dophot (void) {
 
   bool first, lastround;
@@ -31,6 +31,6 @@
 	   (now.tv_sec - then.tv_sec) + 1e-6*(now.tv_usec - then.tv_usec));
 
-  fits_write_header ("test.sub", &header);
-  fits_write_matrix ("test.sub", &matrix);
+  gfits_write_header ("test.sub", &header);
+  gfits_write_matrix ("test.sub", &matrix);
   exit (0);
   */
@@ -68,6 +68,6 @@
 
 # if (0)
-    fits_write_header ("test.sub", &header);
-    fits_write_matrix ("test.sub", &matrix);
+    gfits_write_header ("test.sub", &header);
+    gfits_write_matrix ("test.sub", &matrix);
 
     completeout (nstot);
@@ -85,6 +85,6 @@
 	   
     /* 
-    fits_write_header ("test.sub", &header);
-    fits_write_matrix ("test.sub", &matrix);
+    gfits_write_header ("test.sub", &header);
+    gfits_write_matrix ("test.sub", &matrix);
     completeout (nstot);
     fprintf (stderr, "type return to continue:  ");
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/fillerup.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/fillerup.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/fillerup.c	(revision 21062)
@@ -50,5 +50,5 @@
   if (nsky == 0) return (FALSE);
 
-  sort (ts, nsky);
+  fsort (ts, nsky);
   sky = ts[(int)(0.5*nsky)];
   sum2 = sky;
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/gophot.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/gophot.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/gophot.c	(revision 21062)
@@ -1,5 +1,5 @@
 # include "gophot.h"
 
-main (int argc, char **argv) {
+int main (int argc, char **argv) {
 
   float tmp;
@@ -7,5 +7,5 @@
   if (argc < 4) {
     fprintf (stderr, "ERROR: usage: dophot imagename outfile paramfile\n");
-    exit (0);
+    exit (2);
   }
   ConfigInit (&argc, argv);
@@ -13,18 +13,17 @@
   fprintf (stderr, "reading from %s, writing to %s, %s param file\n", argv[1], argv[2], argv[3]);
 
-  FT_UNSIGN_MODE = FALSE;
   strcpy (files[4], argv[2]);
 
   /* load image header and data */
-  if (!fits_read_header (argv[1], &header)) {
+  if (!gfits_read_header (argv[1], &header)) {
     fprintf (stderr, "ERROR: can't open FITS header %s\n", argv[1]);
     exit (1);
   }
-  if (!fits_read_matrix (argv[1], &matrix)) {
+  if (!gfits_read_matrix (argv[1], &matrix)) {
     fprintf (stderr, "ERROR: can't open FITS matrix %s\n", argv[1]);
     exit (1);
   }
   /* convert to float, set up noise array and axes */
-  fits_convert_format (&header, &matrix, -32, 1.0, 0.0, 0);
+  gfits_convert_format (&header, &matrix, -32, 1.0, 0.0, 0xffff, 0);
   ALLOCATE (noise, float, matrix.size);
   big = (float *) matrix.buffer;
@@ -33,7 +32,7 @@
  
   /* override config values with header values */ 
-  if (fits_scan (&header, "SATVALUE", "%f", 1, &tmp)) itop = tmp;
-  if (fits_scan (&header, "GAIN", "%f", 1, &tmp)) eperdn = tmp;
-  if (fits_scan (&header, "NEWGAIN", "%f", 1, &tmp)) eperdn = tmp;
+  if (gfits_scan (&header, "SATVALUE", "%f", 1, &tmp)) itop = tmp;
+  if (gfits_scan (&header, "GAIN", "%f", 1, &tmp)) eperdn = tmp;
+  if (gfits_scan (&header, "NEWGAIN", "%f", 1, &tmp)) eperdn = tmp;
 
   /* we are scaling the image to electrons, must also scale parameters */
@@ -47,4 +46,5 @@
 
   fprintf (stderr, "SUCCESS\n");
+  exit (0);
 }
 
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/impaper2.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/impaper2.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/impaper2.c	(revision 21062)
@@ -20,5 +20,5 @@
   if (nsort < 1) return (0);
 
-  sort (zsort, nsort);
+  fsort (zsort, nsort);
         
   sky = 0;
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/mediansky.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/mediansky.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/mediansky.c	(revision 21062)
@@ -4,5 +4,4 @@
 static int Nx, Ny;
 static float fx, fy;
-sort (float *, int);
 
 int make_mediansky () {
@@ -59,5 +58,5 @@
       }
 
-      sort (temp, n);
+      fsort (temp, n);
       value = temp[(int)(0.5*n)];
 
@@ -86,5 +85,5 @@
   memcpy (temp, mediansky, Npix*sizeof(float));
 
-  sort (temp, Npix);
+  fsort (temp, Npix);
 
   *sky = temp[(int)(0.5*Npix)];
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/message.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/message.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/message.c	(revision 21062)
@@ -22,8 +22,8 @@
 }
 
-set_verbosity (int level) {
+int set_verbosity (int level) {
 
   f = stderr;
   verbosity = level;
-
+  return 1;
 }
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/paravg.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/paravg.c	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/gophot/src/paravg.c	(revision 21062)
@@ -1,3 +1,18 @@
 # include "gophot.h"
+
+sortkey (int *index, float *key, int N) {
+
+# define SWAPFUNC(A,B){ \
+  int   itmp; itmp = index[A]; index[A] = index[B]; index[B] = itmp; \
+  float ftmp; ftmp = key[A]; key[A] = key[B]; key[B] = ftmp; \
+}
+# define COMPARE(A,B)(key[A] < key[B])
+
+  OHANA_SORT (N, COMPARE, SWAPFUNC);
+
+# undef SWAPFUNC
+# undef COMPARE
+
+}
 
 paravg () {
Index: branches/ipp-magic-v0/Ohana/src/gophot/src/sort.c
===================================================================
--- branches/elixir/Ohana/src/gophot/src/sort.c	(revision 2472)
+++ 	(revision )
@@ -1,77 +1,0 @@
-
-sort (float *value, int N) {
-
-  int l,j,ir,i;
-  float temp;
-  
-  if (N < 2) return;
-  l = N >> 1;
-  ir = N - 1;
-  for (;;) {
-    if (l > 0) {
-      temp = value[--l];
-    }
-    else {
-      temp = value[ir];
-      value[ir] = value[0];
-      if (--ir == 0) {
-	value[0] = temp;
-	return;
-      }
-    }
-    i = l;
-    j = (l << 1) + 1;
-    while (j <= ir) {
-      if (j < ir && value[j] < value[j+1]) ++j;
-      if (temp < value[j]) {
-	value[i]=value[j];
-	j += (i=j) + 1;
-      }
-      else j = ir + 1;
-    }
-    value[i] = temp;
-  }
-}
-
-sortkey (int *index, float *key, int N) {
-
-  int l,j,ir,i;
-  float ktmp;
-  int  itmp;
-  
-  if (N < 2) return;
-  l = N >> 1;
-  ir = N - 1;
-  for (;;) {
-    if (l > 0) {
-      l--;
-      ktmp = key[l];
-      itmp = index[l];
-    }
-    else {
-      ktmp    = key[ir];
-      key[ir] = key[0];
-      itmp      = index[ir];
-      index[ir] = index[0];
-      ir--;
-      if (ir == 0) {
-	key[0] = ktmp;
-	index[0] = itmp;
-	return;
-      }
-    }
-    i = l;
-    j = (l << 1) + 1;
-    while (j <= ir) {
-      if (j < ir && key[j] < key[j+1]) ++j;
-      if (ktmp < key[j]) {
-	key[i] = key[j];
-	index[i] = index[j];
-	j += (i=j) + 1;
-      }
-      else j = ir + 1;
-    }
-    key[i] = ktmp;
-    index[i] = itmp;
-  }
-}
