Upped the version to 3.2.0
[gromacs.git] / include / metacode.h
blob8a1fe715f04399c7208b0b1fd8235ead30ebe0ff
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.2.0
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
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.
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.
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.
31 * For more info, check our website at http://www.gromacs.org
33 * And Hey:
34 * Gromacs Runs On Most of All Computer Systems
37 #ifndef _metacode_h
38 #define _metacode_h
40 #ifdef HAVE_CONFIG_H
41 #include <config.h>
42 #endif
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <stdarg.h>
47 #include <types/simple.h>
49 #ifndef FALSE
50 #define FALSE 0
51 #endif
52 #ifndef TRUE
53 #define TRUE 1
54 #endif
56 #define FCON " &" /* continuation line in f77 */
57 #define max(a,b) (((a) > (b)) ? (a) : (b))
60 /* Array referencing shortcut */
61 #define ARRAY(a,idx) _array(#a,#idx)
63 typedef struct {
64 char typename[150];
65 char name[150];
66 bool breferenced;
67 bool bvector;
68 bool bconst;
69 char constval[50];
70 } decl_t; /* Argument and variable buffer element */
72 extern int prec; /* precision (4=single, 8=double) */
73 extern int IND; /* current indentation */
74 extern char *codebuffer; /* buffer to which code is written */
75 extern char header[10000]; /* buffer for info and loop name */
76 extern FILE *output; /* output file */
77 extern decl_t *decl_list; /* list with args and vars */
78 extern int ndecl; /* length of above list */
79 extern int nargs; /* first nargs are arguments, rest is vars */
81 extern bool bC;
83 /* Concatenate a string to a buffer with plus sign between terms. */
84 void add_to_buffer(char *buffer,char *term);
86 /* initiate output buffers */
87 void init_metacode(void);
89 /* write a function to file and empty buffers */
90 void flush_buffers(void);
92 /* Return the correct indentation as a string */
93 char *indent(void);
95 /* Print a line of code to the output file */
96 void code(char *fmt, ...);
98 void newline(void);
100 /* Add a comment */
101 void comment(char *s);
103 /* Define a new floating-point variable */
104 void declare_real(char *name);
105 void declare_real_vector(char *name);
107 void declare_const_real(char *name,double val);
108 void declare_const_int(char *name,int val);
110 void declare_int(char *name);
111 void declare_int_vector(char *name);
112 void declare_real4(char *name);
113 void declare_int4(char *name);
114 void declare_int8(char *name);
115 void declare_intreal(char *name);
116 void declare_other(char *typename,char *name);
118 /* Cray vector pragma */
119 void vector_pragma(void);
122 char *_array(char *a,char *idx, ...);
124 void _p_state(char *left,char *right,char *symb);
126 void file_error(char *fn);
128 void assign(char *left, char *right, ...);
130 void increment(char *left,char *right, ...);
132 void decrement(char *left,char *right, ...);
134 void add(char *left,char *r1,char *r2, ...);
136 void subtract(char *left,char *r1,char *r2, ...);
138 void multiply(char *left,char *r1,char *r2, ...);
140 void closeit(void);
142 void usage(int argc,char *argv[]);
144 int count_lines(char *fn);
146 void edit_warning(char *fn);
148 void start_loop(char *lvar,char *from,char *to);
150 void start_stride_loop(char *lvar,char *from,char *to, char *stride);
152 void end_loop(void);
154 void start_if(char *cond);
155 void do_else(void);
156 void end_if(void);
158 void close_func(void);
160 #endif