Skip to content

Commit

Permalink
Define constants in chgres_cube.fd/search_util.f90 (#448)
Browse files Browse the repository at this point in the history
Define all constants as parameters and use uppercase.
Add more descriptive prolog. 

Fixes #278
  • Loading branch information
GeorgeGayno-NOAA committed Apr 26, 2021
1 parent 3c1ec74 commit 7a10e6e
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions sorc/chgres_cube.fd/search_util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,49 @@ subroutine search (field, mask, idim, jdim, tile, field_num, latitude, terrain_l

end subroutine search

!> Set sst values based on latitude.
!> Set default Sea Surface Temperature (SST) based on latitude.
!!
!! @param latitude latitude input
!! @param sst sst guess value to be set
!! Based loosely on the average annual SST
!! values from ./fix_am/cfs_oi2sst1x1monclim19822001.grb
!!
!! The temperature in the polar and tropical regions
!! is set to 273.16 and 300.0 Kelvin respectively. Polar
!! regions are poleward of 60 degrees. Tropical regions
!! are within 30 degrees of the equator. In mid-latitudes,
!! a linear change with latitude is used.
!!
!! @param [in] latitude Latitude in decimal degrees
!! @param [out] sst Default SST in Kelvin
!! @author George Gayno NCEP/EMC
subroutine sst_guess(latitude, sst)

use esmf

implicit none

real(esmf_kind_r8), parameter :: SST_POLAR_IN_KELVIN = 273.16 !< Default SST in polar
!! regions.
real(esmf_kind_r8), parameter :: SST_TROPICAL_IN_KELVIN = 300.0 !< Default SST in
!! tropical regions.
real(esmf_kind_r8), parameter :: POLAR_LATITUDE = 60.0 !< Latitude in decimal degrees
!! defining polar regions.
real(esmf_kind_r8), parameter :: TROPICAL_LATITUDE = 30.0 !< Latitude in decimal degrees
!! defining tropical regions.
real(esmf_kind_r8), parameter :: DSST_DLAT = -0.8947 !< Change in SST per latitude in
!! mid-latitudes.
real(esmf_kind_r8), parameter :: SST_Y_INTERCEPT = 326.84 !< y intercept for the linear
!! change of SST in mid-latitudes.

real(esmf_kind_r8), intent(in) :: latitude

real(esmf_kind_r8), intent(out) :: sst

if (abs(latitude) >= 60.0) then
sst = 273.16
elseif (abs(latitude) <= 30.0) then
sst = 300.0
if (abs(latitude) >= POLAR_LATITUDE) then
sst = SST_POLAR_IN_KELVIN
elseif (abs(latitude) <= TROPICAL_LATITUDE) then
sst = SST_TROPICAL_IN_KELVIN
else
sst = (-0.8947) * abs(latitude) + 326.84
sst = DSST_DLAT * abs(latitude) + SST_Y_INTERCEPT
endif

end subroutine sst_guess
Expand Down

0 comments on commit 7a10e6e

Please sign in to comment.