1518 type(time_type),
intent(in) :: time
1520 type(param_file_type),
intent(in) :: param_file
1521 type(diag_ctrl),
target,
intent(inout) :: diag
1522 type(surface_forcing_cs),
pointer :: cs
1523 type(tracer_flow_control_cs),
pointer :: tracer_flow_csp
1533 type(directories) :: dirs
1535 type(time_type) :: time_frc
1537 #include "version_variable.h" 1538 character(len=40) :: mdl =
"MOM_surface_forcing" 1539 character(len=200) :: filename, gust_file
1541 if (
associated(cs))
then 1542 call mom_error(warning,
"surface_forcing_init called with an associated "// &
1543 "control structure.")
1548 id_clock_forcing=cpu_clock_id(
'(Ocean surface forcing)', grain=clock_module)
1549 call cpu_clock_begin(id_clock_forcing)
1552 if (
associated(tracer_flow_csp)) cs%tracer_flow_CSp => tracer_flow_csp
1555 call log_version(param_file, mdl, version,
'')
1556 call get_param(param_file, mdl,
"ENABLE_THERMODYNAMICS", cs%use_temperature, &
1557 "If true, Temperature and salinity are used as state \n"//&
1558 "variables.", default=.true.)
1559 call get_param(param_file, mdl,
"INPUTDIR", cs%inputdir, &
1560 "The directory in which all input files are found.", &
1562 cs%inputdir = slasher(cs%inputdir)
1564 call get_param(param_file, mdl,
"ADIABATIC", cs%adiabatic, &
1565 "There are no diapycnal mass fluxes if ADIABATIC is \n"//&
1566 "true. This assumes that KD = KDML = 0.0 and that \n"//&
1567 "there is no buoyancy forcing, but makes the model \n"//&
1568 "faster by eliminating subroutine calls.", default=.false.)
1569 call get_param(param_file, mdl,
"VARIABLE_WINDS", cs%variable_winds, &
1570 "If true, the winds vary in time after the initialization.", &
1572 call get_param(param_file, mdl,
"VARIABLE_BUOYFORCE", cs%variable_buoyforce, &
1573 "If true, the buoyancy forcing varies in time after the \n"//&
1574 "initialization of the model.", default=.true.)
1576 call get_param(param_file, mdl,
"BUOY_CONFIG", cs%buoy_config, &
1577 "The character string that indicates how buoyancy forcing \n"//&
1578 "is specified. Valid options include (file), (zero), \n"//&
1579 "(linear), (USER), (BFB) and (NONE).", fail_if_missing=.true.)
1580 if (trim(cs%buoy_config) ==
"file")
then 1581 call get_param(param_file, mdl,
"ARCHAIC_OMIP_FORCING_FILE", cs%archaic_OMIP_file, &
1582 "If true, use the forcing variable decomposition from \n"//&
1583 "the old German OMIP prescription that predated CORE. If \n"//&
1584 "false, use the variable groupings available from MOM \n"//&
1585 "output diagnostics of forcing variables.", default=.true.)
1586 if (cs%archaic_OMIP_file)
then 1587 call get_param(param_file, mdl,
"LONGWAVEDOWN_FILE", cs%longwave_file, &
1588 "The file with the downward longwave heat flux, in \n"//&
1589 "variable lwdn_sfc.", fail_if_missing=.true.)
1590 call get_param(param_file, mdl,
"LONGWAVEUP_FILE", cs%longwaveup_file, &
1591 "The file with the upward longwave heat flux, in \n"//&
1592 "variable lwup_sfc.", fail_if_missing=.true.)
1593 call get_param(param_file, mdl,
"EVAPORATION_FILE", cs%evaporation_file, &
1594 "The file with the evaporative moisture flux, in \n"//&
1595 "variable evap.", fail_if_missing=.true.)
1596 call get_param(param_file, mdl,
"SENSIBLEHEAT_FILE", cs%sensibleheat_file, &
1597 "The file with the sensible heat flux, in \n"//&
1598 "variable shflx.", fail_if_missing=.true.)
1599 call get_param(param_file, mdl,
"SHORTWAVEUP_FILE", cs%shortwaveup_file, &
1600 "The file with the upward shortwave heat flux.", &
1601 fail_if_missing=.true.)
1602 call get_param(param_file, mdl,
"SHORTWAVEDOWN_FILE", cs%shortwave_file, &
1603 "The file with the downward shortwave heat flux.", &
1604 fail_if_missing=.true.)
1605 call get_param(param_file, mdl,
"SNOW_FILE", cs%snow_file, &
1606 "The file with the downward frozen precip flux, in \n"//&
1607 "variable snow.", fail_if_missing=.true.)
1608 call get_param(param_file, mdl,
"PRECIP_FILE", cs%rain_file, &
1609 "The file with the downward total precip flux, in \n"//&
1610 "variable precip.", fail_if_missing=.true.)
1611 call get_param(param_file, mdl,
"FRESHDISCHARGE_FILE", cs%runoff_file, &
1612 "The file with the fresh and frozen runoff/calving fluxes, \n"//&
1613 "invariables disch_w and disch_s.", fail_if_missing=.true.)
1616 cs%latentheat_file = cs%evaporation_file ; cs%latent_var =
"evap" 1617 cs%LW_var =
"lwdn_sfc"; cs%SW_var =
"swdn_sfc"; cs%sens_var =
"shflx" 1618 cs%evap_var =
"evap"; cs%rain_var =
"precip"; cs%snow_var =
"snow" 1619 cs%lrunoff_var =
"disch_w"; cs%frunoff_var =
"disch_s" 1622 call get_param(param_file, mdl,
"LONGWAVE_FILE", cs%longwave_file, &
1623 "The file with the longwave heat flux, in the variable \n"//&
1624 "given by LONGWAVE_FORCING_VAR.", fail_if_missing=.true.)
1625 call get_param(param_file, mdl,
"LONGWAVE_FORCING_VAR", cs%LW_var, &
1626 "The variable with the longwave forcing field.", default=
"LW")
1628 call get_param(param_file, mdl,
"SHORTWAVE_FILE", cs%shortwave_file, &
1629 "The file with the shortwave heat flux, in the variable \n"//&
1630 "given by SHORTWAVE_FORCING_VAR.", fail_if_missing=.true.)
1631 call get_param(param_file, mdl,
"SHORTWAVE_FORCING_VAR", cs%SW_var, &
1632 "The variable with the shortwave forcing field.", default=
"SW")
1634 call get_param(param_file, mdl,
"EVAPORATION_FILE", cs%evaporation_file, &
1635 "The file with the evaporative moisture flux, in the \n"//&
1636 "variable given by EVAP_FORCING_VAR.", fail_if_missing=.true.)
1637 call get_param(param_file, mdl,
"EVAP_FORCING_VAR", cs%evap_var, &
1638 "The variable with the evaporative moisture flux.", &
1641 call get_param(param_file, mdl,
"LATENTHEAT_FILE", cs%latentheat_file, &
1642 "The file with the latent heat flux, in the variable \n"//&
1643 "given by LATENT_FORCING_VAR.", fail_if_missing=.true.)
1644 call get_param(param_file, mdl,
"LATENT_FORCING_VAR", cs%latent_var, &
1645 "The variable with the latent heat flux.", default=
"latent")
1647 call get_param(param_file, mdl,
"SENSIBLEHEAT_FILE", cs%sensibleheat_file, &
1648 "The file with the sensible heat flux, in the variable \n"//&
1649 "given by SENSIBLE_FORCING_VAR.", fail_if_missing=.true.)
1650 call get_param(param_file, mdl,
"SENSIBLE_FORCING_VAR", cs%sens_var, &
1651 "The variable with the sensible heat flux.", default=
"sensible")
1653 call get_param(param_file, mdl,
"RAIN_FILE", cs%rain_file, &
1654 "The file with the liquid precipitation flux, in the \n"//&
1655 "variable given by RAIN_FORCING_VAR.", fail_if_missing=.true.)
1656 call get_param(param_file, mdl,
"RAIN_FORCING_VAR", cs%rain_var, &
1657 "The variable with the liquid precipitation flux.", &
1658 default=
"liq_precip")
1659 call get_param(param_file, mdl,
"SNOW_FILE", cs%snow_file, &
1660 "The file with the frozen precipitation flux, in the \n"//&
1661 "variable given by SNOW_FORCING_VAR.", fail_if_missing=.true.)
1662 call get_param(param_file, mdl,
"SNOW_FORCING_VAR", cs%snow_var, &
1663 "The variable with the frozen precipitation flux.", &
1664 default=
"froz_precip")
1666 call get_param(param_file, mdl,
"RUNOFF_FILE", cs%runoff_file, &
1667 "The file with the fresh and frozen runoff/calving \n"//&
1668 "fluxes, in variables given by LIQ_RUNOFF_FORCING_VAR \n"//&
1669 "and FROZ_RUNOFF_FORCING_VAR.", fail_if_missing=.true.)
1670 call get_param(param_file, mdl,
"LIQ_RUNOFF_FORCING_VAR", cs%lrunoff_var, &
1671 "The variable with the liquid runoff flux.", &
1672 default=
"liq_runoff")
1673 call get_param(param_file, mdl,
"FROZ_RUNOFF_FORCING_VAR", cs%frunoff_var, &
1674 "The variable with the frozen runoff flux.", &
1675 default=
"froz_runoff")
1678 call get_param(param_file, mdl,
"SSTRESTORE_FILE", cs%SSTrestore_file, &
1679 "The file with the SST toward which to restore in the \n"//&
1680 "variable given by SST_RESTORE_VAR.", fail_if_missing=.true.)
1681 call get_param(param_file, mdl,
"SALINITYRESTORE_FILE", cs%salinityrestore_file, &
1682 "The file with the surface salinity toward which to \n"//&
1683 "restore in the variable given by SSS_RESTORE_VAR.", &
1684 fail_if_missing=.true.)
1686 if (cs%archaic_OMIP_file)
then 1687 cs%SST_restore_var =
"TEMP" ; cs%SSS_restore_var =
"SALT" 1689 call get_param(param_file, mdl,
"SST_RESTORE_VAR", cs%SST_restore_var, &
1690 "The variable with the SST toward which to restore.", &
1692 call get_param(param_file, mdl,
"SSS_RESTORE_VAR", cs%SSS_restore_var, &
1693 "The variable with the SSS toward which to restore.", &
1698 cs%shortwave_file = trim(cs%inputdir)//trim(cs%shortwave_file)
1699 cs%longwave_file = trim(cs%inputdir)//trim(cs%longwave_file)
1700 cs%sensibleheat_file = trim(cs%inputdir)//trim(cs%sensibleheat_file)
1701 cs%latentheat_file = trim(cs%inputdir)//trim(cs%latentheat_file)
1702 cs%evaporation_file = trim(cs%inputdir)//trim(cs%evaporation_file)
1703 cs%snow_file = trim(cs%inputdir)//trim(cs%snow_file)
1704 cs%rain_file = trim(cs%inputdir)//trim(cs%rain_file)
1705 cs%runoff_file = trim(cs%inputdir)//trim(cs%runoff_file)
1707 cs%shortwaveup_file = trim(cs%inputdir)//trim(cs%shortwaveup_file)
1708 cs%longwaveup_file = trim(cs%inputdir)//trim(cs%longwaveup_file)
1710 cs%SSTrestore_file = trim(cs%inputdir)//trim(cs%SSTrestore_file)
1711 cs%salinityrestore_file = trim(cs%inputdir)//trim(cs%salinityrestore_file)
1712 elseif (trim(cs%buoy_config) ==
"const")
then 1713 call get_param(param_file, mdl,
"SENSIBLE_HEAT_FLUX", cs%constantHeatForcing, &
1714 "A constant heat forcing (positive into ocean) applied \n"//&
1715 "through the sensible heat flux field. ", &
1716 units=
'W/m2', fail_if_missing=.true.)
1718 call get_param(param_file, mdl,
"WIND_CONFIG", cs%wind_config, &
1719 "The character string that indicates how wind forcing \n"//&
1720 "is specified. Valid options include (file), (2gyre), \n"//&
1721 "(1gyre), (gyres), (zero), and (USER).", fail_if_missing=.true.)
1722 if (trim(cs%wind_config) ==
"file")
then 1723 call get_param(param_file, mdl,
"WIND_FILE", cs%wind_file, &
1724 "The file in which the wind stresses are found in \n"//&
1725 "variables STRESS_X and STRESS_Y.", fail_if_missing=.true.)
1726 call get_param(param_file, mdl,
"WINDSTRESS_X_VAR",cs%stress_x_var, &
1727 "The name of the x-wind stress variable in WIND_FILE.", &
1729 call get_param(param_file, mdl,
"WINDSTRESS_Y_VAR", cs%stress_y_var, &
1730 "The name of the y-wind stress variable in WIND_FILE.", &
1732 call get_param(param_file, mdl,
"WINDSTRESS_STAGGER",cs%wind_stagger, &
1733 "A character indicating how the wind stress components \n"//&
1734 "are staggered in WIND_FILE. This may be A or C for now.", &
1736 call get_param(param_file, mdl,
"WINDSTRESS_SCALE", cs%wind_scale, &
1737 "A value by which the wind stresses in WIND_FILE are rescaled.", &
1738 default=1.0, units=
"nondim")
1739 call get_param(param_file, mdl,
"USTAR_FORCING_VAR", cs%ustar_var, &
1740 "The name of the friction velocity variable in WIND_FILE \n"//&
1741 "or blank to get ustar from the wind stresses plus the \n"//&
1742 "gustiness.", default=
" ", units=
"nondim")
1743 cs%wind_file = trim(cs%inputdir) // trim(cs%wind_file)
1745 if (trim(cs%wind_config) ==
"gyres")
then 1746 call get_param(param_file, mdl,
"TAUX_CONST", cs%gyres_taux_const, &
1747 "With the gyres wind_config, the constant offset in the \n"//&
1748 "zonal wind stress profile: \n"//&
1749 " A in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1750 units=
"Pa", default=0.0)
1751 call get_param(param_file, mdl,
"TAUX_SIN_AMP",cs%gyres_taux_sin_amp, &
1752 "With the gyres wind_config, the sine amplitude in the \n"//&
1753 "zonal wind stress profile: \n"//&
1754 " B in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1755 units=
"Pa", default=0.0)
1756 call get_param(param_file, mdl,
"TAUX_COS_AMP",cs%gyres_taux_cos_amp, &
1757 "With the gyres wind_config, the cosine amplitude in \n"//&
1758 "the zonal wind stress profile: \n"//&
1759 " C in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1760 units=
"Pa", default=0.0)
1761 call get_param(param_file, mdl,
"TAUX_N_PIS",cs%gyres_taux_n_pis, &
1762 "With the gyres wind_config, the number of gyres in \n"//&
1763 "the zonal wind stress profile: \n"//&
1764 " n in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1765 units=
"nondim", default=0.0)
1767 if ((trim(cs%wind_config) ==
"2gyre") .or. &
1768 (trim(cs%wind_config) ==
"1gyre") .or. &
1769 (trim(cs%wind_config) ==
"gyres") .or. &
1770 (trim(cs%buoy_config) ==
"linear"))
then 1771 cs%south_lat = g%south_lat
1772 cs%len_lat = g%len_lat
1774 call get_param(param_file, mdl,
"RHO_0", cs%Rho0, &
1775 "The mean ocean density used with BOUSSINESQ true to \n"//&
1776 "calculate accelerations and the mass for conservation \n"//&
1777 "properties, or with BOUSSINSEQ false to convert some \n"//&
1778 "parameters from vertical units of m to kg m-2.", &
1779 units=
"kg m-3", default=1035.0)
1780 call get_param(param_file, mdl,
"RESTOREBUOY", cs%restorebuoy, &
1781 "If true, the buoyancy fluxes drive the model back \n"//&
1782 "toward some specified surface state with a rate \n"//&
1783 "given by FLUXCONST.", default= .false.)
1784 call get_param(param_file, mdl,
"LATENT_HEAT_FUSION", cs%latent_heat_fusion, &
1785 "The latent heat of fusion.", units=
"J/kg", default=hlf)
1786 call get_param(param_file, mdl,
"LATENT_HEAT_VAPORIZATION", cs%latent_heat_vapor, &
1787 "The latent heat of fusion.", units=
"J/kg", default=hlv)
1788 if (cs%restorebuoy)
then 1789 call get_param(param_file, mdl,
"FLUXCONST", cs%Flux_const, &
1790 "The constant that relates the restoring surface fluxes \n"//&
1791 "to the relative surface anomalies (akin to a piston \n"//&
1792 "velocity). Note the non-MKS units.", units=
"m day-1", &
1793 fail_if_missing=.true.)
1795 cs%Flux_const = cs%Flux_const / 86400.0
1796 if (trim(cs%buoy_config) ==
"linear")
then 1797 call get_param(param_file, mdl,
"SST_NORTH", cs%T_north, &
1798 "With buoy_config linear, the sea surface temperature \n"//&
1799 "at the northern end of the domain toward which to \n"//&
1800 "to restore.", units=
"deg C", default=0.0)
1801 call get_param(param_file, mdl,
"SST_SOUTH", cs%T_south, &
1802 "With buoy_config linear, the sea surface temperature \n"//&
1803 "at the southern end of the domain toward which to \n"//&
1804 "to restore.", units=
"deg C", default=0.0)
1805 call get_param(param_file, mdl,
"SSS_NORTH", cs%S_north, &
1806 "With buoy_config linear, the sea surface salinity \n"//&
1807 "at the northern end of the domain toward which to \n"//&
1808 "to restore.", units=
"PSU", default=35.0)
1809 call get_param(param_file, mdl,
"SSS_SOUTH", cs%S_south, &
1810 "With buoy_config linear, the sea surface salinity \n"//&
1811 "at the southern end of the domain toward which to \n"//&
1812 "to restore.", units=
"PSU", default=35.0)
1815 call get_param(param_file, mdl,
"G_EARTH", cs%G_Earth, &
1816 "The gravitational acceleration of the Earth.", &
1817 units=
"m s-2", default = 9.80)
1819 call get_param(param_file, mdl,
"GUST_CONST", cs%gust_const, &
1820 "The background gustiness in the winds.", units=
"Pa", &
1822 call get_param(param_file, mdl,
"READ_GUST_2D", cs%read_gust_2d, &
1823 "If true, use a 2-dimensional gustiness supplied from \n"//&
1824 "an input file", default=.false.)
1825 if (cs%read_gust_2d)
then 1826 call get_param(param_file, mdl,
"GUST_2D_FILE", gust_file, &
1827 "The file in which the wind gustiness is found in \n"//&
1828 "variable gustiness.", fail_if_missing=.true.)
1829 call safe_alloc_ptr(cs%gust,g%isd,g%ied,g%jsd,g%jed)
1830 filename = trim(cs%inputdir) // trim(gust_file)
1831 call read_data(filename,
'gustiness',cs%gust,domain=g%domain%mpp_domain, &
1837 if (trim(cs%wind_config) ==
"USER" .or. trim(cs%buoy_config) ==
"USER" )
then 1838 call user_surface_forcing_init(time, g, param_file, diag, cs%user_forcing_CSp)
1839 elseif (trim(cs%buoy_config) ==
"BFB" )
then 1840 call bfb_surface_forcing_init(time, g, param_file, diag, cs%BFB_forcing_CSp)
1841 elseif (trim(cs%wind_config) ==
"MESO" .or. trim(cs%buoy_config) ==
"MESO" )
then 1842 call meso_surface_forcing_init(time, g, param_file, diag, cs%MESO_forcing_CSp)
1843 elseif (trim(cs%wind_config) ==
"SCM_ideal_hurr")
then 1844 call scm_idealized_hurricane_wind_init(time, g, param_file, cs%SCM_idealized_hurricane_CSp)
1845 elseif (trim(cs%wind_config) ==
"const")
then 1846 call get_param(param_file, mdl,
"CONST_WIND_TAUX", cs%tau_x0, &
1847 "With wind_config const, this is the constant zonal\n"//&
1848 "wind-stress", units=
"Pa", fail_if_missing=.true.)
1849 call get_param(param_file, mdl,
"CONST_WIND_TAUY", cs%tau_y0, &
1850 "With wind_config const, this is the constant zonal\n"//&
1851 "wind-stress", units=
"Pa", fail_if_missing=.true.)
1852 elseif (trim(cs%wind_config) ==
"SCM_CVmix_tests" .or. &
1853 trim(cs%buoy_config) ==
"SCM_CVmix_tests")
then 1854 call scm_cvmix_tests_surface_forcing_init(time, g, param_file, cs%SCM_CVmix_tests_CSp)
1855 cs%SCM_CVmix_tests_CSp%Rho0 = cs%Rho0
1858 call register_forcing_type_diags(time, diag, cs%use_temperature, cs%handles)
1861 call restart_init(param_file, cs%restart_CSp,
"MOM_forcing.res")
1864 call restart_init_end(cs%restart_CSp)
1866 if (
associated(cs%restart_CSp))
then 1867 call get_mom_input(dirs=dirs)
1870 if ((dirs%input_filename(1:1) ==
'n') .and. &
1871 (len_trim(dirs%input_filename) == 1)) new_sim = .true.
1872 if (.not.new_sim)
then 1873 call restore_state(dirs%input_filename, dirs%restart_input_dir, time_frc, &
1879 if (trim(cs%buoy_config) ==
"file")
then 1880 cs%SW_nlev = num_timelevels(cs%shortwave_file, cs%SW_var, min_dims=3)
1881 cs%LW_nlev = num_timelevels(cs%longwave_file, cs%LW_var, min_dims=3)
1882 cs%latent_nlev = num_timelevels(cs%latentheat_file, cs%latent_var, 3)
1883 cs%sens_nlev = num_timelevels(cs%sensibleheat_file, cs%sens_var, min_dims=3)
1885 cs%evap_nlev = num_timelevels(cs%evaporation_file, cs%evap_var, min_dims=3)
1886 cs%precip_nlev = num_timelevels(cs%rain_file, cs%rain_var, min_dims=3)
1887 cs%runoff_nlev = num_timelevels(cs%runoff_file, cs%lrunoff_var, 3)
1889 cs%SST_nlev = num_timelevels(cs%SSTrestore_file, cs%SST_restore_var, 3)
1890 cs%SSS_nlev = num_timelevels(cs%salinityrestore_file, cs%SSS_restore_var, 3)
1893 if (trim(cs%wind_config) ==
"file") &
1894 cs%wind_nlev = num_timelevels(cs%wind_file, cs%stress_x_var, min_dims=3)
1898 call user_revise_forcing_init(param_file, cs%urf_CS)
1900 call cpu_clock_end(id_clock_forcing)
Ocean grid type. See mom_grid for details.