*IF DEF,OCEAN ORH0F404.139
!+ Copies ocean data into stash workspace, using a logical mask COPYODL1.2
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved. GTS2F400.15116
C GTS2F400.15117
C Use, duplication or disclosure of this code is subject to the GTS2F400.15118
C restrictions as set forth in the contract. GTS2F400.15119
C GTS2F400.15120
C Meteorological Office GTS2F400.15121
C London Road GTS2F400.15122
C BRACKNELL GTS2F400.15123
C Berkshire UK GTS2F400.15124
C RG12 2SZ GTS2F400.15125
C GTS2F400.15126
C If no contract has been raised with this copy of the code, the use, GTS2F400.15127
C duplication or disclosure of it is strictly prohibited. Permission GTS2F400.15128
C to do so must first be obtained in writing from the Head of Numerical GTS2F400.15129
C Modelling at the above address. GTS2F400.15130
C ******************************COPYRIGHT****************************** GTS2F400.15131
C GTS2F400.15132
! COPYODL1.3
! Subroutine Interface: COPYODL1.4
SUBROUTINE COPYODIAGL(NX,NY,KM,STDVMD,VMD,DATA,OCEAN,STASHWORK) 9,1COPYODL1.5
COPYODL1.6
IMPLICIT NONE COPYODL1.7
! COPYODL1.8
! Description: COPYODL1.9
! COPYODL1.10
! COPYODIAGL copies the data from the input 2D or 3D DATA array to COPYODL1.11
! the 1D STASHWORK array, in which they are arranged in the normal COPYODL1.12
! Fortran order. It imposes a missing-data mask according to the COPYODL1.13
! logical OCEAN mask array, which has the same dimensions as COPYODL1.14
! DATA. Elements which are .FALSE. in the mask result in missing data COPYODL1.15
! in STASHWORK. If the ocean is cyclic, it is assumed that the last COPYODL1.16
! two columns of DATA (NX-1:NX) are wrap-round columns, which are not COPYODL1.17
! copied to STASHWORK. If STDVMD is .TRUE., missing data is indicated COPYODL1.18
! by the standard missing data value. If STDVMD is .FALSE., the value COPYODL1.19
! of VMD is inserted at missing-data points. COPYODL1.20
! COPYODL1.21
! To copy data of one level, call with KM=1. COPYODL1.22
! COPYODL1.23
! The ...L suffix of the subroutine name indicates that the data is COPYODL1.24
! being masked with a LOGICAL mask. The corresponding routine which COPYODL1.25
! masks with a number-of-levels array is called COPYODIAGN. A routine COPYODL1.26
! which copied without masking at all would be called COPYODIAG. COPYODL1.27
! COPYODL1.28
! Current Code Owner: J.M.Gregory COPYODL1.29
! COPYODL1.30
! History: COPYODL1.31
! Version Date Comment COPYODL1.32
! ------- ---- ------- COPYODL1.33
! 4.0 23.3.95 Original code. J.M.Gregory COPYODL1.34
! 4.3 29.04.97 Ensure incoming data has halos populated ORH5F403.234
! in MPP systems in case of temporal processing ORH5F403.235
! which requires halo info. R. Hill ORH5F403.236
! COPYODL1.35
! Code Description: COPYODL1.36
! Language: FORTRAN 77 + common extensions. COPYODL1.37
! This code is written to UMDP3 v6 programming standards. COPYODL1.38
! COPYODL1.39
! System component covered: <appropriate code> COPYODL1.40
! System Task: <appropriate code> COPYODL1.41
! COPYODL1.42
! Global variables COPYODL1.43
*CALL C_MDI
COPYODL1.44
*CALL CNTLOCN
COPYODL1.45
*CALL COCNINDX
ORH5F403.237
COPYODL1.46
! Input arguments COPYODL1.47
INTEGER COPYODL1.48
& NX ! 1st dimension of DATA, including wrap-round columns COPYODL1.49
&,NY ! 2nd dimension of DATA COPYODL1.50
&,KM ! 3rd dimension of DATA = no. of levels COPYODL1.51
COPYODL1.52
LOGICAL COPYODL1.53
& STDVMD ! Use standard value to indicate missing data COPYODL1.54
&,OCEAN(NX,NY,KM) ! Ocean mask, .TRUE. where data is wanted COPYODL1.55
COPYODL1.56
REAL COPYODL1.57
& VMD ! Missing data value; ignored if .NOT.STDVMD COPYODL1.58
&,DATA(NX,NY,KM) ! Input data COPYODL1.59
COPYODL1.60
! Output arguments COPYODL1.61
REAL COPYODL1.62
& STASHWORK(*) ! Output stashwork array COPYODL1.63
COPYODL1.64
! Local variables COPYODL1.65
INTEGER COPYODL1.66
& ICOL ! Number of columns of data, excluding wrap-round COPYODL1.67
&,I,J,K ! Indices into DATA and OCEAN COPYODL1.68
&,IPOINT ! Index into STASHWORK COPYODL1.69
COPYODL1.70
REAL COPYODL1.71
& TVMD ! Missing data value to be used COPYODL1.72
COPYODL1.73
!- End of header COPYODL1.74
COPYODL1.75
C Work out how many columns of data there are to be copied. COPYODL1.76
IF (.NOT.L_OCYCLIC) THEN COPYODL1.77
ICOL=NX COPYODL1.78
ELSE COPYODL1.79
ICOL=NX-2 COPYODL1.80
ENDIF COPYODL1.81
COPYODL1.82
*IF DEF,MPP ORH5F403.238
CALL SWAPBOUNDS
(DATA,NX,NY,O_EW_HALO,O_NS_HALO,KM) ORH5F403.239
*ENDIF ORH5F403.240
C Decide on the value of missing data. COPYODL1.83
IF (STDVMD) THEN COPYODL1.84
TVMD=RMDI COPYODL1.85
ELSE COPYODL1.86
TVMD=VMD COPYODL1.87
ENDIF COPYODL1.88
COPYODL1.89
C Loop over data to be copied. Copy wanted data to STASHWORK and COPYODL1.90
C substitute TVMD for unwanted elements. COPYODL1.91
IPOINT=1 COPYODL1.92
DO K=1,KM COPYODL1.93
DO J=1,NY COPYODL1.94
DO I=1,ICOL COPYODL1.95
IF (OCEAN(I,J,K)) THEN COPYODL1.96
STASHWORK(IPOINT)=DATA(I,J,K) COPYODL1.97
ELSE COPYODL1.98
STASHWORK(IPOINT)=TVMD COPYODL1.99
ENDIF COPYODL1.100
IPOINT=IPOINT+1 COPYODL1.101
ENDDO COPYODL1.102
ENDDO COPYODL1.103
ENDDO COPYODL1.104
COPYODL1.105
RETURN COPYODL1.106
END COPYODL1.107
*ENDIF ORH0F404.140