!> \mainpage NMMB-MONARCH Code Documentation !! The Multiscale Online Nonhydrostatic AtmospheRe CHemistry model !! (NMMB-MONARCH), a chemical weather prediction system formerly known as !! NMMB/BSC-CTM, that can be run either globally or regionally. The !! NMMB-MONARCH, developed at the Barcelona Supercomputing Center, is based on !! the online coupling of the meteorological Nonhydrostatic Multiscale Model on !! the B-grid \cite Janjic2012 with a full aerosol-chemistry module. !! This documentation is under development and in its current state is !! not comprehensive and may describe developments not completely included in !! the present release or miss some of the ones included. !! !! \htmlonly !!
!! (I) : SOLVER_INITIALIZE (module_SOLVER_GRID_COMP.F90) !! -> PHYSICS_INITIALIZE (module_SOLVER_GRID_COMP.F90) !! -> rad_initialize_nmmb (rad_initialize_nmmb.f) !! -> radinit_nmmb (grrad_nmmb.f) !! -> aer_init (radiation_aerosols_nmmb.f) !! -> mnch_aerinit (radiation_aerosols_nmmb.f) !! !! (II): SOLVER_RUN (module_SOLVER_GRID_COMP.F90) !! -> RADIATION (module_RADIATION.F90) !! -> RRTM (module_RA_RRTM.F90) !! -> grrad_nmmb (grrad_nmmb.f) !! -> setaer (radiation_aerosols_nmmb.f) !! -> mnch_optprops (radiation_aerosols_nmmb.f)!! !! Flux (I) only occurs at the beginning of the simulation (before the first time step) while flux (II) !! at each time step. !! !! In order to assure flexibility, this implementation is based on single aerosol bins/modes and not on !! aerosol species (as it was before). Note that in this document each aerosol size bin (for dust and sea !! salt) and mode (for the other species) is generally indicated as aerosol "type". !! !! !!
!! setari (allocatable, save) -> re-mapping array (to read optical table according to ARI configuration) !! intopt1 (allocatable, save) -> intensive optical properties mapped onto RRTMG SW/LW spectral bands !! optfls(1:4) -> string array containing names of main optical tables available!! !! !!
!! NSPARI -> number of available aerosol species (nspari in configfile) !! NBNARI -> number of available aerosol types (nbnari in configfile) !! numari(1:NSPARI) -> number of running types for each aerosol species (manually filled with num_* in PHYSICS_INITIALIZE routine) !! nxbari(1:NSPARI) -> number of available types for each aerosol species (nxbari in configfile) !! fhbari(1:NBNARI) -> ARI configuration for each type (fhbari in configfile) !! iaertbl -> flag for optical table (tblari in configfile)!! !! As outputs this routine fills the module arrays setari and intopt1 for subsequent runtime calls. !! !! At first, re-mapping for ARI is performed. The array setari is allocated (setari(1:sum(numari),1:2), !! that is as first dimension it takes the same dynamic size of the aerosol tracer array) and filled: !! !!
!! setari(:,1) -> id numbers of running types indicating their position in optical table !! setari(:,2) -> fhbari values for running types (0 -> no ARI, 1 -> hydrophobic, 2 -> hydrophilic)!! !! Note that, since the aerosol types do not have yet an own id number, the re-mapping is done by following !! the order in the tracer array. In other words, the id number that each type gets here is the position it !! would have in the tracer array if all the types were running (the optical table follows the same order). !! !! Then, the actual optical table (opttbl) to be read is selected depending on iaertbl: !! !!
!! opttbl = optfls(iaertbl)!! !! Finally, two internal subroutines are called: !! !!
!! call intprops -> reads optical table and calculates flux weights at each OPAC wavenumber !! call maprrtmg -> maps intensive properties onto RRTMG SW/LW spectral bands and stores them in intopt1!! !! Note that mapping the intensive optical properties means calculating averages for each band, weighted !! by the solar flux. The array intopt1 is previously allocated as: !! !!
!! intopt1(1:3,1:NRHARI,1:NSWLWBD,1:NBNARI)!! !! where the first dimension is for the 3 optical properties (TAU, SSA, ASY), NRHARI is the number of !! relative humidity (RH) levels for optical properties and NSWLWBD the number of SW/LW spectral bands. !! !! !!
!! rhlay(:,:) -> layer mean RH !! dz(:,:) -> layer thickness (km) !! RTPARI -> number of running aerosol types (int_state\%NUM_AERO) !! trcari(:,:,:,1:RTPARI) -> MONARCH aerosol mass concentrations (kg/m³) (int_state\%TRACERS(:,:,:,INDX_AERO_START:INDX_AERO_END))!! !! The outputs are the aerosol optical properties (aerosw and aerolw) for each layer and spectral band: !! !!
!! aerosw/aerolw(:,:,:,1) -> TAU !! aerosw/aerolw(:,:,:,2) -> SSA !! aerosw/aerolw(:,:,:,3) -> ASY!! !! The RH levels containing rhlay (ih1, ih2) and their weight (rdrh) !! are firstly computed for each layer (to interpolate the intensive optical properties). !! !! The main loop over all the running types then starts, within layer and band loops, and the optical !! properties of the aerosol mixture are calculated: !! !!
!! do t = 1, max(1,RTPARI) !! b = setari(t,1) !! if ( setari(t,2) == 1 ) then ! hydrophobic type !! do p = 1, 3 !! iopts(p) = intopt1(p,1,nb,b) !! enddo !! mssari = trcari(i,k,t) !! elseif ( setari(t,2) == 2 ) then ! hydrophilic type !! do p = 1, 3 !! wopt1 = intopt1(p,ih1,nb,b) !! wopt2 = intopt1(p,ih2,nb,b) !! iopts(p) = wopt1 + rdrh*(wopt2 - wopt1) !! enddo !! mssari = trcari(i,k,t) !! ... !! else ! setari(t,2) == 0 -> no ARI for this type !! mssari = f_zero !! endif !! mdz1 = mssari*dz1(k)*1000.0*1000.0 ! g/m² !! aod1 = aod1 + mdz1*iopts(1) ! iopts(1) in m²/g !! ssa1 = ssa1 + mdz1*iopts(1)*iopts(2) !! asy1 = asy1 + mdz1*iopts(1)*iopts(2)*iopts(3) !! enddo!! !! Note that this calculation loop is without "cases". Thanks to setari(t,1) and setari(t,2) it is possible to know !! "who is" each running type. !! !! Finally, the arrays aerosw and aerolw are filled and returned to grrad_nmmb. These optical properties are !! also stored as model outputs, column-integrated and at 0.550µm (actually at the RRTMG band containing 0.550µm): !! !!
!! AERO_OPT_R(:,:,1) -> TAU_550 !! AERO_OPT_R(:,:,2) -> SSA_550 !! AERO_OPT_R(:,:,3) -> ASY_550!! !! !!
!! iaermin -> flag for dust mineralogy (now forced to 0, in future mine in configfile)!! !! A specific instruction does not allow the tables for mineralogy being accidentally selected if minerals !! are not running (in this case iaertbl = 2 is set). Moreover, currently options with more than !! 8 minerals are not allowed. !! !! The dynamic internal mixing mechanism (enabled only if iaertbl == 4) requires at first 2 module !! variables to be filled (for later use in mnch_optprops): !! !!
!! tbl (save) -> flag for optical table (tbl = iaertbl) !! hem(1:8), ilt(1:8), kao(1:8), mtm(1:8) (save) -> dynamic positions of hematite and clays in setari(:,1)!! !! Once calculated hem, ilt, kao and mtm, the ARI configuration for internally mixed !! dust types is OVERWRITTEN: from setari(:,2) == 1 (hydrophobic) to setari(:,2) == 3 (internally !! mixed), in order to assure a special treatment for these types during the calculation of the optical properties. !! !! The optical table for internal mixing contains a higher number of columns (currently 34) than the other tables !! because it includes optical properties for 11 hematite/clays volume ratios: from 0.00 (base case) to 0.20 with !! 0.02 step (I fixed the upper limit to 0.20 for the moment because in the emission dataset I found volume ratios !! always < 0.16, but this has to be tested). So, in routines intprops and maprrtmg a specific code !! is implemented to read and map onto RRTMG bands this special table. !! !! In mnch_optprops (called for each time step and each grid cell), firstly, just before the start of the main !! loop for the calculation of the optical properties, the actual volume ratios of hematite to clays are calculated, !! separately for each bin, starting from tracers (dynamic) and mass densities (module parameters) of the involved !! minerals, and stored in the auxiliary local variable hemcly(1:RTPARI). !! !! Then, within the calculation main loop, the option for internally mixed dust types has been inserted: !! !!
!! ... !! elseif ( setari(t,2) == 3 ) then ! hydrophobic internally mixed type !! hc1 = int(hemcly(t)/HEMSTP) !! hc2 = hc1 + 1 !! if ( hc2 > 10 ) then !! hc1 = 10 !! hc2 = 10 !! rdvr = 0.0 !! else !! rdvr = (hemcly(t)-hc1*HEMSTP)/(hc2*HEMSTP-hc1*HEMSTP) !! endif !! do p = 1, 3 !! xopt1 = intopt1(p+3*hc1,1,nb,b) !! xopt2 = intopt1(p+3*hc2,1,nb,b) !! iopts(p) = xopt1 + rdvr*xopt2 !! enddo !! mssari = trcari(i,k,t) !! ...!! !! Substantially, the integer hematite levels (hc1, hc2) are firstly calculated (HEMSTP is the !! hematite/clays ratio step, set to 0.02 as already reported) and then used to pick up the right columns in intopt1. !! The actual optical properties are thus calculated by linearly interpolating these columns based on the level weight (rdvr). !! !! !!
!! DRE_SW_TOA(:,:,1:(RTPARI+1)) -> aerosol direct radiative effect for SW at TOA (w/m²) !! DRE_SW_SFC(:,:,1:(RTPARI+1)) -> " for SW at SFC (w/m²) !! DRE_LW_TOA(:,:,1:(RTPARI+1)) -> " for LW at TOA (w/m²) !! DRE_LW_SFC(:,:,1:(RTPARI+1)) -> " for LW at SFC (w/m²)!! !! The calculation is performed in the RRTM routine (module_RA_RRTM.F90) through single/double/multiple calls of !! grrad_nmmb, depending on the flag iaermlc (mlcari in configfile). Currently, 4 options are available: !! !!
!! iaermlc == 0 -> 1 call: all tracers !! iaermlc == 1 -> 2 calls: no tracers + all tracers !! iaermlc == 2 -> (RTPARI+2) calls: no tracers + tracer of each running type + all tracers !! iaermlc == 3 -> (RTPARI+2) calls: no tracers + all tracers except each running type + all tracers!! !! When iaermlc > 0, the SW/LW DREs at the top-of-atmosphere (toa) and surface (sfc) are calculated !! as flux (F) differences with (a) and without (0) aerosols, just after the grrad_nmmb calls: !! !! \f[ !! \begin{align} !! DRE_{toa} &= F_{toa}^{\uparrow 0} - F_{toa}^{\uparrow a} \\ !! \\ !! DRE_{sfc} &= (F_{sfc}^{\downarrow a} - F_{sfc}^{\uparrow a}) - (F_{sfc}^{\downarrow 0} - F_{sfc}^{\uparrow 0}) !! \end{align} !! \f] !! !! Note that in this case (iaermlc > 0), always the first call is without aerosols and the last call with all types. !! This implies two things: !! - the output radiative fluxes are not affected by iaermlc; !! - the DRE of all aerosols is always stored in the last position of the DRE arrays (RTPARI+1). !! !! The options iaermlc == 2 and iaermlc == 3 are quite different. In the first case, the DRE of each type !! (alone) is calculated. In the second case, instead, the impact of each type (missing) on the total DRE is calculated. !! !! Other important notes are: !! - the DRE of a single running type is non-zero only if fhbari > 0 for that type; !! - if iaermdl == 0 (OPAC routines), the single call of radiation is automatically set. !! !! !!
!! DNI -> Direct Normalized Irradiance (SW): direct flux (from the Sun) collected by an unit normal surface !! DHI -> Diffuse Horizontal Irradiance (SW): diffuse flux (from all directions) collected by an unit horizontal surface !! GHI -> Global Horizontal Irradiance (SW): direct + diffuse fluxes collected by an unit horizontal surface!! !! From these definitions it follows that: GHI = DNI*cos(zen) + DHI (where zen is the zenith angle). !! These fluxes are computed in the swrad routine (radsw_main_nmmb.f) and stored in the output variable: !! !!
!! ENG_SW_SFC(:,:,1) -> DNI (w/m²) !! ENG_SW_SFC(:,:,2) -> DHI (w/m²) !! ENG_SW_SFC(:,:,3) -> GHI (w/m²)!! !! Currently only total-sky fluxes are stored but the clear-sky fluxes are also computed. !! If the radiation multiple call is activated, the differences between these 3 fluxes !! with and without aerosols are also computed and stored in the same variable: !! !!
!! ENG_SW_SFC(:,:,4) -> DNI - DNI_0 (w/m²) !! ENG_SW_SFC(:,:,5) -> DHI - DHI_0 (w/m²) !! ENG_SW_SFC(:,:,6) -> GHI - GHI_0 (w/m²)!! !! Finally, just for evaluation purpose, cos(zen) is stored in the last position of the array: !! !!
!! ENG_SW_SFC(:,:,7) -> cos(zen)!! !! !!
!! slfari -> flag for ARI LW/SW calculations (old IAER) !! : 0 -> no ARI !! : 1 -> only SW !! : 10 -> only LW !! : 11 -> LW + SW !! : 1** -> as before + volcanic ash (always from OPAC) !! !! mdlari -> flag for ARI module (XMDL in proj_*.conf) !! : 0 -> OPAC climatology !! : 3 -> MONARCH dynamic coupling !! !! mlcari -> flag for multiple call (XMLC in proj_*.conf) !! : 0 -> no DRE !! : 1 -> DRE of all types !! : 2 -> DRE of single types (alone) + all types !! : 3 -> DRE of single types (missing) + all types !! !! tblari -> flag for optical table (XTBL in proj_*.conf) !! : 1 -> OPAC refractive indices (homogeneous dust components) !! : 2 -> OPAC refractive indices + emission p50 for dust imaginary index in (0.25-2.00)µm !! : 3 -> mineral refractive indices: external mixing !! : 4 -> mineral refractive indices: internal mixing for hematite-clays (Maxwell-Garnett mixing rule)!! !! In proj_*.conf another flag (XKOK) has been added, which allows controlling the shape for dust !! (only for tblari: 1, 2): !! !!
!! XKOK -> flag for shape (only for XTBL=1 or XTBL=2) !! : 0 -> spheres !! : 1 -> tri-axial spheroids for dust in (0.25-2.00)µm!! !! Other parameters are required but fixed until the general aerosol parameterization is not changed: !! !!
!! nspari: 10 -> number of available aerosol species (for allocation of nxbari) !! nbnari: 90 -> number of available aerosol types (for allocation of fhbari) !! nxbari: 1 64 8 7 2 1 3 1 2 1 -> number of available types for each aerosol species !! |-| |----| |---------------| |-------------| |---| |-| |-----| |-| |---| |-| !! ash dust salt om bc so4 no3 nh4 unspc aero_uci !! |-| |----| |---------------| |-------------| |---| |-| |-----| |-| |---| |-| !! fhbari: 0 1(x64) 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 1 2 2 0 0 0 0 0 0 0 -> ARI configuration for each type !! : 0 -> no ARI !! : 1 -> hydrophobic !! : 2 -> hydrophilic!! !! Important notes: !! - the order of species in nxbari must be the same as in the aerosol tracer array; !! - the order of types in fhbari (based on nxbari) must be the same as in the optical tables. !! !! !!
!! Main tables: !! mnch_tables_opc.txt (tblari: 1) -> opc stands for OPAC !! mnch_tables_clq.txt (tblari: 2) -> clq stands for Claquin !! mnch_tables_ext.txt (tblari: 3) -> ext stands for external mixing !! mnch_tables_int.txt (tblari: 4) -> int stands for internal mixing !! !! Accessory tables: !! mnch_tables_opc_kok.txt (tblari: 1 + XKOK=1) !! mnch_tables_clq_kok.txt (tblari: 2 + XKOK=1)!! !! In the main tables, only the refractive indices for dust change from one table to another one, while the accessory tables !! only affect the shape for dust (the parameterization for the other species is unvaried and their optical properties are !! repeated in all tables). All the tables have the following structure (b -> size bin; m -> mode): !! !!
!! 1 m1 ash ("phantom" type) !! 2-9 b1-b8 dust (tblari: 1,2) or illite (tblari: 3) or hem/clays mixture (tblari: 4) !! 10-17 b1-b8 dust (tblari: 1,2) or kaolinite (tblari: 3) or hem/clays mixture (tblari: 4) !! 18-25 b1-b8 dust (tblari: 1,2) or montmorillonite (tblari: 3) or hem/clays mixture (tblari: 4) !! 26-33 b1-b8 dust (tblari: 1,2) or calcite (tblari: 3,4) !! 34-41 b1-b8 dust (tblari: 1,2) or quartz (tblari: 3,4) !! 42-49 b1-b8 dust (tblari: 1,2) or feldspar (tblari: 3,4) !! 50-57 b1-b8 dust (tblari: 1,2) or hematite (tblari: 3) or hem/clays mixture (tblari: 4) !! 58-65 b1-b8 dust (tblari: 1,2) or gypsum (tblari: 3,4) !! 66-73 b1-b8 salt (tblari: 1,2,3,4) !! 74-80 m1-m7 om (tblari: 1,2,3,4) !! 81-82 m1-m2 bc (tblari: 1,2,3,4) !! 83 m1 so4 (tblari: 1,2,3,4) !! 84-86 m1-m3 no3 ("phantom" type) !! 87 m1 nh4 ("phantom" type) !! 88-89 m1-m2 unspc ("phantom" type) !! 90 m1 aero_uci ("phantom" type)!! !! The position in the tables of each type (first column) is the id number contained in setari(:,1) and identifies !! the subtable (61 wavelengths: 7 RH levels: 3 optical properties) relative to that type. !! !! !!
!! https://earth.bsc.es/gitlab/ac/monarch-radiative-tables!! !! The uppercase directories contain input data: !! !!
!! OPAC/ (used for all tables) -> refractive indices from OPAC database: !! miam00 <-> dust !! ssam00 <-> salt !! waso00 <-> om !! soot00 <-> bc !! suso00 <-> so4 !! inso00 <-> "phantom" type !! !! MCPH/ (used for all tables) -> microphysical properties for all types (line <-> type): !! growth_factors.txt !! size_distributions.txt !! opac_files.txt !! mass_densities.txt !! segelstein.txt -> water refractive indices [Segelstein, 1981] !! !! SCNZ/ (used for mnch_tables_clq.txt) -> mineral refractive indices [Scanza et al., 2015]: !! illite.txt !! kaolinite.txt !! montmorillonite.txt !! calcite.txt !! quartz.txt !! feldspar.txt !! hematite.txt !! gypsum.txt !! !! OXFD/ (used for mnch_tables_ext/int.txt) -> modified mineral refractive indices (Oxford University ARIA): !! calcite.txt -> (3.0-15.0)µm (E-ray + O-ray) [Posch et al., 2007] !! quartz.txt -> (7.2-15.0)µm [Kitamura et al., 2007] !! !! VLFR/ (used for mnch_tables_clq.txt) -> mineral volume fractions for 28 soil types and 8 bins: !! volume_fractions_* -> from emission dataset [Claquin et al., 1999]!! !! The lowercase directories contain the calculation scripts for the tables: !! !!
!! opc/ clq/ ext/ int/: !! input_*.ipy -> creates input text file (input_*.txt) for spher_sed (Mie code) !! table_*.bash -> reads input_*.txt, runs spher_sed and generates mnch_tables_*.txt !! sbatch_*.cmd -> launches table_*.bash in Marenostrum4 !! !! kok/: !! substitute.py -> substitutes optical properties for tri-axial spheroids [Kok et al., 2017] in mnch_tables_opc/clq.txt!! !! For parallel computing in Marenostrum4 (for main tables) it is necessary to use input_*.txt, table_*.bash, !! sbatch_*.cmd and spher_sed in different directories. In case of internal mixing, this must be done separately !! for each hematite volume ratio (v00, v02, ..., v20) and then running table_int.ipy generates !! mnch_tables_int.txt. !! !! Once calculated mnch_tables_*.txt, these must be copied within the tables2018 directory in the 2 HPC !! repositories for MONARCH: !! !!
!! /gpfs/archive/bsc32/esarchive/exp/monarch/static/fix/fix_aeropt_bsc/ !! /gpfs/projects/bsc32/models/monarch/data/static/fix/fix_aeropt_bsc/!! !! A specific instruction in 05b_sim.sh creates virtual links to all these tables in CURRENT_RUN !! (XKOK controls the virtual link creation for mnch_tables_opc/clq.txt). !! !! Note that in the HPC repositories, other directories (tables_oldfmt_chinhg, tables_oldfmt_opachg !! and tables_newfmt_basepk) contain no longer used optical tables (described in a local README). !*******************************************************************************