updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / da / da_ssmi / da_spemiss_tl.inc
blobcda66a858ef717133d205aab7ba3a9ac3c818198
1 subroutine da_spemiss_tl(f,tk,theta,ssw,ev,eh,TGL_tk,TGL_ev,TGL_eh                               )
3    !-----------------------------------------------------------------------
4    ! Purpose: returns the specular emissivity of sea water for given 
5    ! freq. (GHz), temperature T (K), incidence angle theta (degrees), 
6    ! salinity (permil)
7    !     
8    ! Returned values verified against data in Klein and Swift (1977) and
9    ! against Table 3.8 in Olson (1987, Ph.D. Thesis)
10    !
11    ! Input  : TGL_tk
12    ! Output : TGL_ev, TGL_eh, ev, eh
13    !------------------------------------------------------------------------
15    implicit none
17    real, intent(in)    :: f, tk, theta, TGL_tk
18    real, intent(inout) :: ssw
19    real, intent(out)   :: TGL_ev, TGL_eh, ev, eh
21    real :: epsr,epsi,TGL_epsr,TGL_epsi
23    real    ::  tc,costh,sinth,rthet
24    complex ::  etav,etah,eps,cterm1v,cterm1h,cterm2,cterm3v,cterm3h,epsnew
25    complex ::  TGL_etav,TGL_eps,TGL_cterm1v,TGL_cterm2,TGL_cterm3v
26    complex ::  TGL_cterm3h,TGL_epsnew
27    ! complex   uniti
28    real    ::  tmp1r,tmp1i,tmp2r,tmp2i
29    ! real :: rnorm,tmp0i,tmp0r
30    real    ::  TGL_tc,TGL_tmp1r
31    ! real :: TGL_tmp0r,TGL_tmp0i,TGL_rnorm
32    real    ::  TGL_tmp1i,TGL_tmp2r,TGL_tmp2i 
34    if (trace_use) call da_trace_entry("da_spemiss_tl")
37    tc          =      tk - t_kelvin
38    TGL_tc      =  TGL_tk
40    call da_epsalt_tl(f,tc,ssw,epsr,epsi,TGL_tc, TGL_epsr, TGL_epsi )
42        eps     =  cmplx(epsr,epsi)
43    TGL_eps     =  cmplx(TGL_epsr,TGL_epsi)
44        etav    =  eps
45    TGL_etav    =  TGL_eps
46    etah        =  (1.0,0.0)
47    rthet       =  theta*0.017453292
48    costh       =  cos(rthet)
49    sinth       =  sin(rthet)
50    sinth       =  sinth*sinth
51        cterm1v =  etav*costh
52    TGL_cterm1v =  TGL_etav*costh
53    cterm1h     =  etah*costh
54        epsnew  =      eps - sinth
55    TGL_epsnew  =  TGL_eps
56    cterm2      =  csqrt(epsnew)
58    ! calculate TGL_cterm2
60    if (cabs(epsnew) .gt. 0.0) then
61       TGL_cterm2      =  TGL_epsnew*0.5/cterm2
62    else
63       TGL_cterm2      =  0.0
64    end if
66    ! Wei's Comment
67    !     It is not a standard fortran if statement here.
69    !     if (0) then
70    !               tmp0r   =  real(epsnew)
71    !           TGL_tmp0r   =  real(TGL_epsnew)
72    !               tmp0i   = -aimag(epsnew)
73    !           TGL_tmp0i   = -aimag(TGL_epsnew)
74    !               rnorm   =  sqrt(tmp0r*tmp0r+tmp0i*tmp0i)
75    !               uniti   =  (0,1)
76    !           if (rnorm .gt. 0.0) then
77    !             if (abs(tmp0i) .gt. 0.0) then
78    !                TGL_rnorm =  (tmp0r*TGL_tmp0r + tmp0i*TGL_tmp0i)/rnorm
79    !                TGL_cterm2=  cterm2*0.5*(TGL_rnorm/rnorm  &
80    !                                      -uniti*(TGL_tmp0r*rnorm-TGL_rnorm*tmp0r)/(rnorm*tmp0i))
81    !             else
82    !                TGL_rnorm =  TGL_tmp0r
83    !                TGL_cterm2=  TGL_tmp0r*0.5/sqrt(tmp0r)
84    !             end if
85    !           else 
86    !             TGL_rnorm =  0.0
87    !             TGL_cterm2=  0.0
88    !           end if
89    !     end if
91    ! End Wei's Comment
93        cterm3v =  (cterm1v - cterm2)/(cterm1v + cterm2)
94    TGL_cterm3v =  (TGL_cterm1v - TGL_cterm2)/(cterm1v + cterm2) &
95                  -cterm3v*(TGL_cterm1v + TGL_cterm2)/(cterm1v + cterm2)
96        cterm3h =  (cterm1h - cterm2)/(cterm1h + cterm2)
97    TGL_cterm3h = -TGL_cterm2/(cterm1h + cterm2) &
98                  -cterm3h*TGL_cterm2/(cterm1h + cterm2)
99        tmp1r   =  real(cterm3v)
100    TGL_tmp1r   =  real(TGL_cterm3v)
101        tmp1i   = -aimag(cterm3v)
102    TGL_tmp1i   = -aimag(TGL_cterm3v)
103    ! ev      =  1.0 - cabs(cterm3v)**2
104        ev      =  1.0 - (tmp1r*tmp1r+tmp1i*tmp1i)
105    TGL_ev      = -2.0*tmp1r*TGL_tmp1r - 2.0*tmp1i*TGL_tmp1i
107        tmp2r   =  real(cterm3h)
108    TGL_tmp2r   =  real(TGL_cterm3h)
109        tmp2i   = -aimag(cterm3h)
110    TGL_tmp2i   = -aimag(TGL_cterm3h)
111    ! eh      =  1.0 - cabs(cterm3h)**2
112        eh      =  1.0 - (tmp2r*tmp2r+tmp2i*tmp2i)
113    TGL_eh      = -2.0*tmp2r*TGL_tmp2r - 2.0*tmp2i*TGL_tmp2i
115    if (trace_use) call da_trace_exit("da_spemiss_tl")
117 end subroutine da_spemiss_tl