CALL SEQUENCE... gsapl GSFLD GSLNSP GPFLD GSPRES INPUT OUTPUT \ [ -plv VAL1 -a VAL2 -b VAL3 -c VAL4 -d VAL5 -i VAL6 \ -kind VAL8 -def [AABB][DEFLEVS][FREEFMT] ] DESCRIPTION... gsapl - INTERPOLATE SIGMA/HYBRID/GAL-CHEN/GEM LEVELS TO PRESSURE LEVELS AUTHOR - R. Laprise, FEB 29/88. LAST REVISION: $Header: Correction-au-mode-DEFLEVS-et-autres-trucs-divers @ 2019-04-15 09:48:36 -0400 (dugas) $ PURPOSE - INTERPOLATES FROM ETA (SIGMA/HYBRID/GAL-CHEN/GEM) LEVELS TO NPL PRESSURE LEVELS. THE INTERPOLATION IS LINEAR IN LN(ETA). ANY EXTRAPOLATION UP AND DOWN IS BY LAPSE RATES SPECIFIED BY THE USER. INPUT FILES... GSFLD = SETS OF ETA (SIGMA/HYBRID/GAL-CHEN/GEM) LEVEL GRID DATA GSLNSP = SERIES OF GRIDS OF LN(SF PRES) (see note 2) on units) (the variable's name should be 'LP' or 'LNSP') GSPRES = SETS OF LN(PRESSURE) (EXCLUSIVELY FOR GAL-CHEN LEVELS) OUTPUT FILE... GPFLD = SETS OF PRESSURE LEVEL GRID DATA INPUT PARAMETERS... NPL (plv) = NUMBER OF REQUESTED PRESSURE LEVELS (DEF 16, MAX 999). IF NPL IS NEGATIVE, EACH -NPL LEVP VALUES ARE READ WITH EITHER A I10 FORMAT OR AN E10.0 DEPENDING ON WETHER ANY OF THESE VALUES CONTAINS A DECIMAL POINT. INTEGER VALUES ARE THEN ASSUMED TO BE ENCODED. RLUP (a) = LAPSE RATE USED TO EXTRAPOLATE UPWARDS (DEF 0.0). RLDN (b) = LAPSE RATE USED TO EXTRAPOLATE DOWNWARDS (DEF 0.0). COORD (kind) = 'SIG','ETA','GALC' OR 'GEM'/'GEM2'/'GEM3'/'GEM4' FOR SIGMA, ETA, GAL-CHEN AND FOUR VARIANTS OF THE GEM VERTICAL COORDINATES, RESPECTIVELY. THE FILE CONTENTS IS USED TO DETERMINE THE RPN DEFAULTS ('GEM2','GEM3' OR 'GEM4'). PTOIT (c) = PRESSURE (PA) AT THE LID OF MODEL. THIS PARAMETER IS NOT USED WITH THE GAL-CHEN INPUT LEVELS. THE DEFAULT VALUE DEPENDS ON COORD: 1000. FOR GEM AND 0.01 OTHERWISE. PREF (d) = REF PRESSURE USED WHEN COORD='GEM2' OR 'GEM3' (DEF 80000 PA). Note that for COORD='GEM4', PREF is always set to 100000 PA. R (i) = EXPONENT USED ONLY WHEN COORD='GEM2','GEM3' OR 'GEM4' (DEF 1.0) R2 (i2) = EXPONENT USED ONLY WHEN COORD='GEM4' (DEF 1.0) LEVP = MONOTONIC PRESSURE LEVELS (MB) (READ FROM STANDARD INPUT). THE DEFAULTS ARE AS SPECIFIED IN THE EXAMPLE BELOW. Notes: 1) Units for RLUP and RLDN are that of D(GSFLD)/D(LN PRES) 2) Units for GSLNSP and GSPRES should be consistent. The GAL-CHEN routines expect Pascal, while the routines for the other vertical coordinates expect hPa (MB). 3) RLUP and RLDN are ignored when COORD='GEM','GEM2' or 'GEM3'. 4) The first input line is NOT read if any command-line parameters are passed. 5) Furthermore, the second set of lines will not be read either if the "-def" defaults processing mode is requested without a value. However, if an 'AABB' value is set (see notes #8 for more details), a 'DEFLEVS' character sequence must also be added to activate this option, as in "-def AABB/DEFLEVS". 6) 'GEM' is the original gem coordinate, while 'GEM2' is the original hybrid coordinate as implemented by Edouard & Gravel in GEM/DM v2.2.0. 'GEM3' is the normalized version that was implemented in the v2.3.1 GEM/DM. 'GEM4' is the staggered hybrid coordinate version of GEM/DM from v4.0.6. 7) The default value of COORD is determined by the file type and the program will also try to determine it by the (internal) coding used for the coordinate itself. 8) Specifying "-def AABB" will force the attempt to read a text file called aabb.nml, containing a FORTRAN namelist AABB_NML, which in turns will hold two arrays, A and B such that the local pressure at level K, PL(K), can be calculated as "A(K)+B(K)*PS" for most coordinates. For 'GEM4', the corresponding formula to calculate the K-level natural logaritm of the local pressure is rather "A(K)+B(K)*LN(PS/PREF)". The A and B terms should be such as to produce local pressures in Pa units, even though PS is usually read in units of hPa (before being converted to Pa units internally). In all cases, this approach then by-passes the normal COORD-related calculations for PL(K). ************* Given the above, correctly using the AABB option with a GEM4 file requires specifying the "-kind GEM4" argument. ************* 9) Specifying "-def FREEFMT" indicates that the output pressure levels should read with a list-directed free format. This is obviously not the default behaviour. Pressure values should then only be separated by spaces or comas, and spread over one or more lines. These numbers are then always assumed to be the actual real pressure values, and not their possibly encoded integer values.Turning on the "FREE_FORMAT_LEVEL_IO" environment variable will also activate this behaviour. READ( 5,5010 ) NPL,RLUP,RLDN,COORD,PTOIT,PREF,R,R2 IF (FREEFMT) READ( 5,* ) ( PR(I),I=1,ABS(NPL)) ELSEIF (NPL > 0) READ( 5,5020 ) (LEVP(I),I=1, NPL) ELSEIF (NPL < 0) READ( 5,5030 ) (LEVP(I),I=1, -NPL) 5010 FORMAT(10X,I5,2E10.0,1X,A4,4E10.0) 5020 FORMAT(16I5) 5030 FORMAT(8E10.0) EXAMPLE OF INPUT CARDS (with format 5010 & 5020)... GSAPL. 16 0. 0. GEM 1000. 10 20 30 50 70 100 150 200 250 300 400 500 700 850 925 1000 01234567890123456789012345678901234567890123456789012345678901234567890 1 2 3 4 5 6 7 EXIT CONDITIONS... 0 NO PROBLEMS 1 NUMBER PRESSURE LEVELS GREATER THAN MAXLEV 2 PRESSURE OR MODEL VERT COORDINATE NOT MONOTONIC 3 ERROR READING FIRST SET IN GSLNSP 4 ERROR READING FIRST SET IN GSFLD 5 GSFLD, GSLNSP NOT THE SAME SIZE 6 ERROR UNPACKING FIRST SET IN GSFLD 7 MORE THAN ONE SIZE IN GSFLD 8 MISSING GSLNSP FIELD 9 ERROR ABORT READING INPUT CARD 1 10 ERROR ABORT READING OUTPUT LEVELS 11 ERROR READING FIRST SET IN GSPRES 12 GSFLD, GSPRES NOT THE SAME SIZE 13 MISSING GSPRES SET 14 MORE THAN ONE SIZE IN GSPRES 15 PTOIT GREATER THAN TOP MODEL LEVEL (=ETA(TOP)*PREF) 16 UNSUPPORTED VERTICAL COORDINATE IN GSFLD 17 COORD PARAMETRE AND GSFLD DATA MISMATCH 18 UNABLE TO FIND A GEM4 '!!' RECORD 19 FOUND DATA NOT OF TYPE 'GRID' OR 'SUBA' 20 UNABLE TO READ AABB NAMELIST 21 MORE THAN ONE VERTICAL COORDINATE IN GSFLD 22 WRONG NUMBER OF A,B IN AABB 23 GAL-CHEN NOT supported in AABB mode 24 UNABLE TO ALLOCATE WORKING MEMORY 25 LEVP DOES NOT CONTAIN PRESSURE DATA 26 GSLNSP DOES NOT CONTAIN LN( SURFP ) FOR EARTH 27 UNRECOGNIZED -DEF ARGUMENT VALUE