#include #include #include #include /* utility program, here for historical reasons */ #define DEF_FIXED -1 // // reads in rotation vector file and xy code file with plate codes // // output is lon lat vp vt // // these are the coded plates as in the lon lat code tripel that is // read from stdin // #define CODED_PLATES 14 #define PLATE_CODES "ANT AUS AFR PAC EUR NAM NAZ COC CAR ARA PHI SAM IND JDF " // some factors #define PIOVERONEEIGHTY 0.0174532925199433 #define PIHALF 1.5707963267949 #define PI 3.14159265358979 //#define VELFACTOR (6371009.0/1.0e6*1.0e2) //#define PIOVERONEEIGHTY_TIMES_VELFACTOR (PIOVERONEEIGHTY*VELFACTOR) #define PIOVERONEEIGHTY_TIMES_VELFACTOR 11.1195083724191 FILE *rv_myopen(const char *,const char *); int main(int argc, char *argv[]) { int i,j,k,nplt,nrp,fixed_plate,*stats,minplate,maxplate,normalize=0,unity_vec=0, assigned[CODED_PLATES],hit,name[CODED_PLATES],code,code3; double *rotvel,*points,x,y,z,stheta,cphi,ctheta,sphi,vx,vy,vz,vt,vp, redvec[3],length; char allplates[]=PLATE_CODES,pname[4],tmpstring[300]; FILE *vel; switch(argc){ case 2:{ fixed_plate=DEF_FIXED; break; } case 3:{ sscanf(argv[2],"%i",&fixed_plate); break; } default:{ fprintf(stderr,"%s rotvector_file [fixed_plate]\n",argv[0]); fprintf(stderr,"\t reads points in (x y plate_code) format from stdin\n"); fprintf(stderr,"\t and calculates velocities (vp,vt) from rotvector_file\n"); fprintf(stderr,"\t rotvectorfile is in\n"); fprintf(stderr,"\t platename_1 wx_1 wy_1 wz_1\n"); fprintf(stderr,"\t platename_2 wx_2 wy_2 wz_2...\n"); fprintf(stderr,"\t format, wi_j in input is in [degrees/Myr]\n"); fprintf(stderr,"\t fixed_plate is the reference plate number (1,2,...) in the poles list,\n"); fprintf(stderr,"\t if set to -1, no change in motions.\n"); fprintf(stderr,"\t if set to -2, normalize all omega vectors to 1 deg/Myr length\n"); fprintf(stderr,"\t if set to -3, use 1 deg/Myr w_x vector, rest zero\n"); fprintf(stderr,"\t if set to -4, use 1 deg/Myr w_y vector, rest zero\n"); fprintf(stderr,"\t if set to -5, use 1 deg/Myr w_z vector, rest zero\n"); fprintf(stderr,"\t By default set to %i.\n",DEF_FIXED); fprintf(stderr,"\t output is in\n\tlon lat v_p v_t\n\tformat in cm/yr\n"); exit(-1); break; }} for(i=0;i0){ fprintf(stderr,"%s: input plate number %i will be fixed\n",argv[0],fixed_plate); if(fixed_plate>nplt){ fprintf(stderr,"%s: fixed plate number (%i) greater than plate numbers (1...%i)\n\n", argv[0],fixed_plate,nplt); } for(i=0;i<3;i++) redvec[i]= *(rotvel+name[fixed_plate-1]*3+i); }else{ for(i=0;i<3;i++) redvec[i]=0.0; if(fixed_plate==-2){ normalize=1; fprintf(stderr,"%s: normalizing all vectors\n",argv[0]); }else if(fixed_plate < -2 && fixed_plate > -6){ unity_vec=-fixed_plate-2; fprintf(stderr,"%s: using unity for %ith component of omega, zero else\n", argv[0],unity_vec); } } // // convert rotation poles // for(k=i=0;imaxplate) maxplate= *(points+k+2); nrp++; k += 3; if((points=((double *)realloc(points,sizeof(double)*3*nrp)))==NULL){ fprintf(stderr,"%s: memerror, too many points for x array, %i\n",argv[0],nrp); exit(-1); } } nrp--; fprintf(stderr,"%s: read %i points for velocities, calculating...\n",argv[0],nrp); fprintf(stderr,"%s: input plate codes run from %3i to %3i\n",argv[0],minplate+1,maxplate+1); if(minplate<0){ fprintf(stderr,"%s: expect code to start from 1\n",argv[0]);exit(-1); } if(maxplate>nplt-1 || maxplate-minplate>nplt){ fprintf(stderr,"%s: could only read %i plate codes from rotation vector file\n", argv[0],nplt); fprintf(stderr,"%s: will set velocities for all other codes to zero\n",argv[0]); } fprintf(stderr,"%s: now output...\n",argv[0]); #define WX ( *(rotvel+code3) ) #define WY ( *(rotvel+code3+1) ) #define WZ ( *(rotvel+code3+2) ) for(i=k=0;i