Initialize the surface forcing module.
1376 type(time_type),
intent(in) :: Time
1377 type(ocean_grid_type),
intent(in) :: G
1378 type(unit_scale_type),
intent(in) :: US
1379 type(param_file_type),
intent(in) :: param_file
1380 type(diag_ctrl),
target,
intent(inout) :: diag
1381 type(surface_forcing_CS),
pointer :: CS
1383 type(tracer_flow_control_CS),
pointer :: tracer_flow_CSp
1386 type(directories) :: dirs
1388 type(time_type) :: Time_frc
1390 # include "version_variable.h"
1391 logical :: default_2018_answers
1392 character(len=40) :: mdl =
"MOM_surface_forcing"
1393 character(len=200) :: filename, gust_file
1395 if (
associated(cs))
then
1396 call mom_error(warning,
"surface_forcing_init called with an associated "// &
1397 "control structure.")
1402 id_clock_forcing=cpu_clock_id(
'(Ocean surface forcing)', grain=clock_module)
1403 call cpu_clock_begin(id_clock_forcing)
1406 if (
associated(tracer_flow_csp)) cs%tracer_flow_CSp => tracer_flow_csp
1409 call log_version(param_file, mdl, version,
'')
1410 call get_param(param_file, mdl,
"ENABLE_THERMODYNAMICS", cs%use_temperature, &
1411 "If true, Temperature and salinity are used as state "//&
1412 "variables.", default=.true.)
1413 call get_param(param_file, mdl,
"INPUTDIR", cs%inputdir, &
1414 "The directory in which all input files are found.", &
1416 cs%inputdir = slasher(cs%inputdir)
1418 call get_param(param_file, mdl,
"ADIABATIC", cs%adiabatic, &
1419 "There are no diapycnal mass fluxes if ADIABATIC is "//&
1420 "true. This assumes that KD = KDML = 0.0 and that "//&
1421 "there is no buoyancy forcing, but makes the model "//&
1422 "faster by eliminating subroutine calls.", default=.false.)
1423 call get_param(param_file, mdl,
"VARIABLE_WINDS", cs%variable_winds, &
1424 "If true, the winds vary in time after the initialization.", &
1426 call get_param(param_file, mdl,
"VARIABLE_BUOYFORCE", cs%variable_buoyforce, &
1427 "If true, the buoyancy forcing varies in time after the "//&
1428 "initialization of the model.", default=.true.)
1430 call get_param(param_file, mdl,
"BUOY_CONFIG", cs%buoy_config, &
1431 "The character string that indicates how buoyancy forcing "//&
1432 "is specified. Valid options include (file), (zero), "//&
1433 "(linear), (USER), (BFB) and (NONE).", fail_if_missing=.true.)
1434 if (trim(cs%buoy_config) ==
"file")
then
1435 call get_param(param_file, mdl,
"ARCHAIC_OMIP_FORCING_FILE", cs%archaic_OMIP_file, &
1436 "If true, use the forcing variable decomposition from "//&
1437 "the old German OMIP prescription that predated CORE. If "//&
1438 "false, use the variable groupings available from MOM "//&
1439 "output diagnostics of forcing variables.", default=.true.)
1440 if (cs%archaic_OMIP_file)
then
1441 call get_param(param_file, mdl,
"LONGWAVEDOWN_FILE", cs%longwave_file, &
1442 "The file with the downward longwave heat flux, in "//&
1443 "variable lwdn_sfc.", fail_if_missing=.true.)
1444 call get_param(param_file, mdl,
"LONGWAVEUP_FILE", cs%longwaveup_file, &
1445 "The file with the upward longwave heat flux, in "//&
1446 "variable lwup_sfc.", fail_if_missing=.true.)
1447 call get_param(param_file, mdl,
"EVAPORATION_FILE", cs%evaporation_file, &
1448 "The file with the evaporative moisture flux, in "//&
1449 "variable evap.", fail_if_missing=.true.)
1450 call get_param(param_file, mdl,
"SENSIBLEHEAT_FILE", cs%sensibleheat_file, &
1451 "The file with the sensible heat flux, in "//&
1452 "variable shflx.", fail_if_missing=.true.)
1453 call get_param(param_file, mdl,
"SHORTWAVEUP_FILE", cs%shortwaveup_file, &
1454 "The file with the upward shortwave heat flux.", &
1455 fail_if_missing=.true.)
1456 call get_param(param_file, mdl,
"SHORTWAVEDOWN_FILE", cs%shortwave_file, &
1457 "The file with the downward shortwave heat flux.", &
1458 fail_if_missing=.true.)
1459 call get_param(param_file, mdl,
"SNOW_FILE", cs%snow_file, &
1460 "The file with the downward frozen precip flux, in "//&
1461 "variable snow.", fail_if_missing=.true.)
1462 call get_param(param_file, mdl,
"PRECIP_FILE", cs%rain_file, &
1463 "The file with the downward total precip flux, in "//&
1464 "variable precip.", fail_if_missing=.true.)
1465 call get_param(param_file, mdl,
"FRESHDISCHARGE_FILE", cs%runoff_file, &
1466 "The file with the fresh and frozen runoff/calving fluxes, "//&
1467 "invariables disch_w and disch_s.", fail_if_missing=.true.)
1470 cs%latentheat_file = cs%evaporation_file ; cs%latent_var =
"evap"
1471 cs%LW_var =
"lwdn_sfc"; cs%SW_var =
"swdn_sfc"; cs%sens_var =
"shflx"
1472 cs%evap_var =
"evap"; cs%rain_var =
"precip"; cs%snow_var =
"snow"
1473 cs%lrunoff_var =
"disch_w"; cs%frunoff_var =
"disch_s"
1476 call get_param(param_file, mdl,
"LONGWAVE_FILE", cs%longwave_file, &
1477 "The file with the longwave heat flux, in the variable "//&
1478 "given by LONGWAVE_FORCING_VAR.", fail_if_missing=.true.)
1479 call get_param(param_file, mdl,
"LONGWAVE_FORCING_VAR", cs%LW_var, &
1480 "The variable with the longwave forcing field.", default=
"LW")
1482 call get_param(param_file, mdl,
"SHORTWAVE_FILE", cs%shortwave_file, &
1483 "The file with the shortwave heat flux, in the variable "//&
1484 "given by SHORTWAVE_FORCING_VAR.", fail_if_missing=.true.)
1485 call get_param(param_file, mdl,
"SHORTWAVE_FORCING_VAR", cs%SW_var, &
1486 "The variable with the shortwave forcing field.", default=
"SW")
1488 call get_param(param_file, mdl,
"EVAPORATION_FILE", cs%evaporation_file, &
1489 "The file with the evaporative moisture flux, in the "//&
1490 "variable given by EVAP_FORCING_VAR.", fail_if_missing=.true.)
1491 call get_param(param_file, mdl,
"EVAP_FORCING_VAR", cs%evap_var, &
1492 "The variable with the evaporative moisture flux.", &
1495 call get_param(param_file, mdl,
"LATENTHEAT_FILE", cs%latentheat_file, &
1496 "The file with the latent heat flux, in the variable "//&
1497 "given by LATENT_FORCING_VAR.", fail_if_missing=.true.)
1498 call get_param(param_file, mdl,
"LATENT_FORCING_VAR", cs%latent_var, &
1499 "The variable with the latent heat flux.", default=
"latent")
1501 call get_param(param_file, mdl,
"SENSIBLEHEAT_FILE", cs%sensibleheat_file, &
1502 "The file with the sensible heat flux, in the variable "//&
1503 "given by SENSIBLE_FORCING_VAR.", fail_if_missing=.true.)
1504 call get_param(param_file, mdl,
"SENSIBLE_FORCING_VAR", cs%sens_var, &
1505 "The variable with the sensible heat flux.", default=
"sensible")
1507 call get_param(param_file, mdl,
"RAIN_FILE", cs%rain_file, &
1508 "The file with the liquid precipitation flux, in the "//&
1509 "variable given by RAIN_FORCING_VAR.", fail_if_missing=.true.)
1510 call get_param(param_file, mdl,
"RAIN_FORCING_VAR", cs%rain_var, &
1511 "The variable with the liquid precipitation flux.", &
1512 default=
"liq_precip")
1513 call get_param(param_file, mdl,
"SNOW_FILE", cs%snow_file, &
1514 "The file with the frozen precipitation flux, in the "//&
1515 "variable given by SNOW_FORCING_VAR.", fail_if_missing=.true.)
1516 call get_param(param_file, mdl,
"SNOW_FORCING_VAR", cs%snow_var, &
1517 "The variable with the frozen precipitation flux.", &
1518 default=
"froz_precip")
1520 call get_param(param_file, mdl,
"RUNOFF_FILE", cs%runoff_file, &
1521 "The file with the fresh and frozen runoff/calving "//&
1522 "fluxes, in variables given by LIQ_RUNOFF_FORCING_VAR "//&
1523 "and FROZ_RUNOFF_FORCING_VAR.", fail_if_missing=.true.)
1524 call get_param(param_file, mdl,
"LIQ_RUNOFF_FORCING_VAR", cs%lrunoff_var, &
1525 "The variable with the liquid runoff flux.", &
1526 default=
"liq_runoff")
1527 call get_param(param_file, mdl,
"FROZ_RUNOFF_FORCING_VAR", cs%frunoff_var, &
1528 "The variable with the frozen runoff flux.", &
1529 default=
"froz_runoff")
1532 call get_param(param_file, mdl,
"SSTRESTORE_FILE", cs%SSTrestore_file, &
1533 "The file with the SST toward which to restore in the "//&
1534 "variable given by SST_RESTORE_VAR.", fail_if_missing=.true.)
1535 call get_param(param_file, mdl,
"SALINITYRESTORE_FILE", cs%salinityrestore_file, &
1536 "The file with the surface salinity toward which to "//&
1537 "restore in the variable given by SSS_RESTORE_VAR.", &
1538 fail_if_missing=.true.)
1540 if (cs%archaic_OMIP_file)
then
1541 cs%SST_restore_var =
"TEMP" ; cs%SSS_restore_var =
"SALT"
1543 call get_param(param_file, mdl,
"SST_RESTORE_VAR", cs%SST_restore_var, &
1544 "The variable with the SST toward which to restore.", &
1546 call get_param(param_file, mdl,
"SSS_RESTORE_VAR", cs%SSS_restore_var, &
1547 "The variable with the SSS toward which to restore.", &
1552 cs%shortwave_file = trim(cs%inputdir)//trim(cs%shortwave_file)
1553 cs%longwave_file = trim(cs%inputdir)//trim(cs%longwave_file)
1554 cs%sensibleheat_file = trim(cs%inputdir)//trim(cs%sensibleheat_file)
1555 cs%latentheat_file = trim(cs%inputdir)//trim(cs%latentheat_file)
1556 cs%evaporation_file = trim(cs%inputdir)//trim(cs%evaporation_file)
1557 cs%snow_file = trim(cs%inputdir)//trim(cs%snow_file)
1558 cs%rain_file = trim(cs%inputdir)//trim(cs%rain_file)
1559 cs%runoff_file = trim(cs%inputdir)//trim(cs%runoff_file)
1561 cs%shortwaveup_file = trim(cs%inputdir)//trim(cs%shortwaveup_file)
1562 cs%longwaveup_file = trim(cs%inputdir)//trim(cs%longwaveup_file)
1564 cs%SSTrestore_file = trim(cs%inputdir)//trim(cs%SSTrestore_file)
1565 cs%salinityrestore_file = trim(cs%inputdir)//trim(cs%salinityrestore_file)
1566 elseif (trim(cs%buoy_config) ==
"const")
then
1567 call get_param(param_file, mdl,
"SENSIBLE_HEAT_FLUX", cs%constantHeatForcing, &
1568 "A constant heat forcing (positive into ocean) applied "//&
1569 "through the sensible heat flux field. ", &
1570 units=
'W/m2', fail_if_missing=.true.)
1572 call get_param(param_file, mdl,
"WIND_CONFIG", cs%wind_config, &
1573 "The character string that indicates how wind forcing "//&
1574 "is specified. Valid options include (file), (2gyre), "//&
1575 "(1gyre), (gyres), (zero), and (USER).", fail_if_missing=.true.)
1576 if (trim(cs%wind_config) ==
"file")
then
1577 call get_param(param_file, mdl,
"WIND_FILE", cs%wind_file, &
1578 "The file in which the wind stresses are found in "//&
1579 "variables STRESS_X and STRESS_Y.", fail_if_missing=.true.)
1580 call get_param(param_file, mdl,
"WINDSTRESS_X_VAR",cs%stress_x_var, &
1581 "The name of the x-wind stress variable in WIND_FILE.", &
1583 call get_param(param_file, mdl,
"WINDSTRESS_Y_VAR", cs%stress_y_var, &
1584 "The name of the y-wind stress variable in WIND_FILE.", &
1586 call get_param(param_file, mdl,
"WINDSTRESS_STAGGER",cs%wind_stagger, &
1587 "A character indicating how the wind stress components "//&
1588 "are staggered in WIND_FILE. This may be A or C for now.", &
1590 call get_param(param_file, mdl,
"WINDSTRESS_SCALE", cs%wind_scale, &
1591 "A value by which the wind stresses in WIND_FILE are rescaled.", &
1592 default=1.0, units=
"nondim")
1593 call get_param(param_file, mdl,
"USTAR_FORCING_VAR", cs%ustar_var, &
1594 "The name of the friction velocity variable in WIND_FILE "//&
1595 "or blank to get ustar from the wind stresses plus the "//&
1596 "gustiness.", default=
" ", units=
"nondim")
1597 cs%wind_file = trim(cs%inputdir) // trim(cs%wind_file)
1599 if (trim(cs%wind_config) ==
"gyres")
then
1600 call get_param(param_file, mdl,
"TAUX_CONST", cs%gyres_taux_const, &
1601 "With the gyres wind_config, the constant offset in the "//&
1602 "zonal wind stress profile: "//&
1603 " A in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1604 units=
"Pa", default=0.0)
1605 call get_param(param_file, mdl,
"TAUX_SIN_AMP",cs%gyres_taux_sin_amp, &
1606 "With the gyres wind_config, the sine amplitude in the "//&
1607 "zonal wind stress profile: "//&
1608 " B in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1609 units=
"Pa", default=0.0)
1610 call get_param(param_file, mdl,
"TAUX_COS_AMP",cs%gyres_taux_cos_amp, &
1611 "With the gyres wind_config, the cosine amplitude in "//&
1612 "the zonal wind stress profile: "//&
1613 " C in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1614 units=
"Pa", default=0.0)
1615 call get_param(param_file, mdl,
"TAUX_N_PIS",cs%gyres_taux_n_pis, &
1616 "With the gyres wind_config, the number of gyres in "//&
1617 "the zonal wind stress profile: "//&
1618 " n in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L).", &
1619 units=
"nondim", default=0.0)
1620 call get_param(param_file, mdl,
"DEFAULT_2018_ANSWERS", default_2018_answers, &
1621 "This sets the default value for the various _2018_ANSWERS parameters.", &
1623 call get_param(param_file, mdl,
"WIND_GYRES_2018_ANSWERS", cs%answers_2018, &
1624 "If true, use the order of arithmetic and expressions that recover the answers "//&
1625 "from the end of 2018. Otherwise, use expressions for the gyre friction velocities "//&
1626 "that are rotationally invariant and more likely to be the same between compilers.", &
1627 default=default_2018_answers)
1629 cs%answers_2018 = .false.
1631 if ((trim(cs%wind_config) ==
"2gyre") .or. &
1632 (trim(cs%wind_config) ==
"1gyre") .or. &
1633 (trim(cs%wind_config) ==
"gyres") .or. &
1634 (trim(cs%buoy_config) ==
"linear"))
then
1635 cs%south_lat = g%south_lat
1636 cs%len_lat = g%len_lat
1638 call get_param(param_file, mdl,
"RHO_0", cs%Rho0, &
1639 "The mean ocean density used with BOUSSINESQ true to "//&
1640 "calculate accelerations and the mass for conservation "//&
1641 "properties, or with BOUSSINSEQ false to convert some "//&
1642 "parameters from vertical units of m to kg m-2.", &
1643 units=
"kg m-3", default=1035.0)
1644 call get_param(param_file, mdl,
"RESTOREBUOY", cs%restorebuoy, &
1645 "If true, the buoyancy fluxes drive the model back "//&
1646 "toward some specified surface state with a rate "//&
1647 "given by FLUXCONST.", default= .false.)
1648 call get_param(param_file, mdl,
"LATENT_HEAT_FUSION", cs%latent_heat_fusion, &
1649 "The latent heat of fusion.", units=
"J/kg", default=hlf)
1650 call get_param(param_file, mdl,
"LATENT_HEAT_VAPORIZATION", cs%latent_heat_vapor, &
1651 "The latent heat of fusion.", units=
"J/kg", default=hlv)
1652 if (cs%restorebuoy)
then
1653 call get_param(param_file, mdl,
"FLUXCONST", cs%Flux_const, &
1654 "The constant that relates the restoring surface fluxes "//&
1655 "to the relative surface anomalies (akin to a piston "//&
1656 "velocity). Note the non-MKS units.", units=
"m day-1", &
1657 fail_if_missing=.true.)
1659 if (cs%use_temperature)
then
1660 call get_param(param_file, mdl,
"FLUXCONST_T", cs%Flux_const_T, &
1661 "The constant that relates the restoring surface temperature "//&
1662 "flux to the relative surface anomaly (akin to a piston "//&
1663 "velocity). Note the non-MKS units.", units=
"m day-1", &
1664 default=cs%Flux_const)
1665 call get_param(param_file, mdl,
"FLUXCONST_S", cs%Flux_const_S, &
1666 "The constant that relates the restoring surface salinity "//&
1667 "flux to the relative surface anomaly (akin to a piston "//&
1668 "velocity). Note the non-MKS units.", units=
"m day-1", &
1669 default=cs%Flux_const)
1673 cs%Flux_const = cs%Flux_const / 86400.0
1674 cs%Flux_const_T = cs%Flux_const_T / 86400.0
1675 cs%Flux_const_S = cs%Flux_const_S / 86400.0
1677 if (trim(cs%buoy_config) ==
"linear")
then
1678 call get_param(param_file, mdl,
"SST_NORTH", cs%T_north, &
1679 "With buoy_config linear, the sea surface temperature "//&
1680 "at the northern end of the domain toward which to "//&
1681 "to restore.", units=
"deg C", default=0.0)
1682 call get_param(param_file, mdl,
"SST_SOUTH", cs%T_south, &
1683 "With buoy_config linear, the sea surface temperature "//&
1684 "at the southern end of the domain toward which to "//&
1685 "to restore.", units=
"deg C", default=0.0)
1686 call get_param(param_file, mdl,
"SSS_NORTH", cs%S_north, &
1687 "With buoy_config linear, the sea surface salinity "//&
1688 "at the northern end of the domain toward which to "//&
1689 "to restore.", units=
"PSU", default=35.0)
1690 call get_param(param_file, mdl,
"SSS_SOUTH", cs%S_south, &
1691 "With buoy_config linear, the sea surface salinity "//&
1692 "at the southern end of the domain toward which to "//&
1693 "to restore.", units=
"PSU", default=35.0)
1696 call get_param(param_file, mdl,
"G_EARTH", cs%G_Earth, &
1697 "The gravitational acceleration of the Earth.", &
1698 units=
"m s-2", default = 9.80, scale=us%m_to_L**2*us%Z_to_m*us%T_to_s**2)
1700 call get_param(param_file, mdl,
"GUST_CONST", cs%gust_const, &
1701 "The background gustiness in the winds.", units=
"Pa", &
1703 call get_param(param_file, mdl,
"READ_GUST_2D", cs%read_gust_2d, &
1704 "If true, use a 2-dimensional gustiness supplied from "//&
1705 "an input file", default=.false.)
1706 if (cs%read_gust_2d)
then
1707 call get_param(param_file, mdl,
"GUST_2D_FILE", gust_file, &
1708 "The file in which the wind gustiness is found in "//&
1709 "variable gustiness.", fail_if_missing=.true.)
1710 call safe_alloc_ptr(cs%gust,g%isd,g%ied,g%jsd,g%jed)
1711 filename = trim(cs%inputdir) // trim(gust_file)
1712 call mom_read_data(filename,
'gustiness',cs%gust,g%domain, &
1718 if (trim(cs%wind_config) ==
"USER" .or. trim(cs%buoy_config) ==
"USER" )
then
1719 call user_surface_forcing_init(time, g, us, param_file, diag, cs%user_forcing_CSp)
1720 elseif (trim(cs%buoy_config) ==
"BFB" )
then
1721 call bfb_surface_forcing_init(time, g, us, param_file, diag, cs%BFB_forcing_CSp)
1722 elseif (trim(cs%buoy_config) ==
"dumbbell" )
then
1723 call dumbbell_surface_forcing_init(time, g, us, param_file, diag, cs%dumbbell_forcing_CSp)
1724 elseif (trim(cs%wind_config) ==
"MESO" .or. trim(cs%buoy_config) ==
"MESO" )
then
1725 call meso_surface_forcing_init(time, g, us, param_file, diag, cs%MESO_forcing_CSp)
1726 elseif (trim(cs%wind_config) ==
"Neverland")
then
1727 call neverland_surface_forcing_init(time, g, us, param_file, diag, cs%Neverland_forcing_CSp)
1728 elseif (trim(cs%wind_config) ==
"ideal_hurr" .or.&
1729 trim(cs%wind_config) ==
"SCM_ideal_hurr")
then
1730 call idealized_hurricane_wind_init(time, g, param_file, cs%idealized_hurricane_CSp)
1731 elseif (trim(cs%wind_config) ==
"const")
then
1732 call get_param(param_file, mdl,
"CONST_WIND_TAUX", cs%tau_x0, &
1733 "With wind_config const, this is the constant zonal "//&
1734 "wind-stress", units=
"Pa", fail_if_missing=.true.)
1735 call get_param(param_file, mdl,
"CONST_WIND_TAUY", cs%tau_y0, &
1736 "With wind_config const, this is the constant meridional "//&
1737 "wind-stress", units=
"Pa", fail_if_missing=.true.)
1738 elseif (trim(cs%wind_config) ==
"SCM_CVmix_tests" .or. &
1739 trim(cs%buoy_config) ==
"SCM_CVmix_tests")
then
1740 call scm_cvmix_tests_surface_forcing_init(time, g, param_file, cs%SCM_CVmix_tests_CSp)
1741 cs%SCM_CVmix_tests_CSp%Rho0 = cs%Rho0
1744 call register_forcing_type_diags(time, diag, us, cs%use_temperature, cs%handles)
1747 call restart_init(param_file, cs%restart_CSp,
"MOM_forcing.res")
1750 call restart_init_end(cs%restart_CSp)
1752 if (
associated(cs%restart_CSp))
then
1753 call get_mom_input(dirs=dirs)
1756 if ((dirs%input_filename(1:1) ==
'n') .and. &
1757 (len_trim(dirs%input_filename) == 1)) new_sim = .true.
1758 if (.not.new_sim)
then
1759 call restore_state(dirs%input_filename, dirs%restart_input_dir, time_frc, &
1765 if (trim(cs%buoy_config) ==
"file")
then
1766 cs%SW_nlev = num_timelevels(cs%shortwave_file, cs%SW_var, min_dims=3)
1767 cs%LW_nlev = num_timelevels(cs%longwave_file, cs%LW_var, min_dims=3)
1768 cs%latent_nlev = num_timelevels(cs%latentheat_file, cs%latent_var, 3)
1769 cs%sens_nlev = num_timelevels(cs%sensibleheat_file, cs%sens_var, min_dims=3)
1771 cs%evap_nlev = num_timelevels(cs%evaporation_file, cs%evap_var, min_dims=3)
1772 cs%precip_nlev = num_timelevels(cs%rain_file, cs%rain_var, min_dims=3)
1773 cs%runoff_nlev = num_timelevels(cs%runoff_file, cs%lrunoff_var, 3)
1775 cs%SST_nlev = num_timelevels(cs%SSTrestore_file, cs%SST_restore_var, 3)
1776 cs%SSS_nlev = num_timelevels(cs%salinityrestore_file, cs%SSS_restore_var, 3)
1779 if (trim(cs%wind_config) ==
"file") &
1780 cs%wind_nlev = num_timelevels(cs%wind_file, cs%stress_x_var, min_dims=3)
1784 call user_revise_forcing_init(param_file, cs%urf_CS)
1786 call cpu_clock_end(id_clock_forcing)