Original WRF subgrid support version from John Michalakes without fire
[wrffire.git] / wrfv2_fire / chem / KPP / kpp / kpp-2.1 / src / code.h
bloba40de2de3f0e228d61b1b38f1afd3e3ca13891e0
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;
79 extern FILE * wrf_UpdateRconstFile;
81 extern FILE * currentFile;
83 extern int ident;
84 extern int real;
85 extern char * CommonName;
87 void OpenFile( FILE **fpp, char *name, char * ext, char * identity );
88 FILE * UseFile( FILE *fp );
90 typedef struct {
91 char *name;
92 int type;
93 int baseType;
94 int maxi;
95 int maxj;
96 int value;
97 char *comment;
98 } VARIABLE;
100 extern VARIABLE* varTable[];
102 extern char *outBuf;
103 extern char *outBuffer;
105 void AllowBreak();
106 void bprintf( char *fmt, ... );
107 void FlushBuf();
108 void FlushThisBuf( char * buf );
109 void NewLines( int n );
110 void C_Inline( char *fmt, ... );
111 void F77_Inline( char *fmt, ... );
112 void IncludeFile( char * fname );
113 void IncludeCode( char *fmt, ... );
114 void MapFunctionComment( int f, int *vars );
116 int DefineVariable( char * name, int t, int bt, int maxi, int maxj, char * comment );
117 void FreeVariable( int n );
119 #define DefConst( name, bt, cmt ) DefineVariable( name, CONST, bt, 0, 0, cmt )
120 #define DefElm( name, bt, cmt ) DefineVariable( name, ELM, bt, 0, 0, cmt )
121 #define DefvElm( name, bt, n, cmt ) DefineVariable( name, VELM, bt, n, 0, cmt )
122 #define DefmElm( name, bt, m, n, cmt ) DefineVariable( name, MELM, bt, m, n, cmt )
123 #define DefeElm( name, cmt ) DefineVariable( name, EELM, 0, 0, 0, cmt )
124 #define DefFnc( name, n, cmt ) DefineVariable( name, FNC, 0, n, 0, cmt )
126 typedef struct {
127 int var;
128 union {
129 char * expr;
130 float cnst;
131 struct {
132 int i;
133 int j;
134 } idx;
135 } val;
136 } ELEMENT;
138 typedef struct node {
139 struct node * left;
140 struct node * right;
141 int type;
142 int sign;
143 ELEMENT *elm;
144 } NODE;
146 extern char *F77_types[];
147 extern char *F90_types[];
148 extern char *C_types[];
149 extern char *MATLAB_types[];
151 NODE * Elm( int v, ... );
152 #define Const( x ) Elm( 0, (double)x )
153 #define Expr( x ) Elm( 1, x )
155 void FreeNode( NODE * n );
157 NODE * Add( NODE *n1, NODE *n2 );
158 NODE * Sub( NODE *n1, NODE *n2 );
159 NODE * Mul( NODE *n1, NODE *n2 );
160 NODE * Div( NODE *n1, NODE *n2 );
161 NODE * Pow( NODE *n1, NODE *n2 );
163 void Assign( NODE *lval, NODE *rval );
164 void MkSubst( NODE *n1, NODE *n2 );
165 void RmSubst( NODE *n );
166 void CommentFncBegin( int f, int *vars );
167 void CommentFunctionBegin( int f, ... );
168 void CommentFunctionEnd( int f );
170 void Use_C();
171 void Use_F();
172 void Use_F90();
173 void Use_MATLAB();
175 extern void (*WriteElm)( NODE *n );
176 extern void (*WriteSymbol)( int op );
177 extern void (*WriteAssign)( char* ls, char* rs );
178 extern void (*WriteComment)( char *fmt, ... );
179 extern void (*Declare)( int v );
180 extern void (*ExternDeclare)( int v );
181 extern void (*GlobalDeclare)( int v );
182 extern void (*InitDeclare)( int v, int n, void * values );
183 extern void (*DeclareConstant)( int v, char *val );
184 extern void (*FunctionStart)( int f, int *vars );
185 extern void (*FunctionPrototipe)( int f, ... );
186 extern void (*FunctionBegin)( int f, ... );
187 extern void (*FunctionEnd)( int f );
189 void WriteDelim();
191 #endif