! There are four subgrids, labeled T (for tracer), C (corner of T), N (north of T) and E (east of T).
! The following schematic describes the grid cell notation.
!
!
!
! Ni,j
! +----------+-----------+Ci,j
! | |
! | |
! | |
! + +Ti,j +Ei,j
! | |
! | |
! +----------+-----------+
!
!
!
!
! The grid_spec file would contains all of the following information on each subgrid.
! The following example is for T subgrid. Repeated for E, C, and N subgrids.
!
!
!
! x_T, y_T = Geographic location of T-cell center
! x_vert_T, y_vert_T = Geographic location of T-cell vertices(each cell has 4 vertices)
! area_T = area of T-cell
! angle_T = Angle clockwise between logical and geographic east of T-cell
! ds_00_02_T = Length of western face of T-cell
! ds_20_22_T = Length of eastern face of T-cell
! ds_02_22_T = Length of northern face of T-cell
! ds_00_20_T = Length of southern face of T-cell
! ds_00_01_T = Distance from southwest corner to western face center of T-cell
! ds_01_02_T = Distance from northwest corner to western face center of T-cell
! ds_02_12_T = Distance from northwest corner to northern face center of T-cell
! ds_12_22_T = Distance from northeast corner to northern face center of T-cell
! ds_21_22_T = Distance from northeast corner to eastern face center of T-cell
! ds_20_21_T = Distance from southeast corner to eastern face center of T-cell
! ds_10_20_T = Distance from southeast corner to southern face center of T-cell
! ds_00_10_T = Distance from southwest corner to southern face center of T-cell
! ds_01_11_T = Distance from center to western face of T-cell
! ds_11_12_T = Distance from center to northern face of T-cell
! ds_11_21_T = Distance from center to eastern face of T-cell
! ds_10_11_T = Distance from center to southern face of T-cell
! ds_01_21_T = width of T-cell
! ds_10_12_T = height of T-cell
!
! Distances between points are described in the following schematics (for T-cell).
!
!
!
! +<----ds_02_12_T---->+<----ds_12_22_T---->+
! ^ ^ ^
! | | |
! | | |
! ds_01_02_T ds_11_12_T ds_21_22_T
! | | |
! | | |
! v v v
! +<----ds_01_11_T---->+<----ds_11_21_T---->+
! ^ ^ ^
! | | |
! | | |
! ds_00_01_T ds_10_11_T ds_20_21_T
! | | |
! | | |
! v v v
! +<----ds_00_10_T---->+<----ds_10_20_T---->+
!
!
!
! <-------------- ds_02_22_T---------------->
! ^ +--------------------+--------------------+ ^
! | | ^ | |
! | | | | |
! | | | | |
! | | | | |
! | | | | |
! ds_00_02_T|<-------------------+--ds_01_21_T------->| ds_20_22_T
! | | | | |
! | | ds_10_12_T | |
! | | | | |
! | | | | |
! | | | | |
! | | v | |
! v +--------------------+--------------------+ v
! <-------------- ds_00_20_T---------------->
!
!
! The other three subgrids (E, N, C subgrids) have similiar name but replacing T.
!
! Axis specifications involve specifying the number of regions for varying
! resolution, the bondaries of said regions and the nominal resolution in
! the respective regions.
!
! For instance, for longitude axis specification:
!
! dx_lon(1) = 4 dx_lon(2) = 6
! |<----|----|----|----|----|----|------|------|------|------|------|------>|
! | | |
! x_lon(1) x_lon(2) x_lon(3)
!
! Grid cells are constructed such that
!
! dxt(i) = 0.5*(dxu(i-1)+dxu(i))
!
!
!
!
use mpp_mod, only : mpp_pe, mpp_root_pe, mpp_npes, mpp_error, mpp_chksum, FATAL, NOTE
use mpp_mod, only : uppercase, lowercase
use mpp_io_mod, only : MPP_RDONLY, MPP_ASCII, MPP_MULTI, MPP_SINGLE, MPP_NETCDF
use mpp_io_mod, only : mpp_write_meta, mpp_write, mpp_read, mpp_open, mpp_close
use mpp_io_mod, only : mpp_get_id, mpp_get_info, axistype, fieldtype
use mpp_io_mod, only : mpp_get_atts, mpp_get_axes, mpp_get_fields, mpp_get_axis_data
use mpp_domains_mod, only : domain2d, mpp_get_compute_domain, mpp_get_data_domain
use mpp_domains_mod, only : mpp_define_domains, mpp_global_field
use fms_mod, only : write_version_number, open_namelist_file, file_exist
use fms_mod, only : close_file, check_nml_error, stdout, string
use constants_mod, only : radius, pi, RADIAN, epsln
use axis_utils_mod, only : nearest_index, lon_in_range, get_axis_cart
use grids_type_mod, only : hgrid_data_type, cell_type
use grids_util_mod, only : make_axis, gcell, get_file_unit, write_field_meta
use grids_util_mod, only : write_field_data, set_grid
implicit none
private
integer, parameter :: maxlen=10000,maxbounds=1000
!------ namelist interface ---------------------------------------------
!------ specify a spherical grid resolution in latitude, longitude, and depth
!-----------------------------------------------------------------------
integer :: nxlons = 0
integer :: nylats = 0
real, dimension(maxbounds) :: x_lon, dx_lon, y_lat, dy_lat
logical :: square_grid=.false.
logical :: extend_square_grid=.false.
logical :: cyclic_x=.true.
logical :: cyclic_y=.false.
logical :: tripolar_grid = .false.
real :: lat_join = 65.0 ! requested latitude for rotated grid
logical :: read_my_grid = .false.
character(len=128) :: my_grid_file = 'my_hgrid'
logical :: debug = .false.
logical :: f_plane = .false.
logical :: beta_plane = .false.
logical :: simple_cartesian = .false.
real :: simple_cartesian_dx = 0
real :: simple_cartesian_dy = 0
real :: f_plane_latitude = 30.0
character(len=24) :: lon_axis_t = 'GRID_X_T'
character(len=24) :: lat_axis_t = 'GRID_Y_T'
character(len=24) :: lon_axis_u = 'none'
character(len=24) :: lat_axis_u = 'none'
!