c
c	etos.f 1.4 92/07/01 15:19:17
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Can run on a multi-node cube, but only node 0 does anything.

      include 'fcube.h'

      integer     n, result
      integer     e1(2), e2(2), eresult(2)
      character*5 string1, string2, string3, string4

c  Identify self.

      iam = mynode()

c  If node 0, then ...

      if(iam .eq. 0) then
         print *,'Starting ...'

c    Initialize.

         string1 = '3'
         string2 = '4'
         string3 = '5'
         n       =  5

c    Convert strings to extended numbers.

         call stoe(string1, e1)
         call stoe(string2, e2)
         call stoe(string3, eresult)

c    Add e1 and e2.

         call eadd(e1, e2, eresult) 
         call etos(eresult, string4)
         write(*, 200) string1, string2, string4
200      format(a10, ' + ', a10, ' = ', a10)

c    Subtract e1 from e2.

         call esub(e1, e2, eresult) 
         call etos(eresult, string4)
         write(*, 300) string1, string2, string4
300      format(a10, ' - ', a10, ' = ', a10)

c    Multiply e1 and n.

         call emul(e1, n, eresult) 
         call etos(eresult, string4)
         write(*, 400) string1, string3, string4
400      format(a10, ' * ', a10, ' = ', a10)

c    Divide e1 by n.

         call ediv(e1, n, eresult) 
         call etos(eresult, string4)
         write(*, 500) string1, string3, string4
500      format(a10, ' / ', a10, ' = ', a10)

c    Remainder of e1 divided by n.

         call emod(e1, n, eresult) 
         call etos(eresult, string4)
         write(*, 600) string1, string3, string4
600      format(a10, 'MOD', a10, ' = ', a10)

c    Compare e1 and e2.

         n = ecmp(e1, e2)
         if(n .lt. 0) then
            write(*, 700) string1, string2
700         format(a10, ' is less than ', a10)
         else if(n .eq. 0) then
            write(*, 710) string1, string2
710         format(a10, ' is equal to ', a10)
         else
            write(*, 720) string1, string2
720         format(a10, ' is greater than ', a10)
         endif

      endif

      end
