Manual Reference Pages - jucalc (3)
NAME
jucalc - [M_calculator] parse calculator expression and return numeric or string value
(LICENSE:PD)
CONTENTS
Synopsis
Description
Options
Dependencies
Examples
See Also
References
Author
License
SYNOPSIS
subroutine jucalc(inline,outlin,mssg,slast,ierr)
character(len=*),intent=(in) :: inline
character(len=iclen_calc),intent=(out) :: outlin
character(len=iclen_calc),intent=(out) :: mssg
doubleprecision, intent=(out) :: slast
integer, intent=(out) :: ierr
DESCRIPTION
JUCALC() evaluates FORTRAN-like expressions. It can be used to add
calculator-like abilities to your program.
OPTIONS
inline |
INLINE is a string expression up to (iclen_calc=512) characters long.
The syntax of an expression is described in
the main document of the Calculator Library.
|
outlin |
Returned numeric value as a string when IERR=0.
|
mssg |
MSSG is a string that can serve several purposes
|
o
|
Returned string value when IERR=2
|
o
|
Error message string when IERR=-1
|
o
|
Message from funcs or dump command when IERR=1
|
|
|
slast |
SLAST has different meanings depending on whether a string or number
is being returned
|
o
|
REAL value set to last successfully calculated value when IERR=0
|
o
|
Number of characters in returned string variable when IERR=2
|
|
|
ierr |
status flag.
|
o |
-1 ==> An error occurred
|
o |
0 ==> A numeric value was returned
|
o |
1 ==> A message was returned
|
o |
2 ==> A string value was returned
|
|
|
|
DEPENDENCIES
o
|
ceiling
|
o
|
floor
|
o
|
change
|
o
|
modif
|
o
|
rand
|
o
|
len_trim
|
o
|
Possible User-supplied routines: substitute_subroutine, substitute_c
|
|
EXAMPLES
Example calculator program
program demo_jucalc
!compute(1f): line mode calculator program (that calls jucalc(3f))
use M_calculator, only: jucalc,iclen_calc
! iclen_calc : max length of expression or variable value as a string
implicit none
integer,parameter :: dp=kind(0.0d0)
character(len=iclen_calc) :: line
character(len=iclen_calc) :: outlin
character(len=iclen_calc) :: event
real(kind=dp) :: rvalue
integer :: ierr
ierr=0
call jucalc(ownmode(1),outlin,event,rvalue,ierr)
! activate user-defined function interface
INFINITE: do
read(*,(a),end=999)line
if(line.eq..)stop
call jucalc(line,outlin,event,rvalue,ierr)
select case (ierr)
! several different meanings to the error flag returned by calculator
case(0)
! a numeric value was returned without error
write(*,(a,a,a))trim(outlin), = ,trim(line)
case(2)
! a string value was returned without error
write(*,(a))trim(event(:int(rvalue)))
case(1)
! a request for a message has been returned (from DUMP or FUNC)
write(*,(a,a))message===>,trim(event(:len_trim(event)))
case(-1)
! an error has occurred
write(*,(a,a))error===>,trim(event(:len_trim(event)))
case default
! this should not occur
WRITE(6,(A,i10))*JUCALC* UNEXPECTED IERR VALUE ,IERR
end select
enddo INFINITE
999 continue
end program demo_jucalc
SEE ALSO
see INUM0(),RNUM0(),SNUM0(),STRGAR2(),JUCALCX().
REFERENCES
NONE.
AUTHOR
John S. Urban
LICENSE
Public Domain
| jucalc (3) | November 13, 2019 |
Generated by manServer 1.08 from 94c2a05d-1e2f-468e-9ece-6bc47a1169af using man macros.