! ! To generate the "grid_spec.nc" file used by this example execute in the shell: ! ! echo 0 360 >xa.dat; echo -90 0 90 >ya.dat ! echo 0 180 360 >xl.dat; echo -90 90 >yl.dat ! make_xgrids -a xa.dat,ya.dat -l xl.dat,yl.dat ! program xgrid_example use utilities_mod, only: utilities_init, utilities_end use mpp_domains_mod, only: domain2D, mpp_define_domains use xgrid_mod, only: xmap_type, setup_xmap, xgrid_count, & put_to_xgrid, get_from_xgrid type(domain2D) :: atm_domain, lnd_domain type (xmap_type) :: xmap ! data structure initialized and used by xgrid_mod integer :: n_xgrid ! number of elements in exchange grid variables real, allocatable, dimension(: ) :: xgr_var ! x-grid vars are 1d real, dimension(1,2 ) :: atm_var ! side 1 vars are 2d real, dimension(2,1,1) :: lnd_var ! side 2 vars are 3d; 3rd dim. for partition call utilities_init ( ) ! ! set up domains to run on 1 PE ! call mpp_define_domains( (/1, 1, 1, 2/), (/ 1, 1/), atm_domain) call mpp_define_domains( (/1, 2, 1, 1/), (/ 1, 1/), lnd_domain) ! ! this call initializes xmap for use in the interpolation ! call setup_xmap(xmap, (/ 'ATM', 'LND' /), (/ atm_domain, lnd_domain /), & "grid_spec.nc" ) ! ! the size of exchange grid variables is dynamic; get it to allocate ! n_xgrid = max(xgrid_count(xmap),1) allocate ( xgr_var(n_xgrid) ) atm_var(1,:) = (/-1, 1/); ! different values for SH and NH ! ! do interpolation; unlike coupler, no computations are done with xgr_var ! call put_to_xgrid (atm_var, 'ATM', xgr_var, xmap) call get_from_xgrid (lnd_var, 'LND', xgr_var, xmap) print * ! lnd_var contains atm_var's SH and NH values print *, 'LND_VAR=', lnd_var ! averaged onto WH and EH; i.e. two zeros print * call utilities_end end program xgrid_example