In the Fortran program, is it possible to read an expression including the variables ? For example, the input file is (if necessary, we can change the input form of the expression,e.g.,the binary form), 2(a-4b) It should be noted that the input expression has a very simple form and it only contains integer or fraction or some variables,like the following in the list, {0,232,-2/5a,3a-b,b/9} Here 2a means 2*a
The Fortran program is
Program test
implicit none
real(kind=8)::a,b,exp
a=10.
b=3.
! open file and read the input expression
! that is, exp=2*(a-4*b)
write(*,*) exp ! we can get exp=-4.0
end program
For the complicated expressions, it is obviously not a good idea for Fortran. I just want to know, in this simple input expression case, is it possible to find a better way ?