Fixed a bug in the pdb-writing code.
[gromacs.git] / include / metacode.h
blob2f8962fba2097afb0031b7739e7a3579dbc3eec2
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 3.1
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
29 * And Hey:
30 * Getting the Right Output Means no Artefacts in Calculating Stuff
33 #ifndef _metacode_h
34 #define _metacode_h
36 static char *SRCID_metacode_h = "$Id$";
37 #ifdef HAVE_CONFIG_H
38 #include <config.h>
39 #endif
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <stdarg.h>
44 #include <types/simple.h>
46 #ifndef FALSE
47 #define FALSE 0
48 #endif
49 #ifndef TRUE
50 #define TRUE 1
51 #endif
53 #define FCON " &" /* continuation line in f77 */
54 #define max(a,b) (((a) > (b)) ? (a) : (b))
57 /* Array referencing shortcut */
58 #define ARRAY(a,idx) _array(#a,#idx)
60 typedef struct {
61 char typename[150];
62 char name[150];
63 bool breferenced;
64 bool bvector;
65 bool bconst;
66 char constval[50];
67 } decl_t; /* Argument and variable buffer element */
69 extern int prec; /* precision (4=single, 8=double) */
70 extern int IND; /* current indentation */
71 extern char *codebuffer; /* buffer to which code is written */
72 extern char header[10000]; /* buffer for info and loop name */
73 extern FILE *output; /* output file */
74 extern decl_t *decl_list; /* list with args and vars */
75 extern int ndecl; /* length of above list */
76 extern int nargs; /* first nargs are arguments, rest is vars */
78 extern bool bC;
80 /* Concatenate a string to a buffer with plus sign between terms. */
81 void add_to_buffer(char *buffer,char *term);
83 /* initiate output buffers */
84 void init_metacode(void);
86 /* write a function to file and empty buffers */
87 void flush_buffers(void);
89 /* Return the correct indentation as a string */
90 char *indent(void);
92 /* Print a line of code to the output file */
93 void code(char *fmt, ...);
95 void newline(void);
97 /* Add a comment */
98 void comment(char *s);
100 /* Define a new floating-point variable */
101 void declare_real(char *name);
102 void declare_real_vector(char *name);
104 void declare_const_real(char *name,double val);
105 void declare_const_int(char *name,int val);
107 void declare_int(char *name);
108 void declare_int_vector(char *name);
109 void declare_real4(char *name);
110 void declare_int4(char *name);
111 void declare_int8(char *name);
112 void declare_intreal(char *name);
113 void declare_other(char *typename,char *name);
115 /* Cray vector pragma */
116 void vector_pragma(void);
119 char *_array(char *a,char *idx, ...);
121 void _p_state(char *left,char *right,char *symb);
123 void file_error(char *fn);
125 void assign(char *left, char *right, ...);
127 void increment(char *left,char *right, ...);
129 void decrement(char *left,char *right, ...);
131 void add(char *left,char *r1,char *r2, ...);
133 void subtract(char *left,char *r1,char *r2, ...);
135 void multiply(char *left,char *r1,char *r2, ...);
137 void closeit(void);
139 void usage(int argc,char *argv[]);
141 int count_lines(char *fn);
143 void edit_warning(char *fn);
145 void start_loop(char *lvar,char *from,char *to);
147 void start_stride_loop(char *lvar,char *from,char *to, char *stride);
149 void end_loop(void);
151 void start_if(char *cond);
152 void do_else(void);
153 void end_if(void);
155 void close_func(void);
157 #endif