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