1 subroutine da_ffdduv (F,D,U,V,YLON,ID)
3 !-------------------------------------------------------------------------
6 ! Convert wind speed (F in m/s) and direction (D in degree 0-360) into
7 ! wind (U-V in m/s) components
10 ! Convert wind (U-V in m/s) components into wind speed (F in m/s) and
11 ! direction (D in degree 0-360)
13 ! Need map projection parameters from module da_control
15 ! PHIC: Central latitude
16 ! XLONC: Central longitude
20 !-------------------------------------------------------------------------
24 real, intent (inout) :: f,d
25 real, intent (inout) :: u, v
26 real, intent (in) :: ylon
27 integer, intent (in) :: id
29 real :: aearth, uearth, vearth
30 real :: xlonrt, ang, conv
32 if (trace_use_frequent) call da_trace_entry("da_ffdduv")
40 ! convert wind module/direction into u/v wind components on earth,
41 ! then convert u/v wind components on earth into lambert conformal or
42 ! polar stereographic projection u/v wind components.
44 ! projections change requires only a change of the cone constant, xn
45 ! equations remain the same.
49 UEARTH = -F*Sin(AEARTH)
50 VEARTH = -F*COS(AEARTH)
52 ! for conversion to grid coordinates,
53 ! see program datamap, subr vect, and
54 ! ANTHES METEO. 597 NOTES, EQUA. 2.23, 2.25, 2.28.
58 if (XLONRT .GT. 180.0) XLONRT=XLONRT-360.0
59 if (XLONRT .LT.-180.0) XLONRT=XLONRT+360.0
61 ANG=XLONRT*CONE_FACTOR/CONV
63 ! for mercator projection, the winds are as in earth coordinates
65 if (map_projection.EQ.3) ANG=0.0
67 if (PHIC.LT.0.0) ANG=-ANG
69 U = VEARTH*Sin(ANG) + UEARTH*COS(ANG)
70 V = VEARTH*COS(ANG) - UEARTH*Sin(ANG)
73 ! CONVERT LAMBERT CONFORMAL OR POLAR STEREOGRAPHIC PROJECTION U/V
74 ! WinD COMPONENTS inTO U/V WinD COMPONENTS ON EART
75 ! then CONVERT U/V WinD COMPONENTS ON EARTH inTO WinD module/DIRECTION
77 ! PROJECTIONS CHANGE REQUIRES ONLY A CHANGE OF THE CONE_FACTOR
83 if (XLONRT .GT. 180.0) XLONRT=XLONRT-360.0
84 if (XLONRT .LT.-180.0) XLONRT=XLONRT+360.0
86 ANG=XLONRT*CONE_FACTOR/CONV
88 ! FOR MERCATOR PROJECTION, THE WinDS ARE AS in EARTH COORDinATES
90 if (map_projection .EQ. 3) ANG = 0.0
91 if (PHIC .LT. 0.0) ANG = -ANG
93 UEARTH = U*COS(ANG) - V*Sin(ANG)
94 VEARTH = U*Sin(ANG) + V*COS(ANG)
96 F = sqrt(UEARTH*UEARTH + VEARTH*VEARTH)
100 if (trace_use_frequent) call da_trace_exit("da_ffdduv")
104 if (VEARTH .EQ. 0.0) then
105 if (UEARTH .GT. 0.0) D = 270.0
106 if (UEARTH .LT. 0.0) D = 90.0
108 AEARTH = ATAN (UEARTH/VEARTH)*CONV
110 if (UEARTH .LE. 0.0 .AND. VEARTH .LE. 0.0) D = AEARTH
111 if (UEARTH .LE. 0.0 .AND. VEARTH .GE. 0.0) D = AEARTH + 180.0
112 if (UEARTH .GE. 0.0 .AND. VEARTH .GE. 0.0) D = AEARTH + 180.0
113 if (UEARTH .GE. 0.0 .AND. VEARTH .LE. 0.0) D = AEARTH + 360.0
118 write(unit=message(1),fmt='(A,I2)') ' UNKNOWN OPTION ',ID
119 call da_error(__FILE__,__LINE__,message(1:1))
123 if (trace_use_frequent) call da_trace_exit("da_ffdduv")
125 end subroutine da_ffdduv