*IF DEF,CONTROL GLW1F404.36
!+ Masks ocean data in stash workspace w.r.t. a number-of-levels array MASKODN1.2
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved. GTS2F400.15167
C GTS2F400.15168
C Use, duplication or disclosure of this code is subject to the GTS2F400.15169
C restrictions as set forth in the contract. GTS2F400.15170
C GTS2F400.15171
C Meteorological Office GTS2F400.15172
C London Road GTS2F400.15173
C BRACKNELL GTS2F400.15174
C Berkshire UK GTS2F400.15175
C RG12 2SZ GTS2F400.15176
C GTS2F400.15177
C If no contract has been raised with this copy of the code, the use, GTS2F400.15178
C duplication or disclosure of it is strictly prohibited. Permission GTS2F400.15179
C to do so must first be obtained in writing from the Head of Numerical GTS2F400.15180
C Modelling at the above address. GTS2F400.15181
C ******************************COPYRIGHT****************************** GTS2F400.15182
C GTS2F400.15183
! MASKODN1.3
! Subroutine Interface: MASKODN1.4
SUBROUTINE MASKODIAGN(NX,NY,KM,STDVMD,VMD,FKM,STASHWORK) 9,1MASKODN1.5
MASKODN1.6
IMPLICIT NONE MASKODN1.7
! MASKODN1.8
! Description: MASKODN1.9
! MASKODIAGN replaces with missing data elements of STASHWORK which MASKODN1.10
! are not active ocean points according to the supplied MASKODN1.11
! number-of-levels array FKM. FKM is a 2D array, but the 1D STASHWORK MASKODN1.12
! array is assumed to contain 2D or 3D data in the usual order of a MASKODN1.13
! Fortran array. In the case of a cylic ocean, the last two columns MASKODN1.14
! of FKM (NX-1:NX) correspond to wrap-round columns, and are MASKODN1.15
! ignored. STASHWORK contains data for row of length NX-2 in this MASKODN1.16
! case. If STDVMD is .TRUE., missing data is indicated by the MASKODN1.17
! standard missing data value. If STDVMD is .FALSE., the value MASKODN1.18
! of VMD is inserted at missing-data points. MASKODN1.19
! MASKODN1.20
! To mask data of one level, call with KM=1. MASKODN1.21
! MASKODN1.22
! The ...N suffix of the subroutine name indicates that the data is MASKODN1.23
! being masked with a number-of-levels array. The corresponding MASKODN1.24
! routine which masks with a logical array is called MASKODIAGL. MASKODN1.25
! MASKODN1.26
! Current Code Owner: J.M.Gregory MASKODN1.27
! MASKODN1.28
! History: MASKODN1.29
! Version Date Comment MASKODN1.30
! ------- ---- ------- MASKODN1.31
! 4.0 23.3.95 Original code. J.M.Gregory MASKODN1.32
! MASKODN1.33
! Code Description: MASKODN1.34
! Language: FORTRAN 77 + common extensions. MASKODN1.35
! This code is written to UMDP3 v6 programming standards. MASKODN1.36
! MASKODN1.37
! System component covered: <appropriate code> MASKODN1.38
! System Task: <appropriate code> MASKODN1.39
! MASKODN1.40
MASKODN1.41
! Input arguments MASKODN1.42
INTEGER MASKODN1.43
& NX ! 1st dimension of FKM MASKODN1.44
&,NY ! 2nd dimension of FKM MASKODN1.45
&,KM ! No. of levels of data to be masked in STASHWORK MASKODN1.46
MASKODN1.47
LOGICAL MASKODN1.48
& STDVMD ! Use standard value to indicate missing data MASKODN1.49
MASKODN1.50
REAL MASKODN1.51
& VMD ! Missing data value; ignored if .NOT.STDVMD MASKODN1.52
&,FKM(NX,NY) ! Number of active levels at each point MASKODN1.53
MASKODN1.54
! Input/output arguments MASKODN1.55
REAL MASKODN1.56
& STASHWORK(*) ! Stashwork array MASKODN1.57
MASKODN1.58
! Local variables MASKODN1.59
INTEGER MASKODN1.60
& I,J,K ! Indices into OCEAN MASKODN1.61
MASKODN1.62
LOGICAL MASKODN1.63
& OCEAN(NX,NY,KM) ! Ocean mask, .TRUE. where data is wanted MASKODN1.64
MASKODN1.65
! Function & Subroutine calls: MASKODN1.66
EXTERNAL MASKODIAGL MASKODN1.67
MASKODN1.68
!- End of header MASKODN1.69
MASKODN1.70
C Derive logical ocean mask from number-of-levels array. MASKODN1.71
DO K=1,KM MASKODN1.72
DO J=1,NY MASKODN1.73
DO I=1,NX MASKODN1.74
OCEAN(I,J,K)=K.LE.INT(FKM(I,J)) MASKODN1.75
ENDDO MASKODN1.76
ENDDO MASKODN1.77
ENDDO MASKODN1.78
MASKODN1.79
C Apply mask. MASKODN1.80
CALL MASKODIAGL
(NX,NY,KM,STDVMD,VMD,OCEAN,STASHWORK) MASKODN1.81
MASKODN1.82
C MASKODN1.83
RETURN MASKODN1.84
END MASKODN1.85
*ENDIF GLW1F404.37