NCEPLIBS-ip 5.3.0
All Data Structures Namespaces Files Functions Variables Pages
earth_radius_mod.F90
Go to the documentation of this file.
1!> @file
2!> @brief Determine earth radius and shape.
3!> @author Kyle Gerheiser @date 2021-07-21
4
5!> @brief Determine earth radius and shape.
6!> @author Gayno, Kyle Gerheiser
8 implicit none
9
10 private
11 public :: earth_radius
12
13contains
14
15 !> Determine earth radius and shape.
16 !>
17 !> Determine the radius and shape of the earth from
18 !> the grib 2 grid definition template array - section 3.
19 !>
20 !> @param[in] igdtmpl integer (igdtlen) grid definition template
21 !> array. Corresponds to the gfld%igdtmpl component of the ncep g2
22 !> library gridmod data structure. For all map projections recognized
23 !> by iplib, the entries use by this routine are:
24 !> - 1 shape of earth, section 3, octet 15
25 !> - 2 scale factor of spherical earth radius, octet 16
26 !> - 3 scaled value of radius of spherical earth, octets 17-20
27 !> - 4 scale factor of major axis of elliptical earth, octet 21
28 !> - 5 scaled value of major axis of elliptical earth, octets 22-25
29 !> - 6 scale factor of minor axis of elliptical earth, octet 26
30 !> - 7 scaled value of minor axis of elliptical earth, octets 27-30
31 !> @param[in] igdtlen integer number of elements of the grid
32 !> definition template array. Corresponds to the gfld%igdtlen
33 !> component of the ncep g2 library gridmod data structure.
34 !> @param[out] radius real earth radius in meters. For ellipitical
35 !> earths, this is the semi major axis. See "map projectsions - a
36 !> working manual" by Snyder (1987) for details.
37 !> @param[out] eccen_squared real earth eccentricity squared
38 !>
39 !> @author Gayno @date 2015-07-14
40 SUBROUTINE earth_radius(IGDTMPL, IGDTLEN, RADIUS, ECCEN_SQUARED)
41 IMPLICIT NONE
42
43 INTEGER, INTENT(IN ) :: igdtlen
44 INTEGER, INTENT(IN ) :: igdtmpl(igdtlen)
45
46 REAL, INTENT( OUT) :: eccen_squared
47 REAL, INTENT( OUT) :: radius
48
49 REAL :: flat
50 REAL :: major_axis, minor_axis
51
52 SELECT CASE (igdtmpl(1))
53 CASE (0)
54 radius = 6367470.0
55 eccen_squared = 0.0
56 CASE (1) ! USER SPECIFIED SPHERICAL
57 radius = float(igdtmpl(3))/float(10**igdtmpl(2))
58 eccen_squared = 0.0
59 CASE (2) ! IAU 1965
60 radius = 6378160.0 ! SEMI MAJOR AXIS
61 flat = 1.0/297.0 ! FLATTENING
62 eccen_squared = (2.0*flat) - (flat**2)
63 CASE (3) ! USER SPECIFIED ELLIPTICAL (KM)
64 major_axis = float(igdtmpl(5))/float(10**igdtmpl(4))
65 major_axis = major_axis * 1000.0
66 minor_axis = float(igdtmpl(7))/float(10**igdtmpl(6))
67 minor_axis = minor_axis * 1000.0
68 eccen_squared = 1.0 - (minor_axis**2 / major_axis**2)
69 radius = major_axis
70 CASE (4) ! IAG-GRS80 MODEL
71 radius = 6378137.0 ! SEMI MAJOR AXIS
72 flat = 1.0/298.2572 ! FLATTENING
73 eccen_squared = (2.0*flat) - (flat**2)
74 CASE (5) ! WGS84 DATUM
75 radius = 6378137.0 ! SEMI MAJOR AXIS
76 eccen_squared = 0.00669437999013
77 CASE (6)
78 radius = 6371229.0
79 eccen_squared = 0.0
80 CASE (7) ! USER SPECIFIED ELLIPTICAL (M)
81 major_axis = float(igdtmpl(5))/float(10**igdtmpl(4))
82 minor_axis = float(igdtmpl(7))/float(10**igdtmpl(6))
83 eccen_squared = 1.0 - (minor_axis**2 / major_axis**2)
84 radius = major_axis
85 CASE (8)
86 radius = 6371200.0
87 eccen_squared = 0.0
88 CASE DEFAULT
89 radius = -9999.
90 eccen_squared = -9999.
91 END SELECT
92 !
93 RETURN
94 !
95 END SUBROUTINE earth_radius
96end module earth_radius_mod
Determine earth radius and shape.
subroutine, public earth_radius(igdtmpl, igdtlen, radius, eccen_squared)
Determine earth radius and shape.