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

becker at geodynamics.org becker at geodynamics.org
Wed Jan 9 19:35:42 PST 2008


Author: becker
Date: 2008-01-09 19:35:41 -0800 (Wed, 09 Jan 2008)
New Revision: 8996

Modified:
   mc/1D/hc/trunk/Makefile
   mc/1D/hc/trunk/ggrd_struc.h
   mc/1D/hc/trunk/sh_syn.c
Log:
Modified sh_syn output options.



Modified: mc/1D/hc/trunk/Makefile
===================================================================
--- mc/1D/hc/trunk/Makefile	2008-01-09 01:43:58 UTC (rev 8995)
+++ mc/1D/hc/trunk/Makefile	2008-01-10 03:35:41 UTC (rev 8996)
@@ -8,22 +8,19 @@
 # 
 #
 #
-LD = $(CC)
-#CFLAGS = $(CFLAGS_DEBUG) 
-
 #
 # EDIT HERE FOR GMT VERSION 
 #
 #
 # for GMT3.4.5, use the next two lines
-GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include 
-GGRD_LIBS_LINKLINE = -lggrd -lgmt -lnetcdf
+#GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include 
+#GGRD_LIBS_LINKLINE = -lggrd -lgmt -lnetcdf
 # 
 #
 # for GMT version >= 4.1.2, uncomment the next two lines
 #
-#GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include -DUSE_GMT4 
-#GGRD_LIBS_LINKLINE = -lggrd -lgmt -lpsl -lnetcdf 
+GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include -DUSE_GMT4 
+GGRD_LIBS_LINKLINE = -lggrd -lgmt -lpsl -lnetcdf 
 #
 #
 #
@@ -163,45 +160,45 @@
 
 
 sh_test: $(LIBS) $(INCS) $(ODIR)/sh_test.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/sh_test.o \
+	$(CC) $(LIB_FLAGS) $(ODIR)/sh_test.o \
 		-o $(BDIR)/sh_test -lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
 
 sh_syn: $(LIBS) $(INCS) $(ODIR)/sh_syn.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/sh_syn.o \
-		-o $(BDIR)/sh_syn -lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
+	$(CC) $(LIB_FLAGS) $(ODIR)/sh_syn.o \
+		-o $(BDIR)/sh_syn -lhc -lrick $(HEAL_LIBS_LINKLINE) $(GGRD_LIBS_LINKLINE) -lm $(LDFLAGS)
 
 sh_power: $(LIBS) $(INCS) $(ODIR)/sh_power.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/sh_power.o \
+	$(CC) $(LIB_FLAGS) $(ODIR)/sh_power.o \
 		-o $(BDIR)/sh_power -lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
 
 sh_ana: $(LIBS) $(INCS) $(ODIR)/sh_ana.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/sh_ana.o \
+	$(CC) $(LIB_FLAGS) $(ODIR)/sh_ana.o \
 		-o $(BDIR)/sh_ana -lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
 
 
 hc: $(LIBS) $(INCS) $(ODIR)/main.o $(PREM_OBJS)
-	$(LD) $(LIB_FLAGS) $(ODIR)/main.o -o $(BDIR)/hc \
+	$(CC) $(LIB_FLAGS) $(ODIR)/main.o -o $(BDIR)/hc \
 		-lhc -lrick $(HEAL_LIBS_LINKLINE) $(PREM_OBJS) -lm $(LDFLAGS) 
 
 hc.dbg: $(LIBS) $(INCS) $(ODIR)/main.dbg.o $(PREM_OBJS)
-	$(LD) $(LIB_FLAGS) $(ODIR)/main.dbg.o $(PREM_OBJS) \
+	$(CC) $(LIB_FLAGS) $(ODIR)/main.dbg.o $(PREM_OBJS) \
 	-o $(BDIR)/hc.dbg -lhc.dbg -lrick.dbg \
 	$(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS) 
 
 test_fft: $(LIBS) $(INCS) $(ODIR)/test_fft.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/test_fft.o -o $(BDIR)/test_fft \
+	$(CC) $(LIB_FLAGS) $(ODIR)/test_fft.o -o $(BDIR)/test_fft \
 		-lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS) 
 
 ggrd_test: $(LIBS) $(INCS) $(ODIR)/ggrd_test.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/ggrd_test.o -o $(BDIR)/ggrd_test \
+	$(CC) $(LIB_FLAGS) $(ODIR)/ggrd_test.o -o $(BDIR)/ggrd_test \
 		$(GGRD_LIBS_LINKLINE) -lhc -lrick -lm $(LDFLAGS) 
 
 grdinttester: $(LIBS) $(INCS) $(ODIR)/grdinttester.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/grdinttester.o -o $(BDIR)/grdinttester \
+	$(CC) $(LIB_FLAGS) $(ODIR)/grdinttester.o -o $(BDIR)/grdinttester \
 		$(GGRD_LIBS_LINKLINE) -lhc -lrick -lm $(LDFLAGS) 
 
 hc_extract_sh_layer: $(LIBS) $(INCS) $(PREM_OBJS) $(ODIR)/hc_extract_sh_layer.o
-	$(LD) $(LIB_FLAGS) $(ODIR)/hc_extract_sh_layer.o $(PREM_OBJS) \
+	$(CC) $(LIB_FLAGS) $(ODIR)/hc_extract_sh_layer.o $(PREM_OBJS) \
 		-o $(BDIR)/hc_extract_sh_layer \
 		-lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS) 
 

Modified: mc/1D/hc/trunk/ggrd_struc.h
===================================================================
--- mc/1D/hc/trunk/ggrd_struc.h	2008-01-09 01:43:58 UTC (rev 8995)
+++ mc/1D/hc/trunk/ggrd_struc.h	2008-01-10 03:35:41 UTC (rev 8996)
@@ -4,18 +4,24 @@
 
 
 */
+#ifndef __GGRD_STRUC_INIT__
+
+
 #ifndef __GMT_INCLUDED__
 #include "gmt.h"
-#include "gmt_bcr.h"
 #define __GMT_INCLUDED__
 #endif
+
+
+
+
 /* 
    
 plate tectonic stages interpolation structure
 
 */
-#ifndef GGRD_STRUC_INIT
 
+
 struct ggrd_t{
   GGRD_CPREC *vtimes;		/* times at which velocities 
 				   are specified. this will hold
@@ -114,5 +120,5 @@
   GGRD_CPREC  sf_old_age,sf_old_f1,sf_old_f2;
   int sf_old_left,sf_old_right,sf_ntlim;
 };
-#define GGRD_STRUC_INIT
+#define __GGRD_STRUC_INIT__
 #endif

Modified: mc/1D/hc/trunk/sh_syn.c
===================================================================
--- mc/1D/hc/trunk/sh_syn.c	2008-01-09 01:43:58 UTC (rev 8995)
+++ mc/1D/hc/trunk/sh_syn.c	2008-01-10 03:35:41 UTC (rev 8996)
@@ -1,4 +1,5 @@
 #include "hc.h"
+#include "gmt.h"
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,15 +21,18 @@
   /* 
      switches 
   */
-  hc_boolean verbose = TRUE, short_format = FALSE ,short_format_ivec = FALSE ,binary = FALSE;
-  double regular_basis = 0;
+  hc_boolean verbose = TRUE, short_format = FALSE ,short_format_ivec = FALSE ,binary = FALSE,
+    regular_basis = FALSE;
+  double w,e,s,n,dx,dy;
   /*  */
   float *data,*theta,*phi;
   /* spacing for irregular output */
-  double dphi,x,y;
+  double dphi,x,y,dtheta;
   HC_PREC fac[3] = {1.,1.,1.},zlabel;
   SH_RICK_PREC *dummy;
   struct sh_lms *exp;
+  dx = 1.0;
+  w=0;e=360.;s=-90;n=90;
   if(argc > 1){
     if((strcmp(argv[1],"-h")==0)||(strcmp(argv[1],"--help")==0)||(strcmp(argv[1],"-help")==0))
       argc = -1000;
@@ -43,26 +47,39 @@
     if(i)
       short_format_ivec = TRUE;
   }
-  if(argc > 3)
-    sscanf(argv[3],"%lf",&regular_basis);
-
-  if((argc > 4)||(argc<0)){
-    fprintf(stderr,"usage: %s [short_format, %i] [short_ivec,%i] [regular_basis,%g]\n",
-	    argv[0],short_format,short_format_ivec,regular_basis);
+  if(argc > 3){
+    sscanf(argv[3],"%lf",&w);
+    regular_basis = TRUE;
+  }
+  if(argc > 4)
+    sscanf(argv[4],"%lf",&e);
+  if(argc > 5)
+    sscanf(argv[5],"%lf",&s);
+  if(argc > 6)
+    sscanf(argv[6],"%lf",&n);
+   if(argc > 7)
+    sscanf(argv[7],"%lf",&dx);
+  if(argc > 8)
+    sscanf(argv[8],"%lf",&dy);
+  else
+    dy = dx;
+  if((argc > 8)|| (argc < 0)){
+    fprintf(stderr,"usage: %s [short_format, %i] [short_ivec, %i] [w, %g] [e, %g] [s, %g] [n, %g] [dx, %g] [dy, dx] (in that order)\n",
+	    argv[0],short_format,short_format_ivec,w,e,s,n,dx);
     fprintf(stderr,"short_format:\n\t0: expects regular format with long header\n");
     fprintf(stderr,"\t1: expects short format with only lmax in header\n\n");
     fprintf(stderr,"short_ivec:\n\t0: for short format, expect AB for scalar expansion\n");
     fprintf(stderr,"\t1: for short format, expect poloidal toroidal AP BP AT BT for vector expansion\n\n");
-    fprintf(stderr,"regular_basis:\n\t0: use Gauss latitudes and FFT divided longitudes dependening on lmax\n");
-    fprintf(stderr,"\t>0 use even spacing with regular_basis degree inrecrments on the globe\n\n");
+    fprintf(stderr,"w,e,...\n\tif none of those are set, will use Gauss latitudes and FFT divided longitudes dependening on lmax\n");
+    fprintf(stderr,"\tif set, will switch to regular spaced output with -Rw/e/s/n -Idx/dy type output\n\n");
     fprintf(stderr,"The output format will depend on the type of SH input.\n");
     fprintf(stderr,"\tfor scalara: lon lat scalar if a single SH is read in, else lon lat zlabel scalar.\n");
     fprintf(stderr,"\tfor vectors: lon lat v_theta v_phi if a single SH is read in, else lon lat zlabel v_theta v_phi.\n\n\n");
     exit(-1);
   }
   if(verbose)
-    fprintf(stderr,"%s: waiting to read spherical harmonic coefficients from stdin\n",
-	    argv[0]);
+    fprintf(stderr,"%s: waiting to read spherical harmonic coefficients from stdin (use %s -h for help)\n",
+	    argv[0],argv[0]);
   while(sh_read_parameters_from_file(&type,&lmax,&shps,&ilayer,&nset,
 				     &zlabel,&ivec,stdin,short_format,
 				     binary,verbose)){
@@ -75,26 +92,39 @@
 	      argv[0],lmax,ivec,zlabel);
 
     /* input and init */
-    sh_allocate_and_init(&exp,shps,lmax,type,ivec,verbose,((regular_basis>0)?(1):(0)));
+    sh_allocate_and_init(&exp,shps,lmax,type,ivec,verbose,((regular_basis)?(1):(0)));
     sh_read_coefficients_from_file(exp,shps,-1,stdin,binary,fac,verbose);
-    if(regular_basis > 0){
+    if(regular_basis){
       /* 
 	 irregular basis output 
       */
-      dphi = regular_basis;
       if(verbose)
-	fprintf(stderr,"sh_syn: using regular spaced grid with %g deg spacing\n",dphi);
+	fprintf(stderr,"sh_syn: using regular spaced grid with -R%g/%g/%g/%g -I%g/%g spacing\n",
+		w,e,s,n,dx,dy);
+      if((w > e)||(s>n)||(s<-90)||(s>90)||(n<-90)||(n>90)){
+	fprintf(stderr,"%s: range error\n",argv[0]);
+	exit(-1);
+      }
+
+      if((ivec) && (s == -90)&&(n == 90)){
+	s += dy/2;
+	n -= dy/2;
+	fprintf(stderr,"sh_syn: vector fields: adjusting to -R%g/%g/%g/%g\n",
+		w,e,s,n);
+      }
       /*  */
-      dphi = DEG2RAD(dphi);
-      nphi = (RICK_TWOPI-dphi)/dphi + 1;
-      ntheta = nphi/2;
+      dphi = DEG2RAD(dx);
+      nphi = DEG2RAD(e-w)/dphi + 1;
+      dtheta = DEG2RAD(dy);
+      ntheta = DEG2RAD(n-s)/dtheta + 1;
       npoints = nphi * ntheta;
+
       /*  */
       hc_svecalloc(&phi,nphi,"sh_shsyn");
       hc_svecalloc(&theta,ntheta,"sh_shsyn");
-      for(x=0,i=0;i < nphi;i++,x+=dphi)
+      for(x=LON2PHI(w),i=0;i < nphi;i++,x += dphi)
 	phi[i] = x;
-      for(y=dphi/2,j=0;j<ntheta;y+=dphi,j++)
+      for(y = LAT2THETA(n),j=0;j < ntheta;y += dtheta,j++)
 	theta[j] = y;
       hc_svecalloc(&data,npoints * shps,"sh_shsyn data");
       /* compute the expansion */



More information about the cig-commits mailing list