Atmospheric Surface Boundary Layer
##################################

.. _atmosphericsurfaceboundarylayer:

There are two ways to force CROCO with atmospheric fields. 
The first is the use of classical bulk parameterization 
(BULK_FLUX cpp key). Four have been updated and implemented in 
CROCO (COARE3.0, ECUMEV0, ECUMEV6 and WASP). 
The second is the use of a simplified atmospheric model 
(ABL1D cpp key, :cite:t:`lemarie_simplified_2021`) on top of 
the bulk parameterization.

.. note::

   * ABL1D forcing strategy is still under evaluation.

   * In both cases, the use of a bulk parameterization (BULK_FLUX) 
     is mandatory.

Below you'll find the CPP keys for these two forcing capabilities 
and their descriptions :

**BULK_FLUX's related CPP options:**

================= ===================================================================================
CPP options       Description
================= ===================================================================================
BULK_FLUX          Activate bulk formulation for surface turbulent fluxes
                   (by default, COARE3.0 parametrization is used)
BULK_ECUMEV0       Use ECUMEv0 bulk formulation instead of COARE3.0 formulation
BULK_ECUMEV6       Use ECUMEv6 bulk formulation instead of COARE3.0 formulation
BULK_WASP          Use WASP bulk formulation instead of COARE3.0 formulation
BULK_GUSTINESS     Add in gustiness effect on the surface wind module.
                   Can be used for both bulk parametrizations.
BULK_LW            Add in long-wave radiation feedback from model SST
SFLUX_CFB          Activate current feedback on ... :cite:p:`renault_recipes_2020`
CFB_STRESS         | ... surface stress, using the *Stress-Correction Approach*
                    (by default when SFLUX_CFB is defined)
CFB_WIND_TRA       | ... surface wind for turbulent heat fluxes computation,
                    using the *Wind-Correction Approach*
                    (by default when SFLUX_CFB is defined)
SST_SKIN           Activate skin sst computation :cite:p:`zeng_prognostic_2005`
ONLINE             | Read native files and perform online interpolation on CROCO
                   | grid (default cubic interpolation)
QCORRECTION        Activate heat flux correction around model SST (if BULK_FLUX is undefined) 
SFLX_CORR          Activate freshwater flux correction around model SSS (if BULK_FLUX is undefined)
ANA_DIURNAL_SW     | Activate analytical diurnal modulation of short wave radiations 
                   | (only appropriate if there is no diurnal cycle in data)        
RAIN_FLUX         Add E-P flux  into the mass budget (added in omega) 
================= ===================================================================================

By default COARE3.0 parametrization is used with GUSTINESS effects.
To change bulk parametrization, one has to define one of the following cpp keys (not additional) :

* define BULK_ECUMEV0 to use ECUME_v0 parametrization
* define BULK_ECUMEV6 to use ECUME_v6 parametrization
* define BULK_WASP to use WASP parametrization

.. warning::

   It is possible to add GUSTINESS effects for all parametrizations by defining BULK_GUSTINESS cpp key

**ABL1D's related CPP options:**

====================     ==========================================================================
CPP options              Description
====================     ==========================================================================
ABL1D                    Activate ABL1d model and BULK_FLUX parametrization
ANA_ABL_LSDATA           Impose large scale forcing data for analytical simulations
ANA_ABL_VGRID            Compute vertical grid for ABL1d online for analytical simulations
STRESS_AT_RHO_POINTS     Compute stress at rho points
ABL_NUDGING              Active nudging for ...
ABL_NUDGING_DYN          ... dynamic (two components of the horizontal wind speed)
ABL_NUDGING_TRA          ... tracers (air temperature and specific humidity)
ABL_DYN_RESTORE_EQ       Active Equator dynamic restoration
====================     ==========================================================================

**ONLINE related CPP options:**

ONLINE option is an alternative to pre-processing of surface forcing 
data for both forcing strategy (ABL1D / BULK_FLUX), that can be useful 
for long-term and/or high resolution simulations, especially if 
handling multiple configurations. ONLINE option calls for CUBIC_INTERP
in :file:`set_global_definitions.h`.

==============   ===========================================================================
CPP options      Description
==============   ===========================================================================
ECMWF            Use ECMWF atm fluxes
AROME            Use METEO FRANCE fluxes
READ_PATM        | Read atmospheric pressure instead of using default reference pressure
                 | and take into account the atmospherical pressure gradient in the equations
OBC_PATM         | In the case of READ_PATM, inverse barometer effect to the open boundaries if 
                 | the atmospherical pressure is read in the meteo file. 
==============   ===========================================================================


**ONLINE variables description**

The following table describe what is expected in online forcing file.

+-------------------------------+------------+--------+----------+
| variables                                  |option given cppkey|
+-------------------------------+------------+--------+----------+
| Long name                     | units      | AROME  | ERA_ECMWF| 
+===============================+============+========+==========+
| Temperature above ground      | Kelvin     | t2m    | T2M      |
+-------------------------------+------------+--------+----------+
| specific humidity             | Kg/Kg      | rh     | Q        |
+-------------------------------+------------+--------+----------+
| precipitation rate            | Kg.m-2.s-1 | rain   | TP       |
+-------------------------------+------------+--------+----------+
| Upward Net short wave         | W.m-2      | swhf   | SSR      |
+-------------------------------+------------+--------+----------+
| Downward long wave            | W.m-2      | lwhf   | STRD     |
+-------------------------------+------------+--------+----------+
| U component of wind           | m/s        | u10m   | U10M     |
+-------------------------------+------------+--------+----------+
| V component of wind           | m/s        | v10m   | V10M     |
+-------------------------------+------------+--------+----------+
| Pressure at sea level         | Pa         | pmer   | msl      |
+-------------------------------+------------+--------+----------+
| time vector                   | days       | time   | time     |
+-------------------------------+------------+--------+----------+


.. warning:: For *AROME* time units must be in days since 1900-01-01

.. note ::

    Long wave flux is either downward or net given your inputs in atmospherical 
    modeles : 
    
    * First case : You have a downward flux only. So you have to add *BULK_LW* 
      option to compute the net flux.
    
    * Second case : You already have a net long flux. You must remove the 
      *BULK_LW* to not take twice the feedback into account. 


*Preselected options (cppdefs.h):*

::

# undef BULK_FLUX
# ifdef BULK_FLUX
#  undef  BULK_ECUMEV0
#  undef  BULK_ECUMEV6
#  undef  BULK_WASP
#  define BULK_GUSTINESS
#  define BULK_LW
#  undef  SST_SKIN
#  undef  ANA_DIURNAL_SW
#  undef  ONLINE
#  ifdef ONLINE
#   undef  AROME
#   undef  ERA_ECMWF
#  endif
#  undef READ_PATM
#  ifdef READ_PATM
#   define OBC_PATM
#  endif
# else
#  define QCORRECTION
#  define SFLX_CORR
#  undef  SFLX_CORR_COEF
#  define ANA_DIURNAL_SW
# endif
# undef  SFLUX_CFB
# undef  SEA_ICE_NOFLUX

*Preselected options (cppdefs_dev.h):*

::

#ifdef BULK_FLUX
# ifdef ONLINE
#  define CUBIC_INTERP
# endif
# ifdef BULK_ECUMEV0
#  define BULK_GUSTINESS
# elif defined BULK_ECUMEV6
#  define BULK_GUSTINESS
# elif defined BULK_WASP
#  define BULK_GUSTINESS
# endif
#endif

::

#ifdef SFLUX_CFB
# ifdef BULK_FLUX
#  define CFB_STRESS
#  define CFB_WIND_TRA
# else
#  undef  CFB_STRESS
#  undef  CFB_WIND_TRA
# endif
#endif


