!
! 1.This version of flux_exchange_mod allows the definition of physically independent
! grids for atmosphere, land and sea ice. Ice and ocean must share the same physical
! grid (though the domain decomposition on parallel systems may be different).
! Grid information is input through the grid_spec file (URL). The masked region of the
! land grid and ice/ocean grid must "tile" each other. The masked region of the ice grid
! and ocean grid must be identical.
!
! ATMOSPHERE |----|----|----|----|----|----|----|----|
!
! LAND |---|---|---|---|xxx|xxx|xxx|xxx|xxx|xxx|
!
! ICE |xxx|xxx|xxx|xxx|---|---|---|---|---|---|
!
! OCEAN |xxx|xxx|xxx|xxx|---|---|---|---|---|---|
!
! where |xxx| = masked grid point
!
!
! The atmosphere, land, and ice grids exchange information using the exchange grid xmap_sfc.
!
! The land and ice grids exchange runoff data using the exchange grid xmap_runoff.
!
! Transfer of data between the ice bottom and ocean does not require an exchange
! grid as the grids are physically identical. The flux routines will automatically
! detect and redistribute data if their domain decompositions are different.
!
! To get information from the atmosphere to the ocean it must pass through the
! ice model, first by interpolating from the atmospheric grid to the ice grid,
! and then transferring from the ice grid to the ocean grid.
! 2.Each component model must have a public defined data type containing specific
! boundary fields. A list of these quantities is located in the NOTES of this document.
!
! 3.The surface flux of sensible heat and surface evaporation can be implicit functions
! of surface temperature. As a consequence, the parts of the land and sea-ice models
! that update the surface temperature must be called on the atmospheric time step
!
! 4.The surface fluxes of all other tracers and of momentum are assumed to be explicit
! functions of all surface parameters
!
! 5.While no explicit reference is made within this module to the implicit treatment
! of vertical diffusion in the atmosphere and in the land or sea-ice models, the
! module is designed to allow for simultaneous implicit time integration on both
! sides of the surface interface.
!
! 6.Due to #5, the diffusion part of the land and ice models must be called on the
! atmospheric time step.
!7. Any field passed from one component to another may be "faked" to a
! constant value, or to data acquired from a file, using the
! data_override feature of FMS. The fields to override are runtime
! configurable, using the text file data_table for input.
! See the data_override_mod documentation for more details.
!
! We DO NOT RECOMMEND exercising the data override capabilities of
! the FMS coupler until the user has acquired considerable
! sophistication in running FMS.
!
! Here is a listing of the override capabilities of the flux_exchange
! module:
!
! FROM the atmosphere boundary TO the exchange grid (in sfc_boundary_layer):
!
! t_bot, q_bot, z_bot, p_bot, u_bot, v_bot, p_surf, slp, gust
!
! FROM the ice boundary TO the exchange grid (in sfc_boundary_layer):
!
! t_surf, rough_mom, rough_heat, rough_moist, albedo, u_surf, v_surf
!
! FROM the land boundary TO the exchange grid (in sfc_boundary_layer):
!
! t_surf, t_ca, q_ca, rough_mom, rough_heat, albedo
!
! FROM the exchange grid TO land_ice_atmos_boundary (in
! sfc_boundary_layer):
!
! t, albedo, land_frac, dt_t, dt_q, u_flux, v_flux, dtaudu, dtaudv,
! u_star, b_star, rough_mom
!
! FROM the atmosphere boundary TO the exchange grid (in
! flux_down_from_atmos):
!
! flux_sw, flux_lw, lprec, fprec, coszen, dtmass, delta_t,
! delta_q, dflux_t, dflux_q
!
! FROM the exchange grid TO the land boundary (in
! flux_down_from_atmos):
!
! t_flux, q_flux, lw_flux, sw_flux, lprec, fprec, dhdt, dedt, dedq,
! drdt, drag_q, p_surf
!
! FROM the exchange grid TO the ice boundary (in flux_down_from_atmos):
!
! u_flux, v_flux, t_flux, q_flux, lw_flux, lw_flux_dn, sw_flux,
! sw_flux_dn, lprec, fprec, dhdt, dedt, drdt, coszen, p
!
! FROM the land boundary TO the ice boundary (in flux_land_to_ice):
!
! runoff, calving
!
! FROM the ice boundary TO the ocean boundary (in flux_ice_to_ocean):
!
! u_flux, v_flux, t_flux, q_flux, salt_flux, lw_flux, sw_flux,
! lprec, fprec, runoff, calving, p
!
! FROM the ocean boundary TO the ice boundary (in flux_ocean_to_ice):
!
! u, v, t, s, frazil, sea_level
!
! FROM the ice boundary TO the atmosphere boundary (in flux_up_to_atmos):
!
! t_surf
!
! FROM the land boundary TO the atmosphere boundary (in
! flux_up_to_atmos):
!
! t_ca, t_surf, q_ca
!
! See NOTES below for an explanation of the field names.
!
!
use mpp_mod, only: mpp_npes, mpp_pe, mpp_root_pe, &
mpp_error, stderr, stdout, stdlog, FATAL, NOTE, mpp_set_current_pelist, &
mpp_clock_id, mpp_clock_begin, mpp_clock_end, mpp_sum, &
CLOCK_COMPONENT, CLOCK_SUBCOMPONENT, CLOCK_ROUTINE, lowercase
use mpp_domains_mod, only: mpp_get_compute_domain, mpp_get_compute_domains, &
mpp_global_sum, mpp_redistribute, operator(.EQ.)
use mpp_domains_mod, only: mpp_get_global_domain, mpp_get_data_domain
use mpp_domains_mod, only: mpp_set_global_domain, mpp_set_data_domain, mpp_set_compute_domain
use mpp_domains_mod, only: mpp_deallocate_domain, mpp_copy_domain, domain2d
use mpp_io_mod, only: mpp_close, mpp_open, MPP_MULTI, MPP_SINGLE, MPP_OVERWR
!model_boundary_data_type contains all model fields at the boundary.
!model1_model2_boundary_type contains fields that model2 gets
!from model1, may also include fluxes. These are declared by
!flux_exchange_mod and have private components. All model fields in
!model_boundary_data_type may not be exchanged.
!will support 3 types of flux_exchange:
!REGRID: physically distinct grids, via xgrid
!REDIST: same grid, transfer in index space only
!DIRECT: same grid, same decomp, direct copy
use atmos_model_mod, only: atmos_data_type, land_ice_atmos_boundary_type
use ocean_model_mod, only: ocean_public_type, ice_ocean_boundary_type
use ocean_model_mod, only: ocean_state_type
use ice_model_mod, only: ice_data_type, land_ice_boundary_type, &
ocean_ice_boundary_type, atmos_ice_boundary_type, Ice_stock_pe, &
ice_cell_area => cell_area
use land_model_mod, only: land_data_type, atmos_land_boundary_type
use surface_flux_mod, only: surface_flux
use monin_obukhov_mod, only: mo_profile
use xgrid_mod, only: xmap_type, setup_xmap, set_frac_area, &
put_to_xgrid, get_from_xgrid, &
xgrid_count, some, conservation_check, xgrid_init, &
get_ocean_model_area_elements, stock_integrate_2d, &
stock_move, stock_print
use diag_integral_mod, only: diag_integral_field_init, &
sum_diag_integral_field
use diag_manager_mod, only: register_diag_field, &
register_static_field, send_data, send_tile_averaged_data
use time_manager_mod, only: time_type
use sat_vapor_pres_mod, only: compute_qs
use constants_mod, only: rdgas, rvgas, cp_air, stefan, WTMAIR, HLV, HLF, Radius, PI, CP_OCEAN, &
WTMCO2, WTMC
!Balaji
!utilities stuff into use fms_mod
use fms_mod, only: clock_flag_default, check_nml_error, error_mesg
use fms_mod, only: open_namelist_file, write_version_number
use fms_mod, only: field_exist, field_size, read_data, get_mosaic_tile_grid
use data_override_mod, only: data_override
use coupler_types_mod, only: coupler_1d_bc_type
use atmos_ocean_fluxes_mod, only: atmos_ocean_fluxes_init, atmos_ocean_fluxes_calc
use ocean_model_mod, only: ocean_model_init_sfc, ocean_model_flux_init, ocean_model_data_get
use coupler_types_mod, only: coupler_type_copy
use coupler_types_mod, only: ind_psurf, ind_u10
use atmos_tracer_driver_mod, only: atmos_tracer_flux_init
use field_manager_mod, only: MODEL_ATMOS, MODEL_LAND, MODEL_ICE
use tracer_manager_mod, only: get_tracer_index
use tracer_manager_mod, only: get_tracer_names, get_number_tracers, NO_TRACER
use stock_constants_mod, only: NELEMS, ISTOCK_WATER, ISTOCK_HEAT, ISTOCK_SALT
use stock_constants_mod, only: ISTOCK_SIDE, ISTOCK_TOP, ISTOCK_BOTTOM , STOCK_UNITS, STOCK_NAMES
use stock_constants_mod, only: stocks_file, stocks_report, stocks_report_init
use stock_constants_mod, only: Atm_stock, Ocn_stock, Lnd_stock, Ice_stock
use land_model_mod, only: Lnd_stock_pe
use ocean_model_mod, only: Ocean_stock_pe
use atmos_model_mod, only: Atm_stock_pe
#ifdef SCM
! option to override various surface boundary conditions for SCM
use scm_forc_mod, only: do_specified_flux, scm_surface_flux, &
do_specified_tskin, TSKIN, &
do_specified_albedo, ALBEDO_OBS, &
do_specified_rough_leng, ROUGH_MOM, ROUGH_HEAT, &
do_specified_land
#endif
implicit none
include 'netcdf.inc'
private
character(len=48), parameter :: module_name = 'flux_exchange_mod'
public :: flux_exchange_init, &
sfc_boundary_layer, &
generate_sfc_xgrid, &
flux_down_from_atmos, &
flux_up_to_atmos, &
flux_land_to_ice, &
flux_ice_to_ocean, &
flux_ocean_to_ice, &
flux_check_stocks, &
flux_init_stocks, &
flux_ice_to_ocean_stocks,&
flux_ocean_from_ice_stocks
!-----------------------------------------------------------------------
character(len=128) :: version = '$Id: flux_exchange.F90,v 17.0.4.1.2.5.2.1.2.1 2009/11/06 00:32:10 nnz Exp $'
character(len=128) :: tag = '$Name: mom4p1_pubrel_dec2009_nnz $'
!-----------------------------------------------------------------------
!---- exchange grid maps -----
type(xmap_type), save :: xmap_sfc, xmap_runoff
integer :: n_xgrid_sfc, n_xgrid_runoff
!-----------------------------------------------------------------------
!-------- namelist (for diagnostics) ------
character(len=4), parameter :: mod_name = 'flux'
integer :: id_drag_moist, id_drag_heat, id_drag_mom, &
id_rough_moist, id_rough_heat, id_rough_mom, &
id_land_mask, id_ice_mask, &
id_u_star, id_b_star, id_q_star, id_u_flux, id_v_flux, &
id_t_surf, id_t_flux, id_r_flux, id_q_flux, id_slp, &
id_t_atm, id_u_atm, id_v_atm, id_wind, &
id_t_ref, id_rh_ref, id_u_ref, id_v_ref, id_wind_ref, &
id_del_h, id_del_m, id_del_q, id_rough_scale, &
id_t_ca, id_q_surf, id_q_atm, id_z_atm, id_p_atm, id_gust, &
id_t_ref_land, id_rh_ref_land, id_u_ref_land, id_v_ref_land, &
id_q_ref, id_q_ref_land, id_q_flux_land, id_rh_ref_cmip
integer :: id_co2_atm_dvmr, id_co2_surf_dvmr
integer, allocatable :: id_tr_atm(:), id_tr_surf(:), id_tr_flux(:), id_tr_mol_flux(:)
logical :: first_static = .true.
logical :: do_init = .true.
integer :: remap_method = 1
real, parameter :: bound_tol = 1e-7
real, parameter :: d622 = rdgas/rvgas
real, parameter :: d378 = 1.0-d622
!--- namelist interface ------------------------------------------------------
!