*IF DEF,W08_1A                                                             GLW1F404.56     
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.    GTS2F400.15711  
C                                                                          GTS2F400.15712  
C Use, duplication or disclosure of this code is subject to the            GTS2F400.15713  
C restrictions as set forth in the contract.                               GTS2F400.15714  
C                                                                          GTS2F400.15715  
C                Meteorological Office                                     GTS2F400.15716  
C                London Road                                               GTS2F400.15717  
C                BRACKNELL                                                 GTS2F400.15718  
C                Berkshire UK                                              GTS2F400.15719  
C                RG12 2SZ                                                  GTS2F400.15720  
C                                                                          GTS2F400.15721  
C If no contract has been raised with this copy of the code, the use,      GTS2F400.15722  
C duplication or disclosure of it is strictly prohibited.  Permission      GTS2F400.15723  
C to do so must first be obtained in writing from the Head of Numerical    GTS2F400.15724  
C Modelling at the above address.                                          GTS2F400.15725  
C ******************************COPYRIGHT******************************    GTS2F400.15726  
C                                                                          GTS2F400.15727  
                                                                           UNBLOK.3      
! subroutine to convert fields from blocks to full grid of datapoints      UNBLOK.4      
!                                                                          UNBLOK.5      
! Subroutine Interface:                                                    UNBLOK.6      
                                                                           UNBLOK.7      

          subroutine unblok(field,blkfld,mdata,                             4UNBLOK.8      
*CALL ARGWVAL                                                              UNBLOK.9      
*CALL ARGWVGD                                                              UNBLOK.10     
     & icode)                                                              UNBLOK.11     
                                                                           UNBLOK.12     
      IMPLICIT NONE                                                        UNBLOK.13     
!                                                                          UNBLOK.14     
! Description:                                                             UNBLOK.15     
! This subroutine converts the input array of blocked data used by WAM:    UNBLOK.16     
! fldout(niblo,nblo) to data on the full grid of datapoints:               UNBLOK.17     
! array(mdata)                                                             UNBLOK.18     
!                                                                          UNBLOK.19     
! Method:                                                                  UNBLOK.20     
!   The WAM model grid and block indexing arrays are used                  UNBLOK.21     
!                                                                          UNBLOK.22     
! Current Code Owner: Martin Holt                                          UNBLOK.23     
!                                                                          UNBLOK.24     
! History:                                                                 UNBLOK.25     
! Version   Date     Comment                                               UNBLOK.26     
! -------   ----     -------                                               UNBLOK.27     
! <1.0>    July 1995 Original code.    M Holt                              UNBLOK.28     
!                                                                          UNBLOK.29     
! Code Description:                                                        UNBLOK.30     
!   Language: FORTRAN 77 + common extensions.                              UNBLOK.31     
!   This code is written to UMDP3 v6 programming standards.                UNBLOK.32     
!                                                                          UNBLOK.33     
! System component covered: <UM wave model>                                UNBLOK.34     
! System Task:              <UM wave model>                                UNBLOK.35     
!                                                                          UNBLOK.36     
!- End of header                                                           UNBLOK.37     
                                                                           UNBLOK.38     
*CALL TYPWVAL                                                              UNBLOK.40     
*CALL TYPWVGD                                                              PXORDER.57     
                                                                           UNBLOK.41     
       integer mdata           ! array size - max number of datapoints     UNBLOK.42     
       integer icode           ! out return code                           UNBLOK.43     
       real field(mdata)       ! out   field of values at data points      UNBLOK.44     
       real blkfld(niblo,nblo) ! in    field arranged by blocks            UNBLOK.45     
                                                                           UNBLOK.46     
! local variables                                                          UNBLOK.47     
                                                                           UNBLOK.48     
       integer nstart  ! index on full grid of first point in block        UNBLOK.49     
       integer nend    ! index on full grid of last  point in block        UNBLOK.50     
       integer ip      ! loop counter over all data points                 UNBLOK.51     
       integer ig      ! loop counter over all blocks                      UNBLOK.52     
       integer ifill,i         ! index                                     UNBLOK.53     
                                                                           UNBLOK.54     
       do ip=1,mdata                                                       UNBLOK.55     
         field(ip)=0.                                                      UNBLOK.56     
       enddo                                                               UNBLOK.57     
c                                                                          UNBLOK.58     
c   copy only from points ijs to ijl in each block, to ensure that time    UNBLOK.59     
c   dependent arrays such as U10 , z0 etc are correctly handled at         UNBLOK.60     
c   overlap rows                                                           UNBLOK.61     
c                                                                          UNBLOK.62     
c   nstart should = 1 as ijs(1) = 1                                        UNBLOK.63     
                                                                           UNBLOK.64     
       nstart=ijs(1)                                                       UNBLOK.65     
                                                                           UNBLOK.66     
       do ig=1,igl                                                         UNBLOK.67     
                                                                           UNBLOK.68     
        nend  = nstart + ijl(ig) - ijs(ig)                                 UNBLOK.69     
        ifill=ijs(ig)                                                      UNBLOK.70     
                                                                           UNBLOK.71     
        do i=nstart,nend                                                   UNBLOK.72     
         field(i)=blkfld(ifill,ig)                                         UNBLOK.73     
         ifill=ifill+1                                                     UNBLOK.74     
        enddo                                                              UNBLOK.75     
                                                                           UNBLOK.76     
        nstart=nend + 1                                                    UNBLOK.77     
                                                                           UNBLOK.78     
       enddo                                                               UNBLOK.79     
                                                                           UNBLOK.80     
       return                                                              UNBLOK.81     
      end                                                                  GJC0F405.46     
*ENDIF                                                                     UNBLOK.83