Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 49 additions & 71 deletions pygrt/C_extension/include/grt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Zhu Dengda (zhudengda@mail.iggcas.ac.cn)
* @date 2025-08
*
* C 程序的主函数,由此发起各个子模块的任务
* 集合所有相关的头文件
*
*/

Expand All @@ -18,75 +18,53 @@
#include <ctype.h>
#include <stdbool.h>

// ls grt/*/*.h | tr "" "\n" | sort | awk '{print "#include \""$1"\""}'
#include "grt/common/RT_matrix.h"
#include "grt/common/attenuation.h"
#include "grt/common/bessel.h"
#include "grt/common/checkerror.h"
#include "grt/common/colorstr.h"
#include "grt/common/const.h"
#include "grt/common/coord.h"
#include "grt/common/logo.h"
#include "grt/common/checkerror.h"


#define GRT_MAIN_COMMAND "grt" ///< 主程序名

// ------------------------------------------------------
/** X 宏,用于定义子模块命令。后续的命令名称和函数名称均与此匹配 */
#define GRT_Module_List \
/* dynamic */ \
X(greenfn) \
X(syn) \
X(rotation) \
X(strain) \
X(stress) \
X(kernel) \
/* static */ \
X(static_greenfn) \
X(static_syn) \
X(static_rotation) \
X(static_strain) \
X(static_stress) \
/* other */ \
X(ker2asc) \
X(sac2asc) \
X(travt) \
X(lamb1) \
// ------------------------------------------------------

/** 子模块的函数指针类型 */
typedef int (*GRT_MODULE_FUNC)(int argc, char **argv);

/** 子模块命令注册结构 */
typedef struct {
const char *name;
GRT_MODULE_FUNC func;
} GRT_MODULE_ENTRY;


/** 声明所有子模块函数 */
#define X(name) int name##_main(int argc, char **argv);
GRT_Module_List
#undef X

/** 注册所有子模块命令 */
extern const GRT_MODULE_ENTRY GRT_Modules_Entry[];

/** 定义包含子模块名称的字符串数组 */
extern const char *GRT_Module_Names[];





/** 共有的命令行处理语句 */
#define GRT_Common_Options_in_Switch(X) \
/** 帮助 */ \
case 'h': \
print_help(); \
exit(EXIT_SUCCESS); \
break; \
/** 参数缺失 */ \
case ':': \
GRTMissArgsError(X, ""); \
break; \
/** 非法选项 */ \
case '?': \
default: \
GRTInvalidOptionError(X, ""); \
break; \

#include "grt/common/matrix.h"
#include "grt/common/model.h"
#include "grt/common/myfftw.h"
#include "grt/common/mynetcdf.h"
#include "grt/common/progressbar.h"
#include "grt/common/radiation.h"
#include "grt/common/sacio.h"
#include "grt/common/sacio2.h"
#include "grt/common/search.h"
#include "grt/common/travt.h"
#include "grt/common/util.h"
#include "grt/common/version.h"


#include "grt/dynamic/grn.h"
#include "grt/dynamic/layer.h"
#include "grt/dynamic/signals.h"
#include "grt/dynamic/source.h"
#include "grt/dynamic/syn.h"


#include "grt/static/static_grn.h"
#include "grt/static/static_layer.h"
#include "grt/static/static_source.h"


#include "grt/integral/dcm.h"
#include "grt/integral/dwm.h"
#include "grt/integral/fim.h"
#include "grt/integral/integ_method.h"
#include "grt/integral/iostats.h"
#include "grt/integral/k_integ.h"
#include "grt/integral/kernel.h"
#include "grt/integral/ptam.h"
#include "grt/integral/quadratic.h"
#include "grt/integral/safim.h"


#include "grt/lamb/elliptic.h"
#include "grt/lamb/lamb1.h"
#include "grt/lamb/lamb_util.h"
18 changes: 18 additions & 0 deletions pygrt/C_extension/include/grt/common/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define mkdir(x, y) _mkdir(x) ///< 为windows系统修改mkdir函数
#endif

#define GRT_MAIN_COMMAND "grt" ///< 主程序名

// 使用双精度
typedef double real_t;
Expand Down Expand Up @@ -162,6 +163,23 @@ enum {
/** 当前模块名,根据所调用模块进行切换 */
extern const char *GRT_MODULE_NAME;

/** 共有的命令行处理语句 */
#define GRT_Common_Options_in_Switch(X) \
/** 帮助 */ \
case 'h': \
print_help(); \
exit(EXIT_SUCCESS); \
break; \
/** 参数缺失 */ \
case ':': \
GRTMissArgsError(X, ""); \
break; \
/** 非法选项 */ \
case '?': \
default: \
GRTInvalidOptionError(X, ""); \
break; \


/** 分别对应爆炸源(0阶),垂直力源(0阶),水平力源(1阶),剪切源(0,1,2阶) */
extern const int GRT_SRC_M_ORDERS[GRT_SRC_M_NUM];
Expand Down
10 changes: 0 additions & 10 deletions pygrt/C_extension/src/dynamic/grt_greenfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
*/


#include "grt/dynamic/grn.h"
#include "grt/dynamic/signals.h"
#include "grt/common/const.h"
#include "grt/common/model.h"
#include "grt/common/search.h"
#include "grt/common/sacio2.h"
#include "grt/common/util.h"
#include "grt/common/myfftw.h"
#include "grt/common/travt.h"
#include "grt/integral/integ_method.h"
#include "grt.h"


Expand Down
7 changes: 0 additions & 7 deletions pygrt/C_extension/src/dynamic/grt_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
*
*/

#include "grt/common/const.h"
#include "grt/common/model.h"
#include "grt/integral/kernel.h"
#include "grt/integral/iostats.h"
#include "grt/common/util.h"
#include "grt/common/progressbar.h"

#include "grt.h"

// 一些变量的非零默认值
Expand Down
4 changes: 0 additions & 4 deletions pygrt/C_extension/src/dynamic/grt_rotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*
*/


#include "grt/common/sacio2.h"
#include "grt/common/const.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
4 changes: 0 additions & 4 deletions pygrt/C_extension/src/dynamic/grt_strain.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*
*/


#include "grt/common/sacio2.h"
#include "grt/common/const.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
6 changes: 0 additions & 6 deletions pygrt/C_extension/src/dynamic/grt_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
*
*/

#include "grt/common/myfftw.h"

#include "grt/common/attenuation.h"
#include "grt/common/sacio2.h"
#include "grt/common/const.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
9 changes: 0 additions & 9 deletions pygrt/C_extension/src/dynamic/grt_syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@
*
*/

#include <dirent.h>

#include "grt/dynamic/signals.h"
#include "grt/common/sacio2.h"
#include "grt/common/const.h"
#include "grt/common/radiation.h"
#include "grt/common/coord.h"
#include "grt/dynamic/syn.h"

#include "grt.h"

// 防止被替换为虚数单位
Expand Down
41 changes: 40 additions & 1 deletion pygrt/C_extension/src/grt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,48 @@
*
*/


#include "grt.h"


// ------------------------------------------------------
/** X 宏,用于定义子模块命令。后续的命令名称和函数名称均与此匹配 */
#define GRT_Module_List \
/* dynamic */ \
X(greenfn) \
X(syn) \
X(rotation) \
X(strain) \
X(stress) \
X(kernel) \
/* static */ \
X(static_greenfn) \
X(static_syn) \
X(static_rotation) \
X(static_strain) \
X(static_stress) \
/* other */ \
X(ker2asc) \
X(sac2asc) \
X(travt) \
X(lamb1) \
// ------------------------------------------------------

/** 子模块的函数指针类型 */
typedef int (*GRT_MODULE_FUNC)(int argc, char **argv);

/** 子模块命令注册结构 */
typedef struct {
const char *name;
GRT_MODULE_FUNC func;
} GRT_MODULE_ENTRY;


/** 声明所有子模块函数 */
#define X(name) int name##_main(int argc, char **argv);
GRT_Module_List
#undef X


/** 注册所有子模块命令 */
const GRT_MODULE_ENTRY GRT_Modules_Entry[] = {
#define X(name) {#name, name##_main},
Expand Down
6 changes: 0 additions & 6 deletions pygrt/C_extension/src/lamb/grt_lamb1.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@
* 求解第一类 Lamb 问题的主函数
*/

#include <stdio.h>
#include <stdlib.h>

#include "grt.h"
#include "grt/lamb/lamb1.h"
#include "grt/lamb/lamb_util.h"


/** 该子模块的参数控制结构体 */
typedef struct {
Expand Down
10 changes: 0 additions & 10 deletions pygrt/C_extension/src/static/grt_static_greenfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
*
*/


#include "grt/static/static_grn.h"
#include "grt/common/const.h"
#include "grt/common/model.h"
#include "grt/integral/integ_method.h"
#include "grt/integral/iostats.h"
#include "grt/common/search.h"
#include "grt/common/util.h"
#include "grt/common/mynetcdf.h"

#include "grt.h"

// 一些变量的非零默认值
Expand Down
5 changes: 0 additions & 5 deletions pygrt/C_extension/src/static/grt_static_rotation.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
*
*/


#include "grt/common/const.h"
#include "grt/common/util.h"
#include "grt/common/mynetcdf.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
4 changes: 0 additions & 4 deletions pygrt/C_extension/src/static/grt_static_strain.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*
*/

#include "grt/common/const.h"
#include "grt/common/util.h"
#include "grt/common/mynetcdf.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
4 changes: 0 additions & 4 deletions pygrt/C_extension/src/static/grt_static_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
*
*/

#include "grt/common/const.h"
#include "grt/common/util.h"
#include "grt/common/mynetcdf.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
8 changes: 0 additions & 8 deletions pygrt/C_extension/src/static/grt_static_syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
*
*/


#include "grt/common/const.h"
#include "grt/common/radiation.h"
#include "grt/common/coord.h"
#include "grt/common/util.h"
#include "grt/common/search.h"
#include "grt/common/mynetcdf.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
4 changes: 0 additions & 4 deletions pygrt/C_extension/src/tools/grt_ker2asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
*
*/

#include "grt/common/const.h"
#include "grt/integral/iostats.h"
#include "grt/common/util.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
3 changes: 0 additions & 3 deletions pygrt/C_extension/src/tools/grt_sac2asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
*
*/


#include "grt/common/sacio2.h"

#include "grt.h"

/** 该子模块的参数控制结构体 */
Expand Down
Loading
Loading