74 PUBLIC :: allocate_extract
75 PUBLIC :: deallocate_extract
76 PUBLIC :: initialize_extract
86 real(r8),
allocatable :: Hmin(:)
87 real(r8),
allocatable :: Hmax(:)
88 real(r8),
allocatable :: LonMin(:)
89 real(r8),
allocatable :: LonMax(:)
90 real(r8),
allocatable :: LatMin(:)
91 real(r8),
allocatable :: LatMax(:)
95 real(r8),
pointer :: angler(:,:)
96 real(r8),
pointer :: CosAngler(:,:)
97 real(r8),
pointer :: SinAngler(:,:)
99# if defined CURVGRID && defined UV_ADV
100 real(r8),
pointer :: dmde(:,:)
101 real(r8),
pointer :: dndx(:,:)
103 real(r8),
pointer :: f(:,:)
104 real(r8),
pointer :: h(:,:)
105 real(r8),
pointer :: latp(:,:)
106 real(r8),
pointer :: latr(:,:)
107 real(r8),
pointer :: latu(:,:)
108 real(r8),
pointer :: latv(:,:)
109 real(r8),
pointer :: lonp(:,:)
110 real(r8),
pointer :: lonr(:,:)
111 real(r8),
pointer :: lonu(:,:)
112 real(r8),
pointer :: lonv(:,:)
113 real(r8),
pointer :: MyLon(:,:)
114 real(r8),
pointer :: omn(:,:)
115 real(r8),
pointer :: om_p(:,:)
116 real(r8),
pointer :: om_r(:,:)
117 real(r8),
pointer :: om_u(:,:)
118 real(r8),
pointer :: om_v(:,:)
119 real(r8),
pointer :: on_p(:,:)
120 real(r8),
pointer :: on_r(:,:)
121 real(r8),
pointer :: on_u(:,:)
122 real(r8),
pointer :: on_v(:,:)
123 real(r8),
pointer :: pm(:,:)
124 real(r8),
pointer :: pn(:,:)
125 real(r8),
pointer :: xp(:,:)
126 real(r8),
pointer :: xr(:,:)
127 real(r8),
pointer :: xu(:,:)
128 real(r8),
pointer :: xv(:,:)
129 real(r8),
pointer :: yp(:,:)
130 real(r8),
pointer :: yr(:,:)
131 real(r8),
pointer :: yu(:,:)
132 real(r8),
pointer :: yv(:,:)
134 real(r8),
pointer :: Hz(:,:,:)
135 real(r8),
pointer :: z_r(:,:,:)
136 real(r8),
pointer :: z_v(:,:,:)
137 real(r8),
pointer :: z_w(:,:,:)
140 real(r8),
pointer :: pmask(:,:)
141 real(r8),
pointer :: rmask(:,:)
142 real(r8),
pointer :: umask(:,:)
143 real(r8),
pointer :: vmask(:,:)
153 real(r8),
pointer :: Gx_psi(:)
154 real(r8),
pointer :: Gx_rho(:)
155 real(r8),
pointer :: Gx_u(:)
156 real(r8),
pointer :: Gx_v(:)
158 real(r8),
pointer :: Gy_psi(:)
159 real(r8),
pointer :: Gy_rho(:)
160 real(r8),
pointer :: Gy_u(:)
161 real(r8),
pointer :: Gy_v(:)
164 real(r8),
pointer :: Gmask_psi(:)
165 real(r8),
pointer :: Gmask_rho(:)
166 real(r8),
pointer :: Gmask_u(:)
167 real(r8),
pointer :: Gmask_v(:)
170 real(r8),
pointer :: Iout_psi(:)
171 real(r8),
pointer :: Iout_rho(:)
172 real(r8),
pointer :: Iout_u(:)
173 real(r8),
pointer :: Iout_v(:)
175 real(r8),
pointer :: Jout_psi(:)
176 real(r8),
pointer :: Jout_rho(:)
177 real(r8),
pointer :: Jout_u(:)
178 real(r8),
pointer :: Jout_v(:)
182 TYPE (T_EXTRACT),
allocatable :: EXTRACT(:)
186 SUBROUTINE allocate_extract (ng, Extract_Flag, LBi, UBi, LBj, UBj)
199 integer,
intent(in) :: ng, Extract_Flag
200 integer,
intent(in) :: LBi, UBi, LBj, UBj
212 IF (ng.eq.1)
allocate ( extract(
ngrids) )
216 IF (.not.
allocated(extract(ng) % Hmin)) &
217 &
allocate ( extract(ng) % Hmin(
ngrids) )
219 IF (.not.
allocated(extract(ng) % Hmax)) &
220 &
allocate ( extract(ng) % Hmax(
ngrids) )
222 IF (.not.
allocated(extract(ng) % LonMin)) &
223 &
allocate ( extract(ng) % LonMin(
ngrids) )
225 IF (.not.
allocated(extract(ng) % LonMax)) &
226 &
allocate ( extract(ng) % LonMax(
ngrids) )
228 IF (.not.
allocated(extract(ng) % LatMin)) &
229 &
allocate ( extract(ng) % LatMin(
ngrids) )
231 IF (.not.
allocated(extract(ng) % LatMax)) &
232 &
allocate ( extract(ng) % LatMax(
ngrids) )
236 size2d=real((ubi-lbi+1)*(ubj-lbj+1),r8)
240 allocate ( extract(ng) % angler(lbi:ubi,lbj:ubj) )
243 allocate ( extract(ng) % CosAngler(lbi:ubi,lbj:ubj) )
246 allocate ( extract(ng) % SinAngler(lbi:ubi,lbj:ubj) )
249# if defined CURVGRID && defined UV_ADV
250 allocate ( extract(ng) % dmde(lbi:ubi,lbj:ubj) )
253 allocate ( extract(ng) % dndx(lbi:ubi,lbj:ubj) )
257 allocate ( extract(ng) % f(lbi:ubi,lbj:ubj) )
260 allocate ( extract(ng) % h(lbi:ubi,lbj:ubj) )
263 allocate ( extract(ng) % latp(lbi:ubi,lbj:ubj) )
266 allocate ( extract(ng) % latr(lbi:ubi,lbj:ubj) )
269 allocate ( extract(ng) % latu(lbi:ubi,lbj:ubj) )
272 allocate ( extract(ng) % latv(lbi:ubi,lbj:ubj) )
275 allocate ( extract(ng) % lonp(lbi:ubi,lbj:ubj))
278 allocate ( extract(ng) % lonr(lbi:ubi,lbj:ubj))
281 allocate ( extract(ng) % lonu(lbi:ubi,lbj:ubj))
284 allocate ( extract(ng) % lonv(lbi:ubi,lbj:ubj))
287 allocate ( extract(ng) % Mylon(lbi:ubi,lbj:ubj))
290 allocate ( extract(ng) % pm(lbi:ubi,lbj:ubj) )
293 allocate ( extract(ng) % pn(lbi:ubi,lbj:ubj) )
296 allocate ( extract(ng) % xp(lbi:ubi,lbj:ubj) )
299 allocate ( extract(ng) % xr(lbi:ubi,lbj:ubj) )
302 allocate ( extract(ng) % xu(lbi:ubi,lbj:ubj) )
305 allocate ( extract(ng) % xv(lbi:ubi,lbj:ubj) )
308 allocate ( extract(ng) % yp(lbi:ubi,lbj:ubj) )
311 allocate ( extract(ng) % yr(lbi:ubi,lbj:ubj) )
314 allocate ( extract(ng) % yu(lbi:ubi,lbj:ubj) )
317 allocate ( extract(ng) % yv(lbi:ubi,lbj:ubj) )
321 allocate ( extract(ng) % Hz(lbi:ubi,lbj:ubj,
n(ng)) )
324 allocate ( extract(ng) % z_r(lbi:ubi,lbj:ubj,
n(ng)) )
327 allocate ( extract(ng) % z_v(lbi:ubi,lbj:ubj,
n(ng)) )
330 allocate ( extract(ng) % z_w(lbi:ubi,lbj:ubj,0:
n(ng)) )
331 dmem(ng)=
dmem(ng)+real(
n(ng)+1,r8)*size2d
335 allocate ( extract(ng) % pmask(lbi:ubi,lbj:ubj) )
338 allocate ( extract(ng) % rmask(lbi:ubi,lbj:ubj) )
341 allocate ( extract(ng) % umask(lbi:ubi,lbj:ubj) )
344 allocate ( extract(ng) % vmask(lbi:ubi,lbj:ubj) )
350 IF (extract_flag.ge.1)
THEN
351 my_size=(xtr_iobounds(ng)%IUB_psi-xtr_iobounds(ng)%ILB_psi+1)* &
352 & (xtr_iobounds(ng)%JUB_psi-xtr_iobounds(ng)%JLB_psi+1)
354 allocate ( extract(ng) % Gx_psi(my_size) )
357 allocate ( extract(ng) % Gy_psi(my_size) )
361 allocate ( extract(ng) % Gmask_psi(my_size) )
365 allocate ( extract(ng) % Iout_psi(my_size) )
368 allocate ( extract(ng) % Jout_psi(my_size) )
371 my_size=(xtr_iobounds(ng)%IUB_rho-xtr_iobounds(ng)%ILB_rho+1)* &
372 & (xtr_iobounds(ng)%JUB_rho-xtr_iobounds(ng)%JLB_rho+1)
374 allocate ( extract(ng) % Gx_rho(my_size) )
377 allocate ( extract(ng) % Gy_rho(my_size) )
381 allocate ( extract(ng) % Gmask_rho(my_size) )
385 allocate ( extract(ng) % Iout_rho(my_size) )
388 allocate ( extract(ng) % Jout_rho(my_size) )
391 my_size=(xtr_iobounds(ng)%IUB_u-xtr_iobounds(ng)%ILB_u+1)* &
392 & (xtr_iobounds(ng)%JUB_u-xtr_iobounds(ng)%JLB_u+1)
394 allocate ( extract(ng) % Gx_u(my_size) )
397 allocate ( extract(ng) % Gy_u(my_size) )
401 allocate ( extract(ng) % Gmask_u(my_size) )
405 allocate ( extract(ng) % Iout_u(my_size) )
408 allocate ( extract(ng) % Jout_u(my_size) )
411 my_size=(xtr_iobounds(ng)%IUB_v-xtr_iobounds(ng)%ILB_v+1)* &
412 & (xtr_iobounds(ng)%JUB_v-xtr_iobounds(ng)%JLB_v+1)
414 allocate ( extract(ng) % Gx_v(my_size) )
417 allocate ( extract(ng) % Gy_v(my_size) )
421 allocate ( extract(ng) % Gmask_v(my_size) )
425 allocate ( extract(ng) % Iout_v(my_size) )
428 allocate ( extract(ng) % Jout_v(my_size) )
433 END SUBROUTINE allocate_extract
435 SUBROUTINE deallocate_extract (ng)
445# ifdef SUBOBJECT_DEALLOCATION
451 integer,
intent(in) :: ng
455 character (len=*),
parameter :: MyFile = &
456 & __FILE__//
", deallocate_extract"
458# ifdef SUBOBJECT_DEALLOCATION
467 IF (.not.
destroy(ng, extract(ng)%angler, myfile, &
468 & __line__,
'EXTRACT(ng)%angler'))
RETURN
470 IF (.not.
destroy(ng, extract(ng)%CosAngler, myfile, &
471 & __line__,
'EXTRACT(ng)%CosAngler'))
RETURN
473 IF (.not.
destroy(ng, extract(ng)%SinAngler, myfile, &
474 & __line__,
'EXTRACT(ng)%SinAngler'))
RETURN
476# if defined CURVGRID && defined UV_ADV
477 IF (.not.
destroy(ng, extract(ng)%dmde, myfile, &
478 & __line__,
'EXTRACT(ng)%dmde'))
RETURN
480 IF (.not.
destroy(ng, extract(ng)%dndx, myfile, &
481 & __line__,
'EXTRACT(ng)%dndx'))
RETURN
484 IF (.not.
destroy(ng, extract(ng)%f, myfile, &
485 & __line__,
'EXTRACT(ng)%f'))
RETURN
487 IF (.not.
destroy(ng, extract(ng)%h, myfile, &
488 & __line__,
'EXTRACT(ng)%h'))
RETURN
490 IF (.not.
destroy(ng, extract(ng)%latp, myfile, &
491 & __line__,
'EXTRACT(ng)%latp'))
RETURN
493 IF (.not.
destroy(ng, extract(ng)%latr, myfile, &
494 & __line__,
'EXTRACT(ng)%latr'))
RETURN
496 IF (.not.
destroy(ng, extract(ng)%latu, myfile, &
497 & __line__,
'EXTRACT(ng)%latu'))
RETURN
499 IF (.not.
destroy(ng, extract(ng)%latv, myfile, &
500 & __line__,
'EXTRACT(ng)%latv'))
RETURN
502 IF (.not.
destroy(ng, extract(ng)%lonp, myfile, &
503 & __line__,
'EXTRACT(ng)%lonp'))
RETURN
505 IF (.not.
destroy(ng, extract(ng)%lonr, myfile, &
506 & __line__,
'EXTRACT(ng)%lonr'))
RETURN
508 IF (.not.
destroy(ng, extract(ng)%lonu, myfile, &
509 & __line__,
'EXTRACT(ng)%lonu'))
RETURN
511 IF (.not.
destroy(ng, extract(ng)%lonv, myfile, &
512 & __line__,
'EXTRACT(ng)%lonv'))
RETURN
514 IF (.not.
destroy(ng, extract(ng)%Mylon, myfile, &
515 & __line__,
'EXTRACT(ng)%Mylon'))
RETURN
517 IF (.not.
destroy(ng, extract(ng)%pm, myfile, &
518 & __line__,
'EXTRACT(ng)%pm'))
RETURN
520 IF (.not.
destroy(ng, extract(ng)%pn, myfile, &
521 & __line__,
'EXTRACT(ng)%pn'))
RETURN
524 IF (.not.
destroy(ng, extract(ng)%xp, myfile, &
525 & __line__,
'EXTRACT(ng)%xp'))
RETURN
527 IF (.not.
destroy(ng, extract(ng)%xr, myfile, &
528 & __line__,
'EXTRACT(ng)%xr'))
RETURN
530 IF (.not.
destroy(ng, extract(ng)%xu, myfile, &
531 & __line__,
'EXTRACT(ng)%xu'))
RETURN
533 IF (.not.
destroy(ng, extract(ng)%xv, myfile, &
534 & __line__,
'EXTRACT(ng)%xv'))
RETURN
536 IF (.not.
destroy(ng, extract(ng)%yp, myfile, &
537 & __line__,
'EXTRACT(ng)%yp'))
RETURN
539 IF (.not.
destroy(ng, extract(ng)%yr, myfile, &
540 & __line__,
'EXTRACT(ng)%yr'))
RETURN
542 IF (.not.
destroy(ng, extract(ng)%yu, myfile, &
543 & __line__,
'EXTRACT(ng)%yu'))
RETURN
545 IF (.not.
destroy(ng, extract(ng)%yv, myfile, &
546 & __line__,
'EXTRACT(ng)%yv'))
RETURN
549 IF (.not.
destroy(ng, extract(ng)%Hz, myfile, &
550 & __line__,
'EXTRACT(ng)%Hz'))
RETURN
552 IF (.not.
destroy(ng, extract(ng)%z_r, myfile, &
553 & __line__,
'EXTRACT(ng)%z_r'))
RETURN
555 IF (.not.
destroy(ng, extract(ng)%z_v, myfile, &
556 & __line__,
'GRID(ng)%z_v'))
RETURN
558 IF (.not.
destroy(ng, extract(ng)%z_w, myfile, &
559 & __line__,
'GRID(ng)%z_w'))
RETURN
563 IF (.not.
destroy(ng, extract(ng)%pmask, myfile, &
564 & __line__,
'EXTRACT(ng)%pmask'))
RETURN
566 IF (.not.
destroy(ng, extract(ng)%rmask, myfile, &
567 & __line__,
'EXTRACT(ng)%rmask'))
RETURN
569 IF (.not.
destroy(ng, extract(ng)%umask, myfile, &
570 & __line__,
'EXTRACT(ng)%umask'))
RETURN
572 IF (.not.
destroy(ng, extract(ng)%vmask, myfile, &
573 & __line__,
'EXTRACT(ng)%vmask'))
RETURN
582 IF (
allocated(extract))
deallocate ( extract )
586 END SUBROUTINE deallocate_extract
588 SUBROUTINE initialize_extract (ng, tile, model)
605 integer,
intent(in) :: ng, tile, model
609 integer :: Imin, Imax, Jmin, Jmax
615 real(r8),
parameter :: IniVal = 0.0_r8
616 real(r8) :: IniMetricVal
618# include "set_bounds.h"
623 imin=xtr_bounds(ng)%LBi(tile)
624 imax=xtr_bounds(ng)%UBi(tile)
625 jmin=xtr_bounds(ng)%LBj(tile)
626 jmax=xtr_bounds(ng)%UBj(tile)
628 IF (xtr_domain(ng)%Western_Edge(tile))
THEN
629 imin=xtr_bounds(ng)%LBi(tile)
631 imin=xtr_bounds(ng)%Istr(tile)
633 IF (xtr_domain(ng)%Eastern_Edge(tile))
THEN
634 imax=xtr_bounds(ng)%UBi(tile)
636 imax=xtr_bounds(ng)%Iend(tile)
638 IF (
domain(ng)%Southern_Edge(tile))
THEN
639 jmin=xtr_bounds(ng)%LBj(tile)
641 jmin=xtr_bounds(ng)%Jstr(tile)
643 IF (
domain(ng)%Northern_Edge(tile))
THEN
644 jmax=xtr_bounds(ng)%UBj(tile)
646 jmax=xtr_bounds(ng)%Jend(tile)
667 IF ((model.eq.0).or.(model.eq.
inlm))
THEN
670 extract(ng) % angler(i,j) = inimetricval
671 extract(ng) % CosAngler(i,j) = inival
672 extract(ng) % SinAngler(i,j) = inival
674# if defined CURVGRID && defined UV_ADV
675 extract(ng) % dmde(i,j) = inimetricval
676 extract(ng) % dndx(i,j) = inimetricval
678 extract(ng) % f(i,j) = inimetricval
679 extract(ng) % h(i,j) = inimetricval
681 extract(ng) % latp(i,j) = inival
682 extract(ng) % latr(i,j) = inimetricval
683 extract(ng) % latu(i,j) = inimetricval
684 extract(ng) % latv(i,j) = inimetricval
685 extract(ng) % lonp(i,j) = inival
686 extract(ng) % lonr(i,j) = inimetricval
687 extract(ng) % lonu(i,j) = inimetricval
688 extract(ng) % lonv(i,j) = inimetricval
689 extract(ng) % MyLon(i,j) = inimetricval
691 extract(ng) % pm(i,j) = inimetricval
692 extract(ng) % pn(i,j) = inimetricval
694 extract(ng) % xp(i,j) = inival
695 extract(ng) % xr(i,j) = inimetricval
696 extract(ng) % xu(i,j) = inimetricval
697 extract(ng) % xv(i,j) = inimetricval
698 extract(ng) % yp(i,j) = inival
699 extract(ng) % yr(i,j) = inimetricval
700 extract(ng) % yu(i,j) = inimetricval
701 extract(ng) % yv(i,j) = inimetricval
704 extract(ng) % pmask(i,j) = inival
705 extract(ng) % rmask(i,j) = inimetricval
706 extract(ng) % umask(i,j) = inimetricval
707 extract(ng) % vmask(i,j) = inimetricval
714 extract(ng) % Hz(i,j,k) = inival
715 extract(ng) % z_r(i,j,k) = inival
716 extract(ng) % z_v(i,j,k) = inival
721 extract(ng) % z_w(i,j,k) = inival
729 END SUBROUTINE initialize_extract
integer, dimension(:), allocatable n
real(r8), dimension(:), allocatable dmem
type(t_domain), dimension(:), allocatable domain
real(dp), parameter spval