3333#define THIS_MODULE_MODERN_NAME "gmtgravmag3d"
3434#define THIS_MODULE_LIB "potential"
3535#define THIS_MODULE_PURPOSE "Compute the gravity/magnetic anomaly of a 3-D body by the method of Okabe"
36- #define THIS_MODULE_KEYS "<D{,TD(=,FD(,MD(,GG},>D) "
36+ #define THIS_MODULE_KEYS "<D{,TD(=,FD(,MD(,GG},>DF "
3737#define THIS_MODULE_NEEDS "R"
3838#define THIS_MODULE_OPTIONS "-:RVfhior" GMT_ADD_xg_OPT
3939
@@ -178,7 +178,7 @@ GMT_LOCAL int check_triang_cw (struct GMTGRAVMAG3D_CTRL *Ctrl, unsigned int n, u
178178static int usage (struct GMTAPI_CTRL * API , int level ) {
179179 const char * name = gmt_show_name_and_purpose (API , THIS_MODULE_LIB , THIS_MODULE_CLASSIC_NAME , THIS_MODULE_PURPOSE );
180180 if (level == GMT_MODULE_PURPOSE ) return (GMT_NOERROR );
181- GMT_Usage (API , 0 , "usage: %s [<table>] -Tv <vert_file> | -Tr| s<raw_file> | -M+s<body>/<pars> [-C<density>] [-E<thickness>] "
181+ GMT_Usage (API , 0 , "usage: %s [<table>] -T+v <vert_file> | -T+r|+ s<raw_file> | -M+s<body>/<pars> [-C<density>] [-E<thickness>] "
182182 "[-F<xy_file>] [-G%s] [-H<f_dec>/<f_dip>/<m_int></m_dec>/<m_dip>] [%s] [-L<z_observation>] [%s] "
183183 "[-S<radius>] [-Z<level>] [%s] [-fg] [%s] [%s] [%s] [%s]%s[%s]\n" ,
184184 name , GMT_OUTGRID , GMT_I_OPT , GMT_Rgeo_OPT , GMT_V_OPT , GMT_h_OPT , GMT_i_OPT , GMT_o_OPT , GMT_r_OPT , GMT_xg_OPT , GMT_PAR_OPT );
@@ -188,13 +188,13 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
188188 GMT_Message (API , GMT_TIME_NONE , " REQUIRED ARGUMENTS:\n" );
189189 GMT_Usage (API , 1 , "\n<table>" );
190190 GMT_Usage (API , -2 , "One or more data files (in ASCII, binary, netCDF) with data; see -T for format. If no files are given, standard input is read" );
191- GMT_Usage (API , 1 , "\n-Tv <vert_file> | -Tr| s<raw_file>" );
192- GMT_Usage (API , -2 , "Give names of xyz and vertex (-Tv <fname>) files defining a closed surface. "
193- "If <xyz_file> has more then 3 columns it means variable magnetization; see docs for more details. "
191+ GMT_Usage (API , 1 , "\n-T+v <vert_file> | -T+r|+ s<raw_file>" );
192+ GMT_Usage (API , -2 , "Give names of xyz and vertex (-T+v <fname>) files defining a closed surface. "
193+ "If <xyz_file> has more then 3 columns it means variable magnetization; see HTML docs for more details. "
194194 "The file formats correspond to the output of the triangulate program. "
195195 "Alternatively, use directives to indicate specific formats:" );
196- GMT_Usage (API , 3 , "r: Append <file> in raw triangle format (x1 y1 z1 x2 ... z3)." );
197- GMT_Usage (API , 3 , "s: Append <file> in STL format." );
196+ GMT_Usage (API , 3 , "+ r: Append <file> in raw triangle format (x1 y1 z1 x2 ... z3)." );
197+ GMT_Usage (API , 3 , "+ s: Append <file> in STL format." );
198198 GMT_Usage (API , 1 , "\nOR" );
199199 GMT_Usage (API , 1 , "\n-M+s<body>/<pars>" );
200200 GMT_Usage (API , -2 , "Select among one or more of the following bodies and append <pars>, where x0 and y0 are the horizontal coordinates "
@@ -758,7 +758,7 @@ GMT_LOCAL void solids(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl) {
758758#define bailout (code ) {gmt_M_free_options (mode); return (code);}
759759#define Return (code ) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}
760760
761- EXTERN_MSC int GMT_gmtgravmag3d (void * V_API , int mode , void * args ) {
761+ EXTERN_MSC int GMT_gmtgravmag3d (void * V_API , int mode , void * args ) {
762762
763763 bool bat = true, DO = true;
764764 unsigned int row , col , i , j , k , kk ;
@@ -1076,26 +1076,7 @@ EXTERN_MSC int GMT_gmtgravmag3d (void *V_API, int mode, void *args) {
10761076 }
10771077 }
10781078
1079- if (Ctrl -> G .active ) {
1080- if (Ctrl -> C .active ) {
1081- strcpy (Gout -> header -> title , "Gravity field" );
1082- strcpy (Gout -> header -> z_units , "mGal" );
1083- }
1084- else {
1085- strcpy (Gout -> header -> title , "Magnetic field" );
1086- strcpy (Gout -> header -> z_units , "nT" );
1087- }
1088-
1089- if (GMT_Set_Comment (API , GMT_IS_GRID , GMT_COMMENT_IS_OPTION | GMT_COMMENT_IS_COMMAND , options , Gout )) {
1090- error = API -> error ;
1091- goto END ;
1092- }
1093- if (GMT_Write_Data (API , GMT_IS_GRID , GMT_IS_FILE , GMT_IS_SURFACE , GMT_CONTAINER_AND_DATA , NULL , Ctrl -> G .file , Gout ) != GMT_NOERROR ) {
1094- error = API -> error ;
1095- goto END ;
1096- }
1097- }
1098- else {
1079+ if (Ctrl -> F .active ) {
10991080 double out [3 ];
11001081 char save [GMT_LEN64 ] = {"" };
11011082 struct GMT_RECORD * Out = gmt_new_record (GMT , out , NULL );
@@ -1130,6 +1111,25 @@ EXTERN_MSC int GMT_gmtgravmag3d (void *V_API, int mode, void *args) {
11301111 goto END ;
11311112 }
11321113 }
1114+ else {
1115+ if (Ctrl -> C .active ) {
1116+ strcpy (Gout -> header -> title , "Gravity field" );
1117+ strcpy (Gout -> header -> z_units , "mGal" );
1118+ }
1119+ else {
1120+ strcpy (Gout -> header -> title , "Magnetic field" );
1121+ strcpy (Gout -> header -> z_units , "nT" );
1122+ }
1123+
1124+ if (GMT_Set_Comment (API , GMT_IS_GRID , GMT_COMMENT_IS_OPTION | GMT_COMMENT_IS_COMMAND , options , Gout )) {
1125+ error = API -> error ;
1126+ goto END ;
1127+ }
1128+ if (GMT_Write_Data (API , GMT_IS_GRID , GMT_IS_FILE , GMT_IS_SURFACE , GMT_CONTAINER_AND_DATA , NULL , Ctrl -> G .file , Gout ) != GMT_NOERROR ) {
1129+ error = API -> error ;
1130+ goto END ;
1131+ }
1132+ }
11331133
11341134END :
11351135 gmt_M_toc (GMT ,"" ); /* Print total run time, but only if -Vt was set */
@@ -1159,7 +1159,7 @@ EXTERN_MSC int GMT_gmtgravmag3d (void *V_API, int mode, void *args) {
11591159}
11601160
11611161/* -----------------------------------------------------------------*/
1162- GMT_LOCAL int read_stl (struct GMT_CTRL * GMT , struct GMTGRAVMAG3D_CTRL * Ctrl ) {
1162+ GMT_LOCAL int read_stl (struct GMT_CTRL * GMT , struct GMTGRAVMAG3D_CTRL * Ctrl ) {
11631163 /* read a file with triagles in the stl format and returns nb of triangles */
11641164 unsigned int ndata_s ;
11651165 size_t n_alloc ;
@@ -1211,7 +1211,7 @@ GMT_LOCAL int read_stl (struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl) {
12111211}
12121212
12131213/* -----------------------------------------------------------------*/
1214- GMT_LOCAL int facet_triangulate (struct GMTGRAVMAG3D_CTRL * Ctrl , struct BODY_VERTS * body_verts , unsigned int i , bool bat ) {
1214+ GMT_LOCAL int facet_triangulate (struct GMTGRAVMAG3D_CTRL * Ctrl , struct BODY_VERTS * body_verts , unsigned int i , bool bat ) {
12151215 /* Sets coordinates for the facet whose effect is being calculated */
12161216 double x_a , x_b , x_c , y_a , y_b , y_c , z_a , z_b , z_c ;
12171217 struct GMTGRAVMAG3D_XYZ * triang = Ctrl -> triang ;
@@ -1291,7 +1291,7 @@ GMT_LOCAL int facet_triangulate (struct GMTGRAVMAG3D_CTRL *Ctrl, struct BODY_VER
12911291}
12921292
12931293/* -----------------------------------------------------------------*/
1294- GMT_LOCAL int facet_raw (struct GMTGRAVMAG3D_CTRL * Ctrl , struct BODY_VERTS * body_verts , unsigned int i , bool geo ) {
1294+ GMT_LOCAL int facet_raw (struct GMTGRAVMAG3D_CTRL * Ctrl , struct BODY_VERTS * body_verts , unsigned int i , bool geo ) {
12951295 /* Sets coordinates for the facet in the RAW format */
12961296 double cos_a , cos_b , cos_c , x_a , x_b , x_c , y_a , y_b , y_c , z_a , z_b , z_c ;
12971297
@@ -1315,7 +1315,7 @@ GMT_LOCAL int facet_raw (struct GMTGRAVMAG3D_CTRL *Ctrl, struct BODY_VERTS *body
13151315}
13161316
13171317/* ---------------------------------------------------------------------- */
1318- GMT_LOCAL void set_center (struct GMTGRAVMAG3D_CTRL * Ctrl ) {
1318+ GMT_LOCAL void set_center (struct GMTGRAVMAG3D_CTRL * Ctrl ) {
13191319 /* Calculates triangle center by an approximate (iterative) formula */
13201320 int i , j , k = 5 ;
13211321 double x , y , z , xa [6 ], ya [6 ], xb [6 ], yb [6 ], xc [6 ], yc [6 ];
@@ -1372,7 +1372,7 @@ GMT_LOCAL void gmtgravmag3d_triang_norm (int n_triang) {
13721372}
13731373#endif
13741374
1375- GMT_LOCAL int check_triang_cw (struct GMTGRAVMAG3D_CTRL * Ctrl , unsigned int n , unsigned int type ) {
1375+ GMT_LOCAL int check_triang_cw (struct GMTGRAVMAG3D_CTRL * Ctrl , unsigned int n , unsigned int type ) {
13761376 /* Checks that triangles are given in the correct clock-wise order.
13771377 If not swap them. This is a tricky issue. In the case of "classic"
13781378 trihedron (x positive right; y positive "north" and z positive up),
0 commit comments