Changeset 3681 for palm/trunk
- Timestamp:
- Jan 18, 2019 3:06:05 PM (6 years ago)
- Location:
- palm/trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/pmc_interface_mod.f90
r3655 r3681 25 25 ! ----------------- 26 26 ! $Id$ 27 ! Linear interpolations are replaced by first order interpolations. The linear 28 ! interpolation routines are still included but not called. In the child 29 ! inititialization the interpolation is also changed to 1st order and the linear 30 ! interpolation is not kept. 31 ! Subroutine pmci_map_fine_to_coarse_grid is rewritten. 32 ! Several changes in pmci_init_anterp_tophat. 33 ! Child's parent-grid arrays (uc, vc,...) are made non-overlapping on the PE- 34 ! subdomain boundaries in order to allow grid-spacing ratios higher than nbgp. 35 ! Subroutine pmci_init_tkefactor is removed as unnecessary. 36 ! 37 ! 3655 2019-01-07 16:51:22Z knoop 27 38 ! Remove unused variable simulated_time 28 39 ! … … 334 345 335 346 336 USE arrays_3d,&347 USE arrays_3d, & 337 348 ONLY: diss, diss_2, dzu, dzw, e, e_p, e_2, nc, nc_2, nc_p, nr, nr_2, & 338 349 pt, pt_2, q, q_2, qc, qc_2, qr, qr_2, s, s_2, & … … 378 389 USE pegrid, & 379 390 ONLY: collective_wait, comm1dx, comm1dy, comm2d, myid, myidx, myidy, & 380 numprocs, p left, pnorth, pright, psouth, status391 numprocs, pdims, pleft, pnorth, pright, psouth, status 381 392 382 393 USE pmc_child, & … … 446 457 ! 447 458 !-- Geometry 448 REAL(wp), SAVE :: area_t !<449 459 REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC :: coord_x !< 450 460 REAL(wp), SAVE, DIMENSION(:), ALLOCATABLE, PUBLIC :: coord_y !< … … 455 465 !-- Children's parent-grid arrays 456 466 INTEGER(iwp), SAVE, DIMENSION(5), PUBLIC :: coarse_bound !< subdomain index bounds for children's parent-grid arrays 457 INTEGER(iwp), SAVE, DIMENSION(4), PUBLIC :: coarse_bound_anterp !< subdomain index bounds for anterpolation 458 459 REAL(wp), SAVE :: xexl !< 460 REAL(wp), SAVE :: xexr !< 461 REAL(wp), SAVE :: yexs !< 462 REAL(wp), SAVE :: yexn !< 463 REAL(wp), SAVE, DIMENSION(:,:), ALLOCATABLE :: tkefactor_l !< 464 REAL(wp), SAVE, DIMENSION(:,:), ALLOCATABLE :: tkefactor_n !< 465 REAL(wp), SAVE, DIMENSION(:,:), ALLOCATABLE :: tkefactor_r !< 466 REAL(wp), SAVE, DIMENSION(:,:), ALLOCATABLE :: tkefactor_s !< 467 REAL(wp), SAVE, DIMENSION(:,:), ALLOCATABLE :: tkefactor_t !< 467 INTEGER(iwp), SAVE, DIMENSION(4), PUBLIC :: coarse_bound_aux !< subdomain index bounds for allocation of index-mapping and other auxiliary arrays 468 INTEGER(iwp), SAVE, DIMENSION(4), PUBLIC :: coarse_bound_w !< subdomain index bounds for children's parent-grid work arrays 468 469 469 470 REAL(wp), SAVE, DIMENSION(:,:,:), ALLOCATABLE, TARGET :: dissc !< coarse grid array on child domain - dissipation rate … … 493 494 INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) :: kco !< 494 495 INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) :: kcw !< 496 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: celltmpd !< 495 497 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: r1xo !< 496 498 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: r2xo !< … … 505 507 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: r1zw !< 506 508 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: r2zw !< 507 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:) :: celltmpd !< 509 508 510 ! 509 511 !-- Child index arrays and log-ratio arrays for the log-law near-wall … … 547 549 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:,:,:) :: logc_ratio_w_s !< 548 550 ! 549 !-- Upper bounds for k in anterpolation. 550 INTEGER(iwp), SAVE :: kcto !< 551 INTEGER(iwp), SAVE :: kctw !< 551 INTEGER(iwp), SAVE :: igsr !< Integer grid-spacing ratio in i-direction 552 INTEGER(iwp), SAVE :: jgsr !< Integer grid-spacing ratio in j-direction 553 INTEGER(iwp), SAVE :: kgsr !< Integer grid-spacing ratio in k-direction 554 INTEGER(iwp), SAVE :: kcto !< Upper bound for k in anterpolation of variables other than w. 555 INTEGER(iwp), SAVE :: kctw !< Upper bound for k in anterpolation of w. 556 INTEGER(iwp), SAVE :: nxlfc !< Lower index limit in x-direction for fine-to-coarse index mapping and interpolaton coefficient arrays 557 INTEGER(iwp), SAVE :: nxrfc !< Upper index limit in x-direction for fine-to-coarse index mapping and interpolaton coefficient arrays 558 INTEGER(iwp), SAVE :: nynfc !< Upper index limit in y-direction for fine-to-coarse index mapping and interpolaton coefficient arrays 559 INTEGER(iwp), SAVE :: nysfc !< Lower index limit in y-direction for fine-to-coarse index mapping and interpolaton coefficient arrays 552 560 ! 553 561 !-- Upper bound for k in log-law correction in interpolation. … … 556 564 INTEGER(iwp), SAVE :: nzt_topo_nestbc_r !< 557 565 INTEGER(iwp), SAVE :: nzt_topo_nestbc_s !< 558 !559 !-- Number of ghost nodes in coarse-grid arrays for i and j in anterpolation.560 INTEGER(iwp), SAVE :: nhll !<561 INTEGER(iwp), SAVE :: nhlr !<562 INTEGER(iwp), SAVE :: nhls !<563 INTEGER(iwp), SAVE :: nhln !<564 566 ! 565 567 !-- Spatial under-relaxation coefficients for anterpolation. … … 633 635 INTEGER(idp),ALLOCATABLE,DIMENSION(:,:),PUBLIC,TARGET :: nr_part !< 634 636 INTEGER(idp),ALLOCATABLE,DIMENSION(:,:),PUBLIC,TARGET :: part_adr !< 637 638 !AH 639 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarr_lr 640 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarr_sn 641 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarr_t 642 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarrc_lr 643 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarrc_sn 644 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: workarrc_t 645 INTEGER(iwp) :: workarrc_lr_exchange_type 646 INTEGER(iwp) :: workarrc_sn_exchange_type 647 INTEGER(iwp) :: workarrc_t_exchange_type_x 648 INTEGER(iwp) :: workarrc_t_exchange_type_y 649 !AH 635 650 636 651 INTERFACE pmci_boundary_conds … … 914 929 nz_cl = nz 915 930 ! 916 !-- Find the highest nest level in the coarsegrid for the reduced z931 !-- Find the highest nest level in the parent grid for the reduced z 917 932 !-- transfer 918 933 DO k = 1, nz … … 1130 1145 CALL MPI_COMM_SIZE( comm1dy, npy, ierr ) 1131 1146 ! 1132 !-- The +1 in index is because PALM starts with nx=0 1147 !-- Nrx is the same for all PEs and so is nry, thus there is no need to compute 1148 !-- them separately for each PE. 1133 1149 nrx = nxr - nxl + 1 1134 1150 nry = nyn - nys + 1 … … 1139 1155 ! 1140 1156 !-- Area along y required by actual child PE 1141 DO j = coarse_bound_all(3,k), coarse_bound_all(4,k) 1157 DO j = coarse_bound_all(3,k), coarse_bound_all(4,k) !: j = jcs, jcn of PE# k 1142 1158 ! 1143 1159 !-- Area along x required by actual child PE 1144 DO i = coarse_bound_all(1,k), coarse_bound_all(2,k) 1160 DO i = coarse_bound_all(1,k), coarse_bound_all(2,k) !: i = icl, icr of PE# k 1145 1161 1146 1162 px = i / nrx … … 1230 1246 INTEGER(iwp) :: i !< 1231 1247 INTEGER(iwp) :: ierr !< 1232 INTEGER(iwp) :: icl !< left index limit for children's parent-grid arrays 1233 INTEGER(iwp) :: icla !< left index limit for anterpolation 1234 INTEGER(iwp) :: icr !< left index limit for children's parent-grid arrays 1235 INTEGER(iwp) :: icra !< right index limit for anterpolation 1248 INTEGER(iwp) :: icl !< Left index limit for children's parent-grid arrays 1249 INTEGER(iwp) :: icla !< Left index limit for allocation of index-mapping and other auxiliary arrays 1250 INTEGER(iwp) :: iclw !< Left index limit for children's parent-grid work arrays 1251 INTEGER(iwp) :: icr !< Left index limit for children's parent-grid arrays 1252 INTEGER(iwp) :: icra !< Right index limit for allocation of index-mapping and other auxiliary arrays 1253 INTEGER(iwp) :: icrw !< Right index limit for children's parent-grid work arrays 1236 1254 INTEGER(iwp) :: j !< 1237 INTEGER(iwp) :: jcn !< north index limit for children's parent-grid arrays 1238 INTEGER(iwp) :: jcna !< north index limit for anterpolation 1239 INTEGER(iwp) :: jcs !< sout index limit for children's parent-grid arrays 1240 INTEGER(iwp) :: jcsa !< south index limit for anterpolation 1241 INTEGER(iwp) :: n !< running index for number of chemical species 1255 INTEGER(iwp) :: jcn !< North index limit for children's parent-grid arrays 1256 INTEGER(iwp) :: jcna !< North index limit for allocation of index-mapping and other auxiliary arrays 1257 INTEGER(iwp) :: jcnw !< North index limit for children's parent-grid work arrays 1258 INTEGER(iwp) :: jcs !< South index limit for children's parent-grid arrays 1259 INTEGER(iwp) :: jcsa !< South index limit for allocation of index-mapping and other auxiliary arrays 1260 INTEGER(iwp) :: jcsw !< South index limit for children's parent-grid work arrays 1261 INTEGER(iwp) :: n !< Running index for number of chemical species 1242 1262 1243 1263 INTEGER(iwp), DIMENSION(5) :: val !< … … 1441 1461 ENDIF 1442 1462 ! 1443 !-- Define the SGS-TKE scaling factor based on the grid-spacing ratio. Only1444 !-- if both parent and child are in LES mode or in RANS mode.1445 !-- Please note, in case parent and child are in RANS mode, TKE weighting1446 !-- factor is simply one.1447 IF ( ( rans_mode_parent .AND. rans_mode ) .OR. &1448 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. &1449 .NOT. constant_diffusion ) ) CALL pmci_init_tkefactor1450 !1451 1463 !-- Two-way coupling for general and vertical nesting. 1452 1464 !-- Precompute the index arrays and relaxation functions for the … … 1457 1469 !-- included in the interpolation algorithms. 1458 1470 CALL pmci_init_anterp_tophat 1459 !1460 !-- Finally, compute the total area of the top-boundary face of the domain.1461 !-- This is needed in the pmc_ensure_nest_mass_conservation1462 area_t = ( nx + 1 ) * (ny + 1 ) * dx * dy1463 1471 1464 1472 ENDIF … … 1476 1484 INTEGER(iwp), DIMENSION(2) :: size_of_array !< 1477 1485 1478 INTEGER(iwp) :: i !< 1486 INTEGER(iwp) :: i !< 1487 INTEGER(iwp) :: iauxl !< 1488 INTEGER(iwp) :: iauxr !< 1479 1489 INTEGER(iwp) :: ijaux !< 1480 INTEGER(iwp) :: j !< 1490 INTEGER(iwp) :: j !< 1491 INTEGER(iwp) :: jauxs !< 1492 INTEGER(iwp) :: jauxn !< 1481 1493 REAL(wp) :: loffset !< 1482 1494 REAL(wp) :: noffset !< 1483 1495 REAL(wp) :: roffset !< 1484 1496 REAL(wp) :: soffset !< 1485 1486 ! 1487 !-- If the fine- and coarse grid nodes do not match: 1488 loffset = MOD( coord_x(nxl), cg%dx ) 1489 xexl = cg%dx + loffset 1490 ! 1491 !-- This is needed in the anterpolation phase 1492 nhll = CEILING( xexl / cg%dx ) 1493 xcs = coord_x(nxl) - xexl 1494 DO i = 0, cg%nx 1495 IF ( cg%coord_x(i) > xcs ) THEN 1496 icl = MAX( -1, i-1 ) 1497 EXIT 1498 ENDIF 1499 ENDDO 1500 ! 1501 !-- If the fine- and coarse grid nodes do not match 1502 roffset = MOD( coord_x(nxr+1), cg%dx ) 1503 xexr = cg%dx + roffset 1504 ! 1505 !-- This is needed in the anterpolation phase 1506 nhlr = CEILING( xexr / cg%dx ) 1507 xce = coord_x(nxr+1) + xexr 1508 !-- One "extra" layer is taken behind the right boundary 1509 !-- because it may be needed in cases of non-integer grid-spacing ratio 1510 DO i = cg%nx, 0 , -1 1511 IF ( cg%coord_x(i) < xce ) THEN 1512 icr = MIN( cg%nx+1, i+1 ) 1513 EXIT 1514 ENDIF 1515 ENDDO 1516 ! 1517 !-- If the fine- and coarse grid nodes do not match 1518 soffset = MOD( coord_y(nys), cg%dy ) 1519 yexs = cg%dy + soffset 1520 ! 1521 !-- This is needed in the anterpolation phase 1522 nhls = CEILING( yexs / cg%dy ) 1523 ycs = coord_y(nys) - yexs 1524 DO j = 0, cg%ny 1525 IF ( cg%coord_y(j) > ycs ) THEN 1526 jcs = MAX( -nbgp, j-1 ) 1527 EXIT 1528 ENDIF 1529 ENDDO 1530 ! 1531 !-- If the fine- and coarse grid nodes do not match 1532 noffset = MOD( coord_y(nyn+1), cg%dy ) 1533 yexn = cg%dy + noffset 1534 ! 1535 !-- This is needed in the anterpolation phase 1536 nhln = CEILING( yexn / cg%dy ) 1537 yce = coord_y(nyn+1) + yexn 1538 !-- One "extra" layer is taken behind the north boundary 1539 !-- because it may be needed in cases of non-integer grid-spacing ratio 1540 DO j = cg%ny, 0, -1 1541 IF ( cg%coord_y(j) < yce ) THEN 1542 jcn = MIN( cg%ny + nbgp, j+1 ) 1543 EXIT 1544 ENDIF 1545 ENDDO 1546 1547 coarse_bound(1) = icl 1548 coarse_bound(2) = icr 1549 coarse_bound(3) = jcs 1550 coarse_bound(4) = jcn 1551 coarse_bound(5) = myid 1497 REAL(wp) :: xexl !< Parent-grid array exceedance behind the left edge of the child PE subdomain 1498 REAL(wp) :: xexr !< Parent-grid array exceedance behind the right edge of the child PE subdomain 1499 REAL(wp) :: yexs !< Parent-grid array exceedance behind the south edge of the child PE subdomain 1500 REAL(wp) :: yexn !< Parent-grid array exceedance behind the north edge of the child PE subdomain 1501 1502 !AH! 1503 !AH!-- If the fine- and coarse grid nodes do not match: 1504 !AH loffset = MOD( coord_x(nxl), cg%dx ) 1505 !AH xexl = cg%dx + loffset 1506 !AH xcs = coord_x(nxl) - xexl 1507 !AH DO i = 0, cg%nx 1508 !AH IF ( cg%coord_x(i) > xcs ) THEN 1509 !AH icl = MAX( -1, i-1 ) 1510 !AH EXIT 1511 !AH ENDIF 1512 !AH ENDDO 1513 !AH! 1514 !AH!-- If the fine- and coarse grid nodes do not match 1515 !AH roffset = MOD( coord_x(nxr+1), cg%dx ) 1516 !AH xexr = cg%dx + roffset 1517 !AH xce = coord_x(nxr+1) 1518 !AH IF ( nxr == nx ) THEN 1519 !AH xce = xce + xexr 1520 !AH ENDIF 1521 !AH DO i = cg%nx, 0 , -1 1522 !AH IF ( cg%coord_x(i) < xce ) THEN 1523 !AH icr = MIN( cg%nx+1, i+1 ) 1524 !AH EXIT 1525 !AH ENDIF 1526 !AH ENDDO 1527 !AH! 1528 !AH!-- If the fine- and coarse grid nodes do not match 1529 !AH soffset = MOD( coord_y(nys), cg%dy ) 1530 !AH yexs = cg%dy + soffset 1531 !AH ycs = coord_y(nys) - yexs 1532 !AH DO j = 0, cg%ny 1533 !AH IF ( cg%coord_y(j) > ycs ) THEN 1534 !AH jcs = MAX( -nbgp, j-1 ) 1535 !AH EXIT 1536 !AH ENDIF 1537 !AH ENDDO 1538 !AH! 1539 !AH!-- If the fine- and coarse grid nodes do not match 1540 !AH noffset = MOD( coord_y(nyn+1), cg%dy ) 1541 !AH yexn = cg%dy + noffset 1542 !AH yce = coord_y(nyn+1) 1543 !AH IF ( nyn == ny ) THEN 1544 !AH yce = yce + yexn 1545 !AH ENDIF 1546 !AH DO j = cg%ny, 0, -1 1547 !AH IF ( cg%coord_y(j) < yce ) THEN 1548 !AH jcn = MIN( cg%ny + nbgp, j+1 ) 1549 !AH EXIT 1550 !AH ENDIF 1551 !AH ENDDO 1552 !AH 1553 !AH coarse_bound(1) = icl 1554 !AH coarse_bound(2) = icr 1555 !AH coarse_bound(3) = jcs 1556 !AH coarse_bound(4) = jcn 1557 !AH coarse_bound(5) = myid 1552 1558 ! 1553 1559 !-- Determine the anterpolation index limits. If at least half of the … … 1557 1563 !-- anterpolation domain, or not included at all if we are at the outer 1558 1564 !-- edge of the child domain. 1565 1566 ! 1567 !-- Left 1568 IF ( bc_dirichlet_l ) THEN 1569 loffset = MOD( coord_x(nxl), cg%dx ) 1570 xexl = 2 * cg%dx + loffset 1571 iauxl = 0 1572 ELSE 1573 xexl = 0.0_wp 1574 iauxl = 1 1575 ENDIF 1576 xcs = coord_x(nxl) - xexl 1559 1577 DO i = 0, cg%nx 1560 IF ( cg%coord_x(i) + 0.5_wp * cg%dx >= coord_x(nxl)) THEN1561 icl a= MAX( 0, i )1578 IF ( cg%coord_x(i) + 0.5_wp * cg%dx >= xcs ) THEN 1579 icl = MAX( 0, i ) 1562 1580 EXIT 1563 1581 ENDIF 1564 1582 ENDDO 1583 ! 1584 !-- Right 1585 IF ( bc_dirichlet_r ) THEN 1586 roffset = MOD( coord_x(nxr+1), cg%dx ) 1587 xexr = 2 * cg%dx + roffset 1588 iauxr = 0 1589 ELSE 1590 xexr = 0.0_wp 1591 iauxr = 1 1592 ENDIF 1593 xce = coord_x(nxr+1) + xexr 1565 1594 DO i = cg%nx, 0 , -1 1566 IF ( cg%coord_x(i) + 0.5_wp * cg%dx <= coord_x(nxr+1)) THEN1567 icr a= MIN( cg%nx, i )1595 IF ( cg%coord_x(i) + 0.5_wp * cg%dx <= xce ) THEN 1596 icr = MIN( cg%nx, i ) 1568 1597 EXIT 1569 1598 ENDIF 1570 1599 ENDDO 1600 ! 1601 !-- South 1602 IF ( bc_dirichlet_s ) THEN 1603 soffset = MOD( coord_y(nys), cg%dy ) 1604 yexs = 2 * cg%dy + soffset 1605 jauxs = 0 1606 ELSE 1607 yexs = 0.0_wp 1608 jauxs = 1 1609 ENDIF 1610 ycs = coord_y(nys) - yexs 1571 1611 DO j = 0, cg%ny 1572 IF ( cg%coord_y(j) + 0.5_wp * cg%dy >= coord_y(nys)) THEN1573 jcs a= MAX( 0, j )1612 IF ( cg%coord_y(j) + 0.5_wp * cg%dy >= ycs ) THEN 1613 jcs = MAX( 0, j ) 1574 1614 EXIT 1575 1615 ENDIF 1576 1616 ENDDO 1617 ! 1618 !-- North 1619 IF ( bc_dirichlet_n ) THEN 1620 noffset = MOD( coord_y(nyn+1), cg%dy ) 1621 yexn = 2 * cg%dy + noffset 1622 jauxn = 0 1623 ELSE 1624 yexn = 0.0_wp 1625 jauxn = 1 1626 ENDIF 1627 yce = coord_y(nyn+1) + yexn 1577 1628 DO j = cg%ny, 0 , -1 1578 IF ( cg%coord_y(j) + 0.5_wp * cg%dy <= coord_y(nyn+1)) THEN1579 jcn a= MIN( cg%ny, j )1629 IF ( cg%coord_y(j) + 0.5_wp * cg%dy <= yce ) THEN 1630 jcn = MIN( cg%ny, j ) 1580 1631 EXIT 1581 1632 ENDIF 1582 1633 ENDDO 1583 1634 ! 1584 !-- Make sure that the indexing is contiguous 1635 !-- Make sure that the indexing is contiguous (no gaps, no overlaps) 1636 #if defined( __parallel ) 1585 1637 IF ( nxl == 0 ) THEN 1586 CALL MPI_SEND( icr a, 1, MPI_INTEGER, pright, 717, comm2d, ierr )1638 CALL MPI_SEND( icr, 1, MPI_INTEGER, pright, 717, comm2d, ierr ) 1587 1639 ELSE IF ( nxr == nx ) THEN 1588 1640 CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr ) 1589 icl a= ijaux + 11641 icl = ijaux + 1 1590 1642 ELSE 1591 CALL MPI_SEND( icr a, 1, MPI_INTEGER, pright, 717, comm2d, ierr )1643 CALL MPI_SEND( icr, 1, MPI_INTEGER, pright, 717, comm2d, ierr ) 1592 1644 CALL MPI_RECV( ijaux, 1, MPI_INTEGER, pleft, 717, comm2d, status, ierr ) 1593 icl a= ijaux + 11645 icl = ijaux + 1 1594 1646 ENDIF 1595 1647 IF ( nys == 0 ) THEN 1596 CALL MPI_SEND( jcn a, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )1648 CALL MPI_SEND( jcn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr ) 1597 1649 ELSE IF ( nyn == ny ) THEN 1598 1650 CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr ) 1599 jcs a= ijaux + 11651 jcs = ijaux + 1 1600 1652 ELSE 1601 CALL MPI_SEND( jcn a, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr )1653 CALL MPI_SEND( jcn, 1, MPI_INTEGER, pnorth, 719, comm2d, ierr ) 1602 1654 CALL MPI_RECV( ijaux, 1, MPI_INTEGER, psouth, 719, comm2d, status, ierr ) 1603 jcs a= ijaux + 11655 jcs = ijaux + 1 1604 1656 ENDIF 1605 1606 write(9,"('Anterpolation bounds: ',4(i3,2x))") icla, icra, jcsa, jcna 1607 flush(9) 1608 coarse_bound_anterp(1) = icla 1609 coarse_bound_anterp(2) = icra 1610 coarse_bound_anterp(3) = jcsa 1611 coarse_bound_anterp(4) = jcna 1657 #endif 1658 1659 WRITE(9,"('Pmci_map_fine_to_coarse_grid. parent-grid array bounds: ',4(i3,2x))") icl, icr, jcs, jcn 1660 FLUSH(9) 1661 1662 coarse_bound(1) = icl 1663 coarse_bound(2) = icr 1664 coarse_bound(3) = jcs 1665 coarse_bound(4) = jcn 1666 coarse_bound(5) = myid 1667 ! 1668 !-- The following index bounds are used for allocating index mapping and some other auxiliary arrays 1669 coarse_bound_aux(1) = icl - iauxl 1670 coarse_bound_aux(2) = icr + iauxr 1671 coarse_bound_aux(3) = jcs - jauxs 1672 coarse_bound_aux(4) = jcn + jauxn 1612 1673 ! 1613 1674 !-- Note that MPI_Gather receives data from all processes in the rank order … … 1636 1697 IMPLICIT NONE 1637 1698 1638 INTEGER(iwp) :: acsize !< 1639 INTEGER(iwp) :: i !< 1640 INTEGER(iwp) :: j !< 1641 INTEGER(iwp) :: k !< 1642 INTEGER(iwp) :: kc !< 1643 INTEGER(iwp) :: kdzo !< 1644 INTEGER(iwp) :: kdzw !< 1645 1646 REAL(wp) :: dzmin !< 1647 REAL(wp) :: parentdzmax !< 1648 REAL(wp) :: xb !< 1649 REAL(wp) :: xcsu !< 1650 REAL(wp) :: xfso !< 1651 REAL(wp) :: xcso !< 1652 REAL(wp) :: xfsu !< 1653 REAL(wp) :: yb !< 1654 REAL(wp) :: ycso !< 1655 REAL(wp) :: ycsv !< 1656 REAL(wp) :: yfso !< 1657 REAL(wp) :: yfsv !< 1658 REAL(wp) :: zcso !< 1659 REAL(wp) :: zcsw !< 1660 REAL(wp) :: zfso !< 1661 REAL(wp) :: zfsw !< 1699 INTEGER(iwp) :: acsize !< Maximum dimension of anterpolation cell. 1700 INTEGER(iwp) :: i !< Child-grid i-index 1701 INTEGER(iwp) :: ierr !< MPI error code 1702 INTEGER(iwp) :: j !< Child-grid j-index 1703 INTEGER(iwp) :: k !< Child-grid k-index 1704 INTEGER(iwp) :: kc !< 1705 INTEGER(iwp) :: kdzo !< 1706 INTEGER(iwp) :: kdzw !< 1707 INTEGER(iwp) :: moff !< Parent-grid bound offset in j-direction 1708 INTEGER(iwp) :: loff !< Parent-grid bound offset in i-direction 1709 1710 REAL(wp) :: dzmin !< 1711 REAL(wp) :: parentdzmax !< 1712 REAL(wp) :: xb !< 1713 REAL(wp) :: xcsu !< 1714 REAL(wp) :: xfso !< 1715 REAL(wp) :: xcso !< 1716 REAL(wp) :: xfsu !< 1717 REAL(wp) :: yb !< 1718 REAL(wp) :: ycso !< 1719 REAL(wp) :: ycsv !< 1720 REAL(wp) :: yfso !< 1721 REAL(wp) :: yfsv !< 1722 REAL(wp) :: zcso !< 1723 REAL(wp) :: zcsw !< 1724 REAL(wp) :: zfso !< 1725 REAL(wp) :: zfsw !< 1662 1726 1663 1727 1664 xb = nxl * dx 1665 yb = nys * dy 1666 1667 ALLOCATE( icu(nxlg:nxrg) ) 1668 ALLOCATE( ico(nxlg:nxrg) ) 1669 ALLOCATE( jcv(nysg:nyng) ) 1670 ALLOCATE( jco(nysg:nyng) ) 1671 ALLOCATE( kcw(nzb:nzt+1) ) 1672 ALLOCATE( kco(nzb:nzt+1) ) 1673 ALLOCATE( r1xu(nxlg:nxrg) ) 1674 ALLOCATE( r2xu(nxlg:nxrg) ) 1675 ALLOCATE( r1xo(nxlg:nxrg) ) 1676 ALLOCATE( r2xo(nxlg:nxrg) ) 1677 ALLOCATE( r1yv(nysg:nyng) ) 1678 ALLOCATE( r2yv(nysg:nyng) ) 1679 ALLOCATE( r1yo(nysg:nyng) ) 1680 ALLOCATE( r2yo(nysg:nyng) ) 1681 ALLOCATE( r1zw(nzb:nzt+1) ) 1682 ALLOCATE( r2zw(nzb:nzt+1) ) 1683 ALLOCATE( r1zo(nzb:nzt+1) ) 1684 ALLOCATE( r2zo(nzb:nzt+1) ) 1685 ! 1686 !-- Note that the node coordinates xfs... and xcs... are relative to the 1687 !-- lower-left-bottom corner of the fc-array, not the actual child domain 1688 !-- corner 1689 DO i = nxlg, nxrg 1690 xfsu = coord_x(i) - ( lower_left_coord_x + xb - xexl ) 1691 xfso = coord_x(i) + 0.5_wp * dx - ( lower_left_coord_x + xb - xexl ) 1692 icu(i) = icl + FLOOR( xfsu / cg%dx ) 1693 ico(i) = icl + FLOOR( ( xfso - 0.5_wp * cg%dx ) / cg%dx ) 1694 xcsu = ( icu(i) - icl ) * cg%dx 1695 xcso = ( ico(i) - icl ) * cg%dx + 0.5_wp * cg%dx 1728 !AH 1729 ! 1730 !-- Allocate child-grid work arrays for interpolation. 1731 CALL pmci_allocate_finegrid_workarrays 1732 ! 1733 !-- Determine index bounds for the parent-grid work arrays for 1734 !-- interpolation and allocate them. 1735 CALL pmci_allocate_coarsegrid_workarrays 1736 ! 1737 !-- Define the MPI-datatypes for parent-grid work array 1738 !-- exchange between the PE-subdomains. 1739 CALL pmci_create_coarsegrid_workarray_exchange_datatypes 1740 ! 1741 !-- Determine index bounds for the fine-to-coarse grid index mapping arrays 1742 !-- and interpolation-coefficient arrays and allocate them. 1743 CALL pmci_allocate_fine_to_coarse_mapping_arrays 1744 !AH 1745 ! 1746 xb = nxl * dx 1747 IF ( bc_dirichlet_l ) THEN 1748 loff = 2 1749 ELSE 1750 loff = 0 1751 ENDIF 1752 !AH DO i = nxlg, nxrg 1753 DO i = nxl-1, nxr+1 1754 xfsu = coord_x(i) - ( lower_left_coord_x + xb ) 1755 xfso = coord_x(i) + 0.5_wp * dx - ( lower_left_coord_x + xb ) 1756 ! 1757 !-- icl points to 2 parent-grid cells left form the left nest boundary, 1758 !-- thence icl + loff points to the left nest boundary. 1759 icu(i) = icl + loff + FLOOR( xfsu / cg%dx ) 1760 ico(i) = icl + loff + FLOOR( ( xfso - 0.5_wp * cg%dx ) / cg%dx ) 1761 xcsu = ( icu(i) - ( icl + loff ) ) * cg%dx 1762 xcso = ( ico(i) - ( icl + loff ) + 0.5_wp ) * cg%dx 1696 1763 r2xu(i) = ( xfsu - xcsu ) / cg%dx 1697 1764 r2xo(i) = ( xfso - xcso ) / cg%dx … … 1699 1766 r1xo(i) = 1.0_wp - r2xo(i) 1700 1767 ENDDO 1701 1702 DO j = nysg, nyng 1703 yfsv = coord_y(j) - ( lower_left_coord_y + yb - yexs ) 1704 yfso = coord_y(j) + 0.5_wp * dy - ( lower_left_coord_y + yb - yexs ) 1705 jcv(j) = jcs + FLOOR( yfsv / cg%dy ) 1706 jco(j) = jcs + FLOOR( ( yfso -0.5_wp * cg%dy ) / cg%dy ) 1707 ycsv = ( jcv(j) - jcs ) * cg%dy 1708 ycso = ( jco(j) - jcs ) * cg%dy + 0.5_wp * cg%dy 1768 ! 1769 !-- Fill up the values behind nest boundaries by copying from inside 1770 !-- the domain. 1771 IF ( bc_dirichlet_l ) THEN 1772 icu(nxlfc:nxl-1) = icu(nxlfc+igsr:nxl-1+igsr) - 1 1773 r1xu(nxlfc:nxl-1) = r1xu(nxlfc+igsr:nxl-1+igsr) 1774 r2xu(nxlfc:nxl-1) = r2xu(nxlfc+igsr:nxl-1+igsr) 1775 ico(nxlfc:nxl-1) = ico(nxlfc+igsr:nxl-1+igsr) - 1 1776 r1xo(nxlfc:nxl-1) = r1xo(nxlfc+igsr:nxl-1+igsr) 1777 r2xo(nxlfc:nxl-1) = r2xo(nxlfc+igsr:nxl-1+igsr) 1778 ENDIF 1779 1780 IF ( bc_dirichlet_r ) THEN 1781 icu(nxr+1:nxrfc) = icu(nxr+1-igsr:nxrfc-igsr) + 1 1782 r1xu(nxr+1:nxrfc) = r1xu(nxr+1-igsr:nxrfc-igsr) 1783 r2xu(nxr+1:nxrfc) = r2xu(nxr+1-igsr:nxrfc-igsr) 1784 ico(nxr+1:nxrfc) = ico(nxr+1-igsr:nxrfc-igsr) + 1 1785 r1xo(nxr+1:nxrfc) = r1xo(nxr+1-igsr:nxrfc-igsr) 1786 r2xo(nxr+1:nxrfc) = r2xo(nxr+1-igsr:nxrfc-igsr) 1787 ENDIF 1788 ! 1789 !-- Print out the indices and coefficients for checking and debugging purposes 1790 DO i = nxlfc, nxrfc 1791 WRITE(9,"('pmci_init_interp_tril: i, icu, r1xu r2xu ', 2(i4,2x),2(e12.5,2x))") & 1792 i, icu(i), r1xu(i), r2xu(i) 1793 FLUSH(9) 1794 ENDDO 1795 WRITE(9,*) 1796 DO i = nxlfc, nxrfc 1797 WRITE(9,"('pmci_init_interp_tril: i, ico, r1xo r2xo ', 2(i4,2x),2(e12.5,2x))") & 1798 i, ico(i), r1xo(i), r2xo(i) 1799 FLUSH(9) 1800 ENDDO 1801 WRITE(9,*) 1802 1803 yb = nys * dy 1804 IF ( bc_dirichlet_s ) THEN 1805 moff = 2 1806 ELSE 1807 moff = 0 1808 ENDIF 1809 !AH DO j = nysg, nyng 1810 DO j = nys-1, nyn+1 1811 yfsv = coord_y(j) - ( lower_left_coord_y + yb ) 1812 yfso = coord_y(j) + 0.5_wp * dy - ( lower_left_coord_y + yb ) 1813 ! 1814 !-- jcs points to 2 parent-grid cells south form the south nest boundary, 1815 !-- thence jcs + moff points to the south nest boundary. 1816 jcv(j) = jcs + moff + FLOOR( yfsv / cg%dy ) 1817 jco(j) = jcs + moff + FLOOR( ( yfso - 0.5_wp * cg%dy ) / cg%dy ) 1818 ycsv = ( jcv(j) - ( jcs + moff ) ) * cg%dy 1819 ycso = ( jco(j) - ( jcs + moff ) + 0.5_wp ) * cg%dy 1709 1820 r2yv(j) = ( yfsv - ycsv ) / cg%dy 1710 1821 r2yo(j) = ( yfso - ycso ) / cg%dy … … 1712 1823 r1yo(j) = 1.0_wp - r2yo(j) 1713 1824 ENDDO 1825 ! 1826 !-- Fill up the values behind nest boundaries by copying from inside 1827 !-- the domain. 1828 IF ( bc_dirichlet_s ) THEN 1829 jcv(nysfc:nys-1) = jcv(nysfc+jgsr:nys-1+jgsr) - 1 1830 r1yv(nysfc:nys-1) = r1yv(nysfc+jgsr:nys-1+jgsr) 1831 r2yv(nysfc:nys-1) = r2yv(nysfc+jgsr:nys-1+jgsr) 1832 jco(nysfc:nys-1) = jco(nysfc+jgsr:nys-1+jgsr) - 1 1833 r1yo(nysfc:nys-1) = r1yo(nysfc+jgsr:nys-1+jgsr) 1834 r2yo(nysfc:nys-1) = r2yo(nysfc+jgsr:nys-1+jgsr) 1835 ENDIF 1836 1837 IF ( bc_dirichlet_n ) THEN 1838 jcv(nyn+1:nynfc) = jcv(nyn+1-jgsr:nynfc-jgsr) + 1 1839 r1yv(nyn+1:nynfc) = r1yv(nyn+1-jgsr:nynfc-jgsr) 1840 r2yv(nyn+1:nynfc) = r2yv(nyn+1-jgsr:nynfc-jgsr) 1841 jco(nyn+1:nynfc) = jco(nyn+1-jgsr:nynfc-jgsr) + 1 1842 r1yo(nyn+1:nynfc) = r1yo(nyn+1-jgsr:nynfc-jgsr) 1843 r2yo(nyn+1:nynfc) = r2yo(nyn+1-jgsr:nynfc-jgsr) 1844 ENDIF 1845 ! 1846 !-- Print out the indices and coefficients for checking and debugging purposes 1847 DO j = nysfc, nynfc 1848 WRITE(9,"('pmci_init_interp_tril: j, jcv, r1yv r2yv ', 2(i4,2x),2(e12.5,2x))") & 1849 j, jcv(j), r1yv(j), r2yv(j) 1850 FLUSH(9) 1851 ENDDO 1852 WRITE(9,*) 1853 DO j = nysfc, nynfc 1854 WRITE(9,"('pmci_init_interp_tril: j, jco, r1yo r2yo ', 2(i4,2x),2(e12.5,2x))") & 1855 j, jco(j), r1yo(j), r2yo(j) 1856 FLUSH(9) 1857 ENDDO 1858 WRITE(9,*) 1714 1859 1715 1860 DO k = nzb, nzt + 1 … … 1736 1881 r1zo(k) = 1.0_wp - r2zo(k) 1737 1882 ENDDO 1883 ! 1884 !-- Set the interpolation index- and coefficient-information to the 1885 !-- child-grid cells within the uppermost parent-grid cell. This 1886 !-- information is only needed for the reversibility correction. 1887 kco(nzt+2:nzt+kgsr) = kco(nzt+1) + 1 1888 r1zo(nzt+2:nzt+kgsr) = r1zo(nzt+2-kgsr:nzt) 1889 r2zo(nzt+2:nzt+kgsr) = r2zo(nzt+2-kgsr:nzt) 1890 ! 1891 !-- kcw, r1zw and r2zw are not needed when k > nzt+1 1892 kcw(nzt+2:nzt+kgsr) = 0 1893 r1zw(nzt+2:nzt+kgsr) = 0.0_wp 1894 r2zw(nzt+2:nzt+kgsr) = 0.0_wp 1895 ! 1896 !-- Print out the indices and coefficients for checking and debugging purposes 1897 DO k = nzb, nzt+1 1898 WRITE(9,"('pmci_init_interp_tril: k, kcw, r1zw r2zw ', 2(i4,2x),2(e12.5,2x))") & 1899 k, kcw(k), r1zw(k), r2zw(k) 1900 FLUSH(9) 1901 ENDDO 1902 WRITE(9,*) 1903 DO k = nzb, nzt + kgsr 1904 WRITE(9,"('pmci_init_interp_tril: k, kco, r1zo r2zo ', 2(i4,2x),2(e12.5,2x))") & 1905 k, kco(k), r1zo(k), r2zo(k) 1906 FLUSH(9) 1907 ENDDO 1908 WRITE(9,*) 1738 1909 ! 1739 1910 !-- Determine the maximum dimension of anterpolation cells and allocate the … … 1751 1922 CEILING( parentdzmax / dzmin ) 1752 1923 ALLOCATE( celltmpd(1:acsize) ) 1753 ! write(9,"('acsize: ',i3,2(e12.5,2x))") acsize, dzmin, parentdzmax1754 1924 1755 1925 END SUBROUTINE pmci_init_interp_tril 1756 1757 1758 1926 1927 1928 1929 SUBROUTINE pmci_allocate_finegrid_workarrays 1930 ! 1931 !-- Allocate child-grid work-arrays for interpolation 1932 IMPLICIT NONE 1933 1934 1935 igsr = NINT( cg%dx / dx, iwp ) 1936 jgsr = NINT( cg%dy / dy, iwp ) 1937 kgsr = NINT( cg%dzu(cg%nz+1) / dzu(nzt+1), iwp ) 1938 write(9,"('igsr, jgsr, kgsr: ',3(i3,2x))") igsr, jgsr, kgsr 1939 flush(9) 1940 ! 1941 !-- Note that i-indexing for workarr_lr runs from 0 to igsr-1. 1942 !-- For u, only 0-element is used and all elements 0:igsr-1 1943 !-- are used for all other variables. 1944 ALLOCATE( workarr_lr(nzb:nzt+1,nysg:nyng,0:igsr-1) ) 1945 ! 1946 !-- Note that j-indexing for workarr_sn runs from 0 to jgsr-1. 1947 !-- For v, only 0-element is used and all elements 0:jgsr-1 1948 !-- are used for all other variables. 1949 ALLOCATE( workarr_sn(nzb:nzt+1,0:jgsr-1,nxlg:nxrg) ) 1950 ! 1951 !-- Note that genuine k-indexing is used for workarr_t. 1952 !-- Only nzt-element is used for w and elements nzt+1:nzt+kgsr 1953 !-- are used for all other variables. 1954 ALLOCATE( workarr_t(nzt:nzt+kgsr,nysg:nyng,nxlg:nxrg) ) 1955 1956 END SUBROUTINE pmci_allocate_finegrid_workarrays 1957 1958 1959 1960 SUBROUTINE pmci_allocate_coarsegrid_workarrays 1961 ! 1962 !-- Allocate parent-grid work-arrays for interpolation 1963 IMPLICIT NONE 1964 1965 ! 1966 !-- Determine and store the PE-subdomain dependent index bounds 1967 IF ( bc_dirichlet_l ) THEN 1968 iclw = icl + 1 1969 ELSE 1970 iclw = icl - 1 1971 ENDIF 1972 1973 IF ( bc_dirichlet_r ) THEN 1974 icrw = icr - 1 1975 ELSE 1976 icrw = icr + 1 1977 ENDIF 1978 1979 IF ( bc_dirichlet_s ) THEN 1980 jcsw = jcs + 1 1981 ELSE 1982 jcsw = jcs - 1 1983 ENDIF 1984 1985 IF ( bc_dirichlet_n ) THEN 1986 jcnw = jcn - 1 1987 ELSE 1988 jcnw = jcn + 1 1989 ENDIF 1990 1991 coarse_bound_w(1) = iclw 1992 coarse_bound_w(2) = icrw 1993 coarse_bound_w(3) = jcsw 1994 coarse_bound_w(4) = jcnw 1995 ! 1996 !-- Left and right boundaries. 1997 ALLOCATE( workarrc_lr(0:cg%nz+1,jcsw:jcnw,0:2) ) 1998 ! 1999 !-- South and north boundaries. 2000 ALLOCATE( workarrc_sn(0:cg%nz+1,0:2,iclw:icrw) ) 2001 ! 2002 !-- Top boundary. 2003 ALLOCATE( workarrc_t(0:2,jcsw:jcnw,iclw:icrw) ) 2004 2005 END SUBROUTINE pmci_allocate_coarsegrid_workarrays 2006 2007 2008 2009 SUBROUTINE pmci_create_coarsegrid_workarray_exchange_datatypes 2010 ! 2011 !-- Define specific MPI types for workarrc-exhchange. 2012 IMPLICIT NONE 2013 2014 #if defined( __parallel ) 2015 ! 2016 !-- For the left and right boundaries 2017 CALL MPI_TYPE_VECTOR( 3, cg%nz+2, (jcnw-jcsw+1)*(cg%nz+2), MPI_REAL, & 2018 workarrc_lr_exchange_type, ierr ) 2019 CALL MPI_TYPE_COMMIT( workarrc_lr_exchange_type, ierr ) 2020 ! 2021 !-- For the south and north boundaries 2022 CALL MPI_TYPE_VECTOR( 1, 3*(cg%nz+2), 3*(cg%nz+2), MPI_REAL, & 2023 workarrc_sn_exchange_type, ierr ) 2024 CALL MPI_TYPE_COMMIT( workarrc_sn_exchange_type, ierr ) 2025 ! 2026 !-- For the top-boundary x-slices 2027 CALL MPI_TYPE_VECTOR( icrw-iclw+1, 3, 3*(jcnw-jcsw+1), MPI_REAL, & 2028 workarrc_t_exchange_type_x, ierr ) 2029 CALL MPI_TYPE_COMMIT( workarrc_t_exchange_type_x, ierr ) 2030 ! 2031 !-- For the top-boundary y-slices 2032 CALL MPI_TYPE_VECTOR( 1, 3*(jcnw-jcsw+1), 3*(jcnw-jcsw+1), MPI_REAL, & 2033 workarrc_t_exchange_type_y, ierr ) 2034 CALL MPI_TYPE_COMMIT( workarrc_t_exchange_type_y, ierr ) 2035 #endif 2036 2037 END SUBROUTINE pmci_create_coarsegrid_workarray_exchange_datatypes 2038 2039 2040 2041 SUBROUTINE pmci_allocate_fine_to_coarse_mapping_arrays 2042 ! 2043 !-- Define index limits and allocate the fine-to-coarse grid index mapping 2044 !-- arrays and interpolation coefficient arrays. 2045 IMPLICIT NONE 2046 2047 2048 IF ( bc_dirichlet_l ) THEN 2049 !AH nxlfc = MIN( nxl-igsr, nxlg ) 2050 nxlfc = nxl - igsr 2051 ELSE 2052 !AH nxlfc = nxlg 2053 nxlfc = nxl - 1 2054 ENDIF 2055 IF ( bc_dirichlet_r ) THEN 2056 !AH nxrfc = MAX( nxr+igsr, nxrg ) 2057 nxrfc = nxr + igsr 2058 ELSE 2059 !AH nxrfc = nxrg 2060 nxrfc = nxr + 1 2061 ENDIF 2062 2063 IF ( bc_dirichlet_s ) THEN 2064 !AH nysfc = MIN( nys-jgsr, nysg ) 2065 nysfc = nys - jgsr 2066 ELSE 2067 !AH nysfc = nysg 2068 nysfc = nys - 1 2069 ENDIF 2070 IF ( bc_dirichlet_n ) THEN 2071 !AH nynfc = MAX( nyn+jgsr, nyng ) 2072 nynfc = nyn + jgsr 2073 ELSE 2074 !AH nynfc = nyng 2075 nynfc = nyn + 1 2076 ENDIF 2077 2078 ALLOCATE( icu(nxlfc:nxrfc) ) 2079 ALLOCATE( ico(nxlfc:nxrfc) ) 2080 ALLOCATE( jcv(nysfc:nynfc) ) 2081 ALLOCATE( jco(nysfc:nynfc) ) 2082 ALLOCATE( kcw(nzb:nzt+kgsr) ) 2083 ALLOCATE( kco(nzb:nzt+kgsr) ) 2084 2085 ALLOCATE( r1xu(nxlfc:nxrfc) ) 2086 ALLOCATE( r2xu(nxlfc:nxrfc) ) 2087 ALLOCATE( r1xo(nxlfc:nxrfc) ) 2088 ALLOCATE( r2xo(nxlfc:nxrfc) ) 2089 ALLOCATE( r1yv(nysfc:nynfc) ) 2090 ALLOCATE( r2yv(nysfc:nynfc) ) 2091 ALLOCATE( r1yo(nysfc:nynfc) ) 2092 ALLOCATE( r2yo(nysfc:nynfc) ) 2093 ALLOCATE( r1zw(nzb:nzt+kgsr) ) 2094 ALLOCATE( r2zw(nzb:nzt+kgsr) ) 2095 ALLOCATE( r1zo(nzb:nzt+kgsr) ) 2096 ALLOCATE( r2zo(nzb:nzt+kgsr) ) 2097 2098 END SUBROUTINE pmci_allocate_fine_to_coarse_mapping_arrays 2099 2100 2101 1759 2102 SUBROUTINE pmci_init_loglaw_correction 1760 2103 ! … … 3092 3435 INTEGER(iwp) :: istart !< 3093 3436 INTEGER(iwp) :: ir !< 3437 INTEGER(iwp) :: iw !< Fine-grid index limited to -1 <= iw <= nx+1 3094 3438 INTEGER(iwp) :: j !< Fine-grid index 3095 3439 INTEGER(iwp) :: jj !< Coarse-grid index 3096 3440 INTEGER(iwp) :: jstart !< 3097 3441 INTEGER(iwp) :: jr !< 3442 INTEGER(iwp) :: jw !< Fine-grid index limited to -1 <= jw <= ny+1 3098 3443 INTEGER(iwp) :: k !< Fine-grid index 3099 3444 INTEGER(iwp) :: kk !< Coarse-grid index 3100 3445 INTEGER(iwp) :: kstart !< 3446 INTEGER(iwp) :: kw !< Fine-grid index limited to kw <= nzt+1 3101 3447 REAL(wp) :: xi !< 3102 3448 REAL(wp) :: eta !< … … 3122 3468 ENDIF 3123 3469 ! 3124 !-- First determine kcto and kctw that are the coarse-grid upper bounds for3125 !-- index k3470 !-- First determine kcto and kctw which refer to the uppermost 3471 !-- coarse-grid levels below the child top-boundary level. 3126 3472 kk = 0 3127 3473 DO WHILE ( cg%zu(kk) <= zu(nzt) ) … … 3135 3481 ENDDO 3136 3482 kctw = kk - 1 3137 3138 ALLOCATE( iflu(icl:icr) ) 3139 ALLOCATE( iflo(icl:icr) ) 3140 ALLOCATE( ifuu(icl:icr) ) 3141 ALLOCATE( ifuo(icl:icr) ) 3142 ALLOCATE( jflv(jcs:jcn) ) 3143 ALLOCATE( jflo(jcs:jcn) ) 3144 ALLOCATE( jfuv(jcs:jcn) ) 3145 ALLOCATE( jfuo(jcs:jcn) ) 3483 !AH 3484 write(9,"('kcto, kctw = ', 2(i3,2x))") kcto, kctw 3485 3486 !AH 3487 ! ALLOCATE( iflu(icl:icr) ) 3488 ! ALLOCATE( iflo(icl:icr) ) 3489 ! ALLOCATE( ifuu(icl:icr) ) 3490 ! ALLOCATE( ifuo(icl:icr) ) 3491 ! ALLOCATE( jflv(jcs:jcn) ) 3492 ! ALLOCATE( jflo(jcs:jcn) ) 3493 ! ALLOCATE( jfuv(jcs:jcn) ) 3494 ! ALLOCATE( jfuo(jcs:jcn) ) 3495 ! 3496 ! ALLOCATE( iflu(icl-1:icr+1) ) 3497 ! ALLOCATE( iflo(icl-1:icr+1) ) 3498 ! ALLOCATE( ifuu(icl-1:icr+1) ) 3499 ! ALLOCATE( ifuo(icl-1:icr+1) ) 3500 ! ALLOCATE( jflv(jcs-1:jcn+1) ) 3501 ! ALLOCATE( jflo(jcs-1:jcn+1) ) 3502 ! ALLOCATE( jfuv(jcs-1:jcn+1) ) 3503 ! ALLOCATE( jfuo(jcs-1:jcn+1) ) 3504 ! 3505 icla = coarse_bound_aux(1) 3506 icra = coarse_bound_aux(2) 3507 jcsa = coarse_bound_aux(3) 3508 jcna = coarse_bound_aux(4) 3509 ALLOCATE( iflu(icla:icra) ) 3510 ALLOCATE( iflo(icla:icra) ) 3511 ALLOCATE( ifuu(icla:icra) ) 3512 ALLOCATE( ifuo(icla:icra) ) 3513 ALLOCATE( jflv(jcsa:jcna) ) 3514 ALLOCATE( jflo(jcsa:jcna) ) 3515 ALLOCATE( jfuv(jcsa:jcna) ) 3516 ALLOCATE( jfuo(jcsa:jcna) ) 3517 !AH 3146 3518 ALLOCATE( kflw(0:cg%nz+1) ) 3147 3519 ALLOCATE( kflo(0:cg%nz+1) ) 3148 3520 ALLOCATE( kfuw(0:cg%nz+1) ) 3149 3521 ALLOCATE( kfuo(0:cg%nz+1) ) 3150 3151 ALLOCATE( ijkfc_u(0:cg%nz+1,jcs:jcn,icl:icr) ) 3152 ALLOCATE( ijkfc_v(0:cg%nz+1,jcs:jcn,icl:icr) ) 3153 ALLOCATE( ijkfc_w(0:cg%nz+1,jcs:jcn,icl:icr) ) 3154 ALLOCATE( ijkfc_s(0:cg%nz+1,jcs:jcn,icl:icr) ) 3522 !AH 3523 ! ALLOCATE( ijkfc_u(0:cg%nz+1,jcs:jcn,icl:icr) ) 3524 ! ALLOCATE( ijkfc_v(0:cg%nz+1,jcs:jcn,icl:icr) ) 3525 ! ALLOCATE( ijkfc_w(0:cg%nz+1,jcs:jcn,icl:icr) ) 3526 ! ALLOCATE( ijkfc_s(0:cg%nz+1,jcs:jcn,icl:icr) ) 3527 ! 3528 ! ALLOCATE( ijkfc_u(0:cg%nz+1,jcs-1:jcn+1,icl-1:icr+1) ) 3529 ! ALLOCATE( ijkfc_v(0:cg%nz+1,jcs-1:jcn+1,icl-1:icr+1) ) 3530 ! ALLOCATE( ijkfc_w(0:cg%nz+1,jcs-1:jcn+1,icl-1:icr+1) ) 3531 ! ALLOCATE( ijkfc_s(0:cg%nz+1,jcs-1:jcn+1,icl-1:icr+1) ) 3532 ! 3533 ALLOCATE( ijkfc_u(0:cg%nz+1,jcsa:jcna,icla:icra) ) 3534 ALLOCATE( ijkfc_v(0:cg%nz+1,jcsa:jcna,icla:icra) ) 3535 ALLOCATE( ijkfc_w(0:cg%nz+1,jcsa:jcna,icla:icra) ) 3536 ALLOCATE( ijkfc_s(0:cg%nz+1,jcsa:jcna,icla:icra) ) 3537 !AH 3155 3538 3156 3539 ijkfc_u = 0 … … 3163 3546 tolerance = 0.000001_wp * dx 3164 3547 istart = nxlg 3165 DO ii = icl, icr-1 3548 !AH DO ii = icl, icr 3549 !AH DO ii = icl-1, icr+1 3550 DO ii = icla, icra 3551 3166 3552 ! 3167 3553 !-- In case the child and parent grid lines match in x … … 3196 3582 istart = iflu(ii) 3197 3583 ENDIF 3198 !AH 3584 ! 3585 !-- Print out the index bounds for checking and debugging purposes 3199 3586 write(9,"('pmci_init_anterp_tophat, ii, iflu, ifuu: ', 3(i4,2x))") & 3200 3587 ii, iflu(ii), ifuu(ii) … … 3202 3589 3203 3590 ENDDO 3204 iflu(icr) = nxrg 3205 ifuu(icr) = nxrg 3591 write(9,*) 3206 3592 ! 3207 3593 !-- i-indices of others for each ii-index value 3208 3594 !-- ii=icr is redundant for anterpolation 3209 3595 istart = nxlg 3210 DO ii = icl, icr-1 3596 !AH DO ii = icl, icr 3597 !AH DO ii = icl-1, icr+1 3598 DO ii = icla, icra 3211 3599 i = istart 3212 3600 DO WHILE ( ( coord_x(i) + 0.5_wp * dx < cg%coord_x(ii) ) .AND. & … … 3223 3611 ifuo(ii) = MIN( MAX( i-1, iflo(ii) ), nxrg ) 3224 3612 istart = iflo(ii) 3613 ! 3614 !-- Print out the index bounds for checking and debugging purposes 3615 write(9,"('pmci_init_anterp_tophat, ii, iflo, ifuo: ', 3(i4,2x))") & 3616 ii, iflo(ii), ifuo(ii) 3617 flush(9) 3225 3618 ENDDO 3226 !AH 3227 write(9,"('pmci_init_anterp_tophat, ii, iflo, ifuo: ', 3(i4,2x))") & 3228 ii, iflo(ii), ifuo(ii) 3229 flush(9) 3230 3231 iflo(icr) = nxrg 3232 ifuo(icr) = nxrg 3619 write(9,*) 3233 3620 ! 3234 3621 !-- j-indices of v for each jj-index value … … 3236 3623 tolerance = 0.000001_wp * dy 3237 3624 jstart = nysg 3238 DO jj = jcs, jcn-1 3625 !AH DO jj = jcs, jcn 3626 !AH DO jj = jcs-1, jcn+1 3627 DO jj = jcsa, jcna 3239 3628 ! 3240 3629 !-- In case the child and parent grid lines match in y … … 3269 3658 jstart = jflv(jj) 3270 3659 ENDIF 3271 !AH 3660 ! 3661 !-- Print out the index bounds for checking and debugging purposes 3272 3662 write(9,"('pmci_init_anterp_tophat, jj, jflv, jfuv: ', 3(i4,2x))") & 3273 3663 jj, jflv(jj), jfuv(jj) 3274 3664 flush(9) 3275 3276 3665 ENDDO 3277 jflv(jcn) = nyng 3278 jfuv(jcn) = nyng 3666 write(9,*) 3279 3667 ! 3280 3668 !-- j-indices of others for each jj-index value 3281 3669 !-- jj=jcn is redundant for anterpolation 3282 3670 jstart = nysg 3283 DO jj = jcs, jcn-1 3671 !AH DO jj = jcs, jcn 3672 !AH DO jj = jcs-1, jcn+1 3673 DO jj = jcsa, jcna 3284 3674 j = jstart 3285 3675 DO WHILE ( ( coord_y(j) + 0.5_wp * dy < cg%coord_y(jj) ) .AND. & … … 3296 3686 jfuo(jj) = MIN( MAX( j-1, jflo(jj) ), nyng ) 3297 3687 jstart = jflo(jj) 3298 !AH 3299 write(9,"('pmci_init_anterp_tophat, ii, jflo, jfuo: ', 3(i4,2x))") & 3688 ! 3689 !-- Print out the index bounds for checking and debugging purposes 3690 write(9,"('pmci_init_anterp_tophat, jj, jflo, jfuo: ', 3(i4,2x))") & 3300 3691 jj, jflo(jj), jfuo(jj) 3301 3692 flush(9) 3302 3303 3693 ENDDO 3304 jflo(jcn) = nyng 3305 jfuo(jcn) = nyng 3694 write(9,*) 3306 3695 ! 3307 3696 !-- k-indices of w for each kk-index value … … 3347 3736 ENDIF 3348 3737 !AH 3349 write(9,"('pmci_init_anterp_tophat, kk, kflw, kfuw: ', 3(i4,2x))") &3350 kk, kflw(kk), kfuw(kk) 3738 write(9,"('pmci_init_anterp_tophat, kk, kflw, kfuw: ', 4(i4,2x), 2(e12.5,2x))") & 3739 kk, kflw(kk), kfuw(kk), nzt, cg%zu(kk), cg%zw(kk) 3351 3740 flush(9) 3352 3353 3741 ENDDO 3742 write(9,*) 3354 3743 ! 3355 3744 !-- k-indices of others for each kk-index value … … 3360 3749 !-- Note that anterpolation index limits are needed also for the top boundary 3361 3750 !-- ghost cell level because of the reversibility correction in the interpolation. 3362 !AH DO kk = 1, kcto+13363 3751 DO kk = 1, cg%nz+1 3364 3752 k = kstart 3365 !AH DO WHILE ( ( zu(k) < cg%zw(kk-1) ) .AND. ( k < nzt ) )3366 !-- Note that this is an IMPORTANT correction for the reversibility correction3367 3753 DO WHILE ( ( zu(k) < cg%zw(kk-1) ) .AND. ( k <= nzt ) ) 3368 3754 k = k + 1 3369 3755 ENDDO 3370 3756 kflo(kk) = MIN( MAX( k, 1 ), nzt + 1 ) 3371 !AH DO WHILE ( ( zu(k) <= cg%zw(kk) ) .AND. ( k < nzt+1 ) )3372 !-- Note that this is an IMPORTANT correction for the reversibility correction3373 3757 DO WHILE ( ( zu(k) <= cg%zw(kk) ) .AND. ( k <= nzt+1 ) ) 3374 3758 k = k + 1 … … 3377 3761 kfuo(kk) = MIN( MAX( k-1, kflo(kk) ), nzt + 1 ) 3378 3762 kstart = kflo(kk) 3379 !AH 3380 write(9,"('init kflo, kfuo: ', 4(i3,2x), e12.5)") kk, kflo(kk), kfuo(kk), nzt, cg%zw(kk) 3763 ENDDO 3764 ! 3765 !-- Set the k-index bounds separately for the parent-grid cells cg%nz and cg%nz+1. 3766 !-- Index bounds for cg%nz are needed for the reversibility correction. 3767 kflo(cg%nz) = nzt+1 ! Needed for the reversibility correction 3768 kfuo(cg%nz) = nzt+kgsr ! Needed for the reversibility correction 3769 kflo(cg%nz+1) = nzt+kgsr ! Obsolete 3770 kfuo(cg%nz+1) = nzt+kgsr ! Obsolete 3771 3772 DO kk = 1, cg%nz+1 3773 write(9,"('pmci_init_anterp_tophat, kk, kflo, kfuo: ', 4(i4,2x), 2(e12.5,2x))") & 3774 kk, kflo(kk), kfuo(kk), nzt, cg%zu(kk), cg%zw(kk) 3381 3775 flush(9) 3382 3776 ENDDO 3777 write(9,*) 3778 !AH 3779 3383 3780 ! 3384 3781 !-- Precomputation of number of fine-grid nodes inside parent-grid cells. 3385 3782 !-- Note that ii, jj, and kk are parent-grid indices. 3386 !-- This information is needed in anterpolation. 3387 DO ii = icl, icr 3388 DO jj = jcs, jcn 3389 !AH DO kk = 0, kcto+1 3783 !-- This information is needed in anterpolation and in reversibility 3784 !-- correction in interpolation. For the reversibility correction, ijkfc- 3785 !-- information is needed also beyond the indices for wall_flags_0-masking 3786 !-- must be modified here in the boundary-normal direction (iw, jw, kw). 3787 !AH DO ii = icl, icr 3788 !AH DO jj = jcs, jcn 3789 !AH DO ii = icl-1, icr+1 3790 !AH DO jj = jcs-1, jcn+1 3791 DO ii = icla, icra 3792 DO jj = jcsa, jcna 3390 3793 DO kk = 0, cg%nz+1 3391 3794 ! 3392 3795 !-- u-component 3393 3796 DO i = iflu(ii), ifuu(ii) 3797 iw = MAX( MIN( i, nx+1 ), -1 ) 3394 3798 DO j = jflo(jj), jfuo(jj) 3799 jw = MAX( MIN( j, ny+1 ), -1 ) 3395 3800 DO k = kflo(kk), kfuo(kk) 3396 ijkfc_u(kk,jj,ii) = ijkfc_u(kk,jj,ii) + MERGE( 1, 0, & 3397 BTEST( wall_flags_0(k,j,i), 1 ) ) 3801 kw = MIN( k, nzt+1 ) 3802 ijkfc_u(kk,jj,ii) = ijkfc_u(kk,jj,ii) & 3803 + MERGE( 1, 0, BTEST( wall_flags_0(kw,jw,iw), 1 ) ) 3398 3804 ENDDO 3399 3805 ENDDO … … 3402 3808 !-- v-component 3403 3809 DO i = iflo(ii), ifuo(ii) 3810 iw = MAX( MIN( i, nx+1 ), -1 ) 3404 3811 DO j = jflv(jj), jfuv(jj) 3812 jw = MAX( MIN( j, ny+1 ), -1 ) 3405 3813 DO k = kflo(kk), kfuo(kk) 3406 ijkfc_v(kk,jj,ii) = ijkfc_v(kk,jj,ii) + MERGE( 1, 0, & 3407 BTEST( wall_flags_0(k,j,i), 2 ) ) 3814 kw = MIN( k, nzt+1 ) 3815 ijkfc_v(kk,jj,ii) = ijkfc_v(kk,jj,ii) & 3816 + MERGE( 1, 0, BTEST( wall_flags_0(kw,jw,iw), 2 ) ) 3408 3817 ENDDO 3409 3818 ENDDO … … 3412 3821 !-- scalars 3413 3822 DO i = iflo(ii), ifuo(ii) 3823 iw = MAX( MIN( i, nx+1 ), -1 ) 3414 3824 DO j = jflo(jj), jfuo(jj) 3825 jw = MAX( MIN( j, ny+1 ), -1 ) 3415 3826 DO k = kflo(kk), kfuo(kk) 3416 ijkfc_s(kk,jj,ii) = ijkfc_s(kk,jj,ii) + MERGE( 1, 0, & 3417 BTEST( wall_flags_0(k,j,i), 0 ) ) 3827 kw = MIN( k, nzt+1 ) 3828 ijkfc_s(kk,jj,ii) = ijkfc_s(kk,jj,ii) & 3829 + MERGE( 1, 0, BTEST( wall_flags_0(kw,jw,iw), 0 ) ) 3418 3830 ENDDO 3419 3831 ENDDO 3420 3832 ENDDO 3421 ENDDO3422 3423 !AH DO kk = 0, kctw+13424 DO kk = 0, cg%nz+13425 3833 ! 3426 3834 !-- w-component 3427 3835 DO i = iflo(ii), ifuo(ii) 3836 iw = MAX( MIN( i, nx+1 ), -1 ) 3428 3837 DO j = jflo(jj), jfuo(jj) 3838 jw = MAX( MIN( j, ny+1 ), -1 ) 3429 3839 DO k = kflw(kk), kfuw(kk) 3430 ijkfc_w(kk,jj,ii) = ijkfc_w(kk,jj,ii) + MERGE( 1, 0, & 3431 BTEST( wall_flags_0(k,j,i), 3 ) ) 3840 kw = MIN( k, nzt+1 ) 3841 ijkfc_w(kk,jj,ii) = ijkfc_w(kk,jj,ii) + MERGE( 1, 0, & 3842 BTEST( wall_flags_0(kw,jw,iw), 3 ) ) 3432 3843 ENDDO 3433 3844 ENDDO 3434 3845 ENDDO 3435 ENDDO 3436 3437 ENDDO 3438 ENDDO 3846 3847 ENDDO ! kk 3848 ENDDO ! jj 3849 ENDDO ! ii 3439 3850 ! 3440 3851 !-- Spatial under-relaxation coefficients … … 3445 3856 fray(jcs:jcn) = 1.0_wp 3446 3857 3447 IF ( nesting_mode /= 'vertical' ) THEN3448 DO ii = icl, icr3449 IF ( ifuu(ii) < ( nx + 1 ) / 2 ) THEN3450 xi = ( MAX( 0.0_wp, ( cg%coord_x(ii) - &3451 lower_left_coord_x ) ) / anterp_relax_length_l )**43452 frax(ii) = xi / ( 1.0_wp + xi )3453 ELSE3454 xi = ( MAX( 0.0_wp, ( lower_left_coord_x + ( nx + 1 ) * dx - &3455 cg%coord_x(ii) ) ) / &3456 anterp_relax_length_r )**43457 frax(ii) = xi / ( 1.0_wp + xi )3458 ENDIF3459 ENDDO3460 3461 DO jj = jcs, jcn3462 IF ( jfuv(jj) < ( ny + 1 ) / 2 ) THEN3463 eta = ( MAX( 0.0_wp, ( cg%coord_y(jj) - &3464 lower_left_coord_y ) ) / anterp_relax_length_s )**43465 fray(jj) = eta / ( 1.0_wp + eta )3466 ELSE3467 eta = ( MAX( 0.0_wp, ( lower_left_coord_y + ( ny + 1 ) * dy - &3468 cg%coord_y(jj)) ) / &3469 anterp_relax_length_n )**43470 fray(jj) = eta / ( 1.0_wp + eta )3471 ENDIF3472 ENDDO3473 ENDIF3858 !AH IF ( nesting_mode /= 'vertical' ) THEN 3859 !AH DO ii = icl, icr 3860 !AH IF ( ifuu(ii) < ( nx + 1 ) / 2 ) THEN 3861 !AH xi = ( MAX( 0.0_wp, ( cg%coord_x(ii) - & 3862 !AH lower_left_coord_x ) ) / anterp_relax_length_l )**4 3863 !AH frax(ii) = xi / ( 1.0_wp + xi ) 3864 !AH ELSE 3865 !AH xi = ( MAX( 0.0_wp, ( lower_left_coord_x + ( nx + 1 ) * dx - & 3866 !AH cg%coord_x(ii) ) ) / & 3867 !AH anterp_relax_length_r )**4 3868 !AH frax(ii) = xi / ( 1.0_wp + xi ) 3869 !AH ENDIF 3870 !AH ENDDO 3871 !AH 3872 !AH DO jj = jcs, jcn 3873 !AH IF ( jfuv(jj) < ( ny + 1 ) / 2 ) THEN 3874 !AH eta = ( MAX( 0.0_wp, ( cg%coord_y(jj) - & 3875 !AH lower_left_coord_y ) ) / anterp_relax_length_s )**4 3876 !AH fray(jj) = eta / ( 1.0_wp + eta ) 3877 !AH ELSE 3878 !AH eta = ( MAX( 0.0_wp, ( lower_left_coord_y + ( ny + 1 ) * dy - & 3879 !AH cg%coord_y(jj)) ) / & 3880 !AH anterp_relax_length_n )**4 3881 !AH fray(jj) = eta / ( 1.0_wp + eta ) 3882 !AH ENDIF 3883 !AH ENDDO 3884 !AH ENDIF 3474 3885 3475 3886 ALLOCATE( fraz(0:kcto) ) 3476 DO kk = 0, kcto 3477 zeta = ( ( zu(nzt) - cg%zu(kk) ) / anterp_relax_length_t )**4 3478 fraz(kk) = zeta / ( 1.0_wp + zeta ) 3479 ENDDO 3887 fraz(0:kcto) = 1.0_wp 3888 !AH DO kk = 0, kcto 3889 !AH zeta = ( ( zu(nzt) - cg%zu(kk) ) / anterp_relax_length_t )**4 3890 !AH fraz(kk) = zeta / ( 1.0_wp + zeta ) 3891 !AH ENDDO 3480 3892 3481 3893 END SUBROUTINE pmci_init_anterp_tophat 3482 3483 3484 3485 SUBROUTINE pmci_init_tkefactor3486 3487 !3488 !-- Computes the scaling factor for the SGS TKE from coarse grid to be used3489 !-- as BC for the fine grid. Based on the Kolmogorov energy spectrum3490 !-- for the inertial subrange and assumption of sharp cut-off of the resolved3491 !-- energy spectrum. Near the surface, the reduction of TKE is made3492 !-- smaller than further away from the surface.3493 !-- Please note, in case parent and child model operate in RANS mode,3494 !-- TKE is not grid depenedent and weighting factor is one.3495 3496 IMPLICIT NONE3497 3498 INTEGER(iwp) :: k !< index variable along z3499 INTEGER(iwp) :: k_wall !< topography-top index along z3500 INTEGER(iwp) :: kc !<3501 3502 REAL(wp), PARAMETER :: cfw = 0.2_wp !<3503 REAL(wp), PARAMETER :: c_tkef = 0.6_wp !<3504 REAL(wp) :: fw !<3505 REAL(wp), PARAMETER :: fw0 = 0.9_wp !<3506 REAL(wp) :: glsf !<3507 REAL(wp) :: glsc !<3508 REAL(wp) :: height !<3509 REAL(wp), PARAMETER :: p13 = 1.0_wp/3.0_wp !<3510 REAL(wp), PARAMETER :: p23 = 2.0_wp/3.0_wp !<3511 3512 !3513 IF ( .NOT. rans_mode .AND. .NOT. rans_mode_parent ) THEN3514 IF ( bc_dirichlet_l ) THEN3515 ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )3516 tkefactor_l = 0.0_wp3517 i = nxl - 13518 DO j = nysg, nyng3519 k_wall = get_topography_top_index_ji( j, i, 's' )3520 3521 DO k = k_wall + 1, nzt3522 kc = kco(k) + 13523 glsf = ( dx * dy * dzu(k) )**p133524 glsc = ( cg%dx * cg%dy *cg%dzu(kc) )**p133525 height = zu(k) - zu(k_wall)3526 fw = EXP( -cfw * height / glsf )3527 tkefactor_l(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) * &3528 ( glsf / glsc )**p23 )3529 ENDDO3530 tkefactor_l(k_wall,j) = c_tkef * fw03531 ENDDO3532 ENDIF3533 3534 IF ( bc_dirichlet_r ) THEN3535 ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )3536 tkefactor_r = 0.0_wp3537 i = nxr + 13538 DO j = nysg, nyng3539 k_wall = get_topography_top_index_ji( j, i, 's' )3540 3541 DO k = k_wall + 1, nzt3542 kc = kco(k) + 13543 glsf = ( dx * dy * dzu(k) )**p133544 glsc = ( cg%dx * cg%dy * cg%dzu(kc) )**p133545 height = zu(k) - zu(k_wall)3546 fw = EXP( -cfw * height / glsf )3547 tkefactor_r(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) * &3548 ( glsf / glsc )**p23 )3549 ENDDO3550 tkefactor_r(k_wall,j) = c_tkef * fw03551 ENDDO3552 ENDIF3553 3554 IF ( bc_dirichlet_s ) THEN3555 ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )3556 tkefactor_s = 0.0_wp3557 j = nys - 13558 DO i = nxlg, nxrg3559 k_wall = get_topography_top_index_ji( j, i, 's' )3560 3561 DO k = k_wall + 1, nzt3562 3563 kc = kco(k) + 13564 glsf = ( dx * dy * dzu(k) )**p133565 glsc = ( cg%dx * cg%dy * cg%dzu(kc) ) ** p133566 height = zu(k) - zu(k_wall)3567 fw = EXP( -cfw*height / glsf )3568 tkefactor_s(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) * &3569 ( glsf / glsc )**p23 )3570 ENDDO3571 tkefactor_s(k_wall,i) = c_tkef * fw03572 ENDDO3573 ENDIF3574 3575 IF ( bc_dirichlet_n ) THEN3576 ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )3577 tkefactor_n = 0.0_wp3578 j = nyn + 13579 DO i = nxlg, nxrg3580 k_wall = get_topography_top_index_ji( j, i, 's' )3581 3582 DO k = k_wall + 1, nzt3583 3584 kc = kco(k) + 13585 glsf = ( dx * dy * dzu(k) )**p133586 glsc = ( cg%dx * cg%dy * cg%dzu(kc) )**p133587 height = zu(k) - zu(k_wall)3588 fw = EXP( -cfw * height / glsf )3589 tkefactor_n(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) * &3590 ( glsf / glsc )**p23 )3591 ENDDO3592 tkefactor_n(k_wall,i) = c_tkef * fw03593 ENDDO3594 ENDIF3595 3596 ALLOCATE( tkefactor_t(nysg:nyng,nxlg:nxrg) )3597 k = nzt3598 3599 DO i = nxlg, nxrg3600 DO j = nysg, nyng3601 !3602 !-- Determine vertical index for local topography top3603 k_wall = get_topography_top_index_ji( j, i, 's' )3604 3605 kc = kco(k) + 13606 glsf = ( dx * dy * dzu(k) )**p133607 glsc = ( cg%dx * cg%dy * cg%dzu(kc) )**p133608 height = zu(k) - zu(k_wall)3609 fw = EXP( -cfw * height / glsf )3610 tkefactor_t(j,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) * &3611 ( glsf / glsc )**p23 )3612 ENDDO3613 ENDDO3614 !3615 !-- RANS mode3616 ELSE3617 IF ( bc_dirichlet_l ) THEN3618 ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )3619 tkefactor_l = 1.0_wp3620 ENDIF3621 IF ( bc_dirichlet_r ) THEN3622 ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )3623 tkefactor_r = 1.0_wp3624 ENDIF3625 IF ( bc_dirichlet_s ) THEN3626 ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )3627 tkefactor_s = 1.0_wp3628 ENDIF3629 IF ( bc_dirichlet_n ) THEN3630 ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )3631 tkefactor_n = 1.0_wp3632 ENDIF3633 3634 ALLOCATE( tkefactor_t(nysg:nyng,nxlg:nxrg) )3635 tkefactor_t = 1.0_wp3636 3637 ENDIF3638 3639 END SUBROUTINE pmci_init_tkefactor3640 3894 3641 3895 #endif … … 3667 3921 #endif 3668 3922 END SUBROUTINE pmci_setup_coordinates 3669 3923 3670 3924 !------------------------------------------------------------------------------! 3671 3925 ! Description: … … 4029 4283 INTEGER(iwp) :: i !< 4030 4284 INTEGER(iwp) :: icl !< 4285 INTEGER(iwp) :: icla !< 4286 INTEGER(iwp) :: iclw !< 4031 4287 INTEGER(iwp) :: icr !< 4288 INTEGER(iwp) :: icra !< 4289 INTEGER(iwp) :: icrw !< 4032 4290 INTEGER(iwp) :: j !< 4033 4291 INTEGER(iwp) :: jcn !< 4292 INTEGER(iwp) :: jcna !< 4293 INTEGER(iwp) :: jcnw !< 4034 4294 INTEGER(iwp) :: jcs !< 4295 INTEGER(iwp) :: jcsa !< 4296 INTEGER(iwp) :: jcsw !< 4035 4297 INTEGER(iwp) :: k !< 4036 4298 INTEGER(iwp) :: n !< running index for chemical species … … 4043 4305 ! 4044 4306 !-- Child domain boundaries in the parent index space 4045 icl = coarse_bound(1) 4046 icr = coarse_bound(2) 4047 jcs = coarse_bound(3) 4048 jcn = coarse_bound(4) 4307 icl = coarse_bound(1) 4308 icr = coarse_bound(2) 4309 jcs = coarse_bound(3) 4310 jcn = coarse_bound(4) 4311 icla = coarse_bound_aux(1) 4312 icra = coarse_bound_aux(2) 4313 jcsa = coarse_bound_aux(3) 4314 jcna = coarse_bound_aux(4) 4315 iclw = coarse_bound_w(1) 4316 icrw = coarse_bound_w(2) 4317 jcsw = coarse_bound_w(3) 4318 jcnw = coarse_bound_w(4) 4319 4049 4320 ! 4050 4321 !-- Get data from the parent … … 4052 4323 ! 4053 4324 !-- The interpolation. 4054 CALL pmci_interp_ tril_all ( u, uc, icu, jco, kco, r1xu, r2xu, r1yo, &4325 CALL pmci_interp_1sto_all ( u, uc, icu, jco, kco, r1xu, r2xu, r1yo, & 4055 4326 r2yo, r1zo, r2zo, kcto, iflu, ifuu, & 4056 4327 jflo, jfuo, kflo, kfuo, ijkfc_u, 'u' ) 4057 CALL pmci_interp_ tril_all ( v, vc, ico, jcv, kco, r1xo, r2xo, r1yv, &4328 CALL pmci_interp_1sto_all ( v, vc, ico, jcv, kco, r1xo, r2xo, r1yv, & 4058 4329 r2yv, r1zo, r2zo, kcto, iflo, ifuo, & 4059 4330 jflv, jfuv, kflo, kfuo, ijkfc_v, 'v' ) 4060 CALL pmci_interp_ tril_all ( w, wc, ico, jco, kcw, r1xo, r2xo, r1yo, &4331 CALL pmci_interp_1sto_all ( w, wc, ico, jco, kcw, r1xo, r2xo, r1yo, & 4061 4332 r2yo, r1zw, r2zw, kctw, iflo, ifuo, & 4062 4333 jflo, jfuo, kflw, kfuw, ijkfc_w, 'w' ) … … 4065 4336 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 4066 4337 .NOT. constant_diffusion ) ) THEN 4067 CALL pmci_interp_ tril_all ( e, ec, ico, jco, kco, r1xo, r2xo, r1yo, &4338 CALL pmci_interp_1sto_all ( e, ec, ico, jco, kco, r1xo, r2xo, r1yo, & 4068 4339 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 4069 4340 jflo, jfuo, kflo, kfuo, ijkfc_s, 'e' ) … … 4071 4342 4072 4343 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 4073 CALL pmci_interp_ tril_all ( diss, dissc, ico, jco, kco, r1xo, r2xo,&4344 CALL pmci_interp_1sto_all ( diss, dissc, ico, jco, kco, r1xo, r2xo,& 4074 4345 r1yo, r2yo, r1zo, r2zo, kcto, iflo, ifuo,& 4075 4346 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 4077 4348 4078 4349 IF ( .NOT. neutral ) THEN 4079 CALL pmci_interp_ tril_all ( pt, ptc, ico, jco, kco, r1xo, r2xo, &4350 CALL pmci_interp_1sto_all ( pt, ptc, ico, jco, kco, r1xo, r2xo, & 4080 4351 r1yo, r2yo, r1zo, r2zo, kcto, iflo, ifuo,& 4081 4352 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 4084 4355 IF ( humidity ) THEN 4085 4356 4086 CALL pmci_interp_ tril_all ( q, q_c, ico, jco, kco, r1xo, r2xo, r1yo, &4357 CALL pmci_interp_1sto_all ( q, q_c, ico, jco, kco, r1xo, r2xo, r1yo, & 4087 4358 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 4088 4359 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) 4089 4360 4090 4361 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 4091 CALL pmci_interp_ tril_all ( qc, qcc, ico, jco, kco, r1xo, r2xo, &4362 CALL pmci_interp_1sto_all ( qc, qcc, ico, jco, kco, r1xo, r2xo, & 4092 4363 r1yo, r2yo, r1zo, r2zo, kcto, & 4093 4364 iflo, ifuo, jflo, jfuo, kflo, kfuo, & 4094 4365 ijkfc_s, 's' ) 4095 CALL pmci_interp_ tril_all ( nc, ncc, ico, jco, kco, r1xo, r2xo, &4366 CALL pmci_interp_1sto_all ( nc, ncc, ico, jco, kco, r1xo, r2xo, & 4096 4367 r1yo, r2yo, r1zo, r2zo, kcto, & 4097 4368 iflo, ifuo, jflo, jfuo, kflo, kfuo, & … … 4100 4371 4101 4372 IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN 4102 CALL pmci_interp_ tril_all ( qr, qrc, ico, jco, kco, r1xo, r2xo, &4373 CALL pmci_interp_1sto_all ( qr, qrc, ico, jco, kco, r1xo, r2xo, & 4103 4374 r1yo, r2yo, r1zo, r2zo, kcto, & 4104 4375 iflo, ifuo, jflo, jfuo, kflo, kfuo, & 4105 4376 ijkfc_s, 's' ) 4106 CALL pmci_interp_ tril_all ( nr, nrc, ico, jco, kco, r1xo, r2xo, &4377 CALL pmci_interp_1sto_all ( nr, nrc, ico, jco, kco, r1xo, r2xo, & 4107 4378 r1yo, r2yo, r1zo, r2zo, kcto, & 4108 4379 iflo, ifuo, jflo, jfuo, kflo, kfuo, & … … 4113 4384 4114 4385 IF ( passive_scalar ) THEN 4115 CALL pmci_interp_ tril_all ( s, sc, ico, jco, kco, r1xo, r2xo, r1yo, &4386 CALL pmci_interp_1sto_all ( s, sc, ico, jco, kco, r1xo, r2xo, r1yo, & 4116 4387 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 4117 4388 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 4120 4391 IF ( air_chemistry .AND. nest_chemistry ) THEN 4121 4392 DO n = 1, nspec 4122 CALL pmci_interp_ tril_all ( chem_species(n)%conc, &4393 CALL pmci_interp_1sto_all ( chem_species(n)%conc, & 4123 4394 chem_spec_c(:,:,:,n), & 4124 4395 ico, jco, kco, r1xo, r2xo, r1yo, & … … 4162 4433 4163 4434 4164 SUBROUTINE pmci_interp_ tril_all( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, &4435 SUBROUTINE pmci_interp_1sto_all( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, & 4165 4436 r1z, r2z, kct, ifl, ifu, jfl, jfu, & 4166 4437 kfl, kfu, ijkfc, var ) … … 4173 4444 CHARACTER(LEN=1), INTENT(IN) :: var !< 4174 4445 4175 INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) :: ic !< 4176 INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) :: jc !< 4177 INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 4446 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 4447 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 4448 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 4449 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 4178 4450 4179 4451 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(INOUT) :: f !< 4180 4452 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: fc !< 4181 REAL(wp), DIMENSION(nxl g:nxrg), INTENT(IN):: r1x !<4182 REAL(wp), DIMENSION(nxl g:nxrg), INTENT(IN):: r2x !<4183 REAL(wp), DIMENSION(nys g:nyng), INTENT(IN):: r1y !<4184 REAL(wp), DIMENSION(nys g:nyng), INTENT(IN):: r2y !<4185 REAL(wp), DIMENSION(nzb:nzt+ 1), INTENT(IN) :: r1z !<4186 REAL(wp), DIMENSION(nzb:nzt+ 1), INTENT(IN) :: r2z !<4453 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 4454 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 4455 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 4456 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 4457 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 4458 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 4187 4459 4188 4460 INTEGER(iwp) :: kct 4189 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 4190 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 4191 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 4192 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 4193 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 4194 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 4195 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 4461 !AH INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 4462 !AH INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 4463 !AH INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 4464 !AH INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 4465 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 4466 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 4467 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 4468 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 4469 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 4470 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 4471 !AH 4472 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 4473 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 4474 !AH 4196 4475 4197 4476 INTEGER(iwp) :: i !< 4198 INTEGER(iwp) :: ib !<4199 INTEGER(iwp) :: ie !<4200 INTEGER(iwp) :: ijk !<4201 4477 INTEGER(iwp) :: j !< 4202 INTEGER(iwp) :: jb !<4203 INTEGER(iwp) :: je !<4204 4478 INTEGER(iwp) :: k !< 4205 INTEGER(iwp) :: k_wall !<4206 INTEGER(iwp) :: k1 !<4207 INTEGER(iwp) :: kb !<4208 INTEGER(iwp) :: kbc !<4209 4479 INTEGER(iwp) :: l !< 4480 INTEGER(iwp) :: lb !< 4481 INTEGER(iwp) :: le !< 4210 4482 INTEGER(iwp) :: m !< 4483 INTEGER(iwp) :: mb !< 4484 INTEGER(iwp) :: me !< 4211 4485 INTEGER(iwp) :: n !< 4212 4486 INTEGER(iwp) :: var_flag !< 4213 4487 4214 REAL(wp) :: cellsum !< 4215 REAL(wp) :: cellsumd !< 4216 REAL(wp) :: fk !< 4217 REAL(wp) :: fkj !< 4218 REAL(wp) :: fkjp !< 4219 REAL(wp) :: fkp !< 4220 REAL(wp) :: fkpj !< 4221 REAL(wp) :: fkpjp !< 4222 REAL(wp) :: logratio !< 4223 REAL(wp) :: logzuc1 !< 4224 REAL(wp) :: rcorr !< 4225 REAL(wp) :: rcorr_ijk !< 4226 REAL(wp) :: zuc1 !< 4227 REAL(wp) :: z0_topo !< roughness at vertical walls 4228 4229 4230 ib = nxl 4231 ie = nxr 4232 jb = nys 4233 je = nyn 4234 kb = 0 4488 4489 lb = icl 4490 le = icr 4491 mb = jcs 4492 me = jcn 4493 4235 4494 IF ( nesting_mode /= 'vertical' ) THEN 4236 4495 IF ( bc_dirichlet_l ) THEN 4237 ib = nxl -14496 lb = icl + 1 4238 4497 ! 4239 4498 !-- For u, nxl is a ghost node, but not for the other variables 4240 4499 IF ( var == 'u' ) THEN 4241 ib = nxl4500 lb = icl + 2 4242 4501 ENDIF 4243 4502 ENDIF 4244 4503 IF ( bc_dirichlet_s ) THEN 4245 jb = nys -14504 mb = jcs + 1 4246 4505 ! 4247 4506 !-- For v, nys is a ghost node, but not for the other variables 4248 4507 IF ( var == 'v' ) THEN 4249 jb = nys4508 mb = jcs + 2 4250 4509 ENDIF 4251 4510 ENDIF 4252 4511 IF ( bc_dirichlet_r ) THEN 4253 ie = nxr +14512 le = icr - 1 4254 4513 ENDIF 4255 4514 IF ( bc_dirichlet_n ) THEN 4256 je = nyn +14515 me = jcn - 1 4257 4516 ENDIF 4258 4517 ENDIF 4259 4518 ! 4519 !-- Is masking needed here, think about it. 4260 4520 IF ( var == 'u' ) THEN 4261 4521 var_flag = 1 … … 4266 4526 ELSE 4267 4527 var_flag = 0 4268 ENDIF 4269 ! 4270 !-- Trilinear interpolation. 4271 DO i = ib, ie 4272 DO j = jb, je 4273 ! 4274 !-- Determine the vertical index of the first node above the 4275 !-- topography top at grid point (j,i) in order to not overwrite 4276 !-- the bottom BC. 4277 ! kb = get_topography_top_index_ji( j, i, TRIM ( var ) ) + 1 4278 DO k = kb, nzt + 1 4279 l = ic(i) 4280 m = jc(j) 4281 n = kc(k) 4282 fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 4283 fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 4284 fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 4285 fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 4286 fk = r1y(j) * fkj + r2y(j) * fkjp 4287 fkp = r1y(j) * fkpj + r2y(j) * fkpjp 4288 f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 4528 ENDIF 4529 4530 f(:,:,:) = 0.0_wp 4531 4532 IF ( var == 'u' ) THEN 4533 4534 DO l = lb, le 4535 DO m = mb, me 4536 DO n = 0, kct 4537 4538 DO i = ifl(l), ifl(l+1)-1 4539 DO j = jfl(m), jfu(m) 4540 DO k = kfl(n), kfu(n) 4541 f(k,j,i) = fc(n,m,l) 4542 ENDDO 4543 ENDDO 4544 ENDDO 4545 4546 ENDDO 4289 4547 ENDDO 4290 4548 ENDDO 4291 ENDDO 4292 ! 4293 !-- Correct the interpolated values of u and v in near-wall nodes, i.e. in 4294 !-- the nodes below the coarse-grid nodes with k=1. The corrction is only 4295 !-- made over horizontal wall surfaces in this phase. For the nest boundary 4296 !-- conditions, a corresponding correction is made for all vertical walls, 4297 !-- too. 4298 IF ( constant_flux_layer .AND. ( var == 'u' .OR. var == 'v' ) ) THEN 4299 z0_topo = roughness_length 4300 DO i = ib, nxr 4301 DO j = jb, nyn 4302 ! 4303 !-- Determine vertical index of topography top at grid point (j,i) 4304 k_wall = get_topography_top_index_ji( j, i, TRIM ( var ) ) 4305 ! 4306 !-- kbc is the first coarse-grid point above the surface 4307 kbc = 1 4308 DO WHILE ( cg%zu(kbc) < zu(k_wall) ) 4309 kbc = kbc + 1 4549 4550 ELSE IF ( var == 'v' ) THEN 4551 4552 DO l = lb, le 4553 DO m = mb, me 4554 DO n = 0, kct 4555 4556 DO i = ifl(l), ifu(l) 4557 DO j = jfl(m), jfl(m+1)-1 4558 DO k = kfl(n), kfu(n) 4559 f(k,j,i) = fc(n,m,l) 4560 ENDDO 4561 ENDDO 4562 ENDDO 4563 4310 4564 ENDDO 4311 zuc1 = cg%zu(kbc)4312 k1 = k_wall + 14313 DO WHILE ( zu(k1) < zuc1 )4314 k1 = k1 + 14315 ENDDO4316 logzuc1 = LOG( ( zu(k1) - zu(k_wall) ) / z0_topo )4317 4318 k = k_wall + 14319 DO WHILE ( zu(k) < zuc1 )4320 logratio = ( LOG( ( zu(k) - zu(k_wall) ) / z0_topo ) ) / &4321 logzuc14322 f(k,j,i) = logratio * f(k1,j,i)4323 k = k + 14324 ENDDO4325 f(k_wall,j,i) = 0.0_wp4326 4565 ENDDO 4327 4566 ENDDO 4328 4567 4329 ELSEIF ( var == 'w' ) THEN 4330 4331 DO i = ib, nxr 4332 DO j = jb, nyn 4333 ! 4334 !-- Determine vertical index of topography top at grid point (j,i) 4335 k_wall = get_topography_top_index_ji( j, i, 'w' ) 4336 4337 f(k_wall,j,i) = 0.0_wp 4338 ENDDO 4339 ENDDO 4340 4341 ENDIF 4342 ! 4343 !-- Apply the reversibility correction. 4344 DO l = icl, icr 4345 DO m = jcs, jcn 4346 DO n = 0, kct+1 4347 ijk = 1 4348 cellsum = 0.0_wp 4349 cellsumd = 0.0_wp 4350 ! 4351 !-- Note that the index name i must not be used here as a loop 4352 !-- index name since i is the constant boundary index, hence 4353 !-- the name ia. 4354 DO i = ifl(l), ifu(l) 4355 DO j = jfl(m), jfu(m) 4356 DO k = kfl(n), kfu(n) 4357 cellsum = cellsum + MERGE( f(k,j,i), 0.0_wp, & 4358 BTEST( wall_flags_0(k,j,i), var_flag ) ) 4359 celltmpd(ijk) = ABS( fc(n,m,l) - f(k,j,i) ) 4360 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 4361 0.0_wp, BTEST( wall_flags_0(k,j,i), var_flag ) ) 4362 ijk = ijk + 1 4568 ELSE IF ( var == 'w' ) THEN 4569 4570 DO l = lb, le 4571 DO m = mb, me 4572 DO n = 1, kct + 1 ! It is important to go up to kct+1 4573 4574 DO i = ifl(l), ifu(l) 4575 DO j = jfl(m), jfu(m) 4576 f(nzb,j,i) = 0.0_wp ! Because the n-loop starts from n=1 instead of 0 4577 DO k = kfu(n-1)+1, kfu(n) 4578 f(k,j,i) = fc(n,m,l) 4579 ENDDO 4363 4580 ENDDO 4364 4581 ENDDO 4582 4365 4583 ENDDO 4366 4367 IF ( ijkfc(n,m,l) /= 0 ) THEN 4368 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp ) 4369 rcorr = fc(n,m,l) - cellsum 4370 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp ) 4371 ELSE 4372 cellsum = 0.0_wp 4373 rcorr = 0.0_wp 4374 cellsumd = 1.0_wp 4375 celltmpd = 1.0_wp 4376 ENDIF 4377 ! 4378 !-- Distribute the correction term to the child nodes according to 4379 !-- their relative difference to the parent value such that the 4380 !-- node with the largest difference gets the largest share of the 4381 !-- correction. The distribution is skipped if rcorr is negligibly 4382 !-- small in order to avoid division by zero. 4383 IF ( ABS(rcorr) < 0.000001_wp ) THEN 4384 cellsumd = 1.0_wp 4385 celltmpd = 1.0_wp 4386 ENDIF 4387 4388 ijk = 1 4389 DO i = ifl(l), ifu(l) 4390 DO j = jfl(m), jfu(m) 4391 DO k = kfl(n), kfu(n) 4392 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 4393 f(k,j,i) = f(k,j,i) + rcorr_ijk 4394 ijk = ijk + 1 4584 ENDDO 4585 ENDDO 4586 4587 ELSE ! scalars 4588 4589 DO l = lb, le 4590 DO m = mb, me 4591 DO n = 0, kct 4592 4593 DO i = ifl(l), ifu(l) 4594 DO j = jfl(m), jfu(m) 4595 DO k = kfl(n), kfu(n) 4596 f(k,j,i) = fc(n,m,l) 4597 ENDDO 4395 4598 ENDDO 4396 4599 ENDDO 4600 4397 4601 ENDDO 4398 4399 ENDDO ! n4400 ENDDO ! m 4401 END DO ! l4402 4403 END SUBROUTINE pmci_interp_ tril_all4602 ENDDO 4603 ENDDO 4604 4605 ENDIF ! var 4606 4607 END SUBROUTINE pmci_interp_1sto_all 4404 4608 4405 4609 #endif … … 4674 4878 IMPLICIT NONE 4675 4879 4676 INTEGER(iwp), INTENT(IN) :: direction !<4880 INTEGER(iwp), INTENT(IN) :: direction !< Transfer direction: parent_to_child or child_to_parent 4677 4881 4678 4882 #if defined( __parallel ) 4679 INTEGER(iwp) :: icl !< 4680 INTEGER(iwp) :: icr !< 4681 INTEGER(iwp) :: jcs !< 4682 INTEGER(iwp) :: jcn !< 4683 4684 REAL(wp), DIMENSION(1) :: dtl !< 4883 INTEGER(iwp) :: icl !< Parent-grid array index bound, left 4884 INTEGER(iwp) :: icr !< Parent-grid array index bound, right 4885 INTEGER(iwp) :: jcn !< Parent-grid array index bound, north 4886 INTEGER(iwp) :: jcs !< Parent-grid array index bound, south 4887 INTEGER(iwp) :: icla !< Auxiliary-array (index-mapping etc) index bound, left 4888 INTEGER(iwp) :: icra !< Auxiliary-array (index-mapping etc) index bound, right 4889 INTEGER(iwp) :: jcna !< Auxiliary-array (index-mapping etc) index bound, north 4890 INTEGER(iwp) :: jcsa !< Auxiliary-array (index-mapping etc) index bound, south 4891 INTEGER(iwp) :: iclw !< Parent-grid work array index bound, left 4892 INTEGER(iwp) :: icrw !< Parent-grid work array index bound, right 4893 INTEGER(iwp) :: jcnw !< Parent-grid work array index bound, north 4894 INTEGER(iwp) :: jcsw !< Parent-grid work array index bound, south 4895 4896 REAL(wp), DIMENSION(1) :: dtl !< Time step size 4685 4897 4686 4898 … … 4689 4901 ! 4690 4902 !-- Child domain boundaries in the parent indice space. 4691 icl = coarse_bound(1) 4692 icr = coarse_bound(2) 4693 jcs = coarse_bound(3) 4694 jcn = coarse_bound(4) 4903 icl = coarse_bound(1) 4904 icr = coarse_bound(2) 4905 jcs = coarse_bound(3) 4906 jcn = coarse_bound(4) 4907 icla = coarse_bound_aux(1) 4908 icra = coarse_bound_aux(2) 4909 jcsa = coarse_bound_aux(3) 4910 jcna = coarse_bound_aux(4) 4911 iclw = coarse_bound_w(1) 4912 icrw = coarse_bound_w(2) 4913 jcsw = coarse_bound_w(3) 4914 jcnw = coarse_bound_w(4) 4695 4915 4696 4916 IF ( direction == parent_to_child ) THEN … … 4736 4956 !-- horizontal boundaries 4737 4957 IF ( nesting_mode /= 'vertical' ) THEN 4738 4739 4958 ! 4740 4959 !-- Left border pe: 4741 4960 IF ( bc_dirichlet_l ) THEN 4742 4961 4743 CALL pmci_interp_ tril_lr( u, uc, icu, jco, kco, r1xu, r2xu, &4962 CALL pmci_interp_1sto_lr( u, uc, icu, jco, kco, r1xu, r2xu, & 4744 4963 r1yo, r2yo, r1zo, r2zo, & 4745 4964 logc_u_l, logc_ratio_u_l, & … … 4748 4967 kfuo, ijkfc_u, 'l', 'u' ) 4749 4968 4750 CALL pmci_interp_ tril_lr( v, vc, ico, jcv, kco, r1xo, r2xo, &4969 CALL pmci_interp_1sto_lr( v, vc, ico, jcv, kco, r1xo, r2xo, & 4751 4970 r1yv, r2yv, r1zo, r2zo, & 4752 4971 logc_v_l, logc_ratio_v_l, & … … 4755 4974 kfuo, ijkfc_v, 'l', 'v' ) 4756 4975 4757 CALL pmci_interp_ tril_lr( w, wc, ico, jco, kcw, r1xo, r2xo, &4976 CALL pmci_interp_1sto_lr( w, wc, ico, jco, kcw, r1xo, r2xo, & 4758 4977 r1yo, r2yo, r1zw, r2zw, & 4759 4978 logc_w_l, logc_ratio_w_l, & … … 4765 4984 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 4766 4985 .NOT. constant_diffusion ) ) THEN 4767 ! CALL pmci_interp_ tril_lr( e, ec, ico, jco, kco, r1xo, r2xo, &4986 ! CALL pmci_interp_1sto_lr( e, ec, ico, jco, kco, r1xo, r2xo, & 4768 4987 ! r1yo, r2yo, r1zo, r2zo, & 4769 4988 ! logc_w_l, logc_ratio_w_l, & … … 4780 4999 4781 5000 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 4782 CALL pmci_interp_ tril_lr( diss, dissc, ico, jco, kco, r1xo, &5001 CALL pmci_interp_1sto_lr( diss, dissc, ico, jco, kco, r1xo, & 4783 5002 r2xo, r1yo, r2yo, r1zo, r2zo, & 4784 5003 logc_w_l, logc_ratio_w_l, & … … 4789 5008 4790 5009 IF ( .NOT. neutral ) THEN 4791 CALL pmci_interp_ tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, &5010 CALL pmci_interp_1sto_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, & 4792 5011 r1yo, r2yo, r1zo, r2zo, & 4793 5012 logc_w_l, logc_ratio_w_l, & … … 4799 5018 IF ( humidity ) THEN 4800 5019 4801 CALL pmci_interp_ tril_lr( q, q_c, ico, jco, kco, r1xo, r2xo, &5020 CALL pmci_interp_1sto_lr( q, q_c, ico, jco, kco, r1xo, r2xo, & 4802 5021 r1yo, r2yo, r1zo, r2zo, & 4803 5022 logc_w_l, logc_ratio_w_l, & … … 4807 5026 4808 5027 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 4809 CALL pmci_interp_ tril_lr( qc, qcc, ico, jco, kco, r1xo, &5028 CALL pmci_interp_1sto_lr( qc, qcc, ico, jco, kco, r1xo, & 4810 5029 r2xo, r1yo, r2yo, r1zo, r2zo, & 4811 5030 logc_w_l, logc_ratio_w_l, & … … 4815 5034 kflo, kfuo, ijkfc_s, 'l', 's' ) 4816 5035 4817 CALL pmci_interp_ tril_lr( nc, ncc, ico, jco, kco, r1xo, &5036 CALL pmci_interp_1sto_lr( nc, ncc, ico, jco, kco, r1xo, & 4818 5037 r2xo, r1yo, r2yo, r1zo, r2zo, & 4819 5038 logc_w_l, logc_ratio_w_l, & … … 4825 5044 4826 5045 IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN 4827 CALL pmci_interp_ tril_lr( qr, qrc, ico, jco, kco, r1xo, &5046 CALL pmci_interp_1sto_lr( qr, qrc, ico, jco, kco, r1xo, & 4828 5047 r2xo, r1yo, r2yo, r1zo, r2zo, & 4829 5048 logc_w_l, logc_ratio_w_l, & … … 4833 5052 kflo, kfuo, ijkfc_s, 'l', 's' ) 4834 5053 4835 CALL pmci_interp_ tril_lr( nr, nrc, ico, jco, kco, r1xo, &5054 CALL pmci_interp_1sto_lr( nr, nrc, ico, jco, kco, r1xo, & 4836 5055 r2xo, r1yo, r2yo, r1zo, r2zo, & 4837 5056 logc_w_l, logc_ratio_w_l, & … … 4845 5064 4846 5065 IF ( passive_scalar ) THEN 4847 CALL pmci_interp_ tril_lr( s, sc, ico, jco, kco, r1xo, r2xo, &5066 CALL pmci_interp_1sto_lr( s, sc, ico, jco, kco, r1xo, r2xo, & 4848 5067 r1yo, r2yo, r1zo, r2zo, & 4849 5068 logc_w_l, logc_ratio_w_l, & … … 4856 5075 IF ( air_chemistry .AND. nest_chemistry ) THEN 4857 5076 DO n = 1, nspec 4858 CALL pmci_interp_ tril_lr( chem_species(n)%conc, &5077 CALL pmci_interp_1sto_lr( chem_species(n)%conc, & 4859 5078 chem_spec_c(:,:,:,n), & 4860 5079 ico, jco, kco, r1xo, r2xo, & … … 4873 5092 IF ( bc_dirichlet_r ) THEN 4874 5093 4875 CALL pmci_interp_ tril_lr( u, uc, icu, jco, kco, r1xu, r2xu, &5094 CALL pmci_interp_1sto_lr( u, uc, icu, jco, kco, r1xu, r2xu, & 4876 5095 r1yo, r2yo, r1zo, r2zo, & 4877 5096 logc_u_r, logc_ratio_u_r, & … … 4880 5099 kfuo, ijkfc_u, 'r', 'u' ) 4881 5100 4882 CALL pmci_interp_ tril_lr( v, vc, ico, jcv, kco, r1xo, r2xo, &5101 CALL pmci_interp_1sto_lr( v, vc, ico, jcv, kco, r1xo, r2xo, & 4883 5102 r1yv, r2yv, r1zo, r2zo, & 4884 5103 logc_v_r, logc_ratio_v_r, & … … 4887 5106 kfuo, ijkfc_v, 'r', 'v' ) 4888 5107 4889 CALL pmci_interp_ tril_lr( w, wc, ico, jco, kcw, r1xo, r2xo, &5108 CALL pmci_interp_1sto_lr( w, wc, ico, jco, kcw, r1xo, r2xo, & 4890 5109 r1yo, r2yo, r1zw, r2zw, & 4891 5110 logc_w_r, logc_ratio_w_r, & … … 4897 5116 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 4898 5117 .NOT. constant_diffusion ) ) THEN 4899 ! CALL pmci_interp_ tril_lr( e, ec, ico, jco, kco, r1xo, r2xo, &5118 ! CALL pmci_interp_1sto_lr( e, ec, ico, jco, kco, r1xo, r2xo, & 4900 5119 ! r1yo,r2yo, r1zo, r2zo, & 4901 5120 ! logc_w_r, logc_ratio_w_r, & … … 4911 5130 4912 5131 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 4913 CALL pmci_interp_ tril_lr( diss, dissc, ico, jco, kco, r1xo, &5132 CALL pmci_interp_1sto_lr( diss, dissc, ico, jco, kco, r1xo, & 4914 5133 r2xo, r1yo,r2yo, r1zo, r2zo, & 4915 5134 logc_w_r, logc_ratio_w_r, & … … 4921 5140 4922 5141 IF ( .NOT. neutral ) THEN 4923 CALL pmci_interp_ tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, &5142 CALL pmci_interp_1sto_lr( pt, ptc, ico, jco, kco, r1xo, r2xo, & 4924 5143 r1yo, r2yo, r1zo, r2zo, & 4925 5144 logc_w_r, logc_ratio_w_r, & … … 4930 5149 4931 5150 IF ( humidity ) THEN 4932 CALL pmci_interp_ tril_lr( q, q_c, ico, jco, kco, r1xo, r2xo, &5151 CALL pmci_interp_1sto_lr( q, q_c, ico, jco, kco, r1xo, r2xo, & 4933 5152 r1yo, r2yo, r1zo, r2zo, & 4934 5153 logc_w_r, logc_ratio_w_r, & … … 4939 5158 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 4940 5159 4941 CALL pmci_interp_ tril_lr( qc, qcc, ico, jco, kco, r1xo, &5160 CALL pmci_interp_1sto_lr( qc, qcc, ico, jco, kco, r1xo, & 4942 5161 r2xo, r1yo, r2yo, r1zo, r2zo, & 4943 5162 logc_w_r, logc_ratio_w_r, & … … 4947 5166 kflo, kfuo, ijkfc_s, 'r', 's' ) 4948 5167 4949 CALL pmci_interp_ tril_lr( nc, ncc, ico, jco, kco, r1xo, &5168 CALL pmci_interp_1sto_lr( nc, ncc, ico, jco, kco, r1xo, & 4950 5169 r2xo, r1yo, r2yo, r1zo, r2zo, & 4951 5170 logc_w_r, logc_ratio_w_r, & … … 4960 5179 4961 5180 4962 CALL pmci_interp_ tril_lr( qr, qrc, ico, jco, kco, r1xo, &5181 CALL pmci_interp_1sto_lr( qr, qrc, ico, jco, kco, r1xo, & 4963 5182 r2xo, r1yo, r2yo, r1zo, r2zo, & 4964 5183 logc_w_r, logc_ratio_w_r, & … … 4969 5188 'r', 's' ) 4970 5189 4971 CALL pmci_interp_ tril_lr( nr, nrc, ico, jco, kco, r1xo, &5190 CALL pmci_interp_1sto_lr( nr, nrc, ico, jco, kco, r1xo, & 4972 5191 r2xo, r1yo, r2yo, r1zo, r2zo, & 4973 5192 logc_w_r, logc_ratio_w_r, & … … 4982 5201 4983 5202 IF ( passive_scalar ) THEN 4984 CALL pmci_interp_ tril_lr( s, sc, ico, jco, kco, r1xo, r2xo, &5203 CALL pmci_interp_1sto_lr( s, sc, ico, jco, kco, r1xo, r2xo, & 4985 5204 r1yo, r2yo, r1zo, r2zo, & 4986 5205 logc_w_r, logc_ratio_w_r, & … … 4993 5212 IF ( air_chemistry .AND. nest_chemistry ) THEN 4994 5213 DO n = 1, nspec 4995 CALL pmci_interp_ tril_lr( chem_species(n)%conc, &5214 CALL pmci_interp_1sto_lr( chem_species(n)%conc, & 4996 5215 chem_spec_c(:,:,:,n), & 4997 5216 ico, jco, kco, r1xo, r2xo, & … … 5009 5228 IF ( bc_dirichlet_s ) THEN 5010 5229 5011 CALL pmci_interp_tril_sn( u, uc, icu, jco, kco, r1xu, r2xu, & 5230 CALL pmci_interp_1sto_sn( v, vc, ico, jcv, kco, r1xo, r2xo, & 5231 r1yv, r2yv, r1zo, r2zo, & 5232 logc_v_s, logc_ratio_v_s, & 5233 logc_kbounds_v_s, nzt_topo_nestbc_s, & 5234 kcto, iflo, ifuo, jflv, jfuv, kflo, & 5235 kfuo, ijkfc_v, 's', 'v' ) 5236 5237 CALL pmci_interp_1sto_sn( w, wc, ico, jco, kcw, r1xo, r2xo, & 5238 r1yo, r2yo, r1zw, r2zw, & 5239 logc_w_s, logc_ratio_w_s, & 5240 logc_kbounds_w_s, nzt_topo_nestbc_s, & 5241 kctw, iflo, ifuo, jflo, jfuo, kflw, & 5242 kfuw, ijkfc_w, 's','w' ) 5243 5244 CALL pmci_interp_1sto_sn( u, uc, icu, jco, kco, r1xu, r2xu, & 5012 5245 r1yo, r2yo, r1zo, r2zo, & 5013 5246 logc_u_s, logc_ratio_u_s, & … … 5016 5249 kfuo, ijkfc_u, 's', 'u' ) 5017 5250 5018 CALL pmci_interp_tril_sn( v, vc, ico, jcv, kco, r1xo, r2xo, &5019 r1yv, r2yv, r1zo, r2zo, &5020 logc_v_s, logc_ratio_v_s, &5021 logc_kbounds_v_s, nzt_topo_nestbc_s, &5022 kcto, iflo, ifuo, jflv, jfuv, kflo, &5023 kfuo, ijkfc_v, 's', 'v' )5024 5025 CALL pmci_interp_tril_sn( w, wc, ico, jco, kcw, r1xo, r2xo, &5026 r1yo, r2yo, r1zw, r2zw, &5027 logc_w_s, logc_ratio_w_s, &5028 logc_kbounds_w_s, nzt_topo_nestbc_s, &5029 kctw, iflo, ifuo, jflo, jfuo, kflw, &5030 kfuw, ijkfc_w, 's','w' )5031 5032 5251 IF ( ( rans_mode_parent .AND. rans_mode ) .OR. & 5033 5252 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 5034 5253 .NOT. constant_diffusion ) ) THEN 5035 ! CALL pmci_interp_ tril_sn( e, ec, ico, jco, kco, r1xo, r2xo, &5254 ! CALL pmci_interp_1sto_sn( e, ec, ico, jco, kco, r1xo, r2xo, & 5036 5255 ! r1yo, r2yo, r1zo, r2zo, & 5037 5256 ! logc_w_s, logc_ratio_w_s, & … … 5047 5266 5048 5267 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 5049 CALL pmci_interp_ tril_sn( diss, dissc, ico, jco, kco, r1xo, &5268 CALL pmci_interp_1sto_sn( diss, dissc, ico, jco, kco, r1xo, & 5050 5269 r2xo, r1yo, r2yo, r1zo, r2zo, & 5051 5270 logc_w_s, logc_ratio_w_s, & … … 5056 5275 5057 5276 IF ( .NOT. neutral ) THEN 5058 CALL pmci_interp_ tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, &5277 CALL pmci_interp_1sto_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, & 5059 5278 r1yo, r2yo, r1zo, r2zo, & 5060 5279 logc_w_s, logc_ratio_w_s, & … … 5065 5284 5066 5285 IF ( humidity ) THEN 5067 CALL pmci_interp_ tril_sn( q, q_c, ico, jco, kco, r1xo, r2xo, &5286 CALL pmci_interp_1sto_sn( q, q_c, ico, jco, kco, r1xo, r2xo, & 5068 5287 r1yo,r2yo, r1zo, r2zo, & 5069 5288 logc_w_s, logc_ratio_w_s, & … … 5074 5293 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 5075 5294 5076 CALL pmci_interp_ tril_sn( qc, qcc, ico, jco, kco, r1xo, &5295 CALL pmci_interp_1sto_sn( qc, qcc, ico, jco, kco, r1xo, & 5077 5296 r2xo, r1yo,r2yo, r1zo, r2zo, & 5078 5297 logc_w_s, logc_ratio_w_s, & … … 5082 5301 kflo, kfuo, ijkfc_s, 's', 's' ) 5083 5302 5084 CALL pmci_interp_ tril_sn( nc, ncc, ico, jco, kco, r1xo, &5303 CALL pmci_interp_1sto_sn( nc, ncc, ico, jco, kco, r1xo, & 5085 5304 r2xo, r1yo,r2yo, r1zo, r2zo, & 5086 5305 logc_w_s, logc_ratio_w_s, & … … 5094 5313 IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN 5095 5314 5096 CALL pmci_interp_ tril_sn( qr, qrc, ico, jco, kco, r1xo, &5315 CALL pmci_interp_1sto_sn( qr, qrc, ico, jco, kco, r1xo, & 5097 5316 r2xo, r1yo,r2yo, r1zo, r2zo, & 5098 5317 logc_w_s, logc_ratio_w_s, & … … 5102 5321 kflo, kfuo, ijkfc_s, 's', 's' ) 5103 5322 5104 CALL pmci_interp_ tril_sn( nr, nrc, ico, jco, kco, r1xo, &5323 CALL pmci_interp_1sto_sn( nr, nrc, ico, jco, kco, r1xo, & 5105 5324 r2xo, r1yo,r2yo, r1zo, r2zo, & 5106 5325 logc_w_s, logc_ratio_w_s, & … … 5115 5334 5116 5335 IF ( passive_scalar ) THEN 5117 CALL pmci_interp_ tril_sn( s, sc, ico, jco, kco, r1xo, r2xo, &5336 CALL pmci_interp_1sto_sn( s, sc, ico, jco, kco, r1xo, r2xo, & 5118 5337 r1yo,r2yo, r1zo, r2zo, & 5119 5338 logc_w_s, logc_ratio_w_s, & … … 5126 5345 IF ( air_chemistry .AND. nest_chemistry ) THEN 5127 5346 DO n = 1, nspec 5128 CALL pmci_interp_ tril_sn( chem_species(n)%conc, &5347 CALL pmci_interp_1sto_sn( chem_species(n)%conc, & 5129 5348 chem_spec_c(:,:,:,n), & 5130 5349 ico, jco, kco, r1xo, r2xo, & … … 5142 5361 IF ( bc_dirichlet_n ) THEN 5143 5362 5144 CALL pmci_interp_ tril_sn( u, uc, icu, jco, kco, r1xu, r2xu, &5363 CALL pmci_interp_1sto_sn( u, uc, icu, jco, kco, r1xu, r2xu, & 5145 5364 r1yo, r2yo, r1zo, r2zo, & 5146 5365 logc_u_n, logc_ratio_u_n, & … … 5149 5368 kfuo, ijkfc_u, 'n', 'u' ) 5150 5369 5151 CALL pmci_interp_ tril_sn( v, vc, ico, jcv, kco, r1xo, r2xo, &5370 CALL pmci_interp_1sto_sn( v, vc, ico, jcv, kco, r1xo, r2xo, & 5152 5371 r1yv, r2yv, r1zo, r2zo, & 5153 5372 logc_v_n, logc_ratio_v_n, & … … 5156 5375 kfuo, ijkfc_v, 'n', 'v' ) 5157 5376 5158 CALL pmci_interp_ tril_sn( w, wc, ico, jco, kcw, r1xo, r2xo, &5377 CALL pmci_interp_1sto_sn( w, wc, ico, jco, kcw, r1xo, r2xo, & 5159 5378 r1yo, r2yo, r1zw, r2zw, & 5160 5379 logc_w_n, logc_ratio_w_n, & … … 5166 5385 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 5167 5386 .NOT. constant_diffusion ) ) THEN 5168 ! CALL pmci_interp_ tril_sn( e, ec, ico, jco, kco, r1xo, r2xo, &5387 ! CALL pmci_interp_1sto_sn( e, ec, ico, jco, kco, r1xo, r2xo, & 5169 5388 ! r1yo, r2yo, r1zo, r2zo, & 5170 5389 ! logc_w_n, logc_ratio_w_n, & … … 5180 5399 5181 5400 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 5182 CALL pmci_interp_ tril_sn( diss, dissc, ico, jco, kco, r1xo, &5401 CALL pmci_interp_1sto_sn( diss, dissc, ico, jco, kco, r1xo, & 5183 5402 r2xo, r1yo, r2yo, r1zo, r2zo, & 5184 5403 logc_w_n, logc_ratio_w_n, & … … 5190 5409 5191 5410 IF ( .NOT. neutral ) THEN 5192 CALL pmci_interp_ tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, &5411 CALL pmci_interp_1sto_sn( pt, ptc, ico, jco, kco, r1xo, r2xo, & 5193 5412 r1yo, r2yo, r1zo, r2zo, & 5194 5413 logc_w_n, logc_ratio_w_n, & … … 5199 5418 5200 5419 IF ( humidity ) THEN 5201 CALL pmci_interp_ tril_sn( q, q_c, ico, jco, kco, r1xo, r2xo, &5420 CALL pmci_interp_1sto_sn( q, q_c, ico, jco, kco, r1xo, r2xo, & 5202 5421 r1yo, r2yo, r1zo, r2zo, & 5203 5422 logc_w_n, logc_ratio_w_n, & … … 5208 5427 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 5209 5428 5210 CALL pmci_interp_ tril_sn( qc, qcc, ico, jco, kco, r1xo, &5429 CALL pmci_interp_1sto_sn( qc, qcc, ico, jco, kco, r1xo, & 5211 5430 r2xo, r1yo, r2yo, r1zo, r2zo, & 5212 5431 logc_w_n, logc_ratio_w_n, & … … 5216 5435 kflo, kfuo, ijkfc_s, 'n', 's' ) 5217 5436 5218 CALL pmci_interp_ tril_sn( nc, ncc, ico, jco, kco, r1xo, &5437 CALL pmci_interp_1sto_sn( nc, ncc, ico, jco, kco, r1xo, & 5219 5438 r2xo, r1yo, r2yo, r1zo, r2zo, & 5220 5439 logc_u_n, logc_ratio_u_n, & … … 5228 5447 IF ( bulk_cloud_model .AND. microphysics_seifert ) THEN 5229 5448 5230 CALL pmci_interp_ tril_sn( qr, qrc, ico, jco, kco, r1xo, &5449 CALL pmci_interp_1sto_sn( qr, qrc, ico, jco, kco, r1xo, & 5231 5450 r2xo, r1yo, r2yo, r1zo, r2zo, & 5232 5451 logc_w_n, logc_ratio_w_n, & … … 5236 5455 kflo, kfuo, ijkfc_s, 'n', 's' ) 5237 5456 5238 CALL pmci_interp_ tril_sn( nr, nrc, ico, jco, kco, r1xo, &5457 CALL pmci_interp_1sto_sn( nr, nrc, ico, jco, kco, r1xo, & 5239 5458 r2xo, r1yo, r2yo, r1zo, r2zo, & 5240 5459 logc_w_n, logc_ratio_w_n, & … … 5249 5468 5250 5469 IF ( passive_scalar ) THEN 5251 CALL pmci_interp_ tril_sn( s, sc, ico, jco, kco, r1xo, r2xo, &5470 CALL pmci_interp_1sto_sn( s, sc, ico, jco, kco, r1xo, r2xo, & 5252 5471 r1yo, r2yo, r1zo, r2zo, & 5253 5472 logc_w_n, logc_ratio_w_n, & … … 5260 5479 IF ( air_chemistry .AND. nest_chemistry ) THEN 5261 5480 DO n = 1, nspec 5262 CALL pmci_interp_ tril_sn( chem_species(n)%conc, &5481 CALL pmci_interp_1sto_sn( chem_species(n)%conc, & 5263 5482 chem_spec_c(:,:,:,n), & 5264 5483 ico, jco, kco, r1xo, r2xo, & … … 5276 5495 ! 5277 5496 !-- All PEs are top-border PEs 5278 CALL pmci_interp_tril_t( u, uc, icu, jco, kco, r1xu, r2xu, r1yo, & 5497 CALL pmci_interp_1sto_t( w, wc, ico, jco, kcw, r1xo, r2xo, r1yo, & 5498 r2yo, r1zw, r2zw, kctw, iflo, ifuo, & 5499 jflo, jfuo, kflw, kfuw, ijkfc_w, 'w' ) 5500 CALL pmci_interp_1sto_t( u, uc, icu, jco, kco, r1xu, r2xu, r1yo, & 5279 5501 r2yo, r1zo, r2zo, kcto, iflu, ifuu, & 5280 5502 jflo, jfuo, kflo, kfuo, ijkfc_u, 'u' ) 5281 CALL pmci_interp_ tril_t( v, vc, ico, jcv, kco, r1xo, r2xo, r1yv, &5503 CALL pmci_interp_1sto_t( v, vc, ico, jcv, kco, r1xo, r2xo, r1yv, & 5282 5504 r2yv, r1zo, r2zo, kcto, iflo, ifuo, & 5283 5505 jflv, jfuv, kflo, kfuo, ijkfc_v, 'v' ) 5284 CALL pmci_interp_tril_t( w, wc, ico, jco, kcw, r1xo, r2xo, r1yo, & 5285 r2yo, r1zw, r2zw, kctw, iflo, ifuo, & 5286 jflo, jfuo, kflw, kfuw, ijkfc_w, 'w' ) 5506 5287 5507 5288 5508 IF ( ( rans_mode_parent .AND. rans_mode ) .OR. & 5289 5509 ( .NOT. rans_mode_parent .AND. .NOT. rans_mode .AND. & 5290 5510 .NOT. constant_diffusion ) ) THEN 5291 ! CALL pmci_interp_ tril_t( e, ec, ico, jco, kco, r1xo, r2xo, r1yo, &5511 ! CALL pmci_interp_1sto_t( e, ec, ico, jco, kco, r1xo, r2xo, r1yo, & 5292 5512 ! r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5293 5513 ! jflo, jfuo, kflo, kfuo, ijkfc_s, 'e' ) … … 5299 5519 5300 5520 IF ( rans_mode_parent .AND. rans_mode .AND. rans_tke_e ) THEN 5301 CALL pmci_interp_ tril_t( diss, dissc, ico, jco, kco, r1xo, r2xo, &5521 CALL pmci_interp_1sto_t( diss, dissc, ico, jco, kco, r1xo, r2xo, & 5302 5522 r1yo, r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5303 5523 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5305 5525 5306 5526 IF ( .NOT. neutral ) THEN 5307 CALL pmci_interp_ tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, &5527 CALL pmci_interp_1sto_t( pt, ptc, ico, jco, kco, r1xo, r2xo, & 5308 5528 r1yo, r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5309 5529 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5312 5532 IF ( humidity ) THEN 5313 5533 5314 CALL pmci_interp_ tril_t( q, q_c, ico, jco, kco, r1xo, r2xo, r1yo, &5534 CALL pmci_interp_1sto_t( q, q_c, ico, jco, kco, r1xo, r2xo, r1yo, & 5315 5535 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5316 5536 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5318 5538 IF ( bulk_cloud_model .AND. microphysics_morrison ) THEN 5319 5539 5320 CALL pmci_interp_ tril_t( qc, qcc, ico, jco, kco, r1xo, r2xo, r1yo,&5540 CALL pmci_interp_1sto_t( qc, qcc, ico, jco, kco, r1xo, r2xo, r1yo,& 5321 5541 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5322 5542 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) 5323 5543 5324 CALL pmci_interp_ tril_t( nc, ncc, ico, jco, kco, r1xo, r2xo, r1yo,&5544 CALL pmci_interp_1sto_t( nc, ncc, ico, jco, kco, r1xo, r2xo, r1yo,& 5325 5545 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5326 5546 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5331 5551 5332 5552 5333 CALL pmci_interp_ tril_t( qr, qrc, ico, jco, kco, r1xo, r2xo, r1yo,&5553 CALL pmci_interp_1sto_t( qr, qrc, ico, jco, kco, r1xo, r2xo, r1yo,& 5334 5554 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5335 5555 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) 5336 5556 5337 CALL pmci_interp_ tril_t( nr, nrc, ico, jco, kco, r1xo, r2xo, r1yo,&5557 CALL pmci_interp_1sto_t( nr, nrc, ico, jco, kco, r1xo, r2xo, r1yo,& 5338 5558 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5339 5559 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5344 5564 5345 5565 IF ( passive_scalar ) THEN 5346 CALL pmci_interp_ tril_t( s, sc, ico, jco, kco, r1xo, r2xo, r1yo, &5566 CALL pmci_interp_1sto_t( s, sc, ico, jco, kco, r1xo, r2xo, r1yo, & 5347 5567 r2yo, r1zo, r2zo, kcto, iflo, ifuo, & 5348 5568 jflo, jfuo, kflo, kfuo, ijkfc_s, 's' ) … … 5351 5571 IF ( air_chemistry .AND. nest_chemistry ) THEN 5352 5572 DO n = 1, nspec 5353 CALL pmci_interp_ tril_t( chem_species(n)%conc, &5573 CALL pmci_interp_1sto_t( chem_species(n)%conc, & 5354 5574 chem_spec_c(:,:,:,n), & 5355 5575 ico, jco, kco, r1xo, r2xo, & … … 5444 5664 5445 5665 5446 SUBROUTINE pmci_interp_ tril_lr( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, &5666 SUBROUTINE pmci_interp_1sto_lr( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, & 5447 5667 r2z, logc, logc_ratio, logc_kbounds, & 5448 5668 nzt_topo_nestbc, & … … 5464 5684 REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nys:nyn), & 5465 5685 INTENT(IN) :: logc_ratio !< 5466 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x !< 5467 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x !< 5468 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r1y !< 5469 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r2y !< 5470 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 5471 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 5686 !AH REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x !< 5687 !AH REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x !< 5688 !AH REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r1y !< 5689 !AH REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r2y !< 5690 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 5691 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 5692 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 5693 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 5694 5695 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 5696 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 5697 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 5698 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 5472 5699 5473 INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) :: ic !< 5474 INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) :: jc !< 5475 INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 5700 5701 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 5702 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 5703 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 5704 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 5476 5705 INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nys:nyn), & 5477 5706 INTENT(IN) :: logc !< … … 5479 5708 5480 5709 INTEGER(iwp) :: kct 5481 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5482 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5483 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5484 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 5710 5711 !AH 5712 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5713 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5714 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5715 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 5716 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5717 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5718 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5719 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 5720 !AH 5721 5485 5722 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 5486 5723 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction … … 5489 5726 5490 5727 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5491 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5492 5493 CHARACTER(LEN=1), INTENT(IN) :: edge !< 5494 CHARACTER(LEN=1), INTENT(IN) :: var !< 5495 5496 INTEGER(iwp) :: i !< 5497 INTEGER(iwp) :: ia !< 5498 INTEGER(iwp) :: ib !< 5499 INTEGER(iwp) :: ibgp !< 5500 INTEGER(iwp) :: ijk !< 5501 INTEGER(iwp) :: iw !< 5502 INTEGER(iwp) :: j !< 5728 !AH 5729 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5730 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5731 !AH 5732 5733 CHARACTER(LEN=1), INTENT(IN) :: edge !< Edge symbol: 'l', 'r', 's' or 'n' 5734 CHARACTER(LEN=1), INTENT(IN) :: var !< Variable symbol: 'u', 'v', 'w' or 's' 5735 5736 INTEGER(iwp) :: i !< Lower bound of the running index ia 5737 INTEGER(iwp) :: ia !< i-index running over the parent-grid cell on the boundary 5738 INTEGER(iwp) :: iaw !< Reduced ia-index for workarr_lr 5739 INTEGER(iwp) :: iawbc !< iaw-index pointing to the boundary-value nodes (either 0 or igsr-1) 5740 INTEGER(iwp) :: ibc !< Fixed i-index pointing to the boundary-value nodes (either i or iend) 5741 !AH INTEGER(iwp) :: ibeg !< i-index pointing to the starting point of workarr_lr in the i-direction 5742 INTEGER(iwp) :: iend !< Upper bound of the running index ia 5743 INTEGER(iwp) :: ierr !< MPI error code 5744 INTEGER(iwp) :: ijk !< Running index for all child-grid cells within the anterpolation cell 5745 INTEGER(iwp) :: iw !< i-index for wall_flags_0 5746 INTEGER(iwp) :: j !< Running index in the y-direction 5503 5747 INTEGER(iwp) :: jco !< 5504 5748 INTEGER(iwp) :: jcorr !< 5505 5749 INTEGER(iwp) :: jinc !< 5506 INTEGER(iwp) :: jw !< 5750 INTEGER(iwp) :: jw !< j-index for wall_flags_0 5507 5751 INTEGER(iwp) :: j1 !< 5508 INTEGER(iwp) :: k !< 5509 INTEGER(iwp) :: k_wall !< vertical index of topography top5752 INTEGER(iwp) :: k !< Running index in the z-direction 5753 INTEGER(iwp) :: k_wall !< Vertical index of topography top 5510 5754 INTEGER(iwp) :: kco !< 5511 5755 INTEGER(iwp) :: kcorr !< 5756 INTEGER(iwp) :: kw !< k-index for wall_flags_0 5512 5757 INTEGER(iwp) :: k1 !< 5513 INTEGER(iwp) :: l !< 5514 INTEGER(iwp) :: m !< 5515 INTEGER(iwp) :: n !< 5516 INTEGER(iwp) :: kbc !< 5517 INTEGER(iwp) :: var_flag !< 5518 5519 REAL(wp) :: cellsum !< 5520 REAL(wP) :: cellsumd !< 5521 REAL(wp) :: fkj !< 5522 REAL(wp) :: fkjp !< 5523 REAL(wp) :: fkpj !< 5524 REAL(wp) :: fkpjp !< 5525 REAL(wp) :: fk !< 5526 REAL(wp) :: fkp !< 5527 REAL(wp) :: rcorr !< 5528 REAL(wp) :: rcorr_ijk !< 5529 5758 INTEGER(iwp) :: l !< Parent-grid running index in the x-direction 5759 INTEGER(iwp) :: lbeg !< l-index pointing to the starting point of workarrc_lr in the l-direction 5760 INTEGER(iwp) :: lp1 !< l+1 5761 INTEGER(iwp) :: loff !< l-offset needed on the right boundary to correctly refer to boundary ghost points 5762 INTEGER(iwp) :: lw !< Reduced l-index for workarrc_lr 5763 INTEGER(iwp) :: m !< Parent-grid running index in the y-direction 5764 INTEGER(iwp) :: mnorthv !< Upshift by one for the upper bound of index m in case of var == 'v' 5765 INTEGER(iwp) :: mp1 !< m+1 5766 INTEGER(iwp) :: n !< Parent-grid running index in the z-direction 5767 INTEGER(iwp) :: np1 !< n+1 5768 INTEGER(iwp) :: ntopw !< Upshift by one for the upper bound of index n in case of var == 'w' 5769 INTEGER(iwp) :: var_flag !< Variable flag for BTEST( wall_flags_0 ) 5770 5771 REAL(wp) :: cellsum !< Sum of child-grid node values over the anterpolation cell 5772 REAL(wP) :: cellsumd !< Sum of differences over the anterpolation cell 5773 REAL(wp) :: fkj !< Intermediate result in trilinear interpolation 5774 REAL(wp) :: fkjp !< Intermediate result in trilinear interpolation 5775 REAL(wp) :: fkpj !< Intermediate result in trilinear interpolation 5776 REAL(wp) :: fkpjp !< Intermediate result in trilinear interpolation 5777 REAL(wp) :: fk !< Intermediate result in trilinear interpolation 5778 REAL(wp) :: fkp !< Intermediate result in trilinear interpolation 5779 REAL(wp) :: rcorr !< Average reversibility correction for the whole anterpolation cell 5780 REAL(wp) :: rcorr_ijk !< Reversibility correction distributed to the individual child-grid nodes 5781 5530 5782 ! 5531 5783 !-- Check which edge is to be handled … … 5534 5786 !-- For u, nxl is a ghost node, but not for the other variables 5535 5787 IF ( var == 'u' ) THEN 5536 i = nxl 5537 ib = nxl - 1 5788 i = nxl 5789 iend = nxl 5790 ibc = nxl 5791 iawbc = 0 5792 l = icl + 2 5793 lw = 2 5794 lbeg = icl 5795 loff = 0 5538 5796 ELSE 5539 i = nxl - 1 5540 ib = nxl - 2 5797 i = nxl - igsr 5798 iend = nxl - 1 5799 ibc = nxl - 1 5800 iawbc = igsr-1 5801 l = icl + 1 5802 lw = 1 5803 lbeg = icl 5804 loff = 0 5541 5805 ENDIF 5542 5806 ELSEIF ( edge == 'r' ) THEN 5543 i = nxr + 1 5544 ib = nxr + 2 5807 IF ( var == 'u' ) THEN 5808 i = nxr + 1 5809 iend = nxr + 1 5810 ibc = nxr + 1 5811 iawbc = 0 5812 l = icr - 1 5813 lw = 1 5814 lbeg = icr - 2 5815 loff = 0 5816 ELSE 5817 i = nxr + 1 5818 iend = nxr + igsr 5819 ibc = nxr + 1 5820 iawbc = 0 5821 l = icr - 1 5822 lw = 1 5823 lbeg = icr - 2 5824 loff = 1 5825 ENDIF 5826 ENDIF 5827 5828 IF ( var == 'w' ) THEN 5829 ntopw = 1 5830 ELSE 5831 ntopw = 0 5832 ENDIF 5833 5834 IF ( var == 'v' ) THEN 5835 mnorthv = 0 5836 ELSE 5837 mnorthv = 1 5545 5838 ENDIF 5546 5839 … … 5554 5847 var_flag = 0 5555 5848 ENDIF 5556 5557 DO j = nys, nyn+1 5558 ! 5559 !-- Determine vertical index of topography top at grid point (j,i) 5849 5850 IF ( var == 'u' ) THEN 5851 !AH! 5852 !AH!-- Substitute the necessary parent-grid data to the work array workarrc_lr. 5853 !AH workarrc_lr = 0.0_wp 5854 !AH IF ( pdims(2) > 1 ) THEN 5855 !AH#if defined( __parallel ) 5856 !AH IF ( nys == 0 ) THEN 5857 !AH workarrc_lr(0:cg%nz+1,jcsw:jcnw-1,0:2) & 5858 !AH = fc(0:cg%nz+1,jcsw:jcnw-1,lbeg:lbeg+2) 5859 !AH ELSE IF ( nyn == ny ) THEN 5860 !AH workarrc_lr(0:cg%nz+1,jcsw+1:jcnw,0:2) & 5861 !AH = fc(0:cg%nz+1,jcsw+1:jcnw,lbeg:lbeg+2) 5862 !AH ELSE 5863 !AH workarrc_lr(0:cg%nz+1,jcsw+1:jcnw-1,0:2) & 5864 !AH = fc(0:cg%nz+1,jcsw+1:jcnw-1,lbeg:lbeg+2) 5865 !AH ENDIF 5866 !AH! 5867 !AH!-- South-north exchange if more than one PE subdomain in the y-direction. 5868 !AH!-- Note that in case of 3-D nesting the south (psouth == MPI_PROC_NULL) 5869 !AH!-- and north (pnorth == MPI_PROC_NULL) boundaries are not exchanged 5870 !AH!-- because the nest domain is not cyclic. 5871 !AH!-- From south to north 5872 !AH CALL MPI_SENDRECV( workarrc_lr(0,jcsw+1,0), 1, & 5873 !AH workarrc_lr_exchange_type, psouth, 0, & 5874 !AH workarrc_lr(0,jcnw,0), 1, & 5875 !AH workarrc_lr_exchange_type, pnorth, 0, & 5876 !AH comm2d, status, ierr ) 5877 !AH! 5878 !AH!-- From north to south 5879 !AH CALL MPI_SENDRECV( workarrc_lr(0,jcnw-1,0), 1, & 5880 !AH workarrc_lr_exchange_type, pnorth, 1, & 5881 !AH workarrc_lr(0,jcsw,0), 1, & 5882 !AH workarrc_lr_exchange_type, psouth, 1, & 5883 !AH comm2d, status, ierr ) 5884 !AH#endif 5885 !AH ELSE 5886 !AH workarrc_lr(0:cg%nz+1,jcsw:jcnw,0:2) & 5887 !AH = fc(0:cg%nz+1,jcsw:jcnw,lbeg:lbeg+2) 5888 !AH ENDIF 5889 5890 DO m = jcsw+1, jcnw-1 5891 DO n = 0, kct 5892 5893 DO j = jfl(m), jfu(m) 5894 DO k = kfl(n), kfu(n) 5895 f(k,j,ibc) = fc(n,m,l) 5896 ENDDO 5897 ENDDO 5898 5899 ENDDO 5900 ENDDO 5901 5902 ELSE IF ( var == 'v' ) THEN 5903 5904 DO m = jcsw+1, jcnw-1 5905 DO n = 0, kct 5906 5907 DO j = jfl(m), jfl(m+1)-1 5908 DO k = kfl(n), kfu(n) 5909 f(k,j,ibc) = fc(n,m,l) 5910 ENDDO 5911 ENDDO 5912 5913 ENDDO 5914 ENDDO 5915 5916 ELSE IF ( var == 'w' ) THEN 5917 5918 DO m = jcsw+1, jcnw-1 5919 DO n = 1, kct + 1 ! It is important to go up to kct+1 5920 5921 DO j = jfl(m), jfu(m) 5922 f(nzb,j,ibc) = 0.0_wp ! Because the n-loop starts from n=1 instead of 0 5923 DO k = kfu(n-1)+1, kfu(n) 5924 f(k,j,ibc) = fc(n,m,l) 5925 ENDDO 5926 ENDDO 5927 5928 ENDDO 5929 ENDDO 5930 5931 ELSE ! scalars 5932 5933 DO m = jcsw+1, jcnw-1 5934 DO n = 0, kct 5935 5936 DO j = jfl(m), jfu(m) 5937 DO k = kfl(n), kfu(n) 5938 f(k,j,ibc) = fc(n,m,l) 5939 ENDDO 5940 ENDDO 5941 5942 ENDDO 5943 ENDDO 5944 5945 ENDIF ! var 5946 5947 END SUBROUTINE pmci_interp_1sto_lr 5948 5949 5950 5951 SUBROUTINE pmci_interp_1sto_sn( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, & 5952 r2z, logc, logc_ratio, logc_kbounds, & 5953 nzt_topo_nestbc, & 5954 kct, ifl, ifu, jfl, jfu, kfl, kfu, ijkfc, & 5955 edge, var ) 5956 5957 ! 5958 !-- Interpolation of ghost-node values used as the child-domain boundary 5959 !-- conditions. This subroutine handles the south and north boundaries. 5960 !-- This subroutine is based on trilinear interpolation. 5961 5962 IMPLICIT NONE 5963 5964 INTEGER(iwp) :: nzt_topo_nestbc !< 5965 5966 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & 5967 INTENT(INOUT) :: f !< 5968 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), & 5969 INTENT(IN) :: fc !< 5970 REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nxl:nxr), & 5971 INTENT(IN) :: logc_ratio !< 5972 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 5973 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 5974 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 5975 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 5976 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 5977 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 5978 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 5979 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 5980 5981 5982 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 5983 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 5984 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 5985 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 5986 INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nxl:nxr), & 5987 INTENT(IN) :: logc !< 5988 INTEGER(iwp), DIMENSION(1:2,nxl:nxr), INTENT(IN) :: logc_kbounds !< 5989 5990 INTEGER(iwp) :: kct 5991 !AH 5992 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5993 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5994 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5995 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 5996 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5997 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5998 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5999 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 6000 !AH 6001 6002 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6003 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6004 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6005 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6006 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6007 !AH 6008 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6009 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6010 !AH 6011 6012 CHARACTER(LEN=1), INTENT(IN) :: edge !< Edge symbol: 'l', 'r', 's' or 'n' 6013 CHARACTER(LEN=1), INTENT(IN) :: var !< Variable symbol: 'u', 'v', 'w' or 's' 6014 6015 INTEGER(iwp) :: i !< Running index in the x-direction 6016 INTEGER(iwp) :: iinc !< 6017 INTEGER(iwp) :: icorr !< 6018 INTEGER(iwp) :: ico !< 6019 INTEGER(iwp) :: ierr !< MPI error code 6020 INTEGER(iwp) :: ijk !< Running index for all child-grid cells within the anterpolation cell 6021 INTEGER(iwp) :: iw !< i-index for wall_flags_0 6022 INTEGER(iwp) :: i1 !< 6023 INTEGER(iwp) :: j !< Lower bound of the running index ja 6024 INTEGER(iwp) :: ja !< Index in y-direction running over the parent-grid cell on the boundary 6025 INTEGER(iwp) :: jaw !< Reduced ja-index for workarr_sn 6026 INTEGER(iwp) :: jawbc !< jaw-index pointing to the boundary-value nodes (either 0 or jgsr-1) 6027 !AH INTEGER(iwp) :: jbeg !< j-index pointing to the starting point of workarr_sn in the j-direction 6028 INTEGER(iwp) :: jbc !< Fixed j-index pointing to the boundary-value nodes (either j or jend) 6029 INTEGER(iwp) :: jend !< Upper bound of the running index ja 6030 INTEGER(iwp) :: jw !< j-index for wall_flags_0 6031 INTEGER(iwp) :: k !< Running index in the z-direction 6032 INTEGER(iwp) :: k_wall !< Vertical index of topography top 6033 INTEGER(iwp) :: kcorr !< 6034 INTEGER(iwp) :: kco !< 6035 INTEGER(iwp) :: kw !< k-index for wall_flags_0 6036 INTEGER(iwp) :: k1 !< 6037 INTEGER(iwp) :: l !< Parent-grid running index in the x-direction 6038 INTEGER(iwp) :: lp1 !< l+1 6039 INTEGER(iwp) :: lrightu !< Upshift by one for the upper bound of index l in case of var == 'u' 6040 INTEGER(iwp) :: m !< Parent-grid running index in the y-direction 6041 INTEGER(iwp) :: mbeg !< m-index pointing to the starting point of workarrc_sn in the m-direction 6042 INTEGER(iwp) :: moff !< m-offset needed on the north boundary to correctly refer to boundary ghost points 6043 INTEGER(iwp) :: mp1 !< m+1 6044 INTEGER(iwp) :: mw !< Reduced m-index for workarrc_sn 6045 INTEGER(iwp) :: n !< Parent-grid running index in the z-direction 6046 INTEGER(iwp) :: np1 !< n+1 6047 INTEGER(iwp) :: ntopw !< Upshift by one for the upper bound of index n in case of var == 'w' 6048 INTEGER(iwp) :: var_flag !< Variable flag for BTEST( wall_flags_0 ) 6049 6050 REAL(wp) :: cellsum !< Sum of child-grid node values over the anterpolation cell 6051 REAL(wp) :: cellsumd !< Sum of differences over the anterpolation cell 6052 REAL(wp) :: fk !< Intermediate result in trilinear interpolation 6053 REAL(wp) :: fkj !< Intermediate result in trilinear interpolation 6054 REAL(wp) :: fkjp !< Intermediate result in trilinear interpolation 6055 REAL(wp) :: fkpj !< Intermediate result in trilinear interpolation 6056 REAL(wp) :: fkpjp !< Intermediate result in trilinear interpolation 6057 REAL(wp) :: fkp !< Intermediate result in trilinear interpolation 6058 REAL(wp) :: rcorr !< Average reversibility correction for the whole anterpolation cell 6059 REAL(wp) :: rcorr_ijk !< Reversibility correction distributed to the individual child-grid nodes 6060 6061 ! 6062 !-- Check which edge is to be handled: south or north 6063 IF ( edge == 's' ) THEN 6064 ! 6065 !-- For v, nys is a ghost node, but not for the other variables 6066 IF ( var == 'v' ) THEN 6067 j = nys 6068 jend = nys 6069 jawbc = 0 6070 jbc = nys 6071 m = jcs + 2 6072 mw = 2 6073 mbeg = jcs 6074 moff = 0 6075 ELSE 6076 j = nys - jgsr 6077 jend = nys - 1 6078 jawbc = jgsr - 1 6079 jbc = nys - 1 6080 m = jcs + 1 6081 mw = 1 6082 mbeg = jcs 6083 moff = 0 6084 ENDIF 6085 ELSEIF ( edge == 'n' ) THEN 6086 IF ( var == 'v' ) THEN 6087 j = nyn + 1 6088 jend = nyn + 1 6089 jawbc = 0 6090 jbc = nyn + 1 6091 m = jcn - 1 6092 mw = 1 6093 mbeg = jcn - 2 6094 moff = 0 6095 ELSE 6096 j = nyn + 1 6097 jend = nyn + jgsr 6098 jawbc = 0 6099 jbc = nyn + 1 6100 m = jcn - 1 6101 mw = 1 6102 mbeg = jcn - 2 6103 moff = 1 6104 ENDIF 6105 ENDIF 6106 6107 IF ( var == 'w' ) THEN 6108 ntopw = 1 6109 ELSE 6110 ntopw = 0 6111 ENDIF 6112 6113 IF ( var == 'u' ) THEN 6114 lrightu = 0 6115 ELSE 6116 lrightu = 1 6117 ENDIF 6118 6119 IF ( var == 'u' ) THEN 6120 var_flag = 1 6121 ELSEIF ( var == 'v' ) THEN 6122 var_flag = 2 6123 ELSEIF ( var == 'w' ) THEN 6124 var_flag = 3 6125 ELSE 6126 var_flag = 0 6127 ENDIF 6128 6129 IF ( var == 'v' ) THEN 6130 !AH! 6131 !AH!-- Substitute the necessary parent-grid data to the work array workarrc_sn. 6132 !AH workarrc_sn = 0.0_wp 6133 !AH IF ( pdims(1) > 1 ) THEN 6134 !AH#if defined( __parallel ) 6135 !AH IF ( nxl == 0 ) THEN ! if ( bc_dirichlet_l ) 6136 !AH workarrc_sn(0:cg%nz+1,0:2,iclw:icrw-1) & 6137 !AH = fc(0:cg%nz+1,mbeg:mbeg+2,iclw:icrw-1) 6138 !AH ELSE IF ( nxr == nx ) THEN ! if ( bc_dirichlet_r ) 6139 !AH workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw) & 6140 !AH = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw) 6141 !AH ELSE 6142 !AH workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw-1) & 6143 !AH = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw-1) 6144 !AH ENDIF 6145 !AH! 6146 !AH!-- Left-right exchange if more than one PE subdomain in the x-direction. 6147 !AH!-- Note that in case of 3-D nesting the left (pleft == MPI_PROC_NULL) and 6148 !AH!-- right (pright == MPI_PROC_NULL) boundaries are not exchanged because 6149 !AH!-- the nest domain is not cyclic. 6150 !AH!-- From left to right 6151 !AH CALL MPI_SENDRECV( workarrc_sn(0,0,iclw+1), 1, & 6152 !AH workarrc_sn_exchange_type, pleft, 0, & 6153 !AH workarrc_sn(0,0,icrw), 1, & 6154 !AH workarrc_sn_exchange_type, pright, 0, & 6155 !AH comm2d, status, ierr ) 6156 !AH! 6157 !AH!-- From right to left 6158 !AH CALL MPI_SENDRECV( workarrc_sn(0,0,icrw-1), 1, & 6159 !AH workarrc_sn_exchange_type, pright, 1, & 6160 !AH workarrc_sn(0,0,iclw), 1, & 6161 !AH workarrc_sn_exchange_type, pleft, 1, & 6162 !AH comm2d, status, ierr ) 6163 !AH#endif 6164 !AH ELSE 6165 !AH workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw-1) & 6166 !AH = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw-1) 6167 !AH ENDIF 6168 6169 DO l = iclw+1, icrw-1 6170 DO n = 0, kct 6171 6172 DO i = ifl(l), ifu(l) 6173 DO k = kfl(n), kfu(n) 6174 f(k,jbc,i) = fc(n,m,l) 6175 ENDDO 6176 ENDDO 6177 6178 ENDDO 6179 ENDDO 6180 6181 ELSE IF ( var == 'u' ) THEN 6182 6183 DO l = iclw+1, icrw-1 6184 DO n = 0, kct 6185 6186 DO i = ifl(l), ifl(l+1)-1 6187 DO k = kfl(n), kfu(n) 6188 f(k,jbc,i) = fc(n,m,l) 6189 ENDDO 6190 ENDDO 6191 6192 ENDDO 6193 ENDDO 6194 6195 ELSE IF ( var == 'w' ) THEN 6196 6197 DO l = iclw+1, icrw-1 6198 DO n = 1, kct + 1 ! It is important to go up to kct+1 6199 6200 DO i = ifl(l), ifu(l) 6201 f(nzb,jbc,i) = 0.0_wp ! Because the n-loop starts from n=1 instead of 0 6202 DO k = kfu(n-1)+1, kfu(n) 6203 f(k,jbc,i) = fc(n,m,l) 6204 ENDDO 6205 ENDDO 6206 6207 ENDDO 6208 ENDDO 6209 6210 ELSE ! scalars 6211 6212 DO l = iclw+1, icrw-1 6213 DO n = 0, kct 6214 6215 DO i = ifl(l), ifu(l) 6216 DO k = kfl(n), kfu(n) 6217 f(k,jbc,i) = fc(n,m,l) 6218 ENDDO 6219 ENDDO 6220 6221 ENDDO 6222 ENDDO 6223 6224 ENDIF ! var 6225 6226 END SUBROUTINE pmci_interp_1sto_sn 6227 6228 6229 6230 SUBROUTINE pmci_interp_1sto_t( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, & 6231 r1z, r2z, kct, ifl, ifu, jfl, jfu, kfl, kfu, & 6232 ijkfc, var ) 6233 6234 ! 6235 !-- Interpolation of ghost-node values used as the child-domain boundary 6236 !-- conditions. This subroutine handles the top boundary. 6237 !-- This subroutine is based on trilinear interpolation. 6238 6239 IMPLICIT NONE 6240 6241 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & 6242 INTENT(INOUT) :: f !< Child-grid array 6243 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), & 6244 INTENT(IN) :: fc !< Parent-grid array 6245 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 6246 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 6247 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 6248 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 6249 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 6250 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 6251 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 6252 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 6253 6254 6255 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 6256 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 6257 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 6258 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 6259 6260 INTEGER(iwp) :: kct 6261 !AH 6262 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 6263 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 6264 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 6265 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 6266 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 6267 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 6268 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 6269 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 6270 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6271 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6272 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6273 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6274 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6275 !AH 6276 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6277 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6278 !AH 6279 6280 CHARACTER(LEN=1), INTENT(IN) :: var !< 6281 6282 INTEGER(iwp) :: i !< 6283 INTEGER(iwp) :: ib !< 6284 INTEGER(iwp) :: iclc !< Lower i-index limit for copying fc-data to workarrc_t 6285 INTEGER(iwp) :: icrc !< Upper i-index limit for copying fc-data to workarrc_t 6286 INTEGER(iwp) :: ie !< 6287 INTEGER(iwp) :: ierr !< MPI error code 6288 INTEGER(iwp) :: ijk !< 6289 INTEGER(iwp) :: iw !< 6290 INTEGER(iwp) :: j !< 6291 INTEGER(iwp) :: jb !< 6292 INTEGER(iwp) :: jcsc !< Lower j-index limit for copying fc-data to workarrc_t 6293 INTEGER(iwp) :: jcnc !< Upper j-index limit for copying fc-data to workarrc_t 6294 INTEGER(iwp) :: je !< 6295 INTEGER(iwp) :: jw !< 6296 INTEGER(iwp) :: k !< Vertical child-grid index fixed to the boundary-value level 6297 INTEGER(iwp) :: ka !< Running vertical child-grid index 6298 INTEGER(iwp) :: kw !< 6299 INTEGER(iwp) :: l !< Parent-grid index in x-direction 6300 INTEGER(iwp) :: lp1 !< l+1 6301 INTEGER(iwp) :: m !< Parent-grid index in y-direction 6302 INTEGER(iwp) :: mp1 !< m+1 6303 INTEGER(iwp) :: n !< Parent-grid work array index in z-direction 6304 INTEGER(iwp) :: np1 !< n+1 6305 INTEGER(iwp) :: noff !< n-offset needed on the top boundary to correctly refer to boundary ghost points 6306 INTEGER(iwp) :: nw !< n-index for workarrc_t 6307 INTEGER(iwp) :: var_flag !< 6308 6309 REAL(wp) :: cellsum !< 6310 REAL(wp) :: cellsumd !< 6311 REAL(wp) :: fac 6312 REAL(wp) :: fk !< 6313 REAL(wp) :: fkj !< 6314 REAL(wp) :: fkjp !< 6315 REAL(wp) :: fkpj !< 6316 REAL(wp) :: fkpjp !< 6317 REAL(wp) :: fkp !< 6318 REAL(wp) :: rcorr !< 6319 REAL(wp) :: rcorr_ijk !< 6320 6321 6322 IF ( var == 'w' ) THEN 6323 k = nzt 6324 noff = 0 6325 ELSE 6326 k = nzt + 1 6327 noff = 1 6328 ENDIF 6329 6330 IF ( var == 'u' ) THEN 6331 var_flag = 1 6332 ELSEIF ( var == 'v' ) THEN 6333 var_flag = 2 6334 ELSEIF ( var == 'w' ) THEN 6335 var_flag = 3 6336 ELSE 6337 var_flag = 0 6338 ENDIF 6339 n = kc(k) + noff 6340 nw = 1 6341 6342 IF ( var == 'w' ) THEN 6343 !AH! 6344 !AH!-- Substitute the necessary parent-grid data to the work array. 6345 !AH!-- Note that the dimension of workarrc_t is (0:2,jcsw:jcnw,iclw:icrw), 6346 !AH!-- And the jc?w and ic?w-index bounds depend on the location of the PE- 6347 !AH!-- subdomain relative to the side boundaries. 6348 !AH iclc = iclw + 1 6349 !AH icrc = icrw - 1 6350 !AH jcsc = jcsw + 1 6351 !AH jcnc = jcnw - 1 6352 !AH IF ( bc_dirichlet_l ) THEN 6353 !AH iclc = iclw 6354 !AH ENDIF 6355 !AH IF ( bc_dirichlet_r ) THEN 6356 !AH icrc = icrw 6357 !AH ENDIF 6358 !AH IF ( bc_dirichlet_s ) THEN 6359 !AH jcsc = jcsw 6360 !AH ENDIF 6361 !AH IF ( bc_dirichlet_n ) THEN 6362 !AH jcnc = jcnw 6363 !AH ENDIF 6364 !AH workarrc_t = 0.0_wp 6365 !AH workarrc_t(0:2,jcsc:jcnc,iclc:icrc) & 6366 !AH = fc(kc(k):kc(k)+2,jcsc:jcnc,iclc:icrc) 6367 !AH! 6368 !AH!-- Left-right exchange if more than one PE subdomain in the x-direction. 6369 !AH!-- Note that in case of 3-D nesting the left and right boundaries are 6370 !AH!-- not exchanged because the nest domain is not cyclic. 6371 !AH#if defined( __parallel ) 6372 !AH IF ( pdims(1) > 1 ) THEN 6373 !AH! 6374 !AH!-- From left to right 6375 !AH CALL MPI_SENDRECV( workarrc_t(0,jcsw,iclw+1), 1, & 6376 !AH workarrc_t_exchange_type_y, pleft, 0, & 6377 !AH workarrc_t(0,jcsw,icrw), 1, & 6378 !AH workarrc_t_exchange_type_y, pright, 0, & 6379 !AH comm2d, status, ierr ) 6380 !AH! 6381 !AH!-- From right to left 6382 !AH CALL MPI_SENDRECV( workarrc_t(0,jcsw,icrw-1), 1, & 6383 !AH workarrc_t_exchange_type_y, pright, 1, & 6384 !AH workarrc_t(0,jcsw,iclw), 1, & 6385 !AH workarrc_t_exchange_type_y, pleft, 1, & 6386 !AH comm2d, status, ierr ) 6387 !AH ENDIF 6388 !AH! 6389 !AH!-- South-north exchange if more than one PE subdomain in the y-direction. 6390 !AH!-- Note that in case of 3-D nesting the south and north boundaries are 6391 !AH!-- not exchanged because the nest domain is not cyclic. 6392 !AH IF ( pdims(2) > 1 ) THEN 6393 !AH! 6394 !AH!-- From south to north 6395 !AH CALL MPI_SENDRECV( workarrc_t(0,jcsw+1,iclw), 1, & 6396 !AH workarrc_t_exchange_type_x, psouth, 2, & 6397 !AH workarrc_t(0,jcnw,iclw), 1, & 6398 !AH workarrc_t_exchange_type_x, pnorth, 2, & 6399 !AH comm2d, status, ierr ) 6400 !AH! 6401 !AH!-- From north to south 6402 !AH CALL MPI_SENDRECV( workarrc_t(0,jcnw-1,iclw), 1, & 6403 !AH workarrc_t_exchange_type_x, pnorth, 3, & 6404 !AH workarrc_t(0,jcsw,iclw), 1, & 6405 !AH workarrc_t_exchange_type_x, psouth, 3, & 6406 !AH comm2d, status, ierr ) 6407 !AH ENDIF 6408 !AH#endif 6409 !AH 6410 6411 DO l = iclw+1, icrw-1 6412 DO m = jcsw+1, jcnw-1 6413 6414 DO i = ifl(l), ifu(l) 6415 DO j = jfl(m), jfu(m) 6416 f(k,j,i) = fc(n,m,l) 6417 ENDDO 6418 ENDDO 6419 6420 ENDDO 6421 ENDDO 6422 6423 ELSE IF ( var == 'u' ) THEN 6424 6425 DO l = iclw+1, icrw-1 6426 DO m = jcsw+1, jcnw-1 6427 6428 DO i = ifl(l), ifl(l+1)-1 6429 DO j = jfl(m), jfu(m) 6430 f(k,j,i) = fc(n,m,l) 6431 ENDDO 6432 ENDDO 6433 6434 ENDDO 6435 ENDDO 6436 6437 ELSE IF ( var == 'v' ) THEN 6438 6439 DO l = iclw+1, icrw-1 6440 DO m = jcsw+1, jcnw-1 6441 6442 DO i = ifl(l), ifu(l) 6443 DO j = jfl(m), jfl(m+1)-1 6444 f(k,j,i) = fc(n,m,l) 6445 ENDDO 6446 ENDDO 6447 6448 ENDDO 6449 ENDDO 6450 6451 ELSE ! scalars 6452 6453 DO l = iclw+1, icrw-1 6454 DO m = jcsw+1, jcnw-1 6455 6456 DO i = ifl(l), ifu(l) 6457 DO j = jfl(m), jfu(m) 6458 f(k,j,i) = fc(n,m,l) 6459 ENDDO 6460 ENDDO 6461 6462 ENDDO 6463 ENDDO 6464 6465 ENDIF ! var 6466 6467 END SUBROUTINE pmci_interp_1sto_t 6468 6469 6470 6471 SUBROUTINE pmci_interp_tril_lr( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, & 6472 r2z, logc, logc_ratio, logc_kbounds, & 6473 nzt_topo_nestbc, & 6474 kct, ifl, ifu, jfl, jfu, kfl, kfu, ijkfc, & 6475 edge, var ) 6476 ! 6477 !-- Interpolation of ghost-node values used as the child-domain boundary 6478 !-- conditions. This subroutine handles the left and right boundaries. It is 6479 !-- based on trilinear interpolation. 6480 6481 IMPLICIT NONE 6482 6483 INTEGER(iwp) :: nzt_topo_nestbc !< 6484 6485 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & 6486 INTENT(INOUT) :: f !< 6487 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), & 6488 INTENT(IN) :: fc !< 6489 REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nys:nyn), & 6490 INTENT(IN) :: logc_ratio !< 6491 !AH REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x !< 6492 !AH REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x !< 6493 !AH REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r1y !< 6494 !AH REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r2y !< 6495 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 6496 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 6497 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 6498 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 6499 6500 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 6501 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 6502 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 6503 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 6504 6505 6506 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 6507 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 6508 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 6509 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 6510 INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nys:nyn), & 6511 INTENT(IN) :: logc !< 6512 INTEGER(iwp), DIMENSION(1:2,nys:nyn), INTENT(IN) :: logc_kbounds !< 6513 6514 INTEGER(iwp) :: kct 6515 6516 !AH 6517 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 6518 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 6519 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 6520 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 6521 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 6522 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 6523 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 6524 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 6525 !AH 6526 6527 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6528 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6529 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6530 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 6531 6532 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6533 !AH 6534 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6535 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6536 !AH 6537 6538 CHARACTER(LEN=1), INTENT(IN) :: edge !< Edge symbol: 'l', 'r', 's' or 'n' 6539 CHARACTER(LEN=1), INTENT(IN) :: var !< Variable symbol: 'u', 'v', 'w' or 's' 6540 6541 INTEGER(iwp) :: i !< Lower bound of the running index ia 6542 INTEGER(iwp) :: ia !< i-index running over the parent-grid cell on the boundary 6543 INTEGER(iwp) :: iaw !< Reduced ia-index for workarr_lr 6544 INTEGER(iwp) :: iawbc !< iaw-index pointing to the boundary-value nodes (either 0 or igsr-1) 6545 INTEGER(iwp) :: ibc !< Fixed i-index pointing to the boundary-value nodes (either i or iend) 6546 !AH INTEGER(iwp) :: ibeg !< i-index pointing to the starting point of workarr_lr in the i-direction 6547 INTEGER(iwp) :: iend !< Upper bound of the running index ia 6548 INTEGER(iwp) :: ierr !< MPI error code 6549 INTEGER(iwp) :: ijk !< Running index for all child-grid cells within the anterpolation cell 6550 INTEGER(iwp) :: iw !< i-index for wall_flags_0 6551 INTEGER(iwp) :: j !< Running index in the y-direction 6552 INTEGER(iwp) :: jco !< 6553 INTEGER(iwp) :: jcorr !< 6554 INTEGER(iwp) :: jinc !< 6555 INTEGER(iwp) :: jw !< j-index for wall_flags_0 6556 INTEGER(iwp) :: j1 !< 6557 INTEGER(iwp) :: k !< Running index in the z-direction 6558 INTEGER(iwp) :: k_wall !< Vertical index of topography top 6559 INTEGER(iwp) :: kco !< 6560 INTEGER(iwp) :: kcorr !< 6561 INTEGER(iwp) :: kw !< k-index for wall_flags_0 6562 INTEGER(iwp) :: k1 !< 6563 INTEGER(iwp) :: l !< Parent-grid running index in the x-direction 6564 INTEGER(iwp) :: lbeg !< l-index pointing to the starting point of workarrc_lr in the l-direction 6565 INTEGER(iwp) :: lp1 !< l+1 6566 INTEGER(iwp) :: loff !< l-offset needed on the right boundary to correctly refer to boundary ghost points 6567 INTEGER(iwp) :: lw !< Reduced l-index for workarrc_lr 6568 INTEGER(iwp) :: m !< Parent-grid running index in the y-direction 6569 INTEGER(iwp) :: mnorthv !< Upshift by one for the upper bound of index m in case of var == 'v' 6570 INTEGER(iwp) :: mp1 !< m+1 6571 INTEGER(iwp) :: n !< Parent-grid running index in the z-direction 6572 INTEGER(iwp) :: np1 !< n+1 6573 INTEGER(iwp) :: ntopw !< Upshift by one for the upper bound of index n in case of var == 'w' 6574 INTEGER(iwp) :: var_flag !< Variable flag for BTEST( wall_flags_0 ) 6575 6576 REAL(wp) :: cellsum !< Sum of child-grid node values over the anterpolation cell 6577 REAL(wP) :: cellsumd !< Sum of differences over the anterpolation cell 6578 REAL(wp) :: fkj !< Intermediate result in trilinear interpolation 6579 REAL(wp) :: fkjp !< Intermediate result in trilinear interpolation 6580 REAL(wp) :: fkpj !< Intermediate result in trilinear interpolation 6581 REAL(wp) :: fkpjp !< Intermediate result in trilinear interpolation 6582 REAL(wp) :: fk !< Intermediate result in trilinear interpolation 6583 REAL(wp) :: fkp !< Intermediate result in trilinear interpolation 6584 REAL(wp) :: rcorr !< Average reversibility correction for the whole anterpolation cell 6585 REAL(wp) :: rcorr_ijk !< Reversibility correction distributed to the individual child-grid nodes 6586 6587 ! 6588 !-- Check which edge is to be handled 6589 IF ( edge == 'l' ) THEN 6590 ! 6591 !-- For u, nxl is a ghost node, but not for the other variables 6592 IF ( var == 'u' ) THEN 6593 i = nxl 6594 iend = nxl 6595 ibc = nxl 6596 iawbc = 0 6597 lbeg = icl 6598 loff = 0 6599 ELSE 6600 i = nxl - igsr 6601 iend = nxl - 1 6602 ibc = nxl - 1 6603 iawbc = igsr-1 6604 lbeg = icl 6605 loff = 0 6606 ENDIF 6607 ELSEIF ( edge == 'r' ) THEN 6608 IF ( var == 'u' ) THEN 6609 i = nxr + 1 6610 iend = nxr + 1 6611 ibc = nxr + 1 6612 iawbc = 0 6613 lbeg = icr - 2 6614 loff = 0 6615 ELSE 6616 i = nxr + 1 6617 iend = nxr + igsr 6618 ibc = nxr + 1 6619 iawbc = 0 6620 lbeg = icr - 2 6621 loff = 1 6622 ENDIF 6623 6624 ENDIF 6625 6626 IF ( var == 'w' ) THEN 6627 ntopw = 1 6628 ELSE 6629 ntopw = 0 6630 ENDIF 6631 6632 IF ( var == 'v' ) THEN 6633 mnorthv = 0 6634 ELSE 6635 mnorthv = 1 6636 ENDIF 6637 6638 IF ( var == 'u' ) THEN 6639 var_flag = 1 6640 ELSEIF ( var == 'v' ) THEN 6641 var_flag = 2 6642 ELSEIF ( var == 'w' ) THEN 6643 var_flag = 3 6644 ELSE 6645 var_flag = 0 6646 ENDIF 6647 6648 !AH 6649 ! 6650 !-- Substitute the necessary parent-grid data to the work array workarrc_lr. 6651 workarrc_lr = 0.0_wp 6652 IF ( pdims(2) > 1 ) THEN 6653 #if defined( __parallel ) 6654 IF ( nys == 0 ) THEN 6655 workarrc_lr(0:cg%nz+1,jcsw:jcnw-1,0:2) & 6656 = fc(0:cg%nz+1,jcsw:jcnw-1,lbeg:lbeg+2) 6657 ELSE IF ( nyn == ny ) THEN 6658 workarrc_lr(0:cg%nz+1,jcsw+1:jcnw,0:2) & 6659 = fc(0:cg%nz+1,jcsw+1:jcnw,lbeg:lbeg+2) 6660 ELSE 6661 workarrc_lr(0:cg%nz+1,jcsw+1:jcnw-1,0:2) & 6662 = fc(0:cg%nz+1,jcsw+1:jcnw-1,lbeg:lbeg+2) 6663 ENDIF 6664 ! 6665 !-- South-north exchange if more than one PE subdomain in the y-direction. 6666 !-- Note that in case of 3-D nesting the south (psouth == MPI_PROC_NULL) 6667 !-- and north (pnorth == MPI_PROC_NULL) boundaries are not exchanged 6668 !-- because the nest domain is not cyclic. 6669 !-- From south to north 6670 CALL MPI_SENDRECV( workarrc_lr(0,jcsw+1,0), 1, & 6671 workarrc_lr_exchange_type, psouth, 0, & 6672 workarrc_lr(0,jcnw,0), 1, & 6673 workarrc_lr_exchange_type, pnorth, 0, & 6674 comm2d, status, ierr ) 6675 ! 6676 !-- From north to south 6677 CALL MPI_SENDRECV( workarrc_lr(0,jcnw-1,0), 1, & 6678 workarrc_lr_exchange_type, pnorth, 1, & 6679 workarrc_lr(0,jcsw,0), 1, & 6680 workarrc_lr_exchange_type, psouth, 1, & 6681 comm2d, status, ierr ) 6682 #endif 6683 ELSE 6684 workarrc_lr(0:cg%nz+1,jcsw:jcnw,0:2) & 6685 = fc(0:cg%nz+1,jcsw:jcnw,lbeg:lbeg+2) 6686 ENDIF 6687 ! 6688 !AH 6689 workarr_lr = 0.0_wp 6690 6691 DO ia = i, iend 6692 iaw = ia - i 6693 DO j = nys-1, nyn+1 6694 !AH DO j = nys, nyn 6695 ! 6696 !-- Determine vertical index of topography top at grid point (j,i) 5560 6697 !AH k_wall = get_topography_top_index_ji( j, i, TRIM( var ) ) 5561 5562 DO k = nzb, nzt+1 !k_wall, nzt+1 5563 l = ic(i) 5564 m = jc(j) 5565 n = kc(k) 5566 fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 5567 fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 5568 fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 5569 fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 5570 fk = r1y(j) * fkj + r2y(j) * fkjp 5571 fkp = r1y(j) * fkpj + r2y(j) * fkpjp 5572 f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 6698 DO k = nzb, nzt+1 !k_wall, nzt+1 6699 !AH l = ic(ia) - ic(i) 6700 l = ic(ia) - lbeg 6701 lp1 = MIN( l + 1, 2 ) ! If l+1 > 2 (l=ic(nxr+1)-lbeg), r1x = 1 and r2x = 0 6702 m = jc(j) 6703 mp1 = MIN( m + 1, jcnw ) ! If m+1 > jcn (m=jc(nyn+1)), r1y = 1 and r2y = 0 6704 n = kc(k) 6705 np1 = n + 1 6706 6707 !AH 6708 ! fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 6709 ! fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 6710 ! fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 6711 ! fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 6712 !AH 6713 6714 fkj = r1x(ia) * workarrc_lr(n,m,l) + r2x(ia) * workarrc_lr(n,m,lp1) 6715 fkjp = r1x(ia) * workarrc_lr(n,mp1,l) + r2x(ia) * workarrc_lr(n,mp1,lp1) 6716 fkpj = r1x(ia) * workarrc_lr(np1,m,l) + r2x(ia) * workarrc_lr(np1,m,lp1) 6717 fkpjp = r1x(ia) * workarrc_lr(np1,mp1,l) + r2x(ia) * workarrc_lr(np1,mp1,lp1) 6718 6719 fk = r1y(j) * fkj + r2y(j) * fkjp 6720 fkp = r1y(j) * fkpj + r2y(j) * fkpjp 6721 6722 !AH 6723 ! f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 6724 workarr_lr(k,j,iaw) = r1z(k) * fk + r2z(k) * fkp 6725 6726 ! if ( ( edge == 'l' ) .and. ( ia == ibc ) ) then 6727 ! write(9,"('pmci_interp_tril_lr: ',a2,2x,11(i4,2x),7(e12.5,2x))") var, k, j, ia, ibc, iaw, n, m, l, np1, mp1, lp1, & 6728 ! workarr_lr(k,j,iaw), r1x(ia), r2x(ia), workarrc_lr(n,m,l), workarrc_lr(n,mp1,l), workarrc_lr(np1,m,l), workarrc_lr(np1,mp1,l) 6729 ! flush(9) 6730 ! endif 6731 6732 !AH 6733 6734 ENDDO 5573 6735 ENDDO 5574 6736 ENDDO … … 5651 6813 ENDIF ! ( topography /= 'flat' ) 5652 6814 ! 5653 !-- Apply the reversibility correction to the boundary-normal velocity- 5654 !-- component u and the scalars. It must not be applied to the boundary- 5655 !-- tangential velocity components v and w because their 2-D anterpolation 5656 !-- cells do not cover all the child-grid nodes on the boundary. 5657 IF ( .NOT. ( ( var == 'v' ) .OR. ( var == 'w' ) ) ) THEN 5658 l = ic(i) 5659 DO m = jcs, jcn 5660 DO n = 0, kct+1 5661 ijk = 1 5662 cellsum = 0.0_wp 5663 cellsumd = 0.0_wp 5664 ! 5665 !-- Note that the index name i must not be used here as a loop 5666 !-- index name since i is the constant boundary index, hence 5667 !-- the name ia. 5668 DO ia = ifl(l), ifu(l) 5669 DO j = jfl(m), jfu(m) 5670 DO k = kfl(n), kfu(n) 5671 cellsum = cellsum + MERGE( f(k,j,ia), 0.0_wp, & 5672 BTEST( wall_flags_0(k,j,ia), var_flag ) ) 5673 celltmpd(ijk) = ABS( fc(n,m,l) - f(k,j,ia) ) 5674 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 5675 0.0_wp, BTEST( wall_flags_0(k,j,ia), var_flag ) ) 5676 ijk = ijk + 1 5677 ENDDO 6815 !-- Apply the reversibility correction. 6816 6817 ! if ( var == 'u' ) then 6818 6819 l = ic(ibc) + loff 6820 lw = 1 6821 ! write(9,"('pmci_interp_tril_lr: edge, var, l, i, iend, ifl(l), ifu(l) = ',2(a2,2x),5(i4,2x))") & 6822 ! edge, var, l, i, iend, ifl(l), ifu(l) 6823 ! flush(9) 6824 !AH DO m = jcsw+1, jcnw-1 6825 DO m = jcsw + 1, jcnw - mnorthv ! mnorthv = 0 for v and 1 for all others 6826 DO n = 0, kct + ntopw ! ntopw = 1 for w and 0 for all others 6827 ijk = 1 6828 cellsum = 0.0_wp 6829 cellsumd = 0.0_wp 6830 ! 6831 !-- Note that the index name i must not be used here as a loop 6832 !-- index name since i is the constant boundary index, hence 6833 !-- the name ia. 6834 DO ia = ifl(l), ifu(l) 6835 iaw = ia - i 6836 iw = MAX( MIN( ia, nx+1 ), -1 ) 6837 DO j = jfl(m), jfu(m) 6838 jw = MAX( MIN( j, ny+1 ), -1 ) 6839 DO k = kfl(n), kfu(n) 6840 kw = MIN( k, nzt+1 ) 6841 !AH 6842 ! cellsum = cellsum + MERGE( f(k,j,ia), 0.0_wp, & 6843 ! BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 6844 cellsum = cellsum + MERGE( workarr_lr(k,j,iaw), 0.0_wp, & 6845 BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 6846 !AH 6847 6848 !AH celltmpd(ijk) = ABS( fc(n,m,l) - f(k,j,ia) ) 6849 !AH celltmpd(ijk) = ABS( workarrc_lr(n,m,lw) - f(k,j,ia) ) 6850 celltmpd(ijk) = ABS( workarrc_lr(n,m,lw) - workarr_lr(k,j,iaw) ) 6851 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 6852 0.0_wp, BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 6853 6854 ! write(9,"('lr1: ',a1,2x,8(i4,2x),5(e12.5,2x))") var, n, m, l, k, j, ia, iaw, ijk, & 6855 ! workarrc_lr(n,m,lw), workarr_lr(k,j,iaw), cellsum, celltmpd(ijk), cellsumd 6856 ! flush(9) 6857 6858 ijk = ijk + 1 5678 6859 ENDDO 5679 6860 ENDDO 5680 5681 IF ( ijkfc(n,m,l) /= 0 ) THEN 5682 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp ) 5683 rcorr = fc(n,m,l) - cellsum 5684 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp ) 5685 ELSE 5686 cellsum = 0.0_wp 5687 rcorr = 0.0_wp 5688 cellsumd = 1.0_wp 5689 celltmpd = 1.0_wp 5690 ENDIF 6861 ENDDO 6862 6863 IF ( ijkfc(n,m,l) /= 0 ) THEN 6864 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp ) 6865 ! rcorr = fc(n,m,l) - cellsum 6866 rcorr = workarrc_lr(n,m,lw) - cellsum 6867 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp ) 6868 ELSE 6869 cellsum = 0.0_wp 6870 rcorr = 0.0_wp 6871 cellsumd = 1.0_wp 6872 celltmpd = 1.0_wp 6873 ENDIF 5691 6874 ! 5692 !-- Distribute the correction term to the child nodes according to 5693 !-- their relative difference to the parent value such that the 5694 !-- node with the largest difference gets the largest share of the 5695 !-- correction. The distribution is skipped if rcorr is negligibly 5696 !-- small in order to avoid division by zero. 5697 IF ( ABS(rcorr) < 0.000001_wp ) THEN 5698 cellsumd = 1.0_wp 5699 celltmpd = 1.0_wp 5700 ENDIF 5701 5702 ijk = 1 5703 DO ia = ifl(l), ifu(l) 5704 DO j = jfl(m), jfu(m) 5705 DO k = kfl(n), kfu(n) 5706 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 5707 f(k,j,ia) = f(k,j,ia) + rcorr_ijk 5708 ijk = ijk + 1 5709 ENDDO 6875 !-- Distribute the correction term to the child nodes according to 6876 !-- their relative difference to the parent value such that the 6877 !-- node with the largest difference gets the largest share of the 6878 !-- correction. The distribution is skipped if rcorr is negligibly 6879 !-- small in order to avoid division by zero. 6880 IF ( ABS(rcorr) < 0.000001_wp ) THEN 6881 cellsumd = 1.0_wp 6882 celltmpd = 1.0_wp 6883 ENDIF 6884 6885 ijk = 1 6886 DO ia = ifl(l), ifu(l) 6887 !AH iaw = ia - ifl(l) 6888 iaw = ia - i 6889 DO j = jfl(m), jfu(m) 6890 DO k = kfl(n), kfu(n) 6891 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 6892 !AH f(k,j,ia) = f(k,j,ia) + rcorr_ijk 6893 workarr_lr(k,j,iaw) = workarr_lr(k,j,iaw) + rcorr_ijk 6894 6895 ! write(9,"('lr2: ',a1,2x,9(i4,2x),4(e12.5,2x))") var, n, m, l, k, j, ia, iaw, ijk, ijkfc(n,m,l), & 6896 ! rcorr, rcorr_ijk, workarr_lr(k,j,iaw), workarrc_lr(n,m,lw) 6897 ! flush(9) 6898 6899 ijk = ijk + 1 5710 6900 ENDDO 5711 6901 ENDDO 6902 ENDDO 6903 ! 6904 !-- Velocity components tangential to the boundary need special 6905 !-- treatment because their anterpolation cells are flat in their 6906 !-- direction and hence do not cover all the child-grid boundary nodes. 6907 !-- These components are next linearly interpolated to those child-grid 6908 !-- boundary nodes which are not covered by the anterpolation cells. 6909 IF ( ( var == 'w' ) .AND. ( n > 0 ) ) THEN 6910 DO k = kfu(n-1)+1, kfl(n)-1 6911 IF ( k <= nzt ) THEN 6912 DO j = jfl(m), jfu(m) 6913 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 6914 !AH 6915 ! f(k,j,ia) = r1z(k) * f(kfu(n-1),j,ia) & 6916 ! + r2z(k) * f(kfl(n),j,ia) 6917 workarr_lr(k,j,iawbc) = & 6918 r1z(k) * workarr_lr(kfu(n-1),j,iawbc) & 6919 + r2z(k) * workarr_lr(kfl(n),j,iawbc) 6920 6921 ! write(9,"('lr3: ',a1,2x,7(i4,2x),3(e12.5,2x))") var, n, m, l, k, j, iawbc, ibc, & 6922 ! workarr_lr(k-1,j,iawbc), workarr_lr(k,j,iawbc), workarr_lr(k+1,j,iawbc) 6923 ! flush(9) 6924 6925 !AH 6926 ENDIF 6927 ENDDO 6928 ENDIF 6929 ENDDO 6930 ENDIF 6931 6932 IF ( ( var == 'v' ) .AND. ( m > jcsw ) ) THEN 6933 DO j = jfu(m-1)+1, jfl(m)-1 6934 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 6935 DO k = kfl(n), kfu(n) 6936 IF ( k <= nzt+1 ) THEN 6937 !AH 6938 ! f(k,j,ia) = r1y(j) * f(k,jfu(m-1),ia) & 6939 ! + r2y(j) * f(k,jfl(m),ia) 6940 workarr_lr(k,j,iawbc) = & 6941 r1y(j) * workarr_lr(k,jfu(m-1),iawbc) & 6942 + r2y(j) * workarr_lr(k,jfl(m),iawbc) 6943 6944 ! write(9,"('lr4: ',a1,2x,7(i4,2x),3(e12.5,2x))") var, n, m, l, k, j, iawbc, ibc, & 6945 ! workarr_lr(k,j-1,iawbc), workarr_lr(k,j,iawbc), workarr_lr(k,j+1,iawbc) 6946 ! flush(9) 6947 6948 !AH 6949 ENDIF 6950 ENDDO 6951 ENDIF 6952 ENDDO 6953 ENDIF 5712 6954 5713 ENDDO ! n 5714 ENDDO ! m 5715 5716 ENDIF ! var not v or w 5717 ! 5718 !-- Store the boundary values also into the other redundant ghost node layers. 5719 !-- Note that in case of only one ghost node layer, e.g. for the PW 5720 !-- scheme, the following loops will not be entered. 5721 IF ( edge == 'l' ) THEN 5722 DO ibgp = -nbgp, ib 5723 f(0:nzt+1,nysg:nyng,ibgp) = f(0:nzt+1,nysg:nyng,i) 5724 ENDDO 5725 ELSEIF ( edge == 'r' ) THEN 5726 DO ibgp = ib, nx+nbgp 5727 f(0:nzt+1,nysg:nyng,ibgp) = f(0:nzt+1,nysg:nyng,i) 5728 ENDDO 5729 ENDIF 6955 ENDDO ! n 6956 ENDDO ! m 6957 6958 ! endif ! var 6959 6960 ! 6961 !-- Finally substitute the boundary values. 6962 f(nzb:nzt+1,nys:nyn,ibc) = workarr_lr(nzb:nzt+1,nys:nyn,iawbc) 6963 6964 ! do k = 0, 2 6965 ! do j = nys, nyn 6966 ! if ( edge == 'l' ) then 6967 ! write(9,"('lr5: ',2(a2,2x),4(i4,2x),4(e12.5,2x))") edge, var, k, j, ibc, iawbc, & 6968 ! workarr_lr(k,j,iawbc), f(k,j,ibc), f(k,j,ibc+1), f(k,j,ibc+2) 6969 ! else if ( edge == 'r' ) then 6970 ! write(9,"('lr5: ',2(a2,2x),4(i4,2x),4(e12.5,2x))") edge, var, k, j, ibc, iawbc, & 6971 ! f(k,j,ibc-2), f(k,j,ibc-1), f(k,j,ibc), workarr_lr(k,j,iawbc) 6972 ! endif 6973 ! enddo 6974 ! enddo 6975 ! flush(9) 5730 6976 5731 6977 END SUBROUTINE pmci_interp_tril_lr … … 5754 7000 REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nxl:nxr), & 5755 7001 INTENT(IN) :: logc_ratio !< 5756 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x !< 5757 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x !< 5758 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r1y !< 5759 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r2y !< 5760 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 5761 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 7002 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 7003 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 7004 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 7005 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 7006 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 7007 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 7008 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 7009 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 7010 5762 7011 5763 INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) :: ic !< 5764 INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) :: jc !< 5765 INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 7012 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 7013 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 7014 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 7015 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 5766 7016 INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nxl:nxr), & 5767 7017 INTENT(IN) :: logc !< … … 5769 7019 5770 7020 INTEGER(iwp) :: kct 5771 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 5772 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 5773 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 5774 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7021 !AH 7022 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7023 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7024 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7025 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7026 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7027 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7028 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7029 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7030 !AH 7031 5775 7032 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 5776 7033 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction … … 5778 7035 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 5779 7036 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5780 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 5781 5782 CHARACTER(LEN=1), INTENT(IN) :: edge !< 5783 CHARACTER(LEN=1), INTENT(IN) :: var !< 7037 !AH 7038 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7039 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7040 !AH 7041 7042 CHARACTER(LEN=1), INTENT(IN) :: edge !< Edge symbol: 'l', 'r', 's' or 'n' 7043 CHARACTER(LEN=1), INTENT(IN) :: var !< Variable symbol: 'u', 'v', 'w' or 's' 5784 7044 5785 INTEGER(iwp) :: i !< 5786 INTEGER(iwp) :: iinc !< 5787 INTEGER(iwp) :: icorr !< 5788 INTEGER(iwp) :: ico !< 5789 INTEGER(iwp) :: ijk !< 5790 INTEGER(iwp) :: i1 !< 5791 INTEGER(iwp) :: j !< 5792 INTEGER(iwp) :: ja !< 5793 INTEGER(iwp) :: jb !< 5794 INTEGER(iwp) :: jbgp !< 5795 INTEGER(iwp) :: k !< 5796 INTEGER(iwp) :: k_wall !< vertical index of topography top 5797 INTEGER(iwp) :: kcorr !< 5798 INTEGER(iwp) :: kco !< 5799 INTEGER(iwp) :: k1 !< 5800 INTEGER(iwp) :: l !< 5801 INTEGER(iwp) :: m !< 5802 INTEGER(iwp) :: n !< 5803 INTEGER(iwp) :: var_flag !< 5804 5805 REAL(wp) :: cellsum !< 5806 REAL(wp) :: cellsumd !< 5807 REAL(wp) :: fk !< 5808 REAL(wp) :: fkj !< 5809 REAL(wp) :: fkjp !< 5810 REAL(wp) :: fkpj !< 5811 REAL(wp) :: fkpjp !< 5812 REAL(wp) :: fkp !< 5813 REAL(wp) :: rcorr !< 5814 REAL(wp) :: rcorr_ijk !< 5815 7045 INTEGER(iwp) :: i !< Running index in the x-direction 7046 INTEGER(iwp) :: iinc !< 7047 INTEGER(iwp) :: icorr !< 7048 INTEGER(iwp) :: ico !< 7049 INTEGER(iwp) :: ierr !< MPI error code 7050 INTEGER(iwp) :: ijk !< Running index for all child-grid cells within the anterpolation cell 7051 INTEGER(iwp) :: iw !< i-index for wall_flags_0 7052 INTEGER(iwp) :: i1 !< 7053 INTEGER(iwp) :: j !< Lower bound of the running index ja 7054 INTEGER(iwp) :: ja !< Index in y-direction running over the parent-grid cell on the boundary 7055 INTEGER(iwp) :: jaw !< Reduced ja-index for workarr_sn 7056 INTEGER(iwp) :: jawbc !< jaw-index pointing to the boundary-value nodes (either 0 or jgsr-1) 7057 !AH INTEGER(iwp) :: jbeg !< j-index pointing to the starting point of workarr_sn in the j-direction 7058 INTEGER(iwp) :: jbc !< Fixed j-index pointing to the boundary-value nodes (either j or jend) 7059 INTEGER(iwp) :: jend !< Upper bound of the running index ja 7060 INTEGER(iwp) :: jw !< j-index for wall_flags_0 7061 INTEGER(iwp) :: k !< Running index in the z-direction 7062 INTEGER(iwp) :: k_wall !< Vertical index of topography top 7063 INTEGER(iwp) :: kcorr !< 7064 INTEGER(iwp) :: kco !< 7065 INTEGER(iwp) :: kw !< k-index for wall_flags_0 7066 INTEGER(iwp) :: k1 !< 7067 INTEGER(iwp) :: l !< Parent-grid running index in the x-direction 7068 INTEGER(iwp) :: lp1 !< l+1 7069 INTEGER(iwp) :: lrightu !< Upshift by one for the upper bound of index l in case of var == 'u' 7070 INTEGER(iwp) :: m !< Parent-grid running index in the y-direction 7071 INTEGER(iwp) :: mbeg !< m-index pointing to the starting point of workarrc_sn in the m-direction 7072 INTEGER(iwp) :: moff !< m-offset needed on the north boundary to correctly refer to boundary ghost points 7073 INTEGER(iwp) :: mp1 !< m+1 7074 INTEGER(iwp) :: mw !< Reduced m-index for workarrc_sn 7075 INTEGER(iwp) :: n !< Parent-grid running index in the z-direction 7076 INTEGER(iwp) :: np1 !< n+1 7077 INTEGER(iwp) :: ntopw !< Upshift by one for the upper bound of index n in case of var == 'w' 7078 INTEGER(iwp) :: var_flag !< Variable flag for BTEST( wall_flags_0 ) 7079 7080 REAL(wp) :: cellsum !< Sum of child-grid node values over the anterpolation cell 7081 REAL(wp) :: cellsumd !< Sum of differences over the anterpolation cell 7082 REAL(wp) :: fk !< Intermediate result in trilinear interpolation 7083 REAL(wp) :: fkj !< Intermediate result in trilinear interpolation 7084 REAL(wp) :: fkjp !< Intermediate result in trilinear interpolation 7085 REAL(wp) :: fkpj !< Intermediate result in trilinear interpolation 7086 REAL(wp) :: fkpjp !< Intermediate result in trilinear interpolation 7087 REAL(wp) :: fkp !< Intermediate result in trilinear interpolation 7088 REAL(wp) :: rcorr !< Average reversibility correction for the whole anterpolation cell 7089 REAL(wp) :: rcorr_ijk !< Reversibility correction distributed to the individual child-grid nodes 7090 5816 7091 ! 5817 7092 !-- Check which edge is to be handled: south or north … … 5820 7095 !-- For v, nys is a ghost node, but not for the other variables 5821 7096 IF ( var == 'v' ) THEN 5822 j = nys 5823 jb = nys - 1 7097 j = nys 7098 jend = nys 7099 jawbc = 0 7100 jbc = nys 7101 mbeg = jcs 7102 moff = 0 5824 7103 ELSE 5825 j = nys - 1 5826 jb = nys - 2 7104 j = nys - jgsr 7105 jend = nys - 1 7106 jawbc = jgsr - 1 7107 jbc = nys - 1 7108 mbeg = jcs 7109 moff = 0 5827 7110 ENDIF 5828 7111 ELSEIF ( edge == 'n' ) THEN 5829 j = nyn + 1 5830 jb = nyn + 2 7112 IF ( var == 'v' ) THEN 7113 j = nyn + 1 7114 jend = nyn + 1 7115 jawbc = 0 7116 jbc = nyn + 1 7117 mbeg = jcn - 2 7118 moff = 0 7119 ELSE 7120 j = nyn + 1 7121 jend = nyn + jgsr 7122 jawbc = 0 7123 jbc = nyn + 1 7124 mbeg = jcn - 2 7125 moff = 1 7126 ENDIF 7127 ENDIF 7128 7129 IF ( var == 'w' ) THEN 7130 ntopw = 1 7131 ELSE 7132 ntopw = 0 7133 ENDIF 7134 7135 IF ( var == 'u' ) THEN 7136 lrightu = 0 7137 ELSE 7138 lrightu = 1 5831 7139 ENDIF 5832 7140 … … 5840 7148 var_flag = 0 5841 7149 ENDIF 5842 5843 DO i = nxl, nxr+1 5844 ! 5845 !-- Determine vertical index of topography top at grid point (j,i) 5846 !AH k_wall = get_topography_top_index_ji( j, i, TRIM( var ) ) 5847 5848 DO k = nzb, nzt+1 !AH k_wall, nzt+1 5849 l = ic(i) 5850 m = jc(j) 5851 n = kc(k) 5852 fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 5853 fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 5854 fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 5855 fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 5856 fk = r1y(j) * fkj + r2y(j) * fkjp 5857 fkp = r1y(j) * fkpj + r2y(j) * fkpjp 5858 f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 7150 !AH 7151 ! 7152 !-- Substitute the necessary parent-grid data to the work array workarrc_sn. 7153 workarrc_sn = 0.0_wp 7154 IF ( pdims(1) > 1 ) THEN 7155 #if defined( __parallel ) 7156 IF ( nxl == 0 ) THEN ! if ( bc_dirichlet_l ) 7157 workarrc_sn(0:cg%nz+1,0:2,iclw:icrw-1) & 7158 = fc(0:cg%nz+1,mbeg:mbeg+2,iclw:icrw-1) 7159 ELSE IF ( nxr == nx ) THEN ! if ( bc_dirichlet_r ) 7160 workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw) & 7161 = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw) 7162 ELSE 7163 workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw-1) & 7164 = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw-1) 7165 ENDIF 7166 ! 7167 !-- Left-right exchange if more than one PE subdomain in the x-direction. 7168 !-- Note that in case of 3-D nesting the left (pleft == MPI_PROC_NULL) and 7169 !-- right (pright == MPI_PROC_NULL) boundaries are not exchanged because 7170 !-- the nest domain is not cyclic. 7171 !-- From left to right 7172 CALL MPI_SENDRECV( workarrc_sn(0,0,iclw+1), 1, & 7173 workarrc_sn_exchange_type, pleft, 0, & 7174 workarrc_sn(0,0,icrw), 1, & 7175 workarrc_sn_exchange_type, pright, 0, & 7176 comm2d, status, ierr ) 7177 ! 7178 !-- From right to left 7179 CALL MPI_SENDRECV( workarrc_sn(0,0,icrw-1), 1, & 7180 workarrc_sn_exchange_type, pright, 1, & 7181 workarrc_sn(0,0,iclw), 1, & 7182 workarrc_sn_exchange_type, pleft, 1, & 7183 comm2d, status, ierr ) 7184 #endif 7185 ELSE 7186 workarrc_sn(0:cg%nz+1,0:2,iclw+1:icrw-1) & 7187 = fc(0:cg%nz+1,mbeg:mbeg+2,iclw+1:icrw-1) 7188 ENDIF 7189 ! 7190 !AH 7191 7192 workarr_sn = 0.0_wp 7193 7194 DO i = nxl-1, nxr+1 7195 !AH DO i = nxl, nxr 7196 DO ja = j, jend 7197 jaw = ja - j 7198 DO k = nzb, nzt+1 7199 l = ic(i) 7200 lp1 = MIN( l + 1, icrw ) ! If l+1 > icr (l=ic(nxr+1)), r1x = 1 and r2x = 0 7201 !AH m = jc(ja) - jc(j) 7202 m = jc(ja) - mbeg 7203 mp1 = MIN( m + 1, 2 ) ! If m+1 > 2 (m=jc(nyn+1)-mbeg), r1y = 1 and r2y = 0 7204 n = kc(k) 7205 np1 = n + 1 7206 !AH 7207 ! fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 7208 ! fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 7209 ! fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 7210 ! fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 7211 !AH 7212 fkj = r1x(i) * workarrc_sn(n,m,l) + r2x(i) * workarrc_sn(n,m,lp1) 7213 fkjp = r1x(i) * workarrc_sn(n,mp1,l) + r2x(i) * workarrc_sn(n,mp1,lp1) 7214 fkpj = r1x(i) * workarrc_sn(np1,m,l) + r2x(i) * workarrc_sn(np1,m,lp1) 7215 fkpjp = r1x(i) * workarrc_sn(np1,mp1,l) + r2x(i) * workarrc_sn(np1,mp1,lp1) 7216 7217 fk = r1y(ja) * fkj + r2y(ja) * fkjp 7218 fkp = r1y(ja) * fkpj + r2y(ja) * fkpjp 7219 !AH 7220 ! f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 7221 workarr_sn(k,jaw,i) = r1z(k) * fk + r2z(k) * fkp 7222 7223 ! if ( ( edge == 's' ) .and. ( ja == jbc ) ) then 7224 ! write(9,"('pmci_interp_tril_sn: ',a2,2x,11(i4,2x),1(e12.5,2x))") var, k, ja, i, jbc, jaw, n, m, l, np1, mp1, lp1, & 7225 ! workarr_sn(k,jaw,i) 7226 ! flush(9) 7227 ! endif 7228 7229 !AH 7230 ENDDO 5859 7231 ENDDO 5860 ENDDO 7232 ENDDO 5861 7233 ! 5862 7234 !-- Generalized log-law-correction algorithm. … … 5938 7310 ENDIF ! ( topography /= 'flat' ) 5939 7311 ! 5940 !-- Apply the reversibility correction to the boundary-normal velocity- 5941 !-- component v and the scalars. It must not be applied to the boundary- 5942 !-- tangential velocity components u and w because their 2-D anterpolation 5943 !-- cells do not cover all the child-grid nodes on the boundary. 5944 IF ( .NOT. ( ( var == 'u' ) .OR. ( var == 'w' ) ) ) THEN 5945 m = jc(j) 5946 DO l = icl, icr 5947 DO n = 0, kct+1 7312 !-- Apply the reversibility correction. 7313 7314 ! if ( var == 'u' ) then 7315 7316 m = jc(jbc) + moff 7317 mw = 1 7318 ! write(9,"('pmci_interp_tril_sn: edge, var, m, j, jend, jfl(m), jfu(m) = ',2(a2,2x),5(i4,2x))") & 7319 ! edge, var, m, j, jend, jfl(m), jfu(m) 7320 ! flush(9) 7321 !AH DO l = iclw+1, icrw-1 7322 DO l = iclw + 1, icrw - lrightu ! lrightu = 0 for u and 1 for all others 7323 DO n = 0, kct + ntopw ! ntopw = 1 for w and 0 for all others 7324 ijk = 1 7325 cellsum = 0.0_wp 7326 cellsumd = 0.0_wp 7327 DO i = ifl(l), ifu(l) 7328 iw = MAX( MIN( i, nx+1 ), -1 ) 7329 DO ja = jfl(m), jfu(m) 7330 jaw = ja - j 7331 jw = MAX( MIN( ja, ny+1 ), -1 ) 7332 DO k = kfl(n), kfu(n) 7333 kw = MIN( k, nzt+1 ) 7334 !AH cellsum = cellsum + MERGE( f(k,ja,i), 0.0_wp, & 7335 !AH BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 7336 cellsum = cellsum + MERGE( workarr_sn(k,jaw,i), 0.0_wp, & 7337 BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 7338 !AH celltmpd(ijk) = ABS( fc(n,m,l) - f(k,ja,i) ) 7339 !AH celltmpd(ijk) = ABS( workarrc_sn(n,mw,l) - f(k,ja,i) ) 7340 celltmpd(ijk) = ABS( workarrc_sn(n,mw,l) - workarr_sn(k,jaw,i) ) 7341 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 7342 0.0_wp, BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 7343 7344 ! write(9,"('sn1: ',a1,2x,8(i4,2x),5(e12.5,2x))") var, n, m, l, k, ja, i, jaw, ijk, & 7345 ! workarrc_sn(n,mw,l), workarr_sn(k,jaw,i), cellsum, celltmpd(ijk), cellsumd 7346 ! flush(9) 7347 7348 ijk = ijk + 1 7349 ENDDO 7350 ENDDO 7351 ENDDO 7352 7353 IF ( ijkfc(n,m,l) /= 0 ) THEN 7354 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp ) 7355 !AH rcorr = fc(n,m,l) - cellsum 7356 rcorr = workarrc_sn(n,mw,l) - cellsum 7357 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp ) 7358 ELSE 7359 cellsum = 0.0_wp 7360 rcorr = 0.0_wp 7361 cellsumd = 1.0_wp 7362 celltmpd = 1.0_wp 7363 ENDIF 7364 ! 7365 !-- Distribute the correction term to the child nodes according to 7366 !-- their relative difference to the parent value such that the 7367 !-- node with the largest difference gets the largest share of the 7368 !-- correction. The distribution is skipped if rcorr is negligibly 7369 !-- small in order to avoid division by zero. 7370 IF ( ABS(rcorr) < 0.000001_wp ) THEN 7371 cellsumd = 1.0_wp 7372 celltmpd = 1.0_wp 7373 ENDIF 7374 7375 ijk = 1 7376 DO i = ifl(l), ifu(l) 7377 DO ja = jfl(m), jfu(m) 7378 !AH jaw = ja - jfl(m) 7379 jaw = ja - j 7380 DO k = kfl(n), kfu(n) 7381 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 7382 !AH f(k,ja,i) = f(k,ja,i) + rcorr_ijk 7383 workarr_sn(k,jaw,i) = workarr_sn(k,jaw,i) + rcorr_ijk 7384 7385 ! write(9,"('sn2: ',a1,2x,9(i4,2x),4(e12.5,2x))") var, n, m, l, k, ja, i, jaw, ijk, ijkfc(n,m,l), & 7386 ! rcorr, rcorr_ijk, workarr_sn(k,jaw,i), workarrc_sn(n,mw,l) 7387 ! flush(9) 7388 7389 ijk = ijk + 1 7390 ENDDO 7391 ENDDO 7392 ENDDO 7393 ! 7394 !-- Velocity components tangential to the boundary need special 7395 !-- treatment because their anterpolation cells are flat in their 7396 !-- direction and hence do not cover all the child-grid boundary nodes. 7397 !-- These components are next linearly interpolated to those child-grid 7398 !-- boundary nodes which are not covered by the anterpolation cells. 7399 IF ( ( var == 'w' ) .AND. ( n > 0 ) ) THEN 7400 DO k = kfu(n-1)+1, kfl(n)-1 7401 IF ( k <= nzt ) THEN 7402 DO i = ifl(l), ifu(l) 7403 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7404 !AH f(k,ja,i) = r1z(k) * f(kfu(n-1),ja,i) & 7405 !AH + r2z(k) * f(kfl(n),ja,i) 7406 workarr_sn(k,jawbc,i) = & 7407 r1z(k) * workarr_sn(kfu(n-1),jawbc,i) + & 7408 r2z(k) * workarr_sn(kfl(n),jawbc,i) 7409 7410 ! write(9,"('sn3: ',a1,2x,7(i4,2x),3(e12.5,2x))") var, n, m, l, k, jawbc, i, jbc, & 7411 ! workarr_sn(k-1,jawbc,i), workarr_sn(k,jawbc,i), workarr_sn(k+1,jawbc,i) 7412 ! flush(9) 7413 7414 ENDIF 7415 ENDDO 7416 ENDIF 7417 ENDDO 7418 ENDIF 7419 7420 IF ( ( var == 'u' ) .AND. ( l > iclw ) ) THEN 7421 DO i = ifu(l-1)+1, ifl(l)-1 7422 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7423 DO k = kfl(n), kfu(n) 7424 IF ( k <= nzt+1 ) THEN 7425 !AH f(k,ja,i) = r1x(i) * f(k,ja,ifu(l-1)) & 7426 !AH + r2x(i) * f(k,ja,ifl(l)) 7427 workarr_sn(k,jawbc,i) = & 7428 r1x(i) * workarr_sn(k,jawbc,ifu(l-1)) + & 7429 r2x(i) * workarr_sn(k,jawbc,ifl(l)) 7430 7431 ! write(9,"('sn4: ',a1,2x,7(i4,2x),3(e12.5,2x))") var, n, m, l, k, jawbc, i, jbc, & 7432 ! workarr_sn(k,jawbc,i-1), workarr_sn(k,jawbc,i), workarr_sn(k,jawbc,i+1) 7433 ! flush(9) 7434 7435 ENDIF 7436 ENDDO 7437 ENDIF 7438 ENDDO 7439 ENDIF 7440 7441 ENDDO ! n 7442 ENDDO ! l 7443 7444 ! endif ! var 7445 7446 ! 7447 !-- Finally substitute the boundary values. 7448 f(nzb:nzt+1,jbc,nxl:nxr) = workarr_sn(nzb:nzt+1,jawbc,nxl:nxr) 7449 7450 ! do k = 0, 2 7451 ! do i = nxl, nxr 7452 ! if ( edge == 's' ) then 7453 ! write(9,"('sn5: ',2(a2,2x),4(i4,2x),4(e12.5,2x))") edge, var, k, i, jbc, jawbc, & 7454 ! workarr_sn(k,jawbc,i), f(k,jbc,i), f(k,jbc+1,i), f(k,jbc+2,i) 7455 ! else if ( edge == 'n' ) then 7456 ! write(9,"('sn5: ',2(a2,2x),4(i4,2x),4(e12.5,2x))") edge, var, k, i, jbc, jawbc, & 7457 ! f(k,jbc-2,i), f(k,jbc-1,i), f(k,jbc,i), workarr_sn(k,jawbc,i) 7458 ! endif 7459 ! enddo 7460 ! enddo 7461 ! flush(9) 7462 7463 END SUBROUTINE pmci_interp_tril_sn 7464 7465 7466 7467 SUBROUTINE pmci_interp_tril_t( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, & 7468 r1z, r2z, kct, ifl, ifu, jfl, jfu, kfl, kfu, & 7469 ijkfc, var ) 7470 7471 ! 7472 !-- Interpolation of ghost-node values used as the child-domain boundary 7473 !-- conditions. This subroutine handles the top boundary. 7474 !-- This subroutine is based on trilinear interpolation. 7475 7476 IMPLICIT NONE 7477 7478 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), & 7479 INTENT(INOUT) :: f !< Child-grid array 7480 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), & 7481 INTENT(IN) :: fc !< Parent-grid array 7482 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r1x !< 7483 REAL(wp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: r2x !< 7484 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r1y !< 7485 REAL(wp), DIMENSION(nysfc:nynfc), INTENT(IN) :: r2y !< 7486 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !< 7487 !AH REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !< 7488 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r1z !< 7489 REAL(wp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: r2z !< 7490 7491 7492 INTEGER(iwp), DIMENSION(nxlfc:nxrfc), INTENT(IN) :: ic !< 7493 INTEGER(iwp), DIMENSION(nysfc:nynfc), INTENT(IN) :: jc !< 7494 !AH INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !< 7495 INTEGER(iwp), DIMENSION(nzb:nzt+kgsr), INTENT(IN) :: kc !< 7496 7497 INTEGER(iwp) :: kct 7498 !AH 7499 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7500 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7501 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7502 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7503 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7504 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7505 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7506 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7507 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 7508 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 7509 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 7510 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction 7511 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7512 !AH 7513 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7514 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7515 !AH 7516 7517 CHARACTER(LEN=1), INTENT(IN) :: var !< 7518 7519 INTEGER(iwp) :: i !< 7520 INTEGER(iwp) :: ib !< 7521 INTEGER(iwp) :: iclc !< Lower i-index limit for copying fc-data to workarrc_t 7522 INTEGER(iwp) :: icrc !< Upper i-index limit for copying fc-data to workarrc_t 7523 INTEGER(iwp) :: ie !< 7524 INTEGER(iwp) :: ierr !< MPI error code 7525 INTEGER(iwp) :: ijk !< 7526 INTEGER(iwp) :: iw !< 7527 INTEGER(iwp) :: j !< 7528 INTEGER(iwp) :: jb !< 7529 INTEGER(iwp) :: jcsc !< Lower j-index limit for copying fc-data to workarrc_t 7530 INTEGER(iwp) :: jcnc !< Upper j-index limit for copying fc-data to workarrc_t 7531 INTEGER(iwp) :: je !< 7532 INTEGER(iwp) :: jw !< 7533 INTEGER(iwp) :: k !< Vertical child-grid index fixed to the boundary-value level 7534 INTEGER(iwp) :: ka !< Running vertical child-grid index 7535 INTEGER(iwp) :: kw !< 7536 INTEGER(iwp) :: l !< Parent-grid index in x-direction 7537 INTEGER(iwp) :: lp1 !< l+1 7538 INTEGER(iwp) :: m !< Parent-grid index in y-direction 7539 INTEGER(iwp) :: mp1 !< m+1 7540 INTEGER(iwp) :: n !< Parent-grid work array index in z-direction 7541 INTEGER(iwp) :: np1 !< n+1 7542 INTEGER(iwp) :: noff !< n-offset needed on the top boundary to correctly refer to boundary ghost points 7543 INTEGER(iwp) :: nw !< n-index for workarrc_t 7544 INTEGER(iwp) :: var_flag !< 7545 7546 REAL(wp) :: cellsum !< 7547 REAL(wp) :: cellsumd !< 7548 REAL(wp) :: fk !< 7549 REAL(wp) :: fkj !< 7550 REAL(wp) :: fkjp !< 7551 REAL(wp) :: fkpj !< 7552 REAL(wp) :: fkpjp !< 7553 REAL(wp) :: fkp !< 7554 REAL(wp) :: rcorr !< 7555 REAL(wp) :: rcorr_ijk !< 7556 7557 integer(iwp) :: kend 7558 7559 7560 IF ( var == 'w' ) THEN 7561 k = nzt 7562 noff = 0 7563 kend = nzt 7564 ELSE 7565 k = nzt + 1 7566 noff = 1 7567 kend = nzt+kgsr 7568 ENDIF 7569 ! 7570 !-- These exceedings by one are needed only to avoid stripes 7571 !-- and spots in visualization. They have no effect on the 7572 !-- actual solution. 7573 ! 7574 !AH These loop bounds lead to overflows with the current reduced icl, icr, jcs, jcn 7575 !AH ib = nxl-1 7576 !AH ie = nxr+1 7577 !AH jb = nys-1 7578 !AH je = nyn+1 7579 ib = nxl 7580 ie = nxr 7581 jb = nys 7582 je = nyn 7583 7584 IF ( var == 'u' ) THEN 7585 var_flag = 1 7586 ie = nxr + 1 ! Needed for finishing interpolation for u 7587 ELSEIF ( var == 'v' ) THEN 7588 var_flag = 2 7589 je = nyn + 1 ! Needed for finishing interpolation for v 7590 ELSEIF ( var == 'w' ) THEN 7591 var_flag = 3 7592 ELSE 7593 var_flag = 0 7594 ENDIF 7595 7596 !AH DO i = ib, ie 7597 !AH DO j = jb, je 7598 !AH l = ic(i) 7599 !AH m = jc(j) 7600 !AH n = kc(k) 7601 !AH fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 7602 !AH fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 7603 !AH fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 7604 !AH fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 7605 !AH fk = r1y(j) * fkj + r2y(j) * fkjp 7606 !AH fkp = r1y(j) * fkpj + r2y(j) * fkpjp 7607 !AH f(k,j,i) = r1z(k) * fk + r2z(k) * fkp 7608 !AH ENDDO 7609 !AH ENDDO 7610 7611 ! write(9,"('workarrc_t kbounds: ',a2,2x,5(i3,2x))") var, k, kend, kc(k), kc(kend), cg%nz+1 7612 ! flush(9) 7613 !AH 7614 ! 7615 !-- Substitute the necessary parent-grid data to the work array. 7616 !-- Note that the dimension of workarrc_t is (0:2,jcsw:jcnw,iclw:icrw), 7617 !-- And the jc?w and ic?w-index bounds depend on the location of the PE- 7618 !-- subdomain relative to the side boundaries. 7619 iclc = iclw + 1 7620 icrc = icrw - 1 7621 jcsc = jcsw + 1 7622 jcnc = jcnw - 1 7623 IF ( bc_dirichlet_l ) THEN 7624 iclc = iclw 7625 ENDIF 7626 IF ( bc_dirichlet_r ) THEN 7627 icrc = icrw 7628 ENDIF 7629 IF ( bc_dirichlet_s ) THEN 7630 jcsc = jcsw 7631 ENDIF 7632 IF ( bc_dirichlet_n ) THEN 7633 jcnc = jcnw 7634 ENDIF 7635 workarrc_t = 0.0_wp 7636 workarrc_t(0:2,jcsc:jcnc,iclc:icrc) & 7637 = fc(kc(k):kc(k)+2,jcsc:jcnc,iclc:icrc) 7638 ! 7639 !-- Left-right exchange if more than one PE subdomain in the x-direction. 7640 !-- Note that in case of 3-D nesting the left and right boundaries are 7641 !-- not exchanged because the nest domain is not cyclic. 7642 #if defined( __parallel ) 7643 IF ( pdims(1) > 1 ) THEN 7644 ! 7645 !-- From left to right 7646 CALL MPI_SENDRECV( workarrc_t(0,jcsw,iclw+1), 1, & 7647 workarrc_t_exchange_type_y, pleft, 0, & 7648 workarrc_t(0,jcsw,icrw), 1, & 7649 workarrc_t_exchange_type_y, pright, 0, & 7650 comm2d, status, ierr ) 7651 ! 7652 !-- From right to left 7653 CALL MPI_SENDRECV( workarrc_t(0,jcsw,icrw-1), 1, & 7654 workarrc_t_exchange_type_y, pright, 1, & 7655 workarrc_t(0,jcsw,iclw), 1, & 7656 workarrc_t_exchange_type_y, pleft, 1, & 7657 comm2d, status, ierr ) 7658 ENDIF 7659 ! 7660 !-- South-north exchange if more than one PE subdomain in the y-direction. 7661 !-- Note that in case of 3-D nesting the south and north boundaries are 7662 !-- not exchanged because the nest domain is not cyclic. 7663 IF ( pdims(2) > 1 ) THEN 7664 ! 7665 !-- From south to north 7666 CALL MPI_SENDRECV( workarrc_t(0,jcsw+1,iclw), 1, & 7667 workarrc_t_exchange_type_x, psouth, 2, & 7668 workarrc_t(0,jcnw,iclw), 1, & 7669 workarrc_t_exchange_type_x, pnorth, 2, & 7670 comm2d, status, ierr ) 7671 ! 7672 !-- From north to south 7673 CALL MPI_SENDRECV( workarrc_t(0,jcnw-1,iclw), 1, & 7674 workarrc_t_exchange_type_x, pnorth, 3, & 7675 workarrc_t(0,jcsw,iclw), 1, & 7676 workarrc_t_exchange_type_x, psouth, 3, & 7677 comm2d, status, ierr ) 7678 ENDIF 7679 #endif 7680 ! 7681 !AH 7682 7683 workarr_t = 0.0_wp 7684 7685 DO i = ib, ie 7686 DO j = jb, je 7687 DO ka = k, kend 7688 l = ic(i) 7689 lp1 = MIN( l + 1, icrw ) ! If l+1 > icr (l=ic(nxr+1)), r1x = 1 and r2x = 0 7690 m = jc(j) 7691 mp1 = MIN( m + 1, jcnw ) ! If m+1 > jcn (m=jc(nyn+1)), r1y = 1 and r2y = 0 7692 !AH 7693 ! n = kc(ka) 7694 n = kc(ka) - kc(k) 7695 np1 = n + 1 7696 !AH 7697 ! fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1) 7698 ! fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1) 7699 ! fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1) 7700 ! fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1) 7701 !AH 7702 fkj = r1x(i) * workarrc_t(n,m,l) + r2x(i) * workarrc_t(n,m,lp1) 7703 fkjp = r1x(i) * workarrc_t(n,mp1,l) + r2x(i) * workarrc_t(n,mp1,lp1) 7704 fkpj = r1x(i) * workarrc_t(np1,m,l) + r2x(i) * workarrc_t(np1,m,lp1) 7705 fkpjp = r1x(i) * workarrc_t(np1,mp1,l) + r2x(i) * workarrc_t(np1,mp1,lp1) 7706 !AH 7707 fk = r1y(j) * fkj + r2y(j) * fkjp 7708 fkp = r1y(j) * fkpj + r2y(j) * fkpjp 7709 workarr_t(ka,j,i) = r1z(ka) * fk + r2z(ka) * fkp 7710 7711 ENDDO 7712 ENDDO 7713 ENDDO 7714 7715 !AH! 7716 !AH!-- Just fill up the redundant second ghost-node layer for w. 7717 !AH IF ( var == 'w' ) THEN 7718 !AH f(nzt+1,:,:) = f(nzt,:,:) 7719 !AH ENDIF 7720 ! 7721 !-- Apply the reversibility correction. 7722 n = kc(k) + noff 7723 nw = 0 7724 !AH DO l = icl-1, icr+1 7725 DO l = iclw, icrw 7726 !AH DO m = jcs-1, jcn+1 7727 DO m = jcsw, jcnw 5948 7728 ijk = 1 5949 cellsum = 0.0_wp 7729 cellsum = 0.0_wp 5950 7730 cellsumd = 0.0_wp 5951 7731 DO i = ifl(l), ifu(l) 5952 DO ja = jfl(m), jfu(m) 5953 DO k = kfl(n), kfu(n) 5954 cellsum = cellsum + MERGE( f(k,ja,i), 0.0_wp, & 5955 BTEST( wall_flags_0(k,ja,i), var_flag ) ) 5956 celltmpd(ijk) = ABS( fc(n,m,l) - f(k,ja,i) ) 5957 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 5958 0.0_wp, BTEST( wall_flags_0(k,ja,i), var_flag ) ) 5959 ijk = ijk + 1 7732 iw = MAX( MIN( i, nx+1 ), -1 ) 7733 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7734 DO j = jfl(m), jfu(m) 7735 jw = MAX( MIN( j, ny+1 ), -1 ) 7736 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 7737 DO ka = kfl(n), kfu(n) 7738 kw = MIN( ka, nzt+1 ) 7739 !AH cellsum = cellsum + MERGE( f(ka,j,i), 0.0_wp, & 7740 cellsum = cellsum + MERGE( workarr_t(ka,j,i), 0.0_wp, & 7741 BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 7742 ! cellsum = cellsum + workarr_t(ka,j,i) 7743 !AH celltmpd(ijk) = ABS( fc(n,m,l) - f(ka,j,i) ) 7744 !AH 7745 ! celltmpd(ijk) = ABS( fc(n,m,l) - workarr_t(ka,j,i) ) 7746 celltmpd(ijk) = ABS( workarrc_t(nw,m,l) - workarr_t(ka,j,i) ) 7747 !AH 7748 cellsumd = cellsumd + MERGE( celltmpd(ijk), & 7749 0.0_wp, BTEST( wall_flags_0(kw,jw,iw), var_flag ) ) 7750 ijk = ijk + 1 7751 ENDDO 7752 ENDIF 5960 7753 ENDDO 5961 END DO7754 ENDIF 5962 7755 ENDDO 5963 7756 5964 7757 IF ( ijkfc(n,m,l) /= 0 ) THEN 5965 7758 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp ) 5966 rcorr = fc(n,m,l) - cellsum 7759 !AH 7760 ! rcorr = fc(n,m,l) - cellsum 7761 rcorr = workarrc_t(nw,m,l) - cellsum 7762 !AH 5967 7763 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp ) 5968 7764 ELSE 5969 cellsum = 0.0_wp 7765 cellsum = 0.0_wp 5970 7766 rcorr = 0.0_wp 5971 7767 cellsumd = 1.0_wp … … 5983 7779 ENDIF 5984 7780 5985 ijk = 15986 DO i = ifl(l), ifu(l)5987 DO ja = jfl(m), jfu(m)5988 DO k = kfl(n), kfu(n)5989 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd5990 f(k,ja,i) = f(k,ja,i) + rcorr_ijk5991 ijk = ijk + 15992 ENDDO5993 ENDDO5994 ENDDO5995 5996 ENDDO ! n5997 ENDDO ! l5998 5999 ENDIF ! var not u or w6000 !6001 !-- Store the boundary values also into the other redundant ghost node layers.6002 !-- Note that in case of only one ghost node layer, e.g. for the PW6003 !-- scheme, the following loops will not be entered.6004 IF ( edge == 's' ) THEN6005 DO jbgp = -nbgp, jb6006 f(0:nzt+1,jbgp,nxlg:nxrg) = f(0:nzt+1,j,nxlg:nxrg)6007 ENDDO6008 ELSEIF ( edge == 'n' ) THEN6009 DO jbgp = jb, ny+nbgp6010 f(0:nzt+1,jbgp,nxlg:nxrg) = f(0:nzt+1,j,nxlg:nxrg)6011 ENDDO6012 ENDIF6013 6014 END SUBROUTINE pmci_interp_tril_sn6015 6016 6017 6018 SUBROUTINE pmci_interp_tril_t( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, &6019 r1z, r2z, kct, ifl, ifu, jfl, jfu, kfl, kfu, &6020 ijkfc, var )6021 6022 !6023 !-- Interpolation of ghost-node values used as the child-domain boundary6024 !-- conditions. This subroutine handles the top boundary.6025 !-- This subroutine is based on trilinear interpolation.6026 6027 IMPLICIT NONE6028 6029 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), &6030 INTENT(INOUT) :: f !<6031 REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), &6032 INTENT(IN) :: fc !<6033 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x !<6034 REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x !<6035 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r1y !<6036 REAL(wp), DIMENSION(nysg:nyng), INTENT(IN) :: r2y !<6037 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r1z !<6038 REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN) :: r2z !<6039 6040 INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) :: ic !<6041 INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) :: jc !<6042 INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) :: kc !<6043 6044 INTEGER(iwp) :: kct6045 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction6046 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction6047 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction6048 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction6049 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction6050 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction6051 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction6052 INTEGER(iwp), DIMENSION(0:cg%nz+1), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction6053 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box6054 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box6055 6056 CHARACTER(LEN=1), INTENT(IN) :: var !<6057 6058 INTEGER(iwp) :: i !<6059 INTEGER(iwp) :: ib !<6060 INTEGER(iwp) :: ie !<6061 INTEGER(iwp) :: ijk !<6062 INTEGER(iwp) :: j !<6063 INTEGER(iwp) :: jb !<6064 INTEGER(iwp) :: je !<6065 INTEGER(iwp) :: k !<6066 INTEGER(iwp) :: ka !<6067 INTEGER(iwp) :: l !<6068 INTEGER(iwp) :: m !<6069 INTEGER(iwp) :: n !<6070 INTEGER(iwp) :: var_flag !<6071 6072 REAL(wp) :: cellsum !<6073 REAL(wp) :: cellsumd !<6074 REAL(wp) :: fk !<6075 REAL(wp) :: fkj !<6076 REAL(wp) :: fkjp !<6077 REAL(wp) :: fkpj !<6078 REAL(wp) :: fkpjp !<6079 REAL(wp) :: fkp !<6080 REAL(wp) :: rcorr !<6081 REAL(wp) :: rcorr_ijk !<6082 6083 6084 IF ( var == 'w' ) THEN6085 k = nzt6086 ELSE6087 k = nzt + 16088 ENDIF6089 !6090 !-- These exceedings by one are needed only to avoid stripes6091 !-- and spots in visualization. They have no effect on the6092 !-- actual solution.6093 ib = nxl-16094 ie = nxr+16095 jb = nys-16096 je = nyn+16097 6098 IF ( var == 'u' ) THEN6099 var_flag = 16100 ELSEIF ( var == 'v' ) THEN6101 var_flag = 26102 ELSEIF ( var == 'w' ) THEN6103 var_flag = 36104 ELSE6105 var_flag = 06106 ENDIF6107 6108 DO i = ib, ie6109 DO j = jb, je6110 l = ic(i)6111 m = jc(j)6112 n = kc(k)6113 fkj = r1x(i) * fc(n,m,l) + r2x(i) * fc(n,m,l+1)6114 fkjp = r1x(i) * fc(n,m+1,l) + r2x(i) * fc(n,m+1,l+1)6115 fkpj = r1x(i) * fc(n+1,m,l) + r2x(i) * fc(n+1,m,l+1)6116 fkpjp = r1x(i) * fc(n+1,m+1,l) + r2x(i) * fc(n+1,m+1,l+1)6117 fk = r1y(j) * fkj + r2y(j) * fkjp6118 fkp = r1y(j) * fkpj + r2y(j) * fkpjp6119 f(k,j,i) = r1z(k) * fk + r2z(k) * fkp6120 ENDDO6121 ENDDO6122 !6123 !-- Apply the reversibility correction to the boundary-normal velocity-6124 !-- component w and scalars. It must not be applied to the boundary-6125 !-- tangential velocity components u and v because their 2-D anterpolation6126 !-- cells do not cover all the child-grid nodes on the boundary.6127 IF ( .NOT. ( ( var == 'u' ) .OR. ( var == 'v' ) ) ) THEN6128 IF ( var == 'w' ) THEN6129 n = kc(k)6130 ELSE6131 n = kc(k) + 16132 ENDIF6133 6134 DO l = icl, icr6135 DO m = jcs, jcn6136 ijk = 16137 cellsum = 0.0_wp6138 cellsumd = 0.0_wp6139 DO i = ifl(l), ifu(l)6140 DO j = jfl(m), jfu(m)6141 DO ka = kfl(n), kfu(n)6142 cellsum = cellsum + MERGE( f(ka,j,i), 0.0_wp, &6143 BTEST( wall_flags_0(ka,j,i), var_flag ) )6144 celltmpd(ijk) = ABS( fc(n,m,l) - f(ka,j,i) )6145 cellsumd = cellsumd + MERGE( celltmpd(ijk), &6146 0.0_wp, BTEST( wall_flags_0(ka,j,i), var_flag ) )6147 ijk = ijk + 16148 ENDDO6149 ENDDO6150 ENDDO6151 6152 IF ( ijkfc(n,m,l) /= 0 ) THEN6153 cellsum = cellsum / REAL( ijkfc(n,m,l), KIND=wp )6154 rcorr = fc(n,m,l) - cellsum6155 cellsumd = cellsumd / REAL( ijkfc(n,m,l), KIND=wp )6156 ELSE6157 cellsum = 0.0_wp6158 rcorr = 0.0_wp6159 cellsumd = 1.0_wp6160 celltmpd = 1.0_wp6161 ENDIF6162 6163 IF ( ABS(rcorr) < 0.000001_wp ) THEN6164 cellsumd = 1.0_wp6165 celltmpd = 1.0_wp6166 ENDIF6167 6168 7781 ijk = 1 6169 7782 DO i = ifl(l), ifu(l) 6170 DO j = jfl(m), jfu(m) 6171 DO ka = kfl(n), kfu(n) 6172 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 6173 f(ka,j,i) = f(ka,j,i) + rcorr_ijk 6174 ijk = ijk + 1 7783 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7784 DO j = jfl(m), jfu(m) 7785 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 7786 DO ka = kfl(n), kfu(n) 7787 rcorr_ijk = rcorr * celltmpd(ijk) / cellsumd 7788 !AH f(ka,j,i) = f(ka,j,i) + rcorr_ijk 7789 workarr_t(ka,j,i) = workarr_t(ka,j,i) + rcorr_ijk 7790 7791 ! if ( i == 128 .and. var == 'u' ) then 7792 ! write(9,"('t2: ', 8(i4,2x),3(e12.5,2x))") nw, m, l, ka, j, i, ifl(l), ifu(l), & 7793 ! rcorr, rcorr_ijk, workarr_t(ka,j,i) 7794 ! flush(9) 7795 ! endif 7796 7797 ijk = ijk + 1 7798 ENDDO 7799 ENDIF 6175 7800 ENDDO 7801 ENDIF 7802 ENDDO 7803 ! 7804 !-- Velocity components tangential to the boundary need special 7805 !-- "finishing" because their anterpolation cells are flat in their 7806 !-- direction and hence do not cover all the child-grid boundary nodes. 7807 !-- These components are next linearly interpolated to those child-grid 7808 !-- boundary nodes which are not covered by the anterpolation cells. 7809 IF ( ( var == 'v' ) .AND. ( m > jcs ) ) THEN 7810 DO j = jfu(m-1)+1, jfl(m)-1 7811 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 7812 DO i = ifl(l), ifu(l) 7813 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7814 DO ka = kfl(n), kfu(n) ! This loop should be removed and fixed k-value be used instead 7815 !AH f(ka,j,i) = r1y(j) * f(ka,jfu(m-1),i) & 7816 !AH + r2y(j) * f(ka,jfl(m),i) 7817 workarr_t(ka,j,i) = r1y(j) * workarr_t(ka,jfu(m-1),i) & 7818 + r2y(j) * workarr_t(ka,jfl(m),i) 7819 ENDDO 7820 ENDIF 7821 ENDDO 7822 ENDIF 6176 7823 ENDDO 6177 ENDDO 7824 ENDIF 7825 7826 IF ( ( var == 'u' ) .AND. ( l > icl ) ) THEN 7827 DO i = ifu(l-1)+1, ifl(l)-1 7828 IF ( ( i >= nxl ) .AND. ( i <= nxr+1 ) ) THEN 7829 DO j = jfl(m), jfu(m) 7830 IF ( ( j >= nys ) .AND. ( j <= nyn+1 ) ) THEN 7831 DO ka = kfl(n), kfu(n) ! This loop should be removed and fixed k-value be used instead 7832 !AH f(ka,j,i) = r1x(i) * f(ka,j,ifu(l-1)) + & 7833 !AH r2x(i) * f(ka,j,ifl(l)) 7834 workarr_t(ka,j,i) = r1x(i) * workarr_t(ka,j,ifu(l-1)) & 7835 + r2x(i) * workarr_t(ka,j,ifl(l)) 7836 7837 ! if ( i == 127 ) then 7838 ! write(9,"('t4: ', 8(i4,2x),3(e12.5,2x))") nw, m, l, ka, j, ifu(l-1), i, ifl(l), & 7839 ! workarr_t(ka,j,ifu(l-1)), workarr_t(ka,j,i), workarr_t(ka,j,ifl(l)) 7840 ! flush(9) 7841 ! endif 7842 7843 ENDDO 7844 ENDIF 7845 ENDDO 7846 ENDIF 7847 ENDDO 7848 ENDIF 6178 7849 6179 7850 ENDDO ! m 6180 7851 ENDDO ! l 6181 6182 ENDIF ! var not u or v 6183 ! 6184 !-- Just fill up the redundant second ghost-node layer for w. 6185 IF ( var == 'w' ) THEN 6186 f(nzt+1,:,:) = f(nzt,:,:) 7852 ! 7853 !-- Finally substitute the boundary values. 7854 f(k,nys:nyn,nxl:nxr) = workarr_t(k,nys:nyn,nxl:nxr) 7855 IF ( var == 'w' ) THEN 7856 f(k+1,nys:nyn,nxl:nxr) = f(k,nys:nyn,nxl:nxr) 6187 7857 ENDIF 6188 7858 … … 6204 7874 6205 7875 !AH INTEGER(iwp), DIMENSION(0:kct,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 6206 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7876 !AH 7877 ! INTEGER(iwp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7878 INTEGER(iwp), DIMENSION(0:cg%nz+1,jcsa:jcna,icla:icra), INTENT(IN) :: ijkfc !< number of child grid points contributing to a parent grid box 7879 !AH 6207 7880 6208 7881 INTEGER(iwp) :: i !< Running index x-direction - fine-grid 6209 INTEGER(iwp) :: icla 6210 INTEGER(iwp) :: icra 7882 INTEGER(iwp) :: iclant !< Left boundary index for anterpolation along x 7883 INTEGER(iwp) :: icrant !< Right boundary index for anterpolation along x 6211 7884 INTEGER(iwp) :: ii !< Running index x-direction - coarse grid 6212 7885 INTEGER(iwp) :: j !< Running index y-direction - fine-grid 6213 INTEGER(iwp) :: jcna 6214 INTEGER(iwp) :: jcsa 7886 INTEGER(iwp) :: jcnant !< North boundary index for anterpolation along y 7887 INTEGER(iwp) :: jcsant !< South boundary index for anterpolation along y 6215 7888 INTEGER(iwp) :: jj !< Running index y-direction - coarse grid 6216 7889 INTEGER(iwp) :: k !< Running index z-direction - fine-grid 6217 7890 INTEGER(iwp) :: kcb = 0 !< Bottom boundary index for anterpolation along z 7891 INTEGER(iwp) :: kctant !< Top boundary index for anterpolation along z 6218 7892 INTEGER(iwp) :: kk !< Running index z-direction - coarse grid 6219 7893 INTEGER(iwp) :: var_flag !< bit number used to flag topography on respective grid … … 6221 7895 INTEGER(iwp), INTENT(IN) :: kct !< Top boundary index for anterpolation along z 6222 7896 6223 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 6224 INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 6225 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 6226 INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7897 !AH 7898 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7899 ! INTEGER(iwp), DIMENSION(icl:icr), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7900 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7901 ! INTEGER(iwp), DIMENSION(jcs:jcn), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7902 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifl !< Indicates start index of child cells belonging to certain parent cell - x direction 7903 INTEGER(iwp), DIMENSION(icla:icra), INTENT(IN) :: ifu !< Indicates end index of child cells belonging to certain parent cell - x direction 7904 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfl !< Indicates start index of child cells belonging to certain parent cell - y direction 7905 INTEGER(iwp), DIMENSION(jcsa:jcna), INTENT(IN) :: jfu !< Indicates start index of child cells belonging to certain parent cell - y direction 7906 !AH 7907 6227 7908 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfl !< Indicates start index of child cells belonging to certain parent cell - z direction 6228 7909 !AH INTEGER(iwp), DIMENSION(0:kct), INTENT(IN) :: kfu !< Indicates start index of child cells belonging to certain parent cell - z direction … … 6237 7918 6238 7919 ! 6239 !-- Define the index bounds icla , icra, jcsa and jcna.7920 !-- Define the index bounds iclant, icrant, jcsant and jcnant. 6240 7921 !-- Note that kcb is simply zero and kct enters here as a parameter and it is 6241 7922 !-- determined in pmci_init_anterp_tophat. 6242 7923 !-- Please note, grid points used also for interpolation (from parent to 6243 7924 !-- child) are excluded in anterpolation, e.g. anterpolation is only from 6244 !-- nzb:kct-1, as kct is used for interpolation. Following this approach 6245 !-- avoids numerical problems which may accumulate, particularly for shallow 6246 !-- child domain, leading to increased velocity variances. A more 6247 !-- comprehensive explanation for this is still pending. 6248 icla = coarse_bound_anterp(1) 6249 icra = coarse_bound_anterp(2) 6250 jcsa = coarse_bound_anterp(3) 6251 jcna = coarse_bound_anterp(4) 7925 !-- nzb:kct-1, as kct is used for interpolation. 7926 iclant = icl 7927 icrant = icr 7928 jcsant = jcs 7929 jcnant = jcn 7930 kctant = kct - 1 7931 6252 7932 kcb = 0 6253 7933 IF ( nesting_mode /= 'vertical' ) THEN 6254 7934 IF ( bc_dirichlet_l ) THEN 6255 IF ( var == 'u' ) THEN 6256 icla = coarse_bound_anterp(1) + 2 6257 ELSE 6258 icla = coarse_bound_anterp(1) + 1 6259 ENDIF 7935 iclant = icl + 3 6260 7936 ENDIF 6261 7937 IF ( bc_dirichlet_r ) THEN 6262 icra = coarse_bound_anterp(2) - 1 7938 ! icrant = icr - 5 7939 icrant = icr - 3 6263 7940 ENDIF 6264 7941 6265 7942 IF ( bc_dirichlet_s ) THEN 6266 IF ( var == 'v' ) THEN 6267 jcsa = coarse_bound_anterp(3) + 2 6268 ELSE 6269 jcsa = coarse_bound_anterp(3) + 1 6270 ENDIF 7943 jcsant = jcs + 3 6271 7944 ENDIF 6272 7945 IF ( bc_dirichlet_n ) THEN 6273 jcna = coarse_bound_anterp(4) - 17946 jcnant = jcn - 3 6274 7947 ENDIF 6275 7948 ENDIF 6276 6277 ! write(9,"('pmci_anterp_tophat: ',4(e12.5,2x))") &6278 ! cg%coord_x(icla), cg%coord_y(jcsa), cg%coord_x(icra), cg%coord_y(jcna)6279 ! flush(9)6280 7949 ! 6281 7950 !-- Set masking bit for topography flags … … 6292 7961 !-- Note that ii, jj, and kk are coarse-grid indices and i,j, and k 6293 7962 !-- are fine-grid indices. 6294 DO ii = icla , icra6295 DO jj = jcsa , jcna7963 DO ii = iclant, icrant 7964 DO jj = jcsant, jcnant 6296 7965 ! 6297 7966 !-- For simplicity anterpolate within buildings and under elevated 6298 7967 !-- terrain too 6299 DO kk = kcb, kct - 17968 DO kk = kcb, kctant !kct - 1 6300 7969 cellsum = 0.0_wp 6301 7970 DO i = ifl(ii), ifu(ii) … … 6310 7979 !-- Spatial under-relaxation. 6311 7980 !-- The relaxation buffer zones are no longer needed with 6312 !-- the new reversible interpolation algorithm. 23.1 9.2018.7981 !-- the new reversible interpolation algorithm. 23.10.2018. 6313 7982 ! fra = frax(ii) * fray(jj) * fraz(kk) 6314 7983 ! … … 6318 7987 !-- particular for the temperature. Therefore, in case cellsum is 6319 7988 !-- zero, keep the parent solution at this point. 7989 6320 7990 IF ( ijkfc(kk,jj,ii) /= 0 ) THEN 6321 ! fc(kk,jj,ii) = ( 1.0_wp - fra ) * fc(kk,jj,ii) + &6322 ! fra * cellsum / &6323 ! REAL( ijkfc(kk,jj,ii), KIND=wp )7991 !AH fc(kk,jj,ii) = ( 1.0_wp - fra ) * fc(kk,jj,ii) + & 7992 !AH fra * cellsum / & 7993 !AH REAL( ijkfc(kk,jj,ii), KIND=wp ) 6324 7994 fc(kk,jj,ii) = cellsum / REAL( ijkfc(kk,jj,ii), KIND=wp ) 6325 7995 ENDIF 6326 7996 6327 7997 ENDDO 6328 6329 7998 ENDDO 6330 7999 ENDDO -
palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/templates/module_header
r3458 r3681 37 37 ! PALM. If not, see <http://www.gnu.org/licenses/>. 38 38 ! 39 ! Copyright 1997-201 8Leibniz Universitaet Hannover39 ! Copyright 1997-2019 Leibniz Universitaet Hannover 40 40 !--------------------------------------------------------------------------------! 41 41 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_cbm4/chem_gasphase_mod.f90
r3623 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_passive/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_passive1/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_phstat/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_phstatp/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_salsa+phstat/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_salsa+simple/chem_gasphase_mod.f90
r3639 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_salsagas/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_simple/chem_gasphase_mod.f90
r3639 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_simplep/chem_gasphase_mod.f90
r3639 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/chemistry/gasphase_preproc/mechanisms/def_smog/chem_gasphase_mod.f90
r3585 r3681 41 41 ! PALM. If not,see <http://www.gnu.org/licenses/>. 42 42 ! 43 ! Copyright 1997-201 8Leibniz Universitaet Hannover43 ! Copyright 1997-2019 Leibniz Universitaet Hannover 44 44 !--------------------------------------------------------------------------------! 45 45 ! -
palm/trunk/UTIL/inifor/tests/test-input-files.f90
r3678 r3681 21 21 ! Current revisions: 22 22 ! ----------------- 23 ! Switched to get_datetime_file_list()24 23 ! 25 24 ! … … 27 26 ! ----------------- 28 27 ! $Id$ 28 ! Switched to get_datetime_file_list() 29 ! 30 ! 31 ! 3678 2019-01-17 14:12:17Z eckhard 29 32 ! Prefixed all INIFOR modules with inifor_ 30 33 !
Note: See TracChangeset
for help on using the changeset viewer.