source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp/src/code.h @ 3997

Last change on this file since 3997 was 2696, checked in by kanani, 6 years ago

Merge of branch palm4u into trunk

File size: 5.3 KB
Line 
1/******************************************************************************
2
3  KPP - The Kinetic PreProcessor
4        Builds simulation code for chemical kinetic systems
5
6  Copyright (C) 1995-1996 Valeriu Damian and Adrian Sandu
7  Copyright (C) 1997-2005 Adrian Sandu
8
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.
13
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.
18
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.
23
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
29
30******************************************************************************/
31
32
33#ifndef _CODE_H_
34#define _CODE_H_
35
36#include <stdlib.h>
37#include <time.h>
38#include "gdef.h"
39
40#define MAX_DEPTH        10
41#define MAX_SUBST        20
42#define SUBST           100
43#define MAX_VAR         150
44#define MAX_OUTBUF   200000
45#define MAX_COLS          8
46#define MAX_LINES        20
47
48#define WriteAll bprintf
49
50enum types  { NONE, ADD, SUB, MUL, DIV, POW, CONST, ELM, VELM, MELM, EELM, FNC };
51extern int PRI[];
52
53enum signs { O_PAREN = 20, C_PAREN };
54enum base_types { VOID, INT, REAL, DOUBLE, STRING, DOUBLESTRING };
55/*  mz_rs_20050117+ */
56extern FILE * initFile;
57/*  mz_rs_20050117- */
58extern FILE * driverFile;
59extern FILE * functionFile;
60extern FILE * global_dataFile;
61extern FILE * hessianFile;
62extern FILE * integratorFile;
63extern FILE * jacobianFile;
64extern FILE * linalgFile;
65extern FILE * mapFile;
66extern FILE * makeFile;
67extern FILE * monitorFile;
68extern FILE * mex_funFile;
69extern FILE * mex_jacFile;
70extern FILE * mex_hessFile;
71extern FILE * param_headerFile;
72extern FILE * rateFile;
73extern FILE * sparse_dataFile;
74extern FILE * sparse_jacFile;
75extern FILE * sparse_hessFile;
76extern FILE * sparse_stoicmFile;
77extern FILE * stoichiomFile;
78extern FILE * stochasticFile;
79extern FILE * utilFile;
80
81extern FILE * currentFile;
82
83extern int ident;
84extern int real;
85extern char * CommonName;
86
87void OpenFile( FILE **fpp, char *name, char * ext, char * identity );
88FILE * UseFile( FILE *fp );
89 
90typedef struct {
91                 char *name;
92                 int type;
93                 int baseType;
94                 int maxi;
95                 int maxj;
96                 int value;
97                 char *comment;
98               } VARIABLE;
99
100extern VARIABLE* varTable[];
101
102extern char *outBuf;
103extern char *outBuffer;
104
105void AllowBreak();
106void bprintf( char *fmt, ... );
107void FlushBuf();
108void FlushThisBuf( char * buf );
109void NewLines( int n );
110void C_Inline( char *fmt, ... );
111void F77_Inline( char *fmt, ... );
112void IncludeFile( char * fname );
113void IncludeCode( char *fmt, ... );
114void MapFunctionComment( int f, int *vars );
115     
116int DefineVariable( char * name, int t, int bt, int maxi, int maxj, char * comment );
117void FreeVariable( int n );
118
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 )
125 
126typedef 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;
137
138typedef struct node {
139                      struct node * left;
140                      struct node * right;
141                      int type;
142                      int sign;
143                      ELEMENT *elm;
144                    } NODE;
145
146extern char *F77_types[];
147extern char *F90_types[];
148extern char *C_types[];
149extern char *MATLAB_types[];
150
151NODE * Elm( int v, ... );
152#define Const( x ) Elm( 0, (double)x )
153#define Expr( x ) Elm( 1, x )
154
155void FreeNode( NODE * n );
156
157NODE * Add( NODE *n1, NODE *n2 );
158NODE * Sub( NODE *n1, NODE *n2 );
159NODE * Mul( NODE *n1, NODE *n2 );
160NODE * Div( NODE *n1, NODE *n2 );
161NODE * Pow( NODE *n1, NODE *n2 );
162
163void Assign( NODE *lval, NODE *rval );
164void MkSubst( NODE *n1, NODE *n2 );
165void RmSubst( NODE *n );
166void CommentFncBegin( int f, int *vars );
167void CommentFunctionBegin( int f, ... );
168void CommentFunctionEnd( int f );
169
170void Use_C();
171void Use_F();
172void Use_F90();
173void Use_MATLAB();
174
175extern void (*WriteElm)( NODE *n );
176extern void (*WriteSymbol)( int op );
177extern void (*WriteAssign)( char* ls, char* rs );
178extern void (*WriteComment)( char *fmt, ...  );
179extern void (*Declare)( int v );
180extern void (*ExternDeclare)( int v );
181extern void (*GlobalDeclare)( int v );
182extern void (*InitDeclare)( int v, int n, void * values );
183extern void (*DeclareConstant)( int v, char *val );
184extern void (*FunctionStart)( int f, int *vars );
185extern void (*FunctionPrototipe)( int f, ... );
186extern void (*FunctionBegin)( int f, ... );
187extern void (*FunctionEnd)( int f );
188
189void WriteDelim();
190
191#endif
Note: See TracBrowser for help on using the repository browser.