added README_changes.txt
[wrffire.git] / wrfv2_fire / chem / KPP / kpp / kpp-2.1 / src.org / code.h
blob2f7f9dd8ac672439a7dfdd5264916f90023473c3
1 /******************************************************************************
3 KPP - The Kinetic PreProcessor
4 Builds simulation code for chemical kinetic systems
6 Copyright (C) 1995-1996 Valeriu Damian and Adrian Sandu
7 Copyright (C) 1997-2005 Adrian Sandu
9 KPP is free software; you can redistribute it and/or modify it under the
10 terms of the GNU General Public License as published by the Free Software
11 Foundation (http://www.gnu.org/copyleft/gpl.html); either version 2 of the
12 License, or (at your option) any later version.
14 KPP is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 details.
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, consult http://www.gnu.org/copyleft/gpl.html or
21 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.
24 Adrian Sandu
25 Computer Science Department
26 Virginia Polytechnic Institute and State University
27 Blacksburg, VA 24060
28 E-mail: sandu@cs.vt.edu
30 ******************************************************************************/
33 #ifndef _CODE_H_
34 #define _CODE_H_
36 #include <stdlib.h>
37 #include "gdef.h"
39 #define MAX_DEPTH 10
40 #define MAX_SUBST 20
41 #define SUBST 100
42 #define MAX_VAR 150
43 #define MAX_OUTBUF 200000
44 #define MAX_COLS 8
45 #define MAX_LINES 20
47 #define WriteAll bprintf
49 enum types { NONE, ADD, SUB, MUL, DIV, POW, CONST, ELM, VELM, MELM, EELM, FNC };
50 extern int PRI[];
52 enum signs { O_PAREN = 20, C_PAREN };
53 enum base_types { VOID, INT, REAL, DOUBLE, STRING, DOUBLESTRING };
54 /* mz_rs_20050117+ */
55 extern FILE * initFile;
56 /* mz_rs_20050117- */
57 extern FILE * driverFile;
58 extern FILE * functionFile;
59 extern FILE * global_dataFile;
60 extern FILE * hessianFile;
61 extern FILE * integratorFile;
62 extern FILE * jacobianFile;
63 extern FILE * linalgFile;
64 extern FILE * mapFile;
65 extern FILE * makeFile;
66 extern FILE * monitorFile;
67 extern FILE * mex_funFile;
68 extern FILE * mex_jacFile;
69 extern FILE * mex_hessFile;
70 extern FILE * param_headerFile;
71 extern FILE * rateFile;
72 extern FILE * sparse_dataFile;
73 extern FILE * sparse_jacFile;
74 extern FILE * sparse_hessFile;
75 extern FILE * sparse_stoicmFile;
76 extern FILE * stoichiomFile;
77 extern FILE * stochasticFile;
78 extern FILE * utilFile;
80 extern FILE * currentFile;
82 extern int ident;
83 extern int real;
84 extern char * CommonName;
86 void OpenFile( FILE **fpp, char *name, char * ext, char * identity );
87 FILE * UseFile( FILE *fp );
89 typedef struct {
90 char *name;
91 int type;
92 int baseType;
93 int maxi;
94 int maxj;
95 int value;
96 char *comment;
97 } VARIABLE;
99 extern VARIABLE* varTable[];
101 extern char *outBuf;
102 extern char *outBuffer;
104 void AllowBreak();
105 void bprintf( char *fmt, ... );
106 void FlushBuf();
107 void FlushThisBuf( char * buf );
108 void NewLines( int n );
109 void C_Inline( char *fmt, ... );
110 void F77_Inline( char *fmt, ... );
111 void IncludeFile( char * fname );
112 void IncludeCode( char *fmt, ... );
113 void MapFunctionComment( int f, int *vars );
115 int DefineVariable( char * name, int t, int bt, int maxi, int maxj, char * comment );
116 void FreeVariable( int n );
118 #define DefConst( name, bt, cmt ) DefineVariable( name, CONST, bt, 0, 0, cmt )
119 #define DefElm( name, bt, cmt ) DefineVariable( name, ELM, bt, 0, 0, cmt )
120 #define DefvElm( name, bt, n, cmt ) DefineVariable( name, VELM, bt, n, 0, cmt )
121 #define DefmElm( name, bt, m, n, cmt ) DefineVariable( name, MELM, bt, m, n, cmt )
122 #define DefeElm( name, cmt ) DefineVariable( name, EELM, 0, 0, 0, cmt )
123 #define DefFnc( name, n, cmt ) DefineVariable( name, FNC, 0, n, 0, cmt )
125 typedef struct {
126 int var;
127 union {
128 char * expr;
129 float cnst;
130 struct {
131 int i;
132 int j;
133 } idx;
134 } val;
135 } ELEMENT;
137 typedef struct node {
138 struct node * left;
139 struct node * right;
140 int type;
141 int sign;
142 ELEMENT *elm;
143 } NODE;
145 extern char *F77_types[];
146 extern char *F90_types[];
147 extern char *C_types[];
148 extern char *MATLAB_types[];
150 NODE * Elm( int v, ... );
151 #define Const( x ) Elm( 0, (double)x )
152 #define Expr( x ) Elm( 1, x )
154 void FreeNode( NODE * n );
156 NODE * Add( NODE *n1, NODE *n2 );
157 NODE * Sub( NODE *n1, NODE *n2 );
158 NODE * Mul( NODE *n1, NODE *n2 );
159 NODE * Div( NODE *n1, NODE *n2 );
160 NODE * Pow( NODE *n1, NODE *n2 );
162 void Assign( NODE *lval, NODE *rval );
163 void MkSubst( NODE *n1, NODE *n2 );
164 void RmSubst( NODE *n );
165 void CommentFncBegin( int f, int *vars );
166 void CommentFunctionBegin( int f, ... );
167 void CommentFunctionEnd( int f );
169 void Use_C();
170 void Use_F();
171 void Use_F90();
172 void Use_MATLAB();
174 extern void (*WriteElm)( NODE *n );
175 extern void (*WriteSymbol)( int op );
176 extern void (*WriteAssign)( char* ls, char* rs );
177 extern void (*WriteComment)( char *fmt, ... );
178 extern void (*Declare)( int v );
179 extern void (*ExternDeclare)( int v );
180 extern void (*GlobalDeclare)( int v );
181 extern void (*InitDeclare)( int v, int n, void * values );
182 extern void (*DeclareConstant)( int v, char *val );
183 extern void (*FunctionStart)( int f, int *vars );
184 extern void (*FunctionPrototipe)( int f, ... );
185 extern void (*FunctionBegin)( int f, ... );
186 extern void (*FunctionEnd)( int f );
188 void WriteDelim();
190 #endif