| 153 | } |
| 154 | |
| 155 | static int parse (struct GMT_CTRL *GMT, struct GMTFLEXURE_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 156 | |
| 157 | unsigned int side, k, n_errors = 0; |
| 158 | int n; |
| 159 | bool both; |
| 160 | struct GMT_OPTION *opt = NULL; |
| 161 | struct GMTAPI_CTRL *API = GMT->parent; |
| 162 | |
| 163 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 164 | switch (opt->option) { |
| 165 | |
| 166 | case '>': /* Got named output file */ |
| 167 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 168 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file)); |
| 169 | break; |
| 170 | case 'A': /* Boundary conditions -A[l|r]<bc>[/<w>|<m>/<f>]*/ |
| 171 | both = false; side = 0; |
| 172 | switch (opt->arg[0]) { |
| 173 | case 'l': case 'L': side = LEFT; break; |
| 174 | case 'r': case 'R': side = RIGHT; break; |
| 175 | default: both = true; break; |
| 176 | } |
| 177 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active[side]); |
| 178 | k = (both) ? 0 : 1; /* Offset to <bc> argument */ |
| 179 | n = atoi (&opt->arg[k]); |
| 180 | if (n < BC_INFINITY || n > BC_FREE) { |
| 181 | GMT_Report (API, GMT_MSG_ERROR, "Option -A: <bc> must be in 1-4 range\n"); |
| 182 | n_errors++; |
| 183 | break; |
| 184 | } |
| 185 | Ctrl->A.bc[side] = (unsigned int)n; |
| 186 | if (Ctrl->A.bc[side] == BC_CLAMPED) /* Get clamped deflection */ |
| 187 | Ctrl->A.deflection[side] = (opt->arg[k+2]) ? atof (&opt->arg[k+2]) : 0.0; |
| 188 | else if (Ctrl->A.bc[side] == BC_FREE) { /* Get bending moment and shear force */ |
| 189 | if (opt->arg[k+2]) |
| 190 | sscanf (&opt->arg[k+2], "%lf/%lf", &Ctrl->A.moment[side], &Ctrl->A.force[side]); |
| 191 | } |
| 192 | if (both) { /* Copy values over from left to right */ |
| 193 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active[RIGHT]); |
| 194 | Ctrl->A.active[RIGHT] = true; |
| 195 | Ctrl->A.bc[RIGHT] = Ctrl->A.bc[LEFT]; |
| 196 | Ctrl->A.deflection[RIGHT] = Ctrl->A.deflection[LEFT]; |
| 197 | Ctrl->A.moment[RIGHT] = Ctrl->A.moment[LEFT]; |
| 198 | Ctrl->A.force[RIGHT] = Ctrl->A.force[LEFT]; |
| 199 | } |
| 200 | break; |
| 201 | case 'C': /* Rheology constants E and nu */ |
| 202 | switch (opt->arg[0]) { |
| 203 | case 'p': |
| 204 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active[0]); |
| 205 | n_errors += gmt_get_required_double (GMT, &opt->arg[1], opt->option, 0, &Ctrl->C.nu); |
| 206 | break; |
| 207 | case 'y': |
| 208 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active[1]); |
| 209 | n_errors += gmt_get_required_double (GMT, &opt->arg[1], opt->option, 0, &Ctrl->C.E); |
| 210 | break; |
| 211 | default: |
| 212 | GMT_Report (API, GMT_MSG_ERROR, "Option -C: Unrecognized modifier %c\n", opt->arg[0]); |
no test coverage detected