diff --git a/README.cordex b/README.cordex new file mode 100644 index 0000000000..dac9d82036 --- /dev/null +++ b/README.cordex @@ -0,0 +1,360 @@ +******* WRF module to compute atmospheric model diagnostics required by CORDEX on WRFV3.9.1.1 +* L. Fita, CIMA. December 2017 + +See for more detail wiki page: +http://wiki.cima.fcen.uba.ar/mediawiki/index.php/CDXWRF + +This module computes that variables required by CORDEX which usually are post-processed + +* Compilation & efficiency note + +Efficiency constrains make necessary to introduce a system of compilation in order to do not overload WRF execution. Long simulations are usually used in CORDEX experiments, thus model temporal efficiency is even more important. In order to achieve this, a new pre-compilation variable has been added. According to the value of this giving variable and accordingly modifications in the 'Registry/registry.cordex' file certain variables are computed and provided at the output. This is not very 'WRF'-friendly, since usually all options are directly available with just a single compilation, but it has been shown that the large amount of variables introduced by this module, it slows down too much (up to 40% of additional time) the running time of the model. See below for more details (INSTALLATION section) + +* Subroutines/Functions + - module_diag_cordex: Main subroutine to compute CORDEX required variables + - module_diagvar_cordex: subroutine with the specific computation of CORDEX required variables + - registry.cordex: required definition of the new CORDEX variables + +* Available diagnostics (accordingly to pre-compilation set-up and namelist options) + +** Instantaneous diagnostics (only computed on output times) + - prw: Total water path + - clwvi: Total liquid water path (QCLOUD + QRAIN) + - clivi: Total ice water path (QSNOW+QICE+QGRAUPEL+QHAIL) + - uas: 10m earth-rotated eastward wind [ms-1] + - vas: 10m earth-rotated northward wind [ms-1] + - wss: 10m wind speed [ms-1] + - hurs: 2m relative humidty [1] + - huss: 2m specific humidty [1] + - psl: sea level pressure [Pa] (three different ways) + - mrso: total soil moisture content [kgm-2] + - slw: total liquid water content [kgm-2] + - ws100: 100m wind speed [ms-1] + - uz100: 100m wind x-direction [ms-1] + - vz100: 100m wind y-direction [ms-1] + - tauu, tauuv: components of the downward wind stress at 10 m [m2s-2] (might be zero if sf_sfclay_physics /= 1, 5) + - tauugen, tauuvgen: generic components of the downward wind stress at 10 m [m2s-2] + - cdcdx: drag coefficient [-] (might be zero if sf_sfclay_physics /= 1, 5) + - cdgen: generic drag coefficient [-] + - ps: surface pressure [Pa] + - ts: skin temperature [K] + - zeroith: 0-isotherm [m] + - mrsol: moisture content of soil layer [kgm-2] + - mrsos: first layer soil moisture content (0-10 cm) [kgm-2] + - mrso: total soil moisture content [kgm-2] + - mrsll: liquid water content of soil layer [kgm-2] + - mrlso: total liquid water content of soil layer [kgm-2] + - mrlsos: liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] + - mrsfl: frozen water content of soil layer [kgm-2] + - mrfso: total frozen water content of soil layer [kgm-2] + - mrfsos: frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] + +* CDXWRF=1 + - clivg: graupel water path (QGRAUPEL) + - clivh: hail water path (QHAIL) + - zmla: pbl height following a generic method [m] + - colmax: high-frequency maximum radar reflectivity in the column [dBz] (on auxhist8, wrfhfcdx) + +** Only if 'INSTVALS' modifications are made + - cape: Convective Available Potential Energy [Jkg-1] + - cin: Convective inhibition [Jkg-1] + - zlfc: Height at the Level of free convection [m] + - plfc: Pressure at the Level of free convection [Pa] + - lidx: Lifted index [1] + +* CDXWRF=2 + - ua: 3D earth-rotated eastward wind [ms-1] + - va: 3D earth-rotated northward wind [ms-1] + - ws: 3D wind speed [ms-1] + - ta: 3D air-temperature [K] + - press: 3D air pressure [Pa] + - zg: 3D geopotential height [m] + - hur: 3D relative humidty [1] + - hus: 3D specific humidty [1] + +** Accumulated or similar time dependency (computed at every time-step) +!!! NOTE: CLDFRAC is computed by the radiative scheme thus, +!!! bear in mind to configure the namelist.input that: +!!! auxhist9_interval > radt +!!! otherwise one obtains repeated values of clt, cll, clm, clh!! +!!! + - cltmean: mean clt [%] + - cllmean: mean cll [%] + - clmmean: mean clm [%] + - clhmean: mean clh [%] + - wsgsmax: maximum surface wind gust [ms-1] + - ugsmax: x maximum surface gust wind direction [ms-1] + - vgsmax: y maximum surface gust wind direction [ms-1] + - totwsgsmax: maximum surface wind gust [ms-1] (addition of different methods) + - totugsmax: eastward maximum surface gust wind direction [ms-1] + - totvgsmax: northward maximum surface gust wind direction [ms-1] + - totwsgspercen: percentage of times when grid point got total gust wind [\%] + - wsz100max: maximum 100m wind [ms-1] (two different methods) + - uz100max: eastward maximum 100m wind direction [ms-1] + - vz100max: northward maximum 100m wind direction [ms-1] + - sund: sunshine duration (ac. time with swdown > 120. Wm-2) [s] + - rsds: mean surface Downwelling Shortwave Radiation [Wm-2] + - rlds: mean surface Downwelling Longwave Radiation [Wm-2] + - hfls: mean surface Upward Latent Heat Flux [Wm-2] + - hfss: mean surface Upward Sensible Heat Flux [Wm-2] + - rsus: mean surface Upwelling Shortwave Radiation [Wm-2] + - rlus: mean surface Upwelling Longwave Radiation [Wm-2] + - rsusgen: mean generic surface Upwelling Shortwave Radiation [Wm-2] + - rlusgen: mean generic surface Upwelling Longwave Radiation [Wm-2] + - evspsbl: mean evaporation [kgm-2s-1] + - evspsblpot: mean potential evapotranspiration [kgm-2s-1] + - snc: mean snow area fraction [%] + - snd: mean snow depth [m] + - mrros: mean surface Runoff [kgm-2s-1] + - mrro: mean total Runoff [kgm-2s-1] + - mrsol: mean total water content of soil layer [kgm-2] + - pr: precipitation flux [kgm-2s-1] + - prl: large scale precipitation flux [kgm-2s-1] + - prc: convective precipitation flux [kgm-2s-1] + - prsh: shallow-cumulus precipitation flux [kgm-2s-1] + - prsn: solid precipitation flux [kgm-2s-1] + - snw: accumulated snow [ksm-2] + - rsdt: TOA incident shortwave radiation [kgm-2] + - rsut: TOA outgoing shortwave radiation [kgm-2] + - rlut: TOA outgoing Longwave radiation [kgm-2] + - mrsolmean: mean moisture content of soil layer [kgm-2] + - mrsosmean: mean first layer soil moisture content (0-10 cm) [kgm-2] + - mrsomean: mean total soil moisture content [kgm-2] + - mrsllmean: mean liquid water content of soil layer [kgm-2] + - mrlsomean: mean total liquid water content of soil layer [kgm-2] + - mrlsosmean: mean liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] + - mrsflmean: mean frozen water content of soil layer [kgm-2] + - mrfsomean: mean total frozen water content of soil layer [kgm-2] + - mrfsosmean: mean frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] + +* Only if 'INSTVALS' modifications are made + - clt: total cloud cover [%] + - cll: low-level cloud cover [%] + - clm: mid-level cloud cover [%] + - clh: high-level cloud cover [%] + +* CDXWRF=1 + - capemin: minimum CAPE [Jkg-1] + - cinmin: minimum CIN [Jkg-1] + - zlfcmin: minimum height at LFC [m] + - plfcmin: minimum Pressure at LFC [Pa] + - lidxmin: minimum Lifted index [1] + - capemax: maximum CAPE [Jkg-1] + - cinmax: maximum CIN [Jkg-1] + - zlfcmax: maximum height at LFC [m] + - plfcmax: maximum Pressure at LFC [Pa] + - lidxmax: maximum Lifted index [1] + - capemean: mean CAPE [Jkg-1] + - cinmean: mean CIN [Jkg-1] + - zlfcmean: mean height at LFC [m] + - plfcmean: mean Pressure at LFC [Pa] + - lidxmean: mean Lifted index [1] + - prflux: high-frequency precipitation flux [kgm-2s-1] (on auxhist8, wrfhfcdx) + +* CDXWRF=2 + - tfog: time of presence of fog [s] + - fogvisbltymin: minimun visibility inside fog [km] + - fogvisbltymax: maximun visibility inside fog [km] + - fogvisbltymean: mean visibility inside fog [km] + - tdsmin: minimum 2m dew point temperature [K] + - tdsmax: maximum 2m dew point temperature [K] + - tdsmean: mean 2m dew point temperature [K] + - twsmin: minimum 2m wet-bulb temperature [K] + - twsmax: maximum 2m wet-bulb temperature [K] + - twsmean: mean 2m wet-bulb temperature [K] + +* CDXWRF=3 + - tashurstreshighres: high resolution of simultaneous temporal residence of 2-meter temperature and relative humidity + - tashurstreslowres: low resolution of simultaneous temporal residence of 2-meter temperature and relative humidity + - wbdswsstres: simultaneous temporal residence of 10-meter wind direction (from where it blows) and wind speed + +* CDXWRF=4 + - wbacdiabh: Water-budget vertically integrated accumulated of diabatic heating from microphysics [K] + - wbacpw, wbacpw[c/r/s/i/g/h]: Water-budget vertically integrated accumulated total tendency for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacf, wbacf[c/r/s/i/g/h]: Water-budget vertically integrated accumulated horizontal advection for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacz, wbacz[c/r/s/i/g/h]: Water-budget vertically integrated accumulated vertical advection for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacdiabh\{l/m/h\}: Water-budget vertically integrated accumulated of diabatic heating from microphysics at low, medium and high levels (same as cloudiness) [K] + - wbacpw{l/m/h}, wbacpw[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated total tendency for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + - wbacf{l/m/h}, wbacf[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated horizontal advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + - wbacz{l/m/h}, wbacz[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated vertical advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + +** Only if 'INSTVALS' modifications are made + - fog: whether point is inside fog (vis < 1km) [1] + - vis: visibility inside fog [km] + - tds: 2m dew point temperature [K] + - q[v/c/r/s/i/g/h]ttend: instantaneous 3D time-step tendency for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1s-1] + - q[v/c/r/s/i/g/h]_hadv: instantaneous horizontal advection for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1] + - q[v/c/r/s/i/g/h]_zadv: instantaneous Vertical advection for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1] + + * Pressure interplation + - Interpolation on pressure levels of specific humidty (hus_pl), vertical wind speed (w_pl), Earth-rotated wind x-component (uer), Earth-rotated wind y-component (ver) and wind speed (ws) have been also introduced into the `wrfpress' output + +* INSTALLATION +These steps must be followed prior the re-compilation of the WRF model (it requires a clean -a) + + 1.- Check to the right branch + $ git checkout cdxwrf + + ** NOTE **: assuming that you got the right submodules [e.g. noahMP] (when downloading the fork) !! + + 2.- Clean the code (in order to avoid to run again configure one can make a copy of the 'configure.wrf' and recover it after the clean, otherwise it is erased) + $ cp configure.wrf configure.cordex.wrf + $ ./clean -a + $ cp configure.cordex.wrf configure.wrf + + 3.- edit the `configure.wrf' and add the line (after the line -DNETCDF and/or -DCLWRFGHG) + -DCORDEXDIAG \ + 4.- Set up (or not) the pre-compilation variable CDXWRF (after the line -DCORDEXDIAG) + -DCDXWRF=[value] \ + + Accordingly to the value given to the pre-compilation variable CDXWRF one obtains: + - Without adding the variable: all CORDEX 'Core' variables + - CDXWRF=1 CORDEX 'Tier' variables: clivg, clivh, zmla, [cape/cin/zlfc/plfc/lidx]{min/max/mean} + - CDXWRF=2 The same as with CDXWRF=1 and additional variables: ua, va, ws, ta, press, zg, hur, hus, tfog, fogvisbltymin, fogvisbltymax, fogvisbltymean, tdsmin, tdsmax, tdsmean + - CDXWRF=3 The same as with CDXWRF=1,2 and additional residence-time variables + - CDXWRF=4 The same as with CDXWRF=1,2 and 3 and the Water-Budget relarted ones: wbacdiabh, wbacpw, wbacpw[c/r/s/i/g/h], wbacf, wbacf[c/r/s/i/g/h], wbacz, wbacz[c/r/s/i/g/h], wbacdiabh{l/m/h}, wbacpw{l/m/h}, wbacpw[c/r/s/i/g/h]{l/m/h}, wbacf{l/m/h}, wbacf[c/r/s/i/g/h]{l/m/h}, wbacz{l/m/h}, wbacz[c/r/s/i/g/h]{l/m/h} + Simultanesouly, one needs to: + a.- make a copy of Registry/registry.cordex + $ cp Registry/registry.cordex Registry/registry.cordex_comp + b.- modify the Registry/registry.cordex_comp accordingly to the value of CDXWRF: + - Without adding CDXWRF, nothing needs to be changed + - Adding CDXWRF=1, one needs to remove the comment ##CDXWRF1## at the beginning of the line of the definition of certain variables + - Adding CDXWRF=2, one needs to remove the comment ##CDXWRF1## and ##CDXWRF2## at the beginning of the line of the definition of certain variables + - Adding CDXWRF=3, one needs to remove the comment ##CDXWRF1##, ##CDXWRF2## and ##CDXWRF3## at the beginning of the line of the definition of certain variables + - Adding CDXWRF=4, one needs to remove the comment ##CDXWRF1##, ##CDXWRF2##, ##CDXWRF3## and ##CDXWRF4## at the beginning of the line of the definition of certain variables + + - Additionally, one can also get the instantaneous values for the variables which only certain statistics (accumulation, minimum, mean, ...) are provided. In order to get them, one need to: + a.- Search in 'phys/module_diagnostics_driver.F' and 'phys/module_diag_cordex.F' the lines of code marked with 'INSTVALS' and change accordingly. + b.- Modify Registry/registry.cordex accordingly (removing ##INST## at the beginning of the line of the definition of certain variables, and adding 'h9' to certain others) + c.- re-compile + + 7.- compile as always + · ./compile em_real >& compile.log + +NOTE: after any change into a `Registry' related file, one needs to before the compilation refresh entirely the code throughout +$ ./clean -a + +* USAGE + One need to add to the 'namelist.input' the auxiliary output number 8 (only for CDXWRF>=1, e.g. for every 10 minutes and 1-day files) & 9 (e.g. for output every 3 hours and 1-day files) at the `&history' section: + + auxhist8_outname = "wrfhfcdx_d_" + auxhist8_interval = 10, 10, + frames_per_auxhist8 = 144, 144, + io_form_auxhist8 = 2 + + auxhist9_outname = "wrfcdx_d_" + auxhist9_interval = 180, 180, + frames_per_auxhist9 = 8, 8, + io_form_auxhist9 = 2 + + Also a new section should be added (assuming it will get complex...) + +&cordex + output_cordex = 1 + psl_diag = 1: sea-level pressure diagnostic following hydrostatic Shuell correction + = 2: psl diagnostic following a target pressure + = 3: psl diagnostic following ECMWF method (default) + psmooth = 5: passes of neighborgh filtering (3x3-grid point mean) of psfc for psl_diag=2 (default 5) + ptarget = 70000.: pressure [Pa] target to be used by psl_diag=2 (default 70000.) + output_wb = 1: whether water-budget variables have to computed (1) or not (0, default) + wsgs_diag = 1: wind-gust diagnostic following Brasseur, 2001, MWR (default) + = 2: wsgs folllowing heavy precipitation method + wsz100_diag = 1: wind extraoplation at z100m_wind using power-law method (default) + = 2: wind extraoplation at z100m_wind using Monin-Obukhov theory + z100_wind = 100.: height to extraplate winds (100. default) + zmlagen_dqv = 0.1: percentage of variation of mixing ratio to determine mixed layer depth used in zmla computation (0.1 default) + zmlagen_dtheta = 1.5: increment in K of potantial temperature from its minimum within the MLD used in zmla computation (1.5 default) + integer potevp_diag = 1: potential evapotranspiration diagnostic following Penman-Monteith as in ORCHIDEE (default) + convxtrm_diag = 0: diagnostic of extremes from convection indices: 0: No (default); 1: yes + fogvisibility_diag = 1: diagnostic of visibility inside fog following Kunkel (1984) + = 2: RUC method (Smirnova et al., 2000) + = 3: FRAML 50% prob Gultepe and Milbrandt, (2010) (default) + fogvars = 1: variables to use to diagnose fog using 3D [hur] (default) + = 2: sfc [hus] (not available for Kunkel, 1984) + zmlagen_diag = 1: diagnostic of generic zmla after Nielsen-Gammon et al. (2008) + = 2: bulk-Richardson (Vogelezang and Holtslag, 1996; Seidel et al., 2004) (default) + timedbg = frecuency in minutes of time-debugging (720, default) + londbg = longitude in degrees of grid-point debugging (-999., not used) (-999., default) + latdbg = latitude in degrees of grid-point debugging (-999., not used) (-999., default) + wgsts_wbdswsstres = whether wind gusts should be used for wbds-wss residence-time (0: no, 1: yes (1, default) + +#### ONLY for CDXWRF>=3 + nhtasrng = amount + 1 of high-resolution bins for temporal residence of tas (38, default) + nhhursrng = amount + 1 of high-resolution bins for temporal residence of hurs (25, default) + nltasrng = amount + 1 of low-resolution bins for temporal residence of tas (21, default) + nlhursrng = amount + 1 of low-resolution bins for temporal residence of hurs (25, default) + nwbdsrng = amount + 1 of bins for temporal residence of wbds (33, default) + nwssrng = amount + 1 of bins for temporal residence of wss (22, default) + nhtashursrng = amount + 1 of high-resolution bins for temporal residence of tas and hurs (nhtas+1)*(nhhurs+1) (950, default) + nltashursrng = amount + 1 of low-resolution bins for temporal residence of wss and wbds (nwbds+1)*(nwss+1) (525, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) (726, default) + htasrng = high-resolution bins for temporal residence of tas (/173.15,268.15,269.15,270.15,271.15,272.15,273.15, + 274.15,275.15,276.15,277.15,278.15,279.15,280.15,281.15,282.15,283.15,284.15,285.15,286.15,287.15,288.15,289.15, + 290.15,291.15,292.15,293.15,294.15,295.15,296.15,297.15,298.15,299.15,300.15,301.15,302.15,303.15,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + hhursrng = high-resolution bins for temporal residence of hurs (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40, + 0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + ltasrng = low-resolution bins for temporal residence of tas (/173.15,233.15,238.15,243.15,248.15,253.15, + 258.15,263.15,268.15,273.15,278.15,283.15,288.15,293.15,298.15,303.15,308.15,313.15,318.15,323.15,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00/) + lhursrng = low-resolution bins for temporal residence of hurs (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45, + 0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + wbdsrng = bins for temporal residence of wbds (/-0.0982,0.0982,0.2945,0.4909,0.6872,0.8836, + 1.0799,1.2763,1.4726,1.669,1.8653,2.0617,2.258,2.4544,2.6507,2.8471,3.0434,3.2398,3.4361,3.6325,3.8288, + 4.0252,4.2215,4.4179,4.6142,4.8106,5.0069,5.2033,5.3996,5.596,5.7923,5.9887,6.185,0.0,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) + wssrng = bins for temporal residence of wss (/0.0,0.5,1.0,2.5,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,45.0, + 50.0,60.0,70.0,80.0,90.0,100.0,125.0,150.0,200.0,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) +/ + + +`convxtrm_diag' parameter has only effect with CDXWRF=1 +`outputwb', `fogvisibility_diag' and `fogvars' parameters has only effect with CDXWRF=2 + +# Optional values for wbds & wss residence-time +## +# kt-based: [0., 2.5, 5., 10., 15., 20., 25., 30., 35., 40.. 45., 50., 60., 70., 80., 100., 150., 200., 250., 300. ] +# Transforming to ms-1 as wss = kt * 1852. / 3600. + nwssrng = amount + 1 of bins for temporal residence of wss kt-based (20, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) kt-based (660, default) + wssrng = bins for temporal residence of wss kt based (/0.0,1.2861,2.5722,5.1444,7.7167,10.2889,12.8611, + 15.4333,18.0056,20.5778,23.15,25.7222,30.8667,36.0111,41.1556,51.4444,77.1667,102.8889,128.6111,154.3333,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) + +# Beafourt scale-based: [0., 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, +# 16.5, 17.5, 18.5, 19.5, 21.5, 23.5, 25.5, 27.5, 29.5, 31.5] +# FROM: https://en.wikipedia.org/wiki/Beaufort_scale +# Transforming to ms-1 as wss = 0.836*Bnum**(3./2.) + nwssrng = amount + 1 of bins for temporal residence of wss Beafourt-based (27, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) Beafourt-based (891, default) + wssrng = bins for temporal residence of wss Beafourt-based (/0.0,0.2956,1.5358,3.3046,5.474,7.9804,10.7833, + 13.854,17.1711,20.7174,24.4789,28.444,32.6027,36.9463,41.4674,46.1592,51.0157,56.0315,61.2017,66.5218,71.9877,83.342, + 95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0/) + + +** Pressure interpolation + + Remember to activate section &diags in order to get pressure-level vertical interpolation of state variables (assuming 6 levels only) + + auxhist23_outname=”wrfpress_d_” + io_form_auxhist23 = 2, + auxhist23_interval = 180, 60, + frames_per_auxhist23 = 8, 24, + +&diags + p_lev_diags = 1, + num_press_levels = 6, + press_levels = 100000, 92500, 85000, 70000, 50000, 20000 + use_tot_or_hyd_p = 1 + p_lev_missing = -999. +/ + +Optional 23 p-level values: + num_press_levels = 23, + press_levels = 100000,97500,95000,92500,90000,87500,85000,82500,80000,75000,70000,65000,60000,55000,50000,45000,40000,35000,30000,25000,20000,15000,10000, + diff --git a/README.md b/README.md index b5e292d3fc..1e411058e2 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,446 @@ Information regarding WRF Model citations (including a DOI) can be found here: [ The WRF Model is open-source code in the public domain, and its use is unrestricted. The name "WRF", however, is a registered trademark of the University Corporation for Atmospheric Research. The WRF public domain notice and related information may be found here: [https://www2.mmm.ucar.edu/wrf/users/public.html](https://www2.mmm.ucar.edu/wrf/users/public.html). +# Lluís Fita Borrell fork # +This is the WRF repository of Lluis Fita Borrell, forked from WRF v7.1. CIMA-IFAECI, UBA-CONICET-CNRS-IRD, C. A. Buenos Aries Argentina +## Installation ## + +Getting the code from the fork in a INSTDIR +``` +$ cd $INSTDIR +$ git clone git@github.com:LluisFB/WRF.git +$ cd WRF +``` + +Getting submodules +``` +$ git submodule update --init --recursive +``` + +Listing available branches (all official from WRF v7.1) and the ones created by L Fita +``` +$ git branch -a +``` + +To switch to any WRF branch +``` +$ git checkout [branch_name] +``` + +### cdxwrf: CORDEX-WRF module ### + +See for more detail wiki page: +[http://wiki.cima.fcen.uba.ar/mediawiki/index.php/CDXWRF](http://wiki.cima.fcen.uba.ar/mediawiki/index.php/CDXWRF) + +This module computes that variables required by CORDEX which usually are post-processed. Starting publication: + +- Fita, L., Polcher, J., Giannaros, T. M., Lorenz, T., Milovac, J., Sofiadis, G., Katragkou, E., and Bastin, S.: CORDEX-WRF v1.3: development of a module for the Weather Research and Forecasting (WRF) model to support the CORDEX community, Geosci. Model Dev., 12, 1029–1066, [doi: 10.5194/gmd-12-1029-2019](https://doi.org/10.5194/gmd-12-1029-2019), 2019. + +#### note in Compilation & efficiency #### + +Efficiency constrains make necessary to introduce a system of compilation in order to do not overload WRF execution. Long simulations are usually used in CORDEX experiments, thus model temporal efficiency is even more important. In order to achieve this, a new pre-compilation variable has been added. According to the value of this giving variable and accordingly modifications in the 'Registry/registry.cordex' file certain variables are computed and provided at the output. This is not very 'WRF'-friendly, since usually all options are directly available with just a single compilation, but it has been shown that the large amount of variables introduced by this module, it slows down too much (up to 40% of additional time) the running time of the model. See below for more details (INSTALLATION section) + +#### Subroutines/Functions #### + - module_diag_cordex: Main subroutine to compute CORDEX required variables + - module_diagvar_cordex: subroutine with the specific computation of CORDEX required variables + - registry.cordex: required definition of the new CORDEX variables + +#### Available diagnostics #### +Accordingly to pre-compilation set-up and namelist options + +##### Instantaneous diagnostics ##### +only computed on output times + + - prw: Total water path + - clwvi: Total liquid water path (QCLOUD + QRAIN) + - clivi: Total ice water path (QSNOW+QICE+QGRAUPEL+QHAIL) + - uas: 10m earth-rotated eastward wind [ms-1] + - vas: 10m earth-rotated northward wind [ms-1] + - wss: 10m wind speed [ms-1] + - hurs: 2m relative humidty [1] + - huss: 2m specific humidty [1] + - psl: sea level pressure [Pa] (three different ways) + - mrso: total soil moisture content [kgm-2] + - slw: total liquid water content [kgm-2] + - ws100: 100m wind speed [ms-1] + - uz100: 100m wind x-direction [ms-1] + - vz100: 100m wind y-direction [ms-1] + - tauu, tauuv: components of the downward wind stress at 10 m [m2s-2] (might be zero if sf_sfclay_physics /= 1, 5) + - tauugen, tauuvgen: generic components of the downward wind stress at 10 m [m2s-2] + - cdcdx: drag coefficient [-] (might be zero if sf_sfclay_physics /= 1, 5) + - cdgen: generic drag coefficient [-] + - ps: surface pressure [Pa] + - ts: skin temperature [K] + - zeroith: 0-isotherm [m] + - mrsol: moisture content of soil layer [kgm-2] + - mrsos: first layer soil moisture content (0-10 cm) [kgm-2] + - mrso: total soil moisture content [kgm-2] + - mrsll: liquid water content of soil layer [kgm-2] + - mrlso: total liquid water content of soil layer [kgm-2] + - mrlsos: liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] + - mrsfl: frozen water content of soil layer [kgm-2] + - mrfso: total frozen water content of soil layer [kgm-2] + - mrfsos: frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] + - hus_pl: Pressure level data, Sepcific humidity [1] + - w_pl: Pressure level data, W wind [ms-1] + - uer_pl: Pressure level data, U wind Earth-Rotated [ms-1] + - ver_pl: Pressure level data, V wind Earth-Rotated [ms-1] + - ws_pl: Pressure level data, wind speed [ms-1] + - qc_pl: Pressure level data, cloud mixing ratio [kgkg-1] + - qr_pl: Pressure level data, rain mixing ratio [kgkg-1] + - qs_pl: Pressure level data, snow mixing ratio [kgkg-1] + - qi_pl: Pressure level data, ice mixing ratio [kgkg-1] + - qg_pl: Pressure level data, graupel mixing ratio [kgkg-1] + - qh_pl: Pressure level data, hail mixing ratio [kgkg-1] + - qv_pl_mc: mass-conservative pressure level data, water vapour mixing ratio [kgkg-1] + - qc_pl_mc: mass-conservative pressure level data, cloud mixing ratio [kgkg-1] + - qr_pl_mc: mass-conservative pressure level data, rain mixing ratio [kgkg-1] + - qs_pl_mc: mass-conservative pressure level data, snow mixing ratio [kgkg-1] + - qi_pl_mc: mass-conservative pressure level data, ice mixing ratio [kgkg-1] + - qg_pl_mc: mass-conservative pressure level data, graupel mixing ratio [kgkg-1] + - qh_pl_mc: mass-conservative pressure level data, hail mixing ratio [kgkg-1] + +###### CDXWRF=1 + - clivg: graupel water path (QGRAUPEL) + - clivh: hail water path (QHAIL) + - zmla: pbl height following a generic method [m] + - colmax: high-frequency maximum radar reflectivity in the column [dBz] (on auxhist18, wrfhfcdx) + +###### INSTVALS +Only if `INSTVALS` modifications are made in the code + - cape: Convective Available Potential Energy [Jkg-1] + - cin: Convective inhibition [Jkg-1] + - zlfc: Height at the Level of free convection [m] + - plfc: Pressure at the Level of free convection [Pa] + - lidx: Lifted index [1] + +###### CDXWRF=2 + - ua: 3D earth-rotated eastward wind [ms-1] + - va: 3D earth-rotated northward wind [ms-1] + - ws: 3D wind speed [ms-1] + - ta: 3D air-temperature [K] + - press: 3D air pressure [Pa] + - zg: 3D geopotential height [m] + - hur: 3D relative humidty [1] + - hus: 3D specific humidty [1] + +##### Accumulated or similar time dependency +computed at every time-step + +**NOTE:** CLDFRAC is computed by the radiative scheme thus, bear in mind to configure the `namelist.input` that: +``` + auxhist19_interval > radt +``` +otherwise one obtains repeated values of clt, cll, clm, clh!! + + - cltmean: mean clt [%] + - cllmean: mean cll [%] + - clmmean: mean clm [%] + - clhmean: mean clh [%] + - wsgsmax: maximum surface wind gust [ms-1] + - ugsmax: x maximum surface gust wind direction [ms-1] + - vgsmax: y maximum surface gust wind direction [ms-1] + - totwsgsmax: maximum surface wind gust [ms-1] (addition of different methods) + - totugsmax: eastward maximum surface gust wind direction [ms-1] + - totvgsmax: northward maximum surface gust wind direction [ms-1] + - totwsgspercen: percentage of times when grid point got total gust wind [\%] + - wsz100max: maximum 100m wind [ms-1] (two different methods) + - uz100max: eastward maximum 100m wind direction [ms-1] + - vz100max: northward maximum 100m wind direction [ms-1] + - sund: sunshine duration (ac. time with swdown > 120. Wm-2) [s] + - rsds: mean surface Downwelling Shortwave Radiation [Wm-2] + - rlds: mean surface Downwelling Longwave Radiation [Wm-2] + - hfls: mean surface Upward Latent Heat Flux [Wm-2] + - hfss: mean surface Upward Sensible Heat Flux [Wm-2] + - rsus: mean surface Upwelling Shortwave Radiation [Wm-2] + - rlus: mean surface Upwelling Longwave Radiation [Wm-2] + - rsusgen: mean generic surface Upwelling Shortwave Radiation [Wm-2] + - rlusgen: mean generic surface Upwelling Longwave Radiation [Wm-2] + - evspsbl: mean evaporation [kgm-2s-1] + - evspsblpot: mean potential evapotranspiration [kgm-2s-1] + - snc: mean snow area fraction [%] + - snd: mean snow depth [m] + - mrros: mean surface Runoff [kgm-2s-1] + - mrro: mean total Runoff [kgm-2s-1] + - mrsol: mean total water content of soil layer [kgm-2] + - pr: precipitation flux [kgm-2s-1] + - prl: large scale precipitation flux [kgm-2s-1] + - prc: convective precipitation flux [kgm-2s-1] + - prsh: shallow-cumulus precipitation flux [kgm-2s-1] + - prsn: solid precipitation flux [kgm-2s-1] + - snw: accumulated snow [ksm-2] + - rsdt: TOA incident shortwave radiation [kgm-2] + - rsut: TOA outgoing shortwave radiation [kgm-2] + - rlut: TOA outgoing Longwave radiation [kgm-2] + - mrsolmean: mean moisture content of soil layer [kgm-2] + - mrsosmean: mean first layer soil moisture content (0-10 cm) [kgm-2] + - mrsomean: mean total soil moisture content [kgm-2] + - mrsllmean: mean liquid water content of soil layer [kgm-2] + - mrlsomean: mean total liquid water content of soil layer [kgm-2] + - mrlsosmean: mean liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] + - mrsflmean: mean frozen water content of soil layer [kgm-2] + - mrfsomean: mean total frozen water content of soil layer [kgm-2] + - mrfsosmean: mean frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] + +###### INSTVALS +Only if `INSTVALS` modifications in code are made + - clt: total cloud cover [%] + - cll: low-level cloud cover [%] + - clm: mid-level cloud cover [%] + - clh: high-level cloud cover [%] + +###### CDXWRF=1 + - capemin: minimum CAPE [Jkg-1] + - cinmin: minimum CIN [Jkg-1] + - zlfcmin: minimum height at LFC [m] + - plfcmin: minimum Pressure at LFC [Pa] + - lidxmin: minimum Lifted index [1] + - capemax: maximum CAPE [Jkg-1] + - cinmax: maximum CIN [Jkg-1] + - zlfcmax: maximum height at LFC [m] + - plfcmax: maximum Pressure at LFC [Pa] + - lidxmax: maximum Lifted index [1] + - capemean: mean CAPE [Jkg-1] + - cinmean: mean CIN [Jkg-1] + - zlfcmean: mean height at LFC [m] + - plfcmean: mean Pressure at LFC [Pa] + - lidxmean: mean Lifted index [1] + - prflux: high-frequency precipitation flux [kgm-2s-1] (on auxhist18, wrfhfcdx) + +###### CDXWRF=2 + - tfog: time of presence of fog [s] + - fogvisbltymin: minimun visibility inside fog [km] + - fogvisbltymax: maximun visibility inside fog [km] + - fogvisbltymean: mean visibility inside fog [km] + - tdsmin: minimum 2m dew point temperature [K] + - tdsmax: maximum 2m dew point temperature [K] + - tdsmean: mean 2m dew point temperature [K] + - twsmin: minimum 2m wet-bulb temperature [K] + - twsmax: maximum 2m wet-bulb temperature [K] + - twsmean: mean 2m wet-bulb temperature [K] + +###### CDXWRF=3 + - tashurstreshighres: high resolution of simultaneous temporal residence of 2-meter temperature and relative humidity + - tashurstreslowres: low resolution of simultaneous temporal residence of 2-meter temperature and relative humidity + - wbdswsstres: simultaneous temporal residence of 10-meter wind direction (from where it blows) and wind speed + +###### CDXWRF=4 + - wbacdiabh: Water-budget vertically integrated accumulated of diabatic heating from microphysics [K] + - wbacpw, wbacpw[c/r/s/i/g/h]: Water-budget vertically integrated accumulated total tendency for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacf, wbacf[c/r/s/i/g/h]: Water-budget vertically integrated accumulated horizontal advection for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacz, wbacz[c/r/s/i/g/h]: Water-budget vertically integrated accumulated vertical advection for water vapour, cloud, rain, snow, ice, graupel, hail [mm] + - wbacdiabh\{l/m/h\}: Water-budget vertically integrated accumulated of diabatic heating from microphysics at low, medium and high levels (same as cloudiness) [K] + - wbacpw{l/m/h}, wbacpw[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated total tendency for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + - wbacf{l/m/h}, wbacf[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated horizontal advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + - wbacz{l/m/h}, wbacz[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated vertical advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] + +###### INSTVALS +Only if `INSTVALS` modifications in code are made + - fog: whether point is inside fog (vis < 1km) [1] + - vis: visibility inside fog [km] + - tds: 2m dew point temperature [K] + - q[v/c/r/s/i/g/h]ttend: instantaneous 3D time-step tendency for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1s-1] + - q[v/c/r/s/i/g/h]_hadv: instantaneous horizontal advection for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1] + - q[v/c/r/s/i/g/h]_zadv: instantaneous Vertical advection for water vapor, cloud, rain, snow, ice, graupel, hail [kgkg-1] + +#### Pressure interplation + - Interpolation on pressure levels of specific humidty (`hus_pl`), vertical wind speed (`w_pl`), Earth-rotated wind x-component (`uer`), Earth-rotated wind y-component (`ver`) and wind speed (`ws`) have been also introduced into the `wrfpress` output + +#### INSTALLATION +These steps must be followed prior the re-compilation of the WRF model (it requires a `clean -a`) + +1. Check to the right branch. **NOTE:** assuming that you got the right submodules [e.g. noahMP] (when downloading the fork) !! +``` +git checkout cdxwrf +``` + +2. Clean the code (in order to avoid to run again configure one can make a copy of the `configure.wrf` and recover it after the clean, otherwise it is erased) +``` +cp configure.wrf configure.cordex.wrf +./clean -a +cp configure.cordex.wrf configure.wrf +``` + +3. edit the `configure.wrf` and add the line (after the line `-DNETCDF` and/or `-DCLWRFGHG`) +``` + -DCORDEXDIAG \ +``` +4. Set up (or not) the pre-compilation variable CDXWRF (after the line -DCORDEXDIAG) +``` + -DCDXWRF=[value] \ +``` + + - Accordingly to the value given to the pre-compilation variable CDXWRF one obtains: + - Without adding the variable: all CORDEX 'Core' variables + - `CDXWRF=1` CORDEX 'Tier' variables: `clivg`, `clivh`, `zmla`, [cape/cin/zlfc/plfc/lidx]{min/max/mean} (if `convxtrm_diag = 1`), `colmax`, `prhf` + - `CDXWRF=2` The same as with `CDXWRF=1` and additional variables: `ua`, `va`, `ws`, `ta`, `press`, `zg`, `hur`, `hus`, `tfog`, `fogvisbltymin`, `fogvisbltymax`, `fogvisbltymean`, `tdsmin`, `tdsmax`, `tdsmean`, `twsmin`, `twsmax`, `twsmean` + - `CDXWRF=3` The same as with `CDXWRF=1,2` and additional residence-time variables + - `CDXWRF=4` The same as with `CDXWRF=1,2` and `3` and the Water-Budget relarted ones: `wbacdiabh`, `wbacpw`, `wbacpw[c/r/s/i/g/h]`, `wbacf`, `wbacf[c/r/s/i/g/h]`, `wbacz`, `wbacz[c/r/s/i/g/h]`, `wbacdiabh{l/m/h}`, `wbacpw{l/m/h}`, `wbacpw[c/r/s/i/g/h]{l/m/h}`, `wbacf{l/m/h}`, `wbacf[c/r/s/i/g/h]{l/m/h}`, `wbacz{l/m/h}`, `wbacz[c/r/s/i/g/h]{l/m/h}` + Simultanesouly, one needs to: + 1. make a copy of `Registry/registry.cordex` +``` +cp Registry/registry.cordex Registry/registry.cordex_comp +``` + 2. modify the `Registry/registry.cordex_comp` accordingly to the value of `CDXWRF`: + - Without adding `CDXWRF`, nothing needs to be changed + - Adding `CDXWRF=1`, one needs to remove the comment `##CDXWRF1##` at the beginning of the line of the definition of certain variables + - Adding `CDXWRF=2`, one needs to remove the comment `##CDXWRF1##` and `##CDXWRF2##` at the beginning of the line of the definition of certain variables + - Adding `CDXWRF=3`, one needs to remove the comment `##CDXWRF1##`, `##CDXWRF2##` and `##CDXWRF3##` at the beginning of the line of the definition of certain variables + - Adding `CDXWRF=4`, one needs to remove the comment `##CDXWRF1##`, `##CDXWRF2##`, `##CDXWRF3##` and `##CDXWRF4##` at the beginning of the line of the definition of certain variables + - Example for `CDXWRF=3` +``` +sed -i 's/##CDXWRF1##//g' Registry/registry.cordex_comp +sed -i 's/##CDXWRF2##//g' Registry/registry.cordex_comp +sed -i 's/##CDXWRF3##//g' Registry/registry.cordex_comp +``` + + - Additionally, one can also get the instantaneous values for the variables which only certain statistics (accumulation, minimum, mean, ...) are provided. In order to get them, one need to: + 1. Search in `phys/module_diagnostics_driver.F` and `phys/module_diag_cordex.F` the lines of code marked with `INSTVALS` and change accordingly (not fully tested). + 2. Modify `Registry/registry.cordex` accordingly (removing `##INST##` at the beginning of the line of the definition of certain variables, and adding `h19` to certain others) + + 7. compile as always +``` +./compile em_real >& compile.log +``` + +**NOTE:** after any change into a `Registry` related file, one needs to before the compilation refresh entirely the code throughout +``` +./clean -a +``` + +#### USAGE: namelist.input +One need to add to the `namelist.input` the auxiliary output number 18 (only for `CDXWRF>=1`, e.g. for every 10 minutes and 1-day files) & 19 (e.g. for output every 3 hours and 1-day files) at the `&history' section: +``` + auxhist18_outname = "wrfhfcdx_d_" + auxhist18_interval = 10, 10, + frames_per_auxhist18 = 144, 144, + io_form_auxhist18 = 2 + + auxhist19_outname = "wrfcdx_d_" + auxhist19_interval = 180, 180, + frames_per_auxhist19 = 8, 8, + io_form_auxhist19 = 2 +``` +Also a new section should be added into the `namelist.input + +``` +&cordex + output_cordex = 1 + psl_diag = 1: sea-level pressure diagnostic following hydrostatic Shuell correction + = 2: psl diagnostic following a target pressure + = 3: psl diagnostic following ECMWF method (default) + psmooth = 5: passes of neighborgh filtering (3x3-grid point mean) of psfc for psl_diag=2 (default 5) + ptarget = 70000.: pressure [Pa] target to be used by psl_diag=2 (default 70000.) + output_wb = 1: whether water-budget variables have to computed (1) or not (0, default) + wsgs_diag = 1: wind-gust diagnostic following Brasseur, 2001, MWR (default) + = 2: wsgs folllowing heavy precipitation method + wsz100_diag = 1: wind extraoplation at z100m_wind using power-law method (default) + = 2: wind extraoplation at z100m_wind using Monin-Obukhov theory + z100_wind = 100.: height to extraplate winds (100. default) + zmlagen_dqv = 0.1: percentage of variation of mixing ratio to determine mixed layer depth used in zmla computation (0.1 default) + zmlagen_dtheta = 1.5: increment in K of potantial temperature from its minimum within the MLD used in zmla computation (1.5 default) + integer potevp_diag = 1: potential evapotranspiration diagnostic following Penman-Monteith as in ORCHIDEE (default) + convxtrm_diag = 0: diagnostic of extremes from convection indices: 0: No (default); 1: yes + fogvisibility_diag = 1: diagnostic of visibility inside fog following Kunkel (1984) + = 2: RUC method (Smirnova et al., 2000) + = 3: FRAML 50% prob Gultepe and Milbrandt, (2010) (default) + fogvars = 1: variables to use to diagnose fog using 3D [hur] (default) + = 2: sfc [hus] (not available for Kunkel, 1984) + zmlagen_diag = 1: diagnostic of generic zmla after Nielsen-Gammon et al. (2008) + = 2: bulk-Richardson (Vogelezang and Holtslag, 1996; Seidel et al., 2004) (default) + timedbg = frequency in minutes of time-debugging (720, default) + londbg = longitude in degrees of grid-point debugging (-999., not used) (-999., default) + latdbg = latitude in degrees of grid-point debugging (-999., not used) (-999., default) + wgsts_wbdswsstres = whether wind gusts should be used for wbds-wss residence-time (0: no, 1: yes (1, default) + +#### ONLY for CDXWRF>=3 + nhtasrng = amount + 1 of high-resolution bins for temporal residence of tas (38, default) + nhhursrng = amount + 1 of high-resolution bins for temporal residence of hurs (25, default) + nltasrng = amount + 1 of low-resolution bins for temporal residence of tas (21, default) + nlhursrng = amount + 1 of low-resolution bins for temporal residence of hurs (25, default) + nwbdsrng = amount + 1 of bins for temporal residence of wbds (33, default) + nwssrng = amount + 1 of bins for temporal residence of wss (22, default) + nhtashursrng = amount + 1 of high-resolution bins for temporal residence of tas and hurs (nhtas+1)*(nhhurs+1) (950, default) + nltashursrng = amount + 1 of low-resolution bins for temporal residence of wss and wbds (nwbds+1)*(nwss+1) (525, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) (726, default) + htasrng = high-resolution bins for temporal residence of tas (/173.15,268.15,269.15,270.15,271.15,272.15,273.15, + 274.15,275.15,276.15,277.15,278.15,279.15,280.15,281.15,282.15,283.15,284.15,285.15,286.15,287.15,288.15,289.15, + 290.15,291.15,292.15,293.15,294.15,295.15,296.15,297.15,298.15,299.15,300.15,301.15,302.15,303.15,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + hhursrng = high-resolution bins for temporal residence of hurs (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40, + 0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + ltasrng = low-resolution bins for temporal residence of tas (/173.15,233.15,238.15,243.15,248.15,253.15, + 258.15,263.15,268.15,273.15,278.15,283.15,288.15,293.15,298.15,303.15,308.15,313.15,318.15,323.15,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00/) + lhursrng = low-resolution bins for temporal residence of hurs (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45, + 0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00, + 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) + wbdsrng = bins for temporal residence of wbds (/-0.0982,0.0982,0.2945,0.4909,0.6872,0.8836, + 1.0799,1.2763,1.4726,1.669,1.8653,2.0617,2.258,2.4544,2.6507,2.8471,3.0434,3.2398,3.4361,3.6325,3.8288, + 4.0252,4.2215,4.4179,4.6142,4.8106,5.0069,5.2033,5.3996,5.596,5.7923,5.9887,6.185,0.0,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) + wssrng = bins for temporal residence of wss (/0.0,0.5,1.0,2.5,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,45.0, + 50.0,60.0,70.0,80.0,90.0,100.0,125.0,150.0,200.0,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) +/ +``` + + - `convxtrm_diag` parameter has only effect with `CDXWRF=1` + - `outputwb`, `fogvisibility_diag` and `fogvars` parameters has only effect with `CDXWRF=2` + +###### Optional values for wbds & wss residence-time +In the code, user is provided with 2 different complementary set-ups for the wbds & wss residence-time + +kt-based +The references for wind-speed are based on knots (kt) + - wss: [0., 2.5, 5., 10., 15., 20., 25., 30., 35., 40.. 45., 50., 60., 70., 80., 100., 150., 200., 250., 300. ] + - Transforming to ms-1 as wss = kt * 1852. / 3600. +``` + nwssrng = amount + 1 of bins for temporal residence of wss kt-based (20, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) kt-based (660, default) + wssrng = bins for temporal residence of wss kt based (/0.0,1.2861,2.5722,5.1444,7.7167,10.2889,12.8611, + 15.4333,18.0056,20.5778,23.15,25.7222,30.8667,36.0111,41.1556,51.4444,77.1667,102.8889,128.6111,154.3333,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) +``` + +Beafourt scale-based +The references of wind speed are based on the [Beafourt](https://en.wikipedia.org/wiki/Beaufort_scale) scale + - wss: [0., 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 21.5, 23.5, 25.5, 27.5, 29.5, 31.5] + - Transforming to ms-1 as wss = 0.836*Bnum**(3./2.) +``` + nwssrng = amount + 1 of bins for temporal residence of wss Beafourt-based (27, default) + nwbdswssrng = amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) Beafourt-based (891, default) + wssrng = bins for temporal residence of wss Beafourt-based (/0.0,0.2956,1.5358,3.3046,5.474,7.9804,10.7833, + 13.854,17.1711,20.7174,24.4789,28.444,32.6027,36.9463,41.4674,46.1592,51.0157,56.0315,61.2017,66.5218,71.9877,83.342, + 95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, + 0.0,0.0,0.0,0.0,0.0/) +``` + +#### Pressure interpolation + Remember to activate section `&diags` in order to get pressure-level vertical interpolation of state variables (assuming 6 levels only) +``` + auxhist23_outname=”wrfpress_d_” + io_form_auxhist23 = 2, + auxhist23_interval = 180, 60, + frames_per_auxhist23 = 8, 24, + +&diags + p_lev_diags = 1, + num_press_levels = 6, + press_levels = 100000, 92500, 85000, 70000, 50000, 20000 + use_tot_or_hyd_p = 1 + p_lev_missing = -999. +/ +``` + +- Optional for 23 p-level values: +``` + num_press_levels = 23, + press_levels = 100000,97500,95000,92500,90000,87500,85000,82500,80000,75000,70000,65000,60000,55000,50000,45000,40000,35000, + 30000,25000,20000,15000,10000, +``` + +The module will provide additional mass-conservative vertically integrated values for the water species diff --git a/Registry/Registry.EM_COMMON b/Registry/Registry.EM_COMMON index 4d133c9bfa..d8566e4668 100644 --- a/Registry/Registry.EM_COMMON +++ b/Registry/Registry.EM_COMMON @@ -65,8 +65,9 @@ state real LU_MASK ij misc 1 - i3h1 "LU state real znu k dyn_em 1 - irh "znu" "eta values on half (mass) levels" "" state real znw k dyn_em 1 Z i0rh "znw" "eta values on full (w) levels" "" -state real ZS l misc - Z irh "ZS" "DEPTHS OF CENTERS OF SOIL LAYERS" "m" -state real DZS l misc - Z irh "DZS" "THICKNESSES OF SOIL LAYERS" "m" +# CDXWRF modification +state real ZS l misc - Z irh0{19} "ZS" "DEPTHS OF CENTERS OF SOIL LAYERS" "m" +state real DZS l misc - Z irh0{19} "DZS" "THICKNESSES OF SOIL LAYERS" "m" # cyl : variables for trajectory calculation state real traj_i {ntraj} dyn_em 1 Z irh "traj_i" "grid number of trajectory " "" state real traj_j {ntraj} dyn_em 1 Z irh "traj_j" "grid number of trajectory " "" @@ -1413,7 +1414,7 @@ i1 real ht_loc ij misc 1 - - state integer shadowmask ij misc 1 - - state integer min_ptchsz - misc 1 - r -state real TSK ij misc 1 - i012rhd=(interp_mask_field:lu_index,iswater)u=(copy_fcnm) "TSK" "SURFACE SKIN TEMPERATURE" "K" +state real TSK ij misc 1 - i012rh0d=(interp_mask_field:lu_index,iswater)u=(copy_fcnm) "TSK" "SURFACE SKIN TEMPERATURE" "K" state real dfi_TSK ij misc 1 - r "TSK_dfi" "saved SURFACE SKIN TEMPERATURE" state real TSK_SAVE ij misc 1 - r "TSK_SAVE" "SURFACE SKIN TEMPERATURE, EXTRA COPY FOR SEA ICE TESTS in REAL" "K" state real u_base k misc 1 - ir "u_base" "BASE STATE X WIND IN IDEALIZED CASES" "" @@ -1947,7 +1948,7 @@ state integer NYEAR - misc 1 - r "NY state real NDAY - misc 1 - r "NDAY" "ACCUM TIMESTEPS IN A DAY" "" state real XLAND ij misc 1 - i02rhd=(interp_fcnm_imask)u=(copy_fcnm) "XLAND" "LAND MASK (1 FOR LAND, 2 FOR WATER)" "" state real cplmask i{ncpldom}j misc 1 z i0r "CPLMASK" "COUPLING MASK (0:VALUE FROM SST UPDATE; 1:VALUE FROM COUPLED OCEAN), vertical dim is number of external domains" "" -state real ZNT ij misc 1 - i3r "ZNT" "TIME-VARYING ROUGHNESS LENGTH" "m" +state real ZNT ij misc 1 - i3rh "ZNT" "TIME-VARYING ROUGHNESS LENGTH" "m" state real CK ij misc 1 - r "CK" "ENTHALPY EXCHANGE COEFF AT 10 m" "" state real CKA ij misc 1 - r "CKA" "ENTHALPY EXCHANGE COEFF AT LOWEST MODEL LVL" "" state real CD ij misc 1 - r "CD" "DRAG COEFF AT 10m" "" diff --git a/Registry/Registry.EM_COMMON.var b/Registry/Registry.EM_COMMON.var index 5df5eedcc0..66d894f8d6 100644 --- a/Registry/Registry.EM_COMMON.var +++ b/Registry/Registry.EM_COMMON.var @@ -312,12 +312,12 @@ state real RAINNCV ij misc 1 - r "R # these next 2 are for the HFSoLE/PET demo; writing these to auxhist1 output over MCEL for coupling # with wave model, only if compiled with -DMCELIO, JM 2003/05/29 -state real XLAT ij misc 1 - i0123rh01du=(copy_fcnm) "XLAT" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" -state real XLONG ij misc 1 - i0123rh01du=(copy_fcnm) "XLONG" "LONGITUDE, WEST IS NEGATIVE" "degree_east" -state real XLAT_U ij dyn_em 1 X i012rh01du=(copy_fcnm) "XLAT_U" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" -state real XLONG_U ij dyn_em 1 X i012rh01du=(copy_fcnm) "XLONG_U" "LONGITUDE, WEST IS NEGATIVE" "degree_east" -state real XLAT_V ij dyn_em 1 Y i012rh01du=(copy_fcnm) "XLAT_V" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" -state real XLONG_V ij dyn_em 1 Y i012rh01du=(copy_fcnm) "XLONG_V" "LONGITUDE, WEST IS NEGATIVE" "degree_east" +state real XLAT ij misc 1 - i0123rh01{23}du=(copy_fcnm) "XLAT" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" +state real XLONG ij misc 1 - i0123rh01{23}du=(copy_fcnm) "XLONG" "LONGITUDE, WEST IS NEGATIVE" "degree_east" +state real XLAT_U ij dyn_em 1 X i012rh01{23}du=(copy_fcnm) "XLAT_U" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" +state real XLONG_U ij dyn_em 1 X i012rh01{23}du=(copy_fcnm) "XLONG_U" "LONGITUDE, WEST IS NEGATIVE" "degree_east" +state real XLAT_V ij dyn_em 1 Y i012rh01{23}du=(copy_fcnm) "XLAT_V" "LATITUDE, SOUTH IS NEGATIVE" "degree_north" +state real XLONG_V ij dyn_em 1 Y i012rh01{23}du=(copy_fcnm) "XLONG_V" "LONGITUDE, WEST IS NEGATIVE" "degree_east" state real ALBEDO ij misc 1 - rh "ALBEDO" "ALBEDO" state real CLAT ij misc 1 - i012rhdu=(copy_fcnm) "CLAT" "COMPUTATIONAL GRID LATITUDE, SOUTH IS NEGATIVE" "degree_north" state real ALBBCK ij misc 1 - i0124rh "ALBBCK" "BACKGROUND ALBEDO" "" diff --git a/Registry/registry.cordex b/Registry/registry.cordex new file mode 100644 index 0000000000..0620ab172d --- /dev/null +++ b/Registry/registry.cordex @@ -0,0 +1,390 @@ +# Definition of variables for the computation during model integration of the required CORDEX variables +## L. Fita, CIMA. December 2017 + +# CORDEX Diagnostics package namelist options +rconfig integer output_cordex namelist,cordex 1 0 rh "output_cordex" "CORDEX Diagnostic activation, 1:on" "" +rconfig integer psl_diag namelist,cordex 1 3 rh "psl_diag" "psl diagnostic: 1: hydrostatic Shuell correction; 2: pressure target; 3: ECMWF" "" +rconfig integer psmooth namelist,cordex 1 5 rh "psmooth" "passes of neighbourgh filtering (mean of 3x3-grid points) of psfc for psl_diag=2" "" +rconfig real ptarget namelist,cordex 1 70000. rh "ptarget" "pressure [Pa] target to be used by psl_diag=2" "" +rconfig integer wsgs_diag namelist,cordex 1 1 rh "wsgs_diag" "wind-gust diagnostic: 1: Brasseur, 2001, MWR; 2: heavy precipitation" "" +rconfig integer output_wb namelist,cordex 1 0 rh "output_wb" "FF Water-Budget activation, 1:on" "" +rconfig integer wsz100_diag namelist,cordex 1 1 rh "wsz100_diag" "wind 100m-extrapolation diagnostic: 1: power-law; 2: logarithmic-law, 3: Monin-Obukhov" "" +rconfig real z100m_wind namelist,cordex 1 100. rh "z100m_wind" "height [m] at which 100m wind should be extrapolated" "" +rconfig real z50m namelist,cordex 1 50. rh "z50m" "height [m] at which 50m variables should be extrapolated" "" +rconfig real zmlagen_dqv namelist,cordex 1 0.1 rh "zmlagen_dtqv" "percentage of variation [1] of mixing ratio (qv) to determine mixed layer depth" "" +rconfig real zmlagen_dtheta namelist,cordex 1 1.5 rh "zmlagen_dtheta" "increment [K] of potential temperature (theta) within MLD to determine zmla" "" +rconfig integer potevp_diag namelist,cordex 1 2 rh "potevp_diag" "potential evapotranspiration diagnostic: 1: bulk computation, 2: Milly92 method (Milly, 1992) similar to ORCHIDEE;" "" +rconfig integer convxtrm_diag namelist,cordex 1 0 rh "convxtrm_diag" "diagnostic of extremes from convection indices: 0: No; 1: yes" "" +rconfig integer fogvisibility_diag namelist,cordex 1 3 rh "fogvisibility_diag" "diagnostic of visibility inside fog: 1: Kunkel (1984), 2: RUC method (Smirnova et al., 2000); 3: FRAML 50% prob Gultepe and Milbrandt, (2010)" "" +rconfig integer fogvars namelist,cordex 1 1 rh "fogvars" "variables to use to diagnose fog (1: 3D, 2: sfc)" "" +rconfig integer zmlagen_diag namelist,cordex 1 2 rh "zmlagen_diag" "diagnostic of generic zmla: 1: Nielsen-Gammon et al. (2008), 2: bulk-Richardson (Vogelezang and Holtslag, 1996; Seidel et al., 2004)" "" +rconfig integer timedbg namelist,cordex 1 720 rh "timedbg" "frecuency in minutes of time-debugging" "" +rconfig real londbg namelist,cordex 1 -999. rh "londbg" "longitude in degrees of grid-point debugging (-999., not used)" "" +rconfig real latdbg namelist,cordex 1 -999. rh "latdbg" "latitude in degrees of grid-point debugging (-999., not used)" "" +rconfig integer wgsts_wbdswsstres namelist,cordex 1 1 rh "wgsts_wbdswsstres" "whether wind gusts should be used for wbds-wss residence-time (0: no, 1: yes)" "" + +## L. Fita. This should work, but WRF is not prepared for 4D output variables like this +##CDXWRF3##rconfig integer nhtasrng namelist,cordex 1 38 rh "nhtasrng" "amount + 1 of high-resolution bins for temporal residence of tas" "" +##CDXWRF3##rconfig integer nhhursrng namelist,cordex 1 25 rh "nhhursrng" "amount + 1 of high-resolution bins for temporal residence of hurs" "" +##CDXWRF3##rconfig integer nltasrng namelist,cordex 1 21 rh "nltasrng" "amount + 1 of low-resolution bins for temporal residence of tas" "" +##CDXWRF3##rconfig integer nlhursrng namelist,cordex 1 25 rh "nlhursrng" "amount + 1 of low-resolution bins for temporal residence of hurs" "" +##CDXWRF3##rconfig integer nwbdsrng namelist,cordex 1 33 rh "nwbdsrng" "amount + 1 of bins for temporal residence of wbds" "" +# SI-based +##CDXWRF3##rconfig integer nwssrng namelist,cordex 1 22 rh "nwssrng" "amount + 1 of bins for temporal residence of wss" "" +# kt-based: [0., 2.5, 5., 10., 15., 20., 25., 30., 35., 40.. 45., 50., 60., 70., 80., 100., 150., 200., 250., 300. ] +# Transforming to ms-1 as wss = kt * 1852. / 3600. +###CDXWRF3##rconfig integer nwssrng namelist,cordex 1 20 rh "nwssrng" "amount + 1 of bins for temporal residence of wss kt-based" "" +# Beafourt scale-based: [0., 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, +# 16.5, 17.5, 18.5, 19.5, 21.5, 23.5, 25.5, 27.5, 29.5, 31.5] +# FROM: https://en.wikipedia.org/wiki/Beaufort_scale +# Transforming to ms-1 as wss = 0.836*Bnum**(3./2.) +###CDXWRF3##rconfig integer nwssrng namelist,cordex 1 27 rh "nwssrng" "amount + 1 of bins for temporal residence of wss Beafourt-based" "" +## L. Fita, so, WRF output will provide a (n[h/l]tasrng*n[h/l]hursrng) 3D variable instead +##CDXWRF3##rconfig integer nhtashursrng namelist,cordex 1 950 rh "nhtashursrng" "amount + 1 of high-resolution bins for temporal residence of tas and hurs (nhtas+1)*(nhhurs+1)" "" +##CDXWRF3##rconfig integer nltashursrng namelist,cordex 1 525 rh "nltashursrng" "amount + 1 of low-resolution bins for temporal residence of wss and wbds (nwbds+1)*(nwss+1)" "" +##CDXWRF3##rconfig integer nwbdswssrng namelist,cordex 1 726 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1)" "" +###CDXWRF3##rconfig integer nwbdswssrng namelist,cordex 1 660 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) kt-based" "" +###CDXWRF3##rconfig integer nwbdswssrng namelist,cordex 1 891 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) Beafourt-based" "" +##CDXWRF3##rconfig real htasrng namelist,cordex max_lbins (/173.15,268.15,269.15,270.15,271.15,272.15,273.15,274.15,275.15,276.15,277.15,278.15,279.15,280.15,281.15,282.15,283.15,284.15,285.15,286.15,287.15,288.15,289.15,290.15,291.15,292.15,293.15,294.15,295.15,296.15,297.15,298.15,299.15,300.15,301.15,302.15,303.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "htasrng" "high-resolution bins for temporal residence of tas" "" +##CDXWRF3##rconfig real hhursrng namelist,cordex max_lbins (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "hhursrng" "high-resolution bins for temporal residence of hurs" "" +##CDXWRF3##rconfig real ltasrng namelist,cordex max_lbins (/173.15,233.15,238.15,243.15,248.15,253.15,258.15,263.15,268.15,273.15,278.15,283.15,288.15,293.15,298.15,303.15,308.15,313.15,318.15,323.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "ltasrng" "low-resolution bins for temporal residence of tas" "" +##CDXWRF3##rconfig real lhursrng namelist,cordex max_lbins (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "lhursrng" "low-resolution bins for temporal residence of hurs" "" +##CDXWRF3##rconfig real wbdsrng namelist,cordex max_lbins (/-0.0982,0.0982,0.2945,0.4909,0.6872,0.8836,1.0799,1.2763,1.4726,1.669,1.8653,2.0617,2.258,2.4544,2.6507,2.8471,3.0434,3.2398,3.4361,3.6325,3.8288,4.0252,4.2215,4.4179,4.6142,4.8106,5.0069,5.2033,5.3996,5.596,5.7923,5.9887,6.185,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wbdsrng" "bins for temporal residence of wbds" "" +##CDXWRF3##rconfig real wssrng namelist,cordex max_lbins (/0.0,0.5,1.0,2.5,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,45.0,50.0,60.0,70.0,80.0,90.0,100.0,125.0,150.0,200.0,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss" "" +###CDXWRF3##rconfig real wssrng namelist,cordex max_lbins (/0.0,1.2861,2.5722,5.1444,7.7167,10.2889,12.8611,15.4333,18.0056,20.5778,23.15,25.7222,30.8667,36.0111,41.1556,51.4444,77.1667,102.8889,128.6111,154.3333,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss kt-based" "" +###CDXWRF3##rconfig real wssrng namelist,cordex max_lbins (/0.0,0.2956,1.5358,3.3046,5.474,7.9804,10.7833,13.854,17.1711,20.7174,24.4789,28.444,32.6027,36.9463,41.4674,46.1592,51.0157,56.0315,61.2017,66.5218,71.9877,83.342,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss Beafourt-based" "" + +# CORDEX variables +state integer cdxnsteps - misc - - r "cdxnsteps" "CORDEX Time Step Counter" "" +state integer cdxhfnsteps - misc - - r "cdxhfnsteps" "CORDEX High-Frequemcy Time Step Counter" "" +state integer ijdbg {iit} misc - - rh{19} "ijdbg" "i,j-grid points from londbg,latdbg for debugging" "-" +state real CDXLON ij misc 1 - h{18}{19} "lon" "LONGITUDE" "degrees_east" +state real CDXLAT ij misc 1 - h{18}{19} "lat" "LATITUDE" "degrees_north" +state real PCLT ij misc 1 - r "pclt" "PREVIOUS TOTAL CLOUDINESS" "%" +state real PCLL ij misc 1 - r "pcll" "PREVIOUS LOW-LEVEL CLOUDINESS (p >= 68000 Pa)" "%" +state real PCLM ij misc 1 - r "pclm" "PREVIOUS MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa)" "%" +state real PCLH ij misc 1 - r "pclh" "PREVIOUS HIGH-LEVEL CLOUDINESS (p < 44000 Pa)" "%" +state real CLTMEAN ij misc 1 - rh{19} "cltmean" "MEAN TOTAL CLOUDINESS IN CORDEX OUTPUT" "%" +state real CLLMEAN ij misc 1 - rh{19} "cllmean" "MEAN LOW-LEVEL CLOUDINESS (p >= 68000 Pa) IN CORDEX OUTPUT" "%" +state real CLMMEAN ij misc 1 - rh{19} "clmmean" "MEAN MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa) IN CORDEX OUTPUT" "%" +state real CLHMEAN ij misc 1 - rh{19} "clhmean" "MEAN HIGH-LEVEL CLOUDINESS (p < 44000 Pa) IN CORDEX OUTPUT" "%" +state real PRW ij misc 1 - h{19} "prw" "WATER VAPOR PATH" "kgm-2" +state real PSL ij misc 1 - h{19} "psl" "SEA LEVEL PRESSURE" "Pa" +state real CLWVI ij misc 1 - h{19} "clwvi" "LIQUID WATER PATH" "kgm-2" +state real CLIVI ij misc 1 - h{19} "clivi" "ICE WATER PATH" "kgm-2" +state real HURS ij misc 1 - h{19} "hurs" "2M RELATIVE HUMIDITY" "1" +state real HUSS ij misc 1 - h{19} "huss" "2M SPECIFIC HUMIDITY" "1" +state real UAS ij misc 1 - h{19} "uas" "10M EARTH ROTATED EASTWARD WIND SPEED" "ms-1" +state real VAS ij misc 1 - h{19} "vas" "10M EARTH ROTATED NORTHWARD WIND SPEED" "ms-1" +state real WBDS ij misc 1 - h{19} "wbds" "10M EARTH ROTATED BLOWING WIND DIRECTION (from where it blows)" "ms-1" +state real WSS ij misc 1 - h{19} "wss" "10M WIND SPEED" "ms-1" +state real WSGSMAX ij misc 1 - rh{19} "wsgsmax" "Maximum near-surface wind speed of gust" "ms-1" +state real UGSMAX ij misc 1 - rh{19} "ugsmax" "Eastward maximum near-surface wind speed of gust" "ms-1" +state real VGSMAX ij misc 1 - rh{19} "vgsmax" "Northward maximum near-surface wind speed of gust" "ms-1" +state real WSGSPERCEN ij misc 1 - rh{19} "wsgspercen" "Percentage of time steps where grid point got wind gust" "%" +state real TOTWSGSMAX ij misc 1 - rh{19} "totwsgsmax" "Total (TKE + h. pr) Maximum near-surface wind speed of gust" "ms-1" +state real TOTUGSMAX ij misc 1 - rh{19} "totugsmax" "Total Eastward maximum near-surface wind speed of gust" "ms-1" +state real TOTVGSMAX ij misc 1 - rh{19} "totvgsmax" "Total Northward maximum near-surface wind speed of gust" "ms-1" +state real TOTWSGSPERCEN ij misc 1 - rh{19} "totwsgspercen" "Percentage of time steps where grid point got total wind gust" "%" +state real WSZ100 ij misc 1 - h{19} "wsz100" "100m wind speed" "ms-1" +state real UZ100 ij misc 1 - h{19} "uz100" "Eastward 100 m wind speed" "ms-1" +state real VZ100 ij misc 1 - h{19} "vz100" "Northward 100 m wind speed" "ms-1" +state real WSZ50 ij misc 1 - h{19} "wsz50" "50m wind speed" "ms-1" +state real UZ50 ij misc 1 - h{19} "uz50" "Eastward 50 m wind speed" "ms-1" +state real VZ50 ij misc 1 - h{19} "vz50" "Northward 50 m wind speed" "ms-1" +state real TAZ50 ij misc 1 - h{19} "taz50" "50 m air temperature" "K" +state real QVZ50 ij misc 1 - h{19} "qvz50" "50 m water vapour" "kgkg-1" +state real WSZ100MAX ij misc 1 - rh{19} "wsz100max" "Maximum 100m nwind speed" "ms-1" +state real UZ100MAX ij misc 1 - rh{19} "uz100max" "Eastward maximum 100 m wind speed" "ms-1" +state real VZ100MAX ij misc 1 - rh{19} "vz100max" "Northward maximum 100 m wind speed" "ms-1" +state real SUND ij misc 1 - rh{19} "sund" "SUNSHINE LENGTH (ac. time SWDOWN > 120. Wm-2)" "second" +state real TAUU ij misc 1 - h{19} "tauu" "easthward downward wind stress at 10 m" "m2s-2" +state real TAUV ij misc 1 - h{19} "tauv" "northtward downward wind stress at 10 m" "m2s-2" +state real TAUUGEN ij misc 1 - h{19} "tauugen" "generic eastward downward wind stress at 10 m" "m2s-2" +state real TAUVGEN ij misc 1 - h{19} "tauvgen" "generic northward downward wind stress at 10 m" "m2s-2" +state real RSDS ij misc 1 - rh{19} "rsds" "mean surface Downwelling Shortwave Radiation" "Wm-2" +state real RLDS ij misc 1 - rh{19} "rlds" "mean surface Downwelling Longwave Radiation" "Wm-2" +state real HFLS ij misc 1 - rh{19} "hfls" "mean surface Upward Latent Heat Flux" "Wm-2" +state real HFSS ij misc 1 - rh{19} "hfss" "mean surface Upward Sensible Heat Flux" "Wm-2" +state real RSUS ij misc 1 - rh{19} "rsus" "mean surface Upwelling Shortwave Radiation" "Wm-2" +state real RLUS ij misc 1 - rh{19} "rlus" "mean surface Upwelling Longwave Radiation" "Wm-2" +state real rsusgen ij misc 1 - rh{19} "rsusgen" "mean generic surface Upwelling Shortwave Radiation" "Wm-2" +state real rlusgen ij misc 1 - rh{19} "rlusgen" "mean generic surface Upwelling Longwave Radiation" "Wm-2" +state real EVSPSBL ij misc 1 - rh{19} "evspsbl" "mean evaporation" "kgm-2s-1" +state real EVSPSBLPOT ij misc 1 - rh{19} "evspsblpot" "mean potential evapotranspiration" "kgm-2s-1" +state real EVSPSBLPOTGEN ij misc 1 - rh{19} "evspsblpotgen" "mean generic potential evapotranspiration" "kgm-2s-1" +state real CDCDX ij misc 1 - h{19} "cdcdx" "drag coefficient" "-" +state real CDGEN ij misc 1 - h{19} "cdgen" "generic drag coefficient" "-" +state real SNC ij misc 1 - rh{19} "snc" "mean snow area fraction" "%" +state real SND ij misc 1 - rh{19} "snd" "mean snow depth" "m" +state real PMRROS ij misc 1 - r "pmrros" "previous accumulated surface Runoff" "kgm-2" +state real PMRRO ij misc 1 - r "pmrro" "previous accumulated total Runoff" "kgm-2" +state real MRROS ij misc 1 - rh{19} "mrros" "mean surface Runoff" "kgm-2s-1" +state real MRRO ij misc 1 - rh{19} "mrro" "mean total Runoff" "kgm-2s-1" +state real fracsoil10cm l misc 1 - rh{19} "fracsoil10cm" "Fraction of soil layer to compute soil acc. down to 10 cm" "1." +state real MRSO ij misc 1 - h{19} "mrso" "Total Soil Moisture Content" "kgm-2" +state real MRSOS ij misc 1 - h{19} "mrsos" "Moisture in Upper Portion of Soil Column (0-10cm)" "kgm-2" +state real MRSOL ilj misc 1 - h{19} "mrsol" "total water content of soil layer" "kgm-2" +state real MRSLL ilj misc 1 - h{19} "mrsll" "liquid water content of soil layer" "kgm-2" +state real MRLSO ij misc 1 - h{19} "mrlso" "total liquid water content of soil layer" "kgm-2" +state real MRLSOS ij misc 1 - h{19} "mrlsos" "liquid water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSFL ilj misc 1 - h{19} "mrsfl" "frozen water content of soil layer" "kgm-2" +state real MRFSO ij misc 1 - h{19} "mrfso" "total frozen water content of soil layer" "kgm-2" +state real MRFSOS ij misc 1 - h{19} "mrfsos" "frozen water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSOMEAN ij misc 1 - rh{19} "mrsomean" "mean total Soil Moisture Content" "kgm-2" +state real MRSOSMEAN ij misc 1 - rh{19} "mrsosmean" "mean moisture in Upper Portion of Soil Column (0-10cm)" "kgm-2" +state real MRSOLMEAN ilj misc 1 - rh{19} "mrsolmean" "mean total water content of soil layer" "kgm-2" +state real MRSLLMEAN ilj misc 1 - rh{19} "mrsllmean" "mean liquid water content of soil layer" "kgm-2" +state real MRLSOMEAN ij misc 1 - rh{19} "mrlsomean" "mean total liquid water content of soil layer" "kgm-2" +state real MRLSOSMEAN ij misc 1 - rh{19} "mrlsosmean" "mean liquid water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSFLMEAN ilj misc 1 - rh{19} "mrsflmean" "mean frozen water content of soil layer" "kgm-2" +state real MRFSOMEAN ij misc 1 - rh{19} "mrfsomean" "mean total frozen water content of soil layer" "kgm-2" +state real MRFSOSMEAN ij misc 1 - rh{19} "mrfsosmean" "mean frozen water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real pr ij misc 1 - rh{19} "pr" "precipitation flux" "kgm-2s-1" +state real prl ij misc 1 - rh{19} "prl" "large scale precipitation flux" "kgm-2s-1" +state real prc ij misc 1 - rh{19} "prc" "convective precipitation flux" "kgm-2s-1" +state real prsh ij misc 1 - rh{19} "prsh" "shallow-cumulus precipitation flux" "kgm-2s-1" +state real prsn ij misc 1 - rh{19} "prsn" "solid precipitation flux" "kgm-2s-1" +state real snw ij misc 1 - rh{19} "snw" "accumulated snow precipitation" "kgm-2" +state real rsdt ij misc 1 - rh{19} "rsdt" "mean top of the atmosphere (TOA) incident shortwave radiation" "kgm-2" +state real rsut ij misc 1 - rh{19} "rsut" "mean TOA outgoing shortwave radiation" "kgm-2" +state real rlut ij misc 1 - rh{19} "rlut" "mean TOA outgoing Longwave radiation" "kgm-2" +state real cdxps ij misc 1 - rh{19} "cdxps" "surface pressure" "Pa" +state real cdxts ij misc 1 - rh{19} "cdxts" "skin temperature" "K" +state real tas_hm ij misc 1 - rh{19} "tas_hm" "Corrector-calculator (Hess-McAvaney, 1995) 2m-temperature" "K" +state real qvs_hm ij misc 1 - rh{19} "qvs_hm" "Corrector-calculator (Hess-McAvaney, 1995) 2m water vapor mixing ratio" "K" + +# Uncomment this section to get these variables (replace '##CDXWRF1##state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=1' (following line after '-DCORDEXDIAG') +# 1.- Remove ##CDXWRF1## +# 2.- ./clean -a +# 3.- recompile + +##CDXWRF1##state real ZMLAGEN ij misc 1 - h{19} "zmlagen" "Generic boundary layer height theta(zmlagen) > min(theta[mix. layer]) + 1.5K" "m" +##CDXWRF1##state real CLGVI ij misc 1 - h{19} "clgvi" "GRAUPEL WATER PATH" "kgm-2" +##CDXWRF1##state real CLHVI ij misc 1 - h{19} "clhvi" "HAIL WATER PATH" "kgm-2" +##CDXWRF1##state real CAPEMIN ij misc 1 - rh{19} "capemin" "minimum convective available potential energy" "Jkg-1" +##CDXWRF1##state real CAPEMAX ij misc 1 - rh{19} "capemax" "maximum convective available potential energy" "Jkg-1" +##CDXWRF1##state real CAPEMEAN ij misc 1 - rh{19} "capemean" "mean convective available potential energy" "Jkg-1" +##CDXWRF1##state real CINMIN ij misc 1 - rh{19} "cinmin" "minimum convective inhibition" "Jkg-1" +##CDXWRF1##state real CINMAX ij misc 1 - rh{19} "cinmax" "maximum convective inhibition" "Jkg-1" +##CDXWRF1##state real CINMEAN ij misc 1 - rh{19} "cinmean" "mean convective inhibition" "Jkg-1" +##CDXWRF1##state real LFCPMIN ij misc 1 - rh{19} "lfcpmin" "minimum pressure level free convection" "Pa" +##CDXWRF1##state real LFCPMAX ij misc 1 - rh{19} "lfcpmax" "maximum pressure level free convection" "Pa" +##CDXWRF1##state real LFCPMEAN ij misc 1 - rh{19} "lfcpmean" "mean pressure level free convection" "Pa" +##CDXWRF1##state real LFCZMIN ij misc 1 - rh{19} "lfczmin" "minimum height level free convection" "m" +##CDXWRF1##state real LFCZMAX ij misc 1 - rh{19} "lfczmax" "maximum height level free convection" "m" +##CDXWRF1##state real LFCZMEAN ij misc 1 - rh{19} "lfczmean" "mean height level free convection" "m" +##CDXWRF1##state real LIMEAN ij misc 1 - rh{19} "limean" "mean lifted index" "1" +##CDXWRF1##state real LIMIN ij misc 1 - rh{19} "limin" "minimum lifted index" "1" +##CDXWRF1##state real LIMAX ij misc 1 - rh{19} "limax" "maximum lifted index" "1" +##CDXWRF1##state real IUTMEAN ij misc 1 - rh{19} "iutmean" "mean vertically integrated eastward transport of water vapour" "kgm-1s-1" +##CDXWRF1##state real IVTMEAN ij misc 1 - rh{19} "ivtmean" "mean vertically integrated northward transport of water vapour" "kgm-1s-1" +##CDXWRF1##state real ZEROISOTHERM ij misc 1 - h{19} "zeroisotherm" "height above ground of the 0-isotherm" "m" +##CDXWRF1##state real prhf ij misc 1 - rh{18} "prhf" "precipitation flux" "kgm-2s-1" +##CDXWRF1##state real COLMAX ij misc 1 - h{18} "colmax" "instantaneous maximum radar reflectivity in the column" "dBz" + +# Instantaneous values. If one require them into the output, modify the second '-' by 'h{19}' +##CDXWRF1##state real IUT ij misc 1 - - "iut" "instantaneous vertically integrated eastward transport of water vapour" "kgm-1s-1" +##CDXWRF1##state real IVT ij misc 1 - - "ivt" "instantaneous vertically integrated northward transport of water vapour" "kgm-1s-1" + +# Uncomment this section to get these variables (replace '##CDXWRF2##state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=2' (following line after '-DCORDEXDIAG') +# 1.- Remove ##CDXWRF2## +# 2.- ./clean -a +# 3.- recompile + +##CDXWRF2##state real tfog ij misc 1 - rh{19} "tfog" "time of presence of fog" "seconds" +##CDXWRF2##state real fogvisbltymin ij misc 1 - rh{19} "fogvisbltymin" "minimum of visibility inside fog" "km" +##CDXWRF2##state real fogvisbltymax ij misc 1 - rh{19} "fogvisbltymax" "maximum of visibility inside fog" "km" +##CDXWRF2##state real fogvisbltymean ij misc 1 - rh{19} "fogvisbltymean" "mean of visibility inside fog" "km" +##CDXWRF2##state real tdsmin ij misc 1 - rh{19} "tdsmin" "minimum surface dew point temperature" "K" +##CDXWRF2##state real tdsmax ij misc 1 - rh{19} "tdsmax" "maximum surface dew point temperature" "K" +##CDXWRF2##state real tdsmean ij misc 1 - rh{19} "tdsmean" "mean surface dew point temperature" "K" +##CDXWRF2##state real twsmin ij misc 1 - rh{19} "twsmin" "minimum surface wet-bulb temperature" "K" +##CDXWRF2##state real twsmax ij misc 1 - rh{19} "twsmax" "maximum surface wet-bulb temperature" "K" +##CDXWRF2##state real twsmean ij misc 1 - rh{19} "twsmean" "mean surface wet-bulb temperature" "K" + +# 3D +##CDXWRF2##state real HUR ikj misc 1 - h{19} "hur" "AIR RELATIVE HUMIDITY" "1" +##CDXWRF2##state real HUS ikj misc 1 - h{19} "hus" "AIR SPECIFIC HUMIDITY" "1" +##CDXWRF2##state real ZG ikj misc 1 - h{19} "zg" "AIR GEOPOTENTIAL HEIGHT" "m" +##CDXWRF2##state real PRESS ikj misc 1 - h{19} "press" "AIR PRSSURE" "Pa" +##CDXWRF2##state real TA ikj misc 1 - h{19} "ta" "AIR TEMPERATURE" "K" +##CDXWRF2##state real UA ikj misc 1 - h{19} "ua" "AIR EASTWARD WIND SPEED" "ms-1" +##CDXWRF2##state real VA ikj misc 1 - h{19} "va" "AIR NORTHWARD WIND SPEED" "ms-1" +##CDXWRF2##state real WS ikj misc 1 - h{19} "ws" "AIR WIND SPEED" "ms-1" + +# Uncomment this section to get these variables (replace '##CDXWRF3##state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=3' (following line after '-DCORDEXDIAG') +# 1.- Remove ##CDXWRF3## +# 2.- ./clean -a +# 3.- recompile + +## Residence time +##CDXWRF3##state real htasbins {ht} misc 1 - rh{19} "htasbins" "high-resolution bins of 2-m temperature for simultaneous temporal residence of 2-m temperature and relative humidity" "K" +##CDXWRF3##state real hhursbins {hh} misc 1 - rh{19} "hhursbins" "high-resolution bins of 2-m relative humidity for simultan2ous temporal residence of 2-m temperature and relative humidity" "%" +##CDXWRF3##state real ltasbins {lt} misc 1 - rh{19} "ltasbins" "low-resolution bins of 2-m temperature for simultaneous temporal residence of 2-m temperature and relative humidity" "K" +##CDXWRF3##state real lhursbins {lh} misc 1 - rh{19} "lhursbins" "low-resolution bins of 2-m relative humidity for simultaneous temporal residence of 2-m temperature and relative humidity" "%" +##CDXWRF3##state real wbdsbins {wd} misc 1 - rh{19} "wbdsbins" "bins of 10-m earth rotated blowing wind direction (from where it blows) for simultaneous temporal residence of 10-m wind direction and wind speed" "rad" +##CDXWRF3##state real wssbins {ws} misc 1 - rh{19} "wssbins" "bins of 10-m wind speed for simultaneous temporal residence of 10-m wind direction and wind speed" "ms-1" +##CDXWRF3##state real tashurstreshighres i{hth}j misc 1 - rh{19} "tashurstreshighres" "high-resolution of simultaneous temporal residence of 2-m temperature and relative humidity" "second" +##CDXWRF3##state real tashurstreslowres i{lth}j misc 1 - rh{19} "tashurstreslowres" "low-resolution of simultaneous temporal residence of 2-m temperature and relative humidity" "second" +##CDXWRF3##state real wbdswsstres i{wds}j misc 1 - rh{19} "wbdswsstres" "simultaneous temporal residence of 10-m earth rotated blowing wind direction (from where it blows) and wind speed" "second" + + +# Uncomment this section to get these variables (replace '##CDXWRF4##state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=4' (following line after '-DCORDEXDIAG') +# 1.- Remove ##CDXWRF4## +# 2.- ./clean -a +# 3.- recompile + +## Water budget +##CDXWRF4##state real WBACDIABH ij misc 1 - rh{19} "wbacdiabh" "Water Budget column integrated and time accumulation of diabatic heating from Micro-Physics" "K" +##CDXWRF4##state real WBACPW ij misc 1 - rh{19} "wbacpw" "Water Budget column integrated and time accumulated for water vapor content" "mm" +##CDXWRF4##state real WBACPWC ij misc 1 - rh{19} "wbacpwc" "Water Budget col. int. & time accumulated for cloud content" "mm" +##CDXWRF4##state real WBACPWR ij misc 1 - rh{19} "wbacpwr" "Water Budget col. int. & time accumulated for rain content" "mm" +##CDXWRF4##state real WBACPWS ij misc 1 - rh{19} "wbacpws" "Water Budget col. int. & time accumulated for snow content" "mm" +##CDXWRF4##state real WBACPWI ij misc 1 - rh{19} "wbacpwi" "Water Budget col. int. & time accumulated for ice content" "mm" +##CDXWRF4##state real WBACPWH ij misc 1 - rh{19} "wbacpwh" "Water Budget col. int. & time accumulated for hail content" "mm" +##CDXWRF4##state real WBACPWG ij misc 1 - rh{19} "wbacpwg" "Water Budget col. int. & time accumulated for graupel content" "mm" +##CDXWRF4##state real WBACF ij misc 1 - rh{19} "wbacf" "W.B. c-int. acc. hor. convergence of water vapour (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFC ij misc 1 - rh{19} "wbacfc" "W.B. c-int. acc. hor. convergence of cloud (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFR ij misc 1 - rh{19} "wbacfr" "W.B. c-int. acc. hor. convergence of rain (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFS ij misc 1 - rh{19} "wbacfs" "W.B. c-int. acc. hor. convergence of snow (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFI ij misc 1 - rh{19} "wbacfi" "W.B. c-int. acc. hor. convergence of ice (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFH ij misc 1 - rh{19} "wbacfh" "W.B. c-int. acc. hor. convergence of hail (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACFG ij misc 1 - rh{19} "wbacfg" "W.B. c-int. acc. hor. convergence of graupel (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZ ij misc 1 - rh{19} "wbacz" "W.B. c-int. acc. ver. convergence of water vapour (+, conv.; -, div.), always 0" "mm" +##CDXWRF4##state real WBACZC ij misc 1 - rh{19} "wbaczc" "W.B. c-int. acc. ver. convergence of cloud (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZR ij misc 1 - rh{19} "wbaczr" "W.B. c-int. acc. ver. convergence of rain (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZS ij misc 1 - rh{19} "wbaczs" "W.B. c-int. acc. ver. convergence of snow (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZI ij misc 1 - rh{19} "wbaczi" "W.B. c-int. acc. ver. convergence of ice (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZH ij misc 1 - rh{19} "wbaczh" "W.B. c-int. acc. ver. convergence of hail (+, conv.; -, div.)" "mm" +##CDXWRF4##state real WBACZG ij misc 1 - rh{19} "wbaczg" "W.B. c-int. acc. ver. convergence of graupel (+, conv.; -, div.)" "mm" +# Low-mid-level +##CDXWRF4##state real WBACDIABHL ij misc 1 - rh{19} "wbacdiabhl" "W.B. low level acc. of diabatic heating from MP" "K" +##CDXWRF4##state real WBACDIABHM ij misc 1 - rh{19} "wbacdiabhm" "W.B. mid-level acc. of diabatic heating from MP" "K" +##CDXWRF4##state real WBACDIABHH ij misc 1 - rh{19} "wbacdiabhh" "W.B. high-level acc. of diabatic heating from MP" "K" +##CDXWRF4##state real WBACPWLV ij misc 1 - rh{19} "wbacpwlv" "W.B. low level (p >= 68000 Pa) acc. for QV" "mm" +##CDXWRF4##state real WBACPWMV ij misc 1 - rh{19} "wbacpwmv" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QV" "mm" +##CDXWRF4##state real WBACPWHV ij misc 1 - rh{19} "wbacpwhv" "W.B. high level (p < 44000 Pa) acc. for QV" "mm" +##CDXWRF4##state real WBACFLV ij misc 1 - rh{19} "wbacflv" "W.B. low-lev. acc. hor. convergence of QV" "mm" +##CDXWRF4##state real WBACFMV ij misc 1 - rh{19} "wbacfmv" "W.B. mid-lev. acc. hor. convergence of QV" "mm" +##CDXWRF4##state real WBACFHV ij misc 1 - rh{19} "wbacfhv" "W.B. high-lev. acc. hor. convergence of QV" "mm" +##CDXWRF4##state real WBACZLV ij misc 1 - rh{19} "wbaczlv" "W.B. low level acc. ver. convergence of QV" "mm" +##CDXWRF4##state real WBACZMV ij misc 1 - rh{19} "wbaczmv" "W.B. mid level acc. ver. convergence of QV" "mm" +##CDXWRF4##state real WBACZHV ij misc 1 - rh{19} "wbaczhv" "W.B. high level acc. ver. convergence of QV" "mm" +##CDXWRF4##state real WBACPWLC ij misc 1 - rh{19} "wbacpwlc" "W.B. low level (p >= 68000 Pa) acc. for QC" "mm" +##CDXWRF4##state real WBACPWMC ij misc 1 - rh{19} "wbacpwmc" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QC" "mm" +##CDXWRF4##state real WBACPWHC ij misc 1 - rh{19} "wbacpwhc" "W.B. high level (p < 44000 Pa) acc. for QC" "mm" +##CDXWRF4##state real WBACFLC ij misc 1 - rh{19} "wbacflc" "W.B. low-lev. acc. hor. convergence of QC" "mm" +##CDXWRF4##state real WBACFMC ij misc 1 - rh{19} "wbacfmc" "W.B. mid-lev. acc. hor. convergence of QC" "mm" +##CDXWRF4##state real WBACFHC ij misc 1 - rh{19} "wbacfhc" "W.B. high-lev. acc. hor. convergence of QC" "mm" +##CDXWRF4##state real WBACZLC ij misc 1 - rh{19} "wbaczlc" "W.B. low level acc. ver. convergence of QC" "mm" +##CDXWRF4##state real WBACZMC ij misc 1 - rh{19} "wbaczmc" "W.B. mid level acc. ver. convergence of QC" "mm" +##CDXWRF4##state real WBACZHC ij misc 1 - rh{19} "wbaczhc" "W.B. high level acc. ver. convergence of QC" "mm" +##CDXWRF4##state real WBACPWLR ij misc 1 - rh{19} "wbacpwlr" "W.B. low level (p >= 68000 Pa) acc. for QR" "mm" +##CDXWRF4##state real WBACPWMR ij misc 1 - rh{19} "wbacpwmr" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QR" "mm" +##CDXWRF4##state real WBACPWHR ij misc 1 - rh{19} "wbacpwhr" "W.B. high level (p < 44000 Pa) acc. for QR" "mm" +##CDXWRF4##state real WBACFLR ij misc 1 - rh{19} "wbacflr" "W.B. low-lev. acc. hor. convergence of QR" "mm" +##CDXWRF4##state real WBACFMR ij misc 1 - rh{19} "wbacfmr" "W.B. mid-lev. acc. hor. convergence of QR" "mm" +##CDXWRF4##state real WBACFHR ij misc 1 - rh{19} "wbacfhr" "W.B. high-lev. acc. hor. convergence of QR" "mm" +##CDXWRF4##state real WBACZLR ij misc 1 - rh{19} "wbaczlr" "W.B. low level acc. ver. convergence of QR" "mm" +##CDXWRF4##state real WBACZMR ij misc 1 - rh{19} "wbaczmr" "W.B. mid level acc. ver. convergence of QR" "mm" +##CDXWRF4##state real WBACZHR ij misc 1 - rh{19} "wbaczhr" "W.B. high level acc. ver. convergence of QR" "mm" +##CDXWRF4##state real WBACPWLS ij misc 1 - rh{19} "wbacpwls" "W.B. low level (p >= 68000 Pa) acc. for QS" "mm" +##CDXWRF4##state real WBACPWMS ij misc 1 - rh{19} "wbacpwms" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QS" "mm" +##CDXWRF4##state real WBACPWHS ij misc 1 - rh{19} "wbacpwhs" "W.B. high level (p < 44000 Pa) acc. for QS" "mm" +##CDXWRF4##state real WBACFLS ij misc 1 - rh{19} "wbacfls" "W.B. low-lev. acc. hor. convergence of QS" "mm" +##CDXWRF4##state real WBACFMS ij misc 1 - rh{19} "wbacfms" "W.B. mid-lev. acc. hor. convergence of QS" "mm" +##CDXWRF4##state real WBACFHS ij misc 1 - rh{19} "wbacfhs" "W.B. high-lev. acc. hor. convergence of QS" "mm" +##CDXWRF4##state real WBACZLS ij misc 1 - rh{19} "wbaczls" "W.B. low level acc. ver. convergence of QS" "mm" +##CDXWRF4##state real WBACZMS ij misc 1 - rh{19} "wbaczms" "W.B. mid level acc. ver. convergence of QS" "mm" +##CDXWRF4##state real WBACZHS ij misc 1 - rh{19} "wbaczhs" "W.B. high level acc. ver. convergence of QS" "mm" +##CDXWRF4##state real WBACPWLI ij misc 1 - rh{19} "wbacpwli" "W.B. low level (p >= 68000 Pa) acc. for QI" "mm" +##CDXWRF4##state real WBACPWMI ij misc 1 - rh{19} "wbacpwmi" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QI" "mm" +##CDXWRF4##state real WBACPWHI ij misc 1 - rh{19} "wbacpwhi" "W.B. high level (p < 44000 Pa) acc. for QI" "mm" +##CDXWRF4##state real WBACFLI ij misc 1 - rh{19} "wbacfli" "W.B. low-lev. acc. hor. convergence of QI" "mm" +##CDXWRF4##state real WBACFMI ij misc 1 - rh{19} "wbacfmi" "W.B. mid-lev. acc. hor. convergence of QI" "mm" +##CDXWRF4##state real WBACFHI ij misc 1 - rh{19} "wbacfhi" "W.B. high-lev. acc. hor. convergence of QI" "mm" +##CDXWRF4##state real WBACZLI ij misc 1 - rh{19} "wbaczli" "W.B. low level acc. ver. convergence of QI" "mm" +##CDXWRF4##state real WBACZMI ij misc 1 - rh{19} "wbaczmi" "W.B. mid level acc. ver. convergence of QI" "mm" +##CDXWRF4##state real WBACZHI ij misc 1 - rh{19} "wbaczhi" "W.B. high level acc. ver. convergence of QI" "mm" +##CDXWRF4##state real WBACPWLG ij misc 1 - rh{19} "wbacpwlg" "W.B. low level (p >= 68000 Pa) acc. for QG" "mm" +##CDXWRF4##state real WBACPWMG ij misc 1 - rh{19} "wbacpwmg" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QG" "mm" +##CDXWRF4##state real WBACPWHG ij misc 1 - rh{19} "wbacpwhg" "W.B. high level (p < 44000 Pa) acc. for QG" "mm" +##CDXWRF4##state real WBACFLG ij misc 1 - rh{19} "wbacflg" "W.B. low-lev. acc. hor. convergence of QG" "mm" +##CDXWRF4##state real WBACFMG ij misc 1 - rh{19} "wbacfmg" "W.B. mid-lev. acc. hor. convergence of QG" "mm" +##CDXWRF4##state real WBACFHG ij misc 1 - rh{19} "wbacfhg" "W.B. high-lev. acc. hor. convergence of QG" "mm" +##CDXWRF4##state real WBACZLG ij misc 1 - rh{19} "wbaczlg" "W.B. low level acc. ver. convergence of QG" "mm" +##CDXWRF4##state real WBACZMG ij misc 1 - rh{19} "wbaczmg" "W.B. mid level acc. ver. convergence of QG" "mm" +##CDXWRF4##state real WBACZHG ij misc 1 - rh{19} "wbaczhg" "W.B. high level acc. ver. convergence of QG" "mm" +##CDXWRF4##state real WBACPWLH ij misc 1 - rh{19} "wbacpwlh" "W.B. low level (p >= 68000 Pa) acc. for QH" "mm" +##CDXWRF4##state real WBACPWMH ij misc 1 - rh{19} "wbacpwmh" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QH" "mm" +##CDXWRF4##state real WBACPWHH ij misc 1 - rh{19} "wbacpwhh" "W.B. high level (p < 44000 Pa) acc. for QH" "mm" +##CDXWRF4##state real WBACFLH ij misc 1 - rh{19} "wbacflh" "W.B. low-lev. acc. hor. convergence of QH" "mm" +##CDXWRF4##state real WBACFMH ij misc 1 - rh{19} "wbacfmh" "W.B. mid-lev. acc. hor. convergence of QH" "mm" +##CDXWRF4##state real WBACFHH ij misc 1 - rh{19} "wbacfhh" "W.B. high-lev. acc. hor. convergence of QH" "mm" +##CDXWRF4##state real WBACZLH ij misc 1 - rh{19} "wbaczlh" "W.B. low level acc. ver. convergence of QH" "mm" +##CDXWRF4##state real WBACZMH ij misc 1 - rh{19} "wbaczmh" "W.B. mid level acc. ver. convergence of QH" "mm" +##CDXWRF4##state real WBACZHH ij misc 1 - rh{19} "wbaczhh" "W.B. high level acc. ver. convergence of QH" "mm" + +# Instantaneous values. If one require them into the output, modify the second '-' by 'h{19}' +##CDXWRF4##state real QVTTEND ikj misc 1 - - "qvttend" "inter time-step water vapor tendency" "kgkg-1s-1" +##CDXWRF4##state real QCTTEND ikj misc 1 - - "qcttend" "inter time-step cloud tendency" "kgkg-1s-1" +##CDXWRF4##state real QRTTEND ikj misc 1 - - "qrttend" "inter time-step rain tendency" "kgkg-1s-1" +##CDXWRF4##state real QSTTEND ikj misc 1 - - "qsttend" "inter time-step snow tendency" "kgkg-1s-1" +##CDXWRF4##state real QITTEND ikj misc 1 - - "qittend" "inter time-step ice tendency" "kgkg-1s-1" +##CDXWRF4##state real QHTTEND ikj misc 1 - - "qhttend" "inter time-step hail tendency" "kgkg-1s-1" +##CDXWRF4##state real QGTTEND ikj misc 1 - - "qgttend" "inter time-step graupel tendency" "kgkg-1s-1" +##CDXWRF4##state real QV_HADV ikj misc 1 - - "qv_hadv" "Instantaneous QV Horizontal advection" "kgkg-1" +##CDXWRF4##state real QC_HADV ikj misc 1 - - "qc_hadv" "Instantaneous QC Horizontal advection" "kgkg-1" +##CDXWRF4##state real QR_HADV ikj misc 1 - - "qr_hadv" "Instantaneous QR Horizontal advection" "kgkg-1" +##CDXWRF4##state real QS_HADV ikj misc 1 - - "qs_hadv" "Instantaneous QS Horizontal advection" "kgkg-1" +##CDXWRF4##state real QI_HADV ikj misc 1 - - "qi_hadv" "Instantaneous QI Horizontal advection" "kgkg-1" +##CDXWRF4##state real QH_HADV ikj misc 1 - - "qh_hadv" "Instantaneous QH Horizontal advection" "kgkg-1" +##CDXWRF4##state real QG_HADV ikj misc 1 - - "qg_hadv" "Instantaneous QG Horizontal advection" "kgkg-1" +##CDXWRF4##state real QV_ZADV ikj misc 1 - - "qv_zadv" "Instantaneous QV Vertical advection" "kgkg-1" +##CDXWRF4##state real QC_ZADV ikj misc 1 - - "qc_zadv" "Instantaneous QC Vertical advection" "kgkg-1" +##CDXWRF4##state real QR_ZADV ikj misc 1 - - "qr_zadv" "Instantaneous QR Vertical advection" "kgkg-1" +##CDXWRF4##state real QS_ZADV ikj misc 1 - - "qs_zadv" "Instantaneous QS Vertical advection" "kgkg-1" +##CDXWRF4##state real QI_ZADV ikj misc 1 - - "qi_zadv" "Instantaneous QI Vertical advection" "kgkg-1" +##CDXWRF4##state real QH_ZADV ikj misc 1 - - "qh_zadv" "Instantaneous QH Vertical advection" "kgkg-1" +##CDXWRF4##state real QG_ZADV ikj misc 1 - - "qg_zadv" "Instantaneous QG Vertical advection" "kgkg-1" + +##state real H_TENDENCY ikj misc 1 - - "h_tendency" "Horizontal tendency" "" +##state real Z_TENDENCY ikj misc 1 - - "z_tendency" "Vertical tendency" "" + +### L. Fita, January 2018. CIMA +### These variables would make too much output for a climate run. Include them if you need instantaneaous values (change '##INST##state' by 'state') +### 1.- Look for 'INSTVALS' inside the code and uncomment relted lines +### 2.- ./clean -a +### 3.- recompile +##INST##state real CLT ij misc 1 - h{19} "clt" "TOTAL CLOUDINESS" "1" +##INST##state real CLL ij misc 1 - h{19} "cll" "LOW-LEVEL CLOUDINESS (p >= 68000 Pa)" "1" +##INST##state real CLM ij misc 1 - h{19} "clm" "MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa)" "1" +##INST##state real CLH ij misc 1 - h{19} "clh" "HIGH-LEVEL CLOUDINESS (p < 44000 Pa)" "1" +##INST##state real WSGS ij misc 1 - h{19} "wsgs" "near-surface wind speed of gust" "ms-1" +##INST##state real USGS ij misc 1 - h{19} "usgs" "Eastward near-surface wind speed of gust" "ms-1" +##INST##state real VSGS ij misc 1 - h{19} "vsgs" "Northward near-surface wind speed of gust" "ms-1" +##INST##state integer GUSTPOINT ij misc 1 - h{19} "gustpoint" "whether grid point got wind gust (1) or not (0)" "1" +##INST##state real TOTWSGS ij misc 1 - h{19} "totwsgs" "total (TKE + H. pr) near-surface wind speed of gust" "ms-1" +##INST##state real TOTUSGS ij misc 1 - h{19} "totusgs" "total Eastward near-surface wind speed of gust" "ms-1" +##INST##state real TOTVSGS ij misc 1 - h{19} "totvsgs" "total Northward near-surface wind speed of gust" "ms-1" +##INST##state integer TOTGUSTPOINT ij misc 1 - h{19} "totgustpoint" "whether grid point got total wind gust (1) or not (0)" "1" +##INST##state real POTEVAPO ij misc 1 - h{19} "potevapo" "potential evapotranspiration" "kgm-2s-1" +##INST##state real POTEVAPOGEN ij misc 1 - h{19} "potevapogen" "generic potential evapotranspiration" "kgm-2s-1" +##INST##state real CDXCAPE ij misc 1 - h{19} "cdxcape" "convective available potential energy" "Jkg-1" +##INST##state real CIN ij misc 1 - h{19} "cin" "convective inhibition" "Jkg-1" +##INST##state real LFCP ij misc 1 - h{19} "lfcp" "PRESSURE LEVEL FREE CONVECTION" "Pa" +##INST##state real LFCZ ij misc 1 - h{19} "lfcz" "HEIGHT LEVEL FREE CONVECTION" "m" +##INST##state real LI ij misc 1 - h{19} "li" "LIFTED INDEX" "1" +##INST##state integer fog ij misc 1 - h{19} "fog" "Whether there is fog (1: yes [vis < 1km]; 0: not)" "-" +##INST##state real fogvisblty ij misc 1 - h{19} "fogvisblty" "visibility inside fog" "km" +##INST##state real tds ij misc 1 - h{19} "tds" "surface dew point temperature" "K" +##INST##state real tws ij misc 1 - h{19} "tws" "surface wet-bulb temperature" "K" +##INST##state real CDXDIABH ij misc 1 - h{19} "cdxdiabh" "diabatic heating from Micro-Physics" "K" + +# Water budget related. Only to work if CDXWRF = 3. + diff --git a/Registry/registry.cordex_comp b/Registry/registry.cordex_comp new file mode 100644 index 0000000000..54517cf5c8 --- /dev/null +++ b/Registry/registry.cordex_comp @@ -0,0 +1,390 @@ +# Definition of variables for the computation during model integration of the required CORDEX variables +## L. Fita, CIMA. December 2017 + +# CORDEX Diagnostics package namelist options +rconfig integer output_cordex namelist,cordex 1 0 rh "output_cordex" "CORDEX Diagnostic activation, 1:on" "" +rconfig integer psl_diag namelist,cordex 1 3 rh "psl_diag" "psl diagnostic: 1: hydrostatic Shuell correction; 2: pressure target; 3: ECMWF" "" +rconfig integer psmooth namelist,cordex 1 5 rh "psmooth" "passes of neighbourgh filtering (mean of 3x3-grid points) of psfc for psl_diag=2" "" +rconfig real ptarget namelist,cordex 1 70000. rh "ptarget" "pressure [Pa] target to be used by psl_diag=2" "" +rconfig integer wsgs_diag namelist,cordex 1 1 rh "wsgs_diag" "wind-gust diagnostic: 1: Brasseur, 2001, MWR; 2: heavy precipitation" "" +rconfig integer output_wb namelist,cordex 1 0 rh "output_wb" "FF Water-Budget activation, 1:on" "" +rconfig integer wsz100_diag namelist,cordex 1 1 rh "wsz100_diag" "wind 100m-extrapolation diagnostic: 1: power-law; 2: logarithmic-law, 3: Monin-Obukhov" "" +rconfig real z100m_wind namelist,cordex 1 100. rh "z100m_wind" "height [m] at which 100m wind should be extrapolated" "" +rconfig real z50m namelist,cordex 1 50. rh "z50m" "height [m] at which 50m variables should be extrapolated" "" +rconfig real zmlagen_dqv namelist,cordex 1 0.1 rh "zmlagen_dtqv" "percentage of variation [1] of mixing ratio (qv) to determine mixed layer depth" "" +rconfig real zmlagen_dtheta namelist,cordex 1 1.5 rh "zmlagen_dtheta" "increment [K] of potential temperature (theta) within MLD to determine zmla" "" +rconfig integer potevp_diag namelist,cordex 1 2 rh "potevp_diag" "potential evapotranspiration diagnostic: 1: bulk computation, 2: Milly92 method (Milly, 1992) similar to ORCHIDEE;" "" +rconfig integer convxtrm_diag namelist,cordex 1 0 rh "convxtrm_diag" "diagnostic of extremes from convection indices: 0: No; 1: yes" "" +rconfig integer fogvisibility_diag namelist,cordex 1 3 rh "fogvisibility_diag" "diagnostic of visibility inside fog: 1: Kunkel (1984), 2: RUC method (Smirnova et al., 2000); 3: FRAML 50% prob Gultepe and Milbrandt, (2010)" "" +rconfig integer fogvars namelist,cordex 1 1 rh "fogvars" "variables to use to diagnose fog (1: 3D, 2: sfc)" "" +rconfig integer zmlagen_diag namelist,cordex 1 2 rh "zmlagen_diag" "diagnostic of generic zmla: 1: Nielsen-Gammon et al. (2008), 2: bulk-Richardson (Vogelezang and Holtslag, 1996; Seidel et al., 2004)" "" +rconfig integer timedbg namelist,cordex 1 720 rh "timedbg" "frecuency in minutes of time-debugging" "" +rconfig real londbg namelist,cordex 1 -999. rh "londbg" "longitude in degrees of grid-point debugging (-999., not used)" "" +rconfig real latdbg namelist,cordex 1 -999. rh "latdbg" "latitude in degrees of grid-point debugging (-999., not used)" "" +rconfig integer wgsts_wbdswsstres namelist,cordex 1 1 rh "wgsts_wbdswsstres" "whether wind gusts should be used for wbds-wss residence-time (0: no, 1: yes)" "" + +## L. Fita. This should work, but WRF is not prepared for 4D output variables like this +rconfig integer nhtasrng namelist,cordex 1 38 rh "nhtasrng" "amount + 1 of high-resolution bins for temporal residence of tas" "" +rconfig integer nhhursrng namelist,cordex 1 25 rh "nhhursrng" "amount + 1 of high-resolution bins for temporal residence of hurs" "" +rconfig integer nltasrng namelist,cordex 1 21 rh "nltasrng" "amount + 1 of low-resolution bins for temporal residence of tas" "" +rconfig integer nlhursrng namelist,cordex 1 25 rh "nlhursrng" "amount + 1 of low-resolution bins for temporal residence of hurs" "" +rconfig integer nwbdsrng namelist,cordex 1 33 rh "nwbdsrng" "amount + 1 of bins for temporal residence of wbds" "" +# SI-based +rconfig integer nwssrng namelist,cordex 1 22 rh "nwssrng" "amount + 1 of bins for temporal residence of wss" "" +# kt-based: [0., 2.5, 5., 10., 15., 20., 25., 30., 35., 40.. 45., 50., 60., 70., 80., 100., 150., 200., 250., 300. ] +# Transforming to ms-1 as wss = kt * 1852. / 3600. +#rconfig integer nwssrng namelist,cordex 1 20 rh "nwssrng" "amount + 1 of bins for temporal residence of wss kt-based" "" +# Beafourt scale-based: [0., 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, +# 16.5, 17.5, 18.5, 19.5, 21.5, 23.5, 25.5, 27.5, 29.5, 31.5] +# FROM: https://en.wikipedia.org/wiki/Beaufort_scale +# Transforming to ms-1 as wss = 0.836*Bnum**(3./2.) +#rconfig integer nwssrng namelist,cordex 1 27 rh "nwssrng" "amount + 1 of bins for temporal residence of wss Beafourt-based" "" +## L. Fita, so, WRF output will provide a (n[h/l]tasrng*n[h/l]hursrng) 3D variable instead +rconfig integer nhtashursrng namelist,cordex 1 950 rh "nhtashursrng" "amount + 1 of high-resolution bins for temporal residence of tas and hurs (nhtas+1)*(nhhurs+1)" "" +rconfig integer nltashursrng namelist,cordex 1 525 rh "nltashursrng" "amount + 1 of low-resolution bins for temporal residence of wss and wbds (nwbds+1)*(nwss+1)" "" +rconfig integer nwbdswssrng namelist,cordex 1 726 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1)" "" +#rconfig integer nwbdswssrng namelist,cordex 1 660 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) kt-based" "" +#rconfig integer nwbdswssrng namelist,cordex 1 891 rh "nwbdswssrng" "amount + 1 of bins for temporal residence of wbds and wss (nwbds+1)*(nwss+1) Beafourt-based" "" +rconfig real htasrng namelist,cordex max_lbins (/173.15,268.15,269.15,270.15,271.15,272.15,273.15,274.15,275.15,276.15,277.15,278.15,279.15,280.15,281.15,282.15,283.15,284.15,285.15,286.15,287.15,288.15,289.15,290.15,291.15,292.15,293.15,294.15,295.15,296.15,297.15,298.15,299.15,300.15,301.15,302.15,303.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "htasrng" "high-resolution bins for temporal residence of tas" "" +rconfig real hhursrng namelist,cordex max_lbins (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "hhursrng" "high-resolution bins for temporal residence of hurs" "" +rconfig real ltasrng namelist,cordex max_lbins (/173.15,233.15,238.15,243.15,248.15,253.15,258.15,263.15,268.15,273.15,278.15,283.15,288.15,293.15,298.15,303.15,308.15,313.15,318.15,323.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "ltasrng" "low-resolution bins for temporal residence of tas" "" +rconfig real lhursrng namelist,cordex max_lbins (/0.00,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.80,0.85,0.90,0.95,1.00,1.05,1.10,1.15,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00/) rh "lhursrng" "low-resolution bins for temporal residence of hurs" "" +rconfig real wbdsrng namelist,cordex max_lbins (/-0.0982,0.0982,0.2945,0.4909,0.6872,0.8836,1.0799,1.2763,1.4726,1.669,1.8653,2.0617,2.258,2.4544,2.6507,2.8471,3.0434,3.2398,3.4361,3.6325,3.8288,4.0252,4.2215,4.4179,4.6142,4.8106,5.0069,5.2033,5.3996,5.596,5.7923,5.9887,6.185,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wbdsrng" "bins for temporal residence of wbds" "" +rconfig real wssrng namelist,cordex max_lbins (/0.0,0.5,1.0,2.5,5.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0,45.0,50.0,60.0,70.0,80.0,90.0,100.0,125.0,150.0,200.0,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss" "" +#rconfig real wssrng namelist,cordex max_lbins (/0.0,1.2861,2.5722,5.1444,7.7167,10.2889,12.8611,15.4333,18.0056,20.5778,23.15,25.7222,30.8667,36.0111,41.1556,51.4444,77.1667,102.8889,128.6111,154.3333,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss kt-based" "" +#rconfig real wssrng namelist,cordex max_lbins (/0.0,0.2956,1.5358,3.3046,5.474,7.9804,10.7833,13.854,17.1711,20.7174,24.4789,28.444,32.6027,36.9463,41.4674,46.1592,51.0157,56.0315,61.2017,66.5218,71.9877,83.342,95.2375,107.6506,120.5606,133.9489,147.7992,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0/) rh "wssrng" "bins for temporal residence of wss Beafourt-based" "" + +# CORDEX variables +state integer cdxnsteps - misc - - r "cdxnsteps" "CORDEX Time Step Counter" "" +state integer cdxhfnsteps - misc - - r "cdxhfnsteps" "CORDEX High-Frequemcy Time Step Counter" "" +state integer ijdbg {iit} misc - - rh{19} "ijdbg" "i,j-grid points from londbg,latdbg for debugging" "-" +state real CDXLON ij misc 1 - h{18}{19} "lon" "LONGITUDE" "degrees_east" +state real CDXLAT ij misc 1 - h{18}{19} "lat" "LATITUDE" "degrees_north" +state real PCLT ij misc 1 - r "pclt" "PREVIOUS TOTAL CLOUDINESS" "%" +state real PCLL ij misc 1 - r "pcll" "PREVIOUS LOW-LEVEL CLOUDINESS (p >= 68000 Pa)" "%" +state real PCLM ij misc 1 - r "pclm" "PREVIOUS MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa)" "%" +state real PCLH ij misc 1 - r "pclh" "PREVIOUS HIGH-LEVEL CLOUDINESS (p < 44000 Pa)" "%" +state real CLTMEAN ij misc 1 - rh{19} "cltmean" "MEAN TOTAL CLOUDINESS IN CORDEX OUTPUT" "%" +state real CLLMEAN ij misc 1 - rh{19} "cllmean" "MEAN LOW-LEVEL CLOUDINESS (p >= 68000 Pa) IN CORDEX OUTPUT" "%" +state real CLMMEAN ij misc 1 - rh{19} "clmmean" "MEAN MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa) IN CORDEX OUTPUT" "%" +state real CLHMEAN ij misc 1 - rh{19} "clhmean" "MEAN HIGH-LEVEL CLOUDINESS (p < 44000 Pa) IN CORDEX OUTPUT" "%" +state real PRW ij misc 1 - h{19} "prw" "WATER VAPOR PATH" "kgm-2" +state real PSL ij misc 1 - h{19} "psl" "SEA LEVEL PRESSURE" "Pa" +state real CLWVI ij misc 1 - h{19} "clwvi" "LIQUID WATER PATH" "kgm-2" +state real CLIVI ij misc 1 - h{19} "clivi" "ICE WATER PATH" "kgm-2" +state real HURS ij misc 1 - h{19} "hurs" "2M RELATIVE HUMIDITY" "1" +state real HUSS ij misc 1 - h{19} "huss" "2M SPECIFIC HUMIDITY" "1" +state real UAS ij misc 1 - h{19} "uas" "10M EARTH ROTATED EASTWARD WIND SPEED" "ms-1" +state real VAS ij misc 1 - h{19} "vas" "10M EARTH ROTATED NORTHWARD WIND SPEED" "ms-1" +state real WBDS ij misc 1 - h{19} "wbds" "10M EARTH ROTATED BLOWING WIND DIRECTION (from where it blows)" "ms-1" +state real WSS ij misc 1 - h{19} "wss" "10M WIND SPEED" "ms-1" +state real WSGSMAX ij misc 1 - rh{19} "wsgsmax" "Maximum near-surface wind speed of gust" "ms-1" +state real UGSMAX ij misc 1 - rh{19} "ugsmax" "Eastward maximum near-surface wind speed of gust" "ms-1" +state real VGSMAX ij misc 1 - rh{19} "vgsmax" "Northward maximum near-surface wind speed of gust" "ms-1" +state real WSGSPERCEN ij misc 1 - rh{19} "wsgspercen" "Percentage of time steps where grid point got wind gust" "%" +state real TOTWSGSMAX ij misc 1 - rh{19} "totwsgsmax" "Total (TKE + h. pr) Maximum near-surface wind speed of gust" "ms-1" +state real TOTUGSMAX ij misc 1 - rh{19} "totugsmax" "Total Eastward maximum near-surface wind speed of gust" "ms-1" +state real TOTVGSMAX ij misc 1 - rh{19} "totvgsmax" "Total Northward maximum near-surface wind speed of gust" "ms-1" +state real TOTWSGSPERCEN ij misc 1 - rh{19} "totwsgspercen" "Percentage of time steps where grid point got total wind gust" "%" +state real WSZ100 ij misc 1 - h{19} "wsz100" "100m wind speed" "ms-1" +state real UZ100 ij misc 1 - h{19} "uz100" "Eastward 100 m wind speed" "ms-1" +state real VZ100 ij misc 1 - h{19} "vz100" "Northward 100 m wind speed" "ms-1" +state real WSZ50 ij misc 1 - h{19} "wsz50" "50m wind speed" "ms-1" +state real UZ50 ij misc 1 - h{19} "uz50" "Eastward 50 m wind speed" "ms-1" +state real VZ50 ij misc 1 - h{19} "vz50" "Northward 50 m wind speed" "ms-1" +state real TAZ50 ij misc 1 - h{19} "taz50" "50 m air temperature" "K" +state real QVZ50 ij misc 1 - h{19} "qvz50" "50 m water vapour" "kgkg-1" +state real WSZ100MAX ij misc 1 - rh{19} "wsz100max" "Maximum 100m nwind speed" "ms-1" +state real UZ100MAX ij misc 1 - rh{19} "uz100max" "Eastward maximum 100 m wind speed" "ms-1" +state real VZ100MAX ij misc 1 - rh{19} "vz100max" "Northward maximum 100 m wind speed" "ms-1" +state real SUND ij misc 1 - rh{19} "sund" "SUNSHINE LENGTH (ac. time SWDOWN > 120. Wm-2)" "second" +state real TAUU ij misc 1 - h{19} "tauu" "easthward downward wind stress at 10 m" "m2s-2" +state real TAUV ij misc 1 - h{19} "tauv" "northtward downward wind stress at 10 m" "m2s-2" +state real TAUUGEN ij misc 1 - h{19} "tauugen" "generic eastward downward wind stress at 10 m" "m2s-2" +state real TAUVGEN ij misc 1 - h{19} "tauvgen" "generic northward downward wind stress at 10 m" "m2s-2" +state real RSDS ij misc 1 - rh{19} "rsds" "mean surface Downwelling Shortwave Radiation" "Wm-2" +state real RLDS ij misc 1 - rh{19} "rlds" "mean surface Downwelling Longwave Radiation" "Wm-2" +state real HFLS ij misc 1 - rh{19} "hfls" "mean surface Upward Latent Heat Flux" "Wm-2" +state real HFSS ij misc 1 - rh{19} "hfss" "mean surface Upward Sensible Heat Flux" "Wm-2" +state real RSUS ij misc 1 - rh{19} "rsus" "mean surface Upwelling Shortwave Radiation" "Wm-2" +state real RLUS ij misc 1 - rh{19} "rlus" "mean surface Upwelling Longwave Radiation" "Wm-2" +state real rsusgen ij misc 1 - rh{19} "rsusgen" "mean generic surface Upwelling Shortwave Radiation" "Wm-2" +state real rlusgen ij misc 1 - rh{19} "rlusgen" "mean generic surface Upwelling Longwave Radiation" "Wm-2" +state real EVSPSBL ij misc 1 - rh{19} "evspsbl" "mean evaporation" "kgm-2s-1" +state real EVSPSBLPOT ij misc 1 - rh{19} "evspsblpot" "mean potential evapotranspiration" "kgm-2s-1" +state real EVSPSBLPOTGEN ij misc 1 - rh{19} "evspsblpotgen" "mean generic potential evapotranspiration" "kgm-2s-1" +state real CDCDX ij misc 1 - h{19} "cdcdx" "drag coefficient" "-" +state real CDGEN ij misc 1 - h{19} "cdgen" "generic drag coefficient" "-" +state real SNC ij misc 1 - rh{19} "snc" "mean snow area fraction" "%" +state real SND ij misc 1 - rh{19} "snd" "mean snow depth" "m" +state real PMRROS ij misc 1 - r "pmrros" "previous accumulated surface Runoff" "kgm-2" +state real PMRRO ij misc 1 - r "pmrro" "previous accumulated total Runoff" "kgm-2" +state real MRROS ij misc 1 - rh{19} "mrros" "mean surface Runoff" "kgm-2s-1" +state real MRRO ij misc 1 - rh{19} "mrro" "mean total Runoff" "kgm-2s-1" +state real fracsoil10cm l misc 1 - rh{19} "fracsoil10cm" "Fraction of soil layer to compute soil acc. down to 10 cm" "1." +state real MRSO ij misc 1 - h{19} "mrso" "Total Soil Moisture Content" "kgm-2" +state real MRSOS ij misc 1 - h{19} "mrsos" "Moisture in Upper Portion of Soil Column (0-10cm)" "kgm-2" +state real MRSOL ilj misc 1 - h{19} "mrsol" "total water content of soil layer" "kgm-2" +state real MRSLL ilj misc 1 - h{19} "mrsll" "liquid water content of soil layer" "kgm-2" +state real MRLSO ij misc 1 - h{19} "mrlso" "total liquid water content of soil layer" "kgm-2" +state real MRLSOS ij misc 1 - h{19} "mrlsos" "liquid water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSFL ilj misc 1 - h{19} "mrsfl" "frozen water content of soil layer" "kgm-2" +state real MRFSO ij misc 1 - h{19} "mrfso" "total frozen water content of soil layer" "kgm-2" +state real MRFSOS ij misc 1 - h{19} "mrfsos" "frozen water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSOMEAN ij misc 1 - rh{19} "mrsomean" "mean total Soil Moisture Content" "kgm-2" +state real MRSOSMEAN ij misc 1 - rh{19} "mrsosmean" "mean moisture in Upper Portion of Soil Column (0-10cm)" "kgm-2" +state real MRSOLMEAN ilj misc 1 - rh{19} "mrsolmean" "mean total water content of soil layer" "kgm-2" +state real MRSLLMEAN ilj misc 1 - rh{19} "mrsllmean" "mean liquid water content of soil layer" "kgm-2" +state real MRLSOMEAN ij misc 1 - rh{19} "mrlsomean" "mean total liquid water content of soil layer" "kgm-2" +state real MRLSOSMEAN ij misc 1 - rh{19} "mrlsosmean" "mean liquid water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real MRSFLMEAN ilj misc 1 - rh{19} "mrsflmean" "mean frozen water content of soil layer" "kgm-2" +state real MRFSOMEAN ij misc 1 - rh{19} "mrfsomean" "mean total frozen water content of soil layer" "kgm-2" +state real MRFSOSMEAN ij misc 1 - rh{19} "mrfsosmean" "mean frozen water content in Upper Portion of soil column (0-10cm)" "kgm-2" +state real pr ij misc 1 - rh{19} "pr" "precipitation flux" "kgm-2s-1" +state real prl ij misc 1 - rh{19} "prl" "large scale precipitation flux" "kgm-2s-1" +state real prc ij misc 1 - rh{19} "prc" "convective precipitation flux" "kgm-2s-1" +state real prsh ij misc 1 - rh{19} "prsh" "shallow-cumulus precipitation flux" "kgm-2s-1" +state real prsn ij misc 1 - rh{19} "prsn" "solid precipitation flux" "kgm-2s-1" +state real snw ij misc 1 - rh{19} "snw" "accumulated snow precipitation" "kgm-2" +state real rsdt ij misc 1 - rh{19} "rsdt" "mean top of the atmosphere (TOA) incident shortwave radiation" "kgm-2" +state real rsut ij misc 1 - rh{19} "rsut" "mean TOA outgoing shortwave radiation" "kgm-2" +state real rlut ij misc 1 - rh{19} "rlut" "mean TOA outgoing Longwave radiation" "kgm-2" +state real cdxps ij misc 1 - rh{19} "cdxps" "surface pressure" "Pa" +state real cdxts ij misc 1 - rh{19} "cdxts" "skin temperature" "K" +state real tas_hm ij misc 1 - rh{19} "tas_hm" "Corrector-calculator (Hess-McAvaney, 1995) 2m-temperature" "K" +state real qvs_hm ij misc 1 - rh{19} "qvs_hm" "Corrector-calculator (Hess-McAvaney, 1995) 2m water vapor mixing ratio" "K" + +# Uncomment this section to get these variables (replace 'state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=1' (following line after '-DCORDEXDIAG') +# 1.- Remove +# 2.- ./clean -a +# 3.- recompile + +state real ZMLAGEN ij misc 1 - h{19} "zmlagen" "Generic boundary layer height theta(zmlagen) > min(theta[mix. layer]) + 1.5K" "m" +state real CLGVI ij misc 1 - h{19} "clgvi" "GRAUPEL WATER PATH" "kgm-2" +state real CLHVI ij misc 1 - h{19} "clhvi" "HAIL WATER PATH" "kgm-2" +state real CAPEMIN ij misc 1 - rh{19} "capemin" "minimum convective available potential energy" "Jkg-1" +state real CAPEMAX ij misc 1 - rh{19} "capemax" "maximum convective available potential energy" "Jkg-1" +state real CAPEMEAN ij misc 1 - rh{19} "capemean" "mean convective available potential energy" "Jkg-1" +state real CINMIN ij misc 1 - rh{19} "cinmin" "minimum convective inhibition" "Jkg-1" +state real CINMAX ij misc 1 - rh{19} "cinmax" "maximum convective inhibition" "Jkg-1" +state real CINMEAN ij misc 1 - rh{19} "cinmean" "mean convective inhibition" "Jkg-1" +state real LFCPMIN ij misc 1 - rh{19} "lfcpmin" "minimum pressure level free convection" "Pa" +state real LFCPMAX ij misc 1 - rh{19} "lfcpmax" "maximum pressure level free convection" "Pa" +state real LFCPMEAN ij misc 1 - rh{19} "lfcpmean" "mean pressure level free convection" "Pa" +state real LFCZMIN ij misc 1 - rh{19} "lfczmin" "minimum height level free convection" "m" +state real LFCZMAX ij misc 1 - rh{19} "lfczmax" "maximum height level free convection" "m" +state real LFCZMEAN ij misc 1 - rh{19} "lfczmean" "mean height level free convection" "m" +state real LIMEAN ij misc 1 - rh{19} "limean" "mean lifted index" "1" +state real LIMIN ij misc 1 - rh{19} "limin" "minimum lifted index" "1" +state real LIMAX ij misc 1 - rh{19} "limax" "maximum lifted index" "1" +state real IUTMEAN ij misc 1 - rh{19} "iutmean" "mean vertically integrated eastward transport of water vapour" "kgm-1s-1" +state real IVTMEAN ij misc 1 - rh{19} "ivtmean" "mean vertically integrated northward transport of water vapour" "kgm-1s-1" +state real ZEROISOTHERM ij misc 1 - h{19} "zeroisotherm" "height above ground of the 0-isotherm" "m" +state real prhf ij misc 1 - rh{18} "prhf" "precipitation flux" "kgm-2s-1" +state real COLMAX ij misc 1 - h{18} "colmax" "instantaneous maximum radar reflectivity in the column" "dBz" + +# Instantaneous values. If one require them into the output, modify the second '-' by 'h{19}' +state real IUT ij misc 1 - - "iut" "instantaneous vertically integrated eastward transport of water vapour" "kgm-1s-1" +state real IVT ij misc 1 - - "ivt" "instantaneous vertically integrated northward transport of water vapour" "kgm-1s-1" + +# Uncomment this section to get these variables (replace 'state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=2' (following line after '-DCORDEXDIAG') +# 1.- Remove +# 2.- ./clean -a +# 3.- recompile + +state real tfog ij misc 1 - rh{19} "tfog" "time of presence of fog" "seconds" +state real fogvisbltymin ij misc 1 - rh{19} "fogvisbltymin" "minimum of visibility inside fog" "km" +state real fogvisbltymax ij misc 1 - rh{19} "fogvisbltymax" "maximum of visibility inside fog" "km" +state real fogvisbltymean ij misc 1 - rh{19} "fogvisbltymean" "mean of visibility inside fog" "km" +state real tdsmin ij misc 1 - rh{19} "tdsmin" "minimum surface dew point temperature" "K" +state real tdsmax ij misc 1 - rh{19} "tdsmax" "maximum surface dew point temperature" "K" +state real tdsmean ij misc 1 - rh{19} "tdsmean" "mean surface dew point temperature" "K" +state real twsmin ij misc 1 - rh{19} "twsmin" "minimum surface wet-bulb temperature" "K" +state real twsmax ij misc 1 - rh{19} "twsmax" "maximum surface wet-bulb temperature" "K" +state real twsmean ij misc 1 - rh{19} "twsmean" "mean surface wet-bulb temperature" "K" + +# 3D +state real HUR ikj misc 1 - h{19} "hur" "AIR RELATIVE HUMIDITY" "1" +state real HUS ikj misc 1 - h{19} "hus" "AIR SPECIFIC HUMIDITY" "1" +state real ZG ikj misc 1 - h{19} "zg" "AIR GEOPOTENTIAL HEIGHT" "m" +state real PRESS ikj misc 1 - h{19} "press" "AIR PRSSURE" "Pa" +state real TA ikj misc 1 - h{19} "ta" "AIR TEMPERATURE" "K" +state real UA ikj misc 1 - h{19} "ua" "AIR EASTWARD WIND SPEED" "ms-1" +state real VA ikj misc 1 - h{19} "va" "AIR NORTHWARD WIND SPEED" "ms-1" +state real WS ikj misc 1 - h{19} "ws" "AIR WIND SPEED" "ms-1" + +# Uncomment this section to get these variables (replace 'state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=3' (following line after '-DCORDEXDIAG') +# 1.- Remove +# 2.- ./clean -a +# 3.- recompile + +## Residence time +state real htasbins {ht} misc 1 - rh{19} "htasbins" "high-resolution bins of 2-m temperature for simultaneous temporal residence of 2-m temperature and relative humidity" "K" +state real hhursbins {hh} misc 1 - rh{19} "hhursbins" "high-resolution bins of 2-m relative humidity for simultan2ous temporal residence of 2-m temperature and relative humidity" "%" +state real ltasbins {lt} misc 1 - rh{19} "ltasbins" "low-resolution bins of 2-m temperature for simultaneous temporal residence of 2-m temperature and relative humidity" "K" +state real lhursbins {lh} misc 1 - rh{19} "lhursbins" "low-resolution bins of 2-m relative humidity for simultaneous temporal residence of 2-m temperature and relative humidity" "%" +state real wbdsbins {wd} misc 1 - rh{19} "wbdsbins" "bins of 10-m earth rotated blowing wind direction (from where it blows) for simultaneous temporal residence of 10-m wind direction and wind speed" "rad" +state real wssbins {ws} misc 1 - rh{19} "wssbins" "bins of 10-m wind speed for simultaneous temporal residence of 10-m wind direction and wind speed" "ms-1" +state real tashurstreshighres i{hth}j misc 1 - rh{19} "tashurstreshighres" "high-resolution of simultaneous temporal residence of 2-m temperature and relative humidity" "second" +state real tashurstreslowres i{lth}j misc 1 - rh{19} "tashurstreslowres" "low-resolution of simultaneous temporal residence of 2-m temperature and relative humidity" "second" +state real wbdswsstres i{wds}j misc 1 - rh{19} "wbdswsstres" "simultaneous temporal residence of 10-m earth rotated blowing wind direction (from where it blows) and wind speed" "second" + + +# Uncomment this section to get these variables (replace 'state', by 'state') +# Only work if one includes in configure.wrf '-DCDXWRF=4' (following line after '-DCORDEXDIAG') +# 1.- Remove +# 2.- ./clean -a +# 3.- recompile + +## Water budget +state real WBACDIABH ij misc 1 - rh{19} "wbacdiabh" "Water Budget column integrated and time accumulation of diabatic heating from Micro-Physics" "K" +state real WBACPW ij misc 1 - rh{19} "wbacpw" "Water Budget column integrated and time accumulated for water vapor content" "mm" +state real WBACPWC ij misc 1 - rh{19} "wbacpwc" "Water Budget col. int. & time accumulated for cloud content" "mm" +state real WBACPWR ij misc 1 - rh{19} "wbacpwr" "Water Budget col. int. & time accumulated for rain content" "mm" +state real WBACPWS ij misc 1 - rh{19} "wbacpws" "Water Budget col. int. & time accumulated for snow content" "mm" +state real WBACPWI ij misc 1 - rh{19} "wbacpwi" "Water Budget col. int. & time accumulated for ice content" "mm" +state real WBACPWH ij misc 1 - rh{19} "wbacpwh" "Water Budget col. int. & time accumulated for hail content" "mm" +state real WBACPWG ij misc 1 - rh{19} "wbacpwg" "Water Budget col. int. & time accumulated for graupel content" "mm" +state real WBACF ij misc 1 - rh{19} "wbacf" "W.B. c-int. acc. hor. convergence of water vapour (+, conv.; -, div.)" "mm" +state real WBACFC ij misc 1 - rh{19} "wbacfc" "W.B. c-int. acc. hor. convergence of cloud (+, conv.; -, div.)" "mm" +state real WBACFR ij misc 1 - rh{19} "wbacfr" "W.B. c-int. acc. hor. convergence of rain (+, conv.; -, div.)" "mm" +state real WBACFS ij misc 1 - rh{19} "wbacfs" "W.B. c-int. acc. hor. convergence of snow (+, conv.; -, div.)" "mm" +state real WBACFI ij misc 1 - rh{19} "wbacfi" "W.B. c-int. acc. hor. convergence of ice (+, conv.; -, div.)" "mm" +state real WBACFH ij misc 1 - rh{19} "wbacfh" "W.B. c-int. acc. hor. convergence of hail (+, conv.; -, div.)" "mm" +state real WBACFG ij misc 1 - rh{19} "wbacfg" "W.B. c-int. acc. hor. convergence of graupel (+, conv.; -, div.)" "mm" +state real WBACZ ij misc 1 - rh{19} "wbacz" "W.B. c-int. acc. ver. convergence of water vapour (+, conv.; -, div.), always 0" "mm" +state real WBACZC ij misc 1 - rh{19} "wbaczc" "W.B. c-int. acc. ver. convergence of cloud (+, conv.; -, div.)" "mm" +state real WBACZR ij misc 1 - rh{19} "wbaczr" "W.B. c-int. acc. ver. convergence of rain (+, conv.; -, div.)" "mm" +state real WBACZS ij misc 1 - rh{19} "wbaczs" "W.B. c-int. acc. ver. convergence of snow (+, conv.; -, div.)" "mm" +state real WBACZI ij misc 1 - rh{19} "wbaczi" "W.B. c-int. acc. ver. convergence of ice (+, conv.; -, div.)" "mm" +state real WBACZH ij misc 1 - rh{19} "wbaczh" "W.B. c-int. acc. ver. convergence of hail (+, conv.; -, div.)" "mm" +state real WBACZG ij misc 1 - rh{19} "wbaczg" "W.B. c-int. acc. ver. convergence of graupel (+, conv.; -, div.)" "mm" +# Low-mid-level +state real WBACDIABHL ij misc 1 - rh{19} "wbacdiabhl" "W.B. low level acc. of diabatic heating from MP" "K" +state real WBACDIABHM ij misc 1 - rh{19} "wbacdiabhm" "W.B. mid-level acc. of diabatic heating from MP" "K" +state real WBACDIABHH ij misc 1 - rh{19} "wbacdiabhh" "W.B. high-level acc. of diabatic heating from MP" "K" +state real WBACPWLV ij misc 1 - rh{19} "wbacpwlv" "W.B. low level (p >= 68000 Pa) acc. for QV" "mm" +state real WBACPWMV ij misc 1 - rh{19} "wbacpwmv" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QV" "mm" +state real WBACPWHV ij misc 1 - rh{19} "wbacpwhv" "W.B. high level (p < 44000 Pa) acc. for QV" "mm" +state real WBACFLV ij misc 1 - rh{19} "wbacflv" "W.B. low-lev. acc. hor. convergence of QV" "mm" +state real WBACFMV ij misc 1 - rh{19} "wbacfmv" "W.B. mid-lev. acc. hor. convergence of QV" "mm" +state real WBACFHV ij misc 1 - rh{19} "wbacfhv" "W.B. high-lev. acc. hor. convergence of QV" "mm" +state real WBACZLV ij misc 1 - rh{19} "wbaczlv" "W.B. low level acc. ver. convergence of QV" "mm" +state real WBACZMV ij misc 1 - rh{19} "wbaczmv" "W.B. mid level acc. ver. convergence of QV" "mm" +state real WBACZHV ij misc 1 - rh{19} "wbaczhv" "W.B. high level acc. ver. convergence of QV" "mm" +state real WBACPWLC ij misc 1 - rh{19} "wbacpwlc" "W.B. low level (p >= 68000 Pa) acc. for QC" "mm" +state real WBACPWMC ij misc 1 - rh{19} "wbacpwmc" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QC" "mm" +state real WBACPWHC ij misc 1 - rh{19} "wbacpwhc" "W.B. high level (p < 44000 Pa) acc. for QC" "mm" +state real WBACFLC ij misc 1 - rh{19} "wbacflc" "W.B. low-lev. acc. hor. convergence of QC" "mm" +state real WBACFMC ij misc 1 - rh{19} "wbacfmc" "W.B. mid-lev. acc. hor. convergence of QC" "mm" +state real WBACFHC ij misc 1 - rh{19} "wbacfhc" "W.B. high-lev. acc. hor. convergence of QC" "mm" +state real WBACZLC ij misc 1 - rh{19} "wbaczlc" "W.B. low level acc. ver. convergence of QC" "mm" +state real WBACZMC ij misc 1 - rh{19} "wbaczmc" "W.B. mid level acc. ver. convergence of QC" "mm" +state real WBACZHC ij misc 1 - rh{19} "wbaczhc" "W.B. high level acc. ver. convergence of QC" "mm" +state real WBACPWLR ij misc 1 - rh{19} "wbacpwlr" "W.B. low level (p >= 68000 Pa) acc. for QR" "mm" +state real WBACPWMR ij misc 1 - rh{19} "wbacpwmr" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QR" "mm" +state real WBACPWHR ij misc 1 - rh{19} "wbacpwhr" "W.B. high level (p < 44000 Pa) acc. for QR" "mm" +state real WBACFLR ij misc 1 - rh{19} "wbacflr" "W.B. low-lev. acc. hor. convergence of QR" "mm" +state real WBACFMR ij misc 1 - rh{19} "wbacfmr" "W.B. mid-lev. acc. hor. convergence of QR" "mm" +state real WBACFHR ij misc 1 - rh{19} "wbacfhr" "W.B. high-lev. acc. hor. convergence of QR" "mm" +state real WBACZLR ij misc 1 - rh{19} "wbaczlr" "W.B. low level acc. ver. convergence of QR" "mm" +state real WBACZMR ij misc 1 - rh{19} "wbaczmr" "W.B. mid level acc. ver. convergence of QR" "mm" +state real WBACZHR ij misc 1 - rh{19} "wbaczhr" "W.B. high level acc. ver. convergence of QR" "mm" +state real WBACPWLS ij misc 1 - rh{19} "wbacpwls" "W.B. low level (p >= 68000 Pa) acc. for QS" "mm" +state real WBACPWMS ij misc 1 - rh{19} "wbacpwms" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QS" "mm" +state real WBACPWHS ij misc 1 - rh{19} "wbacpwhs" "W.B. high level (p < 44000 Pa) acc. for QS" "mm" +state real WBACFLS ij misc 1 - rh{19} "wbacfls" "W.B. low-lev. acc. hor. convergence of QS" "mm" +state real WBACFMS ij misc 1 - rh{19} "wbacfms" "W.B. mid-lev. acc. hor. convergence of QS" "mm" +state real WBACFHS ij misc 1 - rh{19} "wbacfhs" "W.B. high-lev. acc. hor. convergence of QS" "mm" +state real WBACZLS ij misc 1 - rh{19} "wbaczls" "W.B. low level acc. ver. convergence of QS" "mm" +state real WBACZMS ij misc 1 - rh{19} "wbaczms" "W.B. mid level acc. ver. convergence of QS" "mm" +state real WBACZHS ij misc 1 - rh{19} "wbaczhs" "W.B. high level acc. ver. convergence of QS" "mm" +state real WBACPWLI ij misc 1 - rh{19} "wbacpwli" "W.B. low level (p >= 68000 Pa) acc. for QI" "mm" +state real WBACPWMI ij misc 1 - rh{19} "wbacpwmi" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QI" "mm" +state real WBACPWHI ij misc 1 - rh{19} "wbacpwhi" "W.B. high level (p < 44000 Pa) acc. for QI" "mm" +state real WBACFLI ij misc 1 - rh{19} "wbacfli" "W.B. low-lev. acc. hor. convergence of QI" "mm" +state real WBACFMI ij misc 1 - rh{19} "wbacfmi" "W.B. mid-lev. acc. hor. convergence of QI" "mm" +state real WBACFHI ij misc 1 - rh{19} "wbacfhi" "W.B. high-lev. acc. hor. convergence of QI" "mm" +state real WBACZLI ij misc 1 - rh{19} "wbaczli" "W.B. low level acc. ver. convergence of QI" "mm" +state real WBACZMI ij misc 1 - rh{19} "wbaczmi" "W.B. mid level acc. ver. convergence of QI" "mm" +state real WBACZHI ij misc 1 - rh{19} "wbaczhi" "W.B. high level acc. ver. convergence of QI" "mm" +state real WBACPWLG ij misc 1 - rh{19} "wbacpwlg" "W.B. low level (p >= 68000 Pa) acc. for QG" "mm" +state real WBACPWMG ij misc 1 - rh{19} "wbacpwmg" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QG" "mm" +state real WBACPWHG ij misc 1 - rh{19} "wbacpwhg" "W.B. high level (p < 44000 Pa) acc. for QG" "mm" +state real WBACFLG ij misc 1 - rh{19} "wbacflg" "W.B. low-lev. acc. hor. convergence of QG" "mm" +state real WBACFMG ij misc 1 - rh{19} "wbacfmg" "W.B. mid-lev. acc. hor. convergence of QG" "mm" +state real WBACFHG ij misc 1 - rh{19} "wbacfhg" "W.B. high-lev. acc. hor. convergence of QG" "mm" +state real WBACZLG ij misc 1 - rh{19} "wbaczlg" "W.B. low level acc. ver. convergence of QG" "mm" +state real WBACZMG ij misc 1 - rh{19} "wbaczmg" "W.B. mid level acc. ver. convergence of QG" "mm" +state real WBACZHG ij misc 1 - rh{19} "wbaczhg" "W.B. high level acc. ver. convergence of QG" "mm" +state real WBACPWLH ij misc 1 - rh{19} "wbacpwlh" "W.B. low level (p >= 68000 Pa) acc. for QH" "mm" +state real WBACPWMH ij misc 1 - rh{19} "wbacpwmh" "W.B. mid level (44000 Pa <= p < 68000 Pa) acc. for QH" "mm" +state real WBACPWHH ij misc 1 - rh{19} "wbacpwhh" "W.B. high level (p < 44000 Pa) acc. for QH" "mm" +state real WBACFLH ij misc 1 - rh{19} "wbacflh" "W.B. low-lev. acc. hor. convergence of QH" "mm" +state real WBACFMH ij misc 1 - rh{19} "wbacfmh" "W.B. mid-lev. acc. hor. convergence of QH" "mm" +state real WBACFHH ij misc 1 - rh{19} "wbacfhh" "W.B. high-lev. acc. hor. convergence of QH" "mm" +state real WBACZLH ij misc 1 - rh{19} "wbaczlh" "W.B. low level acc. ver. convergence of QH" "mm" +state real WBACZMH ij misc 1 - rh{19} "wbaczmh" "W.B. mid level acc. ver. convergence of QH" "mm" +state real WBACZHH ij misc 1 - rh{19} "wbaczhh" "W.B. high level acc. ver. convergence of QH" "mm" + +# Instantaneous values. If one require them into the output, modify the second '-' by 'h{19}' +state real QVTTEND ikj misc 1 - - "qvttend" "inter time-step water vapor tendency" "kgkg-1s-1" +state real QCTTEND ikj misc 1 - - "qcttend" "inter time-step cloud tendency" "kgkg-1s-1" +state real QRTTEND ikj misc 1 - - "qrttend" "inter time-step rain tendency" "kgkg-1s-1" +state real QSTTEND ikj misc 1 - - "qsttend" "inter time-step snow tendency" "kgkg-1s-1" +state real QITTEND ikj misc 1 - - "qittend" "inter time-step ice tendency" "kgkg-1s-1" +state real QHTTEND ikj misc 1 - - "qhttend" "inter time-step hail tendency" "kgkg-1s-1" +state real QGTTEND ikj misc 1 - - "qgttend" "inter time-step graupel tendency" "kgkg-1s-1" +state real QV_HADV ikj misc 1 - - "qv_hadv" "Instantaneous QV Horizontal advection" "kgkg-1" +state real QC_HADV ikj misc 1 - - "qc_hadv" "Instantaneous QC Horizontal advection" "kgkg-1" +state real QR_HADV ikj misc 1 - - "qr_hadv" "Instantaneous QR Horizontal advection" "kgkg-1" +state real QS_HADV ikj misc 1 - - "qs_hadv" "Instantaneous QS Horizontal advection" "kgkg-1" +state real QI_HADV ikj misc 1 - - "qi_hadv" "Instantaneous QI Horizontal advection" "kgkg-1" +state real QH_HADV ikj misc 1 - - "qh_hadv" "Instantaneous QH Horizontal advection" "kgkg-1" +state real QG_HADV ikj misc 1 - - "qg_hadv" "Instantaneous QG Horizontal advection" "kgkg-1" +state real QV_ZADV ikj misc 1 - - "qv_zadv" "Instantaneous QV Vertical advection" "kgkg-1" +state real QC_ZADV ikj misc 1 - - "qc_zadv" "Instantaneous QC Vertical advection" "kgkg-1" +state real QR_ZADV ikj misc 1 - - "qr_zadv" "Instantaneous QR Vertical advection" "kgkg-1" +state real QS_ZADV ikj misc 1 - - "qs_zadv" "Instantaneous QS Vertical advection" "kgkg-1" +state real QI_ZADV ikj misc 1 - - "qi_zadv" "Instantaneous QI Vertical advection" "kgkg-1" +state real QH_ZADV ikj misc 1 - - "qh_zadv" "Instantaneous QH Vertical advection" "kgkg-1" +state real QG_ZADV ikj misc 1 - - "qg_zadv" "Instantaneous QG Vertical advection" "kgkg-1" + +##state real H_TENDENCY ikj misc 1 - - "h_tendency" "Horizontal tendency" "" +##state real Z_TENDENCY ikj misc 1 - - "z_tendency" "Vertical tendency" "" + +### L. Fita, January 2018. CIMA +### These variables would make too much output for a climate run. Include them if you need instantaneaous values (change '##INST##state' by 'state') +### 1.- Look for 'INSTVALS' inside the code and uncomment relted lines +### 2.- ./clean -a +### 3.- recompile +##INST##state real CLT ij misc 1 - h{19} "clt" "TOTAL CLOUDINESS" "1" +##INST##state real CLL ij misc 1 - h{19} "cll" "LOW-LEVEL CLOUDINESS (p >= 68000 Pa)" "1" +##INST##state real CLM ij misc 1 - h{19} "clm" "MID-LEVEL CLOUDINESS (44000 <= p < 68000 Pa)" "1" +##INST##state real CLH ij misc 1 - h{19} "clh" "HIGH-LEVEL CLOUDINESS (p < 44000 Pa)" "1" +##INST##state real WSGS ij misc 1 - h{19} "wsgs" "near-surface wind speed of gust" "ms-1" +##INST##state real USGS ij misc 1 - h{19} "usgs" "Eastward near-surface wind speed of gust" "ms-1" +##INST##state real VSGS ij misc 1 - h{19} "vsgs" "Northward near-surface wind speed of gust" "ms-1" +##INST##state integer GUSTPOINT ij misc 1 - h{19} "gustpoint" "whether grid point got wind gust (1) or not (0)" "1" +##INST##state real TOTWSGS ij misc 1 - h{19} "totwsgs" "total (TKE + H. pr) near-surface wind speed of gust" "ms-1" +##INST##state real TOTUSGS ij misc 1 - h{19} "totusgs" "total Eastward near-surface wind speed of gust" "ms-1" +##INST##state real TOTVSGS ij misc 1 - h{19} "totvsgs" "total Northward near-surface wind speed of gust" "ms-1" +##INST##state integer TOTGUSTPOINT ij misc 1 - h{19} "totgustpoint" "whether grid point got total wind gust (1) or not (0)" "1" +##INST##state real POTEVAPO ij misc 1 - h{19} "potevapo" "potential evapotranspiration" "kgm-2s-1" +##INST##state real POTEVAPOGEN ij misc 1 - h{19} "potevapogen" "generic potential evapotranspiration" "kgm-2s-1" +##INST##state real CDXCAPE ij misc 1 - h{19} "cdxcape" "convective available potential energy" "Jkg-1" +##INST##state real CIN ij misc 1 - h{19} "cin" "convective inhibition" "Jkg-1" +##INST##state real LFCP ij misc 1 - h{19} "lfcp" "PRESSURE LEVEL FREE CONVECTION" "Pa" +##INST##state real LFCZ ij misc 1 - h{19} "lfcz" "HEIGHT LEVEL FREE CONVECTION" "m" +##INST##state real LI ij misc 1 - h{19} "li" "LIFTED INDEX" "1" +##INST##state integer fog ij misc 1 - h{19} "fog" "Whether there is fog (1: yes [vis < 1km]; 0: not)" "-" +##INST##state real fogvisblty ij misc 1 - h{19} "fogvisblty" "visibility inside fog" "km" +##INST##state real tds ij misc 1 - h{19} "tds" "surface dew point temperature" "K" +##INST##state real tws ij misc 1 - h{19} "tws" "surface wet-bulb temperature" "K" +##INST##state real CDXDIABH ij misc 1 - h{19} "cdxdiabh" "diabatic heating from Micro-Physics" "K" + +# Water budget related. Only to work if CDXWRF = 3. + diff --git a/Registry/registry.diags b/Registry/registry.diags index 83c63e4b4a..9c095df25c 100644 --- a/Registry/registry.diags +++ b/Registry/registry.diags @@ -5,13 +5,30 @@ # The new dimspec. We need to have the number of pressure levels to interpolate to. dimspec np 2 namelist=num_press_levels z num_press_levels +## L. Fita, CIMA. Feburary 2023 +#### Added for CORDEX! +## L. Fita 2 grid coordinates for the londbg,latdbg +dimspec iit 2 constant=2 z iit +!ifdef CDXWRF=3 +## L. Fita. This should work, but WRF is not prepared for 4D output variables like this +dimspec ht 2 namelist=nhtasrng c nhtasrng +dimspec hh 2 namelist=nhhursrng c nhhursrng +dimspec lt 2 namelist=nltasrng c nltasrng +dimspec lh 2 namelist=nlhursrng c nlhursrng +dimspec wd 2 namelist=nwbdsrng c nwbdsrng +dimspec ws 2 namelist=nwssrng c nwssrng +## L. Fita, so, WRF output will provide a (n[h/l]tasrng*n[h/l]hursrng) 3D variable instead +dimspec hth 2 namelist=nhtashursrng z nhtashursrng +dimspec lth 2 namelist=nltashursrng z nltashursrng +dimspec wds 2 namelist=nwbdswssrng z nwbdswssrng +!endif # Namelist parameters rconfig integer p_lev_diags namelist,diags 1 0 - "flag to process vertical interp diagnostics: 0=nope, 1=yep" "flag" rconfig integer p_lev_diags_dfi namelist,diags 1 0 - "when doing p_level diags and dfi, turn off diags during 'non forecast'" rconfig integer num_press_levels namelist,diags 1 0 - "number of pressure levels to interpolate diagnostics to" "index" -rconfig real press_levels namelist,diags max_plevs 0 - "array of pressure levels to interpolate diagnostics to" "Pa" +rconfig real press_levels namelist,diags max_plevs 0 - "array of pressure levels to interpolate diagnostics to" "Pa" rconfig integer use_tot_or_hyd_p namelist,diags 1 2 - "1=use total pressure, 2=use hydrostatic pressure" "flag" rconfig integer extrap_below_grnd namelist,diags 1 1 - "1=no extrapolation, 2=extrapolate adiabatically" "flag" rconfig real p_lev_missing namelist,diags 1 -999 - "missing values below ground, no extrapolation" "constant" @@ -30,12 +47,35 @@ state real rh_pl i{np}j misc 1 Z h{23} "RH_PL" "Pressure level state real ght_pl i{np}j misc 1 Z h{23} "GHT_PL" "Pressure level data, Geopotential Height" "m" state real s_pl i{np}j misc 1 Z h{23} "S_PL" "Pressure level data, Speed" "m s-1" state real td_pl i{np}j misc 1 Z h{23} "TD_PL" "Pressure level data, Dew point temperature" "K" -state real q_pl i{np}j misc 1 Z h{23} "Q_PL" "Pressure level data, Mixing ratio" "kg/kg" +state real q_pl i{np}j misc 1 Z h{23} "Q_PL" "Pressure level data, water vapour Mixing ratio" "kg/kg" +## L. Fita, CiMA. March 2018 +#### Added for CORDEX! +state real hus_pl i{np}j misc 1 Z h{23} "HUS_PL" "Pressure level data, Sepcific humidity" "1" +state real w_pl i{np}j misc 1 Z h{23} "W_PL" "Pressure level data, W wind" "m s-1" +state real uer_pl i{np}j misc 1 Z h{23} "UER_PL" "Pressure level data, U wind Earth-Rotated" "m s-1" +state real ver_pl i{np}j misc 1 Z h{23} "VER_PL" "Pressure level data, V wind Earth-Rotated" "m s-1" +state real ws_pl i{np}j misc 1 Z h{23} "WS_PL" "Pressure level data, wind speed" "m s-1" +state real qc_pl i{np}j misc 1 Z h{23} "QC_PL" "Pressure level data, cloud mixing ratio" "kg/kg" +state real qr_pl i{np}j misc 1 Z h{23} "QR_PL" "Pressure level data, rain mixing ratio" "kg/kg" +state real qs_pl i{np}j misc 1 Z h{23} "QS_PL" "Pressure level data, snow mixing ratio" "kg/kg" +state real qi_pl i{np}j misc 1 Z h{23} "QI_PL" "Pressure level data, ice mixing ratio" "kg/kg" +state real qg_pl i{np}j misc 1 Z h{23} "QG_PL" "Pressure level data, graupel mixing ratio" "kg/kg" +state real qh_pl i{np}j misc 1 Z h{23} "QH_PL" "Pressure level data, hail mixing ratio" "kg/kg" +state real qv_pl_mc i{np}j misc 1 Z h{23} "QV_PL_MC" "mass-conservative pressure level data, water vapour mixing ratio" "kg/kg" +state real qc_pl_mc i{np}j misc 1 Z h{23} "QC_PL_MC" "mass-conservative pressure level data, cloud mixing ratio" "kg/kg" +state real qr_pl_mc i{np}j misc 1 Z h{23} "QR_PL_MC" "mass-conservative pressure level data, rain mixing ratio" "kg/kg" +state real qs_pl_mc i{np}j misc 1 Z h{23} "QS_PL_MC" "mass-conservative pressure level data, snow mixing ratio" "kg/kg" +state real qi_pl_mc i{np}j misc 1 Z h{23} "QI_PL_MC" "mass-conservative pressure level data, ice mixing ratio" "kg/kg" +state real qg_pl_mc i{np}j misc 1 Z h{23} "QG_PL_MC" "mass-conservative pressure level data, graupel mixing ratio" "kg/kg" +state real qh_pl_mc i{np}j misc 1 Z h{23} "QH_PL_MC" "mass-conservative pressure level data, hail mixing ratio" "kg/kg" # Package declarations package skip_press_diags p_lev_diags==0 - - -package press_diags p_lev_diags==1 - state:p_pl,u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl,q_pl +## L. Fita, CiMA. March 2018 +#### Added for CORDEX! +##package press_diags p_lev_diags==1 - state:p_pl,u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl,q_pl +package press_diags p_lev_diags==1 - state:p_pl,u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl,q_pl,w_pl,hus_pl,uer_pl,ver_pl,ws_pl,qc_pl,qr_pl,qs_pl,qi_pl,qg_pl,qh_pl,qv_pl_mc,qc_pl_mc,qr_pl_mc,qs_pl_mc,qi_pl_mc,qg_pl_mc,qh_pl_mc diff --git a/Registry/registry.em_shared_collection b/Registry/registry.em_shared_collection index 28a75f175d..a1a7abaa64 100644 --- a/Registry/registry.em_shared_collection +++ b/Registry/registry.em_shared_collection @@ -30,3 +30,4 @@ include registry.solar_fields include registry.diags include registry.iau include registry.CMAQ +include registry.cordex_comp diff --git a/dyn_em/solve_em.F b/dyn_em/solve_em.F index 0761df036f..2dad79b16c 100644 --- a/dyn_em/solve_em.F +++ b/dyn_em/solve_em.F @@ -225,6 +225,11 @@ END SUBROUTINE CMAQ_DRIVER end interface #endif +!#ifdef CORDEXDIAG + INTEGER :: i2, j2, k2 + INTEGER :: ix, iy, iz +!#endif + ! Define benchmarking timers if -DBENCH is compiled #include "bench_solve_em_def.h" @@ -2195,6 +2200,44 @@ END SUBROUTINE CMAQ_DRIVER ! +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 + + ! L. Fita, CIMA. Feb. 2018 + ! Initializing values it gives unitialize values on that unconsidered + ! species + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij, tenddec ) + moist_tile_loop_ini: DO ij = 1 , grid%num_tiles + DO iz=kms,kme + grid%qv_hadv(ims:ime,iz,jms:jme) = 0. + grid%qv_zadv(ims:ime,iz,jms:jme) = 0. + grid%qvttend = 0. + grid%qc_hadv(ims:ime,iz,jms:jme) = 0. + grid%qc_zadv(ims:ime,iz,jms:jme) = 0. + grid%qcttend = 0. + grid%qr_hadv(ims:ime,iz,jms:jme) = 0. + grid%qr_zadv(ims:ime,iz,jms:jme) = 0. + grid%qrttend = 0. + grid%qs_hadv(ims:ime,iz,jms:jme) = 0. + grid%qs_zadv(ims:ime,iz,jms:jme) = 0. + grid%qsttend = 0. + grid%qi_hadv(ims:ime,iz,jms:jme) = 0. + grid%qi_zadv(ims:ime,iz,jms:jme) = 0. + grid%qittend = 0. + grid%qg_hadv(ims:ime,iz,jms:jme) = 0. + grid%qg_zadv(ims:ime,iz,jms:jme) = 0. + grid%qgttend = 0. + grid%qh_hadv(ims:ime,iz,jms:jme) = 0. + grid%qh_zadv(ims:ime,iz,jms:jme) = 0. + grid%qhttend = 0. + END DO + END DO moist_tile_loop_ini + !$OMP END PARALLEL DO +!#endif +!#endif +!#endif moist_scalar_advance: IF (num_3d_m >= PARAM_FIRST_SCALAR ) THEN moist_variable_loop: DO im = PARAM_FIRST_SCALAR, num_3d_m @@ -2209,7 +2252,15 @@ END SUBROUTINE CMAQ_DRIVER moist_tile_loop_1: DO ij = 1 , grid%num_tiles CALL wrf_debug ( 200 , ' call rk_scalar_tend' ) - tenddec = .false. +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 + tenddec = .true. +!#endif +!#endif +!#else +! tenddec = .false. +!#endif BENCH_START(rk_scalar_tend_tim) CALL rk_scalar_tend ( im, im, config_flags, tenddec, & @@ -2303,13 +2354,29 @@ END SUBROUTINE CMAQ_DRIVER moist_tile_loop_2: DO ij = 1 , grid%num_tiles CALL wrf_debug ( 200 , ' call rk_update_scalar' ) - tenddec = .false. +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 + tenddec = .true. +!#endif +!#endif +!#else +! tenddec = .false. +!#endif BENCH_START(update_scal_tim) CALL rk_update_scalar( scs=im, sce=im, & scalar_1=moist_old(ims,kms,jms,im), & scalar_2=moist(ims,kms,jms,im), & sc_tend=moist_tend(ims,kms,jms,im), & +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 + advh_t=advh_t(ims:ime,kms:kme,jms:jme,1), & + advz_t=advz_t(ims:ime,kms:kme,jms:jme,1), & +!#endif +!#endif +!#endif advect_tend=advect_tend, & h_tendency=h_tendency, z_tendency=z_tendency, & msftx=grid%msftx,msfty=grid%msfty, & @@ -2336,6 +2403,96 @@ END SUBROUTINE CMAQ_DRIVER k_start , k_end ) ENDIF ENDIF +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 + IF (rk_step .eq. config_flags%rk_ord .AND. curr_secs2 > 0. .AND. & + config_flags%output_cordex == 1 .AND. config_flags%output_wb == 1) THEN +! L. Fita, January 2018. CIMA +! There is a need to keep the results for each specie since module provides +! accumulated values + IF (im == P_QV) THEN + DO iz=kms,kme + grid%qv_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qv_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qv_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qv_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QC) THEN + DO iz=kms,kme + grid%qc_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qc_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qc_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qc_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QR) THEN + DO iz=kms,kme + grid%qr_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qr_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qr_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qr_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QS) THEN + DO iz=kms,kme + grid%qs_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qs_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qs_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qs_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QI) THEN + DO iz=kms,kme + grid%qi_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qi_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qi_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qi_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QH) THEN + DO iz=kms,kme + grid%qh_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qh_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qh_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qh_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF + IF (im == P_QG) THEN + DO iz=kms,kme + grid%qg_hadv(ims:ime,iz,jms:jme) = h_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + grid%qg_zadv(ims:ime,iz,jms:jme) = z_tendency(ims:ime,iz,jms:jme)* & + grid%msfty(ims:ime,jms:jme)/(grid%mu_2(ims:ime,jms:jme)+grid%mub(ims:ime,jms:jme)) + !grid%qg_hadv(ims:ime,iz,jms:jme) = advh_t(ims:ime,iz,jms:jme,1) + !grid%qg_zadv(ims:ime,iz,jms:jme) = advz_t(ims:ime,iz,jms:jme,1) + END DO + END IF +! i2 = INT((ime + ims)/2) +! j2 = INT((jme + jms)/2) +! WRITE(message,*)' Lluis P_QV:', P_QV,' P_QC:',P_QC, ' P_QR:',P_QR,' P_QS:',P_QS,' P_QI:',P_QI,' P_QH:',P_QH,' P_QG:',P_QG +! CALL wrf_debug(100,message) +! WRITE(message,*)' Lluis im:', im, ' 2 h_tend:', h_tendency(i2,2,j2), ' v_tend:', z_tendency(i2,2,j2), ' advh_t:', advh_t(i2,2,j2,1), ' advz_t 2:', advz_t(i2,2,j2,1) +! CALL wrf_debug(100,message) +! WRITE(message,*)' Lluis qvh:', grid%qv_hadv(i2,2,j2), ' qch:', grid%qc_hadv(i2,2,j2), ' qrh:', grid%qr_hadv(i2,2,j2), ' qsh:', grid%qs_hadv(i2,2,j2), ' qih:', grid%qh_hadv(i2,2,j2), ' qhh:', grid%qh_hadv(i2,2,j2), ' qgh:', grid%qg_hadv(i2,2,j2) +! CALL wrf_debug(100,message) + END IF +!#endif +!#endif +!#endif BENCH_END(update_scal_tim) BENCH_START(flow_depbdy_tim) @@ -4751,6 +4908,36 @@ END SUBROUTINE CMAQ_DRIVER END DO !$OMP END PARALLEL DO +!#ifdef CORDEXDIAG +!#ifdef CDXWRF +!#if CDXWRF>=4 +! Getting some variables for the Water budget + IF (config_flags%output_wb == 1 .AND. curr_secs2 > 0.) THEN + !!i2 = (ime+ims)/2 + !!j2 = (jme+jms)/2 + ! Avoiding floating point exceptions when compiling in debug mode + + ! Inter-time step tendency (only for the existent species!!) + grid%qvttend = (moist(:,:,:,P_QV) - moist_old(:,:,:,P_QV))/REAL(model_config_rec%dt(grid%id)) + grid%qcttend = (moist(:,:,:,P_QC) - moist_old(:,:,:,P_QC))/REAL(model_config_rec%dt(grid%id)) + grid%qrttend = (moist(:,:,:,P_QR) - moist_old(:,:,:,P_QR))/REAL(model_config_rec%dt(grid%id)) + IF (P_QS >= PARAM_FIRST_SCALAR) THEN + grid%qsttend = (moist(:,:,:,P_QS) - moist_old(:,:,:,P_QS))/REAL(model_config_rec%dt(grid%id)) + ENDIF + IF (P_QI >= PARAM_FIRST_SCALAR) THEN + grid%qittend = (moist(:,:,:,P_QI) - moist_old(:,:,:,P_QI))/REAL(model_config_rec%dt(grid%id)) + ENDIF + IF (P_QH >= PARAM_FIRST_SCALAR) THEN + grid%qhttend = (moist(:,:,:,P_QH) - moist_old(:,:,:,P_QH))/REAL(model_config_rec%dt(grid%id)) + ENDIF + IF (P_QG >= PARAM_FIRST_SCALAR) THEN + grid%qgttend = (moist(:,:,:,P_QG) - moist_old(:,:,:,P_QG))/REAL(model_config_rec%dt(grid%id)) + ENDIF + END IF +!#endif +!#endif +!#endif + !----------------------------------------------------------- ! After all of the RK steps, after the microphysics, after p-rho-phi, ! after w, after filtering, we have data ready to use. diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index 96057ebdfb..d946e93e0c 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -1271,6 +1271,20 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ,grid%NC_CU, grid%NI_CU, grid%NR_CU, grid%NS_CU,grid%CCN_CU & ,grid%alevsiz_cu,grid%num_months,grid%no_src_types_cu,grid%aeromcu & ,grid%aeropcu,grid%EFCG,grid%EFCS,grid%EFIG,grid%EFIS,grid%EFSG,grid%EFSS & +!#ifdef CDXWRF + ,grid%fracsoil10cm & + ,model_config_rec%londbg, model_config_rec%latdbg & + ,grid%ijdbg & + +!#if CDXWRF>=3 + ,model_config_rec%nhtasrng, model_config_rec%nhhursrng & + ,model_config_rec%nltasrng, model_config_rec%nlhursrng & + ,model_config_rec%nwbdsrng, model_config_rec%nwssrng & + ,grid%htasbins, grid%hhursbins, grid%ltasbins, grid%lhursbins & + ,grid%wbdsbins, grid%wssbins & +!#endif +!#endif + ) ENDDO ! loop of tiles for phy_init @@ -2044,6 +2058,38 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ,s_pl = grid%s_pl & ,td_pl = grid%td_pl & ,q_pl = grid%q_pl & +!#ifdef CORDEXDIAG + ,sina = grid%sina & + ,cosa = grid%cosa & + ,psfc = grid%psfc & + ,topo = grid%ht & + ,alt = grid%alt & + ,p_top = config_flags%p_top_requested & + ,iqc=moist(:,:,:,P_QC) & + ,iqr=moist(:,:,:,P_QR) & + ,iqs=moist(:,:,:,P_QS) & + ,iqi=moist(:,:,:,P_QI) & + ,iqg=moist(:,:,:,P_QG) & + ,iqh=moist(:,:,:,P_QH) & + ,hus_pl = grid%hus_pl & + ,w_pl = grid%w_pl & + ,uer_pl = grid%uer_pl & + ,ver_pl = grid%ver_pl & + ,ws_pl = grid%ws_pl & + ,qc_pl = grid%qc_pl & + ,qr_pl = grid%qr_pl & + ,qs_pl = grid%qs_pl & + ,qi_pl = grid%qi_pl & + ,qg_pl = grid%qg_pl & + ,qh_pl = grid%qh_pl & + ,qv_pl_mc = grid%qv_pl_mc & + ,qc_pl_mc = grid%qc_pl_mc & + ,qr_pl_mc = grid%qr_pl_mc & + ,qs_pl_mc = grid%qs_pl_mc & + ,qi_pl_mc = grid%qi_pl_mc & + ,qg_pl_mc = grid%qg_pl_mc & + ,qh_pl_mc = grid%qh_pl_mc & +!#endif ! Dimension arguments ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde & ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme & diff --git a/frame/module_driver_constants.F b/frame/module_driver_constants.F index 6c7d797d1a..b7da00e525 100644 --- a/frame/module_driver_constants.F +++ b/frame/module_driver_constants.F @@ -146,6 +146,17 @@ MODULE module_driver_constants ! Default for Earth REAL , PARAMETER :: P2SI = 1.0 #endif + +!#ifdef CORDEXDIAG +!#if CDXWRF>=3 + ! 5. CORDEX-WRF diagnostics + ! Maximum amount of bins per variable for the simultaneous time of residence + INTEGER, PARAMETER :: max_lbins = 50 + ! Maximum amount of bins for the simultaneous time of residence + INTEGER, PARAMETER :: max_rng = 1000 +!#endif +!#endif + CONTAINS SUBROUTINE init_module_driver_constants END SUBROUTINE init_module_driver_constants diff --git a/main/depend.common b/main/depend.common index 0d34bd218b..8008a17c69 100644 --- a/main/depend.common +++ b/main/depend.common @@ -1589,6 +1589,7 @@ module_diagnostics_driver.o: \ module_diag_misc.o \ module_diag_nwp.o \ module_diag_cl.o \ + module_diag_cordex.o \ module_diag_pld.o \ module_diag_zld.o \ module_diag_afwa.o \ @@ -1612,6 +1613,14 @@ module_diag_cl.o: \ ../frame/module_dm.o \ ../frame/module_configure.o +module_diagvar_cordex.o: \ + ../frame/module_wrf_error.o \ + ../share/module_model_constants.o + +module_diag_cordex.o: \ + ../frame/module_dm.o \ + ../frame/module_configure.o \ + module_diagvar_cordex.o module_diag_pld.o: \ ../share/module_model_constants.o diff --git a/phys/Makefile b/phys/Makefile index 5eda61c111..02b243b73e 100644 --- a/phys/Makefile +++ b/phys/Makefile @@ -209,6 +209,7 @@ MODULES = \ module_wind_mav.o \ module_sf_lake.o \ module_diagnostics_driver.o \ + module_diagvar_cordex.o \ module_irrigation.o FIRE_MODULES = \ @@ -226,6 +227,7 @@ DIAGNOSTIC_MODULES_EM = \ module_diag_afwa.o \ module_diag_cl.o \ module_diag_functions.o \ + module_diag_cordex.o \ module_diag_hailcast.o \ module_diag_misc.o \ module_diag_nwp.o \ diff --git a/phys/module_diag_cordex.F b/phys/module_diag_cordex.F new file mode 100644 index 0000000000..61e755916b --- /dev/null +++ b/phys/module_diag_cordex.F @@ -0,0 +1,3003 @@ +MODULE module_diag_cordex +! WRF module to compute atmospheric model diagnostics required by CORDEX +! L. Fita, CIMA. December 2017 +! +! This module computes that variables required by CORDEX which usually are post-processed +! +! Subroutines/Functions +! +! module_diag_cdx: Main subroutine to compute CORDEX required variables + +! Available diagnostics + +!! Instantaneous diagnostics (only computed on output times) +!!! prw: Total water path [kgm-2] +!!! clwvi: Total liquid water path (QCLOUD + QRAIN + QSNOW + QICE) [kgm-2] +!!! clivi: Total ice water path (QSNOW+QICE+GRAUPEL+QHAIL) [kgm-2] +!!! clgvi: Total graupel water path (QGRAUPEL) [kgm-2] +!!! clhvi: Total hail water path (QHAIL) [kgm-2] +!!! ua: 3D earth-rotated eastward wind [ms-1] +!!! va: 3D earth-rotated northward wind [ms-1] +!!! ws: 3D wind speed [ms-1] +!!! ta: 3D air-temperature [K] +!!! press: 3D air pressure [Pa] +!!! zg: 3D geopotential height [m] +!!! hur: 3D relative humidty [1] +!!! hus: 3D specific humidty [1] +!!! uas: 10m earth-rotated eastward wind [ms-1] +!!! vas: 10m earth-rotated northward wind [ms-1] +!!! wss: 10m earth-rotated northward wind [ms-1] +!!! wbds: 10m earth-rotated blowing wind direction [rad] +!!! hurs: 2m relative humidty [1] +!!! huss: 2m specific humidty [1] +!!! psl: sea level pressure [Pa] +!!! tas_hm: 2-m air temperature using corrector-calculator (Hess-McAvaney, 1995) method [K] +!!! qv_hm: 2-m water vapour mixing ratio using corrector-calculator (Hess-McAvaney, 1995) method [kgkg-1] +!!! cape: CAPE [Jkg-1] +!!! cin: CIN [Jkg-1] +!!! zlfc: Height at LFC [m] +!!! plfc: Pressure at LFC [Pa] +!!! lidx: Lifted index [1] +!!! zmla: pbl height following a generic method [m] +!!! ws100: 100m wind speed [ms-1] +!!! uz100: 100m wind x-direction [ms-1] +!!! vz100: 100m wind y-direction [ms-1] +!!! ws50: 50m wind speed [ms-1] +!!! uz50: 50m wind x-direction [ms-1] +!!! vz50: 50m wind y-direction [ms-1] +!!! taz50: 50m air temperature [K] +!!! qvz50: 50m water vapour [kgkg-1] +!!! tauu, tauuv: components of the downward wind stress at 10 m [m2s-2] (might be +!!! zero if sf_sfclay_physics /= 1, 5) +!!! tauugen, tauuvgen: generic components of the downward wind stress at 10 m [m2s-2] +!!! cdcdx: drag coefficient [-] (might be zero if sf_sfclay_physics /= 1, 5) +!!! cdgen: generic drag coefficient [-] +!!! fog: whether point is inside fog (vis < 1km) [1] +!!! vis: visibility inside fog [km] +!!! tds: 2m dew point temperature [K] +!!! tws: wet-bulb temperature [K] +!!! ps: surface pressure [Pa] +!!! ts: skin temperature [K] +!!! zeroith: 0-isotherm [m] +!!! mrsol: moisture content of soil layer [kgm-2] +!!! mrsos: first layer soil moisture content (0-10 cm) [kgm-2] +!!! mrso: total soil moisture content [kgm-2] +!!! mrsll: liquid water content of soil layer [kgm-2] +!!! mrlso: total liquid water content of soil layer [kgm-2] +!!! mrlsos: liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] +!!! mrsfl: frozen water content of soil layer [kgm-2] +!!! mrfso: total frozen water content of soil layer [kgm-2] +!!! mrfsos: frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] + +!! Accumulated or similar time dependency (computed at every time-step) +!!! +!!! cdgen: generic drag coefficient (instantaneous values) [-] +!!! clt: total cloud cover [%] !!!!! NOTE: CLDFRAC is computed by the radiative scheme thus, +!!! cll: low-level (p >= 68000 Pa) cloud cover [%] !! bear in mind that: +!!! clm: mid-level (44000 <= p < 68000 Pa) cloud cover [%] !! auxhist9_interval > radt +!!! clh: high-level (p < 44000 Pa) cloud cover [%] !! otherwise one obtains repeated values !! +!!! cltmean: mean clt [%] +!!! cllmean: mean cll [%] +!!! clmmean: mean clm [%] +!!! clhmean: mean clh [%] +!!! wsgsmax: maximum surface wind gust [ms-1] +!!! ugsmax: x maximum surface gust wind direction [ms-1] +!!! vgsmax: y maximum surface gust wind direction [ms-1] +!!! percengust: percentage of time where the grid point got gust winds [%] +!!! totwsgsmax: total (TKE + heavy precip) maximum surface wind gust [ms-1] +!!! totugsmax: total x maximum surface gust wind direction [ms-1] +!!! totvgsmax: total y maximum surface gust wind direction [ms-1] +!!! totpercengust: percentage of time where the grid point got total gust winds [%] +!!! wsz100max: maximum 100m wind [ms-1] +!!! uz100max: x maximum 100m wind direction [ms-1] +!!! vz100max: y maximum 100m wind direction [ms-1] +!!! sunshine: ac. time with swdown > 120. Wm-2 [s] +!!! rsds: mean surface Downwelling Shortwave Radiation [Wm-2] +!!! rlds: mean surface Downwelling Longwave Radiation [Wm-2] +!!! hfls: mean surface Upward Latent Heat Flux [Wm-2] +!!! hfss: mean surface Upward Sensible Heat Flux [Wm-2] +!!! rsus: mean surface Upwelling Shortwave Radiation [Wm-2] +!!! rlus: mean surface Upwelling Longwave Radiation [Wm-2] +!!! rsusgen: generic mean surface Upwelling Shortwave Radiation [Wm-2] +!!! rlusgen: generic mean surface Upwelling Longwave Radiation [Wm-2] +!!! evspsbl: mean evaporation [kgm-2s-1] +!!! evspsblpot: mean potential evapotranspiration [kgm-2s-1] +!!! evspsblpotgen: mean generic potential evapotranspiration [kgm-2s-1] +!!! cdgen: generic drag coefficient [-] +!!! snc: mean snow area fraction [%] +!!! snd: mean snow depth [m] +!!! mrros: mean surface Runoff [kgm-2s-1] +!!! mrro: mean total Runoff [kgm-2s-1] +!!! mrsolmean: mean moisture content of soil layer [kgm-2] +!!! mrsosmean: mean first layer soil moisture content (0-10 cm) [kgm-2] +!!! mrsomean: mean total soil moisture content [kgm-2] +!!! mrsllmean: mean liquid water content of soil layer [kgm-2] +!!! mrlsomean: mean total liquid water content of soil layer [kgm-2] +!!! mrlsosmean: mean liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] +!!! mrsflmean: mean frozen water content of soil layer [kgm-2] +!!! mrfsomean: mean total frozen water content of soil layer [kgm-2] +!!! mrfsosmean: mean frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] +!!! flxpr: precipitation flux [kgm-2s-1] +!!! flxprl: large scale precipitation flux [kgm-2s-1] +!!! flxprc: convective precipitation flux [kgm-2s-1] +!!! flxprsh: shallow-cumulus precipitation flux [kgm-2s-1] +!!! flxprsn: solid precipitation flux [kgm-2s-1] +!!! snw: accumulated snow [ksm-2] +!!! rsdt: mean top of the Atmosphere (TOA) incident shortwave radiation [kgm-2] +!!! rsut: mean top of the Atmosphere (TOA) outgoing shortwave radiation [kgm-2] +!!! rlut: mean top of the Atmosphere (TOA) outgoing Longwave radiation [kgm-2] +!!! tas_hm: 2-m air temperature using corrector-calculator (Hess-McAvaney, 1995) method [K] +!!! qv_hm: 2-m water vapour mixing ratio using corrector-calculator (Hess-McAvaney, 1995) method [kgkg-1] +!!! capemin: minimum CAPE [Jkg-1] +!!! cinmin: minimum CIN [Jkg-1] +!!! zlfcmin: minimum height at LFC [m] +!!! plfcmin: minimum Pressure at LFC [Pa] +!!! lidxmin: minimum Lifted index [1] +!!! capemax: maximum CAPE [Jkg-1] +!!! cinmax: maximum CIN [Jkg-1] +!!! zlfcmax: maximum height at LFC [m] +!!! plfcmax: maximum Pressure at LFC [Pa] +!!! lidxmax: maximum Lifted index [1] +!!! capemean: mean CAPE [Jkg-1] +!!! cinmean: mean CIN [Jkg-1] +!!! zlfcmean: mean height at LFC [m] +!!! plfcmean: mean Pressure at LFC [Pa] +!!! lidxmean: mean Lifted index [1] +!!! tfog: time of presence of fog [s] +!!! fogvisbltymin: minimun visibility inside fog [km] +!!! fogvisbltymax: maximun visibility inside fog [km] +!!! fogvisbltymean: mean visibility inside fog [km] +!!! tdsmin: minimum 2m dew point temperature [K] +!!! tdsmax: maximum 2m dew point temperature [K] +!!! tdsmean: mean 2m dew point temperature [K] +!!! twsmin: minimum 2m wet-bulb temperature [K] +!!! twsmax: maximum 2m wet-bulb temperature [K] +!!! twsmean: mean 2m wet-bulb temperature [K] +!!! tashurstreshighres: high resolution of simultaneous temporal residence of 2-meter temperature +!!! and relative humidity +!!! tashurstreslowres: low resolution of simultaneous temporal residence of 2-meter temperature +!!! and relative humidity +!!! wbdswsstres: simultaneous temporal residence of 10-meter wind direction (from where it blows) +!!! and wind speed +!!! wbacdh: Water-budget vertically integrated accumulated diabatic heating [K] +!!! wbacpw, wbacpw[c/r/s/i/g/h]: Water-budget vertically integrated accumulated total tendency for water +!!! vapour, cloud, rain, snow, ice, graupel, hail [mm] +!!! wbacf, wbacf[c/r/s/i/g/h]: Water-budget vertically integrated accumulated horizontal advection for +!!! water vapour, cloud, rain, snow, ice, graupel, hail [mm] +!!! wbacz, wbacz[c/r/s/i/g/h]: Water-budget vertically integrated accumulated vertical advection for +!!! water vapour, cloud, rain, snow, ice, graupel, hail [mm] +!!! wbacdh{l/m/h}: Water-budget vertically integrated accumulated diabatic heating at low, medimum and high levels [K] +!!! wbacpw[v/c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated total +!!! tendency for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels +!!! (same as cloudiness) [mm] +!!! wbacf[v/c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated horizontal +!!! advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels +!!! (same as cloudiness) [mm] +!!! wbacz[v/c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated vertical +!!! advection for water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels +!!! (same as cloudiness) [mm] + + ! sea level pressure methods + INTEGER, PARAMETER :: dpslshuell = 1 + INTEGER, PARAMETER :: dpslptarget = 2 + INTEGER, PARAMETER :: dpslecmwf = 3 + ! generic boundary layer + INTEGER, PARAMETER :: zmlagenthetae = 1 + INTEGER, PARAMETER :: zmlagenbulk = 2 + ! surface wind-gust methods + INTEGER, PARAMETER :: dwsgsbrasseur01 = 1 + INTEGER, PARAMETER :: dwsgsheavyprecip = 2 + ! Methods for vertical wind extrapolation + INTEGER, PARAMETER :: dwsz100powerlaw = 1 + INTEGER, PARAMETER :: dwsz100loglaw = 2 + INTEGER, PARAMETER :: dwsz100MO = 3 + ! Methods for potential evapotranspiration + INTEGER, PARAMETER :: dpotevaporbulk = 1 + INTEGER, PARAMETER :: dpotevaporMilly92 = 2 + ! Methods for fog and visibility + INTEGER, PARAMETER :: dfogK84 = 1 + INTEGER, PARAMETER :: dfogRUC = 2 + INTEGER, PARAMETER :: dfogFRAML50 = 3 + CHARACTER(len=256) :: fname + +CONTAINS + + SUBROUTINE cordex_output_calc( & + is_restart, is_output_time, nsteps, & + dt, xtime, curr_secs2, radt, & + cdxH, & + psl_diag, ptarget, psmooth, & + wsgs_diag, & + wbout, & + wsz100_diag, zhgtzw, z50_diag, & + dqv, dtheta, & + potevap_diag, & + convxtrm_diag, & + visibility_diag, fogvars, zmlagen_diag, & + timedbg, wgsts_wbdswsstres, & + londbg, latdbg, & + idbg, jdbg, & +!#ifdef CDXWRF +!#if CDXWRF>=3 + Nhtasrng, Nhhursrng, Nltasrng, Nlhursrng, Nwbdsrng, Nwssrng, & + Nhtashursrng, Nltashursrng, Nwbdswssrng, & + tashrng, hurshrng, taslrng, hurslrng, wbdsrng, wssrng, & +!#endif +!#endif + ! Input + lon, lat, & + cldfra, p8w, p, pb, & + pclt, pcll, pclm, pclh, & + qv, qc, qr, qs, qi, qg, qh, & + mu, mub, deta, & + sina, cosa, & + u, v, t, thp, ph, phb, p_phy, & + u10, v10, q2, t2, th2, ps, qsfc, & + hgt, z, & + dzs, smois, sh2o, & + tke, pblh, & + prc, prnc, prsh, & + ust, znt, rol, & + swdown, & + Cd, & + glw, lh, hfx, swupb, lwupb, qfx, & + snow, snowh, snowc, & + sfcrunoff, udrunoff, & + rho, & + swdnt, swupt, lwupt, & + ts, albedo, emiss, & + sr, & + chs, cdm, br, zol, & + fracsoil10cm, & +!#ifdef CDXWRF +!#if CDXWRF>=1 +!#endif + +!#if CDXWRF>=4 + diabh, & + qvttend, qcttend, qrttend, qsttend, qittend, qgttend, qhttend, & + qvhadv, qchadv, qrhadv, qshadv, qihadv, qghadv, qhhadv, & + qvzadv, qczadv, qrzadv, qszadv, qizadv, qgzadv, qhzadv, & +!#endif +!#endif + ! Output + cltmean, cllmean, clmmean, clhmean, & + prw, clwvi, clivi, & + uas, vas, wss, wbds, hurs, huss, & + psl, & + wsgsmax, ugsmax, vgsmax, percengust, & + totwsgsmax, totugsmax, totvgsmax, totpercengust, & + wsz100, uz100wind, vz100wind, & + wsz100max, uz100max, vz100max, & + wsz50, uz50wind, vz50wind, & + taz50, qvz50, & + sunshine, & + tauu, tauv, & + tauugen, tauvgen, & + rsds, rlds, hfls, hfss, rsus, rlus, rsusgen, rlusgen, & + evspsbl, evspsblpot, evspsblpotgen, & + cdcdx, cdgen, & + snc, snd, & + pmrros, pmrro, & + mrros, mrro, mrso, mrsol, mrsos, & + mrsll, mrlso, mrlsos, & + mrsfl, mrfso, mrfsos, & + mrsomean, mrsolmean, mrsosmean, & + mrsllmean, mrlsomean, mrlsosmean, & + mrsflmean, mrfsomean, mrfsosmean, & + flxpr, flxprl, flxprc, flxprsh, flxprsn, snw, & + rsdt, rsut, rlut, & + tas_hm, qvs_hm, & +!#ifdef CDXWRF +!#if CDXWRF>=1 + clgvi, clhvi, & + zmla, & + capemin, cinmin, zlfcmin, plfcmin, & + capemax, cinmax, zlfcmax, plfcmax, & + capemean, cinmean, zlfcmean, plfcmean, & + iutmean, ivtmean, & + zeroith, & + lidxmin, lidxmax, lidxmean, & +!#endif +!#if CDXWRF>=2 + ua, va, ws, zg, ta, press, hur, hus, & + tfog, fogvisbltymin, fogvisbltymax, fogvisbltymean, & + tdsmin, tdsmax, tdsmean, & + twsmin, twsmax, twsmean, & +!#endif +!#if CDXWRF>=4 + ! Water-budget + wbacdh, & + wbacpw, wbacpwc, wbacpwr, wbacpws, wbacpwi, wbacpwg, wbacpwh, & + wbacf, wbacfc, wbacfr, wbacfs, wbacfi, wbacfg, wbacfh, & + wbacz, wbaczc, wbaczr, wbaczs, wbaczi, wbaczg, wbaczh, & + wbacdhl, wbacdhm, wbacdhh, & + wbacpwlv,wbacpwmv,wbacpwhv,wbacflv,wbacfmv, wbacfhv, wbaczlv, wbaczmv, wbaczhv, & + wbacpwlc,wbacpwmc,wbacpwhc,wbacflc,wbacfmc, wbacfhc, wbaczlc, wbaczmc, wbaczhc, & + wbacpwlr,wbacpwmr,wbacpwhr,wbacflr,wbacfmr, wbacfhr, wbaczlr, wbaczmr, wbaczhr, & + wbacpwls,wbacpwms,wbacpwhs,wbacfls,wbacfms, wbacfhs, wbaczls, wbaczms, wbaczhs, & + wbacpwli,wbacpwmi,wbacpwhi,wbacfli,wbacfmi, wbacfhi, wbaczli, wbaczmi, wbaczhi, & + wbacpwlg,wbacpwmg,wbacpwhg,wbacflg,wbacfmg, wbacfhg, wbaczlg, wbaczmg, wbaczhg, & + wbacpwlh,wbacpwmh,wbacpwhh,wbacflh,wbacfmh, wbacfhh, wbaczlh, wbaczmh, wbaczhh, & +!#endif +!#if CDXWRF>=3 + tashurstreshighres, tashurstreslowres, wbdswsstres, & +!#endif +!#endif + ids,ide, jds,jde, kds,kde, & + ims,ime, jms,jme, kms,kme, & + ips,ipe, jps,jpe, kps,kpe, & ! patch dims + i_start,i_end,j_start,j_end,kts,kte,num_tiles, & + num_soil_layers, n_moist, & + m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh & + !! INSTVALS: Instantaneous values (uncomment and re-compile) +! clt, cll, clm, clh, & +! iut, ivt, & +! wsgs, ugustwind, vgustwind, gustpoint, & +! totwsgs, totugustwind, totvgustwind, gustpoint, & +! potevap, potevapogen, & +!#ifdef CDXWRF +!#if CDXWRF>=1 +! cape, cin, zlfc, plfc, lidx, & +!#endif +!#if CDXWRF>=2 +! fog, fogvisblty, & +! tds, tws & +!#endif +!#endif +!! End of INSTVALS + ) + +!---------------------------------------------------------------------- +! Main subroutine to compute CORDEX required variables + + USE module_dm, ONLY: wrf_dm_sum_real, wrf_dm_maxval + USE module_configure + USE module_diagvar_cordex + + IMPLICIT NONE + +!====================================================================== +! Definitions +!----------- +!-- DT time step (second) +!-- XTIME forecast time +!-- curr_secs2 current time in seconds since simulation restart +!-- radt frequency of radiative calls (minutes) +! +!-- ids start index for i in domain +!-- ide end index for i in domain +!-- jds start index for j in domain +!-- jde end index for j in domain +!-- kds start index for k in domain +!-- kde end index for k in domain +!-- ims start index for i in memory +!-- ime end index for i in memory +!-- jms start index for j in memory +!-- jme end index for j in memory +!-- ips start index for i in patch +!-- ipe end index for i in patch +!-- jps start index for j in patch +!-- jpe end index for j in patch +!-- kms start index for k in memory +!-- kme end index for k in memory +!-- i_start start indices for i in tile +!-- i_end end indices for i in tile +!-- j_start start indices for j in tile +!-- j_end end indices for j in tile +!-- kts start index for k in tile +!-- kte end index for k in tile +!-- num_tiles number of tiles +!-- num_soil_layers number of soil layers +!-- n_moist number of water species +!-- m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh: moist indices for each specie: vapour, cloud, rain, snow, ice, graupel, ice and hail +! +!----------- +! is_restart: whether if simulation is a restart +! is_output_time: whether if this iteration is an output time-step +! cdxH: period of time [minute] of calculations between outputs +! psl_diag: diagnostic to use to compute sea level pressure +! ptarget: pressure target to use for psl_diag=2 (default 70000. Pa) +! psmooth: number of passses of nearest 3x3 grid-point mean filter on psfc on psl_diag=2 (default 5) +! wsgs_diag: diagnostic to compute surface windgust +! wbout: whether Water-Budget terms shoud be computed or not +! wsz100_diag: extrapolation of wind at 100m +! zhgtzw: height at which 100 m winds should be extrapolated [m] (default 100 m) +! z50_diag: height at which 50 m variables (wind, ta, qv) should be extrapolated [m] (default 50 m) +! dqv: percentage of variation of qv to determine mixed layer depth [1] +! dtheta: increment in potential temperature [K] to determine zmla [K] +! potevap_diag: diagnostic of the potential evapotranspiration +! convxtrm_diag: diagnostic of extremes from convection indices +! visibility_diag: diagnostic of visibilty inside fog +! fogvars: variables to use to diagnose fog (1: 3D, 2: sfc) +! zmlagen_diag: diagnostic of generic boundary layer height, zmla (1: thetae-stability, 2: bulk +! Richardson number [default]) +! +! ------- INPUT vars ------- +! lon: longitude +! lat: latitude +! cldfra: cloud fraction [1] +! pclt: previous radt call total cloudiness [1] +! pcll: previous radt call low level cloudiness (p >= 68000 Pa) [1] +! pclm: previous radt call mid-level cloudiness ( 68000 < p >= 44000 Pa) [1] +! pclh: previous radt call high level cloudiness (p < 44000 Pa) [1] +! p8w: 3D pressure array at full eta levels [Pa] +! P: anomaly pressure half eta levels [Pa] +! PB: base pressure half eta levels [Pa] +! qv: water vapour mixing ratio [kgkg-1] +! qc: cloud mixing ratio [kgkg-1] +! qr: rain mixing ratio [kgkg-1] +! qs: snow mixing ratio [kgkg-1] +! qi: ice mixing ratio [kgkg-1] +! qg: graupel mixing ratio [kgkg-1] +! qh: hail mixing ratio [kgkg-1] +! mu: perturbation dry air mass in column [Pa] +! mub: base dry air mass in column [Pa] +! deta: d(eta) values between full (w) levels +! sina: local sine of map rotation [1] +! cosa: local cosine of map rotation [1] +! u: 3D easthward wind direction [ms-1] +! v: 3D northward wind direction [ms-1] +! t: 3D air temperature [K] +! th: 3D air potential temperature [K] +! ph: 3D gepotential perturbation [m2s-2] +! phb: 3D gepotential base state [m2s-2] +! p_phy: 3D total pressure (p+pb) [Pa] +! u10: 10m easthward wind direction [ms-1] +! v10: 10m northward wind direction [ms-1] +! t2: 2m air temperature [K] +! th2: 2m potential air temperature [K] +! q2: 2m water vapour [kgkg-1] +! qsfc: specific humidity at the boundary [kgkg-1] +! hgt: orography [m] +! z: heights of the half levels [gpm] +! dzs: depths of the soil levels [m] +! smois: soil moisture [m3m-3] +! sh2o: liquid soil water content [m3m-3] +! rho: air density [kgm-3] +! diabh: diabatic heating from micro-physics [Ks-1] +! q[v/c/r/s/i/g/h]ttend: internal time-step tendency of water species for water vapour, cloud, rain, +! snow, ice, graupel, hail [kgkg-1s-1] +! q[v/c/r/s/i/g/h]hadv: horizontal advection of water species for water vapour, cloud, rain, snow, +! ice, graupel, hail [kgkg-1] +! q[v/c/r/s/i/g/h]zadv: vertical advection of water species for water vapour, cloud, rain, snow, ice, +! graupel, hail [kgkg-1] +! tke: turbulent kinetic energy [m2s-2] +! pblh: boundary layer height [m] +! prc: convective (from cumulus scheme) precipitation [kgm-2] +! prnc: non-convective (from micro-physics scheme) precipitation [kgm-2] +! prsh: shallow-cumulus (from shallow-cumulus scheme) precipitation [kgm-2] +! ust: u* in similarity theory [ms-1] +! znt: thermal time-varying roughness length [m] +! rol: inverse of Obukhov length [m-1] +! swdown: downward short-wave radiation [Wm-2] +! Cd: Drag coefficient [-] +! glw: downward long wave flux at ground surface [Wm-2] +! lh: latent heat flux at the surface [Wm-2] +! hfx: sensible heat flux at the surface [Wm-2] +! swupb: upwelling shortwave flux at bottom [Wm-2] +! lwupb: upwelling longwave flux at bottom [Wm-2] +! qfx: upward moisture flux at the surface [kgm-2s-1] +! snow: snow water equivalent [kgm-2] +! snowh: physical snow height [m] +! snowc: snow cover [1] +! sfcrunoff: surface runoff [kgm-2] +! udrunoff: underground runoff [kgm-2] +! swdnt: incident short wave at top of the Atmosphere (TOA) [Wm-2] +! swupt: outgoing short wave at top of the Atmosphere (TOA) [Wm-2] +! lwupt: outgoing long wave at top of the Atmosphere (TOA) [Wm-2] +! ts: skin temperature [k] +! albedo: surface land albedo [1] +! emiss: surface emissivity [1] +! sr: fraction of frozen precipitation [1] +! chs: surface exchange coeeficient for heat [-] +! cdm: surface exchange coefficient for momentum [-] +! br: Bulk Richardson number [-] +! zol: Characteristic length (z/L) [-] +! fracsoil10cm: fraction of the soil layer used to compute 0-10 vertical accumulations +! timedbg: frecuency in minutes of time debugging +! londbg, latdbg: coordinates of the debugging grid point (-999. if not set-up) +! idbg, jdbg: grid point coordinates of the debugging grid point +! wgsts_wbdswsstres: whether wind gusts should be used for wbds-wss residence-time (0: no, 1: yes) + +!-------- OUTPUT vars ------- [defined at registry.cordex] and included on Registry.EM_COMMON on auxhist9 +! nsteps: counter of time-steps passed for computation of statistics +! clt: total cloudiness [%] +! cll: low level cloudiness (p >= 68000 Pa) [%] +! clm: mid-level cloudiness ( 68000 < p >= 44000 Pa) [%] +! clh: high level cloudiness (p < 44000 Pa) [%] +! cltmean: mean clt [%] +! cllmean: mean cll [%] +! clmmean: mean clm [%] +! clhmean: mean clh [%] +! prw: Total water path [kgm-2] +! clwvi: Total condensated water path [kgm-2] +! clivi: Total ice water path [kgm-2] +! clgvi: Total graupel water path [kgm-2] +! clhvi: Total hail water path [kgm-2] +! ua: 3D earth-rotated eastward wind [ms-1] +! va: 3D earth-rotated northward wind [ms-1] +! ta: 3D air-temperature [K] +! press: 3D air pressure [Pa] +! zg: 3D geopotential height [m] +! hur: 3D relative humidty [1] +! hus: 3D specific humidty [1] +! uas: 10m earth-rotated eastward wind [ms-1] +! vas: 10m earth-rotated northward wind [ms-1] +! hurs: 2m relative humidty [1] +! huss: 2m specific humidty [1] +! psl: sea level pressure [Pa] +! cape: Convective Available Potential Energy [Jkg-1] +! cin: Convective inhibition [Jkg-1] +! zlfc: Height at the Level of free convection [m] +! plfc: Pressure at the Level of free convection [Pa] +! lidx: Lifted index [1] +! mrsol: moisture content of soil layer [kgm-2] +! mrso: total soil moisture content [kgm-2] +! mrsos: first layer soil moisture content (0-10 cm) [kgm-2] +! mrsll: liquid water content of soil layer [kgm-2] +! mrlso: total liquid water content of soil layer [kgm-2] +! mrlsos: liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] +! mrsfl: frozen water content of soil layer [kgm-2] +! mrfso: total frozen water content of soil layer [kgm-2] +! mrfsos: frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] +! mrsolmean: mean moisture content of soil layer [kgm-2] +! mrsosmean: mean first layer soil moisture content (0-10 cm) [kgm-2] +! mrsomean: mean total soil moisture content [kgm-2] +! mrsllmean: mean liquid water content of soil layer [kgm-2] +! mrlsomean: mean total liquid water content of soil layer [kgm-2] +! mrlsosmean: mean liquid water content in Upper Portion of soil column (0-10cm) [kgm-2] +! mrsflmean: mean frozen water content of soil layer [kgm-2] +! mrfsomean: mean total frozen water content of soil layer [kgm-2] +! mrfsosmean: mean frozen water content in Upper Portion of soil column (0-10cm) [kgm-2] +! wbacpw, wbacpw[c/r/s/i/g/h]: Water-budget vertically integrated accumulated total tendency for water +! vapour, cloud, rain, snow, ice, graupel, hail [mm] +! wbacf, wbacf[c/r/s/i/g/h]: Water-budget vertically integrated accumulated horizontal advection for +! water vapour, cloud, rain, snow, ice, graupel, hail [mm] +! wbacz, wbacz[c/r/s/i/g/h]: Water-budget vertically integrated accumulated vertical advection for +! water vapour, cloud, rain, snow, ice, graupel, hail [mm] +! wbacpw{l/m/h}, wbacpw[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated total tendency for water +! vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] +! wbacf{l/m/h}, wbacf[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated horizontal advection for +! water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] +! wbacz{l/m/h}, wbacz[c/r/s/i/g/h]{l/m/h}: Water-budget vertically integrated accumulated vertical advection for +! water vapour, cloud, rain, snow, ice, graupel, hail at low, medium and high levels (same as cloudiness) [mm] +! acq[v/c/i]blten: accumulated tendency due to boundary layer scheme for water vapour, cloud and ice [mm] +! acq[v/c/i/r/s]cuten: accumulated tendency due to cumulus scheme for water vapour, cloud, ice, rain and snow [mm] +! wsgsmax: maximum surface wind gust [ms-1] +! [u/v]gsmax: x/y maximum surface gust wind direction [ms-1] +! precengust: percenteage of times where grid point got wind gust +! totwsgsmax: total (TKE + heavy precip. methods )maximum surface wind gust [ms-1] +! tot[u/v]gsmax: total x/y maximum surface gust wind direction [ms-1] +! totprecengust: percenteage of times where grid point got total wind gust +! wsz100max: maximum 100m wind [ms-1] +! uz100max: x maximum 100m wind direction [ms-1] +! vz100max: y maximum 100m wind direction [ms-1] +! sunshine: length of sunshine [s] +! tauu, tauuv: components of the downward wind stress at 10 m [m2s-2] +! tauugen, tauuvgen: generic components of the downward wind stress at 10 m [m2s-2] +! cdcdx: drag coefficient [-] +! cdgen: generic drag coefficient [-] +! rsds: mean surface Downwelling Shortwave Radiation [Wm-2] +! rlds: mean surface Downwelling Longwave Radiation [Wm-2] +! hfls: mean surface Upward Latent Heat Flux [Wm-2] +! hfss: mean surface Upward Sensible Heat Flux [Wm-2] +! rsus: mean surface Upwelling Shortwave Radiation [Wm-2] +! rlus: mean surface Upwelling Longwave Radiation [Wm-2] +! rsusgen: mean generic surface Upwelling Shortwave Radiation [Wm-2] +! rlusgen: mean generic surface Upwelling Longwave Radiation [Wm-2] +! evspsbl: mean evaporation [kgm-2s-1] +! evspsblpot: mean potential evapotranspiration [kgm-2s-1] +! evspsblpotgen: mean generic potential evapotranspiration [kgm-2s-1] +! snc: mean snow area fraction [%] +! snd: mean snow depth [m] +! pmrros: previous accumulated surface Runoff [kgm-2] +! pmrro: previous accumulated mean total Runoff [kgm-2] +! mrros: mean surface Runoff [kgm-2s-1] +! mrro: mean total Runoff [kgm-2s-1] +! flxpr: precipitation flux [kgm-2s-1] +! flxprl: large scale precipitation flux [kgm-2s-1] +! flxprc: convective precipitation flux [kgm-2s-1] +! flxprsh: shallow-cumulus precipitation flux [kgm-2s-1] +! flxprsn: solid precipitation flux [kgm-2s-1] +! snw: accumulated snow [ksm-2] +! rsdt: TOA incident shortwave radiation [kgm-2] +! rsut: TOA outgoing shortwave radiation [kgm-2] +! rlut: TOA outgoing Longwave radiation [kgm-2] +! capemin: minimum CAPE [Jkg-1] +! cinmin: minimum CIN [Jkg-1] +! zlfcmin: minimum height at LFC [m] +! plfcmin: minimum Pressure at LFC [Pa] +! lidxmin: minimum Lifted index [1] +! capemax: maximum CAPE [Jkg-1] +! cinmax: maximum CIN [Jkg-1] +! zlfcmax: maximum height at LFC [m] +! plfcmax: maximum Pressure at LFC [Pa] +! lidxmax: maximum Lifted index [1] +! capemean: mean CAPE [Jkg-1] +! cinmean: mean CIN [Jkg-1] +! zlfcmean: mean height at LFC [m] +! plfcmean: mean Pressure at LFC [Pa] +! lidxmean: mean Lifted index [1] +! fog: whether point is inside fog (vis < 1km) [1] +! visblty: visibility inside fog [km] +! tfog: time of presence of fog [s] +! fogvisbltymin: minimun visibility inside fog [km] +! fogvisbltymax: maximun visibility inside fog [km] +! fogvisbltymean: mean visibility inside fog [km] +! tdsmin: minimum 2m dew point temperature [K] +! tdsmax: maximum 2m dew point temperature [K] +! tdsmean: mean 2m dew point temperature [K] +! twsmin: minimum 2m wet-bulb temperature [K] +! twsmax: maximum 2m wet-bulb temperature [K] +! twsmean: mean 2m wet-bulb temperature [K] +! tashurstreshighres: high-resolution of simultaneous temporal residence of 2-m temperature and +! relative humidity +! tashurstreslowres: low-resolution of simultaneous temporal residence of 2-m temperature and +! relative humidity +! wbdswsstres: simultaneous temporal residence of 10-m wind direction (from where it blows) and +! wind speed + +!!!!!!! Structure +! 1.: Compute such variables needed for internal accumulations, extremes +! 2.: Compute the variables from clouds (only actualized at every radt) +! 3.: If the time step is the first after writting the auxhist9 file inittialize the variables of (1., 2.) +! 4.: If the time step is exactly the previous one before the writting of the auxhist9 file: +! a: Compute all other variables +! b: Finish calculation of 1., 2. variables + +!====================================================================== + + INTEGER, INTENT(in) :: & + ids,ide, jds,jde, kds,kde, & + ims,ime, jms,jme, kms,kme, & + ips,ipe, jps,jpe, kps,kpe, & + kts,kte, & + num_tiles, & + num_soil_layers, n_moist + + + INTEGER, DIMENSION(num_tiles), INTENT(in) :: i_start, i_end, j_start, j_end + INTEGER, INTENT(in) :: m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh + + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: cldfra, p8w, p, pb, qv, qc, qr, qs, qi, & + qg, qh, t, thp, ph, phb, p_phy, u, v, z, rho +!#ifdef CDXWRF +!#if CDXWRF>=1 +!#endif + +!#if CDXWRF>=4 + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: diabh + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: qvttend, qcttend, qrttend, qsttend, & + qittend, qgttend, qhttend + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: qvhadv, qchadv, qrhadv, qshadv, qihadv, & + qghadv, qhhadv + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: qvzadv, qczadv, qrzadv, qszadv, qizadv, & + qgzadv, qhzadv +!#endif +!#if CDXWRF>=3 + INTEGER, INTENT(in) :: Nhtasrng, Nhhursrng, Nltasrng, Nlhursrng, & + Nwbdsrng, Nwssrng + INTEGER, INTENT(in) :: Nhtashursrng, Nltashursrng, Nwbdswssrng + REAL, DIMENSION(Nhtasrng), INTENT(in) :: tashrng + REAL, DIMENSION(Nhhursrng), INTENT(in) :: hurshrng + REAL, DIMENSION(Nltasrng), INTENT(in) :: taslrng + REAL, DIMENSION(Nlhursrng), INTENT(in) :: hurslrng + REAL, DIMENSION(Nwbdsrng), INTENT(in) :: wbdsrng + REAL, DIMENSION(Nwssrng), INTENT(in) :: wssrng +!#endif +!#endif + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: lon, lat + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: mu, mub, sina, cosa + REAL, DIMENSION(kms:kme), INTENT(in) :: deta + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: u10, v10, q2, t2, th2, ps, qsfc + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: hgt + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: tke + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: pblh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: prc, prnc, prsh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: ust, znt, rol + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: swdown + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: Cd + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: glw, lh, hfx, swupb, lwupb, qfx + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: snow, snowh, snowc + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: sfcrunoff, udrunoff + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: swdnt, swupt, lwupt + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: ts, albedo, emiss + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: sr + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: chs, cdm, br, zol + + REAL, INTENT(in) :: DT, XTIME + REAL, INTENT(in) :: curr_secs2, radt + INTEGER, INTENT(in) :: cdxH + LOGICAL, INTENT(in) :: is_restart, is_output_time + REAL, INTENT(in) :: ptarget + INTEGER, INTENT(in) :: psl_diag, psmooth + INTEGER, INTENT(in) :: wsgs_diag + INTEGER, INTENT(in) :: wbout + INTEGER, INTENT(in) :: wsz100_diag + REAL, INTENT(in) :: zhgtzw + REAL, INTENT(in) :: z50_diag + INTEGER, INTENT(in) :: potevap_diag + REAL, INTENT(in) :: dqv, dtheta + INTEGER, INTENT(in) :: convxtrm_diag + INTEGER, INTENT(in) :: visibility_diag, fogvars, zmlagen_diag + REAL, DIMENSION(1:num_soil_layers), INTENT(in) :: dzs, fracsoil10cm + INTEGER, INTENT(in) :: timedbg, wgsts_wbdswsstres + REAL, INTENT(in) :: londbg, latdbg + INTEGER, INTENT(in) :: idbg, jdbg + + INTEGER, INTENT(inout) :: nsteps + REAL, DIMENSION(ims:ime,1:num_soil_layers,jms:jme), & + INTENT(in) :: smois, sh2o + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: pclt, pcll, pclm, pclh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: cltmean, cllmean, clmmean, clhmean + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: prw, clwvi, clivi +!#ifdef CDXWRF +!!#if CDXWRF>=1 +!! REAL, DIMENSION(ims:ime,kms:kme,jms:jme) :: ta, press, zg, hur +!!#endif +!#if CDXWRF>=1 + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: zmla + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: clgvi, clhvi + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: capemin, cinmin, zlfcmin, plfcmin + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: capemax, cinmax, zlfcmax, plfcmax + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: capemean, cinmean, zlfcmean, plfcmean, & + lidxmin, lidxmax, lidxmean + REAL, DIMENSION(ims:ime,jms:jme) :: iutmean, ivtmean + REAL, DIMENSION(ims:ime,jms:jme) :: zeroith +!#endif +!#if CDXWRF>=2 + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(out) :: ua, va, ta, press, zg, hur, ws, hus + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: tfog, fogvisbltymin, fogvisbltymax, & + fogvisbltymean + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: tdsmin, tdsmax, tdsmean + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: twsmin, twsmax, twsmean +!#endif +!#if CDXWRF>=4 + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacdh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacpw, wbacpwc, wbacpwr, wbacpws, & + wbacpwi, wbacpwg, wbacpwh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacf, wbacfc, wbacfr, wbacfs, wbacfi, & + wbacfg, wbacfh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacz, wbaczc, wbaczr, wbaczs, wbaczi, & + wbaczg, wbaczh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacdhl, wbacdhm, wbacdhh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacpwlv, wbacpwmv, wbacpwhv, & + wbacpwlc, wbacpwmc, wbacpwhc, wbacpwlr, wbacpwmr, wbacpwhr, wbacpwls, wbacpwms, wbacpwhs, & + wbacpwli, wbacpwmi, wbacpwhi, wbacpwlg, wbacpwmg, wbacpwhg, wbacpwlh, wbacpwmh, wbacpwhh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbacflv, wbacfmv, wbacfhv, & + wbacflc, wbacfmc, wbacfhc, wbacflr, wbacfmr, wbacfhr, wbacfls, wbacfms, wbacfhs, & + wbacfli, wbacfmi, wbacfhi, wbacflg, wbacfmg, wbacfhg, wbacflh, wbacfmh, wbacfhh + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wbaczlv, wbaczmv, wbaczhv, & + wbaczlc, wbaczmc, wbaczhc, wbaczlr, wbaczmr, wbaczhr, wbaczls, wbaczms, wbaczhs, & + wbaczli, wbaczmi, wbaczhi, wbaczlg, wbaczmg, wbaczhg, wbaczlh, wbaczmh, wbaczhh +!#endif +!#if CDXWRF>=3 +!! REAL, DIMENSION(ims:ime,jms:jme,Nhtasrng,Nhhursrng), & +!! INTENT(inout) :: tashurstreshighres +!! REAL, DIMENSION(ims:ime,jms:jme,Nltasrng,Nlhursrng), & +!! INTENT(inout) :: tashurstreslowres + REAL, DIMENSION(ims:ime,Nhtashursrng,jms:jme), & + INTENT(inout) :: tashurstreshighres + REAL, DIMENSION(ims:ime,Nltashursrng,jms:jme), & + INTENT(inout) :: tashurstreslowres + REAL, DIMENSION(ims:ime,Nwbdswssrng,jms:jme), & + INTENT(inout) :: wbdswsstres +!#endif +!#else +! REAL, DIMENSION(ims:ime,kms:kme,jms:jme) :: ta, press, zg +!#endif + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: uas, vas, wss, wbds, hurs, huss + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: psl + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wsgsmax, ugsmax, vgsmax, percengust + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: totwsgsmax, totugsmax, totvgsmax, & + totpercengust + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: wsz100, uz100wind, vz100wind + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: wsz50, uz50wind, vz50wind + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: taz50, qvz50 + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: wsz100max, uz100max, vz100max + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: sunshine + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: cdcdx, tauu, tauv, tauugen, tauvgen + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: rsds, rlds, hfls, hfss, rsus, rlus, & + rsusgen, rlusgen, evspsbl + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: cdgen, evspsblpot, evspsblpotgen + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: snc, snd + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: pmrros, pmrro + REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: mrros, mrro, mrsos, mrso, mrlso, mrlsos, & + mrfso, mrfsos + REAL, DIMENSION(ims:ime,1:num_soil_layers,jms:jme), & + INTENT(out) :: mrsol, mrsll, mrsfl + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: mrsosmean, mrsomean, mrlsomean, & + mrlsosmean, mrfsomean, mrfsosmean + REAL, DIMENSION(ims:ime,1:num_soil_layers,jms:jme), & + INTENT(inout) :: mrsolmean, mrsllmean, mrsflmean + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: flxpr, flxprl, flxprc, flxprsh, flxprsn, & + snw + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: rsdt, rsut, rlut + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: tas_hm, qvs_hm + +!!! INSTVALS: Instantaneous values (uncomment and recompile) +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: clt, cll, clm, clh +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: wsgs, ugustwind, vgustwind +!! INTEGER, DIMENSION(ims:ime,jms:jme), INTENT(out) :: gustpoint +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: totwsgs, totugustwind, totvgustwind +!! INTEGER, DIMENSION(ims:ime,jms:jme), INTENT(out) :: totgustpoint +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: potevap, potevapgen +!#ifdef CDXWRF +!#if CDXWRF>=1 +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: cape, cin, zlfc, plfc, lidx +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: iut, ivt +!#endif +!#if CDXWRF>=2 +!! INTEGER, DIMENSION(ims:ime,jms:jme), INTENT(out) :: fog +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: vis +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: tds +!! REAL, DIMENSION(ims:ime,jms:jme), INTENT(out) :: tws +!#endif +!#endif +!! INSTVALS: comment these lines + REAL, DIMENSION(ims:ime,jms:jme) :: clt, cll, clm, clh + REAL, DIMENSION(ims:ime,jms:jme) :: wsgs, ugustwind, vgustwind + INTEGER, DIMENSION(ims:ime,jms:jme) :: gustpoint + REAL, DIMENSION(ims:ime,jms:jme) :: totwsgs, totugustwind, totvgustwind + INTEGER, DIMENSION(ims:ime,jms:jme) :: totgustpoint + REAL, DIMENSION(ims:ime,jms:jme) :: wsgsb01, ugustwindb01, vgustwindb01 + REAL, DIMENSION(ims:ime,jms:jme) :: wsgshp, ugustwindhp, vgustwindhp + INTEGER, DIMENSION(ims:ime,jms:jme) :: gustpointb01, gustpointhp + REAL, DIMENSION(ims:ime,jms:jme) :: potevap, potevapgen +!#ifdef CDXWRF +!#if CDXWRF>=1 + REAL, DIMENSION(ims:ime,jms:jme) :: cape, cin, zlfc, plfc, lidx + REAL, DIMENSION(ims:ime,jms:jme) :: iut, ivt +!#endif +!#if CDXWRF>=2 + INTEGER, DIMENSION(ims:ime,jms:jme) :: fog + REAL, DIMENSION(ims:ime,jms:jme) :: vis + REAL, DIMENSION(ims:ime,jms:jme) :: tds + REAL, DIMENSION(ims:ime,jms:jme) :: tws +!#endif +!#if CDXWRF>=3 + INTEGER :: itas, ihurs, iwbds, iwss +!#endif +!#if CDXWRF>=4 +!#endif +!#endif +!!! End of INSTVALS + +! LOCAL VAR + + INTEGER :: i, j, k, m, its, ite, jts, jte, ij + !INTEGER :: i_s, i_e, j_s, j_e + INTEGER :: idp, jdp, dimz, dimz1, dz1 + INTEGER :: i1, i_1, j1, j_1, k2, tdbg + INTEGER, DIMENSION(num_tiles) :: i2, j2 + + REAL :: xtimep + REAL :: hus_kts, zg_kts, huss_hm + REAL :: taz2, qcs + REAL, DIMENSION(3) :: cllmh, varlmh + REAL, DIMENSION(ims:ime,kms:kme,jms:jme) :: unu, unv, th, geopoth + REAL, DIMENSION(ims:ime,jms:jme) :: mutot + REAL, DIMENSION(kms:kme) :: qvar, zagl, ri, qsolid + REAL, DIMENSION(ims:ime,kms:kme+1,jms:jme) :: stzg + REAL, DIMENSION(ims:ime,jms:jme) :: smoothp +!#ifdef CDXWRF +!#if CDXWRF>=1 + +!#endif +!#if CDXWRF>=3 + REAL :: uuas, vvas + REAL, DIMENSION(ims:ime,jms:jme) :: wbdsv, wssv +!#endif +!#if CDXWRF>=4 + REAL, DIMENSION(kms:kme,n_moist) :: qvarttend, qvarhadv, qvarzadv + REAL, DIMENSION(ims:ime,kms:kme,jms:jme,n_moist) :: pwqvar, fqvar, zqvar + REAL, DIMENSION(n_moist) :: acpwqvar, acfqvar, aczqvar + REAL, DIMENSION(n_moist) :: acpwlqvar, acpwmqvar, acpwhqvar + REAL, DIMENSION(n_moist) :: acflqvar, acfmqvar, acfhqvar + REAL, DIMENSION(n_moist) :: aczlqvar, aczmqvar, aczhqvar +!#endif +!#endif + INTEGER :: ostat + REAL, DIMENSION(kms:kme) :: zsfc + REAL :: prv + + LOGICAL, EXTERNAL :: wrf_dm_on_monitor + CHARACTER(len=256) :: msg + LOGICAL :: ijdbg, cdone + INTEGER :: dbg_level + + fname = 'cordex_output_calc' + + ! Showing version of the module + IF (curr_secs2 == 0. ) THEN + WRITE(msg,*) ' CORDEX-WRF module version: ' // TRIM(cdxwrfversion) // ' ...' + PRINT *, TRIM(msg) + CALL wrf_debug(0,msg) + END IF + + ! timedbg + ! when time-debug in minutes + tdbg = MOD(xtime, timedbg*1.) + + ! Getting the overall debug level + CALL get_wrf_debug_level( dbg_level ) + cdone = .FALSE. + + ! L. Fita: NOTE about efficiency + ! I am not sure if this is the more efficient way: + ! 1.- IF --> 2.- repeat DO + ! 1.- DO --> 2.- IF + + dimz = kme - kms + 1 + dimz1 = dimz + 1 + dz1 = dimz - 1 + ! Using p8w + !press = p8w + mutot = mu + mub + th = thp + 300. + + ! For test purposes + IF ((londbg == -999.) .OR. (latdbg == -999.)) THEN + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + i2(ij) = INT(0.5*(i_start(ij) + i_end(ij))) + j2(ij) = INT(0.5*(j_start(ij) + j_end(ij))) + END DO + !$OMP END PARALLEL DO + ELSE + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + i2(ij) = idbg + j2(ij) = jdbg + END DO + !$OMP END PARALLEL DO + END IF + k2 = 0.5*(kms+kme) + + ! Computing accumulative variables + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + ! Unstaggering certain variables + unu(i,:,j) = 0.5*(u(i,:,j)+u(i+1,:,j)) + unv(i,:,j) = 0.5*(v(i,:,j)+v(i,:,j+1)) + + ! air-pressure + CALL var_press(p(i,:,j), pb(i,:,j), dimz, press(i,:,j)) + + ! geopotential height + CALL var_zg(ph(i,:,j), phb(i,:,j), dimz1, dimz, stzg(i,:,j), zg(i,:,j)) + ! geopotential height as [m2s-2] + geopoth(i,:,j) = zg(i,:,j)*g + + ! air-temperature + CALL var_ta(thp(i,:,j), press(i,:,j), dimz, ta(i,:,j)) + + ! 2m relative humidity + CALL var_hurs(t2(i,j), ps(i,j), q2(i,j), hurs(i,j)) + + ! 10m Earth rotated winds + CALL var_uasvas(u10(i,j), v10(i,j), sina(i,j), cosa(i,j), uas(i,j), vas(i,j)) + + ! Not using var_vertint, since we have a full loop in soil_layers + !! mrso + !WRITE(msg,*) ' ' // TRIM(fname) // ': computing MRSO diagnostic' + !IF (ijdbg) CALL wrf_debug(50,msg) + !CALL var_vertint(smois(i,:,j), num_soil_layers, dzs(:), ABS(dzs(:)/dzs(:)), mrso(i,j)) + + !! slw + !WRITE(msg,*) ' ' // TRIM(fname) // ': computing SLW diagnostic' + !IF (ijdbg) CALL wrf_debug(50,msg) + !CALL var_vertint(sh2o(i,:,j), num_soil_layers, dzs(:), ABS(dzs(:)/dzs(:)), slw(i,j)) + + ! Land water + ! First layer soil + ! FROM: https://wcrp-cordex.github.io/cordex-cmip6-data-request/) + mrsos(i,j) = 0. + mrso(i,j) = 0. + mrlso(i,j) = 0. + mrlsos(i,j) = 0. + mrfso(i,j) = 0. + mrfsos(i,j) = 0. + DO k=1, num_soil_layers + mrsol(i,k,j) = smois(i,k,j)*dzs(k)*1000. + mrsos(i,j) = mrsos(i,j) + mrsol(i,k,j)*fracsoil10cm(k) + mrso(i,j) = mrso(i,j) + mrsol(i,k,j) + mrsll(i,k,j) = sh2o(i,k,j)*dzs(k)*1000. + mrlso(i,j) = mrlso(i,j) + mrsll(i,k,j) + mrlsos(i,j) = mrlsos(i,j) + mrsll(i,k,j)*fracsoil10cm(k) + mrsfl(i,k,j) = (smois(i,k,j) - sh2o(i,k,j))*dzs(k)*1000. + mrfso(i,j) = mrfso(i,j) + mrsfl(i,k,j) + mrfsos(i,j) = mrfsos(i,j) + mrsfl(i,k,j)*fracsoil10cm(k) + END DO + + ! Wind-gust + + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing Wind-gust' + + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + ! Brasseur methodology + CALL gustwind_Brasseur01(dimz, geopoth(i,:,j), qv(i,:,j), qc(i,:,j), th(i,:,j), tke(i,:,j), & + unu(i,:,j), unv(i,:,j), pblh(i,j), hgt(i,j), sina(i,j), cosa(i,j), ugustwind(i,j), & + vgustwind(i,j), gustpoint(i,j)) + ugustwindb01(i,j) = ugustwind(i,j) + vgustwindb01(i,j) = vgustwind(i,j) + wsgsb01(i,j) = SQRT(ugustwind(i,j)*ugustwind(i,j) + vgustwind(i,j)*vgustwind(i,j)) + gustpointb01(i,j) = gustpoint(i,j) + ! Height above ground + zagl = z(i,:,j)-hgt(i,j) + ! Total precipitation + prv = prc(i,j) + prnc(i,j) + prsh(i,j) + IF (ijdbg .AND. tdbg==0) THEN + WRITE(msg,*)' gustwind_afwa values zagl k=1:', zagl(1), ' prv:', prv, & + ' prate_mm_per_hr:', (prv/dt)*3600., ' ua 1:', unu(i,1,j), ' va 1:', unv(i,1,j) + CALL wrf_debug(100,msg) + END IF + CALL gustwind_afwa(dimz, dt, u10(i,j), v10(i,j), prv, zagl(:), unu(i,:,j), unv(i,:,j), & + sina(i,j), cosa(i,j), ugustwind(i,j), vgustwind(i,j), gustpoint(i,j)) + ugustwindhp(i,j) = ugustwind(i,j) + vgustwindhp(i,j) = vgustwind(i,j) + wsgshp(i,j) = SQRT(ugustwind(i,j)*ugustwind(i,j) + vgustwind(i,j)*vgustwind(i,j)) + gustpointhp(i,j) = gustpoint(i,j) + + ! L. Fita, CIMA. 17 Feburary 2018 + ! Brasseur (TKE) method accounts for the mechanically-induced wind gusts. + ! AFWA (heavy precipitation) accounts for the heavy convectivelly-induced wind gusts + ! For the total wind-gustiness, might be necessary the sum of both methodologies + ! Total wind-gust + totugustwind(i,j) = ugustwindb01(i,j) + ugustwindhp(i,j) + totvgustwind(i,j) = vgustwindb01(i,j) + vgustwindhp(i,j) + totwsgs(i,j) = wsgsb01(i,j) + wsgshp(i,j) + totgustpoint(i,j) = INT( MAXVAL( (/ gustpointb01(i,j)*1.,gustpointhp(i,j)*1. /) ) ) + + wsgsdiag: SELECT CASE (wsgs_diag) + CASE (dwsgsbrasseur01) + WRITE(msg,*) ' ' // TRIM(fname) // ': wsgs diagnostic= ', wsgs_diag, ' Brasseur, 2001'// & + ' method' + ugustwind(i,j) = ugustwindb01(i,j) + vgustwind(i,j) = vgustwindb01(i,j) + wsgs(i,j) = wsgsb01(i,j) + gustpoint(i,j) = gustpointb01(i,j) + + CASE (dwsgsheavyprecip) + WRITE(msg,*) ' ' // TRIM(fname) // ': wsgs diagnostic= ', wsgs_diag, 'AFWA method' + ugustwind(i,j) = ugustwindhp(i,j) + vgustwind(i,j) = vgustwindhp(i,j) + wsgs(i,j) = wsgshp(i,j) + gustpoint(i,j) = gustpointhp(i,j) + + CASE DEFAULT + WRITE (msg,*) ' ' // TRIM(fname) // ": ERROR -- error -- ERROR -- error : type " // & + "of wind gust diagnostic 'wsgs_diag=", wsgs_diag, "' not ready !! " // CHAR(10) // & + " available ones; ", dwsgsbrasseur01, " : Brasseur, 01", dwsgsheavyprecip, & + ' : heavy precipitation' + CALL wrf_error_fatal(msg) + END SELECT wsgsdiag + IF (ijdbg) CALL wrf_debug(50,msg) + ELSE + ugustwind(i,j) = 0. + vgustwind(i,j) = 0. + wsgs(i,j) = 0. + gustpoint(i,j) = 0 + totugustwind(i,j) = 0. + totvgustwind(i,j) = 0. + totwsgs(i,j) = 0. + totgustpoint(i,j) = 0 + ugustwindb01(i,j) = 0. + vgustwindb01(i,j) = 0. + wsgsb01(i,j) = 0. + gustpointb01(i,j) = 0 + ugustwindhp(i,j) = 0. + vgustwindhp(i,j) = 0. + wsgshp(i,j) = 0. + gustpointhp(i,j) = 0 + END IF + + ! z-wind + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing z-wind at:', zhgtzw, ' m' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + + ! Height above surface at half-mass levels + zsfc = zg(i,:,j)-hgt(i,j) + wsz100diag: SELECT CASE (wsz100_diag) + CASE (dwsz100powerlaw) + WRITE(msg,*) ' ' // TRIM(fname) // ': wsz100 diagnostic= ', wsz100_diag, ' power-law' + CALL var_zwind(dimz, unu(i,:,j), unv(i,:,j), zsfc, uas(i,j), vas(i,j), sina(i,j), & + cosa(i,j), zhgtzw, uz100wind(i,j), vz100wind(i,j)) + CASE (dwsz100loglaw) + WRITE(msg,*) ' ' // TRIM(fname) // ': wsz100 diagnostic= ', wsz100_diag, ' logarithmic-law' + CALL var_zwind_log(dimz, unu(i,:,j), unv(i,:,j), zsfc, uas(i,j), vas(i,j), sina(i,j), & + cosa(i,j), zhgtzw, uz100wind(i,j), vz100wind(i,j)) + CASE (dwsz100MO) + WRITE(msg,*) ' ' // TRIM(fname) // ': wsz100 diagnostic= ', wsz100_diag, & + ' Monin-Obukhov theory' + CALL var_zwind_MOtheor(dimz, unu(i,:,j), unv(i,:,j), zg(i,:,j), hgt(i,j), ust(i,j), & + znt(i,j), rol(i,j), u10(i,j), v10(i,j), sina(i,j), cosa(i,j), zhgtzw, uz100wind(i,j), & + vz100wind(i,j)) + CASE DEFAULT + WRITE (msg,*) ' ' // TRIM(fname) // ": ERROR -- error -- ERROR -- error : type " // & + "of z-wind diagnostic 'wsz100_diag=", wsz100_diag, "' not ready !! " // CHAR(10) // & + " available ones; ", dwsz100powerlaw, " : power-law", dwsz100loglaw, 'log-law', & + dwsz100MO, " : Monin-Obukhov" + CALL wrf_error_fatal(msg) + END SELECT wsz100diag + wsz100(i,j) = SQRT(uz100wind(i,j)*uz100wind(i,j) + vz100wind(i,j)*vz100wind(i,j)) + + ! 50 m + CALL var_zwind_MOtheor(dimz, unu(i,:,j), unv(i,:,j), zg(i,:,j), hgt(i,j), ust(i,j), & + znt(i,j), rol(i,j), u10(i,j), v10(i,j), sina(i,j), cosa(i,j), z50_diag, uz50wind(i,j), & + vz50wind(i,j)) + wsz50(i,j) = SQRT(uz50wind(i,j)*uz50wind(i,j) + vz50wind(i,j)*vz50wind(i,j)) + + CALL var_ztaqv_MOtheor(dimz, t(i,:,j), qv(i,:,j), zg(i,:,j), ust(i,j), znt(i,j), rol(i,j), & + hgt(i,j), z50_diag, taz50(i,j), qvz50(i,j)) + + ELSE + uz100wind(i,j) = 0. + vz100wind(i,j) = 0. + wsz100(i,j) = 0. + uz50wind(i,j) = 0. + vz50wind(i,j) = 0. + wsz50(i,j) = 0. + taz50(i,j) = 0. + qvz50(i,j) = 0. + END IF + + ! potential evapotranspiration + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing z-wind at:', zhgtzw, ' m' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + + ! Generic first-order approximation drag coefficient + CALL Cdrag_0(ust(i,j), uas(i,j), vas(i,j), cdgen(i,j)) + + ! potential evap + potevapdiag: SELECT CASE (potevap_diag) + CASE (dpotevaporbulk) + WRITE(msg,*) ' ' // TRIM(fname) // ': potevap diagnostic= ', potevap_diag, & + ' bulk' + CALL var_potevap_bulk(rho(i,1,j), cd(i,j), uas(i,j), vas(i,j), ts(i,j), ps(i,j), & + qv(i,1,j), potevap(i,j)) + CALL var_potevap_bulkgen(rho(i,1,j), ust(i,j), uas(i,j), vas(i,j), ts(i,j), ps(i,j), & + qv(i,1,j), potevapgen(i,j)) + CASE (dpotevaporMilly92) + WRITE(msg,*) ' ' // TRIM(fname) // ': potevap diagnostic= ', potevap_diag, & + ' Milly92' + CALL var_potevap_Milly92(rho(i,1,j), cd(i,j), uas(i,j), vas(i,j), ts(i,j), t(i,1,j), & + ps(i,j), qv(i,1,j), qfx(i,j), emiss(i,j), potevap(i,j)) + CALL var_potevap_Milly92gen(rho(i,1,j), ust(i,j), uas(i,j), vas(i,j), ts(i,j),t(i,1,j), & + ps(i,j), qv(i,1,j), qfx(i,j), emiss(i,j), potevapgen(i,j)) + CASE DEFAULT + WRITE (msg,*) ' ' // TRIM(fname) // ": ERROR -- error -- ERROR -- error : type " // & + "of potevap diagnostic 'potevap_diag=", potevap_diag, "' not ready !! " //CHAR(10)// & + " available ones; ", dpotevaporbulk, " : bulk (Manabe, 1969), ", & + dpotevaporMilly92, " : Milly92 (Milly, 1992)" + CALL wrf_error_fatal(msg) + END SELECT potevapdiag + ELSE + cdgen(i,j) = 0. + potevap(i,j) = 0. + potevapgen(i,j) = 0. + END IF + +!#ifdef CDXWRF +!#if CDXWRF>=1 + ! relative humidity + CALL var_hur(t(i,:,j), press(i,:,j), qv(i,:,j), dimz, hur(i,:,j)) + ! Diagnostics of relative humidity from AFWA's module + !DO k=kms, kme + ! hur(i,k,j) = calc_rh ( p_phy(i,k,j), t(i,k,j), qv(i,k,j) ) / 100. + !END DO + + ! Extremes of convection indices + IF (convxtrm_diag == 1) THEN + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing z-wind at:', zhgtzw, ' m' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + ! cape (no need to reach top of atmosphere... dz1) + WRITE(msg,*) ' ' // TRIM(fname) // ': computing CAPE diagnostic' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + + CALL var_cape_afwa(dz1, t(i,1:dz1,j), hur(i,1:dz1,j)*100., p_phy(i,1:dz1,j), z(i,1:dz1,j),& + 1, cape(i,j), cin(i,j), zlfc(i,j), plfc(i,j), lidx(i,j), 3) + ! Giving it as height above ground + IF (zlfc(i,j) /= -1.) zlfc(i,j) = zlfc(i,j) - hgt(i,j) + END IF + ELSE + cape(i,j) = 0. + cin(i,j) = 0. + zlfc(i,j) = 0. + plfc(i,j) = 0. + lidx(i,j) = 0. + END IF + + ! Horizontal transport of humidty + IF (curr_secs2 > 0. ) THEN + ! iut: eastward horizontal transport of humidity + CALL var_massvertint(qv(i,:,j)*unu(i,:,j), mutot(i,j), dimz, deta, iut(i,j)) + + ! ivt: northward horizontal transport of humidity + CALL var_massvertint(qv(i,:,j)*unv(i,:,j), mutot(i,j), dimz, deta, ivt(i,j)) + ELSE + iut(i,j) = 0. + ivt(i,j) = 0. + END IF +!#endif + +!#if CDXWRF>=2 + ! 2m dew point temperature + CALL var_tds(hurs(i,j), t2(i,j), tds(i,j)) + + ! 2m wet-bulb temperature + CALL var_tws_S11(t2(i,j), hurs(i,j), tws(i,j)) + + ! fog + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing fog' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + + ! fog + fogdiag: SELECT CASE (visibility_diag) + CASE (dfogK84) + WRITE(msg,*) ' ' // TRIM(fname) // ': visibility diagnostic= ', visibility_diag, & + ' from Kunkel (1984)' + IF (fogvars == 2) THEN + WRITE(msg,*)'diagnostics of visibility with visibility_diag=', visibility_diag, & + ' can only be done with 3D variables (fogvars=1). Not with fogvars=', fogvars + CALL wrf_error_fatal(msg) + END IF + CALL var_fog_K84(qc(i,1,j), qc(i,1,j), fog(i,j), vis(i,j)) + CASE (dfogRUC) + WRITE(msg,*) ' ' // TRIM(fname) // ': visibility diagnostic= ', visibility_diag, & + ' from RUC method Smirnova, (2000)' + IF (fogvars == 1) THEN + CALL var_fog_RUC(hur(i,1,j), fog(i,j), vis(i,j)) + ELSE IF (fogvars == 2) THEN + CALL var_fog_RUC(hurs(i,j), fog(i,j), vis(i,j)) + ELSE + WRITE(msg,*)'diagnostics of visibility can only be computed with either 3D ' // & + 'variables (fogvar=1) or sfc variables (fogvar=2), provided value=', fogvars + CALL wrf_error_fatal(msg) + END IF + CASE (dfogFRAML50) + WRITE(msg,*) ' ' // TRIM(fname) // ': visibility diagnostic= ', visibility_diag, & + ' from FRAM-L 50 % probability method from Gultepe and Milbrandt, (2010)' + IF (fogvars == 1) THEN + CALL var_fog_FRAML50(hur(i,1,j), fog(i,j), vis(i,j)) + ELSE IF (fogvars == 2) THEN + CALL var_fog_FRAML50(hurs(i,j), fog(i,j), vis(i,j)) + ELSE + WRITE(msg,*)'diagnostics of visibility can only be computed with either 3D ' // & + 'variables (fogvar=1) or sfc variables (fogvar=2), provided value=', fogvars + CALL wrf_error_fatal(msg) + END IF + CASE DEFAULT + WRITE (msg,*) ' ' // TRIM(fname) // ": ERROR -- error -- ERROR -- error : type " // & + "of fog % visibility diagnostic 'visibility_diag=", visibility_diag, & + "' not ready !! " //CHAR(10)// " available ones; ", dfogK84, " : Kunkel " // & + "(1984); ", dfogRUC, ": RUC method Smirnova, (2000); ", dfogFRAML50, & + " : Gultepe and Milbrandt, (2010)" + CALL wrf_error_fatal(msg) + END SELECT fogdiag + ELSE + fog(i,j) = 0 + vis(i,j) = 0. + END IF + +!#endif +!#if CDXWRF>=3 + ! Computing wind direction from where it blows and speed + ! Towards it blows + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + wbds(i,j) = ATAN2(-vvas,-uuas) + IF (wgsts_wbdswsstres == 1) THEN + ! Should it be totgustwind or gustwind (either Brasseur or heavy precipitation)? + uuas = uas(i,j)+totugustwind(i,j) + vvas = vas(i,j)+totvgustwind(i,j) + ELSE + uuas = uas(i,j)+0. + vvas = vas(i,j)+0. + END IF + ! From where it blows + wbdsv(i,j) = ATAN2(-vvas,-uuas) + ! From -pi,pi to 0,2pi + IF (wbdsv(i,j) < 0.) wbdsv(i,j) = 2*piconst+wbdsv(i,j) + wssv(i,j) = SQRT(uuas*uuas + vvas*vvas) + ELSE + wbdsv(i,j) = 0. + wssv(i,j) = 0. + END IF + + ! Getting first bin [ -pi/(2(Nwbdsrng-1)), pi/(2(Nwbdsrng-1)) ) + IF (wbdsv(i,j) >= piconst*(2.-1./(2.*(Nwbdsrng-1)))) wbdsv(i,j) = wbdsv(i,j) - 2.*piconst + +!#endif +!#if CDXWRF>=4 + ! Water budget + IF (wbout == 1) THEN + WRITE(msg,*)' ' // TRIM(fname) // ' Water species: vapor:', m_qv,' cloud:', m_qc, & + ' rain:', m_qr, ' snow:', m_qs,' ice:', m_qi, ' graupel:', m_qg,' hail:', m_qh + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(100,msg) + + ! Grouping variables + CALL moist_group2D(n_moist, dimz, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + qvttend(i,:,j), qcttend(i,:,j), qrttend(i,:,j), qsttend(i,:,j), qittend(i,:,j), & + qgttend(i,:,j), qhttend(i,:,j), qvarttend) + IF (ijdbg .AND. tdbg==0) THEN + WRITE(message,*)'moist ttend 2: v', qvttend(i,2,j), ' c', qcttend(i,2,j), ' r', & + qrttend(i,2,j), ' s', qsttend(i,2,j), ' i', qittend(i,2,j), ' g', qgttend(i,2,j), & + ' h', qhttend(i,2,j) + CALL wrf_debug(100,message) + WRITE(message,*)'qvarttend:', qvarttend(2,:) + CALL wrf_debug(100,message) + END IF + CALL moist_group2D(n_moist, dimz, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + qvhadv(i,:,j), qchadv(i,:,j), qrhadv(i,:,j), qshadv(i,:,j), qihadv(i,:,j), qghadv(i,:,j), & + qhhadv(i,:,j), qvarhadv) + IF (ijdbg .AND. tdbg==0) THEN + WRITE(message,*)' 2 hadv: v', qvhadv(i,2,j), ' c', qchadv(i,2,j), ' r', qrhadv(i,2,j), & + ' s', qshadv(i,2,j), ' i', qihadv(i,2,j), ' g', qghadv(i,2,j), ' h', qhhadv(i,2,j) + CALL wrf_debug(100,message) + WRITE(message,*)'qvarhadv:', qvarhadv(2,:) + CALL wrf_debug(100,message) + END IF + CALL moist_group2D(n_moist, dimz, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + qvzadv(i,:,j), qczadv(i,:,j), qrzadv(i,:,j), qszadv(i,:,j), qizadv(i,:,j), qgzadv(i,:,j), & + qhzadv(i,:,j), qvarzadv) + + CALL water_budget(dimz, n_moist, mutot(i,j), deta, dt, qvarttend, qvarhadv, qvarzadv, & + pwqvar(i,:,j,:), fqvar(i,:,j,:), zqvar(i,:,j,:)) + END IF + +!#endif +!#endif + + ijdbg = .FALSE. + END DO + END DO + END DO + !$OMP END PARALLEL DO + + ! cloud fraction is only updated when the radiative scheme is called ! + ijdbg = .FALSE. + IF (( MOD(NINT((curr_secs2+dt)/dt),NINT(radt*60./dt)) == 0) ) THEN + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + ! Total cloudiness + CALL var_clt(cldfra(i,:,j), dimz, clt(i,j)) + ! low-mid-high cloudiness + CALL var_cllmh(cldfra(i,:,j), p8w(i,:,j), dimz, cllmh) + cll(i,j) = cllmh(1) + clm(i,j) = cllmh(2) + clh(i,j) = cllmh(3) + ! L. Fita, Feb. 2018. CIMA. + ! I'm not sure if it is necessary, because they might be re-initialized + ! Let's do it in order to keep the values + pclt(i,j) = clt(i,j) + pcll(i,j) = cll(i,j) + pclm(i,j) = clm(i,j) + pclh(i,j) = clh(i,j) + END DO + ijdbg = .FALSE. + END DO + END DO + !$OMP END PARALLEL DO + + ELSE + clt = pclt + cll = pcll + clm = pclm + clh = pclh + END IF + + IF (( MOD(NINT(curr_secs2/dt),NINT(cdxH*60./dt)) == 0) ) THEN + ! Initialization of accumulated variables between outputs + IF ( wrf_dm_on_monitor() ) THEN + CALL wrf_debug(0, ' ' // TRIM(fname) // ': Re-initializing accumulation arrays') + ENDIF + + nsteps = 1 + + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + cltmean(i,j) = clt(i,j) + cllmean(i,j) = cll(i,j) + clmmean(i,j) = clm(i,j) + clhmean(i,j) = clh(i,j) + + ! Gust wind + wsgsmax(i,j) = wsgs(i,j) + ugsmax(i,j) = ugustwind(i,j) + vgsmax(i,j) = vgustwind(i,j) + percengust(i,j) = gustpoint(i,j)*1. + + totwsgsmax(i,j) = totwsgs(i,j) + totugsmax(i,j) = totugustwind(i,j) + totvgsmax(i,j) = totvgustwind(i,j) + totpercengust(i,j) = totgustpoint(i,j)*1. + + ! 100 m wind + wsz100max(i,j) = wsz100(i,j) + uz100max(i,j) = uz100wind(i,j) + vz100max(i,j) = vz100wind(i,j) + + ! sunshine + IF (swdown(i,j) > 120. ) THEN + sunshine(i,j) = dt + ELSE + sunshine(i,j) = 0. + END IF + + ! Fluxes + rsds(i,j) = swdown(i,j) + rlds(i,j) = glw(i,j) + hfls(i,j) = lh(i,j) + hfss(i,j) = hfx(i,j) + ! L. Fita, CIMA. March 2018 + !! Is this equivalent to rsus=-SWDOWN*Albedo ? + rsus(i,j) = swupb(i,j) + rsusgen(i,j) = -swdown(i,j)*albedo(i,j) + ! L. Fita, CIMA. March 2018 + !! Is this equivalent to rlus=CtBoltzman*emiss*SKINTEMP**4 ? + rlus(i,j) = lwupb(i,j) + rlusgen(i,j) = STBOLT*emiss(i,j)*ts(i,j)**4 + evspsbl(i,j) = qfx(i,j) + evspsblpot(i,j) = potevap(i,j) + evspsblpotgen(i,j) = potevapgen(i,j) + + ! Snow + snc(i,j) = snowc(i,j)*100. + snd(i,j) = snowh(i,j) + + ! Run-off (already accumulations) + pmrros(i,j) = sfcrunoff(i,j) + pmrro(i,j) = sfcrunoff(i,j) + udrunoff(i,j) + + ! Precipitations + flxpr(i,j) = prc(i,j) + prnc(i,j) + prsh(i,j) + flxprl(i,j) = prnc(i,j) + flxprc(i,j) = prc(i,j) + flxprsh(i,j) = prsh(i,j) + flxprsn(i,j) = flxpr(i,j)*sr(i,j) + snw(i,j) = snow(i,j) + + ! Fluxes at TOA + rsdt(i,j) = swdnt(i,j) + rsut(i,j) = swupt(i,j) + rlut(i,j) = lwupt(i,j) + + ! Soil + mrsosmean(i,j) = mrsos(i,j) + mrsomean(i,j) = mrso(i,j) + mrlsomean(i,j) = mrlso(i,j) + mrlsosmean(i,j) = mrlsos(i,j) + mrfsomean(i,j) = mrfso(i,j) + mrfsosmean(i,j) = mrfsos(i,j) + DO k=1, num_soil_layers + mrsolmean(i,k,j) = mrsol(i,k,j) + mrsllmean(i,k,j) = mrsll(i,k,j) + mrsflmean(i,k,j) = mrsfl(i,k,j) + END DO + +!#ifdef CDXWRF +!#if CDXWRF>=1 + ! Extremes of convection indices + IF (convxtrm_diag == 1) THEN + capemin(i,j) = cape(i,j) + cinmin(i,j) = cin(i,j) + zlfcmin(i,j) = zlfc(i,j) + plfcmin(i,j) = plfc(i,j) + lidxmin(i,j) = lidx(i,j) + capemax(i,j) = cape(i,j) + cinmax(i,j) = cin(i,j) + zlfcmax(i,j) = zlfc(i,j) + plfcmax(i,j) = plfc(i,j) + lidxmax(i,j) = lidx(i,j) + capemean(i,j) = cape(i,j) + cinmean(i,j) = cin(i,j) + zlfcmean(i,j) = zlfc(i,j) + plfcmean(i,j) = plfc(i,j) + lidxmean(i,j) = lidx(i,j) + END IF + + ! Horizontal water transport + iutmean(i,j) = iut(i,j) + ivtmean(i,j) = ivt(i,j) + + ! fog + IF (fog(i,j) == 1) THEN + tfog(i,j) = dt + fogvisbltymin(i,j) = vis(i,j) + fogvisbltymax(i,j) = vis(i,j) + fogvisbltymean(i,j) = vis(i,j) + ELSE + tfog(i,j) = 0. + fogvisbltymin(i,j) = 0. + fogvisbltymax(i,j) = 0. + fogvisbltymean(i,j) = 0. + END IF + + ! tds + tdsmin(i,j) = tds(i,j) + tdsmax(i,j) = tds(i,j) + tdsmean(i,j) = tds(i,j) + + ! tws + twsmin(i,j) = tws(i,j) + twsmax(i,j) = tws(i,j) + twsmean(i,j) = tws(i,j) +!#endif + +!#if CDXWRF>=4 + IF (wbout == 1) THEN + wbacdh(i,j) = SUM(diabh(i,:,j))*dt + ! Vertical intervals + CALL interval_agg(dimz, 2, 3, diabh(i,:,j), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + wbacdhl(i,j) = varlmh(1)*dt + wbacdhm(i,j) = varlmh(2)*dt + wbacdhh(i,j) = varlmh(3)*dt + DO m=1, n_moist + acpwqvar(m) = SUM(pwqvar(i,:,j,m)) + acfqvar(m) = SUM(fqvar(i,:,j,m)) + aczqvar(m) = SUM(zqvar(i,:,j,m)) + + ! Vertical intervals + CALL interval_agg(dimz, 2, 3, pwqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + acpwlqvar(m) = varlmh(1) + acpwmqvar(m) = varlmh(2) + acpwhqvar(m) = varlmh(3) + CALL interval_agg(dimz, 2, 3, fqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + acflqvar(m) = varlmh(1) + acfmqvar(m) = varlmh(2) + acfhqvar(m) = varlmh(3) + CALL interval_agg(dimz, 2, 3, zqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + aczlqvar(m) = varlmh(1) + aczmqvar(m) = varlmh(2) + aczhqvar(m) = varlmh(3) + END DO + CALL moist_redistribute(n_moist, acpwqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpw(i,j), wbacpwc(i,j), wbacpwr(i,j), wbacpws(i,j), wbacpwi(i,j), wbacpwg(i,j), & + wbacpwh(i,j)) + CALL moist_redistribute(n_moist, acfqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacf(i,j), wbacfc(i,j), wbacfr(i,j), wbacfs(i,j), wbacfi(i,j), wbacfg(i,j), wbacfh(i,j)) + CALL moist_redistribute(n_moist, aczqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi,m_qg, m_qh, & + wbacz(i,j), wbaczc(i,j), wbaczr(i,j), wbaczs(i,j), wbaczi(i,j), wbaczg(i,j), wbaczh(i,j)) + + ! Low-medium-heigh + ! Total tendency + CALL moist_redistribute(n_moist, acpwlqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwlv(i,j), wbacpwlc(i,j), wbacpwlr(i,j), wbacpwls(i,j), wbacpwli(i,j), & + wbacpwlg(i,j), wbacpwlh(i,j)) + CALL moist_redistribute(n_moist, acpwmqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwmv(i,j), wbacpwmc(i,j), wbacpwmr(i,j), wbacpwms(i,j), wbacpwmi(i,j), & + wbacpwmg(i,j), wbacpwmh(i,j)) + CALL moist_redistribute(n_moist, acpwhqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwhv(i,j), wbacpwhc(i,j), wbacpwhr(i,j), wbacpwhs(i,j), wbacpwhi(i,j), & + wbacpwhg(i,j), wbacpwhh(i,j)) + ! Horizontal advection + CALL moist_redistribute(n_moist, acflqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacflv(i,j), wbacflc(i,j), wbacflr(i,j), wbacfls(i,j), wbacfli(i,j), & + wbacflg(i,j), wbacflh(i,j)) + CALL moist_redistribute(n_moist, acfmqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacfmv(i,j), wbacfmc(i,j), wbacfmr(i,j), wbacfms(i,j), wbacfmi(i,j), & + wbacfmg(i,j), wbacfmh(i,j)) + CALL moist_redistribute(n_moist, acfhqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacfhv(i,j), wbacfhc(i,j), wbacfhr(i,j), wbacfhs(i,j), wbacfhi(i,j), & + wbacfhg(i,j), wbacfhh(i,j)) + ! Vertical advection + CALL moist_redistribute(n_moist, aczlqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczlv(i,j), wbaczlc(i,j), wbaczlr(i,j), wbaczls(i,j), wbaczli(i,j), & + wbaczlg(i,j), wbaczlh(i,j)) + CALL moist_redistribute(n_moist, aczmqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczmv(i,j), wbaczmc(i,j), wbaczmr(i,j), wbaczms(i,j), wbaczmi(i,j), & + wbaczmg(i,j), wbaczmh(i,j)) + CALL moist_redistribute(n_moist, aczhqvar(:), m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczhv(i,j), wbaczhc(i,j), wbaczhr(i,j), wbaczhs(i,j), wbaczhi(i,j), & + wbaczhg(i,j), wbaczhh(i,j)) + END IF + +!#endif +!#if CDXWRF>=3 + ! temporal residence + ! Checking consistency + ! L. Fita, January 2024. Removed for efficiency + ! If you encounter problems with the variable, remove it and re-compile without clean -a +! IF (ALL(tashurstreshighres(i,:,j) == 0.)) THEN +! PRINT *,' Empty highres residence time for i,j:', i,j +! END IF + CALL var_residencetime_2var2D(t2(i,j), hurs(i,j), Nhtasrng, Nhhursrng, tashrng, hurshrng, & + itas, ihurs) + tashurstreshighres(i,:,j) = 0. + tashurstreshighres(i,(itas-1)*Nhhursrng+ihurs,j) = dt + + ! Checking consistency + ! L. Fita, January 2024. Removed for efficiency + ! If you encounter problems with the variable, remove it and re-compile without clean -a +! IF (ALL(tashurstreslowres(i,:,j) == 0.)) THEN +! PRINT *,' Empty lowres residence time for i,j:', i,j +! END IF + CALL var_residencetime_2var2D(t2(i,j), hurs(i,j), Nltasrng, Nlhursrng, taslrng, hurslrng, & + itas,ihurs) + tashurstreslowres(i,:,j) = 0. + tashurstreslowres(i,(itas-1)*Nlhursrng+ihurs,j) = dt + + ! wind direction and speed + CALL var_residencetime_2var2D(wbdsv(i,j), wssv(i,j), Nwbdsrng, Nwssrng, wbdsrng, wssrng, & + iwbds,iwss) + wbdswsstres(i,:,j) = 0. + wbdswsstres(i,(iwbds-1)*Nwssrng+iwss,j) = dt + +!#endif +!#endif + + IF (dbg_level >= 75 .AND. ijdbg .AND. tdbg==0) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : first value checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' longitude:', lon(i,j),' latitude:',lat(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clt:', clt(i,j), ' mean:', cltmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' cll:', cll(i,j), ' mean:', cllmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clm:', clm(i,j), ' mean:', clmmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clh:', clh(i,j), ' mean:', clhmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' surface wind gust:', wsgs(i,j), ' x-component:', ugustwind(i,j), & + ' y-component:', vgustwind(i,j), ' N gusts:', percengust(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum surface wind gust:', wsgsmax(i,j), ' x-component:', ugsmax(i,j), & + ' y-component:', vgsmax(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' total surface wind gust:', totwsgs(i,j), ' x-component:', & + totugustwind(i,j), ' y-component:', totvgustwind(i,j), ' N gusts:', totpercengust(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' total maximum surface wind gust:', totwsgsmax(i,j), ' x-component:', & + totugsmax(i,j), ' y-component:', totvgsmax(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' 100m wind:', wsz100(i,j), ' x-component:', uz100wind(i,j), & + ' y-component:', vz100wind(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum 100m wind:', wsz100max(i,j), ' x-component:', uz100max(i,j), & + ' y-component:', vz100max(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdown:', swdown(i,j), ' sunshine:', sunshine(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdown:', swdown(i,j), ' rsds:', rsds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' glw:', glw(i,j), ' rlds:', rlds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lh:', lh(i,j), ' hfls:', hfls(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' hfx:', hfx(i,j), ' hfss:', hfss(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swupb:', swupb(i,j), ' rsus:', rsus(i,j), ' rsusgen:', rsusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lwupb:', lwupb(i,j), ' rlus:', rlus(i,j), ' rlusgen:', rlusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qfx:', qfx(i,j), ' evspsbl:', evspsbl(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevap:', potevap(i,j), ' evspsblpot:', evspsblpot(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevapgen:', potevapgen(i,j), ' evspsblrpotgen:', evspsblpotgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowc:', snowc(i,j), ' snc:', snc(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowh:', snowh(i,j), ' snd:', snd(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' smois (1,3):', smois(i,1,j), smois(i,2,j), smois(i,3,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' dzs (1,3):', dzs(1), dzs(2), dzs(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsos:', mrsos(i,j), ' mrso:', mrso(i,j), ' mrsol (1,2):', mrsol(i,1,j), & + mrsol(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlso:', mrlso(i,j), ' mrlsos:', mrlsos(i,j), ' mrsll (1,2):', & + mrsll(i,1,j), mrsll(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfso:', mrfso(i,j), ' mrfsos:', mrfsos(i,j), ' mrsfl (1,2):', & + mrsfl(i,1,j), mrsfl(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fracsoil10cm (1,3):', fracsoil10cm(1), fracsoil10cm(2), fracsoil10cm(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsosmean:', mrsosmean(i,j), ' mrsomean:', mrsomean(i,j), & + ' mrsolmean (1,2):', mrsolmean(i,1,j), mrsolmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlsomean:', mrlsomean(i,j), ' mrlsosmean:', mrlsosmean(i,j), & + ' mrsllmean (1,2):', mrsllmean(i,1,j), mrsllmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfsomean:', mrfsomean(i,j), ' mrfsosmean:', mrfsosmean(i,j), & + ' mrsflmean (1,2):', mrsflmean(i,1,j), mrsflmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' sfcrunoff:', sfcrunoff(i,j), ' pmrros:', pmrros(i,j), ' mrros:', mrros(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' udrunoff:', udrunoff(i,j), ' pmrro:', pmrro(i,j), ' mrro:', mrro(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j), ' flxprl:', flxprl(i,j), ' flxprc:', flxprc(i,j), ' flxprsh:', flxprsh(i,j),& + ' flxprsn:', flxprsn(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snow:', snow(i,j), ' snw:', snw(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdnt:', swdnt(i,j), ' rsdt:', rsdt(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swupt:', swupt(i,j), ' rsut:', rsut(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lwupt:', lwupt(i,j), ' rlut:', rlut(i,j) + CALL wrf_debug(75,msg) +!#ifdef CDXWRF +!#if CDXWRF>=1 + IF (convxtrm_diag == 1) THEN + WRITE(msg,*) ' cape:', cape(i,j), ' cin:', cin(i,j),' zlfc:', zlfc(i,j), ' plfc:', & + plfc(i,j), 'lidx:', lidx(i,j) + CALL wrf_debug(75,msg) + END IF + WRITE(msg,*) ' iut:', iut(i,j), ' ivt:', ivt(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fog:', fog(i,j), ' tfog:', tfog(i,j), ' vis:', vis(i,j), ' vismin:', & + fogvisbltymin(i,j), ' vismax:', fogvisbltymax(i,j), ' vismean:', fogvisbltymean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tds:', tds(i,j), ' min:', tdsmin(i,j), ' max:', tdsmax(i,j), & + ' mean:', tdsmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tws:', tws(i,j), ' min:', twsmin(i,j), ' max:', twsmax(i,j), & + ' mean:', twsmean(i,j) +!#endif + +!#if CDXWRF>=4 + WRITE(msg,*) ' diabh:', SUM(diabh(i,:,j))*dt, ' wbacdh:', wbacdh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' dhl:', wbacdhl(i,j), 'dhm:', wbacdhm(i,j), 'dhh:', wbacdhh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' WB only vater wapour m_qv:', m_qv + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: pw', SUM(pwqvar(i,:,j,m_qv)), ' acpw:', wbacpw(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: f', SUM(fqvar(i,:,j,m_qv)), ' acf:', wbacf(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: z', SUM(zqvar(i,:,j,m_qv)), ' acz:', wbacz(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zl', varlmh(1), ' aczlv:', wbaczlv(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zm', varlmh(2), ' aczmv:', wbaczmv(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zh', varlmh(3), ' aczhv:', wbaczhv(i,j) + CALL wrf_debug(75,msg) + +!#endif +!#if CDXWRF>=3 + CALL wrf_debug(75,msg) + WRITE(msg,*)' tashurstreshighres: ',tashurstreshighres(i,INT(Nhtasrng/2*Nhhursrng/2),j),& + ' tashurstreslowres: ', tashurstreslowres(i,INT(Nltasrng/2*Nlhursrng/2),j), & + ' wbdswsstres: ', wbdswsstres(i,INT(Nwbdsrng/2*Nwssrng/2),j) + CALL wrf_debug(75,msg) +!#endif +!#endif + !CALL wrf_error_fatal(msg) + END IF + + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + ELSE + xtimep = xtime + dt/60. ! value at end of timestep for time info + nsteps=nsteps+1 + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + cltmean(i,j) = cltmean(i,j) + clt(i,j) + cllmean(i,j) = cllmean(i,j) + cll(i,j) + clmmean(i,j) = clmmean(i,j) + clm(i,j) + clhmean(i,j) = clhmean(i,j) + clh(i,j) + + ! Wind gust + ! Looking for the maximum + IF (wsgs(i,j) > wsgsmax(i,j)) THEN + wsgsmax(i,j) = wsgs(i,j) + ugsmax(i,j) = ugustwind(i,j) + vgsmax(i,j) = vgustwind(i,j) + END IF + percengust(i,j) = percengust(i,j) + gustpoint(i,j)*1. + + IF (totwsgs(i,j) > totwsgsmax(i,j)) THEN + totwsgsmax(i,j) = totwsgs(i,j) + totugsmax(i,j) = totugustwind(i,j) + totvgsmax(i,j) = totvgustwind(i,j) + END IF + totpercengust(i,j) = totpercengust(i,j) + totgustpoint(i,j)*1. + + ! 100 m wind + ! Looking for the maximum + IF (wsz100(i,j) > wsz100max(i,j)) THEN + wsz100max(i,j) = wsz100(i,j) + uz100max(i,j) = uz100wind(i,j) + vz100max(i,j) = vz100wind(i,j) + END IF + + ! sunshine + IF (swdown(i,j) > 120. ) sunshine(i,j) = sunshine(i,j) + dt + + ! Fluxes + rsds(i,j) = rsds(i,j) + swdown(i,j) + rlds(i,j) = rlds(i,j) + glw(i,j) + hfls(i,j) = hfls(i,j) + lh(i,j) + hfss(i,j) = hfss(i,j) + hfx(i,j) + rsus(i,j) = rsus(i,j) + swupb(i,j) + rlus(i,j) = rlus(i,j) + lwupb(i,j) + rsusgen(i,j) = rsusgen(i,j) - swdown(i,j)*albedo(i,j) + rlusgen(i,j) = rlusgen(i,j) + STBOLT*emiss(i,j)*ts(i,j)**4 + evspsbl(i,j) = evspsbl(i,j) + qfx(i,j) + evspsblpot(i,j) = evspsblpot(i,j) + potevap(i,j) + evspsblpotgen(i,j) = evspsblpotgen(i,j) + potevapgen(i,j) + + ! Snow + snc(i,j) = snc(i,j) + snowc(i,j)*100. + snd(i,j) = snd(i,j) + snowh(i,j) + + ! Run-off (already accumulations) + mrros(i,j) = sfcrunoff(i,j) + mrro(i,j) = sfcrunoff(i,j) + udrunoff(i,j) + + ! Soil + mrsosmean(i,j) = mrsosmean(i,j) + mrsos(i,j) + mrsomean(i,j) = mrsomean(i,j) + mrso(i,j) + mrlsomean(i,j) = mrlsomean(i,j) + mrlso(i,j) + mrlsosmean(i,j) = mrlsosmean(i,j) + mrlsos(i,j) + mrfsomean(i,j) = mrfsomean(i,j) + mrfso(i,j) + mrfsosmean(i,j) = mrfsosmean(i,j) + mrfsos(i,j) + DO k=1, num_soil_layers + mrsolmean(i,k,j) = mrsolmean(i,k,j) + mrsol(i,k,j) + mrsllmean(i,k,j) = mrsllmean(i,k,j) + mrsll(i,k,j) + mrsflmean(i,k,j) = mrsflmean(i,k,j) + mrsfl(i,k,j) + END DO + + ! Precipitations + flxpr(i,j) = flxpr(i,j) + prc(i,j) + prnc(i,j) + prsh(i,j) + flxprl(i,j) = flxprl(i,j) + prnc(i,j) + flxprc(i,j) = flxprc(i,j) + prc(i,j) + flxprsh(i,j) = flxprsh(i,j) + prsh(i,j) + flxprsn(i,j) = flxprsn(i,j) + flxpr(i,j)*sr(i,j) + snw(i,j) = snw(i,j) + snow(i,j) + + ! Fluxes at TOA + rsdt(i,j) = rsdt(i,j) + swdnt(i,j) + rsut(i,j) = rsut(i,j) + swupt(i,j) + rlut(i,j) = rlut(i,j) + lwupt(i,j) + +!#ifdef CDXWRF +!#if CDXWRF>=1 + ! Extremes of convection indices + IF (convxtrm_diag == 1) THEN + IF (cape(i,j) < capemin(i,j)) capemin(i,j) = cape(i,j) + IF (cin(i,j) < cinmin(i,j)) cinmin(i,j) = cin(i,j) + IF (zlfc(i,j) < zlfcmin(i,j)) zlfcmin(i,j) = zlfc(i,j) + IF (plfc(i,j) < plfcmin(i,j)) plfcmin(i,j) = plfc(i,j) + IF (lidx(i,j) < lidxmin(i,j)) lidxmin(i,j) = lidx(i,j) + IF (cape(i,j) > capemax(i,j)) capemax(i,j) = cape(i,j) + IF (cin(i,j) > cinmax(i,j)) cinmax(i,j) = cin(i,j) + IF (zlfc(i,j) > zlfcmax(i,j)) zlfcmax(i,j) = zlfc(i,j) + IF (plfc(i,j) > plfcmax(i,j)) plfcmax(i,j) = plfc(i,j) + IF (lidx(i,j) > lidxmax(i,j)) lidxmax(i,j) = lidx(i,j) + capemean(i,j) = capemean(i,j) + cape(i,j) + cinmean(i,j) = cinmean(i,j) + cin(i,j) + zlfcmean(i,j) = zlfcmean(i,j) + zlfc(i,j) + plfcmean(i,j) = plfcmean(i,j) + plfc(i,j) + lidxmean(i,j) = lidxmean(i,j) + lidx(i,j) + END IF + + ! Horizontal water transport + iutmean(i,j) = iutmean(i,j) + iut(i,j) + ivtmean(i,j) = ivtmean(i,j) + ivt(i,j) + + ! fog + IF (fog(i,j) == 1) THEN + tfog(i,j) = tfog(i,j) + dt + IF (fogvisbltymin(i,j) > vis(i,j)) fogvisbltymin(i,j) = vis(i,j) + IF (fogvisbltymax(i,j) < vis(i,j)) fogvisbltymax(i,j) = vis(i,j) + fogvisbltymean(i,j) = fogvisbltymean(i,j) + vis(i,j) + END IF + + ! tds + IF (tdsmin(i,j) > tds(i,j)) tdsmin(i,j) = tds(i,j) + IF (tdsmax(i,j) < tds(i,j)) tdsmax(i,j) = tds(i,j) + tdsmean(i,j) = tdsmean(i,j) + tds(i,j) + + ! tws + IF (twsmin(i,j) > tws(i,j)) twsmin(i,j) = tws(i,j) + IF (twsmax(i,j) < tws(i,j)) twsmax(i,j) = tws(i,j) + twsmean(i,j) = twsmean(i,j) + tws(i,j) +!#endif + +!#if CDXWRF>=4 + + IF (wbout == 1) THEN + wbacdh(i,j) = wbacdh(i,j) + SUM(diabh(i,:,j))*dt + ! Vertical intervals + CALL interval_agg(dimz, 2, 3, diabh(i,:,j), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + wbacdhl(i,j) = wbacdhl(i,j) + varlmh(1)*dt + wbacdhm(i,j) = wbacdhm(i,j) + varlmh(2)*dt + wbacdhh(i,j) = wbacdhh(i,j) + varlmh(3)*dt + ! First get previous values + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacpw(i,j), & + wbacpwc(i,j), wbacpwr(i,j), wbacpws(i,j), wbacpwi(i,j), wbacpwg(i,j), wbacpwh(i,j), & + acpwqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacf(i,j), & + wbacfc(i,j), wbacfr(i,j), wbacfs(i,j), wbacfi(i,j), wbacfg(i,j), wbacfh(i,j), acfqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacz(i,j), & + wbaczc(i,j), wbaczr(i,j), wbaczs(i,j), wbaczi(i,j), wbaczg(i,j), wbaczh(i,j), aczqvar) + ! low-mid-high + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacpwlv(i,j), & + wbacpwlc(i,j), wbacpwlr(i,j), wbacpwls(i,j), wbacpwli(i,j), wbacpwlg(i,j),wbacpwlh(i,j),& + acpwlqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacpwmv(i,j), & + wbacpwmc(i,j), wbacpwmr(i,j), wbacpwms(i,j), wbacpwmi(i,j), wbacpwmg(i,j),wbacpwmh(i,j),& + acpwmqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacpwhv(i,j), & + wbacpwhc(i,j), wbacpwhr(i,j), wbacpwhs(i,j), wbacpwhi(i,j), wbacpwhg(i,j),wbacpwhh(i,j),& + acpwhqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacflv(i,j), & + wbacflc(i,j), wbacflr(i,j), wbacfls(i,j),wbacfli(i,j),wbacflg(i,j),wbacflh(i,j),acflqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacfmv(i,j), & + wbacfmc(i,j), wbacfmr(i,j), wbacfms(i,j),wbacfmi(i,j),wbacfmg(i,j),wbacfmh(i,j),acfmqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbacfhv(i,j), & + wbacfhc(i,j), wbacfhr(i,j), wbacfhs(i,j),wbacfhi(i,j),wbacfhg(i,j),wbacfhh(i,j),acfhqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbaczlv(i,j), & + wbaczlc(i,j), wbaczlr(i,j), wbaczls(i,j),wbaczli(i,j),wbaczlg(i,j),wbaczlh(i,j),aczlqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbaczmv(i,j), & + wbaczmc(i,j), wbaczmr(i,j), wbaczms(i,j),wbaczmi(i,j),wbaczmg(i,j),wbaczmh(i,j),aczmqvar) + CALL moist_group(n_moist, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, wbaczhv(i,j), & + wbaczhc(i,j), wbaczhr(i,j), wbaczhs(i,j),wbaczhi(i,j),wbaczhg(i,j),wbaczhh(i,j),aczhqvar) + DO m=1, n_moist + acpwqvar(m) = acpwqvar(m) + SUM(pwqvar(i,:,j,m)) + acfqvar(m) = acfqvar(m) + SUM(fqvar(i,:,j,m)) + aczqvar(m) = aczqvar(m) + SUM(zqvar(i,:,j,m)) + ! Vertical intervals + CALL interval_agg(dimz, 2, 3, pwqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + acpwlqvar(m) = acpwlqvar(m) + varlmh(1) + acpwmqvar(m) = acpwmqvar(m) + varlmh(2) + acpwhqvar(m) = acpwhqvar(m) + varlmh(3) + CALL interval_agg(dimz, 2, 3, fqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + acflqvar(m) = acflqvar(m) + varlmh(1) + acfmqvar(m) = acfmqvar(m) + varlmh(2) + acfhqvar(m) = acfhqvar(m) + varlmh(3) + CALL interval_agg(dimz, 2, 3, zqvar(i,:,j,m), p8w(i,:,j), (/ prmlcR, prmhcR /), varlmh) + aczlqvar(m) = aczlqvar(m) + varlmh(1) + aczmqvar(m) = aczmqvar(m) + varlmh(2) + aczhqvar(m) = aczhqvar(m) + varlmh(3) + END DO + + CALL moist_redistribute(n_moist, acpwqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpw(i,j), wbacpwc(i,j), wbacpwr(i,j), wbacpws(i,j), wbacpwi(i,j), & + wbacpwg(i,j), wbacpwh(i,j)) + CALL moist_redistribute(n_moist, acfqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacf(i,j), wbacfc(i,j), wbacfr(i,j), wbacfs(i,j), wbacfi(i,j), wbacfg(i,j), & + wbacfh(i,j)) + CALL moist_redistribute(n_moist, aczqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacz(i,j), wbaczc(i,j), wbaczr(i,j), wbaczs(i,j), wbaczi(i,j), wbaczg(i,j), & + wbaczh(i,j)) + ! Low-medium-heigh + ! Total tendency + CALL moist_redistribute(n_moist, acpwlqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwlv(i,j), wbacpwlc(i,j), wbacpwlr(i,j), wbacpwls(i,j), wbacpwli(i,j), & + wbacpwlg(i,j), wbacpwlh(i,j)) + CALL moist_redistribute(n_moist, acpwmqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwmv(i,j), wbacpwmc(i,j), wbacpwmr(i,j), wbacpwms(i,j), wbacpwmi(i,j), & + wbacpwmg(i,j), wbacpwmh(i,j)) + CALL moist_redistribute(n_moist, acpwhqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacpwhv(i,j), wbacpwhc(i,j), wbacpwhr(i,j), wbacpwhs(i,j), wbacpwhi(i,j), & + wbacpwhg(i,j), wbacpwhh(i,j)) + ! Horizontal advection + CALL moist_redistribute(n_moist, acflqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacflv(i,j), wbacflc(i,j), wbacflr(i,j), wbacfls(i,j), wbacfli(i,j), & + wbacflg(i,j), wbacflh(i,j)) + CALL moist_redistribute(n_moist, acfmqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacfmv(i,j), wbacfmc(i,j), wbacfmr(i,j), wbacfms(i,j), wbacfmi(i,j), & + wbacfmg(i,j), wbacfmh(i,j)) + CALL moist_redistribute(n_moist, acfhqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbacfhv(i,j), wbacfhc(i,j), wbacfhr(i,j), wbacfhs(i,j), wbacfhi(i,j), & + wbacfhg(i,j), wbacfhh(i,j)) + ! Vertical advection + CALL moist_redistribute(n_moist, aczlqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczlv(i,j), wbaczlc(i,j), wbaczlr(i,j), wbaczls(i,j), wbaczli(i,j), & + wbaczlg(i,j), wbaczlh(i,j)) + CALL moist_redistribute(n_moist, aczmqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczmv(i,j), wbaczmc(i,j), wbaczmr(i,j), wbaczms(i,j), wbaczmi(i,j), & + wbaczmg(i,j), wbaczmh(i,j)) + CALL moist_redistribute(n_moist, aczhqvar, m_qv, m_qc, m_qr, m_qs, m_qi, m_qg, m_qh, & + wbaczhv(i,j), wbaczhc(i,j), wbaczhr(i,j), wbaczhs(i,j), wbaczhi(i,j), & + wbaczhg(i,j), wbaczhh(i,j)) + END IF +!#endif +!#if CDXWRF>=3 + ! temporal residence + ! High res tas, hurs + CALL var_residencetime_2var2D(t2(i,j), hurs(i,j), Nhtasrng, Nhhursrng, tashrng, hurshrng, & + itas, ihurs) + ! Checking consistency + ! L. Fita, January 2024. Removed for efficiency + ! If you encounter problems with the variable, remove it and re-compile without clean -a + IF (ijdbg .AND. tdbg==0) THEN + PRINT *,' longitude:', lon(i,j),' latitude:',lat(i,j) + PRINT *,' highres i,j:', i,j, ' t2:', t2(i,j), ' ps:', ps(i,j), ' q2:', q2(i,j), & + '=> hurs:', hurs(i,j) + PRINT *,' highres tas bin:', tashrng(itas-1), '- ', tashrng(itas) + PRINT *,' highres hurs bin:', hurshrng(ihurs-1), '- ', hurshrng(ihurs) + PRINT *,' highres Nhtasrng:', Nhtasrng, ' Nhhursrng:', Nhhursrng + PRINT *,' highres itas, ihurs:', itas, ihurs, 'khighrestashurs:', (itas-1)*Nhhursrng+ihurs + PRINT *,' current value prior dt:', tashurstreshighres(i,(itas-1)*Nhhursrng+ihurs,j) +! PRINT *,' all values:', tashurstreshighres(i,:,j) + END IF + tashurstreshighres(i,(itas-1)*Nhhursrng+ihurs,j) = & + tashurstreshighres(i,(itas-1)*Nhhursrng+ihurs,j) + dt + + ! Low res tas, hurs + CALL var_residencetime_2var2D(t2(i,j), hurs(i,j), Nltasrng, Nlhursrng, taslrng, hurslrng, & + itas, ihurs) + ! Checking consistency + ! L. Fita, January 2024. Removed for efficiency + ! If you encounter problems with the variable, remove it and re-compile without clean -a + IF (ijdbg .AND. tdbg==0) THEN + PRINT *,' lowres i,j:', i,j, ' t2:', t2(i,j),' hurs:', hurs(i,j) + PRINT *,' lowres tas bin:', taslrng(itas-1), '- ', taslrng(itas) + PRINT *,' lowres hurs bin:', hurslrng(ihurs-1), '- ', hurslrng(ihurs) + PRINT *,' lowres Nltasrng:', Nltasrng, ' Nlhursrng:', Nlhursrng + PRINT *,' lowres itas, ihurs:', itas, ihurs, 'klowrestashurs:', (itas-1)*Nlhursrng+ihurs + PRINT *,' current value prior dt:', tashurstreslowres(i,(itas-1)*Nlhursrng+ihurs,j) +! PRINT *,' all values:', tashurstreslowres(i,:,j) + END IF + tashurstreslowres(i,(itas-1)*Nlhursrng+ihurs,j) = & + tashurstreslowres(i,(itas-1)*Nlhursrng+ihurs,j) + dt + + ! wind direction and speed + CALL var_residencetime_2var2D(wbdsv(i,j), wssv(i,j), Nwbdsrng, Nwssrng, wbdsrng, wssrng, & + iwbds,iwss) + wbdswsstres(i,(iwbds-1)*Nwssrng+iwss,j) = wbdswsstres(i,(iwbds-1)*Nwssrng+iwss,j) + dt + IF (ijdbg .AND. tdbg==0) THEN + PRINT *,' i,j:', i,j, ' wbds:', wbdsv(i,j),' wss:', wssv(i,j) + PRINT *,' wbds bin:', wbdsrng(iwbds-1), '- ', wbdsrng(iwbds) + PRINT *,' wss bin:', wssrng(iwss-1), '- ', wssrng(iwss) + PRINT *,' Nwbdsrng:', Nwbdsrng, ' Nwssrng:', Nwssrng + PRINT *,' iwbds, iwss:', iwbds, iwss, 'kwbdswss:', (iwbds-1)*Nwssrng+iwss + PRINT *,' current value prior dt:', wbdswsstres(i,(iwbds-1)*Nwssrng+iwss,j) +! PRINT *,' all values:', tashurstreslowres(i,:,j) + END IF + +!#endif +!#endif + + IF (dbg_level >= 75 .AND. ijdbg .AND. tdbg==0) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : intermediate checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' longitude:', lon(i,j),' latitude:',lat(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clt:', clt(i,j), ' mean:', cltmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' cll:', cll(i,j), ' mean:', cllmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clm:', clm(i,j), ' mean:', clmmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' clh:', clh(i,j), ' mean:', clhmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' surface wind gust:', wsgs(i,j), ' x-component:', ugustwind(i,j), & + ' y-component:', vgustwind(i,j), ' N gusts:', percengust(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum surface wind gust:', wsgsmax(i,j), ' x-component:', ugsmax(i,j), & + ' y-component:', vgsmax(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' 100m wind:', wsz100(i,j), ' x-component:', uz100wind(i,j), & + ' y-component:', vz100wind(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum 100m wind:', wsz100max(i,j), ' x-component:', uz100max(i,j), & + ' y-component:', vz100max(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdown:', swdown(i,j), ' sunshine:', sunshine(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdown:', swdown(i,j), ' rsds:', rsds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' glw:', glw(i,j), ' rlds:', rlds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lh:', lh(i,j), ' hfls:', hfls(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' hfx:', hfx(i,j), ' hfss:', hfss(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swupb:', swupb(i,j), ' rsus:', rsus(i,j), ' rsusgen:', rsusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lwupb:', lwupb(i,j), ' rlus:', rlus(i,j), ' rlusgen:', rlusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qfx:', qfx(i,j), ' evspsbl:', evspsbl(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevap:', potevap(i,j), ' evspsbptot:', evspsblpot(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevapgen:', potevapgen(i,j), ' evspsblpotgen:', evspsblpotgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowc:', snowc(i,j), ' snc:', snc(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowh:', snowh(i,j), ' snd:', snd(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' smois (1,3):', smois(i,1,j), smois(i,2,j), smois(i,3,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' dzs (1,3):', dzs(1), dzs(2), dzs(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsos:', mrsos(i,j), ' mrso:', mrso(i,j), ' mrsol (1,2):', mrsol(i,1,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlso:', mrlso(i,j), ' mrlsos:', mrlsos(i,j), ' mrsll (1,2):', & + mrsll(i,1,j), mrsll(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfso:', mrfso(i,j), ' mrfsos:', mrfsos(i,j), ' mrsfl (1,2):', & + mrsfl(i,1,j), mrsfl(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fracsoil10cm (1,3):', fracsoil10cm(1), fracsoil10cm(2), fracsoil10cm(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsosmean:', mrsosmean(i,j), ' mrsomean:', mrsomean(i,j), & + ' mrsolmean (1,2):', mrsolmean(i,1,j), mrsolmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlsomean:', mrlsomean(i,j), ' mrlsosmean:', mrlsosmean(i,j), & + ' mrsllmean (1,2):', mrsllmean(i,1,j), mrsllmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfsomean:', mrfsomean(i,j), ' mrfsosmean:', mrfsosmean(i,j), & + ' mrsflmean (1,2):', mrsflmean(i,1,j), mrsflmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' sfcrunoff:', sfcrunoff(i,j), ' mrros:', mrros(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' udrunoff:', udrunoff(i,j), ' mrro:', mrro(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j), ' flxprl:', flxprl(i,j), ' flxprc:', flxprc(i,j), ' flxprsh:', flxprsh(i,j),& + ' flxprsn:', flxprsn(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snow:', snow(i,j), ' snw:', snw(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdnt:', swdnt(i,j), ' rsdt:', rsdt(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swupt:', swupt(i,j), ' rsut:', rsut(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lwupt:', lwupt(i,j), ' rlut:', rlut(i,j) + CALL wrf_debug(75,msg) + +!#ifdef CDXWRF +!#if CDXWRF>=1 + IF (convxtrm_diag == 1) THEN + WRITE(msg,*) ' cape:', cape(i,j), ' capemin:', capemin(i,j), ' capemax:', & + capemax(i,j), ' capemean:', capemean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' cin:', cin(i,j), ' cinmin:', cinmin(i,j), ' cinmax:', cinmax(i,j), & + ' capemean:', capemean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' zlfc:', zlfc(i,j), ' zlfcmin:', zlfcmin(i,j), ' zlfcmax:', & + zlfcmax(i,j), ' zlfcmean:', zlfcmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' plfc:', plfc(i,j), ' plfcmin:', plfcmin(i,j), ' plfcmax:', & + plfcmax(i,j), ' plfcmean:', plfcmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' lidx:',lidx(i,j), ' lidxmin:', lidxmin(i,j), ' lidxmax:',lidxmax(i,j),& + ' lidxmean:', lidxmean(i,j) + CALL wrf_debug(75,msg) + END IF + WRITE(msg,*) ' iutmean:', iutmean(i,j), ' ivtmean:', ivtmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fog:', fog(i,j), ' tfog:', tfog(i,j), ' vis:', vis(i,j), ' vismin:', & + fogvisbltymin(i,j), ' vismax:', fogvisbltymax(i,j), ' vismean:', fogvisbltymean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tds:', tds(i,j), ' min:', tdsmin(i,j), ' max:', tdsmax(i,j), & + ' mean:', tdsmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tws:', tws(i,j), ' min:', twsmin(i,j), ' max:', twsmax(i,j), & + ' mean:', twsmean(i,j) + CALL wrf_debug(75,msg) +!#endif +!#if CDXWRF>=4 + WRITE(msg,*) ' diabh:', SUM(diabh(i,:,j))*dt, ' wbacdh:', wbacdh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' dhl:', wbacdhl(i,j), 'dhm:', wbacdhm(i,j), 'dhh:', wbacdhh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' WB only vater wapour m_qv:', m_qv + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: pw', SUM(pwqvar(i,:,j,m_qv)), ' acpw:', wbacpw(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: f', SUM(fqvar(i,:,j,m_qv)), ' acf:', wbacf(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: z', SUM(zqvar(i,:,j,m_qv)), ' acz:', wbacz(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zl', varlmh(1), ' aczlv:', wbaczlv(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zm', varlmh(2), ' aczmv:', wbaczmv(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qv: zh', varlmh(3), ' aczhv:', wbaczhv(i,j) + CALL wrf_debug(75,msg) +!#endif +!#if CDXWRF>=3 + WRITE(msg,*)' tashurstreshighres: ',tashurstreshighres(i,INT(Nhtasrng/2*Nhhursrng/2),j),& + ' tashurstreslowres: ', tashurstreslowres(i,INT(Nltasrng/2*Nlhursrng/2),j), & + ' wbdswsstres: ', wbdswsstres(i,INT(Nwbdsrng/2*Nwssrng/2),j) + CALL wrf_debug(75,msg) +!#endif +!#endif + + !CALL wrf_error_fatal(msg) + END IF + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + END IF + + ! Some of CORDEX variables tend to be quite computational intensive, thus, just compute them when + ! it is necessary (only valid for instantaneous variables) + ijdbg = .FALSE. + IF (is_output_time) THEN + CALL wrf_debug(10,' ' // TRIM(fname) // ': Computing instantaneous CORDEX variables') + + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + IF (psl_diag == dpslptarget) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': Smoothing surface pressure ', psmooth, ' times' + CALL wrf_debug(10,msg) + ! Horizontally Smoothing + smoothp = ps + DO k=1, psmooth + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + i1 = MIN(i+1,i_end(ij)) + i_1 = MAX(i-1,i_start(ij)) + j1 = MIN(j+1,j_end(ij)) + j_1 = MAX(j-1,j_start(ij)) + !i1 = i + 1 + !i_1 = i - 1 + !j1 = j + 1 + !j_1 = j - 1 + + ! Smoothing surface pressure + smoothp(i,j)= smoothp(i,j) + smoothp(i_1,j) + smoothp(i_1,j1) + smoothp(i,j1) + & + smoothp(i1,j1) + smoothp(i1,j) + smoothp(i1,j_1) + smoothp(i,j_1) + smoothp(i_1,j_1) + smoothp(i,j)= smoothp(i,j) / 9. + END DO + END DO + WRITE(msg,*) ' ' //TRIM(fname)// ': Smoothed', k,' surface pressure i2, j2:', & + smoothp(i2(ij),j2(ij)) + CALL wrf_debug(100,msg) + END DO + WRITE(msg,*) ' ' //TRIM(fname)// ': Finally Smoothed !!' + CALL wrf_debug(100,msg) + END IF + + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + i1 = MIN(i+1,i_end(ij)) + i_1 = MAX(i-1,i_start(ij)) + j1 = MIN(j+1,j_end(ij)) + j_1 = MAX(j-1,j_start(ij)) + !WRITE(msg, *)'i:',i,' i+1', i+1, ' j:', j, ' j+1:', j+1, ' ilims:', i_start(ij), i_end(ij), ' jlims:', j_start(ij), j_end(ij) + !CALL wrf_debug(10,' ' // TRIM(msg) ) + + ! Height above surface at half-mass levels + zsfc = zg(i,:,j)-hgt(i,j) + + ! Unstaggering certain variables + + ! prw: Total water path + CALL var_massvertint(qv(i,:,j), mutot(i,j), dimz, deta, prw(i,j)) + + ! clwvi: Total condensated water path + qvar = qc(i,:,j)+qr(i,:,j)+qs(i,:,j)+qi(i,:,j) + CALL var_massvertint(qvar, mutot(i,j), dimz, deta, clwvi(i,j)) + + ! clivi: Total ice water path + qvar = qs(i,:,j)+qi(i,:,j)+qg(i,:,j)+qh(i,:,j) + CALL var_massvertint(qvar, mutot(i,j), dimz, deta, clivi(i,j)) + + ! 2m specific humidity + CALL var_huss(q2(i,j), huss(i,j)) + + ! 10m wind speed + wss(i,j) = SQRT(u10(i,j)*u10(i,j)+v10(i,j)*v10(i,j)) + + ! sea level pressure + WRITE(msg,*) ' ' // TRIM(fname) // ': computing sea level pressure diagnostic' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + psldiag: SELECT CASE (psl_diag) + CASE (dpslshuell) + WRITE(msg,*) ' ' // TRIM(fname) // ': psl diagnostic= ', psl_diag, ' hydrostatic ' // & + 'Shuell corrected method' + CALL var_psl_shuell(hgt(i,j), ps(i,j), zg(i,1,j), qv(i,1,j), t(i,1,j), psl(i,j)) + CASE (dpslptarget) + WRITE(msg,*) ' ' // TRIM(fname) // ': psl diagnostic= ', psl_diag, ' ptarget method'//& + ' press. target=', ptarget, ' Pa' + CALL var_psl_ptarget(press(i,:,j), smoothp(i,j), hgt(i,j), t(i,:,j), qv(i,:,j), dimz, & + ptarget, psl(i,j)) + CASE (dpslecmwf) + WRITE(msg,*) ' ' // TRIM(fname) // ': psl diagnostic= ', psl_diag, ' ECMWF method' + CALL var_psl_ecmwf(ps(i,j), hgt(i,j), t(i,1,j), press(i,1,j), p8w(i,2,j), psl(i,j)) + CASE DEFAULT + WRITE (msg,*) ' ' // TRIM(fname) // ": ERROR -- error -- ERROR -- error : type " // & + "of sea level pressure 'psl_diag=", psl_diag, "' not ready !! " // CHAR(10) // & + " available ones; ", dpslshuell, " : shuell", dpslptarget, ' : ptarget, ', & + dpslecmwf,' : ecmwf ' + CALL wrf_error_fatal(msg) + END SELECT psldiag + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(100,msg) + + ! tauu, tauv + WRITE(msg,*) ' ' // TRIM(fname) // ': computing tauu,tauv diagnostic' + IF (ijdbg) CALL wrf_debug(50,msg) + cdcdx(i,j) = Cd(i,j) + tauu(i,j) = cdcdx(i,j)*uas(i,j)*uas(i,j) + tauv(i,j) = cdcdx(i,j)*vas(i,j)*vas(i,j) + tauugen(i,j) = cdgen(i,j)*uas(i,j)*uas(i,j) + tauvgen(i,j) = cdgen(i,j)*vas(i,j)*vas(i,j) + + ! ORCHIDEE t2 & q2 diagnostics + hus_kts = qv(i,kts,j)/(1.0+qv(i,kts,j)) + + ! zg_kts = zg(i,kts,j)/g (It should be gravity maybe from model_constants) + zg_kts = zg(i,kts,j) + CALL SFCDIAGS_ORCHIDEE1D( u(i,kms:kme,j), v(i,kms:kme,j), t(i,kms:kme,j), hus_kts, & + zg_kts, p_phy(i,kms:kme,j), & + ts(i,j), qsfc(i,j), znt(i,j), ps(i,j), & + chs(i,j)/(uas(i,j)**2+vas(i,j)**2), cdgen(i,j), br(i,j), ust(i,j), zol(i,j), & + kms, kme, kts, kte, & + tas_hm(i,j), huss_hm) + qvs_hm(i,j) = huss_hm/(1.0-huss_hm) + + ! Compute statistics (no need when XIOS or similar is used....) + cltmean(i,j) = cltmean(i,j)/nsteps + cllmean(i,j) = cllmean(i,j)/nsteps + clmmean(i,j) = clmmean(i,j)/nsteps + clhmean(i,j) = clhmean(i,j)/nsteps + percengust(i,j) = percengust(i,j)*100./nsteps + totpercengust(i,j) = totpercengust(i,j)*100./nsteps + + ! Fluxes + rsds(i,j) = rsds(i,j)/nsteps + rlds(i,j) = rlds(i,j)/nsteps + hfls(i,j) = hfls(i,j)/nsteps + hfss(i,j) = hfss(i,j)/nsteps + rsus(i,j) = rsus(i,j)/nsteps + rlus(i,j) = rlus(i,j)/nsteps + rsusgen(i,j) = rsusgen(i,j)/nsteps + rlusgen(i,j) = rlusgen(i,j)/nsteps + evspsbl(i,j) = evspsbl(i,j)/nsteps + evspsblpot(i,j) = evspsblpot(i,j)/nsteps + evspsblpotgen(i,j) = evspsblpotgen(i,j)/nsteps + + ! Snow + ! Maybe something more complete... ideas welcome !! + snc(i,j) = snc(i,j)/nsteps + snd(i,j) = snd(i,j)/nsteps + + ! Run-off (de-accumulation) + mrros(i,j) = (mrros(i,j)-pmrros(i,j))/(dt*nsteps) + mrro(i,j) = (mrro(i,j)-pmrro(i,j))/(dt*nsteps) + + ! soil + mrsomean(i,j) = mrsomean(i,j)/nsteps + mrsosmean(i,j) = mrsosmean(i,j)/nsteps + mrlsomean(i,j) = mrlsomean(i,j)/nsteps + mrlsosmean(i,j) = mrlsosmean(i,j)/nsteps + mrfsomean(i,j) = mrfsomean(i,j)/nsteps + mrfsosmean(i,j) = mrfsosmean(i,j)/nsteps + mrsolmean(i,:,j) = mrsolmean(i,:,j)/nsteps + mrsllmean(i,:,j) = mrsllmean(i,:,j)/nsteps + mrsflmean(i,:,j) = mrsflmean(i,:,j)/nsteps + + ! Precipitations + flxpr(i,j) = flxpr(i,j)/(dt*nsteps) + flxprl(i,j) = flxprl(i,j)/(dt*nsteps) + flxprc(i,j) = flxprc(i,j)/(dt*nsteps) + flxprsh(i,j) = flxprsh(i,j)/(dt*nsteps) + flxprsn(i,j) = flxprsn(i,j)/(dt*nsteps) + + ! Fluxes at TOA + rsdt(i,j) = rsdt(i,j)/nsteps + rsut(i,j) = rsut(i,j)/nsteps + rlut(i,j) = rlut(i,j)/nsteps + +!#ifdef CDXWRF +!#if CDXWRF>=1 + ! clgvi: Total graupel water path + qvar = qg(i,:,j) + CALL var_massvertint(qvar, mutot(i,j), dimz, deta, clgvi(i,j)) + + ! clhvi: Total hail water path + qvar = qh(i,:,j) + CALL var_massvertint(qvar, mutot(i,j), dimz, deta, clhvi(i,j)) + + ! zmla_gen + WRITE(msg,*) ' ' // TRIM(fname) // ': computing zmla generic diagnostic' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + IF (zmlagen_diag == zmlagenthetae) THEN + WRITE(msg,*) ' use theta-based method (Nielsen-Gammon et al., 2008)' + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + CALL var_zmla_generic(dimz, qv(i,:,j), th(i,:,j), z(i,:,j), hgt(i,j), dqv, dtheta, & + zmla(i,j)) + ELSE IF (zmlagen_diag == zmlagenbulk) THEN + WRITE(msg,*) ' use bulk-Richardson number method (Vogelezang and Holtslag, 1996; Seidel et al., 2004)' + IF (ijdbg) CALL wrf_debug(50,msg) + ! here is used qcs = from Monin-Obukhov similarity theory + qsolid = qs(i,:,j) + qi(i,:,j) + qg(i,:,j) + qh(i,:,j) + CALL var_bulk_Ri(dimz, th(i,:,j), qv(i,:,j), qc(i,:,j), qsolid, z(i,:,j), unu(i,:,j), & + unv(i,:,j), t(i,:,j), ust(i,j), ri) + CALL var_zmla_RIgen(dimz, ri, zg(i,:,j), hgt(i,j), 0.25, zmla(i,j)) + END IF + + ! cape (no need to reach top of atmosphere... dz1) + WRITE(msg,*) ' ' // TRIM(fname) // ': computing CAPE diagnostic' + IF (ijdbg) CALL wrf_debug(50,msg) +! L. Fita, January 2018. CIMA +!! Changing to subroutine + IF (convxtrm_diag == 0) THEN + CALL var_cape_afwa(dz1, t(i,1:dz1,j), hur(i,1:dz1,j)*100., press(i,1:dz1,j), z(i,1:dz1,j),& + 1, cape(i,j), cin(i,j), zlfc(i,j), plfc(i,j), lidx(i,j), 3) + ! Giving it as height above ground + IF (zlfc(i,j) /= -1.) zlfc(i,j) = zlfc(i,j) - hgt(i,j) + END IF + + ! Extremes of convection indices + IF (convxtrm_diag == 1) THEN + capemean(i,j) = capemean(i,j)/nsteps + cinmean(i,j) = cinmean(i,j)/nsteps + zlfcmean(i,j) = zlfcmean(i,j)/nsteps + plfcmean(i,j) = plfcmean(i,j)/nsteps + lidxmean(i,j) = lidxmean(i,j)/nsteps + END IF + + ! Horizontal water vapour transport + iutmean(i,j) = iutmean(i,j)/nsteps + ivtmean(i,j) = ivtmean(i,j)/nsteps + + ! 0-isotherm + ! Height above ground + zagl = z(i,:,j)-hgt(i,j) + zeroith(i,j) = zero_isotherm1D(dimz, t(i,:,j), zagl(:)) + +!#endif +!#if CDXWRF>=2 + ! specific humidity + CALL var_hus(qv(i,:,j), dimz, hus(i,:,j)) + + ! Earth rotated winds + CALL var_uava(unu(i,:,j), unv(i,:,j), sina(i,j), cosa(i,j), dimz, ua(i,:,j), va(i,:,j)) + + ! Wind speed + ws(i,:,j) = SQRT(unu(i,:,j)*unu(i,:,j)+unv(i,:,j)*unv(i,:,j)) + + ! fog + fogvisbltymean(i,j) = fogvisbltymean(i,j)/nsteps + + ! tds + tdsmean(i,j) = tdsmean(i,j)/nsteps + + ! tws + twsmean(i,j) = twsmean(i,j)/nsteps + +!#endif +!#endif + + IF (dbg_level >= 75 .AND. ijdbg) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : final checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) + WRITE(msg,*) ' tas_hm:', tas_hm(i,j), ' qvs_hm:', qvs_hm(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' cltmean:', cltmean(i,j), ' cllmean:', cllmean(i,j), ' clmmean:', & + clmmean(i,j), ' clhmean', clhmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' prw:', prw(i,j), ' clwvi:', clwvi(i,j), ' clivi:', clivi(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' uas', uas(i,j), ' vas:', vas(i,j), ' wss:', wss(i,j), ' wbds:', & + wbds(i,j), ' hurs', hurs(i,j), ' huss:', huss(i,j), ' psl:', psl(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' mrso:', mrso(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum surface wind gust:', wsgsmax(i,j), ' x-component:', ugsmax(i,j), & + ' y-component:', vgsmax(i,j), ' %:', percengust(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' total maximum surface wind gust:', totwsgsmax(i,j), ' x-component:', & + totugsmax(i,j), ' y-component:', totvgsmax(i,j), ' %:', totpercengust(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' 100m wind:', wsz100(i,j), ' x-component:', uz100wind(i,j), & + ' y-component:', vz100wind(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' maximum 100m wind:', wsz100max(i,j), ' x-component:', uz100max(i,j), & + ' y-component:', vz100max(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swdown:', swdown(i,j), ' sunshine:', sunshine(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' Cd:', Cd(i,j), 'Cdcdx:', cdcdx(i,j), ' tauu:', tauu(i,j), ' tauv:', & + tauv(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' Cdgen:', cdgen(i,j), ' tauugen:', tauugen(i,j), & + ' tauvgen:', tauvgen(i,j) + WRITE(msg,*)' swdown:', swdown(i,j), ' rsds:', rsds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' glw:', glw(i,j), ' rlds:', rlds(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lh:', lh(i,j), ' hfls:', hfls(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' hfx:', hfx(i,j), ' hfss:', hfss(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' swupb:', swupb(i,j), ' rsus:', rsus(i,j), ' rsusgen:', rsusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' lwupb:', lwupb(i,j), ' rlus:', rlus(i,j), ' rlusgen:', rlusgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' qfx:', qfx(i,j), ' evspsbl:', evspsbl(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevap:', potevap(i,j), ' evspsbltot:', evspsblpot(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' potevapgen:', potevapgen(i,j), ' evspsbltotgen:', evspsblpotgen(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowc:', snowc(i,j), ' snc:', snc(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snowh:', snowh(i,j), ' snd:', snd(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' smois (1,3):', smois(i,1,j), smois(i,2,j), smois(i,3,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' dzs (1,3):', dzs(1), dzs(2), dzs(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsos:', mrsos(i,j), ' mrso:', mrso(i,j), ' mrsol (1,2):', mrsol(i,1,j), & + mrsol(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlso:', mrlso(i,j), ' mrlsos:', mrlsos(i,j), ' mrsll (1,2):', & + mrsll(i,1,j), mrsll(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfso:', mrfso(i,j), ' mrfsos:', mrfsos(i,j), ' mrsfl (1,2):', & + mrsfl(i,1,j), mrsfl(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fracsoil10cm (1,3):', fracsoil10cm(1), fracsoil10cm(2), fracsoil10cm(3) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrsosmean:', mrsosmean(i,j), ' mrsomean:', mrsomean(i,j), & + ' mrsolmean (1,2):', mrsolmean(i,1,j), mrsolmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrlsomean:', mrlsomean(i,j), ' mrlsosmean:', mrlsosmean(i,j), & + ' mrsllmean (1,2):', mrsllmean(i,1,j), mrsllmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' mrfsomean:', mrfsomean(i,j), ' mrfsosmean:', mrfsosmean(i,j), & + ' mrsflmean (1,2):', mrsflmean(i,1,j), mrsflmean(i,2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' sfcrunoff:', sfcrunoff(i,j), ' mrros:', mrros(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' udrunoff:', udrunoff(i,j), ' mrro:', mrro(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j), ' flxprl:', flxprl(i,j), ' flxprc:', flxprc(i,j), ' flxprsh:', flxprsh(i,j),& + ' flxprsn:', flxprsn(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' snw:', snw(i,j), ' rsdt:', rsdt(i,j), ' rsut:', rsut(i,j), ' rlut:', & + rlut(i,j) + CALL wrf_debug(75,msg) +!#ifdef CDXWRF +!#if CDXWRF>=1 + WRITE(msg,*) ' clgvi:', clgvi(i,j), ' clhvi:', clhvi(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' zmla_gen:', zmla(i,j) + CALL wrf_debug(75,msg) + IF (convxtrm_diag == 1) THEN + WRITE(msg,*) ' capemean:', capemean(i,j), ' cinmean:', cinmean(i,j), ' zlfcmean:', & + zlfcmean(i,j), ' plfcmean:', plfcmean(i,j), ' lidxmean:', lidxmean(i,j) + CALL wrf_debug(75,msg) + END IF + WRITE(msg,*) ' iutmean:', iutmean(i,j), ' ivtmean:', ivtmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' 0-isotherm:', zeroith(i,j) + CALL wrf_debug(75,msg) +!#endif +!#if CDXWRF>=2 + WRITE(msg,*) ' ua', ua(i,k2,j), ' va:', va(i,k2,j), ' ws:', ws(i,k2,j),' ta:', & + ta(i,k2,j), ' press:', press(i,k2,j), ' zg:', zg(i,k2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' hur', hur(i,k2,j), ' hus:', hus(i,k2,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' cape:', cape(i,j), ' cin:', cin(i,j),' zlfc:', zlfc(i,j), ' plfc:', & + plfc(i,j), 'lidx:', lidx(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' fog:', fog(i,j), ' tfog:', tfog(i,j), ' vis:', vis(i,j), ' vismin:', & + fogvisbltymin(i,j), ' vismax:', fogvisbltymax(i,j), ' vismean:', fogvisbltymean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tds:', tds(i,j), ' min:', tdsmin(i,j), ' max:', tdsmax(i,j), & + ' mean:', tdsmean(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' tws:', tws(i,j), ' min:', twsmin(i,j), ' max:', twsmax(i,j), & + ' mean:', twsmean(i,j) + CALL wrf_debug(75,msg) +!#endif +!#if CDXWRF >=4 + WRITE(msg,*) ' acdh:', wbacdh(i,j), ' dhl:', wbacdhl(i,j), 'dhm:', wbacdhm(i,j), & + 'dhh:', wbacdhh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' WB acpw:', wbacpw(i,j), 'acpwc:', wbacpwc(i,j), 'acpwr:', wbacpwr(i,j), & + 'acpws:', wbacpws(i,j), 'acpwi:', wbacpwi(i,j), 'acpwg:', wbacpwg(i,j), 'acpwh:', & + wbacpwh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' WB acf:', wbacf(i,j), 'acfc:', wbacfc(i,j), 'acfr:', wbacfr(i,j), & + 'acfs:', wbacfs(i,j), 'acfi:', wbacfi(i,j), 'acfg:', wbacfg(i,j), 'acfh:', wbacfh(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' WB acz:', wbacz(i,j), 'aczc:', wbaczc(i,j), 'aczr:', wbaczr(i,j), & + 'acfs:', wbaczs(i,j), 'acfi:', wbaczi(i,j), 'aczg:', wbaczg(i,j), 'aczh:', wbaczh(i,j) + CALL wrf_debug(75,msg) +!#endif +!#endif + END IF + + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + END IF + + END SUBROUTINE cordex_output_calc + +!#ifdef CDXWRF +! CDXWRF - high frequency +!! + SUBROUTINE cordex_hf_output_calc( & + is_restart, is_output_time, cdxH, nsteps, & + dt, xtime, curr_secs2, & + + ! Input + lon, lat, & + timedbg, & + londbg, latdbg, & + idbg, jdbg, & + qr, qs, qg, & + t, & + prc, prnc, prsh, & + rho, & + ! Output +!#if CDXWRF>=1 + flxpr, colmax, & +!#endif + ids,ide, jds,jde, kds,kde, & + ims,ime, jms,jme, kms,kme, & + ips,ipe, jps,jpe, kps,kpe, & ! patch dims + i_start,i_end,j_start,j_end,kts,kte,num_tiles & + ) + +!---------------------------------------------------------------------- +! Main subroutine to compute CORDEX high-frequency variables + + USE module_dm, ONLY: wrf_dm_sum_real, wrf_dm_maxval + USE module_configure + USE module_diagvar_cordex + + IMPLICIT NONE + +!====================================================================== +! Definitions +!----------- +!-- DT time step (second) +!-- XTIME forecast time +!-- curr_secs2 current time in seconds since simulation restart +!-- nsteps amount of time-steps between outputs +! +!-- ids start index for i in domain +!-- ide end index for i in domain +!-- jds start index for j in domain +!-- jde end index for j in domain +!-- kds start index for k in domain +!-- kde end index for k in domain +!-- ims start index for i in memory +!-- ime end index for i in memory +!-- jms start index for j in memory +!-- jme end index for j in memory +!-- ips start index for i in patch +!-- ipe end index for i in patch +!-- jps start index for j in patch +!-- jpe end index for j in patch +!-- kms start index for k in memory +!-- kme end index for k in memory +!-- i_start start indices for i in tile +!-- i_end end indices for i in tile +!-- j_start start indices for j in tile +!-- j_end end indices for j in tile +!-- kts start index for k in tile +!-- kte end index for k in tile +!-- num_tiles number of tiles + +! +!----------- +! is_restart: whether if simulation is a restart +! is_output_time: whether if this iteration is an output time-step +! cdxH: period of time [minute] of calculations between outputs +! +! ------- INPUT vars ------- +! lon: longitude +! lat: latitude +! timedbg: frecuency in minutes of time debugging +! londbg, latdbg: coordinates of the debugging grid point (-999. if not set-up) +! idbg, jdbg: grid point coordinates of the debugging grid point +! qr: rain mixing ratio [kgkg-1] +! qs: snow mixing ratio [kgkg-1] +! qg: graupel mixing ratio [kgkg-1] +! t: 3D air temperature [K] +! rho: air density [kgm-3] +! prc: convective (from cumulus scheme) precipitation [kgm-2] +! prnc: non-convective (from micro-physics scheme) precipitation [kgm-2] +! prsh: shallow-cumulus (from shallow-cumulus scheme) precipitation [kgm-2] + +!-------- OUTPUT vars ------- [defined at registry.cordex] and included on Registry.EM_COMMON on auxhist8 +! flxpr: precipitation flux [kgm-2s-1] +! colmax: maximum radar reflectivity in the column [dBz] + +!!!!!!! Structure +! 1.: Compute such variables needed for internal accumulations, extremes +! 2.: Compute the variables from clouds (only actualized at every radt) +! 3.: If the time step is the first after writting the auxhist8 file inittialize the variables of (1., 2.) +! 4.: If the time step is exactly the previous one before the writting of the auxhist8 file: +! a: Compute all other variables +! b: Finish calculation of 1., 2. variables + +!====================================================================== + + INTEGER, INTENT(in) :: & + ids,ide, jds,jde, kds,kde, & + ims,ime, jms,jme, kms,kme, & + ips,ipe, jps,jpe, kps,kpe, & + kts,kte, & + num_tiles + + + INTEGER, DIMENSION(num_tiles), INTENT(in) :: i_start, i_end, j_start, j_end + + REAL, DIMENSION(ims:ime,kms:kme,jms:jme), INTENT(in) :: qr, qs, qg, t, rho + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: lon, lat + INTEGER, INTENT(in) :: timedbg + REAL, INTENT(in) :: londbg, latdbg + INTEGER, INTENT(in) :: idbg, jdbg + REAL, DIMENSION(ims:ime,jms:jme), INTENT(in) :: prc, prnc, prsh + + REAL, INTENT(in) :: DT, XTIME + REAL, INTENT(in) :: curr_secs2 + INTEGER, INTENT(in) :: cdxH + LOGICAL, INTENT(in) :: is_restart, is_output_time + INTEGER, INTENT(inout) :: nsteps +!#if CDXWRF>=1 + REAL, DIMENSION(ims:ime,jms:jme), INTENT(inout) :: flxpr, colmax +!#endif + +! LOCAL VAR + + INTEGER :: i, j, k, m, its, ite, jts, jte, ij + INTEGER :: idp, jdp, dimz, dimz1, dz1 + INTEGER :: i1, i_1, j1, j_1, k2, tdbg + INTEGER, DIMENSION(num_tiles) :: i2, j2 + + REAL :: xtimep + REAL :: prv + + LOGICAL, EXTERNAL :: wrf_dm_on_monitor + CHARACTER(len=256) :: msg + LOGICAL :: ijdbg, cdone + INTEGER :: dbg_level + + fname = 'cordex_hf_output_calc' + + ! Getting the overall debug level + CALL get_wrf_debug_level( dbg_level ) + cdone = .FALSE. + + ! timedbg + ! when time-debug in minutes + tdbg = MOD(xtime, timedbg*1.) + + ! L. Fita: NOTE about efficiency + ! I am not sure if this is the more efficient way: + ! 1.- IF --> 2.- repeat DO + ! 1.- DO --> 2.- IF + + dimz = kme - kms + 1 + dimz1 = dimz + 1 + dz1 = dimz - 1 + + ! For test purposes + IF ((londbg == -999.) .OR. (latdbg == -999.)) THEN + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + i2(ij) = INT(0.5*(i_start(ij) + i_end(ij))) + j2(ij) = INT(0.5*(j_start(ij) + j_end(ij))) + END DO + !$OMP END PARALLEL DO + ELSE + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + i2(ij) = idbg + j2(ij) = jdbg + END DO + !$OMP END PARALLEL DO + END IF + k2 = 0.5*(kms+kme) + + ! Computing accumulative variables + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + + ! Avoiding seg faults + IF (curr_secs2 > 0. ) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ': computing colmax' + + IF (ijdbg .AND. tdbg==0) CALL wrf_debug(50,msg) + ! Total precipitation + prv = prc(i,j) + prnc(i,j) + prsh(i,j) + + END IF + + + ijdbg = .FALSE. + END DO + END DO + END DO + !$OMP END PARALLEL DO + + IF (( MOD(NINT(curr_secs2/dt),NINT(cdxH*60./dt)) == 0) ) THEN + ! Initialization of accumulated variables between outputs + IF ( wrf_dm_on_monitor() ) THEN + CALL wrf_debug(0, ' ' // TRIM(fname) // ': Re-initializing accumulation arrays') + ENDIF + + nsteps = 1 + + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + +!#if CDXWRF>=1 + ! Precipitations + flxpr(i,j) = prc(i,j) + prnc(i,j) + prsh(i,j) +!#endif + + IF (dbg_level >= 75 .AND. ijdbg .AND. tdbg==0) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : first value checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' longitude:', lon(i,j),' latitude:',lat(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) +!#if CDXWRF>=1 + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j) +!#endif + CALL wrf_debug(75,msg) + END IF + + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + ELSE + xtimep = xtime + dt/60. ! value at end of timestep for time info + nsteps=nsteps+1 + ijdbg = .FALSE. + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + +!#if CDXWRF>=1 + ! Precipitations + flxpr(i,j) = flxpr(i,j) + prc(i,j) + prnc(i,j) + prsh(i,j) +!#endif + IF (dbg_level >= 75 .AND. ijdbg .AND. tdbg==0) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : intermediate checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' longitude:', lon(i,j),' latitude:',lat(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) +!#if CDXWRF>=1 + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j) +!#endif + CALL wrf_debug(75,msg) + END IF + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + END IF + + ! Some of CORDEX variables tend to be quite computational intensive, thus, just compute them when + ! it is necessary (only valid for instantaneous variables) + ijdbg = .FALSE. + IF (is_output_time) THEN + CALL wrf_debug(10,' ' // TRIM(fname) // ': Computing instantaneous CORDEX variables') + + !$OMP PARALLEL DO & + !$OMP PRIVATE ( ij ) + DO ij = 1 , num_tiles + DO i = i_start(ij), i_end(ij) + DO j = j_start(ij), j_end(ij) + IF (ij == 1 .AND. i == i2(ij) .AND. j == j2(ij)) ijdbg = .TRUE. + i1 = MIN(i+1,i_end(ij)) + i_1 = MAX(i-1,i_start(ij)) + j1 = MIN(j+1,j_end(ij)) + j_1 = MAX(j-1,j_start(ij)) + +!#if CDXWRF>=1 + ! colmax + CALL var_colmax1D(dimz, rho(i,:,j), t(i,:,j), qr(i,:,j), qs(i,:,j), qg(i,:,j), colmax(i,j)) + + ! Precipitation + flxpr(i,j) = flxpr(i,j)/(dt*nsteps) +!#endif + IF (dbg_level >= 75 .AND. ijdbg .AND. tdbg==0) THEN + WRITE(msg,*) ' ' // TRIM(fname) // ' ',i,' ,',j,' : final checks _______' + CALL wrf_debug(75,msg) + WRITE(msg,*) ' nsteps:', nsteps + CALL wrf_debug(75,msg) +!#if CDXWRF>=1 + WRITE(msg,*)' prc:', prc(i,j), ' prnc:', prnc(i,j), ' prsh:', prsh(i,j), ' flxpr:', & + flxpr(i,j) + CALL wrf_debug(75,msg) + WRITE(msg,*)' colmax:', colmax(i,j) + CALL wrf_debug(75,msg) +!#endif + END IF + + ijdbg = .FALSE. + ENDDO + ENDDO + ENDDO + !$OMP END PARALLEL DO + + END IF + + END SUBROUTINE cordex_hf_output_calc +!#endif + +END MODULE module_diag_cordex diff --git a/phys/module_diag_pld.F b/phys/module_diag_pld.F index cba25e0a59..2139b89b86 100644 --- a/phys/module_diag_pld.F +++ b/phys/module_diag_pld.F @@ -18,12 +18,26 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & num_press_levels,max_press_levels,press_levels, & p_pl,u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl, & q_pl, & +!#ifdef CORDEXDIAG + ! L. Fita, CIMA. March 2018 + !! Added for CORDEX output + sina, cosa, & + psfc, topo, alt, p_top, & + iqc, iqr, iqs, iqi, iqg, iqh, & + hus_pl, w_pl, uer_pl, ver_pl, ws_pl, & + qc_pl, qr_pl, qs_pl, qi_pl, qg_pl, qh_pl, & ! v2. Adding other species + qv_pl_mc, qc_pl_mc, qr_pl_mc, qs_pl_mc, & ! v2. Adding mass-conservative + qi_pl_mc, qg_pl_mc, qh_pl_mc, & +!#endif ids,ide, jds,jde, kds,kde, & ims,ime, jms,jme, kms,kme, & its,ite, jts,jte, kts,kte ) USE module_model_constants - +!#ifdef CORDEXDIAG +!! It is not working +!! USE module_diagvar_cordex, ONLY: massconserv_vinterp1D, presbars_to_hgtbars +!#endif IMPLICIT NONE @@ -40,11 +54,24 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & REAL , INTENT(IN ) , DIMENSION(ims:ime , kms:kme , jms:jme) :: u,v,w,t,qv,zp,zb,pp,pb,p,pw INTEGER, INTENT(IN ) :: num_press_levels, max_press_levels REAL , INTENT(IN ) , DIMENSION(max_press_levels) :: press_levels - +!#ifdef CORDEXDIAG + REAL :: p_top + REAL , INTENT(IN ) , DIMENSION(ims:ime , jms:jme) :: sina, cosa, topo, psfc + REAL , INTENT(IN ) , DIMENSION(ims:ime , kms:kme , jms:jme) :: alt + REAL , INTENT(IN ) , DIMENSION(ims:ime , kms:kme , jms:jme) :: iqc, iqr, iqs, iqi, iqg, iqh +!#endif ! Output variables REAL , INTENT( OUT) , DIMENSION(num_press_levels) :: p_pl REAL , INTENT( OUT) , DIMENSION(ims:ime , num_press_levels , jms:jme) :: u_pl,v_pl,t_pl,rh_pl,ght_pl,s_pl,td_pl,q_pl +!#ifdef CORDEXDIAG + REAL , INTENT( OUT) , DIMENSION(ims:ime , num_press_levels , jms:jme) :: hus_pl, w_pl, & + uer_pl, ver_pl, ws_pl + REAL , INTENT( OUT) , DIMENSION(ims:ime , num_press_levels , jms:jme) :: qc_pl, qr_pl, & + qs_pl, qi_pl, qg_pl, qh_pl + REAL , INTENT( OUT) , DIMENSION(ims:ime , num_press_levels , jms:jme) :: qv_pl_mc, & + qc_pl_mc, qr_pl_mc, qs_pl_mc, qi_pl_mc, qg_pl_mc, qh_pl_mc +!#endif ! Local variables @@ -61,6 +88,17 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & qu, qd , & eu, ed, em , & du, dd +!#ifdef CORDEXDIAG + INTEGER :: dzstag + REAL :: wu, wd + REAL, DIMENSION(kms:kme) :: press, zg, massv, rho, ohgts, obthgts + INTEGER :: fstrightlevel, Nright + REAL, DIMENSION(num_press_levels) :: hgts, rightdespressv + REAL, DIMENSION(num_press_levels,2) :: bthgts2 + REAL, DIMENSION(num_press_levels) :: rhodes, valsdes + REAL, DIMENSION(kms:kme) :: bthgts + +!#endif REAL :: es, qs REAL :: part, gammas, tvu, tvd @@ -83,6 +121,27 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & s_pl (i,kp,j) = missing td_pl (i,kp,j) = missing q_pl (i,kp,j) = missing +!#ifdef CORDEXDIAG + ! L. Fita. CIMA. March 2018 + hus_pl (i,kp,j) = missing + w_pl (i,kp,j) = missing + uer_pl (i,kp,j) = missing + ver_pl (i,kp,j) = missing + ws_pl (i,kp,j) = missing + qc_pl (i,kp,j) = missing + qr_pl (i,kp,j) = missing + qs_pl (i,kp,j) = missing + qi_pl (i,kp,j) = missing + qg_pl (i,kp,j) = missing + qh_pl (i,kp,j) = missing + qv_pl_mc (i,kp,j) = missing + qc_pl_mc (i,kp,j) = missing + qr_pl_mc (i,kp,j) = missing + qs_pl_mc (i,kp,j) = missing + qi_pl_mc (i,kp,j) = missing + qg_pl_mc (i,kp,j) = missing + qh_pl_mc (i,kp,j) = missing +!#endif END DO END DO END DO @@ -195,6 +254,22 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & ed = max(ed, 0.001) ! water vapor pressure in mb. td_pl(i,kp,j) = t_kelvin + (s1 / ((s2 / log(ed/s3)) - 1.0)) +!#ifdef CORDEXDIAG + ! 8. Specific humidty (1) + + hus_pl(i,kp,j) = q_pl(i,kp,j) / (1. + q_pl(i,kp,j)) + + ! 9. Earth-rotated U and V (m s-1) + + uer_pl(i,kp,j) = u_pl(i,kp,j)*cosa(i,j) - v_pl(i,kp,j)*sina(i,j) + ver_pl(i,kp,j) = u_pl(i,kp,j)*sina(i,j) + v_pl(i,kp,j)*cosa(i,j) + + ! 10. Wind speed (m s-1) + + ws_pl(i,kp,j) = SQRT(u_pl(i,kp,j)*u_pl(i,kp,j) + v_pl(i,kp,j)*v_pl(i,kp,j)) + +!#endif + EXIT ke_loop_half ELSEIF ( ( pd .GE. pm ) .AND. & ( pu .LT. pm ) ) THEN @@ -255,6 +330,55 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & !es = s3 * exp( s2 * (t_pl(i,kp,j) - t_kelvin)/(t_pl(i,kp,j) - s4) ) ! sat vapor pressure over liquid water in mb. !rh_pl(i,kp,j) = 100. * em * ( pm * 0.01 - es ) / ( es * ( pm * 0.01 - em ) ) + +!#ifdef CORDEXDIAG + ! 8. Specific humidty (1) + + hus_pl(i,kp,j) = q_pl(i,kp,j) / (1. + q_pl(i,kp,j)) + + ! 9. Earth-rotated U and V (m s-1) + + uer_pl(i,kp,j) = u_pl(i,kp,j)*cosa(i,j) - v_pl(i,kp,j)*sina(i,j) + ver_pl(i,kp,j) = u_pl(i,kp,j)*sina(i,j) + v_pl(i,kp,j)*cosa(i,j) + + ! 10. Wind speed (m s-1) + + ws_pl(i,kp,j) = SQRT(u_pl(i,kp,j)*u_pl(i,kp,j) + v_pl(i,kp,j)*v_pl(i,kp,j)) + + ! 11. Other water species (kg/kg) + + ! cloud + qu = MAX(iqc(i,ke+1,j),0.) + qd = MAX(iqc(i,ke ,j),0.) + qc_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + + ! rain + qu = MAX(iqr(i,ke+1,j),0.) + qd = MAX(iqr(i,ke ,j),0.) + qr_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + + ! snow + qu = MAX(iqs(i,ke+1,j),0.) + qd = MAX(iqs(i,ke ,j),0.) + qs_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + + ! ice + qu = MAX(iqi(i,ke+1,j),0.) + qd = MAX(iqi(i,ke ,j),0.) + qi_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + + ! graupel + qu = MAX(iqg(i,ke+1,j),0.) + qd = MAX(iqg(i,ke ,j),0.) + qg_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + + ! hail + qu = MAX(iqh(i,ke+1,j),0.) + qd = MAX(iqh(i,ke ,j),0.) + qh_pl(i,kp,j) = ( qu * (pm-pd) + qd * (pu-pm) ) / (pu-pd) + +!#endif + ke_h = ke EXIT ke_loop_half END IF @@ -280,16 +404,410 @@ SUBROUTINE pld ( u,v,w,t,qv,zp,zb,pp,pb,p,pw, & zd = ( zp(i,ke ,j)+zb(i,ke ,j) ) / g ght_pl(i,kp,j) = ( zu * (pm-pd) + zd * (pu-pm) ) / (pu-pd) + +!#ifdef CORDEXDIAG + ! L. Fita. CIMA. March 2018 + ! 2. Vertical wind speed (ms-1) + + wu = w(i,ke+1,j) + wd = w(i,ke ,j) + w_pl(i,kp,j) = ( wu * (pm-pd) + wd * (pu-pm) ) / (pu-pd) +!#endif + ke_f = ke EXIT ke_loop_full END IF END DO ke_loop_full END DO kp_loop + +!#ifdef CORDEXDIAG + ! Mass-conservative vertical interpolation of water species + + ! Transforming p-level bars to heights + dzstag = kte-1 - kts + zg(1:dzstag) = zb(i,kts:kte-1,j) + zp(i,kts:kte-1,j) + press(1:dzstag-1) = pb(i,kts:kte-2,j) + pp(i,kts:kte-2,j) + CALL presbars_to_hgtbars(topo(i,j), dzstag, zg(1:dzstag), dzstag-1, press(1:dzstag-1), & + psfc(i,j), p_top, num_press_levels, p_pl, fstrightlevel, Nright, & + rightdespressv, hgts, bthgts2) + + bthgts(1) = bthgts2(1,1) + bthgts(2:Nright+1) = bthgts2(1:Nright,2) + + obthgts(1:dzstag) = zg(1:dzstag) / g + ohgts(1:dzstag-1) = 0.5*(obthgts(1:dzstag-1)+obthgts(2:dzstag)) + + ! density + rho(1:dzstag-1) = 1. / alt(i,kts:kte-2,j) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + rho(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), rhodes(1:Nright)) + + ! qv: Water vapour + massv(1:dzstag-1) = qv(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv, Nright+1, bthgts(1:num_press_levels+1), & + valsdes(1:Nright)) + ! There is no way to perform extrapolatoin below ground, so, fill since the first right level + qv_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qc: cloud + massv(1:dzstag-1) = iqc(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qc_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qr: rain + massv(1:dzstag-1) = iqr(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qr_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qs: snow + massv(1:dzstag-1) = iqs(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qs_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qi: ice + massv(1:dzstag-1) = iqi(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qi_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qg: graupel + massv(1:dzstag-1) = iqg(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qg_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + + ! qh: hail + massv(1:dzstag-1) = iqh(i,kts:kte-2,j) * rho(1:dzstag-1) + CALL massconserv_vinterp1D(dzstag-1, ohgts(1:dzstag-1), dzstag, obthgts(1:dzstag), & + massv(1:dzstag-1), Nright, rightdespressv(1:Nright), Nright+1, & + bthgts(1:num_press_levels+1), valsdes(1:Nright)) + qh_pl_mc(i,fstrightlevel:fstrightlevel+Nright-1,j) = valsdes(1:Nright) / rhodes(1:Nright) + +!#endif + END DO i_loop END DO j_loop END SUBROUTINE pld +!#ifdef CORDEXDIAG +! L. Fita, February 2023 +! this should not be here, but it seems that the order of compilation does not allow to do it in another +! way. + + SUBROUTINE massconserv_vinterp1D(dorig, levorig, dorig1, btlevorig, valsorig, ddes, levdes, & + ddes1, btlevdes, valsdes) + ! Subrotine to mass-conservative vertically interpolate a variable 1D + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dorig, ddes, dorig1, ddes1 + REAL, DIMENSION(dorig), INTENT(in) :: levorig, valsorig + REAL, DIMENSION(dorig1), INTENT(in) :: btlevorig + REAL, DIMENSION(ddes), INTENT(in) :: levdes + REAL, DIMENSION(ddes1), INTENT(in) :: btlevdes + REAL, DIMENSION(ddes), INTENT(out) :: valsdes + + ! Local + INTEGER :: ko, kd + REAL :: deskm1, deskp1 + REAL :: orikm1, orikp1 + REAL :: Dlevorig, delta_levorig, Dlevdes + REAL :: delta_desm1, delta_desp1 + REAL :: deltatop_levorig, deltabot_levorig + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! dorig: Original amount of vertical levels +! levorig: original values of the levels (centerd into the level) [m] +! valsorig: original values of the field at the original levels (as density or similar [kgm-3]) +! dorig1: original amount of vertical levels + 1 +! btlevorig: bottom, tops of the original cells [m] +! btlev(k) < lev(k) < btlev(k+1) +! ddes: desired amount of vertical levels +! levdes: desired levels [m] +! ddes1: desired amount of vertical levels + 1 +! btlevdes: bottom, tops of the desired cells [m] +! valsdest: mass-conservative interpolated values (as density or similar [kgm-3]) + + fname = 'massconserv_vinterp1D' + + valsdes = 0. + + ! Let's be efficient + + ! Assuming surface -> top vertical layers and Xsfc < Xtop (as the case with height...) + + ! Here comes the proper integration, where the values of the original cells within the range + ! of the desired cell, are added according to the percentage of the height of the original + ! cell that lays within the range of the desired cell + ! + ! valsdes(kd) = SUM_Nlev(delta_levorig(ko)*valsorig(ko)) + + ! deltatop_levorig(itopkin)*valsorig(itopkin) + deltabot_levorig(ibotkin)*valsorig(ibotkin) + ! + ! valdes(kd) = valdes(kd) / Dlevdes + ! + ! where: + ! Dlevdes = deskp1 - deskm1 + ! Dlevorig = orikp1 - orikm1 + ! + ! delta_levorig(ko) = Dlevorig - delta_desm1 - delta_desp1 + ! + ! delta_desm1 = + ! deskm1 - orikm1; deskm1 > orikm1 + ! 0; deskm1 < orikm1 + ! delta_desp1 = + ! orikp1 - deskp1; deskp1 < orikp1 + ! 0; deskp1 > orikp1 + ! + ! deltatop_levorig(itopkin) = orikp1 - deskm1 + ! deltabot_levorig(itopkin) = deskp1 - orikm1 + ! + ! being: + ! orikm1: value at the base of the original cell + ! orikp1: value at the top of the original cell + ! deskm1: value at the base of the desired cell + ! deskp1: value at the top of the desired cell + ! Nlev: amount of original levels within the height of the kd-desired cell + ! Nlev = orilev(ko) <= deskm1 .and. orilev(ko) > deskp1 + + DO kd=1, ddes + + ! Cell's bottom + deskm1 = btlevdes(kd) + ! Cell0s top + deskp1 = btlevdes(kd+1) + + Dlevdes = deskp1 - deskm1 + + ! Looking for the original cells within the range of the desired cell + DO ko=1, dorig + ! original cell's top + orikp1 = btlevorig(ko+1) + + ! original cell's bottom + orikm1 = btlevorig(ko) + + IF (levorig(ko) >= deskm1 .AND. levorig(ko) < deskp1) THEN + ! Center of the columns + + Dlevorig = orikp1 - orikm1 + IF (deskm1 > orikm1) THEN + delta_desm1 = deskm1 - orikm1 + ELSE + delta_desm1 = 0. + END IF + IF (deskp1 < orikp1) THEN + delta_desp1 = orikp1 - deskp1 + ELSE + delta_desp1 = 0. + END IF + + delta_levorig = Dlevorig - delta_desm1 - delta_desp1 + + valsdes(kd) = valsdes(kd) + delta_levorig*valsorig(ko) + + ELSE IF (orikp1 > deskm1 .AND. levorig(ko) < deskm1) THEN + ! We might have only top of the original columns wihtin the range + + deltatop_levorig = orikp1 - deskm1 + + valsdes(kd) = valsdes(kd) + deltatop_levorig*valsorig(ko) + + ELSE IF (orikm1 < deskp1 .AND. levorig(ko) > deskp1) THEN + ! We might have only base of the original columns wihtin the range + + deltabot_levorig = deskp1 - orikm1 + + valsdes(kd) = valsdes(kd) + deltabot_levorig*valsorig(ko) + + ELSE IF (orikm1 > deskp1) THEN + EXIT + + END IF + + END DO + + valsdes(kd) = valsdes(kd)/Dlevdes + + END DO + + RETURN + + END SUBROUTINE massconserv_vinterp1D + + SUBROUTINE presbars_to_hgtbars(topo, dzs, zg, dz, oripres, psfc, ptop, dpres, despressv, & + firstrightlev, Nrightlevs, rightdespressv, hgts, bthgts) + ! Subroutine to transform from desired bars defined by their central pressures to bars in height + ! coordinates using model's geopotential to define its heights + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dpres, dz, dzs + REAL, DIMENSION(dpres), INTENT(in) :: despressv + REAL, INTENT(in) :: topo, psfc, ptop + REAL, DIMENSION(dzs), INTENT(in) :: zg + REAL, DIMENSION(dz), INTENT(in) :: oripres + INTEGER, INTENT(out) :: firstrightlev, Nrightlevs + REAL, DIMENSION(dpres), INTENT(out) :: hgts, rightdespressv + REAL, DIMENSION(dpres,2), INTENT(out) :: bthgts + + ! Local + INTEGER :: k, ko, dzstag + REAL :: botpressv + REAL :: a, b + REAL, DIMENSION(dz) :: orihgt + REAL, DIMENSION(:), ALLOCATABLE :: oribthgt + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! topo: topography [m] +! dzs: amount of geopotential heights +! zg: geopotential heights [m2s-2] +! dz: amount of original pressure +! oripres: original pressure values [Pa] +! psfc: pressure at the surfrace [Pa] +! ptop: pressure at the top [Pa] +! dpres: amount of desired pressure levels +! despressv: desired pressure levels [Pa] +! Nrightlevs: amount of right pressure levels (it might hapeen to want 'below' ground or 'above' top +! values) +! rightdespressv: right desired pressure values to provide heights +! hgts: heights at the desired pressure levels [m] +! bthgts: bottoms and tops of the cells at the desired pressure levels [m] + + fname = 'presbars_to_hgtbars' + + rightdespressv = 0. + hgts = 0. + bthgts = 0. + + IF (dzs == dz+1) THEN + !IF (ALLOCATED(geopt)) DEALLOCATE(geopt) Efficiency ? + dzstag = dzs + ALLOCATE(oribthgt(dzstag)) + oribthgt = zg / 9.81 + ELSE + !IF (ALLOCATED(geopt)) DEALLOCATE(geopt) Efficiency ? + dzstag = dz+1 + ALLOCATE(oribthgt(dzstag)) + oribthgt(1) = zg(1) / 9.81 + DO k=2, dz + oribthgt(k) = 0.5*(zg(k-1) + zg(k))/9.81 + END DO + ! Let's get creative here. We could ask for p_top and get a standard atmosphere + ! conversion to geopotential... instead geopt(dz+1) = geopt(dz) + (zg(dz)-zg(dz-1)) + oribthgt(dzstag) = (zg(dz) + (zg(dz)-zg(dz-1)) ) / 9.81 + END IF + orihgt = 0.5*(oribthgt(2:dzstag)+oribthgt(1:dzstag-1)) + + ! Get the conversion + firstrightlev = -1 + Nrightlevs = 0 + hgts(1) = topo + DO k=1, dpres + DO ko = 1, dz + ! Filtering to avoid 'below ground' and 'above atmos top' interpolation values + IF (oripres(ko) >= despressv(k) .AND. oripres(ko+1) < despressv(k) .AND. & + psfc > despressv(k) .AND. ptop < despressv(k)) THEN + + Nrightlevs = Nrightlevs + 1 + IF (firstrightlev == -1) firstrightlev = k + + a = (oripres(ko+1)*orihgt(ko)-oripres(ko)*orihgt(ko+1))/(oripres(ko+1)-oripres(ko)) + b = (orihgt(ko+1)-orihgt(ko))/(oripres(ko+1)-oripres(ko)) + rightdespressv(Nrightlevs) = despressv(k) + hgts(Nrightlevs) = a + despressv(k)*b + + EXIT + END IF + END DO + END DO + + ! Giving the bottom / tops of only the right desired pressure values. Interpolating from pressure + ! values and using then the geopotential to get the right height, as a way to be more precise + bthgts(1,1) = topo + DO k=2, Nrightlevs + + ! p-height of the cell + botpressv = 0.5*(rightdespressv(k) + rightdespressv(k-1)) + + ! Interprolation + bthgts(k,1) = interpolate1D(dz, oripres, orihgt, botpressv) + bthgts(k-1,2) = bthgts(k,1) + END DO + bthgts(Nrightlevs,2) = oribthgt(dzstag) + + DEALLOCATE(oribthgt) + + RETURN + + END SUBROUTINE presbars_to_hgtbars + + REAL FUNCTION interpolate1D(Nvals, xvals, yvals, xpos) + ! Function to interpolate 1D value + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nvals + REAL, DIMENSION(Nvals), INTENT(in) :: xvals, yvals + REAL, INTENT(in) :: xpos + + ! Local + INTEGER :: i + REAL :: dx, dy, a, b + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! Nvals: Amount of values to use for the interpolation +! xvals: x-axis positions +! yvals: y-axis values +! xpos: position at which we want to interpolate + + fname = 'interpolate1D' + + interpolate1D = 1.e20 + + IF (xvals(2) > xvals(1)) THEN + DO i=1, Nvals-1 + IF (xvals(i) <= xpos .AND. xvals(i+1) > xpos) THEN + dx = xvals(i+1)-xvals(i) + dy = yvals(i+1)-yvals(i) + a = (xvals(i+1)*yvals(i)-xvals(i)*yvals(i+1))/dx + b = dy/dx + interpolate1D = a + xpos*b + EXIT + END IF + END DO + ELSE + DO i=1,Nvals + IF (xvals(i) > xpos .AND. xvals(i+1) <= xpos) THEN + dx = xvals(i)-xvals(i+1) + dy = yvals(i)-yvals(i+1) + a = (xvals(i)*yvals(i+1)-xvals(i+1)*yvals(i))/dx + b = dy/dx + interpolate1D = a + xpos*b + EXIT + END IF + END DO + END IF + + RETURN + + END FUNCTION interpolate1D + +!#endif + END MODULE module_diag_pld #endif diff --git a/phys/module_diagnostics_driver.F b/phys/module_diagnostics_driver.F index aa583b505f..a56eeb7e95 100644 --- a/phys/module_diagnostics_driver.F +++ b/phys/module_diagnostics_driver.F @@ -34,6 +34,10 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & DO_SOLAR_OUTPUT, & PARAM_FIRST_SCALAR, & P_QG, P_QH, P_QV, P_QC, P_QI, P_QS, & +!#ifdef CORDEXDIAG +! L. Fita. CIMA Dec. 2017 + P_QR, & +!#endif P_QNG, P_QH, P_QNH, P_QR, P_QNR, P_QVOLG, & F_QV, F_QC, F_QI, F_QS, & KESSLERSCHEME, LINSCHEME, SBU_YLINSCHEME, WSM3SCHEME, WSM5SCHEME, & @@ -61,8 +65,11 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & model_config_rec USE module_streams - USE module_utility, ONLY : WRFU_Time - +!#ifdef CORDEXDIAG + USE module_utility +!#else +! USE module_utility, ONLY : WRFU_Time +!#endif !============================================================= ! USE Association for the Diagnostic Packages !============================================================= @@ -78,6 +85,10 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & USE module_diag_hailcast, ONLY : hailcast_diagnostic_driver USE module_diag_solar, ONLY : solar_diag USE module_trad_fields, ONLY : trad_fields +!#ifdef CORDEXDIAG +! CORDEX diagnostics. CIMA Dec.17 + USE module_diag_cordex, ONLY: cordex_output_calc, cordex_hf_output_calc +!#endif IMPLICIT NONE @@ -170,6 +181,21 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & ! Current time associated with current simulation step (RASM_DIAGS) TYPE(WRFU_Time) :: currentTime +!#ifdef CORDEXDIAG +! CORDEX diagnostics. CIMA Dec.17 + INTEGER :: rc + LOGICAL :: is_output_t, is_pinterp_t + TYPE(WRFU_Time) :: hist_time, aux19_time, aux18_time, & + aux23_time, CurrTime, StartTime + TYPE(WRFU_TimeInterval) :: dtint, histint, aux18int, aux19int, aux23int + CHARACTER(len=256) :: message, timestr + REAL :: inczsoil +!#ifdef CDXWRF + INTEGER :: i + CHARACTER(len=1024) :: msg +!#endif + +!#endif !============================================================= ! Start of executable code @@ -857,6 +883,38 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & ,s_pl = grid%s_pl & ,td_pl = grid%td_pl & ,q_pl = grid%q_pl & +!#ifdef CORDEXDIAG + ,sina = grid%sina & + ,cosa = grid%cosa & + ,psfc = grid%psfc & + ,topo = grid%ht & + ,alt = grid%alt & + ,p_top = config_flags%p_top_requested & + ,iqc=moist(:,:,:,P_QC) & + ,iqr=moist(:,:,:,P_QR) & + ,iqs=moist(:,:,:,P_QS) & + ,iqi=moist(:,:,:,P_QI) & + ,iqg=moist(:,:,:,P_QG) & + ,iqh=moist(:,:,:,P_QH) & + ,hus_pl = grid%hus_pl & + ,w_pl = grid%w_pl & + ,uer_pl = grid%uer_pl & + ,ver_pl = grid%ver_pl & + ,ws_pl = grid%ws_pl & + ,qc_pl = grid%qc_pl & + ,qr_pl = grid%qr_pl & + ,qs_pl = grid%qs_pl & + ,qi_pl = grid%qi_pl & + ,qg_pl = grid%qg_pl & + ,qh_pl = grid%qh_pl & + ,qv_pl_mc = grid%qv_pl_mc & + ,qc_pl_mc = grid%qc_pl_mc & + ,qr_pl_mc = grid%qr_pl_mc & + ,qs_pl_mc = grid%qs_pl_mc & + ,qi_pl_mc = grid%qi_pl_mc & + ,qg_pl_mc = grid%qg_pl_mc & + ,qh_pl_mc = grid%qh_pl_mc & +!#endif ! Dimension arguments ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde & ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme & @@ -1212,9 +1270,404 @@ SUBROUTINE diagnostics_driver ( grid, config_flags, & kts=k_start, kte=min(k_end,kde-1), num_tiles=grid%num_tiles ) END IF SOLAR_FIELDS +!#ifdef CORDEXDIAG +! CORDEX diagnostics. CIMA Dec.17 - END SUBROUTINE diagnostics_driver + ! CORDEX-oriented diagnostic quantities. + + CORDEX_DIAGS : IF ( config_flags%output_cordex == 1 ) THEN + IF ( ( config_flags%auxhist19_interval == 0 ) ) THEN + WRITE (diag_message , * ) & + "CORDEX: ERROR -- error -- ERROR -- error : NO 'auxhist19_interval' has been defined in 'namelist.input'" + CALL wrf_error_fatal ( diag_message ) + END IF + + CALL wrf_debug ( 100 , '--> CALL DIAGNOSTICS PACKAGE: CORDEX DIAGNOSTICS' ) + ! Do not forget, CDXWRF initialization in phys/module_physics_init.F at SUBROUTINE cdxwrf_init + + ! From AFWA diagnostics ... + CALL WRFU_ALARMGET( grid%alarms( HISTORY_ALARM ), prevringtime=hist_time, & + ringinterval=histint) + CALL WRFU_ALARMGET( grid%alarms(AUXHIST19_ALARM), prevringtime=aux19_time, ringinterval=aux19int) + CALL domain_clock_get ( grid, current_time=CurrTime, simulationStartTime=StartTime, & + current_timestr=timestr, time_step=dtint ) + !is_output_t = ( Currtime .GE. hist_time + histint - dtint .OR. & + ! Currtime .ge. aux19_time + aux19int - dtint ) + is_output_t = ( Currtime .ge. aux19_time + aux19int - dtint ) + ! Complementary way... + !is_output_t=(MOD(NINT((curr_secs2+grid%dt)/grid%dt),NINT(config_flags%auxhist19_interval*60./grid%dt))==0 .OR. curr_secs2==0.) + + IF (is_output_t) THEN + grid%cdxlon = grid%xlong + grid%cdxlat = grid%xlat + grid%cdxps = grid%psfc + grid%cdxts = grid%tsk +!#ifdef CDXWRF +!#if CDXWRF>=4 + !! INSTVALS: Instantaneous values (uncomment and re-compile) +! grid%cdxdiabh = grid%diab_h +!#endif +!#endif + END IF + + CALL cordex_output_calc( & + is_restart=config_flags%restart & + ,is_output_time = is_output_t & + ,cdxH=config_flags%auxhist19_interval & +! ,DT=grid%dt & + ,DT=REAL(model_config_rec%dt(grid%id)) & + ,XTIME=grid%xtime,CURR_SECS2=curr_secs2 & + ,RADT=config_flags%radt & + ,PSL_DIAG=config_flags%psl_diag & + ,WSGS_DIAG=config_flags%wsgs_diag & + ,PTARGET=config_flags%ptarget & + ,PSMOOTH=config_flags%psmooth & + ,WBOUT = config_flags%output_wb & + ,WSZ100_DIAG=config_flags%wsz100_diag & + ,ZHGTZW = config_flags%z100m_wind & + ,Z50_DIAG=config_flags%z50m & + ,DQV = config_flags%zmlagen_dqv & + ,DTHETA = config_flags%zmlagen_dtheta & + ,POTEVAP_DIAG = config_flags%potevp_diag & + ,CONVXTRM_DIAG = config_flags%convxtrm_diag & + ,VISIBILITY_DIAG = config_flags%fogvisibility_diag & + ,FOGVARS = config_flags%fogvars & + ,ZMLAGEN_DIAG = config_flags%zmlagen_diag & + ,TIMEDBG = config_flags%timedbg & + ,LONDBG = config_flags%londbg & + ,LATDBG = config_flags%latdbg & + ,IDBG=grid%ijdbg(1), JDBG=grid%ijdbg(2) & + ,WGSTS_WBDSWSSTRES = config_flags%wgsts_wbdswsstres & +!#ifdef CDXWRF +!#if CDXWRF>=3 + ,NHTASRNG = config_flags%nhtasrng & + ,NHHURSRNG = config_flags%nhhursrng & + ,NLTASRNG = config_flags%nltasrng & + ,NLHURSRNG = config_flags%nlhursrng & + ,NWBDSRNG = config_flags%nwbdsrng & + ,NWSSRNG = config_flags%nwssrng & + ,NHTASHURSRNG = config_flags%nhtashursrng & + ,NLTASHURSRNG = config_flags%nltashursrng & + ,NWBDSWSSRNG = config_flags%nwbdswssrng & +! Should I keep it this? +! ,TASHRNG = grid%htasbins(1:model_config_rec%nhtasrng-1) & +! ,HURSHRNG = grid%hhursbins(1:model_config_rec%nhhursrng-1) & +! ,TASLRNG = grid%ltasbins(1:model_config_rec%nltasrng-1) & +! ,HURSLRNG = grid%lhursbins(1:model_config_rec%nlhursrng-1) & + ,TASHRNG = model_config_rec%htasrng(1:model_config_rec%nhtasrng) & + ,HURSHRNG = model_config_rec%hhursrng(1:model_config_rec%nhhursrng) & + ,TASLRNG = model_config_rec%ltasrng(1:model_config_rec%nltasrng) & + ,HURSLRNG = model_config_rec%lhursrng(1:model_config_rec%nlhursrng) & + ,WBDSRNG = model_config_rec%wbdsrng(1:model_config_rec%nwbdsrng) & + ,WSSRNG = model_config_rec%wssrng(1:model_config_rec%nwssrng) & +!#endif +!#endif + + ! Input + ,LON=grid%xlong, LAT=grid%xlat & + ,CLDFRA=grid%cldfra, p8w=p8w, P=grid%p, PB=grid%pb & + ,PCLT=grid%pclt & + ,PCLL=grid%pcll, PCLM=grid%pclm, PCLH=grid%pclh & + ,QV=moist(:,:,:,P_QV), QC=moist(:,:,:,P_QC) & + ,QR=moist(:,:,:,P_QR), QS=moist(:,:,:,P_QS) & + ,QI=moist(:,:,:,P_QI), QG=moist(:,:,:,P_QG) & + ,QH=moist(:,:,:,P_QH) & + ,MU=grid%mu_2, MUB=grid%mub, DETA=-grid%dnw & + ,SINA=grid%sina, COSA=grid%cosa & +! Which one should be used? +! ,U=grid%u_2, V=grid%v_2, T=grid%t_2 & +! t_phy already as temperature!! not potential temperature! + ,U=grid%u_phy, V=grid%v_phy, T=grid%t_phy & + ,THp=grid%th_phy_m_t0 & + ,PH=grid%ph_2, PHB=grid%phb, P_PHY=p_phy & + ,U10=grid%u10, V10=grid%v10 & + ,Q2=grid%q2, T2=grid%t2, TH2=grid%th2 & + ,PS=grid%psfc, QSFC=grid%qsfc & + ,HGT=grid%ht, Z=grid%z & + ,DZS=grid%dzs, SMOIS=grid%smois, SH2O=grid%sh2o & + ,TKE=grid%tke_pbl, PBLH=grid%pblh & + ,PRC=grid%raincv, PRNC=grid%rainncv, PRSH=grid%rainshv & + ,UST=grid%ust, ZNT=grid%znt, ROL=grid%rmol & + ,SWDOWN=grid%swdown & + ,CD=grid%cd & + ,GLW=grid%glw, LH=grid%lh, HFX=grid%hfx & + ,SWUPB=grid%swupb, LWUPB=grid%lwupb, QFX=grid%qfx & + ,SNOW=grid%snow, SNOWH=grid%snowh, SNOWC=grid%snowc & + ,SFCRUNOFF=grid%sfcrunoff, UDRUNOFF=grid%udrunoff & + ,RHO=grid%rho & + ,SWDNT=grid%swdnt, SWUPT=grid%swupt, LWUPT=grid%lwupt & + ,TS=grid%tsk, ALBEDO=grid%albedo & + ,EMISS=grid%emiss & + ,SR=grid%sr & + ! we are going to assume that drag coefficients for momentum and heat are the same + ! it is scheme dependent, but at his level we are going simple + ! From Registry/Regisyty,EM_COMMON + ! "ch" "surface exchange coeff for heat" "m s-1" + ! We need to transform from surface exchange coefficients to drag coefficients for + ! the tas_hm, qvs_hm diagnostics + ! QCDRAGH = CHS/wspd + ! WRF does not provide the surface exchange coefficient of momentum (not for all + ! sfclay schemes), therefore the generic one (already in CDXWRF as cdgen) will + ! be used as + ! CDM = (ust/wss)**2 + ,CHS=grid%ch, CDM=grid%cd, BR=grid%br, ZOL=grid%zol & + ,FRACSOIL10CM=grid%fracsoil10cm & +!#ifdef CDXWRF +!#if CDXWRF>=1 + +!#elif CDXWRF>=4 + ,DIABH=grid%h_diabatic & + ,QVTTEND=grid%qvttend, QCTTEND=grid%qcttend & + ,QRTTEND=grid%qrttend, QSTTEND=grid%qsttend & + ,QITTEND=grid%qittend, QGTTEND=grid%qgttend & + ,QHTTEND=grid%qhttend & + ,QVHADV=grid%qv_hadv, QCHADV=grid%qc_hadv & + ,QRHADV=grid%qr_hadv, QSHADV=grid%qs_hadv & + ,QIHADV=grid%qi_hadv, QGHADV=grid%qg_hadv & + ,QHHADV=grid%qh_hadv & + ,QVZADV=grid%qv_zadv, QCZADV=grid%qc_zadv & + ,QRZADV=grid%qr_zadv, QSZADV=grid%qs_zadv & + ,QIZADV=grid%qi_zadv, QGZADV=grid%qg_zadv & + ,QHZADV=grid%qh_zadv & +!#endif +!#endif + ! Output + ,NSTEPS=grid%cdxnsteps & + ,CLTMEAN=grid%cltmean, CLLMEAN=grid%cllmean & + ,CLMMEAN=grid%clmmean, CLHMEAN=grid%clhmean & + ,PRW=grid%prw, CLWVI=grid%clwvi, CLIVI=grid%clivi & + ,UAS=grid%uas, VAS=grid%vas & + ,WSS=grid%wss, WBDS=grid%wbds & + ,HURS=grid%hurs ,HUSS=grid%huss & + ,PSL=grid%psl & + ,WSGSMAX=grid%wsgsmax & + ,UGSMAX=grid%ugsmax, VGSMAX=grid%vgsmax & + ,PERCENGUST=grid%wsgspercen & + ,TOTWSGSMAX=grid%totwsgsmax & + ,TOTUGSMAX=grid%totugsmax, TOTVGSMAX=grid%totvgsmax & + ,TOTPERCENGUST=grid%totwsgspercen & + ,WSZ100=grid%wsz100 & + ,UZ100WIND=grid%uz100, VZ100WIND=grid%vz100 & + ,WSZ50=grid%wsz50 & + ,UZ50WIND=grid%uz50, VZ50WIND=grid%vz50 & + ,TAZ50=grid%taz50, QVZ50=grid%qvz50 & + ,WSZ100MAX=grid%wsz100max & + ,UZ100MAX=grid%uz100max, VZ100MAX=grid%vz100max & + ,SUNSHINE=grid%sund & + ,TAUU=grid%tauu, TAUV=grid%tauv & + ,TAUUGEN=grid%tauugen, TAUVGEN=grid%tauvgen & + ,RSDS=grid%rsds, RLDS=grid%rlds, HFLS=grid%hfls & + ,HFSS=grid%hfss, RSUS=grid%rsus, RLUS=grid%rlus & + ,RSUSGEN=grid%rsusgen, RLUSGEN=grid%rlusgen & + ,EVSPSBL=grid%evspsbl, EVSPSBLPOT=grid%evspsblpot & + ,EVSPSBLPOTGEN=grid%evspsblpotgen & + ,CDCDX=grid%cdcdx, CDGEN=grid%cdgen & + ,SNC=grid%snc, SND=grid%snd & + ,PMRROS=grid%pmrros, PMRRO=grid%pmrro & + ,MRROS=grid%mrros, MRRO=grid%mrro, MRSO=grid%mrso & + ,MRSOL=grid%mrsol, MRSOS=grid%mrsos & + ,MRSLL=grid%mrsll, MRLSO=grid%mrlso,MRLSOS=grid%mrlsos & + ,MRSFL=grid%mrsfl, MRFSO=grid%mrfso,MRFSOS=grid%mrfsos & + ,MRSOMEAN=grid%mrsomean, MRSOLMEAN=grid%mrsolmean & + ,MRSOSMEAN=grid%mrsosmean & + ,MRSLLMEAN=grid%mrsllmean, MRLSOMEAN=grid%mrlsomean & + ,MRLSOSMEAN=grid%mrlsosmean & + ,MRSFLMEAN=grid%mrsflmean, MRFSOMEAN=grid%mrfsomean & + ,MRFSOSMEAN=grid%mrfsosmean & + ,FLXPR=grid%pr, FLXPRL=grid%prl,FLXPRC=grid%prc & + ,FLXPRSH=grid%prsh & + ,FLXPRSN=grid%prsn & + ,SNW=grid%snw & + ,RSDT=grid%rsdt, RSUT=grid%rsut, RLUT=grid%rlut & + ,TAS_HM=grid%tas_hm, QVS_HM=grid%qvs_hm & +!#ifdef CDXWRF +!#if CDXWRF>=1 + ,CLGVI=grid%clgvi, CLHVI=grid%clhvi & + ,ZMLA=grid%zmlagen & + ,CAPEMIN=grid%capemin, CINMIN=grid%cinmin & + ,ZLFCMIN=grid%lfczmin, PLFCMIN=grid%lfcpmin & + ,LIDXMIN=grid%limin & + ,CAPEMAX=grid%capemax, CINMAX=grid%cinmax & + ,ZLFCMAX=grid%lfczmax, PLFCMAX=grid%lfcpmax & + ,CAPEMEAN=grid%capemean, CINMEAN=grid%cinmean & + ,ZLFCMEAN=grid%lfczmean, PLFCMEAN=grid%lfcpmean & + ,LIDXMAX=grid%limax & + ,LIDXMEAN=grid%limean & + ,IUTMEAN=grid%iutmean, IVTMEAN=grid%ivtmean & + ,ZEROITH=grid%zeroisotherm & +!#endif +!#if CDXWRF>=2 + ,UA=grid%ua, VA=grid%va, WS=grid%ws, TA=grid%ta & + ,PRESS=grid%press, ZG=grid%zg & + ,HUR=grid%hur, HUS=grid%hus & + ,TFOG=grid%tfog, FOGVISBLTYMIN=grid%fogvisbltymin & + ,FOGVISBLTYMAX=grid%fogvisbltymax & + ,FOGVISBLTYMEAN=grid%fogvisbltymean & + ,TDSMIN=grid%tdsmin, TDSMAX=grid%tdsmax & + ,TDSMEAN=grid%tdsmean & + ,TWSMIN=grid%twsmin, TWSMAX=grid%twsmax & + ,TWSMEAN=grid%twsmean & +!#endif +!#if CDXWRF>=4 + !! Water-budget + ,WBACDH=grid%wbacdiabh & + ,WBACPW=grid%wbacpw, WBACPWC=grid%wbacpwc & + ,WBACPWR=grid%wbacpwr, WBACPWS=grid%wbacpws & + ,WBACPWI=grid%wbacpwi, WBACPWG=grid%wbacpwg & + ,WBACPWH=grid%wbacpwh & + ,WBACF=grid%wbacf, WBACFC=grid%wbacfc & + ,WBACFR=grid%wbacfr, WBACFS=grid%wbacfs & + ,WBACFI=grid%wbacfi, WBACFG=grid%wbacfg & + ,WBACFH=grid%wbacfh & + ,WBACZ=grid%wbacz, WBACZC=grid%wbaczc & + ,WBACZR=grid%wbaczr, WBACZS=grid%wbaczs & + ,WBACZI=grid%wbaczi, WBACZG=grid%wbaczg & + ,WBACZH=grid%wbaczh & + ! Low-medium-high + ,WBACDHL=grid%wbacdiabhl, WBACDHM=grid%wbacdiabhm & + ,WBACDHH=grid%wbacdiabhh & + ,WBACPWLV=grid%wbacpwlv, WBACPWMV=grid%wbacpwmv & + ,WBACPWHV=grid%wbacpwhv, WBACFLV=grid%wbacflv & + ,WBACFMV=grid%wbacfmv, WBACFHV=grid%wbacfhv & + ,WBACZLV=grid%wbaczlv, WBACZMV=grid%wbaczmv & + ,WBACZHV=grid%wbaczhv & + ,WBACPWLC=grid%wbacpwlc, WBACPWMC=grid%wbacpwmc & + ,WBACPWHC=grid%wbacpwhc, WBACFLC=grid%wbacflc & + ,WBACFMC=grid%wbacfmc, WBACFHC=grid%wbacfhc & + ,WBACZLC=grid%wbaczlc, WBACZMC=grid%wbaczmc & + ,WBACZHC=grid%wbaczhc & + ,WBACPWLR=grid%wbacpwlr, WBACPWMR=grid%wbacpwmr & + ,WBACPWHR=grid%wbacpwhr, WBACFLR=grid%wbacflr & + ,WBACFMR=grid%wbacfmr, WBACFHR=grid%wbacfhr & + ,WBACZLR=grid%wbaczlr, WBACZMR=grid%wbaczmr & + ,WBACZHR=grid%wbaczhr & + ,WBACPWLS=grid%wbacpwls, WBACPWMS=grid%wbacpwms & + ,WBACPWHS=grid%wbacpwhs, WBACFLS=grid%wbacfls & + ,WBACFMS=grid%wbacfms, WBACFHS=grid%wbacfhs & + ,WBACZLS=grid%wbaczls, WBACZMS=grid%wbaczms & + ,WBACZHS=grid%wbaczhs & + ,WBACPWLI=grid%wbacpwli, WBACPWMI=grid%wbacpwmi & + ,WBACPWHI=grid%wbacpwhi, WBACFLI=grid%wbacfli & + ,WBACFMI=grid%wbacfmi, WBACFHI=grid%wbacfhi & + ,WBACZLI=grid%wbaczli, WBACZMI=grid%wbaczmi & + ,WBACZHI=grid%wbaczhi & + ,WBACPWLG=grid%wbacpwlg, WBACPWMG=grid%wbacpwmg & + ,WBACPWHG=grid%wbacpwhg, WBACFLG=grid%wbacflg & + ,WBACFMG=grid%wbacfmg, WBACFHG=grid%wbacfhg & + ,WBACZLG=grid%wbaczlg, WBACZMG=grid%wbaczmg & + ,WBACZHG=grid%wbaczhg & + ,WBACPWLH=grid%wbacpwlh, WBACPWMH=grid%wbacpwmh & + ,WBACPWHH=grid%wbacpwhh, WBACFLH=grid%wbacflh & + ,WBACFMH=grid%wbacfmh, WBACFHH=grid%wbacfhh & + ,WBACZLH=grid%wbaczlh, WBACZMH=grid%wbaczmh & + ,WBACZHH=grid%wbaczhh & +!#endif +!#if CDXWRF>=3 + ,TASHURSTRESHIGHRES=grid%tashurstreshighres & + ,TASHURSTRESLOWRES=grid%tashurstreslowres & + ,WBDSWSSTRES=grid%wbdswsstres & +!#endif +!#endif + ! Dimension arguments + ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde & + ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme & + ,IPS=ips,IPE=ipe, JPS=jps,JPE=jpe, KPS=kps,KPE=kpe & + ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1) & + ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1) & + ,KTS=k_start, KTE=k_end & + ,NUM_TILES=grid%num_tiles & + ,NUM_SOIL_LAYERS=grid%num_soil_layers & + ,N_MOIST=num_moist & + ,M_QV=p_qv, M_QC=p_qc, M_QR=p_qr, M_QS=p_qs & + ,M_QI=p_qi, M_QG=p_qg, M_QH=p_qh & +!!! INSTVALS: Instantaneous values (uncomment and re-compile) +!! ,CLT=grid%clt & +!! ,CLL=grid%cll, CLM=grid%clm, CLH=grid%clh & +!! ,WSGS=grid%wsgs, UGUSTWIND=grid%usgs & +!! ,VGUSTWIND=grid%vsgs, GUSTPOINT=grid%gustpoint & +!! ,TOTWSGS=grid%totwsgs, TOTUGUSTWIND=grid%totusgs & +!! ,TOTVGUSTWIND=grid%totvsgs & +!! ,TOTGUSTPOINT=grid%totgustpoint & +!! ,POTEVAPO=grid%potevapo & +!! ,POTEVAPOGEN=grid%potevapogen & +!#ifdef CDXWRF +!#if CDXWRF>=1 +!! ,CAPE=grid%cdxcape & +!! ,CIN=grid%cin, ZLFC=grid%lfcz & +!! ,PLFC=grid%lfcp, LIDX=grid%li & +!#endif +!#if CDXWRF>=2 +!! ,FOG=grid%fog, FOGVISBLTY=grid%fogvisblty & +!! ,TDS=grid%tds, TWS=grid%tws & +!#endif +!#endif +!!! End of INSTVALS + ) + +!! +! High-frequency CORDEX diagnostics +!! + ! Only to be computed if an interval is provided + IF ( ( config_flags%auxhist18_interval /= 0 ) ) THEN + + CALL wrf_debug ( 100 , '--> CALL DIAGNOSTICS PACKAGE: High-Frequency CORDEX DIAGNOSTICS' ) + + ! From AFWA diagnostics ... + CALL WRFU_ALARMGET( grid%alarms( HISTORY_ALARM ), prevringtime=hist_time, & + ringinterval=histint) + CALL WRFU_ALARMGET( grid%alarms(AUXHIST18_ALARM), prevringtime=aux18_time, ringinterval=aux18int) + CALL domain_clock_get ( grid, current_time=CurrTime, simulationStartTime=StartTime, & + current_timestr=timestr, time_step=dtint ) + is_output_t = ( Currtime .ge. aux18_time + aux18int - dtint ) + + IF (is_output_t) THEN + grid%cdxlon = grid%xlong + grid%cdxlat = grid%xlat + END IF + + CALL cordex_hf_output_calc( & + is_restart=config_flags%restart & + ,is_output_time = is_output_t & + ,cdxH=config_flags%auxhist18_interval & +! ,DT=grid%dt & + ,DT=REAL(model_config_rec%dt(grid%id)) & + ,XTIME=grid%xtime,CURR_SECS2=curr_secs2 & + + ! Input + ,LON=grid%xlong, LAT=grid%xlat & + ,TIMEDBG = config_flags%timedbg & + ,LONDBG = config_flags%londbg & + ,LATDBG = config_flags%latdbg & + ,IDBG=grid%ijdbg(1), JDBG=grid%ijdbg(2) & + ,QR=moist(:,:,:,P_QR), QS=moist(:,:,:,P_QS) & + ,QG=moist(:,:,:,P_QG) & + ,T=grid%t_phy & + ,PRC=grid%raincv, PRNC=grid%rainncv, PRSH=grid%rainshv & + ,RHO=grid%rho & + ! Output + ,nsteps=grid%cdxhfnsteps & +!#if CDXWRF>=1 + ,FLXPR=grid%prhf, COLMAX=grid%colmax & +!#endif + ! Dimension arguments + ,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde & + ,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme & + ,IPS=ips,IPE=ipe, JPS=jps,JPE=jpe, KPS=kps,KPE=kpe & + ,I_START=grid%i_start,I_END=min(grid%i_end, ide-1) & + ,J_START=grid%j_start,J_END=min(grid%j_end, jde-1) & + ,KTS=k_start, KTE=k_end & + ,NUM_TILES=grid%num_tiles & + ) + + ! End if for auxhist18 value + END IF + + END IF CORDEX_DIAGS + +!#endif + + END SUBROUTINE diagnostics_driver SUBROUTINE update_phys_fields ( grid, config_flags, moist, & diff --git a/phys/module_diagvar_cordex.F b/phys/module_diagvar_cordex.F new file mode 100644 index 0000000000..f5f317639e --- /dev/null +++ b/phys/module_diagvar_cordex.F @@ -0,0 +1,4447 @@ +MODULE module_diagvar_cordex +! Module with the specific subroutines and functions to compute the CORDEX required variables +! L. Fita, CIMA. December 2017 +! + USE module_model_constants + +!! These are the definition of parameters used in the calculations +! They might be placed on the general WRF's share/module_model_constants.F ... ? + ! Current version of the module + CHARACTER(LEN=50) :: cdxwrfversion = '3.1' + + INTEGER, PARAMETER :: r_k = KIND(1.d0) + + REAL(r_k), PARAMETER :: ZEPSEC=1.0D-12 +! Low limit pressure for medium clouds [Pa] + REAL(r_k), PARAMETER :: prmhc = 44000.d0 +! Low limit pressure for High clouds [Pa] + REAL(r_k), PARAMETER :: prmlc = 68000.d0 +! Real values for cloud intervals + REAL, PARAMETER :: prmhcR = prmhc*1. + REAL, PARAMETER :: prmlcR = prmlc*1. +! August-Roche-Magnus approximation + REAL, PARAMETER :: ARM1 = 6.1094 + REAL, PARAMETER :: ARM2 = 17.625 + REAL, PARAMETER :: ARM3 = 243.04 + +! Ratio between molecular weights of water and dry air + REAL, PARAMETER :: mol_watdry = 0.622 +! Standard atmospheric lapse-rate [Km-1] + REAL, PARAMETER :: gammav=6.5e-3 + + REAL(r_k), PARAMETER :: zeroRK=0.d0 + REAL(r_K), PARAMETER :: halfRK=0.5d0 + REAL(r_K), PARAMETER :: oneRK=1.d0 + REAL(r_k), PARAMETER :: twoRK=2.d0 +! FillValue + REAL, PARAMETER :: fillValueR=1.e20 + + CHARACTER(LEN=50) :: sfname, IS, RS + CHARACTER (LEN=256) :: message + CHARACTER (LEN=1000) :: Lmessage + +! Zero +! REAL, PARAMETER :: zero=10.e-6 + +! null value + REAL(r_k) :: nullv = 1.e-7 + !REAL(r_k) :: nullv = 1.d-15 + + CONTAINS + +!!! +! Variables +!!! +! Cdrag_0: first order generic approximation of the drag coefficient +! Theta: potential temperature +! Thetae: equivalent potential temperature +! The2T: temperature at any pressure level along a saturation adiabat +! VirtualTemperature: virtual temperature +! SaturationMixingRatio: saturation mixing ratio +! TLCL: Temperature of a parcel of air would have dry adiabatically lifted to it's lcl +! VirtPotTemp: Function to compute virtual potential temperature + +!!!!!!! diagnosted variables +! var_bulk_Ri: Subroutine to compute the bulk Richardson number at all the space +! var_cape_afwa: CAPE following AFWA methodology +! var_cllmh: low, medium, high-cloud [0,100] +! var_clt: total cloudiness [0,100] +! var_colmax1D: Subroutine to compute 1D maximum radar reflectivity +! var_fog_K84: Computation of fog and visibility following Kunkel, (1984) +! var_fog_RUC: Computation of fog and visibility following RUC method Smirnova, (2000) +! var_fog_FRAML50: fog and visibility following Gultepe and Milbrandt, (2010) +! var_hur: relative humidity using August-Roche-Magnus approximation [1] +! var_hurs: relative humidity at 2m using August-Roche-Magnus approximation [1] +! var_hus: specific humidity [1] +! var_huss: 2m specific humidity [1] +! var_potevap_bulk: potential evapotranspiration following simple bulk formulation +! var_potevap_Milly92: potential bulk evapotranspiration with Milly 1992 correction +! var_potevap_bulkgen: generic potential evapotranspiration following simple bulk formulation +! var_potevap_Milly92gen: genreic potential bulk evapotranspiration with Milly 1992 correction +! var_press: air pressure [Pa] +! var_psl_ecmwf: sea level pressure using ECMWF method +! var_psl_ptarget: mean sea level pressure using a target pressure +! var_psl_shuell: mean sea level pressure using the hydrostatic equation with the Shuell correction +! var_massvertint: Subroutine to vertically integrate a 1D variable in eta vertical coordinates +! var_vertint: Subroutine to vertically integrate a 1D variable in any vertical coordinates +! var_residencetime_2var2D: Subroutine to compute the time of residence of two 2D variables for a +! single time-step +! var_ta: air temperature [K] +! var_tav: Function for variable virtual temperature including solid water species +! var_tds: dew point temperature at 2m using August-Roche-Magnus approximation [K] +! var_tws_S11: Subroutine to compute wet bulb temperature using equation after Stull, R. (2011) [K] +! var_uava: earth-rotated wind components [ms-1] +! var_uasvas: 10m earth-rotated wind components [ms-1] +! var_zg: geopotential height [m] +! var_zmla_generic: pbl-height following a generic method [m] +! var_zmla_RIgen: Subroutine to compute the pbl height using bulk Richardson number +! var_ztaqv_MOtheor: Subroutine of temperature and water vapour extrapolation following Moin-Obukhov +! Similarity theory +! var_zwind: extrapolate the wind at a given height following the 'power law' methodology +! var_zwind_log: extrapolate the wind at a given height following the 'logarithmic law' methodology +! var_zwind_MOtheor: wind extrapolation following Moin-Obukhov theory +! water_budget: Subroutine to compute accumulated water budget +! gustwind_Brasseur01: Wind gust following Brasseur (2001), MWR. +! gustwind_afwa: Wind gust following heavy precip methodology +! stabfunc_scalar_businger: Subroutine of the stability function after Businger et al. (1971), JAS, +! 28(2), 181-189 +! univ_func_scal_Businger71: Subroutine of the universal functions for scalars according to Businger +! 1971 +! zero_isotherm1D: Function to compute 1D 0-isotherm + +!!! +! Operations +!!! +! interval_agg: Subroutine to compute aggregation by intervals along the full axis of of mass-values +! massconserv_vinterp1D: Subrotine to mass-conservative vertically interpolate a variable 1D +! moist_group: Subroutine to group 1D values from each water-species to a single variable +! moist_group2D: Subroutine to group 2D values from each water-species to a single variable +! moist_redistribute: Subroutine to re-distribute a multi water-species 1D value to each specie +! moist_redistribute2D: Subroutine to re-distribute a multi water-species 2D value to each specie +! NumIntegration: Subroutine to compute numerical integrations according to the trapezoidal methodology +! partial_agg: Subroutine to compute a partial aggregation of mass-values between an interval +! presbars_to_hgtbars: Subroutine to transform from desired bars defined by their central pressures to +! bars in height coordinates using model's geopotential to define its heights + +!!! +! ORCHIDEE related diagnostics (version 2 inclusion) +!!! +! coefcdrag1D: 1D copmutation of the drag coefficients for momentum, sensible and latent heat fluxs, +! neutral and the Richardson number between the surface and the reference level and the pressure at +! the refernce level +! SFCDIAGS_ORCHIDEE1D: 1D Surface diagnostics of t2 and q2 from the ORCHIDEE land model +! screenc1D: 1D correction to the wind, potential temperature and specific humidity anomalies at the +! reference level zref, and relatively to the first level (for wind) o to the surface (for the +! potential temperature and humidity +! screenp1D: 1D forecaster of the wind, potential temperature and specific humidity anomalies at the +! reference level zref, and relatively to the first level (for wind) o to the surface (for the +! potential temperature and humidity from Dyer-Businger relations + + +!!! +! Variables +!!! + + SUBROUTINE var_colmax1D(dz, rho, t_phy, qr, qs, qg, refd_max) + ! Subroutine to compute 1D maximum radar reflectivity + ! Folllowing code from phys/module_diag_afwa.F in WRF v4.3.1 + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, dimension(dz), INTENT(in) :: rho, t_phy, qr, qs, qg + + REAL, INTENT(inout) :: refd_max + + ! Local + INTEGER :: k, ktop + + REAL :: refd, refd_com + REAL, dimension(dz) :: z_e + + ! From subroutine wrf_dbzcalc + REAL :: factor_r, factor_s, factor_g, factorb_s, & + factorb_g, ronv, sonv, gonv + REAL :: temp_c, rhoair, qgr, qra, qsn + INTEGER, PARAMETER :: iBrightBand = 1 + REAL, PARAMETER :: T_0 = 273.15 + REAL, PARAMETER :: PI = 3.1415926536 + REAL, PARAMETER :: rgas=287.04, gamma_seven = 720.0, & + alpha2 = 0.224 + + !! Densities of rain, snow, graupel, and cloud ice. + !! ------------------------------------------------ + REAL, PARAMETER :: rho_w = 1000.0, rho_r = 1000.0, rho_s = 100.0 + REAL, PARAMETER :: rho_g = 400.0, rho_i = 890.0 + REAL, PARAMETER :: ron=8.e6, son=2.e7, gon=5.e7, r1=1.e-15 + REAL, PARAMETER :: ron_min = 8.e6, ron2=1.e10 + REAL, PARAMETER :: ron_qr0 = 0.0001, ron_delqr0 = 0.25*ron_qr0 + REAL, PARAMETER :: ron_const1r = (ron2-ron_min)*0.5 + REAL, PARAMETER :: ron_const2r = (ron2+ron_min)*0.5 + + CHARACTER(len=50) :: fname + +!!!!!! Variables +! dz: amount of vertical levels +! rho: dry air density [kgm-3] +! t_phy: air temperature [K] +! qr: water vapour mixing ratio [kgkg-1] + ! qs: snow mixing ratio [kgkg-1] +! qg: graupel mixing ratio [kgkg-1] +!! See subroutine phy_prep in 'dyn_em/module_big_step_utilities_em.F' +! z: vertical height at half eta-levels [m] z[k] = 0.5*(dz8w[k] + dz8w[k+1]) +! dz8w: distance between full eta-levels [m] dz8w[k+1] = (zg[k+1]-zg[k])/9.81; dz8w[1] = 0. + +! z_e: column radar reflectivity +! refd: reflectivity 1st level +! refd_max: maximum composite reflectivity + + fname = 'var_colmax1D' + + refd_max = 0. + + ! From subroutine wrf_dbzcalc + !! Constant intercepts + !! ------------------- + ronv = 8.e6 ! m^-4 + sonv = 2.e7 ! m^-4 + gonv = 4.e6 ! m^-4 + + factor_r = gamma_seven * 1.e18 * (1./(pi*rho_r))**1.75 + factor_s = gamma_seven * 1.e18 * (1./(pi*rho_s))**1.75 & + * (rho_s/rho_w)**2 * alpha2 + factor_g = gamma_seven * 1.e18 * (1./(pi*rho_g))**1.75 & + * (rho_g/rho_w)**2 * alpha2 + + DO k = 1, dz + + ! From subroutine wrf_dbzcalc + !! Calculate equivalent radar reflectivity factor (z_e) using + !! old RIP code (2004) if running radar or VIL packages. + factorb_s = factor_s + factorb_g = factor_g + + !! In this case snow or graupel particle scatters like liquid + !! water because it is assumed to have a liquid skin + !! ---------------------------------------------------------- + IF( iBrightBand == 1 ) THEN + IF (t_phy(k) > T_0) THEN + factorb_s = factor_s /alpha2 + factorb_g = factor_g /alpha2 + ENDIF + ENDIF + + !! Calculate variable intercept parameters + !! --------------------------------------- + temp_c = amin1(-0.001, t_phy(k)- T_0) + sonv = amin1(2.0e8, 2.0e6*exp(-0.12*temp_c)) + gonv = gon + qgr = qg(k) + qra = qr(k) + qsn = qs(k) + IF (qgr.gt.r1) THEN + gonv = 2.38*(pi*rho_g/(rho(k)*qgr))**0.92 + gonv = max(1.e4, min(gonv,gon)) + ENDIF + ronv = ron2 + IF (qra.gt. r1) THEN + ronv = ron_const1r*tanh((ron_qr0-qra)/ron_delqr0) + ron_const2r + ENDIF + + IF (qra < 0.0 ) qra = 0.0 + IF (qsn < 0.0 ) qsn = 0.0 + IF (qgr < 0.0 ) qgr = 0.0 + z_e(k) = factor_r * (rho(k)*qra)**1.75/ronv**.75 + factorb_s * (rho(k)*qsn)**1.75/sonv**.75 + & + factorb_g * (rho(k)*qgr)**1.75/gonv**.75 + + IF ( z_e(k) < 0.0 ) z_e(k) = 0.0 + + ! From subroutine radar_diagnostics + IF (z_e(k) .gt. 1.e-20) THEN + + !! Reflectivity (first level) + !! -------------------------- + IF (k == 1) refd = MAX(10.0 * log10(z_e(k)),0.) + + ! Composite reflectivity calc (max reflectivity in the column) + ! ------------------------------------------------------------ + IF (10.0 * log10(z_e(k)) .gt. refd_max) THEN + refd_max = 10.0 * log10(z_e(k)) + ENDIF + + ENDIF + + END DO + + RETURN + + END SUBROUTINE var_colmax1D + + SUBROUTINE Cdrag_0(ust,uas,vas,Cd) +! Fuction to compute a first order generic approximation of the drag coefficient as +! CD = (ust/wss)**2 +! after, Garratt, J.R., 1992.: The Atmospheric Boundary Layer. Cambridge Univ. Press, +! Cambridge, U.K., 316 pp +! Ackonwledgement: M. A. Jimenez, UIB +! + IMPLICIT NONE + + REAL, INTENT(in) :: ust, uas, vas + REAL, INTENT(out) :: Cd + +!!!!!!! Variables +! ust: u* in similarity theory [ms-1] +! uas, vas: x/y-components of wind at 10 m +! Cd: Drag coefficient [-] + + sfname = 'Cdrag_0' + IF (uas**2 + vas**2 /= 0.) THEN + Cd = ust**2/(uas**2+vas**2) + ELSE + Cd = 0. + END IF + + END SUBROUTINE Cdrag_0 + +! +! L. Fita, CIMA. Jan 2018 +! ---- BEGIN modified from module_diag_afwa.F / module_diag_functions.F ---- ! + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ calc_rh + !~ + !~ Description: + !~ This function calculates relative humidity given pressure, + !~ temperature, and water vapor mixing ratio. + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION calc_rh ( p, t, qv ) result ( rh ) + + IMPLICIT NONE + + REAL, INTENT(IN) :: p, t, qv + REAL :: rh + + ! Local + ! ----- + REAL, PARAMETER :: pq0=379.90516 + REAL, PARAMETER :: a2=17.2693882 + REAL, PARAMETER :: a3=273.16 + REAL, PARAMETER :: a4=35.86 + REAL, PARAMETER :: rhmin=1. + REAL :: q, qs + INTEGER :: i,j,k + + ! Following algorithms adapted from WRFPOST + ! May want to substitute with another later + ! ----------------------------------------- + q=qv/(1.0+qv) + qs=pq0/p*exp(a2*(t-a3)/(t-a4)) + rh=100.*q/qs + IF (rh .gt. 100.) THEN + rh=100. + ELSE IF (rh .lt. rhmin) THEN + rh=rhmin + ENDIF + + END FUNCTION calc_rh + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ Theta + !~ + !~ Description: + !~ This function calculates potential temperature as defined by + !~ Poisson's equation, given temperature and pressure ( hPa ). + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION Theta ( t, p ) + IMPLICIT NONE + + !~ Variable declaration + ! -------------------- + REAL, INTENT ( IN ) :: t + REAL, INTENT ( IN ) :: p + REAL :: theta + + ! Using WRF values + !REAL :: Rd ! Dry gas constant + !REAL :: Cp ! Specific heat of dry air at constant pressure + !REAL :: p00 ! Standard pressure ( 1000 hPa ) + REAL :: Rd, p00 + + !Rd = 287.04 + !Cp = 1004.67 + !p00 = 1000.00 + + Rd = r_d + p00 = p1000mb/100. + + !~ Poisson's equation + ! ------------------ + theta = t * ( (p00/p)**(Rd/Cp) ) + + END FUNCTION Theta + + + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ Thetae + !~ + !~ Description: + !~ This function returns equivalent potential temperature using the + !~ method described in Bolton 1980, Monthly Weather Review, equation 43. + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION Thetae ( tK, p, rh, mixr ) + IMPLICIT NONE + + !~ Variable Declarations + ! --------------------- + REAL :: tK ! Temperature ( K ) + REAL :: p ! Pressure ( hPa ) + REAL :: rh ! Relative humidity + REAL :: mixr ! Mixing Ratio ( kg kg^-1) + REAL :: te ! Equivalent temperature ( K ) + REAL :: thetae ! Equivalent potential temperature + + ! Using WRF values + !REAL, PARAMETER :: R = 287.04 ! Universal gas constant (J/deg kg) + !REAL, PARAMETER :: P0 = 1000.0 ! Standard pressure at surface (hPa) + REAL :: R, p00, Lv + !REAL, PARAMETER :: lv = 2.54*(10**6) ! Latent heat of vaporization + ! (J kg^-1) + !REAL, PARAMETER :: cp = 1004.67 ! Specific heat of dry air constant + ! at pressure (J/deg kg) + REAL :: tlc ! LCL temperature + + R = r_d + p00 = p1000mb/100. + lv = XLV + + !~ Calculate the temperature of the LCL + ! ------------------------------------ + tlc = TLCL ( tK, rh ) + + !~ Calculate theta-e + ! ----------------- + thetae = (tK * (p00/p)**( (R/Cp)*(1.- ( (.28E-3)*mixr*1000.) ) ) )* & + exp( (((3.376/tlc)-.00254))*& + (mixr*1000.*(1.+(.81E-3)*mixr*1000.)) ) + + END FUNCTION Thetae + + + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ The2T.f90 + !~ + !~ Description: + !~ This function returns the temperature at any pressure level along a + !~ saturation adiabat by iteratively solving for it from the parcel + !~ thetae. + !~ + !~ Dependencies: + !~ function thetae.f90 + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION The2T ( thetaeK, pres, flag ) result ( tparcel ) + IMPLICIT NONE + + !~ Variable Declaration + ! -------------------- + REAL, INTENT ( IN ) :: thetaeK + REAL, INTENT ( IN ) :: pres + LOGICAL, INTENT ( INOUT ) :: flag + REAL :: tparcel + + REAL :: thetaK + REAL :: tovtheta + REAL :: tcheck + REAL :: svpr, svpr2 + REAL :: smixr, smixr2 + REAL :: thetae_check, thetae_check2 + REAL :: tguess_2, correction + + LOGICAL :: found + INTEGER :: iter + + ! Using WRF values + !REAL :: R ! Dry gas constant + !REAL :: Cp ! Specific heat for dry air + !REAL :: kappa ! Rd / Cp + !REAL :: Lv ! Latent heat of vaporization at 0 deg. C + REAL :: R, kappa, Lv + + R = r_d + Lv = XLV + !R = 287.04 + !Cp = 1004.67 + Kappa = R/Cp + !Lv = 2.500E+6 + + !~ Make initial guess for temperature of the parcel + ! ------------------------------------------------ + tovtheta = (pres/100000.0)**(r/cp) + tparcel = thetaeK/exp(lv*.012/(cp*295.))*tovtheta + + iter = 1 + found = .false. + flag = .false. + + DO + IF ( iter > 105 ) EXIT + + tguess_2 = tparcel + REAL ( 1 ) + + svpr = 6.122 * exp ( (17.67*(tparcel-273.15)) / (tparcel-29.66) ) + smixr = ( 0.622*svpr ) / ( (pres/100.0)-svpr ) + svpr2 = 6.122 * exp ( (17.67*(tguess_2-273.15)) / (tguess_2-29.66) ) + smixr2 = ( 0.622*svpr2 ) / ( (pres/100.0)-svpr2 ) + + ! ------------------------------------------------------------------ ~! + !~ When this function was orinially written, the final parcel ~! + !~ temperature check was based off of the parcel temperature and ~! + !~ not the theta-e it produced. As there are multiple temperature- ~! + !~ mixing ratio combinations that can produce a single theta-e value, ~! + !~ we change the check to be based off of the resultant theta-e ~! + !~ value. This seems to be the most accurate way of backing out ~! + !~ temperature from theta-e. ~! + !~ ~! + !~ Rentschler, April 2010 ~! + ! ------------------------------------------------------------------ ! + + !~ Old way... + !thetaK = thetaeK / EXP (lv * smixr /(cp*tparcel) ) + !tcheck = thetaK * tovtheta + + !~ New way + thetae_check = Thetae ( tparcel, pres/100., 100., smixr ) + thetae_check2 = Thetae ( tguess_2, pres/100., 100., smixr2 ) + + !~ Whew doggies - that there is some accuracy... + !IF ( ABS (tparcel-tcheck) < .05) THEN + IF ( ABS (thetaeK-thetae_check) < .001) THEN + found = .true. + flag = .true. + EXIT + END IF + + !~ Old + !tparcel = tparcel + (tcheck - tparcel)*.3 + + !~ New + correction = ( thetaeK-thetae_check ) / ( thetae_check2-thetae_check ) + tparcel = tparcel + correction + + iter = iter + 1 + END DO + + !IF ( .not. found ) THEN + ! print*, "Warning! Thetae to temperature calculation did not converge!" + ! print*, "Thetae ", thetaeK, "Pressure ", pres + !END IF + + END FUNCTION The2T + + + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ VirtualTemperature + !~ + !~ Description: + !~ This function returns virtual temperature given temperature ( K ) + !~ and mixing ratio. + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION VirtualTemperature ( tK, w ) result ( Tv ) + IMPLICIT NONE + + !~ Variable declaration + real, intent ( in ) :: tK !~ Temperature + real, intent ( in ) :: w !~ Mixing ratio ( kg kg^-1 ) + real :: Tv !~ Virtual temperature + + Tv = tK * ( 1.0 + (w/0.622) ) / ( 1.0 + w ) + + END FUNCTION VirtualTemperature + + REAL FUNCTION var_tav(ta, qv, qc, qs) + ! Function for variable virtual temperature including solid water species + ! FROM: https://glossary.ametsoc.org/wiki/Virtual_temperature + ! tav = ta(1 + qv/epsilon)/(1 + qv + qc + qs) + + IMPLICIT NONE + + REAL, INTENT(IN) :: ta, qv, qc, qs + + ! Local + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! ta: air temperature [K] +! qv: water vapor mixing ratio [kgkg-1] +! qc: liquid water (cloud) mixing ratio [kgkg-1] +! qs: solid water (ice+snow+whail+graupel) mixing ratio [kgkg-1] +! epsilon = Rd/Rv = 0.622 + + fname = 'var_tav' + + var_tav = -99999. + + var_tav = ta*(1.+qv/EP_2)/(1. + qv + qc + qs) + + RETURN + + END FUNCTION var_tav + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ SaturationMixingRatio + !~ + !~ Description: + !~ This function calculates saturation mixing ratio given the + !~ temperature ( K ) and the ambient pressure ( Pa ). Uses + !~ approximation of saturation vapor pressure. + !~ + !~ References: + !~ Bolton (1980), Monthly Weather Review, pg. 1047, Eq. 10 + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION SaturationMixingRatio ( tK, p ) result ( ws ) + + IMPLICIT NONE + + REAL, INTENT ( IN ) :: tK + REAL, INTENT ( IN ) :: p + REAL :: ws + + REAL :: es + + es = 6.122 * exp ( (17.67*(tK-273.15))/ (tK-29.66) ) + ws = ( 0.622*es ) / ( (p/100.0)-es ) + + END FUNCTION SaturationMixingRatio + + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ + !~ Name: + !~ tlcl + !~ + !~ Description: + !~ This function calculates the temperature of a parcel of air would have + !~ if lifed dry adiabatically to it's lifting condensation level (lcl). + !~ + !~ References: + !~ Bolton (1980), Monthly Weather Review, pg. 1048, Eq. 22 + !~ + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + FUNCTION TLCL ( tk, rh ) + + IMPLICIT NONE + + REAL, INTENT ( IN ) :: tK !~ Temperature ( K ) + REAL, INTENT ( IN ) :: rh !~ Relative Humidity ( % ) + REAL :: tlcl + + REAL :: denom, term1, term2 + + term1 = 1.0 / ( tK - 55.0 ) + IF ( rh > REAL (0) ) THEN + term2 = ( LOG (rh/100.0) / 2840.0 ) + ELSE + term2 = ( LOG (0.001/1.0) / 2840.0 ) + END IF + denom = term1 - term2 + tlcl = ( 1.0 / denom ) + REAL ( 55 ) + + END FUNCTION TLCL + +! Changing to a subroutine +! FUNCTION var_cape_afwa(nz, tk, rhv, p, hgt, sfc, cape, cin, zlfc, plfc, lidx, parcel) RESULT (ostat) + SUBROUTINE var_cape_afwa(nz, tk, rh, p, hgt, sfc, cape, cin, zlfc, plfc, lidx, parcel) +! Function to compute cape on a 1D column following implementation in phys/module_diag_afwa.F (version from WRF4.3.1) + +!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + !~ ~! + !~ Name: ~! + !~ Buoyancy ~! + !~ ~! + !~ Description: ~! + !~ This function computes Convective Available Potential Energy (CAPE) ~! + !~ with inhibition as a result of water loading given the data required ~! + !~ to run up a sounding. ~! + !~ ~! + !~ Additionally, since we are running up a sounding anyways, this ~! + !~ function returns the height of the Level of Free Convection (LFC) and ~! + !~ the pressure at the LFC. That-a-ways, we don't have to run up a ~! + !~ sounding later, saving a relatively computationally expensive ~! + !~ routine. ~! + !~ ~! + !~ Usage: ~! + !~ ostat = Buoyancy ( tK, rh, p, hgt, sfc, CAPE, ZLFC, PLFC, parcel ) ~! + !~ ~! + !~ Where: ~! + !~ ~! + !~ IN ~! + !~ -- ~! + !~ tK = Temperature ( K ) ~! + !~ rh = Relative Humidity ( % ) ~! + !~ p = Pressure ( Pa ) ~! + !~ hgt = Geopotential heights ( m ) ~! + !~ sfc = integer rank within submitted arrays that represents the ~! + !~ surface ~! + !~ ~! + !~ OUT ~! + !~ --- ~! + !~ ostat INTEGER return status. Nonzero is bad. ~! + !~ CAPE ( J/kg ) Convective Available Potential Energy ~! + !~ ZLFC ( gpm ) Height at the LFC ~! + !~ PLFC ( Pa ) Pressure at the LFC ~! + !~ ~! + !~ tK, rh, p, and hgt are all REAL arrays, arranged from lower levels ~! + !~ to higher levels. ~! + !~ ~! + !!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!! + + IMPLICIT NONE + + INTEGER, INTENT ( IN ) :: nz !~ Number of vertical levels + INTEGER, INTENT ( IN ) :: sfc !~ Surface level in the profile + REAL, INTENT ( IN ) :: tk ( nz ) !~ Temperature profile ( K ) + REAL, INTENT ( IN ) :: rh ( nz ) !~ Relative Humidity profile ( % ) + REAL, INTENT ( IN ) :: p ( nz ) !~ Pressure profile ( Pa ) + REAL, INTENT ( IN ) :: hgt ( nz ) !~ Height profile ( gpm ) + REAL, INTENT ( OUT ) :: cape !~ CAPE ( J kg^-1 ) + REAL, INTENT ( OUT ) :: cin !~ CIN ( J kg^-1 ) + REAL, INTENT ( OUT ) :: zlfc !~ LFC Height ( gpm ) + REAL, INTENT ( OUT ) :: plfc !~ LFC Pressure ( Pa ) + REAL, INTENT ( OUT ) :: lidx !~ Lifted index + INTEGER :: ostat !~ Function return status + !~ Nonzero is bad. + + INTEGER, INTENT ( IN ) :: parcel !~ Most Unstable = 1 (default) + !~ Mean layer = 2 + !~ Surface based = 3 + + !~ Derived profile variables + ! ------------------------- + REAL :: ws ( nz ) !~ Saturation mixing ratio + REAL :: w ( nz ) !~ Mixing ratio + REAL :: etheta( nz )!~ Equivalent potential temperature. Modified by Zhixiao. + REAL :: dTvK ( nz ) !~ Parcel / ambient Tv difference + REAL :: buoy ( nz ) !~ Buoyancy + REAL :: tlclK !~ LCL temperature ( K ) + REAL :: plcl !~ LCL pressure ( Pa ) + REAL :: pel !~ Equilibrium pressure ( Pa ). Modified by Zhixiao. + REAL :: nbuoy !~ Negative buoyancy + REAL :: pbuoy !~ Positive buoyancy + + !~ Source parcel information + ! ------------------------- + REAL :: srctK !~ Source parcel temperature ( K ) + REAL :: srcrh !~ Source parcel rh ( % ) + REAL :: srcws !~ Source parcel sat. mixing ratio + REAL :: srcw !~ Source parcel mixing ratio + REAL :: srcp !~ Source parcel pressure ( Pa ) + REAL :: srctheta !~ Source parcel theta ( K ) + REAL :: srcthetaeK !~ Source parcel theta-e ( K ) + INTEGER :: srclev !~ Level of the source parcel + REAL :: spdiff !~ Pressure difference + REAL :: srce !~ Equivalent potential temperature ( K ). Modified by Zhixiao. + + !~ Parcel variables + ! ---------------- + REAL :: ptK !~ Parcel temperature ( K ) + REAL :: ptvK !~ Parcel virtual temperature ( K ) + REAL :: tvK !~ Ambient virtual temperature ( K ) + REAL :: pw !~ Parcel mixing ratio + + !~ Other utility variables + ! ----------------------- + INTEGER :: i, j, k !~ Dummy iterator + INTEGER :: lfclev !~ Level of LFC + INTEGER :: ellev !~ Level of EL. Modified by Zhixiao. + INTEGER :: lcllev !~ Level of LCL. Modified by Zhixiao. + INTEGER :: prcl !~ Internal parcel type indicator + INTEGER :: mlev !~ Level for ML calculation + INTEGER :: lyrcnt !~ Number of layers in mean layer + LOGICAL :: flag !~ Dummy flag + LOGICAL :: wflag !~ Saturation flag + REAL :: freeze !~ Water loading multiplier + REAL :: pdiff !~ Pressure difference between levs + REAL :: pm, pu, pd !~ Middle, upper, lower pressures + REAL :: lidxu !~ Lifted index at upper level + REAL :: lidxd !~ Lifted index at lower level + + !~ Thermo / dynamical constants + ! ---------------------------- + REAL :: Rd !~ Dry gas constant + PARAMETER ( Rd = 287.058 ) !~ J deg^-1 kg^-1 + REAL :: Cp !~ Specific heat constant pressure + PARAMETER ( Cp = 1004.67 ) !~ J deg^-1 kg^-1 + REAL :: g !~ Acceleration due to gravity + PARAMETER ( g = 9.80665 ) !~ m s^-2 + REAL :: RUNDEF + PARAMETER ( RUNDEF = -9.999E30 ) + + +!!!!!!! Variables +! nz: Number of vertical levels +! sfc: Surface level in the profile +! tk: Temperature profile [K] +! rhv: Relative Humidity profile [1] +! rh: Relative Humidity profile [%] +! p: Pressure profile [Pa] +! hgt: Height profile [gpm] +! cape: CAPE [Jkg-1] +! cin: CIN [Jkg-1] +! zlfc: LFC Height [gpm] +! plfc: LFC Pressure [Pa] +! lidx: Lifted index +! FROM: https://en.wikipedia.org/wiki/Lifted_index +! lidx >= 6: Very Stable Conditions +! 6 > lidx > 1: Stable Conditions, Thunderstorms Not Likely +! 0 > lidx > -2: Slightly Unstable, Thunderstorms Possible, With Lifting Mechanism (i.e., cold front, daytime heating, ...) +! -2 > lidx > -6: Unstable, Thunderstorms Likely, Some Severe With Lifting Mechanism +! -6 > lidx: Very Unstable, Severe Thunderstorms Likely With Lifting Mechanism +! ostat: Function return status (Nonzero is bad) +! parcel: +! Most Unstable = 1 (default) +! Mean layer = 2 +! Surface based = 3 +!~ Derived profile variables +! ------------------------- +! ws: Saturation mixing ratio +! w: Mixing ratio +! dTvK: Parcel / ambient Tv difference +! buoy: Buoyancy +! tlclK: LCL temperature [K] +! plcl: LCL pressure [Pa] +! nbuoy: Negative buoyancy +! pbuoy: Positive buoyancy + +!~ Source parcel information +! ------------------------- +! srctK: Source parcel temperature [K] +! srcrh: Source parcel rh [%] +! srcws: Source parcel sat. mixing ratio +! srcw: Source parcel mixing ratio +! srcp: Source parcel pressure [Pa] +! srctheta: Source parcel theta [K] +! srcthetaeK: Source parcel theta-e [K] +! srclev: Level of the source parcel +! spdiff: Pressure difference + +!~ Parcel variables +! ---------------- +! ptK: Parcel temperature [K] +! ptvK: Parcel virtual temperature [K] +! tvK: Ambient virtual temperature [K] +! pw: Parcel mixing ratio + +!~ Other utility variables +! ----------------------- +! lfclev: Level of LFC +! prcl: Internal parcel type indicator +! mlev: Level for ML calculation +! lyrcnt: Number of layers in mean layer +! flag: Dummy flag +! wflag: Saturation flag +! freeze: Water loading multiplier +! pdiff: Pressure difference between levs +! pm, pu, pd: Middle, upper, lower pressures +! lidxu: Lifted index at upper level +! lidxd: Lifted index at lower level + + sfname = 'var_cape_afwa' + + !~ Initialize variables + ! -------------------- + ostat = 0 + CAPE = REAL ( 0 ) + CIN = RUNDEF !Change CIN filling values from 0 to default filling. + ! CIN should not initially be filled by 0, because 0 means + ! no inhibition energy. Modified by Zhixiao + ZLFC = RUNDEF + PLFC = RUNDEF + + !~ Look for submitted parcel definition + !~ 1 = Most unstable + !~ 2 = Mean layer + !~ 3 = Surface based + ! ------------------------------------- + IF ( parcel > 3 .or. parcel < 1 ) THEN + prcl = 1 + ELSE + prcl = parcel + END IF + + !~ Initalize our parcel to be (sort of) surface based. Because of + !~ issues we've been observing in the WRF model, specifically with + !~ excessive surface moisture values at the surface, using a true + !~ surface based parcel is resulting a more unstable environment + !~ than is actually occuring. To address this, our surface parcel + !~ is now going to be defined as the parcel between 25-50 hPa + !~ above the surface. UPDATE - now that this routine is in WRF, + !~ going to trust surface info. GAC 20140415 + ! ---------------------------------------------------------------- + + !~ Compute mixing ratio values for the layer + ! ----------------------------------------- + DO k = sfc, nz + ws ( k ) = SaturationMixingRatio ( tK(k), p(k) ) + w ( k ) = ( rh(k)/100.0 ) * ws ( k ) + !Removed by Zhixiao. Water vapor mixing ratio (w) is not conserved during parcel lifting + ! processes. We should not use w to define MU layer. + !thetav(k) = Theta ( VirtualTemperature ( tK (k), w (k) ), p(k)/100.0 ) + !Added by Zhixiao. Critical modification: We use the model level with maximum equivalent + ! potential temperature (etheta) below 500mb to define the MU layer + !Because equivalent potential temperature is conserved in dry and moist adiabatic processes. + etheta(k) = Thetae( tK(k), p(k)/100.0, rh(k), w(k) ) + END DO + + srclev = sfc + srctK = tK ( sfc ) + srcrh = rh ( sfc ) + srcp = p ( sfc ) + srcws = ws ( sfc ) + srcw = w ( sfc ) + srctheta = Theta ( tK(sfc), p(sfc)/100.0 ) + srce = etheta (sfc) !Modified by Zhixiao + + !~ Compute the profile mixing ratio. If the parcel is the MU parcel, + !~ define our parcel to be the most unstable parcel within the lowest + !~ 180 mb. + ! ------------------------------------------------------------------- + mlev = sfc + 1 + !Change initial searching level from the second to first model level. Because we did not compute + ! pdiff, and p(k-1) properties is unnecessary. + !Modified by Zhixiao. + DO k = sfc, nz + + !~ Identify the last layer within 100 hPa of the surface + ! ----------------------------------------------------- + pdiff = ( p (sfc) - p (k) ) / REAL ( 100 ) + IF ( pdiff <= REAL (100) ) mlev = k + + !~ If we've made it past the lowest 500 hPa, exit the loop. MU layer is assumed below 500 hPa. Modified by Zhixiao. + ! ------------------------------------------------------- + IF ( p(k) <= REAL (50000) ) EXIT + + IF ( prcl == 1 ) THEN + ! Removed by Zhixiao, w can not used for defining MU layer + !IF ( (p(k) > 70000.0) .and. (w(k) > srcw) ) THEN + ! Modified by Zhixiao, MU layer is featured by the max etheta + IF (etheta(k) > srce) THEN !Modified by Zhixiao. + srctheta = Theta ( tK(k), p(k)/100.0 ) + srcw = w ( k ) + srclev = k + srctK = tK ( k ) + srcrh = rh ( k ) + srcp = p ( k ) + srce = etheta(k) !Modified by Zhixiao + END IF + END IF + + END DO + + !~ If we want the mean layer parcel, compute the mean values in the + !~ lowest 100 hPa. + ! ---------------------------------------------------------------- + lyrcnt = mlev - sfc + 1 + IF ( prcl == 2 ) THEN + + srclev = sfc + srctK = SUM ( tK (sfc:mlev) ) / REAL ( lyrcnt ) + srcw = SUM ( w (sfc:mlev) ) / REAL ( lyrcnt ) + srcrh = SUM ( rh (sfc:mlev) ) / REAL ( lyrcnt ) + srcp = SUM ( p (sfc:mlev) ) / REAL ( lyrcnt ) + srctheta = Theta ( srctK, srcp/100. ) + + END IF + + srcthetaeK = Thetae ( srctK, srcp/100.0, srcrh, srcw ) + !~ Calculate temperature and pressure of the LCL + ! --------------------------------------------- + tlclK = TLCL ( tK(srclev), rh(srclev) ) + plcl = p(srclev) * ( (tlclK/tK(srclev))**(Cp/Rd) ) + + !Add caculation for LCL. Modified by Zhixiao + lcllev = -1 !Modified by Zhixiao + flag=.false. !Modified by Zhixiao + DO k=sfc,nz !zhixiao search the layer of LCL + IF (p (k) <= plcl) THEN !Modified by Zhixiao + lcllev=k !Modified by Zhixiao + flag=.true. !Modified by Zhixiao + END IF !Modified by Zhixiao + IF (flag) EXIT !Modified by Zhixiao + END DO !Modified by Zhixiao + + flag=.false. !Modified by Zhixiao + !~ Now lift the parcel + ! ------------------- + + buoy = REAL ( 0 ) + pw = srcw + wflag = .false. + DO k = srclev, nz + IF ( p (k) <= plcl ) THEN + + !~ The first level after we pass the LCL, we're still going to + !~ lift the parcel dry adiabatically, as we haven't added the + !~ the required code to switch between the dry adiabatic and moist + !~ adiabatic cooling. Since the dry version results in a greater + !~ temperature loss, doing that for the first step so we don't over + !~ guesstimate the instability. + ! ---------------------------------------------------------------- + + IF ( wflag ) THEN + flag = .false. + + !~ Above the LCL, our parcel is now undergoing moist adiabatic + !~ cooling. Because of the latent heating being undergone as + !~ the parcel rises above the LFC, must iterative solve for the + !~ parcel temperature using equivalant potential temperature, + !~ which is conserved during both dry adiabatic and + !~ pseudoadiabatic displacements. + ! -------------------------------------------------------------- + ptK = The2T ( srcthetaeK, p(k), flag ) + + !~ Calculate the parcel mixing ratio, which is now changing + !~ as we condense moisture out of the parcel, and is equivalent + !~ to the saturation mixing ratio, since we are, in theory, at + !~ saturation. + ! ------------------------------------------------------------ + pw = SaturationMixingRatio ( ptK, p(k) ) + + !~ Now we can calculate the virtual temperature of the parcel + !~ and the surrounding environment to assess the buoyancy. + ! ---------------------------------------------------------- + ptvK = VirtualTemperature ( ptK, pw ) + tvK = VirtualTemperature ( tK (k), w (k) ) + + !~ Modification to account for water loading + ! ----------------------------------------- + freeze = 0.033 * ( 263.15 - pTvK ) + IF ( freeze > 1.0 ) freeze = 1.0 + IF ( freeze < 0.0 ) freeze = 0.0 + + !~ Approximate how much of the water vapor has condensed out + !~ of the parcel at this level + ! --------------------------------------------------------- + freeze = freeze * 333700.0 * ( srcw - pw ) / 1005.7 + + pTvK = pTvK - pTvK * ( srcw - pw ) + freeze + dTvK ( k ) = ptvK - tvK + buoy ( k ) = g * ( dTvK ( k ) / tvK ) + + ELSE + + !~ Since the theta remains constant whilst undergoing dry + !~ adiabatic processes, can back out the parcel temperature + !~ from potential temperature below the LCL + ! -------------------------------------------------------- + ptK = srctheta / ( 100000.0/p(k) )**(Rd/Cp) + + !~ Grab the parcel virtual temperture, can use the source + !~ mixing ratio since we are undergoing dry adiabatic cooling + ! ---------------------------------------------------------- + ptvK = VirtualTemperature ( ptK, srcw ) + + !~ Virtual temperature of the environment + ! -------------------------------------- + tvK = VirtualTemperature ( tK (k), w (k) ) + + !~ Buoyancy at this level + ! ---------------------- + dTvK ( k ) = ptvK - tvK + buoy ( k ) = g * ( dtvK ( k ) / tvK ) + + wflag = .true. + + END IF + + ELSE + + !~ Since the theta remains constant whilst undergoing dry + !~ adiabatic processes, can back out the parcel temperature + !~ from potential temperature below the LCL + ! -------------------------------------------------------- + ptK = srctheta / ( 100000.0/p(k) )**(Rd/Cp) + + !~ Grab the parcel virtual temperture, can use the source + !~ mixing ratio since we are undergoing dry adiabatic cooling + ! ---------------------------------------------------------- + ptvK = VirtualTemperature ( ptK, srcw ) + + !~ Virtual temperature of the environment + ! -------------------------------------- + tvK = VirtualTemperature ( tK (k), w (k) ) + + !~ Buoyancy at this level + ! --------------------- + dTvK ( k ) = ptvK - tvK + buoy ( k ) = g * ( dtvK ( k ) / tvK ) + + END IF + + !~ Chirp + ! ----- + ! WRITE ( *,'(I15,6F15.3)' )k,p(k)/100.,ptK,pw*1000.,ptvK,tvK,buoy(k) + + END DO + + !~ Add up the buoyancies, find the LFC + ! ----------------------------------- + flag = .false. + lfclev = -1 + ellev = -1 !Modified by Zhixiao + DO k = sfc, nz !Modified by Zhixiao + !~ LFC is defiend as the highest level when negative buyancy turns postive. + ! Let us ignore the lower LFCs, and keep the highest LFC as the final result + ! ----------------------------------- + IF ( .not. flag .and. buoy (k) > REAL (0) .and. p (k) <= plcl ) THEN !Modified by Zhixiao + flag = .true. + lfclev = k + END IF + !~ Take the Highest EL as final result. Modified by Zhixiao + ! ---------------------------------------------------------------- + IF (k >= 2) THEN !Modified by Zhixiao + IF ( flag .and. buoy (k) < REAL (0) .and. buoy (k-1) >= REAL (0)) THEN !Modified by Zhixiao + ellev = k !Modified by Zhixiao + END IF + END IF + END DO + IF (ellev >= 0) THEN !Modified by Zhixiao + pel = p(ellev) !Modified by Zhixiao + CIN=REAL ( 0 ) !Modified by Zhixiao + DO k = sfc+1, nz !Modified by Zhixiao + ! CAPE and CIN is defined as integrated positive and negative buoyant energy between LCL and EL, respectively. Modified by Zhixiao + IF ( p (k) <= plcl .and. p (k) >= pel) THEN !Modified by Zhixiao + CAPE = CAPE + MAX ( buoy (k), 0.0 ) * ( hgt (k) - hgt (k-1) ) !Modified by Zhixiao + CIN = CIN + MIN ( buoy (k), 0.0 ) * ( hgt (k) - hgt (k-1) ) !Modified by Zhixiao + END IF !Modified by Zhixiao + END DO !Modified by Zhixiao + END IF !Modified by Zhixiao + !~ Calculate lifted index by interpolating difference between + !~ parcel and ambient Tv to 500mb. + ! ---------------------------------------------------------- + DO k = sfc + 1, nz + + pm = 50000. + pu = p ( k ) + pd = p ( k - 1 ) + + !~ If we're already above 500mb just set lifted index to 0. + !~ -------------------------------------------------------- + IF ( pd .le. pm ) THEN + lidx = 0. + EXIT + + ELSEIF ( pu .le. pm .and. pd .gt. pm) THEN + + !~ Found trapping pressure: up, middle, down. + !~ We are doing first order interpolation. + ! ------------------------------------------ + lidxu = -dTvK ( k ) * ( pu / 100000. ) ** (Rd/Cp) + lidxd = -dTvK ( k-1 ) * ( pd / 100000. ) ** (Rd/Cp) + lidx = ( lidxu * (pm-pd) + lidxd * (pu-pm) ) / (pu-pd) + EXIT + + ENDIF + + END DO + !~ Assuming the the LFC is at a pressure level for now + ! --------------------------------------------------- + IF ( lfclev > 0 ) THEN + PLFC = p ( lfclev ) + ZLFC = hgt ( lfclev ) + END IF + + IF ( PLFC /= PLFC .OR. PLFC < REAL (0) ) THEN + PLFC = REAL ( -1 ) + ZLFC = REAL ( -1 ) + END IF + + IF ( CAPE /= CAPE ) cape = REAL ( 0 ) + + IF ( CIN /= CIN ) cin = RUNDEF + + !~ Chirp + ! ----- + ! WRITE ( *,* ) ' CAPE: ', cape, ' CIN: ', cin + ! WRITE ( *,* ) ' LFC: ', ZLFC, ' PLFC: ', PLFC + ! WRITE ( *,* ) '' + ! WRITE ( *,* ) ' Exiting buoyancy.' + ! WRITE ( *,* ) ' ==================================== ' + ! WRITE ( *,* ) '' + + END SUBROUTINE var_cape_afwa + +! ---- END modified from module_diag_afwa.F ---- ! + +! FUNCTION var_cllmh(clfra, p, dz) [L. Fita Not working as function ?!] + SUBROUTINE var_cllmh(clfra, p, dz, cllmh) +! Function to compute cllmh on a 1D column 1: low-cloud; 2: medium-cloud; 3: high-cloud [1] + + USE module_wrf_error + USE module_model_constants + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: clfra, p + REAL, DIMENSION(3), INTENT(out) :: cllmh + +! _ocal + INTEGER :: iz + REAL(r_k) :: zclearl, zcloudl, zclearm, zcloudm, & + zclearh, zcloudh + REAL(r_k), DIMENSION(3) :: Dcllmh + +!!!!!!! Variables +! clfra: cloudfraction as 1D verical-column [1] +! p: pressure values of the column + sfname = 'var_cllmh' + + message = "CORDEX computing '" // TRIM(sfname) // "' " + CALL wrf_debug(1000,message) + + zclearl = oneRK + zcloudl = zeroRK + zclearm = oneRK + zcloudm = zeroRK + zclearh = oneRK + zcloudh = zeroRK + + Dcllmh = oneRK + + DO iz=1, dz + IF (p(iz) < prmhc) THEN + Dcllmh(3) = Dcllmh(3)*(oneRK-MAX(clfra(iz),zcloudh))/(oneRK-MIN(zcloudh,oneRK-ZEPSEC)) + zcloudh = clfra(iz) + ELSE IF ( (p(iz) >= prmhc) .AND. (p(iz) < prmlc) ) THEN + Dcllmh(2) = Dcllmh(2)*(oneRK-MAX(clfra(iz),zcloudm))/(oneRK-MIN(zcloudm,oneRK-ZEPSEC)) + zcloudm = clfra(iz) + ELSE IF (p(iz) >= prmlc) THEN + Dcllmh(1) = Dcllmh(1)*(oneRK-MAX(clfra(iz),zcloudl))/(oneRK-MIN(zcloudl,oneRK-ZEPSEC)) + zcloudl = clfra(iz) + ELSE + PRINT *,' ' // TRIM(sfname) // ': This is weird, pressure:', p(iz), ' Pa fails out!!' + PRINT *,' from high, low cloud pressures:', prmhc, ' ,', prmlc,' Pa at z-level:', iz + PRINT *,' p_high > p:', prmhc,'> ',p(iz),' Pa' + PRINT *,' p_low > p >= p_high:', prmlc,'> ',p(iz),' >=', prmhc,' Pa' + PRINT *,' p_low >= p:', prmlc,'>= ',p(iz),' Pa' + message = "program wrf: error on computing 'cllmh' for CORDEX" + CALL WRF_ERROR_FATAL ( message ) + !STOP + END IF + END DO + + cllmh = REAL(oneRK - Dcllmh)*100. + + RETURN + +! END FUNCTION var_cllmh + END SUBROUTINE var_cllmh + +! REAL FUNCTION var_clt(clfra, dz) + SUBROUTINE var_clt(clfra, dz, clt) +! Function to compute the total cloud following 'newmicro.F90' from LMDZ using 1D vertical +! column values + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: clfra + REAL, INTENT(out) :: clt + + +! Local + INTEGER :: iz + REAL(r_k) :: zclear, zcloud, Dclt + +!!!!!!! Variables +! cfra: 1-column cloud fraction values + + sfname = 'var_clt' + + message = "CORDEX computing '" // TRIM(sfname) // "' " + CALL wrf_debug(1000,message) + + zclear = oneRK + zcloud = zeroRK + + DO iz=1,dz + zclear = zclear*(oneRK-MAX(clfra(iz),zcloud))/(oneRK-MIN(zcloud,1.-ZEPSEC)) + Dclt = oneRK - zclear + zcloud = clfra(iz) + END DO + + clt = REAL(Dclt)*100. + + RETURN + +! END FUNCTION var_clt + END SUBROUTINE var_clt + + SUBROUTINE var_hur(t, press, q, dz, hur) +! Subroutine to compute relative humidity using August-Roche-Magnus approximation [1] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: t, press, q + REAL, DIMENSION(dz), INTENT(out) :: hur + +! Local + INTEGER :: k + REAL :: tC, es, ws + +!!!!!!! Variables +! t: temperature [K] +! press: pressure [Pa] +! q: mixing ratio [kgkg-1] +! dz: vertical extension +! hur: relative humidity [1] + + sfname = 'var_hur' + + ! August - Roche - Magnus formula (Avoiding overflow on last level) + DO k=1,dz-1 + tC = t(k) - SVPT0 + + es = ARM1 * exp(ARM2*tC/(tC+ARM3)) + ! Saturated mixing ratio + ws = mol_watdry*es/(0.01*press(k)-es) + + ! Relative humidity + hur(k) = q(k) / ws + END DO + + RETURN + + END SUBROUTINE var_hur + + SUBROUTINE var_hurs(tas, ps, qas, hurs) +! Subroutine to compute relative humidity at 2m using August-Roche-Magnus approximation [1] + + IMPLICIT NONE + + REAL, INTENT(in) :: tas, ps, qas + REAL, INTENT(out) :: hurs + +! Local + REAL :: es, ws + +!!!!!!! Variables +! tas: 2m temperature [K] +! ps: surface pressure [Pa] +! qas: 2m mixing ratio [kgkg-1] +! hurs: 2m relative humidity [1] + + sfname = 'var_hurs' + + ! August - Roche - Magnus formula + es = ARM1 * exp(ARM2*(tas-SVPT0)/((tas-SVPT0)+ARM3)) + ! Saturated mixing ratio (assuming ps similar press_2m) + ws = mol_watdry*es/(0.01*ps-es) + + ! Relative humidity + hurs = qas / ws + + RETURN + + END SUBROUTINE var_hurs + + SUBROUTINE var_hus(q, dz, hus) +! Subroutine to compute specific humidity [1] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: q + REAL, DIMENSION(dz), INTENT(out) :: hus + +!!!!!!! Variables +! q: mixing ratio [kgkg-1] +! dz: vertical extension +! hus: specific humidity [1] + + sfname = 'var_hus' + + ! Specifc humidity + hus = q / (1. + q) + + RETURN + + END SUBROUTINE var_hus + + SUBROUTINE var_huss(qas, huss) +! Subroutine to compute 2m specific humidity [1] + + IMPLICIT NONE + + REAL, INTENT(in) :: qas + REAL, INTENT(out) :: huss + +!!!!!!! Variables +! qas: 2m mixing ratio [kgkg-1] +! huss: 2m specific humidity [1] + + sfname = 'var_huss' + + ! Specifc humidity + huss = qas / (1. + qas) + + RETURN + + END SUBROUTINE var_huss + + SUBROUTINE var_massvertint(var, mutot, dz, deta, integral) + ! Subroutine to vertically integrate a 1D variable in eta vertical coordinates + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, INTENT(in) :: mutot + REAL, DIMENSION(dz), INTENT(in) :: var, deta + REAL, INTENT(out) :: integral + +! Local + INTEGER :: k + +!!!!!!! Variables +! var: vertical variable to integrate (assuming kgkg-1) +! mutot: total dry-air mass in column +! dz: vertical dimension +! deta: eta-levels difference between full eta-layers + + sfname = 'var_massvertint' + +! integral=0. +! DO k=1,dz +! integral = integral + var(k)*deta(k) +! END DO + integral = SUM(var*deta) + + integral=integral*mutot/g + + RETURN + + END SUBROUTINE var_massvertint + + SUBROUTINE var_vertint(var, dz, deta, zweight, integral) + ! Subroutine to vertically integrate a 1D variable in any vertical coordinates + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: var, deta, zweight + REAL, INTENT(out) :: integral + +!!!!!!! Variables +! var: vertical variable to integrate +! dz: vertical dimension +! deta: eta-levels difference between layers +! zweight: weight for each level to be applied (=1. for no effect) + + sfname = 'var_vertint' + + integral = SUM(var*deta*zweight) + + RETURN + + END SUBROUTINE var_vertint + + SUBROUTINE var_psl_ecmwf(PRPRESS, hgt, PTB, PRESBH, PRESBF, psl) + ! Subroutine to compute sea level pressure using ECMWF method following Mats Hamrud and Philippe Courtier + ! method found in LMDZ in phylmd/pppmer.F90 in combination with phylmd/ctsar.F90 + +! IMPLICIT ARGUMENTS : CONSTANTS FROM YOMCST,YOMGEM,YOMSTA. +! -------------------- + + IMPLICIT NONE + + REAL, INTENT(in) :: PRPRESS, hgt, PTB, PRESBH, PRESBF + REAL, INTENT(out) :: psl + +! Local + REAL :: ghgt, PTSTAR, PT0, ZTSTAR + REAL :: ZALPHA, POROG + REAL :: ZDTDZSG, ZOROG, ZT0, ZTX, ZTY, ZX, ZY, ZY2 + REAL, PARAMETER :: RDTDZ1 = -gammav + +!!!!!!! Variables +! PRPRESS: Surface pressure [Pa] +! hgt: Terrain height [m] +! PTB: Temperature first half-level [K] +! PRESBH: Pressure first half-level [Pa] +! PRESBF: Pressure second full-level [Pa] +! psl: sea-level pressure + + sfname = 'var_psl_ecmwf' + + ! Height by gravity + POROG = hgt*g + + !* 1. COMPUTES SURFACE TEMPERATURE + !* THEN STANDARD SURFACE TEMPERATURE. + + ZDTDZSG=-RDTDZ1/g + ZALPHA=ZDTDZSG*r_d + + PTSTAR=PTB*(1.0+ZALPHA*(PRESBH/PRESBF-1.0)) + PT0=PTSTAR+ZDTDZSG*POROG + + !* 2. POST-PROCESS MSL PRESSURE. + ! -------------------------- + + !* 2.1 COMPUTATION OF MODIFIED ALPHA AND TSTAR. + + ZTX=290.5 + ZTY=255.0 + + IF (PTSTAR < ZTY) THEN + ZTSTAR=0.5*(ZTY+PTSTAR) + ELSEIF (PTSTAR < ZTX) THEN + ZTSTAR=PTSTAR + ELSE + ZTSTAR=0.5*(ZTX+PTSTAR) + ENDIF + + ZT0=ZTSTAR+ZDTDZSG*POROG + IF (ZTX > ZTSTAR .AND. ZT0 > ZTX) THEN + ZT0=ZTX + ELSEIF (ZTX <= ZTSTAR .AND. ZT0 > ZTSTAR) THEN + ZT0=ZTSTAR + ELSE + ZT0=PT0 + ENDIF + + ZOROG=SIGN(MAX(1.0,ABS(POROG)),POROG) + ZALPHA=r_d*(ZT0-ZTSTAR)/ZOROG + + !* 2.2 COMPUTATION OF MSL PRESSURE. + + IF (ABS(POROG) >= 0.001) THEN + ZX=POROG/(r_d*ZTSTAR) + ZY=ZALPHA*ZX + ZY2=ZY*ZY + + psl=PRPRESS*EXP(ZX*(1.0-0.5*ZY+1.0/3.*ZY2)) + ELSE + psl=PRPRESS + ENDIF + + RETURN + + END SUBROUTINE var_psl_ecmwf + + SUBROUTINE var_psl_ptarget(press, ps, hgt, ta, qv, dz, ptarget, psl) + ! Subroutine to compute sea level pressure using a target pressure. Similar to the Benjamin + ! and Miller (1990). Method found in p_interp.F90 + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: press, ta, qv + REAL, INTENT(in) :: ps, hgt, ptarget + REAL, INTENT(out) :: psl + +! Local + INTEGER :: kin + INTEGER :: kupper + REAL :: dpmin, dp, tbotextrap, & + tvbotextrap, virtual + ! Exponential related to standard atmosphere lapse rate r_d*gammav/g + REAL, PARAMETER :: expon=r_d*gammav/g + +!!!!!!! Variables +! press: Atmospheric pressure [Pa] +! ps: surface pressure [Pa] +! hgt: surface height +! ta: temperature [K] +! qv: water vapor mixing ratio +! dz: number of vertical levels +! psl: sea-level pressure + + sfname = 'var_psl_ptarget' + + IF (hgt /= 0.) THEN + + ! target pressure to be used for the extrapolation [Pa] (defined in namelist.input) + ! ptarget = 70000. default value + + ! Minimal distance between pressures [Pa] + dpmin=1.e6 + + psl=0. + +! We are below both the ground and the lowest data level. + +! First, find the model level that is closest to a "target" pressure +! level, where the "target" pressure is delta-p less that the local +! value of a horizontally smoothed surface pressure field. We use +! delta-p = 150 hPa here. A standard lapse rate temperature profile +! passing through the temperature at this model level will be used +! to define the temperature profile below ground. This is similar +! to the Benjamin and Miller (1990) method, using +! 700 hPa everywhere for the "target" pressure. + + kupper = 0 + loop_kIN: DO kin=dz,1,-1 + kupper = kin + dp=abs( press(kin) - ptarget ) + IF (dp .GT. dpmin) EXIT loop_kIN + dpmin=min(dpmin,dp) + ENDDO loop_kIN + + tbotextrap=ta(kupper)*(ps/ptarget)**expon + ! L. Fita. iCIMA, Janury 2018 + ! Using AFWA's one + tvbotextrap=virtualTemperature(tbotextrap,qv(kupper)) + IF (tvbotextrap == 0.) THEN + WRITE(message,*)' ' // TRIM(sfname) //': wrong virtual temperature:', tvbotextrap, '!!' + CALL wrf_debug(0,message) + WRITE(message,*)'press:', press(kupper), ' ps:', ps, ' hgt:', hgt, ' ta:', ta(kupper), ' qv:',& + ' ptarget:', ptarget, ' kupper:', kupper, ' dz:', dz + CALL wrf_debug(0,message) + Lmessage = '' + DO kin=1,dz-1 + WRITE(RS,'(F10.3)')press(kin) - ptarget + WRITE(IS,'(I3)')kin + WRITE(Lmessage,*) TRIM(Lmessage) // TRIM(IS) // ' :' // TRIM(RS) // ', ' + END DO + WRITE(RS,'(F10.3)')press(dz) + WRITE(IS,'(I3)')dz + WRITE(Lmessage,*) TRIM(Lmessage) // TRIM(IS) // ' :' // TRIM(RS) + CALL wrf_debug(0,Lmessage) + END IF + + psl = ps*((tvbotextrap+gammav*hgt)/tvbotextrap)**(1/expon) + IF (psl -1 == psl) THEN + WRITE(message,*)' ' // TRIM(sfname) //': wrong psl:', psl, '!!' + CALL wrf_debug(0,message) + WRITE(message,*)'press:', press(kupper), ' ps:', ps, ' hgt:', hgt, ' ta:', ta(kupper), ' qv:',& + ' ptarget:', ptarget, ' kupper:', kupper, ' dz:', dz + CALL wrf_debug(0,message) + WRITE(message,*)'expon', expon, ' tvbotextrap:', tvbotextrap, ' gammav:', gammav + CALL wrf_debug(0,message) + END IF + ELSE + psl = ps + END IF + + RETURN + + END SUBROUTINE var_psl_ptarget + + SUBROUTINE var_psl_shuell(hgt, ps, zlev1, qlev1, tlev1, psl) + ! Subroutine to compute sea level pressure using the hydrostatic equation with the Shuell + ! correction and existing code from 'phys/module_diag_afwa.F' + + IMPLICIT NONE + + REAL, INTENT(in) :: hgt, ps, zlev1, qlev1, tlev1 + REAL, INTENT(out) :: psl + +! Local + REAL :: tauvrt, tauvr_sfc, tau_sfc, tau_sl, & + tauvr_sl, tauavg, zsfc + + ! Inverse of gravity + REAL, PARAMETER :: gi=1./g + ! Sea-level height + REAL, PARAMETER :: zsl=0.0 + ! control Tau + REAL, PARAMETER :: taucr=r_d*gi*290.66 + ! Constant + REAL, PARAMETER :: const=0.005*g/r_d + + +!!!!!!! Variables +! hgt: surface height [m] +! ps: surgface pressure [Pa] +! zlev1: height first level [m] +! qlev1: mixing ratio at first level [kgkg-1] +! tlev1: temperature at first level [K] +! psl: sea level pressure [Pa] + + sfname = 'var_psl_shuell' + + psl = ps + zsfc = hgt + + IF (hgt /= 0.) THEN + +! Compute layer tau (virtual temp*rd/g) + tauvrt = tlev1*(1.0+0.608*qlev1) + +! Compute tau at the ground (z=zsfc) and sea level (z=0) assuming a constant lapse rate of +! gammav=6.5deg/km + tauvr_sfc = tauvrt + (zlev1 - zsfc)*gammav + tau_sfc = tauvr_sfc*r_d*gi + tauvr_sl = tauvrt + (zlev1 - zsl)*gammav + tau_sl = tauvr_sl*r_d*gi + +! if need be apply Sheull correction + IF ((tau_sl.GT.taucr) .AND. (tau_sfc.LE.taucr)) THEN + tau_sl = taucr + ELSEIF ((tau_sl.GT.taucr) .AND. (tau_sfc.GT.taucr)) THEN + tau_sl = taucr-const*(tau_sfc-taucr)**2 + ENDIF + +! compute mean tau + tauavg = 0.5*(tau_sl+tau_sfc) + +! compute sea level pressure + psl = ps*EXP(hgt/tauavg) + END IF + + RETURN + + END SUBROUTINE var_psl_shuell + + SUBROUTINE var_press(p, pb, dz, press) +! Subroutine to compute air pressure [Pa] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: p, pb + REAL, DIMENSION(dz), INTENT(out) :: press + +!!!!!!! Variables +! p: WRF air-pressure perturbation [Pa] +! pb: WRF air-pressure base-state [Pa] +! dz: vertical extension (half-levels) +! press: air pressure (half-levels) [Pa] + + sfname = 'var_press' + + press = p + pb + + RETURN + + END SUBROUTINE var_press + + SUBROUTINE var_ta(tpot, press, dz, ta) +! Subroutine to compute air temperature [K] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: tpot, press + REAL, DIMENSION(dz), INTENT(out) :: ta + +!!!!!!! Variables +! tpot: WRF potential air-temperature [K] +! press: air-pressure [Pa] +! dz: vertical extension (half-levels) +! ta: air temperature [K] + + sfname = 'var_ta' + + ta = (tpot + 300.)*(press/p0)**(rcp) + + RETURN + + END SUBROUTINE var_ta + + SUBROUTINE var_uava(u, v, sina, cosa, dz, ua, va) +! Subroutine to compute earth-rotated wind components [ms-1] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: u, v + REAL, INTENT(in) :: sina, cosa + REAL, DIMENSION(dz), INTENT(out) :: ua, va + +! Local + INTEGER :: k + +!!!!!!! Variables +! u, v: WRF unstaggered wind components [ms-1] +! sina, cosa: local sine and cosine of map rotation [1] +! dz: vertical extension +! ua, va: earth-rotated wind speed components [ms-1] + sfname = 'var_uava' + + DO k=1, dz + ua(k) = u(k)*cosa - v(k)*sina + va(k) = u(k)*sina + v(k)*cosa + END DO + + RETURN + + END SUBROUTINE var_uava + + SUBROUTINE var_uasvas(u10, v10, sina, cosa, uas, vas) +! Subroutine to compute 10m earth-rotated wind components [ms-1] + + IMPLICIT NONE + + REAL, INTENT(in) :: u10, v10, sina, cosa + REAL, INTENT(out) :: uas, vas + +!!!!!!! Variables +! u10, v10: WRF 10m wind components [ms-1] +! sina, cosa: local sine and cosine of map rotation [1] +! uas, vas: earth-rotated 2m wind speed components [ms-1] + + sfname = 'var_uasvas' + + uas = u10*cosa - v10*sina + vas = u10*sina + v10*cosa + + RETURN + + END SUBROUTINE var_uasvas + + SUBROUTINE var_zg(ph, phb, dz1, dz, zg, unzg) +! Subroutine to compute geopotential height [m] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz, dz1 + REAL, DIMENSION(dz1), INTENT(in) :: ph, phb + REAL, DIMENSION(dz1), INTENT(out) :: zg + REAL, DIMENSION(dz), INTENT(out) :: unzg + +! Local + INTEGER :: k + +!!!!!!! Variables +! ph: WRF geopotential perturbation [m2s-2] +! phb: WRF geopotential base-state [m2s-2] +! dz1: vertical extension (full-levels) +! dz: vertical extension (half-levels) +! zg: geopotential height (full-levels) [m] +! unzg: geopotential height (half-levels) [m] + + sfname = 'var_zg' + + zg = (ph + phb) / g + + unzg(1:dz) = 0.5*(zg(1:dz) + zg(2:dz1)) + + RETURN + + END SUBROUTINE var_zg + +!!!!!!! Some more complex variables + + SUBROUTINE water_budget(dz, Nmoist, mutot, deta, dt, dtqvar, qvarhadv, qvarzadv, pwqvar, fqvar, zqvar) +! Subroutine to compute accumulated water budget +!! Code from: Fita and Flaounas, QJRMS, 2018 +!! After Jian et al., 2008, Wea. Forecasting, 23, 44-61 + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz, Nmoist + REAL, INTENT(in) :: mutot + REAL, DIMENSION(dz), INTENT(in) :: deta + REAL, INTENT(in) :: dt + REAL, DIMENSION(dz,Nmoist), INTENT(in) :: dtqvar, qvarhadv, qvarzadv + REAL, DIMENSION(dz,Nmoist), INTENT(out) :: pwqvar, fqvar, zqvar + +! Local + INTEGER :: k, l + REAL :: wrfhadvqvar, wrfzadvqvar + +!!!!!!! Variables +! dz: vertical extent +! Nmoist: number of water species +! mutot: total dry-air pressure [Pa] +! deta: thickness of eta layers +! dt: time-step [s] +! dtqvar: tendenchy of all water species [kgkg-1s-1] +! qvarhadv: horizontal advection of all water species [kgkg-1s-1] +! qvarzadv: vertical advection of all water species [kgkg-1s-1] +! pwqvar: total tendency of all water species [mm] +! fqvar: horizontal advecton of all water species [mm] +! zqvar: vertical advecton of all water species [mm] + + sfname = 'water_budget' + + ! Initializing variables + pwqvar = 0. + fqvar = 0. + zqvar = 0. + + ! Looping on the vertical + vertlevels: DO k=1,dz + + ! Looping on species + DO l=1, Nmoist + + ! total tendency + pwqvar(k,l) = (1./g)*mutot*deta(k)*dtqvar(k,l)*dt + + ! horizontal advection + fqvar(k,l) = deta(k)*qvarhadv(k,l)*mutot*dt/g + ! vertical advection + ! original acz = wrfzadvqv(i,k,j)/dt + zqvar(k,l) = deta(k)*qvarzadv(k,l)*mutot*dt/g + + END DO + + END DO vertlevels + + END SUBROUTINE water_budget + + SUBROUTINE gustwind_afwa(dz, dt, u10, v10, pr, zagl, u_phy, v_phy, sa, ca, ublend, vblend, gustij) +! Subroutine to compute wind gust following heavy precip methodology found in phys/module_diag_afwa.F diagnostics + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, INTENT(in) :: dt, u10, v10, pr, sa, ca + REAL, DIMENSION(dz), INTENT(in) :: zagl, u_phy, v_phy + REAL, INTENT(out) :: ublend, vblend + INTEGER, INTENT(out) :: gustij + +! Local + INTEGER :: k + REAL :: wind_vel, prate_mm_per_hr + LOGICAL :: is_target_level + REAL :: factor, u1km, v1km + REAL :: ublend0, vblend0 + +!!!!!!! Variables +! dz: number of vertical levels +! dt: time-step [s] +! u10, v10: 10-m horizontal wind components [ms-1] +! pr: time-step precipitation [kgm-2] +! zagl: height above ground [m] +! u_phy, v_phy: air wind speed [ms-1] +! sa, ca: : Map factors sinus and cosionus +! ublend, vblend: blended winds at 1 km AGL to be considered as wind gust components [ms-1] +! gustij: whether the grid point got gust winds (1) or not (0) + + sfname = 'gustwind_afwa' + + ! Calculate the max 10 m wind speed between output times + ! ------------------------------------------------------ + ! UPDATE 20150112 - GAC + ! Diagnose from model 10 m winds, and blend with 1 km AGL + ! winds when precipitation rate is > 50 mm/hr to account + ! for increased surface wind gust potential when precip + ! is heavy and when winds aloft are strong. Will use the + ! higher of the surface and the blended winds. Blending + ! is linear weighted between 50-150 mm/hr precip rates. + ! ------------------------------------------------------- + ublend = 0. + vblend = 0. + + wind_vel = SQRT(u10*u10 + v10*v10) + prate_mm_per_hr = (pr/dt)*3600. + + ! Is this an area of heavy precip? Calculate 1km winds to blend down + ! ------------------------------------------------------------------- + IF ( prate_mm_per_hr .GT. 50. ) THEN + gustij = 1 + is_target_level = .FALSE. + DO k=1,dz + IF ( (zagl(k) >= 1000.) .AND. (.NOT.is_target_level) .AND. (k .ne. 1)) THEN + is_target_level = .TRUE. + u1km = u_phy(k-1) + (1000.-zagl(k-1))*((u_phy(k)-u_phy(k-1))/(zagl(k))) + v1km = v_phy(k-1) + (1000.-zagl(k-1))*((v_phy(k)-v_phy(k-1))/(zagl(k))) + EXIT ! We've found our level, break the loop + ENDIF + ENDDO + + ! Compute blended wind + ! -------------------- + factor = MAX( ((150.-prate_mm_per_hr)/100.), 0.) + ublend0 = u10*factor + u1km*(1.-factor) + vblend0 = v10*factor + v1km*(1.-factor) + + ! Rotating winds + ublend = ublend0*ca-vblend0*sa + vblend = vblend0*ca+ublend0*sa + ELSE + gustij = 0 + ublend = 0. + vblend = 0. + ENDIF + + RETURN + + END SUBROUTINE gustwind_afwa + +! From clWRF heavy + SUBROUTINE gustwind_Brasseur01(dz, geopoth, qr, lr, pt, tke, u, v, hpbl, topo, sina, cosa, & + ugustwind, vgustwind, gustij) +! Subroutine to compute 1D wind gust following Brasseur (2001), MWR. +! Downdraft effect from convection has not been applied + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: geopoth, qr, lr, pt, tke, u, v + REAL, INTENT(in) :: hpbl, topo, sina, cosa + REAL, INTENT(out) :: ugustwind, vgustwind + INTEGER, INTENT(out) :: gustij +! Not needed for climate runs +! REAL, DIMENSION, INTENT(out) :: ugustlow, vgustlow, ugustup, vgustup + +! Local + INTEGER :: i,j,k,l, Nlevs, km2, ilev + INTEGER :: Ngustlevels, Ngustlowlev, maxlev + REAL, DIMENSION(dz) :: vpt, heights, dheights, dvpt + REAL, DIMENSION(dz,2) :: wge !, wge_low, wge_up + INTEGER, DIMENSION(dz) :: gustlevels + REAL :: preshpbl, tke_int, vpt_int + REAL :: height2pres, virtualpottemp, pres2height + REAL :: wgemax !, wgemaxlow, wgemaxup + REAL :: ugust, vgust +! REAL :: ugustl, vgustl, ugustu, vgustu + CHARACTER(LEN=1024) :: outstring + +!!!!!!!!!! Variables +! geopoth: 3D geopotential height +! qr: 3D vapour water mixing ratio +! lr: 3D liquid water mixing ratio +! pt: 3D potential temperature +! tke: 3D turbulent kinetic energy +! u, v: 3D wind components +! hpbl: pbl height +! topo: topography +! sina, cosa: Map factors sinus and cosionus +! ugustwind, vgustwind: gust wind components +! ugustlow, vgustlow: gust wind components of lower bounder +! ugustup, vgustup: gust wind components of upper bounder +! Nlevs: number of layers within pbl +! Ngustlevels: number of pbl layers with a int_tke >= int_ept +! Ngustlowlev: number of pbl layers with a 2.5*tke(lay)/11. >= int_ept +! vpt: virtual potential temperature +! heights: vector of heights according hydrostatic conversion from pressure +! dheights: vector of differences between heights +! wge: estimated wind gusts +! wge_low: low doundaries of estimated wind gust +! wge_up: up boundary of estimated wind gust +! gustlevels: levels of pbl with a possible deflected air parcel +! preshpbl: hydrostatic equivalent pbl height pressure +! tke_int: tke integral up to a given layer +! vpt_int: vpt integral up to a given layer +! wgemax: maximum wge +! wgemaxlow: lower wge boundary +! wgemaxup: upper wge boundary +! zero: zero values +! gustij: whether the grid point got gust winds (1) or not (0) + +!!!!!!!!!! Functions +! virtualpottemp: calculates virtual potential temperature + + sfname = 'gustwind_Brasseur01' + + km2=INT(dz/2) + + ugustwind=0. + vgustwind=0. +!! Not needed on climate runs +! ugustlow=0. +! vgustlow=0. +! ugustup=0. +! vgustup=0. + + maxlev=0 + heights=0. + dheights=0. + vpt=0. + wge=0. + !wge_low=0. + !wge_up=0. + + k=1 + IF ((geopoth(k+1)/g-topo) <= hpbl .AND. (k <= dz)) THEN + !!outstring = ' ' // TRIM(sfname) // ' _______' + !!CALL wrf_debug(750, outstring) + !!WRITE(outstring,"(4x,A4,1x,11(A10,1x))")'k','geoph','topo','geo_h','hpbl','pt', 'qr','lr', & + !! 'vpt', 'u', 'v', 'h' + CALL wrf_debug(750, outstring) + END IF +!! 'DO WHILE' does not work +!! DO WHILE (( (geopoth(k+1)/g-topo) <= hpbl) .AND. (k+1 <= dz) ) + DO k=1,dz-1 + IF ( (geopoth(k+1)/g-topo) > hpbl ) THEN + EXIT + ELSE +!! Function does not work. Let's make it with subroutines +!! vpt(k)=virtualpottemp(pt(k), qr(k), lr(k)) + CALL VirtPotTemp(pt(k), qr(k), lr(k), vpt(k)) + heights(k)=geopoth(k)/g-topo + + !!WRITE(outstring,*)' ',k, geopoth(k), topo, geopoth(k)/g-topo, hpbl, pt(k), qr(k), lr(k), & + !! vpt(k), u(k), v(k), heights(k) + !!CALL wrf_debug(750, outstring) + END IF + END DO + Nlevs=k-1 +! +!! Computation of wind gusts only if more than 1 levels behind 'hpbl' are found + + more1lev: IF (Nlevs > 1) THEN + + !wge_up(1:Nlevs,1)=u(1:Nlevs) + !wge_up(1:Nlevs,2)=v(1:Nlevs) + + !!WRITE(outstring,"(3x,A14,1x)")'Integrating...' + !!CALL wrf_debug ( 750, TRIM(outstring) ) + + dheights(1:Nlevs-1)=heights(2:Nlevs)-heights(1:Nlevs-1) + + Ngustlevels=0 + Ngustlowlev=0 + !!WRITE(outstring,"(9(A10,1x))")'ilev','vpt','dvpt','h','dh','tke','tkeInt','dvptInt', '25tke11' + !!CALL wrf_debug(750, outstring) + + dvpt=0. + dvpt(1)=g*(vpt(2)-vpt(1))/vpt(1) + dvpt(2:Nlevs-1)=g*(vpt(3:Nlevs)-vpt(1:Nlevs-2))/vpt(2:Nlevs-1) + dvpt(Nlevs)=g*(vpt(Nlevs)-vpt(Nlevs-1))/vpt(Nlevs) + ilev=1 + !!WRITE(outstring,*)ilev, vpt(ilev), dvpt(ilev), heights(ilev), dheights(ilev), tke(ilev), 0.0, & + !! 0.0, 2.5*tke(ilev)/11. + !!CALL wrf_debug(750, outstring) + + DO ilev=2,Nlevs + tke_int = 0. + vpt_int = 0. + +! Trapezoidal integrations +! CALL NumIntegration(tke,heights,ilev,Nlevs,tke_int) +! CALL NumIntegration(dvpt,heights,ilev,Nlevs,vpt_int) +! Standard integrations + DO k=1,ilev + tke_int = tke_int + tke(k)*dheights(k) + vpt_int = vpt_int + dvpt(k) + END DO + + tke_int=tke_int/heights(ilev) + !!WRITE(outstring,*)ilev, vpt(ilev), dvpt(ilev), heights(ilev), dheights(ilev), tke(ilev), & + !! tke_int, vpt_int, 2.5*tke(ilev)/11. + !!CALL wrf_debug(750, outstring) + + IF (tke_int >= vpt_int) THEN + Ngustlevels=Ngustlevels+1 + gustlevels(Ngustlevels)=ilev + wge(Ngustlevels,1)=u(ilev) + wge(Ngustlevels,2)=v(ilev) + ELSE + ! End of deflection + EXIT + END IF + +! IF (2.5*tke(ilev)/11. >= vpt_int) THEN +! Ngustlowlev=Ngustlowlev+1 +! wge_low(Ngustlowlev,1)=u(ilev) +! wge_low(Ngustlowlev,2)=v(ilev) +! END IF + END DO + + !!WRITE(outstring,*)' ' // TRIM(sfname) // ': Wind gust estimation...' + !!CALL wrf_debug( 750, outstring) + +! gustwind +!! + IF (Ngustlevels > 0 ) THEN + gustij = 1 + wgemax=MAXVAL(SQRT(wge(:,1)*wge(:,1)+wge(:,2)*wge(:,2))) + DO ilev=1,Ngustlevels + IF (ABS(wgemax - SQRT(wge(ilev,1)*wge(ilev,1)+wge(ilev,2)*wge(ilev,2))) < nullv) THEN + maxlev=ilev + EXIT + END IF + END DO + ugust=wge(maxlev,1) + vgust=wge(maxlev,2) + ELSE + gustij = 0 + ugust=0. + vgust=0. + ENDIF + + !!WRITE(outstring,"(5x,A14,1x,I3,1x,3(A10,1x))")'N gust levels:',Ngustlevels,'gust lev', 'u wge', & + !! 'v wge' + !!CALL wrf_debug (750, outstring) + !!DO l=1,Ngustlevels + !!WRITE(outstring,"(22x,I10,1x,2(f10.4,1x))")gustlevels(l),wge(l,1:2) + !!CALL wrf_debug(750,outstring) + !!END DO + +! gustwind lower bound +!! +! IF (Ngustlowlev > 0) THEN +! wgemaxlow=MAXVAL(SQRT(wge_low(:,1)*wge_low(:,1)+wge_low(:,2)*wge_low(:,2))) +! DO ilev=1,Ngustlowlev +! IF (ABS(wgemaxlow - SQRT(wge_low(ilev,1)*wge_low(ilev,1)+wge_low(ilev,2)*wge_low(ilev,2))) & +! < zero) THEN +! maxlev=ilev +! EXIT +! END IF +! END DO +! ugustl=wge_low(maxlev,1) +! vgustl=wge_low(maxlev,2) +! ELSE +! ugustl=0. +! vgustl=0. +! END IF + +! gustwind upperbound +!! +! IF (Nlevs > 0) THEN +! wgemaxup=MAXVAL(SQRT(wge_up(:,1)*wge_up(:,1)+wge_up(:,2)*wge_up(:,2))) +! DO ilev=1,Nlevs +! IF (ABS(wgemaxup - SQRT(wge_up(ilev,1)*wge_up(ilev,1)+wge_up(ilev,2)*wge_up(ilev,2))) < & +! zero ) THEN +! maxlev=ilev +! EXIT +! END IF +! END DO +! ugustu=wge_up(maxlev,1) +! vgustu=wge_up(maxlev,2) +! ELSE +! ugustu=0. +! vgustu=0. +! END IF + ELSE + gustij = 0 + ugust=0. + vgust=0. +! ugustl=0. +! vgustl=0. +! ugustu=0. +! vgustu=0. + END IF more1lev + + ! Rotation of winds to Earth surface +#if (EM_CORE == 1) + ugustwind = ugust*cosa-vgust*sina + vgustwind = vgust*cosa+ugust*sina +! ugustlow = ugustl*cosa-vgustl*sina +! vgustlow = vgustl*cosa+ugustl*sina +! ugustup = ugustu*cosa-vgustu*sina +! vgustup = vgustu*cosa+ugustu*sina +#else + ugustwind = ugust + vgustwind = vgust +! ugustlow = ugustl +! vgustlow = vgustl +! ugustup = ugustu +! vgustup = vgustu +#endif + + ! Some debugging printing + !!outstring = ' ' // TRIM(sfname) // ' _______' + !!CALL wrf_debug(750, outstring) + !!WRITE(outstring,"(5x,6(A12,1x))")'name','u wind','v wind', 'rot. u wind', 'rot. v wind','wind' + !!CALL wrf_debug(750, outstring) + !!WRITE(outstring,"(11x,A12,1x,5(f12.5,1x))")'Gust wind', ugust, vgust, ugustwind, vgustwind, & + !! sqrt(ugustwind*ugustwind+vgustwind*vgustwind) +! CALL wrf_debug(750, outstring) +! WRITE(outstring,"(11x,A12,1x,5(f12.5,1x))")'Low bound', ugustl, vgustl, ugustlow, vgustlow, & +! sqrt(ugustlow*ugustlow+vgustlow*vgustlow) +! CALL wrf_debug(750, outstring) +! WRITE(outstring,"(11x,A12,1x,5(f12.5,1x))")'Upper bound', ugustu, vgustu, ugustup, vgustup, & +! sqrt(ugustup*ugustup+vgustup*vgustup) +! CALL wrf_debug(750, outstring) + + RETURN + + END SUBROUTINE gustwind_Brasseur01 + + REAL FUNCTION virtualpottemp(pt_vpt, r_vpt, l_vpt) +! Function to compute virtual potential temperature + + IMPLICIT NONE + + REAL, INTENT(in) :: pt_vpt, r_vpt, l_vpt +! Local + REAL, PARAMETER :: vptA=0.61 + + virtualpottemp=pt_vpt*(1+vptA*r_vpt-l_vpt) + + RETURN + + END FUNCTION virtualpottemp + + SUBROUTINE VirtPotTemp(pt_vpt, r_vpt, l_vpt, vpt) +! Subroutine to compute virtual potential temperature + + IMPLICIT NONE + + REAL, INTENT(in) :: pt_vpt, r_vpt, l_vpt + REAL, INTENT(out) :: vpt +! Local + REAL, PARAMETER :: vptA=0.61 + + vpt=pt_vpt*(1.+vptA*r_vpt-l_vpt) + + RETURN + + END SUBROUTINE VirtPotTemp + + SUBROUTINE var_zmla_generic(dz, qv, tpot, z, topo, dqvar, refdt, zmla) +! Subroutine to compute pbl-height following a generic method +! from Nielsen-Gammon et al., 2008 J. Appl. Meteor. Clim. +! applied also in Garcia-Diez et al., 2013, QJRMS +! where +! "The technique identifies the ML height as a threshold increase of +! potential temperature from +! its minimum value within the boundary layer." +! here applied similarly to Garcia-Diez et al. where +! zmla = "...first level where potential temperature exceeds the minimum +! potential temperature +! reached in the mixed layer by more than 1.5 K" + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: qv, tpot, z + REAL, INTENT(in) :: topo, dqvar, refdt + REAL, INTENT(out) :: zmla + +! Local + INTEGER :: mldlev, bllev + REAL :: tpotmin + +!!!!!!! Variables +! qv: water vapour mixing ratio +! tpot: potential temperature [K] +! z: height above sea level [m] +! topo: topographic height [m] +! dqvar: Pecentage of difference of mixing ratio used to determine Mixed layer depth +! refdt: Change [K] in temperature to determine boundary layer height +! zmla: boundary layer height [m] + + sfname = 'var_zmla_generic' + + ! MLD = Mixed layer with no substantial variation of mixing ratio /\qv < 10% + ! ? + !PRINT *,' Mixed layer mixing ratios qv[1] lev qv[lev] dqvar% _______' + DO mldlev = 2, dz + IF (ABS(qv(mldlev)-qv(1))/qv(1) > dqvar ) EXIT + ! PRINT *,qv(1), mldlev, qv(mldlev), ABS(qv(mldlev)-qv(1))/qv(1) + END DO + + ! Looking for the minimum potential temperature within the MLD [tpotmin = + ! min(tpot)_0^MLD] + tpotmin = MINVAL(tpot(1:mldlev)) + + ! Determine the first level where tpot > tpotmin + 1.5 K + !PRINT *,' Mixed layer tpotmin lev tpotmin[lev] dtpot _______' + DO bllev = 1, dz + IF (ABS(tpot(bllev)-tpotmin) > refdt ) EXIT + ! PRINT *,tpotmin, bllev, tpot(bllev), ABS(tpot(bllev)-tpotmin) + END DO + + !PRINT *,' height end MLD:', z(mldlev) + !PRINT *,' pbl height:', z(bllev) + + zmla = z(bllev) - topo + + RETURN + + END SUBROUTINE var_zmla_generic + + SUBROUTINE var_bulk_Ri(dz, pt, qv, qc, qs, z, ua, va, ta, ust, ri) + ! Subroutine to compute the bulk Richardson number at all the space + ! after: + ! https://glossary.ametsoc.org/wiki/Bulk_richardson_number + ! Vogelezang and Holtslag, 1996, Bound.-Lay. Meteorol., 81, 245–269, + ! doi:10.1007/BF02430331 + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: pt, qv, qc, qs, z, ua, va, ta + REAL, INTENT(in) :: ust + REAL, DIMENSION(dz), INTENT(out) :: ri + + ! Local + INTEGER :: iz + REAL :: tav, gtav, ri1, ri2, b, tahvb, tahvt + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! pt: potential temperature (K) +! qv: water vapour mixing ratio (kgkg-1) +! qc: cloud mixing ratio (kgkg-1) +! qs: solid species (qs+qi+qg+qh) mixing ratio (kgkg-1) +! z: height [m] +! ua: eastward air wind speed [ms-1] +! va: northward air wind speed [ms-1] +! ust: air friction velocity from the similarity theory [ms-1] + + fname = 'var_bulk_Ri' + + ri = -99999. + + b = 100. + CALL VirtPotTemp(pt(1), qv(1), qc(1), tahvb) + DO iz=1, dz-1 + tav = var_tav(ta(iz), qv(iz), qc(iz), qs(iz)) + gtav = g/tav + CALL VirtPotTemp(pt(iz+1), qv(iz+1), qc(iz+1), tahvt) + ri1 = gtav*(tahvt-tahvb)*(z(iz+1)-z(iz)) + ! Note, ust**2 term is included as a way to take into account turbulence due to surface friction + ! on neutral boundary layer (eq 3 in Vogelezang and Holstlag, 1996) + ri2 = (ua(iz+1)-ua(iz))**2+(va(iz+1)-va(iz))**2+b*ust**2 + ! Let's get only positive values ? + ri(iz) = ABS(ri1/ri2) + tahvb = tahvt + END DO + + RETURN + + END SUBROUTINE var_bulk_Ri + + SUBROUTINE var_zmla_RIgen(dz, ri, zv, topo, rithres, zmla) + ! Subroutine to compute the pbl height using bulk Richardson number + ! Vogelezang and Holtslag, 1996, Bound.-Lay. Meteorol., 81, 245–269, + ! doi:10.1007/BF02430331, + ! Seidel et al., 2012: J. Geophys. Res.-Atmos., 117, 1–15, + ! doi:10.1029/2012JD018143 + ! + ! zmla = ri[z] <= rithres < ri[z+1] or ri[z] >= rithres > ri[z+1] + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, INTENT(in) :: topo, rithres + REAL, DIMENSION(dz), INTENT(in) :: ri, zv + REAL, INTENT(out) :: zmla + + ! Local + INTEGER :: iz + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! ri: 3D bulk Richardson number [-] +! zv: heights [m] +! topo: topography [m] +! rithres: threshold used to determine zmla (0.25 Vogelezang and Hollstag, 1996) + + fname = 'var_zmla_RIgen' + + zmla = -9. + + ! Looking for the height + DO iz=1, dz-1 + IF ( (ri(iz)<=rithres.AND.ri(iz+1)>rithres) .OR. (ri(iz+1)<=rithres.AND.ri(iz)>rithres) ) THEN + zmla = zv(iz) - topo + EXIT + END IF + END DO + + RETURN + + END SUBROUTINE var_zmla_RIgen + + SUBROUTINE var_zwind(d1, u, v, z, u10, v10, sa, ca, newz, unewz, vnewz) +! Subroutine to extrapolate the wind at a given height following the 'power law' methodology +! wss[newz] = wss[z1]*(newz/z1)**alpha +! alpha = (ln(wss[z2])-ln(wss[z1]))/(ln(z2)-ln(z1)) +! AFTER: Phd Thesis: +! Benedicte Jourdier. Ressource eolienne en France metropolitaine : methodes d’evaluation du +! potentiel, variabilite et tendances. Climatologie. Ecole Doctorale Polytechnique, 2015. French +! + + IMPLICIT NONE + + INTEGER, INTENT(in) :: d1 + REAL, DIMENSION(d1), INTENT(in) :: u,v,z + REAL, INTENT(in) :: u10, v10, sa, ca, newz + REAL, INTENT(out) :: unewz, vnewz + +! Local + INTEGER :: inear + REAL :: zaground + REAL, DIMENSION(2) :: v1, v2, zz, alpha, uvnewz + +!!!!!!! Variables +! u,v: vertical wind components [ms-1] +! z: height above surface [m] +! u10,v10: 10-m wind components [ms-1] +! topo: topographical height [m] +! sa, ca: local sine and cosine of map rotation [1.] +! newz: desired height above grpund of extrapolation +! unewz,vnewz: Wind compoonents at the given height [ms-1] + + sfname = 'var_zwind' + + !!WRITE(message,*)' ilev zaground newz z[ilev+1] z[ilev+2] _______' + !!CALL wrf_debug(750,message) + ! Looking for the level below desired height + IF (z(1) < newz ) THEN + DO inear = 1,d1-2 + ! L. Fita, CIMA. Feb. 2018 + !! Choose between extra/inter-polate. Maybe better interpolate? + ! Here we extrapolate from two closest lower levels + !zaground = z(inear+2) + ! Here we interpolate between levels + zaground = z(inear+1) + !!WRITE(message,*)inear, z(inear), newz, z(inear+1), z(inear+2) + !!CALL wrf_debug(750,message) + IF ( zaground >= newz) EXIT + END DO + ELSE + !!WRITE(message,*)1, z(1), newz, z(2), z(3), ' z(1) > newz' + !!CALL wrf_debug(750,message) + inear = d1 - 2 + END IF + + IF (inear == d1-2) THEN + ! No vertical pair of levels is below newz, using 10m wind as first value + ! and the first level as the second + v1(1) = u10 + v1(2) = v10 + v2(1) = u(1) + v2(2) = v(1) + zz(1) = 10. + zz(2) = z(1) + ELSE + v1(1) = u(inear) + v1(2) = v(inear) + v2(1) = u(inear+1) + v2(2) = v(inear+1) + zz(1) = z(inear) + zz(2) = z(inear+1) + END IF + + ! Computing for each component + alpha = (LOG(ABS(v2))-LOG(ABS(v1)))/(LOG(zz(2))-LOG(zz(1))) + !!WRITE(message,*)' Computing with v1:', v1, ' ms-1 v2:', v2, ' ms-1' + !!CALL wrf_debug(750,message) + !!WRITE(message,*)' z1:', zz(1), 'm z2:', zz(2), ' m' + !!CALL wrf_debug(750,message) + !!WRITE(message,*)' alhpa u:', alpha(1), ' alpha 2:', alpha(2) + !!CALL wrf_debug(750,message) + + uvnewz = v1*(newz/zz(1))**alpha + ! Earth-rotation + unewz = uvnewz(1)*ca - uvnewz(2)*sa + vnewz = uvnewz(1)*sa + uvnewz(2)*ca + + !!WRITE(message,*)' result vz:', uvnewz + !!CALL wrf_debug(750,message) + + RETURN + + END SUBROUTINE var_zwind + + SUBROUTINE var_zwind_log(d1, u, v, z, u10, v10, sa, ca, newz, unewz, vnewz) +! Subroutine to extrapolate the wind at a given height following the 'logarithmic law' methodology +! wsz = wss[z2]*(ln(newz)-ln(z0))(ln(z2)-ln(z0)) +! ln(z0) = (ws(z2)*ln(z1)-ws(z1)*ln(z2))/(ws(z2)-ws(z1)) +! AFTER: Phd Thesis: +! Benedicte Jourdier. Ressource eolienne en France metropolitaine : methodes d’evaluation du +! potentiel, variabilite et tendances. Climatologie. Ecole Doctorale +! Polytechnique, 2015. French +! + IMPLICIT NONE + + INTEGER, INTENT(in) :: d1 + REAL, DIMENSION(d1), INTENT(in) :: u,v,z + REAL, INTENT(in) :: u10, v10, sa, ca, newz + REAL, INTENT(out) :: unewz, vnewz + +! Local + INTEGER :: inear + REAL :: zaground + REAL, DIMENSION(2) :: v1, v2, zz, logz0, uvnewz + +!!!!!!! Variables +! u,v: vertical wind components [ms-1] +! z: height above surface on half-mass levels [m] +! u10,v10: 10-m wind components [ms-1] +! sa, ca: local sine and cosine of map rotation [1.] +! newz: desired height above grpund of extrapolation +! unewz,vnewz: Wind compoonents at the given height [ms-1] + + sfname = 'var_zwind_log' + + IF (z(1) < newz ) THEN + DO inear = 1,d1-2 + ! L. Fita, CIMA. Feb. 2018 + !! Choose between extra/inter-polate. Maybe better interpolate? + ! Here we extrapolate from two closest lower levels + !zaground = z(inear+2) + zaground = z(inear+1) + IF ( zaground >= newz) EXIT + END DO + ELSE + inear = d1 - 2 + END IF + + IF (inear == d1-2) THEN + ! No vertical pair of levels is below newz, using 10m wind as first value + ! and the first level as the second + v1(1) = u10 + v1(2) = v10 + v2(1) = u(1) + v2(2) = v(1) + zz(1) = 10. + zz(2) = z(1) + ELSE + v1(1) = u(inear) + v1(2) = v(inear) + v2(1) = u(inear+1) + v2(2) = v(inear+1) + zz(1) = z(inear) + zz(2) = z(inear+1) + END IF + + ! Computing for each component + logz0 = (v2*LOG(zz(1))-v1*LOG(zz(2)))/(v2-v1) + + uvnewz = v2*(LOG(newz)-logz0)/(LOG(zz(2))-logz0) + ! Earth-rotation + unewz = uvnewz(1)*ca - uvnewz(2)*sa + vnewz = uvnewz(1)*sa + uvnewz(2)*ca + + RETURN + + END SUBROUTINE var_zwind_log + + SUBROUTINE univ_func_scal_Businger71(zL, univ_func) + ! Subroutine of the universal functions for scalars according to Businger 1971 + + IMPLICIT NONE + + REAL, INTENT(in) :: zl + REAL, INTENT(out) :: univ_func + + ! Local + REAL, PARAMETER :: kappa = 0.35 + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! zL: height/Obukhov length division [-] + + fname = 'univ_func_scal_Businger71' + + IF (zL > -2. .AND. zL < 0.) THEN + ! Unstable + univ_func = 0.74*(1. - 9.*zL)**(-0.5) + ELSE IF (zL == 0.) THEN + ! Neutral + !! From table 2.7 after T. Foken, 2008, 'Micrometeorology', ed. Springer, + ! ISBN: 978-3-540-74665-2, e-ISBN: 978-3-540-74666-9 + ! univ_func = 1. + ! Although in Businger et al. 1971 + univ_func = 0.74 + ELSE IF (zL > 0. .AND. zL < 1.) THEN + ! Stable (0 < zL < 1) + univ_func = 0.74 + 4.7*zL + ELSE + ! Undefined (zL < -2. .OR. zL > 1.) + !PRINT *,' ' // TRIM(fname) // ': undefined regime zL < -2. .OR. zL > 1. !!, zL=', zL + univ_func = 0. + END IF + + RETURN + + END SUBROUTINE univ_func_scal_Businger71 + + SUBROUTINE stabfunc_scalar_businger(z, L, stabfunc_busingerv) + ! Subroutine of the stability function after Businger et al. (1971), JAS, 28(2), 181-189 + ! NOTE: In Businger's article is said in page 185 right column after equation 18 + ! "... In the atmosphere, the temperature gradient usually vanishes at 100 m or so under + ! unstable conditions, and there is a tendency for this height to decrease with increasing + ! instability... Therefore if Eq. (16) describes the correct height dependence for conditions + ! approaching and incluing free convection, a new scale has to be introduced to replace u*." + ! Therefore, ther is an inherent potential missbehaour of this approximation (L. Fita) + + IMPLICIT NONE + + REAL, INTENT(in) :: z,L + REAL, INTENT(out) :: stabfunc_busingerv + +! Local + REAL :: zL, X, ufunc + REAL, PARAMETER :: kappa = 0.35 + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! z: height [m] +! L: Obukhov length [-] + + fname = 'stabfunc_scalar_businger' + + IF (L /= 0.) THEN + zL = z/L + ELSE + ! Neutral + zL = 0. + END IF + + CALL univ_func_scal_Businger71(zL, ufunc) + !IF (ufunc == 0.) THEN + ! PRINT *,' ' // TRIM(fname) // ': Monin-Obukhov length L', L, ' z', z + !END IF + + IF (zL >= 0.) THEN + ! Stable case + stabfunc_busingerv = 1.- ufunc + ELSE IF (zL < 0.) THEN + ! unstable + X = 1./ufunc + !stabfunc_busingerv = -2.*LOG((1.+X)/2.)-LOG((1.+X**2)/2.)+2.*ATAN(X)-piconst/2. + stabfunc_busingerv = LOG( ((1.+X)/2.)**2. ) + END IF + + RETURN + + END SUBROUTINE stabfunc_scalar_businger + + SUBROUTINE var_ztaqv_MOtheor(dz, ta, qv, z, ust, znt, rmol, topo, newz, taznew, qvznew) + ! Subroutine of temperature and water vapour extrapolation following Moin-Obukhov Similarity theory + ! R. B. Stull, 1988, Springer (p376-383) + ! NOTE only usefull for newz < 80. m (outside surface layer of the PBL) + ! + ! Here, the profiles for scalars will be used from Businger 1971. + ! Model does not provide t*, neither q*, therefore we need to introduce a 4-step methodology to + ! extrapolate the amounts (example for ta, the same for qv) + ! + ! 1. Compute the increment (e.g. /\ta' = ta(k+1)-ta(k)) of the variable respect a known heights + ! (at vertical levels k and k+1) from the 3-dimensional atmospheric temperature field + ! 2. Infer ta∗ + ! 3. Compute the increment between one of the 3-dimensional temperatures and the desired height + ! using ta∗ (e.g. /\ta'' = ta(k)-ta(zd)), to obtain ta0 + ! 4. Obtain ta(zd) + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, INTENT(in) :: ust, znt, rmol, topo + REAL, DIMENSION(dz), INTENT(in) :: ta, qv, z + REAL, INTENT(in) :: newz + REAL, INTENT(out) :: taznew, qvznew + +! Local + INTEGER :: k, kclosest + REAL, PARAMETER :: kappa = 0.35 + REAL :: hgt, hgtp1 + REAL :: delta_ta, delta_ta2 + REAL :: delta_qv, delta_qv2 + REAL :: OL + REAL :: stability, stabilityp1, stabilitynewz + REAL :: tast, qvst + REAL :: wsz, alpha + REAL :: minta, minqv, maxta, maxqv + REAL, DIMENSION(2) :: uvnewz + +!!!!!!! Variables +! dz: vertical levels +! ta: 3-dimensional air temperature [K] +! qv: 3-dimensional water vapour [kgkg-1] +! z: 3-dimensional height [m] +! ust: u* in similarity theory [ms-1] +! z0: roughness length [m] +!!! L. Fita, CIMA. Feb. 2018 +!! NOT SURE if it should be z0 instead? +! znt: thermal time-varying roughness length [m] +! rmol: inverse of Obukhov length [m-1] +! topo: topographical height [m] +! + sfname = 'var_ztaqv_MOtheor' + + ! 1.- /\ta' = ta(k+1) - ta(k) + + k = 1 + hgt = z(k)-topo + hgtp1 = z(k+1)-topo + + ! We can only apply the technique within Monin-Obukhov range, therfore + IF (hgt*rmol > -2. .AND. hgt*rmol < 1. .AND. hgtp1*rmol > -2. .AND. hgtp1*rmol < 1.) THEN + + delta_ta = ta(k+1)-ta(k) + delta_qv = qv(k+1)-qv(k) + + ! 2.- infer ta* + ! ta* = kappa*(delta_ta) / (ln(hgtp1/hgt) - Psi_scalar(hgt/OL) + Psi_scalar(hgtp1/OL)) + ! + ! Psi_scalar: stability functions for scalars, Psi=func(phi(z,OL,stab.)), phi: universal function + ! (Businger, 19671) + ! OL: Obukhov length, stab.: stability + + ! Obukhov Length (using the Boussinesq approximation) + OL = 1./rmol + + ! Stability function + CALL stabfunc_scalar_businger(hgt, OL, stability) + CALL stabfunc_scalar_businger(hgtp1, OL, stabilityp1) + + tast = kappa*(delta_ta)/(LOG(hgtp1/hgt) - stability + stabilityp1) + qvst = kappa*(delta_qv)/(LOG(hgtp1/hgt) - stability + stabilityp1) + + ! 3.+4.- /\ta' = ta(k) - ta(kd) + ! ta(kd) = ta(hgt) - ta*/kappa*(ln(hgt/newz) - Psi_scalar(hgt/OL) + Psi_scalar(newz/OL)) + + CALL stabfunc_scalar_businger(newz, OL, stabilitynewz) + + IF (hgt > newz) THEN + taznew = ta(k) - tast/kappa*( LOG(hgt/newz) - stabilitynewz + stability) + qvznew = qv(k) - qvst/kappa*( LOG(hgt/newz) - stabilitynewz + stability) + ELSE IF (hgt < newz) THEN + taznew = tast/kappa*( LOG(hgt/newz) - stabilitynewz + stability) + ta(k) + qvznew = qvst/kappa*( LOG(hgt/newz) - stabilitynewz + stability) + qv(k) + ELSE + taznew = ta(k) + qvznew = qv(k) + END IF + + ! Checking for consistency, limiting the extrapolated value to the range of values at k, k+1 + minta = MIN(ta(k), ta(k+1)) + minqv = MIN(qv(k), qv(k+1)) + maxta = MAX(ta(k), ta(k+1)) + maxqv = MAX(qv(k), qv(k+1)) + IF (ABS(hgt - newz) < ABS(hgtp1 - newz)) THEN + kclosest = k + ELSE + kclosest = k+1 + END IF + IF (taznew < minta) taznew = ta(kclosest) + IF (qvznew < minqv) qvznew = qv(kclosest) + IF (taznew > maxta) taznew = ta(kclosest) + IF (qvznew > maxta) qvznew = qv(kclosest) + + ELSE + ! Linear interpolation. Something better? + taznew = interpolate1D(dz, z-topo, ta, newz) + qvznew = interpolate1D(dz, z-topo, qv, newz) + END IF + + RETURN + + END SUBROUTINE var_ztaqv_MOtheor + + SUBROUTINE var_zwind_MOtheor(dz, ua, va, z, topo, ust, znt, rmol, u10, v10, sa, ca, newz, uznew, & + vznew) + ! Subroutine of wind extrapolation following Moin-Obukhov theory R. B. Stull, 1988, + ! Springer (p376-383) + ! NOTE only usefull for newz < 80. m and within turbelence driven layer + ! newz/L > -2. & newz/L < 1. + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, INTENT(in) :: topo, ust, znt, rmol, u10, v10, sa, ca + REAL, INTENT(in) :: newz + REAL, DIMENSION(dz), INTENT(in) :: ua, va, z + REAL, INTENT(out) :: uznew, vznew + +! Local + REAL :: OL + REAL :: stability + REAL :: wsz, alpha + REAL, DIMENSION(2) :: uvnewz + +!!!!!!! Variables +! dz: amount of vertical layers +! ua,va: 3D wind speed [ms-1] +! z: height of the levels [m] +! topo: topography [m] +! ust: u* in similarity theory [ms-1] +! z0: roughness length [m] +!!! L. Fita, CIMA. Feb. 2018 +!! NOT SURE if it should be z0 instead? +! znt: thermal time-varying roughness length [m] +! rmol: inverse of Obukhov length [m-1] +! u10: x-component 10-m wind speed [ms-1] +! v10: y-component 10-m wind speed [ms-1] +! sa, ca: local sine and cosine of map rotation [1.] +! + sfname = 'var_zwind_MOtheor' + + ! We can only apply the technique within Monin-Obukhov range, therfore + IF (newz*rmol > -2. .AND. newz*rmol < 1.) THEN + + ! Obukhov Length (using the Boussinesq approximation giving Tv from t2) + OL = 1/rmol + + ! Wind speed at desired height + CALL stabfunc_businger(newz,OL,stability) + wsz = ust/karman*( LOG(newz/znt) + stability) + + ! Without taking into account rotation of winds due to Ekman pumping, etc... redistributed by + ! components unsing 10-m wind as reference... + alpha = ATAN2(v10,u10) + uvnewz(1) = wsz*COS(alpha) + uvnewz(2) = wsz*SIN(alpha) + + ELSE + ! Linear interpolation. Something better? + uvnewz(1) = interpolate1D(dz, z-topo, ua, newz) + uvnewz(2) = interpolate1D(dz, z-topo, va, newz) + + END IF + + ! Earth-rotation + uznew = uvnewz(1)*ca - uvnewz(2)*sa + vznew = uvnewz(1)*sa + uvnewz(2)*ca + + RETURN + + END SUBROUTINE var_zwind_MOtheor + + ! L. Fita, CIMA. Feb. 2018 + ! WRF seems to have problems with my functions, let'suse subroutine instead + !REAL FUNCTION stabfunc_businger(z,L) + SUBROUTINE stabfunc_businger(z,L,stabfunc_busingerv) + ! Fucntion of the stability function after Businger et al. (1971), JAS, 28(2), 181–189 + + IMPLICIT NONE + + REAL, INTENT(in) :: z,L + REAL, INTENT(out) :: stabfunc_busingerv + +! Local + REAL :: zL, X + +!!!!!!! Variables +! z: height [m] +! L: Obukhov length [-] + + sfname = 'stabfunc_businger' + + IF (L /= 0.) THEN + zL = z/L + ELSE + ! Neutral + zL = 0. + END IF + + IF (zL > 0.) THEN + ! Stable case + stabfunc_busingerv = 4.7*z/L + ELSE IF (zL < 0.) THEN + ! unstable + X = (1. - 15.*z/L)**(0.25) + !stabfunc_busingerv = -2.*LOG((1.+X)/2.)-LOG((1.+X**2)/2.)+2.*ATAN(X)-piconst/2. + stabfunc_busingerv = LOG( ((1.+X**2)/2.)*((1.+X)/2.)**2)-2.*ATAN(X)+piconst/2. + ELSE + stabfunc_busingerv = 0. + END IF + + RETURN + +! END FUNCTION stabfunc_businger + END SUBROUTINE stabfunc_businger + + SUBROUTINE var_potevap_bulk(rho1, cd, uas, vas, ts, ps, qv1, potevap) +! Subroutine to compute the generic potential evapotranspiration following simple bulk formulation +! Manabe, S., (1969): Climate and the ocean circulation, 1. the atmospheric circulation and the hydrology of +! the earth's surface, Mon. Weather Rev., 97, 739-774 +! potevap = dt*rho1*qc*(q2sat-qv1) + + IMPLICIT NONE + + REAL, INTENT(in) :: rho1, cd, uas, vas, ts, ps, qv1 + REAL, INTENT(out) :: potevap + +! Local + REAL :: qsol_sat, qc + +!!!!!!! Variables +! rho1: atsmophere density at the first layer [kgm-3] +! cd: drag coefficient [-] +! uas, vas: x/y-components of 10-m wind [ms-1] +! ts: surface temperature [K] +! ps: surface pressure [Pa] +! qv1: 1st layer atmospheric mixing ratio [kgkg-1] +! potevap: potential evapo transpiration [kgm-2s-1] + sfname = 'var_potevap_bulk' + + ! qsol_sat: Saturated air at ts + qsol_sat = SaturationMixingRatio(ts, ps) + + ! qc: surface drag coefficient + qc = SQRT(uas**2 + vas**2)*cd + + potevap = MAX(zeroRK, rho1*qc*(qsol_sat - qv1)) + + END SUBROUTINE var_potevap_bulk + + SUBROUTINE var_potevap_Milly92(rho1, cd, uas, vas, tsk, ta1, ps, qv1, sfcevap, emiss, potevap) +! Subroutine to compute the potential bulk evapotranspiration with Milly 1992 correction +! Milly, P. C. D. (1992): Potential evaporation and soil moisture in general circulation models, +! J. Climate, 5, 209–226 +! potevap = potevap_bulk*[1./(1.+correction_Milly)] +! ETp(Ts) = potevap_bulk(Ts) = (dens/ra)*[qs(Ts) − qa] +! ETp(Tv) = (dens/ra)*[qs(Tv) − qa] +! correction_Milly = [ETp(Ts) - ETp(Tv)]/ETp(Tw) +! see more details in: +! A. Barella-Ortiz et al., (2013), Hydrol. Earth Syst. Sci., 17, 4625-4639 +! + IMPLICIT NONE + + REAL, INTENT(in) :: rho1, cd, uas, vas, tsk, ta1, ps, qv1, & + sfcevap, emiss + REAL, INTENT(out) :: potevap + +! Local + REAL :: qsol_sat, qc + REAL :: ta_05, ta05 + REAL :: potevapo_bulk, beta, derivT_qsol_sat + REAL :: correction_Milly, corr_Milly1, & + corr_Milly2, corr_Milly + +!!!!!!! Variables +! rho1: atsmophere density at the first layer [kgm-3] +! cd: drag coefficient [-] +! uas, vas: x/y-components of 10-m wind [ms-1] +! tsk: surface skin temperature +! ta1: 1st level air-temperature [K] +! ps: surface pressure [Pa] +! qv1: 1st layer atmospheric mixing ratio [kgkg-1] +! sfcevap: surface eavporation flux [Wm-2s-1] +! emiss: emissivity [1] +! potevap: potential evapo transpiration [kgm-2s-1] + sfname = 'var_potevap_Milly92' + + ! qsol_sat: Saturated air by tsk + qsol_sat = SaturationMixingRatio(tsk, ps) + + ! qc: surface drag coefficient + qc = SQRT(uas**2 + vas**2)*cd + + ! Bulk potential evapotranspiration + potevapo_bulk = rho1*qc*(qsol_sat-qv1) + + ! Moisture availability function (in a similar way is done in ORCHIDEE) + ! beta = sfcevap / potevapo_bulk + beta = sfcevap / potevapo_bulk + + ! derivT_qsol_sat: Derivative of Saturated air by ta1 + ! Using numerical 1st order approximation + ! derivT_qsol_sat(T) = [qsol_sat(T+h) - qsol_sat(T-h)]/(2h) + ta_05 = ta1-halfRK + ta05 = ta1+halfRK + derivT_qsol_sat = (SaturationMixingRatio(ta05, ps) - SaturationMixingRatio(ta_05, ps)) / (2.*halfRK) + + ! Milly's correction + corr_Milly1 = XLV*rho1*qc*derivT_qsol_sat*(1.-beta) + corr_Milly2 = 4.*emiss*STBOLT*ta1**3 + rho1*Cp*qc + XLV*rho1*qc*derivT_qsol_sat*beta + correction_Milly = corr_Milly1 / corr_Milly2 + corr_Milly = 1./(1. + correction_Milly) + + potevap = MAX(zeroRK, potevapo_bulk*corr_Milly) + + END SUBROUTINE var_potevap_Milly92 + + SUBROUTINE var_potevap_bulkgen(rho1, ust, uas, vas, ts, ps, qv1, potevap) +! Subroutine to compute the generic potential evapotranspiration following simple bulk formulation +! Manabe, S., (1969): Climate and the ocean circulation, 1. the atmospheric circulation and the hydrology of +! the earth's surface, Mon. Weather Rev., 97, 739-774 +! potevap = dt*rho1*qc*(q2sat-qv1) + + IMPLICIT NONE + + REAL, INTENT(in) :: rho1, ust, uas, vas, ts, ps, qv1 + REAL, INTENT(out) :: potevap + +! Local + REAL :: qsol_sat, Cd, qc + +!!!!!!! Variables +! rho1: atsmophere density at the first layer [kgm-3] +! ust: u* in similarity theory [ms-1] +! uas, vas: x/y-components of 10-m wind [ms-1] +! ts: surface temperature [K] +! ps: surface pressure [Pa] +! qv1: 1st layer atmospheric mixing ratio [kgkg-1] +! potevap: potential evapo transpiration [kgm-2s-1] + sfname = 'var_potevap_bulkgen' + + ! qsol_sat: Saturated air at ts + qsol_sat = SaturationMixingRatio(ts, ps) + + ! Cd: drag coeffiecient + CALL Cdrag_0(ust, uas, vas, Cd) + + ! qc: surface drag coefficient + qc = SQRT(uas**2 + vas**2)*Cd + + potevap = MAX(zeroRK, rho1*qc*(qsol_sat - qv1)) + + END SUBROUTINE var_potevap_bulkgen + + SUBROUTINE var_potevap_Milly92gen(rho1, ust, uas, vas, tsk, ta1, ps, qv1, sfcevap, emiss, potevap) +! Subroutine to compute the genric potential bulk evapotranspiration with Milly 1992 correction +! Milly, P. C. D. (1992): Potential evaporation and soil moisture in general circulation models, +! J. Climate, 5, 209–226 +! potevap = potevap_bulk*[1./(1.+correction_Milly)] +! ETp(Ts) = potevap_bulk(Ts) = (dens/ra)*[qs(Ts) − qa] +! ETp(Tv) = (dens/ra)*[qs(Tv) − qa] +! correction_Milly = [ETp(Ts) - ETp(Tv)]/ETp(Tw) +! see more details in: +! A. Barella-Ortiz et al., (2013), Hydrol. Earth Syst. Sci., 17, 4625-4639 +! + IMPLICIT NONE + + REAL, INTENT(in) :: rho1, ust, uas, vas, tsk, ta1, ps, qv1, & + sfcevap, emiss + REAL, INTENT(out) :: potevap + +! Local + REAL :: qsol_sat, Cd, qc + REAL :: ta_05, ta05 + REAL :: potevapo_bulk, beta, derivT_qsol_sat + REAL :: correction_Milly, corr_Milly1, & + corr_Milly2, corr_Milly + +!!!!!!! Variables +! rho1: atsmophere density at the first layer [kgm-3] +! ust: u* in similarity theory [ms-1] +! uas, vas: x/y-components of 10-m wind [ms-1] +! tsk: surface skin temperature +! ta1: 1st level air-temperature [K] +! ps: surface pressure [Pa] +! qv1: 1st layer atmospheric mixing ratio [kgkg-1] +! sfcevap: surface eavporation flux [Wm-2s-1] +! emiss: emissivity [1] +! potevap: potential evapo transpiration [kgm-2s-1] + sfname = 'var_potevap_Milly92gen' + + ! qsol_sat: Saturated air by tsk + qsol_sat = SaturationMixingRatio(tsk, ps) + + ! Cd: drag coeffiecient + CALL Cdrag_0(ust, uas, vas, Cd) + + ! qc: surface drag coefficient + qc = SQRT(uas**2 + vas**2)*Cd + + ! Bulk potential evapotranspiration + potevapo_bulk = rho1*qc*(qsol_sat-qv1) + + ! Moisture availability function (in a similar way is done in ORCHIDEE) + ! beta = sfcevap / potevapo_bulk + beta = sfcevap / potevapo_bulk + + ! derivT_qsol_sat: Derivative of Saturated air by ta1 + ! Using numerical 1st order approximation + ! derivT_qsol_sat(T) = [qsol_sat(T+h) - qsol_sat(T-h)]/(2h) + ta_05 = ta1-halfRK + ta05 = ta1+halfRK + derivT_qsol_sat = (SaturationMixingRatio(ta05, ps) - SaturationMixingRatio(ta_05, ps)) / (2.*halfRK) + + ! Milly's correction + corr_Milly1 = XLV*rho1*qc*derivT_qsol_sat*(1.-beta) + corr_Milly2 = 4.*emiss*STBOLT*ta1**3 + rho1*Cp*qc + XLV*rho1*qc*derivT_qsol_sat*beta + correction_Milly = corr_Milly1 / corr_Milly2 + corr_Milly = 1./(1. + correction_Milly) + + potevap = MAX(zeroRK, potevapo_bulk*corr_Milly) + + END SUBROUTINE var_potevap_Milly92gen + + SUBROUTINE var_fog_K84(qc, qi, fog, vis) + ! Computation of fog (vis < 1km) only computed where qcloud, qice /= 0. + ! And visibility following Kunkel, B. A., (1984): Parameterization of droplet terminal velocity and + ! extinction coefficient in fog models. J. Climate Appl. Meteor., 23, 34–41. + + IMPLICIT NONE + + REAL, INTENT(in) :: qc, qi + INTEGER, INTENT(out) :: fog + REAL, INTENT(out) :: vis + +! Local + REAL :: visc, visi + +!!!!!!! Variables +! qc: cloud mixing ratio [kgkg-1] +! qi, ice mixing ratio [kgkg-1] +! fog: presence of fog (1: yes, 0: no) +! vis: visibility within fog [km] + + sfname = 'var_fog_K84' + + IF (qi > nullv .OR. qc > nullv) THEN + visc = 100000.*oneRK + visi = 100000.*oneRK + ! From: Gultepe, 2006, JAM, 45, 1469-1480 + IF (qc > nullv) visc = 0.027*(qc*1000.)**(-0.88) + IF (qi > nullv) visi = 0.024*(qi*1000.)**(-1.0) + ! Getting the lowest visibility + vis = MINVAL((/visc, visi/)) + IF (vis <= oneRK) THEN + fog = 1 + ELSE + fog = 0 + vis = -oneRK + END IF + ELSE + fog = 0 + vis = -oneRK + END IF + + END SUBROUTINE var_fog_K84 + + SUBROUTINE var_fog_RUC(rhv, fog, vis) + ! Computation of fog (vis < 1km) only computed where qcloud, qice /= 0. + ! And visibility following RUC method Smirnova, T. G., S. G. Benjamin, and J. M. Brown, 2000: Case + ! study verification of RUC/MAPS fog and visibility forecasts. Preprints, 9 th Conference on + ! Aviation, Range, and Aerospace Meteorlogy, AMS, Orlando, FL, Sep. 2000. Paper#2.3, 6 pp. + + IMPLICIT NONE + + REAL, INTENT(in) :: rhv + INTEGER, INTENT(out) :: fog + REAL, INTENT(out) :: vis + +! Local + REAL :: rh + +!!!!!!! Variables +! rh: relative humidty [1] +! vis: visibility within fog [km] + + sfname = 'var_fog_RUC' + + ! Avoiding supersaturation + rh = MINVAL((/1.,rhv/)) + + IF (rh > 0.3) THEN + ! From: Gultepe, I., and G. Isaac, 2006: Visbility versus precipitation rate and relative + ! humidity. Preprints, 12th Cloud Physics Conf, Madison, WI, Amer. Meteor. Soc., P2.55. + ! [Available online at http://ams.confex.com/ams/Madison2006/techprogram/paper_l13177.htm] + vis = 60.*EXP(-2.5*(rh*100.-15.)/80.) + IF (vis <= oneRK) THEN + fog = 1 + ELSE + fog = 0 + vis = -oneRK + END IF + ELSE + fog = 0 + vis = -oneRK + END IF + + END SUBROUTINE var_fog_RUC + + SUBROUTINE var_fog_FRAML50(rhv, fog, vis) + ! Computation of fog (vis < 1km) + ! And visibility following Gultepe, I. and J.A. Milbrandt, 2010: Probabilistic Parameterizations + ! of Visibility Using Observations of Rain Precipitation Rate, Relative Humidity, and Visibility. + ! J. Appl. Meteor. Climatol., 49, 36-46, https://doi.org/10.1175/2009JAMC1927.1 + ! Interest is focused on a 'general' fog/visibilty approach, thus the fit at 50 % of probability + ! is chosen + ! Effects from precipitation are not considered + + IMPLICIT NONE + + REAL, INTENT(in) :: rhv + INTEGER, INTENT(out) :: fog + REAL, INTENT(out) :: vis + +! Local + REAL :: rh + +!!!!!!! Variables +! rhv: relative humidty [1] +! fog: presence of fog (1: yes, 0: no) +! vis: visibility within fog [km] + + sfname = 'var_fog_FRAML50' + + ! Avoiding supersaturation + rh = MINVAL((/1.,rhv/)) + + IF (rh > 0.3) THEN + vis = -5.19*10.**(-10)*(rh*100.)**5.44+40.10 + ! Fog definition (vis <= 1. km) + IF (vis <= oneRK) THEN + fog = 1 + ELSE + vis = -oneRK + fog = 0 + END IF + ELSE + vis = -oneRK + fog = 0 + END IF + + END SUBROUTINE var_fog_FRAML50 + + SUBROUTINE var_tds(hurs, tas, tds) +! Subroutine to compute dew point temperature at 2m using August-Roche-Magnus approximation [k] + + IMPLICIT NONE + + REAL, INTENT(in) :: hurs, tas + REAL, INTENT(out) :: tds + +! Local + REAL :: gammatarh + +!!!!!!! Variables +! hurs: 2m relative humidity [1] +! tds: dew point temperature [k] + + sfname = 'var_tds' + + gammatarh = LOG(hurs) + ARM2*(tas-SVPT0)/((tas-SVPT0)+ARM3) + tds = ARM3*gammatarh/(ARM2-gammatarh) + SVPT0 + + RETURN + + END SUBROUTINE var_tds + + SUBROUTINE var_tws_S11(ta0, hur0, tws) +! Subroutine to compute wet bulb temperature using equation after: +! Stull, R. (2011), J. Appl. Meteor. Climatol. 50(11):2267-2269. doi: 10.1175/JAMC-D-11-0143.1 + + IMPLICIT NONE + + REAL, INTENT(in) :: ta0, hur0 + REAL, INTENT(out) :: tws + +! Local + REAL :: ta, hur + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! ta0: temperature [K] (does it only make sense if it is at 2 m?) +! hur0: relative humidity [1] (does it only make sense if it is at 2 m?) +! tws: wet bulb temperature [C] + + fname = 'var_tws_S11' + + ta = ta0 - SVPT0 + hur = hur0*100.*oneRK + + tws = ta * ATAN(0.151977*SQRT(hur+8.313659)) + ATAN(ta+hur) - ATAN(hur-1.676331) + & + 0.00391838*(hur)**(1.5)*ATAN(0.023101*hur) - 4.686035 + + RETURN + + END SUBROUTINE var_tws_S11 + + SUBROUTINE var_residencetime_2var2D(vals1, vals2, Nrng1, Nrng2, rng1, rng2, ir1, ir2) +! Subroutine to compute the time of residence of two 2D variables for a single time-step +! +! Time of residence: accumulated time passed within a given range of variables +! + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nrng1, Nrng2 + REAL, DIMENSION(Nrng1), INTENT(in) :: rng1 + REAL, DIMENSION(Nrng2), INTENT(in) :: rng2 + REAL, INTENT(in) :: vals1, vals2 + INTEGER, INTENT(out) :: ir1, ir2 + + ! Local + INTEGER :: ir + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! vals[1/2]: values of the variable 1 and 2 +! Nrng[1/2]: amount of intervals + 1 along the variable 1/2 +! rng[1/2]: intervals along the variable 1/2 +! dt: interval of time (in seconds) +! tresidence2D: 2D time of residence, the amount of time passed simultaneously within rangeN of var 1 +! and rangeM of var2 + + fname = 'var_residencetime_2var2D' + + ! inicialization + ir1 = -1 + ir2 = -1 + + ! Looking for the varibale1's bin + IF (vals1 < rng1(1)) THEN + ir1 = 1 + ELSE IF (vals1 >= rng1(Nrng1-1)) THEN + ir1 = Nrng1 + ELSE + DO ir=1, Nrng1-2 + IF (vals1 >= rng1(ir) .AND. vals1 < rng1(ir+1)) THEN + ir1 = ir+1 + END IF + END DO + END IF + + ! Looking for the varibale2's bin + IF (vals2 < rng2(1)) THEN + ir2 = 1 + ELSE IF (vals2 >= rng2(Nrng2-1)) THEN + ir2 = Nrng2 + ELSE + DO ir=1, Nrng2-2 + IF (vals2 >= rng2(ir) .AND. vals2 < rng2(ir+1)) THEN + ir2 = ir+1 + END IF + END DO + END IF + + ! Checking consistency + ! L. Fita, January 2024. Removed for efficiency + ! If you encounter problems with the variable, remove it and re-compile without clean -a +! IF (ir1 == -1 .OR. ir2 == -1) THEN +! PRINT *,' ' // TRIM(fname) // ': Unsuccesfull allocation of var1:', vals1,' var2:', vals2 +! PRINT *,' resultant ir1=', ir1, ' ir2=', ir2 +! PRINT 23,'var1 bins: ', rng1 +! PRINT 23,'var2 bins:', rng2 +! END IF + + 23 FORMAT(4x,A10,50(F86.2)) + + RETURN + + END SUBROUTINE var_residencetime_2var2D + + REAL FUNCTION zero_isotherm1D(dz, ta, hgt) + ! Function to compute 1D 0-isotherm + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dz + REAL, DIMENSION(dz), INTENT(in) :: ta, hgt + + ! Local + INTEGER :: iz, i0ta + REAL :: zeroK + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! dz: amount of vertical levels +! ta: vertical temperature [K] +! hgt: height above ground (zg/9.81 - topo) [m] +! interp: whether height should be interpolated or provide the closest level + + fname = 'zero_isotherm1D' + + zero_isotherm1D = 1.e20 + + zeroK = 273.15 + + zero_isotherm1D = interpolate1D(dz, ta, hgt, zeroK) + + RETURN + + END FUNCTION zero_isotherm1D + +!!! +! Operations +!!! + + SUBROUTINE massconserv_vinterp1D(dorig, levorig, dorig1, btlevorig, valsorig, ddes, levdes, & + ddes1, btlevdes, valsdes) + ! Subrotine to mass-conservative vertically interpolate a variable 1D + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dorig, ddes, dorig1, ddes1 + REAL, DIMENSION(dorig), INTENT(in) :: levorig, valsorig + REAL, DIMENSION(dorig1), INTENT(in) :: btlevorig + REAL, DIMENSION(ddes), INTENT(in) :: levdes + REAL, DIMENSION(ddes1), INTENT(in) :: btlevdes + REAL, DIMENSION(ddes), INTENT(out) :: valsdes + + ! Local + INTEGER :: ko, kd + REAL :: deskm1, deskp1 + REAL :: orikm1, orikp1 + REAL :: Dlevorig, delta_levorig, Dlevdes + REAL :: delta_desm1, delta_desp1 + REAL :: deltatop_levorig, deltabot_levorig + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! dorig: Original amount of vertical levels +! levorig: original values of the levels (centerd into the level) [m] +! valsorig: original values of the field at the original levels (as density or similar [kgm-3]) +! dorig1: original amount of vertical levels + 1 +! btlevorig: bottom, tops of the original cells [m] +! btlev(k) < lev(k) < btlev(k+1) +! ddes: desired amount of vertical levels +! levdes: desired levels [m] +! ddes1: desired amount of vertical levels + 1 +! btlevdes: bottom, tops of the desired cells [m] +! valsdest: mass-conservative interpolated values (as density or similar [kgm-3]) + + fname = 'massconserv_vinterp1D' + + valsdes = zeroRK + + ! Let's be efficient + + ! Assuming surface -> top vertical layers and Xsfc < Xtop (as the case with height...) + + ! Here comes the proper integration, where the values of the original cells within the range + ! of the desired cell, are added according to the percentage of the height of the original + ! cell that lays within the range of the desired cell + ! + ! valsdes(kd) = SUM_Nlev(delta_levorig(ko)*valsorig(ko)) + + ! deltatop_levorig(itopkin)*valsorig(itopkin) + deltabot_levorig(ibotkin)*valsorig(ibotkin) + ! + ! valdes(kd) = valdes(kd) / Dlevdes + ! + ! where: + ! Dlevdes = deskp1 - deskm1 + ! Dlevorig = orikp1 - orikm1 + ! + ! delta_levorig(ko) = Dlevorig - delta_desm1 - delta_desp1 + ! + ! delta_desm1 = + ! deskm1 - orikm1; deskm1 > orikm1 + ! 0; deskm1 < orikm1 + ! delta_desp1 = + ! orikp1 - deskp1; deskp1 < orikp1 + ! 0; deskp1 > orikp1 + ! + ! deltatop_levorig(itopkin) = orikp1 - deskm1 + ! deltabot_levorig(ibotkin) = deskp1 - orikm1 + ! + ! being: + ! orikm1: value at the base of the original cell + ! orikp1: value at the top of the original cell + ! deskm1: value at the base of the desired cell + ! deskp1: value at the top of the desired cell + ! Nlev: amount of original levels within the height of the kd-desired cell + ! Nlev = orilev(ko) <= deskm1 .and. orilev(ko) > deskp1 + + DO kd=1, ddes + + ! Cell's bottom + deskm1 = btlevdes(kd) + ! Cell0s top + deskp1 = btlevdes(kd+1) + + Dlevdes = deskp1 - deskm1 + + ! Looking for the original cells within the range of the desired cell + DO ko=1, dorig + ! original cell's top + orikp1 = btlevorig(ko+1) + + ! original cell's bottom + orikm1 = btlevorig(ko) + + IF (levorig(ko) >= deskm1 .AND. levorig(ko) < deskp1) THEN + ! Center of the columns + + Dlevorig = orikp1 - orikm1 + IF (deskm1 > orikm1) THEN + delta_desm1 = deskm1 - orikm1 + ELSE + delta_desm1 = zeroRK + END IF + IF (deskp1 < orikp1) THEN + delta_desp1 = orikp1 - deskp1 + ELSE + delta_desp1 = zeroRK + END IF + + delta_levorig = Dlevorig - delta_desm1 - delta_desp1 + + valsdes(kd) = valsdes(kd) + delta_levorig*valsorig(ko) + + ELSE IF (orikp1 > deskm1 .AND. levorig(ko) < deskm1) THEN + ! We might have only top of the original columns wihtin the range + + deltatop_levorig = orikp1 - deskm1 + + valsdes(kd) = valsdes(kd) + deltatop_levorig*valsorig(ko) + + ELSE IF (orikm1 < deskp1 .AND. levorig(ko) > deskp1) THEN + ! We might have only base of the original columns wihtin the range + + deltabot_levorig = deskp1 - orikm1 + + valsdes(kd) = valsdes(kd) + deltabot_levorig*valsorig(ko) + + ELSE IF (orikm1 > deskp1) THEN + EXIT + + END IF + + END DO + + valsdes(kd) = valsdes(kd)/Dlevdes + + END DO + + RETURN + + END SUBROUTINE massconserv_vinterp1D + + SUBROUTINE presbars_to_hgtbars(topo, dzs, zg, dz, oripres, psfc, ptop, dpres, despressv, & + firstrightlev, Nrightlevs, rightdespressv, hgts, bthgts) + ! Subroutine to transform from desired bars defined by their central pressures to bars in height + ! coordinates using model's geopotential to define its heights + + IMPLICIT NONE + + INTEGER, INTENT(in) :: dpres, dz, dzs + REAL, DIMENSION(dpres), INTENT(in) :: despressv + REAL, INTENT(in) :: topo, psfc, ptop + REAL, DIMENSION(dzs), INTENT(in) :: zg + REAL, DIMENSION(dz), INTENT(in) :: oripres + INTEGER, INTENT(out) :: firstrightlev, Nrightlevs + REAL, DIMENSION(dpres), INTENT(out) :: hgts, rightdespressv + REAL, DIMENSION(dpres,2), INTENT(out) :: bthgts + + ! Local + INTEGER :: k, ko, dzstag + REAL :: botpressv + REAL :: a, b + REAL, DIMENSION(dz) :: orihgt + REAL, DIMENSION(dzs) :: oribthgt + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! topo: topography [m] +! dzs: amount of geopotential heights +! zg: geopotential heights [m2s-2] +! dz: amount of original pressure +! oripres: original pressure values [Pa] +! psfc: pressure at the surfrace [Pa] +! ptop: pressure at the top [Pa] +! dpres: amount of desired pressure levels +! despressv: desired pressure levels [Pa] +! Nrightlevs: amount of right pressure levels (it might hapeen to want 'below' ground or 'above' top +! values) +! rightdespressv: right desired pressure values to provide heights +! hgts: heights at the desired pressure levels [m] +! bthgts: bottoms and tops of the cells at the desired pressure levels [m] + + fname = 'presbars_to_hgtbars' + + rightdespressv = 0. + hgts = 0. + bthgts = 0. + + ! WRF has staggered zg + dzstag = dzs + oribthgt = zg / 9.81 + orihgt = 0.5*(oribthgt(2:dzstag)+oribthgt(1:dzstag-1)) + + ! Get the conversion + firstrightlev = -1 + Nrightlevs = 0 + hgts(1) = topo + DO k=1, dpres + DO ko = 1, dz + ! Filtering to avoid 'below ground' and 'above atmos top' interpolation values + IF (oripres(ko) >= despressv(k) .AND. oripres(ko+1) < despressv(k) .AND. & + psfc > despressv(k) .AND. ptop < despressv(k)) THEN + + Nrightlevs = Nrightlevs + 1 + IF (firstrightlev == -1) firstrightlev = k + + a = (oripres(ko+1)*orihgt(ko)-oripres(ko)*orihgt(ko+1))/(oripres(ko+1)-oripres(ko)) + b = (orihgt(ko+1)-orihgt(ko))/(oripres(ko+1)-oripres(ko)) + rightdespressv(Nrightlevs) = despressv(k) + hgts(Nrightlevs) = a + despressv(k)*b + + EXIT + END IF + END DO + END DO + + ! Giving the bottom / tops of only the right desired pressure values. Interpolating from pressure + ! values and using then the geopotential to get the right height, as a way to be more precise + bthgts(1,1) = topo + DO k=2, Nrightlevs + + ! p-height of the cell + botpressv = 0.5*(rightdespressv(k) + rightdespressv(k-1)) + + ! Interprolation + bthgts(k,1) = interpolate1D(dz, oripres, orihgt, botpressv) + bthgts(k-1,2) = bthgts(k,1) + END DO + bthgts(Nrightlevs,2) = oribthgt(dzstag) + + RETURN + + END SUBROUTINE presbars_to_hgtbars + + REAL FUNCTION interpolate1D(Nvals, xvals, yvals, xpos) + ! Function to interpolate 1D value + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nvals + REAL, DIMENSION(Nvals), INTENT(in) :: xvals, yvals + REAL, INTENT(in) :: xpos + + ! Local + INTEGER :: i, ip, iclosest + REAL(r_k) :: mindist, avi, avip + REAL :: vi, vip, dx, dy, a, b + LOGICAL :: found + CHARACTER(len=50) :: fname + +!!!!!!! Variables +! Nvals: Amount of values to use for the interpolation +! xvals: x-axis positions +! yvals: y-axis values +! xpos: position at which we want to interpolate + + fname = 'interpolate1D' + + interpolate1D = 1.e20 + + found = .FALSE. + + avi = ABS(xvals(1) - xpos) + iclosest = 1 + mindist = avi + DO i=1, Nvals-1 + ip = i + 1 + vi = xvals(i) - xpos + vip = xvals(ip) - xpos + avip = ABS(vip) + IF (avip < mindist) THEN + mindist = avip + iclosest = ip + END IF + + IF (vi*vip <= 0.) THEN + dx = xvals(ip)-xvals(i) + dy = yvals(ip)-yvals(i) + a = (xvals(ip)*yvals(i)-xvals(i)*yvals(ip))/dx + b = dy/dx + interpolate1D = a + xpos*b + found = .TRUE. + EXIT + END IF + END DO + + ! Case where xpos does not lay within 2 consecutive xvals + IF (.NOT.found) THEN + IF (iclosest == Nvals) THEN + i = Nvals-1 + ip = Nvals + ELSE + i = iclosest + ip = iclosest + 1 + END IF + dx = xvals(ip)-xvals(i) + dy = yvals(ip)-yvals(i) + a = (xvals(ip)*yvals(i)-xvals(i)*yvals(ip))/dx + b = dy/dx + interpolate1D = a + xpos*b + END IF + + RETURN + + END FUNCTION interpolate1D + + + SUBROUTINE NumIntegration(yvals, xvals, Nvalint, Ntotval, intval) +! Subroutine to compute numerical integrations according to the trapezoidal methodology + + IMPLICIT NONE + + REAL, DIMENSION(Ntotval), INTENT(in) :: yvals, xvals + INTEGER, INTENT(in) :: Nvalint, Ntotval + REAL, INTENT(out) :: intval + +!!!!!!! Variables +! yvals: values to integrate +! xvals: equivalent positions on x-axis +! Nvalint: range of the integral +! Ntotval: total number of values +! intval: result of the integration + + intval=0. + intval=SUM((xvals(2:Nvalint)-xvals(1:Nvalint-1))*(yvals(1:Nvalint-1)+yvals(2:Nvalint))/2.) + + RETURN + + END SUBROUTINE NumIntegration + + SUBROUTINE partial_agg(d1, vals, dvals, idvals, edvals, partagg) +! Subroutine to compute a partial aggregation of mass-values between an interval. + + IMPLICIT NONE + + INTEGER, INTENT(in) :: d1 + REAL, DIMENSION(d1), INTENT(in) :: vals, dvals + REAL, INTENT(in) :: idvals, edvals + REAL, INTENT(out) :: partagg + +! Local + INTEGER :: k + +!!!!!!! Variables +! d1: length of the axis +! vals: values to aggregate +! dvals: values along the axis +! idvals, edvals: initial and final value of the interval +! partagg: partial aggregation + + sfname = 'partial_agg' + + partagg = 0. + + DO k=1,d1 + IF (dvals(k) >= idvals .AND. (dvals(k) <= edvals )) partagg = partagg + vals(k) + END DO + + RETURN + + END SUBROUTINE partial_agg + + SUBROUTINE interval_agg(d1, Ninterv, Ninterv1, vals, dvals, interval, intagg) +! Subroutine to compute aggregation by intervals along the full axis of of mass-values + + IMPLICIT NONE + + INTEGER, INTENT(in) :: d1, Ninterv, Ninterv1 + REAL, DIMENSION(d1), INTENT(in) :: vals, dvals + REAL, DIMENSION(Ninterv), INTENT(in) :: interval + REAL, DIMENSION(Ninterv1), INTENT(out) :: intagg + +! Local + INTEGER :: k, ijk + REAL :: signd + +!!!!!!! Variables +! d1: length of the axis +! Ninterv: Number of intervals +! Ninterv1: Number of aggregations (Ninterv+1) +! vals: values to aggregate +! dvals: values along the axis +! interval: values of the intervals +! intagg: aggregation along intervals + + sfname = 'interval_agg' + + intagg = 0. + + IF (dvals(1) > dvals(2)) THEN + signd = -1 +! Lest work fast ... +! IF (interval(1) < interval(2)) THEN +! WRITE(msg,*)'Axis values decrese, thus interval values must too' +! CALL ErrMsg(msg, TRIM(sfname), -1) +! END IF + ELSE + signd = 1 +! Lest work fast ... +! IF (interval(1) > interval(2)) THEN +! WRITE(msg,*)'Axis values increase, thus interval values must too' +! CALL ErrMsg(msg, TRIM(sfname), -1) +! END IF + END IF + + ijk = 1 + IF (signd == -1) THEN + ! Axis in descending sense + DO k=1, d1 + IF (dvals(k) < interval(ijk)) THEN + IF (ijk < Ninterv) THEN + ijk = ijk + 1 + intagg(ijk) = intagg(ijk) + vals(k) + ELSE + intagg(Ninterv1) = intagg(Ninterv1) + vals(k) + END IF + ELSE + intagg(ijk) = intagg(ijk) + vals(k) + END IF + END DO + + ELSE + ! Axis in ascending sense + DO k=1, d1 + IF (dvals(k) > interval(ijk)) THEN + IF (ijk < Ninterv) THEN + ijk = ijk + 1 + intagg(ijk) = intagg(ijk) + vals(k) + ELSE + intagg(Ninterv1) = intagg(Ninterv1) + vals(k) + END IF + ELSE + intagg(ijk) = intagg(ijk) + vals(k) + END IF + END DO + + END IF + + RETURN + + END SUBROUTINE interval_agg + + SUBROUTINE moist_group(Nmoist, i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh, qvval, qcval, qrval, qsval,& + qival, qgval, qhval, qvarvals) +! Subroutine to group 1D values from each water-species to a single variable + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nmoist, i_qv, i_qc, i_qr, i_qs, i_qi, & + i_qg, i_qh + REAL, INTENT(in) :: qvval, qcval, qrval, qsval, qival, qgval, & + qhval + REAL, DIMENSION(Nmoist), INTENT(out) :: qvarvals + +!!!!!!! Variables +! Nmoist: number of water species +! i_q[v/c/r/s/i/g/h]: index for water vapour, cloud, rain, snow, ice, graupel and hail +! q[v/c/r/s/i/g/h]val: individual values for water vapour, cloud, rain, snow, ice, graupel and hail +! qvarvals: 2D values of multiple water species + + sfname = 'moist_group' + + IF (MAXVAL((/ i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh /)) > Nmoist) THEN + WRITE(message,*) ' ' // TRIM(sfname) // ': Wrong number of water-species Nmoist:', Nmoist, & + ' for:', i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh,' increase it !!' + CALL wrf_error_fatal(message) + END IF + + qvarvals(i_qv) = qvval + qvarvals(i_qc) = qcval + qvarvals(i_qr) = qrval + qvarvals(i_qs) = qsval + qvarvals(i_qi) = qival + qvarvals(i_qg) = qgval + qvarvals(i_qh) = qhval + + RETURN + + END SUBROUTINE moist_group + + SUBROUTINE moist_group2D(Nmoist, d1, i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh, qvval, qcval, qrval, & + qsval, qival, qgval, qhval, qvarvals) +! Subroutine to group 2D values from each water-species to a single variable + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nmoist, d1, i_qv, i_qc, i_qr, i_qs, i_qi, & + i_qg, i_qh + REAL, DIMENSION(d1), INTENT(in) :: qvval, qcval, qrval, qsval, qival, qgval, & + qhval + REAL, DIMENSION(d1,Nmoist), INTENT(out) :: qvarvals + +!!!!!!! Variables +! Nmoist: number of water species +! i_q[v/c/r/s/i/g/h]: index for water vapour, cloud, rain, snow, ice, graupel and hail +! q[v/c/r/s/i/g/h]val: individual values for water vapour, cloud, rain, snow, ice, graupel and hail +! qvarvals: 2D values of multiple water species + + sfname = 'moist_group2D' + + IF (MAXVAL((/ i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh /)) > Nmoist) THEN + WRITE(message,*) ' ' // TRIM(sfname) // ': Wrong number of water-species Nmoist:', Nmoist, & + ' for:', i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh,' increase it !!' + CALL wrf_error_fatal(message) + END IF + + qvarvals(:,i_qv) = qvval(:) + qvarvals(:,i_qc) = qcval(:) + qvarvals(:,i_qr) = qrval(:) + qvarvals(:,i_qs) = qsval(:) + qvarvals(:,i_qi) = qival(:) + qvarvals(:,i_qg) = qgval(:) + qvarvals(:,i_qh) = qhval(:) + + RETURN + + END SUBROUTINE moist_group2D + + SUBROUTINE moist_redistribute(Nmoist, qvarvals, i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh, qvval, & + qcval, qrval, qsval, qival, qgval, qhval) +! Subroutine to re-distribute a multi water-species 1D value to each specie + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nmoist, i_qv, i_qc, i_qr, i_qs, i_qi, & + i_qg, i_qh + REAL, DIMENSION(Nmoist), INTENT(in) :: qvarvals + REAL, INTENT(out) :: qvval, qcval, qrval, qsval, qival, qgval, & + qhval + +!!!!!!! Variables +! Nmoist: number of water species +! qvarvals: 1D values of multiple water species +! i_q[v/c/r/s/i/g/h]: index for water vapour, cloud, rain, snow, ice, graupel and hail +! q[v/c/r/s/i/g/h]val: individual values for water vapour, cloud, rain, snow, ice, graupel and hail + + sfname = 'moist_redistribute' + + qvval = qvarvals(i_qv) + qcval = qvarvals(i_qc) + qrval = qvarvals(i_qr) + qsval = qvarvals(i_qs) + qival = qvarvals(i_qi) + qgval = qvarvals(i_qg) + qhval = qvarvals(i_qh) + + RETURN + + END SUBROUTINE moist_redistribute + + SUBROUTINE moist_redistribute2D(Nmoist, d1, qvarvals, i_qv, i_qc, i_qr, i_qs, i_qi, i_qg, i_qh, & + qvval, qcval, qrval, qsval, qival, qgval, qhval) +! Subroutine to re-distribute a multi water-species 2D value to each specie + + IMPLICIT NONE + + INTEGER, INTENT(in) :: Nmoist, d1, i_qv, i_qc, i_qr, i_qs, i_qi, & + i_qg, i_qh + REAL, DIMENSION(d1,Nmoist), INTENT(in) :: qvarvals + REAL, DIMENSION(d1), INTENT(out) :: qvval, qcval, qrval, qsval, qival, qgval, & + qhval + +!!!!!!! Variables +! Nmoist: number of water species +! qvarvals: 2D values of multiple water species +! i_q[v/c/r/s/i/g/h]: index for water vapour, cloud, rain, snow, ice, graupel and hail +! q[v/c/r/s/i/g/h]val: individual values for water vapour, cloud, rain, snow, ice, graupel and hail + + sfname = 'moist_redistribute2D' + + qvval(:) = qvarvals(:,i_qv) + qcval(:) = qvarvals(:,i_qc) + qrval(:) = qvarvals(:,i_qr) + qsval(:) = qvarvals(:,i_qs) + qival(:) = qvarvals(:,i_qi) + qgval(:) = qvarvals(:,i_qg) + qhval(:) = qvarvals(:,i_qh) + + RETURN + + END SUBROUTINE moist_redistribute2D + + + +!!!!! ORCHIDEE related diagnostics ------------------------------------------------------- + + SUBROUTINE SFCDIAGS_ORCHIDEE1D( u1, v1, t1, q1, z1, ps1, & + ts1, qsurf, rugos, psol, & + cdrah, cdram, ri1, ustar, lmon, & + kms, kme, kts, kte, & + t_2m, q_2m) + + ! Surface diagnostics of t2 and q2 from the LMDZ GCM (old version) + + IMPLICIT NONE + + INTEGER, INTENT(in) :: kms, kme, kts, kte + + + REAL , DIMENSION(kms:kme) , INTENT(in) :: u1, v1, t1, ps1 + REAL , INTENT(in) :: q1, z1, ts1, qsurf, rugos, cdrah, cdram + REAL , INTENT(in) :: ri1, psol, ustar, lmon +! + REAL , INTENT(inout) :: t_2m, q_2m +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! niter : nombre iterations calcul "corrector" +! INTEGER, PARAMETER :: niter=6, ncon=niter-1 + INTEGER, PARAMETER :: niter=2, ncon=niter-1 +! Variables locales + INTEGER :: i, j, n + REAL :: zref + REAL :: speed + REAL :: tasmin, qvsmin, tasmax, qvsmax +! tpot : temperature potentielle + REAL :: tpot + REAL :: zri1 + REAL :: testar, qstar + REAL :: zdte, zdq + DOUBLE PRECISION, PARAMETER :: eps=1.0D-20 + REAL :: delu, delte, delq + REAL :: u_zref, te_zref, q_zref + REAL :: temp, pref + LOGICAL :: okri + REAL :: u_zref_p, te_zref_p, temp_p, q_zref_p +!convergence + REAL :: te_zref_con, q_zref_con + REAL :: u_zref_c, te_zref_c, temp_c, q_zref_c + REAL :: ok_pred, ok_corr +!conversion humidite specifique + REAL :: qs +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +!!!!!!! Variables +! u1: eastward wind speed at the first atmospheric layer [ms-1] +! v1: northward wind speed at the first atmospheric layer [ms-1] +! t1: air temperature at the first atmospheric layer [K] +! q1: water vapour mixing ratio at the first atmospheric layer [kgkg-1] +! z1: geopotential at the first atmospheric layer [m] +! ps1: air pressure at the first atmospheric layer [Pa] +! ts1: surface temperature [K] +! qsurf: surface water vapour [kgkg-1] +! rugos: rugossity [-] +! psol: surface pressure [Pa] +! cdrah: drag coefficien for heat [-] +! cdram: drag coefficient for momentum [-] +! ri1: Richardson number at the first atmospheric layer [-] +! ustar: U* in similarity theroy [ms-1] +! lmon: Monin-Obukhov length [-] + + speed=SQRT(u1(kts)**2+v1(kts)**2) +! + okri=.TRUE. + + CALL coefcdrag1D(speed, t1(kts), q1, z1, psol, & + & ts1, qsurf, rugos, okri, ri1, & + & zri1, pref) + +! +!---------Star variables---------------------------------------------------- +! + + tpot = t1(kts)* (psol/ps1(kts))**rcp + zdte = tpot - ts1 + zdq = max(q1,0.0) - max(qsurf,0.0) + zdte = sign(max(abs(zdte),1.e-10),zdte) +! + testar = (cdrah * zdte * speed)/ustar + qstar = (cdrah * zdq * speed)/ustar +! +!----------First aproximation of variables at zref -------------------------- + zref = 2.0 + CALL screenp1D(speed, tpot, q1, & + & ts1, qsurf, rugos, lmon, & + & ustar, testar, qstar, zref, & + & delu, delte, delq) + +! + u_zref = delu + q_zref = max(qsurf,0.0) + delq + te_zref = ts1 + delte + temp = te_zref * (psol/ps1(kts))**(-rcp) + q_zref_p = q_zref +! te_zref_p = te_zref + temp_p = temp +! +! Iteration of the variables at the reference level zref : corrector calculation ; see Hess & McAvaney, 1995 +! + DO n = 1, niter +! + okri=.TRUE. + CALL screenc1D(u_zref, temp, q_zref, zref, & + & ts1, qsurf, rugos, psol, & + & ustar, testar, qstar, okri, ri1, & + & pref, delu, delte, delq, & + & cdram, cdrah) +! + u_zref = delu + q_zref = delq + max(qsurf,0.0) + te_zref = delte + ts1 + ! + ! return to normal temperature + ! + temp = te_zref * (psol/pref)**(-rcp) + IF (n.EQ.ncon) THEN + te_zref_con = te_zref + q_zref_con = q_zref + ENDIF +! + ENDDO + + q_zref_c = q_zref + temp_c = temp + + ok_pred=0. + ok_corr=1. + + t_2m = temp_p * ok_pred + temp_c * ok_corr + q_2m = q_zref_p * ok_pred + q_zref_c * ok_corr + qs = pq0/psol*exp(a2*(t_2m-a3)/(t_2m-a4)) + q_2m = MIN(qs, q_2m) + + ! Capping the diagnostics to prevent large values + tasmin = MIN(t1(kts), ts1) + qvsmin = MIN(q1, qsurf) + tasmax = MAX(t1(kts), ts1) + qvsmax = MAX(q1, qsurf) + + IF (t_2m < tasmin) t_2m = tasmin + IF (q_2m < qvsmin) q_2m = qvsmin + IF (t_2m > tasmax) t_2m = tasmin + IF (q_2m > qvsmax) q_2m = qvsmax + + RETURN + + END subroutine SFCDIAGS_ORCHIDEE1D + +!======================================================================= +! +! +! + SUBROUTINE coefcdrag1D (speed, t, q, zgeop, psol, & + ts, qsurf, rugos, okri, ri1, & + zri1, pref) + + IMPLICIT none +!------------------------------------------------------------------------- +! Objet : calcul des cdrags pour le moment (cdram) et les flux de chaleur +! sensible et latente (cdrah), du cdrag neutre (cdran), +! du nombre de Richardson entre la surface et le niveau de reference +! (zri1) et de la pression au niveau de reference (pref). +! +! I. Musat, 01.07.2002 +!------------------------------------------------------------------------- +! +! speed---input-R- module du vent au 1er niveau du modele +! t-------input-R- temperature de l'air au 1er niveau du modele +! q-------input-R- humidite de l'air au 1er niveau du modele +! zgeop---input-R- geopotentiel au 1er niveau du modele +! psol----input-R- pression au sol +! ts------input-R- temperature de l'air a la surface +! qsurf---input-R- humidite de l'air a la surface +! rugos---input-R- rugosite +! okri----input-L- TRUE si on veut tester le nb. Richardson entre la sfce +! et zref par rapport au Ri entre la sfce et la 1ere couche +! ri1-----input-R- nb. Richardson entre la surface et la 1ere couche +! +! zri1---output-R- nb. Richardson entre la surface et la couche zgeop/g +! pref---output-R- pression au niveau zgeop/g + + REAL, INTENT(in) :: speed, t, q, zgeop, psol + REAL, INTENT(in) :: ts, qsurf, rugos, ri1 + LOGICAL, INTENT(in) :: okri +! + REAL, INTENT(out) :: zri1, pref +!------------------------------------------------------------------------- +! +! include "YOMCST.h" +! include "YOETHF.h" +! INCLUDE "clesphys.h" +! Quelques constantes : + REAL , PARAMETER :: RVTMP2 = 4*rvovrd/3.5 -1 + REAL, parameter :: CE=5.0, CC=5.0, CD=5.0, cepdu2=(0.1)**2 +! +! Variables locales : + INTEGER :: i, j + REAL :: zdu2, zdphi, ztsolv, ztvd + REAL :: zscf, friv, frih, zucf, zcr + REAL :: zcfm1, zcfh1 + REAL :: zcfm2, zcfh2 + REAL :: trm0, trm1 + +!------------------------------------------------------------------------- + + zdphi = zgeop + zdu2 = max(cepdu2,speed**2) + pref = exp(log(psol) - zdphi/(r_d*t* & + (1.+ p608 * max(q,0.0)))) + ztsolv = ts +! ztvd = t * (psol/pref)**rcp +! ztvd = (t+zdphi/cp/(1.+RVTMP2*q)) & +! *(1.+p608*q) + ztvd = (t+zdphi/cp/(1.+RVTMP2*q)) + trm0 = 1. + p608 * max(qsurf,0.0) + trm1 = 1. + p608 * max(q,0.0) + ztsolv = ztsolv * trm0 + ztvd = ztvd * trm1 + zri1 = zdphi*(ztvd-ztsolv)/(zdu2*ztvd) +! +! on teste zri1 par rapport au Richardson de la 1ere couche ri1 +! + +!IM +++ + IF(1.EQ.0) THEN + IF (okri) THEN + IF (ri1.GE.0.0.AND.zri1.LT.0.0) THEN + zri1 = ri1 + ELSE IF(ri1.LT.0.0.AND.zri1.GE.0.0) THEN + zri1 = ri1 + ENDIF + ENDIF + ENDIF +!IM --- +! + RETURN + + END SUBROUTINE coefcdrag1D +!======================================================================= + SUBROUTINE screenp1D(speed, tair, qair, & + & ts, qsurf, rugos, lmon, & + & ustar, testar, qstar, zref, & + & delu, delte, delq) + + + IMPLICIT none +!------------------------------------------------------------------------- +! +! Objet : calcul "predicteur" des anomalies du vent, de la temperature +! potentielle et de l'humidite specifique au niveau de reference zref et +! par rapport au 1er niveau (pour u) ou a la surface (pour theta et q) +! a partir des relations de Dyer-Businger. +! +! Reference : Hess, Colman et McAvaney (1995) +! +! I. Musat, 01.07.2002 +!------------------------------------------------------------------------- +! +! speed---input-R- module du vent au 1er niveau du modele +! tair----input-R- temperature de l'air au 1er niveau du modele +! qair----input-R- humidite specifique au 1er niveau du modele +! ts------input-R- temperature de l'air a la surface +! qsurf---input-R- humidite specifique a la surface +! rugos---input-R- rugosite +! lmon----input-R- longueur de Monin-Obukov +! ustar---input-R- facteur d'echelle pour le vent +! testar--input-R- facteur d'echelle pour la temperature potentielle +! qstar---input-R- facteur d'echelle pour l'humidite +! zref----input-R- altitude de reference +! +! delu----input-R- anomalie du vent par rapport au 1er niveau +! delte---input-R- anomalie de la temperature potentielle par rapport a la surface +! delq----input-R- anomalie de l'humidite par rapport a la surface + + REAL, INTENT(in) :: speed, tair, qair + REAL, INTENT(in) :: ts, qsurf, rugos + REAL, INTENT(in) :: lmon + REAL, INTENT(in) :: ustar, testar, qstar + REAL, INTENT(in) :: zref +! + REAL, INTENT(out) :: delu, delte, delq +! +!------------------------------------------------------------------------- +! Variables locales et constantes : + INTEGER :: i, j + REAL :: xtmp, xtmp0 +!------------------------------------------------------------------------- +! + IF (lmon.GE.0.) THEN +! +! STABLE CASE +! + IF (speed.GT.1.5.AND.lmon.LE.1.0 .AND. rugos.LE.1.0) THEN + delu = (ustar/KARMAN)* & + (log(zref/(rugos)+1.) + & + min(5.d0, 5.0 *(zref - rugos)/lmon)) + delte = (testar/KARMAN)* & + (log(zref/(rugos)+1.) + & + min(5.d0, 5.0 * (zref - rugos)/lmon)) + delq = (qstar/KARMAN)* & + (log(zref/(rugos)+1.) + & + min(5.d0, 5.0 * (zref - rugos)/lmon)) + ELSE + delu = 0.1 * speed + delte = 0.1 * (tair - ts ) + delq = 0.1 * (max(qair,0.0) - max(qsurf,0.0)) + ENDIF + ELSE +! +! UNSTABLE CASE +! + IF (speed.GT.5.0.AND.abs(lmon).LE.50.0) THEN + xtmp = (1. - 16. * (zref/lmon))**(1./4.) + xtmp0 = (1. - 16. * (rugos/lmon))**(1./4.) + delu = (ustar/KARMAN)* & + (log(zref/(rugos)+1.) & + - 2.*log(0.5*(1. + xtmp)) & + + 2.*log(0.5*(1. + xtmp0)) & + - log(0.5*(1. + xtmp*xtmp)) & + + log(0.5*(1. + xtmp0*xtmp0)) & + + 2.*atan(xtmp) - 2.*atan(xtmp0)) + delte = (testar/KARMAN)* & + (log(zref/(rugos)+1.) & + - 2.0 * log(0.5*(1. + xtmp*xtmp)) & + + 2.0 * log(0.5*(1. + xtmp0*xtmp0))) + delq = (qstar/KARMAN)* & + (log(zref/(rugos)+1.) & + - 2.0 * log(0.5*(1. + xtmp*xtmp)) & + + 2.0 * log(0.5*(1. + xtmp0*xtmp0))) + ELSE + delu = 0.5 * speed + delte = 0.5 * (tair - ts ) + delq = 0.5 * (max(qair,0.0) - max(qsurf,0.0)) + ENDIF + ENDIF +! +! + RETURN + + END SUBROUTINE screenp1D + +!======================================================================= + SUBROUTINE screenc1D(speed, temp, q_zref, zref, & + ts, qsurf, rugos, psol, & + ustar, testar, qstar, okri, ri1, & + pref, delu, delte, delq, & + cdram, cdrah) + + IMPLICIT NONE +!----------------------------------------------------------------------- +! +! Objet : calcul "correcteur" des anomalies du vent, de la temperature +! potentielle et de l'humidite specifique au niveau de reference zref et +! par rapport au 1er niveau (pour u) ou a la surface (pour theta et q) +! a partir des equations de Louis. +! +! Reference : Hess, Colman et McAvaney (1995) +! +! I. Musat, 01.07.2002 +!----------------------------------------------------------------------- +! +! speed---input-R- module du vent au 1er niveau du modele +! temp----input-R- temperature de l'air au 1er niveau du modele +! q_zref--input-R- humidite specifique au 1er niveau du modele +! zref----input-R- altitude de reference +! ts------input-R- temperature de l'air a la surface +! qsurf---input-R- humidite specifique a la surface +! rugos---input-R- rugosite +! psol----input-R- pression au sol +! ustar---input-R- facteur d'echelle pour le vent +! testar--input-R- facteur d'echelle pour la temperature potentielle +! qstar---input-R- facteur d'echelle pour l'humidite +! okri----input-L- TRUE si on veut tester le nb. Richardson entre la sfce +! et zref par rapport au Ri entre la sfce et la 1ere couche +! ri1-----input-R- nb. Richardson entre la surface et la 1ere couche +! +! pref----input-R- pression au niveau de reference +! delu----input-R- anomalie du vent par rapport au 1er niveau +! delte---input-R- anomalie de la temperature potentielle par rapport a la surface +! delq----input-R- anomalie de l'humidite par rapport a la surface + + LOGICAL, INTENT(in) :: okri + REAL, INTENT(in) :: speed, temp, q_zref + REAL, INTENT(in) :: zref + REAL, INTENT(in) :: ts, qsurf, rugos, psol + REAL, INTENT(in) :: ustar, testar, qstar, ri1 + REAL, INTENT(in) :: cdram, cdrah +! + REAL, INTENT(out) :: pref, delu, delte, delq +!----------------------------------------------------------------------- +! include "YOMCST.h" +! +! Variables locales + INTEGER :: i, j + REAL :: zri1, gref +! +!------------------------------------------------------------------------- + gref = zref*g +! +! Richardson at reference level +! + CALL coefcdrag1D(speed, temp, q_zref, gref, psol, & + & ts, qsurf, rugos, okri, ri1, & + & zri1, pref) + !!!!!!!!!!!!!L'update des coefficients de trainee a ete enleve +! + delu = ustar/sqrt(cdram) + delte= (testar* sqrt(cdram))/ cdrah + delq= (qstar* sqrt(cdram))/ cdrah +! + RETURN + + END SUBROUTINE screenc1D +!======================================================================= + +END MODULE module_diagvar_cordex diff --git a/phys/module_physics_init.F b/phys/module_physics_init.F index 8f94e171e2..511eb7694d 100644 --- a/phys/module_physics_init.F +++ b/phys/module_physics_init.F @@ -273,6 +273,17 @@ SUBROUTINE phy_init ( id, config_flags, DT, restart, zfull, zhalf, & ,alevsiz_cu,num_months,no_src_types_cu,aeromcu,aeropcu & ! PSH/TWG 06/10/16 ,EFCG,EFCS,EFIG,EFIS,EFSG,EFSS & ! TWG #endif +!#ifdef CDXWRF + ,fracsoil10cm & + ,londbg, latdbg & + ,ijdbg & +!#if CDXWRF>=3 + ,nhtasrng, nhhursrng, nltasrng, nlhursrng & + ,nwbdsrng, nwssrng & + ,htasbins, hhursbins, ltasbins, lhursbins & + ,wbdsbins, wssbins & +!#endif +!#endif ) !----------------------------------------------------------------- @@ -843,6 +854,24 @@ SUBROUTINE phy_init ( id, config_flags, DT, restart, zfull, zhalf, & REAL, OPTIONAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , INTENT(OUT) :: & RDCASHTEN, RQCDCSHTEN +!#ifdef CDXWRF + REAL, DIMENSION(1:num_soil_layers), INTENT(out) :: fracsoil10cm + REAL, INTENT(in) :: londbg, latdbg + INTEGER, DIMENSION(2), INTENT(out) :: ijdbg + +!#if CDXWRF>=3 + INTEGER, INTENT(in) :: nhtasrng, nhhursrng, nltasrng, nlhursrng + INTEGER, INTENT(in) :: nwbdsrng, nwssrng + REAL, DIMENSION(Nhtasrng), INTENT(out) :: htasbins + REAL, DIMENSION(Nhhursrng), INTENT(out) :: hhursbins + REAL, DIMENSION(Nltasrng), INTENT(out) :: ltasbins + REAL, DIMENSION(Nlhursrng), INTENT(out) :: lhursbins + REAL, DIMENSION(Nwbdsrng), INTENT(out) :: wbdsbins + REAL, DIMENSION(Nwssrng), INTENT(out) :: wssbins +!#endif +!#endif + + ! Local data REAL :: ALBLND,ZZLND,ZZWTR,THINLD,XMAVA,CEN_LAT,pptop @@ -1739,6 +1768,32 @@ SUBROUTINE phy_init ( id, config_flags, DT, restart, zfull, zhalf, & end if #endif +!#ifdef CDXWRF + CALL cdxwrf_init(config_flags%num_soil_layers, dzs & + ,xlong, xlat & + ,londbg, latdbg & + ,ids, ide, jds, jde, kds, kde & + ,ims, ime, jms, jme, kms, kme & + ,its, ite, jts, jte, kts, kte & + +!#if CDXWRF>=3 + ,model_config_rec%nhtasrng, model_config_rec%nhhursrng & + ,model_config_rec%nltasrng, model_config_rec%nlhursrng & + ,model_config_rec%nwbdsrng, model_config_rec%nwssrng & + ,model_config_rec%nhtashursrng, model_config_rec%nltashursrng & + ,model_config_rec%nwbdswssrng & + ,model_config_rec%htasrng, model_config_rec%hhursrng & + ,model_config_rec%ltasrng, model_config_rec%lhursrng & + ,model_config_rec%wbdsrng, model_config_rec%wssrng & +!#endif + ,ijdbg & +!#if CDXWRF>=3 + ,htasbins, hhursbins, ltasbins, lhursbins & + ,wbdsbins, wssbins & +!#endif + ,fracsoil10cm) +!#endif + END SUBROUTINE phy_init !===================================================================== @@ -5747,4 +5802,212 @@ SUBROUTINE shalwater_init(ims,ime,jms,jme, & END SUBROUTINE shalwater_init +!#ifdef CDXWRF + SUBROUTINE cdxwrf_init(num_soil_layers, dzs & + ,xlong, xlat & + ,londbg, latdbg & + ,ids, ide, jds, jde, kds, kde & + ,ims, ime, jms, jme, kms, kme & + ,its, ite, jts, jte, kts, kte & + +!#if CDXWRF>=3 + ,nhtasrng, nhhursrng & + ,nltasrng, nlhursrng & + ,nwbdsrng, nwssrng & + ,nhtashursrng, nltashursrng & + ,nwbdswssrng & + ,htasrng, hhursrng, ltasrng, lhursrng & + ,wbdsrng, wssrng & +!#endif + ! Output + ,ijdbg & +!#if CDXWRF>=3 + ,htasbins, hhursbins, ltasbins, lhursbins, wbdsbins, wssbins & +!#endif + ,fracsoil10cm) + ! Subroutine to initialize CDXWRF module + + IMPLICIT NONE + + ! Input + INTEGER, INTENT(in) :: num_soil_layers + REAL, DIMENSION(1:num_soil_layers), INTENT(in) :: dzs + INTEGER, INTENT(in) :: ids, ide, jds, jde, kds, kde + INTEGER, INTENT(in) :: ims, ime, jms, jme, kms, kme + INTEGER, INTENT(in) :: its, ite, jts, jte, kts, kte + REAL, DIMENSION( ims:ime , jms:jme ), INTENT(in) :: xlong, xlat + REAL, INTENT(in) :: londbg, latdbg +!#if CDXWRF>=3 + INTEGER, INTENT(in) :: nhtasrng, nhhursrng, nltasrng, nlhursrng + INTEGER, INTENT(in) :: nwbdsrng, nwssrng + INTEGER, INTENT(in) :: nhtashursrng, nltashursrng + INTEGER, INTENT(in) :: nwbdswssrng + REAL, DIMENSION(Nhtasrng), INTENT(in) :: htasrng + REAL, DIMENSION(Nhhursrng), INTENT(in) :: hhursrng + REAL, DIMENSION(Nltasrng), INTENT(in) :: ltasrng + REAL, DIMENSION(Nlhursrng), INTENT(in) :: lhursrng + REAL, DIMENSION(Nwbdsrng), INTENT(in) :: wbdsrng + REAL, DIMENSION(Nwssrng), INTENT(in) :: wssrng +!#endif + + ! Output + INTEGER, DIMENSION(2), INTENT(out) :: ijdbg + REAL, DIMENSION(1:num_soil_layers), INTENT(out) :: fracsoil10cm +!#if CDXWRF>=3 + REAL, DIMENSION(Nhtasrng), INTENT(out) :: htasbins + REAL, DIMENSION(Nhhursrng), INTENT(out) :: hhursbins + REAL, DIMENSION(Nltasrng), INTENT(out) :: ltasbins + REAL, DIMENSION(Nlhursrng), INTENT(out) :: lhursbins + REAL, DIMENSION(Nwbdsrng), INTENT(out) :: wbdsbins + REAL, DIMENSION(Nwssrng), INTENT(out) :: wssbins +!#endif + + ! Local + INTEGER :: i,j,k + INTEGER :: idbg, jdbg + REAL :: inczsoil + REAL :: mindist + REAL :: ddlon, ddlat, mindd + REAL, DIMENSION( ims:ime , jms:jme ) :: dist, ddist, dlon, dlat + CHARACTER (LEN=1000) :: diag_message + LOGICAL :: found + +!!!!!!!! Variables +! num_soil_layers: amount of soil layers +! dzs: depths of the soil layers [m] +! xlong, xlat: matrices of longitudes and latitudes +! londbg, latdbg: coordinates of the debugging grid point +! ids, ide, jds, jde, kds, kde: extension of the matrices +! ims, ime, jms, jme, kms, kme: extension of the matrices in memory +! its, ite, jts, jte, kts, kte: extension of the martices by tile +! nhtasrng, nhhursrng: range of the high-resolution temperature and relative humidity residence time +! nltasrng, nlhursrng: range of the low-resolution temperature and relative humidity residence time +! nwbdsrng, nwssrng: range of the blowing wind direction and wind speed residence time +! nhtashursrng, nltashursrng: combined ranges of the high/low tas-hurs residence time +! nwbdswssrng: combined ranges of the wbds-wss residence time +! htasrng, hhursrng, ltasrng, lhursrng: individual ranges of the high/low tas-hurs residence time +! wbdsrng, wssrng: individual ranges of the wbds-wss residence time +! idbg, jdbg: point coordinates of the debugging point +! htasbins, hhursbins, ltasbins, lhursbins, wbdsbins, wssbins: bins for the residence time +! fracsoil10cm: fraction of the verical soil layer to use to compute 10cm depth soil values + + ! lon, lat debugging point + ! L. Fita, UBA-CIMA-IFAECI. This should be done as in share/wrf_timeseries.F, but it uses + ! a lot of aditional modules, that might not be worth to mess with in the phys/ folder ¿? + ! Minimum grid distance + ! Filling matrices with absurd numbers + DO i=ims, ime + DO j=jms, jme + dlon(i,j) = 10000.*i + 10.*j + dlat(i,j) = 20000.*i + 10.*j + END DO + END DO + dlon(its:ite-1,jts:jte-1) = xlong(its:ite-1,jts:jte-1)-xlong(its+1:ite,jts+1:jte) + dlat(its:ite-1,jts:jte-1) = xlat(its:ite-1,jts:jte-1)-xlat(its+1:ite,jts+1:jte) + + ddist = 1000. + ddist = SQRT(dlon*dlon + dlat*dlat) + mindd = MINVAL(ddist) + + ! Minimum distance to the debugging point + dist = SQRT((xlong-londbg)**2+(xlat-latdbg)**2) + mindist = MINVAL(dist) + + found = .FALSE. + WRITE(diag_message,*)'its,ite:', its,ite,' jts,jte:', jts,jte,' mindist:', mindist, ' mindd:', mindd + CALL wrf_debug(75,diag_message) + IF (mindist < mindd) THEN + DO i=its, ite + DO j=jts, jte + + IF (dist(i,j) == mindist) THEN + idbg = i + jdbg = j + found = .TRUE. + WRITE(diag_message,*)' found debugging grid point _______' + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*)' lon,lat dbg: ', londbg, ' ,', latdbg,' mindist:', mindist + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*)' i,j dbg: ', idbg, jdbg + CALL wrf_debug(75,diag_message) + ijdbg(1) = idbg + ijdbg(2) = jdbg + EXIT + END IF + END DO + IF (found) EXIT + END DO + END IF + + ! Soil layers to retrieve 10cm diagnostics + inczsoil = 0. + DO k=1, num_soil_layers + IF (inczsoil < 0.1) THEN + IF (inczsoil + dzs(k) <= 0.1) THEN + fracsoil10cm(k) = 1. + ELSE IF (inczsoil + dzs(k) > 0.1) THEN + fracsoil10cm(k) = (0.1 - inczsoil) / dzs(k) + ELSE + fracsoil10cm(k) = 0. + END IF + END IF + inczsoil = inczsoil + dzs(k) + END DO + +!#if CDXWRF>=3 + ! Residence time + + ! Consistency checks + IF ( nhtasrng*nhhursrng /= nhtashursrng) THEN + PRINT *, ' nhtasrng: ', nhtasrng, ' nhhursrng: ', nhhursrng, ' nhtashursrng: ', nhtashursrng + WRITE (diag_message , * ) & + "CORDEX: ERROR -- error -- ERROR -- error: individual ranges nhtasrng, nhhursrng " // & + "and nhtashursrng do not coincide! nhtashursrng = nhtasrng*nhursrng" + CALL wrf_error_fatal ( diag_message ) + END IF + + IF ( nltasrng*nlhursrng /= nltashursrng) THEN + PRINT *, ' nltasrng: ', nltasrng, ' nlhursrng: ', nlhursrng, ' nltashursrng: ', nltashursrng + WRITE (diag_message , * ) & + "CORDEX: ERROR -- error -- ERROR -- error: individual ranges nltasrng, nlhursrng " // & + "and nltashursrng do not coincide! nltashursrng = nltasrng*nlursrng" + CALL wrf_error_fatal ( diag_message ) + END IF + + IF ( nwbdsrng*nwssrng /= nwbdswssrng) THEN + PRINT *, ' nwbdsrng: ', nwbdsrng, ' nwssrng: ', nwssrng, ' nwbdswssrng: ', nwbdswssrng + WRITE (diag_message , * ) & + "CORDEX: ERROR -- error -- ERROR -- error: individual ranges nwbdsrng, nwssrng " // & + "and nwbdswssrng do not coincide! nwbdswssrng = nwbdsrng*nwssrng" + CALL wrf_error_fatal ( diag_message ) + END IF + + ! Fillling up the bins + htasbins(1:nhtasrng-1) = htasrng(1:nhtasrng-1) + hhursbins(1:nhhursrng-1) = hhursrng(1:nhhursrng-1) + ltasbins(1:nltasrng-1) = ltasrng(1:nltasrng-1) + lhursbins(1:nlhursrng-1) = lhursrng(1:nlhursrng-1) + wbdsbins(1:nwbdsrng-1) = wbdsrng(1:nwbdsrng-1) + wssbins(1:nwssrng-1) = wssrng(1:nwssrng-1) + + WRITE(diag_message,*) ' high-res tas bins ', (htasbins(k), k=1, nhtasrng-1) + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*) ' high-res hurs bins ', (hhursbins(k), k=1, nhhursrng-1) + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*) ' low-res tas bins ', (ltasbins(k), k=1, nltasrng-1) + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*) ' low-res tas bins ', (lhursbins(k), k=1, nlhursrng-1) + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*) ' wbds bins ', (wbdsbins(k), k=1, nwbdsrng-1) + CALL wrf_debug(75,diag_message) + WRITE(diag_message,*) ' wss bins ', (wssbins(k), k=1, nwssrng-1) + CALL wrf_debug(75,diag_message) + +!#endif + + RETURN + + END SUBROUTINE cdxwrf_init +!#endif + END MODULE module_physics_init