|
24 | 24 | # - mechanism.ro2
|
25 | 25 | # - mechanism.f90
|
26 | 26 | #
|
27 |
| -# Acknowledgements: B. Nelson, M. Newland |
| 27 | +# Acknowledgements: B. Nelson, M. Newland, A. Mayhew |
28 | 28 | #
|
29 | 29 | # ARGUMENTS:
|
30 | 30 | # 1. path to the mechanism .fac file
|
@@ -71,9 +71,10 @@ def tokenise_and_process(input_string, vars_dict):
|
71 | 71 | assert isinstance(vars_dict, dict), \
|
72 | 72 | 'tokenise_and_process: vars_dict is not of type dict: ' + str(vars_dict)
|
73 | 73 |
|
74 |
| - # Generate start and end points of sections of symbols and non-symbols. |
75 |
| - symbol_regex = r'[()\-+*@/ ]+' |
76 |
| - nonsymbol_regex = r'[^()\-+*@/ ]+' |
| 74 | + # Generate start and end points of sections of symbols and nonsymbols |
| 75 | + symbol_regex = '[()\-+*@/, ]+' |
| 76 | + nonsymbol_regex = '[^()\-+*@/, ]+' |
| 77 | + |
77 | 78 | list_of_symbol_starts = [m.start(0) for m in re.finditer(symbol_regex, input_string)]
|
78 | 79 | list_of_symbol_ends = [m.end(0) for m in re.finditer(symbol_regex, input_string)]
|
79 | 80 | list_of_nonsymbol_starts = [m.start(0) for m in re.finditer(nonsymbol_regex, input_string)]
|
@@ -302,6 +303,15 @@ def convert_to_fortran(input_file, mech_dir, mcm_vers):
|
302 | 303 | continue
|
303 | 304 |
|
304 | 305 | # -------------------------------------------------
|
| 306 | + # Read in the names of user-defined custom rate functions and add them |
| 307 | + # to the list of reserved names so that they will be carried through the |
| 308 | + # rate definitions (in a similar manner to LOG10) |
| 309 | + with open(mech_dir + '/customRateFuncs.f90') as custom_func_file: |
| 310 | + func_def_pat = "function +([a-zA-Z0-9_]*) *\(" |
| 311 | + custom_func_names = re.findall(func_def_pat, custom_func_file.read(), re.I) |
| 312 | + |
| 313 | + for n in custom_func_names: |
| 314 | + reservedOtherList.append(n) |
305 | 315 |
|
306 | 316 | # Initialise list, dictionary and a counter.
|
307 | 317 | mechanism_rates_coeff_list = []
|
@@ -551,6 +561,7 @@ def convert_to_fortran(input_file, mech_dir, mcm_vers):
|
551 | 561 |
|
552 | 562 | subroutine update_p(p, q, TEMP, N2, O2, M, RH, H2O, BLHEIGHT, DEC, JFAC, DILUTE, ROOFOPEN, ASA, J, RO2) bind(c,name='update_p')
|
553 | 563 |
|
| 564 | + use custom_functions_mod |
554 | 565 | integer, parameter :: DP = selected_real_kind( p = 15, r = 307 )
|
555 | 566 | real(c_double), intent(inout) :: p(*), q(*)
|
556 | 567 | real(c_double), intent(in) :: TEMP, N2, O2, M, RH, H2O, BLHEIGHT, DEC, JFAC, DILUTE, ROOFOPEN, ASA, J(*), RO2
|
|
0 commit comments