108 MI,MO,KM,IBI,LI,GI, &
109 NO,RLAT,RLON,IBO,LO,GO,IRET)
110 class(ip_grid),
intent(in) :: grid_in, grid_out
112 INTEGER,
INTENT(IN ) :: IBI(KM), IPOPT(20), KM, MI, MO
113 INTEGER,
INTENT( OUT) :: IBO(KM), IRET, NO
115 LOGICAL*1,
INTENT(IN ) :: LI(MI,KM)
116 LOGICAL*1,
INTENT( OUT) :: LO(MO,KM)
118 REAL,
INTENT(IN ) :: GI(MI,KM)
119 REAL,
INTENT( OUT) :: GO(MO,KM), RLAT(MO), RLON(MO)
121 REAL,
PARAMETER :: FILL=-9999.
124 INTEGER :: JB, J1, K, LB, LSW, MP, N
125 INTEGER :: N11(MO), NB, NB1, NB2, NB3, NB4, NV
127 REAL :: PMP,RLOB(MO),RLAB(MO)
128 REAL :: WB, WO(MO,KM), XI, YI
129 REAL :: XPTB(MO),YPTB(MO),XPTS(MO),YPTS(MO)
131 logical :: to_station_points
133 select type(grid_out)
134 type is(ip_station_points_grid)
135 to_station_points = .true.
137 to_station_points = .false.
143 if(to_station_points)
then
144 CALL gdswzd(grid_out, 0,mo,fill,xpts,ypts,rlon,rlat,no)
146 CALL gdswzd(grid_in,-1,no,fill,xpts,ypts,rlon,rlat,nv)
149 CALL gdswzd(grid_out, 0,mo,fill,xpts,ypts,rlon,rlat,no)
156 IF(iret.EQ.0.AND.nb1.LT.0) iret=32
158 IF(ipopt(1).EQ.-1.OR.ipopt(2).EQ.-1) lsw=0
159 IF(iret.EQ.0.AND.lsw.EQ.1.AND.nb1.GT.15) iret=32
161 IF(mp.EQ.-1.OR.mp.EQ.0) mp=50
162 IF(mp.LT.0.OR.mp.GT.100) iret=32
171 nb4=nb4+8*ib*ipopt(2+ib)
191 ib=nb-(jb+nb1)*nb2-nb1-1
192 lb=max(abs(ib),abs(jb))
194 IF(lsw.EQ.1) wb=ipopt(2+lb)
195 IF(abs(wb).GT.tinyreal)
THEN
197 xptb(n)=xpts(n)+ib/real(nb2)
198 yptb(n)=ypts(n)+jb/real(nb2)
200 if(to_station_points)
then
201 CALL gdswzd(grid_in, 1,no,fill,xptb,yptb,rlob,rlab,nv)
202 CALL gdswzd(grid_in,-1,no,fill,xptb,yptb,rlob,rlab,nv)
204 CALL gdswzd(grid_out, 1,no,fill,xptb,yptb,rlob,rlab,nv)
205 CALL gdswzd(grid_in,-1,no,fill,xptb,yptb,rlob,rlab,nv)
207 IF(iret.EQ.0.AND.nv.EQ.0.AND.lb.EQ.0) iret=2
211 IF(abs(xi-fill).GT.tinyreal.AND.abs(yi-fill).GT.tinyreal)
THEN
214 n11(n)=grid_in%field_pos(i1, j1)
224 IF(ibi(k).EQ.0.OR.li(n11(n),k))
THEN
225 go(n,k)=go(n,k)+wb*gi(n11(n),k)
238 lo(n,k)=wo(n,k).GE.pmp*nb4
240 go(n,k)=go(n,k)/wo(n,k)
248 select type(grid_out)
249 type is(ip_equid_cylind_grid)
250 CALL polfixs(no,mo,km,rlat,ibo,lo,go)
352 MI,MO,KM,IBI,LI,UI,VI, &
353 NO,RLAT,RLON,CROT,SROT,IBO,LO,UO,VO,IRET)
354 class(ip_grid),
intent(in) :: grid_in, grid_out
356 INTEGER,
INTENT(IN ) :: IPOPT(20), IBI(KM)
357 INTEGER,
INTENT(IN ) :: KM, MI, MO
358 INTEGER,
INTENT( OUT) :: IRET, NO, IBO(KM)
360 LOGICAL*1,
INTENT(IN ) :: LI(MI,KM)
361 LOGICAL*1,
INTENT( OUT) :: LO(MO,KM)
363 REAL,
INTENT(IN ) :: UI(MI,KM),VI(MI,KM)
364 REAL,
INTENT(INOUT) :: RLAT(MO),RLON(MO)
365 REAL,
INTENT( OUT) :: UO(MO,KM),VO(MO,KM)
366 REAL,
INTENT( OUT) :: CROT(MO),SROT(MO)
368 REAL,
PARAMETER :: FILL=-9999.
371 INTEGER :: IB, JB, I1, J1
372 INTEGER :: K, LB, LSW, MP, N, NV
373 INTEGER :: NB, NB1, NB2, NB3, NB4
377 REAL :: C11(MO),S11(MO)
378 REAL :: CM11, SM11, PMP
379 REAL :: U11, V11, UROT, VROT
380 REAL :: WB, WO(MO,KM), XI, YI
381 REAL :: RLOB(MO),RLAB(MO)
382 REAL :: XPTS(MO),YPTS(MO)
383 REAL :: XPTB(MO),YPTB(MO)
385 logical :: to_station_points
388 INTEGER,
SAVE :: MIX=-1
389 REAL,
ALLOCATABLE,
SAVE :: CROI(:),SROI(:)
390 REAL,
ALLOCATABLE,
SAVE :: XPTI(:),YPTI(:)
391 REAL,
ALLOCATABLE,
SAVE :: RLOI(:),RLAI(:)
392 class(ip_grid),
allocatable,
save :: prev_grid_in
394 select type(grid_out)
395 type is(ip_station_points_grid)
396 to_station_points = .true.
398 to_station_points = .false.
404 CALL gdswzd(grid_out, 0,mo,fill,xpts,ypts,rlon,rlat,no,crot,srot)
406 if(to_station_points)
then
407 CALL gdswzd(grid_in,-1,no,fill,xpts,ypts,rlon,rlat,nv,crot,srot)
411 if (.not.
allocated(prev_grid_in))
then
412 allocate(prev_grid_in, source = grid_in)
416 same_grid = grid_in == prev_grid_in
418 if (.not. same_grid)
then
419 deallocate(prev_grid_in)
420 allocate(prev_grid_in, source = grid_in)
424 IF(.NOT.same_grid)
THEN
426 IF(mix.GE.0)
DEALLOCATE(xpti,ypti,rloi,rlai,croi,sroi)
427 ALLOCATE(xpti(mi),ypti(mi),rloi(mi),rlai(mi),croi(mi),sroi(mi))
430 CALL gdswzd(grid_in,0,mi,fill,xpti,ypti, &
431 rloi,rlai,nv,croi,sroi)
437 IF(iret.EQ.0.AND.nb1.LT.0) iret=32
439 IF(ipopt(1).EQ.-1.OR.ipopt(2).EQ.-1) lsw=0
440 IF(iret.EQ.0.AND.lsw.EQ.1.AND.nb1.GT.15) iret=32
442 IF(mp.EQ.-1.OR.mp.EQ.0) mp=50
443 IF(mp.LT.0.OR.mp.GT.100) iret=32
452 nb4=nb4+8*ib*ipopt(2+ib)
472 ib=nb-(jb+nb1)*nb2-nb1-1
473 lb=max(abs(ib),abs(jb))
475 IF(lsw.EQ.1) wb=ipopt(2+lb)
476 IF(abs(wb).GT.tinyreal)
THEN
478 xptb(n)=xpts(n)+ib/real(nb2)
479 yptb(n)=ypts(n)+jb/real(nb2)
481 if(to_station_points)
then
482 CALL gdswzd(grid_in, 1,no,fill,xptb,yptb,rlob,rlab,nv)
483 CALL gdswzd(grid_in,-1,no,fill,xptb,yptb,rlob,rlab,nv)
485 CALL gdswzd(grid_out, 1,no,fill,xptb,yptb,rlob,rlab,nv)
486 CALL gdswzd(grid_in,-1,no,fill,xptb,yptb,rlob,rlab,nv)
488 IF(iret.EQ.0.AND.nv.EQ.0.AND.lb.EQ.0) iret=2
492 IF(abs(xi-fill).GT.tinyreal.AND.abs(yi-fill).GT.tinyreal)
THEN
495 n11(n)=grid_in%field_pos(i1, j1)
497 CALL movect(rlai(n11(n)),rloi(n11(n)),rlat(n),rlon(n),cm11,sm11)
498 c11(n)=cm11*croi(n11(n))+sm11*sroi(n11(n))
499 s11(n)=sm11*croi(n11(n))-cm11*sroi(n11(n))
510 IF(ibi(k).EQ.0.OR.li(n11(n),k))
THEN
511 u11=c11(n)*ui(n11(n),k)-s11(n)*vi(n11(n),k)
512 v11=s11(n)*ui(n11(n),k)+c11(n)*vi(n11(n),k)
513 uo(n,k)=uo(n,k)+wb*u11
514 vo(n,k)=vo(n,k)+wb*v11
527 lo(n,k)=wo(n,k).GE.pmp*nb4
529 uo(n,k)=uo(n,k)/wo(n,k)
530 vo(n,k)=vo(n,k)/wo(n,k)
531 urot=crot(n)*uo(n,k)-srot(n)*vo(n,k)
532 vrot=srot(n)*uo(n,k)+crot(n)*vo(n,k)
543 select type(grid_out)
544 type is(ip_equid_cylind_grid)
545 CALL polfixv(no,mo,km,rlat,rlon,ibo,lo,uo,vo)