3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
46 #include "gmx_fatal.h"
49 int ifunc_index(directive d
,int type
)
76 gmx_fatal(FARGS
,"Invalid bond type %d",type
);
87 return F_CROSS_BOND_BONDS
;
89 return F_CROSS_BOND_ANGLES
;
91 return F_UREY_BRADLEY
;
93 return F_QUARTIC_ANGLES
;
97 gmx_fatal(FARGS
,"Invalid angle type %d",type
);
102 if (type
== 1 || (d
== d_pairtypes
&& type
== 2))
107 gmx_fatal(FARGS
,"Invalid pairs type %d",type
);
109 return F_LJC_PAIRS_NB
;
111 case d_dihedraltypes
:
126 return F_PDIHS
; /* proper dihedrals where we allow multiple terms over single bond */
128 gmx_fatal(FARGS
,"Invalid dihedral type %d",type
);
135 case d_nonbond_params
:
153 gmx_fatal(FARGS
,"Invalid vsites3 type %d",type
);
162 gmx_fatal(FARGS
,"Invalid vsites4 type %d",type
);
167 case d_constrainttypes
:
174 gmx_fatal(FARGS
,"Invalid constraints type %d",type
);
178 case d_position_restraints
:
183 gmx_fatal(FARGS
,"Water polarization should now be listed under [ water_polarization ]\n");
185 gmx_fatal(FARGS
,"Invalid position restraint type %d",type
);
188 return F_POLARIZATION
;
189 case d_thole_polarization
:
191 case d_water_polarization
:
193 case d_angle_restraints
:
195 case d_angle_restraints_z
:
197 case d_distance_restraints
:
199 case d_orientation_restraints
:
201 case d_dihedral_restraints
:
204 gmx_fatal(FARGS
,"invalid directive %s in ifunc_index (%s:%s)",
205 dir2str(d
),__FILE__
,__LINE__
);
210 const char *dir2str (directive d
)
218 directive
str2dir (char *dstr
)
221 char buf
[STRLEN
],*ptr
;
223 /* Hack to be able to read old topologies */
224 if (gmx_strncasecmp_min(dstr
,"dummies",7) == 0) {
225 sprintf(buf
,"virtual_sites%s",dstr
+7);
231 for (d
=0; (d
<d_maxdir
); d
++)
232 if (gmx_strcasecmp_min(ptr
,dir2str((directive
)d
)) == 0)
238 static directive
**necessary
= NULL
;
240 static void set_nec(directive
**n
, ...)
241 /* Must always have at least one extra argument */
249 d
= (directive
)va_arg(ap
,int);
252 } while (d
!= d_none
);
256 void DS_Init(DirStack
**DS
)
258 if (necessary
==NULL
) {
261 snew(necessary
,d_maxdir
);
262 set_nec(&(necessary
[d_defaults
]),d_none
);
263 set_nec(&(necessary
[d_atomtypes
]),d_defaults
,d_none
);
264 set_nec(&(necessary
[d_bondtypes
]),d_atomtypes
,d_none
);
265 set_nec(&(necessary
[d_constrainttypes
]),d_atomtypes
,d_none
);
266 set_nec(&(necessary
[d_pairtypes
]),d_atomtypes
,d_none
);
267 set_nec(&(necessary
[d_angletypes
]),d_atomtypes
,d_none
);
268 set_nec(&(necessary
[d_dihedraltypes
]),d_atomtypes
,d_none
);
269 set_nec(&(necessary
[d_nonbond_params
]),d_atomtypes
,d_none
);
270 set_nec(&(necessary
[d_implicit_genborn_params
]),d_atomtypes
,d_none
);
271 set_nec(&(necessary
[d_implicit_surface_params
]),d_atomtypes
,d_none
);
272 set_nec(&(necessary
[d_cmaptypes
]),d_atomtypes
,d_none
);
273 set_nec(&(necessary
[d_moleculetype
]),d_atomtypes
,d_none
);
274 set_nec(&(necessary
[d_atoms
]),d_moleculetype
,d_none
);
275 set_nec(&(necessary
[d_vsites2
]),d_atoms
,d_none
);
276 set_nec(&(necessary
[d_vsites3
]),d_atoms
,d_none
);
277 set_nec(&(necessary
[d_vsites4
]),d_atoms
,d_none
);
278 set_nec(&(necessary
[d_vsitesn
]),d_atoms
,d_none
);
279 set_nec(&(necessary
[d_bonds
]),d_atoms
,d_none
);
280 set_nec(&(necessary
[d_exclusions
]),d_bonds
,d_constraints
,d_settles
,d_none
);
281 set_nec(&(necessary
[d_pairs
]),d_atoms
,d_none
);
282 set_nec(&(necessary
[d_pairs_nb
]),d_atoms
,d_none
);
283 set_nec(&(necessary
[d_angles
]),d_atoms
,d_none
);
284 set_nec(&(necessary
[d_polarization
]),d_atoms
,d_none
);
285 set_nec(&(necessary
[d_water_polarization
]),d_atoms
,d_none
);
286 set_nec(&(necessary
[d_thole_polarization
]),d_atoms
,d_none
);
287 set_nec(&(necessary
[d_dihedrals
]),d_atoms
,d_none
);
288 set_nec(&(necessary
[d_constraints
]),d_atoms
,d_none
);
289 set_nec(&(necessary
[d_settles
]),d_atoms
,d_none
);
290 set_nec(&(necessary
[d_system
]),d_moleculetype
,d_none
);
291 set_nec(&(necessary
[d_molecules
]),d_system
,d_none
);
292 set_nec(&(necessary
[d_position_restraints
]),d_atoms
,d_none
);
293 set_nec(&(necessary
[d_angle_restraints
]),d_atoms
,d_none
);
294 set_nec(&(necessary
[d_angle_restraints_z
]),d_atoms
,d_none
);
295 set_nec(&(necessary
[d_distance_restraints
]),d_atoms
,d_none
);
296 set_nec(&(necessary
[d_orientation_restraints
]),d_atoms
,d_none
);
297 set_nec(&(necessary
[d_dihedral_restraints
]),d_atoms
,d_none
);
298 set_nec(&(necessary
[d_cmap
]), d_atoms
, d_none
);
300 for(i
=0; (i
<d_maxdir
); i
++) {
302 fprintf(debug
,"%20s: ",dir2str((directive
)i
));
309 fprintf(debug
,"%20s ",dir2str(d
));
320 void DS_Done (DirStack
**DS
)
324 while (*DS
!= NULL
) {
331 void DS_Push (DirStack
**DS
, directive d
)
341 int DS_Search(DirStack
*DS
, directive d
)
346 while ((D
!= NULL
) && (D
->d
!= d
))
352 int DS_Check_Order(DirStack
*DS
,directive d
)
357 /* Check if parameter definitions appear after a moleculetype directive */
358 if (d
<d_moleculetype
&& DS_Search(DS
,d_moleculetype
))
361 /* Check if all the necessary directives have appeared before directive d */
362 if (necessary
[d
][0] == d_none
)
366 d0
=necessary
[d
][i
++];
367 if (DS_Search(DS
,d0
))