CALL SEQUENCE... gsapzl GSPHI GSPHIS GSLNSP GPPHI GPTEMP INPUT OUTPUT \ [ -plv VAL1 -a VAL2 -b VAL3 -c VAL4 \ -d VAL5 -i VAL6 -kind VAL7 \ -def [AABB][DEFLEVS][FREEFMT] ] DESCRIPTION... gsapzl - CALCULATES T & PHI ON PRESSURE LEVELS FROM PHI ON ETA (SIGMA/HYBRID) 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 - CALCULATES T AND PHI ON PRESSURE LEVELS FROM "PHI" OR "TEMP" ON MODEL LEVELS. NOTES A) THE FOLLOWINGS ARE THE NECESSARY STEPS TO BE TAKEN IF TEMP IS USED INSTEAD OF PHI AS INPUT AND COORD IS 'SIG' OR 'ETA': 1) INPUT FILE... GETEMP, INSTEAD OF GSPHI. 2) READ-IN LAYERING PARAMETER LAY. 3) FILEV RETURNS SH, TEMPERATURE MID LAYER POSITION, 4) BASCAL COMPUTES SHB (LAYER BASES) FROM SH AND LAY. 5) COORDAB COMPUTES PARAMETERS A AND B (ETA COORD) FROM SHB. 6) MODIFY ETAPHI TO EXTRAPOLATE UPWARD USING UPPERMOST TEMPERATURE. B) If COORD is any type of GEM coordinates, the procedure should receive virtual temperatures, but will still continue if it receives temperatures. INPUT FILES... GSPHI = IF COORD = 'SIG'/'ETA', SETS OF "PHI" ON MODEL LEVELS, DEFINED AS "PHI"=PHIS + INT(R*T*D LN ETA) IN PAKGCMH IF COORD = 'GEM?", SETS OF 'VT' or 'TT' ON MODEL LEVELS. GSPHIS = MOUNTAINS (SURFACE GEOPOTENTIAL). The variables's name should be 'PHIS','MT' (in gm) or 'ME' (in m) GSLNSP = SET OF LN(SURFACE PRESSURE). The variable's name should be 'LP' or 'LNSP', with units in hPa. OUTPUT FILES... GPPHI = PRESSURE LEVEL GEOPOTENTIALS. GPTEMP = PRESSURE LEVEL TEMPERATURES. INPUT PARAMETERS... NPL (plv) = NUMBER OF 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) = DT/D LN(P) FOR TEMP EXTRAP UPWARDS (DEF=0.0) GAMMA (b) = DT/D LN(P) FOR TEMP,PHI EXTRAP DOWNWARD (DEF=6.5E-3) PTOIT (c) = PRESSURE (PA) OF LID AT TOP OF MODEL. COORD (kind) = 'SIG'/'ETA' OR 'GEM'/'GEM2'/'GEM3'/'GEM4' FOR SIGMA, ETA AND FOUR VARIANTS OF THE GEM VERTICAL COORDINATES, RESPECTIVELY. THE FILE CONTENTS IS USED TO DETERMINE THE RPN DEFAULTS ('GEM2','GEM3' OR 'GEM4'). 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) LP = MONOTONIC PRESSURE LEVELS (MB) (READ FROM STANDARD INPUT). THE DEFAULTS ARE AS SPECIFIED IN THE EXAMPLE BELOW. Notes: 1) Units for RLUP are that of D(GSPHI)/D(LN PRES) 2) RLUP is ignored when COORD='GEM','GEM2' or 'GEM3' 3) The first input line is NOT read if any command-line parameters are passed. 4) 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 #7 for more details), a 'DEFLEVS' character sequence must also be added to activate this option, as in "-def AABB/DEFLEVS". 5) '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. 6) 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. 7) 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. ************* 8) 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,GAMMA,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)... GSAPZL. 16 0. 6.5E-3 ETA pression_au_toit 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 OF PRESSURE LEVELS GREATER THAN MAXLEV 2 PRESSURE OR MODEL LEVELS NOT MONOTONIC/INCREASING 3 ERROR READING FIRST SET IN GSLNSP 4 ERROR READING SURFACE GEOPOTENTIAL 5 ERROR READING FIRST SET IN GSPHI 6 GSPHI,GSPHIS,GSLNSP NOT THE SAME HORIZONTAL SIZE 7 FOUND NAME OTHER THAN PHI OR GZ IN GSPHI 8 MORE THAN ONE VERTICAL SIZE IN GSPHI 9 MISSING GSLNSP RECORD 10 ERROR ABORT READING INPUT CARD 1 11 ERROR ABORT READING OUTPUT LEVELS 12 GSPHI/GSPHIS/GSLNSP NAME PROBLEM 13 LP DOES NOT CONTAIN PRESSURE DATA 14 PTOIT GREATER THAN TOP MODEL LEVEL (=ETA(TOP)*PREF) 15 UNABLE TO ALLOCATE WORKING MEMORY 16 UNSUPPORTED VERTICAL COORDINATE IN GSPHI 17 COORD PARAMETRE AND GSPHI DATA MISMATCH 18 UNABLE TO FIND A GEM4 '!!' RECORD 20 UNABLE TO READ AABB NAMELIST 21 WRONG NUMBER OF AG,BG IN AABB 22 MORE THAN ONE VERTICAL COORDINATE IN GSPHI 23 MORE THAN ONE SIZE IN GSLNSP 24 GSLNSP DOES NOT CONTAIN LN( SURFP ) FOR EARTH 25 UNRECOGNIZED -DEF ARGUMENT VALUE