expression(3f) - [M_calculator] return value from a string expression processing messages to simplify call to CALCULATOR(3f) (LICENSE:PD)
subroutine expression(inlin0,outval,outlin0,ierr,ilen)
character(len=*), intent=(in) :: inlin0
doubleprecision, intent=(out) :: outval
character(len=*), intent=(out) :: outlin0
integer, intent=(out) :: ierr
integer, intent=(out) :: ilen
expression() takes a string containing a FORTRAN-like expression and evaluates it and returns a numeric or string value as appropriate. The main purpose of expression() is to assume the burden of displaying the calculator messages for codes that make multiple calls to CALCULATOR(3f). CALCULATOR(3f) does not display error messages directly.
All programs that call the calculator routine can supply their own substitute_subroutine(3f) and substitute_C(3f) procedures, which allow adding procedures to the calculator without altering the M_calculator module. See the example program for samples.
Sample program:
program demo_expression
use M_calculator, only : iclen_calc
use M_calculator, only : expression
character(len=iclen_calc) :: outlin0
doubleprecision :: outval
call expression('A=3.4**5 ',outval,outlin0,ierr,ilen)
write(*,*)'value of expression is ',outval
write(*,*)'string representation of value is ',trim(outlin0)
write(*,*)'error flag value is ',ierr
write(*,*)'length of expression is ',ilen
end program demo_expression
Results:
value of expression is 454.35424000000000
string representation of value is 454.35424
error flag value is 0
length of expression is 8
See also: RNUM0(),CALCULATOR(),INUM0(),SNUM0()