Redefine the default boolean type to gmx_bool.
[alexxy/gromacs.git] / src / gmxlib / selection / selmethod.c
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \internal \file
32  * \brief Implementation of functions in selmethod.h.
33  */
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37
38 #include <ctype.h>
39 #include <stdarg.h>
40
41 #include <macros.h>
42 #include <string2.h>
43
44 #include <selmethod.h>
45
46 #include "selcollection.h"
47 #include "symrec.h"
48
49 /*
50  * These global variables cannot be const because gmx_ana_selmethod_register()
51  * modifies them to set some defaults. This is a small price to pay for the
52  * convenience of not having to remember exactly how the selection compiler
53  * expects the structures to be filled, and even more so if the expectations
54  * change. Also, even if the gmx_ana_selmethod_t structures were made const,
55  * the parameters could not be without typecasts somewhere, because the param
56  * field in gmx_ana_selmethod_t cannot be declared const.
57  *
58  * Even though the variables may be modified, this should be thread-safe as
59  * modifications are done only in gmx_ana_selmethod_register(), and it should
60  * work even if called more than once for the same structure, and even if
61  * called concurrently from multiple threads (as long as the selection
62  * collection is not the same).
63  *
64  * All of these problems should go away if/when the selection methods are
65  * implemented as C++ classes.
66  */
67
68 /* From sm_com.c */
69 extern gmx_ana_selmethod_t sm_cog;
70 extern gmx_ana_selmethod_t sm_com;
71 /* From sm_simple.c */
72 extern gmx_ana_selmethod_t sm_all;
73 extern gmx_ana_selmethod_t sm_none;
74 extern gmx_ana_selmethod_t sm_atomnr;
75 extern gmx_ana_selmethod_t sm_resnr;
76 extern gmx_ana_selmethod_t sm_resindex;
77 extern gmx_ana_selmethod_t sm_molindex;
78 extern gmx_ana_selmethod_t sm_atomname;
79 extern gmx_ana_selmethod_t sm_atomtype;
80 extern gmx_ana_selmethod_t sm_resname;
81 extern gmx_ana_selmethod_t sm_insertcode;
82 extern gmx_ana_selmethod_t sm_chain;
83 extern gmx_ana_selmethod_t sm_mass;
84 extern gmx_ana_selmethod_t sm_charge;
85 extern gmx_ana_selmethod_t sm_altloc;
86 extern gmx_ana_selmethod_t sm_occupancy;
87 extern gmx_ana_selmethod_t sm_betafactor;
88 extern gmx_ana_selmethod_t sm_x;
89 extern gmx_ana_selmethod_t sm_y;
90 extern gmx_ana_selmethod_t sm_z;
91 /* From sm_distance.c */
92 extern gmx_ana_selmethod_t sm_distance;
93 extern gmx_ana_selmethod_t sm_mindistance;
94 extern gmx_ana_selmethod_t sm_within;
95 /* From sm_insolidangle.c */
96 extern gmx_ana_selmethod_t sm_insolidangle;
97 /* From sm_same.c */
98 extern gmx_ana_selmethod_t sm_same;
99
100 /* From sm_merge.c */
101 extern gmx_ana_selmethod_t sm_merge;
102 extern gmx_ana_selmethod_t sm_plus;
103 /* From sm_permute.c */
104 extern gmx_ana_selmethod_t sm_permute;
105
106 /*! \brief
107  * Helper structure for defining selection methods.
108  */
109 typedef struct {
110     /*! \brief
111      * Name to register the method under.
112      *
113      * If NULL, use the actual name of the method.
114      * This field is used for defining synonyms.
115      */
116     const char            *name;
117     /** Method data structure to register. */
118     gmx_ana_selmethod_t   *method;
119 } t_register_method;
120
121 /** Array of selection methods defined in the library. */
122 static const t_register_method smtable_def[] = {
123     {NULL,         &sm_cog},
124     {NULL,         &sm_com},
125
126     {NULL,         &sm_all},
127     {NULL,         &sm_none},
128     {NULL,         &sm_atomnr},
129     {NULL,         &sm_resnr},
130     {"resid",      &sm_resnr},
131     {NULL,         &sm_resindex},
132     {"residue",    &sm_resindex},
133     {NULL,         &sm_molindex},
134     {"mol",        &sm_molindex},
135     {"molecule",   &sm_molindex},
136     {NULL,         &sm_atomname},
137     {NULL,         &sm_atomtype},
138     {NULL,         &sm_resname},
139     {NULL,         &sm_insertcode},
140     {NULL,         &sm_chain},
141     {NULL,         &sm_mass},
142     {NULL,         &sm_charge},
143     {NULL,         &sm_altloc},
144     {NULL,         &sm_occupancy},
145     {NULL,         &sm_betafactor},
146     {NULL,         &sm_x},
147     {NULL,         &sm_y},
148     {NULL,         &sm_z},
149
150     {NULL,         &sm_distance},
151     {NULL,         &sm_mindistance},
152     {NULL,         &sm_within},
153     {NULL,         &sm_insolidangle},
154     {NULL,         &sm_same},
155
156     {NULL,         &sm_merge},
157     {NULL,         &sm_plus},
158     {NULL,         &sm_permute},
159 };
160
161 /*! \brief
162  * Convenience function for reporting errors found in selection methods.
163  */
164 static void
165 report_error(FILE *fp, const char *name, const char *fmt, ...)
166 {
167     va_list ap;
168     va_start(ap, fmt);
169     if (fp)
170     {
171         fprintf(fp, "selection method '%s': ", name);
172         vfprintf(fp, fmt, ap);
173         fprintf(fp, "\n");
174     }
175     va_end(ap);
176 }
177
178 /*! \brief
179  * Convenience function for reporting errors found in selection method parameters.
180  */
181 static void
182 report_param_error(FILE *fp, const char *mname, const char *pname,
183                    const char *fmt, ...)
184 {
185     va_list ap;
186     va_start(ap, fmt);
187     if (fp)
188     {
189         fprintf(fp, "selection method '%s': parameter '%s': ", mname, pname);
190         vfprintf(fp, fmt, ap);
191         fprintf(fp, "\n");
192     }
193     va_end(ap);
194 }
195
196 /*! \brief
197  * Checks the validity of parameters.
198  *
199  * \param[in]     fp      File handle to use for diagnostic messages
200  *   (can be NULL).
201  * \param[in]     name    Name of the method (used for error messages).
202  * \param[in]     nparams Number of parameters in \p param.
203  * \param[in,out] param   Parameter array
204  *   (only the \c flags field of gmx_boolean parameters may be modified).
205  * \param[in]     symtab  Symbol table (used for checking overlaps).
206  * \returns       TRUE if there are no problems with the parameters,
207  *   FALSE otherwise.
208  *
209  * This function performs some checks common to both check_method() and
210  * check_modifier().
211  * The purpose of these checks is to ensure that the selection parser does not
212  * need to check for the validity of the parameters at each turn, and to
213  * report programming errors as early as possible.
214  * If you remove a check, make sure that the parameter parser can handle the
215  * resulting parameters.
216  */
217 static gmx_bool
218 check_params(FILE *fp, const char *name, int nparams, gmx_ana_selparam_t param[],
219              gmx_sel_symtab_t *symtab)
220 {
221     gmx_bool              bOk = TRUE;
222     gmx_sel_symrec_t *sym;
223     int               i, j;
224
225     if (nparams > 0 && !param)
226     {
227         report_error(fp, name, "error: missing parameter data");
228         bOk = FALSE;
229         return FALSE;
230     }
231     if (nparams == 0 && param)
232     {
233         report_error(fp, name, "warning: parameter data unused because nparams=0");
234     }
235     /* Check each parameter */
236     for (i = 0; i < nparams; ++i)
237     {
238         /* Check that there is at most one NULL name, in the beginning */
239         if (param[i].name == NULL && i > 0)
240         {
241             report_error(fp, name, "error: NULL parameter should be the first one");
242             bOk = FALSE;
243             continue;
244         }
245         /* Check for duplicates */
246         for (j = 0; j < i; ++j)
247         {
248             if (param[j].name == NULL)
249             {
250                 continue;
251             }
252             if (!gmx_strcasecmp(param[i].name, param[j].name))
253             {
254                 report_error(fp, name, "error: duplicate parameter name '%s'", param[i].name);
255                 bOk = FALSE;
256                 break;
257             }
258         }
259         /* Check flags */
260         if (param[i].flags & SPAR_SET)
261         {
262             report_param_error(fp, name, param[i].name, "warning: flag SPAR_SET is set");
263             param[i].flags &= ~SPAR_SET;
264         }
265         if (param[i].flags & SPAR_RANGES)
266         {
267             if (param[i].val.type != INT_VALUE && param[i].val.type != REAL_VALUE)
268             {
269                 report_param_error(fp, name, param[i].name, "error: SPAR_RANGES cannot be set for a non-numeric parameter");
270                 bOk = FALSE;
271             }
272             if (param[i].flags & SPAR_DYNAMIC)
273             {
274                 report_param_error(fp, name, param[i].name, "warning: SPAR_DYNAMIC does not have effect with SPAR_RANGES");
275                 param[i].flags &= ~SPAR_DYNAMIC;
276             }
277             if (!(param[i].flags & SPAR_VARNUM) && param[i].val.nr != 1)
278             {
279                 report_param_error(fp, name, param[i].name, "error: range should take either one or an arbitrary number of values");
280                 bOk = FALSE;
281             }
282             if (param[i].flags & SPAR_ATOMVAL)
283             {
284                 report_param_error(fp, name, param[i].name, "error: SPAR_RANGES and SPAR_ATOMVAL both set");
285                 bOk = FALSE;
286             }
287         }
288         if ((param[i].flags & SPAR_VARNUM) && (param[i].flags & SPAR_ATOMVAL))
289         {
290             report_param_error(fp, name, param[i].name, "error: SPAR_VARNUM and SPAR_ATOMVAL both set");
291             bOk = FALSE;
292         }
293         if (param[i].flags & SPAR_ENUMVAL)
294         {
295             if (param[i].val.type != STR_VALUE)
296             {
297                 report_param_error(fp, name, param[i].name, "error: SPAR_ENUMVAL can only be set for string parameters");
298                 bOk = FALSE;
299             }
300             if (param[i].val.nr != 1)
301             {
302                 report_param_error(fp, name, param[i].name, "error: SPAR_ENUMVAL parameters should take exactly one value");
303                 bOk = FALSE;
304             }
305             if (param[i].flags & (SPAR_DYNAMIC | SPAR_VARNUM | SPAR_ATOMVAL))
306             {
307                 report_param_error(fp, name, param[i].name, "error: only SPAR_OPTIONAL supported with SPAR_ENUMVAL");
308                 bOk = FALSE;
309             }
310         }
311         /* Check gmx_boolean parameters */
312         if (param[i].val.type == NO_VALUE)
313         {
314             if (param[i].val.nr != 0)
315             {
316                 report_param_error(fp, name, param[i].name, "error: number of values should be zero for gmx_boolean parameters");
317                 bOk = FALSE;
318             }
319             /* The gmx_boolean parameters should always be optional, so set the
320              * flag for convenience. */
321             param[i].flags |= SPAR_OPTIONAL;
322             /* Any other flags should not be specified */
323             if (param[i].flags & ~SPAR_OPTIONAL)
324             {
325                 report_param_error(fp, name, param[i].name, "error: gmx_boolean parameter should not have any flags set");
326                 bOk = FALSE;
327             }
328         }
329         /* Check val.nr */
330         if (param[i].flags & (SPAR_VARNUM | SPAR_ATOMVAL))
331         {
332             if (param[i].val.nr != -1)
333             {
334                 report_param_error(fp, name, param[i].name, "warning: val.nr is not -1 although SPAR_VARNUM/SPAR_ATOMVAL is set");
335             }
336             param[i].val.nr = -1;
337         }
338         else if (param[i].val.type != NO_VALUE)
339         {
340             if (param[i].val.nr <= 0)
341             {
342                 report_param_error(fp, name, param[i].name, "error: val.nr <= 0");
343                 bOk = FALSE;
344             }
345         }
346         /* Check that the value pointer is NULL */
347         if (param[i].nvalptr != NULL)
348         {
349             report_param_error(fp, name, param[i].name, "warning: nvalptr is set");
350         }
351         if (param[i].val.u.ptr != NULL && !(param[i].flags & SPAR_ENUMVAL))
352         {
353             report_param_error(fp, name, param[i].name, "warning: value pointer is set");
354         }
355         /* Check that the name contains only valid characters */
356         if (param[i].name == NULL)
357         {
358             continue;
359         }
360         if (!isalpha(param[i].name[0]))
361         {
362             report_param_error(fp, name, param[i].name, "error: name does not begin with a letter");
363             bOk = FALSE;
364             continue;
365         }
366         for (j = 1; param[i].name[j] != 0; ++j)
367         {
368             if (param[i].name[j] != '_' && !isalnum(param[i].name[j]))
369             {
370                 report_param_error(fp, name, param[i].name, "error: name contains non-alphanumeric characters");
371                 bOk = FALSE;
372                 break;
373             }
374         }
375         if (param[i].name[j] != 0)
376         {
377             continue;
378         }
379         /* Check that the name does not conflict with a method */
380         if (_gmx_sel_find_symbol(symtab, param[i].name, TRUE))
381         {
382             report_param_error(fp, name, param[i].name, "error: name conflicts with another method or a keyword");
383             bOk = FALSE;
384         }
385     } /* End of parameter loop */
386     /* Check parameters of existing methods */
387     sym = _gmx_sel_first_symbol(symtab, SYMBOL_METHOD);
388     while (sym)
389     {
390         gmx_ana_selmethod_t *method = _gmx_sel_sym_value_method(sym);
391         gmx_ana_selparam_t  *param =
392             gmx_ana_selmethod_find_param(name, method);
393         if (param)
394         {
395             report_param_error(fp, method->name, param->name, "error: name conflicts with another method or a keyword");
396             bOk = FALSE;
397         }
398         sym = _gmx_sel_next_symbol(sym, SYMBOL_METHOD);
399     }
400     return bOk;
401 }
402
403 /*! \brief
404  * Checks the validity of selection method callback functions.
405  *
406  * \param[in] fp        File handle to use for diagnostic messages
407  *   (can be NULL).
408  * \param[in] method    The method to check.
409  * \returns   TRUE if there are no problems, FALSE otherwise.
410  *
411  * This function performs some checks common to both check_method() and
412  * check_modifier().
413  * This function checks that all the required callbacks are defined, i.e.,
414  * not NULL, to find programming errors.
415  */
416 static gmx_bool
417 check_callbacks(FILE *fp, gmx_ana_selmethod_t *method)
418 {
419     gmx_bool         bOk = TRUE;
420     gmx_bool         bNeedInit;
421     int          i;
422
423     /* Make some checks on init_data and free */
424     if (method->nparams > 0 && !method->init_data)
425     {
426         report_error(fp, method->name, "error: init_data should be provided because the method has parameters");
427         bOk = FALSE;
428     }
429     if (method->free && !method->init_data)
430     {
431         report_error(fp, method->name, "warning: free is not used because of missing init_data");
432     }
433     /* Check presence of outinit for position-valued methods */
434     if (method->type == POS_VALUE && !method->outinit)
435     {
436         report_error(fp, method->name, "error: outinit should be provided because the method has POS_VALUE");
437         bOk = FALSE;
438     }
439     /* Warn of dynamic callbacks in static methods */
440     if (!(method->flags & SMETH_MODIFIER))
441     {
442         if (method->pupdate && !(method->flags & SMETH_DYNAMIC))
443         {
444             report_error(fp, method->name, "warning: pupdate not used because the method is static");
445             method->pupdate = NULL;
446         }
447     }
448     /* Check that there is an evaluation function */
449     if (method->type != NO_VALUE && !method->update && !method->pupdate)
450     {
451         report_error(fp, method->name, "error: evaluation function missing");
452         bOk = FALSE;
453     }
454     /* Loop through the parameters to determine if initialization callbacks
455      * are needed. */
456     bNeedInit = FALSE;
457     for (i = 0; i < method->nparams; ++i)
458     {
459         if (method->param[i].val.type != POS_VALUE
460             && (method->param[i].flags & (SPAR_VARNUM | SPAR_ATOMVAL)))
461         {
462             bNeedInit = TRUE;
463         }
464     }
465     /* Check that the callbacks required by the parameters are present */
466     if (bNeedInit && !method->init)
467     {
468         report_error(fp, method->name, "error: init should be provided");
469         bOk = FALSE;
470     }
471     return bOk;
472 }
473
474 /*!
475  * Checks the validity of a selection method.
476  *
477  * \param[in]     fp     File handle to use for diagnostic messages
478  *   (can be NULL).
479  * \param[in,out] method Method to check.
480  * \param[in]     symtab Symbol table (used for checking overlaps).
481  *
482  * Checks the validity of the given selection method data structure
483  * that does not have \ref SMETH_MODIFIER set.
484  * If you remove a check, please make sure that the selection parser,
485  * compiler, and evaluation functions can deal with the method.
486  */
487 static gmx_bool
488 check_method(FILE *fp, gmx_ana_selmethod_t *method, gmx_sel_symtab_t *symtab)
489 {
490     gmx_bool         bOk = TRUE;
491
492     /* Check the type */
493     if (method->type == NO_VALUE)
494     {
495         report_error(fp, method->name, "error: no value type specified");
496         bOk = FALSE;
497     }
498     if (method->type == STR_VALUE && method->nparams > 0)
499     {
500         report_error(fp, method->name, "error: evaluates to a string but is not a keyword");
501         bOk = FALSE;
502     }
503     /* Check flags */
504     if (method->type == GROUP_VALUE)
505     {
506         /* Group methods should always have SMETH_SINGLEVAL,
507          * so set it for convenience. */
508         method->flags |= SMETH_SINGLEVAL;
509         /* Check that conflicting flags are not present. */
510         if (method->flags & SMETH_VARNUMVAL)
511         {
512             report_error(fp, method->name, "error: SMETH_VARNUMVAL cannot be set for group-valued methods");
513             bOk = FALSE;
514         }
515     }
516     else
517     {
518         if ((method->flags & SMETH_SINGLEVAL)
519             && (method->flags & SMETH_VARNUMVAL))
520         {
521             report_error(fp, method->name, "error: SMETH_SINGLEVAL and SMETH_VARNUMVAL both set");
522             bOk = FALSE;
523         }
524     }
525     if ((method->flags & SMETH_CHARVAL) && method->type != STR_VALUE)
526     {
527         report_error(fp, method->name, "error: SMETH_CHARVAL can only be specified for STR_VALUE methods");
528         bOk = FALSE;
529     }
530     /* Check the parameters */
531     if (!check_params(fp, method->name, method->nparams, method->param, symtab))
532     {
533         bOk = FALSE;
534     }
535     /* Check the callback pointers */
536     if (!check_callbacks(fp, method))
537     {
538         bOk = FALSE;
539     }
540
541     return bOk;
542 }
543
544 /*!
545  * Checks the validity of a selection modifier method.
546  *
547  * \param[in]     fp     File handle to use for diagnostic messages
548  *   (can be NULL).
549  * \param[in,out] method Method to check.
550  * \param[in]     symtab Symbol table (used for checking overlaps).
551  *
552  * Checks the validity of the given selection method data structure
553  * that has \ref SMETH_MODIFIER set.
554  * If you remove a check, please make sure that the selection parser,
555  * compiler, and evaluation functions can deal with the method.
556  */
557 static gmx_bool
558 check_modifier(FILE *fp, gmx_ana_selmethod_t *method, gmx_sel_symtab_t *symtab)
559 {
560     gmx_bool         bOk = TRUE;
561
562     /* Check the type */
563     if (method->type != NO_VALUE && method->type != POS_VALUE)
564     {
565         report_error(fp, method->name, "error: modifier should have type POS_VALUE or NO_VALUE");
566         bOk = FALSE;
567     }
568     /* Check flags */
569     if (method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL))
570     {
571         report_error(fp, method->name, "error: modifier should not have SMETH_SINGLEVAL or SMETH_VARNUMVAL set");
572         bOk = FALSE;
573     }
574     /* Check the parameters */
575     /* The first parameter is skipped */
576     if (!check_params(fp, method->name, method->nparams-1, method->param+1, symtab))
577     {
578         bOk = FALSE;
579     }
580     /* Check the callback pointers */
581     if (!check_callbacks(fp, method))
582     {
583         bOk = FALSE;
584     }
585     if (method->update)
586     {
587         report_error(fp, method->name, "error: modifier should not have update");
588         bOk = FALSE;
589     }
590     if (method->type == POS_VALUE && !method->pupdate)
591     {
592         report_error(fp, method->name, "error: evaluation function missing");
593         bOk = FALSE;
594     }
595
596     return bOk;
597 }
598
599 /*!
600  * \param[in,out] sc     Selection collection to registered the method to.
601  * \param[in]     name   Name under which the method should be registered.
602  * \param[in]     method Method to register.
603  * \returns       0 on success, EINVAL if there was something wrong with the
604  *   method.
605  *
606  * \p name does not need to match the name of the method, and the same
607  * method can be registered multiple times under different names.
608  * If \p name equals some previously registered name,
609  * an error message is printed and the method is not registered.
610  *
611  * The function also performs some sanity checking on the input method,
612  * and refuses to register it if there are problems.
613  * Some problems only generate warnings.
614  * All problems are described to \p stderr.
615  */
616 int
617 gmx_ana_selmethod_register(struct gmx_ana_selcollection_t *sc,
618                            const char *name, gmx_ana_selmethod_t *method)
619 {
620     gmx_bool bOk;
621
622     /* Check the method */
623     if (method->flags & SMETH_MODIFIER)
624     {
625         bOk = check_modifier(stderr, method, sc->symtab);
626     }
627     else
628     {
629         bOk = check_method(stderr, method, sc->symtab);
630     }
631     /* Try to register the method if everything is ok */
632     if (bOk) 
633     {
634         if (!_gmx_sel_add_method_symbol(sc->symtab, name, method))
635         {
636             bOk = FALSE;
637         }
638     }
639     if (!bOk)
640     {
641         report_error(stderr, name, "warning: not registered");
642         return EINVAL;
643     }
644     return 0;
645 }
646
647 /*!
648  * \param[in,out] sc     Selection collection to registered the methods to.
649  * \returns       0 on success, -1 if any of the default methods could not be
650  *   registered.
651  */
652 int
653 gmx_ana_selmethod_register_defaults(struct gmx_ana_selcollection_t *sc)
654 {
655     size_t i;
656     int  rc;
657     gmx_bool bOk;
658
659     bOk = TRUE;
660     for (i = 0; i < asize(smtable_def); ++i)
661     {
662         gmx_ana_selmethod_t *method = smtable_def[i].method;
663
664         if (smtable_def[i].name == NULL)
665         {
666             rc = gmx_ana_selmethod_register(sc, method->name, method);
667         }
668         else
669         {
670             rc = gmx_ana_selmethod_register(sc, smtable_def[i].name, method);
671         }
672         if (rc != 0)
673         {
674             bOk = FALSE;
675         }
676     }
677     return bOk ? 0 : -1;
678 }
679
680 /*!
681  * \param[in] name   Name of the parameter to search.
682  * \param[in] method Method to search for the parameter.
683  * \returns   Pointer to the parameter in the
684  *   \ref gmx_ana_selmethod_t::param "method->param" array,
685  *   or NULL if no parameter with name \p name was found.
686  *
687  * This is a simple wrapper for gmx_ana_selparam_find().
688  */
689 gmx_ana_selparam_t *
690 gmx_ana_selmethod_find_param(const char *name, gmx_ana_selmethod_t *method)
691 {
692     return gmx_ana_selparam_find(name, method->nparams, method->param);
693 }