c
c	ctoh1.f 1.4 92/07/01 15:18:34
c
c  Copyright 1991 Intel Corporation, Inc.
c  See the "Copyright" file for complete rights and liability information.
c
c  Part 1:
c    Runs on the host. Loads the node program in the "ctoh2.f" file.
c    Converts data to cube byte-order, sends it to the cube,
c    receives data from the cube, and converts it to host byte-order.

      double precision dpvar
      real             rvar
      integer*4        i4var
      integer*2        i2var

c  Set host PID, get a cube, and load the node program.

      call getcube('alpha', '1', '', 0, '')
      call setpid(100)
      call load("ctoh2", -1, 0)

c  Initialize variables.

      dpvar = 2.5**50
      rvar  = 2.5**20
      i4var = 2**20
      i2var = 2**10

      print *, 'Data before conversion to cube byte-order:'
      write(*, 100) dpvar, rvar, i4var, i2var
100   format('dpvar = ', d40.4, /,
     1       'rvar  = ', f40.4, /,
     2       'i4var = ', i40, /,
     3       'i2var = ', i40, /)

c  Convert to cube byte-order.

      call htocd(dpvar, 1)
      call htocf(rvar, 1)
      call htocl(i4var, 1)
      call htocs(i2var, 1)

      print *, 'Data after conversion to cube byte-order:'
      write(*, 100) dpvar, rvar, i4var, i2var

c  Send data to cube.

      call csend(10, dpvar, 16, 0, 0)
      call csend(11, rvar, 8, 0, 0)
      call csend(12, i4var, 4, 0, 0)
      call csend(13, i2var, 2, 0, 0)

c  Receive data from cube.

      call crecv(20, dpvar, 16)
      call crecv(21, rvar, 8)
      call crecv(22, i4var, 4)
      call crecv(23, i2var, 2)

      print *, 'Data before conversion to host byte-order:'
      write(*, 100) dpvar, rvar, i4var, i2var

c  Convert to host byte-order.

      call ctohd(dpvar, 1)
      call ctohf(rvar, 1)
      call ctohl(i4var, 1)
      call ctohs(i2var, 1)

      print *, 'Data after conversion to host byte-order:'
      write(*, 100) dpvar, rvar, i4var, i2var

      call waitall(-1, -1)

      end
