Last change
on this file since 4651 was
3799,
checked in by forkel, 6 years ago
|
editing in kpp4palm: add statements for avoiding unused variables, remove $Id
|
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 | // |
---|
13 | // Former revisions: |
---|
14 | // ----------------------- |
---|
15 | // Deleted $Id since document_changes does not work for C and C++ (15.03.2019, forkel) |
---|
16 | // |
---|
17 | // initial version (Nov. 2016, ketelsen) |
---|
18 | |
---|
19 | |
---|
20 | // mz_rs_20090111+ |
---|
21 | // stdlib is necessary to define abort(): |
---|
22 | #include <stdlib.h> |
---|
23 | // mz_rs_20090111- |
---|
24 | |
---|
25 | #include "utils.h" |
---|
26 | |
---|
27 | void string_token::fill_token (string s) { |
---|
28 | int ip,ib; |
---|
29 | |
---|
30 | string buf=s+" "; |
---|
31 | size_val = 0; |
---|
32 | |
---|
33 | tokens.clear(); |
---|
34 | position.clear(); |
---|
35 | |
---|
36 | // extract fields from buffer |
---|
37 | |
---|
38 | int i=0; |
---|
39 | int pos=0; |
---|
40 | while( 1 ) { |
---|
41 | while (1) { |
---|
42 | ib = buf.find(seperator,0); |
---|
43 | if(ib == string::npos) break; |
---|
44 | if(ib != 0) break; |
---|
45 | buf.erase(0,1); |
---|
46 | pos++; |
---|
47 | } |
---|
48 | ip = buf.find(seperator,0); |
---|
49 | if(ip == string::npos) break; |
---|
50 | tokens.push_back(buf.substr(0,ip)); |
---|
51 | position.push_back(pos); |
---|
52 | size_val++; |
---|
53 | buf.erase(0,ip); |
---|
54 | pos += ib; |
---|
55 | |
---|
56 | i++; |
---|
57 | } |
---|
58 | |
---|
59 | is = tokens.begin(); |
---|
60 | |
---|
61 | return; |
---|
62 | }; |
---|
63 | |
---|
64 | |
---|
65 | void my_abort (string s) { |
---|
66 | cout << "*** ERROR: " << s <<endl; |
---|
67 | abort(); |
---|
68 | |
---|
69 | return; |
---|
70 | } |
---|
71 | |
---|
72 | string my_to_upper(string sinp) { |
---|
73 | string s1,s2; |
---|
74 | |
---|
75 | const char *c1; |
---|
76 | char c2[2]; |
---|
77 | int i1,i2; |
---|
78 | |
---|
79 | for(int i=0; i<sinp.size(); i++) { |
---|
80 | s1.clear(); |
---|
81 | s1 = sinp.substr(i,1); |
---|
82 | c1 = s1.c_str(); |
---|
83 | |
---|
84 | i1 = *c1; |
---|
85 | i2 = toupper(i1); |
---|
86 | *c2 = i2; |
---|
87 | c2[1] = 0; |
---|
88 | |
---|
89 | s2 += c2; |
---|
90 | } |
---|
91 | |
---|
92 | return s2; |
---|
93 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.