[cig-commits] r5379 - mc/1D/hc/trunk
becker at geodynamics.org
becker at geodynamics.org
Wed Nov 29 13:27:21 PST 2006
Author: becker
Date: 2006-11-29 13:27:20 -0800 (Wed, 29 Nov 2006)
New Revision: 5379
Modified:
mc/1D/hc/trunk/Makefile
mc/1D/hc/trunk/README.TXT
mc/1D/hc/trunk/ggrd_grdtrack_util.c
mc/1D/hc/trunk/ggrd_grdtrack_util.h
mc/1D/hc/trunk/ggrd_readgrds.c
mc/1D/hc/trunk/hc_auto_proto.h
mc/1D/hc/trunk/hc_polsol.c
Log:
Modified several files to make integration with GMT 4.1.2 work.
Modified: mc/1D/hc/trunk/Makefile
===================================================================
--- mc/1D/hc/trunk/Makefile 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/Makefile 2006-11-29 21:27:20 UTC (rev 5379)
@@ -4,6 +4,22 @@
#
#
#
+
+#
+# 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
+#
+# 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
+#
+#
+#
+#
# object file directory
ODIR = ../hc/objects/$(ARCH)/
#
@@ -59,12 +75,6 @@
GGRD_DEFINES = -I$(GMTHOME)/include -I$(NETCDFHOME)/include
GGRD_LIB_FLAGS = -L$(GMTHOME)/lib -L$(NETCDFHOME)/lib
GGRD_LIBS = $(ODIR)/libggrd.a $(ODIR)/libggrd.dfast.a $(ODIR)/libggrd.dbg.a
-# for GMT3.4.5
-GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include
-GGRD_LIBS_LINKLINE = -lggrd -lgmt -lnetcdf
-# for GMT 4.0
-#GGRD_INC_FLAGS = -I$(GMTHOME)/include -I$(NETCDFHOME)/include -DUSE_GMT4
-#GGRD_LIBS_LINKLINE = -lggrd -lgmt -lpsl -lnetcdf
#
#
#
@@ -129,8 +139,11 @@
really_all: dirs proto all
+
proto: hc_auto_proto.h
+
+
sh_test: $(LIBS) $(INCS) $(ODIR)/sh_test.o
$(LD) $(LIB_FLAGS) $(ODIR)/sh_test.o \
-o $(BDIR)/sh_test -lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
@@ -170,11 +183,17 @@
-o $(BDIR)/hc_extract_sh_layer \
-lhc -lrick $(HEAL_LIBS_LINKLINE) -lm $(LDFLAGS)
-
-# C function prototyper
+#
+# C function prototyper, strip out GMT version dependent things,
+# those are handled in other header
+#
hc_auto_proto.h:
cproto $(INC_FLAGS)-DGENERATE_PROTO -f 2 -p *.c | \
- grep -v "void main(" | grep -v "int main(" > hc_auto_proto.h
+ grep -v "void main(" | \
+ grep -v "ggrd_gt_bcr_init_loc(" | \
+ grep -v "ggrd_grdtrack_interpolate(" | \
+ grep -v "ggrd_grdtrack_init(" | \
+ grep -v "int main(" > hc_auto_proto.h
dirs:
if [ ! -s ../hc/ ]; then\
Modified: mc/1D/hc/trunk/README.TXT
===================================================================
--- mc/1D/hc/trunk/README.TXT 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/README.TXT 2006-11-29 21:27:20 UTC (rev 5379)
@@ -1,9 +1,46 @@
INSTALLATION
-The code should compile on any basic UNIX/Linux system. See Makefile
-for comments.
+The code should compile on any basic UNIX/Linux system with the GMT
+tools and libraries installed. See the Makefile for comments and what
+to modify.
+The Makefile assumes that the following environment variables are
+predefined:
+1) ARCH: should be the architecture you are compiling on, e.g. set with
+
+ setenv ARCH `uname -m | gawk '{print(tolower($1))}'`
+
+ for example, i686 for Intel
+
+
+2) GMTHOME: needs to point to the base directory of the GMT installation,
+e.g.
+ /usr/local/src/GMTdev/GMT3.4.5/
+
+
+3) NETCDFHOME: for the netcdf libraries, should be e.g.
+
+ /usr/local/src/netcdf-3.5.0/
+
+Also, the Makefile uses the commonly defined compiler variables CC,
+F77, CFLAGS, LD, and LDFLAGS.
+
+One common problem is the interface of the ggrd_ subroutines with
+GMT. By default, the Makefile is set up for the old syntac of GMT
+version 3.4.5. The other alternative is to use 4.1.2 and upward (note
+that there were changes between 4.0 and 4.1.2). If you have GMT newer
+or equal to 4.1.2, uncomment the two corresponding lines in the
+Makefile.
+
+With all things set up, you should be able to type
+
+make all
+
+to compile the programs.
+
+
+
HC CODE usage
Described in the help page that is displayed for "hc -h" as below. See
Modified: mc/1D/hc/trunk/ggrd_grdtrack_util.c
===================================================================
--- mc/1D/hc/trunk/ggrd_grdtrack_util.c 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/ggrd_grdtrack_util.c 2006-11-29 21:27:20 UTC (rev 5379)
@@ -515,20 +515,38 @@
if(*nz == 1){
if(verbose >= 2)
fprintf(stderr,"ggrd_grdtrack_init: opening single file %s\n",grdfile);
+#ifndef USE_GMT4 /* old */
if (GMT_cdf_read_grd_info (grdfile,(*grd))) {
fprintf (stderr, "%s: error opening file %s\n",
"ggrd_grdtrack_init", grdfile);
return 4;
}
+#else /* 4.1.2 */
+ sprintf((*grd)->name,"%s",grdfile);
+ if (GMT_cdf_read_grd_info ((*grd))) {
+ fprintf (stderr, "%s: error opening file %s\n",
+ "ggrd_grdtrack_init", grdfile);
+ return 4;
+ }
+#endif
}else{
/* loop through headers for testing purposess */
for(i=0;i<(*nz);i++){
sprintf(filename,"%s.%i.grd",grdfile,i+1);
+#ifndef USE_GMT4
if (GMT_cdf_read_grd_info (filename, (*grd+i))) {
fprintf (stderr, "%s: error opening file %s (-D option was used)\n",
"ggrd_grdtrack_init", filename);
return 6;
}
+#else
+ sprintf((*grd+i)->name,"%s",filename);
+ if (GMT_cdf_read_grd_info ((*grd+i))) {
+ fprintf (stderr, "%s: error opening file %s (-D option was used)\n",
+ "ggrd_grdtrack_init", filename);
+ return 6;
+ }
+#endif
if(i == 0){
/* save the first grid parameters */
ogrd.x_min = (*grd)[0].x_min;
@@ -622,9 +640,10 @@
read the grd files
*/
#ifdef USE_GMT4
- if (GMT_cdf_read_grd (filename, (*grd+i), (*f+i* (*mm)),
+ sprintf((*grd+i)->name,"%s",filename);
+ if (GMT_cdf_read_grd ((*grd+i), (*f+i* (*mm)),
*west, *east, *south, *north,
- pad, FALSE,NC_FLOAT)) {
+ pad, FALSE)) {
fprintf (stderr, "%s: error reading file %s\n", "ggrd_grdtrack_init", grdfile);
return 10;
}
Modified: mc/1D/hc/trunk/ggrd_grdtrack_util.h
===================================================================
--- mc/1D/hc/trunk/ggrd_grdtrack_util.h 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/ggrd_grdtrack_util.h 2006-11-29 21:27:20 UTC (rev 5379)
@@ -49,13 +49,16 @@
*/
int ggrd_read_time_intervals(struct ggrd_t *,char *,unsigned char ,unsigned char);
int ggrd_read_vel_grids(struct ggrd_vel *, double, unsigned short, unsigned short, char *);
+
#ifdef USE_GMT4
+/* GMT4.1.2 */
unsigned char ggrd_grdtrack_interpolate(double *, unsigned char , struct GRD_HEADER *, float *,
struct GMT_EDGEINFO *, int, float *, int , double *,unsigned char,
struct GMT_BCR *);
int ggrd_grdtrack_init(double *, double *, double *, double *, float **, int *, char *, struct GRD_HEADER **, struct GMT_EDGEINFO **, char *, unsigned char *, int *, unsigned char, char *, float **, int *, unsigned char, unsigned char, unsigned char, struct GMT_BCR *);
#else
+/* GMT 3.4.5 */
unsigned char ggrd_grdtrack_interpolate(double *, unsigned char , struct GRD_HEADER *, float *,
struct GMT_EDGEINFO *, int, float *, int , double *,unsigned char);
@@ -76,6 +79,7 @@
int *, /* number of layers */
unsigned char , /* linear/cubic? */
unsigned char ,unsigned char);
+void ggrd_gt_bcr_init_loc(void);
#endif
/*
Modified: mc/1D/hc/trunk/ggrd_readgrds.c
===================================================================
--- mc/1D/hc/trunk/ggrd_readgrds.c 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/ggrd_readgrds.c 2006-11-29 21:27:20 UTC (rev 5379)
@@ -226,10 +226,18 @@
sprintf(sname,"%s%svp.%i.%s",
prefix,loc_prefix,level,suffix);
if(v->read_gmt){
+#ifndef USE_GMT4 /* old */
if(GMT_cdf_read_grd_info (sname,header) == -1){
fprintf(stderr,"ggrd_read_vel_grids: error opening GMT grd file %s\n",sname);
return(-2);
}
+#else /* new */
+ sprintf(header->name,"%s",sname);
+ if(GMT_cdf_read_grd_info (header) == -1){
+ fprintf(stderr,"ggrd_read_vel_grids: error opening GMT grd file %s\n",sname);
+ return(-2);
+ }
+#endif
}else{
in = hc_open(sname,"r","ggrd_read_vel_grids");
// read header type of information
@@ -345,16 +353,17 @@
exit(-1);
}
}
- if(v->read_gmt)
+ if(v->read_gmt){
#ifdef USE_GMT4
// read the netcdf GRD file
- GMT_cdf_read_grd (sname,header,fgrd, 0.0, 0.0, 0.0, 0.0,
- dummy, 0, NC_FLOAT);
+ sprintf(header->name,"%s",sname);
+ GMT_cdf_read_grd (header,fgrd, 0.0, 0.0, 0.0, 0.0,
+ dummy, 0);
#else
GMT_cdf_read_grd (sname,header,fgrd, 0.0, 0.0, 0.0, 0.0,
dummy, 0);
#endif
- else{
+ }else{
fread(dgrd,sizeof(double),header->nx*header->ny,in);
fclose(in);
}
Modified: mc/1D/hc/trunk/hc_auto_proto.h
===================================================================
--- mc/1D/hc/trunk/hc_auto_proto.h 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/hc_auto_proto.h 2006-11-29 21:27:20 UTC (rev 5379)
@@ -7,16 +7,13 @@
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 *);
-int ggrd_grdtrack_init(double *, double *, double *, double *, float **, int *, char *, struct GRD_HEADER **, struct GMT_EDGEINFO **, char *, unsigned char *, int *, unsigned char, char *, float **, int *, unsigned char, unsigned char, unsigned char);
void ggrd_print_layer_avg(float *, float *, int, int, FILE *);
-unsigned char ggrd_grdtrack_interpolate(double *, unsigned char, struct GRD_HEADER *, float *, struct GMT_EDGEINFO *, int, float *, int, double *, unsigned char);
int ggrd_read_time_intervals(struct ggrd_t *, char *, unsigned char, unsigned char);
void ggrd_gt_interpolate_z(double, float *, int, int *, int *, double *, double *, unsigned char);
void ggrd_interpol_time(double, struct ggrd_t *, int *, int *, double *, double *, double);
int interpolate_seafloor_ages(double, double, double, struct ggrd_vel *, double *);
float ggrd_gt_rms(float *, int);
float ggrd_gt_mean(float *, int);
-void ggrd_gt_bcr_init_loc(void);
/* ggrd_readgrds.c */
void ggrd_init_vstruc(struct ggrd_vel *);
int ggrd_read_vel_grids(struct ggrd_vel *, double, unsigned short, unsigned short, char *);
Modified: mc/1D/hc/trunk/hc_polsol.c
===================================================================
--- mc/1D/hc/trunk/hc_polsol.c 2006-11-29 19:14:23 UTC (rev 5378)
+++ mc/1D/hc/trunk/hc_polsol.c 2006-11-29 21:27:20 UTC (rev 5379)
@@ -195,7 +195,7 @@
int newprp,newpot,jpb,inho2,ibv,indx[3],a_or_b,ilayer,lmax,
nprops_max;
HC_PREC *xprem;
- double *b,du1,du2,el,rnext,gf,drho,dadd;
+ double *b,du1,du2,el,rnext,drho,dadd;
double amat[3][3],bvec[3],u[4],poten[2],unew[4],potnew[2],clm[2];
static int ncalled = 0;
/* scaling factors will only be computed once */
More information about the cig-commits
mailing list