Ignore:
Timestamp:
Jun 13, 2016 7:12:51 AM (8 years ago)
Author:
hellstea
Message:

last commit documented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/pmc_interface_mod.f90

    r1928 r1933  
    11MODULE pmc_interface
    22
    3 !------------------------------------------------------------------------------!
     3!-------------------------------------------------------------------------------!
    44! This file is part of PALM.
    55!
     
    1616!
    1717! Copyright 1997-2016 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     18!-------------------------------------------------------------------------------!
    1919!
    2020! Current revisions:
     
    2626! $Id$
    2727!
    28 ! 1927 2016-06-07 11:56:53Z hellstea
    29 ! Error check for overlapping parallel nests added
     28! 1901 2016-05-04 15:39:38Z raasch
     29! Initial version of purely vertical nesting introduced.
     30! Code clean up. The words server/client changed to parent/child.
    3031!
    3132! 1900 2016-05-04 15:27:53Z raasch
     
    6263! introduction of different datatransfer modes,
    6364! further formatting cleanup, parameter checks added (including mismatches
    64 ! between root and client model settings),
     65! between root and nest model settings),
    6566! +routine pmci_check_setting_mismatches
    6667! comm_world_nesting introduced
     
    106107! Domain nesting interface routines. The low-level inter-domain communication   
    107108! is conducted by the PMC-library routines.
    108 !------------------------------------------------------------------------------!
     109!-------------------------------------------------------------------------------!
    109110
    110111#if defined( __nopointer )
    111     USE arrays_3d,                                                             &
    112         ONLY:  dzu, dzw, e, e_p, pt, pt_p, q, q_p, u, u_p, v, v_p, w, w_p, zu, &
     112    USE arrays_3d,                                                              &
     113        ONLY:  dzu, dzw, e, e_p, pt, pt_p, q, q_p, u, u_p, v, v_p, w, w_p, zu,  &
    113114               zw, z0
    114115#else
    115    USE arrays_3d,                                                              &
    116         ONLY:  dzu, dzw, e, e_p, e_1, e_2, pt, pt_p, pt_1, pt_2, q, q_p, q_1,  &
    117                q_2, u, u_p, u_1, u_2, v, v_p, v_1, v_2, w, w_p, w_1, w_2, zu,  &
     116   USE arrays_3d,                                                               &
     117        ONLY:  dzu, dzw, e, e_p, e_1, e_2, pt, pt_p, pt_1, pt_2, q, q_p, q_1,   &
     118               q_2, u, u_p, u_1, u_2, v, v_p, v_1, v_2, w, w_p, w_1, w_2, zu,   &
    118119               zw, z0
    119120#endif
    120121
    121     USE control_parameters,                                                    &
    122         ONLY:  coupling_char, dt_3d, dz, humidity, message_string,             &
    123                nest_bound_l, nest_bound_r, nest_bound_s, nest_bound_n,         &
    124                nest_domain, neutral, passive_scalar, simulated_time,           &
     122    USE control_parameters,                                                     &
     123        ONLY:  coupling_char, dt_3d, dz, humidity, message_string,              &
     124               nest_bound_l, nest_bound_r, nest_bound_s, nest_bound_n,          &
     125               nest_domain, neutral, passive_scalar, simulated_time,            &
    125126               topography, volume_flow
    126127
    127     USE cpulog,                                                                &
     128    USE cpulog,                                                                 &
    128129        ONLY:  cpu_log, log_point_s
    129130
    130     USE grid_variables,                                                        &
     131    USE grid_variables,                                                         &
    131132        ONLY:  dx, dy
    132133
    133     USE indices,                                                               &
    134         ONLY:  nbgp, nx, nxl, nxlg, nxlu, nxr, nxrg, ny, nyn, nyng, nys, nysg, &
    135                nysv, nz, nzb, nzb_s_inner, nzb_u_inner, nzb_u_outer,           &
     134    USE indices,                                                                &
     135        ONLY:  nbgp, nx, nxl, nxlg, nxlu, nxr, nxrg, ny, nyn, nyng, nys, nysg,  &
     136               nysv, nz, nzb, nzb_s_inner, nzb_u_inner, nzb_u_outer,            &
    136137               nzb_v_inner, nzb_v_outer, nzb_w_inner, nzb_w_outer, nzt
    137138
     
    145146#endif
    146147
    147     USE pegrid,                                                                &
    148         ONLY:  collective_wait, comm1dx, comm1dy, comm2d, myid, myidx, myidy,  &
     148    USE pegrid,                                                                 &
     149        ONLY:  collective_wait, comm1dx, comm1dy, comm2d, myid, myidx, myidy,   &
    149150               numprocs
    150151
    151     USE pmc_client,                                                            &
    152         ONLY:  pmc_clientinit, pmc_c_clear_next_array_list,                    &
    153                pmc_c_getnextarray, pmc_c_get_2d_index_list, pmc_c_getbuffer,   &
    154                pmc_c_putbuffer, pmc_c_setind_and_allocmem,                     &
     152    USE pmc_child,                                                              &
     153        ONLY:  pmc_childinit, pmc_c_clear_next_array_list,                      &
     154               pmc_c_getnextarray, pmc_c_get_2d_index_list, pmc_c_getbuffer,    &
     155               pmc_c_putbuffer, pmc_c_setind_and_allocmem,                      &
    155156               pmc_c_set_dataarray, pmc_set_dataarray_name
    156157
    157     USE pmc_general,                                                           &
     158    USE pmc_general,                                                            &
    158159        ONLY:  da_namelen
    159160
    160     USE pmc_handle_communicator,                                               &
    161         ONLY:  pmc_get_model_info, pmc_init_model, pmc_is_rootmodel,           &
    162                pmc_no_namelist_found, pmc_server_for_client
    163 
    164     USE pmc_mpi_wrapper,                                                       &
    165         ONLY:  pmc_bcast, pmc_recv_from_client, pmc_recv_from_server,          &
    166                pmc_send_to_client, pmc_send_to_server
    167 
    168     USE pmc_server,                                                            &
    169         ONLY:  pmc_serverinit, pmc_s_clear_next_array_list, pmc_s_fillbuffer,  &
    170                pmc_s_getdata_from_buffer, pmc_s_getnextarray,                  &
    171                pmc_s_setind_and_allocmem, pmc_s_set_active_data_array,         &
     161    USE pmc_handle_communicator,                                                &
     162        ONLY:  pmc_get_model_info, pmc_init_model, pmc_is_rootmodel,            &
     163               pmc_no_namelist_found, pmc_parent_for_child
     164
     165    USE pmc_mpi_wrapper,                                                        &
     166        ONLY:  pmc_bcast, pmc_recv_from_child, pmc_recv_from_parent,            &
     167               pmc_send_to_child, pmc_send_to_parent
     168
     169    USE pmc_parent,                                                             &
     170        ONLY:  pmc_parentinit, pmc_s_clear_next_array_list, pmc_s_fillbuffer,   &
     171               pmc_s_getdata_from_buffer, pmc_s_getnextarray,                   &
     172               pmc_s_setind_and_allocmem, pmc_s_set_active_data_array,          &
    172173               pmc_s_set_dataarray, pmc_s_set_2d_index_list
    173174
     
    180181!
    181182!-- Constants
    182     INTEGER(iwp), PARAMETER ::  client_to_server = 2   !:
    183     INTEGER(iwp), PARAMETER ::  server_to_client = 1   !:
     183    INTEGER(iwp), PARAMETER ::  child_to_parent = 2   !:
     184    INTEGER(iwp), PARAMETER ::  parent_to_child = 1   !:
    184185
    185186!
     
    196197                                                         !: parameter for data-
    197198                                                         !: transfer mode
    198     CHARACTER(LEN=7), SAVE ::  nesting_mode = 'two-way'  !: steering parameter
     199    CHARACTER(LEN=8), SAVE ::  nesting_mode = 'two-way'  !: steering parameter
    199200                                                         !: for 1- or 2-way nesting
    200201
     
    216217
    217218!
    218 !-- Client coarse data arrays
     219!-- Child coarse data arrays
    219220    INTEGER(iwp), DIMENSION(5)                  ::  coarse_bound   !:
    220221
     
    237238
    238239!
    239 !-- Client interpolation coefficients and client-array indices to be precomputed
    240 !-- and stored.
     240!-- Child interpolation coefficients and child-array indices to be
     241!-- precomputed and stored.
    241242    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) ::  ico    !:
    242243    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) ::  icu    !:
     
    259260
    260261!
    261 !-- Client index arrays and log-ratio arrays for the log-law near-wall
     262!-- Child index arrays and log-ratio arrays for the log-law near-wall
    262263!-- corrections. These are not truly 3-D arrays but multiple 2-D arrays.
    263264    INTEGER(iwp), SAVE :: ncorr  !: 4th dimension of the log_ratio-arrays
     
    313314
    314315!
    315 !-- Client-array indices to be precomputed and stored for anterpolation.
     316!-- Child-array indices to be precomputed and stored for anterpolation.
    316317    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) ::  iflu   !:
    317318    INTEGER(iwp), SAVE, ALLOCATABLE, DIMENSION(:) ::  ifuu   !:
     
    363364    END INTERFACE
    364365
    365     INTERFACE pmci_client_initialize
    366        MODULE PROCEDURE pmci_client_initialize
     366    INTERFACE pmci_child_initialize
     367       MODULE PROCEDURE pmci_child_initialize
    367368    END INTERFACE
    368369
     
    387388    END INTERFACE
    388389
    389     INTERFACE pmci_server_initialize
    390        MODULE PROCEDURE pmci_server_initialize
     390    INTERFACE pmci_parent_initialize
     391       MODULE PROCEDURE pmci_parent_initialize
    391392    END INTERFACE
    392393
     
    395396    END INTERFACE pmci_set_swaplevel
    396397
    397     PUBLIC anterp_relax_length_l, anterp_relax_length_r,                       &
    398            anterp_relax_length_s, anterp_relax_length_n,                       &
    399            anterp_relax_length_t, client_to_server, comm_world_nesting,        &
    400            cpl_id, nested_run, nesting_datatransfer_mode, nesting_mode,        &
    401            server_to_client
    402     PUBLIC pmci_client_initialize
     398    PUBLIC anterp_relax_length_l, anterp_relax_length_r,                        &
     399           anterp_relax_length_s, anterp_relax_length_n,                        &
     400           anterp_relax_length_t, child_to_parent, comm_world_nesting,          &
     401           cpl_id, nested_run, nesting_datatransfer_mode, nesting_mode,         &
     402           parent_to_child
     403    PUBLIC pmci_child_initialize
    403404    PUBLIC pmci_datatrans
    404405    PUBLIC pmci_ensure_nest_mass_conservation
    405406    PUBLIC pmci_init
    406407    PUBLIC pmci_modelconfiguration
    407     PUBLIC pmci_server_initialize
     408    PUBLIC pmci_parent_initialize
    408409    PUBLIC pmci_synchronize
    409410    PUBLIC pmci_set_swaplevel
     
    415416 SUBROUTINE pmci_init( world_comm )
    416417
    417     USE control_parameters,                                                  &
     418    USE control_parameters,                                                     &
    418419        ONLY:  message_string
    419420
     
    429430
    430431
    431     CALL pmc_init_model( world_comm, nesting_datatransfer_mode, nesting_mode,  &
     432    CALL pmc_init_model( world_comm, nesting_datatransfer_mode, nesting_mode,   &
    432433                         pmc_status )
    433434
     
    445446!
    446447!-- Check steering parameter values
    447     IF ( TRIM( nesting_mode ) /= 'one-way'  .AND.                              &
    448          TRIM( nesting_mode ) /= 'two-way' )                                   &
     448    IF ( TRIM( nesting_mode ) /= 'one-way'  .AND.                               &
     449         TRIM( nesting_mode ) /= 'two-way'  .AND.                               &
     450         TRIM( nesting_mode ) /= 'vertical' )                                   &                 
    449451    THEN
    450452       message_string = 'illegal nesting mode: ' // TRIM( nesting_mode )
     
    452454    ENDIF
    453455
    454     IF ( TRIM( nesting_datatransfer_mode ) /= 'cascade'  .AND.                 &
    455          TRIM( nesting_datatransfer_mode ) /= 'mixed'    .AND.                 &
    456          TRIM( nesting_datatransfer_mode ) /= 'overlap' )                      &
     456    IF ( TRIM( nesting_datatransfer_mode ) /= 'cascade'  .AND.                  &
     457         TRIM( nesting_datatransfer_mode ) /= 'mixed'    .AND.                  &
     458         TRIM( nesting_datatransfer_mode ) /= 'overlap' )                       &
    457459    THEN
    458        message_string = 'illegal nesting datatransfer mode: '                  &
     460       message_string = 'illegal nesting datatransfer mode: '                   &
    459461                        // TRIM( nesting_datatransfer_mode )
    460462       CALL message( 'pmci_init', 'PA0418', 3, 2, 0, 6, 0 )
     
    468470!-- Get some variables required by the pmc-interface (and in some cases in the
    469471!-- PALM code out of the pmci) out of the pmc-core
    470     CALL pmc_get_model_info( comm_world_nesting = comm_world_nesting,          &
    471                              cpl_id = cpl_id, cpl_parent_id = cpl_parent_id,   &
    472                              cpl_name = cpl_name, npe_total = cpl_npe_total,   &
    473                              lower_left_x = lower_left_coord_x,                &
     472    CALL pmc_get_model_info( comm_world_nesting = comm_world_nesting,           &
     473                             cpl_id = cpl_id, cpl_parent_id = cpl_parent_id,    &
     474                             cpl_name = cpl_name, npe_total = cpl_npe_total,    &
     475                             lower_left_x = lower_left_coord_x,                 &
    474476                             lower_left_y = lower_left_coord_y )
    475477!
     
    513515    CALL pmci_setup_coordinates
    514516!
    515 !-- Initialize the client (must be called before pmc_setup_server)
    516     CALL pmci_setup_client
    517 !
    518 !-- Initialize PMC Server
    519     CALL pmci_setup_server
    520 !
    521 !-- Check for mismatches between settings of master and client variables
    522 !-- (e.g., all clients have to follow the end_time settings of the root master)
     517!-- Initialize the child (must be called before pmc_setup_parent)
     518    CALL pmci_setup_child
     519!
     520!-- Initialize PMC parent
     521    CALL pmci_setup_parent
     522!
     523!-- Check for mismatches between settings of master and child variables
     524!-- (e.g., all children have to follow the end_time settings of the root master)
    523525    CALL pmci_check_setting_mismatches
    524526
     
    529531
    530532
    531  SUBROUTINE pmci_setup_server
     533 SUBROUTINE pmci_setup_parent
    532534
    533535#if defined( __parallel )
     
    536538    CHARACTER(LEN=32) ::  myname
    537539
    538     INTEGER(iwp) ::  client_id        !:
     540    INTEGER(iwp) ::  child_id         !:
    539541    INTEGER(iwp) ::  ierr             !:
    540542    INTEGER(iwp) ::  i                !:
     
    558560    REAL(wp) ::  dx_cl            !:
    559561    REAL(wp) ::  dy_cl            !:
     562    REAL(wp) ::  left_limit       !:
     563    REAL(wp) ::  north_limit      !:
     564    REAL(wp) ::  right_limit      !:
     565    REAL(wp) ::  south_limit      !:
    560566    REAL(wp) ::  xez              !:
    561567    REAL(wp) ::  yez              !:
     
    568574
    569575!
    570 !   Initialize the pmc server
    571     CALL pmc_serverinit
     576!   Initialize the pmc parent
     577    CALL pmc_parentinit
    572578
    573579!
    574580!-- Corners of all children of the present parent
    575     IF ( ( SIZE( pmc_server_for_client ) - 1 > 0 ) .AND. myid == 0 )  THEN
    576        ALLOCATE( ch_xl(1:SIZE( pmc_server_for_client ) - 1) )
    577        ALLOCATE( ch_xr(1:SIZE( pmc_server_for_client ) - 1) )
    578        ALLOCATE( ch_ys(1:SIZE( pmc_server_for_client ) - 1) )
    579        ALLOCATE( ch_yn(1:SIZE( pmc_server_for_client ) - 1) )
     581    IF ( ( SIZE( pmc_parent_for_child ) - 1 > 0 ) .AND. myid == 0 )  THEN
     582       ALLOCATE( ch_xl(1:SIZE( pmc_parent_for_child ) - 1) )
     583       ALLOCATE( ch_xr(1:SIZE( pmc_parent_for_child ) - 1) )
     584       ALLOCATE( ch_ys(1:SIZE( pmc_parent_for_child ) - 1) )
     585       ALLOCATE( ch_yn(1:SIZE( pmc_parent_for_child ) - 1) )
    580586    ENDIF
    581587
    582588!
    583589!-- Get coordinates from all children
    584     DO  m = 1, SIZE( pmc_server_for_client ) - 1
    585 
    586        client_id = pmc_server_for_client(m)
     590    DO  m = 1, SIZE( pmc_parent_for_child ) - 1
     591
     592       child_id = pmc_parent_for_child(m)
    587593       IF ( myid == 0 )  THEN       
    588594
    589           CALL pmc_recv_from_client( client_id, val,  size(val),  0, 123, ierr )
    590           CALL pmc_recv_from_client( client_id, fval, size(fval), 0, 124, ierr )
     595          CALL pmc_recv_from_child( child_id, val,  size(val),  0, 123, ierr )
     596          CALL pmc_recv_from_child( child_id, fval, size(fval), 0, 124, ierr )
    591597         
    592598          nx_cl = val(1)
     
    598604
    599605!
    600 !--       Find the highest client level in the coarse grid for the reduced z
     606!--       Find the highest nest level in the coarse grid for the reduced z
    601607!--       transfer
    602608          DO  k = 1, nz                 
     
    612618          ALLOCATE( cl_coord_y(-nbgp:ny_cl+nbgp) )
    613619         
    614           CALL pmc_recv_from_client( client_id, cl_coord_x, SIZE( cl_coord_x ),&
     620          CALL pmc_recv_from_child( child_id, cl_coord_x, SIZE( cl_coord_x ),   &
    615621                                     0, 11, ierr )
    616           CALL pmc_recv_from_client( client_id, cl_coord_y, SIZE( cl_coord_y ),&
     622          CALL pmc_recv_from_child( child_id, cl_coord_y, SIZE( cl_coord_y ),   &
    617623                                     0, 12, ierr )
    618 !          WRITE ( 0, * )  'receive from pmc Client ', client_id, nx_cl, ny_cl
     624!          WRITE ( 0, * )  'receive from pmc child ', child_id, nx_cl, ny_cl
    619625         
    620626          define_coarse_grid_real(1) = lower_left_coord_x
     
    631637
    632638!
    633 !--       Check that the client domain is completely inside the server domain.
     639!--       Check that the child domain matches parent domain.
    634640          nomatch = 0
    635           xez = ( nbgp + 1 ) * dx
    636           yez = ( nbgp + 1 ) * dy
    637           IF ( ( cl_coord_x(0) < define_coarse_grid_real(1) + xez )       .OR. &
    638                ( cl_coord_x(nx_cl+1) > define_coarse_grid_real(5) - xez ) .OR. &
    639                ( cl_coord_y(0) < define_coarse_grid_real(2) + yez )       .OR. &
    640                ( cl_coord_y(ny_cl+1) > define_coarse_grid_real(6) - yez ) )    &
    641           THEN
    642              nomatch = 1
     641          IF ( nesting_mode == 'vertical' )  THEN
     642             right_limit = define_coarse_grid_real(5)
     643             north_limit = define_coarse_grid_real(6)
     644             IF ( ( cl_coord_x(nx_cl+1) /= right_limit ) .OR.                   &
     645                  ( cl_coord_y(ny_cl+1) /= north_limit ) )  THEN
     646                nomatch = 1
     647             ENDIF
     648          ELSE
     649         
     650!
     651!--       Check that the children domain is completely inside the parent domain.
     652             xez = ( nbgp + 1 ) * dx
     653             yez = ( nbgp + 1 ) * dy
     654             left_limit  = lower_left_coord_x + xez
     655             right_limit = define_coarse_grid_real(5) - xez
     656             south_limit = lower_left_coord_y + yez
     657             north_limit = define_coarse_grid_real(6) - yez
     658             IF ( ( cl_coord_x(0) < left_limit )        .OR.                    &
     659                  ( cl_coord_x(nx_cl+1) > right_limit ) .OR.                    &
     660                  ( cl_coord_y(0) < south_limit )       .OR.                    &
     661                  ( cl_coord_y(ny_cl+1) > north_limit ) )  THEN
     662                nomatch = 1
     663             ENDIF
    643664          ENDIF
    644665
     
    646667!--       Check that parallel nest domains, if any, do not overlap.
    647668          nest_overlap = 0
    648           IF ( SIZE( pmc_server_for_client ) - 1 > 0 )  THEN
     669          IF ( SIZE( pmc_parent_for_child ) - 1 > 0 )  THEN
    649670             ch_xl(m) = cl_coord_x(-nbgp)
    650671             ch_xr(m) = cl_coord_x(nx_cl+nbgp)
     
    654675             IF ( m > 1 )  THEN
    655676                DO mm = 1, m-1
    656                    IF ( ( ch_xl(m) < ch_xr(mm) .OR. ch_xr(m) > ch_xl(mm) ) .AND.  &
    657                         ( ch_ys(m) < ch_yn(mm) .OR. ch_yn(m) > ch_ys(mm) ) )  THEN                       
     677                   IF ( ( ch_xl(m) < ch_xr(mm) .OR.                             &
     678                          ch_xr(m) > ch_xl(mm) )  .AND.                         &
     679                        ( ch_ys(m) < ch_yn(mm) .OR.                             &
     680                          ch_yn(m) > ch_ys(mm) ) )  THEN                       
    658681                      nest_overlap = 1
    659682                   ENDIF
     
    667690!
    668691!--       Send coarse grid information to child
    669           CALL pmc_send_to_client( client_id, define_coarse_grid_real,         &
    670                                    SIZE( define_coarse_grid_real ), 0, 21,     &
     692          CALL pmc_send_to_child( child_id, define_coarse_grid_real,            &
     693                                   SIZE( define_coarse_grid_real ), 0, 21,      &
    671694                                   ierr )
    672           CALL pmc_send_to_client( client_id, define_coarse_grid_int,  3, 0,   &
     695          CALL pmc_send_to_child( child_id, define_coarse_grid_int,  3, 0,      &
    673696                                   22, ierr )
    674697
    675698!
    676699!--       Send local grid to child
    677           CALL pmc_send_to_client( client_id, coord_x, nx+1+2*nbgp, 0, 24,     &
     700          CALL pmc_send_to_child( child_id, coord_x, nx+1+2*nbgp, 0, 24,        &
    678701                                   ierr )
    679           CALL pmc_send_to_client( client_id, coord_y, ny+1+2*nbgp, 0, 25,     &
     702          CALL pmc_send_to_child( child_id, coord_y, ny+1+2*nbgp, 0, 25,        &
    680703                                   ierr )
    681704
    682705!
    683706!--       Also send the dzu-, dzw-, zu- and zw-arrays here
    684           CALL pmc_send_to_client( client_id, dzu, nz_cl+1, 0, 26, ierr )
    685           CALL pmc_send_to_client( client_id, dzw, nz_cl+1, 0, 27, ierr )
    686           CALL pmc_send_to_client( client_id, zu,  nz_cl+2, 0, 28, ierr )
    687           CALL pmc_send_to_client( client_id, zw,  nz_cl+2, 0, 29, ierr )
     707          CALL pmc_send_to_child( child_id, dzu, nz_cl+1, 0, 26, ierr )
     708          CALL pmc_send_to_child( child_id, dzw, nz_cl+1, 0, 27, ierr )
     709          CALL pmc_send_to_child( child_id, zu,  nz_cl+2, 0, 28, ierr )
     710          CALL pmc_send_to_child( child_id, zw,  nz_cl+2, 0, 29, ierr )
    688711
    689712       ENDIF
     
    691714       CALL MPI_BCAST( nomatch, 1, MPI_INTEGER, 0, comm2d, ierr )
    692715       IF ( nomatch /= 0 ) THEN
    693           WRITE ( message_string, * )  'Error: nested child domain does ',    &
     716          WRITE ( message_string, * )  'Error: nested child domain does ',      &
    694717                                       'not fit into its parent domain'
    695           CALL message( 'pmc_palm_setup_server', 'PA0425', 3, 2, 0, 6, 0 )
     718          CALL message( 'pmci_setup_parent', 'PA0425', 3, 2, 0, 6, 0 )
    696719       ENDIF
    697720 
     
    700723          WRITE ( message_string, * )  'Nested parallel child ',    &
    701724                                       'domains overlap'
    702           CALL message( 'pmc_palm_setup_server', 'PA0426', 3, 2, 0, 6, 0 )
     725          CALL message( 'pmci_setup_parent', 'PA0426', 3, 2, 0, 6, 0 )
    703726       ENDIF
    704727     
     
    710733
    711734!
    712 !--    Include couple arrays into server content
     735!--    Include couple arrays into parent content
    713736!--    TO_DO: Klaus: please give a more meaningful comment
    714737       CALL pmc_s_clear_next_array_list
    715        DO  WHILE ( pmc_s_getnextarray( client_id, myname ) )
    716           CALL pmci_set_array_pointer( myname, client_id = client_id,          &
     738       DO  WHILE ( pmc_s_getnextarray( child_id, myname ) )
     739          CALL pmci_set_array_pointer( myname, child_id = child_id,             &
    717740                                       nz_cl = nz_cl )
    718741       ENDDO
    719        CALL pmc_s_setind_and_allocmem( client_id )
     742       CALL pmc_s_setind_and_allocmem( child_id )
    720743    ENDDO
    721744
    722     IF ( ( SIZE( pmc_server_for_client ) - 1 > 0 ) .AND. myid == 0 )  THEN
     745    IF ( ( SIZE( pmc_parent_for_child ) - 1 > 0 ) .AND. myid == 0 )  THEN
    723746       DEALLOCATE( ch_xl )
    724747       DEALLOCATE( ch_xr )
     
    747770       INTEGER(iwp) ::  px                 !:
    748771       INTEGER(iwp) ::  py                 !:
    749        INTEGER(iwp) ::  server_pe          !:
     772       INTEGER(iwp) ::  parent_pe          !:
    750773
    751774       INTEGER(iwp), DIMENSION(2) ::  scoord             !:
     
    757780       IF ( myid == 0 )  THEN
    758781!--       TO_DO: Klaus: give more specific comment what size_of_array stands for
    759           CALL pmc_recv_from_client( client_id, size_of_array, 2, 0, 40, ierr )
     782          CALL pmc_recv_from_child( child_id, size_of_array, 2, 0, 40, ierr )
    760783          ALLOCATE( coarse_bound_all(size_of_array(1),size_of_array(2)) )
    761           CALL pmc_recv_from_client( client_id, coarse_bound_all,              &
    762                                      SIZE( coarse_bound_all ), 0, 41, ierr )
     784          CALL pmc_recv_from_child( child_id, coarse_bound_all,                 &
     785                                    SIZE( coarse_bound_all ), 0, 41, ierr )
    763786
    764787!
     
    783806          ic  = 0
    784807!
    785 !--       Loop over all client PEs
     808!--       Loop over all children PEs
    786809          DO  k = 1, size_of_array(2)
    787810!
    788 !--          Area along y required by actual client PE
     811!--          Area along y required by actual child PE
    789812             DO  j = coarse_bound_all(3,k), coarse_bound_all(4,k)
    790813!
    791 !--             Area along x required by actual client PE
     814!--             Area along x required by actual child PE
    792815                DO  i = coarse_bound_all(1,k), coarse_bound_all(2,k)
    793816
     
    796819                   scoord(1) = px
    797820                   scoord(2) = py
    798                    CALL MPI_CART_RANK( comm2d, scoord, server_pe, ierr )
     821                   CALL MPI_CART_RANK( comm2d, scoord, parent_pe, ierr )
    799822                 
    800823                   ic = ic + 1
    801824!
    802 !--                First index in server array
     825!--                First index in parent array
    803826                   index_list(1,ic) = i - ( px * nrx ) + 1 + nbgp
    804827!
    805 !--                Second index in server array
     828!--                Second index in parent array
    806829                   index_list(2,ic) = j - ( py * nry ) + 1 + nbgp
    807830!
    808 !--                x index of client coarse grid
     831!--                x index of child coarse grid
    809832                   index_list(3,ic) = i - coarse_bound_all(1,k) + 1
    810833!
    811 !--                y index of client coarse grid
     834!--                y index of child coarse grid
    812835                   index_list(4,ic) = j - coarse_bound_all(3,k) + 1
    813836!
    814 !--                PE number of client
     837!--                PE number of child
    815838                   index_list(5,ic) = k - 1
    816839!
    817 !--                PE number of server
    818                    index_list(6,ic) = server_pe
     840!--                PE number of parent
     841                   index_list(6,ic) = parent_pe
    819842
    820843                ENDDO
     
    823846!
    824847!--       TO_DO: Klaus: comment what is done here
    825           CALL pmc_s_set_2d_index_list( client_id, index_list(:,1:ic) )
     848          CALL pmc_s_set_2d_index_list( child_id, index_list(:,1:ic) )
    826849
    827850       ELSE
     
    829852!--       TO_DO: Klaus: comment why this dummy allocation is required
    830853          ALLOCATE( index_list(6,1) )
    831           CALL pmc_s_set_2d_index_list( client_id, index_list )
     854          CALL pmc_s_set_2d_index_list( child_id, index_list )
    832855       ENDIF
    833856
     
    837860
    838861#endif
    839  END SUBROUTINE pmci_setup_server
    840 
    841 
    842 
    843  SUBROUTINE pmci_setup_client
     862 END SUBROUTINE pmci_setup_parent
     863
     864
     865
     866 SUBROUTINE pmci_setup_child
    844867
    845868#if defined( __parallel )
     
    867890!
    868891!-- TO_DO: describe what is happening in this if-clause
    869 !-- Root Model does not have Server and is not a client
     892!-- Root model does not have a parent and is not a child
    870893    IF ( .NOT. pmc_is_rootmodel() )  THEN
    871894
    872        CALL pmc_clientinit
     895       CALL pmc_childinit
    873896!
    874897!--    Here AND ONLY HERE the arrays are defined, which actualy will be
    875 !--    exchanged between client and server.
     898!--    exchanged between child and parent.
    876899!--    If a variable is removed, it only has to be removed from here.
    877900!--    Please check, if the arrays are in the list of POSSIBLE exchange arrays
    878901!--    in subroutines:
    879 !--    pmci_set_array_pointer (for server arrays)
    880 !--    pmci_create_client_arrays (for client arrays)
     902!--    pmci_set_array_pointer (for parent arrays)
     903!--    pmci_create_child_arrays (for child arrays)
    881904       CALL pmc_set_dataarray_name( 'coarse', 'u'  ,'fine', 'u',  ierr )
    882905       CALL pmc_set_dataarray_name( 'coarse', 'v'  ,'fine', 'v',  ierr )
     
    893916
    894917!
    895 !--    Send grid to server
     918!--    Send grid to parent
    896919       val(1)  = nx
    897920       val(2)  = ny
     
    903926       IF ( myid == 0 )  THEN
    904927
    905           CALL pmc_send_to_server( val, SIZE( val ), 0, 123, ierr )
    906           CALL pmc_send_to_server( fval, SIZE( fval ), 0, 124, ierr )
    907           CALL pmc_send_to_server( coord_x, nx + 1 + 2 * nbgp, 0, 11, ierr )
    908           CALL pmc_send_to_server( coord_y, ny + 1 + 2 * nbgp, 0, 12, ierr )
     928          CALL pmc_send_to_parent( val, SIZE( val ), 0, 123, ierr )
     929          CALL pmc_send_to_parent( fval, SIZE( fval ), 0, 124, ierr )
     930          CALL pmc_send_to_parent( coord_x, nx + 1 + 2 * nbgp, 0, 11, ierr )
     931          CALL pmc_send_to_parent( coord_y, ny + 1 + 2 * nbgp, 0, 12, ierr )
    909932
    910933!
    911934!--       Receive Coarse grid information.
    912935!--       TO_DO: find shorter and more meaningful name for  define_coarse_grid_real
    913           CALL pmc_recv_from_server( define_coarse_grid_real,                  &
     936          CALL pmc_recv_from_parent( define_coarse_grid_real,                  &
    914937                                     SIZE(define_coarse_grid_real), 0, 21, ierr )
    915           CALL pmc_recv_from_server( define_coarse_grid_int,  3, 0, 22, ierr )
     938          CALL pmc_recv_from_parent( define_coarse_grid_int,  3, 0, 22, ierr )
    916939!
    917940!--        Debug-printouts - keep them
    918 !          WRITE(0,*) 'Coarse grid from Server '
     941!          WRITE(0,*) 'Coarse grid from parent '
    919942!          WRITE(0,*) 'startx_tot    = ',define_coarse_grid_real(1)
    920943!          WRITE(0,*) 'starty_tot    = ',define_coarse_grid_real(2)
     
    929952       ENDIF
    930953
    931        CALL MPI_BCAST( define_coarse_grid_real, SIZE(define_coarse_grid_real), &
     954       CALL MPI_BCAST( define_coarse_grid_real, SIZE(define_coarse_grid_real),  &
    932955                       MPI_REAL, 0, comm2d, ierr )
    933956       CALL MPI_BCAST( define_coarse_grid_int, 3, MPI_INTEGER, 0, comm2d, ierr )
     
    941964
    942965!
    943 !--    Get server coordinates on coarse grid
     966!--    Get parent coordinates on coarse grid
    944967       ALLOCATE( cg%coord_x(-nbgp:cg%nx+nbgp) )
    945968       ALLOCATE( cg%coord_y(-nbgp:cg%ny+nbgp) )
     
    951974
    952975!
    953 !--    Get coarse grid coordinates and vales of the z-direction from server
     976!--    Get coarse grid coordinates and values of the z-direction from the parent
    954977       IF ( myid == 0)  THEN
    955978
    956           CALL pmc_recv_from_server( cg%coord_x, cg%nx+1+2*nbgp, 0, 24, ierr )
    957           CALL pmc_recv_from_server( cg%coord_y, cg%ny+1+2*nbgp, 0, 25, ierr )
    958           CALL pmc_recv_from_server( cg%dzu, cg%nz + 1, 0, 26, ierr )
    959           CALL pmc_recv_from_server( cg%dzw, cg%nz + 1, 0, 27, ierr )
    960           CALL pmc_recv_from_server( cg%zu, cg%nz + 2, 0, 28, ierr )
    961           CALL pmc_recv_from_server( cg%zw, cg%nz + 2, 0, 29, ierr )
     979          CALL pmc_recv_from_parent( cg%coord_x, cg%nx+1+2*nbgp, 0, 24, ierr )
     980          CALL pmc_recv_from_parent( cg%coord_y, cg%ny+1+2*nbgp, 0, 25, ierr )
     981          CALL pmc_recv_from_parent( cg%dzu, cg%nz + 1, 0, 26, ierr )
     982          CALL pmc_recv_from_parent( cg%dzw, cg%nz + 1, 0, 27, ierr )
     983          CALL pmc_recv_from_parent( cg%zu, cg%nz + 2, 0, 28, ierr )
     984          CALL pmc_recv_from_parent( cg%zw, cg%nz + 2, 0, 29, ierr )
    962985
    963986       ENDIF
     
    9801003
    9811004!
    982 !--    Include couple arrays into client content
    983 !--    TO_DO: Klaus: better explain the above comment (what is client content?)
     1005!--    Include couple arrays into child content
     1006!--    TO_DO: Klaus: better explain the above comment (what is child content?)
    9841007       CALL  pmc_c_clear_next_array_list
    9851008       DO  WHILE ( pmc_c_getnextarray( myname ) )
    986 !--       TO_DO: Klaus, why the c-arrays are still up to cg%nz??
    987           CALL pmci_create_client_arrays ( myname, icl, icr, jcs, jcn, cg%nz )
     1009!--       TO_DO: Klaus, why the child-arrays are still up to cg%nz??
     1010          CALL pmci_create_child_arrays ( myname, icl, icr, jcs, jcn, cg%nz )
    9881011       ENDDO
    9891012       CALL pmc_c_setind_and_allocmem
    9901013
    9911014!
    992 !--    Precompute interpolation coefficients and client-array indices
     1015!--    Precompute interpolation coefficients and child-array indices
    9931016       CALL pmci_init_interp_tril
    9941017
     
    10021025
    10031026!
    1004 !--    Two-way coupling.
     1027!--    Two-way coupling for general and vertical nesting.
    10051028!--    Precompute the index arrays and relaxation functions for the
    10061029!--    anterpolation
    1007        IF ( nesting_mode == 'two-way' )  THEN
     1030       IF ( TRIM( nesting_mode ) == 'two-way' .OR.                              &
     1031                  nesting_mode == 'vertical' )  THEN
    10081032          CALL pmci_init_anterp_tophat
    10091033       ENDIF
     
    10971121!--    Note that MPI_Gather receives data from all processes in the rank order
    10981122!--    TO_DO: refer to the line where this fact becomes important
    1099        CALL MPI_GATHER( coarse_bound, 5, MPI_INTEGER, coarse_bound_all, 5, &
     1123       CALL MPI_GATHER( coarse_bound, 5, MPI_INTEGER, coarse_bound_all, 5,      &
    11001124                        MPI_INTEGER, 0, comm2d, ierr )
    11011125
     
    11031127          size_of_array(1) = SIZE( coarse_bound_all, 1 )
    11041128          size_of_array(2) = SIZE( coarse_bound_all, 2 )
    1105           CALL pmc_send_to_server( size_of_array, 2, 0, 40, ierr )
    1106           CALL pmc_send_to_server( coarse_bound_all, SIZE( coarse_bound_all ), &
     1129          CALL pmc_send_to_parent( size_of_array, 2, 0, 40, ierr )
     1130          CALL pmc_send_to_parent( coarse_bound_all, SIZE( coarse_bound_all ), &
    11071131                                   0, 41, ierr )
    11081132       ENDIF
     
    11141138    SUBROUTINE pmci_init_interp_tril
    11151139!
    1116 !--    Precomputation of the interpolation coefficients and client-array indices
     1140!--    Precomputation of the interpolation coefficients and child-array indices
    11171141!--    to be used by the interpolation routines interp_tril_lr, interp_tril_ns
    11181142!--    and interp_tril_t.
     
    11671191!
    11681192!--    Note that the node coordinates xfs... and xcs... are relative to the
    1169 !--    lower-left-bottom corner of the fc-array, not the actual client domain
     1193!--    lower-left-bottom corner of the fc-array, not the actual child domain
    11701194!--    corner
    11711195       DO  i = nxlg, nxrg
     
    12621286          DO  i = nxl-1, nxl
    12631287             DO  j = nys, nyn
    1264                 nzt_topo_nestbc_l = MAX( nzt_topo_nestbc_l, nzb_u_inner(j,i),  &
     1288                nzt_topo_nestbc_l = MAX( nzt_topo_nestbc_l, nzb_u_inner(j,i),   &
    12651289                                         nzb_v_inner(j,i), nzb_w_inner(j,i) )
    12661290             ENDDO
     
    12731297          i = nxr + 1
    12741298          DO  j = nys, nyn
    1275              nzt_topo_nestbc_r = MAX( nzt_topo_nestbc_r, nzb_u_inner(j,i),     &
     1299             nzt_topo_nestbc_r = MAX( nzt_topo_nestbc_r, nzb_u_inner(j,i),      &
    12761300                                      nzb_v_inner(j,i), nzb_w_inner(j,i) )
    12771301          ENDDO
     
    12831307          DO  j = nys-1, nys
    12841308             DO  i = nxl, nxr
    1285                 nzt_topo_nestbc_s = MAX( nzt_topo_nestbc_s, nzb_u_inner(j,i),  &
     1309                nzt_topo_nestbc_s = MAX( nzt_topo_nestbc_s, nzb_u_inner(j,i),   &
    12861310                                         nzb_v_inner(j,i), nzb_w_inner(j,i) )
    12871311             ENDDO
     
    12941318          j = nyn + 1
    12951319          DO  i = nxl, nxr
    1296              nzt_topo_nestbc_n = MAX( nzt_topo_nestbc_n, nzb_u_inner(j,i),     &
     1320             nzt_topo_nestbc_n = MAX( nzt_topo_nestbc_n, nzb_u_inner(j,i),      &
    12971321                                      nzb_v_inner(j,i), nzb_w_inner(j,i) )
    12981322          ENDDO
     
    13031327!--    Then determine the maximum number of near-wall nodes per wall point based
    13041328!--    on the grid-spacing ratios.
    1305        nzt_topo_max = MAX( nzt_topo_nestbc_l, nzt_topo_nestbc_r,               &
     1329       nzt_topo_max = MAX( nzt_topo_nestbc_l, nzt_topo_nestbc_r,                &
    13061330                           nzt_topo_nestbc_s, nzt_topo_nestbc_n )
    13071331
     
    13431367             k   = kb + 1
    13441368             wall_index = kb
    1345              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1369             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    13461370                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    13471371             logc_u_l(1,k,j) = lc
     
    13541378             k   =  kb + 1
    13551379             wall_index = kb
    1356              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1380             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    13571381                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    13581382             logc_v_l(1,k,j) = lc
     
    13851409             k   = kb + 1
    13861410             wall_index = kb
    1387              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1411             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    13881412                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    13891413             logc_u_r(1,k,j) = lc
     
    13961420             k   = kb + 1
    13971421             wall_index = kb
    1398              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1422             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    13991423                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    14001424             logc_v_r(1,k,j) = lc
     
    14281452             k   =  kb + 1
    14291453             wall_index = kb
    1430              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1454             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    14311455                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    14321456             logc_u_s(1,k,i) = lc
     
    14391463             k   = kb + 1
    14401464             wall_index = kb
    1441              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1465             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    14421466                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    14431467             logc_v_s(1,k,i) = lc
     
    14711495             k   = kb + 1
    14721496             wall_index = kb
    1473              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1497             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    14741498                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    14751499             logc_u_n(1,k,i) = lc
     
    14821506             k   = kb + 1
    14831507             wall_index = kb
    1484              CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,     &
     1508             CALL pmci_define_loglaw_correction_parameters( lc, lcr, k, j,      &
    14851509                                inc, wall_index, z0(j,i), kb, direction, ncorr )
    14861510             logc_v_n(1,k,i) = lc
     
    15021526
    15031527             ALLOCATE( logc_w_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
    1504              ALLOCATE( logc_ratio_w_l(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_l,     &
     1528             ALLOCATE( logc_ratio_w_l(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_l,      &
    15051529                                      nys:nyn) )
    15061530
     
    15131537!--                Wall for u on the south side, but not on the north side
    15141538                   i  = 0
    1515                    IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) ) .AND.        &
    1516                         ( nzb_u_outer(j,i) == nzb_u_outer(j-1,i) ) )           &
     1539                   IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) ) .AND.         &
     1540                        ( nzb_u_outer(j,i) == nzb_u_outer(j-1,i) ) )            &
    15171541                   THEN
    15181542                      inc        =  1
    15191543                      wall_index =  j
    1520                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1544                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    15211545                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    15221546!
     
    15311555!--                Wall for u on the north side, but not on the south side
    15321556                   i  = 0
    1533                    IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) ) .AND.        &
     1557                   IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) ) .AND.         &
    15341558                        ( nzb_u_outer(j,i) == nzb_u_outer(j+1,i) ) )  THEN
    15351559                      inc        = -1
    15361560                      wall_index =  j + 1
    1537                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1561                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    15381562                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    15391563!
     
    15481572!--                Wall for w on the south side, but not on the north side.
    15491573                   i  = -1
    1550                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) )  .AND.       &
     1574                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) )  .AND.        &
    15511575                        ( nzb_w_outer(j,i) == nzb_w_outer(j-1,i) ) )  THEN
    15521576                      inc        =  1
    15531577                      wall_index =  j
    1554                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1578                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    15551579                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    15561580!
     
    15651589!--                Wall for w on the north side, but not on the south side.
    15661590                   i  = -1
    1567                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) )  .AND.       &
     1591                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) )  .AND.        &
    15681592                        ( nzb_w_outer(j,i) == nzb_w_outer(j+1,i) ) )  THEN
    15691593                      inc        = -1
    15701594                      wall_index =  j+1
    1571                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1595                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    15721596                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    15731597!
     
    15891613
    15901614             ALLOCATE( logc_w_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
    1591              ALLOCATE( logc_ratio_w_r(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_r,     &
     1615             ALLOCATE( logc_ratio_w_r(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_r,      &
    15921616                                      nys:nyn) )
    15931617             logc_w_r       = 0
     
    16001624!
    16011625!--                Wall for u on the south side, but not on the north side
    1602                    IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) )  .AND.       &
     1626                   IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) )  .AND.        &
    16031627                        ( nzb_u_outer(j,i) == nzb_u_outer(j-1,i) ) )  THEN
    16041628                      inc        = 1
    16051629                      wall_index = j
    1606                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1630                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    16071631                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    16081632!
     
    16161640!
    16171641!--                Wall for u on the north side, but not on the south side
    1618                    IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) )  .AND.       &
     1642                   IF ( ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) )  .AND.        &
    16191643                        ( nzb_u_outer(j,i) == nzb_u_outer(j+1,i) ) )  THEN
    16201644                      inc        = -1
    16211645                      wall_index =  j+1
    1622                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1646                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    16231647                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    16241648!
     
    16321656!
    16331657!--                Wall for w on the south side, but not on the north side
    1634                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) )  .AND.       &
     1658                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) )  .AND.        &
    16351659                        ( nzb_w_outer(j,i) == nzb_w_outer(j-1,i) ) )  THEN
    16361660                      inc        =  1
    16371661                      wall_index =  j
    1638                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1662                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    16391663                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    16401664!
     
    16481672!
    16491673!--                Wall for w on the north side, but not on the south side
    1650                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) )  .AND.       &
     1674                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) )  .AND.        &
    16511675                        ( nzb_w_outer(j,i) == nzb_w_outer(j+1,i) ) )  THEN
    16521676                      inc        = -1
    16531677                      wall_index =  j+1
    1654                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1678                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    16551679                          k, j, inc, wall_index, z0(j,i), kb, direction, ncorr )
    16561680
     
    16731697
    16741698             ALLOCATE( logc_w_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
    1675              ALLOCATE( logc_ratio_w_s(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_s,     &
     1699             ALLOCATE( logc_ratio_w_s(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_s,      &
    16761700                                      nxl:nxr) )
    16771701             logc_w_s       = 0
     
    16841708!--                Wall for v on the left side, but not on the right side
    16851709                   j  = 0
    1686                    IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) )  .AND.       &
     1710                   IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) )  .AND.        &
    16871711                        ( nzb_v_outer(j,i) == nzb_v_outer(j,i-1) ) )  THEN
    16881712                      inc        =  1
    16891713                      wall_index =  i
    1690                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1714                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    16911715                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    16921716!
     
    17011725!--                Wall for v on the right side, but not on the left side
    17021726                   j  = 0
    1703                    IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) )  .AND.       &
     1727                   IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) )  .AND.        &
    17041728                        ( nzb_v_outer(j,i) == nzb_v_outer(j,i+1) ) )  THEN
    17051729                      inc        = -1
    17061730                      wall_index =  i+1
    1707                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1731                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    17081732                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    17091733!
     
    17181742!--                Wall for w on the left side, but not on the right side
    17191743                   j  = -1
    1720                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) )  .AND.       &
     1744                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) )  .AND.        &
    17211745                        ( nzb_w_outer(j,i) == nzb_w_outer(j,i-1) ) )  THEN
    17221746                      inc        =  1
    17231747                      wall_index =  i
    1724                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1748                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    17251749                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    17261750!
     
    17351759!--                Wall for w on the right side, but not on the left side
    17361760                   j  = -1
    1737                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) )  .AND.       &
     1761                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) )  .AND.        &
    17381762                        ( nzb_w_outer(j,i) == nzb_w_outer(j,i+1) ) )  THEN
    17391763                      inc        = -1
    17401764                      wall_index =  i+1
    1741                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1765                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    17421766                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    17431767!
     
    17591783
    17601784             ALLOCATE( logc_w_n(1:2,nzb:nzt_topo_nestbc_n, nxl:nxr) )
    1761              ALLOCATE( logc_ratio_w_n(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_n,     &
     1785             ALLOCATE( logc_ratio_w_n(1:2,0:ncorr-1,nzb:nzt_topo_nestbc_n,      &
    17621786                                      nxl:nxr) )
    17631787             logc_w_n       = 0
     
    17701794!
    17711795!--                Wall for v on the left side, but not on the right side
    1772                    IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) )  .AND.       &
     1796                   IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) )  .AND.        &
    17731797                        ( nzb_v_outer(j,i) == nzb_v_outer(j,i-1) ) )  THEN
    17741798                      inc        = 1
    17751799                      wall_index = i
    1776                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1800                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    17771801                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    17781802!
     
    17861810!
    17871811!--                Wall for v on the right side, but not on the left side
    1788                    IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) )  .AND.       &
     1812                   IF ( ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) )  .AND.        &
    17891813                        ( nzb_v_outer(j,i) == nzb_v_outer(j,i+1) ) )  THEN
    17901814                      inc        = -1
    17911815                      wall_index =  i + 1
    1792                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1816                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    17931817                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    17941818!
     
    18021826!
    18031827!--                Wall for w on the left side, but not on the right side
    1804                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) )  .AND.       &
     1828                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) )  .AND.        &
    18051829                        ( nzb_w_outer(j,i) == nzb_w_outer(j,i-1) ) )  THEN
    18061830                      inc        = 1
    18071831                      wall_index = i
    1808                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1832                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    18091833                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    18101834!
     
    18181842!
    18191843!--                Wall for w on the right side, but not on the left side
    1820                    IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) )  .AND.       &
     1844                   IF ( ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) )  .AND.        &
    18211845                        ( nzb_w_outer(j,i) == nzb_w_outer(j,i+1) ) )  THEN
    18221846                      inc        = -1
    18231847                      wall_index =  i+1
    1824                       CALL pmci_define_loglaw_correction_parameters( lc, lcr,  &
     1848                      CALL pmci_define_loglaw_correction_parameters( lc, lcr,   &
    18251849                          k, i, inc, wall_index, z0(j,i), kb, direction, ncorr )
    18261850!
     
    18431867
    18441868
    1845     SUBROUTINE pmci_define_loglaw_correction_parameters( lc, lcr, k, ij, inc,  &
     1869    SUBROUTINE pmci_define_loglaw_correction_parameters( lc, lcr, k, ij, inc,   &
    18461870                                        wall_index, z0_l, kb, direction, ncorr )
    18471871
     
    18971921                corr_index = ij + lcorr   ! In this case (direction = 2) ij is j
    18981922                IF ( lcorr == 0 )  THEN
    1899                    CALL pmci_find_logc_pivot_j( lc, logvelc1, ij, wall_index,  &
     1923                   CALL pmci_find_logc_pivot_j( lc, logvelc1, ij, wall_index,   &
    19001924                                                z0_l, inc )
    19011925                ENDIF
     
    19051929!--             valid in both directions
    19061930                IF ( inc * corr_index < inc * lc )  THEN
    1907                    lcr(alcorr) = LOG( ABS( coord_y(corr_index) + 0.5_wp * dy   &
    1908                                          - coord_y(wall_index) ) / z0_l )      &
     1931                   lcr(alcorr) = LOG( ABS( coord_y(corr_index) + 0.5_wp * dy    &
     1932                                         - coord_y(wall_index) ) / z0_l )       &
    19091933                                 / logvelc1
    19101934                   more = .TRUE.
     
    19241948                corr_index = ij + lcorr   ! In this case (direction = 3) ij is i
    19251949                IF ( lcorr == 0 )  THEN
    1926                    CALL pmci_find_logc_pivot_i( lc, logvelc1, ij, wall_index,  &
     1950                   CALL pmci_find_logc_pivot_i( lc, logvelc1, ij, wall_index,   &
    19271951                                                z0_l, inc )
    19281952                ENDIF
     
    19311955!--             valid in both directions
    19321956                IF ( inc * corr_index < inc * lc )  THEN
    1933                    lcr(alcorr) = LOG( ABS( coord_x(corr_index) + 0.5_wp * dx   &
    1934                                          - coord_x(wall_index) ) / z0_l )      &
     1957                   lcr(alcorr) = LOG( ABS( coord_x(corr_index) + 0.5_wp * dx    &
     1958                                         - coord_x(wall_index) ) / z0_l )       &
    19351959                                 / logvelc1
    19361960                   more = .TRUE.
     
    19631987       INTEGER(iwp) ::  k1     !:
    19641988
    1965        REAL(wp),INTENT(OUT) ::  logzc1     !:
     1989       REAL(wp), INTENT(OUT) ::  logzc1     !:
    19661990       REAL(wp), INTENT(IN) ::  z0_l       !:
    19671991
     
    20722096    SUBROUTINE pmci_init_anterp_tophat
    20732097!
    2074 !--    Precomputation of the client-array indices for
     2098!--    Precomputation of the child-array indices for
    20752099!--    corresponding coarse-grid array index and the
    20762100!--    Under-relaxation coefficients to be used by anterp_tophat.
     
    21482172       DO  ii = icl, icr
    21492173          i = istart
    2150           DO  WHILE ( ( coord_x(i) < cg%coord_x(ii) - 0.5_wp * cg%dx )  .AND.  &
     2174          DO  WHILE ( ( coord_x(i) < cg%coord_x(ii) - 0.5_wp * cg%dx )  .AND.   &
    21512175                      ( i < nxrg ) )
    21522176             i = i + 1
    21532177          ENDDO
    21542178          iflu(ii) = MIN( MAX( i, nxlg ), nxrg )
    2155           DO  WHILE ( ( coord_x(i) < cg%coord_x(ii) + 0.5_wp * cg%dx )  .AND.  &
     2179          DO  WHILE ( ( coord_x(i) < cg%coord_x(ii) + 0.5_wp * cg%dx )  .AND.   &
    21562180                      ( i < nxrg ) )
    21572181             i = i + 1
     
    21662190       DO  ii = icl, icr
    21672191          i = istart
    2168           DO  WHILE ( ( coord_x(i) + 0.5_wp * dx < cg%coord_x(ii) )  .AND.     &
     2192          DO  WHILE ( ( coord_x(i) + 0.5_wp * dx < cg%coord_x(ii) )  .AND.      &
    21692193                      ( i < nxrg ) )
    21702194             i = i + 1
    21712195          ENDDO
    21722196          iflo(ii) = MIN( MAX( i, nxlg ), nxrg )
    2173           DO  WHILE ( ( coord_x(i) + 0.5_wp * dx < cg%coord_x(ii) + cg%dx )    &
     2197          DO  WHILE ( ( coord_x(i) + 0.5_wp * dx < cg%coord_x(ii) + cg%dx )     &
    21742198                      .AND.  ( i < nxrg ) )
    21752199             i = i + 1
     
    21842208       DO  jj = jcs, jcn
    21852209          j = jstart
    2186           DO  WHILE ( ( coord_y(j) < cg%coord_y(jj) - 0.5_wp * cg%dy )  .AND.  &
     2210          DO  WHILE ( ( coord_y(j) < cg%coord_y(jj) - 0.5_wp * cg%dy )  .AND.   &
    21872211                      ( j < nyng ) )
    21882212             j = j + 1
    21892213          ENDDO
    21902214          jflv(jj) = MIN( MAX( j, nysg ), nyng )
    2191           DO  WHILE ( ( coord_y(j) < cg%coord_y(jj) + 0.5_wp * cg%dy )  .AND.  &
     2215          DO  WHILE ( ( coord_y(j) < cg%coord_y(jj) + 0.5_wp * cg%dy )  .AND.   &
    21922216                      ( j < nyng ) )
    21932217             j = j + 1
     
    22022226       DO  jj = jcs, jcn
    22032227          j = jstart
    2204           DO  WHILE ( ( coord_y(j) + 0.5_wp * dy < cg%coord_y(jj) )  .AND.     &
     2228          DO  WHILE ( ( coord_y(j) + 0.5_wp * dy < cg%coord_y(jj) )  .AND.      &
    22052229                      ( j < nyng ) )
    22062230             j = j + 1
    22072231          ENDDO
    22082232          jflo(jj) = MIN( MAX( j, nysg ), nyng )
    2209           DO  WHILE ( ( coord_y(j) + 0.5_wp * dy < cg%coord_y(jj) + cg%dy )    &
     2233          DO  WHILE ( ( coord_y(j) + 0.5_wp * dy < cg%coord_y(jj) + cg%dy )     &
    22102234                      .AND.  ( j < nyng ) )
    22112235             j = j + 1
     
    22222246       DO  kk = 1, kctw
    22232247          k = kstart
    2224           DO  WHILE ( ( zw(k) < cg%zw(kk) - 0.5_wp * cg%dzw(kk) )  .AND.       &
     2248          DO  WHILE ( ( zw(k) < cg%zw(kk) - 0.5_wp * cg%dzw(kk) )  .AND.        &
    22252249                      ( k < nzt ) )
    22262250             k = k + 1
    22272251          ENDDO
    22282252          kflw(kk) = MIN( MAX( k, 1 ), nzt + 1 )
    2229           DO  WHILE ( ( zw(k) < cg%zw(kk) + 0.5_wp * cg%dzw(kk+1) )  .AND.     &
     2253          DO  WHILE ( ( zw(k) < cg%zw(kk) + 0.5_wp * cg%dzw(kk+1) )  .AND.      &
    22302254                      ( k < nzt ) )
    22312255             k = k + 1
     
    22422266       DO  kk = 1, kctu
    22432267          k = kstart
    2244           DO  WHILE ( ( zu(k) < cg%zu(kk) - 0.5_wp * cg%dzu(kk) )  .AND.       &
     2268          DO  WHILE ( ( zu(k) < cg%zu(kk) - 0.5_wp * cg%dzu(kk) )  .AND.        &
    22452269                      ( k < nzt ) )
    22462270             k = k + 1
    22472271          ENDDO
    22482272          kflo(kk) = MIN( MAX( k, 1 ), nzt + 1 )
    2249           DO  WHILE ( ( zu(k) < cg%zu(kk) + 0.5_wp * cg%dzu(kk+1) )  .AND.     &
     2273          DO  WHILE ( ( zu(k) < cg%zu(kk) + 0.5_wp * cg%dzu(kk+1) )  .AND.      &
    22502274                      ( k < nzt ) )
    22512275             k = k + 1
     
    22722296!--    Spatial under-relaxation coefficients
    22732297       ALLOCATE( frax(icl:icr) )
    2274 
    2275        DO  ii = icl, icr
    2276           IF ( nest_bound_l )  THEN
    2277              xi = ( MAX( 0.0_wp, ( cg%coord_x(ii) - lower_left_coord_x ) ) /   &
    2278                     anterp_relax_length_l )**4
    2279           ELSEIF ( nest_bound_r )  THEN
    2280              xi = ( MAX( 0.0_wp, ( lower_left_coord_x + ( nx + 1 ) * dx -      &
    2281                                    cg%coord_x(ii) ) ) /                        &
    2282                     anterp_relax_length_r )**4
    2283           ELSE
    2284              xi = 999999.9_wp
    2285           ENDIF
    2286           frax(ii) = xi / ( 1.0_wp + xi )
    2287        ENDDO
    2288 
    22892298       ALLOCATE( fray(jcs:jcn) )
    2290 
    2291        DO  jj = jcs, jcn
    2292           IF ( nest_bound_s )  THEN
    2293              eta = ( MAX( 0.0_wp, ( cg%coord_y(jj) - lower_left_coord_y ) ) /  &
    2294                      anterp_relax_length_s )**4
    2295           ELSEIF ( nest_bound_n )  THEN
    2296              eta = ( MAX( 0.0_wp, ( lower_left_coord_y + ( ny + 1 ) * dy -     &
    2297                                     cg%coord_y(jj)) ) /                        &
    2298                      anterp_relax_length_n )**4
    2299           ELSE
    2300              eta = 999999.9_wp
    2301           ENDIF
    2302           fray(jj) = eta / ( 1.0_wp + eta )
    2303        ENDDO
     2299       
     2300       frax(icl:icr) = 1.0_wp
     2301       fray(jcs:jcn) = 1.0_wp
     2302
     2303       IF ( nesting_mode /= 'vertical' )  THEN
     2304          DO  ii = icl, icr
     2305             IF ( nest_bound_l )  THEN
     2306                xi = ( MAX( 0.0_wp, ( cg%coord_x(ii) -                          &
     2307                       lower_left_coord_x ) ) / anterp_relax_length_l )**4
     2308             ELSEIF ( nest_bound_r )  THEN
     2309                xi = ( MAX( 0.0_wp, ( lower_left_coord_x + ( nx + 1 ) * dx -    &
     2310                                      cg%coord_x(ii) ) ) /                      &
     2311                       anterp_relax_length_r )**4
     2312             ELSE
     2313                xi = 999999.9_wp
     2314             ENDIF
     2315             frax(ii) = xi / ( 1.0_wp + xi )
     2316          ENDDO
     2317
     2318
     2319          DO  jj = jcs, jcn
     2320             IF ( nest_bound_s )  THEN
     2321                eta = ( MAX( 0.0_wp, ( cg%coord_y(jj) -                         &
     2322                        lower_left_coord_y ) ) / anterp_relax_length_s )**4
     2323             ELSEIF ( nest_bound_n )  THEN
     2324                eta = ( MAX( 0.0_wp, ( lower_left_coord_y + ( ny + 1 ) * dy -   &
     2325                                       cg%coord_y(jj)) ) /                      &
     2326                        anterp_relax_length_n )**4
     2327             ELSE
     2328                eta = 999999.9_wp
     2329             ENDIF
     2330             fray(jj) = eta / ( 1.0_wp + eta )
     2331          ENDDO
     2332       ENDIF
    23042333     
    23052334       ALLOCATE( fraz(0:kctu) )
     
    23472376                height = zu(k) - zu(nzb_s_inner(j,i))
    23482377                fw     = EXP( -cfw * height / glsf )
    2349                 tkefactor_l(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *     &
     2378                tkefactor_l(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *      &
    23502379                                              ( glsf / glsc )**p23 )
    23512380             ENDDO
     
    23652394                height = zu(k) - zu(nzb_s_inner(j,i))
    23662395                fw     = EXP( -cfw * height / glsf )
    2367                 tkefactor_r(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *     &
     2396                tkefactor_r(k,j) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *      &
    23682397                                              ( glsf / glsc )**p23 )
    23692398             ENDDO
     
    23832412                height = zu(k) - zu(nzb_s_inner(j,i))
    23842413                fw     = EXP( -cfw*height / glsf )
    2385                 tkefactor_s(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *     &
     2414                tkefactor_s(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *      &
    23862415                                              ( glsf / glsc )**p23 )
    23872416             ENDDO
     
    24012430                height = zu(k) - zu(nzb_s_inner(j,i))
    24022431                fw     = EXP( -cfw * height / glsf )
    2403                 tkefactor_n(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *     &
     2432                tkefactor_n(k,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *      &
    24042433                                              ( glsf / glsc )**p23 )
    24052434             ENDDO
     
    24172446             height = zu(k) - zu(nzb_s_inner(j,i))
    24182447             fw     = EXP( -cfw * height / glsf )
    2419              tkefactor_t(j,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *        &
     2448             tkefactor_t(j,i) = c_tkef * ( fw0 * fw + ( 1.0_wp - fw ) *         &
    24202449                                           ( glsf / glsc )**p23 )
    24212450          ENDDO
     
    24252454
    24262455#endif
    2427  END SUBROUTINE pmci_setup_client
     2456 END SUBROUTINE pmci_setup_child
    24282457
    24292458
     
    24562485
    24572486
    2458  SUBROUTINE pmci_set_array_pointer( name, client_id, nz_cl )
     2487 SUBROUTINE pmci_set_array_pointer( name, child_id, nz_cl )
    24592488
    24602489    IMPLICIT NONE
    24612490
    2462     INTEGER, INTENT(IN)          ::  client_id   !:
     2491    INTEGER, INTENT(IN)          ::  child_id    !:
    24632492    INTEGER, INTENT(IN)          ::  nz_cl       !:
    24642493    CHARACTER(LEN=*), INTENT(IN) ::  name        !:
     
    24932522#if defined( __nopointer )
    24942523    IF ( ASSOCIATED( p_3d ) )  THEN
    2495        CALL pmc_s_set_dataarray( client_id, p_3d, nz_cl, nz )
     2524       CALL pmc_s_set_dataarray( child_id, p_3d, nz_cl, nz )
    24962525    ELSEIF ( ASSOCIATED( p_2d ) )  THEN
    2497        CALL pmc_s_set_dataarray( client_id, p_2d )
     2526       CALL pmc_s_set_dataarray( child_id, p_2d )
    24982527    ELSE
    24992528!
     
    25012530       IF ( myid == 0  .AND.  cpl_id == 1 )  THEN
    25022531
    2503           message_string = 'pointer for array "' // TRIM( name ) //            &
     2532          message_string = 'pointer for array "' // TRIM( name ) //             &
    25042533                           '" can''t be associated'
    25052534          CALL message( 'pmci_set_array_pointer', 'PA0117', 3, 2, 0, 6, 0 )
     
    25192548
    25202549    IF ( ASSOCIATED( p_3d ) )  THEN
    2521        CALL pmc_s_set_dataarray( client_id, p_3d, nz_cl, nz, &
     2550       CALL pmc_s_set_dataarray( child_id, p_3d, nz_cl, nz,                    &
    25222551                                 array_2 = p_3d_sec )
    25232552    ELSEIF ( ASSOCIATED( p_2d ) )  THEN
    2524        CALL pmc_s_set_dataarray( client_id, p_2d )
     2553       CALL pmc_s_set_dataarray( child_id, p_2d )
    25252554    ELSE
    25262555!
     
    25282557       IF ( myid == 0  .AND.  cpl_id == 1 )  THEN
    25292558
    2530           message_string = 'pointer for array "' // TRIM( name ) //            &
     2559          message_string = 'pointer for array "' // TRIM( name ) //             &
    25312560                           '" can''t be associated'
    25322561          CALL message( 'pmci_set_array_pointer', 'PA0117', 3, 2, 0, 6, 0 )
     
    25452574
    25462575
    2547  SUBROUTINE pmci_create_client_arrays( name, is, ie, js, je, nzc  )
     2576 SUBROUTINE pmci_create_child_arrays( name, is, ie, js, je, nzc  )
    25482577
    25492578    IMPLICIT NONE
     
    25992628    ELSE
    26002629!
    2601 !--    Give only one message for the first client domain
     2630!--    Give only one message for the first child domain
    26022631       IF ( myid == 0  .AND.  cpl_id == 2 )  THEN
    26032632
    2604           message_string = 'pointer for array "' // TRIM( name ) //            &
     2633          message_string = 'pointer for array "' // TRIM( name ) //             &
    26052634                           '" can''t be associated'
    2606           CALL message( 'pmci_create_client_arrays', 'PA0170', 3, 2, 0, 6, 0 )
     2635          CALL message( 'pmci_create_child_arrays', 'PA0170', 3, 2, 0, 6, 0 )
    26072636       ELSE
    26082637!
     
    26132642
    26142643#endif
    2615  END SUBROUTINE pmci_create_client_arrays
    2616 
    2617 
    2618 
    2619  SUBROUTINE pmci_server_initialize
    2620 !-- TO_DO: add general explanations about what this subroutine does
     2644 END SUBROUTINE pmci_create_child_arrays
     2645
     2646
     2647
     2648 SUBROUTINE pmci_parent_initialize
     2649
     2650!
     2651!-- Send data for the children in order to let them create initial
     2652!-- conditions by interpolating the parent-domain fields.
    26212653#if defined( __parallel )
    26222654    IMPLICIT NONE
    26232655
    2624     INTEGER(iwp) ::  client_id   !:
     2656    INTEGER(iwp) ::  child_id    !:
    26252657    INTEGER(iwp) ::  m           !:
    26262658
    2627     REAL(wp) ::  waittime    !:
    2628 
    2629 
    2630     DO  m = 1, SIZE( pmc_server_for_client ) - 1
    2631        client_id = pmc_server_for_client(m)
    2632        CALL pmc_s_fillbuffer( client_id, waittime=waittime )
     2659    REAL(wp) ::  waittime        !:
     2660
     2661
     2662    DO  m = 1, SIZE( pmc_parent_for_child ) - 1
     2663       child_id = pmc_parent_for_child(m)
     2664       CALL pmc_s_fillbuffer( child_id, waittime=waittime )
    26332665    ENDDO
    26342666
    26352667#endif
    2636  END SUBROUTINE pmci_server_initialize
    2637 
    2638 
    2639 
    2640  SUBROUTINE pmci_client_initialize
    2641 !-- TO_DO: add general explanations about what this subroutine does
     2668 END SUBROUTINE pmci_parent_initialize
     2669
     2670
     2671
     2672 SUBROUTINE pmci_child_initialize
     2673
     2674!
     2675!-- Create initial conditions for the current child domain by interpolating
     2676!-- the parent-domain fields.
    26422677#if defined( __parallel )
    26432678    IMPLICIT NONE
     
    26502685    INTEGER(iwp) ::  jcs        !:
    26512686
    2652     REAL(wp) ::  waittime   !:
    2653 
    2654 !
    2655 !-- Root id is never a client
     2687    REAL(wp) ::  waittime       !:
     2688
     2689!
     2690!-- Root id is never a child
    26562691    IF ( cpl_id > 1 )  THEN
    26572692
    26582693!
    2659 !--    Client domain boundaries in the server index space
     2694!--    Child domain boundaries in the parent index space
    26602695       icl = coarse_bound(1)
    26612696       icr = coarse_bound(2)
     
    26642699
    26652700!
    2666 !--    Get data from server
     2701!--    Get data from the parent
    26672702       CALL pmc_c_getbuffer( waittime = waittime )
    26682703
    26692704!
    26702705!--    The interpolation.
    2671        CALL pmci_interp_tril_all ( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,   &
     2706       CALL pmci_interp_tril_all ( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,    &
    26722707                                   r2yo, r1zo, r2zo, nzb_u_inner, 'u' )
    2673        CALL pmci_interp_tril_all ( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,   &
     2708       CALL pmci_interp_tril_all ( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,    &
    26742709                                   r2yv, r1zo, r2zo, nzb_v_inner, 'v' )
    2675        CALL pmci_interp_tril_all ( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,   &
     2710       CALL pmci_interp_tril_all ( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,    &
    26762711                                   r2yo, r1zw, r2zw, nzb_w_inner, 'w' )
    2677        CALL pmci_interp_tril_all ( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,   &
     2712       CALL pmci_interp_tril_all ( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,    &
    26782713                                   r2yo, r1zo, r2zo, nzb_s_inner, 'e' )
    26792714       IF ( .NOT. neutral )  THEN
    2680           CALL pmci_interp_tril_all ( pt, ptc, ico, jco, kco, r1xo, r2xo,      &
     2715          CALL pmci_interp_tril_all ( pt, ptc, ico, jco, kco, r1xo, r2xo,       &
    26812716                                      r1yo, r2yo, r1zo, r2zo, nzb_s_inner, 's' )
    26822717       ENDIF
    26832718       IF ( humidity  .OR.  passive_scalar )  THEN
    2684           CALL pmci_interp_tril_all ( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,  &
     2719          CALL pmci_interp_tril_all ( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,   &
    26852720                                      r2yo, r1zo, r2zo, nzb_s_inner, 's' )
    26862721       ENDIF
     
    27102745
    27112746
    2712     SUBROUTINE pmci_interp_tril_all( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y,    &
     2747    SUBROUTINE pmci_interp_tril_all( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y,     &
    27132748                                     r1z, r2z, kb, var )
    27142749!
    2715 !--    Interpolation of the internal values for the client-domain initialization
     2750!--    Interpolation of the internal values for the child-domain initialization
    27162751!--    This subroutine is based on trilinear interpolation.
    27172752!--    Coding based on interp_tril_lr/sn/t
     
    27392774
    27402775       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg), INTENT(INOUT) :: f !:
    2741        REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: fc    !:
     2776       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr), INTENT(IN) :: fc       !:
    27422777       REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r1x   !:
    27432778       REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN) :: r2x   !:
     
    27622797       jb = nys
    27632798       je = nyn
    2764        IF ( nest_bound_l )  THEN
    2765           ib = nxl - 1
    2766 !
    2767 !--       For u, nxl is a ghost node, but not for the other variables
    2768           IF ( var == 'u' )  THEN
    2769              ib = nxl
     2799       IF ( nesting_mode /= 'vertical' )  THEN
     2800          IF ( nest_bound_l )  THEN
     2801             ib = nxl - 1
     2802!
     2803!--          For u, nxl is a ghost node, but not for the other variables
     2804             IF ( var == 'u' )  THEN
     2805                ib = nxl
     2806             ENDIF
    27702807          ENDIF
    2771        ENDIF
    2772        IF ( nest_bound_s )  THEN
    2773           jb = nys - 1
    2774 !
    2775 !--       For v, nys is a ghost node, but not for the other variables
    2776           IF ( var == 'v' )  THEN
    2777              jb = nys
     2808          IF ( nest_bound_s )  THEN
     2809             jb = nys - 1
     2810!
     2811!--          For v, nys is a ghost node, but not for the other variables
     2812             IF ( var == 'v' )  THEN
     2813                jb = nys
     2814             ENDIF
    27782815          ENDIF
    2779        ENDIF
    2780        IF ( nest_bound_r )  THEN
    2781           ie = nxr + 1
    2782        ENDIF
    2783        IF ( nest_bound_n )  THEN
    2784           je = nyn + 1
    2785        ENDIF
    2786 
     2816          IF ( nest_bound_r )  THEN
     2817             ie = nxr + 1
     2818          ENDIF
     2819          IF ( nest_bound_n )  THEN
     2820             je = nyn + 1
     2821          ENDIF
     2822       ENDIF
    27872823!
    27882824!--    Trilinear interpolation.
     
    28282864                k = kb(j,i) + 1
    28292865                DO  WHILE ( zu(k) < zuc1 )
    2830                    logratio = ( LOG( ( zu(k) - zu(kb(j,i)) ) / z0(j,i)) ) / logzuc1
     2866                   logratio = ( LOG( ( zu(k) - zu(kb(j,i)) ) / z0(j,i)) ) /     &
     2867                                logzuc1
    28312868                   f(k,j,i) = logratio * f(k1,j,i)
    28322869                   k  = k + 1
     
    28492886
    28502887#endif
    2851  END SUBROUTINE pmci_client_initialize
     2888 END SUBROUTINE pmci_child_initialize
    28522889
    28532890
     
    28552892 SUBROUTINE pmci_check_setting_mismatches
    28562893!
    2857 !-- Check for mismatches between settings of master and client variables
    2858 !-- (e.g., all clients have to follow the end_time settings of the root model).
     2894!-- Check for mismatches between settings of master and child variables
     2895!-- (e.g., all children have to follow the end_time settings of the root model).
    28592896!-- The root model overwrites variables in the other models, so these variables
    28602897!-- only need to be set once in file PARIN.
     
    28622899#if defined( __parallel )
    28632900
    2864     USE control_parameters,                                                    &
     2901    USE control_parameters,                                                     &
    28652902        ONLY:  dt_restart, end_time, message_string, restart_time, time_restart
    28662903
     
    28842921    IF ( .NOT. pmc_is_rootmodel() )  THEN
    28852922       IF ( end_time /= end_time_root )  THEN
    2886           WRITE( message_string, * )  'mismatch between root model and ',      &
    2887                'client settings &   end_time(root) = ', end_time_root,         &
    2888                ' &   end_time(client) = ', end_time, ' & client value is set', &
     2923          WRITE( message_string, * )  'mismatch between root model and ',       &
     2924               'child settings &   end_time(root) = ', end_time_root,           &
     2925               ' &   end_time(child) = ', end_time, ' & child value is set',    &
    28892926               ' to root value'
    2890           CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6, &
     2927          CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6,  &
    28912928                        0 )
    28922929          end_time = end_time_root
     
    29012938    IF ( .NOT. pmc_is_rootmodel() )  THEN
    29022939       IF ( restart_time /= restart_time_root )  THEN
    2903           WRITE( message_string, * )  'mismatch between root model and ',      &
    2904                'client settings &   restart_time(root) = ', restart_time_root, &
    2905                ' &   restart_time(client) = ', restart_time, ' & client ',     &
     2940          WRITE( message_string, * )  'mismatch between root model and ',       &
     2941               'child settings &   restart_time(root) = ', restart_time_root,  &
     2942               ' &   restart_time(child) = ', restart_time, ' & child ',        &
    29062943               'value is set to root value'
    2907           CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6, &
     2944          CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6,  &
    29082945                        0 )
    29092946          restart_time = restart_time_root
     
    29182955    IF ( .NOT. pmc_is_rootmodel() )  THEN
    29192956       IF ( dt_restart /= dt_restart_root )  THEN
    2920           WRITE( message_string, * )  'mismatch between root model and ',      &
    2921                'client settings &   dt_restart(root) = ', dt_restart_root,     &
    2922                ' &   dt_restart(client) = ', dt_restart, ' & client ',         &
     2957          WRITE( message_string, * )  'mismatch between root model and ',       &
     2958               'child settings &   dt_restart(root) = ', dt_restart_root,       &
     2959               ' &   dt_restart(child) = ', dt_restart, ' & child ',            &
    29232960               'value is set to root value'
    2924           CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6, &
     2961          CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6,  &
    29252962                        0 )
    29262963          dt_restart = dt_restart_root
     
    29352972    IF ( .NOT. pmc_is_rootmodel() )  THEN
    29362973       IF ( time_restart /= time_restart_root )  THEN
    2937           WRITE( message_string, * )  'mismatch between root model and ',      &
    2938                'client settings &   time_restart(root) = ', time_restart_root, &
    2939                ' &   time_restart(client) = ', time_restart, ' & client ',     &
     2974          WRITE( message_string, * )  'mismatch between root model and ',       &
     2975               'child settings &   time_restart(root) = ', time_restart_root,  &
     2976               ' &   time_restart(child) = ', time_restart, ' & child ',        &
    29402977               'value is set to root value'
    2941           CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6, &
     2978          CALL message( 'pmci_check_setting_mismatches', 'PA0419', 0, 1, 0, 6,  &
    29422979                        0 )
    29432980          time_restart = time_restart_root
     
    29532990 SUBROUTINE pmci_ensure_nest_mass_conservation
    29542991
    2955 #if defined( __parallel )
    29562992!
    29572993!-- Adjust the volume-flow rate through the top boundary so that the net volume
     
    29592995    IMPLICIT NONE
    29602996
    2961     INTEGER(iwp) ::  i                          !:
    2962     INTEGER(iwp) ::  ierr                       !:
    2963     INTEGER(iwp) ::  j                          !:
    2964     INTEGER(iwp) ::  k                          !:
     2997    INTEGER(iwp) ::  i                           !:
     2998    INTEGER(iwp) ::  ierr                        !:
     2999    INTEGER(iwp) ::  j                           !:
     3000    INTEGER(iwp) ::  k                           !:
    29653001
    29663002    REAL(wp) ::  dxdy                            !:
     
    29963032#if defined( __parallel )
    29973033    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    2998     CALL MPI_ALLREDUCE( volume_flow_l(1), volume_flow(1), 1, MPI_REAL, &
     3034    CALL MPI_ALLREDUCE( volume_flow_l(1), volume_flow(1), 1, MPI_REAL,          &
    29993035                        MPI_SUM, comm2d, ierr )
    30003036#else
     
    30293065#if defined( __parallel )
    30303066    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    3031     CALL MPI_ALLREDUCE( volume_flow_l(2), volume_flow(2), 1, MPI_REAL,         &
     3067    CALL MPI_ALLREDUCE( volume_flow_l(2), volume_flow(2), 1, MPI_REAL,          &
    30323068                        MPI_SUM, comm2d, ierr )
    30333069#else
     
    30493085#if defined( __parallel )
    30503086    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
    3051     CALL MPI_ALLREDUCE( volume_flow_l(3), volume_flow(3), 1, MPI_REAL,         &
     3087    CALL MPI_ALLREDUCE( volume_flow_l(3), volume_flow(3), 1, MPI_REAL,          &
    30523088                        MPI_SUM, comm2d, ierr )
    30533089#else
     
    30663102    ENDDO
    30673103
    3068 #endif
    30693104 END SUBROUTINE pmci_ensure_nest_mass_conservation
    30703105
     
    31013136    IMPLICIT NONE
    31023137
    3103     INTEGER(iwp),INTENT(IN) ::  swaplevel  !: swaplevel (1 or 2) of PALM's
    3104                                            !: timestep
    3105 
    3106     INTEGER(iwp)            ::  client_id  !:
    3107     INTEGER(iwp)            ::  m          !:
    3108 
    3109     DO  m = 1, SIZE( pmc_server_for_client )-1
    3110        client_id = pmc_server_for_client(m)
    3111        CALL pmc_s_set_active_data_array( client_id, swaplevel )
     3138    INTEGER(iwp), INTENT(IN) ::  swaplevel  !: swaplevel (1 or 2) of PALM's
     3139                                            !: timestep
     3140
     3141    INTEGER(iwp)            ::  child_id    !:
     3142    INTEGER(iwp)            ::  m           !:
     3143
     3144    DO  m = 1, SIZE( pmc_parent_for_child )-1
     3145       child_id = pmc_parent_for_child(m)
     3146       CALL pmc_s_set_active_data_array( child_id, swaplevel )
    31123147    ENDDO
    31133148
     
    31313166    INTEGER(iwp)           ::  istat  !:
    31323167
    3133     CHARACTER(LEN=*),INTENT(IN) ::  local_nesting_mode
    3134 
    3135     IF ( local_nesting_mode == 'one-way' )  THEN
    3136 
    3137        CALL pmci_client_datatrans( server_to_client )
    3138        CALL pmci_server_datatrans( server_to_client )
     3168    CHARACTER(LEN=*), INTENT(IN) ::  local_nesting_mode
     3169
     3170    IF ( TRIM( local_nesting_mode ) == 'one-way' )  THEN
     3171
     3172       CALL pmci_child_datatrans( parent_to_child )
     3173       CALL pmci_parent_datatrans( parent_to_child )
    31393174
    31403175    ELSE
    31413176
    3142        IF ( nesting_datatransfer_mode == 'cascade' )  THEN
    3143 
    3144           CALL pmci_client_datatrans( server_to_client )
    3145           CALL pmci_server_datatrans( server_to_client )
    3146 
    3147           CALL pmci_server_datatrans( client_to_server )
    3148           CALL pmci_client_datatrans( client_to_server )
    3149 
    3150        ELSEIF ( nesting_datatransfer_mode == 'overlap' )  THEN
    3151 
    3152           CALL pmci_server_datatrans( server_to_client )
    3153           CALL pmci_client_datatrans( server_to_client )
    3154 
    3155           CALL pmci_client_datatrans( client_to_server )
    3156           CALL pmci_server_datatrans( client_to_server )
    3157 
    3158        ELSEIF ( TRIM( nesting_datatransfer_mode ) == 'mixed' )  THEN
    3159 
    3160           CALL pmci_server_datatrans( server_to_client )
    3161           CALL pmci_client_datatrans( server_to_client )
    3162 
    3163           CALL pmci_server_datatrans( client_to_server )
    3164           CALL pmci_client_datatrans( client_to_server )
     3177       IF( nesting_datatransfer_mode == 'cascade' )  THEN
     3178
     3179          CALL pmci_child_datatrans( parent_to_child )
     3180          CALL pmci_parent_datatrans( parent_to_child )
     3181
     3182          CALL pmci_parent_datatrans( child_to_parent )
     3183          CALL pmci_child_datatrans( child_to_parent )
     3184
     3185       ELSEIF( nesting_datatransfer_mode == 'overlap')  THEN
     3186
     3187          CALL pmci_parent_datatrans( parent_to_child )
     3188          CALL pmci_child_datatrans( parent_to_child )
     3189
     3190          CALL pmci_child_datatrans( child_to_parent )
     3191          CALL pmci_parent_datatrans( child_to_parent )
     3192
     3193       ELSEIF( TRIM( nesting_datatransfer_mode ) == 'mixed' )  THEN
     3194
     3195          CALL pmci_parent_datatrans( parent_to_child )
     3196          CALL pmci_child_datatrans( parent_to_child )
     3197
     3198          CALL pmci_parent_datatrans( child_to_parent )
     3199          CALL pmci_child_datatrans( child_to_parent )
    31653200
    31663201       ENDIF
     
    31733208
    31743209
    3175  SUBROUTINE pmci_server_datatrans( direction )
     3210 SUBROUTINE pmci_parent_datatrans( direction )
    31763211
    31773212    IMPLICIT NONE
    31783213
    3179     INTEGER(iwp),INTENT(IN) ::  direction   !:
     3214    INTEGER(iwp), INTENT(IN) ::  direction   !:
    31803215
    31813216#if defined( __parallel )
    3182     INTEGER(iwp) ::  client_id   !:
     3217    INTEGER(iwp) ::  child_id    !:
    31833218    INTEGER(iwp) ::  i           !:
    31843219    INTEGER(iwp) ::  j           !:
     
    31913226
    31923227
    3193     DO  m = 1, SIZE( PMC_Server_for_Client )-1
    3194        client_id = PMC_Server_for_Client(m)
     3228    DO  m = 1, SIZE( pmc_parent_for_child ) - 1
     3229       child_id = pmc_parent_for_child(m)
    31953230       
    3196        IF ( direction == server_to_client )  THEN
    3197           CALL cpu_log( log_point_s(71), 'pmc server send', 'start' )
    3198           CALL pmc_s_fillbuffer( client_id )
    3199           CALL cpu_log( log_point_s(71), 'pmc server send', 'stop' )
     3231       IF ( direction == parent_to_child )  THEN
     3232          CALL cpu_log( log_point_s(71), 'pmc parent send', 'start' )
     3233          CALL pmc_s_fillbuffer( child_id )
     3234          CALL cpu_log( log_point_s(71), 'pmc parent send', 'stop' )
    32003235       ELSE
    32013236!
    3202 !--       Communication from client to server
    3203           CALL cpu_log( log_point_s(72), 'pmc server recv', 'start' )
    3204           client_id = pmc_server_for_client(m)
    3205           CALL pmc_s_getdata_from_buffer( client_id )
    3206           CALL cpu_log( log_point_s(72), 'pmc server recv', 'stop' )
     3237!--       Communication from child to parent
     3238          CALL cpu_log( log_point_s(72), 'pmc parent recv', 'start' )
     3239          child_id = pmc_parent_for_child(m)
     3240          CALL pmc_s_getdata_from_buffer( child_id )
     3241          CALL cpu_log( log_point_s(72), 'pmc parent recv', 'stop' )
    32073242
    32083243!
     
    32343269
    32353270#endif
    3236  END SUBROUTINE pmci_server_datatrans
    3237 
    3238 
    3239 
    3240  SUBROUTINE pmci_client_datatrans( direction )
     3271 END SUBROUTINE pmci_parent_datatrans
     3272
     3273
     3274
     3275 SUBROUTINE pmci_child_datatrans( direction )
    32413276
    32423277    IMPLICIT NONE
     
    32583293    IF ( cpl_id > 1 )  THEN
    32593294!
    3260 !--    Client domain boundaries in the server indice space.
     3295!--    Child domain boundaries in the parent indice space.
    32613296       icl = coarse_bound(1)
    32623297       icr = coarse_bound(2)
     
    32643299       jcn = coarse_bound(4)
    32653300
    3266        IF ( direction == server_to_client )  THEN
    3267 
    3268           CALL cpu_log( log_point_s(73), 'pmc client recv', 'start' )
     3301       IF ( direction == parent_to_child )  THEN
     3302
     3303          CALL cpu_log( log_point_s(73), 'pmc child recv', 'start' )
    32693304          CALL pmc_c_getbuffer( )
    3270           CALL cpu_log( log_point_s(73), 'pmc client recv', 'stop' )
     3305          CALL cpu_log( log_point_s(73), 'pmc child recv', 'stop' )
    32713306
    32723307          CALL cpu_log( log_point_s(75), 'pmc interpolation', 'start' )
     
    32763311       ELSE
    32773312!
    3278 !--       direction == client_to_server
     3313!--       direction == child_to_parent
    32793314          CALL cpu_log( log_point_s(76), 'pmc anterpolation', 'start' )
    32803315          CALL pmci_anterpolation
    32813316          CALL cpu_log( log_point_s(76), 'pmc anterpolation', 'stop' )
    32823317
    3283           CALL cpu_log( log_point_s(74), 'pmc client send', 'start' )
     3318          CALL cpu_log( log_point_s(74), 'pmc child send', 'start' )
    32843319          CALL pmc_c_putbuffer( )
    3285           CALL cpu_log( log_point_s(74), 'pmc client send', 'stop' )
     3320          CALL cpu_log( log_point_s(74), 'pmc child send', 'stop' )
    32863321
    32873322       ENDIF
     
    32973332
    32983333!
    3299 !--    Add IF-condition here: IF not vertical nesting
     3334!--    In case of vertical nesting no interpolation is needed for the
     3335!--    horizontal boundaries
     3336       IF ( nesting_mode /= 'vertical' )  THEN
     3337       
     3338!
    33003339!--    Left border pe:
    3301        IF ( nest_bound_l )  THEN
    3302           CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,  &
    3303                                     r2yo, r1zo, r2zo, nzb_u_inner, logc_u_l,   &
    3304                                     logc_ratio_u_l, nzt_topo_nestbc_l, 'l',    &
    3305                                     'u' )
    3306           CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,  &
    3307                                     r2yv, r1zo, r2zo, nzb_v_inner, logc_v_l,   &
    3308                                     logc_ratio_v_l, nzt_topo_nestbc_l, 'l',    &
    3309                                     'v' )
    3310           CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,  &
    3311                                     r2yo, r1zw, r2zw, nzb_w_inner, logc_w_l,   &
    3312                                     logc_ratio_w_l, nzt_topo_nestbc_l, 'l',    &
    3313                                     'w' )
    3314           CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,  &
    3315                                     r2yo, r1zo, r2zo, nzb_s_inner, logc_u_l,   &
    3316                                     logc_ratio_u_l, nzt_topo_nestbc_l, 'l',    &
    3317                                     'e' )
    3318           IF ( .NOT. neutral )  THEN
    3319              CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo,     &
    3320                                        r1yo, r2yo, r1zo, r2zo, nzb_s_inner,    &
    3321                                        logc_u_l, logc_ratio_u_l,               &
    3322                                        nzt_topo_nestbc_l, 'l', 's' )
    3323           ENDIF
    3324           IF ( humidity  .OR.  passive_scalar )  THEN
    3325              CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, &
    3326                                        r2yo, r1zo, r2zo, nzb_s_inner,          &
    3327                                        logc_u_l, logc_ratio_u_l,               &
    3328                                        nzt_topo_nestbc_l, 'l', 's' )
    3329           ENDIF
    3330 
    3331           IF ( nesting_mode == 'one-way' )  THEN
    3332              CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'l', 'u' )
    3333              CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'l', 'v' )
    3334              CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'l', 'w' )
    3335              CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'l', 'e' )
     3340          IF ( nest_bound_l )  THEN
     3341             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,      &
     3342                                       r1yo, r2yo, r1zo, r2zo, nzb_u_inner,     &
     3343                                       logc_u_l, logc_ratio_u_l,                &
     3344                                       nzt_topo_nestbc_l, 'l', 'u' )
     3345             CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo,      &
     3346                                       r1yv, r2yv, r1zo, r2zo, nzb_v_inner,     &
     3347                                       logc_v_l, logc_ratio_v_l,                &
     3348                                       nzt_topo_nestbc_l, 'l', 'v' )
     3349             CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo,      &
     3350                                       r1yo, r2yo, r1zw, r2zw, nzb_w_inner,     &
     3351                                       logc_w_l, logc_ratio_w_l,                &
     3352                                       nzt_topo_nestbc_l, 'l', 'w' )
     3353             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,      &
     3354                                       r1yo, r2yo, r1zo, r2zo, nzb_s_inner,     &
     3355                                       logc_u_l, logc_ratio_u_l,                &
     3356                                       nzt_topo_nestbc_l, 'l', 'e' )
    33363357             IF ( .NOT. neutral )  THEN
    3337                 CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'l', 's' )
     3358                CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo,   &
     3359                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3360                                          logc_u_l, logc_ratio_u_l,             &
     3361                                          nzt_topo_nestbc_l, 'l', 's' )
    33383362             ENDIF
    33393363             IF ( humidity  .OR.  passive_scalar )  THEN
    3340                 CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'l', 's' )
     3364                CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo,     &
     3365                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3366                                          logc_u_l, logc_ratio_u_l,             &
     3367                                          nzt_topo_nestbc_l, 'l', 's' )
    33413368             ENDIF
     3369
     3370             IF ( TRIM( nesting_mode ) == 'one-way' )  THEN
     3371                CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'l', 'u' )
     3372                CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'l', 'v' )
     3373                CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'l', 'w' )
     3374                CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'l', 'e' )
     3375                IF ( .NOT. neutral )  THEN
     3376                   CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'l', 's' )
     3377                ENDIF
     3378                IF ( humidity  .OR.  passive_scalar )  THEN
     3379                   CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'l', 's' )
     3380                ENDIF
     3381             ENDIF
     3382
    33423383          ENDIF
    33433384
    3344        ENDIF
    3345 !
    3346 !--    Right border pe
    3347        IF ( nest_bound_r )  THEN
    3348           CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,  &
    3349                                     r2yo, r1zo, r2zo, nzb_u_inner, logc_u_r,   &
    3350                                     logc_ratio_u_r, nzt_topo_nestbc_r, 'r',    &
    3351                                     'u' )
    3352           CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,  &
    3353                                     r2yv, r1zo, r2zo, nzb_v_inner, logc_v_r,   &
    3354                                     logc_ratio_v_r, nzt_topo_nestbc_r, 'r',    &
    3355                                     'v' )
    3356           CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,  &
    3357                                     r2yo, r1zw, r2zw, nzb_w_inner, logc_w_r,   &
    3358                                     logc_ratio_w_r, nzt_topo_nestbc_r, 'r',    &
    3359                                     'w' )
    3360           CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,  &
    3361                                     r2yo, r1zo, r2zo, nzb_s_inner, logc_u_r,   &
    3362                                     logc_ratio_u_r, nzt_topo_nestbc_r, 'r',    &
    3363                                     'e' )
    3364           IF ( .NOT. neutral )  THEN
    3365              CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo,     &
    3366                                        r1yo, r2yo, r1zo, r2zo, nzb_s_inner,    &
    3367                                        logc_u_r, logc_ratio_u_r,               &
    3368                                        nzt_topo_nestbc_r, 'r', 's' )
    3369           ENDIF
    3370           IF ( humidity  .OR.  passive_scalar )  THEN
    3371              CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, &
    3372                                        r2yo, r1zo, r2zo, nzb_s_inner,          &
    3373                                        logc_u_r, logc_ratio_u_r,               &
    3374                                        nzt_topo_nestbc_r, 'r', 's' )
    3375           ENDIF
    3376 
    3377           IF ( nesting_mode == 'one-way' )  THEN
    3378              CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'r', 'u' )
    3379              CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'r', 'v' )
    3380              CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'r', 'w' )
    3381              CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'r', 'e' )
     3385   !
     3386   !--    Right border pe
     3387          IF ( nest_bound_r )  THEN
     3388             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,      &
     3389                                       r1yo, r2yo, r1zo, r2zo, nzb_u_inner,     &
     3390                                       logc_u_r, logc_ratio_u_r,                &
     3391                                       nzt_topo_nestbc_r, 'r', 'u' )
     3392             CALL pmci_interp_tril_lr( v,  vc,  ico, jcv, kco, r1xo, r2xo,      &
     3393                                       r1yv, r2yv, r1zo, r2zo, nzb_v_inner,     &
     3394                                       logc_v_r, logc_ratio_v_r,                &
     3395                                       nzt_topo_nestbc_r, 'r', 'v' )
     3396             CALL pmci_interp_tril_lr( w,  wc,  ico, jco, kcw, r1xo, r2xo,      &
     3397                                       r1yo, r2yo, r1zw, r2zw, nzb_w_inner,     &
     3398                                       logc_w_r, logc_ratio_w_r,                &
     3399                                       nzt_topo_nestbc_r, 'r', 'w' )
     3400             CALL pmci_interp_tril_lr( e,  ec,  ico, jco, kco, r1xo, r2xo,      &
     3401                                       r1yo,r2yo, r1zo, r2zo, nzb_s_inner,      &
     3402                                       logc_u_r, logc_ratio_u_r,                &
     3403                                       nzt_topo_nestbc_r, 'r', 'e' )
    33823404             IF ( .NOT. neutral )  THEN
    3383                 CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'r', 's' )
     3405                CALL pmci_interp_tril_lr( pt, ptc, ico, jco, kco, r1xo, r2xo,   &
     3406                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3407                                          logc_u_r, logc_ratio_u_r,             &
     3408                                          nzt_topo_nestbc_r, 'r', 's' )
    33843409             ENDIF
    33853410             IF ( humidity  .OR.  passive_scalar )  THEN
    3386                 CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'r', 's' )
     3411                CALL pmci_interp_tril_lr( q, qc, ico, jco, kco, r1xo, r2xo,     &
     3412                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3413                                          logc_u_r, logc_ratio_u_r,             &
     3414                                          nzt_topo_nestbc_r, 'r', 's' )
    33873415             ENDIF
     3416
     3417             IF ( TRIM( nesting_mode ) == 'one-way' )  THEN
     3418                CALL pmci_extrap_ifoutflow_lr( u, nzb_u_inner, 'r', 'u' )
     3419                CALL pmci_extrap_ifoutflow_lr( v, nzb_v_inner, 'r', 'v' )
     3420                CALL pmci_extrap_ifoutflow_lr( w, nzb_w_inner, 'r', 'w' )
     3421                CALL pmci_extrap_ifoutflow_lr( e, nzb_s_inner, 'r', 'e' )
     3422                IF ( .NOT. neutral )  THEN
     3423                   CALL pmci_extrap_ifoutflow_lr( pt,nzb_s_inner, 'r', 's' )
     3424                ENDIF
     3425                IF ( humidity  .OR.  passive_scalar )  THEN
     3426                   CALL pmci_extrap_ifoutflow_lr( q, nzb_s_inner, 'r', 's' )
     3427                ENDIF
     3428             ENDIF
     3429
    33883430          ENDIF
    33893431
    3390        ENDIF
    3391 !
    3392 !--    South border pe
    3393        IF ( nest_bound_s )  THEN
    3394           CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,  &
    3395                                     r2yo, r1zo, r2zo, nzb_u_inner, logc_u_s,   &
    3396                                     logc_ratio_u_s, nzt_topo_nestbc_s, 's',    &
    3397                                     'u' )
    3398           CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,  &
    3399                                     r2yv, r1zo, r2zo, nzb_v_inner, logc_v_s,   &
    3400                                     logc_ratio_v_s, nzt_topo_nestbc_s, 's',    &
    3401                                     'v' )
    3402           CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,  &
    3403                                     r2yo, r1zw, r2zw, nzb_w_inner, logc_w_s,   &
    3404                                     logc_ratio_w_s, nzt_topo_nestbc_s, 's',    &
    3405                                     'w' )
    3406           CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,  &
    3407                                     r2yo, r1zo, r2zo, nzb_s_inner, logc_u_s,   &
    3408                                     logc_ratio_u_s, nzt_topo_nestbc_s, 's',    &
    3409                                     'e' )
    3410           IF ( .NOT. neutral )  THEN
    3411              CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,     &
    3412                                        r1yo, r2yo, r1zo, r2zo, nzb_s_inner,    &
    3413                                        logc_u_s, logc_ratio_u_s,               &
    3414                                        nzt_topo_nestbc_s, 's', 's' )
    3415           ENDIF
    3416           IF ( humidity  .OR.  passive_scalar )  THEN
    3417              CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, &
    3418                                        r2yo, r1zo, r2zo, nzb_s_inner,          &
    3419                                        logc_u_s, logc_ratio_u_s,               &
    3420                                        nzt_topo_nestbc_s, 's', 's' )
    3421           ENDIF
    3422 
    3423           IF ( nesting_mode == 'one-way' )  THEN
    3424              CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 's', 'u' )
    3425              CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 's', 'v' )
    3426              CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 's', 'w' )
    3427              CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 's', 'e' )
     3432   !
     3433   !--    South border pe
     3434          IF ( nest_bound_s )  THEN
     3435             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,      &
     3436                                       r1yo, r2yo, r1zo, r2zo, nzb_u_inner,     &
     3437                                       logc_u_s, logc_ratio_u_s,                &
     3438                                       nzt_topo_nestbc_s, 's', 'u' )
     3439             CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo,      &
     3440                                       r1yv, r2yv, r1zo, r2zo, nzb_v_inner,     &
     3441                                       logc_v_s, logc_ratio_v_s,                &
     3442                                       nzt_topo_nestbc_s, 's', 'v' )
     3443             CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo,      &
     3444                                       r1yo, r2yo, r1zw, r2zw, nzb_w_inner,     &
     3445                                       logc_w_s, logc_ratio_w_s,                &
     3446                                       nzt_topo_nestbc_s, 's','w' )
     3447             CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,      &
     3448                                       r1yo, r2yo, r1zo, r2zo, nzb_s_inner,     &
     3449                                       logc_u_s, logc_ratio_u_s,                &
     3450                                       nzt_topo_nestbc_s, 's', 'e' )
    34283451             IF ( .NOT. neutral )  THEN
    3429                 CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 's', 's' )
     3452                CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,   &
     3453                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3454                                          logc_u_s, logc_ratio_u_s,             &
     3455                                          nzt_topo_nestbc_s, 's', 's' )
    34303456             ENDIF
    34313457             IF ( humidity  .OR.  passive_scalar )  THEN
    3432                 CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 's', 's' )
     3458                CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo,     &
     3459                                          r1yo,r2yo, r1zo, r2zo, nzb_s_inner,   &
     3460                                          logc_u_s, logc_ratio_u_s,             &
     3461                                          nzt_topo_nestbc_s, 's', 's' )
    34333462             ENDIF
     3463
     3464             IF ( TRIM( nesting_mode ) == 'one-way' )  THEN
     3465                CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 's', 'u' )
     3466                CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 's', 'v' )
     3467                CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 's', 'w' )
     3468                CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 's', 'e' )
     3469                IF ( .NOT. neutral )  THEN
     3470                   CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 's', 's' )
     3471                ENDIF
     3472                IF ( humidity  .OR.  passive_scalar )  THEN
     3473                   CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 's', 's' )
     3474                ENDIF
     3475             ENDIF
     3476
    34343477          ENDIF
    34353478
    3436        ENDIF
    3437 !
    3438 !--    North border pe
    3439        IF ( nest_bound_n )  THEN
    3440           CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,  &
    3441                                     r2yo, r1zo, r2zo, nzb_u_inner, logc_u_n,   &
    3442                                     logc_ratio_u_n, nzt_topo_nestbc_n, 'n',    &
    3443                                     'u' )
    3444           CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,  &
    3445                                     r2yv, r1zo, r2zo, nzb_v_inner, logc_v_n,   &
    3446                                     logc_ratio_v_n, nzt_topo_nestbc_n, 'n',    &
    3447                                     'v' )
    3448           CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,  &
    3449                                     r2yo, r1zw, r2zw, nzb_w_inner, logc_w_n,   &
    3450                                     logc_ratio_w_n, nzt_topo_nestbc_n, 'n',    &
    3451                                     'w' )
    3452           CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,  &
    3453                                     r2yo, r1zo, r2zo, nzb_s_inner, logc_u_n,   &
    3454                                     logc_ratio_u_n, nzt_topo_nestbc_n, 'n',    &
    3455                                     'e' )
    3456           IF ( .NOT. neutral )  THEN
    3457              CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,     &
    3458                                        r1yo, r2yo, r1zo, r2zo, nzb_s_inner,    &
    3459                                        logc_u_n, logc_ratio_u_n,               &
    3460                                        nzt_topo_nestbc_n, 'n', 's' )
    3461           ENDIF
    3462           IF ( humidity  .OR.  passive_scalar )  THEN
    3463              CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo, r1yo, &
    3464                                        r2yo, r1zo, r2zo, nzb_s_inner,          &
    3465                                        logc_u_n, logc_ratio_u_n,               &
    3466                                        nzt_topo_nestbc_n, 'n', 's' )
    3467           ENDIF
    3468 
    3469           IF ( nesting_mode == 'one-way' )  THEN
    3470              CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 'n', 'u' )
    3471              CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 'n', 'v' )
    3472              CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 'n', 'w' )
    3473              CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 'n', 'e' )
     3479   !
     3480   !--    North border pe
     3481          IF ( nest_bound_n )  THEN
     3482             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,      &
     3483                                       r1yo, r2yo, r1zo, r2zo, nzb_u_inner,     &
     3484                                       logc_u_n, logc_ratio_u_n,                &
     3485                                       nzt_topo_nestbc_n, 'n', 'u' )
     3486             CALL pmci_interp_tril_sn( v,  vc,  ico, jcv, kco, r1xo, r2xo,      &
     3487                                       r1yv, r2yv, r1zo, r2zo, nzb_v_inner,     &
     3488                                       logc_v_n, logc_ratio_v_n,                &
     3489                                       nzt_topo_nestbc_n, 'n', 'v' )
     3490             CALL pmci_interp_tril_sn( w,  wc,  ico, jco, kcw, r1xo, r2xo,      &
     3491                                       r1yo, r2yo, r1zw, r2zw, nzb_w_inner,     &
     3492                                       logc_w_n, logc_ratio_w_n,                &
     3493                                       nzt_topo_nestbc_n, 'n', 'w' )
     3494             CALL pmci_interp_tril_sn( e,  ec,  ico, jco, kco, r1xo, r2xo,      &
     3495                                       r1yo, r2yo, r1zo, r2zo, nzb_s_inner,     &
     3496                                       logc_u_n, logc_ratio_u_n,                &
     3497                                       nzt_topo_nestbc_n, 'n', 'e' )
    34743498             IF ( .NOT. neutral )  THEN
    3475                 CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 'n', 's' )
     3499                CALL pmci_interp_tril_sn( pt, ptc, ico, jco, kco, r1xo, r2xo,   &
     3500                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3501                                          logc_u_n, logc_ratio_u_n,             &
     3502                                          nzt_topo_nestbc_n, 'n', 's' )
    34763503             ENDIF
    34773504             IF ( humidity  .OR.  passive_scalar )  THEN
    3478                 CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 'n', 's' )
     3505                CALL pmci_interp_tril_sn( q, qc, ico, jco, kco, r1xo, r2xo,     &
     3506                                          r1yo, r2yo, r1zo, r2zo, nzb_s_inner,  &
     3507                                          logc_u_n, logc_ratio_u_n,             &
     3508                                          nzt_topo_nestbc_n, 'n', 's' )
    34793509             ENDIF
    34803510
     3511             IF ( TRIM( nesting_mode ) == 'one-way' )  THEN
     3512                CALL pmci_extrap_ifoutflow_sn( u, nzb_u_inner, 'n', 'u' )
     3513                CALL pmci_extrap_ifoutflow_sn( v, nzb_v_inner, 'n', 'v' )
     3514                CALL pmci_extrap_ifoutflow_sn( w, nzb_w_inner, 'n', 'w' )
     3515                CALL pmci_extrap_ifoutflow_sn( e, nzb_s_inner, 'n', 'e' )
     3516                IF ( .NOT. neutral )  THEN
     3517                   CALL pmci_extrap_ifoutflow_sn( pt,nzb_s_inner, 'n', 's' )
     3518                ENDIF
     3519                IF ( humidity  .OR.  passive_scalar )  THEN
     3520                   CALL pmci_extrap_ifoutflow_sn( q, nzb_s_inner, 'n', 's' )
     3521                ENDIF
     3522
     3523             ENDIF
     3524
    34813525          ENDIF
    34823526
    3483        ENDIF
     3527       ENDIF       !: IF ( nesting_mode /= 'vertical' )
    34843528
    34853529!
    34863530!--    All PEs are top-border PEs
    3487        CALL pmci_interp_tril_t( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,      &
     3531       CALL pmci_interp_tril_t( u,  uc,  icu, jco, kco, r1xu, r2xu, r1yo,       &
    34883532                                r2yo, r1zo, r2zo, 'u' )
    3489        CALL pmci_interp_tril_t( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,      &
     3533       CALL pmci_interp_tril_t( v,  vc,  ico, jcv, kco, r1xo, r2xo, r1yv,       &
    34903534                                r2yv, r1zo, r2zo, 'v' )
    3491        CALL pmci_interp_tril_t( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,      &
     3535       CALL pmci_interp_tril_t( w,  wc,  ico, jco, kcw, r1xo, r2xo, r1yo,       &
    34923536                                r2yo, r1zw, r2zw, 'w' )
    3493        CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,      &
     3537       CALL pmci_interp_tril_t( e,  ec,  ico, jco, kco, r1xo, r2xo, r1yo,       &
    34943538                                r2yo, r1zo, r2zo, 'e' )
    34953539       IF ( .NOT. neutral )  THEN
    3496           CALL pmci_interp_tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo,   &
     3540          CALL pmci_interp_tril_t( pt, ptc, ico, jco, kco, r1xo, r2xo, r1yo,    &
    34973541                                   r2yo, r1zo, r2zo, 's' )
    34983542       ENDIF
    34993543       IF ( humidity .OR. passive_scalar )  THEN
    3500           CALL pmci_interp_tril_t( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,     &
     3544          CALL pmci_interp_tril_t( q, qc, ico, jco, kco, r1xo, r2xo, r1yo,      &
    35013545                                   r2yo, r1zo, r2zo, 's' )
    35023546       ENDIF
    35033547
    3504        IF ( nesting_mode == 'one-way' )  THEN
     3548       IF ( TRIM( nesting_mode ) == 'one-way' )  THEN
    35053549          CALL pmci_extrap_ifoutflow_t( u,  'u' )
    35063550          CALL pmci_extrap_ifoutflow_t( v,  'v' )
     
    35133557             CALL pmci_extrap_ifoutflow_t( q, 's' )
    35143558          ENDIF
    3515       ENDIF
     3559       ENDIF
    35163560
    35173561   END SUBROUTINE pmci_interpolation
     
    35263570      IMPLICIT NONE
    35273571
    3528       CALL pmci_anterp_tophat( u,  uc,  kctu, iflu, ifuu, jflo, jfuo, kflo,    &
     3572      CALL pmci_anterp_tophat( u,  uc,  kctu, iflu, ifuu, jflo, jfuo, kflo,     &
    35293573                               kfuo, ijfc_u, 'u' )
    3530       CALL pmci_anterp_tophat( v,  vc,  kctu, iflo, ifuo, jflv, jfuv, kflo,    &
     3574      CALL pmci_anterp_tophat( v,  vc,  kctu, iflo, ifuo, jflv, jfuv, kflo,     &
    35313575                               kfuo, ijfc_v, 'v' )
    3532       CALL pmci_anterp_tophat( w,  wc,  kctw, iflo, ifuo, jflo, jfuo, kflw,    &
     3576      CALL pmci_anterp_tophat( w,  wc,  kctw, iflo, ifuo, jflo, jfuo, kflw,     &
    35333577                               kfuw, ijfc_s, 'w' )
    35343578      IF ( .NOT. neutral )  THEN
    3535          CALL pmci_anterp_tophat( pt, ptc, kctu, iflo, ifuo, jflo, jfuo, kflo, &
     3579         CALL pmci_anterp_tophat( pt, ptc, kctu, iflo, ifuo, jflo, jfuo, kflo,  &
    35363580                                  kfuo, ijfc_s, 's' )
    35373581      ENDIF
    35383582      IF ( humidity  .OR.  passive_scalar )  THEN
    3539          CALL pmci_anterp_tophat( q, qc, kctu, iflo, ifuo, jflo, jfuo, kflo,   &
     3583         CALL pmci_anterp_tophat( q, qc, kctu, iflo, ifuo, jflo, jfuo, kflo,    &
    35403584                                  kfuo, ijfc_s, 's' )
    35413585      ENDIF
     
    35453589
    35463590
    3547    SUBROUTINE pmci_interp_tril_lr( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, &
    3548                                    r2z, kb, logc, logc_ratio, nzt_topo_nestbc, &
     3591   SUBROUTINE pmci_interp_tril_lr( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z,  &
     3592                                   r2z, kb, logc, logc_ratio, nzt_topo_nestbc,  &
    35493593                                   edge, var )
    35503594!
    3551 !--   Interpolation of ghost-node values used as the client-domain boundary
     3595!--   Interpolation of ghost-node values used as the child-domain boundary
    35523596!--   conditions. This subroutine handles the left and right boundaries. It is
    35533597!--   based on trilinear interpolation.
     
    35553599      IMPLICIT NONE
    35563600
    3557       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
     3601      REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
    35583602                                      INTENT(INOUT) ::  f       !:
    3559       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                          &
     3603      REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                           &
    35603604                                      INTENT(IN)    ::  fc      !:
    3561       REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nys:nyn),          &
     3605      REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nys:nyn),           &
    35623606                                      INTENT(IN)    ::  logc_ratio   !:
    35633607      REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN)    ::  r1x     !:
     
    35723616      INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg), INTENT(IN) ::  kb     !:
    35733617      INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN)           ::  kc     !:
    3574       INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nys:nyn),                &
     3618      INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nys:nyn),                 &
    35753619                                          INTENT(IN)           ::  logc   !:
    35763620      INTEGER(iwp) ::  nzt_topo_nestbc   !:
    35773621
    3578       CHARACTER(LEN=1),INTENT(IN) ::  edge   !:
    3579       CHARACTER(LEN=1),INTENT(IN) ::  var    !:
     3622      CHARACTER(LEN=1), INTENT(IN) ::  edge   !:
     3623      CHARACTER(LEN=1), INTENT(IN) ::  var    !:
    35803624
    35813625      INTEGER(iwp) ::  i       !:
     
    37013745                     DO  kcorr = 0, ncorr-1
    37023746                        kco = k + kcorr
    3703                         f(kco,jco,i) = 0.5_wp * ( logc_ratio(1,kcorr,k,j) *    &
    3704                                                   f(k1,j,i)                    &
    3705                                                 + logc_ratio(2,jcorr,k,j) *    &
     3747                        f(kco,jco,i) = 0.5_wp * ( logc_ratio(1,kcorr,k,j) *     &
     3748                                                  f(k1,j,i)                     &
     3749                                                + logc_ratio(2,jcorr,k,j) *     &
    37063750                                                  f(k,j1,i) )
    37073751                     ENDDO
     
    37473791
    37483792
    3749    SUBROUTINE pmci_interp_tril_sn( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z, &
    3750                                    r2z, kb, logc, logc_ratio,                  &
     3793   SUBROUTINE pmci_interp_tril_sn( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z,  &
     3794                                   r2z, kb, logc, logc_ratio,                   &
    37513795                                   nzt_topo_nestbc, edge, var )
    37523796
    37533797!
    3754 !--   Interpolation of ghost-node values used as the client-domain boundary
     3798!--   Interpolation of ghost-node values used as the child-domain boundary
    37553799!--   conditions. This subroutine handles the south and north boundaries.
    37563800!--   This subroutine is based on trilinear interpolation.
     
    37583802      IMPLICIT NONE
    37593803
    3760       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
     3804      REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
    37613805                                      INTENT(INOUT) ::  f             !:
    3762       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                          &
     3806      REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                           &
    37633807                                      INTENT(IN)    ::  fc            !:
    3764       REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nxl:nxr),          &
     3808      REAL(wp), DIMENSION(1:2,0:ncorr-1,nzb:nzt_topo_nestbc,nxl:nxr),           &
    37653809                                      INTENT(IN)    ::  logc_ratio    !:
    37663810      REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN)    ::  r1x           !:
     
    37753819      INTEGER(iwp), DIMENSION(nysg:nyng,nxlg:nxrg), INTENT(IN) ::  kb    !:
    37763820      INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN)           ::  kc    !:
    3777       INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nxl:nxr),                &
     3821      INTEGER(iwp), DIMENSION(1:2,nzb:nzt_topo_nestbc,nxl:nxr),                 &
    37783822                                          INTENT(IN)           ::  logc  !:
    37793823      INTEGER(iwp) ::  nzt_topo_nestbc   !:
     
    39023946                     DO  kcorr = 0, ncorr-1
    39033947                        kco = k + kcorr
    3904                         f(kco,i,ico) = 0.5_wp * ( logc_ratio(1,kcorr,k,i) *    &
     3948                        f(kco,i,ico) = 0.5_wp * ( logc_ratio(1,kcorr,k,i) *     &
    39053949                                                  f(k1,j,i)  &
    3906                                                 + logc_ratio(2,icorr,k,i) *    &
     3950                                                + logc_ratio(2,icorr,k,i) *     &
    39073951                                                  f(k,j,i1) )
    39083952                     ENDDO
     
    39483992 
    39493993
    3950    SUBROUTINE pmci_interp_tril_t( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z,  &
     3994   SUBROUTINE pmci_interp_tril_t( f, fc, ic, jc, kc, r1x, r2x, r1y, r2y, r1z,   &
    39513995                                  r2z, var )
    39523996
    39533997!
    3954 !--   Interpolation of ghost-node values used as the client-domain boundary
     3998!--   Interpolation of ghost-node values used as the child-domain boundary
    39553999!--   conditions. This subroutine handles the top boundary.
    39564000!--   This subroutine is based on trilinear interpolation.
     
    39584002      IMPLICIT NONE
    39594003
    3960       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                      &
     4004      REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                       &
    39614005                                      INTENT(INOUT) ::  f     !:
    3962       REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                          &
     4006      REAL(wp), DIMENSION(0:cg%nz+1,jcs:jcn,icl:icr),                           &
    39634007                                      INTENT(IN)    ::  fc    !:
    39644008      REAL(wp), DIMENSION(nxlg:nxrg), INTENT(IN)    ::  r1x   !:
     
    39694013      REAL(wp), DIMENSION(nzb:nzt+1), INTENT(IN)    ::  r2z   !:
    39704014     
    3971       INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) ::  ic   !:
    3972       INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) ::  jc   !:
    3973       INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) ::  kc   !:
     4015      INTEGER(iwp), DIMENSION(nxlg:nxrg), INTENT(IN) ::  ic    !:
     4016      INTEGER(iwp), DIMENSION(nysg:nyng), INTENT(IN) ::  jc    !:
     4017      INTEGER(iwp), DIMENSION(nzb:nzt+1), INTENT(IN) ::  kc    !:
    39744018     
    39754019      CHARACTER(LEN=1), INTENT(IN) :: var   !:
     
    40384082    SUBROUTINE pmci_extrap_ifoutflow_lr( f, kb, edge, var )
    40394083!
    4040 !--    After the interpolation of ghost-node values for the client-domain
     4084!--    After the interpolation of ghost-node values for the child-domain
    40414085!--    boundary conditions, this subroutine checks if there is a local outflow
    40424086!--    through the boundary. In that case this subroutine overwrites the
     
    40474091       IMPLICIT NONE
    40484092
    4049        CHARACTER(LEN=1),INTENT(IN) ::  edge   !:
    4050        CHARACTER(LEN=1),INTENT(IN) ::  var    !:
     4093       CHARACTER(LEN=1), INTENT(IN) ::  edge   !:
     4094       CHARACTER(LEN=1), INTENT(IN) ::  var    !:
    40514095
    40524096       INTEGER(iwp) ::  i     !:
     
    41164160    SUBROUTINE pmci_extrap_ifoutflow_sn( f, kb, edge, var )
    41174161!
    4118 !--    After  the interpolation of ghost-node values for the client-domain
     4162!--    After  the interpolation of ghost-node values for the child-domain
    41194163!--    boundary conditions, this subroutine checks if there is a local outflow
    41204164!--    through the boundary. In that case this subroutine overwrites the
     
    41934237    SUBROUTINE pmci_extrap_ifoutflow_t( f, var )
    41944238!
    4195 !--    Interpolation of ghost-node values used as the client-domain boundary
     4239!--    Interpolation of ghost-node values used as the child-domain boundary
    41964240!--    conditions. This subroutine handles the top boundary. It is based on
    41974241!--    trilinear interpolation.
     
    42084252       REAL(wp) ::  vdotnor   !:
    42094253
    4210        REAL(wp), DIMENSION(nzb:nzt+1,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp),     &
     4254       REAL(wp), DIMENSION(nzb:nzt+1,nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp),      &
    42114255                 INTENT(INOUT) ::  f   !:
    42124256     
     
    42414285
    42424286
    4243     SUBROUTINE pmci_anterp_tophat( f, fc, kct, ifl, ifu, jfl, jfu, kfl, kfu,   &
     4287    SUBROUTINE pmci_anterp_tophat( f, fc, kct, ifl, ifu, jfl, jfu, kfl, kfu,    &
    42444288                                   ijfc, var )
    42454289!
    4246 !--    Anterpolation of internal-node values to be used as the server-domain
     4290!--    Anterpolation of internal-node values to be used as the parent-domain
    42474291!--    values. This subroutine is based on the first-order numerical
    42484292!--    integration of the fine-grid values contained within the coarse-grid
     
    42964340!--    Note that kcb is simply zero and kct enters here as a parameter and it is
    42974341!--    determined in pmci_init_anterp_tophat
    4298        IF ( nest_bound_l )  THEN
    4299           IF ( var == 'u' )  THEN
    4300              iclp = icl + nhll + 1
    4301           ELSE
     4342
     4343       IF ( nesting_mode == 'vertical' )  THEN
     4344          IF ( nest_bound_l )  THEN
    43024345             iclp = icl + nhll
    43034346          ENDIF
    4304        ENDIF
    4305        IF ( nest_bound_r )  THEN
    4306           icrm = icr - nhlr
    4307        ENDIF
    4308 
    4309        IF ( nest_bound_s )  THEN
    4310           IF ( var == 'v' )  THEN
    4311              jcsp = jcs + nhls + 1
    4312           ELSE
     4347          IF ( nest_bound_r ) THEN
     4348             icrm = icr - nhlr
     4349          ENDIF
     4350          IF ( nest_bound_s )  THEN
    43134351             jcsp = jcs + nhls
    43144352          ENDIF
    4315        ENDIF
    4316        IF ( nest_bound_n )  THEN
    4317           jcnm = jcn - nhln
    4318        ENDIF
    4319        kcb = 0
    4320 
     4353          IF ( nest_bound_n )  THEN
     4354             jcnm = jcn - nhln
     4355          ENDIF
     4356       ELSE
     4357          IF ( nest_bound_l )  THEN
     4358             IF ( var == 'u' )  THEN
     4359                iclp = icl + nhll + 1
     4360             ELSE
     4361                iclp = icl + nhll
     4362             ENDIF
     4363          ENDIF
     4364          IF ( nest_bound_r )  THEN
     4365             icrm = icr - nhlr
     4366          ENDIF
     4367
     4368          IF ( nest_bound_s )  THEN
     4369             IF ( var == 'v' )  THEN
     4370                jcsp = jcs + nhls + 1
     4371             ELSE
     4372                jcsp = jcs + nhls
     4373             ENDIF
     4374          ENDIF
     4375          IF ( nest_bound_n )  THEN
     4376             jcnm = jcn - nhln
     4377          ENDIF
     4378          kcb = 0
     4379       ENDIF
     4380       
    43214381!
    43224382!--    Note that ii, jj, and kk are coarse-grid indices and i,j, and k
     
    43494409                ENDIF
    43504410
    4351                 fc(kk,jj,ii) = ( 1.0_wp - fra ) * fc(kk,jj,ii) +               &
     4411                fc(kk,jj,ii) = ( 1.0_wp - fra ) * fc(kk,jj,ii) +                &
    43524412                               fra * cellsum / REAL( nfc, KIND = wp )
    43534413
     
    43594419
    43604420#endif
    4361  END SUBROUTINE pmci_client_datatrans
     4421 END SUBROUTINE pmci_child_datatrans
    43624422
    43634423END MODULE pmc_interface
Note: See TracChangeset for help on using the changeset viewer.