c %Z% %M% %I% (IDS) %G%

C+
C*
C*   This file contains the following routines in the host part 
C*   of the host-node program :
C*   
C*   1) subroutine hnint - host-node interface
C*                              
C-

C+
C  subroutine hnint - Interfaces with the nodal program.  Sends the 
C                     inputs for either the bilinear or bicubic 
C                     interpolation to node 0 and receives the outputs
C                     from node 0. Before sending the other input
C                     parameters, it broadcasts the type of request
C                     to all the nodes.
C  
C  Current requests are :-
C
C  1) MPBILL for bilinear interpolation
C  2) MPBIC  for bicubic interpolation (as in bic1nu.f)
C
C  The values are defined in slgcm.mp.  Note slgcm.mpp is no longer used.
C
C  Inputs : wina corresponds to ust (yuupt)
C           winb    "        "  vst (yvvpt)
C           rlatitude "      "  spuh (sphi)
C           rlongitude "     "  sluh (slam)
C           faclama   
C           faclamb    
C           facphia
C           facphib 
C           ja, jb      - range of indices
C           interpol    - bilinear (bicubic)
C  
C  Outputs : woua corresponds to c1a (yuupts or yvvpts)
C            woub     "       "  c2a (yvupts or yuvpts)
C  
C  The items in parantheses refers to the bicubic interpolation. For
C  further details about the quantities one is referred to Yong Li's 
C  notes.
C-
      subroutine hnint(wina, woua,faclama, facphia,
     *                winb, woub,faclamb, facphib, 
     *                rlatitude,rlongitude, ja, jb, interpol)

      include "slgcm.slgprm"
      include "slgcm.mp"

      implicit none

      real   wina ( imp3 ,jmp3 )   !first input field
      real   woua ( imp3 ,jm   )   !first output field
      real   winb ( imp3 ,jmp3 )   !second input field
      real   woub ( imp3 ,jm   )   !second output field
      real   rlatitude  ( imp3 ,jm   ) ! arrays with coordinates on
      real   rlongitude  ( imp3 ,jm   ) ! which the subroutine interpolates
      real   faclama
      real   faclamb
      real   facphia
      real   facphib
      integer ja, jb, interpol
      integer status                ! status of the communication routines

C*
C*    Function prototypes
      integer mp_rcv_rblock
      integer mp_send_rblock
      integer mp_send_real
      integer mp_send_int
C*
C*

      print *, "In hbill.f"
C2      call mp_enable_nodes()
C1      call mp_bc_int_from_host(MPBILL)
      call mp_bc_int_from_host(interpol)
      call mp_serve_nodes()
      print *, "Sending input parameters"
      status = mp_send_rblock(0, 0, wina, imp3, jmp3)
      status = mp_send_rblock(0, 0, winb, imp3, jmp3)
      status = mp_send_rblock(0, 0, rlatitude, imp3, jm)
      status = mp_send_rblock(0, 0, rlongitude, imp3, jm)
      status = mp_send_real(0, 0, faclama)
      status = mp_send_real(0, 0, faclamb)
      status = mp_send_real(0, 0, facphia)
      status = mp_send_real(0, 0, facphib)
      status = mp_send_int(0, 0, ja)
      status = mp_send_int(0, 0, jb)

C! 
C!        Uncomment if the nodal programs are using UNIX CALLS
        call mp_serve_nodes()

        print *, "Host at receiving end"
        status = mp_rcv_rblock(0, 0, woua, imp3, jm)
        status = mp_rcv_rblock(0, 0, woub, imp3, jm)

        print *, "Host finished receiving"
C1        call mp_bc_int_from_host(MPCONT)

C!      call exit(0)
C!      stop
      end
