CALL SEQUENCE... gsathl GSFLD GSLNSP GSTEMP GTHFLD INPUT OUTPUT [ -na ] \ [ -n VAL1 -a VAL2 -b VAL3 -c VAL4 -kind VAL5 \ -d VAL6 -i VAL7 [VAL8] -def [AABB][DEFLEVS][FREEFMT] ] DESCRIPTION... gsathl - INTERPOLATES A FIELD FROM SIGMA/HYBRID OR PRESSURE LEVELS TO NTHL THETA (POTENTIAL TEMPERATURE) LEVELS AUTHOR - J. Koshyk, July 27/94. 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) OR PRESSURE LEVELS TO NTHL POTENTIAL TEMPERATURE (THETA) LEVELS. THE INTERPOLATION IS LINEAR IN LN(THETA). EXTRAPOLATION UP AND DOWN IS BY LAPSE RATES, DF/D(LN THETA) SPECIFIED BY THE USER. INPUT FILES... GSFLD = SETS OF ETA (SIGMA/HYBRID) OR PRESSURE LEVEL GRID DATA. GSLNSP = SERIES OF GRIDS OF LN(SF PRES IN MB) (IGNORED IF COORD='PRES') GSTEMP = SERIES OF GRIDS OF TEMPERATURE. OUTPUT FILE... GTHFLD = SETS OF THETA LEVEL GRID DATA. INPUT PARAMETERS... NTHL (n) = NUMBER OF REQUESTED THETA LEVELS (DEF 5, MAX 999). IF NTHL IS NEGATIVE, EACH -NTHL LEVTH 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, (D FLD/D LN(THETA)) USED TO EXTRAPOLATE UPWARDS, RLDN (b) = LAPSE RATE USED TO EXTRAPOLATE DOWNWARDS. The default value for both RLUP and RLDN is 0.0. COORD (kind) = 'SIG'/'ETA'/'ET10'/'ET15' FOR INPUT VERTICAL COORDINATES AND 'GEM2'/'GEM3'/'GEM4' FOR VARIANTS OF THE GEM VERTICAL COORDINATES 'PRES' FOR INPUT PRESSURE COORDINATES. PTOIT (c) = PRESSURE (PA) AT THE LID OF MODEL. PREF (d) = REF PRESSURE USED WHEN COORD='GEM2' OR 'GEM3' (DEF 80000 PA). R (i) = EXPONENT USED ONLY WHEN COORD='GEM2' OR 'GEM3' (DEF 1.0) R2 (i2) = Second reference exponent if COORD='GEM4' (DEF 1.0) LEVTH = THETA LEVELS (K) (MONOTONE DECREASING I.E. TOP OF ATMOSPHERE TO BOTTOM). THE DEFAULTS ARE AS SPECIFIED IN THE EXAMPLE BELOW. Notes: 1) The first input line is NOT read if any of its parametres are passed via the command line. 2) 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". 3) Specifying "-na' prevents the routine EATHL from aborting when it find a well-mixed theta layer. 4) RLUP and RLDN are ignored when COORD='GEM' or 'GEM2'. 5) GEM2 is the Original hybrid coordinate as implemented by Edouard & Gravel in GEM/DM v2.2.0. GEM3 is the normalized that was implemented in the v2.3.1 GEM/DM. GEM4 is the staggered hybrid 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) When COORD='GEM4' and the AABB option is selected, and if GSFLD is defined on momentum levels, a second pair of (AT,BT) namelist vectors will have to be provided for the calculation of the local pressures of the thermodynamic (GSTEMP) levels. The original (A,B) pair will be used to calculate the local pressures on dynamic GSFLD levels. 9) Specifying "-def FREEFMT" indicates that the output theta levels should read with a list-directed free format. This is obviously not the default behaviour. Theta 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 theta 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) NTHL,RLUP,RLDN,COORD,PTOIT,PREF,R,R2 IF (FREEFMT) READ( 5,* ) ( TH(I),I=1,ABS(NTHL)) ELSEIF (NTHL.GT.0) READ( 5,5020 ) (LEVTH(I),I=1, NTHL) IF (NTHL.LT.0) READ( 5,5030 ) (LEVTH(I),I=1, -NTHL) 5010 FORMAT(10X,I5,2E10.0,1X,A4,4E10.0) 5020 FORMAT(16E5.0) 5030 FORMAT(8E10.0) EXAMPLE OF INPUT CARDS (with format 5010 & 5020)... GSATHL. 5 0. 0. PRES 850. 700. 550. 400. 330. 0123456789012345678901234567890123456789012345678901234567890 1 2 3 4 5 6 7 EXIT CONDITIONS... 0 NO PROBLEMS 1 NUMBER OF THETA LEVELS GREATER THAN MAXLEV 2 THETA NOT MONOTONIC DECREASING 3 ERROR READING FIRST TEMPERATURE SET 4 ERROR READING FIRST FIELD IN GSLNSP 5 ERROR READING FIRST SET IN GSFLD 6 GSFLD,GSLNSP OR GSTEMP NOT THE SAME SIZE 7 MORE THAN ONE SIZE IN GSFLD 8 MISSING GSLNSP SET 9 MORE THAN ONE SIZE IN GSLNSP 10 MISSING GSTEMP SET 11 MORE THAN ONE SIZE IN GSTEMP 12 GSTEMP DOES NOT CONTAIN TEMPERATURES 13 EROR ABORT READING INPUT CARD 1 14 ERROR ABORT READING OUTPUT LEVELS 15 GSFLD AND GSTEMP VERT COORDINATE DIFFER 16 UNSUPPORTED VERTICAL COORDINATE IN GSTEMP 17 COORD PARAMETRE AND GSTEMP MISMATCH 18 UNABLE TO FIND A GEM4 '!!' RECORD 19 PTOIT GREATER THAN TOP MODEL LEVEL (=ETA(TOP)*PREF) 20 UNABLE TO READ AABB NAMELIST 21 MORE THAN ONE VERTICAL COORDINATE IN GSFLD 22 WRONG NUMBER OF A,B IN AABB 23 INCONSISTENT GSFLD AND GSTEMP VERTICAL LEVELS 24 GSFLD VERT COORDINATE NOT MONOTONIC 25 GSLNSP DOES NOT CONTAIN LN( SURFP ) FOR EARTH 26 UNABLE TO ALLOCATE WORKING MEMORY 27 FOUND UNSUPPORTED DATA TYPE 28 LEVTH DOES NOT CONTAIN THETA DATA 29 WRONG NUMBER OF AT,BT IN AABB 30 UNRECOGNIZED -DEF ARGUMENT VALUE