clone_MD_to_MD copies one MOM_domain_type into another, while allowing some properties of the new type to differ from the original one.
1603 type(MOM_domain_type),
intent(in) :: MD_in
1604 type(MOM_domain_type),
pointer :: MOM_dom
1607 integer,
dimension(2), &
1608 optional,
intent(inout) :: min_halo
1611 integer,
optional,
intent(in) :: halo_size
1614 logical,
optional,
intent(in) :: symmetric
1618 optional,
intent(in) :: domain_name
1621 integer :: global_indices(4)
1622 logical :: mask_table_exists
1623 character(len=64) :: dom_name
1625 if (.not.
associated(mom_dom))
then
1627 allocate(mom_dom%mpp_domain)
1628 allocate(mom_dom%mpp_domain_d2)
1632 mom_dom%niglobal = md_in%niglobal ; mom_dom%njglobal = md_in%njglobal
1633 mom_dom%nihalo = md_in%nihalo ; mom_dom%njhalo = md_in%njhalo
1635 mom_dom%symmetric = md_in%symmetric
1636 mom_dom%nonblocking_updates = md_in%nonblocking_updates
1638 mom_dom%X_FLAGS = md_in%X_FLAGS ; mom_dom%Y_FLAGS = md_in%Y_FLAGS
1639 mom_dom%layout(:) = md_in%layout(:) ; mom_dom%io_layout(:) = md_in%io_layout(:)
1641 if (
associated(md_in%maskmap))
then
1642 mask_table_exists = .true.
1643 allocate(mom_dom%maskmap(mom_dom%layout(1), mom_dom%layout(2)))
1644 mom_dom%maskmap(:,:) = md_in%maskmap(:,:)
1646 mask_table_exists = .false.
1649 if (
present(halo_size) .and.
present(min_halo))
call mom_error(fatal, &
1650 "clone_MOM_domain can not have both halo_size and min_halo present.")
1652 if (
present(min_halo))
then
1653 mom_dom%nihalo = max(mom_dom%nihalo, min_halo(1))
1654 min_halo(1) = mom_dom%nihalo
1655 mom_dom%njhalo = max(mom_dom%njhalo, min_halo(2))
1656 min_halo(2) = mom_dom%njhalo
1659 if (
present(halo_size))
then
1660 mom_dom%nihalo = halo_size ; mom_dom%njhalo = halo_size
1663 if (
present(symmetric))
then ; mom_dom%symmetric = symmetric ;
endif
1666 if (
present(domain_name)) dom_name = trim(domain_name)
1668 global_indices(1) = 1 ; global_indices(2) = mom_dom%niglobal
1669 global_indices(3) = 1 ; global_indices(4) = mom_dom%njglobal
1670 if (mask_table_exists)
then
1671 call mom_define_domain( global_indices, mom_dom%layout, mom_dom%mpp_domain, &
1672 xflags=mom_dom%X_FLAGS, yflags=mom_dom%Y_FLAGS, &
1673 xhalo=mom_dom%nihalo, yhalo=mom_dom%njhalo, &
1674 symmetry = mom_dom%symmetric, name=dom_name, &
1675 maskmap=mom_dom%maskmap )
1677 call mom_define_domain( global_indices, mom_dom%layout, mom_dom%mpp_domain, &
1678 xflags=mom_dom%X_FLAGS, yflags=mom_dom%Y_FLAGS, &
1679 xhalo=mom_dom%nihalo, yhalo=mom_dom%njhalo, &
1680 symmetry = mom_dom%symmetric, name=dom_name)
1683 if ((mom_dom%io_layout(1) + mom_dom%io_layout(2) > 0) .and. &
1684 (mom_dom%layout(1)*mom_dom%layout(2) > 1))
then
1685 call mom_define_io_domain(mom_dom%mpp_domain, mom_dom%io_layout)