function Evaluate_r2fp32(parser,x) result(f)
class(EquationParser) :: parser
real(real32) :: x(:,:,:)
real(real32) :: f(lbound(x,1):ubound(x,1), &
lbound(x,2):ubound(x,2))
! Local
integer :: i,k
type(Token) :: t
type(r2fp32Stack) :: stack
real(real32) :: vnumber
real(real32),allocatable :: v(:,:)
real(real32),allocatable :: a(:,:)
real(real32),allocatable :: b(:,:)
real(real32),allocatable :: c(:,:)
integer :: l1,l2,u1,u2
l1 = lbound(x,1)
l2 = lbound(x,2)
u1 = ubound(x,1)
u2 = ubound(x,2)
allocate(v(l1:u1,l2:u2), &
a(l1:u1,l2:u2), &
b(l1:u1,l2:u2), &
c(l1:u1,l2:u2))
call stack%Construct(Stack_Length,v)
do k = 1,parser%postfix%top_index
t = parser%postfix%tokens(k)%Copy()
print*,trim(t%tokenString)
select case(t%tokenType)
case(Number_Token)
if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then
v = pi_real32
else
read(t%tokenString,*) vnumber
v = vnumber
endif
call stack%Push(v)
case(Variable_Token)
do i = 1,parser%nIndepVars
if(trim(t%tokenString) == parser%indepVars(i)%value) then
call stack%Push(x(:,:,i))
exit
endif
enddo
case(Operator_Token)
call stack%Pop(a)
call stack%Pop(b)
select case(trim(t%tokenString))
case('+')
c = a+b
case('-')
c = b-a
case('*')
c = a*b
case('/')
c = b/a
case('^')
c = b**a
case default
endselect
call stack%Push(c)
case(Function_Token)
call stack%Pop(a)
b = Functions(t%tokenIndex)%invoke(a)
call stack%Push(b)
case(Monadic_Token)
if(trim(t%tokenString) == '-') then
call stack%Pop(a)
a = -a
call stack%Push(a)
endif
case default
endselect
enddo
call stack%Pop(a)
f = a
deallocate(v,a,b,c)
endfunction Evaluate_r2fp32