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 HNTFAP(INGRIB,INLEN)
12C
13C---->
14C**** HNTFAP
15C
16C     Purpose
17C     -------
18C
19C     Prepare to interpolate input field...
20C
21C
22C     Interface
23C     ---------
24C
25C     IRET = HNTFAP(INGRIB,INLEN)
26C
27C     Input
28C     -----
29C
30C     INGRIB - Input field (packed).
31C     INLEN  - Input field length (words).
32C
33C
34C     Output
35C     ------
36C
37C     Field unpacked values are in ZNFELDI, rotated if necessary.
38C
39C     Returns: 0, if OK. Otherwise, an error occured in interpolation.
40C
41C
42C     Method
43C     ------
44C
45C     Calls HNTFAPS to handle rotation when input and output fields
46C     are both spectral.
47C
48C     Calls HNTFAPH in all other cases.
49C
50C
51C     Externals
52C     ---------
53C
54C     HNTFAPS - Handle rotation when input and output fields
55C               are both spectral.
56C     HNTFAPH - Handle rotation in all other cases.
57C
58C
59C     Author
60C     ------
61C
62C     J.D.Chambers     ECMWF     January 31, 2001
63C
64C
65C----<
66C
67C     -----------------------------------------------------------------|
68C*    Section 0.   Variables
69C     -----------------------------------------------------------------|
70C
71      IMPLICIT NONE
72C
73#include "parim.h"
74#include "nifld.common"
75#include "nofld.common"
76#include "grfixed.h"
77#include "intf.h"
78C
79C     Parameters
80C
81      INTEGER JPROUTINE
82      PARAMETER (JPROUTINE = 40100 )
83C
84C     Function arguments
85C
86      INTEGER INGRIB(*),INLEN
87C
88C     Local variables
89C
90      INTEGER IRET
91C
92C     Externals
93C
94      INTEGER  HNTFAPS, HNTFAPH
95      EXTERNAL HNTFAPS, HNTFAPH
96C
97C     -----------------------------------------------------------------|
98C*    Section 1.   Initialise
99C     -----------------------------------------------------------------|
100C
101  100 CONTINUE
102C
103      HNTFAP = 0
104C
105C     -----------------------------------------------------------------|
106C*    Section 2.   Split handling in case there are rotations to do.
107C     -----------------------------------------------------------------|
108C
109  200 CONTINUE
110C
111C     Is the interpolation from SH to SH?
112C
113      IF( ((NIREPR.EQ.JPSPHERE).OR.(NIREPR.EQ.JPSPHROT)) .AND.
114     X    ((NOREPR.EQ.JPSPHERE).OR.(NOREPR.EQ.JPSPHROT)) ) THEN
115C
116        IRET = HNTFAPS(INGRIB,INLEN)
117C
118      ELSE
119C
120        IRET = HNTFAPH(INGRIB,INLEN)
121C
122      ENDIF
123C
124      IF( IRET.NE.0 ) HNTFAP = JPROUTINE
125C
126C     -----------------------------------------------------------------|
127C*    Section 9.   Closedown.
128C     -----------------------------------------------------------------|
129C
130  900 CONTINUE
131C
132      RETURN
133      END
134