File: hsp2gg2.F

package info (click to toggle)
emoslib 000380%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 47,712 kB
  • ctags: 11,551
  • sloc: fortran: 89,643; ansic: 24,200; makefile: 370; sh: 355
file content (222 lines) | stat: -rwxr-xr-x 4,482 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
C Copyright 1981-2007 ECMWF
C 
C Licensed under the GNU Lesser General Public License which
C incorporates the terms and conditions of version 3 of the GNU
C General Public License.
C See LICENSE and gpl-3.0.txt for details.
C

      INTEGER FUNCTION HSP2GG2(KTRUNC,NS,EW,KGAUSS,KPTS,PLATS,KSIZE)
C
C---->
C**** HSP2GG2
C
C     Purpose
C     -------
C
C     This routine finds a suitable gaussian grid for a given
C     spectral truncation.
C
C
C     Interface
C     ---------
C
C     IRET = HSP2GG2(KTRUNC,KGAUSS,KPTS,KSIZE)
C
C
C     Input parameters
C     ----------------
C
C     KTRUNC - The spectral truncation
C
C
C     Output parameters
C     -----------------
C
C     KGAUSS - The gaussian number
C     KPTS   - Array giving number of points along each line of latitude
C              in the reduced gaussian grid (both hemispheres)
C     PLATS  - Array giving gaussian latitudes (both hemispheres)
C     KSIZE  - The number of points in the reduced gaussian grid
C
C     Returns 0 if all OK, otherwise there is an error.
C
C
C     Common block usage
C     ------------------
C
C     None
C
C
C     Method
C     ------
C
C     None
C
C
C     Externals
C     ---------
C
C     JGETGG - Reads the definition of a gaussian grid
C
C
C     Reference
C     ---------
C
C     None.
C
C
C     Comments
C     --------
C
C     None.
C
C
C     Author
C     ------
C
C     J.D.Chambers      ECMWF      February 2001
C
C
C     Modifications
C     -------------
C
C     S.Curic     ECMWF      March 2005
C     Added checking for a automatic trancation T255, T399, T799, T2047 
C     and corresponding gaussian grid.
C
C     S.Curic     ECMWF      April 2008
C     Added checking for a automatic trancation T1279
C     and corresponding gaussian grid.
C
C
C     S.Curic     ECMWF      Semptember 2009
C     Match T255 and T213 against N128 instead of N160
C     upon Alan Geer request
C
C----<
C     -----------------------------------------------------------------|
C*    Section 0. Definition of variables.
C     -----------------------------------------------------------------|
C
      IMPLICIT NONE
C
#include "parim.h"
C
C     Function arguments
C
      INTEGER KTRUNC, KGAUSS, KPTS(*), KSIZE
      REAL NS, EW, STEP
      REAL PLATS(*)
#include "jparams.h"
C
C     Local variables
C
      INTEGER LOOP, IRET
      LOGICAL LDEBUG
C
C
C     -----------------------------------------------------------------|
C     Section 1.  Initialise.
C     -----------------------------------------------------------------|
      STEP = MIN(ABS(NS),ABS(EW))
C
  100 CONTINUE
C
      HSP2GG2 = 0
c
      CALL JDEBUG()
      LDEBUG = ( NDBG.NE.0 )

C     2.5 and greater -> T63
C
      IF( STEP.GE.2.5 ) THEN
        KTRUNC = 63
        KGAUSS  = 48
        GOTO 890
      ENDIF
C
C     1.5 to 2.5      -> T106
C
      IF( STEP.GE.1.5 ) THEN
        KTRUNC = 106
        KGAUSS = 80
        GOTO 890
      ENDIF
C
C     0.6 to 1.5      -> T213
C
      IF( STEP.GE.0.6 ) THEN
        KTRUNC = 213
        KGAUSS  = 128
        GOTO 890
      ENDIF
C
C     0.4 to 0.6      -> T319
C
      IF( STEP.GE.0.4 ) THEN
        KTRUNC = 319
        KGAUSS  = 160
        GOTO 890
      ENDIF
C
C     0.3 to 0.4      -> T511
C
      IF( STEP.GE.0.3 ) THEN
        KTRUNC  = 511
        KGAUSS  = 256
        GOTO 890
      ENDIF
C
C     0.15 to 0.3      -> T799
C
      IF( STEP.GE.0.15 ) THEN
        KTRUNC  = 799
        KGAUSS  = 400
        GOTO 890
      ENDIF

C
C     0.09 to 0.15      -> T1279
C
      IF( STEP.GE.0.09 ) THEN
        KTRUNC  = 1279
        KGAUSS  = 640
        GOTO 890
      ENDIF
c
      KTRUNC  = 2047
      KGAUSS  = 1024
C
C     Get the reduced gaussian grid information and count the
C     number of points.
C
  890 CONTINUE
      CALL JGETGG(KGAUSS,'R',PLATS,KPTS,IRET)
      IF( IRET.NE.0 ) THEN
        CALL INTLOG(JP_ERROR,
     X    'HSP2GG2: JGETGG failed to get gaussian data',JPQUIET)
        HSP2GG2 = 2
        GOTO 900
      ENDIF
C
      KSIZE = 0
      DO LOOP = 1, KGAUSS*2
        KSIZE = KSIZE + KPTS(LOOP)
      ENDDO

      IF( LDEBUG ) THEN
          CALL INTLOG(JP_DEBUG,
     X    'HSP2GG2: Corresponding Spectral Truncation:',KTRUNC)
          CALL INTLOG(JP_DEBUG,
     X    'HSP2GG2: Corresponding Gaussian Number:',KGAUSS)
      ENDIF
C
C     -----------------------------------------------------------------|
C     Section 9.  Return.
C     -----------------------------------------------------------------|
C
  900 CONTINUE
C
      RETURN
      END