da_ffdduv.inc

References to this file elsewhere.
1 subroutine da_ffdduv (F,D,U,V,YLON,ID)
2 
3    !-------------------------------------------------------------------------
4    ! Purpose: TBD
5    ! When ID =  1
6    ! Convert wind speed (F in m/s) and direction (D in degree 0-360) into
7    ! wind (U-V in m/s) components
8    !
9    ! When ID = -1
10    ! Convert wind (U-V in m/s) components into wind speed (F in m/s) and 
11    ! direction (D in degree 0-360)
12    !
13    ! Need map projection parameters from module da_control
14    !
15    ! PHIC:  Central latitude 
16    ! XLONC: Central longitude
17    ! XN:    Cone projection
18    ! CONV:  180/Pi
19    !
20    !-------------------------------------------------------------------------
21 
22    implicit none
23 
24    real,    intent (inout) :: F,D
25    real,    intent (inout) :: U, V
26    real,    intent (in)    :: YLON
27    integer, intent (in)    :: ID
28 
29    real :: AEARTH, UEARTH, VEARTH
30    real :: XLONRT, ANG, conv
31 
32 
33    conv = 180.0 / pi
34 
35    select case (ID)
36 
37       case (convert_fd2uv);
38 
39          ! CONVERT WinD module/DIRECTION inTO U/V WinD COMPONENTS ON EARTH,
40          ! then CONVERT U/V WinD COMPONENTS ON EARTH inTO LAMBERT CONFORMAL OR
41          ! POLAR STEREOGRAPHIC PROJECTION U/V WinD COMPONENTS.
42 
43          ! PROJECTIONS CHANGE REQUIRES ONLY A CHANGE OF THE CONE CONSTANT, XN
44          ! EQUATIONS REMAin THE SAME.
45 
46          AEARTH = D/CONV
47 
48          UEARTH = -F*Sin(AEARTH)
49          VEARTH = -F*COS(AEARTH)
50 
51          ! FOR CONVERSION TO GRID COORDinATES,
52          ! SEE program DATAMAP, SUBR VECT, AND
53          ! ANTHES METEO. 597 NOTES, EQUA. 2.23, 2.25, 2.28.
54 
55          XLONRT = XLONC-YLON
56 
57          if (XLONRT .GT. 180.) XLONRT=XLONRT-360.
58          if (XLONRT .LT.-180.) XLONRT=XLONRT+360.
59 
60          ANG=XLONRT*CONE_FACTOR/CONV
61 
62          ! FOR MERCATOR PROJECTION, THE WinDS ARE AS in EARTH COORDinATES
63 
64          if (map_projection.EQ.3) ANG=0.
65 
66          if (PHIC.LT.0.0) ANG=-ANG
67 
68          U = VEARTH*Sin(ANG) + UEARTH*COS(ANG)
69          V = VEARTH*COS(ANG) - UEARTH*Sin(ANG)
70 
71 
72          ! CONVERT LAMBERT CONFORMAL OR POLAR STEREOGRAPHIC PROJECTION U/V
73          ! WinD COMPONENTS inTO U/V WinD COMPONENTS ON EART
74          ! then CONVERT U/V WinD COMPONENTS ON EARTH inTO WinD module/DIRECTION
75 
76          ! PROJECTIONS CHANGE REQUIRES ONLY A CHANGE OF THE CONE_FACTOR
77 
78       case (convert_uv2fd);
79 
80          XLONRT = XLONC-YLON
81 
82          if (XLONRT .GT. 180.) XLONRT=XLONRT-360.
83          if (XLONRT .LT.-180.) XLONRT=XLONRT+360.
84 
85          ANG=XLONRT*CONE_FACTOR/CONV
86 
87          ! FOR MERCATOR PROJECTION, THE WinDS ARE AS in EARTH COORDinATES
88 
89          if (map_projection .EQ.  3) ANG = 0.
90          if (PHIC  .LT. 0.) ANG = -ANG
91 
92          UEARTH = U*COS(ANG) - V*Sin(ANG)
93          VEARTH = U*Sin(ANG) + V*COS(ANG)
94 
95          F = sqrt(UEARTH*UEARTH + VEARTH*VEARTH)
96 
97          if (F .EQ. 0.0) then
98             D = 0.
99             return
100          end if
101 
102          if (VEARTH .EQ. 0.) then
103             if (UEARTH .GT. 0.) D = 270.
104             if (UEARTH .LT. 0.) D =  90.
105          else
106             AEARTH = ATAN (UEARTH/VEARTH)*CONV
107 
108             if (UEARTH .LE. 0.0 .AND. VEARTH .LE. 0.0) D = AEARTH
109             if (UEARTH .LE. 0.0 .AND. VEARTH .GE. 0.0) D = AEARTH + 180.0
110             if (UEARTH .GE. 0.0 .AND. VEARTH .GE. 0.0) D = AEARTH + 180.0
111             if (UEARTH .GE. 0.0 .AND. VEARTH .LE. 0.0) D = AEARTH + 360.0
112 
113          end if
114 
115       case default
116          write(unit=message(1),fmt='(A,I2)') ' UNKNOWN OPTION ',ID
117          call da_error(__FILE__,__LINE__,message(1:1))
118 
119    end select
120 
121 end subroutine da_ffdduv
122 
123