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
|
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
SUBROUTINE JMAKGG( KUNIT, KTRUNC, KROW, PLAT, PLEG, KRET)
C
C---->
C**** JMAKGG
C
C PURPOSE
C _______
C
C This routine creates legendre functions for latitude rows upto
C the given latitude in a gaussian grid file.
C
C INTERFACE
C _________
C
C CALL JMAKGG( KUNIT, KTRUNC, KROW, PLAT, PLEG, KRET)
C
C Input parameters
C ________________
C
C KUNIT - Unit number for open file of legendre functions.
C KTRUNC - Truncation.
C KROW - Latitude row number in the file
C PLAT - Array of latitudes for the gaussian grid
C
C Output parameters
C ________________
C
C PLEG - Array of legendre functions for the latitude.
C KRET - Return status code
C 0 = OK
C
C Common block usage
C __________________
C
C None.
C
C Method
C ______
C
C Determine which functions already exist for the latitude rows
C in the file, skip to the end and create necessary extra functions
C and add to the file.
C
C Externals
C _________
C
C PBSEEK - Position the coefficients file
C PBWRITE - Write the coefficients file
C INTLOG - Output log message
C
C Reference
C _________
C
C None.
C
C Comments
C ________
C
C Only positive row numbers are allowed.
C
C AUTHOR
C ______
C
C J.D.Chambers *ECMWF* Jan 1994
C
C MODIFICATIONS
C _____________
C
C None.
C
C----<
C _______________________________________________________
C
C
C* Section 0. Definition of variables.
C _______________________________________________________
C
C* Prefix conventions for variable names
C
C Logical L (but not LP), global or common.
C O, dummy argument
C G, local variable
C LP, parameter.
C Character C, global or common.
C H, dummy argument
C Y (but not YP), local variable
C YP, parameter.
C Integer M and N, global or common.
C K, dummy argument
C I, local variable
C J (but not JP), loop control
C JP, parameter.
C REAL A to F and Q to X, global or common.
C P (but not PP), dummy argument
C Z, local variable
C PP, parameter.
C
IMPLICIT NONE
#include "jparams.h"
#include "parim.h"
C
C Parameters
INTEGER JPROUTINE
PARAMETER ( JPROUTINE = 30400 )
C
C Subroutine arguments
INTEGER KUNIT, KTRUNC, KROW, KRET
REAL PLAT, PLEG
DIMENSION PLAT(*)
DIMENSION PLEG(*)
C
C Local variables
INTEGER NEWPOS, NSIZE, NRET, NROWCT, NLATIT
REAL ALAT, PIBY2, DEG2RAD
C
C _______________________________________________________
C
C* Section 1. Initialization.
C _______________________________________________________
C
100 CONTINUE
IF ( KROW .LT. 0.0 ) THEN
KRET = JPROUTINE + 1
CALL INTLOG(JP_ERROR,'JMAKGG - negative row number given',KROW)
GOTO 990
ENDIF
C
C Calculate the byte offset into the file where the legendre
C functions for the latitude should be.
#ifdef REAL_8
NSIZE = 8 * (KTRUNC+1)*(KTRUNC+4)/2
#else
NSIZE = 4 * (KTRUNC+1)*(KTRUNC+4)/2
#endif
NEWPOS = (KROW - 1) * NSIZE
C
C Find the current file length
CALL PBSEEK( KUNIT, 0, 2, NRET)
IF ( NRET .LT. 0 ) THEN
CALL INTLOG(JP_ERROR,'JMAKGG - PBSEEK error', NRET)
KRET = JPROUTINE + 2
GOTO 990
ENDIF
C
C Use the length to determine how many rows have already been
C put into the file
NROWCT = NRET/NSIZE
C
C _______________________________________________________
C
C* Section 2. Processing.
C _______________________________________________________
C
C Loop through latitudes not in the file yet
PIBY2 = PPI / 2.0
DEG2RAD = PPI / 180.0
C
DO 210 NLATIT = NROWCT+1, KROW
ALAT = PLAT(NLATIT) * DEG2RAD
CALL JSPLEG1( PLEG, ALAT, KTRUNC)
CALL PBWRITE( KUNIT, PLEG, NSIZE, NRET)
IF ( NRET .LT. NSIZE ) THEN
CALL INTLOG(JP_ERROR,'JMAKGG - PBWRITE error.', NRET)
CALL INTLOG(JP_ERROR,'JMAKGG - bytes required = ', NSIZE)
KRET = JPROUTINE + 3
GOTO 990
ENDIF
210 CONTINUE
C _______________________________________________________
C
C* Section 9. Return to calling routine. Format statements
C _______________________________________________________
C
900 CONTINUE
KRET = 0
C
990 CONTINUE
RETURN
END
|