MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / deploy_test

Function deploy_test

src/testapi_uservectors.c:191–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191int deploy_test (unsigned int intype, unsigned int outtype, int alloc_in_GMT, int def_mode, int verbose) {
192 /* Run the test using the specified in and out types */
193 uint64_t dim[3] = {NCOLS, NROWS, 0}; /* ncols, nrows, type */
194 int bad = 0;
195 unsigned int out_via = (outtype + 1) * 100 + GMT_IS_POINT; /* To get GMT_VIA_<type */
196 unsigned int mode = GMT_SESSION_EXTERNAL;
197 double diff, range[2] = {1.0, NROWS}, inc[2] = {1.0, 1.0};
198 //void *API = NULL; /* The API control structure */
199 struct GMT_VECTOR *V[2] = {NULL, NULL}; /* Structure to hold input/output datasets as vectors */
200 char input[GMT_VF_LEN] = {""}; /* String to hold virtual input filename */
201 char output[GMT_VF_LEN] = {""}; /* String to hold virtual output filename */
202 char args[128] = {""}; /* String to hold module command arguments */
203 void *in_data[NCOLS] = {NULL, NULL}, *out_data[NCOLS] = {NULL, NULL};
204 struct GMTAPI_CTRL *API = NULL;
205
206 if (verbose) mode += (6 << 16); /* Activate -Vd */
207 in_data[GMT_X] = get_array (intype, 1); /* Create dummy user dataset in_data[] = k */
208 in_data[GMT_Y] = get_array (intype, 1); /* Create dummy user dataset in_data[] = k */
209
210 /* Initialize a GMT session */
211 API = GMT_Create_Session ("test", 2U, mode, NULL);
212 /* Create a blank vector container that will hold our user in_data */
213 if (def_mode == 0) { /* Use dimensions to allocate */
214 if ((V[GMT_IN] = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_CONTAINER_ONLY, dim, NULL, NULL, 0, 0, NULL)) == NULL) return (EXIT_FAILURE);
215 }
216 else { /* Use col dimension and range and inc to allocate space */
217 dim[1] = 0; /* So that we compute it in GMT_Create_Vector */
218 if ((V[GMT_IN] = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_CONTAINER_ONLY, dim, range, inc, 0, 0, NULL)) == NULL) return (EXIT_FAILURE);
219 }
220 /* Hook the user input arrays up to this container */
221 GMT_Put_Vector (API, V[GMT_IN], GMT_X, intype, in_data[GMT_X]);
222 GMT_Put_Vector (API, V[GMT_IN], GMT_Y, intype, in_data[GMT_Y]);
223 /* Associate our vectors container with a virtual dataset file to "read" from. REFERENCE will be switched to DUPLICATE if input is not double */
224 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_IN|GMT_IS_REFERENCE, V[GMT_IN], input);
225 if (alloc_in_GMT) /* Request vectors container for output data to be allocated by GMT */
226 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, out_via, GMT_OUT|GMT_IS_REFERENCE, NULL, output);
227 else { /* Preallocate array space here in the app */
228 out_data[GMT_X] = get_array (outtype, 0); /* Make user space for output */
229 out_data[GMT_Y] = get_array (outtype, 0); /* Make user space for output */
230 /* Create a blank vectors container that will hold our user out_data, and pass dim so we can set those correctly */
231 if (def_mode == 0) { /* Use dimensions to allocate */
232 V[GMT_OUT] = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_IS_OUTPUT, dim, NULL, NULL, 0, 0, NULL);
233 }
234 else { /* Use region and inc instead */
235 V[GMT_OUT] = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_IS_OUTPUT, dim, range, inc, 0, 0, NULL);
236 }
237 /* Hook the user output array up to this containers */
238 GMT_Put_Vector (API, V[GMT_OUT], GMT_X, outtype, out_data[GMT_X]);
239 GMT_Put_Vector (API, V[GMT_OUT], GMT_Y, outtype, out_data[GMT_Y]);
240 /* Associate our data vectors with a virtual dataset file to "write" to. REFERENCE will be switched to DUPLICATE if output is not double */
241 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_OUT|GMT_IS_REFERENCE, V[GMT_OUT], output);
242 }
243 /* Prepare the module arguments to multiply the input dataset by 10 then add 1 */
244 sprintf (args, "%s 10 MUL 1 ADD = %s", input, output);
245 /* Call the gmtmath module */
246 GMT_Call_Module (API, "gmtmath", GMT_MODULE_CMD, args);
247 if (alloc_in_GMT) { /* Obtain the vectors container from the output virtual file */
248 V[GMT_OUT] = GMT_Read_VirtualFile (API, output);

Callers 1

mainFunction · 0.70

Calls 12

GMT_Create_SessionFunction · 0.85
GMT_Create_DataFunction · 0.85
GMT_Put_VectorFunction · 0.85
GMT_Open_VirtualFileFunction · 0.85
GMT_Call_ModuleFunction · 0.85
GMT_Read_VirtualFileFunction · 0.85
GMT_Get_VectorFunction · 0.85
GMT_Close_VirtualFileFunction · 0.85
sum_arraysFunction · 0.85
GMT_Destroy_SessionFunction · 0.85
get_arrayFunction · 0.70
put_arrayFunction · 0.70

Tested by

no test coverage detected