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

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

Merge of branch palm4u into trunk

File size: 2.7 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#include <string>
15#include <list>
16#include <vector>
17
18#include <iostream>
19#include <string>
20
21using namespace std;
22
23extern void my_abort(string s);
24extern string my_to_upper(string sinp);
25
26class Vvar {
27 public:
28  string                name;
29  vector<string>        dim_var;
30
31  int nr_dim() {return dim_var.size(); };
32  void clear() {name.clear(); dim_var.clear(); return; };
33};
34
35class control_switches {
36 private:
37  bool   vector_mode;            // false     Generate scalar code
38                                 // true      Generate vector code
39
40  string vector_length;
41
42  int de_index_mode;              // 0: no de-indexing
43                                  // 1: normal de-indexing
44                                  // 2: 'fast' de-indexing  (LU)
45                                  // 3: 'old' de-indexing
46
47 public:
48
49  void   set_vector_mode()              {vector_mode = true; return;};
50  void   set_vector_length (string s)   {vector_length=s; return;};
51  void   set_de_index_mode(int i)       {de_index_mode = i; return;};
52
53
54  bool   is_vector()           {return vector_mode;};
55  string get_vector_length ()  {return vector_length;};
56  int de_indexing ()           {return de_index_mode;};
57
58  control_switches () {vector_mode = false; vector_length="1"; de_index_mode=0;} 
59};
60
61extern control_switches kpp_switches;
62
63class string_token {
64 private:
65  int                         size_val;
66  string                      seperator;
67  vector <string>             tokens;
68  vector <string>::iterator   is;
69  vector <int>                position;
70
71 public:
72    void set_separator (string s) {seperator.clear();seperator=s; return; };
73
74    void    fill_token (string s);
75    bool    get_next_token(string &s) { s=*is++; return (is == tokens.end()); };
76    string  get_token_by_index (int index) { if(index <= size_val-1) {
77                                               return tokens[index]; 
78                                             } else {
79                                               return " "; }; };
80    int     size()                         { return size_val; };
81    void    update (int i, string s)       { tokens[i].clear(); tokens[i] = s;return;};
82    int     get_position(int i)            { return position[i]; };
83    void    reset (string s)               { tokens.clear(); fill_token (s); return; };
84
85
86    string_token ()         {size_val=0;seperator=" ";};
87    string_token (string s) {size_val=0;seperator=s;};
88
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.