[cig-commits] r12862 - mc/1D/hc/trunk

becker at geodynamics.org becker at geodynamics.org
Thu Sep 11 00:25:50 PDT 2008


Author: becker
Date: 2008-09-11 00:25:49 -0700 (Thu, 11 Sep 2008)
New Revision: 12862

Modified:
   mc/1D/hc/trunk/Makefile
   mc/1D/hc/trunk/calc_vel_and_plot
   mc/1D/hc/trunk/ggrd_grdtrack_util.c
   mc/1D/hc/trunk/ggrd_grdtrack_util.h
   mc/1D/hc/trunk/ggrd_struc.h
   mc/1D/hc/trunk/hc_auto_proto.h
   mc/1D/hc/trunk/prem.h
   mc/1D/hc/trunk/sh_exp.c
Log:
Minor further GMT adjustments (longitudes will not automatically be shifted to 0 ... 360 
anymore; that should now be taken up by the actual GMT part).



Modified: mc/1D/hc/trunk/Makefile
===================================================================
--- mc/1D/hc/trunk/Makefile	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/Makefile	2008-09-11 07:25:49 UTC (rev 12862)
@@ -181,10 +181,12 @@
 		 $(GGRD_LIBS_LINKLINE) -lm $(LDFLAGS) 
 
 hc.dbg: $(LIBS) $(INCS) $(ODIR)/main.dbg.o $(PREM_OBJS)
-	$(CC) $(LIB_FLAGS) $(ODIR)/main.dbg.o $(PREM_OBJS) \
-	-o $(BDIR)/hc.dbg -lhc.dbg -lrick.dbg -lggrd.dbg -lgmt -lnetcdf \
-	$(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS) 
+	$(CC) $(LIB_FLAGS) $(ODIR)/main.dbg.o -o $(BDIR)/hc.dbg \
+		-lhc.dbg -lrick.dbg $(HEAL_LIBS_LINKLINE) $(PREM_OBJS) \
+		 $(GGRD_LIBS_LINKLINE) -lm $(LDFLAGS) 
 
+
+
 test_fft: $(LIBS) $(INCS) $(ODIR)/test_fft.o
 	$(CC) $(LIB_FLAGS) $(ODIR)/test_fft.o -o $(BDIR)/test_fft \
 		-lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS) 

Modified: mc/1D/hc/trunk/calc_vel_and_plot
===================================================================
--- mc/1D/hc/trunk/calc_vel_and_plot	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/calc_vel_and_plot	2008-09-11 07:25:49 UTC (rev 12862)
@@ -8,6 +8,7 @@
                                 # 1: geoid
                                 # 2: plate velocities
                                 # 3: tractions
+                                # 4: extract all velocities into grids
 
 #
 # options
@@ -21,8 +22,8 @@
 #
 # boundary conditions
 #
-tbc=-fs                	# -fs: free slip
-#tbc="-pvel example_data/pvel.sh.dat"         # empty: plates, or specific plate velocity file
+#tbc=-fs                	# -fs: free slip
+tbc="-pvel example_data/pvel.sh.dat"         # empty: plates, or specific plate velocity file
 
 #
 # viscosity file

Modified: mc/1D/hc/trunk/ggrd_grdtrack_util.c
===================================================================
--- mc/1D/hc/trunk/ggrd_grdtrack_util.c	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/ggrd_grdtrack_util.c	2008-09-11 07:25:49 UTC (rev 12862)
@@ -82,7 +82,6 @@
   static ggrd_boolean bilinear = TRUE; /* bilinear by default */
   
   int pad[4];
-  ggrd_boolean geographic_in;	/* this is set by grdtrack_init */
   int i,j;
   float zavg,tmp;
   /* clear all entries */
@@ -92,7 +91,7 @@
 
   if(ggrd_grdtrack_init(&g->west,&g->east,&g->south,&g->north,&g->f,&g->mm,
 			grdfile,&g->grd,&g->edgeinfo,
-			gmt_edgeinfo_string,&geographic_in,
+			gmt_edgeinfo_string,&g->geographic_in,
 			pad,is_three,depth_file,&g->z,&g->nz,
 			bilinear,verbose,change_z_sign,
 			g->loc_bcr))
@@ -190,7 +189,8 @@
 */
 ggrd_boolean ggrd_grdtrack_interpolate_rtp(double r,double t,double p,
 					   struct ggrd_gt *g,double *value,
-					   ggrd_boolean verbose)
+					   ggrd_boolean verbose,
+					   ggrd_boolean shift_to_pos_lon)
 {
   double x[3];
   ggrd_boolean result;
@@ -206,11 +206,13 @@
      convert coordinates to lon / lat / z
   */
   x[0] = p * ONEEIGHTYOVERPI; /* lon */
-  /* make sure we are in 0 ... 360 system */
-  if(x[0]<0)
-    x[0]+=360.0;
-  if(x[0]>=360)
-    x[0]-=360.0;
+  if(shift_to_pos_lon){
+    /* make sure we are in 0 ... 360 system ? */
+    if(x[0]<0)
+      x[0]+=360.0;
+    if(x[0]>=360)
+      x[0]-=360.0;
+  }
   x[1] = 90.0 - t * ONEEIGHTYOVERPI; /* lat */
   x[2] = (1.0-r) * 6371.0;	/* depth in [km] */
   if(g->zlevels_are_negative)	/* adjust for depth */
@@ -269,9 +271,10 @@
 
 */
 ggrd_boolean ggrd_grdtrack_interpolate_tp(double t,double p,
-					   struct ggrd_gt *g,
-					   double *value,
-					   ggrd_boolean verbose)
+					  struct ggrd_gt *g,
+					  double *value,
+					  ggrd_boolean verbose,
+					  ggrd_boolean shift_to_pos_lon)
 {
   double x[3];
   ggrd_boolean result;
@@ -287,10 +290,12 @@
      convert coordinates
   */
   x[0] = p * ONEEIGHTYOVERPI; /* lon */
-  if(x[0] < 0)
-    x[0] += 360.0;
-  if(x[0] >= 360.0)
-    x[0]-=360.0;
+  if(shift_to_pos_lon){
+    if(x[0] < 0)
+      x[0] += 360.0;
+    if(x[0] >= 360.0)
+      x[0]-=360.0;
+  }
   x[1] = 90.0 - t * ONEEIGHTYOVERPI; /* lat */
   x[2] = 1.0;
   result = ggrd_grdtrack_interpolate(x,FALSE,g->grd,g->f,
@@ -432,7 +437,7 @@
   FILE *din;
   float dz1,dz2;
   struct GRD_HEADER ogrd;
-  int i,one_or_zero,nx,ny,mx,my,nn;
+  int i,j,one_or_zero,nx,ny,mx,my,nn;
   char filename[BUFSIZ*2],*cdummy;
   static int gmt_init = FALSE;
   /* 
@@ -473,12 +478,14 @@
   if (strlen(edgeinfo_string)>2){ /* the boundary flag was set */
     /* parse */
     GMT_boundcond_parse (*edgeinfo, (edgeinfo_string+2));
-    if ((*edgeinfo)->gn) 
-      *geographic_in = TRUE;
+    if ((*edgeinfo)->gn)
+      *geographic_in = 1;
+    else if((*edgeinfo)->nxp == -1)
+      *geographic_in = 2;
     else
-      *geographic_in = FALSE;
+      *geographic_in = 0;
   }else{
-    *geographic_in = FALSE;
+    *geographic_in = 0;
   }
   if(verbose >= 2)
     if(*geographic_in)
@@ -568,7 +575,7 @@
       return 4;
     }
    
-#else  /* 4.1.2 */
+#else  /* >=4.1.2 */
     if(verbose >= 2)
       fprintf(stderr,"ggrd_grdtrack_init: opening single file %s, GMT4 mode\n",grdfile);
     if(GMT_read_grd_info (grdfile,*grd)){
@@ -635,8 +642,8 @@
   if(verbose > 2)
     fprintf(stderr,"ggrd_grdtrack_init: read %i headers OK, grids appear to be same size\n",*nz);
   if (fabs(*west - (*east)) < 5e-7) {	/* No subset asked for , west same as east*/
-    *west = (*grd)[0].x_min;
-    *east = (*grd)[0].x_max;
+    *west =  (*grd)[0].x_min;
+    *east =  (*grd)[0].x_max;
     *south = (*grd)[0].y_min;
     *north = (*grd)[0].y_max;
   }
@@ -1163,6 +1170,7 @@
   int left, right,i;
   GGRD_CPREC f1,f2;
   double a1,a2;
+  static ggrd_boolean shift_to_pos_lon = FALSE;
 
   if(!ggrd->sf_init){
     /* 
@@ -1216,14 +1224,14 @@
     f1 = ggrd->sf_old_f1;f2 = ggrd->sf_old_f2;
   }
   if(!ggrd_grdtrack_interpolate_tp((double)xt,(double)xp,
-				   (ggrd->ages+left),&a1,FALSE)){
+				   (ggrd->ages+left),&a1,FALSE,shift_to_pos_lon)){
     fprintf(stderr,"interpolate_seafloor_ages: interpolation error left\n");
     return -6;
   }
   if(a1 > ggrd->ages[left].fmaxlim[0]) /* limit to bandlim */
     a1 = ggrd->ages[left].bandlim;
   if(!ggrd_grdtrack_interpolate_tp((double)xt,(double)xp,
-				   (ggrd->ages+right),&a2,FALSE)){
+				   (ggrd->ages+right),&a2,FALSE,shift_to_pos_lon)){
     fprintf(stderr,"interpolate_seafloor_ages: interpolation error right\n");
     return -6;
   }

Modified: mc/1D/hc/trunk/ggrd_grdtrack_util.h
===================================================================
--- mc/1D/hc/trunk/ggrd_grdtrack_util.h	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/ggrd_grdtrack_util.h	2008-09-11 07:25:49 UTC (rev 12862)
@@ -37,7 +37,7 @@
 			       ggrd_boolean);
 ggrd_boolean ggrd_grdtrack_interpolate_rtp(double ,double ,double ,
 					    struct ggrd_gt *,double *,
-					    ggrd_boolean);
+					    ggrd_boolean,ggrd_boolean);
 ggrd_boolean ggrd_grdtrack_interpolate_xyz(double ,double ,double ,
 					    struct ggrd_gt *,double *,
 					    ggrd_boolean);
@@ -48,7 +48,7 @@
 ggrd_boolean ggrd_grdtrack_interpolate_tp(double ,double ,
 					   struct ggrd_gt *,
 					   double *,
-					   ggrd_boolean );
+					   ggrd_boolean ,ggrd_boolean);
 
 void ggrd_grdtrack_free_gstruc(struct ggrd_gt *);
 

Modified: mc/1D/hc/trunk/ggrd_struc.h
===================================================================
--- mc/1D/hc/trunk/ggrd_struc.h	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/ggrd_struc.h	2008-09-11 07:25:49 UTC (rev 12862)
@@ -72,7 +72,7 @@
 
   unsigned char zlevels_are_negative;
 
-  unsigned char init,
+  unsigned char init,geographic_in,
     is_three;			/* is it a 3-D set? */
 
   double west,east,south,north;

Modified: mc/1D/hc/trunk/hc_auto_proto.h
===================================================================
--- mc/1D/hc/trunk/hc_auto_proto.h	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/hc_auto_proto.h	2008-09-11 07:25:49 UTC (rev 12862)
@@ -3,9 +3,9 @@
 void ggrd_grdinfo(char *);
 int ggrd_grdtrack_init_general(unsigned char, char *, char *, char *, struct ggrd_gt *, unsigned char, unsigned char);
 int ggrd_grdtrack_rescale(struct ggrd_gt *, unsigned char, unsigned char, unsigned char, double);
-unsigned char ggrd_grdtrack_interpolate_rtp(double, double, double, struct ggrd_gt *, double *, unsigned char);
+unsigned char ggrd_grdtrack_interpolate_rtp(double, double, double, struct ggrd_gt *, double *, unsigned char,unsigned char);
 unsigned char ggrd_grdtrack_interpolate_xyz(double, double, double, struct ggrd_gt *, double *, unsigned char);
-unsigned char ggrd_grdtrack_interpolate_tp(double, double, struct ggrd_gt *, double *, unsigned char);
+unsigned char ggrd_grdtrack_interpolate_tp(double, double, struct ggrd_gt *, double *, unsigned char,unsigned char);
 unsigned char ggrd_grdtrack_interpolate_xy(double, double, struct ggrd_gt *, double *, unsigned char);
 void ggrd_grdtrack_free_gstruc(struct ggrd_gt *);
 void ggrd_find_spherical_vel_from_rigid_cart_rot(double *, double *, double *, double *, double *);

Modified: mc/1D/hc/trunk/prem.h
===================================================================
--- mc/1D/hc/trunk/prem.h	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/prem.h	2008-09-11 07:25:49 UTC (rev 12862)
@@ -9,8 +9,10 @@
 
 #ifndef __READ_PREM_HEADER__
 #include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
 
-
 #define PREM_F_STRING "%lf"
 
 /* default number of layers */

Modified: mc/1D/hc/trunk/sh_exp.c
===================================================================
--- mc/1D/hc/trunk/sh_exp.c	2008-09-10 22:27:00 UTC (rev 12861)
+++ mc/1D/hc/trunk/sh_exp.c	2008-09-11 07:25:49 UTC (rev 12862)
@@ -816,7 +816,7 @@
 	 interpolate from grd 
       */
       for(k=0;k < shps;k++){
-	if(!ggrd_grdtrack_interpolate_tp((double)xp[HC_THETA],(double)xp[HC_PHI],(ggrd+k),&dvalue,FALSE)){
+	if(!ggrd_grdtrack_interpolate_tp((double)xp[HC_THETA],(double)xp[HC_PHI],(ggrd+k),&dvalue,FALSE,FALSE)){
 	  fprintf(stderr,"sh_read_spatial_data: interpolation error grd %i, lon %g lat %g\n",
 		  k+1,PHI2LON(xp[HC_PHI]),THETA2LAT(xp[HC_THETA]));
 	  exit(-1);



More information about the cig-commits mailing list