Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pnorris/#1915 all MAPL orbital parameters now encapsulated in Sun_Mod in MAPL_sun_uc.F90 #1920

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added subroutine `MAPL_SunGetLocalSolarHourAngle()` in `base/MAPL_sun_uc.F90`. This provides a
  convenient local solar hour angle diagnostic which will be used to detect local
  solar noon via the EXAMPLE OF USE in the subroutine header. See DESCRIPTION in code for more
  details. Provides the TRUE local solar hour angle (i.e., with equation of time included), but
  can also provide the MEAN value (without EOT) via FORCE_MLSHA=.TRUE. optional argument.
- Added subroutine `MAPL_SunGetLocalSolarHourAngle()` in `base/MAPL_sun_uc.F90`. This
provides a convenient local solar hour angle diagnostic which will be used to detect local
solar noon via the `EXAMPLE OF USE` in the subroutine header. See `DESCRIPTION` in code
for more details. Provides the TRUE local solar hour angle (i.e., with equation of time
included), but can also provide the MEAN value (without EOT) via `FORCE_MLSHA=.TRUE.`
optional argument.

### Changed

- Changed call to `MAPL_SunOrbitCreate()` inside `MAPL_Generic.F90` to call to new function
`MAPL_SunOrbitCreateFromConfig()`, the latter which get the orbital parameters from the MAPL
state's Config. In this way no default orbital parameter values need appear in `MAPL_Generic.F90`.
Rather, these default values are encapsulated where they belong in `Sun_Mod` in `base/MAPL_sun_uc.F90`
and are now explicitly named and commented on at the head of the module. This is a structural
zero-diff change.

### Fixed

- Added the correct values to halo corner of LatLon grid
Expand Down
202 changes: 202 additions & 0 deletions base/MAPL_sun_uc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module MAPL_SunMod
! !PUBLIC MEMBER FUNCTIONS:

public MAPL_SunOrbitCreate
public MAPL_SunOrbitCreateFromConfig
public MAPL_SunOrbitCreated
public MAPL_SunOrbitDestroy
public MAPL_SunOrbitQuery
Expand All @@ -56,6 +57,53 @@ module MAPL_SunMod
integer, public, parameter :: MAPL_SunDailyMean = 5
integer, public, parameter :: MAPL_SunAnnualMean = 6

! Default solar orbital system parameters (private).
! Dont change these unless you know what you are doing.
! They are appropriate for the current modern epoch circa 2000.
! -------------------------------------------------------------

! Parameters of old orbital system (tabularized intercalation cycle)
! ------------------------------------------------------------------
real, parameter :: DEFAULT_ORBIT_ECCENTRICITY = 0.0167
real, parameter :: DEFAULT_ORBIT_OBLIQUITY = 23.45 ! degrees
real, parameter :: DEFAULT_ORBIT_PERIHELION = 102.0 ! degrees
integer, parameter :: DEFAULT_ORBIT_EQUINOX = 80 ! days

! Parameters of new orbital system (analytic two-body), which allows some
! time-varying behavior, namely, linear variation in LAMBDAP, ECC, and OBQ.
! -------------------------------------------------------------------------

! Fixed anomalistic year length in mean solar days
real, parameter :: DEFAULT_ORB2B_YEARLEN = 365.2596

! Reference date and time for orbital parameters
! (defaults to J2000 = 01Jan2000 12:00:00 TT = 11:58:56 UTC)
integer, parameter :: DEFAULT_ORB2B_REF_YYYYMMDD = 20000101
integer, parameter :: DEFAULT_ORB2B_REF_HHMMSS = 115856

! Orbital eccentricity at reference date
real, parameter :: DEFAULT_ORB2B_ECC_REF = 0.016710
! Rate of change of orbital eccentricity per Julian century
real, parameter :: DEFAULT_ORB2B_ECC_RATE = -4.2e-5

! Earth's obliquity (axial tilt) at reference date [degrees]
real, parameter :: DEFAULT_ORB2B_OBQ_REF = 23.44
! Rate of change of obliquity [degrees per Julian century]
real, parameter :: DEFAULT_ORB2B_OBQ_RATE = -1.3e-2

! Longitude of perihelion at reference date [degrees]
! (from March equinox to perihelion in direction of earth's motion)
real, parameter :: DEFAULT_ORB2B_LAMBDAP_REF = 282.947
! Rate of change of LAMBDAP [degrees per Julian century]
! (Combines both equatorial and ecliptic precession)
real, parameter :: DEFAULT_ORB2B_LAMBDAP_RATE = 1.7195

! March Equinox date and time
! (defaults to March 20, 2000 at 07:35:00 UTC)
integer, parameter :: DEFAULT_ORB2B_EQUINOX_YYYYMMDD = 20000320
integer, parameter :: DEFAULT_ORB2B_EQUINOX_HHMMSS = 73500

dr0cloud marked this conversation as resolved.
Show resolved Hide resolved
! -------------------------------------------------------------

interface MAPL_SunGetInsolation
module procedure SOLAR_1D
Expand Down Expand Up @@ -759,6 +807,160 @@ end function MAPL_SunOrbitCreate

!==========================================================================

!BOPI

! !IROUTINE: MAPL_SunOrbitCreateFromConfig

! !DESCRIPTION:

! Like MAPL_SunOrbitCreate() but gets orbital parameters from Config CF.

! !INTERFACE:

function MAPL_SunOrbitCreateFromConfig ( &
CF, CLOCK, FIX_SUN, RC) result (ORBIT)

! !ARGUMENTS:

type (ESMF_Config), intent(INOUT) :: CF
type (ESMF_Clock), intent(IN ) :: CLOCK
logical, intent(IN ) :: FIX_SUN
integer, optional, intent(OUT ) :: RC

type (MAPL_SunOrbit) :: ORBIT

!EOPI

character(len=ESMF_MAXSTR), parameter :: IAm = "SunOrbitCreateFromConfig"
integer :: STATUS

real :: ECC, OB, PER
integer :: EQNX

logical :: EOT, ORBIT_ANAL2B
integer :: ORB2B_REF_YYYYMMDD, ORB2B_REF_HHMMSS, &
ORB2B_EQUINOX_YYYYMMDD, ORB2B_EQUINOX_HHMMSS
real :: ORB2B_YEARLEN, &
ORB2B_ECC_REF, ORB2B_ECC_RATE, &
ORB2B_OBQ_REF, ORB2B_OBQ_RATE, &
ORB2B_LAMBDAP_REF, ORB2B_LAMBDAP_RATE

! pmn: There is one orbit is per STATE, so, for example, the MAPL states of the
! solar and land gridded components can potentially have independent solar orbits.
! Usually these "independent orbits" will be IDENTICAL because the configuration
! resources such as "ECCENTRICITY:" or "EOT:" will not be qualified by the name
! of the gridded component. But for example, if the resource file specifies
! "EOT: .FALSE."
! but
! "SOLAR_EOT: .TRUE."
! then only SOLAR will have an EOT correction. The same goes for the new orbital
! system choice ORBIT_ANAL2B.
! A state's orbit is actually created in this routine by requesting the ORBIT
! object. If its not already created then it will be made below. GridComps that
! don't needed an orbit and dont request one will not have one.

! Parameters of standard orbital system (tabularized intercalation cycle)
! -----------------------------------------------------------------------
call ESMF_ConfigGetAttribute (CF, &
ECC, label="ECCENTRICITY:", &
default=DEFAULT_ORBIT_ECCENTRICITY, _RC)

call ESMF_ConfigGetAttribute (CF, &
OB, label="OBLIQUITY:", &
default=DEFAULT_ORBIT_OBLIQUITY, _RC)

call ESMF_ConfigGetAttribute (CF, &
PER, label="PERIHELION:", &
default=DEFAULT_ORBIT_PERIHELION, _RC)

call ESMF_ConfigGetAttribute (CF, &
EQNX, label="EQUINOX:", &
default=DEFAULT_ORBIT_EQUINOX, _RC)
dr0cloud marked this conversation as resolved.
Show resolved Hide resolved

! Apply Equation of Time correction?
! ----------------------------------
call ESMF_ConfigGetAttribute (CF, &
EOT, label="EOT:", &
default=.FALSE., _RC)

! New orbital system (analytic two-body) allows some time-varying
! behavior, namely, linear variation in LAMBDAP, ECC, and OBQ.
! ---------------------------------------------------------------

call ESMF_ConfigGetAttribute (CF, &
ORBIT_ANAL2B, label="ORBIT_ANAL2B:", &
default=.FALSE., _RC)

! Fixed anomalistic year length in mean solar days
call ESMF_ConfigGetAttribute (CF, &
ORB2B_YEARLEN, label="ORB2B_YEARLEN:", &
default=DEFAULT_ORB2B_YEARLEN, _RC)

! Reference date and time for orbital parameters
call ESMF_ConfigGetAttribute (CF, &
ORB2B_REF_YYYYMMDD, label="ORB2B_REF_YYYYMMDD:", &
default=DEFAULT_ORB2B_REF_YYYYMMDD, _RC)
call ESMF_ConfigGetAttribute (CF, &
ORB2B_REF_HHMMSS, label="ORB2B_REF_HHMMSS:", &
default=DEFAULT_ORB2B_REF_HHMMSS, _RC)

! Orbital eccentricity at reference date
call ESMF_ConfigGetAttribute (CF, &
ORB2B_ECC_REF, label="ORB2B_ECC_REF:", &
default=DEFAULT_ORB2B_ECC_REF, _RC)

! Rate of change of orbital eccentricity per Julian century
call ESMF_ConfigGetAttribute (CF, &
ORB2B_ECC_RATE, label="ORB2B_ECC_RATE:", &
default=DEFAULT_ORB2B_ECC_RATE, _RC)

! Earth's obliquity (axial tilt) at reference date [degrees]
call ESMF_ConfigGetAttribute (CF, &
ORB2B_OBQ_REF, label="ORB2B_OBQ_REF:", &
default=DEFAULT_ORB2B_OBQ_REF, _RC)

! Rate of change of obliquity [degrees per Julian century]
call ESMF_ConfigGetAttribute (CF, &
ORB2B_OBQ_RATE, label="ORB2B_OBQ_RATE:", &
default=DEFAULT_ORB2B_OBQ_RATE, _RC)

! Longitude of perihelion at reference date [degrees]
! (from March equinox to perihelion in direction of earth's motion)
call ESMF_ConfigGetAttribute (CF, &
ORB2B_LAMBDAP_REF, label="ORB2B_LAMBDAP_REF:", &
default=DEFAULT_ORB2B_LAMBDAP_REF, _RC)

! Rate of change of LAMBDAP [degrees per Julian century]
! (Combines both equatorial and ecliptic precession)
call ESMF_ConfigGetAttribute (CF, &
ORB2B_LAMBDAP_RATE, label="ORB2B_LAMBDAP_RATE:", &
default=DEFAULT_ORB2B_LAMBDAP_RATE, _RC)

! March Equinox date and time
call ESMF_ConfigGetAttribute (CF, &
ORB2B_EQUINOX_YYYYMMDD, label="ORB2B_EQUINOX_YYYYMMDD:", &
default=DEFAULT_ORB2B_EQUINOX_YYYYMMDD, _RC)
call ESMF_ConfigGetAttribute (CF, &
ORB2B_EQUINOX_HHMMSS, label="ORB2B_EQUINOX_HHMMSS:", &
default=DEFAULT_ORB2B_EQUINOX_HHMMSS, _RC)

! create the orbit object
ORBIT = MAPL_SunOrbitCreate ( &
CLOCK, ECC, OB, PER, EQNX, &
EOT, ORBIT_ANAL2B, ORB2B_YEARLEN, &
ORB2B_REF_YYYYMMDD, ORB2B_REF_HHMMSS, &
ORB2B_ECC_REF, ORB2B_ECC_RATE, &
ORB2B_OBQ_REF, ORB2B_OBQ_RATE, &
ORB2B_LAMBDAP_REF, ORB2B_LAMBDAP_RATE, &
ORB2B_EQUINOX_YYYYMMDD, ORB2B_EQUINOX_HHMMSS, &
FIX_SUN=FIX_SUN,_RC)

_RETURN(ESMF_SUCCESS)

end function MAPL_SunOrbitCreateFromConfig

!==========================================================================

!BOP

! !IROUTINE: MAPL_SunOrbitDestroy
Expand Down
Loading