chgres_cube  1.12.0
 All Data Structures Files Functions Variables
wam_climo_data.f90
Go to the documentation of this file.
1 
9 
23  subroutine gettemp(iday,xlat,pr,np,pf,temp,n_o,n_o2,n_n2)
24  use msis_init, only: msisinit
25  use msis_constants, only: rp
26  use esmf, only: esmf_kind_r8
27 
28  implicit none
29 
30  integer, intent(in) :: iday ! calender day
31  real(kind=esmf_kind_r8), intent(in) :: xlat ! latitude (degrees)
32  real(kind=esmf_kind_r8), intent(in) :: pr(np) ! pressure (hPa)
33  integer, intent(in) :: np ! number of pressure layers
34  character(*), intent(in) :: pf ! path to parmfile for msisinit
35  real(kind=esmf_kind_r8), intent(out) :: temp(np) ! temperature (K)
36  real(kind=esmf_kind_r8), intent(out) :: n_o(np) ! number density of o
37  real(kind=esmf_kind_r8), intent(out) :: n_o2(np) ! number density of o2
38  real(kind=esmf_kind_r8), intent(out) :: n_n2(np) ! number density of n2
39 ! Local variables
40  real(kind=rp), parameter :: alt=100, ut=0, f107=150, f107a=150, ap(7)=9, xlong=0
41  real(kind=rp) :: t, d(10), zkm
42  integer :: ip
43  real(4) :: switch_legacy(1:25)
44 
45 ! set swich 7,8,10,14 to zero to avoid diurnal changes in output tempe
46 ! #7 is for diurnal, #8 for semidiurnal, #10 is for all ut/longitudinal
47 ! effect, #14 is for terdiurnal
48  switch_legacy(:) = 1.
49  switch_legacy(7) = 0.
50  switch_legacy(8) = 0.
51  switch_legacy(10) = 0.
52  switch_legacy(14) = 0.
53 
54  call msisinit(parmfile=pf, switch_legacy=switch_legacy)
55 ! calculate temperature, species, for each pres level
56  do ip=1,np
57  call ghp8(real(iday, rp), ut, alt, real(xlat, rp), &
58  xlong , f107a, f107, ap, real(pr(ip), rp), &
59  zkm, d, t)
60  temp(ip)=real(t, esmf_kind_r8)
61  n_n2(ip)=real(d(2), esmf_kind_r8)
62  n_o2(ip)=real(d(3), esmf_kind_r8)
63  n_o( ip)=real(d(4), esmf_kind_r8)
64  enddo
65 
66  end subroutine gettemp
67 
85  subroutine ghp8(day,utsec,z0,glat,glon,f107a,f107,ap,pres,alt,dn,tn)
86 
87  use msis_constants, only: kb, na, g0, rp
88  use msis_calc, only: msiscalc
89  use msis_utils, only: alt2gph
90 
91  implicit none
92 
93  real(kind=rp),intent(in) :: day
94  real(kind=rp),intent(in) :: utsec
95  real(kind=rp),intent(in) :: z0 !! first guess
96  real(kind=rp),intent(in) :: glat,glon
97  real(kind=rp),intent(in) :: f107a,f107
98  real(kind=rp),intent(in) :: ap(7)
99  real(kind=rp),intent(in) :: pres !!! pressure in hPa
100  real(kind=rp),intent(out) :: alt
101  real(kind=rp),intent(out) :: dn(10)
102  real(kind=rp),intent(out) :: tn
103 ! Local variables
104  real, parameter :: tol = 0.000043
105  integer, parameter :: maxit = 30
106  real :: plog,delta
107  real(kind=rp) :: tex,zkm,pzkm
108  real :: xn,gz,xmbar,scl
109  integer :: n
110  real(8) :: xlat,alt0,alt1
111 
112  plog = log10(pres*100.0_rp)
113  zkm = z0
114  delta = 1.0_rp
115 
116  n = 0
117 
118  do while ( abs(delta) .ge. tol .and. n .le. maxit )
119  n = n + 1
120 
121  call msiscalc(day,utsec,zkm,glat,glon,f107a,f107,ap,tn,dn,tex)
122 
123  xn = sum(dn(2:8))
124  pzkm = kb * xn * tn
125  delta = plog - log10(pzkm)
126  xmbar = dn(1) / xn / 1.66e-24_rp
127  xlat = dble(glat)
128  alt0 = dble(zkm)
129  alt1 = alt0 + 1.0d0
130  gz = real((alt2gph(xlat,alt1) - alt2gph(xlat,alt0)) * g0)
131  scl = na * kb * tn / (xmbar * gz)
132 
133  ! difference
134  zkm = zkm - scl * delta / 1000.0_rp
135  end do
136  alt = zkm
137 
138  end subroutine ghp8
subroutine ghp8(day, utsec, z0, glat, glon, f107a, f107, ap, pres, alt, dn, tn)
Wrapper routine for calls to MSIS 2.1 for computing temperature and neutral density at a given pressu...
subroutine gettemp(iday, xlat, pr, np, pf, temp, n_o, n_o2, n_n2)
Routine that computes temperature and neutral density values utilizing MSIS 2.1.