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

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

Merge of branch palm4u into trunk

File size: 1.5 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//  mz_rs_20090111+
13// stdlib is necessary to define abort():
14#include <stdlib.h>
15//  mz_rs_20090111-
16
17#include "utils.h"
18
19void string_token::fill_token (string s) {
20   int      ip,ib;
21
22   string buf=s+" ";
23   size_val  = 0;
24
25   tokens.clear();
26   position.clear();
27
28// extract fields from buffer
29
30   int i=0;
31   int pos=0;
32   while( 1 ) {
33     while (1) {
34        ib = buf.find(seperator,0);
35        if(ib == string::npos)   break;
36        if(ib != 0)   break;
37        buf.erase(0,1);
38        pos++;
39     }
40     ip = buf.find(seperator,0);
41     if(ip == string::npos)   break;
42     tokens.push_back(buf.substr(0,ip));
43     position.push_back(pos);
44     size_val++;
45     buf.erase(0,ip);
46     pos += ib;
47
48     i++;
49   }
50
51   is = tokens.begin();
52
53   return;
54};
55
56
57void my_abort (string s) {
58   cout << "*** ERROR: " << s  <<endl;
59   abort();
60
61   return;
62}
63
64string my_to_upper(string sinp) {
65  string       s1,s2;
66
67  const char   *c1;
68  char         c2[2];
69  int          i1,i2;
70
71  for(int i=0; i<sinp.size(); i++) {
72    s1.clear();
73    s1 = sinp.substr(i,1);
74    c1 = s1.c_str();
75
76    i1 = *c1;
77    i2 = toupper(i1);
78    *c2 = i2;
79    c2[1] = 0;
80
81    s2 += c2;
82  }
83
84  return s2;
85}
Note: See TracBrowser for help on using the repository browser.