Partial commit of the project to remove all static variables.
[gromacs.git] / include / metacode.h
blob5a8c830298c61d53b5b64a9ee7183b9fd7d02033
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 #ifdef HAVE_CONFIG_H
37 #include <config.h>
38 #endif
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <stdarg.h>
43 #include <types/simple.h>
45 #ifndef FALSE
46 #define FALSE 0
47 #endif
48 #ifndef TRUE
49 #define TRUE 1
50 #endif
52 #define FCON " &" /* continuation line in f77 */
53 #define max(a,b) (((a) > (b)) ? (a) : (b))
56 /* Array referencing shortcut */
57 #define ARRAY(a,idx) _array(#a,#idx)
59 typedef struct {
60 char typename[150];
61 char name[150];
62 bool breferenced;
63 bool bvector;
64 bool bconst;
65 char constval[50];
66 } decl_t; /* Argument and variable buffer element */
68 extern int prec; /* precision (4=single, 8=double) */
69 extern int IND; /* current indentation */
70 extern char *codebuffer; /* buffer to which code is written */
71 extern char header[10000]; /* buffer for info and loop name */
72 extern FILE *output; /* output file */
73 extern decl_t *decl_list; /* list with args and vars */
74 extern int ndecl; /* length of above list */
75 extern int nargs; /* first nargs are arguments, rest is vars */
77 extern bool bC;
79 /* Concatenate a string to a buffer with plus sign between terms. */
80 void add_to_buffer(char *buffer,char *term);
82 /* initiate output buffers */
83 void init_metacode(void);
85 /* write a function to file and empty buffers */
86 void flush_buffers(void);
88 /* Return the correct indentation as a string */
89 char *indent(void);
91 /* Print a line of code to the output file */
92 void code(char *fmt, ...);
94 void newline(void);
96 /* Add a comment */
97 void comment(char *s);
99 /* Define a new floating-point variable */
100 void declare_real(char *name);
101 void declare_real_vector(char *name);
103 void declare_const_real(char *name,double val);
104 void declare_const_int(char *name,int val);
106 void declare_int(char *name);
107 void declare_int_vector(char *name);
108 void declare_real4(char *name);
109 void declare_int4(char *name);
110 void declare_int8(char *name);
111 void declare_intreal(char *name);
112 void declare_other(char *typename,char *name);
114 /* Cray vector pragma */
115 void vector_pragma(void);
118 char *_array(char *a,char *idx, ...);
120 void _p_state(char *left,char *right,char *symb);
122 void file_error(char *fn);
124 void assign(char *left, char *right, ...);
126 void increment(char *left,char *right, ...);
128 void decrement(char *left,char *right, ...);
130 void add(char *left,char *r1,char *r2, ...);
132 void subtract(char *left,char *r1,char *r2, ...);
134 void multiply(char *left,char *r1,char *r2, ...);
136 void closeit(void);
138 void usage(int argc,char *argv[]);
140 int count_lines(char *fn);
142 void edit_warning(char *fn);
144 void start_loop(char *lvar,char *from,char *to);
146 void start_stride_loop(char *lvar,char *from,char *to, char *stride);
148 void end_loop(void);
150 void start_if(char *cond);
151 void do_else(void);
152 void end_if(void);
154 void close_func(void);
156 #endif