PUBLIC INTERFACE / ROUTINES / DIAGNOSTICS / ERRORS / NOTES


module bgrid_diagnostics_mod

     Contact:   Bruce Wyman
     Reviewers:
     Change history: WebCVS Log for bgrid_diagnostics.f90


OVERVIEW


     Handles the archiving of B-grid prognostic variables and
     other miscellaneous diagnostics fields to NetCDF files.

     This module uses the interfaces of the FMS diagnostics manager
     (diag_manager), which provides support for NetCDF and distributed
     memory systems.  This also allows dynamical variables to be saved
     with variables from other parts of the (atmospheric) model.

     The user controls file names, output interval, time averaging,
     data packing, and many other features through the diagnostics
     manager diag_table.

     One of the functions of this module is to initialize the atmospheric
     model's diagnostic axes. The axis identification returned by this
     module is then used throughout the atmospheric model wherever
     diagnostic fields are saved (e.g., the physics).

     A second function of this module is to initialize and save the
     dynamical core's prognostic fields, their time tendencies, and
     several computed quantities. For a complete list of fields that
     can be saved see the diagnostic fields section.


OTHER MODULES USED


   bgrid_horiz_mod
   bgrid_vert_mod
   bgrid_masks_mod
   bgrid_prog_var_mod
   bgrid_change_grid_mod
   diag_manager_mod
   time_manager_mod
   fms_mod
   constants_mod
   field_manager_mod
   tracer_manager_mod


PUBLIC INTERFACE


use bgrid_diagnostics_mod [, only: bgrid_diagnostics_init,
                                   bgrid_diagnostics,
                                   bgrid_diagnostics_tend  ]

    bgrid_diagnostics_init
         Must be called to initialize the module.
         Also, axis identifiers (for the diag_manager) are returned.
         The static fields (zsurf, res, ...) are saved to the output file.
 
    bgrid_diagnostics
         Should be called at the end of every time step.
         Outputs the prognostics variables, omega, wind speed, divergence,
         and vorticity.  The time passed to bgrid_diagnostics will used to
         determine if the output fields should be written.
 
    bgrid_diagnostics_tend
         Should be called every time step immediately after dynamics..
         Outputs the tendencies of the prognostics variables due to the
         dynamics. 
 

PUBLIC ROUTINES



call bgrid_diagnostics_init ( Time, Hgrid, Vgrid, Var, fis, res,
                                   mass_axes, vel_axes )

 INPUT

   Time        The current time. [time_type]

   Hgrid       Data structure containing horizontal grid constants
               for the B-grid dynamical core.  [horiz_grid_type]

   Vgrid       Data structure containing vertical grid constants
               for the B-grid dynamical core.    [vert_grid_type]

   Var         Data structure containing the model's prognostics
               variables.    [prog_var_type]

   fis         Surface geopotential height, a static field that is passed
               to the diagnostics manager and saved to the NetCDF file as a 
               static field (i.e., no time axis).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:)]

   res         Reciprocal of eta at the surface, saved to the NetCDF file
               as a static field (i.e., no time axis).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:)]

 OUTPUT

   mass_axes   Integer identifiers for the mass axes (x,y,pfull,phalf).
                   [integer, dimension(4)]

   vel_axes    Integer identifiers for the velocity axes (x,y,pfull,phalf).
               Note that the vertical axes (pfull,phalf) will be the same
               as for the mass axes.  [integer, dimension(4)]

 NOTES

  1) Arguments fis and res must have dimensions consistent with the
     dynamical core (in Hgrid), the storage can be allocated using
     module prog_var_mod.

  2) Static fields (fis, res, ...) are written to the output
     (NetCDF) file if requested by the diagnostics manager.

------------------------------------------------------------------


call bgrid_diagnostics ( Hgrid, Vgrid, Var, Masks, Time, omega, div, mfew, mfns )

 INPUT

   Hgrid       Data structure containing horizontal grid constants
               for the B-grid dynamical core.  [horiz_grid_type]

   Vgrid       Data structure containing vertical grid constants
               for the B-grid dynamical core.    [vert_grid_type]

   Var         Data structure containing the model's prognostics
               variables.    [prog_var_type]

   Masks       Data structure containing grid mask information.
                 [grid_mask_type]
               
   Time        The current time. [time_type]

   omega       Omega diagnostic (in Pascals/sec).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

   div         Divergence diagnostic (in 1/sec).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

   mfew        Zonal mass flux on the east-west sides of a
               temperature grid box (in Pascals-m^2/sec).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

   mfns        Meridional mass flux on the south-north sides of a
               temperature grid box (in Pascals-m^2/sec).
                   [real, dimension(Hgrid%ilb:,Hgrid%jlb:,:)]

------------------------------------------------------------------


call bgrid_diagnostics_tend ( Hgrid, Var_dt, Masks, Time )

 INPUT

   Hgrid       Data structure containing horizontal grid constants
               for the B-grid dynamical core.  [horiz_grid_type]

   Var_dt      Data structure containing the tendencies of the
               model's prognostics variables.    [prog_var_type]

   Masks       Data structure containing grid mask information.
                 [grid_mask_type]

   Time        The current time. [time_type]

 NOTE
   The assumption is made that "Var_dt" contains only the
   tendencies from the dynamical core. This assumption is valid
   for all current B-grid core drivers.


DIAGNOSTIC FIELDS

Diagnostic fields may be output to a netcdf file by specifying the
module name dynamics and the desired field names (given below)
in file diag_table. See the documentation for diag_manager.

Diagnostic fields for module name: dynamics

   field name   field description
   ----------   -----------------

    bk          vertical coordinate eta value
    pk          vertical coordinate pressure value (Pascals)
    zsurf       height of the surface (m)
    res         reciprocal of eta at the surface
    alm         actual longitudes for temperature grid (degrees_E)
    aph         actual latitudes for temperature grid (degrees_N)

    ps          surface pressure (Pascals)
    slp         sea level pressure (Pascals)
    ucomp       zonal wind component (m/s)
    vcomp       meridional wind component (m/s)
    temp        temperature (deg_k)
    theta       potential temperature (deg_k)

    pres_full   pressure at full model levels (pascals)
    pres_half   pressure at half model levels (pascals)
    omega       omega vertical velocity (pascals/sec)
    wspd        wind speed (m/s)
    div         divergence (1/s)
    vor         relative vorticity (1/s)
    mfew        zonal mass flux (Pascals-m2/s)
    mfns        meridional mass flux (Pascals-m2/s)

    ucomp_sq    zonal wind component squared (m2/s2)
    vcomp_sq    meridional wind component squared (m2/s2)
    temp_sq     temperature squared (deg_K**2)
    omega_sq    omega vertical velocity squared (Pa**2/s**2)
    ucomp_vcomp zonal times meridional wind components (m2/s2)
    omega_temp  omega vertical velocity times temperature (Pascals*deg_K/sec)

    udt_dyn     zonal wind tendency for dynamics (m/s2)
    vdt_dyn     meridional wind tendency for dynamics (m/s2)
    tdt_dyn     temperature tendency for dynamics (deg_k/sec)

    trname         tracers concentrations
    trname_dt_dyn  tracers tendencies for dynamics

Notes:

   1) bk, pk, zsurf, res, alm, aph  are static variables

   2) In this version, div, vor are recomputed for diagnostics

   3) The names for tracer tendencies are determined from the tracer names.
      The short names will be appended with "_dt_dyn", the long names are
      modified to indicated a tendency for dynamics, and the units are
      appended with "/s".

   4) All available diagnostic tracer fields will be printed to the logfile.


ERROR MESSAGES


   None.


KNOWN BUGS


     None.


NOTES


   None.


FUTURE PLANS


   None.