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 IGGRID (KGTRUNC, KAREA, KLN, PGAUSS, KLONG, 12 1 KNWE, KLATG, KNNS, OWEGLOBE, KPR, KERR) 13C 14C----> 15C**** *IGGRID* 16C 17C PURPOSE 18C _______ 19C 20C Generate the arrays of latitude and longitude points for a 21C Gaussian truncation and area. 22C 23C INTERFACE 24C _________ 25C 26C IERR = IGGRID (KGTRUNC, KAREA, KLN, PGAUSS, KLONG, KNWE, KLATG, 27C 1 KNNS, OWEGLOBE, KPR, KERR) 28C 29C Input parameters 30C ________________ 31C 32C KGTRUNC - The Gaussian truncation. 33C 34C KAREA - The area definition (N, W, S, E) provided by the 35C calling routine. 36C 37C KLN - The Northern Gaussian latitude number for this area. 38C 39C PGAUSS - The full list of Gaussian latitudes for this 40C truncation. 41C 42C KNWE - The number of points in the West-East direction in 43C this field. 44C 45C KNNS - The number of points in the North-South direction 46C in this field. 47C 48C OWEGLOBE - This variable will be true if the array of 49C longitudes spans the globe and it is an input grid. 50C 51C KPR - The debug print switch. 52C 0 , No debugging output. 53C 1 , Produce debugging output. 54C 55C KERR - The error control flag. 56C -ve, No error message. Return error code. 57C 0 , Hard failure with error message. 58C +ve, Print error message. Return error code. 59C 60C Output parameters 61C ________________ 62C 63C KLONG - The array of longitudes for this Gaussian 64C truncation and area. If OWEGLOBE is true the 65C West-East field array has element KNWE + 1 set 66C equal to element 1 to help with recognising where 67C an output grid "wraps around" the break in the 68C input grid. 69C 70C KLATG - The array of latitudes for this Gaussian 71C truncation and area. 72C 73C Return value 74C ____________ 75C 76C The error indicator (INTEGER). 77C 78C Error and Warning Return Values 79C _______________________________ 80C 81C None 82C 83C Common block usage 84C __________________ 85C 86C None 87C 88C EXTERNALS 89C _________ 90C 91C INTLOG(R) - Logs messages. 92C 93C METHOD 94C ______ 95C 96C The arrays KLONG and KLATG are generated using the information 97C provided by the other parameters. Note that Gaussian latitudes 98C will be stored as NINT (PGAUSS * 1.0E4). 99C 100C REFERENCE 101C _________ 102C 103C None 104C 105C COMMENTS 106C ________ 107C 108C Program contains sections 0 to 3 and 9 109C 110C AUTHOR 111C ______ 112C 113C K. Fielding *ECMWF* Oct 1993 114C 115C MODIFICATIONS 116C _____________ 117C 118C None 119C 120C----< 121C _______________________________________________________ 122C 123C 124C* Section 0. Definition of variables. 125C _______________________________________________________ 126C 127C* Prefix conventions for variable names 128C 129C Logical L (but not LP), global or common. 130C O, dummy argument 131C G, local variable 132C LP, parameter. 133C Character C, global or common. 134C H, dummy argument 135C Y (but not YP), local variable 136C YP, parameter. 137C Integer M and N, global or common. 138C K, dummy argument 139C I, local variable 140C J (but not JP), loop control 141C JP, parameter. 142C REAL A to F and Q to X, global or common. 143C P (but not PP), dummy argument 144C Z, local variable 145C PP, parameter. 146C 147C Implicit statement to force declarations 148C 149 IMPLICIT NONE 150C 151#include "parim.h" 152C 153C Dummy arguments 154 LOGICAL OWEGLOBE 155 INTEGER KGTRUNC, KNWE, KNNS, KLN, KPR, KERR 156 INTEGER KAREA (4) 157 INTEGER KLONG (KNWE + 1), KLATG (KNNS) 158 REAL PGAUSS (*) 159C 160C Local variables 161C 162 INTEGER IEAST, IWEST 163 INTEGER JLONG, JLAT 164 REAL*8 RWEST, RKKK, RLNSTR 165 INTEGER JPROUTINE 166 PARAMETER (JPROUTINE = 24800) 167C 168C Function externals 169C 170C _______________________________________________________ 171C 172C* Section 1. Initialisation 173C _______________________________________________________ 174C 175 100 CONTINUE 176C 177 IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGGRID: Section 1.',JPQUIET) 178C 179 IGGRID = 0 180C 181 IF (KPR .GE. 1) THEN 182 CALL INTLOG(JP_DEBUG,'IGGRID: Input parameters.',JPQUIET) 183 CALL INTLOG(JP_DEBUG,'IGGRID: Northern Gaussian line is ',KLN) 184 CALL INTLOG(JP_DEBUG,'IGGRID: No.long.pts = ',KNWE) 185 CALL INTLOG(JP_DEBUG,'IGGRID: No.lat. pts = ',KNNS) 186 CALL INTLOG(JP_DEBUG,'IGGRID: Area North = ', KAREA(1)) 187 CALL INTLOG(JP_DEBUG,'IGGRID: Area West = ', KAREA(2)) 188 CALL INTLOG(JP_DEBUG,'IGGRID: Area South = ', KAREA(3)) 189 CALL INTLOG(JP_DEBUG,'IGGRID: Area East = ', KAREA(4)) 190 IF( OWEGLOBE ) THEN 191 CALL INTLOG(JP_DEBUG, 192 X 'IGGRID: Input W-E fld is global.',JPQUIET) 193 ELSE 194 CALL INTLOG(JP_DEBUG, 195 X 'IGGRID: Input W-E fld is NOT global.',JPQUIET) 196 ENDIF 197 ENDIF 198C 199 IF(KNWE.GT.0.AND.OWEGLOBE) THEN 200 RLNSTR = (REAL(JP360)*10000.0) / REAL(KNWE) 201 ELSE 202 RLNSTR = (REAL(JP90)*10000.0) / REAL(KGTRUNC) 203 ENDIF 204 205 IEAST = KAREA(JPEAST) 206 IWEST = KAREA(JPWEST) 207C 208C _______________________________________________________ 209C 210C* Section 2. Generate points around a line of latitude. 211C _______________________________________________________ 212C 213 200 CONTINUE 214C 215 IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGGRID: Section 2.',JPQUIET) 216C 217C Standardise range so that EAST > WEST 218C 219 IF (IEAST .LT. IWEST ) THEN 220C 221 IF (IEAST .LT. 0) THEN 222 IEAST = IEAST + JP360 223 ELSE 224 IWEST = IWEST - JP360 225 ENDIF 226C 227 ENDIF 228C 229 RWEST = REAL(IWEST)*10000.0 230C 231C Generate points in standardised range (0, jp360) 232C 233 DO 210 JLONG = 1, KNWE 234C 235 RKKK = RWEST + RLNSTR * (JLONG - 1) 236 KLONG (JLONG) = NINT(RKKK/10000.0) 237C 238 IF (KLONG (JLONG) .LT. 0) KLONG(JLONG) = KLONG(JLONG) + JP360 239C 240 210 CONTINUE 241C 242C Add first point to end of list if global 243C 244 IF (OWEGLOBE) KLONG(KNWE + 1) = KLONG (1) 245C 246C _______________________________________________________ 247C 248C* Section 3. Generate points along a line of meridian 249C _______________________________________________________ 250C 251 300 CONTINUE 252C 253 IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGGRID: Section 3.',JPQUIET) 254C 255 DO 320 JLAT = 1, KNNS 256C 257 KLATG (JLAT) = NINT (PGAUSS (JLAT + KLN - 1) * PPMULT) 258C 259 320 CONTINUE 260C 261C _______________________________________________________ 262C 263C* Section 9. Return to calling routine. Format statements 264C _______________________________________________________ 265C 266 900 CONTINUE 267C 268 IF (KPR.GE.1) CALL INTLOG(JP_DEBUG,'IGGRID: Section 9.',JPQUIET) 269C 270 RETURN 271 END 272