Revision: 8533
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8533&view=rev
Author:   jswhit
Date:     2010-07-08 14:22:11 +0000 (Thu, 08 Jul 2010)

Log Message:
-----------
new files from ncl 4.2.0 version.

Added Paths:
-----------
    trunk/toolkits/natgrid/src/ncarg/
    trunk/toolkits/natgrid/src/ncarg/ngmath.h
    trunk/toolkits/natgrid/src/nnculld.c
    trunk/toolkits/natgrid/src/nnculls.c

Added: trunk/toolkits/natgrid/src/ncarg/ngmath.h
===================================================================
--- trunk/toolkits/natgrid/src/ncarg/ngmath.h                           (rev 0)
+++ trunk/toolkits/natgrid/src/ncarg/ngmath.h   2010-07-08 14:22:11 UTC (rev 
8533)
@@ -0,0 +1,94 @@
+/* 
+ * $Id: ngmath.h.sed,v 1.3 2008/07/27 04:02:35 haley Exp $
+ */
+/************************************************************************
+*                                                                       *
+*                Copyright (C)  2000                                    *
+*        University Corporation for Atmospheric Research                *
+*                All Rights Reserved                                    *
+*                                                                       *
+*    The use of this Software is governed by a License Agreement.       *
+*                                                                       *
+************************************************************************/
+
+
+/*
+ *  This file contains some system includes used by Ngmath functions,
+ *  a source for the NGCALLF macro, the function prototypes for all 
+ *  user entry points in the Ngmath library, and some specific defines.
+ */
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+/*
+ *  Fortran function macro.  This macro is used to provide the appropriate
+ *  system-specific C function name for it to be Fortran callable.
+ */
+
+/*
+ *  Function prototypes for the natgrid package.
+ */
+
+/* was duplicated in nnuhead.h */
+void    c_nnseti(char *, int);
+void    c_nngeti(char *, int *);
+void    c_nnsetr(char *, float);
+void    c_nngetr(char *, float *);
+
+/* was duplicated in nnuheads.h */
+void    c_nnsetc(char *, char *);
+void    c_nngetc(char *, char *);
+float   *c_natgrids(int, float [], float [], float [],
+                     int, int, float [], float [], int *);
+
+/* was duplicated in nncheads.h */
+void    c_nngetslopes(int, int, float *, int *);
+void    c_nngetaspects(int, int, float *, int *);
+void    c_nnpntinits(int, float [], float [], float []);
+void    c_nnpnts(float, float, float *);
+void    c_nnpntend();
+void    c_nngetwts(int *, int *, float *, float *, float *, float *);
+
+/* was duplicated in nnuheadd.h */
+void    c_nnsetrd(char *, double);
+void    c_nngetrd(char *, double *);
+double  *c_natgridd(int, double [], double [], double [],
+                     int, int, double [], double [], int *);
+
+/* was duplicated in nncheadd.h */
+void    c_nngetsloped(int, int, double *, int *);
+void    c_nngetaspectd(int, int, double *, int *);
+void    c_nnpntinitd(int, double [], double [], double []);
+void    c_nnpntd(double, double, double *);
+void    c_nnpntendd();
+void    c_nngetwtsd(int *, int *, double *, double *, double *, double *);
+
+#ifdef  UNICOS
+#include <fortran.h>
+#define NGstring            _fcd
+#define NGCstrToFstr(cstr,len) ((cstr)?_cptofcd((char 
*)cstr,len):_cptofcd("",0)
+)
+#define NGFstrToCstr(fstr) (_fcdtocp(fstr))
+#define NGFlgclToClgcl(flog)  (_ltob(&flog))
+#define NGClgclToFlgcl(clog)  (_btol(clog))
+float   *c_natgrids(int, float [], float [], float [],
+float   *c_natgrids(int, float [], float [], float [],
+float   *c_natgrids(int, float [], float [], float [],
+float   *c_natgrids(int, float [], float [], float [],
+                     int, int, float [], float [], int *);
+                     int, int, float [], float [], int *);
+                     int, int, float [], float [], int *);
+                     int, int, float [], float [], int *);
+#else
+#define NGstring            char *
+#define NGCstrToFstr(cstr,len) (char *)cstr
+#define NGFstrToCstr(fstr) fstr
+#define NGFlgclToClgcl(flog)  flog
+#define NGClgclToFlgcl(clog)  clog
+#endif
+
+#define NGSTRLEN(cstr)      ((cstr)?strlen(cstr):0)
+ 

Added: trunk/toolkits/natgrid/src/nnculld.c
===================================================================
--- trunk/toolkits/natgrid/src/nnculld.c                                (rev 0)
+++ trunk/toolkits/natgrid/src/nnculld.c        2010-07-08 14:22:11 UTC (rev 
8533)
@@ -0,0 +1,124 @@
+#include <stdio.h>
+#include <string.h>
+#include <ncarg/ngmath.h>
+
+extern int maxmsg;
+
+/*
+ *  Comparison function for qsort to sort double precision triples.
+ */
+int comp_dtriples(const void *q1, const void *q2)
+{
+  double *p1, *p2;
+
+  p1 = (double *) q1;
+  p2 = (double *) q2;
+
+  if (p1[0] < p2[0]) {
+    return (-1);
+  }
+  else if (p1[0] > p2[0]) {
+    return (1);
+  }
+  else {
+    if (p1[1] < p2[1]) {
+      return (-1);
+    }
+    else if (p1[1] > p2[1]) {
+      return (1);
+    }
+    else {
+      if (p1[2] != p2[2]) {
+        printf("\n  Natgrid - two input triples have the same x/y 
coordinates");
+        printf("\n            but different data values: \n\n");
+        printf("                First triple:  %f %f %f\n",p1[0],p1[1],p1[2]);
+        printf("                Second triple: %f %f %f\n",p2[0],p2[1],p2[2]);
+        printf("\n\n");
+        exit(1);
+      }
+    }
+  }
+}
+
+/*
+ *  This function culls duplicate double precision triples 
+ *  from an array of "tnum" such in "data".  The triples
+ *  in "data" are assumed to have been sorted into
+ *  ascending order.  The number of distinct triples
+ *  is returned and the distinct triples themselves
+ *  are stored back in data.
+ */ 
+int cull_dtriples(int tnum, double *data) {
+  int i, ic, icm1, kout=0, msgmx=0, fmsg=0;
+  double *out,*xtmp; 
+
+  ic   = 3*sizeof(double);
+  icm1 = 2*sizeof(double);
+  out  = (double *) malloc(tnum*ic);
+
+/*
+ *  Copy over the first data triple.
+ */
+  kout++;
+  memcpy( (void *) out, (void *) data, ic);
+  
+/*
+ *  Test for duplicate points and copy non-duplicates to out.  All
+ *  full duplicates (coordinates plus data values) will be culled,
+ *  but duplicate coordinates having different data values will 
+ *  produce a fatal error.
+ */
+  for (i = 1; i < tnum; i++) {
+/*
+ *  Test for duplicate triples - do not copy them to "out".
+ */
+    if (memcmp((void *)(data+3*(i-1)), (void *)(data+3*i), ic) == 0) {
+      if (msgmx >= maxmsg && fmsg == 0 && maxmsg > 0) {
+        printf("Natgrid - maximum number of messages about duplicate input 
coordinates \n");
+        printf("          has been reached - no more such messages will be 
issued\n");
+        printf("          for this Natgrid call.\n");
+        fmsg = 1;
+      } 
+      else if (msgmx < maxmsg && fmsg == 0) {
+        printf("Natgrid info message - duplicate coordinate found, and 
culled,\n");
+        printf("                       in the input data for coordinate 
(%f,%f)\n",
+               data[3*(i-1)], data[3*(i-1)+1]);
+        msgmx++;
+      }
+    }
+
+/*
+ *  In the case of Natgrid the test for duplicate coordinates with 
+ *  different data values has already been done in the call to
+ *  qsort using the compare function comp_triples.  If this were 
+ *  not the case, the following commented lines would be appropriate 
+ *  to uncomment.
+ * 
+ *  else if ( (memcmp((void *)(data+3*(i-1)), 
+ *                    (void *)(data+3*i), 
+ *                    2*sizeof(double);) == 0) &&
+ *            (memcmp((void *)(data+3*(i-1)), 
+ *                    (void *)(data+3*i), 
+ *                    ic  ) != 0) ) {
+ *      printf("Error: duplicate coordinates found in the input data, at \
+ *              coordinate (%f,%f), having different data values.", \
+ *              data[i*ic],data[i*ic+1]);
+ *  }
+ */
+
+/*
+ *  Copy non-duplicate value to output.
+ */
+    else {
+        memcpy((void *)(out+3*kout), (void *)(data+3*i), ic);
+        kout++;
+    }
+  }
+
+/*  
+ *  Copy unique values back to the input array and free memory.
+ */
+  memcpy((void *)data, (void *)out, kout*ic);
+  free (out);
+  return kout;
+}

Added: trunk/toolkits/natgrid/src/nnculls.c
===================================================================
--- trunk/toolkits/natgrid/src/nnculls.c                                (rev 0)
+++ trunk/toolkits/natgrid/src/nnculls.c        2010-07-08 14:22:11 UTC (rev 
8533)
@@ -0,0 +1,123 @@
+#include <stdio.h>
+#include <string.h>
+#include <ncarg/ngmath.h>
+
+extern int maxmsg;
+
+/*
+ *  Comparison function for qsort to sort single precision triples.
+ */
+int comp_striples(const void *q1, const void *q2)
+{
+  float *p1, *p2;
+
+  p1 = (float *) q1;
+  p2 = (float *) q2;
+
+  if (p1[0] < p2[0]) {
+    return (-1);
+  }
+  else if (p1[0] > p2[0]) {
+    return (1);
+  }
+  else {
+    if (p1[1] < p2[1]) {
+      return (-1);
+    }
+    else if (p1[1] > p2[1]) {
+      return (1);
+    }
+    else {
+      if (p1[2] != p2[2]) {
+        printf("\n  Natgrid - two input triples have the same x/y 
coordinates");
+        printf("\n            but different data values: \n\n");
+        printf("                First triple:  %f %f %f\n",p1[0],p1[1],p1[2]);
+        printf("                Second triple: %f %f %f\n",p2[0],p2[1],p2[2]);
+        printf("\n\n");
+        exit(1);
+      }
+    }
+  }
+}
+
+/*
+ *  This function culls duplicate single precision triples 
+ *  from an array of "tnum" such in "data".  The triples
+ *  in "data" are assumed to have been sorted into
+ *  ascending order.  The number of distinct triples
+ *  is returned and the distinct triples themselves
+ *  are stored back in data.
+ */ 
+int cull_striples(int tnum, float *data) {
+  int i,ic,icm1,kout=0,msgmx=0,fmsg=0;
+  float *out,*xtmp; 
+
+  ic   = 3*sizeof(float);
+  icm1 = 2*sizeof(float);
+  out  = (float *) malloc(tnum*ic);
+
+/*
+ *  Copy over the first data triple.
+ */
+  kout++;
+  memcpy( (void *) out, (void *) data, ic);
+  
+/*
+ *  Test for duplicate points and copy non-duplicates to out.  All
+ *  full duplicates (coordinates plus data values) will be culled,
+ *  but duplicate coordinates having different data values will 
+ *  produce a fatal error.
+ */
+  for (i = 1; i < tnum; i++) {
+/*
+ *  Test for duplicate triples - do not copy them to "out".
+ */
+    if (memcmp((void *)(data+3*(i-1)), (void *)(data+3*i), ic) == 0) {
+      if (msgmx >= maxmsg && fmsg == 0 && maxmsg > 0) {
+        printf("Natgrid - maximum number of messages about duplicate input 
coordinates \n");
+        printf("          has been reached - no more such messages will be 
issued\n");
+        printf("          for this Natgrid call.\n");
+        fmsg = 1;
+      } 
+      else if (msgmx < maxmsg && fmsg == 0) {
+        printf("Natgrid info message - duplicate coordinate found, and 
culled,\n");
+        printf("                       in the input data for coordinate 
(%f,%f)\n",
+               data[3*(i-1)], data[3*(i-1)+1]);
+        msgmx++;
+      }
+    }
+
+/*
+ *  In the case of Natgrid the test for duplicate coordinates with 
+ *  different data values has already been done in the call to
+ *  qsort_triples.  If this were not the case, the following 
+ *  commented lines would be appropriate to uncomment.
+ * 
+ *  else if ( (memcmp((void *)(data+3*(i-1)), 
+ *                    (void *)(data+3*i), 
+ *                    2*sizeof(float);) == 0) &&
+ *            (memcmp((void *)(data+3*(i-1)), 
+ *                    (void *)(data+3*i), 
+ *                    ic  ) != 0) ) {
+ *      printf("Error: duplicate coordinates found in the input data, at \
+ *              coordinate (%f,%f), having different data values.", \
+ *              data[i*ic],data[i*ic+1]);
+ *  }
+ */
+
+/*
+ *  Copy non-duplicate value to output.
+ */
+    else {
+        memcpy((void *)(out+3*kout), (void *)(data+3*i), ic);
+        kout++;
+    }
+  }
+
+/*  
+ *  Copy unique values back to the input array and free memory.
+ */
+  memcpy((void *)data, (void *)out, kout*ic);
+  free (out);
+  return kout;
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to