Returns true if unit tests of neutral_diffusion functions fail. Otherwise returns false.
1517 logical,
intent(in) :: verbose
1519 integer,
parameter :: nk = 4
1520 real,
dimension(nk+1) :: TiL, TiR1, TiR2, TiR4, Tio
1521 real,
dimension(nk) :: TL
1522 real,
dimension(nk+1) :: SiL
1523 real,
dimension(nk+1) :: PiL, PiR4
1524 real,
dimension(2*nk+2) :: PiLRo, PiRLo
1525 integer,
dimension(2*nk+2) :: KoL, KoR
1526 real,
dimension(2*nk+1) :: hEff
1527 real,
dimension(2*nk+1) :: Flx
1530 real :: h_neglect, h_neglect_edge
1532 h_neglect_edge = 1.0e-10 ; h_neglect = 1.0e-30
1536 ndiff_unit_tests_continuous = .false.
1537 write(*,*)
'==== MOM_neutral_diffusion: ndiff_unit_tests_continuous ='
1539 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1540 test_fv_diff(v,1.,1.,1., 0.,1.,2., 1.,
'FV: Straight line on uniform grid')
1541 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1542 test_fv_diff(v,1.,1.,0., 0.,4.,8., 7.,
'FV: Vanished right cell')
1543 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1544 test_fv_diff(v,0.,1.,1., 0.,4.,8., 7.,
'FV: Vanished left cell')
1545 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1546 test_fv_diff(v,1.,2.,4., 0.,3.,9., 4.,
'FV: Stretched grid')
1547 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1548 test_fv_diff(v,2.,0.,2., 0.,1.,2., 0.,
'FV: Vanished middle cell')
1549 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1550 test_fv_diff(v,0.,1.,0., 0.,1.,2., 2.,
'FV: Vanished on both sides')
1551 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1552 test_fv_diff(v,1.,0.,0., 0.,1.,2., 0.,
'FV: Two vanished cell sides')
1553 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1554 test_fv_diff(v,0.,0.,0., 0.,1.,2., 0.,
'FV: All vanished cells')
1556 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1557 test_fvlsq_slope(v,1.,1.,1., 0.,1.,2., 1.,
'LSQ: Straight line on uniform grid')
1558 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1559 test_fvlsq_slope(v,1.,1.,0., 0.,1.,2., 1.,
'LSQ: Vanished right cell')
1560 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1561 test_fvlsq_slope(v,0.,1.,1., 0.,1.,2., 1.,
'LSQ: Vanished left cell')
1562 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1563 test_fvlsq_slope(v,1.,2.,4., 0.,3.,9., 2.,
'LSQ: Stretched grid')
1564 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1565 test_fvlsq_slope(v,1.,0.,1., 0.,1.,2., 2.,
'LSQ: Vanished middle cell')
1566 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1567 test_fvlsq_slope(v,0.,1.,0., 0.,1.,2., 0.,
'LSQ: Vanished on both sides')
1568 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1569 test_fvlsq_slope(v,1.,0.,0., 0.,1.,2., 0.,
'LSQ: Two vanished cell sides')
1570 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1571 test_fvlsq_slope(v,0.,0.,0., 0.,1.,2., 0.,
'LSQ: All vanished cells')
1573 call interface_scalar(4, (/10.,10.,10.,10./), (/24.,18.,12.,6./), tio, 1, h_neglect)
1576 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1577 test_data1d(v,5, tio, (/24.,22.5,15.,7.5,6./),
'Linear profile, linear interface temperatures')
1578 call interface_scalar(4, (/10.,10.,10.,10./), (/24.,18.,12.,6./), tio, 2, h_neglect)
1579 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1580 test_data1d(v,5, tio, (/24.,22.,15.,8.,6./),
'Linear profile, PPM interface temperatures')
1582 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1583 test_ifndp(v,-1.0, 0., 1.0, 1.0, 0.5,
'Check mid-point')
1584 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1585 test_ifndp(v, 0.0, 0., 1.0, 1.0, 0.0,
'Check bottom')
1586 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1587 test_ifndp(v, 0.1, 0., 1.1, 1.0, 0.0,
'Check below')
1588 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1589 test_ifndp(v,-1.0, 0., 0.0, 1.0, 1.0,
'Check top')
1590 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1591 test_ifndp(v,-1.0, 0., -0.1, 1.0, 1.0,
'Check above')
1592 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1593 test_ifndp(v,-1.0, 0., 3.0, 1.0, 0.25,
'Check 1/4')
1594 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1595 test_ifndp(v,-3.0, 0., 1.0, 1.0, 0.75,
'Check 3/4')
1596 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1597 test_ifndp(v, 1.0, 0., 1.0, 1.0, 0.0,
'Check dRho=0 below')
1598 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1599 test_ifndp(v,-1.0, 0., -1.0, 1.0, 1.0,
'Check dRho=0 above')
1600 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1601 test_ifndp(v, 0.0, 0., 0.0, 1.0, 0.5,
'Check dRho=0 mid')
1602 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. &
1603 test_ifndp(v,-2.0, .5, 5.0, 0.5, 0.5,
'Check dP=0')
1606 call find_neutral_surface_positions_continuous(3, &
1607 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1608 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1609 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1610 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1611 pilro, pirlo, kol, kor, heff)
1612 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1613 (/1,1,2,2,3,3,3,3/), &
1614 (/1,1,2,2,3,3,3,3/), &
1615 (/0.,0.,0.,0.,0.,0.,1.,1./), &
1616 (/0.,0.,0.,0.,0.,0.,1.,1./), &
1617 (/0.,10.,0.,10.,0.,10.,0./), &
1618 'Identical columns')
1619 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 8, &
1620 absolute_positions(3, 8, (/0.,10.,20.,30./), kol, pilro), &
1621 (/0.,0.,10.,10.,20.,20.,30.,30./),
'... left positions')
1622 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 8, &
1623 absolute_positions(3, 8, (/0.,10.,20.,30./), kor, pirlo), &
1624 (/0.,0.,10.,10.,20.,20.,30.,30./),
'... right positions')
1625 call neutral_surface_flux(3, 2*3+2, 2, (/10.,10.,10./), (/10.,10.,10./), &
1626 (/20.,16.,12./), (/20.,16.,12./), &
1627 pilro, pirlo, kol, kor, heff, flx, .true., &
1628 h_neglect, h_neglect_edge=h_neglect_edge)
1629 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 7, flx, &
1630 (/0.,0.,0.,0.,0.,0.,0./),
'Identical columns, rho flux (=0)')
1631 call neutral_surface_flux(3, 2*3+2, 2, (/10.,10.,10./), (/10.,10.,10./), &
1632 (/-1.,-1.,-1./), (/1.,1.,1./), &
1633 pilro, pirlo, kol, kor, heff, flx, .true., &
1634 h_neglect, h_neglect_edge=h_neglect_edge)
1635 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 7, flx, &
1636 (/0.,20.,0.,20.,0.,20.,0./),
'Identical columns, S flux')
1639 call find_neutral_surface_positions_continuous(3, &
1640 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1641 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1642 (/0.,10.,20.,30./), (/20.,16.,12.,8./), (/0.,0.,0.,0./), &
1643 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1644 pilro, pirlo, kol, kor, heff)
1645 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1646 (/1,1,2,2,3,3,3,3/), &
1647 (/1,1,1,2,2,3,3,3/), &
1648 (/0.,0.5,0.,0.5,0.,0.5,1.,1./), &
1649 (/0.,0.,0.5,0.,0.5,0.,0.5,1./), &
1650 (/0.,5.,5.,5.,5.,5.,0./), &
1651 'Right column slightly cooler')
1652 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 8, &
1653 absolute_positions(3, 8, (/0.,10.,20.,30./), kol, pilro), &
1654 (/0.,5.,10.,15.,20.,25.,30.,30./),
'... left positions')
1655 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_data1d(v, 8, &
1656 absolute_positions(3, 8, (/0.,10.,20.,30./), kor, pirlo), &
1657 (/0.,0.,5.,10.,15.,20.,25.,30./),
'... right positions')
1660 call find_neutral_surface_positions_continuous(3, &
1661 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1662 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1663 (/0.,10.,20.,30./), (/24.,20.,16.,12./), (/0.,0.,0.,0./), &
1664 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1665 pilro, pirlo, kol, kor, heff)
1666 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1667 (/1,1,1,2,2,3,3,3/), &
1668 (/1,1,2,2,3,3,3,3/), &
1669 (/0.,0.,0.5,0.,0.5,0.,0.5,1./), &
1670 (/0.,0.5,0.,0.5,0.,0.5,1.,1./), &
1671 (/0.,5.,5.,5.,5.,5.,0./), &
1672 'Right column slightly warmer')
1675 call find_neutral_surface_positions_continuous(3, &
1676 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1677 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1678 (/0.,10.,20.,30./), (/16.,12.,8.,4./), (/0.,0.,0.,0./), &
1679 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1680 pilro, pirlo, kol, kor, heff)
1681 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1682 (/1,2,2,3,3,3,3,3/), &
1683 (/1,1,1,1,2,2,3,3/), &
1684 (/0.,0.,0.5,0.,0.5,1.,1.,1./), &
1685 (/0.,0.,0.,0.5,0.,0.5,0.,1./), &
1686 (/0.,0.,5.,5.,5.,0.,0./), &
1687 'Right column somewhat cooler')
1690 call find_neutral_surface_positions_continuous(3, &
1691 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1692 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1693 (/0.,10.,20.,30./), (/9.,7.,5.,3./), (/0.,0.,0.,0./), &
1694 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1695 pilro, pirlo, kol, kor, heff)
1696 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1697 (/1,2,3,3,3,3,3,3/), &
1698 (/1,1,1,1,1,2,3,3/), &
1699 (/0.,0.,0.,1.,1.,1.,1.,1./), &
1700 (/0.,0.,0.,0.,0.,0.,0.,1./), &
1701 (/0.,0.,0.,0.,0.,0.,0./), &
1702 'Right column much cooler')
1705 call find_neutral_surface_positions_continuous(3, &
1706 (/0.,10.,20.,30./), (/22.,18.,14.,10./), (/0.,0.,0.,0./), &
1707 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1708 (/0.,10.,20.,30./), (/14.,14.,10.,2./), (/0.,0.,0.,0./), &
1709 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1710 pilro, pirlo, kol, kor, heff)
1711 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1712 (/1,2,3,3,3,3,3,3/), &
1713 (/1,1,1,1,2,3,3,3/), &
1714 (/0.,0.,0.,0.,0.,1.,1.,1./), &
1715 (/0.,0.,0.,0.,0.,0.,0.,1./), &
1716 (/0.,0.,0.,0.,10.,0.,0./), &
1717 'Right column with mixed layer')
1720 call find_neutral_surface_positions_continuous(3, &
1721 (/0.,10.,20.,30./), (/14.,14.,10.,2./), (/0.,0.,0.,0./), &
1722 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1723 (/0.,10.,20.,30./), (/14.,14.,10.,2./), (/0.,0.,0.,0./), &
1724 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1725 pilro, pirlo, kol, kor, heff)
1726 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1727 (/1,1,2,2,3,3,3,3/), &
1728 (/1,1,2,2,3,3,3,3/), &
1729 (/0.,0.,0.,0.,0.,0.,1.,1./), &
1730 (/0.,0.,0.,0.,0.,0.,1.,1./), &
1731 (/0.,10.,0.,10.,0.,10.,0./), &
1732 'Indentical columns with mixed layer')
1735 call find_neutral_surface_positions_continuous(3, &
1736 (/0.,10.,20.,30./), (/14.,14.,10.,2./), (/0.,0.,0.,0./), &
1737 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1738 (/0.,10.,20.,30./), (/10.,14.,12.,4./), (/0.,0.,0.,0./), &
1739 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1740 pilro, pirlo, kol, kor, heff)
1741 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1742 (/1,2,3,3,3,3,3,3/), &
1743 (/1,1,1,2,3,3,3,3/), &
1744 (/0.,0.,0.,0.,0.,0.,.75,1./), &
1745 (/0.,0.,0.,0.,0.,0.25,1.,1./), &
1746 (/0.,0.,0.,0.,0.,7.5,0./), &
1747 'Right column with unstable mixed layer')
1750 call find_neutral_surface_positions_continuous(3, &
1751 (/0.,10.,20.,30./), (/10.,14.,12.,4./), (/0.,0.,0.,0./), &
1752 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1753 (/0.,10.,20.,30./), (/14.,14.,10.,2./), (/0.,0.,0.,0./), &
1754 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1755 pilro, pirlo, kol, kor, heff)
1756 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1757 (/1,1,1,2,3,3,3,3/), &
1758 (/1,2,3,3,3,3,3,3/), &
1759 (/0.,0.,0.,0.,0.,0.25,1.,1./), &
1760 (/0.,0.,0.,0.,0.,0.,.75,1./), &
1761 (/0.,0.,0.,0.,0.,7.5,0./), &
1762 'Left column with unstable mixed layer')
1765 call find_neutral_surface_positions_continuous(3, &
1766 (/0.,10.,20.,30./), (/8.,12.,10.,2./), (/0.,0.,0.,0./), &
1767 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1768 (/0.,10.,20.,30./), (/10.,14.,12.,4./), (/0.,0.,0.,0./), &
1769 (/-1.,-1.,-1.,-1./), (/1.,1.,1.,1./), &
1770 pilro, pirlo, kol, kor, heff)
1771 ndiff_unit_tests_continuous = ndiff_unit_tests_continuous .or. test_nsp(v, 8, kol, kor, pilro, pirlo, heff, &
1772 (/1,1,1,1,2,3,3,3/), &
1773 (/1,2,3,3,3,3,3,3/), &
1774 (/0.,0.,0.,0.,0.,0.,0.75,1./), &
1775 (/0.,0.,0.,0.5,0.5,0.5,1.,1./), &
1776 (/0.,0.,0.,0.,0.,6.,0./), &
1777 'Two unstable mixed layers')
1779 if (.not. ndiff_unit_tests_continuous)
write(*,*)
'Pass'