inum0(3f) - [M_calculator] return integer value from calculator expression (LICENSE:PD)
integer function inum0(inline,ierr)
character(len=*),intent(in) :: inline
integer,optional,intent(out) :: ierr
INUM0(3f) evaluates a CHARACTER argument as a FORTRAN-like calculator expression and returns an integer.
Values returned are assumed to be very close to being whole integer values. A small value (0.01) is added to the result before it is returned to reduce roundoff error problems. This could introduce errors if INUM0 is misused and is not being used to calculate essentially integer results.
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_inum0
use M_calculator, only : inum0
i=inum0('20/3.4')
j=inum0('CI = 13 * 3.1')
k=inum0('CI')
write(*,*)'Answers are ',I,J,K
end program demo_inum0
The syntax of an expression is as described in the main document of the Calculator Library. See CALCULATOR(3f), RNUM0(3f), DNUM0(3f), SNUM0(3f), EXPRESSION(3f)