14 use grdvars, only : x,y,xsgp1,ysgp1,sg_maxlat
15 use grdvars, only : latbu,lonbu,lonct
17 use grdvars, only : mastertask, debug
28 integer :: i,j,i1,i2,m,n
31 integer(int_kind) :: ipolesg(2)
34 real(dbl_kind) :: len_lon
35 real(dbl_kind) :: pi_720deg
36 real(dbl_kind) :: lonb(2,2)
37 real(dbl_kind) :: lon_scale = 0.0
44 xsgp1 = 0.0; ysgp1 = 0.0
49 if(y(i,j) .eq. sg_maxlat)ipolesg(1) = i
52 if(y(i,j) .eq. sg_maxlat)ipolesg(2) = i
54 if(mastertask .and. debug)print *,
'poles found at ',ipolesg
56 xsgp1(:,0:ny) = x(:,0:ny)
57 ysgp1(:,0:ny) = y(:,0:ny)
60 do i = ipolesg(1)-5,ipolesg(1)+5
61 i2 = ipolesg(2)+(ipolesg(1)-i)+1
62 if(mastertask .and. debug)print *,i,i2
65 do i = ipolesg(2)-5,ipolesg(2)+5
66 i2 = ipolesg(2)+(ipolesg(1)-i)+1
67 if(mastertask .and. debug)print *,i,i2
72 i2 = ipolesg(2)+(ipolesg(1)-i)
73 xsgp1(i,ny+1) = xsgp1(i2,ny)
74 ysgp1(i,ny+1) = ysgp1(i2,ny)
78 if(mastertask .and. debug)
then
80 i1 = ipolesg(1); i2 = ipolesg(2)-(ipolesg(1)-i1)
81 print *,
'replicate X across seam on SG'
82 print *,xsgp1(i1-2,j),xsgp1(i2+2,j)
83 print *,xsgp1(i1-1,j),xsgp1(i2+1,j)
84 print *,xsgp1(i1, j),xsgp1(i2, j)
85 print *,xsgp1(i1+1,j),xsgp1(i2-1,j)
86 print *,xsgp1(i1+2,j),xsgp1(i2-2,j)
88 print *,
'replicate Y across seam on SG'
89 print *,ysgp1(i1-2,j),ysgp1(i2+2,j)
90 print *,ysgp1(i1-1,j),ysgp1(i2+1,j)
91 print *,ysgp1(i1, j),ysgp1(i2, j)
92 print *,ysgp1(i1+1,j),ysgp1(i2-1,j)
93 print *,ysgp1(i1+2,j),ysgp1(i2-2,j)
103 pi_720deg = atan(1.0) / 180.0
105 do j=1,ny ;
do i=1,nx-1
109 lon_scale = cos(pi_720deg*(ysgp1(i-1,j-1) + ysgp1(i+1,j-1) + &
110 ysgp1(i-1,j+1) + ysgp1(i+1,j+1)) )
111 angq(i,j) = atan2(lon_scale*((lonb(1,2) - lonb(2,1)) + (lonb(2,2) - lonb(1,1))), &
112 ysgp1(i-1,j+1) + ysgp1(i+1,j+1) - &
113 ysgp1(i-1,j-1) - ysgp1(i+1,j-1) )
117 if(mastertask .and. debug)
then
119 i1 = ipolesg(1); i2 = ipolesg(2)-(ipolesg(1)-i1)
120 print *,
'angq along seam on SG'
121 print *,angq(i1-2,j),angq(i2+2,j)
122 print *,angq(i1-1,j),angq(i2+1,j)
123 print *,angq(i1, j),angq(i2, j)
124 print *,angq(i1+1,j),angq(i2-1,j)
125 print *,angq(i1+2,j),angq(i2-2,j)
140 real(dbl_kind) :: len_lon
141 real(dbl_kind) :: pi_720deg
142 real(dbl_kind) :: lonb(2,2)
143 real(dbl_kind) :: lon_scale = 0.0
154 pi_720deg = atan(1.0) / 180.0
156 do j=1,nj;
do i = 1,ni
158 jj = j+n-2; ii = i+m-2
167 lon_scale = cos(pi_720deg*((latbu(ii,jj) + latbu(i,j)) + &
168 (latbu(i,jj) + latbu(ii,j)) ) )
169 anglet(i,j) = atan2(lon_scale*((lonb(1,2) - lonb(2,1)) + (lonb(2,2) - lonb(1,1))), &
170 (latbu(ii,j) - latbu(i,jj)) + &
171 (latbu(i,j) - latbu(ii,jj)) )
193 real(dbl_kind),
intent(in) :: x
194 real(dbl_kind),
intent(in) :: xc
195 real(dbl_kind),
intent(in) :: lx
196 real(dbl_kind) :: x_mod
199 x_mod = modulo(x - (xc - 0.5*lx), lx) + (xc - 0.5*lx)
subroutine find_ang
Find the rotation angle on center (Ct) grid points.
real(dbl_kind) function modulo_around_point(x, xc, Lx)
Return the modulo value of x in an interval [xc-(Lx/2) xc+(Lx/2)] If Lx<=0, then it returns x without...
subroutine find_angq
Find the rotation angle on corner grid (Bu) points using the full MOM6 supergrid. ...