1C Copyright 1981-2016 ECMWF.
2C
3C This software is licensed under the terms of the Apache Licence
4C Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5C
6C In applying this licence, ECMWF does not waive the privileges and immunities
7C granted to it by virtue of its status as an intergovernmental organisation
8C nor does it submit to any jurisdiction.
9C
10
11      INTEGER FUNCTION ZPREC (POFELD, KOWE, KONS, KPR, KERR)
12C
13C---->
14C**** *ZPREC*
15C
16C     PURPOSE
17C     _______
18C
19C     Perform additional interpolation processes for precipitation
20C     fields
21C
22C     INTERFACE
23C     _________
24C
25C     IERR = ZPREC ( POFELD, KOWE, KONS, KPR, KERR)
26C
27C     Input parameters
28C     ________________
29C
30C     POFELD     - The output field as previously calculated.
31C
32C     KOWE       - The number of points in the West-East direction in
33C                  the output field.
34C
35C     KONS       - The number of points in the North-South direction
36C                  in the output field.
37C
38C     KPR        - The debug print switch.
39C                  0  , No debugging output.
40C                  1  , Produce debugging output.
41C
42C     KERR       - The error control flag.
43C                  -ve, No error message. Return error code.
44C                  0  , Hard failure with error message.
45C                  +ve, Print error message. Return error code.
46C
47C     Output parameters
48C     ________________
49C
50C     POFELD     - The output field as modified to allow for
51C                  precipitation.
52C
53C     Return value
54C     ____________
55C
56C     The error indicator (INTEGER).
57C
58C     Error and Warning Return Values
59C     _______________________________
60C
61C     None
62C
63C     Common block usage
64C     __________________
65C
66C     None
67C
68C     EXTERNALS
69C     _________
70C
71C     INTLOG(R)    - Logs messages.
72C     CHKPREC - Check if precipitation threshold has been redefined
73C
74C     METHOD
75C     ______
76C
77C     The precipitation at a point is set to zero if the value is less
78C     then threshold
79C
80C     REFERENCE
81C     _________
82C
83C     None
84C
85C     COMMENTS
86C     ________
87C
88C     Program contains sections 0 to 3
89C
90C     AUTHOR
91C     ______
92C
93C     S. Curic      *ECMWF*      Sep 2005
94C
95C     MODIFICATIONS
96C     _____________
97C
98C     None
99C
100C----<
101C     _______________________________________________________
102C
103C
104C*    Section 0. Definition of variables.
105C     _______________________________________________________
106C
107C*    Prefix conventions for variable names
108C
109C     Logical      L (but not LP), global or common.
110C                  O, dummy argument
111C                  G, local variable
112C                  LP, parameter.
113C     Character    C, global or common.
114C                  H, dummy argument
115C                  Y (but not YP), local variable
116C                  YP, parameter.
117C     Integer      M and N, global or common.
118C                  K, dummy argument
119C                  I, local variable
120C                  J (but not JP), loop control
121C                  JP, parameter.
122C     REAL         A to F and Q to X, global or common.
123C                  P (but not PP), dummy argument
124C                  Z, local variable
125C                  PP, parameter.
126C
127C     Implicit statement to force declarations
128C
129      IMPLICIT NONE
130C
131#include "parim.h"
132#include "nifld.common"
133C
134C     Dummy arguments
135      INTEGER KOWE, KONS, KPR, KERR
136      REAL POFELD (KOWE, KONS)
137C
138C     Local variables
139      INTEGER JOLAT, JOLON
140      INTEGER JPROUTINE
141      PARAMETER (JPROUTINE = 23500)
142C
143C     _______________________________________________________
144C
145C*    Section 1. Initialisation
146C     _______________________________________________________
147C
148      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'ZPREC: Section 1.',JPQUIET)
149C
150      ZPREC = 0
151C
152      IF (KPR .GE. 1) THEN
153        CALL INTLOG(JP_DEBUG,'ZPREC: No. of output fld lats = ',KONS)
154        CALL INTLOG(JP_DEBUG,'ZPREC: No. of output fld longs = ',KOWE)
155      ENDIF
156C
157C     _______________________________________________________
158C
159C*    Section 2. eliminate output negative  precipitation
160C     _______________________________________________________
161C
162      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IRPREC: Section 2.',JPQUIET)
163C
164       CALL CHKPREC()
165C
166      DO 360 JOLAT = 1, KONS
167C
168         DO 210 JOLON = 1, KOWE
169C
170            IF (POFELD (JOLON, JOLAT) .LT. ZPRECIP) THEN
171               POFELD (JOLON, JOLAT) = PPZERO
172            ENDIF
173C
174  210    CONTINUE
175C
176C
177  360 CONTINUE
178C
179C     _______________________________________________________
180C
181C
182C*    Section 3. Return to calling routine. Format statements
183C     _______________________________________________________
184C
185C
186      IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'ZPREC: Section 3.',JPQUIET)
187C
188      RETURN
189      END
190