Go to the documentation of this file.
75 character(1),
intent(in) :: str_in
80 ascii_rep = iachar(str_in(1:1))
81 if (ascii_rep>= iachar(
"0") .and. ascii_rep<=iachar(
"9") )
then
106 character(1),
intent(in) :: str_in
143 character(1),
intent(in) :: str_in
174 character(1),
intent(in) :: str_in
205 character(1),
intent(in) :: str_in
237 character(1),
intent(in) :: str_in
271 character(1),
intent(in) :: str_in
273 real(
r_kind) :: number_1,number_2
288 "."//new_line(
"A")//
'Unknown operator "'//&
289 trim(adjustl(str_in))//
'".',
"operation",&
316 character(max_fname_len),
intent(in) :: str_in
317 real(
r_kind),
intent(in) :: number
320 select case(trim(adjustl(str_in)))
345 "."//new_line(
"A")//
'Function "'//trim(adjustl(str_in))//&
346 '" not known.',
"eval_function",360004)
375 integer :: max_length_tmp
376 logical :: still_busy
380 do i = 1, max_length_tmp
382 if (j>= iachar(
"A") .and. j<=iachar(
"Z") )
then
396 do while (still_busy)
398 do i=2,max_length_tmp
443 character(len=*),
intent(in) :: inp_str
447 select case(trim(adjustl(inp_str)))
485 character(max_fname_len) :: digit_tmp
486 character(max_fname_len) :: internal_pars
487 real(
r_kind) :: tmp_storage
499 & .and. (.not.
is_operator(internal_pars(i-1:i-1))))
then
514 "."//new_line(
"A")//&
515 'Allocation of "operators" failed.',&
516 "store_digits_operator",360001)
519 digit_tmp = trim(adjustl(internal_pars(1:1)))
526 & .and. (.not.
is_operator(internal_pars(i-1:i-1))))
then
531 if (tmp_storage .ne. -1)
then
534 read( digit_tmp, *,iostat=istat)
numbers(o_c_tmp)
537 "."//new_line(
"A")//&
538 'Could not convert "'//trim(adjustl(digit_tmp))//
'" to float.',&
539 "store_digits_operator",360005)
546 if (tmp_storage .ne. -1)
then
549 read( digit_tmp, *,iostat=istat)
numbers(o_c_tmp)
552 "."//new_line(
"A")//&
553 'Could not convert "'//trim(adjustl(digit_tmp))//
'" to float.',&
554 "store_digits_operator",360005)
562 digit_tmp = trim(adjustl(digit_tmp))//trim(adjustl(internal_pars(i:i)))
563 elseif (internal_pars(i:i) .eq.
' ')
then
567 "."//new_line(
"A")//&
568 'Unknown character. ',&
569 "store_digits_operator",360006)
597 integer :: operator_count_tmp
598 logical :: dot_operation
599 logical :: line_operation,power_operation
600 real(
r_kind):: helper_result
604 "."//new_line(
"A")//&
605 'Array "operators" was not allocated.',&
606 "get_simple_result",360007)
614 power_operation = .true.
615 do while(power_operation)
616 power_operation = .false.
617 innerloop_power:
do i=1, operator_count_tmp
620 if (i .gt. operator_count_tmp)
exit innerloop_power
629 do j=i,operator_count_tmp-1
634 power_operation=.true.
636 operator_count_tmp = operator_count_tmp -1
639 end do innerloop_power
643 dot_operation = .true.
644 do while(dot_operation)
645 dot_operation = .false.
646 innerloop_dot:
do i=1, operator_count_tmp
649 if (i .gt. operator_count_tmp)
exit innerloop_dot
657 do j=i,operator_count_tmp-1
664 operator_count_tmp = operator_count_tmp -1
671 line_operation = .true.
672 do while(line_operation)
673 line_operation = .false.
674 innerloop_line:
do i=1, operator_count_tmp
682 do j=i,operator_count_tmp-1
687 line_operation=.true.
689 operator_count_tmp = operator_count_tmp -1
692 end do innerloop_line
716 character(max_fname_len) :: mod_expression
718 integer :: start_block
719 integer :: end_block,len_function_name
720 character(max_fname_len) :: string_res
722 character(max_fname_len) :: function_name,function_store
733 cc = mod_expression(i:i)
736 if (cc .eq.
' ')
then
744 if (cc .ne.
"(")
then
745 function_name =trim(adjustl(function_name))//cc
750 if (mod_expression(i:i) .eq.
'(')
then
752 function_store=function_name
756 if (mod_expression(i:i) .eq.
')')
then
765 if (trim(adjustl(function_store)) .ne.
'')
then
767 len_function_name = len(trim(adjustl(function_store)))
768 start_block = start_block-len_function_name
772 mod_expression = mod_expression(1:start_block-2)//trim(adjustl(string_res))//mod_expression(end_block+2:
max_fname_len)
808 character(300),
intent(in) :: input_string
809 real(
r_kind),
intent(in) :: var_value
812 info_entry(
"PARSE_STRING")
830 info_exit(
"PARSE_STRING")
857 character(300),
intent(in) :: input_string
858 real(
r_kind),
intent(in) :: eq_value
859 real(
r_kind),
intent(in) :: initial_guess
860 logical,
intent(out) :: converged
861 real(
r_kind),
intent(out) :: result
864 integer,
parameter :: maxiter = 100
866 real(
r_kind) :: x1,x2,xnew
868 real(
r_kind),
parameter :: diff = 1d-5
869 real(
r_kind),
parameter :: tol = 1d-5
871 integer,
parameter :: max_try_count = 10
873 info_entry(
"FIND_START_VALUE")
876 newguess=initial_guess
882 outer_loop:
do try_count=1, max_try_count
909 if (abs(x1-xnew) .lt. tol)
then
920 newguess = newguess+1d2
926 if (converged) result = xnew
928 info_exit(
"FIND_START_VALUE")
logical function, private is_line_operator(str_in)
Function to decide whether a character is a "+" or "-".
subroutine, private evaluate
Evaluate a complex string expression.
character(max_fname_len), private complete_string
Complete input string.
real(r_kind) function, private operation(number_1, number_2, str_in)
Function to perform a simple mathematical operation.
logical function, private is_dot_operator(str_in)
Function to decide whether a character is "*" or "/".
character(:) function, allocatable, public int_to_str(num)
Converts a given integer to a string.
subroutine, public raise_exception(msg, sub, error_code)
Raise a exception with a given error message.
logical function, private is_power_operator(str_in)
Function to decide whether a character is a "^".
real(r_kind) function, private eval_function(number, str_in)
Function to perform a function operations.
integer, parameter, public max_fname_len
maximum length of filenames
real(r_kind), private variable_value
Input variable, set by parse_string.
integer, private operator_count
subroutine, private get_simple_result
Evaluate a simple string expression, without brackets and functions.
integer, private number_count
real(r_kind), dimension(:), allocatable, private numbers
Array containing the numbers of the equation (e.g., [1, 2, 3])
Subroutines for equation parsing in case of an analytic trajectory or luminosity mode.
subroutine, private make_pars_str_consistent
Subroutine to check the parsing string for consistency and correct it.
subroutine, public find_start_value(input_string, eq_value, initial_guess, converged, result)
Finds a value of the variable for a given y-value.
character(1), parameter, private variable_name
Name of the variable that is replaced by parse_string.
real(r_kind) function, public parse_string(input_string, var_value)
Takes a string and evaluates the expression.
character(:) function, allocatable, public num_to_str(num)
Converts a given real to a string with format "(1pE10.2)".
real(r_kind) function, private common_variables(inp_str)
Function to define constants.
character(1), dimension(:), allocatable, private operators
Array containing the operations of the equation as a character (e.g., ["*","+"])
logical function, private is_digit(str_in)
Function to decide whether a character is a number or not (i.e., 0-9).
logical function, private is_operator(str_in)
Function to decide whether a character is a mathematical operator or not. Functions (as e....
character(max_fname_len), private parsing_string
Current substring to parse.
subroutine, private store_digits_operator
Store mathematical operators (+-*/) and numbers in arrays.
Contains all runtime parameters as well as phys and math constants.
logical function, private is_separator(str_in)
Function to decide whether a character can be associated with a number.