| 183 | |
| 184 | === Vtables === |
| 185 | |
| 186 | One of the main structural modifications is to modify the routines that read the meteorological input data from the GRIB files so that all the variable references are made to names of the corresponding meteorological fields rather than a combination of GRIB parameter codes. In order to do this, we have borrowed the approach from the NWP model WRF (Weather Research and Forecasting model) whereby a Variable Table (Vtable) provides the mapping between the FLEXPART meteorological field names (e.g.. TT, U, U10, …) and the respective GRIB codes. Vtables for ECMWF and GFS data are provided inside the Vtables directory in the usual options directory. The layout of the Vtables is such as: |
| 187 | |
| 188 | |
| 189 | {{{ |
| 190 | GRIB1 | Level| flexpart | flexpart | flexpart |GRIB2|GRIB2|GRIB2|GRIB2| |
| 191 | Param | Type | Name | Units | Description |Discp|Catgy|Param|Level| |
| 192 | ------+------+----------+----------+------------------------+-----------------------+ |
| 193 | 130 | 109 | TT | K | Temperature | 0 | 0 | 0 | 105 | |
| 194 | 131 | 109 | UU | m s-1 | U | 0 | 2 | 2 | 105 | |
| 195 | 132 | 109 | VV | m s-1 | V | 0 | 2 | 3 | 105 | |
| 196 | 133 | 109 | QV | kg kg-1 | Specific humidity | 0 | 1 | 0 | 105 | |
| 197 | 134 | 1 | PS | Pa | Surface pressure | 0 | 3 | 0 | 1 | |
| 198 | 135 | 109 | ETADOT | Pa s-1 | Vertical velocity | 0 | 2 | 32 | 105 | |
| 199 | 141 | 1 | SD | m | Snow depth | 0 | 1 | 11 | 1 | |
| 200 | 151 | 1 | MSL | Pa | Sea-level Pressure | 0 | 3 | 0 | 101 | |
| 201 | 164 | 1 | TCC | (0-1) | Total cloud cover | 192 | 128 | 164 | 1 | |
| 202 | 165 | 1 | U10 | m s-1 | 10m U | 0 | 2 | 2 | 103 | |
| 203 | 166 | 1 | V10 | m s-1 | 10m V | 0 | 2 | 3 | 103 | |
| 204 | 167 | 1 | T2 | K | 2m Temperature | 0 | 0 | 0 | 103 | |
| 205 | 168 | 1 | TD2 | K | 2m Dewpoint | 0 | 0 | 6 | 103 | |
| 206 | |
| 207 | … |
| 208 | |
| 209 | 172 | 1 | LSM | 0/1 Flag | Land/Sea flag | 2 | 0 | 0 | 1 | |
| 210 | 246 | 1 | CLWC | kg kg-1 | Spec. cld liq water | 0 | 1 | 83 | 103 | |
| 211 | 247 | 1 | CIWC | kg kg-1 | Spec. cld ice water | 0 | 1 | 84 | 103 | |
| 212 | 201031| 1 | QC | kg kg-1 | Spec. cld water cont. | 0 | 201 | 31 | 105 | |
| 213 | ------+------+----------+----------+------------------------+-----------------------+ |
| 214 | |
| 215 | }}} |
| 216 | |
| 217 | |
| 218 | In order to use the Vtables, the routines that read the meteorological data (gridcheck and readwind) are modified and, the structures like: |
| 219 | |
| 220 | |
| 221 | {{{ |
| 222 | if(isec1(6).eq.131) uuh(i,j,nlev_ec-k+2)= &!! U VELOCITY |
| 223 | zsec4(nxfield*(ny-j-1)+i+1) |
| 224 | }}} |
| 225 | |
| 226 | |
| 227 | Are now modified to simply call the actual variable name: |
| 228 | |
| 229 | |
| 230 | {{{ |
| 231 | . |
| 232 | ELSE IF(TRIM(fpname) .EQ. 'UU') THEN |
| 233 | iumax=max(iumax,nlev_ec-k+1) |
| 234 | DO j=0,nymin1 |
| 235 | DO i=0,nxfield-1 |
| 236 | uuh(i,j,nlev_ec-k+2) = zsec4(nxfield*(ny-j-1)+i+1) |
| 237 | END DO |
| 238 | END DO |
| 239 | }}} |
| 240 | |
| 241 | This has required the generation of an additional library, provided with the code, that handles the conversion from variable names to corresponding GRIB parameters. The library is provided in ''src/gributils/class_vtable_mod.f90'' . This library handles as well the GRIB2 to GRIB1 conversions of parameters. |
| 242 | |
| 243 | The benefits of this approach are: |
| 244 | |
| 245 | * The code itself is more understandable and not dependent on specific GRIB parameter |
| 246 | values |
| 247 | * Users can experiment with new sources of met fields by creating a new Vtable, mapping |
| 248 | to the new GRIB parameters, without the need to modify code |
| 249 | |
| 250 | This approach, however, adds a level of indirection to the code (a table lookup) that has been compensated by restructuring the code and rearranging the loops in readwind, leading to even better performance in comparison with the original code. |
| 251 | |
| 252 | From the user perspective, the only difference is that a link to the correct Vtable has to be done in the run directory (where pathnames sits) |
| 253 | |
| 254 | The code has been tested against our testing environment showing zero differences for the test cases. |
| 255 | |
| 256 | In order to implement and deploy the Vtable approach, the following main modifications/additions have been carried out: |
| 257 | |
| 258 | * Creation of an independent ''gributils/class_Vtable_mod.f90'' to abstract all the operations of using the Vtables and matching GRIB file parameter codes to the appropriate Vtable entry. Gributils is provided inside ''src/'' |
| 259 | * Modification of the code in the following source files that deal directly with GRIB parameter codes - ''gridcheck_ecmwf.f90'', ''readwind_ecmwf.f90'', ''gridcheck_nests.f90'', and ''readwind_nests.f90'' . These modifications include: |
| 260 | * Added code that initializes a Vtable object |
| 261 | * Added code that used Vtable object routines to determine the fpname (e.g. UU,T2, CONVPREC , etc.) of a GRIB message |
| 262 | * Modified code to look for a specific fpname rather than specific GRIB parameters |
| 263 | |
| 264 | === Testing environment === |
| 265 | |
| 266 | A new and independent top-level directory, ''ctbto-testing-env'' was added to the directory tree. This directory contains the following: |
| 267 | |
| 268 | * '''case_data''': this directory includes the different test cases used in the testing environment, with the corresponding tree structure and control data. The cases are organised first according to the meteorological type of data (e.g. ''ecmwf_02hr_1p0deg'') and then, several cases underneath depending on the type of FLEXPART run with this data (eg. ''case_ecmwf_02hr_1p0deg_1species_1emission_bwd'', ''case_ecmwf_02hr_1p0deg_1species_1emission_fwd''). In each of the case directories, the user finds the control output (the output the testing environment will test against), the rundir_template directory (with the right options, pathnames and Vtable) and the par_mod file. |
| 269 | * '''check''': this directory contains all the high level routines to control the tests and includes the files the user should invoke to use the testing environment. The test driver, *check.py* is a Python program that expects an XML file as an argument, then creates a *TestSuite* consisting of all the components needed and performs all the compilations, simulations and testing. XML files for the case data are provided. In addition, ''run_selected_cases.py'' adds the possibility to run multiple cases defined in a text file (-lst) and multi_configtest.py calls in the ''run_selected_cases.py'' but using different makefiles provided as well by the user. How the code is executed is provided through the help function. |
| 270 | * '''distrotest''': includes all the routines that prepares all the information and populate the directories to perform the testing |
| 271 | * '''doc''': documentation for this environment is in the ''ctbto-testing-env/doc/'' directory, in Markdown format. With appropriate Markdown Extension, pointing the browser to ''ctbto-testing-env/doc/Overview.md'' should provide a usable browsing of the documentation. |
| 272 | * '''flextest''': lower level components for compiling, running, and evaluating FLEXPART output. These provide low level access routines for running FLEXPART programs, as well as numerous tools for accessing, evaluating and comparing FLEXPART outputs. |
| 273 | * '''metfetch''': the testing environment requires to have meteorological data to drive the test cases. metfetch automatically gets the NCEP data and prompts information on restricted ECMWF data. |
| 274 | * '''test''': set of unit tests for the testing environment development |
| 275 | * '''utilities''': includes examples of additional output one could obtain from the testing environment. |
| 276 | * '''distropath''': link to where the source code to run the testing environment is located. |
| 277 | |
| 278 | Apart from the documentation inside the testing environment itself, an updated version is kept in: |
| 279 | http://borealscicomp.com/CTBTO_FLEXPART/WO17/ctbto_testenv_docs/Overview.md |
| 280 | |
| 281 | The testing environment includes control case data using the original NILU code for serial tests but with the modifications in the header . For the MPI control data, the new version with the modifications detailed below, has been used to create it |
| 282 | |
| 283 | |
| 284 | |