Tagged files with gromacs 3.0 header and added some license info
[alexxy/gromacs.git] / include / metacode.h
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.0
11  * 
12  * Copyright (c) 1991-2001
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * If you want to redistribute modifications, please consider that
22  * scientific software is very special. Version control is crucial -
23  * bugs must be traceable. We will be happy to consider code for
24  * inclusion in the official distribution, but derived work must not
25  * be called official GROMACS. Details are found in the README & COPYING
26  * files - if they are missing, get the official version at www.gromacs.org.
27  * 
28  * To help us fund GROMACS development, we humbly ask that you cite
29  * the papers on the package - you can find them in the top README file.
30  * 
31  * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
32  * 
33  * And Hey:
34  * Giving Russians Opium May Alter Current Situation
35  */
36
37 #ifndef _metacode_h
38 #define _metacode_h
39
40 static char *SRCID_metacode_h = "$Id$";
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <stdarg.h>
48 #include <types/simple.h>
49
50 static char *SRCID_metacode_h = "";
51
52 #ifndef FALSE
53 #define FALSE 0
54 #endif
55 #ifndef TRUE
56 #define TRUE  1
57 #endif
58
59 #define FCON "     &" /* continuation line in f77 */
60 #define max(a,b) (((a) > (b)) ? (a) : (b))
61
62
63 /* Array referencing shortcut */
64 #define ARRAY(a,idx)          _array(#a,#idx)
65
66 typedef struct {
67   char typename[150];
68   char name[150];
69   bool breferenced;
70   bool bvector;
71   bool bconst;
72   char constval[50];
73 } decl_t;         /* Argument and variable buffer element */
74
75 extern int prec;  /* precision (4=single, 8=double) */
76 extern int IND;   /* current indentation */
77 extern char *codebuffer; /* buffer to which code is written */
78 extern char header[10000]; /* buffer for info and loop name */
79 extern FILE *output;  /* output file */
80 extern decl_t *decl_list; /* list with args and vars */
81 extern int ndecl; /* length of above list */
82 extern int nargs; /* first nargs are arguments, rest is vars */
83
84 extern bool bC;   
85
86 /* Concatenate a string to a buffer with plus sign between terms. */
87 void add_to_buffer(char *buffer,char *term);
88   
89 /* initiate output buffers */
90 void init_metacode(void);
91
92 /* write a function to file and empty buffers */
93 void flush_buffers(void);
94
95 /* Return the correct indentation as a string */
96 char *indent(void);
97
98 /* Print a line of code to the output file */
99 void code(char *fmt, ...);
100
101 void newline(void);
102
103 /* Add a comment */
104 void comment(char *s);
105
106 /* Define a new floating-point variable */
107 void declare_real(char *name);
108 void declare_real_vector(char *name);
109
110 void declare_const_real(char *name,double val);
111 void declare_const_int(char *name,int val);
112
113 void declare_int(char *name);
114 void declare_int_vector(char *name);
115 void declare_real4(char *name);
116 void declare_int4(char *name);
117 void declare_int8(char *name);
118 void declare_intreal(char *name);
119 void declare_other(char *typename,char *name);
120
121 /* Cray vector pragma */
122 void vector_pragma(void);
123
124
125 char *_array(char *a,char *idx, ...);
126
127 void _p_state(char *left,char *right,char *symb);
128
129 void file_error(char *fn);
130
131 void assign(char *left, char *right, ...);
132
133 void increment(char *left,char *right, ...);
134
135 void decrement(char *left,char *right, ...);
136
137 void add(char *left,char *r1,char *r2, ...);
138
139 void subtract(char *left,char *r1,char *r2, ...);
140
141 void multiply(char *left,char *r1,char *r2, ...);
142
143 void closeit(void);
144
145 void usage(int argc,char *argv[]);
146
147 int count_lines(char *fn);
148
149 void edit_warning(char *fn);
150
151 void start_loop(char *lvar,char *from,char *to);
152
153 void start_stride_loop(char *lvar,char *from,char *to, char *stride);
154
155 void end_loop(void);
156
157 void start_if(char *cond);
158 void do_else(void);
159 void end_if(void);
160
161 void close_func(void);
162
163 #endif
164