source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/utils.h @ 3458

Last change on this file since 3458 was 3458, checked in by kanani, 5 years ago

Reintegrated fixes/changes from branch chemistry

File size: 3.0 KB
Line 
1#ifndef UTIL
2#define UTIL 1
3
4// ############################################################################
5//
6//     create_mz_kpp_module
7//
8//     create scalar code from .f90 sources created by KPP to be used in MESSy
9//
10//     COPYRIGHT Klaus Ketelsen and MPI-CH   April 2007
11//
12// ############################################################################
13//
14//Current revisions:
15//------------------
16//
17//
18// Former revisions:
19// -----------------------
20// $Id: utils.h 3327 2018-10-09 19:55:00Z forkel $
21//
22// initial version                                  (Nov. 2016, ketelsen)
23//
24
25#include <string>
26#include <list>
27#include <vector>
28
29#include <iostream>
30#include <string>
31
32using namespace std;
33
34extern void my_abort(string s);
35extern string my_to_upper(string sinp);
36
37class Vvar {
38 public:
39  string                name;
40  vector<string>        dim_var;
41
42  int nr_dim() {return dim_var.size(); };
43  void clear() {name.clear(); dim_var.clear(); return; };
44};
45
46class control_switches {
47 private:
48  bool   vector_mode;            // false     Generate scalar code
49                                 // true      Generate vector code
50
51  string vector_length;
52
53  int de_index_mode;              // 0: no de-indexing
54                                  // 1: normal de-indexing
55                                  // 2: 'fast' de-indexing  (LU)
56                                  // 3: 'old' de-indexing
57
58 public:
59
60  void   set_vector_mode()              {vector_mode = true; return;};
61  void   set_vector_length (string s)   {vector_length=s; return;};
62  void   set_de_index_mode(int i)       {de_index_mode = i; return;};
63
64
65  bool   is_vector()           {return vector_mode;};
66  string get_vector_length ()  {return vector_length;};
67  int de_indexing ()           {return de_index_mode;};
68
69  control_switches () {vector_mode = false; vector_length="1"; de_index_mode=0;} 
70};
71
72extern control_switches kpp_switches;
73
74class string_token {
75 private:
76  int                         size_val;
77  string                      seperator;
78  vector <string>             tokens;
79  vector <string>::iterator   is;
80  vector <int>                position;
81
82 public:
83    void set_separator (string s) {seperator.clear();seperator=s; return; };
84
85    void    fill_token (string s);
86    bool    get_next_token(string &s) { s=*is++; return (is == tokens.end()); };
87    string  get_token_by_index (int index) { if(index <= size_val-1) {
88                                               return tokens[index]; 
89                                             } else {
90                                               return " "; }; };
91    int     size()                         { return size_val; };
92    void    update (int i, string s)       { tokens[i].clear(); tokens[i] = s;return;};
93    int     get_position(int i)            { return position[i]; };
94    void    reset (string s)               { tokens.clear(); fill_token (s); return; };
95
96
97    string_token ()         {size_val=0;seperator=" ";};
98    string_token (string s) {size_val=0;seperator=s;};
99
100};
101
102#endif
Note: See TracBrowser for help on using the repository browser.