1# Copyright 2005-2018 ECMWF. 2# 3# This software is licensed under the terms of the Apache Licence Version 2.0 4# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5# 6# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by 7# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. 8# 9 10 11constant P_INST = 0; 12constant P_TAVG = 1; 13constant P_TACC = 3; 14 15constant TYPE_AN = 2; 16constant TYPE_FC = 9; 17constant TYPE_CF = 10; 18constant TYPE_PF = 11; 19constant TYPE_FF = 25; 20constant TYPE_OF = 26; 21constant TYPE_OR = 70; 22constant TYPE_FX = 71; 23 24constant coordAveraging0 = "inst"; 25constant coordAveraging1 = "tavg"; 26constant coordAveraging2 = 2; 27constant coordAveraging3 = "tacc"; 28constant coordAveragingTims = "tims"; 29 30constant isectionNumber2 = "h"; 31constant isectionNumber3 = "m"; 32constant isectionNumber4 = "z"; 33 34 35constant tsectionNumber3 = "v"; 36constant tsectionNumber4 = "z"; 37constant tsectionNumber5 = "m"; 38 39constant GRIB_DEPTH = 2; 40constant GRIB_LONGITUDE = 3; 41constant GRIB_LATITUDE = 4; 42 43meta verificationDate g1verificationdate(dataDate, dataTime, endStep) : read_only; 44 45 46if(horizontalCoordinateDefinition == 0) 47 { 48 49 if(coordinate1Flag == 1 ) 50 { 51 52# range 53 54 55 if(averaging1Flag == P_TAVG ){ 56 if( 57 marsType == TYPE_OR 58 || marsType == TYPE_FC 59 || marsType == TYPE_FF 60 || marsType == TYPE_FX 61 ) 62 { 63 meta marsRange evaluate((coordinate1End - coordinate1Start)/3600); 64 alias mars.range = marsRange; 65 } 66 } 67# section 68 69 if(coordinate2Flag == 2) { alias mars.section = isectionNumber2;} 70 if(coordinate2Flag == 3) { alias mars.section = isectionNumber3;} 71 if(coordinate2Flag == 4) { alias mars.section = isectionNumber4;} 72 73# levelist latitude longitude 74 75 if(coordinate2Flag == GRIB_DEPTH){ 76 meta marsLevelist divdouble( coordinate2Start,1000 ); 77 meta roundedMarsLevelist round( marsLevelist ,1000); 78 alias mars.levelist = roundedMarsLevelist ; 79 80 } 81 if(coordinate2Flag == GRIB_LONGITUDE){ 82 meta marsLongitude divdouble( coordinate2Start,1000000 ); 83 meta roundedMarsLongitude round( marsLongitude ,1000); 84 alias mars.longitude = roundedMarsLongitude ; 85 } 86 87 if(coordinate2Flag == GRIB_LATITUDE){ 88 meta marsLatitude divdouble( coordinate2Start,1000000 ); 89 90 meta roundedMarsLatitude round( marsLatitude ,1000); 91 alias mars.latitude = roundedMarsLatitude ; 92 } 93 94 95#product 96 if(averaging1Flag == 0) { alias mars.product = coordAveraging0;} 97 if(averaging1Flag == 1) { alias mars.product = coordAveraging1;} 98 if(averaging1Flag == 2) { alias mars.product = coordAveraging2;} 99 if(averaging1Flag == 3) { alias mars.product = coordAveraging3;} 100 101# date 102 if( 103 (marsType == TYPE_OR && averaging1Flag == P_TAVG) 104 || (marsType == TYPE_OR && averaging1Flag == P_TACC) 105 || (marsType == TYPE_FX && averaging1Flag == P_TAVG) 106 ) 107 { 108 #remove mars.date; 109 alias mars.date = verificationDate; 110 #remove mars.step; 111 constant stepZero = 0; 112 alias mars.step = stepZero; 113 } 114 115 116 } 117 else 118 { 119 120 meta coordinateIndexNumber evaluate(coordinate4Flag+coordinate3Flag); 121 122# levelist latitude longitude 123 124 if(coordinateIndexNumber== 3) 125 { 126 meta marsLatitude divdouble( coordinate1Start,1000000); 127 meta marsLongitude divdouble( coordinate2Start,1000000); 128 129 meta roundedMarsLatitude round( marsLatitude ,1000); 130 meta roundedMarsLongitude round( marsLongitude ,1000); 131 132 alias mars.latitude = roundedMarsLatitude ; 133 alias mars.longitude = roundedMarsLongitude ; 134 135 } 136 137 if(coordinateIndexNumber == 4) 138 { 139 meta marsLevelist divdouble( coordinate1Start,1000); 140 meta marsLatitude divdouble( coordinate2Start,1000000); 141 142 meta roundedMarsLevelist round( marsLevelist ,1000); 143 meta roundedMarsLatitude round( marsLatitude ,1000); 144 145 alias mars.levelist = roundedMarsLevelist ; 146 alias mars.latitude = roundedMarsLatitude ; 147 } 148 149 if(coordinateIndexNumber == 5) 150 { 151 meta marsLevelist divdouble( coordinate1Start,1000); 152 meta marsLongitude divdouble( coordinate2Start,1000000); 153 154 meta roundedMarsLevelist round( marsLevelist ,1000); 155 meta roundedMarsLongitude round( marsLongitude ,1000); 156 157 alias mars.levelist = roundedMarsLevelist ; 158 alias mars.longitude = roundedMarsLongitude ; 159 160 } 161 162# section 163 164 if(coordinateIndexNumber == 3) { alias mars.section = tsectionNumber3;} 165 if(coordinateIndexNumber == 4) { alias mars.section = tsectionNumber4;} 166 if(coordinateIndexNumber == 5) { alias mars.section = tsectionNumber5;} 167 168# range 169 if(averaging1Flag == P_INST){ 170 if( 171 (marsType == TYPE_OR) 172 ||(marsType == TYPE_FC) 173 ||(marsType == TYPE_CF) 174 ||(marsType == TYPE_PF) 175 ||(marsType == TYPE_FF) 176 ||(marsType == TYPE_OF) 177 ) 178 { 179 if( coordinate4Flag == 1){ 180 meta marsRange evaluate((coordinate4OfLastGridPoint - coordinate4OfFirstGridPoint)/3600); 181 }else{ 182 183 meta marsRange evaluate((coordinate3OfLastGridPoint - coordinate3OfFirstGridPoint)/3600); 184 } 185 186 alias mars.range = marsRange; 187 } 188 } 189 190# product 191 alias mars.product = coordAveragingTims; 192# date 193 194 195 if(marsType == TYPE_OR && averaging1Flag == P_INST){ 196 197 #remove mars.date; 198 alias mars.date = verificationDate; 199 #remove mars.step; 200 constant stepZero = 0; 201 alias mars.step =stepZero; 202 203 } 204 205 206 } 207 208 209} 210