📄 ciasp.c
字号:
#include <stdlib.h>#include <stdio.h>#include <string.h>#include "iasp.h"#ifdef HAVE_CONFIG_H#include <config.h>#endif/** * \brief Returns the model used (e.g., IASP91, AK135 ,...) * * Returns the Earth model implemented in this library. * This API method should be implemented by all libraries providing * such models (e.g., IASP, AK135,....) */char *libmodelversion(void) {char *s; s= malloc(strlen(PACKAGE)+strlen(VERSION)+3); sprintf(s,"%s-%s",PACKAGE,VERSION); return(s);}float TPTT(char id[IASPPHLENGTH],float *delta,float *depth, float *dtdd,float *dtdh);int MTPTT(char id[IASPPHLENGTH],float *delta,float *depth, int *max, char idph[MAXIASPPH][IASPPHLENGTH], float tt[MAXIASPPH], float dtdd[MAXIASPPH], float dtdh[MAXIASPPH]);float wtptt(char *id,float delta,float depth,struct ttime *tt){ char phase[IASPPHLENGTH]; int n=strlen(id),i; if (n>IASPPHLENGTH) n=IASPPHLENGTH; memset(phase,' ',IASPPHLENGTH); memcpy(phase,id,n); memcpy(tt->phase,phase,n); tt->phase[n]=0; tt->delta=delta; tt->depth=depth; n=MAXIASPPH; tt->N=MTPTT("all ",&(tt->delta),&(tt->depth), &n, tt->mphase, tt->mtt, tt->mdtdd,tt->mdtdh); if (tt->mtt[0]<0.0) {#ifdef IASP_VERBOSE fprintf(stderr,"Error looking for phase 'all'\n");#endif tt->N=0; return(-1.0); } tt->tt=-1.0; for (i=0; i<tt->N; i++) if (!memcmp(phase,tt->mphase[i],8)) { memcpy(tt->phase,tt->mphase[i],8); tt->tt=tt->mtt[i]; tt->dtdd=tt->mdtdd[i]; tt->dtdh=tt->mdtdh[i]; break; }#ifdef IASP_VERBOSE if (tt->tt<0.) { fprintf(stderr,"'%.8s' (%.2f %.2f): phase not found\n", phase,delta,depth); fprintf(stderr,"Found: "); for (i=0; i<tt->N; i++) fprintf(stderr,"'%.8s' ",tt->mphase[i]); fprintf(stderr,"\n"); }#endif return(tt->tt);}int wmtptt(char *id,float delta,float depth,struct ttime *tt){ char phase[IASPPHLENGTH]; int n=strlen(id); if (n>IASPPHLENGTH) n=IASPPHLENGTH; memset(phase,' ',IASPPHLENGTH); memcpy(phase,id,n); memcpy(tt->phase,phase,n); tt->phase[n]=0; tt->delta=delta; tt->depth=depth; n=MAXIASPPH; tt->N=MTPTT(phase,&(tt->delta),&(tt->depth), &n, tt->mphase, tt->mtt, tt->mdtdd,tt->mdtdh); return(tt->N);}/* Sets the path to the iasp tables. Argument: path + basename of the tables. For example, if the tables are "/foo/bar/iasp91.hed" and "/foo/bar/iasp91.tbl" (note that only the file extension differs), this function should be called with "/foo/bar/iasp91". Return value: -1 if the path is too long, 0 otherwise. (Arnaud Giersch, Thu Mar 28 10:52:00 CET 2002)*/int set_modnam (const char *s){ extern char mnpath_[]; const int mnlen = 256; int i; for (i = 0; i < mnlen && s[i]; i++) mnpath_[i] = s[i]; if (i == mnlen) return -1; for (/*nop*/; i < mnlen; i++) mnpath_[i] = ' '; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -