| 110 | } |
| 111 | |
| 112 | static int parse (struct GMT_CTRL *GMT, struct BLOCKMEAN_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 113 | /* This parses the options provided to blockmean and sets parameters in CTRL. |
| 114 | * Any GMT common options will override values set previously by other commands. |
| 115 | * It also replaces any file names specified as input or output with the data ID |
| 116 | * returned when registering these sources/destinations with the API. |
| 117 | */ |
| 118 | |
| 119 | unsigned int n_errors = 0, k; |
| 120 | char arg[GMT_LEN16] = {""}; |
| 121 | struct GMT_OPTION *opt = NULL; |
| 122 | struct GMTAPI_CTRL *API = GMT->parent; |
| 123 | |
| 124 | for (opt = options; opt; opt = opt->next) { |
| 125 | switch (opt->option) { |
| 126 | |
| 127 | case '<': /* Skip input files */ |
| 128 | if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++; |
| 129 | break; |
| 130 | |
| 131 | /* Processes program-specific parameters */ |
| 132 | |
| 133 | case 'A': /* Requires -G and selects which fields should be written as grids */ |
| 134 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 135 | BLK_strip_commas (opt->arg, arg); /* Make local copy with any commas removed */ |
| 136 | for (k = 0; arg[k] && Ctrl->A.n_selected < BLK_N_FIELDS; k++) { |
| 137 | switch (arg[k]) { |
| 138 | case 'z': Ctrl->A.selected[0] = true; break; |
| 139 | case 's': Ctrl->A.selected[1] = true; break; |
| 140 | case 'l': Ctrl->A.selected[2] = true; break; |
| 141 | case 'h': Ctrl->A.selected[3] = true; break; |
| 142 | case 'w': Ctrl->A.selected[4] = true; break; |
| 143 | default: |
| 144 | GMT_Report (API, GMT_MSG_ERROR, "Unrecognized field argument %s in -A.!\n", arg[k]); |
| 145 | n_errors++; |
| 146 | break; |
| 147 | } |
| 148 | Ctrl->A.n_selected++; |
| 149 | } |
| 150 | if (Ctrl->A.n_selected == 0) { /* No argument; let -Az be the default */ |
| 151 | GMT_Report (API, GMT_MSG_DEBUG, "-A interpreted to mean -Az.\n"); |
| 152 | Ctrl->A.selected[0] = true; |
| 153 | Ctrl->A.n_selected = 1; |
| 154 | } |
| 155 | break; |
| 156 | case 'C': /* Report center of block instead */ |
| 157 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 158 | n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0); |
| 159 | break; |
| 160 | case 'E': /* Extended report with standard deviation, min, and max in cols 4-6 */ |
| 161 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 162 | if (opt->arg[0] == 'p') { /* Old -Ep option */ |
| 163 | GMT_Report (API, GMT_MSG_COMPAT, "-Ep is deprecated; see -E+p|P instead.\n"); |
| 164 | Ctrl->E.mode = BLK_MODE_OBSOLETE; |
| 165 | } |
| 166 | else if (opt->arg[0] && strstr (opt->arg, "+p")) /* Error propagation on simple mean */ |
| 167 | Ctrl->E.mode = BLK_MODE_WEIGHTED; |
| 168 | else if (opt->arg[0] && strstr (opt->arg, "+P")) /* Error propagation on weighted mean */ |
| 169 | Ctrl->E.mode = BLK_MODE_SIMPLE; |
no test coverage detected