-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc_uvmet.f90
86 lines (68 loc) · 2.24 KB
/
calc_uvmet.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
!! Diagnostics: U & V on earth coordinates
! from ARWpost postprocessing routine from the WRF package.
SUBROUTINE calc_uvmet(UUU,VVV,SCRa, SCRb, i3dflag)
IMPLICIT NONE
!Arguments
real, allocatable, dimension(:,:,:) :: SCRa, SCRb
character (len=128) :: cname, cdesc, cunits
!Local
integer :: i, j, k
integer :: i3dflag
real :: cone
real, dimension(west_east_dim,south_north_dim) :: diff, alpha
cname = "uvmet"
cdesc = "Rotated wind component"
cunits = "m s-1"
use com_mod
IF ( map_proj .ge. 3 ) THEN ! No need to rotate
IF ( i3dflag == 1 ) THEN
SCRa = UUU
SCRb = VVV
ENDIF
IF ( i3dflag == 0 ) THEN
SCRa(:,:,1) = U10(:,:)
SCRb(:,:,1) = V10(:,:)
END IF
RETURN
END IF
cone = 1. ! PS
IF ( map_proj .eq. 1) THEN ! Lambert Conformal mapping
IF (ABS(truelat1-truelat2) .GT. 0.1) THEN
cone=(ALOG(COS(truelat1*RAD_PER_DEG))- &
ALOG(COS(truelat2*RAD_PER_DEG))) / &
(ALOG(TAN((90.-ABS(truelat1))*RAD_PER_DEG*0.5 ))- &
ALOG(TAN((90.-ABS(truelat2))*RAD_PER_DEG*0.5 )) )
ELSE
cone = SIN(ABS(truelat1)*RAD_PER_DEG )
ENDIF
END IF
diff = XLONG - stand_lon
DO i = 1, west_east_dim
DO j = 1, south_north_dim
IF ( diff(i,j) .gt. 180. ) THEN
diff(i,j) = diff(i,j) - 360.
END IF
IF ( diff(i,j) .lt. -180. ) THEN
diff(i,j) = diff(i,j) + 360.
END IF
END DO
END DO
DO i = 1, west_east_dim
DO j = 1, south_north_dim
IF ( XLAT(i,j) .lt. 0. ) THEN
alpha(i,j) = - diff(i,j) * cone * RAD_PER_DEG
ELSE
alpha(i,j) = diff(i,j) * cone * RAD_PER_DEG
END IF
END DO
END DO
IF ( i3dflag == 1 ) THEN
DO k = 1,bottom_top_dim
SCRa(:,:,k) = VVV(:,:,k)*sin(alpha) + UUU(:,:,k)*cos(alpha)
SCRb(:,:,k) = VVV(:,:,k)*cos(alpha) - UUU(:,:,k)*sin(alpha)
END DO
ELSE
SCRa(:,:,1) = V10(:,:)*sin(alpha) + U10(:,:)*cos(alpha)
SCRb(:,:,1) = V10(:,:)*cos(alpha) - U10(:,:)*sin(alpha)
END IF
END SUBROUTINE calc_uvmet