source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/src/utils.C @ 3512

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

Reintegrated fixes/changes from branch chemistry

File size: 1.7 KB
Line 
1
2// ############################################################################
3//
4//     create_mz_kpp_module
5//
6//     create scalar code from .f90 sources created by KPP to be used in MESSy
7//
8//     COPYRIGHT Klaus Ketelsen and MPI-CH   April 2007
9//
10// ############################################################################
11//
12//Current revisions:
13//------------------
14//
15//
16// Former revisions:
17// -----------------------
18// $Id: utils.C 3327 2018-10-09 19:55:00Z forkel $
19//
20// initial version                                  (Nov. 2016, ketelsen)
21
22
23//  mz_rs_20090111+
24// stdlib is necessary to define abort():
25#include <stdlib.h>
26//  mz_rs_20090111-
27
28#include "utils.h"
29
30void string_token::fill_token (string s) {
31   int      ip,ib;
32
33   string buf=s+" ";
34   size_val  = 0;
35
36   tokens.clear();
37   position.clear();
38
39// extract fields from buffer
40
41   int i=0;
42   int pos=0;
43   while( 1 ) {
44     while (1) {
45        ib = buf.find(seperator,0);
46        if(ib == string::npos)   break;
47        if(ib != 0)   break;
48        buf.erase(0,1);
49        pos++;
50     }
51     ip = buf.find(seperator,0);
52     if(ip == string::npos)   break;
53     tokens.push_back(buf.substr(0,ip));
54     position.push_back(pos);
55     size_val++;
56     buf.erase(0,ip);
57     pos += ib;
58
59     i++;
60   }
61
62   is = tokens.begin();
63
64   return;
65};
66
67
68void my_abort (string s) {
69   cout << "*** ERROR: " << s  <<endl;
70   abort();
71
72   return;
73}
74
75string my_to_upper(string sinp) {
76  string       s1,s2;
77
78  const char   *c1;
79  char         c2[2];
80  int          i1,i2;
81
82  for(int i=0; i<sinp.size(); i++) {
83    s1.clear();
84    s1 = sinp.substr(i,1);
85    c1 = s1.c_str();
86
87    i1 = *c1;
88    i2 = toupper(i1);
89    *c2 = i2;
90    c2[1] = 0;
91
92    s2 += c2;
93  }
94
95  return s2;
96}
Note: See TracBrowser for help on using the repository browser.