Changeset 3182 for palm


Ignore:
Timestamp:
Jul 27, 2018 1:36:03 PM (7 years ago)
Author:
suehring
Message:

New Inifor features: grid stretching, improved command-interface, support start dates in different formats in both YYYYMMDD and YYYYMMDDHH, Ability to manually control input file prefixes (--radiation-prefix, --soil-preifx, --flow-prefix, --soilmoisture-prefix) for compatiblity with DWD forcast naming scheme; GNU-style short and long option; Prepared output of large-scale forcing profiles (no computation yet); Added preprocessor flag netcdf4 to switch output format between netCDF 3 and 4; Updated netCDF variable names and attributes to comply with PIDS v1.9; Inifor bugfixes: Improved compatibility with older Intel Intel compilers by avoiding implicit array allocation; Added origin_lon/_lat values and correct reference time in dynamic driver global attributes; corresponding PALM changes: adjustments to revised Inifor; variables names in dynamic driver adjusted; enable geostrophic forcing also in offline nested mode; variable names in LES-LES and COSMO offline nesting changed; lateral boundary flags for nesting, in- and outflow conditions renamed

Location:
palm/trunk
Files:
2 added
45 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified palm/trunk/SOURCE/advec_ws.f90

    r3022 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Rename variables for boundary-condition flags and for offline nesting mode
    2323!
    2424! Former revisions:
     
    460460
    461461       USE control_parameters,                                                 &
    462            ONLY:  force_bound_l, force_bound_n, force_bound_r, force_bound_s,  &
    463                   inflow_l, inflow_n, inflow_r, inflow_s, momentum_advec,      &
    464                   nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,      &
    465                   outflow_l, outflow_n, outflow_r, outflow_s, scalar_advec
     462           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
     463                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
     464                  bc_radiation_r, bc_radiation_s, momentum_advec, scalar_advec
    466465
    467466       USE indices,                                                            &
     
    501500                    .OR.  .NOT. BTEST(wall_flags_0(k,j,i+2),0)                 &   
    502501                    .OR.  .NOT. BTEST(wall_flags_0(k,j,i-1),0) )               &
    503                       .OR.  ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    504                                 force_bound_l )                                &
     502                      .OR.  ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    505503                            .AND.  i == nxl   )                                &
    506                       .OR.  ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    507                                 force_bound_r )                                &
     504                      .OR.  ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    508505                            .AND.  i == nxr   ) )                              &
    509506                   THEN
     
    520517                            )                                                  &
    521518                                                    .OR.                       &
    522                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    523                                 force_bound_r )                                &
     519                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    524520                              .AND. i == nxr-1 )    .OR.                       &
    525                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    526                                 force_bound_l )                                &
     521                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    527522                              .AND. i == nxlu  ) )                             & ! why not nxl+1
    528523                   THEN
     
    542537                    .OR.  .NOT. BTEST(wall_flags_0(k,j+2,i),0)                 &   
    543538                    .OR.  .NOT. BTEST(wall_flags_0(k,j-1,i),0))                &
    544                       .OR.  ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    545                                 force_bound_s )                                &
     539                      .OR.  ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    546540                            .AND.  j == nys   )                                &
    547                       .OR.  ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    548                                 force_bound_n )                                &
     541                      .OR.  ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    549542                            .AND.  j == nyn   ) )                              &
    550543                   THEN
     
    563556                            )                                                  &
    564557                                                    .OR.                       &
    565                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    566                                 force_bound_s )                                &
     558                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    567559                              .AND. j == nysv  )    .OR.                       & ! why not nys+1
    568                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    569                                 force_bound_n )                                &
     560                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    570561                              .AND. j == nyn-1 ) )                             &         
    571562                   THEN
     
    655646!--                WS1 (9), WS3 (10), WS5 (11)
    656647                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),1)  .OR.             &
    657                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    658                                 force_bound_l )                                &
     648                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    659649                              .AND. i <= nxlu  )    .OR.                       &
    660                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    661                                 force_bound_r )                                &
     650                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    662651                              .AND. i == nxr   ) )                             &
    663652                   THEN
     
    667656                              .NOT. BTEST(wall_flags_0(k,j,i-1),1) )           &
    668657                                                        .OR.                   &
    669                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    670                                 force_bound_r )                                &
     658                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    671659                              .AND. i == nxr-1 )    .OR.                       &
    672                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    673                                 force_bound_l )                                &
     660                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    674661                              .AND. i == nxlu+1) )                             &
    675662                   THEN
     
    691678!--                WS1 (12), WS3 (13), WS5 (14)
    692679                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),1)   .OR.            &
    693                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    694                                 force_bound_s )                                &
     680                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    695681                              .AND. j == nys   )    .OR.                       &
    696                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    697                                 force_bound_n )                                &
     682                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    698683                              .AND. j == nyn   ) )                             &
    699684                   THEN
     
    703688                              .NOT. BTEST(wall_flags_0(k,j-1,i),1) )           &
    704689                                                        .OR.                   &
    705                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    706                                 force_bound_s )                                &
     690                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    707691                              .AND. j == nysv  )    .OR.                       &
    708                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    709                                 force_bound_n )                                &
     692                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    710693                              .AND. j == nyn-1 ) )                             &
    711694                   THEN
     
    789772!--                WS1 (18), WS3 (19), WS5 (20)
    790773                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),2)  .OR.             &
    791                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    792                                 force_bound_l )                                &
     774                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    793775                              .AND. i == nxl   )    .OR.                       &
    794                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    795                                 force_bound_r )                                &
     776                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    796777                              .AND. i == nxr   ) )                             &
    797778                  THEN
     
    803784                              .NOT. BTEST(wall_flags_0(k,j,i-1),2)             &
    804785                                                    .OR.                       &
    805                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    806                                 force_bound_r )                                &
     786                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    807787                              .AND. i == nxr-1 )    .OR.                       &
    808                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    809                                 force_bound_l )                                &
     788                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
    810789                              .AND. i == nxlu  ) )                             &
    811790                   THEN
     
    827806!--                WS1 (21), WS3 (22), WS5 (23)
    828807                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),2) .OR.              &
    829                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    830                                 force_bound_s )                                &
     808                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    831809                              .AND. j <= nysv  )    .OR.                       &
    832                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    833                                 force_bound_n )                                &
     810                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    834811                              .AND. j == nyn   ) )                             &
    835812                   THEN
     
    839816                              .NOT. BTEST(wall_flags_0(k,j-1,i),2) )           &
    840817                                                        .OR.                   &
    841                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    842                                 force_bound_s )                                &
     818                            ( (  bc_dirichlet_s .OR. bc_radiation_s )          &
    843819                              .AND. j == nysv+1)    .OR.                       &
    844                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    845                                 force_bound_n )                                &
     820                            ( (  bc_dirichlet_n .OR. bc_radiation_n )          &
    846821                              .AND. j == nyn-1 ) )                             &
    847822                   THEN
     
    924899!--                WS1 (27), WS3 (28), WS5 (29)
    925900                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),3) .OR.              &
    926                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    927                                 force_bound_l )                                &
     901                            ( (  bc_dirichlet_l .OR. bc_radiation_l )          &
    928902                              .AND. i == nxl   )    .OR.                       &
    929                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    930                                 force_bound_r )                                &
     903                            ( (  bc_dirichlet_r .OR. bc_radiation_r )          &
    931904                              .AND. i == nxr   ) )                             &
    932905                   THEN
     
    936909                              .NOT. BTEST(wall_flags_0(k,j,i-1),3) )           &
    937910                                                        .OR.                   &
    938                             ( ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.&
    939                                 force_bound_r )                                &
     911                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
    940912                              .AND. i == nxr-1 )    .OR.                       &
    941                             ( ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.&
    942                                 force_bound_l )                                &
     913                            ( ( bc_dirichlet_l .OR.  bc_radiation_l )          &
    943914                              .AND. i == nxlu  ) )                             &
    944915                   THEN
     
    960931!--                WS1 (30), WS3 (31), WS5 (32)
    961932                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),3) .OR.              &
    962                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    963                                 force_bound_s )                                &
     933                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    964934                              .AND. j == nys   )    .OR.                       &
    965                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    966                                 force_bound_n )                                &
     935                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    967936                              .AND. j == nyn   ) )                             &
    968937                   THEN
     
    972941                              .NOT. BTEST(wall_flags_0(k,j-1,i),3) )           &
    973942                                                        .OR.                   &
    974                             ( ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.&
    975                                 force_bound_s )                                &
     943                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
    976944                              .AND. j == nysv  )    .OR.                       &
    977                             ( ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.&
    978                                 force_bound_n )                                &
     945                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
    979946                              .AND. j == nyn-1 ) )                             &
    980947                   THEN
     
    10671034!--       Set boundary flags at inflow and outflow boundary in case of
    10681035!--       non-cyclic boundary conditions.
    1069           IF ( inflow_l      .OR.  outflow_l  .OR.                             &
    1070                nest_bound_l  .OR.  force_bound_l )  THEN
     1036          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    10711037             advc_flags_1(:,:,nxl-1) = advc_flags_1(:,:,nxl)
    10721038             advc_flags_2(:,:,nxl-1) = advc_flags_2(:,:,nxl)
    10731039          ENDIF
    10741040
    1075           IF ( inflow_r      .OR.  outflow_r  .OR.                             &
    1076                nest_bound_r  .OR.  force_bound_r )  THEN
     1041          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    10771042            advc_flags_1(:,:,nxr+1) = advc_flags_1(:,:,nxr)
    10781043            advc_flags_2(:,:,nxr+1) = advc_flags_2(:,:,nxr)
    10791044          ENDIF
    10801045
    1081           IF ( inflow_n      .OR.  outflow_n  .OR.                             &
    1082                nest_bound_n  .OR.  force_bound_n )  THEN
     1046          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    10831047             advc_flags_1(:,nyn+1,:) = advc_flags_1(:,nyn,:)
    10841048             advc_flags_2(:,nyn+1,:) = advc_flags_2(:,nyn,:)
    10851049          ENDIF
    10861050
    1087           IF ( inflow_s      .OR.  outflow_s  .OR.                             &
    1088                nest_bound_s  .OR.  force_bound_s )  THEN
     1051          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    10891052             advc_flags_1(:,nys-1,:) = advc_flags_1(:,nys,:)
    10901053             advc_flags_2(:,nys-1,:) = advc_flags_2(:,nys,:)
  • TabularUnified palm/trunk/SOURCE/boundary_conds.f90

    r3129 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename some variables concerning LES-LES as well as offline nesting
    2323!
    2424! Former revisions:
     
    186186    USE arrays_3d,                                                             &
    187187        ONLY:  c_u, c_u_m, c_u_m_l, c_v, c_v_m, c_v_m_l, c_w, c_w_m, c_w_m_l,  &
    188                diss, diss_p, dzu, e_p, nc_p, nr_p, pt, pt_p, q, q_p, qc_p, qr_p, s,  &
     188               diss, diss_p, dzu, e_p, nc_p, nr_p, pt, pt_p, q, q_p, qc_p,     &
     189               qr_p, s,                                                        &
    189190               s_p, sa, sa_p, u, ug, u_init, u_m_l, u_m_n, u_m_r, u_m_s, u_p,  &
    190191               v, vg, v_init, v_m_l, v_m_n, v_m_r, v_m_s, v_p,                 &
     
    195196             
    196197    USE control_parameters,                                                    &
    197         ONLY:  air_chemistry, bc_pt_t_val, bc_q_t_val, bc_s_t_val,             &
    198                constant_diffusion, cloud_physics, coupling_mode, dt_3d,        &
    199                force_bound_l, force_bound_s, forcing, humidity,                &
    200                ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b, ibc_s_t,        &
    201                ibc_sa_t, ibc_uv_b, ibc_uv_t, inflow_l, inflow_n, inflow_r,    &
    202                inflow_s, intermediate_timestep_count, kappa,                   &
    203                microphysics_morrison, microphysics_seifert, nest_domain,       &
    204                nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, nudging,&
    205                ocean, outflow_l, outflow_n, outflow_r, outflow_s,              &
    206                passive_scalar, rans_mode, rans_tke_e, tsc, use_cmax
     198        ONLY:  air_chemistry, bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,  &
     199               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
     200               bc_radiation_s, bc_pt_t_val, bc_q_t_val, bc_s_t_val,            &
     201               child_domain, constant_diffusion, cloud_physics, coupling_mode, &
     202               dt_3d, humidity, ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b, &
     203               ibc_s_t,ibc_sa_t, ibc_uv_b, ibc_uv_t,                           &
     204               intermediate_timestep_count, kappa,                             &
     205               microphysics_morrison, microphysics_seifert,                    &
     206               nesting_offline, nudging,                                       &
     207               ocean, passive_scalar, rans_mode, rans_tke_e, tsc, use_cmax
    207208
    208209    USE grid_variables,                                                        &
     
    275276!
    276277!-- Vertical nesting: Vertical velocity not zero at the top of the fine grid
    277     IF (  .NOT.  nest_domain  .AND.                                            &
     278    IF (  .NOT.  child_domain  .AND.                                           &
    278279                 TRIM(coupling_mode) /= 'vnested_fine' )  THEN
    279280       w_p(nzt:nzt+1,:,:) = 0.0_wp  !< nzt is not a prognostic level (but cf. pres)
     
    409410       ENDIF
    410411
    411        IF ( .NOT. nest_domain )  THEN
     412       IF ( .NOT. child_domain )  THEN
    412413          e_p(nzt+1,:,:) = e_p(nzt,:,:)
    413414!
     
    421422          IF ( rans_mode_parent  .AND.  .NOT. rans_mode )  THEN
    422423
    423 
    424 
    425424             e_p(nzt+1,:,:) = e_p(nzt,:,:)
    426              IF ( nest_bound_l )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
    427              IF ( nest_bound_r )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
    428              IF ( nest_bound_s )  e_p(:,nys-1,:) = e_p(:,nys,:)
    429              IF ( nest_bound_n )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
     425             IF ( bc_dirichlet_l )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
     426             IF ( bc_dirichlet_r )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
     427             IF ( bc_dirichlet_s )  e_p(:,nys-1,:) = e_p(:,nys,:)
     428             IF ( bc_dirichlet_n )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
    430429
    431430          ENDIF
     
    510509       ENDDO
    511510
    512        IF ( .NOT. nest_domain )  THEN
     511       IF ( .NOT. child_domain )  THEN
    513512          diss_p(nzt+1,:,:) = diss_p(nzt,:,:)
    514513       ENDIF
     
    697696!-- have to be restored here.
    698697!-- For the SGS-TKE, Neumann boundary conditions are used at the inflow.
    699     IF ( inflow_s )  THEN
     698    IF ( bc_dirichlet_s )  THEN
    700699       v_p(:,nys,:) = v_p(:,nys-1,:)
    701700       IF ( .NOT. constant_diffusion ) e_p(:,nys-1,:) = e_p(:,nys,:)
    702     ELSEIF ( inflow_n )  THEN
     701    ELSEIF ( bc_dirichlet_n )  THEN
    703702       IF ( .NOT. constant_diffusion ) e_p(:,nyn+1,:) = e_p(:,nyn,:)
    704     ELSEIF ( inflow_l ) THEN
     703    ELSEIF ( bc_dirichlet_l ) THEN
    705704       u_p(:,:,nxl) = u_p(:,:,nxl-1)
    706705       IF ( .NOT. constant_diffusion ) e_p(:,:,nxl-1) = e_p(:,:,nxl)
    707     ELSEIF ( inflow_r )  THEN
     706    ELSEIF ( bc_dirichlet_r )  THEN
    708707       IF ( .NOT. constant_diffusion ) e_p(:,:,nxr+1) = e_p(:,:,nxr)
    709708    ENDIF
     
    712711!-- The same restoration for u at i=nxl and v at j=nys as above must be made
    713712!-- in case of nest boundaries. This must not be done in case of vertical nesting
    714 !-- mode as in that case the lateral boundaries are actually cyclic.
    715     IF ( nesting_mode /= 'vertical'  .OR.  forcing )  THEN
    716        IF ( nest_bound_s  .OR.  force_bound_s )  THEN
     713!-- mode as in that case the lateral boundaries are actually cyclic.
     714!-- @todo: Is this really needed? Boundary values will be overwritten in
     715!--        coupler or by Inifor data.
     716    IF ( nesting_mode /= 'vertical'  .OR.  nesting_offline )  THEN
     717       IF ( bc_dirichlet_s )  THEN
    717718          v_p(:,nys,:) = v_p(:,nys-1,:)
    718719       ENDIF
    719        IF ( nest_bound_l  .OR.  force_bound_l )  THEN
     720       IF ( bc_dirichlet_l )  THEN
    720721          u_p(:,:,nxl) = u_p(:,:,nxl-1)
    721722       ENDIF
     
    724725!
    725726!-- Lateral boundary conditions for scalar quantities at the outflow
    726     IF ( outflow_s )  THEN
     727    IF ( bc_radiation_s )  THEN
    727728       pt_p(:,nys-1,:)     = pt_p(:,nys,:)
    728729       IF ( .NOT. constant_diffusion )  e_p(:,nys-1,:) = e_p(:,nys,:)
     
    740741       ENDIF
    741742       IF ( passive_scalar )  s_p(:,nys-1,:) = s_p(:,nys,:)
    742     ELSEIF ( outflow_n )  THEN
     743    ELSEIF ( bc_radiation_n )  THEN
    743744       pt_p(:,nyn+1,:)     = pt_p(:,nyn,:)
    744745       IF ( .NOT. constant_diffusion )  e_p(:,nyn+1,:) = e_p(:,nyn,:)
     
    756757       ENDIF
    757758       IF ( passive_scalar )  s_p(:,nyn+1,:) = s_p(:,nyn,:)
    758     ELSEIF ( outflow_l )  THEN
     759    ELSEIF ( bc_radiation_l )  THEN
    759760       pt_p(:,:,nxl-1)     = pt_p(:,:,nxl)
    760761       IF ( .NOT. constant_diffusion )  e_p(:,:,nxl-1) = e_p(:,:,nxl)
     
    772773       ENDIF
    773774       IF ( passive_scalar )  s_p(:,:,nxl-1) = s_p(:,:,nxl)
    774     ELSEIF ( outflow_r )  THEN
     775    ELSEIF ( bc_radiation_r )  THEN
    775776       pt_p(:,:,nxr+1)     = pt_p(:,:,nxr)
    776777       IF ( .NOT. constant_diffusion )  e_p(:,:,nxr+1) = e_p(:,:,nxr)
     
    799800!-- ensures numerical stability (CFL-condition) or calculated after
    800801!-- Orlanski(1976) and averaged along the outflow boundary.
    801     IF ( outflow_s )  THEN
     802    IF ( bc_radiation_s )  THEN
    802803
    803804       IF ( use_cmax )  THEN
     
    938939    ENDIF
    939940
    940     IF ( outflow_n )  THEN
     941    IF ( bc_radiation_n )  THEN
    941942
    942943       IF ( use_cmax )  THEN
     
    10771078    ENDIF
    10781079
    1079     IF ( outflow_l )  THEN
     1080    IF ( bc_radiation_l )  THEN
    10801081
    10811082       IF ( use_cmax )  THEN
     
    12161217    ENDIF
    12171218
    1218     IF ( outflow_r )  THEN
     1219    IF ( bc_radiation_r )  THEN
    12191220
    12201221       IF ( use_cmax )  THEN
  • TabularUnified palm/trunk/SOURCE/check_parameters.f90

    r3129 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename boundary conditions in offline nesting
    2323!
    2424! Former revisions:
     
    10691069!-- Check turbulence closure setup
    10701070    CALL tcm_check_parameters
     1071
    10711072!
    10721073!-- Check approximation
     
    14371438       CALL MPI_ALLREDUCE( dt_spinup,   dt_spinup_max,   1, MPI_REAL,          &
    14381439                           MPI_MAX, MPI_COMM_WORLD, ierr )
     1440
    14391441       IF ( spinup_time /= spinup_time_max  .OR.  dt_spinup /= dt_spinup_max ) &
    14401442       THEN
     
    17811783!
    17821784!-- Overwrite latitude if necessary and compute Coriolis parameter.
    1783 !-- To do - move initialization of f and fs to coriolis_mod.
     1785!-- @todo - move initialization of f and fs to coriolis_mod.
    17841786    IF ( input_pids_static )  THEN
    17851787       latitude  = init_model%latitude
     
    19761978!-- TO_DO: later set bc_p_t to neumann before, in case of nested domain
    19771979    ELSEIF ( bc_p_t == 'neumann' .OR. bc_p_t == 'nested'  .OR.                 &
    1978              bc_p_t == 'forcing'  )  THEN
     1980             bc_p_t == 'nesting_offline'  )  THEN
    19791981       ibc_p_t = 1
    19801982    ELSE
     
    20062008    ELSEIF ( bc_pt_t == 'initial_gradient' )  THEN
    20072009       ibc_pt_t = 2
    2008     ELSEIF ( bc_pt_t == 'nested'  .OR.  bc_pt_t == 'forcing' )  THEN
     2010    ELSEIF ( bc_pt_t == 'nested'  .OR.  bc_pt_t == 'nesting_offline' )  THEN
    20092011       ibc_pt_t = 3
    20102012    ELSE
     
    22342236       ELSEIF ( bc_uv_t == 'neumann' )  THEN
    22352237          ibc_uv_t = 1
    2236        ELSEIF ( bc_uv_t == 'nested'  .OR.  bc_uv_t == 'forcing' )  THEN
     2238       ELSEIF ( bc_uv_t == 'nested'  .OR.  bc_uv_t == 'nesting_offline' )  THEN
    22372239          ibc_uv_t = 3
    22382240       ELSE
     
    39263928          dist_nxl    = MAX( inflow_disturbance_begin, nxl )
    39273929          dist_nxr(1) = MIN( inflow_disturbance_end, nxr )
    3928        ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'forcing' )  THEN
     3930       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
    39293931          dist_nxl    = MAX( inflow_disturbance_begin, nxl )
    39303932          dist_nxr    = MIN( nx - inflow_disturbance_begin, nxr )
     
    39363938          dist_nys    = MAX( inflow_disturbance_begin, nys )
    39373939          dist_nyn(1) = MIN( inflow_disturbance_end, nyn )
    3938        ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'forcing' )  THEN
     3940       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
    39393941          dist_nys    = MAX( inflow_disturbance_begin, nys )
    39403942          dist_nyn    = MIN( ny - inflow_disturbance_begin, nyn )
     
    39493951          dist_nxl    = inflow_disturbance_begin
    39503952          dist_nxr(1) = inflow_disturbance_end
    3951        ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'forcing' )  THEN
     3953       ELSEIF ( bc_lr == 'nested'  .OR.  bc_lr == 'nesting_offline' )  THEN
    39523954          dist_nxr    = nx - inflow_disturbance_begin
    39533955          dist_nxl    = inflow_disturbance_begin
     
    39593961          dist_nys    = inflow_disturbance_begin
    39603962          dist_nyn(1) = inflow_disturbance_end
    3961        ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'forcing' )  THEN
     3963       ELSEIF ( bc_ns == 'nested'  .OR.  bc_ns == 'nesting_offline' )  THEN
    39623964          dist_nyn    = ny - inflow_disturbance_begin
    39633965          dist_nys    = inflow_disturbance_begin
     
    44034405       ELSEIF ( bc_t == 'initial_gradient' )  THEN
    44044406          ibc_t = 2
    4405        ELSEIF ( bc_t == 'nested'  .OR.  bc_t == 'forcing' )  THEN
     4407       ELSEIF ( bc_t == 'nested'  .OR.  bc_t == 'nesting_offline' )  THEN
    44064408          ibc_t = 3
    44074409       ELSE
  • TabularUnified palm/trunk/SOURCE/chemistry_model_mod.f90

    r3173 r3182  
    2222! Current revisions:
    2323! -----------------
    24 !
     24! Rename flags indicating outflow boundary conditions
    2525!
    2626! Former revisions:
     
    291291                                                                                 
    292292    USE control_parameters,                                                    & 
    293         ONLY: air_chemistry, outflow_l, outflow_n, outflow_r, outflow_s                 
     293        ONLY:  air_chemistry, bc_radiation_l, bc_radiation_n, bc_radiation_r,  &
     294               bc_radiation_s               
    294295    USE indices,                                                               & 
    295         ONLY: nxl, nxr,  nxlg, nxrg, nyng, nysg, nzt                             
     296        ONLY:  nxl, nxr,  nxlg, nxrg, nyng, nysg, nzt                             
    296297                                                                                 
    297298!    USE prognostic_equations_mod,                                             &
    298299
    299300    USE arrays_3d,                                                             &     
    300         ONLY: dzu                                               
     301        ONLY:  dzu                                               
    301302    USE surface_mod,                                                           &
    302         ONLY: bc_h                                                           
     303        ONLY:  bc_h                                                           
    303304
    304305    CHARACTER (len=*), INTENT(IN) :: mode
     
    420421!--          Lateral boundary conditions for chem species at outflow boundary
    421422
    422           IF ( outflow_s )  THEN
     423          IF ( bc_radiation_s )  THEN
    423424             DO lsp = 1, nspec
    424425                chem_species(lsp)%conc_p(:,nys-1,:) = chem_species(lsp)%conc_p(:,nys,:)
    425426             ENDDO
    426           ELSEIF ( outflow_n )  THEN
     427          ELSEIF ( bc_radiation_n )  THEN
    427428             DO lsp = 1, nspec
    428429                chem_species(lsp)%conc_p(:,nyn+1,:) = chem_species(lsp)%conc_p(:,nyn,:)
    429430             ENDDO
    430           ELSEIF ( outflow_l )  THEN
     431          ELSEIF ( bc_radiation_l )  THEN
    431432             DO lsp = 1, nspec
    432433                chem_species(lsp)%conc_p(:,:,nxl-1) = chem_species(lsp)%conc_p(:,:,nxl)
    433434             ENDDO
    434           ELSEIF ( outflow_r )  THEN
     435          ELSEIF ( bc_radiation_r )  THEN
    435436             DO lsp = 1, nspec
    436437                chem_species(lsp)%conc_p(:,:,nxr+1) = chem_species(lsp)%conc_p(:,:,nxr)
  • TabularUnified palm/trunk/SOURCE/coriolis.f90

    r2718 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Remove masking of geostrophic wind forcing in offline nesting case
    2323!
    2424! Former revisions:
     
    109109           
    110110       USE control_parameters,                                                 &
    111            ONLY:  f, forcing, fs, message_string
     111           ONLY:  f, fs, message_string, nesting_offline
    112112           
    113113       USE indices,                                                            &
     
    123123       INTEGER(iwp) ::  k          !< running index z direction
    124124
    125        REAL(wp)     ::  flag       !< flag to mask topography
    126        REAL(wp)     ::  flag_force !< flag to mask large-scale pressure gradient in case larger-scale forcing is applied
    127 
    128        flag_force = MERGE( 0.0_wp, 1.0_wp, forcing )
     125       REAL(wp)     ::  flag           !< flag to mask topography
     126
    129127!
    130128!--    Compute Coriolis terms for the three velocity components
     
    144142                      tend(k,j,i) = tend(k,j,i) + f  *    ( 0.25_wp *          &
    145143                                   ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +    &
    146                                      v(k,j+1,i) ) - vg(k) * flag_force         &
    147                                                           ) * flag           &
     144                                     v(k,j+1,i) ) - vg(k) ) * flag             &
    148145                                                - fs *    ( 0.25_wp *          &
    149146                                   ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) +  &
     
    167164                      tend(k,j,i) = tend(k,j,i) - f *     ( 0.25_wp *          &
    168165                                   ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) +    &
    169                                      u(k,j,i+1) ) - ug(k) * flag_force         &
    170                                                           ) * flag
     166                                     u(k,j,i+1) ) - ug(k) ) * flag
    171167                   ENDDO
    172168                ENDDO
     
    212208           
    213209       USE control_parameters,                                                 &
    214            ONLY:  f, forcing, fs, message_string
     210           ONLY:  f, fs, message_string, nesting_offline
    215211           
    216212       USE indices,                                                            &
     
    227223
    228224       REAL(wp)     ::  flag       !< flag to mask topography
    229        REAL(wp)     ::  flag_force !< flag to mask large-scale pressure gradient in case larger-scale forcing is applied
    230 
    231        flag_force = MERGE( 0.0_wp, 1.0_wp, forcing )
     225
    232226!
    233227!--    Compute Coriolis terms for the three velocity components
     
    244238                tend(k,j,i) = tend(k,j,i) + f  *     ( 0.25_wp *               &
    245239                                ( v(k,j,i-1) + v(k,j,i) + v(k,j+1,i-1) +       &
    246                                   v(k,j+1,i) ) - vg(k) * flag_force            &
     240                                  v(k,j+1,i) ) - vg(k)                         &
    247241                                                     ) * flag                  &
    248242                                          - fs *     ( 0.25_wp *               &
     
    261255                tend(k,j,i) = tend(k,j,i) - f *        ( 0.25_wp *             &
    262256                                ( u(k,j-1,i) + u(k,j,i) + u(k,j-1,i+1) +       &
    263                                   u(k,j,i+1) ) - ug(k)   * flag_force          &
    264                                                        ) * flag
     257                                  u(k,j,i+1) ) - ug(k) ) * flag
    265258             ENDDO
    266259
  • TabularUnified palm/trunk/SOURCE/exchange_horiz_2d.f90

    r2718 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables in offline nesting mode and flags indicating lateral
     23! boundary conditions
    2324!
    2425! Former revisions:
     
    8485
    8586    USE control_parameters,                                                    &
    86         ONLY :  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,            &
    87                 force_bound_r, force_bound_s,                                  &
    88                 inflow_l, inflow_n, inflow_r, inflow_s,                        &
    89                 nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,        &
    90                 outflow_l, outflow_n, outflow_r, outflow_s
     87        ONLY :  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                &
     88                bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,          &
     89                bc_radiation_n, bc_radiation_r, bc_radiation_s
    9190               
    9291    USE cpulog,                                                                &
     
    184183!-- Neumann-conditions at inflow/outflow/nested boundaries
    185184    IF ( nesting_mode /= 'vertical' )  THEN
    186        IF ( inflow_l .OR. outflow_l .OR. nest_bound_l  .OR.  force_bound_l )   &
    187        THEN
     185       IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    188186          DO  i = nbgp, 1, -1
    189187             ar(:,nxl-i) = ar(:,nxl)
    190188          ENDDO
    191189       ENDIF
    192        IF ( inflow_r .OR. outflow_r .OR. nest_bound_r  .OR.  force_bound_r )   &
    193        THEN
     190       IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    194191          DO  i = 1, nbgp
    195192             ar(:,nxr+i) = ar(:,nxr)
    196193          ENDDO
    197194       ENDIF
    198        IF ( inflow_s .OR. outflow_s .OR. nest_bound_s  .OR.  force_bound_s )   &
    199        THEN
     195       IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    200196          DO  i = nbgp, 1, -1
    201197             ar(nys-i,:) = ar(nys,:)
    202198          ENDDO
    203199       ENDIF
    204        IF ( inflow_n .OR. outflow_n .OR. nest_bound_n  .OR.  force_bound_n )   &
    205        THEN
     200       IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    206201          DO  i = 1, nbgp
    207202             ar(nyn+i,:) = ar(nyn,:)
     
    227222
    228223    USE control_parameters,                                                    &
    229         ONLY:  bc_lr_cyc, bc_ns_cyc, grid_level, force_bound_l, force_bound_n, &
    230                force_bound_r, force_bound_s, nest_bound_l, nest_bound_n,       &
    231                nest_bound_r, nest_bound_s
     224        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                &
     225               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
     226               bc_radiation_n, bc_radiation_r, bc_radiation_s, grid_level
    232227       
    233228    USE cpulog,                                                                &
     
    326321!
    327322!-- Neumann-conditions at inflow/outflow/nested boundaries
    328     IF ( nest_bound_l  .OR.  force_bound_l )  THEN
     323    IF ( bc_dirichlet_l )  THEN
    329324       DO  i = nbgp_local, 1, -1
    330325         ar(:,nxl_l-i) = ar(:,nxl_l)
    331326       ENDDO
    332327    ENDIF
    333     IF ( nest_bound_r  .OR.  force_bound_r )  THEN
     328    IF ( bc_dirichlet_r )  THEN
    334329       DO  i = 1, nbgp_local
    335330          ar(:,nxr_l+i) = ar(:,nxr_l)
    336331       ENDDO
    337332    ENDIF
    338     IF ( nest_bound_s  .OR.  force_bound_s )  THEN
     333    IF ( bc_dirichlet_s )  THEN
    339334       DO  i = nbgp_local, 1, -1
    340335         ar(nys_l-i,:) = ar(nys_l,:)
    341336       ENDDO
    342337    ENDIF
    343     IF ( nest_bound_n  .OR.  force_bound_n )  THEN
     338    IF ( bc_dirichlet_n )  THEN
    344339       DO  i = 1, nbgp_local
    345340         ar(nyn_l+i,:) = ar(nyn_l,:)
  • TabularUnified palm/trunk/SOURCE/init_3d_model.f90

    r3159 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Revise Inifor initialization
    2323!
    2424! Former revisions:
     
    535535
    536536    USE netcdf_data_input_mod,                                                 &
    537         ONLY:  init_3d, netcdf_data_input_interpolate, netcdf_data_input_init_3d
     537        ONLY:  init_3d, netcdf_data_input_init_3d
    538538   
    539539    USE particle_attributes,                                                   &
     
    611611    REAL(wp)     ::  t_surface !< air temperature at the surface
    612612
     613    REAL(wp), DIMENSION(:), ALLOCATABLE ::  init_l        !< dummy array used for averaging 3D data to obtain inital profiles
    613614    REAL(wp), DIMENSION(:), ALLOCATABLE ::  p_hydrostatic !< hydrostatic pressure
    614615
     
    10061007!-- Arrays to store velocity data from t-dt and the phase speeds which
    10071008!-- are needed for radiation boundary conditions
    1008     IF ( outflow_l )  THEN
     1009    IF ( bc_radiation_l )  THEN
    10091010       ALLOCATE( u_m_l(nzb:nzt+1,nysg:nyng,1:2),                               &
    10101011                 v_m_l(nzb:nzt+1,nysg:nyng,0:1),                               &
    10111012                 w_m_l(nzb:nzt+1,nysg:nyng,0:1) )
    10121013    ENDIF
    1013     IF ( outflow_r )  THEN
     1014    IF ( bc_radiation_r )  THEN
    10141015       ALLOCATE( u_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
    10151016                 v_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx),                           &
    10161017                 w_m_r(nzb:nzt+1,nysg:nyng,nx-1:nx) )
    10171018    ENDIF
    1018     IF ( outflow_l  .OR.  outflow_r )  THEN
     1019    IF ( bc_radiation_l  .OR.  bc_radiation_r )  THEN
    10191020       ALLOCATE( c_u(nzb:nzt+1,nysg:nyng), c_v(nzb:nzt+1,nysg:nyng),           &
    10201021                 c_w(nzb:nzt+1,nysg:nyng) )
    10211022    ENDIF
    1022     IF ( outflow_s )  THEN
     1023    IF ( bc_radiation_s )  THEN
    10231024       ALLOCATE( u_m_s(nzb:nzt+1,0:1,nxlg:nxrg),                               &
    10241025                 v_m_s(nzb:nzt+1,1:2,nxlg:nxrg),                               &
    10251026                 w_m_s(nzb:nzt+1,0:1,nxlg:nxrg) )
    10261027    ENDIF
    1027     IF ( outflow_n )  THEN
     1028    IF ( bc_radiation_n )  THEN
    10281029       ALLOCATE( u_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
    10291030                 v_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg),                           &
    10301031                 w_m_n(nzb:nzt+1,ny-1:ny,nxlg:nxrg) )
    10311032    ENDIF
    1032     IF ( outflow_s  .OR.  outflow_n )  THEN
     1033    IF ( bc_radiation_s  .OR.  bc_radiation_n )  THEN
    10331034       ALLOCATE( c_u(nzb:nzt+1,nxlg:nxrg), c_v(nzb:nzt+1,nxlg:nxrg),           &
    10341035                 c_w(nzb:nzt+1,nxlg:nxrg) )
    10351036    ENDIF
    1036     IF ( outflow_l  .OR.  outflow_r  .OR.  outflow_s  .OR.  outflow_n )  THEN
     1037    IF ( bc_radiation_l  .OR.  bc_radiation_r  .OR.  bc_radiation_s  .OR.      &
     1038         bc_radiation_n )  THEN
    10371039       ALLOCATE( c_u_m_l(nzb:nzt+1), c_v_m_l(nzb:nzt+1), c_w_m_l(nzb:nzt+1) )                   
    10381040       ALLOCATE( c_u_m(nzb:nzt+1), c_v_m(nzb:nzt+1), c_w_m(nzb:nzt+1) )
     
    11521154    sums_l_l           = 0.0_wp
    11531155    sums_wsts_bc_l     = 0.0_wp
    1154 
    1155 
    1156 
     1156   
    11571157!
    11581158!-- Initialize model variables
     
    11691169          CALL netcdf_data_input_init_3d
    11701170!
    1171 !--       Please note, at the moment INIFOR assumes only an equidistant vertical
    1172 !--       grid. In case of vertical grid stretching, input of inital data
    1173 !--       need to be inter- and/or extrapolated.
    1174 !--       Therefore, check if zu grid on file is identical to numeric zw grid.
    1175 !--       Please note 
    1176           IF ( ANY( zu(1:nzt+1) /= init_3d%zu_atmos(1:init_3d%nzu) ) )  THEN
    1177 
    1178              IF( init_3d%lod_u == 1 )                                          &
    1179                 CALL netcdf_data_input_interpolate(                            &
    1180                                                  init_3d%u_init(nzb+1:nzt+1),  &
    1181                                                  zu(nzb+1:nzt+1),              &
    1182                                                  init_3d%zu_atmos )
    1183                                                  
    1184              IF( init_3d%lod_v == 1 )                                          &
    1185                 CALL netcdf_data_input_interpolate(                            &
    1186                                                  init_3d%v_init(nzb+1:nzt+1),  &
    1187                                                  zu(nzb+1:nzt+1),              &
    1188                                                  init_3d%zu_atmos )
    1189                                                  
    1190 !              CALL netcdf_data_input_interpolate( init_3d%w_init(nzb+1:nzt),    &
    1191 !                                                  zw(nzb+1:nzt),                &
    1192 !                                                  init_3d%zw_atmos )
    1193 
    1194              IF ( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                  &
    1195                 CALL netcdf_data_input_interpolate(                            &
    1196                                              init_3d%pt_init(nzb+1:nzt+1),     &
    1197                                              zu(nzb+1:nzt+1),                  &
    1198                                              init_3d%zu_atmos )
    1199                                              
    1200              IF ( humidity  .AND.  init_3d%lod_q == 1 )                        &
    1201                 CALL netcdf_data_input_interpolate(                            &
    1202                                              init_3d%q_init(nzb+1:nzt+1),      &
    1203                                              zu(nzb+1:nzt+1),                  &
    1204                                              init_3d%zu_atmos )
    1205           ENDIF
    1206 !
    1207 !--       In case of LOD=1, initialize 1D profiles and 3D data. 
    1208           IF( init_3d%lod_u == 1 )  u_init = init_3d%u_init
    1209           IF( init_3d%lod_v == 1 )  v_init = init_3d%v_init   
    1210           IF( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                      &
    1211              pt_init = init_3d%pt_init
    1212           IF( humidity  .AND.  init_3d%lod_q == 1 )                            &
    1213              q_init  = init_3d%q_init
    1214 
    1215 !
    1216 !--       Please note, Inifor provides data from nzb+1 to nzt+1.
    1217 !--       Initialize pt and q with Neumann condition at nzb.
    1218           IF( .NOT. neutral )  pt_init(nzb) = pt_init(nzb+1)
    1219           IF( humidity      )  q_init(nzb)  = q_init(nzb+1)
     1171!--       Please note, Inifor provides data from nzb+1 to nzt.
     1172!--       Bottom and top boundary conditions for Inifor profiles are already
     1173!--       set (just after reading), so that this is not necessary here.
     1174!--       Depending on the provided level-of-detail, initial Inifor data is
     1175!--       either stored on data type (lod=1), or directly on 3D arrays (lod=2).
     1176!--       In order to obtain also initial profiles in case of lod=2 (which
     1177!--       is required for e.g. damping), average over 3D data.
     1178          IF( init_3d%lod_u == 1 )  THEN
     1179             u_init = init_3d%u_init
     1180          ELSEIF( init_3d%lod_u == 2 )  THEN
     1181             ALLOCATE( init_l(nzb:nzt+1) )
     1182             DO  k = nzb, nzt+1
     1183                init_l(k) = SUM( u(k,nys:nyn,nxl:nxr) )
     1184             ENDDO
     1185             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
     1186
     1187#if defined( __parallel )
     1188             CALL MPI_ALLREDUCE( init_l, u_init, nzt+1-nzb+1,                  &
     1189                                 MPI_REAL, MPI_SUM, comm2d, ierr )
     1190#else
     1191             u_init = init_l
     1192#endif
     1193             DEALLOCATE( init_l )
     1194
     1195          ENDIF
     1196           
     1197          IF( init_3d%lod_v == 1 )  THEN 
     1198             v_init = init_3d%v_init
     1199          ELSEIF( init_3d%lod_v == 2 )  THEN
     1200             ALLOCATE( init_l(nzb:nzt+1) )
     1201             DO  k = nzb, nzt+1
     1202                init_l(k) = SUM( v(k,nys:nyn,nxl:nxr) )
     1203             ENDDO
     1204             init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
     1205
     1206#if defined( __parallel )
     1207             CALL MPI_ALLREDUCE( init_l, v_init, nzt+1-nzb+1,                  &
     1208                                 MPI_REAL, MPI_SUM, comm2d, ierr )
     1209#else
     1210             v_init = init_l
     1211#endif
     1212             DEALLOCATE( init_l )
     1213          ENDIF
     1214          IF( .NOT. neutral )  THEN
     1215             IF( init_3d%lod_pt == 1 )  THEN
     1216                pt_init = init_3d%pt_init
     1217             ELSEIF( init_3d%lod_pt == 2 )  THEN
     1218                ALLOCATE( init_l(nzb:nzt+1) )
     1219                DO  k = nzb, nzt+1
     1220                   init_l(k) = SUM( pt(k,nys:nyn,nxl:nxr) )
     1221                ENDDO
     1222                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
     1223
     1224#if defined( __parallel )
     1225                CALL MPI_ALLREDUCE( init_l, pt_init, nzt+1-nzb+1,               &
     1226                                    MPI_REAL, MPI_SUM, comm2d, ierr )
     1227#else
     1228                pt_init = init_l
     1229#endif
     1230                DEALLOCATE( init_l )
     1231             ENDIF
     1232          ENDIF
     1233
     1234
     1235          IF( humidity )  THEN
     1236             IF( init_3d%lod_q == 1 )  THEN
     1237                q_init = init_3d%q_init
     1238             ELSEIF( init_3d%lod_q == 2 )  THEN
     1239                ALLOCATE( init_l(nzb:nzt+1) )
     1240                DO  k = nzb, nzt+1
     1241                   init_l(k) = SUM( q(k,nys:nyn,nxl:nxr) )
     1242                ENDDO
     1243                init_l = init_l / REAL( ( nx + 1 ) * ( ny + 1 ), KIND = wp )
     1244
     1245#if defined( __parallel )
     1246                CALL MPI_ALLREDUCE( init_l, q_init, nzt+1-nzb+1,               &
     1247                                    MPI_REAL, MPI_SUM, comm2d, ierr )
     1248#else
     1249                q_init = init_l
     1250#endif
     1251                DEALLOCATE( init_l )
     1252             ENDIF
     1253          ENDIF
     1254
     1255!
     1256!--       Write initial profiles onto 3D arrays. Note, only in case of lod = 1,
     1257!--       for lod = 2 data is already on 3D arrays.   
    12201258          DO  i = nxlg, nxrg
    12211259             DO  j = nysg, nyng
     
    12241262                IF( .NOT. neutral  .AND.  init_3d%lod_pt == 1 )                &
    12251263                   pt(:,j,i) = pt_init(:)
    1226                 IF( humidity  .AND.  init_3d%lod_q == 1 )                      &
    1227                    q(:,j,i)  = q_init(:)
     1264                IF( humidity  .AND.  init_3d%lod_q == 1 )  q(:,j,i) = q_init(:)
    12281265             ENDDO
    12291266          ENDDO
    12301267!
    1231 !--       MS: What about the geostrophic wind profiles? Actually these
    1232 !--           are not identical to the initial wind profiles in this case.
    1233 !--           This need to be further revised.
     1268!--       Exchange ghost points in case of level-of-detail = 2
     1269          IF( init_3d%lod_u == 2 )   CALL exchange_horiz( u, nbgp )
     1270          IF( init_3d%lod_v == 2 )   CALL exchange_horiz( v, nbgp )
     1271          IF( init_3d%lod_w == 2 )   CALL exchange_horiz( w, nbgp )
     1272          IF( .NOT. neutral  .AND.  init_3d%lod_pt == 2 )                      &
     1273             CALL exchange_horiz( pt, nbgp )
     1274          IF( humidity  .AND.  init_3d%lod_q == 2 )                            &
     1275             CALL exchange_horiz( q, nbgp )
     1276!
     1277!--       Set geostrophic wind components. 
    12341278          IF ( init_3d%from_file_ug )  THEN
    12351279             ug(:) = init_3d%ug_init(:)
     
    12381282             vg(:) = init_3d%vg_init(:)
    12391283          ENDIF
    1240 
     1284         
    12411285          ug(nzt+1) = ug(nzt)
    12421286          vg(nzt+1) = vg(nzt)
    1243 
    12441287!
    12451288!--       Set inital w to 0
     
    18151858!--       Use these mean profiles at the inflow (provided that Dirichlet
    18161859!--       conditions are used)
    1817           IF ( inflow_l )  THEN
     1860          IF ( bc_dirichlet_l )  THEN
    18181861             DO  j = nysg, nyng
    18191862                DO  k = nzb, nzt+1
     
    19632006!
    19642007!--    Initialize old timelevels needed for radiation boundary conditions
    1965        IF ( outflow_l )  THEN
     2008       IF ( bc_radiation_l )  THEN
    19662009          u_m_l(:,:,:) = u(:,:,1:2)
    19672010          v_m_l(:,:,:) = v(:,:,0:1)
    19682011          w_m_l(:,:,:) = w(:,:,0:1)
    19692012       ENDIF
    1970        IF ( outflow_r )  THEN
     2013       IF ( bc_radiation_r )  THEN
    19712014          u_m_r(:,:,:) = u(:,:,nx-1:nx)
    19722015          v_m_r(:,:,:) = v(:,:,nx-1:nx)
    19732016          w_m_r(:,:,:) = w(:,:,nx-1:nx)
    19742017       ENDIF
    1975        IF ( outflow_s )  THEN
     2018       IF ( bc_radiation_s )  THEN
    19762019          u_m_s(:,:,:) = u(:,0:1,:)
    19772020          v_m_s(:,:,:) = v(:,1:2,:)
    19782021          w_m_s(:,:,:) = w(:,0:1,:)
    19792022       ENDIF
    1980        IF ( outflow_n )  THEN
     2023       IF ( bc_radiation_n )  THEN
    19812024          u_m_n(:,:,:) = u(:,ny-1:ny,:)
    19822025          v_m_n(:,:,:) = v(:,ny-1:ny,:)
     
    23012344!-- Initialize nudging if required
    23022345    IF ( nudging )  CALL nudge_init
    2303 
    23042346!
    23052347!-- Initialize 1D/3D offline-nesting with COSMO model and read data from
    23062348!-- external file.
    2307     IF ( large_scale_forcing  .OR.  forcing )  CALL lsf_init
    2308    
     2349    IF ( large_scale_forcing  .OR.  nesting_offline )  CALL lsf_init
    23092350!
    23102351!-- Initialize surface forcing corresponding to large-scale forcing. Therein,
  • TabularUnified palm/trunk/SOURCE/init_grid.f90

    r3142 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
     
    342342       
    343343    USE control_parameters,                                                    &
    344         ONLY:  bc_lr_cyc, bc_ns_cyc, building_height, building_length_x,       &
     344        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
     345               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
     346               bc_radiation_n, bc_radiation_r, bc_radiation_s,                 &
     347               building_height, building_length_x,                             &
    345348               building_length_y, building_wall_left, building_wall_south,     &
    346349               canyon_height, canyon_wall_left, canyon_wall_south,             &
     
    350353               dz_stretch_level_end_index, dz_stretch_level_start_index,       &
    351354               dz_stretch_level_start, grid_level,                             &
    352                force_bound_l, force_bound_r, force_bound_n, force_bound_s,     &
    353                ibc_uv_b, inflow_l, inflow_n, inflow_r, inflow_s,               &
    354                masking_method, maximum_grid_level, message_string,             &
    355                momentum_advec, nest_domain, nest_bound_l,                      &
    356                nest_bound_n, nest_bound_r, nest_bound_s,                       &
    357                number_stretch_level_end, number_stretch_level_start, ocean,    &
    358                outflow_l, outflow_n, outflow_r, outflow_s, psolver,            &
    359                scalar_advec, topography, topography_grid_convention,           &
    360                tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,   &
     355               ibc_uv_b, masking_method, maximum_grid_level, message_string,   &
     356               momentum_advec, number_stretch_level_end,                       &
     357               number_stretch_level_start,ocean, psolver, scalar_advec,        &
     358               topography, topography_grid_convention, tunnel_height,          &
     359               tunnel_length, tunnel_width_x, tunnel_width_y,                  &
    361360               tunnel_wall_depth, use_surface_fluxes, use_top_fluxes,          &
    362361               wall_adjustment_factor
     
    386385    IMPLICIT NONE
    387386
    388     INTEGER(iwp) ::  i                           !< index variable along x
    389     INTEGER(iwp) ::  j                           !< index variable along y
    390     INTEGER(iwp) ::  k                           !< index variable along z
    391     INTEGER(iwp) ::  k_top                       !< topography top index on local PE
    392     INTEGER(iwp) ::  n                           !< loop variable for stretching
    393     INTEGER(iwp) ::  number_dz                   !< number of user-specified dz values       
    394     INTEGER(iwp) ::  nzb_local_max               !< vertical grid index of maximum topography height
    395     INTEGER(iwp) ::  nzb_local_min               !< vertical grid index of minimum topography height
     387    INTEGER(iwp) ::  i             !< index variable along x
     388    INTEGER(iwp) ::  j             !< index variable along y
     389    INTEGER(iwp) ::  k             !< index variable along z
     390    INTEGER(iwp) ::  k_top         !< topography top index on local PE
     391    INTEGER(iwp) ::  l             !< loop variable
     392    INTEGER(iwp) ::  n             !< loop variable for stretching
     393    INTEGER(iwp) ::  number_dz     !< number of user-specified dz values       
     394    INTEGER(iwp) ::  nzb_local_max !< vertical grid index of maximum topography height
     395    INTEGER(iwp) ::  nzb_local_min !< vertical grid index of minimum topography height
    396396                                     
    397397    INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  nzb_local  !< index for topography top at cell-center
     
    834834    nzb_max = k_top + 1
    835835#endif
    836     IF ( inflow_l  .OR.  outflow_l  .OR.  force_bound_l  .OR.  nest_bound_l  .OR.&
    837          inflow_r  .OR.  outflow_r  .OR.  force_bound_r  .OR.  nest_bound_r  .OR.&
    838          inflow_n  .OR.  outflow_n  .OR.  force_bound_n  .OR.  nest_bound_n  .OR.&
    839          inflow_s  .OR.  outflow_s  .OR.  force_bound_s  .OR.  nest_bound_s )    &
     836    IF ( bc_dirichlet_l  .OR.  bc_radiation_l     .OR.                         &
     837         bc_dirichlet_r  .OR.  bc_radiation_r     .OR.                         &
     838         bc_dirichlet_n  .OR.  bc_radiation_n     .OR.                         &
     839         bc_dirichlet_s  .OR.  bc_radiation_s )                                &
    840840         nzb_max = nzt
    841841!   
    842842!-- Finally, if topography extents up to the model top, limit nzb_max to nzt.
    843     nzb_max = MIN( nzb_max, nzt )
     843    nzb_max = MIN( nzb_max, nzt ) 
    844844!
    845845!-- Determine minimum index of topography. Usually, this will be nzb. In case
     
    857857!-- Initialize boundary conditions via surface type
    858858    CALL init_bc
     859
    859860!
    860861!-- Allocate and set topography height arrays required for data output
     
    926927#if defined( __parallel )
    927928       CALL MPI_ALLREDUCE( MAXVAL( get_topography_top_index( 's' ) ),          &
    928                            nzb_local_max, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )             
     929                           nzb_local_max, 1, MPI_INTEGER, MPI_MAX, comm2d, ierr )              
    929930#else
    930931       nzb_local_max = MAXVAL( get_topography_top_index( 's' ) )
  • TabularUnified palm/trunk/SOURCE/init_pegrid.f90

    r3058 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Rename variables and boundary conditions in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
     
    239239
    240240    USE control_parameters,                                                    &
    241         ONLY:  bc_lr, bc_ns, coupling_mode, coupling_mode_remote,              &
    242                coupling_topology, force_bound_l, force_bound_n, force_bound_r, &
    243                force_bound_s, gathered_size, grid_level,                       &
    244                grid_level_count, inflow_l, inflow_n, inflow_r, inflow_s,       &
    245                maximum_grid_level, message_string,                             &
    246                mg_switch_to_pe0_level, momentum_advec, nest_bound_l,           &
    247                nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, neutral, &
    248                psolver, outflow_l, outflow_n, outflow_r, outflow_s,            &
    249                outflow_source_plane, recycling_width, scalar_advec,            &
     241        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r, bc_dirichlet_s, &
     242               bc_lr, bc_ns, bc_radiation_l, bc_radiation_n, bc_radiation_r,   &
     243               bc_radiation_s, coupling_mode, coupling_mode_remote,            &
     244               coupling_topology, gathered_size, grid_level,                   &
     245               grid_level_count, maximum_grid_level, message_string,           &
     246               mg_switch_to_pe0_level, momentum_advec, neutral,                &
     247               psolver, outflow_source_plane, recycling_width, scalar_advec,   &
    250248               subdomain_size, turbulent_outflow, y_shift
    251249
     
    12321230!-- Setting of flags for inflow/outflow/nesting conditions.
    12331231    IF ( pleft == MPI_PROC_NULL )  THEN
    1234        IF ( bc_lr == 'dirichlet/radiation' )  THEN
    1235           inflow_l  = .TRUE.
     1232       IF ( bc_lr == 'dirichlet/radiation'  .OR.  bc_lr == 'nested'  .OR.      &
     1233            bc_lr == 'nesting_offline' )  THEN
     1234          bc_dirichlet_l  = .TRUE.
    12361235       ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
    1237           outflow_l = .TRUE.
    1238        ELSEIF ( bc_lr == 'nested' )  THEN
    1239           nest_bound_l = .TRUE.
    1240        ELSEIF ( bc_lr == 'forcing' )  THEN
    1241           force_bound_l = .TRUE.
     1236          bc_radiation_l = .TRUE.
    12421237       ENDIF
    12431238    ENDIF
     
    12451240    IF ( pright == MPI_PROC_NULL )  THEN
    12461241       IF ( bc_lr == 'dirichlet/radiation' )  THEN
    1247           outflow_r = .TRUE.
    1248        ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
    1249           inflow_r  = .TRUE.
    1250        ELSEIF ( bc_lr == 'nested' )  THEN
    1251           nest_bound_r = .TRUE.
    1252        ELSEIF ( bc_lr == 'forcing' )  THEN
    1253           force_bound_r = .TRUE.
     1242          bc_radiation_r = .TRUE.
     1243       ELSEIF ( bc_lr == 'radiation/dirichlet'  .OR.  bc_lr == 'nested'  .OR.  &
     1244                bc_lr == 'nesting_offline' )  THEN
     1245          bc_dirichlet_r  = .TRUE.
    12541246       ENDIF
    12551247    ENDIF
     
    12571249    IF ( psouth == MPI_PROC_NULL )  THEN
    12581250       IF ( bc_ns == 'dirichlet/radiation' )  THEN
    1259           outflow_s = .TRUE.
     1251          bc_radiation_s = .TRUE.
     1252       ELSEIF ( bc_ns == 'radiation/dirichlet'  .OR.  bc_ns == 'nested'  .OR.  &
     1253                bc_ns == 'nesting_offline' )  THEN
     1254          bc_dirichlet_s  = .TRUE.
     1255       ENDIF
     1256    ENDIF
     1257
     1258    IF ( pnorth == MPI_PROC_NULL )  THEN
     1259       IF ( bc_ns == 'dirichlet/radiation'  .OR.  bc_ns == 'nested'  .OR.      &
     1260            bc_ns == 'nesting_offline' )  THEN
     1261          bc_dirichlet_n  = .TRUE.
    12601262       ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
    1261           inflow_s  = .TRUE.
    1262        ELSEIF ( bc_ns == 'nested' )  THEN
    1263           nest_bound_s = .TRUE.
    1264        ELSEIF ( bc_ns == 'forcing' )  THEN
    1265           force_bound_s = .TRUE.
    1266        ENDIF
    1267     ENDIF
    1268 
    1269     IF ( pnorth == MPI_PROC_NULL )  THEN
    1270        IF ( bc_ns == 'dirichlet/radiation' )  THEN
    1271           inflow_n  = .TRUE.
    1272        ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
    1273           outflow_n = .TRUE.
    1274        ELSEIF ( bc_ns == 'nested' )  THEN
    1275           nest_bound_n = .TRUE.
    1276        ELSEIF ( bc_ns == 'forcing' )  THEN
    1277           force_bound_n = .TRUE.
     1263          bc_radiation_n = .TRUE.
    12781264       ENDIF
    12791265    ENDIF
     
    12831269!-- only at the left lateral boundary.
    12841270    IF ( use_syn_turb_gen )  THEN
    1285        IF ( force_bound_l  .OR.  nest_bound_l  .OR.  inflow_l )  THEN
     1271       IF ( bc_dirichlet_l )  THEN
    12861272          id_stg_left_l = myidx
    12871273       ELSE
    12881274          id_stg_left_l = 0
    12891275       ENDIF
    1290        IF ( force_bound_r  .OR.  nest_bound_r )  THEN
     1276       IF ( bc_dirichlet_r )  THEN
    12911277          id_stg_right_l = myidx
    12921278       ELSE
    12931279          id_stg_right_l = 0
    12941280       ENDIF
    1295        IF ( force_bound_s  .OR.  nest_bound_s )  THEN
     1281       IF ( bc_dirichlet_s )  THEN
    12961282          id_stg_south_l = myidy
    12971283       ELSE
    12981284          id_stg_south_l = 0
    12991285       ENDIF
    1300        IF ( force_bound_n  .OR.  nest_bound_n )  THEN
     1286       IF ( bc_dirichlet_n )  THEN
    13011287          id_stg_north_l = myidy
    13021288       ELSE
     
    13241310!
    13251311!-- Broadcast the id of the inflow PE
    1326     IF ( inflow_l )  THEN
     1312    IF ( bc_dirichlet_l )  THEN
    13271313       id_inflow_l = myidx
    13281314    ELSE
     
    13501336    IF ( turbulent_outflow )  THEN
    13511337
    1352        IF ( outflow_r )  THEN
     1338       IF ( bc_radiation_r )  THEN
    13531339          id_outflow_l = myidx
    13541340       ELSE
     
    13751361#else
    13761362    IF ( bc_lr == 'dirichlet/radiation' )  THEN
    1377        inflow_l = .TRUE.
    1378        outflow_r = .TRUE.
     1363       bc_dirichlet_l = .TRUE.
     1364       bc_radiation_r = .TRUE.
    13791365    ELSEIF ( bc_lr == 'radiation/dirichlet' )  THEN
    1380        outflow_l = .TRUE.
    1381        inflow_r = .TRUE.
     1366       bc_radiation_l = .TRUE.
     1367       bc_dirichlet_r = .TRUE.
    13821368    ENDIF
    13831369
    13841370    IF ( bc_ns == 'dirichlet/radiation' )  THEN
    1385        inflow_n = .TRUE.
    1386        outflow_s = .TRUE.
     1371       bc_dirichlet_n = .TRUE.
     1372       bc_radiation_s = .TRUE.
    13871373    ELSEIF ( bc_ns == 'radiation/dirichlet' )  THEN
    1388        outflow_n = .TRUE.
    1389        inflow_s = .TRUE.
     1374       bc_radiation_n = .TRUE.
     1375       bc_dirichlet_s = .TRUE.
    13901376    ENDIF
    13911377#endif
     
    13941380!-- At the inflow or outflow, u or v, respectively, have to be calculated for
    13951381!-- one more grid point.
    1396     IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
     1382    IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    13971383       nxlu = nxl + 1
    13981384    ELSE
    13991385       nxlu = nxl
    14001386    ENDIF
    1401     IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
     1387    IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    14021388       nysv = nys + 1
    14031389    ELSE
  • TabularUnified palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90

    r3049 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! * Adjustment to new Inifor version:
     23!   - No vertical interpolation/extrapolation of lateral boundary data required
     24!     any more (Inifor can treat grid stretching now
     25!   - Revise initialization in case of COSMO forcing
     26! * Rename variables and subroutines for offline nesting
    2327!
    2428! Former revisions:
     
    6973
    7074    USE arrays_3d,                                                             &
    71         ONLY:  dzw, e, heatflux_input_conversion, pt, pt_init, q, q_init, s,   &
    72                tend, u, u_init, ug, v, v_init, vg, w, w_subs,                  &
     75        ONLY:  dzw, e, diss, heatflux_input_conversion, pt, pt_init, q,        &
     76               q_init, s, tend, u, u_init, ug, v, v_init, vg, w, w_subs,       &
    7377               waterflux_input_conversion, zu, zw                 
    7478
    7579    USE control_parameters,                                                    &
    76         ONLY:  bc_lr, bc_ns, bc_pt_b, bc_q_b, constant_diffusion,              &
     80        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r, bc_dirichlet_s, &
     81               bc_lr, bc_ns, bc_pt_b, bc_q_b, constant_diffusion,              &
    7782               constant_heatflux, constant_waterflux,                          &
    78                data_output_pr, dt_3d, end_time, forcing,                       &
    79                force_bound_l, force_bound_n, force_bound_r, force_bound_s,     & 
     83               data_output_pr, dt_3d, end_time,                                &
    8084               humidity, initializing_actions, intermediate_timestep_count,    &
    8185               ibc_pt_b, ibc_q_b,                                              &
    8286               large_scale_forcing, large_scale_subsidence, lsf_surf, lsf_vert,&
    83                lsf_exception, message_string, neutral, nudging, passive_scalar,&
    84                pt_surface, ocean, q_surface, surface_heatflux,                 &
    85                surface_pressure, surface_waterflux, topography,                &
    86                use_subsidence_tendencies
     87               lsf_exception, message_string, nesting_offline, neutral,        &
     88               nudging, passive_scalar, pt_surface, ocean, q_surface,          &
     89               surface_heatflux, surface_pressure, surface_waterflux,          &
     90               topography, use_subsidence_tendencies
    8791
    8892    USE grid_variables
    89 
    90     USE pegrid
    9193
    9294    USE indices,                                                               &
     
    9698    USE kinds
    9799
     100    USE netcdf_data_input_mod,                                                 &
     101        ONLY:  nest_offl
     102
     103    USE pegrid
     104
    98105    USE surface_mod,                                                           &
    99106        ONLY:  surf_def_h, surf_lsm_h, surf_usm_h
     
    101108    USE statistics,                                                            &
    102109        ONLY:  hom, statistic_regions, sums_ls_l, weight_substep
    103 
    104     USE netcdf_data_input_mod,                                                 &
    105         ONLY:  force, netcdf_data_input_interpolate
    106110
    107111    INTEGER(iwp) ::  nlsf = 1000                       !< maximum number of profiles in LSF_DATA (large scale forcing)
     
    140144!
    141145!-- Public subroutines
    142     PUBLIC ls_forcing_surf, ls_forcing_vert, ls_advec, lsf_init,               &
     146    PUBLIC calc_tnudge, ls_forcing_surf, ls_forcing_vert, ls_advec, lsf_init,  &
    143147           lsf_nudging_check_parameters, nudge_init,                           &
    144148           lsf_nudging_check_data_output_pr, lsf_nudging_header,               &
    145            calc_tnudge, nudge, nudge_ref, forcing_bc_mass_conservation,        &
    146            forcing_bc
     149           lsf_nesting_offline, lsf_nesting_offline_mass_conservation,         &
     150           nudge, nudge_ref
     151           
    147152!
    148153!-- Public variables
    149154    PUBLIC qsws_surf, shf_surf, td_lsa_lpt, td_lsa_q, td_sub_lpt,              &
    150            td_sub_q, time_vert, force
     155           td_sub_q, time_vert
    151156
    152157
     
    167172! Description:
    168173! ------------
    169 !> @todo Missing subroutine description.
    170 !------------------------------------------------------------------------------!
    171     SUBROUTINE forcing_bc_mass_conservation
     174!> In this subroutine a constant mass within the model domain is guaranteed.
     175!> Larger-scale models may be based on a compressible equation system, which is
     176!> not consistent with PALMs incompressible equation system. In order to avoid
     177!> a decrease or increase of mass during the simulation, non-divergent flow
     178!> through the lateral and top boundaries is compensated by the vertical wind
     179!> component at the top boundary.
     180!------------------------------------------------------------------------------!
     181    SUBROUTINE lsf_nesting_offline_mass_conservation
    172182
    173183       USE control_parameters,                                                 &
     
    176186       IMPLICIT NONE
    177187
    178        INTEGER(iwp) ::  i !<
    179        INTEGER(iwp) ::  j !<
    180        INTEGER(iwp) ::  k !<
    181 
    182        REAL(wp) ::  w_correct !<
    183        REAL(wp), DIMENSION(1:3) ::  volume_flow_l   !<
     188       INTEGER(iwp) ::  i !< grid index in x-direction
     189       INTEGER(iwp) ::  j !< grid index in y-direction
     190       INTEGER(iwp) ::  k !< grid index in z-direction
     191
     192       REAL(wp) ::  w_correct                       !< vertical velocity increment required to compensate non-divergent flow through the boundaries
     193       REAL(wp), DIMENSION(1:3) ::  volume_flow_l   !< local volume flow
    184194
    185195       volume_flow   = 0.0_wp
     
    188198       d_area_t = 1.0_wp / ( ( nx + 1 ) * dx * ( ny + 1 ) * dy )
    189199
    190        IF ( force_bound_l )  THEN
     200       IF ( bc_dirichlet_l )  THEN
    191201          i = nxl
    192202          DO  j = nys, nyn
     
    198208          ENDDO
    199209       ENDIF
    200        IF ( force_bound_r )  THEN
     210       IF ( bc_dirichlet_r )  THEN
    201211          i = nxr+1
    202212          DO  j = nys, nyn
     
    208218          ENDDO
    209219       ENDIF
    210        IF ( force_bound_s )  THEN
     220       IF ( bc_dirichlet_s )  THEN
    211221          j = nys
    212222          DO  i = nxl, nxr
     
    218228          ENDDO
    219229       ENDIF
    220        IF ( force_bound_n )  THEN
     230       IF ( bc_dirichlet_n )  THEN
    221231          j = nyn+1
    222232          DO  i = nxl, nxr
     
    255265       ENDDO
    256266
    257 write(9,*) "w correction", w_correct
    258 flush(9)
    259 
    260     END SUBROUTINE forcing_bc_mass_conservation
     267    END SUBROUTINE lsf_nesting_offline_mass_conservation
    261268
    262269
     
    264271! Description:
    265272! ------------
    266 !> @todo Missing subroutine description.
    267 !------------------------------------------------------------------------------!
    268     SUBROUTINE forcing_bc
     273!> Set the lateral and top boundary conditions in case the PALM domain is
     274!> nested offline in a mesoscale model.
     275!------------------------------------------------------------------------------!
     276    SUBROUTINE lsf_nesting_offline
    269277
    270278       USE control_parameters,                                                 &
    271            ONLY:  force_bound_l, force_bound_n, force_bound_r, force_bound_s,  &
    272                   humidity, neutral, passive_scalar, simulated_time
    273 
    274        USE netcdf_data_input_mod,                                              &
    275            ONLY:  force                             
     279           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
     280                  bc_dirichlet_s, humidity, neutral, passive_scalar, rans_mode,&
     281                  rans_tke_e, time_since_reference_point                     
    276282
    277283       IMPLICIT NONE
     
    284290       REAL(wp) ::  ddt_lsf !< inverse value of time resolution of forcing data
    285291       REAL(wp) ::  t_ref   !< time past since last reference step
    286 
    287 !
    288 !--    If required, interpolate and/or extrapolate data vertically. This is
    289 !--    required as Inifor outputs only equidistant vertical data.
    290        IF ( ANY( zu(1:nzt+1) /= force%zu_atmos(1:force%nzu) ) )  THEN
    291           IF ( .NOT. force%interpolated )  THEN
    292 
    293              DO  t = 0, 1
    294                 IF ( force_bound_l )  THEN
    295                    CALL netcdf_data_input_interpolate( force%u_left(t,:,:),    &
    296                                                        zu(nzb+1:nzt+1),        &
    297                                                        force%zu_atmos )
    298                    CALL netcdf_data_input_interpolate( force%v_left(t,:,:),    &
    299                                                        zu(nzb+1:nzt+1),        &
    300                                                        force%zu_atmos )
    301                    CALL netcdf_data_input_interpolate( force%w_left(t,:,:),    &
    302                                                        zw(nzb+1:nzt+1),        &
    303                                                        force%zw_atmos )
    304                    IF ( .NOT. neutral )                                        &
    305                       CALL netcdf_data_input_interpolate( force%pt_left(t,:,:),&
    306                                                           zu(nzb+1:nzt+1),     &
    307                                                           force%zu_atmos )
    308                    IF ( humidity )                                             &
    309                       CALL netcdf_data_input_interpolate( force%q_left(t,:,:), &
    310                                                           zu(nzb+1:nzt+1),     &
    311                                                           force%zu_atmos )
    312                 ENDIF
    313                 IF ( force_bound_r )  THEN
    314                    CALL netcdf_data_input_interpolate( force%u_right(t,:,:),   &
    315                                                        zu(nzb+1:nzt+1),        &
    316                                                        force%zu_atmos )
    317                    CALL netcdf_data_input_interpolate( force%v_right(t,:,:),   &
    318                                                        zu(nzb+1:nzt+1),        &
    319                                                        force%zu_atmos )
    320                    CALL netcdf_data_input_interpolate( force%w_right(t,:,:),   &
    321                                                        zw(nzb+1:nzt+1),        &
    322                                                        force%zw_atmos )
    323                    IF ( .NOT. neutral )                                        &
    324                       CALL netcdf_data_input_interpolate( force%pt_right(t,:,:),&
    325                                                           zu(nzb+1:nzt+1),     &
    326                                                           force%zu_atmos )
    327                    IF ( humidity )                                             &
    328                       CALL netcdf_data_input_interpolate( force%q_right(t,:,:),&
    329                                                           zu(nzb+1:nzt+1),     &
    330                                                           force%zu_atmos )
    331                 ENDIF
    332                 IF ( force_bound_n )  THEN
    333                    CALL netcdf_data_input_interpolate( force%u_north(t,:,:),   &
    334                                                        zu(nzb+1:nzt+1),        &
    335                                                        force%zu_atmos )
    336                    CALL netcdf_data_input_interpolate( force%v_north(t,:,:),   &
    337                                                        zu(nzb+1:nzt+1),        &
    338                                                        force%zu_atmos )
    339                    CALL netcdf_data_input_interpolate( force%w_north(t,:,:),   &
    340                                                        zw(nzb+1:nzt+1),        &
    341                                                        force%zw_atmos )
    342                    IF ( .NOT. neutral )                                        &
    343                       CALL netcdf_data_input_interpolate( force%pt_north(t,:,:),&
    344                                                           zu(nzb+1:nzt+1),     &
    345                                                           force%zu_atmos )
    346                    IF ( humidity )                                             &
    347                       CALL netcdf_data_input_interpolate( force%q_north(t,:,:),&
    348                                                           zu(nzb+1:nzt+1),     &
    349                                                           force%zu_atmos )
    350                 ENDIF
    351                 IF ( force_bound_s )  THEN
    352                    CALL netcdf_data_input_interpolate( force%u_south(t,:,:),   &
    353                                                        zu(nzb+1:nzt+1),        &
    354                                                        force%zu_atmos )
    355                    CALL netcdf_data_input_interpolate( force%v_south(t,:,:),   &
    356                                                        zu(nzb+1:nzt+1),        &
    357                                                        force%zu_atmos )
    358                    CALL netcdf_data_input_interpolate( force%w_south(t,:,:),   &
    359                                                        zw(nzb+1:nzt+1),        &
    360                                                        force%zw_atmos )
    361                    IF ( .NOT. neutral )                                        &
    362                       CALL netcdf_data_input_interpolate( force%pt_south(t,:,:),&
    363                                                           zu(nzb+1:nzt+1),     &
    364                                                           force%zu_atmos )
    365                    IF ( humidity )                                             &
    366                       CALL netcdf_data_input_interpolate( force%q_south(t,:,:),&
    367                                                           zu(nzb+1:nzt+1),     &
    368                                                           force%zu_atmos )
    369                 ENDIF
    370              ENDDO
    371 !
    372 !--          Note, no interpolation of top boundary. Just use initial value.
    373 !--          No physical meaningful extrapolation possible if only one layer is
    374 !--          given.
    375 
    376              force%interpolated = .TRUE.
    377           ENDIF
    378        ENDIF
    379      
     292     
    380293!
    381294!--    Calculate time interval of forcing data       
    382        ddt_lsf = 1.0_wp / ( force%time(force%tind_p) - force%time(force%tind) )
     295       ddt_lsf = 1.0_wp / ( nest_offl%time(nest_offl%tind_p) -                 &
     296                            nest_offl%time(nest_offl%tind) )
    383297!
    384298!--    Calculate reziproke time past since last reference step. Please note,
    385 !--    as simulated time is still not updated, the actual time here is
    386 !--    simulated time + dt_3d
    387        t_ref = simulated_time + dt_3d - force%time(force%tind)
    388 
    389        IF ( force_bound_l )  THEN
    390 
    391           DO  j = nys, nyn
    392              DO  k = nzb+1, nzt+1
    393                 u(k,j,nxlg:nxl) = force%u_left(0,k,j) + ddt_lsf * t_ref *      &
    394                          ( force%u_left(1,k,j) - force%u_left(0,k,j) ) *       &
    395                            MERGE( 1.0_wp, 0.0_wp,                              &
    396                                   BTEST( wall_flags_0(k,j,nxlg:nxl), 1 ) )
    397              ENDDO
    398           ENDDO
     299!--    the time coordinate is still not updated, so that the actual time need
     300!--    to be incremented by dt_3d. Moreover, note that the simulation time
     301!--    passed since simulation start is time_since_reference_point, not
     302!--    simulated_time!
     303       t_ref = time_since_reference_point + dt_3d -                            &
     304                                            nest_offl%time(nest_offl%tind)
     305                                           
     306       IF ( bc_dirichlet_l )  THEN
    399307
    400308          DO  j = nys, nyn
    401309             DO  k = nzb+1, nzt
    402                 w(k,j,nxlg:nxl-1) = force%w_left(0,k,j) + ddt_lsf * t_ref *    &
    403                          ( force%w_left(1,k,j) - force%w_left(0,k,j) ) *       &
    404                            MERGE( 1.0_wp, 0.0_wp,                              &
    405                                   BTEST( wall_flags_0(k,j,nxlg:nxl-1), 3 ) )
     310                u(k,j,nxlg:nxl) = nest_offl%u_left(0,k,j) + ddt_lsf * t_ref  * &
     311                       ( nest_offl%u_left(1,k,j) - nest_offl%u_left(0,k,j) ) * &
     312                         MERGE( 1.0_wp, 0.0_wp,                                &
     313                                BTEST( wall_flags_0(k,j,nxlg:nxl), 1 ) )
     314             ENDDO
     315          ENDDO
     316
     317          DO  j = nys, nyn
     318             DO  k = nzb+1, nzt-1
     319                w(k,j,nxlg:nxl-1) = nest_offl%w_left(0,k,j) + ddt_lsf * t_ref *&
     320                       ( nest_offl%w_left(1,k,j) - nest_offl%w_left(0,k,j) )  *&
     321                         MERGE( 1.0_wp, 0.0_wp,                                &
     322                                BTEST( wall_flags_0(k,j,nxlg:nxl-1), 3 ) )
    406323             ENDDO
    407324          ENDDO
    408325
    409326          DO  j = nysv, nyn
    410              DO  k = nzb+1, nzt+1
    411                 v(k,j,nxlg:nxl-1) = force%v_left(0,k,j) + ddt_lsf * t_ref *    &
    412                          ( force%v_left(1,k,j) - force%v_left(0,k,j) ) *       &
    413                            MERGE( 1.0_wp, 0.0_wp,                              &
    414                                   BTEST( wall_flags_0(k,j,nxlg:nxl-1), 2 ) )
     327             DO  k = nzb+1, nzt
     328                v(k,j,nxlg:nxl-1) = nest_offl%v_left(0,k,j) + ddt_lsf * t_ref *&
     329                       ( nest_offl%v_left(1,k,j) - nest_offl%v_left(0,k,j) )  *&
     330                         MERGE( 1.0_wp, 0.0_wp,                                &
     331                                BTEST( wall_flags_0(k,j,nxlg:nxl-1), 2 ) )
    415332             ENDDO
    416333          ENDDO
     
    418335          IF ( .NOT. neutral )  THEN
    419336             DO  j = nys, nyn
    420                 DO  k = nzb+1, nzt+1
    421                    pt(k,j,nxlg:nxl-1) = force%pt_left(0,k,j) + ddt_lsf *       &
    422                                                                   t_ref   *    &
    423                        ( force%pt_left(1,k,j) - force%pt_left(0,k,j) )
     337                DO  k = nzb+1, nzt
     338                   pt(k,j,nxlg:nxl-1) = nest_offl%pt_left(0,k,j) + ddt_lsf *   &
     339                                                                   t_ref   *   &
     340                       ( nest_offl%pt_left(1,k,j) - nest_offl%pt_left(0,k,j) )
    424341 
    425342                ENDDO
     
    429346          IF ( humidity )  THEN
    430347             DO  j = nys, nyn
    431                 DO  k = nzb+1, nzt+1
    432                    q(k,j,nxlg:nxl-1) = force%q_left(0,k,j) + ddt_lsf   *       &
    433                                                                   t_ref   *    &
    434                        ( force%q_left(1,k,j) - force%q_left(0,k,j) )
     348                DO  k = nzb+1, nzt
     349                   q(k,j,nxlg:nxl-1) = nest_offl%q_left(0,k,j) + ddt_lsf   *   &
     350                                                                 t_ref     *   &
     351                       ( nest_offl%q_left(1,k,j) - nest_offl%q_left(0,k,j) )
    435352 
    436353                ENDDO
     
    440357       ENDIF
    441358
    442        IF ( force_bound_r )  THEN
    443 
    444           DO  j = nys, nyn
    445              DO  k = nzb+1, nzt+1
    446                 u(k,j,nxr+1:nxrg) = force%u_right(0,k,j) + ddt_lsf * t_ref *   &
    447                         ( force%u_right(1,k,j) - force%u_right(0,k,j) ) *      &
    448                            MERGE( 1.0_wp, 0.0_wp,                              &
    449                                   BTEST( wall_flags_0(k,j,nxr+1:nxrg), 1 ) )
    450 
    451              ENDDO
    452           ENDDO
     359       IF ( bc_dirichlet_r )  THEN
     360
    453361          DO  j = nys, nyn
    454362             DO  k = nzb+1, nzt
    455                 w(k,j,nxr+1:nxrg) = force%w_right(0,k,j) + ddt_lsf * t_ref *   &
    456                         ( force%w_right(1,k,j) - force%w_right(0,k,j) ) *      &
    457                            MERGE( 1.0_wp, 0.0_wp,                              &
    458                                   BTEST( wall_flags_0(k,j,nxr+1:nxrg), 3 ) )
     363                u(k,j,nxr+1:nxrg) = nest_offl%u_right(0,k,j) + ddt_lsf * t_ref *&
     364                      ( nest_offl%u_right(1,k,j) - nest_offl%u_right(0,k,j) )  *&
     365                         MERGE( 1.0_wp, 0.0_wp,                                 &
     366                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 1 ) )
     367
     368             ENDDO
     369          ENDDO
     370          DO  j = nys, nyn
     371             DO  k = nzb+1, nzt-1
     372                w(k,j,nxr+1:nxrg) = nest_offl%w_right(0,k,j) + ddt_lsf * t_ref *&
     373                      ( nest_offl%w_right(1,k,j) - nest_offl%w_right(0,k,j) )  *&
     374                         MERGE( 1.0_wp, 0.0_wp,                                 &
     375                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 3 ) )
    459376             ENDDO
    460377          ENDDO
    461378
    462379          DO  j = nysv, nyn
    463              DO  k = nzb+1, nzt+1
    464                 v(k,j,nxr+1:nxrg) = force%v_right(0,k,j) + ddt_lsf * t_ref *   &
    465                         ( force%v_right(1,k,j) - force%v_right(0,k,j) ) *      &
    466                            MERGE( 1.0_wp, 0.0_wp,                              &
    467                                   BTEST( wall_flags_0(k,j,nxr+1:nxrg), 2 ) )
     380             DO  k = nzb+1, nzt
     381                v(k,j,nxr+1:nxrg) = nest_offl%v_right(0,k,j) + ddt_lsf * t_ref *&
     382                      ( nest_offl%v_right(1,k,j) - nest_offl%v_right(0,k,j) )  *&
     383                         MERGE( 1.0_wp, 0.0_wp,                                 &
     384                                BTEST( wall_flags_0(k,j,nxr+1:nxrg), 2 ) )
    468385             ENDDO
    469386          ENDDO
     
    471388          IF ( .NOT. neutral )  THEN
    472389             DO  j = nys, nyn
    473                 DO  k = nzb+1, nzt+1
    474                    pt(k,j,nxr+1:nxrg) = force%pt_right(0,k,j) + ddt_lsf *      &
    475                                                                   t_ref   *    &
    476                      ( force%pt_right(1,k,j) - force%pt_right(0,k,j) )
     390                DO  k = nzb+1, nzt
     391                   pt(k,j,nxr+1:nxrg) = nest_offl%pt_right(0,k,j) + ddt_lsf *  &
     392                                                                    t_ref   *  &
     393                     ( nest_offl%pt_right(1,k,j) - nest_offl%pt_right(0,k,j) )
    477394 
    478395                ENDDO
     
    482399          IF ( humidity )  THEN
    483400             DO  j = nys, nyn
    484                 DO  k = nzb+1, nzt+1
    485                    q(k,j,nxr+1:nxrg) = force%q_right(0,k,j) + ddt_lsf   *      &
    486                                                                   t_ref   *    &
    487                        ( force%q_right(1,k,j) - force%q_right(0,k,j) )
     401                DO  k = nzb+1, nzt
     402                   q(k,j,nxr+1:nxrg) = nest_offl%q_right(0,k,j) + ddt_lsf   *  &
     403                                                                    t_ref   *  &
     404                       ( nest_offl%q_right(1,k,j) - nest_offl%q_right(0,k,j) )
    488405 
    489406                ENDDO
     
    493410       ENDIF
    494411
    495        IF ( force_bound_s )  THEN
    496 
    497           DO  i = nxl, nxr
    498              DO  k = nzb+1, nzt+1
    499                 v(k,nysg:nys,i)   = force%v_south(0,k,i) + ddt_lsf * t_ref *   &
    500                         ( force%v_south(1,k,i) - force%v_south(0,k,i) ) *      &
    501                            MERGE( 1.0_wp, 0.0_wp,                              &
    502                                   BTEST( wall_flags_0(k,nysg:nys,i), 2 ) )
    503              ENDDO
    504           ENDDO
     412       IF ( bc_dirichlet_s )  THEN
    505413
    506414          DO  i = nxl, nxr
    507415             DO  k = nzb+1, nzt
    508                 w(k,nysg:nys-1,i) = force%w_south(0,k,i) + ddt_lsf * t_ref *   &
    509                         ( force%w_south(1,k,i) - force%w_south(0,k,i) ) *      &
    510                            MERGE( 1.0_wp, 0.0_wp,                              &
     416                v(k,nysg:nys,i)   = nest_offl%v_south(0,k,i) + ddt_lsf * t_ref *&
     417                      ( nest_offl%v_south(1,k,i) - nest_offl%v_south(0,k,i) )  *&
     418                         MERGE( 1.0_wp, 0.0_wp,                                 &
     419                                BTEST( wall_flags_0(k,nysg:nys,i), 2 ) )
     420             ENDDO
     421          ENDDO
     422
     423          DO  i = nxl, nxr
     424             DO  k = nzb+1, nzt-1
     425                w(k,nysg:nys-1,i) = nest_offl%w_south(0,k,i) + ddt_lsf * t_ref  *&
     426                        ( nest_offl%w_south(1,k,i) - nest_offl%w_south(0,k,i) ) *&
     427                           MERGE( 1.0_wp, 0.0_wp,                                &
    511428                                  BTEST( wall_flags_0(k,nysg:nys-1,i), 3 ) )
    512429             ENDDO
     
    514431
    515432          DO  i = nxlu, nxr
    516              DO  k = nzb+1, nzt+1
    517                 u(k,nysg:nys-1,i) = force%u_south(0,k,i) + ddt_lsf * t_ref *   &
    518                         ( force%u_south(1,k,i) - force%u_south(0,k,i) ) *      &
    519                            MERGE( 1.0_wp, 0.0_wp,                              &
     433             DO  k = nzb+1, nzt
     434                u(k,nysg:nys-1,i) = nest_offl%u_south(0,k,i) + ddt_lsf * t_ref  *&
     435                        ( nest_offl%u_south(1,k,i) - nest_offl%u_south(0,k,i) ) *&
     436                           MERGE( 1.0_wp, 0.0_wp,                                &
    520437                                  BTEST( wall_flags_0(k,nysg:nys-1,i), 1 ) )
    521438             ENDDO
     
    524441          IF ( .NOT. neutral )  THEN
    525442             DO  i = nxl, nxr
    526                 DO  k = nzb+1, nzt+1
    527                    pt(k,nysg:nys-1,i) = force%pt_south(0,k,i) + ddt_lsf *      &
    528                                                                   t_ref   *    &
    529                      ( force%pt_south(1,k,i) - force%pt_south(0,k,i) )
     443                DO  k = nzb+1, nzt
     444                   pt(k,nysg:nys-1,i) = nest_offl%pt_south(0,k,i) + ddt_lsf *  &
     445                                                                    t_ref   *  &
     446                     ( nest_offl%pt_south(1,k,i) - nest_offl%pt_south(0,k,i) )
    530447 
    531448                ENDDO
     
    535452          IF ( humidity )  THEN
    536453             DO  i = nxl, nxr
    537                 DO  k = nzb+1, nzt+1
    538                    q(k,nysg:nys-1,i) = force%q_south(0,k,i) + ddt_lsf   *      &
    539                                                                   t_ref   *    &
    540                        ( force%q_south(1,k,i) - force%q_south(0,k,i) )
     454                DO  k = nzb+1, nzt
     455                   q(k,nysg:nys-1,i) = nest_offl%q_south(0,k,i) + ddt_lsf   *  &
     456                                                                    t_ref   *  &
     457                       ( nest_offl%q_south(1,k,i) - nest_offl%q_south(0,k,i) )
    541458 
    542459                ENDDO
     
    546463       ENDIF
    547464
    548        IF ( force_bound_n )  THEN
    549 
    550           DO  i = nxl, nxr
    551              DO  k = nzb+1, nzt+1
    552                 v(k,nyn+1:nyng,i)   = force%v_north(0,k,i) + ddt_lsf * t_ref * &
    553                         ( force%v_north(1,k,i) - force%v_north(0,k,i) ) *      &
    554                            MERGE( 1.0_wp, 0.0_wp,                              &
    555                                   BTEST( wall_flags_0(k,nyn+1:nyng,i), 2 ) )
    556              ENDDO
    557           ENDDO
     465       IF ( bc_dirichlet_n )  THEN
     466
    558467          DO  i = nxl, nxr
    559468             DO  k = nzb+1, nzt
    560                 w(k,nyn+1:nyng,i) = force%w_north(0,k,i) + ddt_lsf * t_ref *   &
    561                         ( force%w_north(1,k,i) - force%w_north(0,k,i) ) *      &
    562                            MERGE( 1.0_wp, 0.0_wp,                              &
     469                v(k,nyn+1:nyng,i)   = nest_offl%v_north(0,k,i) + ddt_lsf * t_ref *&
     470                        ( nest_offl%v_north(1,k,i) - nest_offl%v_north(0,k,i) )  *&
     471                           MERGE( 1.0_wp, 0.0_wp,                                 &
     472                                  BTEST( wall_flags_0(k,nyn+1:nyng,i), 2 ) )
     473             ENDDO
     474          ENDDO
     475          DO  i = nxl, nxr
     476             DO  k = nzb+1, nzt-1
     477                w(k,nyn+1:nyng,i) = nest_offl%w_north(0,k,i) + ddt_lsf * t_ref  *&
     478                        ( nest_offl%w_north(1,k,i) - nest_offl%w_north(0,k,i) ) *&
     479                           MERGE( 1.0_wp, 0.0_wp,                                &
    563480                                  BTEST( wall_flags_0(k,nyn+1:nyng,i), 3 ) )
    564481             ENDDO
     
    566483
    567484          DO  i = nxlu, nxr
    568              DO  k = nzb+1, nzt+1
    569                 u(k,nyn+1:nyng,i) = force%u_north(0,k,i) + ddt_lsf * t_ref *   &
    570                         ( force%u_north(1,k,i) - force%u_north(0,k,i) ) *      &
    571                            MERGE( 1.0_wp, 0.0_wp,                              &
     485             DO  k = nzb+1, nzt
     486                u(k,nyn+1:nyng,i) = nest_offl%u_north(0,k,i) + ddt_lsf * t_ref  *&
     487                        ( nest_offl%u_north(1,k,i) - nest_offl%u_north(0,k,i) ) *&
     488                           MERGE( 1.0_wp, 0.0_wp,                                &
    572489                                  BTEST( wall_flags_0(k,nyn+1:nyng,i), 1 ) )
    573490
     
    577494          IF ( .NOT. neutral )  THEN
    578495             DO  i = nxl, nxr
    579                 DO  k = nzb+1, nzt+1
    580                    pt(k,nyn+1:nyng,i) = force%pt_north(0,k,i) + ddt_lsf *      &
    581                                                                   t_ref   *    &
    582                      ( force%pt_north(1,k,i) - force%pt_north(0,k,i) )
     496                DO  k = nzb+1, nzt
     497                   pt(k,nyn+1:nyng,i) = nest_offl%pt_north(0,k,i) + ddt_lsf *  &
     498                                                                    t_ref   *  &
     499                     ( nest_offl%pt_north(1,k,i) - nest_offl%pt_north(0,k,i) )
    583500 
    584501                ENDDO
     
    588505          IF ( humidity )  THEN
    589506             DO  i = nxl, nxr
    590                 DO  k = nzb+1, nzt+1
    591                    q(k,nyn+1:nyng,i) = force%q_north(0,k,i) + ddt_lsf   *      &
    592                                                                   t_ref   *    &
    593                        ( force%q_north(1,k,i) - force%q_north(0,k,i) )
     507                DO  k = nzb+1, nzt
     508                   q(k,nyn+1:nyng,i) = nest_offl%q_north(0,k,i) + ddt_lsf   *  &
     509                                                                    t_ref   *  &
     510                       ( nest_offl%q_north(1,k,i) - nest_offl%q_north(0,k,i) )
    594511 
    595512                ENDDO
     
    600517!
    601518!--    Top boundary.
    602 !--    Please note, only map Inifor data on model top in case the numeric is
    603 !--    identical to the Inifor grid. At the top boundary an extrapolation is
    604 !--    not possible.
    605519       DO  i = nxlu, nxr
    606520          DO  j = nys, nyn
    607              u(nzt+1,j,i) = force%u_top(0,j,i) + ddt_lsf * t_ref *             &
    608                         ( force%u_top(1,j,i) - force%u_top(0,j,i) ) *          &
    609                            MERGE( 1.0_wp, 0.0_wp,                             &
     521             u(nzt+1,j,i) = nest_offl%u_top(0,j,i) + ddt_lsf * t_ref *         &
     522                        ( nest_offl%u_top(1,j,i) - nest_offl%u_top(0,j,i) ) *  &
     523                           MERGE( 1.0_wp, 0.0_wp,                              &
    610524                                  BTEST( wall_flags_0(nzt+1,j,i), 1 ) )
    611525          ENDDO
     
    614528       DO  i = nxl, nxr
    615529          DO  j = nysv, nyn
    616              v(nzt+1,j,i) = force%v_top(0,j,i) + ddt_lsf * t_ref *             &
    617                         ( force%v_top(1,j,i) - force%v_top(0,j,i) ) *          &
     530             v(nzt+1,j,i) = nest_offl%v_top(0,j,i) + ddt_lsf * t_ref *         &
     531                        ( nest_offl%v_top(1,j,i) - nest_offl%v_top(0,j,i) ) *  &
    618532                           MERGE( 1.0_wp, 0.0_wp,                              &
    619533                                  BTEST( wall_flags_0(nzt+1,j,i), 2 ) )
     
    623537       DO  i = nxl, nxr
    624538          DO  j = nys, nyn
    625              w(nzt:nzt+1,j,i) = force%w_top(0,j,i) + ddt_lsf * t_ref *         &
    626                         ( force%w_top(1,j,i) - force%w_top(0,j,i) ) *          &
     539             w(nzt:nzt+1,j,i) = nest_offl%w_top(0,j,i) + ddt_lsf * t_ref *     &
     540                        ( nest_offl%w_top(1,j,i) - nest_offl%w_top(0,j,i) ) *  &
    627541                           MERGE( 1.0_wp, 0.0_wp,                              &
    628542                                  BTEST( wall_flags_0(nzt:nzt+1,j,i), 3 ) )
     
    634548          DO  i = nxl, nxr
    635549             DO  j = nys, nyn
    636                 pt(nzt+1,j,i) = force%pt_top(0,j,i) + ddt_lsf * t_ref *        &
    637                         ( force%pt_top(1,j,i) - force%pt_top(0,j,i) )
     550                pt(nzt+1,j,i) = nest_offl%pt_top(0,j,i) + ddt_lsf * t_ref *    &
     551                        ( nest_offl%pt_top(1,j,i) - nest_offl%pt_top(0,j,i) )
    638552             ENDDO
    639553          ENDDO
     
    643557          DO  i = nxl, nxr
    644558             DO  j = nys, nyn
    645                 q(nzt+1,j,i) = force%q_top(0,j,i) + ddt_lsf * t_ref *          &
    646                         ( force%q_top(1,j,i) - force%q_top(0,j,i) )
     559                q(nzt+1,j,i) = nest_offl%q_top(0,j,i) + ddt_lsf * t_ref *      &
     560                        ( nest_offl%q_top(1,j,i) - nest_offl%q_top(0,j,i) )
    647561             ENDDO
    648562          ENDDO
     
    651565!--    At the edges( left-south, left-north, right-south and right-north) set
    652566!--    data on ghost points.
    653        IF ( force_bound_l  .AND.  force_bound_s )  THEN
     567       IF ( bc_dirichlet_l  .AND.  bc_dirichlet_s )  THEN
    654568          DO  i = 1, nbgp
    655569             u(:,nys-i,nxlg:nxl)   = u(:,nys,nxlg:nxl)
    656570             w(:,nys-i,nxlg:nxl-1) = w(:,nys,nxlg:nxl-1)
    657571             IF ( .NOT. neutral )  pt(:,nys-i,nxlg:nxl-1) = pt(:,nys,nxlg:nxl-1)
    658              IF ( humidity )       q(:,nys-i,nxlg:nxl-1)  = q(:,nys,nxlg:nxl-1)
     572             IF ( humidity      )  q(:,nys-i,nxlg:nxl-1)  = q(:,nys,nxlg:nxl-1)
    659573          ENDDO
    660574          DO  i = 1, nbgp+1
     
    662576          ENDDO
    663577       ENDIF
    664        IF ( force_bound_l  .AND.  force_bound_n )  THEN
     578       IF ( bc_dirichlet_l  .AND.  bc_dirichlet_n )  THEN
    665579          DO  i = 1, nbgp
    666580             u(:,nyn+i,nxlg:nxl)   = u(:,nyn,nxlg:nxl)
     
    668582             w(:,nyn+i,nxlg:nxl-1) = w(:,nyn,nxlg:nxl-1)
    669583             IF ( .NOT. neutral )  pt(:,nyn+i,nxlg:nxl-1) = pt(:,nyn,nxlg:nxl-1)
    670              IF ( humidity )       q(:,nyn+i,nxlg:nxl-1)  = q(:,nyn,nxlg:nxl-1)
    671           ENDDO
    672        ENDIF
    673        IF ( force_bound_r  .AND.  force_bound_s )  THEN
     584             IF ( humidity      )  q(:,nyn+i,nxlg:nxl-1)  = q(:,nyn,nxlg:nxl-1)
     585          ENDDO
     586       ENDIF
     587       IF ( bc_dirichlet_r  .AND.  bc_dirichlet_s )  THEN
    674588          DO  i = 1, nbgp
    675589             u(:,nys-i,nxr+1:nxrg) = u(:,nys,nxr+1:nxrg)
    676590             w(:,nys-i,nxr+1:nxrg) = w(:,nys,nxr+1:nxrg)
    677591             IF ( .NOT. neutral )  pt(:,nys-i,nxr+1:nxrg) = pt(:,nys,nxr+1:nxrg)
    678              IF ( humidity )       q(:,nys-i,nxr+1:nxrg)  = q(:,nys,nxr+1:nxrg)
     592             IF ( humidity      )  q(:,nys-i,nxr+1:nxrg)  = q(:,nys,nxr+1:nxrg)
    679593          ENDDO
    680594          DO  i = 1, nbgp+1
     
    682596          ENDDO
    683597       ENDIF
    684        IF ( force_bound_r  .AND.  force_bound_n )  THEN
     598       IF ( bc_dirichlet_r  .AND.  bc_dirichlet_n )  THEN
    685599          DO  i = 1, nbgp
    686600             u(:,nyn+i,nxr+1:nxrg) = u(:,nyn,nxr+1:nxrg)
     
    688602             w(:,nyn+i,nxr+1:nxrg) = w(:,nyn,nxr+1:nxrg)
    689603             IF ( .NOT. neutral )  pt(:,nyn+i,nxr+1:nxrg) = pt(:,nyn,nxr+1:nxrg)
    690              IF ( humidity )       q(:,nyn+i,nxr+1:nxrg)  = q(:,nyn,nxr+1:nxrg)
    691           ENDDO
    692        ENDIF
    693 !
    694 !--    Moreover, set Neumann boundary condition for subgrid-scale TKE and
    695 !--    passive scalar
     604             IF ( humidity      )  q(:,nyn+i,nxr+1:nxrg)  = q(:,nyn,nxr+1:nxrg)
     605          ENDDO
     606       ENDIF
     607!
     608!--    Moreover, set Neumann boundary condition for subgrid-scale TKE,
     609!--    passive scalar, dissipation, and chemical species if required
     610       IF ( rans_mode  .AND.  rans_tke_e )  THEN
     611          IF (  bc_dirichlet_l )  diss(:,:,nxl-1) = diss(:,:,nxl)
     612          IF (  bc_dirichlet_r )  diss(:,:,nxr+1) = diss(:,:,nxr)
     613          IF (  bc_dirichlet_s )  diss(:,nys-1,:) = diss(:,nys,:)
     614          IF (  bc_dirichlet_n )  diss(:,nyn+1,:) = diss(:,nyn,:)
     615       ENDIF
    696616       IF ( .NOT. constant_diffusion )  THEN
    697           IF (  force_bound_l )  e(:,:,nxl-1) = e(:,:,nxl)
    698           IF (  force_bound_r )  e(:,:,nxr+1) = e(:,:,nxr)
    699           IF (  force_bound_s )  e(:,nys-1,:) = e(:,nys,:)
    700           IF (  force_bound_n )  e(:,nyn+1,:) = e(:,nyn,:)
     617          IF (  bc_dirichlet_l )  e(:,:,nxl-1) = e(:,:,nxl)
     618          IF (  bc_dirichlet_r )  e(:,:,nxr+1) = e(:,:,nxr)
     619          IF (  bc_dirichlet_s )  e(:,nys-1,:) = e(:,nys,:)
     620          IF (  bc_dirichlet_n )  e(:,nyn+1,:) = e(:,nyn,:)
    701621          e(nzt+1,:,:) = e(nzt,:,:)
    702622       ENDIF
    703623       IF ( passive_scalar )  THEN
    704           IF (  force_bound_l )  s(:,:,nxl-1) = s(:,:,nxl)
    705           IF (  force_bound_r )  s(:,:,nxr+1) = s(:,:,nxr)
    706           IF (  force_bound_s )  s(:,nys-1,:) = s(:,nys,:)
    707           IF (  force_bound_n )  s(:,nyn+1,:) = s(:,nyn,:)
    708        ENDIF
     624          IF (  bc_dirichlet_l )  s(:,:,nxl-1) = s(:,:,nxl)
     625          IF (  bc_dirichlet_r )  s(:,:,nxr+1) = s(:,:,nxr)
     626          IF (  bc_dirichlet_s )  s(:,nys-1,:) = s(:,nys,:)
     627          IF (  bc_dirichlet_n )  s(:,nyn+1,:) = s(:,nyn,:)
     628       ENDIF
     629
    709630
    710631
     
    720641!--    treatment of fluxes.
    721642!--    For the moment, comment this out!
    722 !      surface_pressure = force%surface_pressure(force%tind) +                 &
     643!      surface_pressure = nest_offl%surface_pressure(nest_offl%tind) +                 &
    723644!                                                      ddt_lsf * t_ref *       &
    724 !                                    ( force%surface_pressure(force%tind_p)    &
    725 !                                    - force%surface_pressure(force%tind) )
    726 
    727     END SUBROUTINE forcing_bc
     645!                                    ( nest_offl%surface_pressure(nest_offl%tind_p)    &
     646!                                    - nest_offl%surface_pressure(nest_offl%tind) )
     647
     648    END SUBROUTINE lsf_nesting_offline
    728649
    729650!------------------------------------------------------------------------------!
     
    1040961       REAL(wp) ::  r_dummy           !<
    1041962
    1042        IF ( forcing )  THEN
     963       IF ( nesting_offline )  THEN
    1043964!
    1044965!--       Allocate arrays for geostrophic wind components. Arrays will
     
    1047968!--       case of cyclic boundary conditions.
    1048969          IF ( bc_lr_cyc  .AND.  bc_ns_cyc )  THEN
    1049              ALLOCATE( force%ug(0:1,nzb:nzt+1) )
    1050              ALLOCATE( force%vg(0:1,nzb:nzt+1) )
     970             ALLOCATE( nest_offl%ug(0:1,nzb:nzt+1) )
     971             ALLOCATE( nest_offl%vg(0:1,nzb:nzt+1) )
    1051972          ENDIF
    1052973!
    1053974!--       Allocate arrays for reading boundary values. Arrays will incorporate 2
    1054975!--       time levels in order to interpolate in between.
    1055           IF ( force_bound_l )  THEN
    1056              ALLOCATE( force%u_left(0:1,nzb+1:nzt+1,nys:nyn)  )
    1057              ALLOCATE( force%v_left(0:1,nzb+1:nzt+1,nysv:nyn) )
    1058              ALLOCATE( force%w_left(0:1,nzb+1:nzt,nys:nyn)    )
    1059              IF ( humidity )      ALLOCATE( force%q_left(0:1,nzb+1:nzt+1,nys:nyn)  )
    1060              IF ( .NOT. neutral ) ALLOCATE( force%pt_left(0:1,nzb+1:nzt+1,nys:nyn) )
    1061           ENDIF
    1062           IF ( force_bound_r )  THEN
    1063              ALLOCATE( force%u_right(0:1,nzb+1:nzt+1,nys:nyn)  )
    1064              ALLOCATE( force%v_right(0:1,nzb+1:nzt+1,nysv:nyn) )
    1065              ALLOCATE( force%w_right(0:1,nzb+1:nzt,nys:nyn)    )
    1066              IF ( humidity )      ALLOCATE( force%q_right(0:1,nzb+1:nzt+1,nys:nyn)  )
    1067              IF ( .NOT. neutral ) ALLOCATE( force%pt_right(0:1,nzb+1:nzt+1,nys:nyn) )
    1068           ENDIF
    1069           IF ( force_bound_n )  THEN
    1070              ALLOCATE( force%u_north(0:1,nzb+1:nzt+1,nxlu:nxr) )
    1071              ALLOCATE( force%v_north(0:1,nzb+1:nzt+1,nxl:nxr)  )
    1072              ALLOCATE( force%w_north(0:1,nzb+1:nzt,nxl:nxr)    )
    1073              IF ( humidity )      ALLOCATE( force%q_north(0:1,nzb+1:nzt+1,nxl:nxr)  )
    1074              IF ( .NOT. neutral ) ALLOCATE( force%pt_north(0:1,nzb+1:nzt+1,nxl:nxr) )
    1075           ENDIF
    1076           IF ( force_bound_s )  THEN
    1077              ALLOCATE( force%u_south(0:1,nzb+1:nzt+1,nxlu:nxr) )
    1078              ALLOCATE( force%v_south(0:1,nzb+1:nzt+1,nxl:nxr)  )
    1079              ALLOCATE( force%w_south(0:1,nzb+1:nzt,nxl:nxr)    )
    1080              IF ( humidity )      ALLOCATE( force%q_south(0:1,nzb+1:nzt+1,nxl:nxr)  )
    1081              IF ( .NOT. neutral ) ALLOCATE( force%pt_south(0:1,nzb+1:nzt+1,nxl:nxr) )
     976          IF ( bc_dirichlet_l )  THEN
     977             ALLOCATE( nest_offl%u_left(0:1,nzb+1:nzt,nys:nyn)  )
     978             ALLOCATE( nest_offl%v_left(0:1,nzb+1:nzt,nysv:nyn) )
     979             ALLOCATE( nest_offl%w_left(0:1,nzb+1:nzt-1,nys:nyn) )
     980             IF ( humidity )      ALLOCATE( nest_offl%q_left(0:1,nzb+1:nzt,nys:nyn)  )
     981             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_left(0:1,nzb+1:nzt,nys:nyn) )
     982          ENDIF
     983          IF ( bc_dirichlet_r )  THEN
     984             ALLOCATE( nest_offl%u_right(0:1,nzb+1:nzt,nys:nyn)  )
     985             ALLOCATE( nest_offl%v_right(0:1,nzb+1:nzt,nysv:nyn) )
     986             ALLOCATE( nest_offl%w_right(0:1,nzb+1:nzt-1,nys:nyn) )
     987             IF ( humidity )      ALLOCATE( nest_offl%q_right(0:1,nzb+1:nzt,nys:nyn)  )
     988             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_right(0:1,nzb+1:nzt,nys:nyn) )
     989          ENDIF
     990          IF ( bc_dirichlet_n )  THEN
     991             ALLOCATE( nest_offl%u_north(0:1,nzb+1:nzt,nxlu:nxr) )
     992             ALLOCATE( nest_offl%v_north(0:1,nzb+1:nzt,nxl:nxr)  )
     993             ALLOCATE( nest_offl%w_north(0:1,nzb+1:nzt-1,nxl:nxr) )
     994             IF ( humidity )      ALLOCATE( nest_offl%q_north(0:1,nzb+1:nzt,nxl:nxr)  )
     995             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_north(0:1,nzb+1:nzt,nxl:nxr) )
     996          ENDIF
     997          IF ( bc_dirichlet_s )  THEN
     998             ALLOCATE( nest_offl%u_south(0:1,nzb+1:nzt,nxlu:nxr) )
     999             ALLOCATE( nest_offl%v_south(0:1,nzb+1:nzt,nxl:nxr)  )
     1000             ALLOCATE( nest_offl%w_south(0:1,nzb+1:nzt-1,nxl:nxr)    )
     1001             IF ( humidity )      ALLOCATE( nest_offl%q_south(0:1,nzb+1:nzt,nxl:nxr)  )
     1002             IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_south(0:1,nzb+1:nzt,nxl:nxr) )
    10821003          ENDIF
    10831004         
    1084           ALLOCATE( force%u_top(0:1,nys:nyn,nxlu:nxr) )
    1085           ALLOCATE( force%v_top(0:1,nysv:nyn,nxl:nxr) )
    1086           ALLOCATE( force%w_top(0:1,nys:nyn,nxl:nxr)  )
    1087           IF ( humidity )      ALLOCATE( force%q_top(0:1,nys:nyn,nxl:nxr)  )
    1088           IF ( .NOT. neutral ) ALLOCATE( force%pt_top(0:1,nys:nyn,nxl:nxr) )
    1089 
    1090 !
    1091 !--       Initial call of input. Time array, initial 3D data of u, v, w,
    1092 !--       potential temperature, as well as mixing ratio, will be read.
    1093 !--       Moreover, data at lateral and top boundary will be read. 
     1005          ALLOCATE( nest_offl%u_top(0:1,nys:nyn,nxlu:nxr) )
     1006          ALLOCATE( nest_offl%v_top(0:1,nysv:nyn,nxl:nxr) )
     1007          ALLOCATE( nest_offl%w_top(0:1,nys:nyn,nxl:nxr)  )
     1008          IF ( humidity )      ALLOCATE( nest_offl%q_top(0:1,nys:nyn,nxl:nxr)  )
     1009          IF ( .NOT. neutral ) ALLOCATE( nest_offl%pt_top(0:1,nys:nyn,nxl:nxr) )
     1010
     1011!
     1012!--       Read COSMO data at lateral and top boundaries
    10941013          CALL netcdf_data_input_lsf
    10951014!
    1096 !--       Please note, at the moment INIFOR assumes only an equidistant vertical
    1097 !--       grid. In case of vertical grid stretching, input of inital 3D data
    1098 !--       need to be inter- and/or extrapolated.
    1099 !--       Therefore, check if zw grid on file is identical to numeric zw grid.   
    1100           IF ( ANY( zu(1:nzt+1) /= force%zu_atmos(1:force%nzu) ) )  THEN
    1101 !
    1102 !--          Also data at the boundaries need to be inter/extrapolated at both
    1103 !--          time levels
    1104              DO  t = 0, 1
    1105                 IF ( force_bound_l )  THEN
    1106                    CALL netcdf_data_input_interpolate( force%u_left(t,:,:),    &
    1107                                                        zu(1:nzt+1),            &
    1108                                                        force%zu_atmos )
    1109                    CALL netcdf_data_input_interpolate( force%v_left(t,:,:),    &
    1110                                                        zu(1:nzt+1),            &
    1111                                                        force%zu_atmos )
    1112                    CALL netcdf_data_input_interpolate( force%w_left(t,:,:),    &
    1113                                                        zw(1:nzt+1),            &
    1114                                                        force%zw_atmos )
    1115                    IF ( .NOT. neutral )                                        &
    1116                       CALL netcdf_data_input_interpolate( force%pt_left(t,:,:),&
    1117                                                           zu(1:nzt+1),         &
    1118                                                           force%zu_atmos )
    1119                    IF ( humidity )                                             &
    1120                       CALL netcdf_data_input_interpolate( force%q_left(t,:,:), &
    1121                                                           zu(1:nzt+1),         &
    1122                                                           force%zu_atmos )
    1123                 ENDIF
    1124                 IF ( force_bound_r )  THEN
    1125                    CALL netcdf_data_input_interpolate( force%u_right(t,:,:),   &
    1126                                                        zu(1:nzt+1),            &
    1127                                                        force%zu_atmos )
    1128                    CALL netcdf_data_input_interpolate( force%v_right(t,:,:),   &
    1129                                                        zu(1:nzt+1),            &
    1130                                                        force%zu_atmos )
    1131                    CALL netcdf_data_input_interpolate( force%w_right(t,:,:),   &
    1132                                                        zw(1:nzt+1),            &
    1133                                                        force%zw_atmos )
    1134                    IF ( .NOT. neutral )                                        &
    1135                       CALL netcdf_data_input_interpolate( force%pt_right(t,:,:),&
    1136                                                           zu(1:nzt+1),          &
    1137                                                           force%zu_atmos )
    1138                    IF ( humidity )                                             &
    1139                       CALL netcdf_data_input_interpolate( force%q_right(t,:,:),&
    1140                                                           zu(1:nzt+1),         &
    1141                                                           force%zu_atmos )
    1142                 ENDIF
    1143                 IF ( force_bound_n )  THEN
    1144                    CALL netcdf_data_input_interpolate( force%u_north(t,:,:),   &
    1145                                                        zu(1:nzt+1),            &
    1146                                                        force%zu_atmos )
    1147                    CALL netcdf_data_input_interpolate( force%v_north(t,:,:),   &
    1148                                                        zu(1:nzt+1),            &
    1149                                                        force%zu_atmos )
    1150                    CALL netcdf_data_input_interpolate( force%w_north(t,:,:),   &
    1151                                                        zw(1:nzt+1),            &
    1152                                                        force%zw_atmos )
    1153                    IF ( .NOT. neutral )                                        &
    1154                       CALL netcdf_data_input_interpolate( force%pt_north(t,:,:),&
    1155                                                           zu(1:nzt+1),          &
    1156                                                           force%zu_atmos )
    1157                    IF ( humidity )                                             &
    1158                       CALL netcdf_data_input_interpolate( force%q_north(t,:,:),&
    1159                                                           zu(1:nzt+1),         &
    1160                                                           force%zu_atmos )
    1161                 ENDIF
    1162                 IF ( force_bound_s )  THEN
    1163                    CALL netcdf_data_input_interpolate( force%u_south(t,:,:),   &
    1164                                                        zu(1:nzt+1),            &
    1165                                                        force%zu_atmos )
    1166                    CALL netcdf_data_input_interpolate( force%v_south(t,:,:),   &
    1167                                                        zu(1:nzt+1),            &
    1168                                                        force%zu_atmos )
    1169                    CALL netcdf_data_input_interpolate( force%w_south(t,:,:),   &
    1170                                                        zw(1:nzt+1),            &
    1171                                                        force%zw_atmos )
    1172                    IF ( .NOT. neutral )                                        &
    1173                       CALL netcdf_data_input_interpolate( force%pt_south(t,:,:),&
    1174                                                           zu(1:nzt+1),          &
    1175                                                           force%zu_atmos )
    1176                    IF ( humidity )                                             &
    1177                       CALL netcdf_data_input_interpolate( force%q_south(t,:,:),&
    1178                                                           zu(1:nzt+1),         &
    1179                                                           force%zu_atmos )
    1180                 ENDIF
    1181              ENDDO
    1182           ENDIF
    1183 
    1184 !
    1185 !--       Exchange ghost points
    1186           CALL exchange_horiz( u, nbgp )
    1187           CALL exchange_horiz( v, nbgp )
    1188           CALL exchange_horiz( w, nbgp )
    1189           IF ( .NOT. neutral )  CALL exchange_horiz( pt, nbgp )
    1190           IF ( humidity      )  CALL exchange_horiz( q,  nbgp )
    1191 !
    1192 !--       At lateral boundaries, set also initial boundary conditions
    1193           IF ( force_bound_l )  THEN
    1194              u(:,:,nxl)   = u(:,:,nxlu)
    1195              v(:,:,nxl-1) = v(:,:,nxl)
    1196              w(:,:,nxl-1) = w(:,:,nxl)
    1197              IF ( .NOT. neutral )  pt(:,:,nxl-1) = pt(:,:,nxl)
    1198              IF ( humidity      )  q(:,:,nxl-1)  = q(:,:,nxl)
    1199           ENDIF
    1200           IF ( force_bound_r )  THEN
    1201              u(:,:,nxr+1) = u(:,:,nxr)
    1202              v(:,:,nxr+1) = v(:,:,nxr)
    1203              w(:,:,nxr+1) = w(:,:,nxr)
    1204              IF ( .NOT. neutral )  pt(:,:,nxr+1) = pt(:,:,nxr)
    1205              IF ( humidity      )  q(:,:,nxr+1)  = q(:,:,nxr)
    1206           ENDIF
    1207           IF ( force_bound_s )  THEN
    1208              u(:,nys-1,:) = u(:,nys,:)
    1209              v(:,nys,:)   = v(:,nysv,:)
    1210              w(:,nys-1,:) = w(:,nys,:)
    1211              IF ( .NOT. neutral )  pt(:,nys-1,:) = pt(:,nys,:)
    1212              IF ( humidity      )  q(:,nys-1,:)  = q(:,nys,:)
    1213           ENDIF
    1214           IF ( force_bound_n )  THEN
    1215              u(:,nyn+1,:) = u(:,nyn,:)
    1216              v(:,nyn+1,:) = v(:,nyn,:)
    1217              w(:,nyn+1,:) = w(:,nyn,:)
    1218              IF ( .NOT. neutral )  pt(:,nyn+1,:) = pt(:,nyn,:)
    1219              IF ( humidity      )  q(:,nyn+1,:)  = q(:,nyn,:)
    1220           ENDIF
    1221 
     1015!--       Write COSMO data at lateral and top boundaries
     1016          CALL lsf_nesting_offline
    12221017!
    12231018!--       After 3D data is initialized, ensure mass conservation
    1224           CALL forcing_bc_mass_conservation
     1019          CALL lsf_nesting_offline_mass_conservation
    12251020!
    12261021!--       Initialize surface pressure. Please note, time-dependent surface
     
    12281023!--       treatment of fluxes.
    12291024!--       For the moment, comment this out!
    1230 !         surface_pressure = force%surface_pressure(0)
     1025!         surface_pressure = nest_offl%surface_pressure(0)
    12311026
    12321027       ELSE
  • TabularUnified palm/trunk/SOURCE/modules.f90

    r3162 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Rename offline nesting variables:
     23! -inflow_l, inflow_n, inflow_r, inflow_s,
     24!  nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s, nest_domain, forcing,
     25!  force_bound_l, force_bound_n, force_bound_r, force_bound_s, outflow_l,
     26!  outflow_n, outflow_r, outflow_s
     27! +bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_n, bc_dirichlet_r,
     28!  bc_radiation_l, bc_radiation_n, bc_radiation_n, bc_radiation_r, child_domain
     29!  nesting_offline
    2330!
    2431! Former revisions:
     
    12721279    LOGICAL ::  agent_time_unlimited = .FALSE.                   !< namelist parameter
    12731280    LOGICAL ::  air_chemistry = .FALSE.                          !< chemistry model switch
     1281    LOGICAL ::  bc_dirichlet_l                                   !< flag indicating dirichlet boundary condition on left model boundary
     1282    LOGICAL ::  bc_dirichlet_n                                   !< flag indicating dirichlet boundary condition on north model boundary
     1283    LOGICAL ::  bc_dirichlet_r                                   !< flag indicating dirichlet boundary condition on right model boundary
     1284    LOGICAL ::  bc_dirichlet_s                                   !< flag indicating dirichlet boundary condition on south model boundary
    12741285    LOGICAL ::  bc_lr_cyc =.TRUE.                                !< left-right boundary condition cyclic?
    12751286    LOGICAL ::  bc_lr_dirrad = .FALSE.                           !< left-right boundary condition dirichlet/radiation?
     
    12781289    LOGICAL ::  bc_ns_dirrad = .FALSE.                           !< north-south boundary condition dirichlet/radiation?
    12791290    LOGICAL ::  bc_ns_raddir = .FALSE.                           !< north-south boundary condition radiation/dirichlet?
     1291    LOGICAL ::  bc_radiation_l = .FALSE.                         !< radiation boundary condition for outflow at left domain boundary
     1292    LOGICAL ::  bc_radiation_n = .FALSE.                         !< radiation boundary condition for outflow at north domain boundary
     1293    LOGICAL ::  bc_radiation_r = .FALSE.                         !< radiation boundary condition for outflow at right domain boundary
     1294    LOGICAL ::  bc_radiation_s = .FALSE.                         !< radiation boundary condition for outflow at south domain boundary
    12801295    LOGICAL ::  calc_soil_moisture_during_spinup = .FALSE.       !< namelist parameter
    12811296    LOGICAL ::  call_microphysics_at_all_substeps = .FALSE.      !< namelist parameter
    12821297    LOGICAL ::  call_psolver_at_all_substeps = .TRUE.            !< namelist parameter
     1298    LOGICAL ::  child_domain  = .FALSE.                          !< flag indicating that model is nested in a parent domain
    12831299    LOGICAL ::  cloud_droplets = .FALSE.                         !< namelist parameter
    12841300    LOGICAL ::  cloud_physics = .FALSE.                          !< namelist parameter
     
    13101326    LOGICAL ::  first_call_mas = .TRUE.                          !< call mas only once per timestep
    13111327    LOGICAL ::  force_print_header = .FALSE.                     !< namelist parameter
    1312     LOGICAL ::  force_bound_l = .FALSE.                          !< flag indicating domain boundary on left side to set forcing boundary conditions
    1313     LOGICAL ::  force_bound_n = .FALSE.                          !< flag indicating domain boundary on north side to set forcing boundary conditions
    1314     LOGICAL ::  force_bound_r = .FALSE.                          !< flag indicating domain boundary on right side to set forcing boundary conditions
    1315     LOGICAL ::  force_bound_s = .FALSE.                          !< flag indicating domain boundary on south side to set forcing boundary conditions
    1316     LOGICAL ::  forcing = .FALSE.                                !< flag controlling forcing from large-scale model     
    13171328    LOGICAL ::  galilei_transformation = .FALSE.                 !< namelist parameter
    13181329    LOGICAL ::  humidity = .FALSE.                               !< namelist parameter
    13191330    LOGICAL ::  humidity_remote = .FALSE.                        !< switch for receiving near-surface humidity flux (atmosphere-ocean coupling)
    1320     LOGICAL ::  inflow_l = .FALSE.                               !< left domain boundary has non-cyclic inflow?
    1321     LOGICAL ::  inflow_n = .FALSE.                               !< north domain boundary has non-cyclic inflow?
    1322     LOGICAL ::  inflow_r = .FALSE.                               !< right domain boundary has non-cyclic inflow?
    1323     LOGICAL ::  inflow_s = .FALSE.                               !< south domain boundary has non-cyclic inflow?
    13241331    LOGICAL ::  large_scale_forcing = .FALSE.                    !< namelist parameter
    13251332    LOGICAL ::  large_scale_subsidence = .FALSE.                 !< namelist parameter
     
    13361343    LOGICAL ::  microphysics_seifert = .FALSE.                   !< use 2-moment Seifert and Beheng scheme
    13371344    LOGICAL ::  mg_switch_to_pe0 = .FALSE.                       !< internal multigrid switch for steering the ghost point exchange in case that data has been collected on PE0
    1338     LOGICAL ::  nest_bound_l = .FALSE.                           !< flag indicating nested domain boundary on left side
    1339     LOGICAL ::  nest_bound_n = .FALSE.                           !< flag indicating nested domain boundary on north side
    1340     LOGICAL ::  nest_bound_r = .FALSE.                           !< flag indicating nested domain boundary on right side
    1341     LOGICAL ::  nest_bound_s = .FALSE.                           !< flag indicating nested domain boundary on south side
    1342     LOGICAL ::  nest_domain  = .FALSE.                           !< domain is nested into a parent domain?
     1345    LOGICAL ::  nesting_offline = .FALSE.                        !< flag controlling offline nesting in COSMO model 
    13431346    LOGICAL ::  neutral = .FALSE.                                !< namelist parameter
    13441347    LOGICAL ::  nudging = .FALSE.                                !< namelist parameter
    13451348    LOGICAL ::  ocean = .FALSE.                                  !< namelist parameter
    1346     LOGICAL ::  outflow_l = .FALSE.                              !< left domain boundary has non-cyclic outflow?
    1347     LOGICAL ::  outflow_n = .FALSE.                              !< north domain boundary has non-cyclic outflow?
    1348     LOGICAL ::  outflow_r = .FALSE.                              !< right domain boundary has non-cyclic outflow?
    1349     LOGICAL ::  outflow_s = .FALSE.                              !< south domain boundary has non-cyclic outflow?
    13501349    LOGICAL ::  passive_scalar = .FALSE.                         !< namelist parameter
    13511350    LOGICAL ::  plant_canopy = .FALSE.                           !< switch for use of plant canopy model
  • TabularUnified palm/trunk/SOURCE/netcdf_data_input_mod.f90

    r3106 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Adjust input of dynamic driver according to revised Inifor version.
     23! Replace simulated_time by time_since_reference_point.
     24! Rename variables in mesoscale-offline nesting mode.
    2325!
    2426! Former revisions:
     
    199201!-- Define data type for nesting in larger-scale models like COSMO.
    200202!-- Data type comprises u, v, w, pt, and q at lateral and top boundaries.
    201     TYPE force_type
     203    TYPE nest_offl_type
    202204
    203205       CHARACTER(LEN=100), DIMENSION(:), ALLOCATABLE ::  var_names
     
    206208       INTEGER(iwp) ::  nzu    !< number of vertical levels on scalar grid in dynamic input file
    207209       INTEGER(iwp) ::  nzw    !< number of vertical levels on w grid in dynamic input file
    208        INTEGER(iwp) ::  tind   !< time index for reference time in large-scale forcing data
    209        INTEGER(iwp) ::  tind_p !< time index for following time in large-scale forcing data
     210       INTEGER(iwp) ::  tind   !< time index for reference time in mesoscale-offline nesting
     211       INTEGER(iwp) ::  tind_p !< time index for following time in mesoscale-offline nesting
    210212
    211213       LOGICAL      ::  init         = .FALSE.
    212        LOGICAL      ::  interpolated = .FALSE.
    213214       LOGICAL      ::  from_file    = .FALSE.
    214215
     
    251252       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  pt_top   !< potentital temperautre at top boundary
    252253
    253     END TYPE force_type
     254    END TYPE nest_offl_type
    254255
    255256    TYPE init_type
     
    474475    TYPE(dims_xy)    ::  dim_static  !< data structure for x, y-dimension in static input file
    475476
    476     TYPE(force_type) ::  force     !< data structure for data input at lateral and top boundaries (provided by Inifor)
     477    TYPE(nest_offl_type) ::  nest_offl  !< data structure for data input at lateral and top boundaries (provided by Inifor) 
    477478
    478479    TYPE(init_type) ::  init_3d    !< data structure for the initialization of the 3D flow and soil fields
     
    606607!-- Public variables
    607608    PUBLIC albedo_pars_f, albedo_type_f, basal_area_density_f, buildings_f,    &
    608            building_id_f, building_pars_f, building_type_f, force, init_3d,    &
     609           building_id_f, building_pars_f, building_type_f, init_3d,           &
    609610           init_model, input_file_static, input_pids_static,                   &
    610            input_pids_dynamic, leaf_area_density_f,                            &
     611           input_pids_dynamic, leaf_area_density_f, nest_offl,                 &
    611612           pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f,       &
    612613           root_area_density_lad_f, root_area_density_lsm_f, soil_pars_f,      &
     
    719720!--    sun-zenith angles. To avoid this, longitude and latitude in each model
    720721!--    domain will be set to the values of the root model. Please note, this
    721 !--    synchronization is required already here.
     722!--    synchronization is required already here. 
    722723#if defined( __parallel )
    723724       CALL MPI_BCAST( init_model%latitude,  1, MPI_REAL, 0,                   &
     
    726727                       MPI_COMM_WORLD, ierr )
    727728#endif
    728 
    729729
    730730    END SUBROUTINE netcdf_data_input_init
     
    20572057
    20582058       USE arrays_3d,                                                          &
    2059            ONLY:  q, pt, u, v, w
     2059           ONLY:  q, pt, u, v, w, zu, zw
    20602060
    20612061       USE control_parameters,                                                 &
    2062            ONLY:  bc_lr_cyc, bc_ns_cyc, forcing, humidity, land_surface,       &
    2063                   message_string, neutral, surface_pressure
     2062           ONLY:  bc_lr_cyc, bc_ns_cyc, humidity, land_surface, message_string,&
     2063                  nesting_offline, neutral, surface_pressure
    20642064
    20652065       USE indices,                                                            &
     
    21192119       CALL get_dimension_length( id_dynamic, init_3d%nzu, 'z'     )
    21202120       CALL get_dimension_length( id_dynamic, init_3d%nzw, 'zw'    )
    2121        CALL get_dimension_length( id_dynamic, init_3d%nzs, 'depth' )
     2121       CALL get_dimension_length( id_dynamic, init_3d%nzs, 'zsoil' )
    21222122!
    21232123!--    Read also the horizontal dimensions. These are used just used fo
     
    21422142       ENDIF
    21432143
    2144        IF ( init_3d%nzu-1 /= nz )  THEN
     2144       IF ( init_3d%nzu /= nz )  THEN
    21452145          message_string = 'Number of inifor vertical grid points ' //         &
    21462146                           'does not match the number of numeric grid '//      &
     
    21592159          CALL get_variable( id_dynamic, 'zw', init_3d%zw_atmos )
    21602160       ENDIF
    2161        IF ( check_existence( var_names, 'depth' ) )  THEN
     2161       IF ( check_existence( var_names, 'zsoil' ) )  THEN
    21622162          ALLOCATE( init_3d%z_soil(1:init_3d%nzs) )
    2163           CALL get_variable( id_dynamic, 'depth', init_3d%z_soil )
    2164        ENDIF
    2165 !
    2166 !--    Read initial geostrophic wind components at t = 0 (index 1 in file).
    2167 !        IF ( check_existence( var_names, 'tend_ug' ) )  THEN
     2163          CALL get_variable( id_dynamic, 'zsoil', init_3d%z_soil )
     2164       ENDIF
     2165!
     2166!--    Check for consistency between vertical coordinates in dynamic
     2167!--    driver and numeric grid.
     2168!--    Please note, depending on compiler options both may be
     2169!--    equal up to a certain threshold, and differences between
     2170!--    the numeric grid and vertical coordinate in the driver can built-
     2171!--    up to 10E-1-10E-0 m. For this reason, the check is performed not
     2172!--    for exactly matching values.
     2173       IF ( ANY( ABS( zu(1:nzt)   - init_3d%zu_atmos(1:init_3d%nzu) )    &
     2174                      > 10E-1 )  .OR.                                    &
     2175            ANY( ABS( zw(1:nzt-1) - init_3d%zw_atmos(1:init_3d%nzw) )    &
     2176                      > 10E-1 ) )  THEN
     2177          message_string = 'Vertical grid in dynamic driver does not '// &
     2178                           'match the numeric grid.'
     2179          CALL message( 'netcdf_data_input_mod', 'NDI003', 1, 2, 0, 6, 0 )
     2180       ENDIF
     2181!
     2182!--    Read initial geostrophic wind components at
     2183!--    t = 0 (index 1 in file).
    21682184       IF ( check_existence( var_names, 'ls_forcing_ug' ) )  THEN
    21692185          ALLOCATE( init_3d%ug_init(nzb:nzt+1) )
    2170 !           CALL get_variable_pr( id_dynamic, 'tend_ug', 1,                      &
    2171 !                                 init_3d%ug_init )
    2172           CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1,                &
    2173                                 init_3d%ug_init )
     2186          init_3d%ug_init = 0.0_wp
     2187
     2188          CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', 1,          &
     2189                                init_3d%ug_init(1:nzt) )
     2190!
     2191!--       Set top-boundary condition (Neumann)
     2192          init_3d%ug_init(nzt+1) = init_3d%ug_init(nzt)
     2193
    21742194          init_3d%from_file_ug = .TRUE.
    21752195       ELSE
    21762196          init_3d%from_file_ug = .FALSE.
    21772197       ENDIF
    2178 !        IF ( check_existence( var_names, 'tend_vg' ) )  THEN
    21792198       IF ( check_existence( var_names, 'ls_forcing_vg' ) )  THEN
    21802199          ALLOCATE( init_3d%vg_init(nzb:nzt+1) )
    2181 !           CALL get_variable_pr( id_dynamic, 'tend_vg', 1,                      &
    2182 !                                 init_3d%vg_init )
    2183           CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1,                &
    2184                                 init_3d%vg_init )
     2200          init_3d%vg_init = 0.0_wp
     2201
     2202          CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', 1,          &
     2203                                init_3d%vg_init(1:nzt) )
     2204!
     2205!--       Set top-boundary condition (Neumann)
     2206          init_3d%vg_init(nzt+1) = init_3d%vg_init(nzt)
     2207
    21852208          init_3d%from_file_vg = .TRUE.
    21862209       ELSE
     
    21952218!--    into separate loops. 
    21962219!--    Read u-component
    2197        IF ( check_existence( var_names, 'init_u' ) )  THEN
     2220       IF ( check_existence( var_names, 'init_atmosphere_u' ) )  THEN
    21982221!
    21992222!--       Read attributes for the fill value and level-of-detail
    22002223          CALL get_attribute( id_dynamic, char_fill, init_3d%fill_u,           &
    2201                               .FALSE., 'init_u' )
     2224                              .FALSE., 'init_atmosphere_u' )
    22022225          CALL get_attribute( id_dynamic, char_lod, init_3d%lod_u,             &
    2203                               .FALSE., 'init_u' )
     2226                              .FALSE., 'init_atmosphere_u' )
    22042227!
    22052228!--       level-of-detail 1 - read initialization profile
     
    22082231             init_3d%u_init = 0.0_wp
    22092232
    2210              CALL get_variable( id_dynamic, 'init_u',                          &
    2211                                 init_3d%u_init(nzb+1:nzt+1) )
     2233             CALL get_variable( id_dynamic, 'init_atmosphere_u',               &
     2234                                init_3d%u_init(nzb+1:nzt) )
     2235!
     2236!--          Set top-boundary condition (Neumann)
     2237             init_3d%u_init(nzt+1) = init_3d%u_init(nzt)
    22122238!
    22132239!--       level-of-detail 2 - read 3D initialization data
    22142240          ELSEIF ( init_3d%lod_u == 2 )  THEN
    2215 
    2216              CALL get_variable( id_dynamic, 'init_u',                          &
    2217                                 u(nzb+1:nzt+1,nys:nyn,nxlu:nxr),               &
     2241             CALL get_variable( id_dynamic, 'init_atmosphere_u',               &
     2242                                u(nzb+1:nzt,nys:nyn,nxlu:nxr),                 &
    22182243                                nxlu, nys+1, nzb+1,                            &
    22192244                                nxr-nxlu+1, nyn-nys+1, init_3d%nzu,            &
    22202245                                dynamic_3d )
     2246!
     2247!--          Set value at leftmost model grid point nxl = 0. This is because
     2248!--          Inifor provides data only from 1:nx-1 since it assumes non-cyclic
     2249!--          conditions.
     2250             IF ( nxl == 0 )                                                   &
     2251                u(nzb+1:nzt,nys:nyn,nxl) = u(nzb+1:nzt,nys:nyn,nxlu)
     2252!
     2253!--          Set bottom and top-boundary
     2254             u(nzb,:,:)   = u(nzb+1,:,:)
     2255             u(nzt+1,:,:) = u(nzt,:,:)
     2256             
    22212257          ENDIF
    22222258          init_3d%from_file_u = .TRUE.
     
    22242260!
    22252261!--    Read v-component
    2226        IF ( check_existence( var_names, 'init_v' ) )  THEN
     2262       IF ( check_existence( var_names, 'init_atmosphere_v' ) )  THEN
    22272263!
    22282264!--       Read attributes for the fill value and level-of-detail
    22292265          CALL get_attribute( id_dynamic, char_fill, init_3d%fill_v,           &
    2230                               .FALSE., 'init_v' )
     2266                              .FALSE., 'init_atmosphere_v' )
    22312267          CALL get_attribute( id_dynamic, char_lod, init_3d%lod_v,             &
    2232                               .FALSE., 'init_v' )
     2268                              .FALSE., 'init_atmosphere_v' )
    22332269!
    22342270!--       level-of-detail 1 - read initialization profile
     
    22372273             init_3d%v_init = 0.0_wp
    22382274
    2239              CALL get_variable( id_dynamic, 'init_v',                          &
    2240                                 init_3d%v_init(nzb+1:nzt+1) )
    2241 
     2275             CALL get_variable( id_dynamic, 'init_atmosphere_v',               &
     2276                                init_3d%v_init(nzb+1:nzt) )
     2277!
     2278!--          Set top-boundary condition (Neumann)
     2279             init_3d%v_init(nzt+1) = init_3d%v_init(nzt)
    22422280!
    22432281!--       level-of-detail 2 - read 3D initialization data
    22442282          ELSEIF ( init_3d%lod_v == 2 )  THEN
    2245 
    2246              CALL get_variable( id_dynamic, 'init_v',                          &
    2247                                 v(nzb+1:nzt+1,nysv:nyn,nxl:nxr),               &
     2283         
     2284             CALL get_variable( id_dynamic, 'init_atmosphere_v',               &
     2285                                v(nzb+1:nzt,nysv:nyn,nxl:nxr),                 &
    22482286                                nxl+1, nysv, nzb+1,                            &
    22492287                                nxr-nxl+1, nyn-nysv+1, init_3d%nzu,            &
    22502288                                dynamic_3d )
     2289!
     2290!--          Set value at southmost model grid point nys = 0. This is because
     2291!--          Inifor provides data only from 1:ny-1 since it assumes non-cyclic
     2292!--          conditions.
     2293             IF ( nys == 0 )                                                   &
     2294                v(nzb+1:nzt,nys,nxl:nxr) = v(nzb+1:nzt,nysv,nxl:nxr)                               
     2295!
     2296!--          Set bottom and top-boundary
     2297             v(nzb,:,:)   = v(nzb+1,:,:)
     2298             v(nzt+1,:,:) = v(nzt,:,:)
    22512299             
    22522300          ENDIF
     
    22552303!
    22562304!--    Read w-component
    2257        IF ( check_existence( var_names, 'init_w' ) )  THEN
     2305       IF ( check_existence( var_names, 'init_atmosphere_w' ) )  THEN
    22582306!
    22592307!--       Read attributes for the fill value and level-of-detail
    22602308          CALL get_attribute( id_dynamic, char_fill, init_3d%fill_w,           &
    2261                               .FALSE., 'init_w' )
     2309                              .FALSE., 'init_atmosphere_w' )
    22622310          CALL get_attribute( id_dynamic, char_lod, init_3d%lod_w,             &
    2263                               .FALSE., 'init_w' )
     2311                              .FALSE., 'init_atmosphere_w' )
    22642312!
    22652313!--       level-of-detail 1 - read initialization profile
     
    22682316             init_3d%w_init = 0.0_wp
    22692317
    2270              CALL get_variable( id_dynamic, 'init_w',                          &
    2271                                 init_3d%w_init(nzb+1:nzt) )
    2272 
     2318             CALL get_variable( id_dynamic, 'init_atmosphere_w',               &
     2319                                init_3d%w_init(nzb+1:nzt-1) )
     2320!
     2321!--          Set top-boundary condition (Neumann)
     2322             init_3d%w_init(nzt:nzt+1) = init_3d%w_init(nzt-1)
    22732323!
    22742324!--       level-of-detail 2 - read 3D initialization data
    22752325          ELSEIF ( init_3d%lod_w == 2 )  THEN
    22762326
    2277              CALL get_variable( id_dynamic, 'init_w',                           &
    2278                                 w(nzb+1:nzt,nys:nyn,nxl:nxr),                   &
     2327             CALL get_variable( id_dynamic, 'init_atmosphere_w',                &
     2328                                w(nzb+1:nzt-1,nys:nyn,nxl:nxr),                 &
    22792329                                nxl+1, nys+1, nzb+1,                            &
    22802330                                nxr-nxl+1, nyn-nys+1, init_3d%nzw,              &
    22812331                                dynamic_3d )
     2332!
     2333!--          Set bottom and top-boundary                               
     2334             w(nzb,:,:)   = 0.0_wp 
     2335             w(nzt,:,:)   = w(nzt-1,:,:)
     2336             w(nzt+1,:,:) = w(nzt-1,:,:)
    22822337
    22832338          ENDIF
     
    22872342!--    Read potential temperature
    22882343       IF ( .NOT. neutral )  THEN
    2289           IF ( check_existence( var_names, 'init_pt' ) )  THEN
     2344          IF ( check_existence( var_names, 'init_atmosphere_pt' ) )  THEN
    22902345!
    22912346!--          Read attributes for the fill value and level-of-detail
    22922347             CALL get_attribute( id_dynamic, char_fill, init_3d%fill_pt,       &
    2293                                  .FALSE., 'init_pt' )
     2348                                 .FALSE., 'init_atmosphere_pt' )
    22942349             CALL get_attribute( id_dynamic, char_lod, init_3d%lod_pt,         &
    2295                                  .FALSE., 'init_pt' )
     2350                                 .FALSE., 'init_atmosphere_pt' )
    22962351!
    22972352!--          level-of-detail 1 - read initialization profile
     
    22992354                ALLOCATE( init_3d%pt_init(nzb:nzt+1) )
    23002355
    2301                 CALL get_variable( id_dynamic, 'init_pt',                      &
    2302                                    init_3d%pt_init(nzb+1:nzt+1) )
    2303 !
    2304 !--             Set Neumann surface boundary condition for initial profil
    2305                 init_3d%pt_init(nzb) = init_3d%pt_init(nzb+1)
     2356                CALL get_variable( id_dynamic, 'init_atmosphere_pt',           &
     2357                                   init_3d%pt_init(nzb+1:nzt) )
     2358!
     2359!--             Set Neumann top and surface boundary condition for initial
     2360!--             profil
     2361                init_3d%pt_init(nzb)   = init_3d%pt_init(nzb+1)
     2362                init_3d%pt_init(nzt+1) = init_3d%pt_init(nzt)
    23062363!
    23072364!--          level-of-detail 2 - read 3D initialization data
    23082365             ELSEIF ( init_3d%lod_pt == 2 )  THEN
    23092366
    2310                 CALL get_variable( id_dynamic, 'init_pt',                      &
    2311                                    pt(nzb+1:nzt+1,nys:nyn,nxl:nxr),            &
     2367                CALL get_variable( id_dynamic, 'init_atmosphere_pt',           &
     2368                                   pt(nzb+1:nzt,nys:nyn,nxl:nxr),              &
    23122369                                   nxl+1, nys+1, nzb+1,                        &
    23132370                                   nxr-nxl+1, nyn-nys+1, init_3d%nzu,          &
    23142371                                   dynamic_3d )
    2315 
     2372                                   
     2373!
     2374!--             Set bottom and top-boundary
     2375                pt(nzb,:,:)   = pt(nzb+1,:,:)
     2376                pt(nzt+1,:,:) = pt(nzt,:,:)             
    23162377
    23172378             ENDIF
     
    23222383!--    Read mixing ratio
    23232384       IF ( humidity )  THEN
    2324           IF ( check_existence( var_names, 'init_qv' ) )  THEN
     2385          IF ( check_existence( var_names, 'init_atmosphere_qv' ) )  THEN
    23252386!
    23262387!--          Read attributes for the fill value and level-of-detail
    23272388             CALL get_attribute( id_dynamic, char_fill, init_3d%fill_q,        &
    2328                                  .FALSE., 'init_qv' )
     2389                                 .FALSE., 'init_atmosphere_qv' )
    23292390             CALL get_attribute( id_dynamic, char_lod, init_3d%lod_q,          &
    2330                                  .FALSE., 'init_qv' )
     2391                                 .FALSE., 'init_atmosphere_qv' )
    23312392!
    23322393!--          level-of-detail 1 - read initialization profile
     
    23342395                ALLOCATE( init_3d%q_init(nzb:nzt+1) )
    23352396
    2336                 CALL get_variable( id_dynamic, 'init_qv',                      &
    2337                                    init_3d%q_init(nzb+1:nzt+1) )
    2338 !
    2339 !--             Set Neumann surface boundary condition for initial profil
    2340                 init_3d%q_init(nzb) = init_3d%q_init(nzb+1)
    2341 
     2397                CALL get_variable( id_dynamic, 'init_atmosphere_qv',           &
     2398                                    init_3d%q_init(nzb+1:nzt) )
     2399!
     2400!--             Set bottom and top boundary condition (Neumann)
     2401                init_3d%q_init(nzb)   = init_3d%q_init(nzb+1)
     2402                init_3d%q_init(nzt+1) = init_3d%q_init(nzt)
    23422403!
    23432404!--          level-of-detail 2 - read 3D initialization data
    23442405             ELSEIF ( init_3d%lod_q == 2 )  THEN
    23452406             
    2346                 CALL get_variable( id_dynamic, 'init_qv',                      &
    2347                                    q(nzb+1:nzt+1,nys:nyn,nxl:nxr),             &
     2407                CALL get_variable( id_dynamic, 'init_atmosphere_qv',           &
     2408                                   q(nzb+1:nzt,nys:nyn,nxl:nxr),               &
    23482409                                   nxl+1, nys+1, nzb+1,                        &
    23492410                                   nxr-nxl+1, nyn-nys+1, init_3d%nzu,          &
    23502411                                   dynamic_3d )
    2351 
    2352 
    2353 
     2412                                   
     2413!
     2414!--             Set bottom and top-boundary
     2415                q(nzb,:,:)   = q(nzb+1,:,:)
     2416                q(nzt+1,:,:) = q(nzt,:,:)
     2417               
    23542418             ENDIF
    23552419             init_3d%from_file_q = .TRUE.
     
    23822446
    23832447               CALL get_variable( id_dynamic, 'init_soil_m',                   &   
    2384                                   init_3d%msoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
    2385                                   nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
     2448                                init_3d%msoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
     2449                                nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
    23862450
    23872451             ENDIF
     
    24132477               
    24142478                CALL get_variable( id_dynamic, 'init_soil_t',                  &   
    2415                                   init_3d%tsoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
    2416                                   nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
     2479                                init_3d%tsoil(0:init_3d%nzs-1,nys:nyn,nxl:nxr),&
     2480                                nxl, nxr, nys, nyn, 0, init_3d%nzs-1 )
    24172481             ENDIF
    24182482             init_3d%from_file_tsoil = .TRUE.
     
    24392503          ENDIF
    24402504          IF ( .NOT. check_passed )  THEN
    2441              message_string = 'NetCDF input for u_init must not contain ' //   &
    2442                               'any _FillValues'
     2505             message_string = 'NetCDF input for init_atmosphere_u must ' //    &
     2506                              'not contain any _FillValues'
    24432507             CALL message( 'netcdf_data_input_mod', 'NDI004', 2, 2, 0, 6, 0 )
    24442508          ENDIF
     
    24552519          ENDIF
    24562520          IF ( .NOT. check_passed )  THEN
    2457              message_string = 'NetCDF input for v_init must not contain ' //   &
    2458                               'any _FillValues'
     2521             message_string = 'NetCDF input for init_atmosphere_v must ' //    &
     2522                              'not contain any _FillValues'
    24592523             CALL message( 'netcdf_data_input_mod', 'NDI005', 2, 2, 0, 6, 0 )
    24602524          ENDIF
     
    24712535          ENDIF
    24722536          IF ( .NOT. check_passed )  THEN
    2473              message_string = 'NetCDF input for w_init must not contain ' //   &
    2474                               'any _FillValues'
     2537             message_string = 'NetCDF input for init_atmosphere_w must ' //    &
     2538                              'not contain any _FillValues'
    24752539             CALL message( 'netcdf_data_input_mod', 'NDI006', 2, 2, 0, 6, 0 )
    24762540          ENDIF
     
    24872551          ENDIF
    24882552          IF ( .NOT. check_passed )  THEN
    2489              message_string = 'NetCDF input for pt_init must not contain ' //  &
    2490                               'any _FillValues'
     2553             message_string = 'NetCDF input for init_atmosphere_pt must ' //   &
     2554                              'not contain any _FillValues'
    24912555             CALL message( 'netcdf_data_input_mod', 'NDI007', 2, 2, 0, 6, 0 )
    24922556          ENDIF
     
    25032567          ENDIF
    25042568          IF ( .NOT. check_passed )  THEN
    2505              message_string = 'NetCDF input for q_init must not contain ' //   &
    2506                               'any _FillValues'
     2569             message_string = 'NetCDF input for init_atmosphere_q must ' //    &
     2570                              'not contain any _FillValues'
    25072571             CALL message( 'netcdf_data_input_mod', 'NDI008', 2, 2, 0, 6, 0 )
    25082572          ENDIF
     
    25242588
    25252589       USE control_parameters,                                                 &
    2526            ONLY:  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,          &
    2527                   force_bound_r, force_bound_s,                                &
    2528                   forcing, humidity, message_string, neutral, simulated_time
    2529 
     2590           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
     2591                  bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, humidity,              &
     2592                  message_string, neutral, nesting_offline,                    &
     2593                  time_since_reference_point
    25302594
    25312595       USE indices,                                                            &
     
    25332597
    25342598       IMPLICIT NONE
    2535 
    2536        LOGICAL      ::  dynamic_3d = .TRUE. !< flag indicating that 3D data is read from dynamic file
    25372599       
    25382600       INTEGER(iwp) ::  i          !< running index along x-direction
     
    25452607       REAL(wp) ::  dum           !< dummy variable to skip columns while reading topography file
    25462608
    2547        force%from_file = MERGE( .TRUE., .FALSE., input_pids_dynamic )
     2609       nest_offl%from_file = MERGE( .TRUE., .FALSE., input_pids_dynamic )
    25482610!
    25492611!--    Skip input if no forcing from larger-scale models is applied.
    2550        IF ( .NOT. forcing )  RETURN
     2612       IF ( .NOT. nesting_offline )  RETURN
    25512613
    25522614!
     
    25602622                            TRIM( coupling_char ), id_dynamic )
    25612623!
    2562 !--    Initialize INIFOR forcing.
    2563        IF ( .NOT. force%init )  THEN
     2624!--    Initialize INIFOR forcing. 
     2625       IF ( .NOT. nest_offl%init )  THEN
    25642626!
    25652627!--       At first, inquire all variable names.
     
    25672629!
    25682630!--       Allocate memory to store variable names.
    2569           ALLOCATE( force%var_names(1:num_vars) )
    2570           CALL inquire_variable_names( id_dynamic, force%var_names )
     2631          ALLOCATE( nest_offl%var_names(1:num_vars) )
     2632          CALL inquire_variable_names( id_dynamic, nest_offl%var_names )
    25712633!
    25722634!--       Read time dimension, allocate memory and finally read time array
    2573           CALL get_dimension_length( id_dynamic, force%nt, 'time' )
    2574 
    2575           IF ( check_existence( force%var_names, 'time' ) )  THEN
    2576              ALLOCATE( force%time(0:force%nt-1) )
    2577              CALL get_variable( id_dynamic, 'time', force%time )
     2635          CALL get_dimension_length( id_dynamic, nest_offl%nt, 'time' )
     2636
     2637          IF ( check_existence( nest_offl%var_names, 'time' ) )  THEN
     2638             ALLOCATE( nest_offl%time(0:nest_offl%nt-1) )
     2639             CALL get_variable( id_dynamic, 'time', nest_offl%time )
    25782640          ENDIF
    25792641!
    25802642!--       Read vertical dimension of scalar und w grid
    2581           CALL get_dimension_length( id_dynamic, force%nzu, 'z' )
    2582           CALL get_dimension_length( id_dynamic, force%nzw, 'zw' )
    2583 
    2584           IF ( check_existence( force%var_names, 'z' ) )  THEN
    2585              ALLOCATE( force%zu_atmos(1:force%nzu) )
    2586              CALL get_variable( id_dynamic, 'z', force%zu_atmos )
    2587           ENDIF
    2588           IF ( check_existence( force%var_names, 'zw' ) )  THEN
    2589              ALLOCATE( force%zw_atmos(1:force%nzw) )
    2590              CALL get_variable( id_dynamic, 'zw', force%zw_atmos )
     2643          CALL get_dimension_length( id_dynamic, nest_offl%nzu, 'z' )
     2644          CALL get_dimension_length( id_dynamic, nest_offl%nzw, 'zw' )
     2645
     2646          IF ( check_existence( nest_offl%var_names, 'z' ) )  THEN
     2647             ALLOCATE( nest_offl%zu_atmos(1:nest_offl%nzu) )
     2648             CALL get_variable( id_dynamic, 'z', nest_offl%zu_atmos )
     2649          ENDIF
     2650          IF ( check_existence( nest_offl%var_names, 'zw' ) )  THEN
     2651             ALLOCATE( nest_offl%zw_atmos(1:nest_offl%nzw) )
     2652             CALL get_variable( id_dynamic, 'zw', nest_offl%zw_atmos )
    25912653          ENDIF
    25922654
    25932655!
    25942656!--       Read surface pressure
    2595           IF ( check_existence( force%var_names,                               &
    2596                             'surface_forcing_surface_pressure' ) )  THEN
    2597              ALLOCATE( force%surface_pressure(0:force%nt-1) )
     2657          IF ( check_existence( nest_offl%var_names,                           &
     2658                                'surface_forcing_surface_pressure' ) )  THEN
     2659             ALLOCATE( nest_offl%surface_pressure(0:nest_offl%nt-1) )
    25982660             CALL get_variable( id_dynamic,                                    &
    25992661                                'surface_forcing_surface_pressure',            &
    2600                                 force%surface_pressure )
     2662                                nest_offl%surface_pressure )
    26012663          ENDIF
    26022664!
    26032665!--       Set control flag to indicate that initialization is already done
    2604           force%init = .TRUE.
     2666          nest_offl%init = .TRUE.
    26052667
    26062668       ENDIF
     
    26102672!--    @todo: At the moment time, in INIFOR and simulated time correspond
    26112673!--           to each other. If required, adjust to daytime.
    2612        force%tind = MINLOC( ABS( force%time - simulated_time ), DIM = 1 )      &
    2613                     - 1
    2614        force%tind_p = force%tind + 1       
     2674       nest_offl%tind = MINLOC( ABS( nest_offl%time -                          &
     2675                                     time_since_reference_point ), DIM = 1 )   &
     2676                        - 1
     2677       nest_offl%tind_p = nest_offl%tind + 1       
    26152678!
    26162679!--    Read geostrophic wind components. In case of forcing, this is only
    26172680!--    required if cyclic boundary conditions are applied.
    26182681       IF ( bc_lr_cyc  .AND.  bc_ns_cyc )  THEN
    2619           DO  t = force%tind, force%tind_p
     2682          DO  t = nest_offl%tind, nest_offl%tind_p
    26202683!              CALL get_variable_pr( id_dynamic, 'tend_ug', t+1,           &
    2621 !                                    force%ug(t-force%tind,:) )
     2684!                                    nest_offl%ug(t-nest_offl%tind,:) )
    26222685!              CALL get_variable_pr( id_dynamic, 'tend_vg', t+1,           &
    2623 !                                    force%ug(t-force%tind,:) )
     2686!                                    nest_offl%ug(t-nest_offl%tind,:) )
    26242687             CALL get_variable_pr( id_dynamic, 'ls_forcing_ug', t+1,           &
    2625                                    force%ug(t-force%tind,:) )
     2688                                   nest_offl%ug(t-nest_offl%tind,:) )
    26262689             CALL get_variable_pr( id_dynamic, 'ls_forcing_vg', t+1,           &
    2627                                    force%ug(t-force%tind,:) )
     2690                                   nest_offl%ug(t-nest_offl%tind,:) )
    26282691          ENDDO
    26292692       ENDIF
     
    26332696!--    For the v-component, the data starts at nysv, while for the other
    26342697!--    quantities the data starts at nys. This is equivalent at the north
    2635 !--    and south domain boundary for the u-component.
    2636        IF ( force_bound_l )  THEN
     2698!--    and south domain boundary for the u-component.
     2699!--    Further, lateral data is not accessed by parallel IO, indicated by the
     2700!--    last passed flag in the subroutine get_variable(). This is because
     2701!--    not every PE participates in this collective blocking read operation.
     2702       IF ( bc_dirichlet_l )  THEN
    26372703          CALL get_variable( id_dynamic, 'ls_forcing_left_u',                  &
    2638                            force%u_left(0:1,nzb+1:nzt+1,nys:nyn),              &
    2639                            nys+1, nzb+1, force%tind+1,                         &
    2640                            nyn-nys+1, force%nzu, 2, dynamic_3d )
    2641          
     2704                           nest_offl%u_left(0:1,nzb+1:nzt,nys:nyn),            &
     2705                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2706                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
     2707     
    26422708          CALL get_variable( id_dynamic, 'ls_forcing_left_v',                  &
    2643                            force%v_left(0:1,nzb+1:nzt+1,nysv:nyn),             &
    2644                            nysv, nzb+1, force%tind+1,                          &
    2645                            nyn-nysv+1, force%nzu, 2, dynamic_3d )
     2709                           nest_offl%v_left(0:1,nzb+1:nzt,nysv:nyn),           &
     2710                           nysv, nzb+1, nest_offl%tind+1,                      &
     2711                           nyn-nysv+1, nest_offl%nzu, 2, .FALSE. )
    26462712
    26472713          CALL get_variable( id_dynamic, 'ls_forcing_left_w',                  &
    2648                            force%w_left(0:1,nzb+1:nzt,nys:nyn),                &
    2649                            nys+1, nzb+1, force%tind+1,                         &
    2650                            nyn-nys+1, force%nzw, 2, dynamic_3d )
     2714                           nest_offl%w_left(0:1,nzb+1:nzt-1,nys:nyn),          &
     2715                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2716                           nyn-nys+1, nest_offl%nzw, 2, .FALSE. )
    26512717
    26522718          IF ( .NOT. neutral )  THEN
    26532719             CALL get_variable( id_dynamic, 'ls_forcing_left_pt',              &
    2654                            force%pt_left(0:1,nzb+1:nzt+1,nys:nyn),             &
    2655                            nys+1, nzb+1, force%tind+1,                         &
    2656                            nyn-nys+1, force%nzu, 2, dynamic_3d )
    2657           ENDIF
     2720                           nest_offl%pt_left(0:1,nzb+1:nzt,nys:nyn),           &
     2721                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2722                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
     2723          ENDIF
     2724
    26582725          IF ( humidity )  THEN
    26592726             CALL get_variable( id_dynamic, 'ls_forcing_left_qv',              &
    2660                            force%q_left(0:1,nzb+1:nzt+1,nys:nyn),              &
    2661                            nys+1, nzb+1, force%tind+1,                         &
    2662                            nyn-nys+1, force%nzu, 2, dynamic_3d )
    2663           ENDIF
    2664        ENDIF
    2665 
    2666        IF ( force_bound_r )  THEN
     2727                           nest_offl%q_left(0:1,nzb+1:nzt,nys:nyn),            &
     2728                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2729                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
     2730          ENDIF
     2731
     2732       ENDIF
     2733
     2734       IF ( bc_dirichlet_r )  THEN
    26672735          CALL get_variable( id_dynamic, 'ls_forcing_right_u',                 &
    2668                            force%u_right(0:1,nzb+1:nzt+1,nys:nyn),             &
    2669                            nys+1, nzb+1, force%tind+1,                         &
    2670                            nyn-nys+1, force%nzu, 2, dynamic_3d )
     2736                           nest_offl%u_right(0:1,nzb+1:nzt,nys:nyn),           &
     2737                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2738                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
    26712739                           
    26722740          CALL get_variable( id_dynamic, 'ls_forcing_right_v',                 &
    2673                            force%v_right(0:1,nzb+1:nzt+1,nysv:nyn),            &
    2674                            nysv, nzb+1, force%tind+1,                          &
    2675                            nyn-nysv+1, force%nzu, 2, dynamic_3d )
     2741                           nest_offl%v_right(0:1,nzb+1:nzt,nysv:nyn),          &
     2742                           nysv, nzb+1, nest_offl%tind+1,                      &
     2743                           nyn-nysv+1, nest_offl%nzu, 2, .FALSE. )
    26762744                           
    26772745          CALL get_variable( id_dynamic, 'ls_forcing_right_w',                 &
    2678                            force%w_right(0:1,nzb+1:nzt,nys:nyn),               &
    2679                            nys+1, nzb+1, force%tind+1,                         &
    2680                            nyn-nys+1, force%nzw, 2, dynamic_3d )
     2746                           nest_offl%w_right(0:1,nzb+1:nzt-1,nys:nyn),         &
     2747                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2748                           nyn-nys+1, nest_offl%nzw, 2, .FALSE. )
    26812749                           
    26822750          IF ( .NOT. neutral )  THEN
    26832751             CALL get_variable( id_dynamic, 'ls_forcing_right_pt',             &
    2684                            force%pt_right(0:1,nzb+1:nzt+1,nys:nyn),            &
    2685                            nys+1, nzb+1, force%tind+1,                         &
    2686                            nyn-nys+1, force%nzu, 2, dynamic_3d )
     2752                           nest_offl%pt_right(0:1,nzb+1:nzt,nys:nyn),          &
     2753                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2754                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
    26872755          ENDIF
    26882756          IF ( humidity )  THEN
    26892757             CALL get_variable( id_dynamic, 'ls_forcing_right_qv',             &
    2690                            force%q_right(0:1,nzb+1:nzt+1,nys:nyn),             &
    2691                            nys+1, nzb+1, force%tind+1,                         &
    2692                            nyn-nys+1, force%nzu, 2, dynamic_3d )
    2693           ENDIF
    2694        ENDIF
    2695 
    2696        IF ( force_bound_n )  THEN
     2758                           nest_offl%q_right(0:1,nzb+1:nzt,nys:nyn),           &
     2759                           nys+1, nzb+1, nest_offl%tind+1,                     &
     2760                           nyn-nys+1, nest_offl%nzu, 2, .FALSE. )
     2761          ENDIF
     2762       ENDIF
     2763
     2764       IF ( bc_dirichlet_n )  THEN
    26972765       
    26982766          CALL get_variable( id_dynamic, 'ls_forcing_north_u',                 &
    2699                            force%u_north(0:1,nzb+1:nzt+1,nxlu:nxr),            &
    2700                            nxlu, nzb+1, force%tind+1,                          &
    2701                            nxr-nxlu+1, force%nzu, 2, dynamic_3d )
    2702 
     2767                           nest_offl%u_north(0:1,nzb+1:nzt,nxlu:nxr),          &
     2768                           nxlu, nzb+1, nest_offl%tind+1,                      &
     2769                           nxr-nxlu+1, nest_offl%nzu, 2, .FALSE. )
     2770                           
    27032771          CALL get_variable( id_dynamic, 'ls_forcing_north_v',                 &
    2704                            force%v_north(0:1,nzb+1:nzt+1,nxl:nxr),             &
    2705                            nxl+1, nzb+1, force%tind+1,                         &
    2706                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
     2772                           nest_offl%v_north(0:1,nzb+1:nzt,nxl:nxr),           &
     2773                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2774                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
    27072775                           
    27082776          CALL get_variable( id_dynamic, 'ls_forcing_north_w',                 &
    2709                            force%w_north(0:1,nzb+1:nzt,nxl:nxr),               &
    2710                            nxl+1, nzb+1, force%tind+1,                         &
    2711                            nxr-nxl+1, force%nzw, 2, dynamic_3d )
     2777                           nest_offl%w_north(0:1,nzb+1:nzt-1,nxl:nxr),         &
     2778                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2779                           nxr-nxl+1, nest_offl%nzw, 2, .FALSE. )
    27122780                           
    27132781          IF ( .NOT. neutral )  THEN
    27142782             CALL get_variable( id_dynamic, 'ls_forcing_north_pt',             &
    2715                            force%pt_north(0:1,nzb+1:nzt+1,nxl:nxr),            &
    2716                            nxl+1, nzb+1, force%tind+1,                         &
    2717                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
     2783                           nest_offl%pt_north(0:1,nzb+1:nzt,nxl:nxr),          &
     2784                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2785                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
    27182786          ENDIF
    27192787          IF ( humidity )  THEN
    27202788             CALL get_variable( id_dynamic, 'ls_forcing_north_qv',             &
    2721                            force%q_north(0:1,nzb+1:nzt+1,nxl:nxr),             &
    2722                            nxl+1, nzb+1, force%tind+1,                         &
    2723                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
    2724           ENDIF
    2725        ENDIF
    2726 
    2727        IF ( force_bound_s )  THEN
     2789                           nest_offl%q_north(0:1,nzb+1:nzt,nxl:nxr),           &
     2790                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2791                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
     2792          ENDIF
     2793       ENDIF
     2794
     2795       IF ( bc_dirichlet_s )  THEN
    27282796          CALL get_variable( id_dynamic, 'ls_forcing_south_u',                 &
    2729                            force%u_south(0:1,nzb+1:nzt+1,nxlu:nxr),            &
    2730                            nxlu, nzb+1, force%tind+1,                          &
    2731                            nxr-nxlu+1, force%nzu, 2, dynamic_3d )
     2797                           nest_offl%u_south(0:1,nzb+1:nzt,nxlu:nxr),          &
     2798                           nxlu, nzb+1, nest_offl%tind+1,                      &
     2799                           nxr-nxlu+1, nest_offl%nzu, 2, .FALSE. )
    27322800
    27332801          CALL get_variable( id_dynamic, 'ls_forcing_south_v',                 &
    2734                            force%v_south(0:1,nzb+1:nzt+1,nxl:nxr),             &
    2735                            nxl+1, nzb+1, force%tind+1,                         &
    2736                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
     2802                           nest_offl%v_south(0:1,nzb+1:nzt,nxl:nxr),           &
     2803                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2804                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
    27372805                           
    27382806          CALL get_variable( id_dynamic, 'ls_forcing_south_w',                 &
    2739                            force%w_south(0:1,nzb+1:nzt,nxl:nxr),               &
    2740                            nxl+1, nzb+1, force%tind+1,                         &
    2741                            nxr-nxl+1, force%nzw, 2, dynamic_3d )
     2807                           nest_offl%w_south(0:1,nzb+1:nzt-1,nxl:nxr),         &
     2808                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2809                           nxr-nxl+1, nest_offl%nzw, 2, .FALSE. )
    27422810                           
    27432811          IF ( .NOT. neutral )  THEN
    27442812             CALL get_variable( id_dynamic, 'ls_forcing_south_pt',             &
    2745                            force%pt_south(0:1,nzb+1:nzt+1,nxl:nxr),            &
    2746                            nxl+1, nzb+1, force%tind+1,                         &
    2747                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
     2813                           nest_offl%pt_south(0:1,nzb+1:nzt,nxl:nxr),          &
     2814                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2815                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
    27482816          ENDIF
    27492817          IF ( humidity )  THEN
    27502818             CALL get_variable( id_dynamic, 'ls_forcing_south_qv',             &
    2751                            force%q_south(0:1,nzb+1:nzt+1,nxl:nxr),             &
    2752                            nxl+1, nzb+1, force%tind+1,                         &
    2753                            nxr-nxl+1, force%nzu, 2, dynamic_3d )
    2754           ENDIF
    2755        ENDIF
     2819                           nest_offl%q_south(0:1,nzb+1:nzt,nxl:nxr),           &
     2820                           nxl+1, nzb+1, nest_offl%tind+1,                     &
     2821                           nxr-nxl+1, nest_offl%nzu, 2, .FALSE. )
     2822          ENDIF
     2823       ENDIF
     2824
    27562825!
    27572826!--    Top boundary
    27582827       CALL get_variable( id_dynamic, 'ls_forcing_top_u',                      &
    2759                              force%u_top(0:1,nys:nyn,nxlu:nxr),                &
    2760                              nxlu, nys+1, force%tind+1,                        &
    2761                              nxr-nxlu+1, nyn-nys+1, 2, dynamic_3d )
     2828                             nest_offl%u_top(0:1,nys:nyn,nxlu:nxr),            &
     2829                             nxlu, nys+1, nest_offl%tind+1,                    &
     2830                             nxr-nxlu+1, nyn-nys+1, 2, .TRUE. )
    27622831
    27632832       CALL get_variable( id_dynamic, 'ls_forcing_top_v',                      &
    2764                              force%v_top(0:1,nysv:nyn,nxl:nxr),                &
    2765                              nxl+1, nysv, force%tind+1,                        &
    2766                              nxr-nxl+1, nyn-nysv+1, 2, dynamic_3d )
     2833                             nest_offl%v_top(0:1,nysv:nyn,nxl:nxr),            &
     2834                             nxl+1, nysv, nest_offl%tind+1,                    &
     2835                             nxr-nxl+1, nyn-nysv+1, 2, .TRUE. )
    27672836                             
    27682837       CALL get_variable( id_dynamic, 'ls_forcing_top_w',                      &
    2769                              force%w_top(0:1,nys:nyn,nxl:nxr),                 &
    2770                              nxl+1, nys+1, force%tind+1,                       &
    2771                              nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
     2838                             nest_offl%w_top(0:1,nys:nyn,nxl:nxr),             &
     2839                             nxl+1, nys+1, nest_offl%tind+1,                   &
     2840                             nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
    27722841                             
    27732842       IF ( .NOT. neutral )  THEN
    27742843          CALL get_variable( id_dynamic, 'ls_forcing_top_pt',                  &
    2775                                 force%pt_top(0:1,nys:nyn,nxl:nxr),             &
    2776                                 nxl+1, nys+1, force%tind+1,                    &
    2777                                 nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
     2844                                nest_offl%pt_top(0:1,nys:nyn,nxl:nxr),         &
     2845                                nxl+1, nys+1, nest_offl%tind+1,                &
     2846                                nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
    27782847       ENDIF
    27792848       IF ( humidity )  THEN
    27802849          CALL get_variable( id_dynamic, 'ls_forcing_top_qv',                  &
    2781                                 force%q_top(0:1,nys:nyn,nxl:nxr),              &
    2782                                 nxl+1, nys+1, force%tind+1,                    &
    2783                                 nxr-nxl+1, nyn-nys+1, 2, dynamic_3d )
     2850                                nest_offl%q_top(0:1,nys:nyn,nxl:nxr),          &
     2851                                nxl+1, nys+1, nest_offl%tind+1,                &
     2852                                nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
    27842853       ENDIF
    27852854
     
    27922861       CALL cpu_log( log_point_s(86), 'NetCDF input forcing', 'stop' )
    27932862
    2794 !
    2795 !--    Finally, after data input set control flag indicating that vertical
    2796 !--    inter- and/or extrapolation is required.
    2797 !--    Please note, inter/extrapolation of INIFOR data is only a workaroud,
    2798 !--    as long as INIFOR delivers vertically equidistant data.
    2799        force%interpolated = .FALSE.
    2800 
    28012863    END SUBROUTINE netcdf_data_input_lsf
    28022864
     
    28102872
    28112873       USE control_parameters,                                                 &
    2812            ONLY:  initializing_actions, forcing, message_string
     2874           ONLY:  initializing_actions, message_string, nesting_offline
    28132875
    28142876       IMPLICIT NONE
     
    28162878!
    28172879!--    In case of forcing, check whether dynamic input file is present
    2818        IF ( .NOT. input_pids_dynamic  .AND.  forcing )  THEN
    2819           message_string = 'forcing = .TRUE. requires dynamic input file ' //  &
     2880       IF ( .NOT. input_pids_dynamic  .AND.  nesting_offline  )  THEN
     2881          message_string = 'nesting_offline = .TRUE. requires dynamic '  //    &
     2882                            'input file ' //                                   &
    28202883                            TRIM( input_file_dynamic ) // TRIM( coupling_char )
    28212884          CALL message( 'netcdf_data_input_mod', 'NDI009', 1, 2, 0, 6, 0 )
     
    45144577!------------------------------------------------------------------------------!
    45154578    SUBROUTINE get_variable_3d_real_dynamic( id, variable_name, var,           &
    4516                             i1s, i2s, i3s, count_1, count_2, count_3, dynamic)
     4579                                             i1s, i2s, i3s,                    &
     4580                                             count_1, count_2, count_3,        &
     4581                                             par_access )
    45174582                               
    45184583       USE indices
     
    45234588       CHARACTER(LEN=*)              ::  variable_name   !< variable name
    45244589
    4525        LOGICAL                       ::  dynamic         !< additional flag just used to select correct overloaded routine from interface block
     4590       LOGICAL                       ::  par_access      !< additional flag indicating whether parallel read operations should be performed or not
    45264591       
    45274592       INTEGER(iwp)                  ::  count_1         !< number of elements to be read along 1st dimension (with respect to file)
     
    45504615#if defined( __netcdf )
    45514616!
    4552 !--    Inquire variable id
     4617!--    Inquire variable id.
    45534618       nc_stat = NF90_INQ_VARID( id, TRIM( variable_name ), id_var )
    45544619!
    45554620!--    Check for collective read-operation and set respective NetCDF flags if
    45564621!--    required.
    4557        IF ( collective_read )  THEN
     4622!--    Please note, in contrast to the other input routines where each PEs
     4623!--    reads its subdomain data, dynamic input data not by all PEs, only
     4624!--    by those which encompass lateral model boundaries. Hence, collective
     4625!--    read operations are only enabled for top-boundary data.
     4626       IF ( collective_read  .AND.  par_access )  THEN
    45584627          nc_stat = NF90_VAR_PAR_ACCESS (id, id_var, NF90_COLLECTIVE)
    45594628       ENDIF   
  • TabularUnified palm/trunk/SOURCE/palm.f90

    r2977 r3182  
    238238    USE control_parameters,                                                    &
    239239        ONLY:  air_chemistry,                                                  &
    240                cloud_physics, constant_diffusion, coupling_char, coupling_mode,&
     240               cloud_physics, constant_diffusion, child_domain, coupling_char, &
     241               coupling_mode,                                                  &
    241242               do2d_at_begin, do3d_at_begin, humidity, initializing_actions,   &
    242243               io_blocks, io_group, large_scale_forcing,                       &
    243244               message_string, microphysics_morrison, microphysics_seifert,    &
    244                nest_domain, neutral, nudging, passive_scalar, runnr,           &
     245               neutral, nudging, passive_scalar, runnr,                        &
    245246               simulated_time, simulated_time_chr, spinup,                     &
    246247               time_since_reference_point,                                     &
     
    428429!
    429430!--    Exchange_horiz is needed after the nest initialization
    430           IF ( nest_domain )  THEN
     431          IF ( child_domain )  THEN
    431432             CALL exchange_horiz( u, nbgp )
    432433             CALL exchange_horiz( v, nbgp )
  • TabularUnified palm/trunk/SOURCE/parin.f90

    r3159 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables and boundary conditions in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
     
    529529             dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
    530530             dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
    531              e_min, fft_method, flux_input_mode, flux_output_mode, forcing,    &
     531             e_min, fft_method, flux_input_mode, flux_output_mode,             &
    532532             galilei_transformation, humidity,                                 &
    533533             inflow_damping_height, inflow_damping_width,                      &
     
    538538             loop_optimization, lsf_exception, masking_method, mg_cycles,      &
    539539             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
    540              most_method, na_init, nc_const, netcdf_precision, neutral, ngsrb, &
     540             most_method, na_init, nc_const, nesting_offline,                  &
     541             netcdf_precision, neutral, ngsrb,                                 &
    541542             nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor,     &
    542543             outflow_source_plane, passive_scalar,                             &
     
    601602             dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
    602603             dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
    603              e_min, fft_method, flux_input_mode, flux_output_mode, forcing,    &
     604             e_min, fft_method, flux_input_mode, flux_output_mode,             &
    604605             galilei_transformation, humidity,                                 &
    605606             inflow_damping_height, inflow_damping_width,                      &
     
    610611             loop_optimization, lsf_exception, masking_method, mg_cycles,      &
    611612             mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
    612              most_method, na_init, nc_const, netcdf_precision, neutral, ngsrb, &
     613             most_method, na_init, nc_const, nesting_offline,                  &
     614             netcdf_precision, neutral, ngsrb,                                 &
    613615             nsor, nsor_ini, nudging, nx, ny, nz, ocean, omega, omega_sor,     &
    614616             outflow_source_plane, passive_scalar,                             &
     
    924926                   bc_ns   = 'cyclic'
    925927                ENDIF
    926                 IF ( nest_domain )  THEN
     928                IF ( child_domain )  THEN
    927929                   bc_uv_t  = 'nested'
    928930                   bc_pt_t  = 'nested'
     
    936938!--          nested domains.
    937939             ELSE
    938                 IF ( nest_domain )  THEN
     940                IF ( child_domain )  THEN
    939941                   bc_lr    = 'nested'
    940942                   bc_ns    = 'nested'
     
    948950             ENDIF
    949951          ENDIF
    950 
    951           IF ( forcing )  THEN
    952              bc_lr    = 'forcing'
    953              bc_ns    = 'forcing'
    954              bc_uv_t  = 'forcing'
    955              bc_pt_t  = 'forcing'
    956              bc_q_t   = 'forcing'
    957              bc_s_t   = 'forcing'  ! scalar boundary condition is not clear
    958              bc_cs_t  = 'forcing'  ! same for chemical species
     952!
     953!--       Set boundary conditions also in case the model is offline-nested in
     954!--       larger-scale models.
     955          IF ( nesting_offline )  THEN
     956             bc_lr    = 'nesting_offline'
     957             bc_ns    = 'nesting_offline'
     958             bc_uv_t  = 'nesting_offline'
     959             bc_pt_t  = 'nesting_offline'
     960             bc_q_t   = 'nesting_offline'
     961             bc_s_t   = 'nesting_offline'  ! scalar boundary condition is not clear
     962             bc_cs_t  = 'nesting_offline'  ! same for chemical species
    959963             bc_p_t   = 'neumann'
    960964          ENDIF
     
    968972!--       are set properly. An exception is made in case of restart runs and
    969973!--       if user decides to do everything by its own.
    970           IF ( nest_domain  .AND.  .NOT. (                                     &
     974          IF ( child_domain  .AND.  .NOT. (                                    &
    971975               TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
    972976               TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
     
    979983
    980984             initializing_actions = 'set_constant_profiles'
    981           ENDIF
    982            
     985          ENDIF           
    983986!
    984987!--       Check validity of lateral boundary conditions. This has to be done
     
    987990          IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
    988991               bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
    989                bc_lr /= 'forcing' )  THEN
     992               bc_lr /= 'nesting_offline' )  THEN
    990993             message_string = 'unknown boundary condition: bc_lr = "' // &
    991994                              TRIM( bc_lr ) // '"'
     
    994997          IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
    995998               bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
    996                bc_ns /= 'forcing' )  THEN
     999               bc_ns /= 'nesting_offline' )  THEN
    9971000             message_string = 'unknown boundary condition: bc_ns = "' // &
    9981001                              TRIM( bc_ns ) // '"'
  • TabularUnified palm/trunk/SOURCE/pmc_interface_mod.f90

    r3083 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Variable names for nest_bound_x replaced by bc_dirichlet_x.
     23! Remove commented prints into debug files.
    2324!
    2425! Former revisions:
     
    306307   USE arrays_3d,                                                              &
    307308        ONLY:  diss, diss_2, dzu, dzw, e, e_p, e_2, nc, nc_2, nc_p, nr, nr_2,  &
    308                pt, pt_2, q, q_2, qc, qc_2, qr, qr_2, s, s_2,                       &
     309               pt, pt_2, q, q_2, qc, qc_2, qr, qr_2, s, s_2,                   &
    309310               u, u_p, u_2, v, v_p, v_2, w, w_p, w_2, zu, zw
    310311#endif
    311312
    312313    USE control_parameters,                                                    &
    313         ONLY:  air_chemistry, cloud_physics,                                   &
     314        ONLY:  air_chemistry, bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,  &
     315               bc_dirichlet_s, cloud_physics, child_domain,                    &
    314316               constant_diffusion, constant_flux_layer,                        &
    315317               coupling_char, dt_3d, dz, humidity, message_string,             &
    316318               microphysics_morrison, microphysics_seifert,                    &
    317                nest_bound_l, nest_bound_r, nest_bound_s, nest_bound_n,         &
    318                nest_domain, neutral, passive_scalar, rans_mode, rans_tke_e,    &
     319               neutral, passive_scalar, rans_mode, rans_tke_e,                 &
    319320               roughness_length, simulated_time, topography, volume_flow
    320321
     
    743744!-- course the root domain (cpl_id = 1) is not nested)
    744745    IF ( cpl_id >= 2 )  THEN
    745        nest_domain = .TRUE.
     746       child_domain = .TRUE.
    746747       WRITE( coupling_char, '(A2,I2.2)') '_N', cpl_id
    747748    ENDIF
     
    11921193        childgrid(m)%uz_coord   = zmax_coarse(2)
    11931194        childgrid(m)%uz_coord_b = zmax_coarse(1)
    1194 
    1195 !         WRITE(9,*)                 'edge coordinates for child id ',child_id,m
    1196 !         WRITE(9,*)                 'Number of Boundray cells lpm  ',nbgp_lpm
    1197 !         WRITE(9,'(a,3i7,2f10.2)') ' model size                    ', nx_cl, ny_cl, nz_cl, dx_cl, dy_cl
    1198 !          WRITE(9,'(a,5f10.2)')     ' model edge                    ', childgrid(m)%lx_coord,  &
    1199 !                                childgrid(m)%rx_coord, childgrid(m)%sy_coord,                  &
    1200 !                                childgrid(m)%ny_coord,childgrid(m)%uz_coord
    1201 !          WRITE(9,'(a,4f10.2)')     ' model edge with Boundary      ', childgrid(m)%lx_coord_b,&
    1202 !                                childgrid(m)%rx_coord_b, childgrid(m)%sy_coord_b,              &
    1203 !                                childgrid(m)%ny_coord_b
    12041195
    12051196     END SUBROUTINE set_child_edge_coords
     
    17141705!--    interpolation routines.
    17151706       nzt_topo_nestbc_l = nzb
    1716        IF ( nest_bound_l )  THEN
     1707       IF ( bc_dirichlet_l )  THEN
    17171708          DO  i = nxl-1, nxl
    17181709             DO  j = nys, nyn
     
    17401731     
    17411732       nzt_topo_nestbc_r = nzb
    1742        IF ( nest_bound_r )  THEN
     1733       IF ( bc_dirichlet_r )  THEN
    17431734          i = nxr + 1
    17441735          DO  j = nys, nyn
     
    17651756
    17661757       nzt_topo_nestbc_s = nzb
    1767        IF ( nest_bound_s )  THEN
     1758       IF ( bc_dirichlet_s )  THEN
    17681759          DO  j = nys-1, nys
    17691760             DO  i = nxl, nxr
     
    17911782
    17921783       nzt_topo_nestbc_n = nzb
    1793        IF ( nest_bound_n )  THEN
     1784       IF ( bc_dirichlet_n )  THEN
    17941785          j = nyn + 1
    17951786          DO  i = nxl, nxr
     
    18621853!--    logc_kbounds_* need to be allocated and initialized here.
    18631854!--    Left boundary
    1864        IF ( nest_bound_l )  THEN
     1855       IF ( bc_dirichlet_l )  THEN
    18651856
    18661857          ALLOCATE( logc_u_l(1:2,nzb:nzt_topo_nestbc_l,nys:nyn) )
     
    19231914!
    19241915!--    Right boundary
    1925        IF ( nest_bound_r )  THEN
     1916       IF ( bc_dirichlet_r )  THEN
    19261917           
    19271918          ALLOCATE( logc_u_r(1:2,nzb:nzt_topo_nestbc_r,nys:nyn) )
     
    19851976!
    19861977!--    South boundary
    1987        IF ( nest_bound_s )  THEN
     1978       IF ( bc_dirichlet_s )  THEN
    19881979
    19891980          ALLOCATE( logc_u_s(1:2,nzb:nzt_topo_nestbc_s,nxl:nxr) )
     
    20442035!
    20452036!--    North boundary
    2046        IF ( nest_bound_n )  THEN
     2037       IF ( bc_dirichlet_n )  THEN
    20472038
    20482039          ALLOCATE( logc_u_n(1:2,nzb:nzt_topo_nestbc_n,nxl:nxr) )
     
    21162107!       
    21172108!--       Left boundary
    2118           IF ( nest_bound_l )  THEN
     2109          IF ( bc_dirichlet_l )  THEN
    21192110             logc_kbounds_u_l(1:2,nys:nyn) = 0
    21202111             logc_kbounds_v_l(1:2,nys:nyn) = 0             
     
    22552246             ENDDO
    22562247
    2257           ENDIF   !  IF ( nest_bound_l )
     2248          ENDIF   !  IF ( bc_dirichlet_l )
    22582249!       
    22592250!--       Right boundary
    2260           IF ( nest_bound_r )  THEN
     2251          IF ( bc_dirichlet_r )  THEN
    22612252             logc_kbounds_u_r(1:2,nys:nyn) = 0
    22622253             logc_kbounds_v_r(1:2,nys:nyn) = 0             
     
    23952386             ENDDO
    23962387             
    2397           ENDIF   !  IF ( nest_bound_r )
     2388          ENDIF   !  IF ( bc_dirichlet_r )
    23982389!       
    23992390!--       South boundary
    2400           IF ( nest_bound_s )  THEN
     2391          IF ( bc_dirichlet_s )  THEN
    24012392             logc_kbounds_u_s(1:2,nxl:nxr) = 0
    24022393             logc_kbounds_v_s(1:2,nxl:nxr) = 0
     
    25372528             ENDDO
    25382529
    2539           ENDIF   !  IF (nest_bound_s )
     2530          ENDIF   !  IF (bc_dirichlet_s )
    25402531!       
    25412532!--       North boundary
    2542           IF ( nest_bound_n )  THEN
     2533          IF ( bc_dirichlet_n )  THEN
    25432534             logc_kbounds_u_n(1:2,nxl:nxr) = 0             
    25442535             logc_kbounds_v_n(1:2,nxl:nxr) = 0
     
    26782669             ENDDO
    26792670
    2680           ENDIF   !  IF ( nest_bound_n )
     2671          ENDIF   !  IF ( bc_dirichlet_n )
    26812672
    26822673       ENDIF   !  IF ( topography /= 'flat' )
     
    27862777
    27872778       END SELECT
    2788          
    2789        !write(9,"('pmci_define_loglaw_correction_parameters: ', 6(i3,2x))")    &
    2790        !     direction, ij, k, wall_index, inc, lc
    27912779
    27922780    END SUBROUTINE pmci_define_loglaw_correction_parameters
     
    33253313!
    33263314       IF ( .NOT. rans_mode  .AND.  .NOT. rans_mode_parent )  THEN
    3327           IF ( nest_bound_l )  THEN
     3315          IF ( bc_dirichlet_l )  THEN
    33283316             ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )
    33293317             tkefactor_l = 0.0_wp
     
    33453333          ENDIF
    33463334
    3347           IF ( nest_bound_r )  THEN
     3335          IF ( bc_dirichlet_r )  THEN
    33483336             ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )
    33493337             tkefactor_r = 0.0_wp
     
    33653353          ENDIF
    33663354
    3367           IF ( nest_bound_s )  THEN
     3355          IF ( bc_dirichlet_s )  THEN
    33683356             ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )
    33693357             tkefactor_s = 0.0_wp
     
    33863374          ENDIF
    33873375
    3388           IF ( nest_bound_n )  THEN
     3376          IF ( bc_dirichlet_n )  THEN
    33893377             ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )
    33903378             tkefactor_n = 0.0_wp
     
    34283416!--    RANS mode
    34293417       ELSE
    3430           IF ( nest_bound_l )  THEN
     3418          IF ( bc_dirichlet_l )  THEN
    34313419             ALLOCATE( tkefactor_l(nzb:nzt+1,nysg:nyng) )
    34323420             tkefactor_l = 1.0_wp
    34333421          ENDIF
    3434           IF ( nest_bound_r )  THEN
     3422          IF ( bc_dirichlet_r )  THEN
    34353423             ALLOCATE( tkefactor_r(nzb:nzt+1,nysg:nyng) )
    34363424             tkefactor_r = 1.0_wp
    34373425          ENDIF
    3438           IF ( nest_bound_s )  THEN
     3426          IF ( bc_dirichlet_s )  THEN
    34393427             ALLOCATE( tkefactor_s(nzb:nzt+1,nxlg:nxrg) )
    34403428             tkefactor_s = 1.0_wp
    34413429          ENDIF
    3442           IF ( nest_bound_n )  THEN
     3430          IF ( bc_dirichlet_n )  THEN
    34433431             ALLOCATE( tkefactor_n(nzb:nzt+1,nxlg:nxrg) )
    34443432             tkefactor_n = 1.0_wp
     
    39803968       je = nyn
    39813969       IF ( nesting_mode /= 'vertical' )  THEN
    3982           IF ( nest_bound_l )  THEN
     3970          IF ( bc_dirichlet_l )  THEN
    39833971             ib = nxl - 1
    39843972!
     
    39883976             ENDIF
    39893977          ENDIF
    3990           IF ( nest_bound_s )  THEN
     3978          IF ( bc_dirichlet_s )  THEN
    39913979             jb = nys - 1
    39923980!
     
    39963984             ENDIF
    39973985          ENDIF
    3998           IF ( nest_bound_r )  THEN
     3986          IF ( bc_dirichlet_r )  THEN
    39993987             ie = nxr + 1
    40003988          ENDIF
    4001           IF ( nest_bound_n )  THEN
     3989          IF ( bc_dirichlet_n )  THEN
    40023990             je = nyn + 1
    40033991          ENDIF
     
    42014189    volume_flow_l(1) = 0.0_wp
    42024190
    4203     IF ( nest_bound_l )  THEN
     4191    IF ( bc_dirichlet_l )  THEN
    42044192       i = 0
    42054193       innor = dy
     
    42134201    ENDIF
    42144202
    4215     IF ( nest_bound_r )  THEN
     4203    IF ( bc_dirichlet_r )  THEN
    42164204       i = nx + 1
    42174205       innor = -dy
     
    42384226    volume_flow_l(2) = 0.0_wp
    42394227
    4240     IF ( nest_bound_s )  THEN
     4228    IF ( bc_dirichlet_s )  THEN
    42414229       j = 0
    42424230       innor = dx
     
    42504238    ENDIF
    42514239
    4252     IF ( nest_bound_n )  THEN
     4240    IF ( bc_dirichlet_n )  THEN
    42534241       j = ny + 1
    42544242       innor = -dx
     
    45494537!
    45504538!--       Left border pe:
    4551           IF ( nest_bound_l )  THEN
     4539          IF ( bc_dirichlet_l )  THEN
    45524540             
    45534541             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
     
    46564644!
    46574645!--       Right border pe
    4658           IF ( nest_bound_r )  THEN
     4646          IF ( bc_dirichlet_r )  THEN
    46594647             
    46604648             CALL pmci_interp_tril_lr( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
     
    47694757!
    47704758!--       South border pe
    4771           IF ( nest_bound_s )  THEN
     4759          IF ( bc_dirichlet_s )  THEN
    47724760
    47734761             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
     
    48804868!
    48814869!--       North border pe
    4882           IF ( nest_bound_n )  THEN
     4870          IF ( bc_dirichlet_n )  THEN
    48834871             
    48844872             CALL pmci_interp_tril_sn( u,  uc,  icu, jco, kco, r1xu, r2xu,     &
     
    57485736!--    comprehensive explanation for this is still pending.
    57495737       IF ( nesting_mode == 'vertical' )  THEN
    5750           IF ( nest_bound_l )  THEN
     5738          IF ( bc_dirichlet_l )  THEN
    57515739             iclp = icl + nhll
    57525740          ENDIF
    5753           IF ( nest_bound_r ) THEN
     5741          IF ( bc_dirichlet_r ) THEN
    57545742             icrm = icr - nhlr
    57555743          ENDIF
    5756           IF ( nest_bound_s )  THEN
     5744          IF ( bc_dirichlet_s )  THEN
    57575745             jcsp = jcs + nhls
    57585746          ENDIF
    5759           IF ( nest_bound_n )  THEN
     5747          IF ( bc_dirichlet_n )  THEN
    57605748             jcnm = jcn - nhln
    57615749          ENDIF
    57625750       ELSE
    5763           IF ( nest_bound_l )  THEN
     5751          IF ( bc_dirichlet_l )  THEN
    57645752             IF ( var == 'u' )  THEN
    57655753                iclp = icl + nhll + 1 + 1
     
    57685756             ENDIF
    57695757          ENDIF
    5770           IF ( nest_bound_r )  THEN
     5758          IF ( bc_dirichlet_r )  THEN
    57715759             icrm = icr - nhlr - 1
    57725760          ENDIF
    57735761
    5774           IF ( nest_bound_s )  THEN
     5762          IF ( bc_dirichlet_s )  THEN
    57755763             IF ( var == 'v' )  THEN
    57765764                jcsp = jcs + nhls + 1 + 1
     
    57795767             ENDIF
    57805768          ENDIF
    5781           IF ( nest_bound_n )  THEN
     5769          IF ( bc_dirichlet_n )  THEN
    57825770             jcnm = jcn - nhln - 1
    57835771          ENDIF
  • TabularUnified palm/trunk/SOURCE/pmc_parent_mod.f90

    r3049 r3182  
    203203    INTEGER(iwp) ::  istat     !<
    204204
    205 
    206205    DO  i = 1, SIZE( pmc_parent_for_child )-1
    207206
     
    219218       CALL MPI_COMM_REMOTE_SIZE( children(childid)%inter_comm,                &
    220219                                  children(childid)%inter_npes, istat )
    221 
    222220!
    223221!--    Intra communicator is used for MPI_GET
     
    228226
    229227       ALLOCATE( children(childid)%pes(children(childid)%inter_npes))
    230 
    231228!
    232229!--    Allocate array of TYPE arraydef for all child PEs to store information
     
    865862    DO
    866863       CALL pmc_bcast( myname%couple_index, 0, comm=m_to_child_comm(childid) )
     864
    867865       IF ( myname%couple_index == -1 )  EXIT
     866
    868867       CALL pmc_bcast( myname%parentdesc,   0, comm=m_to_child_comm(childid) )
    869868       CALL pmc_bcast( myname%nameonparent, 0, comm=m_to_child_comm(childid) )
  • TabularUnified palm/trunk/SOURCE/poismg_mod.f90

    r2939 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
     
    2626! $Id$
    2727! Set lateral boundary conditions for divergence
    28 ! 
     28!
    2929! 2937 2018-03-27 14:58:33Z suehring
    3030! Corrected "Former revisions" section
     
    107107 
    108108    USE control_parameters,                                                    &
    109         ONLY:  grid_level, force_bound_l, force_bound_n, force_bound_r,        &
    110                force_bound_s, forcing, inflow_l, inflow_n, inflow_r, inflow_s, &
    111                nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,         &
    112                outflow_l, outflow_n, outflow_r, outflow_s
     109        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
     110               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
     111               bc_radiation_s, grid_level, nesting_offline
    113112
    114113    USE cpulog,                                                                &
     
    206205!--    Set lateral boundary conditions in non-cyclic case
    207206       IF ( .NOT. bc_lr_cyc )  THEN
    208           IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  &
     207          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )                          &
    209208             d(:,:,nxl-1) = d(:,:,nxl)
    210           IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  &
     209          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )                          &
    211210             d(:,:,nxr+1) = d(:,:,nxr)
    212211       ENDIF
    213212       IF ( .NOT. bc_ns_cyc )  THEN
    214           IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  &
     213          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )                          &
    215214             d(:,nyn+1,:) = d(:,nyn,:)
    216           IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  &
     215          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )                          &
    217216             d(:,nys-1,:) = d(:,nys,:)
    218217       ENDIF
     
    375374
    376375       IF ( .NOT. bc_lr_cyc )  THEN
    377           IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
    378                force_bound_l )  THEN
     376          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    379377             r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
    380378          ENDIF
    381           IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
    382                force_bound_r )  THEN
     379          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    383380             r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
    384381          ENDIF
     
    386383
    387384       IF ( .NOT. bc_ns_cyc )  THEN
    388           IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
    389                force_bound_n )  THEN
     385          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    390386             r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
    391387          ENDIF
    392           IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
    393                force_bound_s )  THEN
     388          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    394389             r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
    395390          ENDIF
     
    510505!--    Horizontal boundary conditions
    511506       IF ( .NOT. bc_lr_cyc )  THEN
    512           IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
    513                force_bound_l )  THEN
     507          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    514508             f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
    515509          ENDIF
    516           IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
    517                force_bound_r )  THEN
     510          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    518511             f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
    519512          ENDIF
     
    521514
    522515       IF ( .NOT. bc_ns_cyc )  THEN
    523           IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
    524                force_bound_n )  THEN
     516          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    525517             f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
    526518          ENDIF
    527           IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
    528                force_bound_s )  THEN
     519          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    529520             f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
    530521          ENDIF
     
    681672
    682673       IF ( .NOT. bc_lr_cyc )  THEN
    683           IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.             &
    684                force_bound_l )  THEN
     674          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    685675             temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
    686676          ENDIF
    687           IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.             &
    688                force_bound_r )  THEN
     677          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    689678             temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
    690679          ENDIF
     
    692681
    693682       IF ( .NOT. bc_ns_cyc )  THEN
    694           IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.             &
    695                force_bound_n )  THEN
     683          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    696684             temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
    697685          ENDIF
    698           IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.             &
    699                force_bound_s )  THEN
     686          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    700687             temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
    701688          ENDIF
     
    991978
    992979             IF ( .NOT. bc_lr_cyc )  THEN
    993                 IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.       &
    994                      force_bound_l )  THEN
     980                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    995981                   p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
    996982                ENDIF
    997                 IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.       &
    998                      force_bound_r )  THEN
     983                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    999984                   p_mg(:,:,nxr_mg(l)+1) = p_mg(:,:,nxr_mg(l))
    1000985                ENDIF
     
    1002987
    1003988             IF ( .NOT. bc_ns_cyc )  THEN
    1004                 IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.       &
    1005                      force_bound_n )  THEN
     989                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    1006990                   p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
    1007991                ENDIF
    1008                 IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.       &
    1009                      force_bound_s )  THEN
     992                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    1010993                   p_mg(:,nys_mg(l)-1,:) = p_mg(:,nys_mg(l),:)
    1011994                ENDIF
     
    14231406       USE control_parameters,                                                 &
    14241407           ONLY:  bc_lr_dirrad, bc_lr_raddir, bc_ns_dirrad, bc_ns_raddir,      &
    1425                   gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,                &
     1408                  child_domain, gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,  &
    14261409                  maximum_grid_level,  mg_switch_to_pe0_level,                 &
    1427                   mg_switch_to_pe0, nest_domain, ngsrb
     1410                  mg_switch_to_pe0, ngsrb
    14281411
    14291412       USE indices,                                                            &
     
    15641547!--          because then they have the total domain.
    15651548             IF ( bc_lr_dirrad )  THEN
    1566                 inflow_l  = .TRUE.
    1567                 inflow_r  = .FALSE.
    1568                 outflow_l = .FALSE.
    1569                 outflow_r = .TRUE.
     1549                bc_dirichlet_l  = .TRUE.
     1550                bc_dirichlet_r  = .FALSE.
     1551                bc_radiation_l = .FALSE.
     1552                bc_radiation_r = .TRUE.
    15701553             ELSEIF ( bc_lr_raddir )  THEN
    1571                 inflow_l  = .FALSE.
    1572                 inflow_r  = .TRUE.
    1573                 outflow_l = .TRUE.
    1574                 outflow_r = .FALSE.
    1575              ELSEIF ( nest_domain )  THEN
    1576                 nest_bound_l = .TRUE.
    1577                 nest_bound_r = .TRUE.
    1578              ELSEIF ( forcing )  THEN
    1579                 force_bound_l = .TRUE.
    1580                 force_bound_r = .TRUE.
     1554                bc_dirichlet_l  = .FALSE.
     1555                bc_dirichlet_r  = .TRUE.
     1556                bc_radiation_l = .TRUE.
     1557                bc_radiation_r = .FALSE.
     1558             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
     1559                bc_dirichlet_l = .TRUE.
     1560                bc_dirichlet_r = .TRUE.
    15811561             ENDIF
    15821562
    15831563             IF ( bc_ns_dirrad )  THEN
    1584                 inflow_n  = .TRUE.
    1585                 inflow_s  = .FALSE.
    1586                 outflow_n = .FALSE.
    1587                 outflow_s = .TRUE.
     1564                bc_dirichlet_n  = .TRUE.
     1565                bc_dirichlet_s  = .FALSE.
     1566                bc_radiation_n = .FALSE.
     1567                bc_radiation_s = .TRUE.
    15881568             ELSEIF ( bc_ns_raddir )  THEN
    1589                 inflow_n  = .FALSE.
    1590                 inflow_s  = .TRUE.
    1591                 outflow_n = .TRUE.
    1592                 outflow_s = .FALSE.
    1593              ELSEIF ( nest_domain )  THEN
    1594                 nest_bound_s = .TRUE.
    1595                 nest_bound_n = .TRUE.
    1596              ELSEIF ( forcing )  THEN
    1597                 force_bound_s = .TRUE.
    1598                 force_bound_n = .TRUE.
     1569                bc_dirichlet_n  = .FALSE.
     1570                bc_dirichlet_s  = .TRUE.
     1571                bc_radiation_n = .TRUE.
     1572                bc_radiation_s = .FALSE.
     1573             ELSEIF ( child_domain  .OR.  nesting_offline)  THEN
     1574                bc_dirichlet_s = .TRUE.
     1575                bc_dirichlet_n = .TRUE.
    15991576             ENDIF
    16001577
     
    16591636!--          For non-cyclic lateral boundary conditions and in case of nesting,
    16601637!--          restore the in-/outflow conditions.
    1661              inflow_l  = .FALSE.;  inflow_r  = .FALSE.
    1662              inflow_n  = .FALSE.;  inflow_s  = .FALSE.
    1663              outflow_l = .FALSE.;  outflow_r = .FALSE.
    1664              outflow_n = .FALSE.;  outflow_s = .FALSE.
    1665 !
    1666 !--          In case of nesting or forcing, restore lateral boundary conditions
    1667              IF ( nest_domain )  THEN
    1668                 nest_bound_l = .FALSE.
    1669                 nest_bound_r = .FALSE.
    1670                 nest_bound_s = .FALSE.
    1671                 nest_bound_n = .FALSE.     
    1672              ENDIF
    1673              IF ( forcing )  THEN
    1674                 force_bound_l = .FALSE.
    1675                 force_bound_r = .FALSE.
    1676                 force_bound_s = .FALSE.
    1677                 force_bound_n = .FALSE.     
    1678              ENDIF
     1638             bc_dirichlet_l = .FALSE.;  bc_dirichlet_r = .FALSE.
     1639             bc_dirichlet_n = .FALSE.;  bc_dirichlet_s = .FALSE.
     1640             bc_radiation_l = .FALSE.;  bc_radiation_r = .FALSE.
     1641             bc_radiation_n = .FALSE.;  bc_radiation_s = .FALSE.
    16791642
    16801643             IF ( pleft == MPI_PROC_NULL )  THEN
    1681                 IF ( bc_lr_dirrad )  THEN
    1682                    inflow_l  = .TRUE.
     1644                IF ( bc_lr_dirrad  .OR.  child_domain  .OR.  nesting_offline ) &
     1645                THEN
     1646                   bc_dirichlet_l = .TRUE.
    16831647                ELSEIF ( bc_lr_raddir )  THEN
    1684                    outflow_l = .TRUE.
    1685                 ELSEIF ( nest_domain )  THEN
    1686                    nest_bound_l = .TRUE.
    1687                 ELSEIF ( forcing )  THEN
    1688                    force_bound_l = .TRUE.
     1648                   bc_radiation_l = .TRUE.
    16891649                ENDIF
    16901650             ENDIF
     
    16921652             IF ( pright == MPI_PROC_NULL )  THEN
    16931653                IF ( bc_lr_dirrad )  THEN
    1694                    outflow_r = .TRUE.
    1695                 ELSEIF ( bc_lr_raddir )  THEN
    1696                    inflow_r  = .TRUE.
    1697                 ELSEIF ( nest_domain )  THEN
    1698                    nest_bound_r = .TRUE.
    1699                 ELSEIF ( forcing )  THEN
    1700                    force_bound_r = .TRUE.
     1654                   bc_radiation_r = .TRUE.
     1655                ELSEIF ( bc_lr_raddir  .OR.  child_domain  .OR.                &
     1656                         nesting_offline )  THEN
     1657                   bc_dirichlet_r = .TRUE.
    17011658                ENDIF
    17021659             ENDIF
     
    17041661             IF ( psouth == MPI_PROC_NULL )  THEN
    17051662                IF ( bc_ns_dirrad )  THEN
    1706                    outflow_s = .TRUE.
     1663                   bc_radiation_s = .TRUE.
     1664                ELSEIF ( bc_ns_raddir  .OR.  child_domain  .OR.                &
     1665                         nesting_offline )  THEN
     1666                   bc_dirichlet_s = .TRUE.
     1667                ENDIF
     1668             ENDIF
     1669
     1670             IF ( pnorth == MPI_PROC_NULL )  THEN
     1671                IF ( bc_ns_dirrad  .OR.  child_domain  .OR.  nesting_offline ) &
     1672                THEN
     1673                   bc_dirichlet_n = .TRUE.
    17071674                ELSEIF ( bc_ns_raddir )  THEN
    1708                    inflow_s  = .TRUE.
    1709                 ELSEIF ( nest_domain )  THEN
    1710                    nest_bound_s = .TRUE.
    1711                 ELSEIF ( forcing )  THEN
    1712                    force_bound_s = .TRUE.
    1713                 ENDIF
    1714              ENDIF
    1715 
    1716              IF ( pnorth == MPI_PROC_NULL )  THEN
    1717                 IF ( bc_ns_dirrad )  THEN
    1718                    inflow_n  = .TRUE.
    1719                 ELSEIF ( bc_ns_raddir )  THEN
    1720                    outflow_n = .TRUE.
    1721                 ELSEIF ( nest_domain )  THEN
    1722                    nest_bound_n = .TRUE.
    1723                 ELSEIF ( forcing )  THEN
    1724                    force_bound_n = .TRUE.
     1675                   bc_radiation_n = .TRUE.
    17251676                ENDIF
    17261677             ENDIF
  • TabularUnified palm/trunk/SOURCE/poismg_noopt_mod.f90

    r2939 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
     
    165165 
    166166    USE control_parameters,                                                    &
    167         ONLY:  grid_level, force_bound_l, force_bound_n, force_bound_r,        &
    168                force_bound_s, forcing, inflow_l, inflow_n, inflow_r, inflow_s, &
    169                nest_bound_l, nest_bound_n, nest_bound_r, nest_bound_s,         &
    170                outflow_l, outflow_n, outflow_r, outflow_s
     167        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
     168               bc_dirichlet_s, bc_radiation_l, bc_radiation_n, bc_radiation_r, &
     169               bc_radiation_s, child_domain, grid_level, nesting_offline
    171170
    172171    USE cpulog,                                                                &
     
    261260!--    Set lateral boundary conditions in non-cyclic case
    262261       IF ( .NOT. bc_lr_cyc )  THEN
    263           IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  &
     262          IF ( bc_dirichlet_l   .OR.  bc_radiation_l )                         &
    264263             d(:,:,nxl-1) = d(:,:,nxl)
    265           IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  &
     264          IF ( bc_dirichlet_r   .OR.  bc_radiation_r )                         &
    266265             d(:,:,nxr+1) = d(:,:,nxr)
    267266       ENDIF
    268267       IF ( .NOT. bc_ns_cyc )  THEN
    269           IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  &
     268          IF ( bc_dirichlet_n   .OR.  bc_radiation_n )                         &
    270269             d(:,nyn+1,:) = d(:,nyn,:)
    271           IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  &
     270          IF ( bc_dirichlet_s   .OR.  bc_radiation_s )                         &
    272271             d(:,nys-1,:) = d(:,nys,:)
    273272       ENDIF
     
    442441
    443442       IF ( .NOT. bc_lr_cyc )  THEN
    444           IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
     443          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    445444             r(:,:,nxl_mg(l)-1) = r(:,:,nxl_mg(l))
    446445          ENDIF
    447           IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
     446          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    448447             r(:,:,nxr_mg(l)+1) = r(:,:,nxr_mg(l))
    449448          ENDIF
     
    451450
    452451       IF ( .NOT. bc_ns_cyc )  THEN
    453           IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
     452          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    454453             r(:,nyn_mg(l)+1,:) = r(:,nyn_mg(l),:)
    455454          ENDIF
    456           IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
     455          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    457456             r(:,nys_mg(l)-1,:) = r(:,nys_mg(l),:)
    458457          ENDIF
     
    657656
    658657       IF ( .NOT. bc_lr_cyc )  THEN
    659           IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
     658          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    660659             f_mg(:,:,nxl_mg(l)-1) = f_mg(:,:,nxl_mg(l))
    661660          ENDIF
    662           IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
     661          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    663662             f_mg(:,:,nxr_mg(l)+1) = f_mg(:,:,nxr_mg(l))
    664663          ENDIF
     
    666665
    667666       IF ( .NOT. bc_ns_cyc )  THEN
    668           IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
     667          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    669668             f_mg(:,nyn_mg(l)+1,:) = f_mg(:,nyn_mg(l),:)
    670669          ENDIF
    671           IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
     670          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    672671             f_mg(:,nys_mg(l)-1,:) = f_mg(:,nys_mg(l),:)
    673672          ENDIF
     
    770769
    771770    IF ( .NOT. bc_lr_cyc )  THEN
    772        IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
     771       IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    773772          temp(:,:,nxl_mg(l)-1) = temp(:,:,nxl_mg(l))
    774773       ENDIF
    775        IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
     774       IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    776775          temp(:,:,nxr_mg(l)+1) = temp(:,:,nxr_mg(l))
    777776       ENDIF
     
    779778
    780779    IF ( .NOT. bc_ns_cyc )  THEN
    781        IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
     780       IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    782781          temp(:,nyn_mg(l)+1,:) = temp(:,nyn_mg(l),:)
    783782       ENDIF
    784        IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
     783       IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    785784          temp(:,nys_mg(l)-1,:) = temp(:,nys_mg(l),:)
    786785       ENDIF
     
    12001199
    12011200             IF ( .NOT. bc_lr_cyc )  THEN
    1202                 IF ( inflow_l .OR. outflow_l .OR. nest_bound_l .OR. force_bound_l )  THEN
     1201                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    12031202                   p_mg(:,:,nxl_mg(l)-1) = p_mg(:,:,nxl_mg(l))
    12041203                ENDIF
    1205                 IF ( inflow_r .OR. outflow_r .OR. nest_bound_r .OR. force_bound_r )  THEN
     1204                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    12061205                   p_mg(:,:,nxr_mg(l)+1) = p_mg(:,:,nxr_mg(l))
    12071206                ENDIF
     
    12091208
    12101209             IF ( .NOT. bc_ns_cyc )  THEN
    1211                 IF ( inflow_n .OR. outflow_n .OR. nest_bound_n .OR. force_bound_n )  THEN
     1210                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    12121211                   p_mg(:,nyn_mg(l)+1,:) = p_mg(:,nyn_mg(l),:)
    12131212                ENDIF
    1214                 IF ( inflow_s .OR. outflow_s .OR. nest_bound_s .OR. force_bound_s )  THEN
     1213                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    12151214                   p_mg(:,nys_mg(l)-1,:) = p_mg(:,nys_mg(l),:)
    12161215                ENDIF
     
    14221421                  gamma_mg, grid_level_count, ibc_p_b, ibc_p_t,                &
    14231422                  maximum_grid_level,                                          &
    1424                   mg_switch_to_pe0_level, mg_switch_to_pe0, nest_domain, ngsrb
     1423                  mg_switch_to_pe0_level, mg_switch_to_pe0, ngsrb
    14251424
    14261425
     
    15621561!--          because then they have the total domain.
    15631562             IF ( bc_lr_dirrad )  THEN
    1564                 inflow_l  = .TRUE.
    1565                 inflow_r  = .FALSE.
    1566                 outflow_l = .FALSE.
    1567                 outflow_r = .TRUE.
     1563                bc_dirichlet_l  = .TRUE.
     1564                bc_dirichlet_r  = .FALSE.
     1565                bc_radiation_l = .FALSE.
     1566                bc_radiation_r = .TRUE.
    15681567             ELSEIF ( bc_lr_raddir )  THEN
    1569                 inflow_l  = .FALSE.
    1570                 inflow_r  = .TRUE.
    1571                 outflow_l = .TRUE.
    1572                 outflow_r = .FALSE.
    1573              ELSEIF ( nest_domain )  THEN
    1574                 nest_bound_l = .TRUE.
    1575                 nest_bound_r = .TRUE.
    1576              ELSEIF ( forcing )  THEN
    1577                 force_bound_l = .TRUE.
    1578                 force_bound_r = .TRUE.
     1568                bc_dirichlet_l  = .FALSE.
     1569                bc_dirichlet_r  = .TRUE.
     1570                bc_radiation_l = .TRUE.
     1571                bc_radiation_r = .FALSE.
     1572             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
     1573                bc_dirichlet_l = .TRUE.
     1574                bc_dirichlet_r = .TRUE.
    15791575             ENDIF
    15801576
    15811577             IF ( bc_ns_dirrad )  THEN
    1582                 inflow_n  = .TRUE.
    1583                 inflow_s  = .FALSE.
    1584                 outflow_n = .FALSE.
    1585                 outflow_s = .TRUE.
     1578                bc_dirichlet_n  = .TRUE.
     1579                bc_dirichlet_s  = .FALSE.
     1580                bc_radiation_n = .FALSE.
     1581                bc_radiation_s = .TRUE.
    15861582             ELSEIF ( bc_ns_raddir )  THEN
    1587                 inflow_n  = .FALSE.
    1588                 inflow_s  = .TRUE.
    1589                 outflow_n = .TRUE.
    1590                 outflow_s = .FALSE.
    1591              ELSEIF ( nest_domain )  THEN
    1592                 nest_bound_s = .TRUE.
    1593                 nest_bound_n = .TRUE.
    1594              ELSEIF ( forcing )  THEN
    1595                 force_bound_s = .TRUE.
    1596                 force_bound_n = .TRUE.
     1583                bc_dirichlet_n  = .FALSE.
     1584                bc_dirichlet_s  = .TRUE.
     1585                bc_radiation_n = .TRUE.
     1586                bc_radiation_s = .FALSE.
     1587             ELSEIF ( child_domain  .OR.  nesting_offline )  THEN
     1588                bc_dirichlet_s = .TRUE.
     1589                bc_dirichlet_n = .TRUE.
    15971590             ENDIF
    15981591
     
    16551648!--          For non-cyclic lateral boundary conditions and in case of nesting,
    16561649!--          restore the in-/outflow conditions.
    1657              inflow_l  = .FALSE.;  inflow_r  = .FALSE.
    1658              inflow_n  = .FALSE.;  inflow_s  = .FALSE.
    1659              outflow_l = .FALSE.;  outflow_r = .FALSE.
    1660              outflow_n = .FALSE.;  outflow_s = .FALSE.
    1661 !
    1662 !--          In case of nesting, restore lateral boundary conditions
    1663              IF ( nest_domain )  THEN
    1664                 nest_bound_l = .FALSE.
    1665                 nest_bound_r = .FALSE.
    1666                 nest_bound_s = .FALSE.
    1667                 nest_bound_n = .FALSE.     
    1668              ENDIF
    1669              IF ( forcing )  THEN
    1670                 force_bound_l = .FALSE.
    1671                 force_bound_r = .FALSE.
    1672                 force_bound_s = .FALSE.
    1673                 force_bound_n = .FALSE.     
    1674              ENDIF
     1650             bc_dirichlet_l = .FALSE.;  bc_dirichlet_r = .FALSE.
     1651             bc_dirichlet_n = .FALSE.;  bc_dirichlet_s = .FALSE.
     1652             bc_radiation_l = .FALSE.;  bc_radiation_r = .FALSE.
     1653             bc_radiation_n = .FALSE.;  bc_radiation_s = .FALSE.
    16751654
    16761655             IF ( pleft == MPI_PROC_NULL )  THEN
    1677                 IF ( bc_lr_dirrad )  THEN
    1678                    inflow_l  = .TRUE.
     1656                IF ( bc_lr_dirrad  .OR.  child_domain  .OR.  nesting_offline )  &
     1657                THEN
     1658                   bc_dirichlet_l = .TRUE.
    16791659                ELSEIF ( bc_lr_raddir )  THEN
    1680                    outflow_l = .TRUE.
    1681                 ELSEIF ( nest_domain )  THEN
    1682                    nest_bound_l = .TRUE.
    1683                 ELSEIF ( forcing )  THEN
    1684                    force_bound_l = .TRUE.
     1660                   bc_radiation_l = .TRUE.
    16851661                ENDIF
    16861662             ENDIF
     
    16881664             IF ( pright == MPI_PROC_NULL )  THEN
    16891665                IF ( bc_lr_dirrad )  THEN
    1690                    outflow_r = .TRUE.
    1691                 ELSEIF ( bc_lr_raddir )  THEN
    1692                    inflow_r  = .TRUE.
    1693                 ELSEIF ( nest_domain )  THEN
    1694                    nest_bound_r = .TRUE.
    1695                 ELSEIF ( forcing )  THEN
    1696                    force_bound_r = .TRUE.
     1666                   bc_radiation_r = .TRUE.
     1667                ELSEIF ( bc_lr_raddir  .OR.  child_domain  .OR.                 &
     1668                         nesting_offline )  THEN
     1669                   bc_dirichlet_r = .TRUE.
    16971670                ENDIF
    16981671             ENDIF
     
    17001673             IF ( psouth == MPI_PROC_NULL )  THEN
    17011674                IF ( bc_ns_dirrad )  THEN
    1702                    outflow_s = .TRUE.
    1703                 ELSEIF ( bc_ns_raddir )  THEN
    1704                    inflow_s  = .TRUE.
    1705                 ELSEIF ( nest_domain )  THEN
    1706                    nest_bound_s = .TRUE.
    1707                 ELSEIF ( forcing )  THEN
    1708                    force_bound_s = .TRUE.
     1675                   bc_radiation_s = .TRUE.
     1676                ELSEIF ( bc_ns_raddir  .OR.  child_domain  .OR.                 &
     1677                         nesting_offline )  THEN
     1678                   bc_dirichlet_s = .TRUE.
    17091679                ENDIF
    17101680             ENDIF
    17111681
    17121682             IF ( pnorth == MPI_PROC_NULL )  THEN
    1713                 IF ( bc_ns_dirrad )  THEN
    1714                    inflow_n  = .TRUE.
     1683                IF ( bc_ns_dirrad  .OR.  child_domain  .OR.  nesting_offline )  &
     1684                THEN
     1685                   bc_dirichlet_n = .TRUE.
    17151686                ELSEIF ( bc_ns_raddir )  THEN
    1716                    outflow_n = .TRUE.
    1717                 ELSEIF ( nest_domain )  THEN
    1718                    nest_bound_n = .TRUE.
    1719                 ELSEIF ( forcing )  THEN
    1720                    force_bound_n = .TRUE.
     1687                   bc_radiation_n = .TRUE.
    17211688                ENDIF
    17221689             ENDIF
     
    18971864!--          Set non-cyclic boundary conditions on respective multigrid level
    18981865             IF ( .NOT. bc_ns_cyc )  THEN
    1899                 IF ( inflow_s  .OR.  outflow_s  .OR.  nest_bound_s  .OR.       &
    1900                      force_bound_s )  THEN
     1866                IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
    19011867!                    topo_tmp(:,-2,:) = topo_tmp(:,0,:)
    19021868                   topo_tmp(:,-1,:) = topo_tmp(:,0,:)
    19031869                ENDIF
    1904                 IF ( inflow_n  .OR.  outflow_n  .OR.  nest_bound_n  .OR.       &
    1905                      force_bound_n )  THEN
     1870                IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
    19061871!                    topo_tmp(:,nyn_l+2,:) = topo_tmp(:,nyn_l,:)
    19071872                   topo_tmp(:,nyn_l+1,:) = topo_tmp(:,nyn_l,:)
     
    19091874             ENDIF
    19101875             IF ( .NOT. bc_lr_cyc )  THEN
    1911                 IF ( inflow_l  .OR.  outflow_l  .OR.  nest_bound_l  .OR.       &
    1912                      force_bound_l )  THEN
     1876                IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
    19131877!                    topo_tmp(:,:,-2) = topo_tmp(:,:,0)
    19141878                   topo_tmp(:,:,-1) = topo_tmp(:,:,0)
    19151879                ENDIF
    1916                 IF ( inflow_r  .OR.  outflow_r  .OR.  nest_bound_r  .OR.       &
    1917                      force_bound_r )  THEN
     1880                IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
    19181881!                    topo_tmp(:,:,nxr_l+2) = topo_tmp(:,:,nxr_l)     
    19191882                   topo_tmp(:,:,nxr_l+1) = topo_tmp(:,:,nxr_l)   
  • TabularUnified palm/trunk/SOURCE/pres.f90

    r3016 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Rename variables for boundary flags and nesting
    2323!
    2424! Former revisions:
     
    161161
    162162    USE control_parameters,                                                    &
    163         ONLY:  bc_lr_cyc, bc_ns_cyc, conserve_volume_flow, coupling_mode,      &
     163        ONLY:  bc_lr_cyc, bc_ns_cyc, bc_radiation_l, bc_radiation_n,           &
     164               bc_radiation_r, bc_radiation_s, child_domain,                   &
     165               conserve_volume_flow, coupling_mode,                            &
    164166               dt_3d, gathered_size, ibc_p_b, ibc_p_t,                         &
    165167               intermediate_timestep_count, intermediate_timestep_count_max,   &
    166                mg_switch_to_pe0_level, nest_domain, outflow_l, outflow_n,      &
    167                outflow_r, outflow_s, psolver, subdomain_size, topography,      &
    168                volume_flow, volume_flow_area, volume_flow_initial
     168               mg_switch_to_pe0_level, psolver, subdomain_size,                &
     169               topography, volume_flow, volume_flow_area, volume_flow_initial
    169170
    170171    USE cpulog,                                                                &
     
    219220    REAL(wp), DIMENSION(1:nzt) ::  w_l_l               !<
    220221
    221     LOGICAL :: nest_domain_nvn      !<
     222    LOGICAL :: child_domain_nvn      !<
    222223
    223224
     
    280281!
    281282!-- Left/right
    282     IF ( conserve_volume_flow  .AND.  ( outflow_l .OR. outflow_r ) )  THEN
     283    IF ( conserve_volume_flow  .AND.  ( bc_radiation_l .OR.                    &
     284                                        bc_radiation_r ) )  THEN
    283285
    284286       volume_flow(1)   = 0.0_wp
    285287       volume_flow_l(1) = 0.0_wp
    286288
    287        IF ( outflow_l )  THEN
     289       IF ( bc_radiation_l )  THEN
    288290          i = 0
    289        ELSEIF ( outflow_r )  THEN
     291       ELSEIF ( bc_radiation_r )  THEN
    290292          i = nx+1
    291293       ENDIF
     
    325327!
    326328!-- South/north
    327     IF ( conserve_volume_flow  .AND.  ( outflow_n .OR. outflow_s ) )  THEN
     329    IF ( conserve_volume_flow  .AND.  ( bc_radiation_n .OR. bc_radiation_s ) )  THEN
    328330
    329331       volume_flow(2)   = 0.0_wp
    330332       volume_flow_l(2) = 0.0_wp
    331333
    332        IF ( outflow_s )  THEN
     334       IF ( bc_radiation_s )  THEN
    333335          j = 0
    334        ELSEIF ( outflow_n )  THEN
     336       ELSEIF ( bc_radiation_n )  THEN
    335337          j = ny+1
    336338       ENDIF
     
    372374!-- used both at bottom and top boundary, and if not a nested domain in a
    373375!-- normal nesting run. In case of vertical nesting, this must be done.
    374 !-- Therefore an auxiliary logical variable nest_domain_nvn is used here, and
     376!-- Therefore an auxiliary logical variable child_domain_nvn is used here, and
    375377!-- nvn stands for non-vertical nesting.
    376378!-- This cannot be done before the first initial time step because ngp_2dh_outer
    377379!-- is not yet known then.
    378     nest_domain_nvn = nest_domain
    379     IF ( nest_domain .AND. nesting_mode == 'vertical' )  THEN
    380        nest_domain_nvn = .FALSE.
     380    child_domain_nvn = child_domain
     381    IF ( child_domain .AND. nesting_mode == 'vertical' )  THEN
     382       child_domain_nvn = .FALSE.
    381383    ENDIF
    382384
    383385    IF ( ibc_p_b == 1  .AND.  ibc_p_t == 1  .AND.                               &
    384          .NOT. nest_domain_nvn  .AND. intermediate_timestep_count /= 0 )        &
     386         .NOT. child_domain_nvn  .AND. intermediate_timestep_count /= 0 )       &
    385387    THEN
    386388       w_l = 0.0_wp;  w_l_l = 0.0_wp
     
    758760!-- height nzt after above modifications. Hint: w level nzt+1 does not impact
    759761!-- results.
    760     IF (nest_domain .OR. coupling_mode == 'vnested_fine') THEN
     762    IF ( child_domain  .OR.  coupling_mode == 'vnested_fine' ) THEN
    761763       w(nzt+1,:,:) = w(nzt,:,:)
    762764    ENDIF
  • TabularUnified palm/trunk/SOURCE/prognostic_equations.f90

    r3022 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Remove unused variables from USE statements
    2323!
    2424! Former revisions:
     
    297297               cloud_physics, cloud_top_radiation, constant_diffusion,         &
    298298               dp_external, dp_level_ind_b, dp_smooth_factor, dpdxy, dt_3d,    &
    299                humidity,                                                       &
    300                inflow_l, intermediate_timestep_count,                          &
     299               humidity, intermediate_timestep_count,                          &
    301300               intermediate_timestep_count_max, large_scale_forcing,           &
    302301               large_scale_subsidence, microphysics_morrison,                  &
    303302               microphysics_seifert, microphysics_sat_adjust, neutral, nudging,&
    304                ocean, outflow_l, outflow_s, passive_scalar, plant_canopy,      &
     303               ocean, passive_scalar, plant_canopy,                            &
    305304               prho_reference, prho_reference,                                 &
    306305               prho_reference, pt_reference, pt_reference, pt_reference,       &
  • TabularUnified palm/trunk/SOURCE/read_restart_data_mod.f90

    r3065 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables for boundary flags
    2323!
    2424! Former revisions:
     
    17651765                      READ ( 13 )  tmp_3dwul
    17661766                   ENDIF
    1767                    IF ( outflow_l )  THEN
     1767                   IF ( bc_radiation_l )  THEN
    17681768                      u_m_l(:,nysc-nbgp:nync+nbgp,:) =                         &
    17691769                         tmp_3dwul(:,nysf-nbgp:nynf+nbgp,:)
     
    17761776                      READ ( 13 )  tmp_3dwun
    17771777                   ENDIF
    1778                    IF ( outflow_n )  THEN
     1778                   IF ( bc_radiation_n )  THEN
    17791779                      u_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    17801780                         tmp_3dwun(:,:,nxlf-nbgp:nxrf+nbgp)
     
    17871787                      READ ( 13 )  tmp_3dwur
    17881788                   ENDIF
    1789                    IF ( outflow_r )  THEN
     1789                   IF ( bc_radiation_r )  THEN
    17901790                      u_m_r(:,nysc-nbgp:nync+nbgp,:) =                         &
    17911791                         tmp_3dwur(:,nysf-nbgp:nynf+nbgp,:)
     
    17981798                      READ ( 13 )  tmp_3dwus
    17991799                   ENDIF
    1800                    IF ( outflow_s )  THEN
     1800                   IF ( bc_radiation_s )  THEN
    18011801                      u_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    18021802                         tmp_3dwus(:,:,nxlf-nbgp:nxrf+nbgp)
     
    18301830                      READ ( 13 )  tmp_3dwvl
    18311831                   ENDIF
    1832                    IF ( outflow_l )  THEN
     1832                   IF ( bc_radiation_l )  THEN
    18331833                      v_m_l(:,nysc-nbgp:nync+nbgp,:) =                         &
    18341834                         tmp_3dwvl(:,nysf-nbgp:nynf+nbgp,:)
     
    18411841                      READ ( 13 )  tmp_3dwvn
    18421842                   ENDIF
    1843                    IF ( outflow_n )  THEN
     1843                   IF ( bc_radiation_n )  THEN
    18441844                      v_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    18451845                         tmp_3dwvn(:,:,nxlf-nbgp:nxrf+nbgp)
     
    18521852                      READ ( 13 )  tmp_3dwvr
    18531853                   ENDIF
    1854                    IF ( outflow_r )  THEN
     1854                   IF ( bc_radiation_r )  THEN
    18551855                      v_m_r(:,nysc-nbgp:nync+nbgp,:) =                         &
    18561856                         tmp_3dwvr(:,nysf-nbgp:nynf+nbgp,:)
     
    18631863                      READ ( 13 )  tmp_3dwvs
    18641864                   ENDIF
    1865                    IF ( outflow_s )  THEN
     1865                   IF ( bc_radiation_s )  THEN
    18661866                      v_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    18671867                         tmp_3dwvs(:,:,nxlf-nbgp:nxrf+nbgp)
     
    19001900                      READ ( 13 )  tmp_3dwwl
    19011901                   ENDIF
    1902                    IF ( outflow_l )  THEN
     1902                   IF ( bc_radiation_l )  THEN
    19031903                      w_m_l(:,nysc-nbgp:nync+nbgp,:) =                         &
    19041904                         tmp_3dwwl(:,nysf-nbgp:nynf+nbgp,:)
     
    19111911                      READ ( 13 )  tmp_3dwwn
    19121912                   ENDIF
    1913                    IF ( outflow_n )  THEN
     1913                   IF ( bc_radiation_n )  THEN
    19141914                      w_m_n(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    19151915                         tmp_3dwwn(:,:,nxlf-nbgp:nxrf+nbgp)
     
    19221922                      READ ( 13 )  tmp_3dwwr
    19231923                   ENDIF
    1924                    IF ( outflow_r )  THEN
     1924                   IF ( bc_radiation_r )  THEN
    19251925                      w_m_r(:,nysc-nbgp:nync+nbgp,:) =                         &
    19261926                         tmp_3dwwr(:,nysf-nbgp:nynf+nbgp,:)
     
    19331933                      READ ( 13 )  tmp_3dwws
    19341934                   ENDIF
    1935                    IF ( outflow_s )  THEN
     1935                   IF ( bc_radiation_s )  THEN
    19361936                      w_m_s(:,:,nxlc-nbgp:nxrc+nbgp) =                         &
    19371937                         tmp_3dwws(:,:,nxlf-nbgp:nxrf+nbgp)
  • TabularUnified palm/trunk/SOURCE/sor.f90

    r2718 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables in mesoscale-offline nesting mode
    2323!
    2424! Former revisions:
    2525! -----------------
    2626! $Id$
     27! Corrected "Former revisions" section
     28!
     29! 2718 2018-01-02 08:49:38Z maronga
    2730! Corrected "Former revisions" section
    2831!
     
    8285
    8386    USE control_parameters,                                                    &
    84         ONLY:  bc_lr_cyc, bc_ns_cyc, force_bound_l, force_bound_n,             &
    85                force_bound_r, force_bound_s, ibc_p_b, ibc_p_t, inflow_l,       &
    86                inflow_n, inflow_r, inflow_s, nest_bound_l, nest_bound_n,       &
    87                nest_bound_r, nest_bound_s, n_sor, omega_sor, outflow_l,        &
    88                outflow_n, outflow_r, outflow_s
     87        ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
     88               bc_dirichlet_s, bc_lr_cyc, bc_ns_cyc, bc_radiation_l,           &
     89               bc_radiation_n, bc_radiation_r, bc_radiation_s, ibc_p_b,        &
     90               ibc_p_t, n_sor, omega_sor
    8991
    9092    IMPLICIT NONE
     
    175177!--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
    176178       IF ( .NOT. bc_lr_cyc )  THEN
    177           IF ( inflow_l      .OR.  outflow_l  .OR.                                 &
    178                nest_bound_l  .OR.  force_bound_l )  p(:,:,nxl-1) = p(:,:,nxl)
    179           IF ( inflow_r      .OR.  outflow_r  .OR.                                 &
    180                nest_bound_r  .OR.  force_bound_r )  p(:,:,nxr+1) = p(:,:,nxr)
     179          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  p(:,:,nxl-1) = p(:,:,nxl)
     180          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  p(:,:,nxr+1) = p(:,:,nxr)
    181181       ENDIF
    182182       IF ( .NOT. bc_ns_cyc )  THEN
    183           IF ( inflow_n      .OR.  outflow_n  .OR.                                 &
    184                nest_bound_n  .OR.  force_bound_n )  p(:,nyn+1,:) = p(:,nyn,:)
    185           IF ( inflow_s      .OR.  outflow_s  .OR.                                 &
    186                nest_bound_s  .OR.  force_bound_s )  p(:,nys-1,:) = p(:,nys,:)
     183          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  p(:,nyn+1,:) = p(:,nyn,:)
     184          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  p(:,nys-1,:) = p(:,nys,:)
    187185       ENDIF
    188186
     
    241239!--    Horizontal (Neumann) boundary conditions in case of non-cyclic boundaries
    242240       IF ( .NOT. bc_lr_cyc )  THEN
    243           IF ( inflow_l      .OR.  outflow_l  .OR.                             &
    244                nest_bound_l  .OR.  force_bound_l )  p(:,:,nxl-1) = p(:,:,nxl)
    245           IF ( inflow_r      .OR.  outflow_r  .OR.                             &
    246                nest_bound_r  .OR.  force_bound_r )  p(:,:,nxr+1) = p(:,:,nxr)
     241          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  p(:,:,nxl-1) = p(:,:,nxl)
     242          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  p(:,:,nxr+1) = p(:,:,nxr)
    247243       ENDIF
    248244       IF ( .NOT. bc_ns_cyc )  THEN
    249           IF ( inflow_n      .OR.  outflow_n  .OR.                             &
    250                nest_bound_n  .OR.  force_bound_n )  p(:,nyn+1,:) = p(:,nyn,:)
    251           IF ( inflow_s      .OR.  outflow_s  .OR.                             &
    252                nest_bound_s  .OR.  force_bound_s )  p(:,nys-1,:) = p(:,nys,:)
     245          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  p(:,nyn+1,:) = p(:,nyn,:)
     246          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  p(:,nys-1,:) = p(:,nys,:)
    253247       ENDIF
    254248
  • TabularUnified palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90

    r3065 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables and extend error message
     23! Enable geneartor also for stretched grids
    2324!
    2425! Former revisions:
     
    119120!> @bug  Height information from input file is not used. Profiles from input
    120121!>       must match with current PALM grid.
    121 !>       Transformation of length scales to number of gridpoints does not
    122 !>       consider grid stretching.
    123122!>       In case of restart, velocity seeds differ from precursor run if a11,
    124123!>       a22, or a33 are zero.
     
    160159    INCLUDE "mpif.h"
    161160#endif
     161
    162162
    163163    LOGICAL :: velocity_seed_initialized = .FALSE.  !< true after first call of stg_main
     
    317317
    318318    USE control_parameters,                                                    &
    319         ONLY:  bc_lr, bc_ns, forcing, nest_domain, number_stretch_level_start, &
    320                rans_mode, turbulent_inflow
     319        ONLY:  bc_lr, bc_ns, child_domain, nesting_offline,                    &
     320               number_stretch_level_start, rans_mode, turbulent_inflow
    321321
    322322    USE pmc_interface,                                                         &
     
    326326    IMPLICIT NONE
    327327
    328     IF ( .NOT. use_syn_turb_gen  .AND.  .NOT. rans_mode  .AND.  forcing )  THEN
    329        message_string = 'Synthetic turbulence generator has to be applied ' // &
    330                         'when forcing is used and model operates in LES mode.'
    331        CALL message( 'stg_check_parameters', 'PA0000', 1, 2, 0, 6, 0 )
     328    IF ( .NOT. use_syn_turb_gen  .AND.  .NOT. rans_mode  .AND.                 &
     329          nesting_offline )  THEN
     330       message_string = 'No synthetic turbulence generator is applied. ' //    &
     331                        'In case PALM operates in LES mode and lateral ' //    &
     332                        'boundary conditions are provided by COSMO model, ' // &
     333                        'turbulence may require large adjustment lenght at ' //&
     334                        'the lateral inflow boundaries. Please check your ' // &
     335                        'results carefully.'
     336       CALL message( 'stg_check_parameters', 'PA0000', 0, 0, 0, 6, 0 )
    332337    ENDIF
    333338
    334     IF ( .NOT. use_syn_turb_gen  .AND.  nest_domain                            &
     339    IF ( .NOT. use_syn_turb_gen  .AND.  child_domain                           &
    335340         .AND. rans_mode_parent  .AND.  .NOT. rans_mode )  THEN
    336341       message_string = 'Synthetic turbulence generator has to be applied ' // &
     
    342347    IF ( use_syn_turb_gen )  THEN
    343348
    344        IF ( .NOT. forcing  .AND.  .NOT. nest_domain )  THEN
    345 
     349       IF ( .NOT. nesting_offline  .AND.  .NOT. child_domain )  THEN
     350       
    346351          IF ( INDEX( initializing_actions, 'set_constant_profiles' ) == 0     &
    347352        .AND.  INDEX( initializing_actions, 'read_restart_data' ) == 0 )  THEN
     
    371376          CALL message( 'stg_check_parameters', 'PA0039', 1, 2, 0, 6, 0 )
    372377       ENDIF
    373        
    374        IF ( number_stretch_level_start > 0 )  THEN
    375           message_string = 'Using synthetic turbulence generator ' //          &
    376                            'in combination with stretching is not allowed'
    377           CALL message( 'stg_check_parameters', 'PA0420', 1, 2, 0, 6, 0 )
    378        ENDIF
    379378
    380379    ENDIF
     
    424423
    425424    USE control_parameters,                                                    &
    426         ONLY:  coupling_char, dz, e_init, forcing, nest_domain, rans_mode
     425        ONLY:  child_domain, coupling_char, dz, e_init, nesting_offline,       &
     426               rans_mode
    427427
    428428    USE grid_variables,                                                        &
     
    512512!        nzt_x_stg = myidx * nnz + MOD( nz , pdims(1) )
    513513
    514     IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
    515                    .NOT.  rans_mode ) )  THEN
     514    IF ( nesting_offline   .OR.  ( child_domain  .AND.  rans_mode_parent       &
     515                            .AND.  .NOT.  rans_mode ) )  THEN
    516516       nnz = nz / pdims(2)
    517517       nzb_y_stg = 1 + myidy * INT( nnz )
     
    558558!-- layer
    559559!-- stg_type_xz: xz-slice with vertical bounds nzb:nzt+1
    560     IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
    561                    .NOT.  rans_mode ) )  THEN
     560    IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent         &
     561                           .AND.  .NOT.  rans_mode ) )  THEN
    562562       CALL MPI_TYPE_CREATE_SUBARRAY( 2, [nzt-nzb+2,nxrg-nxlg+1],              &
    563563               [1,nxrg-nxlg+1], [0,0], MPI_ORDER_FORTRAN, MPI_REAL, newtype, ierr )
     
    612612       READ( 90, * )
    613613
    614        DO  k = nzb, nzt+1
     614       DO  k = nzb+1, nzt+1
    615615          READ( 90, * ) zz, luy, luz, tu(k), lvy, lvz, tv(k), lwy, lwz, tw(k), &
    616616                        r11(k), r21(k), r22(k), r31(k), r32(k), r33(k),        &
     
    618618
    619619!
    620 !--       Convert length scales from meter to number of grid points. Attention:
    621 !--       Does not work if grid stretching is used
     620!--       Convert length scales from meter to number of grid points.
    622621          nuy(k) = INT( luy * ddy )
    623           nuz(k) = INT( luz / dz(1) )
     622          nuz(k) = INT( luz * ddzw(k) )
    624623          nvy(k) = INT( lvy * ddy )
    625           nvz(k) = INT( lvz / dz(1) )
     624          nvz(k) = INT( lvz * ddzw(k) )
    626625          nwy(k) = INT( lwy * ddy )
    627           nwz(k) = INT( lwz / dz(1) )
     626          nwz(k) = INT( lwz * ddzw(k) )
    628627!
    629628!--       Workaround, assume isotropic turbulence
     
    640639          ENDIF
    641640       ENDDO
    642 
     641!
     642!--    Set lenght scales at surface grid point
     643       nuy(nzb) = nuy(nzb+1)
     644       nuz(nzb) = nuz(nzb+1)
     645       nvy(nzb) = nvy(nzb+1)
     646       nvz(nzb) = nvz(nzb+1)
     647       nwy(nzb) = nwy(nzb+1)
     648       nwz(nzb) = nwz(nzb+1)
     649       
    643650       CLOSE( 90 )
    644651
     
    710717!
    711718!-- Assign initial profiles
    712     IF ( .NOT. forcing  .AND.  .NOT.  nest_domain )  THEN
     719    IF ( .NOT. nesting_offline  .AND.  .NOT.  child_domain )  THEN
    713720       u_init = mean_inflow_profiles(:,1)
    714721       v_init = mean_inflow_profiles(:,2)
     
    10421049
    10431050    USE control_parameters,                                                    &
    1044         ONLY:  dt_3d, forcing, intermediate_timestep_count,  nest_domain,      &
    1045                rans_mode, simulated_time, volume_flow_initial
     1051        ONLY:  child_domain, dt_3d, intermediate_timestep_count,               &
     1052               nesting_offline, rans_mode, simulated_time, volume_flow_initial
    10461053
    10471054    USE grid_variables,                                                        &
     
    10861093       CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fw_yz, id_stg_left )
    10871094
    1088        IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.        &
    1089                       .NOT.  rans_mode ) )  THEN
     1095       IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent      &
     1096                                .AND.  .NOT.  rans_mode ) )  THEN
    10901097!
    10911098!--       Generate turbulence at right boundary
     
    11121119    CALL stg_generate_seed_yz( nwy, nwz, bwy, bwz, fwo_yz, id_stg_left )
    11131120
    1114     IF ( forcing  .OR.  ( nest_domain .AND.  rans_mode_parent  .AND.           &
    1115                    .NOT.  rans_mode ) )  THEN
     1121    IF ( nesting_offline  .OR.  ( child_domain .AND.  rans_mode_parent         &
     1122                             .AND.  .NOT.  rans_mode ) )  THEN
    11161123!
    11171124!--       Generate turbulence at right boundary
     
    11911198!--    This correction factor insures that the mass flux is preserved at the
    11921199!--    inflow boundary
    1193        IF ( .NOT. forcing  .AND.  .NOT. nest_domain )  THEN
     1200       IF ( .NOT. nesting_offline  .AND.  .NOT. child_domain )  THEN
    11941201          mc_factor_l = 0.0_wp
    11951202          mc_factor   = 0.0_wp
  • TabularUnified palm/trunk/SOURCE/time_integration.f90

    r3176 r3182  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Replace simulated_time by time_since_reference_point in COSMO nesting mode.
     23! Rename subroutines and variables in COSMO nesting mode
    2324!
    2425! Former revisions:
     
    368369        ONLY:  advected_distance_x, advected_distance_y, air_chemistry,        &
    369370               average_count_3d, averaging_interval, averaging_interval_pr,    &
    370                bc_lr_cyc, bc_ns_cyc, bc_pt_t_val,                              &
    371                bc_q_t_val, call_psolver_at_all_substeps, cloud_droplets,       &
     371               bc_lr_cyc, bc_ns_cyc, bc_pt_t_val, bc_q_t_val,                  &
     372               call_psolver_at_all_substeps,  child_domain, cloud_droplets,    &
    372373               cloud_physics, constant_flux_layer, constant_heatflux,          &
    373374               create_disturbances, dopr_n, constant_diffusion, coupling_mode, &
     
    378379               dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_domask,dt_dopts, dt_dopr,   &
    379380               dt_dopr_listing, dt_dots, dt_dvrp, dt_run_control, end_time,    &
    380                first_call_lpm, first_call_mas, forcing, galilei_transformation,&
     381               first_call_lpm, first_call_mas, galilei_transformation,         &
    381382               humidity, intermediate_timestep_count,                          &
    382                intermediate_timestep_count_max, land_surface,                  &
    383                large_scale_forcing, loop_optimization, lsf_surf, lsf_vert,     &
    384                masks, microphysics_morrison, microphysics_seifert, mid,        &
    385                nest_domain, neutral, nr_timesteps_this_run, nudging,           &
     383               intermediate_timestep_count_max,                                &
     384               land_surface, large_scale_forcing,                              &
     385               loop_optimization, lsf_surf, lsf_vert, masks,                   &
     386               microphysics_morrison, microphysics_seifert, mid,               &
     387               nesting_offline, neutral, nr_timesteps_this_run, nudging,       &
    386388               ocean, passive_scalar, prho_reference, pt_reference,            &
    387389               pt_slope_offset, random_heatflux, rans_mode,                    &
     
    426428    USE lsf_nudging_mod,                                                       &
    427429        ONLY:  calc_tnudge, ls_forcing_surf, ls_forcing_vert, nudge_ref,       &
    428                forcing_bc, forcing_bc_mass_conservation
    429 
    430     USE netcdf_data_input_mod,                                                 &
    431         ONLY:  force, netcdf_data_input_lsf
     430               lsf_nesting_offline, lsf_nesting_offline_mass_conservation
    432431
    433432    USE microphysics_mod,                                                      &
    434433        ONLY: collision_turbulence
     434
     435    USE netcdf_data_input_mod,                                                 &
     436        ONLY:  nest_offl, netcdf_data_input_lsf
    435437
    436438    USE multi_agent_system_mod,                                                &
     
    594596!--    If forcing by larger-scale models is applied, check if new data
    595597!--    at domain boundaries need to be read.
    596        IF ( forcing )  THEN
    597           IF ( force%time(force%tind_p) <= simulated_time )                    &
     598       IF ( nesting_offline )  THEN
     599          IF ( nest_offl%time(nest_offl%tind_p) <= time_since_reference_point )&
    598600             CALL netcdf_data_input_lsf
    599601       ENDIF
     
    843845!--          Commented out April 18, 2018 as seemingly unnecessary.
    844846!--          Will later be completely removed.
    845 !--             IF ( nest_domain )  THEN
     847!--             IF ( child_domain )  THEN
    846848!--                CALL pmci_ensure_nest_mass_conservation
    847849!--             ENDIF
     850
    848851
    849852             CALL cpu_log( log_point(60), 'nesting', 'stop' )
     
    888891                   CALL disturb_field( 'v', tend, v )
    889892                ELSEIF ( ( .NOT. bc_lr_cyc  .OR.  .NOT. bc_ns_cyc )            &
    890                      .AND. .NOT. nest_domain  .AND.  .NOT.  forcing )  THEN
     893                     .AND. .NOT. child_domain  .AND.  .NOT.  nesting_offline )  &
     894                THEN
    891895!
    892896!--                Runs with a non-cyclic lateral wall need perturbations
     
    904908!--       Map forcing data derived from larger scale model onto domain
    905909!--       boundaries.
    906           IF ( forcing  .AND.  intermediate_timestep_count ==                  &
    907                                intermediate_timestep_count_max  )  THEN
    908              CALL forcing_bc
     910          IF ( nesting_offline  .AND.  intermediate_timestep_count ==          &
     911                                       intermediate_timestep_count_max  )  THEN
     912             CALL lsf_nesting_offline
    909913!
    910914!--          Moreover, ensure mass conservation
    911              CALL forcing_bc_mass_conservation
     915             CALL lsf_nesting_offline_mass_conservation
    912916          ENDIF
    913917
  • TabularUnified palm/trunk/SOURCE/turbulence_closure_mod.f90

    r3145 r3182  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Rename variables and remove unused variable from USE statement
    2323!
    2424! Former revisions:
     
    149149
    150150    USE control_parameters,                                                    &
    151         ONLY:  constant_diffusion, dt_3d, e_init, humidity, inflow_l,          &
     151        ONLY:  constant_diffusion, dt_3d, e_init, humidity,                    &
    152152               initializing_actions, intermediate_timestep_count,              &
    153153               intermediate_timestep_count_max, kappa, km_constant,            &
     
    212212
    213213    REAL(wp), DIMENSION(:), ALLOCATABLE ::  l_black    !< mixing length according to Blackadar
     214
    214215    REAL(wp), DIMENSION(:), ALLOCATABLE ::  l_grid     !< geometric mean of grid sizes dx, dy, dz
    215216
     
    378379
    379380    USE control_parameters,                                                    &
    380         ONLY:  message_string, nest_domain, neutral, turbulent_inflow,         &
    381                turbulent_outflow
     381        ONLY:  message_string, neutral, turbulent_inflow, turbulent_outflow
    382382
    383383    IMPLICIT NONE
     
    10491049
    10501050    USE control_parameters,                                                    &
    1051         ONLY:  complex_terrain, dissipation_1d, topography
     1051        ONLY:  bc_dirichlet_l, complex_terrain, dissipation_1d, topography
    10521052
    10531053    USE model_1d_mod,                                                          &
     
    12521252!--       Use these mean profiles at the inflow (provided that Dirichlet
    12531253!--       conditions are used)
    1254           IF ( inflow_l )  THEN
     1254          IF ( bc_dirichlet_l )  THEN
    12551255             DO  j = nysg, nyng
    12561256                DO  k = nzb, nzt+1
     
    46134613
    46144614    USE control_parameters,                                                    &
    4615         ONLY:  e_min, outflow_l, outflow_n, outflow_r, outflow_s
     4615        ONLY:  bc_radiation_l, bc_radiation_n, bc_radiation_r, bc_radiation_s, &
     4616               e_min
    46164617
    46174618    USE surface_layer_fluxes_mod,                                              &
     
    47724773!-- Set Neumann boundary conditions at the outflow boundaries in case of
    47734774!-- non-cyclic lateral boundaries
    4774     IF ( outflow_l )  THEN
     4775    IF ( bc_radiation_l )  THEN
    47754776       km(:,:,nxl-1) = km(:,:,nxl)
    47764777       kh(:,:,nxl-1) = kh(:,:,nxl)
    47774778    ENDIF
    4778     IF ( outflow_r )  THEN
     4779    IF ( bc_radiation_r )  THEN
    47794780       km(:,:,nxr+1) = km(:,:,nxr)
    47804781       kh(:,:,nxr+1) = kh(:,:,nxr)
    47814782    ENDIF
    4782     IF ( outflow_s )  THEN
     4783    IF ( bc_radiation_s )  THEN
    47834784       km(:,nys-1,:) = km(:,nys,:)
    47844785       kh(:,nys-1,:) = kh(:,nys,:)
    47854786    ENDIF
    4786     IF ( outflow_n )  THEN
     4787    IF ( bc_radiation_n )  THEN
    47874788       km(:,nyn+1,:) = km(:,nyn,:)
    47884789       kh(:,nyn+1,:) = kh(:,nyn,:)
  • TabularUnified palm/trunk/SOURCE/virtual_flight_mod.f90

    r3065 r3182  
    978978
    979979       IMPLICIT NONE
    980 
    981980 
    982981       CALL wrd_write_string( 'u_agl' )
     
    984983
    985984       CALL wrd_write_string( 'v_agl' )
     985
    986986       WRITE ( 14 )  v_agl
    987987
     
    997997       CALL wrd_write_string( 'z_pos' )
    998998       WRITE ( 14 )  z_pos
    999 
    1000999       
    10011000    END SUBROUTINE flight_wrd_global   
  • TabularUnified palm/trunk/SOURCE/wind_turbine_model_mod.f90

    r3174 r3182  
    15651565!--          Interpolation of lift and drag coefficiencts on fine grid of radius
    15661566!--          segments and angles of attack
     1567
    15671568             turb_cl_tab(iialpha,iir) = ( alpha_attack_tab(ialpha) -           &
    15681569                                          alpha_attack_i ) /                   &
  • TabularUnified palm/trunk/UTIL/inifor/Makefile

    r2718 r3182  
    2020# Current revisions:
    2121# -----------------
     22# Added __netcdf4 preprocessor flag
    2223#
    2324#
     
    5152                  -Wline-truncation -fbacktrace -fcheck=all -pedantic \
    5253                  -ffpe-trap=invalid,zero,underflow,overflow
    53 FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS)
     54FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS) -cpp -D__netcdf4
    5455INCLUDE = -I/home/ekadasch/local/include
    5556LIBRARY = -L/home/ekadasch/local/lib64 -lnetcdff
  • TabularUnified palm/trunk/UTIL/inifor/Makefile.gnu

    r2718 r3182  
    2020# Current revisions:
    2121# -----------------
    22 #
     22# Added __netcdf4 preprocessor flag
     23# Corrected compilation order
     24#
    2325#
    2426# Former revisions:
     
    4345TEST_PATH = $(PROJECT_PATH)/tests
    4446
    45 MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/control.mod $(SRC_PATH)/util.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
     47MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/util.mod $(SRC_PATH)/control.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
    4648SOURCES = $(MODULES:%.mod=%.f90) $(SRC_PATH)/$(PROJECT).f90
    4749OBJECTS = $(SOURCES:%.f90=%.o)
     
    5153                  -Wline-truncation -fbacktrace -fcheck=all -pedantic \
    5254                  -ffpe-trap=invalid,zero,underflow,overflow
    53 FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS)
     55FFLAGS  = -fdefault-real-8 -Og -g $(WRNGS) -cpp -D__netcdf4
    5456INCLUDE = -I/home/ekadasch/local/include
    5557LIBRARY = -L/home/ekadasch/local/lib64 -lnetcdff
     
    5759.PHONY: all clean doc run tags test test-verbose $(PROJECT)
    5860
    59 $(PROJECT): $(OBJECTS) $(MODULES)
     61$(PROJECT): $(OBJECTS) $(MODULES) tags
    6062        @echo ""
    6163        mkdir -p $(BIN_PATH)
     
    7880        rm -rf ./doc/latex ./doc/html
    7981        rm -f $(SRC_PATH)/tags
    80         rm -f *.files
    81         rm -f palm-hsurf.nc
    8282        $(MAKE) -C $(TEST_PATH) clean
    8383        $(MAKE) -C $(SRC_PATH) clean
  • TabularUnified palm/trunk/UTIL/inifor/Makefile.ifort

    r2718 r3182  
    2020# Current revisions:
    2121# -----------------
    22 #
     22# Added __netcdf4 preprocessor flag
     23# Corrected compilation order
     24#
    2325#
    2426# Former revisions:
     
    4345TEST_PATH = $(PROJECT_PATH)/tests
    4446
    45 MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/control.mod $(SRC_PATH)/util.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
     47MODULES = $(SRC_PATH)/defs.mod $(SRC_PATH)/util.mod $(SRC_PATH)/control.mod $(SRC_PATH)/types.mod $(SRC_PATH)/transform.mod $(SRC_PATH)/io.mod $(SRC_PATH)/grid.mod
    4648SOURCES = $(MODULES:%.mod=%.f90) $(SRC_PATH)/$(PROJECT).f90
    4749OBJECTS = $(SOURCES:%.f90=%.o)
    4850
    4951FC      = ifort
    50 FFLAGS  = -g -real-size 64 -no-wrap-margin
     52FFLAGS  = -g -real-size 64 -no-wrap-margin -cpp -D__netcdf4
    5153INCLUDE = -I/usr/local/pkg/netcdf/4.3.2/include
    5254LIBRARY = -L/usr/local/pkg/netcdf/4.3.2/lib -lnetcdff
     
    5456.PHONY: all clean doc run tags test test-verbose $(PROJECT)
    5557
    56 $(PROJECT): $(OBJECTS) $(MODULES)
     58$(PROJECT): $(OBJECTS) $(MODULES) tags
    5759        @echo ""
    5860        mkdir -p $(BIN_PATH)
     
    7577        rm -rf ./doc/latex ./doc/html
    7678        rm -f $(SRC_PATH)/tags
    77         rm -f *.files
    78         rm -f palm-hsurf.nc
    7979        $(MAKE) -C $(TEST_PATH) clean
    80         $(MAKE) -C $(SRC_PATH) tags
     80        $(MAKE) -C $(SRC_PATH) clean
    8181
    8282doc:
  • TabularUnified palm/trunk/UTIL/inifor/README

    r2696 r3182  
    1 INIFOR - Initialization and Forcing of PALM-4U (v1.1.5)
     1# INIFOR - Mesoscale Interface for Initializing and Forcing PALM-4U (v1.3.0)
    22
    33INIFOR provides the meteorological fields required to initialize and drive the
     
    55interpolated from output data of the meso-scale model COSMO.
    66
    7 COMPILATION
     7
     8## COMPILATION
    89
    9101. Customize ./Makefile and ./tests/Makefile (netCDF library location, compiler
    1011   and parameters, use Makefile.ifort as a template if you want to use the Intel
    1112   Fortran compiler)
    12 2. $ make
     132. Run `make`
    1314
    14 USAGE
    1515
    16 1. Customize ./namelist (number or grid points and spacings, end_time)
    17 2. $ ./bin/inifor -path <scenario path> -date <YYYYMMDD> -clat <latitude> -clon <longitude>
     16## USAGE
    1817
    19 All COMMAND-LINE PARAMETERS
     181. Customize `./namelist` (number or grid points and spacings, end_time)
     192. Run `current_version/trunk/SCRIPTS/inifor -path <scenario path> -date <YYYYMMDD>`
    2020
    21 -date <date>: Start date of the simulation in the form YYYMMDD. Currently,
    22     INIFOR assumes that the simulation starts at O UTC on that day.
    23     Default: 20130721
    2421
    25 -hhl <netCDF file>: Location of the netCDF file containing the vertical COSMO-DE
    26     grid (hhh = height of half layers, i.e. vertical cell faces).
    27     Default: <scenario path>/hhl.nc
     22## AVAILABLE NAMELIST PARAMETERS
    2823
    29 -mode profile: Produce average profiles instead of three-dimensional fields as
    30     initial conditions.
     24INIFOR mirrors a subset of the PALM-4U's Fortran namelists `inipar` and `d3par`
     25and supports the following parameters:
    3126
    32 -n <namelist file>: Location of the PALM-4U namelist file. INIFOR expects the
    33     file to contain two namelists, inipar and d3par, from which it will read
    34     grid parameters and the simulation time. Default: ./namelist
    3527
    36 -o <ouput file>: Name of the INIFOR output file. Default: ./palm-4u-input.nc
     28### inipar
    3729
    38 -p0 <pressure>: Surface pressure at z=0 in the PALM-4U domain [Pa].
    39     Default: 1e5 Pa = 1000 hPa
     30    nx, ny, nz - number of PALM-4U grid points in x, y, and z direction
     31    dx, dy, dz(10) - PALM-4U grid spacings in x, y, and z direction [m]
     32    dz_stretch_level - height above which the grid will be stretched [m]
     33    dz_stretch_factor - factor by which the grid will be stretched
     34    dz_max - maximum vertical grid spacing [m]
     35    dz_stretch_level_start(9) - array of height levels above which the grid is
     36    to be stretched vertically [m]
     37    dz_stretch_level_end(9) - array of height levels until which the grid is to
     38    be stretched vertically [m]
     39    longitude, latitude - geographical coordinates of the PALM-4U origin [deg]
    4040
    41 -path <scenario path>: Scenario path, i.e. the path of the meteorological input
    42     data. Default: ./
    4341
    44 -soil <netCDF file>: Location of the netCDF file containing the COSMO-DE soil type
    45     map.
    46     Default: <scenario path>/soil.nc
     42### d3par
    4743
    48 -static <static driver file>: Location of the netCDF file containing the static
    49     driver file for the case to be simulated with PALM-4U. Optional parameter.
    50     Default: None
     44    end_time - PALM-4U simulation time. INIFOR will produce hourly forcing data
     45        from the start date (see -d command-line option) to end_time seconds
     46        thereafter. [s]
    5147
    52 -ug <velocity>: Specifies the geostrophic wind in x direction [m/s]. Default: 0
    5348
    54 -vg <velocity>: Specifies the geostrophic wind in y direction [m/s]. Default: 0
     49### EXAMPLE NAMELIST FILE
    5550
    56 -z0 <height>: Specifies the elevation of the the PALM-4U domain above sea level [m].
    57     Default: 35 m
     51    &inipar nx = 4679, ny = 3939, nz = 360
     52            dx = 10., dy = 10., dz = 10.
     53            dz_stretch_level = 2500.0, dz_stretch_factor = 1.08, dz_max = 100.0
     54            longitude = 13.082744, latitude = 52.325079
     55    /
     56   
     57    &d3par  end_time = 86400.0
     58    /
    5859
     60
     61## AVAILABLE COMMAND-LINE PARAMETERS
     62
     63    -d, --date, -date <date>:
     64        Start date of the simulation in the form YYYYMMDD of YYYYMMDDHH. If no
     65        hours (HH) are given, INIFOR assumes that the simulation starts at O UTC
     66        on that day. Default: 20130721
     67       
     68    -i, --init-mode, -mode <mode>:
     69        Set the PALM-4U initialization mode. INIFOR can provide initial conditions
     70        as either profiles or three-dimensional fields. The corresponding modes
     71        are 'profile' and 'volume'. Default: volume
     72
     73    -l, --hhl-file, -hhl <netCDF file>:
     74        Location of the netCDF file containing the vertical COSMO-DE grid levels,
     75        specifically the heights of half levels (hhl, i.e. vertical cell faces).
     76        Default: <scenario path>/hhl.nc
     77
     78    -n, --namelist <namelist file>:
     79        Location of the PALM-4U namelist file. INIFOR expects the file to contain
     80        two namelists, inipar and d3par, from which it will read grid parameters
     81        and the simulation time. Default: ./namelist
     82
     83    -o, --output <output file>:
     84        Name of the INIFOR output file, i.e. the PALM-4U dynamic driver.
     85        Default: ./palm-4u-input.nc
     86
     87    -p, --path, -path <scenario path>:
     88        Scenario path, i.e. the path of the meteorological input data. Default: ./
     89
     90    -r, --surface-pressure, -p0 <pressure>:
     91        Surface pressure at z=0 in the PALM-4U domain [Pa].
     92        Default: 1e5
     93
     94    -s, --soil-file, -soil <netCDF file>:
     95        Location of the netCDF file containing the COSMO-DE soil type map.
     96        Default: <scenario path>/soil.nc
     97
     98    -t, --static-driver, -static <netCDF file>:
     99        Location of the netCDF file containing the static driver file for the case
     100        to be simulated with PALM-4U. Optional parameter. Default: None
     101
     102    -u, --geostrophic-u, -ug <velocity>:
     103        Specifies the geostrophic wind in x direction [m/s]. Default: 0
     104
     105    -v, --geostrophic-v, -vg <velocity>:
     106        Specifies the geostrophic wind in y direction [m/s]. Default: 0
     107
     108    --version:
     109        Output version number and exit.
     110
     111    -z, --elevation, -z0 <height>: Specifies the elevation of the PALM-4U domain
     112        above sea level [m]. Default: 35
     113
     114
     115## ADDITIONAL COMMAND-LINE OPTIONS
     116
     117    --flow-prefix <prefix>:
     118        Set the file prefix of flow input files. Default: laf
     119
     120    --radiation-prefix <prefix>:
     121        Set the file prefix of radiation input files. Default: laf
     122
     123    --soil-prefix <prefix>:
     124        Set the file prefix of soil input files. Default: laf
     125
     126    --soilmoisture-prefix <prefix>:
     127        Set the file prefix of soil moisture input files. Default: laf
  • TabularUnified palm/trunk/UTIL/inifor/src/control.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Added version and copyright output
    2324!
    2425!
     
    4243
    4344    USE defs,                                                                  &
    44         ONLY:  LNAME, dp
     45        ONLY:  LNAME, dp, VERSION, COPYRIGHT
    4546
    4647    USE util,                                                                  &
     
    9596
    9697    END SUBROUTINE abort
     98
     99
     100    SUBROUTINE print_version()
     101       PRINT *, "INIFOR " // VERSION
     102       PRINT *, COPYRIGHT
     103    END SUBROUTINE print_version
    97104
    98105
  • TabularUnified palm/trunk/UTIL/inifor/src/defs.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Updated defaults for soil extrapolation steps and nudging time-scale
     24! Improved handling of the start date string
     25! Added gas constant for water vapor
     26! Bumped INIFOR version number
    2327!
    2428!
     
    6266 REAL(dp), PARAMETER ::  T_SL = 288.15_dp                     !< Reference temperature for computation of COSMO-DE's basic state pressure [K]
    6367 REAL(dp), PARAMETER ::  BETA = 42.0_dp                       !< logarithmic lapse rate, dT / d ln(p), for computation of COSMO-DE's basic state pressure [K]
    64  REAL(dp), PARAMETER ::  RD   = 287.05_dp                     !< specific gar constant of dry air, used in computation of COSMO-DE's basic state [J/kg/K]
     68 REAL(dp), PARAMETER ::  RD   = 287.05_dp                     !< specific gas constant of dry air, used in computation of COSMO-DE's basic state [J/kg/K]
     69 REAL(dp), PARAMETER ::  RV   = 461.51_dp                     !< specific gas constant of water vapor [J/kg/K]
    6570 REAL(dp), PARAMETER ::  G    = 9.80665_dp                    !< acceleration of Earth's gravity, used in computation of COSMO-DE's basic state [m/s/s]
    6671 REAL(dp), PARAMETER ::  RHO_L = 1e3_dp                       !< density of liquid water, used to convert W_SO from [kg/m^2] to [m^3/m^3], in [kg/m^3]
     
    7277
    7378 ! INIFOR parameters
    74  INTEGER, PARAMETER          ::  FILL_ITERATIONS = 10         !< Number of iterations for extrapolating soil data into COSMO-DE water cells [-]
    75  REAL(dp), PARAMETER         ::  FORCING_FREQ = 3600.0_dp     !< Reference pressure for potential temperature [Pa]
    76  CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.1.4'            !< path to script for generating input file names
     79 INTEGER, PARAMETER          ::  FILL_ITERATIONS = 5          !< Number of iterations for extrapolating soil data into COSMO-DE water cells [-]
     80 INTEGER, PARAMETER          ::  FORCING_STEP = 1             !< Number of hours between forcing time steps [h]
     81 REAL(dp), PARAMETER         ::  NUDGING_TAU = 21600.0_dp     !< Nudging relaxation time scale [s]
     82 CHARACTER(LEN=*), PARAMETER ::  VERSION = '1.3.0'            !< INIFOR version number
     83 CHARACTER(LEN=*), PARAMETER ::  COPYRIGHT = 'Copyright 2017-2018 Leibniz Universitaet Hannover' // &
     84     NEW_LINE(' ') // ' Copyright 2017-2018 Deutscher Wetterdienst Offenbach' !< Copyright notice
    7785
    7886 END MODULE defs
  • TabularUnified palm/trunk/UTIL/inifor/src/grid.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
    23 !
     23! Introduced new PALM grid stretching
     24! Updated variable names and metadata for PIDS v1.9 compatibility
     25! Better compatibility with older Intel compilers:
     26! - avoiding implicit array allocation with new get_netcdf_variable()
     27!   subroutine instead of function
     28! Improved command line interface:
     29! - Produce forcing variables when '-mode profile' is being used
     30! - Renamend initial-condition mode variable 'mode' to 'ic_mode'
     31! - Improved handling of the start date string
     32! Removed unnecessary variables and routines
     33!
    2434!
    2535! Former revisions:
     
    4757    USE defs,                                                                  &
    4858        ONLY:  DATE, EARTH_RADIUS, TO_RADIANS, TO_DEGREES, PI, dp, hp, sp,     &
    49                SNAME, LNAME, PATH, FORCING_FREQ, WATER_ID, FILL_ITERATIONS,    &
     59               SNAME, LNAME, PATH, FORCING_STEP, WATER_ID, FILL_ITERATIONS,    &
    5060               BETA, P_SL, T_SL, BETA, RD, G, P_REF, RD_PALM, CP_PALM, RHO_L
    5161    USE io,                                                                    &
    5262        ONLY:  get_netcdf_variable, get_netcdf_attribute,                      &
    53                parse_command_line_arguments
     63               parse_command_line_arguments, validate_config
    5464    USE netcdf,                                                                &
    5565        ONLY:  NF90_MAX_NAME, NF90_MAX_VAR_DIMS
     
    6777    SAVE
    6878   
    69     REAL(dp) ::  phi_equat = 0.0_dp    !< latitude of rotated equator of COSMO-DE grid [rad]
    70     REAL(dp) ::  phi_n     = 0.0_dp    !< latitude of rotated pole of COSMO-DE grid [rad]
    71     REAL(dp) ::  lambda_n  = 0.0_dp    !< longitude of rotaded pole of COSMO-DE grid [rad]
    72     REAL(dp) ::  phi_c     = 0.0_dp    !< rotated-grid latitude of the center of the PALM domain [rad]
    73     REAL(dp) ::  lambda_c  = 0.0_dp    !< rotated-grid longitude of the centre of the PALM domain [rad]
    74     REAL(dp) ::  phi_cn    = 0.0_dp    !< latitude of the rotated pole relative to the COSMO-DE grid [rad]
    75     REAL(dp) ::  lambda_cn = 0.0_dp    !< longitude of the rotated pole relative to the COSMO-DE grid [rad]
    76     REAL(dp) ::  gam       = 0.0_dp    !< angle for working around phirot2phi/rlarot2rla bug
    77     REAL(dp) ::  dx        = 0.0_dp    !< PALM-4U grid spacing in x direction [m]
    78     REAL(dp) ::  dy        = 0.0_dp    !< PALM-4U grid spacing in y direction [m]
    79     REAL(dp) ::  dz        = 0.0_dp    !< PALM-4U grid spacing in z direction [m]
    80     REAL(dp) ::  dxi       = 0.0_dp    !< inverse PALM-4U grid spacing in x direction [m^-1]
    81     REAL(dp) ::  dyi       = 0.0_dp    !< inverse PALM-4U grid spacing in y direction [m^-1]
    82     REAL(dp) ::  dzi       = 0.0_dp    !< inverse PALM-4U grid spacing in z direction [m^-1]
    83     REAL(dp) ::  lx        = 0.0_dp    !< PALM-4U domain size in x direction [m]
    84     REAL(dp) ::  ly        = 0.0_dp    !< PALM-4U domain size in y direction [m]
    85     REAL(dp) ::  lz        = 0.0_dp    !< PALM-4U domain size in z direction [m]
    86     REAL(dp) ::  ug        = 0.0_dp    !< geostrophic wind in x direction [m/s]
    87     REAL(dp) ::  vg        = 0.0_dp    !< geostrophic wind in y direction [m/s]
    88     REAL(dp) ::  p0        = 0.0_dp    !< PALM-4U surface pressure, at z0 [Pa]
    89     REAL(dp) ::  x0        = 0.0_dp    !< x coordinate of PALM-4U Earth tangent [m]
    90     REAL(dp) ::  y0        = 0.0_dp    !< y coordinate of PALM-4U Earth tangent [m]
    91     REAL(dp) ::  z0        = 0.0_dp    !< Elevation of the PALM-4U domain above sea level [m]
    92     REAL(dp) ::  lonmin    = 0.0_dp    !< Minimunm longitude of COSMO-DE's rotated-pole grid
    93     REAL(dp) ::  lonmax    = 0.0_dp    !< Maximum longitude of COSMO-DE's rotated-pole grid
    94     REAL(dp) ::  latmin    = 0.0_dp    !< Minimunm latitude of COSMO-DE's rotated-pole grid
    95     REAL(dp) ::  latmax    = 0.0_dp    !< Maximum latitude of COSMO-DE's rotated-pole grid
    96     REAL(dp) ::  latitude  = 0.0_dp    !< geograpohical latitude of the PALM-4U origin, from inipar namelist [deg]
    97     REAL(dp) ::  longitude = 0.0_dp    !< geograpohical longitude of the PALM-4U origin, from inipar namelist [deg]
    98     REAL(dp) ::  origin_lat= 0.0_dp    !< geograpohical latitude of the PALM-4U origin, from static driver netCDF file [deg]
    99     REAL(dp) ::  origin_lon= 0.0_dp    !< geograpohical longitude of the PALM-4U origin, from static driver netCDF file [deg]
    100     REAL(dp) ::  end_time  = 0.0_dp    !< PALM-4U simulation time [s]
     79    REAL(dp) ::  phi_equat         = 0.0_dp       !< latitude of rotated equator of COSMO-DE grid [rad]
     80    REAL(dp) ::  phi_n             = 0.0_dp       !< latitude of rotated pole of COSMO-DE grid [rad]
     81    REAL(dp) ::  lambda_n          = 0.0_dp       !< longitude of rotaded pole of COSMO-DE grid [rad]
     82    REAL(dp) ::  phi_c             = 0.0_dp       !< rotated-grid latitude of the center of the PALM domain [rad]
     83    REAL(dp) ::  lambda_c          = 0.0_dp       !< rotated-grid longitude of the centre of the PALM domain [rad]
     84    REAL(dp) ::  phi_cn            = 0.0_dp       !< latitude of the rotated pole relative to the COSMO-DE grid [rad]
     85    REAL(dp) ::  lambda_cn         = 0.0_dp       !< longitude of the rotated pole relative to the COSMO-DE grid [rad]
     86    REAL(dp) ::  gam               = 0.0_dp       !< angle for working around phirot2phi/rlarot2rla bug
     87    REAL(dp) ::  dx                = 0.0_dp       !< PALM-4U grid spacing in x direction [m]
     88    REAL(dp) ::  dy                = 0.0_dp       !< PALM-4U grid spacing in y direction [m]
     89    REAL(dp) ::  dz(10)            = -1.0_dp      !< PALM-4U grid spacing in z direction [m]
     90    REAL(dp) ::  dz_max            = 1000.0_dp    !< maximum vertical grid spacing [m]
     91    REAL(dp) ::  dz_stretch_factor = 1.08_dp      !< factor for vertical grid stretching [m]
     92    REAL(dp) ::  dz_stretch_level  = -9999999.9_dp!< height above which the vertical grid will be stretched [m]
     93    REAL(dp) ::  dz_stretch_level_start(9) = -9999999.9_dp !< namelist parameter
     94    REAL(dp) ::  dz_stretch_level_end(9) = 9999999.9_dp !< namelist parameter
     95    REAL(dp) ::  dz_stretch_factor_array(9) = 1.08_dp !< namelist parameter
     96    REAL(dp) ::  dxi               = 0.0_dp       !< inverse PALM-4U grid spacing in x direction [m^-1]
     97    REAL(dp) ::  dyi               = 0.0_dp       !< inverse PALM-4U grid spacing in y direction [m^-1]
     98    REAL(dp) ::  dzi               = 0.0_dp       !< inverse PALM-4U grid spacing in z direction [m^-1]
     99    REAL(dp) ::  lx                = 0.0_dp       !< PALM-4U domain size in x direction [m]
     100    REAL(dp) ::  ly                = 0.0_dp       !< PALM-4U domain size in y direction [m]
     101    REAL(dp) ::  ug                = 0.0_dp       !< geostrophic wind in x direction [m/s]
     102    REAL(dp) ::  vg                = 0.0_dp       !< geostrophic wind in y direction [m/s]
     103    REAL(dp) ::  p0                = 0.0_dp       !< PALM-4U surface pressure, at z0 [Pa]
     104    REAL(dp) ::  x0                = 0.0_dp       !< x coordinate of PALM-4U Earth tangent [m]
     105    REAL(dp) ::  y0                = 0.0_dp       !< y coordinate of PALM-4U Earth tangent [m]
     106    REAL(dp) ::  z0                = 0.0_dp       !< Elevation of the PALM-4U domain above sea level [m]
     107    REAL(dp) ::  z_top             = 0.0_dp       !< height of the scalar top boundary [m]
     108    REAL(dp) ::  zw_top            = 0.0_dp       !< height of the vertical velocity top boundary [m]
     109    REAL(dp) ::  lonmin            = 0.0_dp       !< Minimunm longitude of COSMO-DE's rotated-pole grid
     110    REAL(dp) ::  lonmax            = 0.0_dp       !< Maximum longitude of COSMO-DE's rotated-pole grid
     111    REAL(dp) ::  latmin            = 0.0_dp       !< Minimunm latitude of COSMO-DE's rotated-pole grid
     112    REAL(dp) ::  latmax            = 0.0_dp       !< Maximum latitude of COSMO-DE's rotated-pole grid
     113    REAL(dp) ::  latitude          = 0.0_dp       !< geographical latitude of the PALM-4U origin, from inipar namelist [deg]
     114    REAL(dp) ::  longitude         = 0.0_dp       !< geographical longitude of the PALM-4U origin, from inipar namelist [deg]
     115    REAL(dp) ::  origin_lat        = 0.0_dp       !< geographical latitude of the PALM-4U origin, from static driver netCDF file [deg]
     116    REAL(dp) ::  origin_lon        = 0.0_dp       !< geographical longitude of the PALM-4U origin, from static driver netCDF file [deg]
     117    REAL(dp) ::  rotation_angle    = 0.0_dp       !< clockwise angle the PALM-4U north is rotated away from geographical north [deg]
     118    REAL(dp) ::  end_time          = 0.0_dp       !< PALM-4U simulation time [s]
    101119
    102120    REAL(dp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  hhl             !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from external file
     
    106124    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  rlon            !< longitudes of COSMO-DE's rotated-pole grid
    107125    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  rlat            !< latitudes of COSMO-DE's rotated-pole grid
    108     REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  time
     126    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  time            !< output times
     127    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  x               !< base palm grid x coordinate vector pointed to by grid_definitions
     128    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  xu              !< base palm grid xu coordinate vector pointed to by grid_definitions
     129    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  y               !< base palm grid y coordinate vector pointed to by grid_definitions
     130    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  yv              !< base palm grid yv coordinate vector pointed to by grid_definitions
     131    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  z_column        !< base palm grid z coordinate vector including the top boundary coordinate (entire column)
     132    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  zw_column       !< base palm grid zw coordinate vector including the top boundary coordinate (entire column)
     133    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  z               !< base palm grid z coordinate vector pointed to by grid_definitions
     134    REAL(dp), DIMENSION(:), ALLOCATABLE, TARGET     ::  zw              !< base palm grid zw coordinate vector pointed to by grid_definitions
    109135
    110136    INTEGER(hp), DIMENSION(:,:,:), ALLOCATABLE, TARGET ::  soiltyp      !< COSMO-DE soil type map
     137    INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
     138    INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
    111139    INTEGER ::  i     !< indexing variable
    112     INTEGER ::  imin, imax, jmin, jmax !< index ranges for profile averaging
     140    INTEGER ::  average_imin, average_imax, average_jmin, average_jmax !< index ranges for profile averaging
    113141    INTEGER ::  k     !< indexing variable
    114142    INTEGER ::  nt    !< number of output time steps
     
    130158    LOGICAL ::  init_variables_required
    131159    LOGICAL ::  boundary_variables_required
     160    LOGICAL ::  ls_forcing_variables_required
     161    LOGICAL ::  profile_grids_required
    132162
    133163    INTEGER ::  n_invar = 0 !< number of variables in the input variable table
     
    193223    TYPE(io_group), ALLOCATABLE, TARGET ::  io_group_list(:)  !< List of I/O groups, which group together output variables that share the same input variable
    194224 
    195     NAMELIST /inipar/ nx, ny, nz, dx, dy, dz, longitude, latitude
     225    NAMELIST /inipar/ nx, ny, nz, dx, dy, dz, longitude, latitude,             &
     226                      dz_max, dz_stretch_factor, dz_stretch_level,             & !< old grid stretching parameters
     227                      dz_stretch_level_start, dz_stretch_level_end               !< new grid stretching parameters
    196228    NAMELIST /d3par/  end_time
    197229   
    198230    CHARACTER(LEN=LNAME) ::  nc_source_text     = ''  !< Text describing the source of the output data, e.g. 'COSMO-DE analysis from ...'
    199     CHARACTER(LEN=DATE)  ::  start_date         = ''  !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation
    200     CHARACTER(LEN=PATH)  ::  hhl_file           = ''  !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces)
    201     CHARACTER(LEN=PATH)  ::  namelist_file      = ''  !< Path to the PALM-4U namelist file
    202     CHARACTER(LEN=PATH)  ::  static_driver_file = ''  !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
    203     CHARACTER(LEN=PATH)  ::  soiltyp_file       = ''  !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
    204     CHARACTER(LEN=PATH)  ::  input_path         = ''  !< Path to the input data file directory
    205231    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  flow_files
    206232    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  soil_moisture_files
     
    212238    CHARACTER(LEN=SNAME) ::  radiation_suffix     !< Suffix of radiation input files, e.g. 'radiation'
    213239    CHARACTER(LEN=SNAME) ::  soilmoisture_suffix  !< Suffix of input files for soil moisture spin-up, e.g. 'soilmoisture'
    214     CHARACTER(LEN=SNAME) ::  mode                 !< INIFOR's initialization mode, 'profile' or 'volume'
    215240                         
    216241    TYPE(nc_file) ::  output_file
     242
     243    TYPE(inifor_config) ::  cfg !< Container of INIFOR configuration
    217244
    218245 CONTAINS
     
    224251! Section 1: Define default parameters
    225252!------------------------------------------------------------------------------
    226        start_date = '2013072100'
     253       cfg % start_date = '2013072100'
    227254       end_hour = 2
    228255       start_hour_soil = -2
     
    249276       origin_lat = 52.325079_dp * TO_RADIANS ! south-west of Berlin, origin used for the Dec 2017 showcase simulation
    250277       origin_lon = 13.082744_dp * TO_RADIANS
    251        z0 = 35.0_dp
     278       cfg % z0 = 35.0_dp
    252279
    253280       ! Default atmospheric parameters
    254281       ug = 0.0_dp
    255282       vg = 0.0_dp
    256        p0 = P_SL
     283       cfg % p0 = P_SL
    257284
    258285       ! Parameters for file names
     
    262289       start_hour_soilmoisture = start_hour_flow - 2
    263290       end_hour_soilmoisture = start_hour_flow
    264        step_hour = 1
     291       step_hour = FORCING_STEP
     292
    265293       input_prefix = 'laf'  ! 'laf' for COSMO-DE analyses
     294       cfg % flow_prefix = input_prefix
     295       cfg % soil_prefix = input_prefix
     296       cfg % radiation_prefix = input_prefix
     297       cfg % soilmoisture_prefix  = input_prefix
     298
    266299       flow_suffix = '-flow'
    267300       soil_suffix = '-soil'
     
    273306!------------------------------------------------------------------------------
    274307
    275        ! Set default paths
    276        input_path         = './'
    277        hhl_file           = ''
    278        soiltyp_file       = ''
    279        namelist_file      = './namelist'
    280        output_file % name = './palm-4u-input.nc'
     308       ! Set default paths and modes
     309       cfg % input_path         = './'
     310       cfg % hhl_file           = ''
     311       cfg % soiltyp_file       = ''
     312       cfg % namelist_file      = './namelist'
     313       cfg % static_driver_file = ''
     314       cfg % output_file = './palm-4u-input.nc'
     315       cfg % ic_mode = 'volume'
     316       cfg % bc_mode = 'real'
    281317
    282318       ! Update default file names and domain centre
    283        CALL parse_command_line_arguments( start_date, hhl_file, soiltyp_file,  &
    284                static_driver_file, input_path, output_file % name,             &
    285                namelist_file, ug, vg, p0, z0, mode )
    286 
    287        init_variables_required     = .TRUE.
    288        boundary_variables_required = (TRIM(mode) .NE. 'profile')
    289 
    290        CALL normalize_path(input_path)
    291        IF (TRIM(hhl_file) == '')  hhl_file = TRIM(input_path) // 'hhl.nc'
    292        IF (TRIM(soiltyp_file) == '')  soiltyp_file = TRIM(input_path) // 'soil.nc'
    293 
    294        CALL report('setup_parameters', "       data path: " // TRIM(input_path))
    295        CALL report('setup_parameters', "        hhl file: " // TRIM(hhl_file))
    296        CALL report('setup_parameters', "    soiltyp file: " // TRIM(soiltyp_file))
    297        CALL report('setup_parameters', "   namelist file: " // TRIM(namelist_file))
    298        CALL report('setup_parameters', "output data file: " // TRIM(output_file % name))
     319       CALL parse_command_line_arguments( cfg )
     320
     321       output_file % name = cfg % output_file
     322       z0 = cfg % z0
     323       p0 = cfg % p0
     324
     325       init_variables_required = .TRUE.
     326       boundary_variables_required = TRIM( cfg % bc_mode ) == 'real'
     327       ls_forcing_variables_required = TRIM( cfg % bc_mode ) == 'ideal'
     328
     329       IF ( ls_forcing_variables_required )  THEN
     330          message = "Averaging of large-scale forcing profiles " //            &
     331                    "has not been implemented, yet."
     332          CALL abort('setup_parameters', message)
     333       END IF
     334
     335       CALL normalize_path(cfg % input_path)
     336       IF (TRIM(cfg % hhl_file) == '')  cfg % hhl_file = TRIM(cfg % input_path) // 'hhl.nc'
     337       IF (TRIM(cfg % soiltyp_file) == '')  cfg % soiltyp_file = TRIM(cfg % input_path) // 'soil.nc'
     338
     339       CALL validate_config( cfg )
     340
     341       CALL report('setup_parameters', "initialization mode: " // TRIM(cfg % ic_mode))
     342       CALL report('setup_parameters', "       forcing mode: " // TRIM(cfg % bc_mode))
     343       CALL report('setup_parameters', "          data path: " // TRIM(cfg % input_path))
     344       CALL report('setup_parameters', "           hhl file: " // TRIM(cfg % hhl_file))
     345       CALL report('setup_parameters', "       soiltyp file: " // TRIM(cfg % soiltyp_file))
     346       CALL report('setup_parameters', "      namelist file: " // TRIM(cfg % namelist_file))
     347       CALL report('setup_parameters', "   output data file: " // TRIM(output_file % name))
    299348
    300349 CALL run_control('time', 'init')
    301350       ! Read in namelist parameters
    302        OPEN(10, FILE=namelist_file)
     351       OPEN(10, FILE=cfg % namelist_file)
    303352       READ(10, NML=inipar) ! nx, ny, nz, dx, dy, dz
    304353       READ(10, NML=d3par)  ! end_time
     
    306355 CALL run_control('time', 'read')
    307356
    308        end_hour = CEILING(end_time / FORCING_FREQ)
     357       end_hour = CEILING( end_time / 3600.0 * step_hour )
    309358
    310359       ! Generate input file lists
    311        CALL input_file_list(start_date, start_hour_flow, end_hour, step_hour,  &
    312           input_path, input_prefix, flow_suffix, flow_files)
    313        CALL input_file_list(start_date, start_hour_soil, end_hour, step_hour,  &
    314           input_path, input_prefix, soil_suffix, soil_files)
    315        CALL input_file_list(start_date, start_hour_radiation, end_hour, step_hour, &
    316           input_path, input_prefix, radiation_suffix, radiation_files)
    317        CALL input_file_list(start_date, start_hour_soilmoisture, end_hour_soilmoisture, step_hour, &
    318           input_path, input_prefix, soilmoisture_suffix, soil_moisture_files)
     360       CALL get_input_file_list(cfg % start_date, start_hour_flow, end_hour, step_hour,  &
     361          cfg % input_path, cfg % flow_prefix, flow_suffix, flow_files)
     362       CALL get_input_file_list(cfg % start_date, start_hour_soil, end_hour, step_hour,  &
     363          cfg % input_path, cfg % soil_prefix, soil_suffix, soil_files)
     364       CALL get_input_file_list(cfg % start_date, start_hour_radiation, end_hour, step_hour, &
     365          cfg % input_path, cfg % radiation_prefix, radiation_suffix, radiation_files)
     366       CALL get_input_file_list(cfg % start_date, start_hour_soilmoisture, end_hour_soilmoisture, step_hour, &
     367          cfg % input_path, cfg % soilmoisture_prefix, soilmoisture_suffix, soil_moisture_files)
    319368
    320369!
     
    322371! Section 3: Check for consistency
    323372!------------------------------------------------------------------------------
    324        IF (dx*dy*dz .EQ. 0.0_dp)  THEN
    325           message = "Grid cells have zero volume. Grid spacings are probably"//&
    326              " set incorrectly in namelist file '" // TRIM(namelist_file) // "'."
    327           CALL abort('setup_parameters', message)
    328        END IF
     373
    329374!
    330375!------------------------------------------------------------------------------
     
    339384       ! Read COSMO-DE soil type map
    340385       cosmo_var % name = 'SOILTYP'
    341        soiltyp = NINT(get_netcdf_variable(soiltyp_file, cosmo_var), hp)
     386       CALL get_netcdf_variable(cfg % soiltyp_file, cosmo_var, soiltyp)
    342387
    343388       message = 'Reading PALM-4U origin from'
    344        IF (TRIM(static_driver_file) .NE. '')  THEN
    345 
    346           origin_lon = get_netcdf_attribute(static_driver_file, 'origin_lon')
    347           origin_lat = get_netcdf_attribute(static_driver_file, 'origin_lat')
     389       IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
     390
     391          origin_lon = get_netcdf_attribute(cfg % static_driver_file, 'origin_lon')
     392          origin_lat = get_netcdf_attribute(cfg % static_driver_file, 'origin_lat')
    348393
    349394          message = TRIM(message) // " static driver file '"                   &
    350                                   // TRIM(static_driver_file) // "'"
     395                                  // TRIM(cfg % static_driver_file) // "'"
    351396
    352397
     
    357402
    358403          message = TRIM(message) // " namlist file '"                         &
    359                                   // TRIM(namelist_file) // "'"
     404                                  // TRIM(cfg % namelist_file) // "'"
    360405
    361406       END IF
     
    368413       ! Read in COSMO-DE heights of half layers (vertical cell faces)
    369414       cosmo_var % name = 'HHL'
    370        hhl = get_netcdf_variable(hhl_file, cosmo_var)
     415       CALL get_netcdf_variable(cfg % hhl_file, cosmo_var, hhl)
    371416 CALL run_control('time', 'read')
    372417
     
    392437       lx = (nx+1) * dx
    393438       ly = (ny+1) * dy
    394        lz = (nz+1) * dz
    395439       
    396440       ! PALM-4U point of Earth tangency
     
    399443
    400444       ! time vector
    401        nt = CEILING(end_time / FORCING_FREQ) + 1
     445       nt = CEILING(end_time / (step_hour * 3600.0_dp)) + 1
    402446       ALLOCATE( time(nt) )
    403447       CALL linspace(0.0_dp, 3600.0_dp * (nt-1), time)
     
    463507    SUBROUTINE setup_grids() ! setup_grids(inifor_settings(with nx, ny, nz,...))
    464508       CHARACTER ::  interp_mode
    465        
     509
    466510!------------------------------------------------------------------------------
    467 ! Section 1: Define model and initialization grids
     511! Section 0: Define base PALM-4U grid coordinate vectors
     512!------------------------------------------------------------------------------
     513       ! palm x y z, we allocate the column to nz+1 in order to include the top
     514       ! scalar boundary. The interpolation grids will be associated with
     515       ! a shorter column that omits the top element.
     516       
     517       ALLOCATE( x(0:nx), y(0:ny), z(1:nz), z_column(1:nz+1) )
     518       CALL linspace(0.5_dp * dx, lx - 0.5_dp * dx, x)
     519       CALL linspace(0.5_dp * dy, ly - 0.5_dp * dy, y)
     520       CALL stretched_z(z_column, dz, dz_max=dz_max,                           &
     521                        dz_stretch_factor=dz_stretch_factor,                   &
     522                        dz_stretch_level=dz_stretch_level,                     &
     523                        dz_stretch_level_start=dz_stretch_level_start,         &
     524                        dz_stretch_level_end=dz_stretch_level_end,             &
     525                        dz_stretch_factor_array=dz_stretch_factor_array)
     526       z(1:nz) = z_column(1:nz)
     527       z_top = z_column(nz+1)
     528
     529       ! palm xu yv zw, compared to the scalar grid, velocity coordinates
     530       ! contain one element less.
     531       ALLOCATE( xu(1:nx),  yv(1:ny), zw(1:nz-1), zw_column(1:nz))
     532       CALL linspace(dx, lx - dx, xu)
     533       CALL linspace(dy, ly - dy, yv)
     534       CALL midpoints(z_column, zw_column)
     535       zw(1:nz-1) = zw_column(1:nz-1)
     536       zw_top     = zw_column(nz)
     537
     538
     539!------------------------------------------------------------------------------
     540! Section 1: Define initialization and boundary grids
    468541!------------------------------------------------------------------------------
    469542       CALL init_grid_definition('palm', grid=palm_grid,                       &
    470543               xmin=0.0_dp, xmax=lx,                                           &
    471544               ymin=0.0_dp, ymax=ly,                                           &
    472                zmin=0.0_dp, zmax=lz, x0=x0, y0=y0, z0=z0,                      &
    473                nx=nx, ny=ny, nz=nz, mode=mode)
     545               x0=x0, y0=y0, z0=z0,                      &
     546               nx=nx, ny=ny, nz=nz, z=z, zw=zw, ic_mode=cfg % ic_mode)
    474547
    475548       ! Subtracting 1 because arrays will be allocated with nlon + 1 elements.
     
    477550               xmin=lonmin, xmax=lonmax,                                       &
    478551               ymin=latmin, ymax=latmax,                                       &
    479                zmin=0.0_dp, zmax=51.0_dp, x0=x0, y0=y0, z0=0.0_dp,             &
     552               x0=x0, y0=y0, z0=0.0_dp,             &
    480553               nx=nlon-1, ny=nlat-1, nz=nlev-1)
    481554
     
    487560               xmin=0.0_dp, xmax=lx,                                           &
    488561               ymin=0.0_dp, ymax=ly,                                           &
    489                zmin=0.0_dp, zmax=lz, x0=x0, y0=y0, z0=z0,                      &
     562               x0=x0, y0=y0, z0=z0,                      &
    490563               nx=nx, ny=ny, nz=nlev-2)
    491564
     
    493566               xmin = dx, xmax = lx - dx,                                      &
    494567               ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    495                zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    496568               x0=x0, y0=y0, z0 = z0,                                          &
    497569               nx = nx-1, ny = ny, nz = nz,                                    &
    498                dx = dx, dy = dy, dz = dz, mode=mode)
     570               z=z, ic_mode=cfg % ic_mode)
    499571
    500572       CALL init_grid_definition('boundary', grid=v_initial_grid,              &
    501573               xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    502574               ymin = dy, ymax = ly - dy,                                      &
    503                zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    504575               x0=x0, y0=y0, z0 = z0,                                          &
    505576               nx = nx, ny = ny-1, nz = nz,                                    &
    506                dx = dx, dy = dy, dz = dz, mode=mode)
     577               z=z, ic_mode=cfg % ic_mode)
    507578
    508579       CALL init_grid_definition('boundary', grid=w_initial_grid,              &
    509580               xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    510581               ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    511                zmin = dz, zmax = lz - dz,                                      &
    512582               x0=x0, y0=y0, z0 = z0,                                          &
    513583               nx = nx, ny = ny, nz = nz-1,                                    &
    514                dx = dx, dy = dy, dz = dz, mode=mode)
     584               z=zw, ic_mode=cfg % ic_mode)
    515585
    516586       CALL init_grid_definition('boundary intermediate', grid=u_initial_intermediate,      &
    517587               xmin = dx, xmax = lx - dx,                                      &
    518588               ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    519                zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    520589               x0=x0, y0=y0, z0 = z0,                                          &
    521                nx = nx-1, ny = ny, nz = nlev - 2,                              &
    522                dx = dx, dy = dy, dz = dz)
     590               nx = nx-1, ny = ny, nz = nlev - 2)
    523591
    524592       CALL init_grid_definition('boundary intermediate', grid=v_initial_intermediate,      &
    525593               xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    526594               ymin = dy, ymax = ly - dy,                                      &
    527                zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    528595               x0=x0, y0=y0, z0 = z0,                                          &
    529                nx = nx, ny = ny-1, nz = nlev - 2,                              &
    530                dx = dx, dy = dy, dz = dz)
     596               nx = nx, ny = ny-1, nz = nlev - 2)
    531597
    532598       CALL init_grid_definition('boundary intermediate', grid=w_initial_intermediate,      &
    533599               xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    534600               ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    535                zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    536601               x0=x0, y0=y0, z0 = z0,                                          &
    537                nx = nx, ny = ny, nz = nlev - 2,                                &
    538                dx = dx, dy = dy, dz = dz)
     602               nx = nx, ny = ny, nz = nlev - 2)
    539603
    540604      IF (boundary_variables_required)  THEN
     
    546610                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    547611                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    548                   zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
    549                   x0=x0, y0=y0, z0 = z0,                                          &
    550                   nx = 0, ny = ny, nz = nz,                                       &
    551                   dx = dx, dy = dy, dz = dz)
     612                  x0=x0, y0=y0, z0 = z0,                                          &
     613                  nx = 0, ny = ny, nz = nz, z=z)
    552614
    553615          CALL init_grid_definition('boundary', grid=scalars_west_grid,           &
    554616                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    555617                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    556                   zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
    557                   x0=x0, y0=y0, z0 = z0,                                          &
    558                   nx = 0, ny = ny, nz = nz,                                       &
    559                   dx = dx, dy = dy, dz = dz)
     618                  x0=x0, y0=y0, z0 = z0,                                          &
     619                  nx = 0, ny = ny, nz = nz, z=z)
    560620
    561621          CALL init_grid_definition('boundary', grid=scalars_north_grid,          &
    562622                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    563623                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    564                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    565                   x0=x0, y0=y0, z0 = z0,                                          &
    566                   nx = nx, ny = 0, nz = nz,                                       &
    567                   dx = dx, dy = dy, dz = dz)
     624                  x0=x0, y0=y0, z0 = z0,                                          &
     625                  nx = nx, ny = 0, nz = nz, z=z)
    568626
    569627          CALL init_grid_definition('boundary', grid=scalars_south_grid,          &
    570628                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    571629                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    572                   zmin =  0.5_dp * dz, zmax = lz - 0.5_dp * dz,                   &
    573                   x0=x0, y0=y0, z0 = z0,                                          &
    574                   nx = nx, ny = 0, nz = nz,                                       &
    575                   dx = dx, dy = dy, dz = dz)
     630                  x0=x0, y0=y0, z0 = z0,                                          &
     631                  nx = nx, ny = 0, nz = nz, z=z)
    576632
    577633          CALL init_grid_definition('boundary', grid=scalars_top_grid,            &
    578634                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    579635                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    580                   zmin =  lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,              &
    581                   x0=x0, y0=y0, z0 = z0,                                          &
    582                   nx = nx, ny = ny, nz = 0,                                       &
    583                   dx = dx, dy = dy, dz = dz)
     636                  x0=x0, y0=y0, z0 = z0,                                          &
     637                  nx = nx, ny = ny, nz = 1, z=(/z_top/))
    584638
    585639          CALL init_grid_definition('boundary', grid=u_east_grid,                 &
    586640                  xmin = lx, xmax = lx,                                           &
    587641                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    588                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    589                   x0=x0, y0=y0, z0 = z0,                                          &
    590                   nx = 0, ny = ny, nz = nz,                                       &
    591                   dx = dx, dy = dy, dz = dz)
     642                  x0=x0, y0=y0, z0 = z0,                                          &
     643                  nx = 0, ny = ny, nz = nz, z=z)
    592644
    593645          CALL init_grid_definition('boundary', grid=u_west_grid,                 &
    594646                  xmin = 0.0_dp, xmax = 0.0_dp,                                   &
    595647                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    596                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    597                   x0=x0, y0=y0, z0 = z0,                                          &
    598                   nx = 0, ny = ny, nz = nz,                                       &
    599                   dx = dx, dy = dy, dz = dz)
     648                  x0=x0, y0=y0, z0 = z0,                                          &
     649                  nx = 0, ny = ny, nz = nz, z=z)
    600650
    601651          CALL init_grid_definition('boundary', grid=u_north_grid,                &
    602652                  xmin = dx, xmax = lx - dx,                                      &
    603653                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    604                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    605                   x0=x0, y0=y0, z0 = z0,                                          &
    606                   nx = nx-1, ny = 0, nz = nz,                                     &
    607                   dx = dx, dy = dy, dz = dz)
    608 
     654                  x0=x0, y0=y0, z0 = z0,                                          &
     655                  nx = nx-1, ny = 0, nz = nz, z=z)
     656   
    609657          CALL init_grid_definition('boundary', grid=u_south_grid,                &
    610658                  xmin = dx, xmax = lx - dx,                                      &
    611659                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    612                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    613                   x0=x0, y0=y0, z0 = z0,                                          &
    614                   nx = nx-1, ny = 0, nz = nz,                                     &
    615                   dx = dx, dy = dy, dz = dz)
     660                  x0=x0, y0=y0, z0 = z0,                                          &
     661                  nx = nx-1, ny = 0, nz = nz, z=z)
    616662
    617663          CALL init_grid_definition('boundary', grid=u_top_grid,                  &
    618664                  xmin = dx, xmax = lx - dx,                                      &
    619665                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    620                   zmin = lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,               &
    621                   x0=x0, y0=y0, z0 = z0,                                          &
    622                   nx = nx-1, ny = ny, nz = 0,                                     &
    623                   dx = dx, dy = dy, dz = dz)
     666                  x0=x0, y0=y0, z0 = z0,                                          &
     667                  nx = nx-1, ny = ny, nz = 1, z=(/z_top/))
    624668
    625669          CALL init_grid_definition('boundary', grid=v_east_grid,                 &
    626670                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    627671                  ymin = dy, ymax = ly - dy,                                      &
    628                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    629                   x0=x0, y0=y0, z0 = z0,                                          &
    630                   nx = 0, ny = ny-1, nz = nz,                                     &
    631                   dx = dx, dy = dy, dz = dz)
     672                  x0=x0, y0=y0, z0 = z0,                                          &
     673                  nx = 0, ny = ny-1, nz = nz, z=z)
    632674
    633675          CALL init_grid_definition('boundary', grid=v_west_grid,                 &
    634676                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    635677                  ymin = dy, ymax = ly - dy,                                      &
    636                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    637                   x0=x0, y0=y0, z0 = z0,                                          &
    638                   nx = 0, ny = ny-1, nz = nz,                                     &
    639                   dx = dx, dy = dy, dz = dz)
     678                  x0=x0, y0=y0, z0 = z0,                                          &
     679                  nx = 0, ny = ny-1, nz = nz, z=z)
    640680
    641681          CALL init_grid_definition('boundary', grid=v_north_grid,                &
    642682                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    643683                  ymin = ly, ymax = ly,                                           &
    644                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    645                   x0=x0, y0=y0, z0 = z0,                                          &
    646                   nx = nx, ny = 0, nz = nz,                                       &
    647                   dx = dx, dy = dy, dz = dz)
     684                  x0=x0, y0=y0, z0 = z0,                                          &
     685                  nx = nx, ny = 0, nz = nz, z=z)
    648686
    649687          CALL init_grid_definition('boundary', grid=v_south_grid,                &
    650688                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    651689                  ymin = 0.0_dp, ymax = 0.0_dp,                                   &
    652                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                    &
    653                   x0=x0, y0=y0, z0 = z0,                                          &
    654                   nx = nx, ny = 0, nz = nz,                                       &
    655                   dx = dx, dy = dy, dz = dz)
     690                  x0=x0, y0=y0, z0 = z0,                                          &
     691                  nx = nx, ny = 0, nz = nz, z=z)
    656692
    657693          CALL init_grid_definition('boundary', grid=v_top_grid,                  &
    658694                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    659695                  ymin = dy, ymax = ly - dy,                                      &
    660                   zmin = lz + 0.5_dp * dz, zmax = lz + 0.5_dp * dz,               &
    661                   x0=x0, y0=y0, z0 = z0,                                          &
    662                   nx = nx, ny = ny-1, nz = 0,                                     &
    663                   dx = dx, dy = dy, dz = dz)
     696                  x0=x0, y0=y0, z0 = z0,                                          &
     697                  nx = nx, ny = ny-1, nz = 1, z=(/z_top/))
    664698
    665699          CALL init_grid_definition('boundary', grid=w_east_grid,                 &
    666700                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    667701                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    668                   zmin =  dz, zmax = lz - dz,                                     &
    669                   x0=x0, y0=y0, z0 = z0,                                          &
    670                   nx = 0, ny = ny, nz = nz - 1,                                   &
    671                   dx = dx, dy = dy, dz = dz)
     702                  x0=x0, y0=y0, z0 = z0,                                          &
     703                  nx = 0, ny = ny, nz = nz - 1, z=zw)
    672704
    673705          CALL init_grid_definition('boundary', grid=w_west_grid,                 &
    674706                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    675707                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    676                   zmin = dz, zmax = lz - dz,                                      &
    677                   x0=x0, y0=y0, z0 = z0,                                          &
    678                   nx = 0, ny = ny, nz = nz - 1,                                   &
    679                   dx = dx, dy = dy, dz = dz)
     708                  x0=x0, y0=y0, z0 = z0,                                          &
     709                  nx = 0, ny = ny, nz = nz - 1, z=zw)
    680710
    681711          CALL init_grid_definition('boundary', grid=w_north_grid,                &
    682712                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    683713                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    684                   zmin = dz, zmax = lz - dz,                                      &
    685                   x0=x0, y0=y0, z0 = z0,                                          &
    686                   nx = nx, ny = 0, nz = nz - 1,                                   &
    687                   dx = dx, dy = dy, dz = dz)
     714                  x0=x0, y0=y0, z0 = z0,                                          &
     715                  nx = nx, ny = 0, nz = nz - 1, z=zw)
    688716
    689717          CALL init_grid_definition('boundary', grid=w_south_grid,                &
    690718                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    691719                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    692                   zmin = dz, zmax = lz - dz,                                      &
    693                   x0=x0, y0=y0, z0 = z0,                                          &
    694                   nx = nx, ny = 0, nz = nz - 1,                                   &
    695                   dx = dx, dy = dy, dz = dz)
     720                  x0=x0, y0=y0, z0 = z0,                                          &
     721                  nx = nx, ny = 0, nz = nz - 1, z=zw)
    696722
    697723          CALL init_grid_definition('boundary', grid=w_top_grid,                  &
    698724                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    699725                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    700                   zmin = lz, zmax = lz,                                           &
    701                   x0=x0, y0=y0, z0 = z0,                                          &
    702                   nx = nx, ny = ny, nz = 0,                                       &
    703                   dx = dx, dy = dy, dz = dz)
     726                  x0=x0, y0=y0, z0 = z0,                                          &
     727                  nx = nx, ny = ny, nz = 1, z=(/zw_top/))
    704728
    705729          CALL init_grid_definition('boundary intermediate', grid=scalars_east_intermediate,   &
    706730                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    707731                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    708                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    709                   x0=x0, y0=y0, z0 = z0,                                          &
    710                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    711                   dx = dx, dy = dy, dz = dz)
     732                  x0=x0, y0=y0, z0 = z0,                                          &
     733                  nx = 0, ny = ny, nz = nlev - 2)
    712734
    713735          CALL init_grid_definition('boundary intermediate', grid=scalars_west_intermediate,   &
    714736                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    715737                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    716                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    717                   x0=x0, y0=y0, z0 = z0,                                          &
    718                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    719                   dx = dx, dy = dy, dz = dz)
     738                  x0=x0, y0=y0, z0 = z0,                                          &
     739                  nx = 0, ny = ny, nz = nlev - 2)
    720740
    721741          CALL init_grid_definition('boundary intermediate', grid=scalars_north_intermediate,  &
    722742                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    723743                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    724                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    725                   x0=x0, y0=y0, z0 = z0,                                          &
    726                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    727                   dx = dx, dy = dy, dz = dz)
     744                  x0=x0, y0=y0, z0 = z0,                                          &
     745                  nx = nx, ny = 0, nz = nlev - 2)
    728746
    729747          CALL init_grid_definition('boundary intermediate', grid=scalars_south_intermediate,  &
    730748                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    731749                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    732                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    733                   x0=x0, y0=y0, z0 = z0,                                          &
    734                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    735                   dx = dx, dy = dy, dz = dz)
     750                  x0=x0, y0=y0, z0 = z0,                                          &
     751                  nx = nx, ny = 0, nz = nlev - 2)
    736752
    737753          CALL init_grid_definition('boundary intermediate', grid=scalars_top_intermediate,    &
    738754                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    739755                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    740                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    741                   x0=x0, y0=y0, z0 = z0,                                          &
    742                   nx = nx, ny = ny, nz = nlev - 2,                                &
    743                   dx = dx, dy = dy, dz = dz)
     756                  x0=x0, y0=y0, z0 = z0,                                          &
     757                  nx = nx, ny = ny, nz = nlev - 2)
    744758
    745759          CALL init_grid_definition('boundary intermediate', grid=u_east_intermediate,         &
    746760                  xmin = lx, xmax = lx,                                           &
    747761                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    748                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    749                   x0=x0, y0=y0, z0 = z0,                                          &
    750                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    751                   dx = dx, dy = dy, dz = dz)
     762                  x0=x0, y0=y0, z0 = z0,                                          &
     763                  nx = 0, ny = ny, nz = nlev - 2)
    752764
    753765          CALL init_grid_definition('boundary intermediate', grid=u_west_intermediate,         &
    754766                  xmin = 0.0_dp, xmax = 0.0_dp,                                   &
    755767                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    756                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    757                   x0=x0, y0=y0, z0 = z0,                                          &
    758                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    759                   dx = dx, dy = dy, dz = dz)
     768                  x0=x0, y0=y0, z0 = z0,                                          &
     769                  nx = 0, ny = ny, nz = nlev - 2)
    760770
    761771          CALL init_grid_definition('boundary intermediate', grid=u_north_intermediate,        &
    762772                  xmin = dx, xmax = lx - dx,                                      &
    763773                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    764                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    765                   x0=x0, y0=y0, z0 = z0,                                          &
    766                   nx = nx-1, ny = 0, nz = nlev - 2,                               &
    767                   dx = dx, dy = dy, dz = dz)
     774                  x0=x0, y0=y0, z0 = z0,                                          &
     775                  nx = nx-1, ny = 0, nz = nlev - 2)
    768776
    769777          CALL init_grid_definition('boundary intermediate', grid=u_south_intermediate,        &
    770778                  xmin = dx, xmax = lx - dx,                                      &
    771779                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    772                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    773                   x0=x0, y0=y0, z0 = z0,                                          &
    774                   nx = nx-1, ny = 0, nz = nlev - 2,                               &
    775                   dx = dx, dy = dy, dz = dz)
     780                  x0=x0, y0=y0, z0 = z0,                                          &
     781                  nx = nx-1, ny = 0, nz = nlev - 2)
    776782
    777783          CALL init_grid_definition('boundary intermediate', grid=u_top_intermediate,          &
    778784                  xmin = dx, xmax = lx - dx,                                      &
    779785                  ymin = 0.5_dp * dy, ymax = ly - 0.5_dp * dy,                    &
    780                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    781                   x0=x0, y0=y0, z0 = z0,                                          &
    782                   nx = nx-1, ny = ny, nz = nlev - 2,                              &
    783                   dx = dx, dy = dy, dz = dz)
     786                  x0=x0, y0=y0, z0 = z0,                                          &
     787                  nx = nx-1, ny = ny, nz = nlev - 2)
    784788
    785789          CALL init_grid_definition('boundary intermediate', grid=v_east_intermediate,         &
    786790                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    787791                  ymin = dy, ymax = ly - dy,                                      &
    788                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    789                   x0=x0, y0=y0, z0 = z0,                                          &
    790                   nx = 0, ny = ny-1, nz = nlev - 2,                               &
    791                   dx = dx, dy = dy, dz = dz)
     792                  x0=x0, y0=y0, z0 = z0,                                          &
     793                  nx = 0, ny = ny-1, nz = nlev - 2)
    792794
    793795          CALL init_grid_definition('boundary intermediate', grid=v_west_intermediate,         &
    794796                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    795797                  ymin = dy, ymax = ly - dy,                                      &
    796                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    797                   x0=x0, y0=y0, z0 = z0,                                          &
    798                   nx = 0, ny = ny-1, nz = nlev - 2,                               &
    799                   dx = dx, dy = dy, dz = dz)
     798                  x0=x0, y0=y0, z0 = z0,                                          &
     799                  nx = 0, ny = ny-1, nz = nlev - 2)
    800800
    801801          CALL init_grid_definition('boundary intermediate', grid=v_north_intermediate,        &
    802802                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    803803                  ymin = ly, ymax = ly,                                           &
    804                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    805                   x0=x0, y0=y0, z0 = z0,                                          &
    806                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    807                   dx = dx, dy = dy, dz = dz)
     804                  x0=x0, y0=y0, z0 = z0,                                          &
     805                  nx = nx, ny = 0, nz = nlev - 2)
    808806
    809807          CALL init_grid_definition('boundary intermediate', grid=v_south_intermediate,        &
    810808                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    811809                  ymin = 0.0_dp, ymax = 0.0_dp,                                   &
    812                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    813                   x0=x0, y0=y0, z0 = z0,                                          &
    814                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    815                   dx = dx, dy = dy, dz = dz)
     810                  x0=x0, y0=y0, z0 = z0,                                          &
     811                  nx = nx, ny = 0, nz = nlev - 2)
    816812
    817813          CALL init_grid_definition('boundary intermediate', grid=v_top_intermediate,          &
    818814                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    819815                  ymin = dy, ymax = ly - dy,                                      &
    820                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    821                   x0=x0, y0=y0, z0 = z0,                                          &
    822                   nx = nx, ny = ny-1, nz = nlev - 2,                              &
    823                   dx = dx, dy = dy, dz = dz)
     816                  x0=x0, y0=y0, z0 = z0,                                          &
     817                  nx = nx, ny = ny-1, nz = nlev - 2)
    824818
    825819          CALL init_grid_definition('boundary intermediate', grid=w_east_intermediate,         &
    826820                  xmin = lx + 0.5_dp * dx, xmax = lx + 0.5_dp * dx,               &
    827821                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    828                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    829                   x0=x0, y0=y0, z0 = z0,                                          &
    830                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    831                   dx = dx, dy = dy, dz = dz)
     822                  x0=x0, y0=y0, z0 = z0,                                          &
     823                  nx = 0, ny = ny, nz = nlev - 2)
    832824
    833825          CALL init_grid_definition('boundary intermediate', grid=w_west_intermediate,         &
    834826                  xmin = -0.5_dp * dx, xmax = -0.5_dp * dx,                       &
    835827                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    836                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    837                   x0=x0, y0=y0, z0 = z0,                                          &
    838                   nx = 0, ny = ny, nz = nlev - 2,                                 &
    839                   dx = dx, dy = dy, dz = dz)
     828                  x0=x0, y0=y0, z0 = z0,                                          &
     829                  nx = 0, ny = ny, nz = nlev - 2)
    840830
    841831          CALL init_grid_definition('boundary intermediate', grid=w_north_intermediate,        &
    842832                  xmin = 0.5_dp * dx, xmax = lx - 0.5_dp * dx,                    &
    843833                  ymin = ly + 0.5_dp * dy, ymax = ly + 0.5_dp * dy,               &
    844                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    845                   x0=x0, y0=y0, z0 = z0,                                          &
    846                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    847                   dx = dx, dy = dy, dz = dz)
     834                  x0=x0, y0=y0, z0 = z0,                                          &
     835                  nx = nx, ny = 0, nz = nlev - 2)
    848836
    849837          CALL init_grid_definition('boundary intermediate', grid=w_south_intermediate,        &
    850838                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    851839                  ymin = -0.5_dp * dy, ymax = -0.5_dp * dy,                       &
    852                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    853                   x0=x0, y0=y0, z0 = z0,                                          &
    854                   nx = nx, ny = 0, nz = nlev - 2,                                 &
    855                   dx = dx, dy = dy, dz = dz)
     840                  x0=x0, y0=y0, z0 = z0,                                          &
     841                  nx = nx, ny = 0, nz = nlev - 2)
    856842
    857843          CALL init_grid_definition('boundary intermediate', grid=w_top_intermediate,          &
    858844                  xmin =  0.5_dp * dx, xmax = lx - 0.5_dp * dx,                   &
    859845                  ymin =  0.5_dp * dy, ymax = ly - 0.5_dp * dy,                   &
    860                   zmin =  0.0_dp, zmax = 0.0_dp,                                  &
    861                   x0=x0, y0=y0, z0 = z0,                                          &
    862                   nx = nx, ny = ny, nz = nlev - 2,                                &
    863                   dx = dx, dy = dy, dz = dz)
     846                  x0=x0, y0=y0, z0 = z0,                                          &
     847                  nx = nx, ny = ny, nz = nlev - 2)
    864848       END IF
    865849
     
    869853!------------------------------------------------------------------------------
    870854
    871        IF (TRIM(mode) == 'profile')  THEN
     855       profile_grids_required = ( TRIM(cfg % ic_mode) == 'profile' .OR.              &
     856                                  TRIM(cfg % bc_mode) == 'ideal' )
     857
     858       IF (profile_grids_required)  THEN
    872859          CALL init_grid_definition('boundary', grid=scalar_profile_grid,      &
    873860                  xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    874861                  ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    875                   zmin = 0.5_dp * dz, zmax = lz - 0.5_dp * dz,                 &
    876862                  x0=x0, y0=y0, z0 = z0,                                       &
    877                   nx = 0, ny = 0, nz = nz,                                     &
    878                   dx = dx, dy = dy, dz = dz)
     863                  nx = 0, ny = 0, nz = nz, z=z)
    879864
    880865          CALL init_grid_definition('boundary', grid=w_profile_grid,           &
    881866                  xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    882867                  ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    883                   zmin = dz, zmax = lz - dz,                                   &
    884868                  x0=x0, y0=y0, z0 = z0,                                       &
    885                   nx = 0, ny = 0, nz = nz - 1,                                 &
    886                   dx = dx, dy = dy, dz = dz)
     869                  nx = 0, ny = 0, nz = nz - 1, z=zw)
    887870
    888871          CALL init_grid_definition('boundary', grid=scalar_profile_intermediate,&
    889872                  xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    890873                  ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    891                   zmin = 0.0_dp, zmax = 0.0_dp,                                &
    892874                  x0=x0, y0=y0, z0 = z0,                                       &
    893                   nx = 0, ny = 0, nz = nlev - 2,                               &
    894                   dx = dx, dy = dy, dz = dz)
     875                  nx = 0, ny = 0, nz = nlev - 2, z=z)
    895876
    896877          CALL init_grid_definition('boundary', grid=w_profile_intermediate,   &
    897878                  xmin = 0.5_dp * lx, xmax = 0.5_dp * lx,                      &
    898879                  ymin = 0.5_dp * ly, ymax = 0.5_dp * ly,                      &
    899                   zmin = 0.0_dp, zmax = 0.0_dp,                                &
    900880                  x0=x0, y0=y0, z0 = z0,                                       &
    901                   nx = 0, ny = 0, nz = nlev - 2,                               &
    902                   dx = dx, dy = dy, dz = dz)
     881                  nx = 0, ny = 0, nz = nlev - 2, z=zw)
    903882       END IF
    904883
     
    908887!------------------------------------------------------------------------------
    909888       interp_mode = 's'
    910        CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, mode=mode)
     889       CALL setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, interp_mode, ic_mode=cfg % ic_mode)
    911890       IF (boundary_variables_required)  THEN
    912891          CALL setup_interpolation(cosmo_grid, scalars_east_grid, scalars_east_intermediate, interp_mode)
     
    918897
    919898       interp_mode = 'u'
    920        CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, mode=mode)
     899       CALL setup_interpolation(cosmo_grid, u_initial_grid, u_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
    921900       IF (boundary_variables_required)  THEN
    922901          CALL setup_interpolation(cosmo_grid, u_east_grid, u_east_intermediate, interp_mode)
     
    928907
    929908       interp_mode = 'v'
    930        CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, mode=mode)
     909       CALL setup_interpolation(cosmo_grid, v_initial_grid, v_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
    931910       IF (boundary_variables_required)  THEN
    932911          CALL setup_interpolation(cosmo_grid, v_east_grid, v_east_intermediate, interp_mode)
     
    938917
    939918       interp_mode = 'w'
    940        CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, mode=mode)
     919       CALL setup_interpolation(cosmo_grid, w_initial_grid, w_initial_intermediate, interp_mode, ic_mode=cfg % ic_mode)
    941920       IF (boundary_variables_required)  THEN
    942921          CALL setup_interpolation(cosmo_grid, w_east_grid, w_east_intermediate, interp_mode)
     
    947926       END IF
    948927
    949        IF (TRIM(mode) == 'profile')  THEN
    950            CALL setup_averaging(cosmo_grid, palm_intermediate, imin, imax, jmin, jmax)
     928       IF (TRIM(cfg % ic_mode) == 'profile')  THEN
     929           CALL setup_averaging(cosmo_grid, palm_intermediate,                 &
     930                average_imin, average_imax, average_jmin, average_jmax)
    951931       END IF
    952932       
     
    955935
    956936
    957     SUBROUTINE setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, kind, mode)
     937    SUBROUTINE setup_interpolation(cosmo_grid, palm_grid, palm_intermediate, kind, ic_mode)
    958938
    959939       TYPE(grid_definition), INTENT(IN), TARGET    ::  cosmo_grid
    960940       TYPE(grid_definition), INTENT(INOUT), TARGET ::  palm_grid, palm_intermediate
    961941       CHARACTER, INTENT(IN)                        ::  kind
    962        CHARACTER(LEN=*), INTENT(IN), OPTIONAL       ::  mode
     942       CHARACTER(LEN=*), INTENT(IN), OPTIONAL       ::  ic_mode
    963943
    964944       TYPE(grid_definition), POINTER      ::  grid
     
    966946       REAL(dp), DIMENSION(:,:,:), POINTER ::  h
    967947
    968        LOGICAL :: setup_vertical = .TRUE.
    969 
    970        IF (PRESENT(mode))  THEN
    971           IF (TRIM(mode) == 'profile')  setup_vertical = .FALSE.
    972        ELSE
    973           setup_vertical = .TRUE.
     948       LOGICAL :: setup_vertical
     949
     950       setup_vertical = .TRUE.
     951       IF (PRESENT(ic_mode))  THEN
     952          IF (TRIM(ic_mode) == 'profile')  setup_vertical = .FALSE.
    974953       END IF
    975954
     
    1006985       CASE DEFAULT
    1007986
    1008           message = "Interpolation mode '" // mode // "' is not supported."
     987          message = "Interpolation quantity '" // kind // "' is not supported."
    1009988          CALL abort('setup_interpolation', message)
    1010989
     
    1014993
    1015994       CALL find_horizontal_neighbours(lat, lon,                               &
    1016           cosmo_grid % dxi, cosmo_grid % dyi, grid % clat,                     &
    1017           grid % clon, grid % ii, grid % jj)
     995          grid % clat, grid % clon, grid % ii, grid % jj)
    1018996
    1019997       CALL compute_horizontal_interp_weights(lat, lon,                        &
    1020           cosmo_grid % dxi, cosmo_grid % dyi, grid % clat,                     &
    1021           grid % clon, grid % ii, grid % jj, grid % w_horiz)
     998          grid % clat, grid % clon, grid % ii, grid % jj, grid % w_horiz)
    1022999
    10231000!------------------------------------------------------------------------------
     
    10441021
    10451022       TYPE(grid_definition), POINTER    ::  grid
    1046        REAL ::  lonmin_pos,lonmax_pos, latmin_pos, latmax_pos
     1023       REAL(dp)                          ::  lonmin_pos,lonmax_pos, latmin_pos, latmax_pos
     1024       REAL(dp)                          ::  cosmo_dxi, cosmo_dyi
     1025
     1026       cosmo_dxi = 1.0_dp / (cosmo_grid % lon(1) - cosmo_grid % lon(0))
     1027       cosmo_dyi = 1.0_dp / (cosmo_grid % lat(1) - cosmo_grid % lat(0))
    10471028
    10481029       ! find horizontal index ranges for profile averaging
    1049        lonmin_pos = (MINVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_grid % dxi
    1050        lonmax_pos = (MAXVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_grid % dxi
    1051        latmin_pos = (MINVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_grid % dyi
    1052        latmax_pos = (MAXVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_grid % dyi
     1030       lonmin_pos = (MINVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_dxi
     1031       lonmax_pos = (MAXVAL(palm_intermediate % clon(:,:)) - cosmo_grid % lon(0)) * cosmo_dxi
     1032       latmin_pos = (MINVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_dyi
     1033       latmax_pos = (MAXVAL(palm_intermediate % clat(:,:)) - cosmo_grid % lat(0)) * cosmo_dyi
    10531034
    10541035       imin = FLOOR(lonmin_pos)
     
    10761057! Description:
    10771058! ------------
    1078 !> Helper function that computes horizontal domain extend in x or y direction
    1079 !> such that the centres of a boundary grid fall at -dx/2 or lx + dx/2.
    1080 !>
    1081 !> Input parameters:
    1082 !> -----------------
    1083 !> dxy : grid spacing in x or y direction
    1084 !> lxy : domain length in dxy direction
    1085 !>
    1086 !> Output parameters:
    1087 !> ------------------
    1088 !> boundary_extent : Domain minimum xymin (maximum xymax) if dxy < 0 (> 0)
    1089 !------------------------------------------------------------------------------!
    1090     REAL(dp) FUNCTION boundary_extent(dxy, lxy)
    1091         REAL(dp), INTENT(IN) ::  dxy, lxy
    1092 
    1093         boundary_extent = 0.5_dp * lxy + SIGN(lxy + ABS(dxy), dxy)
    1094 
    1095     END FUNCTION boundary_extent
    1096 
    1097 
    1098 !------------------------------------------------------------------------------!
    1099 ! Description:
    1100 ! ------------
    11011059!> Initializes grid_definition-type variables.
    11021060!>
    11031061!> Input parameters:
    11041062!> -----------------
    1105 !> mode : Initialization mode, distinguishes between PALM-4U and COSMO-DE grids
    1106 !>    as well as grids covering the boundary surfaces. Valid modes are:
     1063!> kind : Grid kind, distinguishes between PALM-4U and COSMO-DE grids
     1064!>    as well as grids covering the boundary surfaces. Valid kinds are:
    11071065!>       - 'palm'
    11081066!>       - 'cosmo-de'
     
    11141072!>    PALM-4U computational domain (i.e. the outer cell faces). The coordinates
    11151073!>    of the generated grid will be inferred from this information taking into
    1116 !>    account the initialization mode. For example, the coordinates of a
     1074!>    account the initialization mode ic_mode. For example, the coordinates of a
    11171075!>    boundary grid initialized using mode 'eastwest-scalar' will be located in
    11181076!>    planes one half grid point outwards of xmin and xmax.
     
    11261084!> grid : Grid variable to be initialized.
    11271085!------------------------------------------------------------------------------!
    1128     SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax, zmin, zmax,  &
    1129                                     x0, y0, z0, nx, ny, nz, dx, dy, dz, grid, mode)
     1086    SUBROUTINE init_grid_definition(kind, xmin, xmax, ymin, ymax,              &
     1087                                    x0, y0, z0, nx, ny, nz, z, zw, grid, ic_mode)
    11301088        CHARACTER(LEN=*), INTENT(IN)           ::  kind
    1131         CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  mode
     1089        CHARACTER(LEN=*), INTENT(IN), OPTIONAL ::  ic_mode
    11321090        INTEGER, INTENT(IN)                    ::  nx, ny, nz
    1133         REAL(dp), INTENT(IN)                   ::  xmin, xmax, ymin, ymax, zmin, zmax
     1091        REAL(dp), INTENT(IN)                   ::  xmin, xmax, ymin, ymax
    11341092        REAL(dp), INTENT(IN)                   ::  x0, y0, z0
    1135         REAL(dp), OPTIONAL, INTENT(IN)         ::  dx, dy, dz
     1093        REAL(dp), INTENT(IN), TARGET, OPTIONAL ::  z(:)
     1094        REAL(dp), INTENT(IN), TARGET, OPTIONAL ::  zw(:)
    11361095        TYPE(grid_definition), INTENT(INOUT)   ::  grid
    11371096
     
    11421101        grid % lx = xmax - xmin
    11431102        grid % ly = ymax - ymin
    1144         grid % lz = zmax - zmin
    11451103
    11461104        grid % x0 = x0
     
    11511109
    11521110        CASE('boundary')
    1153            IF (.NOT. PRESENT(dx))  THEN
    1154               message = "dx is not present but needed for 'eastwest-scalar' "//&
    1155                         "initializaton."
     1111
     1112           IF (.NOT.PRESENT(z))  THEN
     1113              message = "z has not been passed but is required for 'boundary' grids"
    11561114              CALL abort('init_grid_definition', message)
    11571115           END IF
    1158            IF (.NOT. PRESENT(dy))  THEN
    1159               message = "dy is not present but needed for 'eastwest-scalar' "//&
    1160                         "initializaton."
    1161               CALL abort('init_grid_definition', message)
    1162            END IF
    1163            IF (.NOT. PRESENT(dz))  THEN
    1164               message = "dz is not present but needed for 'eastwest-scalar' "//&
    1165                         "initializaton."
    1166               CALL abort('init_grid_definition', message)
    1167            END IF
    1168 
    1169            grid % dx  = dx
    1170            grid % dy  = dy
    1171            grid % dz  = dz
    1172 
    1173            grid % dxi = 1.0_dp / grid % dx
    1174            grid % dyi = 1.0_dp / grid % dy
    1175            grid % dzi = 1.0_dp / grid % dz
    11761116
    11771117           ALLOCATE( grid % x(0:nx) )
     
    11811121           CALL linspace(ymin, ymax, grid % y)
    11821122
    1183            ALLOCATE( grid % z(0:nz) )
    1184            CALL linspace(zmin, zmax, grid % z)
     1123           grid % z => z
    11851124
    11861125           ! Allocate neighbour indices and weights
    1187            IF (TRIM(mode) .NE. 'profile')  THEN
    1188               ALLOCATE( grid % kk(0:nx, 0:ny, 0:nz, 2) )
     1126           IF (TRIM(ic_mode) .NE. 'profile')  THEN
     1127              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
    11891128              grid % kk(:,:,:,:) = -1
    11901129
    1191               ALLOCATE( grid % w_verti(0:nx, 0:ny, 0:nz, 2) )
     1130              ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) )
    11921131              grid % w_verti(:,:,:,:) = 0.0_dp
    11931132           END IF
    11941133       
    11951134        CASE('boundary intermediate')
    1196            IF (.NOT. PRESENT(dx))  THEN
    1197               message = "dx is not present but needed for 'eastwest-scalar' "//&
    1198                         "initializaton."
    1199               CALL abort('init_grid_definition', message)
    1200            END IF
    1201            IF (.NOT. PRESENT(dy))  THEN
    1202               message = "dy is not present but needed for 'eastwest-scalar' "//&
    1203                         "initializaton."
    1204               CALL abort('init_grid_definition', message)
    1205            END IF
    1206            IF (.NOT. PRESENT(dz))  THEN
    1207               message = "dz is not present but needed for 'eastwest-scalar' "//&
    1208                         "initializaton."
    1209               CALL abort('init_grid_definition', message)
    1210            END IF
    1211 
    1212            grid % dx  = dx
    1213            grid % dy  = dy
    1214            grid % dz  = dz
    1215 
    1216            grid % dxi = 1.0_dp / grid % dx
    1217            grid % dyi = 1.0_dp / grid % dy
    1218            grid % dzi = 1.0_dp / grid % dz
    12191135
    12201136           ALLOCATE( grid % x(0:nx) )
     
    12241140           CALL linspace(ymin, ymax, grid % y)
    12251141
    1226            ALLOCATE( grid % z(0:nz) )
    1227            CALL linspace(zmin, zmax, grid % z)
    1228 
    12291142           ALLOCATE( grid % clon(0:nx, 0:ny), grid % clat(0:nx, 0:ny)  )
     1143
    12301144           CALL rotate_to_cosmo(                                               &
    1231               phir = project( grid % y, y0, EARTH_RADIUS ) , & ! = plate-carree latitude
    1232               lamr = project( grid % x, x0, EARTH_RADIUS ) , & ! = plate-carree longitude
     1145              phir = project( grid % y, y0, EARTH_RADIUS ) ,                   & ! = plate-carree latitude
     1146              lamr = project( grid % x, x0, EARTH_RADIUS ) ,                   & ! = plate-carree longitude
    12331147              phip = phi_cn, lamp = lambda_cn,                                 &
    12341148              phi  = grid % clat,                                              &
     
    12491163        ! corresponding latitudes and longitudes of the rotated pole grid.
    12501164        CASE('palm')
     1165
     1166           IF (.NOT.PRESENT(z))  THEN
     1167              message = "z has not been passed but is required for 'palm' grids"
     1168              CALL abort('init_grid_definition', message)
     1169           END IF
     1170
     1171           IF (.NOT.PRESENT(zw))  THEN
     1172              message = "zw has not been passed but is required for 'palm' grids"
     1173              CALL abort('init_grid_definition', message)
     1174           END IF
     1175
    12511176           grid % name(1) = 'x and lon'
    12521177           grid % name(2) = 'y and lat'
    12531178           grid % name(3) = 'z'
    12541179
    1255            grid % dx  = grid % lx / (nx + 1)
    1256            grid % dy  = grid % ly / (ny + 1)
    1257            grid % dz  = grid % lz / (nz + 1)
    1258 
    1259            grid % dxi = 1.0_dp / grid % dx
    1260            grid % dyi = 1.0_dp / grid % dy
    1261            grid % dzi = 1.0_dp / grid % dz
    1262 
    1263            ALLOCATE( grid % x(0:nx),   grid % y(0:ny),  grid % z(0:nz)  )
    1264            ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny), grid % zw(1:nz) )
    1265            CALL linspace(xmin + 0.5_dp*grid % dx, xmax - 0.5_dp*grid % dx, grid % x)
    1266            CALL linspace(ymin + 0.5_dp*grid % dy, ymax - 0.5_dp*grid % dy, grid % y)
    1267            CALL linspace(zmin + 0.5_dp*grid % dz, zmax - 0.5_dp*grid % dz, grid % z)
    1268            CALL linspace(xmin + grid % dx, xmax - grid % dx, grid % xu)
    1269            CALL linspace(ymin + grid % dy, ymax - grid % dy, grid % yv)
    1270            CALL linspace(zmin + grid % dz, zmax - grid % dz, grid % zw)
     1180           !TODO: Remove use of global dx, dy, dz variables. Consider
     1181           !TODO:   associating global x,y, and z arrays.
     1182           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
     1183           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
     1184           CALL linspace(xmin + 0.5_dp* dx, xmax - 0.5_dp* dx, grid % x)
     1185           CALL linspace(ymin + 0.5_dp* dy, ymax - 0.5_dp* dy, grid % y)
     1186           grid % z => z
     1187           CALL linspace(xmin +  dx, xmax -  dx, grid % xu)
     1188           CALL linspace(ymin +  dy, ymax -  dy, grid % yv)
     1189           grid % zw => zw
    12711190
    12721191           grid % depths => depths
    12731192
    12741193           ! Allocate neighbour indices and weights
    1275            IF (TRIM(mode) .NE. 'profile')  THEN
    1276               ALLOCATE( grid % kk(0:nx, 0:ny, 0:nz, 2) )
     1194           IF (TRIM(ic_mode) .NE. 'profile')  THEN
     1195              ALLOCATE( grid % kk(0:nx, 0:ny, 1:nz, 2) )
    12771196              grid % kk(:,:,:,:) = -1
    12781197
    1279               ALLOCATE( grid % w_verti(0:nx, 0:ny, 0:nz, 2) )
     1198              ALLOCATE( grid % w_verti(0:nx, 0:ny, 1:nz, 2) )
    12801199              grid % w_verti(:,:,:,:) = 0.0_dp
    12811200           END IF
    12821201
    12831202        CASE('palm intermediate')
     1203
    12841204           grid % name(1) = 'x and lon'
    12851205           grid % name(2) = 'y and lat'
    1286            grid % name(3) = 'z'
    1287 
    1288            grid % dx  = grid % lx / (nx + 1)
    1289            grid % dy  = grid % ly / (ny + 1)
    1290            grid % dz  = grid % lz / (nz + 1)
    1291 
    1292            grid % dxi = 1.0_dp / grid % dx
    1293            grid % dyi = 1.0_dp / grid % dy
    1294            grid % dzi = 1.0_dp / grid % dz
    1295 
    1296            ALLOCATE( grid % x(0:nx),   grid % y(0:ny),  grid % z(0:nz)  )
    1297            ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny), grid % zw(1:nz) )
    1298            CALL linspace(xmin + 0.5_dp*grid % dx, xmax - 0.5_dp*grid % dx, grid % x)
    1299            CALL linspace(ymin + 0.5_dp*grid % dy, ymax - 0.5_dp*grid % dy, grid % y)
    1300            CALL linspace(zmin + 0.5_dp*grid % dz, zmax - 0.5_dp*grid % dz, grid % z)
    1301            CALL linspace(xmin + grid % dx, xmax - grid % dx, grid % xu)
    1302            CALL linspace(ymin + grid % dy, ymax - grid % dy, grid % yv)
    1303            CALL linspace(zmin + grid % dz, zmax - grid % dz, grid % zw)
     1206           grid % name(3) = 'interpolated hhl or hfl'
     1207
     1208           !TODO: Remove use of global dx, dy, dz variables. Consider
     1209           !TODO:   associating global x,y, and z arrays.
     1210           ALLOCATE( grid % x(0:nx),   grid % y(0:ny) )
     1211           ALLOCATE( grid % xu(1:nx),  grid % yv(1:ny) )
     1212           CALL linspace(xmin + 0.5_dp*dx, xmax - 0.5_dp*dx, grid % x)
     1213           CALL linspace(ymin + 0.5_dp*dy, ymax - 0.5_dp*dy, grid % y)
     1214           CALL linspace(xmin + dx, xmax - dx, grid % xu)
     1215           CALL linspace(ymin + dy, ymax - dy, grid % yv)
    13041216
    13051217           grid % depths => depths
     
    13551267           grid % name(3) = 'height'
    13561268
    1357            grid % dx  = grid % lx / nx     ! = 0.025 deg, stored in radians
    1358            grid % dy  = grid % ly / ny     ! = 0.025 deg, stored in radians
    1359            grid % dz  = 0.0_dp             ! not defined yet
    1360 
    1361            grid % dxi = 1.0_dp / grid % dx ! [rad^-1]
    1362            grid % dyi = 1.0_dp / grid % dy ! [rad^-1]
    1363            grid % dzi = 0.0_dp             ! not defined yet
    1364 
    1365            ALLOCATE( grid % lon(0:nx),   grid % lat(0:ny),  grid % z(0:nz)  )
    1366            ALLOCATE( grid % lonu(0:nx),  grid % latv(0:ny), grid % zw(0:nz) )
     1269           ALLOCATE( grid % lon(0:nx),   grid % lat(0:ny)  )
     1270           ALLOCATE( grid % lonu(0:nx),  grid % latv(0:ny) )
    13671271
    13681272           CALL linspace(xmin, xmax, grid % lon)
    13691273           CALL linspace(ymin, ymax, grid % lat)
    1370            grid % lonu(:) = grid % lon + 0.5_dp * grid % dx
    1371            grid % latv(:) = grid % lat + 0.5_dp * grid % dy
     1274           grid % lonu(:) = grid % lon + 0.5_dp * (grid % lx / grid % nx)
     1275           grid % latv(:) = grid % lat + 0.5_dp * (grid % ly / grid % ny)
    13721276
    13731277           ! Point to heights of half levels (hhl) and compute heights of full
     
    13841288
    13851289    END SUBROUTINE init_grid_definition
     1290
     1291
     1292!------------------------------------------------------------------------------!
     1293! Description:
     1294! ------------
     1295!> PALM's stretched vertical grid generator. Forked from PALM revision 3139, see
     1296!> https://palm.muk.uni-hannover.de/trac/browser/palm/trunk/SOURCE/init_grid.f90?rev=3139
     1297!>
     1298!> This routine computes the levels of scalar points. The levels of the velocity
     1299!> points are then obtained as the midpoints inbetween using the INIFOR routine
     1300!> 'modpoints'.
     1301!------------------------------------------------------------------------------!
     1302    SUBROUTINE stretched_z(z, dz, dz_max, dz_stretch_factor, dz_stretch_level, &
     1303                           dz_stretch_level_start, dz_stretch_level_end,       &
     1304                           dz_stretch_factor_array)
     1305
     1306       REAL(dp), DIMENSION(:), INTENT(INOUT) ::  z, dz, dz_stretch_factor_array
     1307       REAL(dp), DIMENSION(:), INTENT(INOUT) ::  dz_stretch_level_start, dz_stretch_level_end
     1308       REAL(dp), INTENT(IN) ::  dz_max, dz_stretch_factor, dz_stretch_level
     1309
     1310       INTEGER ::  number_stretch_level_start        !< number of user-specified start levels for stretching
     1311       INTEGER ::  number_stretch_level_end          !< number of user-specified end levels for stretching
     1312
     1313       REAL(dp), DIMENSION(:), ALLOCATABLE ::  min_dz_stretch_level_end
     1314       REAL(dp) ::  dz_level_end, dz_stretched
     1315
     1316       INTEGER ::  dz_stretch_level_end_index(9)               !< vertical grid level index until which the vertical grid spacing is stretched
     1317       INTEGER ::  dz_stretch_level_start_index(9)             !< vertical grid level index above which the vertical grid spacing is stretched
     1318       INTEGER ::  dz_stretch_level_index = 0
     1319       INTEGER ::  k, n, number_dz
     1320!
     1321!-- Compute height of u-levels from constant grid length and dz stretch factors
     1322       IF ( dz(1) == -1.0_dp )  THEN
     1323          message = 'missing dz'
     1324          CALL abort( 'stretched_z', message)
     1325       ELSEIF ( dz(1) <= 0.0_dp )  THEN
     1326          WRITE( message, * ) 'dz=', dz(1),' <= 0.0'
     1327          CALL abort( 'stretched_z', message)
     1328       ENDIF
     1329
     1330!
     1331!-- Initialize dz_stretch_level_start with the value of dz_stretch_level
     1332!-- if it was set by the user
     1333       IF ( dz_stretch_level /= -9999999.9_dp ) THEN
     1334          dz_stretch_level_start(1) = dz_stretch_level
     1335       ENDIF
     1336       
     1337!
     1338!-- Determine number of dz values and stretching levels specified by the
     1339!-- user to allow right controlling of the stretching mechanism and to
     1340!-- perform error checks. The additional requirement that dz /= dz_max
     1341!-- for counting number of user-specified dz values is necessary. Otherwise
     1342!-- restarts would abort if the old stretching mechanism with dz_stretch_level
     1343!-- is used (Attention: The user is not allowed to specify a dz value equal
     1344!-- to the default of dz_max = 999.0).
     1345       number_dz = COUNT( dz /= -1.0_dp .AND. dz /= dz_max )
     1346       number_stretch_level_start = COUNT( dz_stretch_level_start /=           &
     1347                                           -9999999.9_dp )
     1348       number_stretch_level_end = COUNT( dz_stretch_level_end /=               &
     1349                                         9999999.9_dp )
     1350
     1351!
     1352!-- The number of specified end levels +1 has to be the same than the number
     1353!-- of specified dz values
     1354       IF ( number_dz /= number_stretch_level_end + 1 ) THEN
     1355          WRITE( message, * ) 'The number of values for dz = ',                &
     1356                              number_dz, 'has to be the same than ',           &
     1357                              'the number of values for ',                     &
     1358                              'dz_stretch_level_end + 1 = ',                   &
     1359                              number_stretch_level_end+1
     1360          CALL abort( 'stretched_z', message)
     1361       ENDIF
     1362   
     1363!
     1364!--    The number of specified start levels has to be the same or one less than
     1365!--    the number of specified dz values
     1366       IF ( number_dz /= number_stretch_level_start + 1 .AND.                  &
     1367            number_dz /= number_stretch_level_start ) THEN
     1368          WRITE( message, * ) 'The number of values for dz = ',         &
     1369                              number_dz, 'has to be the same or one ', &
     1370                              'more than& the number of values for ',  &
     1371                              'dz_stretch_level_start = ',             &
     1372                              number_stretch_level_start
     1373          CALL abort( 'stretched_z', message)
     1374       ENDIF
     1375   
     1376!--    The number of specified start levels has to be the same or one more than
     1377!--    the number of specified end levels
     1378       IF ( number_stretch_level_start /= number_stretch_level_end + 1 .AND.   &
     1379            number_stretch_level_start /= number_stretch_level_end ) THEN
     1380          WRITE( message, * ) 'The number of values for ',              &
     1381                              'dz_stretch_level_start = ',              &
     1382                              dz_stretch_level_start, 'has to be the ',&
     1383                              'same or one more than& the number of ', &
     1384                              'values for dz_stretch_level_end = ',    &
     1385                              number_stretch_level_end
     1386          CALL abort( 'stretched_z', message)
     1387       ENDIF
     1388
     1389!
     1390!-- Initialize dz for the free atmosphere with the value of dz_max
     1391       IF ( dz(number_stretch_level_start+1) == -1.0_dp .AND.                     &
     1392            number_stretch_level_start /= 0 ) THEN
     1393          dz(number_stretch_level_start+1) = dz_max
     1394       ENDIF
     1395       
     1396!
     1397!-- Initialize the stretching factor if (infinitely) stretching in the free
     1398!-- atmosphere is desired (dz_stretch_level_end was not specified for the
     1399!-- free atmosphere)
     1400       IF ( number_stretch_level_start == number_stretch_level_end + 1 ) THEN
     1401          dz_stretch_factor_array(number_stretch_level_start) =                   &
     1402          dz_stretch_factor
     1403       ENDIF
     1404
     1405!-- Allocation of arrays for stretching
     1406       ALLOCATE( min_dz_stretch_level_end(number_stretch_level_start) )
     1407
     1408!
     1409!--    The stretching region has to be large enough to allow for a smooth
     1410!--    transition between two different grid spacings
     1411       DO n = 1, number_stretch_level_start
     1412          min_dz_stretch_level_end(n) = dz_stretch_level_start(n) +            &
     1413                                        4 * MAX( dz(n),dz(n+1) )
     1414       ENDDO
     1415
     1416       IF ( ANY( min_dz_stretch_level_end(1:number_stretch_level_start) >      &
     1417                 dz_stretch_level_end(1:number_stretch_level_start) ) ) THEN
     1418       !IF ( ANY( min_dz_stretch_level_end >      &
     1419       !          dz_stretch_level_end ) ) THEN
     1420             message = 'Each dz_stretch_level_end has to be larger '  // &
     1421                       'than its corresponding value for ' //            &
     1422                       'dz_stretch_level_start + 4*MAX(dz(n),dz(n+1)) '//&
     1423                       'to allow for smooth grid stretching'
     1424             CALL abort('stretched_z', message)
     1425       ENDIF
     1426       
     1427!
     1428!--    Stretching must not be applied within the prandtl_layer
     1429!--    (first two grid points). For the default case dz_stretch_level_start
     1430!--    is negative. Therefore the absolut value is checked here.
     1431       IF ( ANY( ABS( dz_stretch_level_start ) < dz(1) * 1.5_dp ) ) THEN
     1432          WRITE( message, * ) 'Eeach dz_stretch_level_start has to be ',&
     1433                              'larger than ', dz(1) * 1.5
     1434             CALL abort( 'stretched_z', message)
     1435       ENDIF
     1436
     1437!
     1438!--    The stretching has to start and end on a grid level. Therefore
     1439!--    user-specified values have to ''interpolate'' to the next lowest level
     1440       IF ( number_stretch_level_start /= 0 ) THEN
     1441          dz_stretch_level_start(1) = INT( (dz_stretch_level_start(1) -        &
     1442                                            dz(1)/2.0) / dz(1) )               &
     1443                                      * dz(1) + dz(1)/2.0
     1444       ENDIF
     1445       
     1446       IF ( number_stretch_level_start > 1 ) THEN
     1447          DO n = 2, number_stretch_level_start
     1448             dz_stretch_level_start(n) = INT( dz_stretch_level_start(n) /      &
     1449                                              dz(n) ) * dz(n)
     1450          ENDDO
     1451       ENDIF
     1452       
     1453       IF ( number_stretch_level_end /= 0 ) THEN
     1454          DO n = 1, number_stretch_level_end
     1455             dz_stretch_level_end(n) = INT( dz_stretch_level_end(n) /          &
     1456                                            dz(n+1) ) * dz(n+1)
     1457          ENDDO
     1458       ENDIF
     1459 
     1460!
     1461!--    Determine stretching factor if necessary
     1462       IF ( number_stretch_level_end >= 1 ) THEN
     1463          CALL calculate_stretching_factor( number_stretch_level_end, dz,      &
     1464                                            dz_stretch_factor,                 &
     1465                                            dz_stretch_factor_array,           &   
     1466                                            dz_stretch_level_end,              &
     1467                                            dz_stretch_level_start )
     1468       ENDIF
     1469
     1470       z(1) = dz(1) * 0.5_dp
     1471!
     1472       dz_stretch_level_index = n
     1473       dz_stretched = dz(1)
     1474       DO  k = 2, n
     1475
     1476          IF ( dz_stretch_level <= z(k-1)  .AND.  dz_stretched < dz_max )  THEN
     1477
     1478             dz_stretched = dz_stretched * dz_stretch_factor
     1479             dz_stretched = MIN( dz_stretched, dz_max )
     1480
     1481             IF ( dz_stretch_level_index == n ) dz_stretch_level_index = k-1
     1482
     1483          ENDIF
     1484
     1485          z(k) = z(k-1) + dz_stretched
     1486
     1487       ENDDO
     1488!--    Determine u and v height levels considering the possibility of grid
     1489!--    stretching in several heights.
     1490       n = 1
     1491       dz_stretch_level_start_index(:) = UBOUND(z, 1)
     1492       dz_stretch_level_end_index(:) = UBOUND(z, 1)
     1493       dz_stretched = dz(1)
     1494
     1495!--    The default value of dz_stretch_level_start is negative, thus the first
     1496!--    condition is always true. Hence, the second condition is necessary.
     1497       DO  k = 2, UBOUND(z, 1)
     1498          IF ( dz_stretch_level_start(n) <= z(k-1) .AND.                      &
     1499               dz_stretch_level_start(n) /= -9999999.9_dp ) THEN
     1500             dz_stretched = dz_stretched * dz_stretch_factor_array(n)
     1501             
     1502             IF ( dz(n) > dz(n+1) ) THEN
     1503                dz_stretched = MAX( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (higher) dz
     1504             ELSE
     1505                dz_stretched = MIN( dz_stretched, dz(n+1) ) !Restrict dz_stretched to the user-specified (lower) dz
     1506             ENDIF
     1507             
     1508             IF ( dz_stretch_level_start_index(n) == UBOUND(z, 1) )            &
     1509             dz_stretch_level_start_index(n) = k-1
     1510             
     1511          ENDIF
     1512         
     1513          z(k) = z(k-1) + dz_stretched
     1514         
     1515!
     1516!--       Make sure that the stretching ends exactly at dz_stretch_level_end
     1517          dz_level_end = ABS( z(k) - dz_stretch_level_end(n) )
     1518         
     1519          IF ( dz_level_end < dz(n+1)/3.0 ) THEN
     1520             z(k) = dz_stretch_level_end(n)
     1521             dz_stretched = dz(n+1)
     1522             dz_stretch_level_end_index(n) = k
     1523             n = n + 1             
     1524          ENDIF
     1525       ENDDO
     1526
     1527       DEALLOCATE( min_dz_stretch_level_end )
     1528
     1529    END SUBROUTINE stretched_z
     1530
     1531
     1532! Description: [PALM subroutine]
     1533! -----------------------------------------------------------------------------!
     1534!> Calculation of the stretching factor through an iterative method. Ideas were
     1535!> taken from the paper "Regional stretched grid generation and its application
     1536!> to the NCAR RegCM (1999)". Normally, no analytic solution exists because the
     1537!> system of equations has two variables (r,l) but four requirements
     1538!> (l=integer, r=[0,88;1,2], Eq(6), Eq(5) starting from index j=1) which
     1539!> results into an overdetermined system.
     1540!------------------------------------------------------------------------------!
     1541 SUBROUTINE calculate_stretching_factor( number_end, dz, dz_stretch_factor,    &
     1542                                         dz_stretch_factor_array,              &   
     1543                                         dz_stretch_level_end,                 &
     1544                                         dz_stretch_level_start )
     1545 
     1546    REAL(dp), DIMENSION(:), INTENT(IN)    ::  dz
     1547    REAL(dp), DIMENSION(:), INTENT(INOUT) ::  dz_stretch_factor_array
     1548    REAL(dp), DIMENSION(:), INTENT(IN)    ::  dz_stretch_level_end, dz_stretch_level_start
     1549    REAL(dp)                              ::  dz_stretch_factor
     1550 
     1551    INTEGER ::  iterations  !< number of iterations until stretch_factor_lower/upper_limit is reached 
     1552    INTEGER ::  l_rounded   !< after l_rounded grid levels dz(n) is strechted to dz(n+1) with stretch_factor_2
     1553    INTEGER ::  n           !< loop variable for stretching
     1554   
     1555    INTEGER, INTENT(IN) ::  number_end !< number of user-specified end levels for stretching
     1556       
     1557    REAL(dp) ::  delta_l               !< absolute difference between l and l_rounded
     1558    REAL(dp) ::  delta_stretch_factor  !< absolute difference between stretch_factor_1 and stretch_factor_2
     1559    REAL(dp) ::  delta_total_new       !< sum of delta_l and delta_stretch_factor for the next iteration (should be as small as possible)
     1560    REAL(dp) ::  delta_total_old       !< sum of delta_l and delta_stretch_factor for the last iteration
     1561    REAL(dp) ::  distance              !< distance between dz_stretch_level_start and dz_stretch_level_end (stretching region)
     1562    REAL(dp) ::  l                     !< value that fulfil Eq. (5) in the paper mentioned above together with stretch_factor_1 exactly
     1563    REAL(dp) ::  numerator             !< numerator of the quotient
     1564    REAL(dp) ::  stretch_factor_1      !< stretching factor that fulfil Eq. (5) togehter with l exactly
     1565    REAL(dp) ::  stretch_factor_2      !< stretching factor that fulfil Eq. (6) togehter with l_rounded exactly
     1566   
     1567    REAL(dp) ::  dz_stretch_factor_array_2(9) = 1.08_dp  !< Array that contains all stretch_factor_2 that belongs to stretch_factor_1
     1568   
     1569    REAL(dp), PARAMETER ::  stretch_factor_interval = 1.0E-06  !< interval for sampling possible stretching factors
     1570    REAL(dp), PARAMETER ::  stretch_factor_lower_limit = 0.88  !< lowest possible stretching factor
     1571    REAL(dp), PARAMETER ::  stretch_factor_upper_limit = 1.12  !< highest possible stretching factor
     1572 
     1573 
     1574    l = 0
     1575    DO  n = 1, number_end
     1576   
     1577       iterations = 1
     1578       stretch_factor_1 = 1.0
     1579       stretch_factor_2 = 1.0
     1580       delta_total_old = 1.0
     1581       
     1582       IF ( dz(n) > dz(n+1) ) THEN
     1583          DO WHILE ( stretch_factor_1 >= stretch_factor_lower_limit )
     1584             
     1585             stretch_factor_1 = 1.0 - iterations * stretch_factor_interval
     1586             distance = ABS( dz_stretch_level_end(n) -                   &
     1587                        dz_stretch_level_start(n) )
     1588             numerator = distance*stretch_factor_1/dz(n) +               &
     1589                         stretch_factor_1 - distance/dz(n)
     1590             
     1591             IF ( numerator > 0.0 ) THEN
     1592                l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0
     1593                l_rounded = NINT( l )
     1594                delta_l = ABS( l_rounded - l ) / l
     1595             ENDIF
     1596             
     1597             stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) )
     1598             
     1599             delta_stretch_factor = ABS( stretch_factor_1 -              &
     1600                                         stretch_factor_2 ) /            &
     1601                                    stretch_factor_2
     1602             
     1603             delta_total_new = delta_l + delta_stretch_factor
     1604
     1605!
     1606!--                stretch_factor_1 is taken to guarantee that the stretching
     1607!--                procedure ends as close as possible to dz_stretch_level_end.
     1608!--                stretch_factor_2 would guarantee that the stretched dz(n) is
     1609!--                equal to dz(n+1) after l_rounded grid levels.
     1610             IF (delta_total_new < delta_total_old) THEN
     1611                dz_stretch_factor_array(n) = stretch_factor_1
     1612                dz_stretch_factor_array_2(n) = stretch_factor_2
     1613                delta_total_old = delta_total_new
     1614             ENDIF
     1615             
     1616             iterations = iterations + 1
     1617           
     1618          ENDDO
     1619             
     1620       ELSEIF ( dz(n) < dz(n+1) ) THEN
     1621          DO WHILE ( stretch_factor_1 <= stretch_factor_upper_limit )
     1622                     
     1623             stretch_factor_1 = 1.0 + iterations * stretch_factor_interval
     1624             distance = ABS( dz_stretch_level_end(n) -                      &
     1625                        dz_stretch_level_start(n) )
     1626             numerator = distance*stretch_factor_1/dz(n) +                  &
     1627                         stretch_factor_1 - distance/dz(n)
     1628             
     1629             l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0
     1630             l_rounded = NINT( l )
     1631             delta_l = ABS( l_rounded - l ) / l
     1632             
     1633             stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) )
     1634
     1635             delta_stretch_factor = ABS( stretch_factor_1 -                 &
     1636                                        stretch_factor_2 ) /                &
     1637                                        stretch_factor_2
     1638             
     1639             delta_total_new = delta_l + delta_stretch_factor
     1640             
     1641!
     1642!--                stretch_factor_1 is taken to guarantee that the stretching
     1643!--                procedure ends as close as possible to dz_stretch_level_end.
     1644!--                stretch_factor_2 would guarantee that the stretched dz(n) is
     1645!--                equal to dz(n+1) after l_rounded grid levels.
     1646             IF (delta_total_new < delta_total_old) THEN
     1647                dz_stretch_factor_array(n) = stretch_factor_1
     1648                dz_stretch_factor_array_2(n) = stretch_factor_2
     1649                delta_total_old = delta_total_new
     1650             ENDIF
     1651             
     1652             iterations = iterations + 1
     1653          ENDDO
     1654         
     1655       ELSE
     1656          message = 'Two adjacent values of dz must be different'
     1657          CALL abort( 'calculate_stretching_factor', message)
     1658       ENDIF
     1659
     1660!
     1661!--    Check if also the second stretching factor fits into the allowed
     1662!--    interval. If not, print a warning for the user.
     1663       IF ( dz_stretch_factor_array_2(n) < stretch_factor_lower_limit .OR.     &
     1664            dz_stretch_factor_array_2(n) > stretch_factor_upper_limit ) THEN
     1665          WRITE( message, * ) 'stretch_factor_2 = ',                    &
     1666                                     dz_stretch_factor_array_2(n), ' which is',&
     1667                                     ' responsible for exactly reaching& dz =',&
     1668                                      dz(n+1), 'after a specific amount of',   &
     1669                                     ' grid levels& exceeds the upper',        &
     1670                                     ' limit =', stretch_factor_upper_limit,   &
     1671                                     ' &or lower limit = ',                    &
     1672                                     stretch_factor_lower_limit
     1673          CALL abort( 'calculate_stretching_factor', message )
     1674           
     1675       ENDIF
     1676    ENDDO
     1677       
     1678 END SUBROUTINE calculate_stretching_factor
     1679
     1680    SUBROUTINE midpoints(z, zw)
     1681
     1682        REAL(dp), INTENT(IN)  ::  z(0:)
     1683        REAL(dp), INTENT(OUT) ::  zw(1:)
     1684
     1685        INTEGER ::  k
     1686
     1687        DO k = 1, UBOUND(zw, 1)
     1688           zw(k) = 0.5_dp * (z(k-1) + z(k))
     1689        END DO
     1690
     1691    END SUBROUTINE midpoints
    13861692
    13871693
     
    14091715       )
    14101716
    1411        !potential temperature, surface pressure
     1717       !potential temperature, surface pressure, including nudging and subsidence
    14121718       io_group_list(3) = init_io_group(                                       &
    14131719          in_files = flow_files,                                               &
    1414           out_vars = [output_var_table(3:8), output_var_table(42:42)],         &
     1720          out_vars = [output_var_table(3:8), output_var_table(42:42),          &
     1721                      output_var_table(49:51)],                                &
    14151722          in_var_list = (/input_var_table(3), input_var_table(17)/),           &
    14161723          kind = 'temperature'                                                 &
    14171724       )
    14181725
    1419        !specific humidity
     1726       !specific humidity including nudging and subsidence
    14201727       io_group_list(4) = init_io_group(                                       &
    14211728          in_files = flow_files,                                               &
    1422           out_vars = output_var_table(9:14),                                   &
     1729          out_vars = [output_var_table(9:14), output_var_table(52:54)],        &
    14231730          in_var_list = input_var_table(4:4),                                  &
    14241731          kind = 'scalar'                                                      &
     
    14281735       io_group_list(5) = init_io_group(                                       &
    14291736          in_files = flow_files,                                               &
    1430           out_vars = [output_var_table(15:26), output_var_table(43:44)],       &
     1737          out_vars = [output_var_table(15:26), output_var_table(43:46)],       &
    14311738          !out_vars = output_var_table(15:20),                                  &
    14321739          in_var_list = input_var_table(5:6),                                  &
     
    14441751       !io_group_list(6) % to_be_processed = .FALSE.
    14451752   
    1446        !w velocity
     1753       !w velocity and subsidence and w nudging
    14471754       io_group_list(7) = init_io_group(                                       &
    14481755          in_files = flow_files,                                               &
    1449           out_vars = output_var_table(27:32),                                  &
     1756          out_vars = [output_var_table(27:32), output_var_table(47:48)],       &
    14501757          in_var_list = input_var_table(7:7),                                  &
    14511758          kind = 'scalar'                                                      &
     
    14591766          kind = 'accumulated'                                                 &
    14601767       )
     1768       io_group_list(8) % to_be_processed = .FALSE.
    14611769
    14621770       !snow
     
    14671775          kind = 'accumulated'                                                 &
    14681776       )
     1777       io_group_list(9) % to_be_processed = .FALSE.
    14691778
    14701779       !graupel
     
    14751784          kind = 'accumulated'                                                 &
    14761785       )
     1786       io_group_list(10) % to_be_processed = .FALSE.
    14771787
    14781788       !evapotranspiration
     
    14831793          kind = 'accumulated'                                                 &
    14841794       )
     1795       io_group_list(11) % to_be_processed = .FALSE.
    14851796
    14861797       !2m air temperature
     
    15171828          kind = 'running average'                                             &
    15181829       )
     1830       io_group_list(15) % to_be_processed = .FALSE.
    15191831
    15201832       !lw radiation balance
     
    15251837          kind = 'running average'                                             &
    15261838       )
     1839       io_group_list(16) % to_be_processed = .FALSE.
    15271840
    15281841    END SUBROUTINE setup_io_groups
     
    15621875       CALL report('fini_grids', 'Deallocating grids')
    15631876       
     1877       DEALLOCATE(x, y, z, xu, yv, zw, z_column, zw_column)
     1878
    15641879       DEALLOCATE(palm_grid%x,  palm_grid%y,  palm_grid%z,                     &
    15651880                  palm_grid%xu, palm_grid%yv, palm_grid%zw,                    &
     
    15721887                  palm_intermediate%clonu, palm_intermediate%clatu)
    15731888
    1574        DEALLOCATE(cosmo_grid%lon,  cosmo_grid%lat,  cosmo_grid%z,              &
    1575                   cosmo_grid%lonu, cosmo_grid%latv, cosmo_grid%zw,             &
     1889       DEALLOCATE(cosmo_grid%lon,  cosmo_grid%lat,                             &
     1890                  cosmo_grid%lonu, cosmo_grid%latv,                            &
    15761891                  cosmo_grid%hfl)
    15771892
     
    15841899!> Initializes the the variable list.
    15851900!------------------------------------------------------------------------------!
    1586     SUBROUTINE setup_variable_tables(mode)
    1587        CHARACTER(LEN=*), INTENT(IN) ::  mode
     1901    SUBROUTINE setup_variable_tables(ic_mode)
     1902       CHARACTER(LEN=*), INTENT(IN) ::  ic_mode
    15881903       TYPE(nc_var), POINTER        ::  var
    15891904
    1590        IF (TRIM(start_date) == '')  THEN
     1905       IF (TRIM(cfg % start_date) == '')  THEN
    15911906          message = 'Simulation start date has not been set.'
    15921907          CALL abort('setup_variable_tables', message)
    15931908       END IF
    15941909
    1595        nc_source_text = 'COSMO-DE analysis from ' // TRIM(start_date)
     1910       nc_source_text = 'COSMO-DE analysis from ' // TRIM(cfg % start_date)
    15961911
    15971912       n_invar = 17
    1598        n_outvar = 44
     1913       n_outvar = 55
    15991914       ALLOCATE( input_var_table(n_invar) )
    16001915       ALLOCATE( output_var_table(n_outvar) )
     
    16932008!- Section 2: NetCDF output variables
    16942009!------------------------------------------------------------------------------
     2010!
     2011!------------------------------------------------------------------------------
     2012! Section 2.1: Realistic forcings, i.e. 3D initial and boundary conditions
     2013!------------------------------------------------------------------------------
    16952014       output_var_table(1) = init_nc_var(                                      &
    16962015          name              = 'init_soil_t',                                   &
     
    17182037
    17192038       output_var_table(3) = init_nc_var(                                      &
    1720           name              = 'init_pt',                                       &
     2039          name              = 'init_atmosphere_pt',                            &
    17212040          std_name          = "",                                              &
    17222041          long_name         = "initial potential temperature",                 &
     
    17272046          grid              = palm_grid,                                       &
    17282047          intermediate_grid = palm_intermediate,                               &
    1729           is_profile = (TRIM(mode) == 'profile')                               &
    1730        )
    1731        IF (TRIM(mode) == 'profile')  THEN
     2048          is_profile = (TRIM(ic_mode) == 'profile')                            &
     2049       )
     2050       IF (TRIM(ic_mode) == 'profile')  THEN
    17322051          output_var_table(3) % grid => scalar_profile_grid
    17332052          output_var_table(3) % intermediate_grid => scalar_profile_intermediate
     
    17952114
    17962115       output_var_table(9) = init_nc_var(                                      &
    1797           name              = 'init_qv',                                       &
     2116          name              = 'init_atmosphere_qv',                            &
    17982117          std_name          = "",                                              &
    17992118          long_name         = "initial specific humidity",                     &
     
    18042123          grid              = palm_grid,                                       &
    18052124          intermediate_grid = palm_intermediate,                               &
    1806           is_profile = (TRIM(mode) == 'profile')                               &
    1807        )
    1808        IF (TRIM(mode) == 'profile')  THEN
     2125          is_profile = (TRIM(ic_mode) == 'profile')                            &
     2126       )
     2127       IF (TRIM(ic_mode) == 'profile')  THEN
    18092128          output_var_table(9) % grid => scalar_profile_grid
    18102129          output_var_table(9) % intermediate_grid => scalar_profile_intermediate
     
    18722191
    18732192       output_var_table(15) = init_nc_var(                                     &
    1874           name              = 'init_u',                                        &
     2193          name              = 'init_atmosphere_u',                             &
    18752194          std_name          = "",                                              &
    18762195          long_name         = "initial wind component in x direction",         &
     
    18812200          grid              = u_initial_grid,                                  &
    18822201          intermediate_grid = u_initial_intermediate,                          &
    1883           is_profile = (TRIM(mode) == 'profile')                               &
    1884        )
    1885        IF (TRIM(mode) == 'profile')  THEN
     2202          is_profile = (TRIM(ic_mode) == 'profile')                            &
     2203       )
     2204       IF (TRIM(ic_mode) == 'profile')  THEN
    18862205          output_var_table(15) % grid => scalar_profile_grid
    18872206          output_var_table(15) % intermediate_grid => scalar_profile_intermediate
     
    19492268
    19502269       output_var_table(21) = init_nc_var(                                     &
    1951           name              = 'init_v',                                        &
     2270          name              = 'init_atmosphere_v',                             &
    19522271          std_name          = "",                                              &
    19532272          long_name         = "initial wind component in y direction",         &
     
    19582277          grid              = v_initial_grid,                                  &
    19592278          intermediate_grid = v_initial_intermediate,                          &
    1960           is_profile = (TRIM(mode) == 'profile')                               &
    1961        )
    1962        IF (TRIM(mode) == 'profile')  THEN
     2279          is_profile = (TRIM(ic_mode) == 'profile')                            &
     2280       )
     2281       IF (TRIM(ic_mode) == 'profile')  THEN
    19632282          output_var_table(21) % grid => scalar_profile_grid
    19642283          output_var_table(21) % intermediate_grid => scalar_profile_intermediate
     
    20262345
    20272346       output_var_table(27) = init_nc_var(                                     &
    2028           name              = 'init_w',                                        &
     2347          name              = 'init_atmosphere_w',                             &
    20292348          std_name          = "",                                              &
    20302349          long_name         = "initial wind component in z direction",         &
     
    20352354          grid              = w_initial_grid,                                  &
    20362355          intermediate_grid = w_initial_intermediate,                          &
    2037           is_profile = (TRIM(mode) == 'profile')                               &
    2038        )
    2039        IF (TRIM(mode) == 'profile')  THEN
     2356          is_profile = (TRIM(ic_mode) == 'profile')                            &
     2357       )
     2358       IF (TRIM(ic_mode) == 'profile')  THEN
    20402359          output_var_table(27) % grid => w_profile_grid
    20412360          output_var_table(27) % intermediate_grid => w_profile_intermediate
     
    22092528          intermediate_grid = palm_intermediate                                &
    22102529       )
    2211 
     2530!
     2531!------------------------------------------------------------------------------
     2532! Section 2.2: Idealized large-scale forcings
     2533!------------------------------------------------------------------------------
    22122534       output_var_table(42) = init_nc_var(                                     &
    22132535          name              = 'surface_forcing_surface_pressure',              &
     
    22272549          long_name         = "geostrophic wind (u component)",                &
    22282550          units             = "m/s",                                           &
    2229           kind              = "profile",                                       &
    2230           input_id          = 1,                                               &
    2231           output_file       = output_file,                                     &
    2232           grid              = palm_grid,                                       &
    2233           intermediate_grid = palm_intermediate                                &
     2551          kind              = "constant scalar profile",                       &
     2552          input_id          = 1,                                               &
     2553          output_file       = output_file,                                     &
     2554          grid              = scalar_profile_grid,                             &
     2555          intermediate_grid = scalar_profile_intermediate                      &
    22342556       )
    22352557
     
    22392561          long_name         = "geostrophic wind (v component)",                &
    22402562          units             = "m/s",                                           &
    2241           kind              = "profile",                                       &
    2242           input_id          = 1,                                               &
    2243           output_file       = output_file,                                     &
    2244           grid              = palm_grid,                                       &
    2245           intermediate_grid = palm_intermediate                                &
    2246        )
     2563          kind              = "constant scalar profile",                       &
     2564          input_id          = 1,                                               &
     2565          output_file       = output_file,                                     &
     2566          grid              = scalar_profile_grid,                             &
     2567          intermediate_grid = scalar_profile_intermediate                      &
     2568       )
     2569
     2570       output_var_table(45) = init_nc_var(                                     &
     2571          name              = 'nudging_u',                                     &
     2572          std_name          = "",                                              &
     2573          long_name         = "wind component in x direction",                 &
     2574          units             = "m/s",                                           &
     2575          kind              = "large-scale scalar forcing",                    &
     2576          input_id          = 1,                                               &
     2577          output_file       = output_file,                                     &
     2578          grid              = scalar_profile_grid,                             &
     2579          intermediate_grid = scalar_profile_intermediate                      &
     2580       )
     2581       output_var_table(45) % to_be_processed = ls_forcing_variables_required
     2582
     2583       output_var_table(46) = init_nc_var(                                     &
     2584          name              = 'nudging_v',                                     &
     2585          std_name          = "",                                              &
     2586          long_name         = "wind component in y direction",                 &
     2587          units             = "m/s",                                           &
     2588          kind              = "large-scale scalar forcing",                    &
     2589          input_id          = 1,                                               &
     2590          output_file       = output_file,                                     &
     2591          grid              = scalar_profile_grid,                             &
     2592          intermediate_grid = scalar_profile_intermediate                      &
     2593       )
     2594       output_var_table(46) % to_be_processed = ls_forcing_variables_required
     2595
     2596       output_var_table(47) = init_nc_var(                                     &
     2597          name              = 'ls_forcing_sub_w',                              &
     2598          std_name          = "",                                              &
     2599          long_name         = "subsidence velocity of w",                      &
     2600          units             = "m/s",                                           &
     2601          kind              = "large-scale w forcing",                         &
     2602          input_id          = 1,                                               &
     2603          output_file       = output_file,                                     &
     2604          grid              = w_profile_grid,                                  &
     2605          intermediate_grid = w_profile_intermediate                           &
     2606       )
     2607       output_var_table(47) % to_be_processed = ls_forcing_variables_required
     2608
     2609       output_var_table(48) = init_nc_var(                                     &
     2610          name              = 'nudging_w',                                     &
     2611          std_name          = "",                                              &
     2612          long_name         = "wind component in w direction",                 &
     2613          units             = "m/s",                                           &
     2614          kind              = "large-scale w forcing",                         &
     2615          input_id          = 1,                                               &
     2616          output_file       = output_file,                                     &
     2617          grid              = w_profile_grid,                                  &
     2618          intermediate_grid = w_profile_intermediate                           &
     2619       )
     2620       output_var_table(48) % to_be_processed = ls_forcing_variables_required
     2621
     2622
     2623       output_var_table(49) = init_nc_var(                                     &
     2624          name              = 'ls_forcing_adv_pt',                             &
     2625          std_name          = "",                                              &
     2626          long_name         = "advection of potential temperature",            &
     2627          units             = "K/s",                                           &
     2628          kind              = "large-scale scalar forcing",                    &
     2629          input_id          = 1,                                               &
     2630          output_file       = output_file,                                     &
     2631          grid              = scalar_profile_grid,                             &
     2632          intermediate_grid = scalar_profile_intermediate                      &
     2633       )
     2634       output_var_table(49) % to_be_processed = ls_forcing_variables_required
     2635
     2636       output_var_table(50) = init_nc_var(                                     &
     2637          name              = 'ls_forcing_sub_pt',                             &
     2638          std_name          = "",                                              &
     2639          long_name         = "subsidence velocity of potential temperature",  &
     2640          units             = "K/s",                                           &
     2641          kind              = "large-scale scalar forcing",                    &
     2642          input_id          = 1,                                               &
     2643          output_file       = output_file,                                     &
     2644          grid              = scalar_profile_grid,                             &
     2645          intermediate_grid = scalar_profile_intermediate                      &
     2646       )
     2647       output_var_table(50) % to_be_processed = ls_forcing_variables_required
     2648
     2649       output_var_table(51) = init_nc_var(                                     &
     2650          name              = 'nudging_pt',                                    &
     2651          std_name          = "",                                              &
     2652          long_name         = "potential temperature",                         &
     2653          units             = "K",                                             &
     2654          kind              = "large-scale scalar forcing",                    &
     2655          input_id          = 1,                                               &
     2656          output_file       = output_file,                                     &
     2657          grid              = scalar_profile_grid,                             &
     2658          intermediate_grid = scalar_profile_intermediate                      &
     2659       )
     2660       output_var_table(51) % to_be_processed = ls_forcing_variables_required
     2661
     2662       output_var_table(52) = init_nc_var(                                     &
     2663          name              = 'ls_forcing_adv_qv',                             &
     2664          std_name          = "",                                              &
     2665          long_name         = "advection of specific humidity",                &
     2666          units             = "kg/kg/s",                                       &
     2667          kind              = "large-scale scalar forcing",                    &
     2668          input_id          = 1,                                               &
     2669          output_file       = output_file,                                     &
     2670          grid              = scalar_profile_grid,                             &
     2671          intermediate_grid = scalar_profile_intermediate                      &
     2672       )
     2673       output_var_table(52) % to_be_processed = ls_forcing_variables_required
     2674
     2675
     2676       output_var_table(53) = init_nc_var(                                     &
     2677          name              = 'ls_forcing_sub_qv',                             &
     2678          std_name          = "",                                              &
     2679          long_name         = "subsidence velocity of specific humidity",      &
     2680          units             = "kg/kg/s",                                       &
     2681          kind              = "large-scale scalar forcing",                    &
     2682          input_id          = 1,                                               &
     2683          output_file       = output_file,                                     &
     2684          grid              = scalar_profile_grid,                             &
     2685          intermediate_grid = scalar_profile_intermediate                      &
     2686       )
     2687       output_var_table(53) % to_be_processed = ls_forcing_variables_required
     2688
     2689       output_var_table(54) = init_nc_var(                                     &
     2690          name              = 'nudging_qv',                                    &
     2691          std_name          = "",                                              &
     2692          long_name         = "specific humidity",                             &
     2693          units             = "kg/kg",                                         &
     2694          kind              = "large-scale scalar forcing",                    &
     2695          input_id          = 1,                                               &
     2696          output_file       = output_file,                                     &
     2697          grid              = scalar_profile_grid,                             &
     2698          intermediate_grid = scalar_profile_intermediate                      &
     2699       )
     2700       output_var_table(54) % to_be_processed = ls_forcing_variables_required
     2701
     2702       output_var_table(55) = init_nc_var(                                     &
     2703          name              = 'nudging_tau',                                   &
     2704          std_name          = "",                                              &
     2705          long_name         = "nudging relaxation time scale",                 &
     2706          units             = "s",                                             &
     2707          kind              = "constant scalar profile",                       &
     2708          input_id          = 1,                                               &
     2709          output_file       = output_file,                                     &
     2710          grid              = scalar_profile_grid,                             &
     2711          intermediate_grid = scalar_profile_intermediate                      &
     2712       )
     2713       output_var_table(55) % to_be_processed = ls_forcing_variables_required
     2714
    22472715
    22482716       ! Attributes shared among all variables
    22492717       output_var_table(:) % source = nc_source_text
     2718
    22502719
    22512720    END SUBROUTINE setup_variable_tables
     
    22602729!------------------------------------------------------------------------------!
    22612730    FUNCTION init_nc_var(name, std_name, long_name, units, kind, input_id,     &
    2262                          grid, intermediate_grid, output_file, is_profile) RESULT(var)
     2731                         grid, intermediate_grid, output_file, is_profile      &
     2732             ) RESULT(var)
    22632733
    22642734       CHARACTER(LEN=*), INTENT(IN)      ::  name, std_name, long_name, units, kind
     
    23672837          var % task            = "average profile"
    23682838
    2369        CASE ( 'surface forcing' )
    2370           var % lod             = 1
     2839       CASE( 'surface forcing' )
     2840          var % lod             = -1
    23712841          var % ndim            = 3
    23722842          var % dimids(3)       = output_file % dimid_time
     
    23772847          var % task            = "interpolate_2d"
    23782848
    2379        CASE ( 'left scalar', 'right scalar') ! same as right
    2380           var % lod             = 2
     2849       CASE( 'left scalar', 'right scalar') ! same as right
     2850          var % lod             = -1
    23812851          var % ndim            = 3
    23822852          var % dimids(3)       = output_file % dimid_time
     
    23892859          var % task            = "interpolate_3d"
    23902860
    2391        CASE ( 'north scalar', 'south scalar') ! same as south
    2392           var % lod             = 2
     2861       CASE( 'north scalar', 'south scalar') ! same as south
     2862          var % lod             = -1
    23932863          var % ndim            = 3
    23942864          var % dimids(3)       = output_file % dimid_time
     
    24012871          var % task            = "interpolate_3d"
    24022872
    2403        CASE ( 'top scalar', 'top w' )
    2404           var % lod             = 2
     2873       CASE( 'top scalar', 'top w' )
     2874          var % lod             = -1
    24052875          var % ndim            = 3
    24062876          var % dimids(3)       = output_file % dimid_time
     
    24132883          var % task            = "interpolate_3d"
    24142884
    2415        CASE ( 'left u', 'right u' )
    2416           var % lod             = 2
     2885       CASE( 'left u', 'right u' )
     2886          var % lod             = -1
    24172887          var % ndim            = 3
    24182888          var % dimids(3)       = output_file % dimid_time
     
    24252895          var % task            = "interpolate_3d"
    24262896
    2427        CASE ( 'north u', 'south u' )
    2428           var % lod             = 2
     2897       CASE( 'north u', 'south u' )
     2898          var % lod             = -1
    24292899          var % ndim            = 3
    24302900          var % dimids(3)       = output_file % dimid_time    !t
     
    24372907          var % task            = "interpolate_3d"
    24382908
    2439        CASE ( 'top u' )
    2440           var % lod             = 2
     2909       CASE( 'top u' )
     2910          var % lod             = -1
    24412911          var % ndim            = 3
    24422912          var % dimids(3)       = output_file % dimid_time    !t
     
    24492919          var % task            = "interpolate_3d"
    24502920
    2451        CASE ( 'left v', 'right v' )
    2452           var % lod             = 2
     2921       CASE( 'left v', 'right v' )
     2922          var % lod             = -1
    24532923          var % ndim            = 3
    24542924          var % dimids(3)       = output_file % dimid_time
     
    24612931          var % task            = "interpolate_3d"
    24622932
    2463        CASE ( 'north v', 'south v' )
    2464           var % lod             = 2
     2933       CASE( 'north v', 'south v' )
     2934          var % lod             = -1
    24652935          var % ndim            = 3
    24662936          var % dimids(3)       = output_file % dimid_time    !t
     
    24732943          var % task            = "interpolate_3d"
    24742944
    2475        CASE ( 'top v' )
    2476           var % lod             = 2
     2945       CASE( 'top v' )
     2946          var % lod             = -1
    24772947          var % ndim            = 3
    24782948          var % dimids(3)       = output_file % dimid_time    !t
     
    24852955          var % task            = "interpolate_3d"
    24862956
    2487        CASE ( 'left w', 'right w')
    2488           var % lod             = 2
     2957       CASE( 'left w', 'right w')
     2958          var % lod             = -1
    24892959          var % ndim            = 3
    24902960          var % dimids(3)       = output_file % dimid_time
     
    24972967          var % task            = "interpolate_3d"
    24982968
    2499        CASE ( 'north w', 'south w' )
    2500           var % lod             = 2
     2969       CASE( 'north w', 'south w' )
     2970          var % lod             = -1
    25012971          var % ndim            = 3
    25022972          var % dimids(3)       = output_file % dimid_time    !t
     
    25092979          var % task            = "interpolate_3d"
    25102980
    2511        CASE ( 'time series' )
     2981       CASE( 'time series' )
    25122982          var % lod             = 0
    25132983          var % ndim            = 1
     
    25172987          var % task            = "average scalar"
    25182988
    2519        CASE ( 'profile' )
    2520           var % lod             = 2
     2989       CASE( 'constant scalar profile' )
     2990          var % lod             = -1
    25212991          var % ndim            = 2
    25222992          var % dimids(2)       = output_file % dimid_time    !t
     
    25252995          var % dimvarids(1)    = output_file % dimvarids_scl(3)
    25262996          var % to_be_processed = .TRUE.
    2527           var % task            = "profile"
     2997          var % task            = "set profile"
     2998
     2999       CASE( 'large-scale scalar forcing' )
     3000          var % lod             = -1
     3001          var % ndim            = 2
     3002          var % dimids(2)       = output_file % dimid_time    !t
     3003          var % dimids(1)       = output_file % dimids_scl(3) !z
     3004          var % dimvarids(2)    = output_file % dimvarid_time
     3005          var % dimvarids(1)    = output_file % dimvarids_scl(3)
     3006          var % to_be_processed = ls_forcing_variables_required
     3007          var % task            = "average large-scale profile"
     3008
     3009       CASE( 'large-scale w forcing' )
     3010          var % lod             = -1
     3011          var % ndim            = 2
     3012          var % dimids(2)       = output_file % dimid_time    !t
     3013          var % dimids(1)       = output_file % dimids_vel(3) !z
     3014          var % dimvarids(2)    = output_file % dimvarid_time
     3015          var % dimvarids(1)    = output_file % dimvarids_vel(3)
     3016          var % to_be_processed = ls_forcing_variables_required
     3017          var % task            = "average large-scale profile"
    25283018
    25293019       CASE DEFAULT
     
    25603050
    25613051
    2562     SUBROUTINE input_file_list(start_date_string, start_hour, end_hour,        &
    2563                                step_hour, path, prefix, suffix, file_list)
     3052    SUBROUTINE get_input_file_list(start_date_string, start_hour, end_hour,        &
     3053                                   step_hour, path, prefix, suffix, file_list)
    25643054
    25653055       CHARACTER (LEN=DATE), INTENT(IN) ::  start_date_string
     
    25683058       CHARACTER(LEN=*), ALLOCATABLE, INTENT(INOUT) ::  file_list(:)
    25693059
    2570        INTEGER             ::  number_of_files, hour, i
     3060       INTEGER             ::  number_of_intervals, hour, i
    25713061       CHARACTER(LEN=DATE) ::  date_string
    25723062
    2573        number_of_files = end_hour - start_hour + 1
    2574 
    2575        ALLOCATE( file_list(number_of_files) )
    2576 
    2577        DO i = 1, number_of_files
    2578           hour = start_hour + (i-1) * step_hour
     3063       number_of_intervals = CEILING( REAL(end_hour - start_hour) / step_hour )
     3064       ALLOCATE( file_list(number_of_intervals + 1) )
     3065
     3066       DO i = 0, number_of_intervals
     3067          hour = start_hour + i * step_hour
    25793068          date_string = add_hours_to(start_date_string, hour)
    25803069
    2581           file_list(i) = TRIM(path) // TRIM(prefix) // TRIM(date_string) //    &
    2582                          TRIM(suffix) // '.nc'
    2583           message = "Set up input file name '" // TRIM(file_list(i)) //"'"
     3070          file_list(i+1) = TRIM(path) // TRIM(prefix) // TRIM(date_string) //    &
     3071                           TRIM(suffix) // '.nc'
     3072          message = "Set up input file name '" // TRIM(file_list(i+1)) //"'"
    25843073          CALL report('input_file_list', message)
    25853074       END DO
    25863075
    2587     END SUBROUTINE input_file_list
     3076    END SUBROUTINE get_input_file_list
    25883077
    25893078
     
    26073096       
    26083097       REAL(dp), ALLOCATABLE                       ::  basic_state_pressure(:)
    2609        TYPE(container), ALLOCATABLE                ::  compute_buffer(:)
     3098       TYPE(container), ALLOCATABLE                ::  preprocess_buffer(:)
    26103099       INTEGER                                     ::  hour, dt
    26113100       INTEGER                                     ::  i, j, k
     
    26173106       
    26183107       CASE( 'velocities' )
    2619           ! Allocate a compute puffer with the same number of arrays as the input
    2620           ALLOCATE( compute_buffer( SIZE(input_buffer) ) )
     3108          ! Allocate a compute buffer with the same number of arrays as the input
     3109          ALLOCATE( preprocess_buffer( SIZE(input_buffer) ) )
    26213110
    26223111          ! Allocate u and v arrays with scalar dimensions
     
    26243113          ny = SIZE(input_buffer(1) % array, 2)
    26253114          nz = SIZE(input_buffer(1) % array, 3)
    2626           ALLOCATE( compute_buffer(1) % array(nx, ny, nz) ) ! u buffer
    2627           ALLOCATE( compute_buffer(2) % array(nx, ny, nz) ) ! v buffer
     3115          ALLOCATE( preprocess_buffer(1) % array(nx, ny, nz) ) ! u buffer
     3116          ALLOCATE( preprocess_buffer(2) % array(nx, ny, nz) ) ! v buffer
    26283117
    26293118 CALL run_control('time', 'alloc')
     
    26323121          CALL centre_velocities( u_face = input_buffer(1) % array,            &
    26333122                                  v_face = input_buffer(2) % array,            &
    2634                                   u_centre = compute_buffer(1) % array,        &
    2635                                   v_centre = compute_buffer(2) % array )
     3123                                  u_centre = preprocess_buffer(1) % array,     &
     3124                                  v_centre = preprocess_buffer(2) % array )
    26363125         
    2637           ! rotate U and V to PALM-4U orientation and overwrite U and V with
    2638           ! rotated velocities
    2639           DO k = 1, nz
    2640           DO j = 2, ny
    2641           DO i = 2, nx
    2642              CALL uv2uvrot( urot = compute_buffer(1) % array(i,j,k),           &
    2643                             vrot = compute_buffer(2) % array(i,j,k),           &
    2644                             rlat = cosmo_grid % lat(j-1),                      &
    2645                             rlon = cosmo_grid % lon(i-1),                      &
    2646                             pollat = phi_cn,                                   &
    2647                             pollon = lambda_cn,                                &
    2648                             u = input_buffer(1) % array(i,j,k),                &
    2649                             v = input_buffer(2) % array(i,j,k) )
    2650           END DO
    2651           END DO
    2652           END DO
     3126          cfg % rotation_method = 'rotated-pole'
     3127          SELECT CASE(cfg % rotation_method)
     3128
     3129          CASE('rotated-pole')
     3130             ! rotate U and V to PALM-4U orientation and overwrite U and V with
     3131             ! rotated velocities
     3132             DO k = 1, nz
     3133             DO j = 2, ny
     3134             DO i = 2, nx
     3135                CALL uv2uvrot( urot = preprocess_buffer(1) % array(i,j,k),     &
     3136                               vrot = preprocess_buffer(2) % array(i,j,k),     &
     3137                               rlat = cosmo_grid % lat(j-1),                   &
     3138                               rlon = cosmo_grid % lon(i-1),                   &
     3139                               pollat = phi_cn,                                &
     3140                               pollon = lambda_cn,                             &
     3141                               u = input_buffer(1) % array(i,j,k),             &
     3142                               v = input_buffer(2) % array(i,j,k) )
     3143             END DO
     3144             END DO
     3145             END DO
     3146
     3147          CASE DEFAULT
     3148             message = "Rotation method '" // TRIM(cfg % rotation_method) //   &
     3149                "' not recognized."
     3150             CALL abort('preprocess', message)
     3151
     3152          END SELECT
     3153
     3154          ! set values
    26533155          input_buffer(1) % array(1,:,:) = 0.0_dp
    26543156          input_buffer(2) % array(1,:,:) = 0.0_dp
     
    26593161 CALL run_control('time', 'comp')
    26603162
    2661           DEALLOCATE( compute_buffer )
     3163          DEALLOCATE( preprocess_buffer )
    26623164 CALL run_control('time', 'alloc')
    26633165
  • TabularUnified palm/trunk/UTIL/inifor/src/inifor.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Introduced new PALM grid stretching
     24! Renamend initial-condition mode variable 'mode' to 'ic_mode'
     25! Improved log messages
    2326!
    2427!
     
    4851        ONLY:  setup_parameters, setup_grids, setup_variable_tables,           &
    4952               setup_io_groups, fini_grids, fini_variables, fini_io_groups,    &
    50                fini_file_lists, preprocess,                                    &
     53               fini_file_lists, preprocess, origin_lon, origin_lat,            &
    5154               output_file, io_group_list, output_var_table,                   &
    52                cosmo_grid, palm_grid, nx, ny, nz, ug, vg, p0, mode,            &
    53                imin, imax, jmin, jmax
     55               cosmo_grid, palm_grid, nx, ny, nz, ug, vg, p0, cfg,             &
     56               average_imin, average_imax, average_jmin, average_jmax
    5457
    5558    USE io
     
    8487
    8588    ! Initialize the netCDF output file and define dimensions
    86     CALL setup_netcdf_dimensions(output_file, palm_grid)
     89    CALL setup_netcdf_dimensions(output_file, palm_grid, cfg % start_date,    &
     90                                 origin_lon, origin_lat)
    8791 CALL run_control('time', 'write')
    8892
    8993    ! Set up the tables containing the input and output variables and set
    9094    ! the corresponding netCDF dimensions for each output variable
    91     CALL setup_variable_tables(mode)
     95    CALL setup_variable_tables(cfg % ic_mode)
    9296 CALL run_control('time', 'write')
    9397
     
    9599    CALL setup_netcdf_variables(output_file % name, output_var_table)
    96100
    97     CALL setup_io_groups() 
     101    CALL setup_io_groups()
    98102 CALL run_control('time', 'init')
    99103
     
    118122 CALL run_control('time', 'comp')
    119123
     124             !TODO: move this assertion into 'preprocess'.
    120125             IF ( .NOT. ALL(input_buffer(:) % is_preprocessed .AND. .TRUE.) )  THEN
    121126                message = "Input buffers for group '" // TRIM(group % kind) // &
     
    159164                      CASE DEFAULT
    160165
    161                           CALL abort("main loop", 'Not a soil variable')
     166                          message = "'" // TRIM(output_var % kind) // "' is not a soil variable"
     167                          CALL abort("main loop", message)
    162168
    163169                      END SELECT
     
    173179                      ALLOCATE( output_arr( 0:output_var % grid % nx,          &
    174180                                            0:output_var % grid % ny,          &
    175                                             0:output_var % grid % nz ) )
     181                                            1:output_var % grid % nz ) )
    176182
    177183 CALL run_control('time', 'alloc')
     
    187193                      ALLOCATE( output_arr( 0:output_var % grid % nx,          &
    188194                                            0:output_var % grid % ny,          &
    189                                             0:output_var % grid % nz ) )
     195                                            1:output_var % grid % nz ) )
    190196 CALL run_control('time', 'alloc')
    191197                     
     
    193199                      CALL average_profile(                                    &
    194200                         input_buffer(output_var % input_id) % array(:,:,:),   &
    195                          output_arr(:,:,:), imin, imax, jmin, jmax,            &
     201                         output_arr(:,:,:), average_imin, average_imax,        &
     202                         average_jmin, average_jmax,                           &
    196203                         output_var % intermediate_grid,                       &
    197204                         output_var % grid)
     
    205212 CALL run_control('time', 'comp')
    206213
    207                    CASE ( 'profile' )
     214                   CASE ( 'set profile' )
    208215                     
    209                       ALLOCATE( output_arr( 1, 1, 0:nz ) )
     216                      ALLOCATE( output_arr( 1, 1, 1:nz ) )
    210217 CALL run_control('time', 'alloc')
    211218
     
    217224                      CASE('ls_forcing_vg')
    218225                          output_arr(1, 1, :) = vg
     226
     227                      CASE('nudging_tau')
     228                          output_arr(1, 1, :) = NUDGING_TAU
    219229
    220230                      CASE DEFAULT
     
    225235                      END SELECT
    226236 CALL run_control('time', 'comp')
     237
     238                   CASE('average large-scale profile')
     239                      message = "Averaging of large-scale forcing profiles " //&
     240                                "has not been implemented, yet."
     241                      CALL abort('main loop', message)
     242                      !ALLOCATE( output_arr( 1, 1, 1:nz ) )
    227243
    228244                   CASE DEFAULT
     
    269285       ELSE
    270286
    271           message = "Skipping IO group '" // TRIM(group % kind) // "'"
     287          message = "Skipping IO group " // TRIM(str(igroup)) // " '" // TRIM(group % kind) // "'"
    272288          IF ( ALLOCATED(group % in_var_list) )  THEN
    273289              message = TRIM(message) // " with input variable '" //           &
     
    291307 CALL run_control('report', 'void')
    292308
    293     message = "Finished writing forcing file '" // TRIM(output_file % name) // &
     309    message = "Finished writing dynamic driver '" // TRIM(output_file % name) // &
    294310              "' successfully."
    295311    CALL report('main loop', message)
  • TabularUnified palm/trunk/UTIL/inifor/src/io.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Introduced new PALM grid stretching
     24! Updated variable names and metadata for PIDS v1.9 compatibility
     25! Improved handling of the start date string
     26! Better compatibility with older Intel compilers:
     27! - avoiding implicit array allocation with new get_netcdf_variable()
     28!   subroutine instead of function
     29! Improved command line interface:
     30! - Added configuration validation
     31! - New options to configure input file prefixes
     32! - GNU-style short and long option names
     33! - Added version and copyright output
    2334!
    24 ! 
     35!
    2536! Former revisions:
    2637! -----------------
     
    4354    USE control
    4455    USE defs,                                                                  &
    45         ONLY:  DATE, SNAME, PATH, PI, dp, TO_RADIANS, TO_DEGREES, VERSION
     56        ONLY:  DATE, SNAME, PATH, PI, dp, hp, TO_RADIANS, TO_DEGREES, VERSION
    4657    USE netcdf
    4758    USE types
    4859    USE util,                                                                  &
    49         ONLY:  reverse, str
     60        ONLY:  reverse, str, real_to_str
    5061
    5162    IMPLICIT NONE
    5263
     64    INTERFACE get_netcdf_variable
     65        MODULE PROCEDURE get_netcdf_variable_int
     66        MODULE PROCEDURE get_netcdf_variable_real
     67    END INTERFACE get_netcdf_variable
     68
     69    PRIVATE ::  get_netcdf_variable_int, get_netcdf_variable_real
     70
    5371 CONTAINS
     72
     73    SUBROUTINE get_netcdf_variable_int(in_file, in_var, buffer)
     74
     75       CHARACTER(LEN=PATH), INTENT(IN)         ::  in_file
     76       TYPE(nc_var), INTENT(INOUT)             ::  in_var
     77       INTEGER(hp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
     78
     79       INCLUDE 'get_netcdf_variable.inc'
     80
     81    END SUBROUTINE get_netcdf_variable_int
     82
     83
     84    SUBROUTINE get_netcdf_variable_real(in_file, in_var, buffer)
     85
     86       CHARACTER(LEN=PATH), INTENT(IN)      ::  in_file
     87       TYPE(nc_var), INTENT(INOUT)          ::  in_var
     88       REAL(dp), ALLOCATABLE, INTENT(INOUT) ::  buffer(:,:,:)
     89
     90       INCLUDE 'get_netcdf_variable.inc'
     91
     92    END SUBROUTINE get_netcdf_variable_real
     93
    5494
    5595    SUBROUTINE netcdf_define_variable(var, ncid)
     
    5999
    60100        CALL check(nf90_def_var(ncid, var % name, NF90_FLOAT,       var % dimids(1:var % ndim), var % varid))
    61         CALL check(nf90_put_att(ncid, var % varid, "standard_name", var % standard_name))
    62101        CALL check(nf90_put_att(ncid, var % varid, "long_name",     var % long_name))
    63102        CALL check(nf90_put_att(ncid, var % varid, "units",         var % units))
    64         CALL check(nf90_put_att(ncid, var % varid, "lod",           var % lod))
     103        IF ( var % lod .GE. 0 )  THEN
     104           CALL check(nf90_put_att(ncid, var % varid, "lod",           var % lod))
     105        END IF
    65106        CALL check(nf90_put_att(ncid, var % varid, "source",        var % source))
    66107        CALL check(nf90_put_att(ncid, var % varid, "_FillValue",    NF90_FILL_REAL))
     
    94135!> parameters for the PALM-4U computational grid.
    95136!------------------------------------------------------------------------------!
    96     SUBROUTINE parse_command_line_arguments( start_date, hhl_file,             &
    97        soiltyp_file, static_driver_file, input_path, output_file,              &
    98        namelist_file, ug, vg, p0, z0, mode )
    99 
    100        CHARACTER(LEN=PATH), INTENT(INOUT)  ::  hhl_file, soiltyp_file,         &
    101            static_driver_file, input_path, output_file, namelist_file
    102        CHARACTER(LEN=SNAME), INTENT(INOUT) ::  mode
    103        REAL(dp), INTENT(INOUT)             ::  ug, vg, p0, z0
    104        CHARACTER(LEN=DATE), INTENT(INOUT)  ::  start_date
    105 
    106        CHARACTER(LEN=PATH)     ::  option, arg
    107        INTEGER                 ::  arg_count, i
     137    SUBROUTINE parse_command_line_arguments( cfg )
     138
     139       TYPE(inifor_config), INTENT(INOUT) ::  cfg
     140
     141       CHARACTER(LEN=PATH)                ::  option, arg
     142       INTEGER                            ::  arg_count, i
    108143
    109144       arg_count = COMMAND_ARGUMENT_COUNT()
     
    111146
    112147          ! Every option should have an argument.
    113           IF ( MOD(arg_count, 2) .NE. 0 )  THEN
    114              message = "Syntax error in command line."
    115              CALL abort('parse_command_line_arguments', message)
    116           END IF
     148          !IF ( MOD(arg_count, 2) .NE. 0 )  THEN
     149          !   message = "Syntax error in command line."
     150          !   CALL abort('parse_command_line_arguments', message)
     151          !END IF
    117152         
    118153          message = "The -clon and -clat command line options are depricated. " // &
    119154             "Please remove them form your inifor command and specify the " // &
    120155             "location of the PALM-4U origin either" // NEW_LINE(' ') // &
    121              "   - by setting the namelist parameters 'origin_lon' and 'origin_lat, or'" // NEW_LINE(' ') // &
     156             "   - by setting the namelist parameters 'longitude' and 'latitude', or" // NEW_LINE(' ') // &
    122157             "   - by providing a static driver netCDF file via the -static command-line option."
    123158
    124           ! Loop through option/argument pairs.
    125           DO i = 1, arg_count, 2
     159          i = 1
     160          DO WHILE (i .LE. arg_count)
    126161
    127162             CALL GET_COMMAND_ARGUMENT( i, option )
    128              CALL GET_COMMAND_ARGUMENT( i+1, arg )
    129163
    130164             SELECT CASE( TRIM(option) )
    131165
    132              CASE( '-date' )
    133                 start_date = TRIM(arg)
     166             CASE( '-date', '-d', '--date' )
     167                CALL get_option_argument( i, arg )
     168                cfg % start_date = TRIM(arg)
    134169
    135170             ! Elevation of the PALM-4U domain above sea level
    136              CASE( '-z0' )
    137                 READ(arg, *) z0
     171             CASE( '-z0', '-z', '--elevation' )
     172                CALL get_option_argument( i, arg )
     173                READ(arg, *) cfg % z0
    138174
    139175             ! surface pressure, at z0
    140              CASE( '-p0' )
    141                 READ(arg, *) p0
    142 
    143              ! surface pressure, at z0
    144              CASE( '-ug' )
    145                 READ(arg, *) ug
    146 
    147              ! surface pressure, at z0
    148              CASE( '-vg' )
    149                 READ(arg, *) vg
    150 
    151              ! Domain centre geographical longitude
    152              CASE( '-clon' )
     176             CASE( '-p0', '-r', '--surface-pressure' )
     177                CALL get_option_argument( i, arg )
     178                READ(arg, *) cfg % p0
     179
     180             ! geostrophic wind in x direction
     181             CASE( '-ug', '-u', '--geostrophic-u' )
     182                CALL get_option_argument( i, arg )
     183                READ(arg, *) cfg % ug
     184
     185             ! geostrophic wind in y direction
     186             CASE( '-vg', '-v', '--geostrophic-v' )
     187                CALL get_option_argument( i, arg )
     188                READ(arg, *) cfg % vg
     189
     190             ! domain centre geographical longitude and latitude
     191             CASE( '-clon', '-clat' )
    153192                CALL abort('parse_command_line_arguments', message)         
    154193                !READ(arg, *) lambda_cg
    155194                !lambda_cg = lambda_cg * TO_RADIANS
    156 
    157              ! Domain centre geographical latitude
    158              CASE( '-clat' )
    159                 CALL abort('parse_command_line_arguments', message)         
    160195                !READ(arg, *) phi_cg
    161196                !phi_cg = phi_cg * TO_RADIANS
    162197
    163              CASE( '-path' )
    164                  input_path = TRIM(arg)
    165 
    166              CASE( '-hhl' )
    167                  hhl_file = TRIM(arg)
    168 
    169              CASE( '-static' )
    170                  static_driver_file = TRIM(arg)
    171 
    172              CASE( '-soil' )
    173                  soiltyp_file = TRIM(arg)
    174 
    175              CASE( '-o' )
    176                 output_file = TRIM(arg)
    177 
    178              CASE( '-n' )
    179                 namelist_file = TRIM(arg)
    180 
    181              ! Initialization mode: 'profile' / 'volume'
    182              CASE( '-mode' )
    183                 mode = TRIM(arg)
    184 
    185                 SELECT CASE( TRIM(mode) )
    186 
    187                 CASE( 'profile' )
    188 
    189                 CASE DEFAULT
    190                    message = "Mode '" // TRIM(mode) // "' is not supported. " //&
    191                              "Currently, '-mode profile' is the only supported option. " //&
    192                              "Select this one or omit the -mode option entirely."
    193                    CALL abort( 'parse_command_line_arguments', message )
    194                 END SELECT
     198             CASE( '-path', '-p', '--path' )
     199                CALL get_option_argument( i, arg )
     200                 cfg % input_path = TRIM(arg)
     201
     202             CASE( '-hhl', '-l', '--hhl-file' )
     203                CALL get_option_argument( i, arg )
     204                 cfg % hhl_file = TRIM(arg)
     205
     206             CASE( '-static', '-t', '--static-driver' )
     207                CALL get_option_argument( i, arg )
     208                 cfg % static_driver_file = TRIM(arg)
     209
     210             CASE( '-soil', '-s', '--soil-file')
     211                CALL get_option_argument( i, arg )
     212                 cfg % soiltyp_file = TRIM(arg)
     213
     214             CASE( '--flow-prefix')
     215                CALL get_option_argument( i, arg )
     216                 cfg % flow_prefix = TRIM(arg)
     217
     218             CASE( '--radiation-prefix')
     219                CALL get_option_argument( i, arg )
     220                 cfg % radiation_prefix = TRIM(arg)
     221
     222             CASE( '--soil-prefix')
     223                CALL get_option_argument( i, arg )
     224                 cfg % soil_prefix = TRIM(arg)
     225
     226             CASE( '--soilmoisture-prefix')
     227                CALL get_option_argument( i, arg )
     228                 cfg % soilmoisture_prefix = TRIM(arg)
     229
     230             CASE( '-o', '--output' )
     231                CALL get_option_argument( i, arg )
     232                cfg % output_file = TRIM(arg)
     233
     234             CASE( '-n', '--namelist' )
     235                CALL get_option_argument( i, arg )
     236                cfg % namelist_file = TRIM(arg)
     237
     238             ! initial condition mode: 'profile' / 'volume'
     239             CASE( '-mode', '-i', '--init-mode' )
     240                CALL get_option_argument( i, arg )
     241                cfg % ic_mode = TRIM(arg)
     242
     243             ! boundary conditions / forcing mode: 'ideal' / 'real'
     244             CASE( '-f', '--forcing-mode' )
     245                CALL get_option_argument( i, arg )
     246                cfg % bc_mode = TRIM(arg)
     247
     248             CASE( '--version' )
     249                CALL print_version()
     250                STOP
     251
     252             CASE( '--help' )
     253                CALL print_version()
     254                PRINT *, ""
     255                PRINT *, "For a list of command-line options have a look at the README file."
     256                STOP
    195257
    196258             CASE DEFAULT
    197                 message = "unknown option '" // TRIM(option(2:)) // "'."
     259                message = "unknown option '" // TRIM(option) // "'."
    198260                CALL abort('parse_command_line_arguments', message)
    199261
    200262             END SELECT
     263
     264             i = i + 1
    201265
    202266          END DO
     
    210274
    211275   END SUBROUTINE parse_command_line_arguments
     276
     277   
     278   SUBROUTINE get_option_argument(i, arg)
     279      CHARACTER(LEN=PATH), INTENT(INOUT) ::  arg
     280      INTEGER, INTENT(INOUT)             ::  i
     281
     282      i = i + 1
     283      CALL GET_COMMAND_ARGUMENT(i, arg)
     284
     285   END SUBROUTINE
     286
     287
     288   SUBROUTINE validate_config(cfg)
     289      TYPE(inifor_config), INTENT(IN) ::  cfg
     290      LOGICAL                         ::  all_files_present
     291
     292      all_files_present = .TRUE.
     293      all_files_present = all_files_present .AND. file_present(cfg % hhl_file)
     294      all_files_present = all_files_present .AND. file_present(cfg % namelist_file)
     295      all_files_present = all_files_present .AND. file_present(cfg % output_file)
     296      all_files_present = all_files_present .AND. file_present(cfg % soiltyp_file)
     297
     298      ! Only check optional static driver file name, if it has been given.
     299      IF (TRIM(cfg % static_driver_file) .NE. '')  THEN
     300         all_files_present = all_files_present .AND. file_present(cfg % static_driver_file)
     301      END IF
     302
     303      IF (.NOT. all_files_present)  THEN
     304         message = "INIFOR configuration invalid; some input files are missing."
     305         CALL abort( 'validate_config', message )
     306      END IF
     307     
     308     
     309      SELECT CASE( TRIM(cfg % ic_mode) )
     310      CASE( 'profile', 'volume')
     311      CASE DEFAULT
     312         message = "Initialization mode '" // TRIM(cfg % ic_mode) //&
     313                   "' is not supported. " //&
     314                   "Please select either 'profile' or 'volume', " //&
     315                   "or omit the -i/--init-mode/-mode option entirely, which corresponds "//&
     316                   "to the latter."
     317         CALL abort( 'validate_config', message )
     318      END SELECT
     319
     320
     321      SELECT CASE( TRIM(cfg % bc_mode) )
     322      CASE( 'real', 'ideal')
     323      CASE DEFAULT
     324         message = "Forcing mode '" // TRIM(cfg % bc_mode) //&
     325                   "' is not supported. " //&
     326                   "Please select either 'real' or 'ideal', " //&
     327                   "or omit the -f/--forcing-mode option entirely, which corresponds "//&
     328                   "to the latter."
     329         CALL abort( 'validate_config', message )
     330      END SELECT
     331
     332
     333   END SUBROUTINE validate_config
     334
     335
     336   LOGICAL FUNCTION file_present(filename)
     337      CHARACTER(LEN=PATH), INTENT(IN) ::  filename
     338
     339      INQUIRE(FILE=filename, EXIST=file_present)
     340
     341      IF (.NOT. file_present)  THEN
     342         message = "The given file '" // "' does not exist."
     343         CALL report('file_present', message)
     344      END IF
     345
     346   END FUNCTION file_present
    212347
    213348
     
    222357!> writes the actual data.
    223358!------------------------------------------------------------------------------!
    224     SUBROUTINE setup_netcdf_dimensions(output_file, palm_grid)
     359   SUBROUTINE setup_netcdf_dimensions(output_file, palm_grid,                  &
     360                                      start_date_string, origin_lon, origin_lat)
    225361
    226362       TYPE(nc_file), INTENT(INOUT)      ::  output_file
    227363       TYPE(grid_definition), INTENT(IN) ::  palm_grid
    228 
    229        CHARACTER (LEN=SNAME) ::  date
     364       CHARACTER (LEN=DATE), INTENT(IN)  ::  start_date_string
     365       REAL(dp), INTENT(IN)              ::  origin_lon, origin_lat
     366
     367       CHARACTER (LEN=8)     ::  date_string
     368       CHARACTER (LEN=10)    ::  time_string
     369       CHARACTER (LEN=5)     ::  zone_string
     370       CHARACTER (LEN=SNAME) ::  history_string
    230371       INTEGER               ::  ncid, nx, ny, nz, nt, dimids(3), dimvarids(3)
    231372       REAL(dp)              ::  z0
    232373
     374       message = "Initializing PALM-4U dynamic driver file '" //               &
     375                 TRIM(output_file % name) // "' and setting up dimensions."
     376       CALL report('setup_netcdf_dimensions', message)
     377
    233378       ! Create the NetCDF file. NF90_CLOBBER selects overwrite mode.
     379#if defined( __netcdf4 )
    234380       CALL check(nf90_create(TRIM(output_file % name), OR(NF90_CLOBBER, NF90_HDF5), ncid))
     381#else
     382       CALL check(nf90_create(TRIM(output_file % name), NF90_CLOBBER, ncid))
     383#endif
    235384
    236385!
     
    238387!- Section 1: Write global NetCDF attributes
    239388!------------------------------------------------------------------------------
    240        CALL date_and_time(date)
     389       CALL date_and_time(DATE=date_string, TIME=time_string, ZONE=zone_string)
     390       history_string =                                                        &
     391           'Created on '// date_string      //                                 &
     392           ' at '       // time_string(1:2) // ':' // time_string(3:4) //      &
     393           ' (UTC'      // zone_string // ')'
     394
    241395       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'title',          'PALM input file for scenario ...'))
    242396       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'institution',    'Deutscher Wetterdienst, Offenbach'))
    243397       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'author',         'Eckhard Kadasch, eckhard.kadasch@dwd.de'))
    244        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'history',        'Created on '//date))
     398       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'history',        TRIM(history_string)))
    245399       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'references',     '--'))
    246400       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'comment',        '--'))
    247        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat',     '--'))
    248        CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon',     '--'))
     401       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lat',     TRIM(real_to_str(origin_lat*TO_DEGREES, '(F18.13)'))))
     402       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'origin_lon',     TRIM(real_to_str(origin_lon*TO_DEGREES, '(F18.13)'))))
    249403       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'inifor_version', TRIM(VERSION)))
    250404       CALL check(nf90_put_att(ncid, NF90_GLOBAL, 'palm_version',   '--'))
     
    267421          CALL check( nf90_def_dim(ncid, "x", nx+1, dimids(1)) )
    268422          CALL check( nf90_def_dim(ncid, "y", ny+1, dimids(2)) )
    269           CALL check( nf90_def_dim(ncid, "z", nz+1, dimids(3)) )
     423          CALL check( nf90_def_dim(ncid, "z", nz, dimids(3)) )
    270424          output_file % dimids_scl = dimids ! save dimids for later
    271425
     
    285439
    286440       ! overwrite third dimid with the one of depth
    287        CALL check(nf90_def_dim(ncid, "depth", SIZE(palm_grid % depths), dimids(3)) )
     441       CALL check(nf90_def_dim(ncid, "zsoil", SIZE(palm_grid % depths), dimids(3)) )
    288442       output_file % dimids_soil = dimids ! save dimids for later
    289443
    290444       ! overwrite third dimvarid with the one of depth
    291        CALL check(nf90_def_var(ncid, "depth", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3)))
     445       CALL check(nf90_def_var(ncid, "zsoil", NF90_FLOAT, output_file % dimids_soil(3), dimvarids(3)))
    292446       CALL check(nf90_put_att(ncid, dimvarids(3), "standard_name", "depth_below_land"))
    293447       CALL check(nf90_put_att(ncid, dimvarids(3), "positive", "down"))
     
    301455          CALL check(nf90_def_dim(ncid, "xu", nx, dimids(1)) )
    302456          CALL check(nf90_def_dim(ncid, "yv", ny, dimids(2)) )
    303           CALL check(nf90_def_dim(ncid, "zw", nz, dimids(3)) )
     457          CALL check(nf90_def_dim(ncid, "zw", nz-1, dimids(3)) )
    304458       output_file % dimids_vel = dimids ! save dimids for later
    305459
     
    328482       CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "standard_name", "time"))
    329483       CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "long_name", "time"))
    330        CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "units", "seconds since..."))
     484       CALL check(nf90_put_att(ncid, output_file % dimvarid_time, "units",     &
     485                               "seconds since " // start_date_string // " UTC"))
    331486
    332487       CALL check(nf90_enddef(ncid))
     
    363518       INTEGER                              ::  i, ncid
    364519
    365        message = "Initializing PALM-4U forcing file '" // TRIM(filename) // "'."
     520       message = "Defining variables in dynamic driver '" // TRIM(filename) // "'."
    366521       CALL report('setup_netcdf_variables', message)
    367522
     
    374529
    375530          IF ( var % to_be_processed )  THEN
    376              message = "Defining variable #" // TRIM(str(i)) // " '" // TRIM(var%name) // "'."
     531             message = "  variable #" // TRIM(str(i)) // " '" // TRIM(var%name) // "'."
    377532             CALL report('setup_netcdf_variables', message)
    378533
     
    386541       CALL check(nf90_close(ncid))
    387542
    388        message = "Forcing file '" // TRIM(filename) // "' initialized successfully."
     543       message = "Dynamic driver '" // TRIM(filename) // "' initialized successfully."
    389544       CALL report('setup_netcdf_variables', message)
    390545
     
    447602
    448603          input_var => group % in_var_list(1)
    449           buffer(buf_id) % array = get_netcdf_variable( input_file, input_var ) 
     604          CALL get_netcdf_variable(input_file, input_var, buffer(buf_id) % array)
    450605          CALL report('read_input_variables', "Read accumulated " // TRIM(group % in_var_list(1) % name))
    451606
     
    472627             END IF
    473628
    474              buffer(ivar) % array = get_netcdf_variable( input_file, input_var ) 
     629             CALL get_netcdf_variable(input_file, input_var, buffer(ivar) % array)
    475630
    476631             IF ( input_var % is_upside_down )  CALL reverse(buffer(ivar) % array)
     
    545700
    546701          CALL check(nf90_get_att(ncid, NF90_GLOBAL, TRIM(attribute), attribute_value))
     702          CALL check(nf90_close(ncid))
    547703
    548704       ELSE
     
    555711
    556712    END FUNCTION get_netcdf_attribute
    557 
    558 
    559 
    560     FUNCTION get_netcdf_variable(in_file, in_var) RESULT(buffer)
    561 
    562        CHARACTER(LEN=PATH), INTENT(IN)      ::  in_file
    563        TYPE(nc_var), INTENT(INOUT)          ::  in_var
    564        REAL(dp), ALLOCATABLE                ::  buffer(:,:,:)
    565        INTEGER                              ::  i, ncid, start(3)
    566 
    567 
    568        ! Read in_var NetCDF attributes
    569        IF ( nf90_open( TRIM(in_file), NF90_NOWRITE, ncid ) .EQ. NF90_NOERR .AND. &
    570             nf90_inq_varid( ncid, in_var % name, in_var % varid ) .EQ. NF90_NOERR )  THEN
    571 
    572           CALL check(nf90_get_att(ncid, in_var % varid, "long_name", in_var % long_name))
    573           CALL check(nf90_get_att(ncid, in_var % varid, "units", in_var % units))
    574 
    575           ! Read in_var NetCDF dimensions
    576           CALL check(nf90_inquire_variable( ncid, in_var % varid,              &
    577                                             ndims  = in_var % ndim,            &
    578                                             dimids = in_var % dimids ))
    579                                        
    580           DO i = 1, in_var % ndim
    581              CALL check(nf90_inquire_dimension( ncid, in_var % dimids(i),      &
    582                                                 name = in_var % dimname(i),    &
    583                                                 len  = in_var % dimlen(i) ))
    584           END DO
    585 
    586           start = (/ 1, 1, 1 /)
    587           IF ( TRIM(in_var % name) .EQ. 'T_SO' )  THEN
    588              ! Skip depth = 0.0 for T_SO and reduce number of depths from 9 to 8
    589              in_var % dimlen(3) = in_var % dimlen(3) - 1
    590 
    591              ! Start reading from second level, e.g. depth = 0.005 instead of 0.0
    592              start(3) = 2
    593           END IF
    594 
    595           SELECT CASE(in_var % ndim)
    596 
    597           CASE (2)
    598 
    599              ALLOCATE( buffer( in_var % dimlen(1),                             &
    600                                in_var % dimlen(2),                             &
    601                                1 ) )
    602 
    603           CASE (3)
    604 
    605              ALLOCATE( buffer( in_var % dimlen(1),                             &
    606                                in_var % dimlen(2),                             &
    607                                in_var % dimlen(3) ) )
    608           CASE (4)
    609 
    610              ALLOCATE( buffer( in_var % dimlen(1),                             &
    611                                in_var % dimlen(2),                             &
    612                                in_var % dimlen(3) ) )
    613           CASE DEFAULT
    614 
    615              message = "Failed reading NetCDF variable " //                    &
    616                 TRIM(in_var % name) // " with " // TRIM(str(in_var%ndim)) //   &
    617                 " dimensions because only two- and and three-dimensional" //   &
    618                 " variables are supported."
    619              CALL abort('get_netcdf_variable', message)
    620 
    621           END SELECT
    622  CALL run_control('time', 'alloc')
    623          
    624           ! TODO: Check for matching dimensions of buffer and var
    625           CALL check(nf90_get_var( ncid, in_var % varid, buffer,               &
    626                                    start = start,                              &
    627                                    count = in_var % dimlen(1:3) ) )
    628 
    629  CALL run_control('time', 'read')
    630        ELSE
    631 
    632           message = "Failed to read '" // TRIM(in_var % name) // &
    633              "' from file '" // TRIM(in_file) // "'."
    634           CALL report('get_netcdf_variable', message)
    635 
    636        END IF
    637 
    638        CALL check(nf90_close(ncid))
    639 
    640  CALL run_control('time', 'read')
    641 
    642     END FUNCTION get_netcdf_variable
    643713
    644714
     
    657727
    658728       ! Skip time dimension for output
    659        IF ( var_is_time_dependent )  THEN
    660           ndim = var % ndim - 1
    661        ELSE
    662           ndim = var % ndim
    663        END IF
     729       ndim = var % ndim
     730       IF ( var_is_time_dependent )  ndim = var % ndim - 1
    664731
    665732       start(:)      = (/1,1,1,1/)
     
    733800                                   start=start(1:ndim+1) ) )
    734801
    735        CASE ( 'profile' )
     802       CASE ( 'constant scalar profile' )
    736803
    737804          CALL check(nf90_put_var( ncid, var%varid, array(1,1,:),              &
    738805                                   start=start(1:ndim+1),                      &
    739806                                   count=count(1:ndim) ) )
     807
     808       CASE ( 'large-scale scalar forcing', 'large-scale w forcing' )
     809
     810           message = "Doing nothing in terms of writing large-scale forings."
     811           CALL report('update_output', message)
    740812
    741813       CASE DEFAULT
  • TabularUnified palm/trunk/UTIL/inifor/src/transform.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Introduced new PALM grid stretching
     24! Removed unnecessary subroutine parameters
     25! Renamed kcur to k_intermediate
    2326!
    2427!
     
    8083       TYPE(grid_definition), INTENT(IN) ::  outgrid
    8184       REAL(dp), INTENT(IN)              ::  in_arr(0:,0:,0:)
    82        REAL(dp), INTENT(OUT)             ::  out_arr(0:,0:,0:)
    83 
    84        INTEGER :: i, j, k, l, nx, ny, nz
    85 
    86        nx = UBOUND(out_arr, 1)
    87        ny = UBOUND(out_arr, 2)
     85       REAL(dp), INTENT(OUT)             ::  out_arr(0:,0:,:)
     86
     87       INTEGER :: i, j, k, l, nz
     88
    8889       nz = UBOUND(out_arr, 3)
    8990
    90        DO j = 0, ny
    91        DO i = 0, nx
    92        DO k = nz, 0, -1
     91       DO j = LBOUND(out_arr, 2), UBOUND(out_arr, 2)
     92       DO i = LBOUND(out_arr, 1), UBOUND(out_arr, 1)
     93       DO k = nz, LBOUND(out_arr, 3), -1
    9394
    9495          ! TODO: Remove IF clause and extrapolate based on a critical vertical
     
    101102             out_arr(i,j,k) = 0.0_dp
    102103             DO l = 1, 2
    103                 out_arr(i,j,k) = out_arr(i,j,k) +                                 &
    104                     outgrid % w_verti(i,j,k,l) *                                  &
     104                out_arr(i,j,k) = out_arr(i,j,k) +                              &
     105                    outgrid % w_verti(i,j,k,l) *                               &
    105106                    in_arr(i,j,outgrid % kk(i,j,k, l) )
    106107             END DO
     
    139140    ! I index 0-based for the indices of the outvar to be consistent with the
    140141    ! outgrid indices and interpolation weights.
    141        TYPE(grid_definition), INTENT(IN) ::  outgrid
    142        REAL(dp), INTENT(IN)              ::  invar(0:,0:,0:)
    143        REAL(dp), INTENT(OUT)             ::  outvar(0:,0:,0:)
     142       TYPE(grid_definition), INTENT(IN)  ::  outgrid
     143       REAL(dp), INTENT(IN)               ::  invar(0:,0:,0:)
     144       REAL(dp), INTENT(OUT)              ::  outvar(0:,0:,0:)
    144145       TYPE(nc_var), INTENT(IN), OPTIONAL ::  ncvar
    145146
     
    413414
    414415    END SUBROUTINE rotate_to_cosmo
     416       
    415417
    416418
     
    427429!>                     -------------
    428430!>           jj, lat
    429 !>              ^      j
    430 !>              |       \          i
     431!>              ^        j
     432!>              |         \          i
    431433!>  jj(i,j,2/3) + ... 2 ---\--------/------ 3
    432434!>              |     | ^   \      /        |
     
    459461!>
    460462!------------------------------------------------------------------------------!
    461     SUBROUTINE find_horizontal_neighbours(cosmo_lat, cosmo_lon, cosmo_dxi,     &
    462        cosmo_dyi, palm_clat, palm_clon, palm_ii, palm_jj)
     463    SUBROUTINE find_horizontal_neighbours(cosmo_lat, cosmo_lon,                &
     464                                          palm_clat, palm_clon,                &
     465                                          palm_ii, palm_jj)
    463466
    464467       REAL(dp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
    465468       REAL(dp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
    466        REAL(dp), INTENT(IN)                       ::  cosmo_dxi, cosmo_dyi
     469       REAL(dp)                                   ::  cosmo_dxi, cosmo_dyi
    467470       INTEGER, DIMENSION(0:,0:,1:), INTENT(OUT)  ::  palm_ii, palm_jj
    468471
     
    472475       lon0 = cosmo_lon(0)
    473476       lat0 = cosmo_lat(0)
     477       cosmo_dxi = 1.0_dp / (cosmo_lon(1) - cosmo_lon(0))
     478       cosmo_dyi = 1.0_dp / (cosmo_lat(1) - cosmo_lat(0))
    474479
    475480       DO j = 0, UBOUND(palm_clon, 2)!palm_grid % ny
     
    508513       TYPE(grid_definition), INTENT(IN)    ::  palm_intermediate
    509514
    510        INTEGER  ::  i, j, k, nx, ny, nz, nlev, kcur
     515       INTEGER  ::  i, j, k, nx, ny, nz, nlev, k_intermediate
    511516       LOGICAL  ::  point_is_below_grid, point_is_above_grid,                  &
    512517                    point_is_in_current_cell
     
    523528       DO j = 0, ny
    524529
    525           kcur = 0
     530          k_intermediate = 0
    526531
    527532          column_base = palm_intermediate % h(i,j,0)
     
    532537          ! cell, or above column_top. Keep increasing current cell index until
    533538          ! the current cell overlaps with the current_height.
    534           DO k = 0, nz
     539          DO k = 1, nz
    535540
    536541             ! Memorize the top and bottom boundaries of the coarse cell and the
    537542             ! current height within it
    538543             current_height = palm_grid % z(k) + palm_grid % z0
    539              h_top    = palm_intermediate % h(i,j,kcur+1)
    540              h_bottom = palm_intermediate % h(i,j,kcur)
     544             h_top    = palm_intermediate % h(i,j,k_intermediate+1)
     545             h_bottom = palm_intermediate % h(i,j,k_intermediate)
    541546
    542547             point_is_above_grid = (current_height > column_top) !22000m, very unlikely
     
    556561                palm_grid % w_verti(i,j,k,1:2) = - 2.0_dp
    557562
     563                message = "PALM-4U grid extends above COSMO-DE model top."
     564                CALL abort('find_vertical_neighbours_and_weights', message)
     565
    558566             ELSE IF (point_is_below_grid)  THEN
    559567
     
    564572                ! cycle through intermediate levels until current
    565573                ! intermediate-grid cell overlaps with current_height
    566                 DO WHILE (.NOT. point_is_in_current_cell .AND. kcur <= nlev-1)
    567                    kcur = kcur + 1
    568 
    569                    h_top    = palm_intermediate % h(i,j,kcur+1)
    570                    h_bottom = palm_intermediate % h(i,j,kcur)
     574                DO WHILE (.NOT. point_is_in_current_cell .AND. k_intermediate <= nlev-1)
     575                   k_intermediate = k_intermediate + 1
     576
     577                   h_top    = palm_intermediate % h(i,j,k_intermediate+1)
     578                   h_bottom = palm_intermediate % h(i,j,k_intermediate)
    571579                   point_is_in_current_cell = (                                &
    572580                      current_height >= h_bottom .AND.                         &
     
    575583                END DO
    576584
    577                 ! kcur = 48 indicates the last section (indices 48 and 49), i.e.
    578                 ! kcur = 49 is not the beginning of a valid cell.
    579                 IF (kcur > nlev-1)  THEN
    580                    message = "Index " // TRIM(str(kcur)) // " is above intermediate grid range."
     585                ! k_intermediate = 48 indicates the last section (indices 48 and 49), i.e.
     586                ! k_intermediate = 49 is not the beginning of a valid cell.
     587                IF (k_intermediate > nlev-1)  THEN
     588                   message = "Index " // TRIM(str(k_intermediate)) //          &
     589                             " is above intermediate grid range."
    581590                   CALL abort('find_vertical_neighbours', message)
    582591                END IF
    583592   
    584                 palm_grid % kk(i,j,k,1) = kcur
    585                 palm_grid % kk(i,j,k,2) = kcur + 1
     593                palm_grid % kk(i,j,k,1) = k_intermediate
     594                palm_grid % kk(i,j,k,2) = k_intermediate + 1
    586595
    587596                ! copmute vertical weights
     
    643652!         
    644653    SUBROUTINE compute_horizontal_interp_weights(cosmo_lat, cosmo_lon,         &
    645        cosmo_dxi, cosmo_dyi, palm_clat, palm_clon, palm_ii, palm_jj, palm_w_horiz)
     654       palm_clat, palm_clon, palm_ii, palm_jj, palm_w_horiz)
    646655       
    647656       REAL(dp), DIMENSION(0:), INTENT(IN)        ::  cosmo_lat, cosmo_lon
    648        REAL(dp), INTENT(IN)                       ::  cosmo_dxi, cosmo_dyi
     657       REAL(dp)                                   ::  cosmo_dxi, cosmo_dyi
    649658       REAL(dp), DIMENSION(0:,0:), INTENT(IN)     ::  palm_clat, palm_clon
    650659       INTEGER, DIMENSION(0:,0:,1:), INTENT(IN)   ::  palm_ii, palm_jj
     
    654663       REAL(dp) ::  wl, wp
    655664       INTEGER  ::  i, j
     665
     666       cosmo_dxi = 1.0_dp / (cosmo_lon(1) - cosmo_lon(0))
     667       cosmo_dyi = 1.0_dp / (cosmo_lat(1) - cosmo_lat(0))
    656668
    657669       DO j = 0, UBOUND(palm_clon, 2)
  • TabularUnified palm/trunk/UTIL/inifor/src/types.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Introduced new PALM grid stretching:
     24! - Converted vertical grid_definition coordinte variables to pointers
     25! Improved command line interface:
     26! - Moved INIFOR configuration into a new derived data type
     27! Removed unnecessary variables
    2328!
    2429!
     
    4146 
    4247 USE defs,                                                                     &
    43     ONLY:  dp, PATH, SNAME, LNAME
     48    ONLY:  dp, DATE, PATH, SNAME, LNAME
    4449 USE netcdf,                                                                   &
    4550    ONLY:  NF90_MAX_VAR_DIMS, NF90_MAX_NAME
    4651
    4752 IMPLICIT NONE
     53
     54 TYPE inifor_config
     55    CHARACTER(LEN=DATE)  ::  start_date           !< String of the FORMAT YYYYMMDDHH indicating the start of the intended PALM-4U simulation
     56
     57    CHARACTER(LEN=PATH)  ::  input_path           !< Path to the input data file directory
     58    CHARACTER(LEN=PATH)  ::  hhl_file             !< Path to the file containing the COSMO-DE HHL variable (height of half layers, i.e. vertical cell faces)
     59    CHARACTER(LEN=PATH)  ::  namelist_file        !< Path to the PALM-4U namelist file
     60    CHARACTER(LEN=PATH)  ::  output_file          !< Path to the INIFOR output file (i.e. PALM-4U dynamic driver')
     61    CHARACTER(LEN=PATH)  ::  soiltyp_file         !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
     62    CHARACTER(LEN=PATH)  ::  static_driver_file   !< Path to the file containing the COSMO-DE SOILTYP variable (map of COSMO-DE soil types)
     63
     64    CHARACTER(LEN=SNAME) ::  flow_prefix          !< Prefix of flow input files, e.g. 'laf' for COSMO-DE analyses
     65    CHARACTER(LEN=SNAME) ::  soil_prefix          !< Prefix of soil input files, e.g. 'laf' for COSMO-DE analyses
     66    CHARACTER(LEN=SNAME) ::  radiation_prefix     !< Prefix of radiation input files, e.g 'laf' for COSMO-DE analyses
     67    CHARACTER(LEN=SNAME) ::  soilmoisture_prefix  !< Prefix of input files for soil moisture spin-up, e.g 'laf' for COSMO-DE analyses
     68
     69    CHARACTER(LEN=SNAME) ::  bc_mode
     70    CHARACTER(LEN=SNAME) ::  ic_mode
     71    CHARACTER(LEN=SNAME) ::  rotation_method
     72
     73    REAL(dp)             ::  p0
     74    REAL(dp)             ::  ug
     75    REAL(dp)             ::  vg
     76    REAL(dp)             ::  z0 !< Elevation of the PALM-4U domain above sea level [m]
     77 END TYPE inifor_config
    4878
    4979 TYPE grid_definition
     
    5585    INTEGER, ALLOCATABLE  ::  jj(:,:,:)     !< Given a point (i,j,k) in the PALM-4U grid, jj(i,j,l) gives the y index of the l'th horizontl neighbour on the COSMO-DE grid.
    5686    INTEGER, ALLOCATABLE  ::  kk(:,:,:,:)   !< Given a point (i,j,k) in the PALM-4U grid, kk(i,j,k,l) gives the z index of the l'th vertical neighbour in the intermediate grid.
    57     REAL(dp)              ::  dx            !< grid spacing in the first dimension [m]
    58     REAL(dp)              ::  dy            !< grid spacing in the second dimension [m]
    59     REAL(dp)              ::  dz            !< grid spacing in the third dimension [m]
    60     REAL(dp)              ::  dxi           !< inverse grid spacing in the first dimension [m^-1]
    61     REAL(dp)              ::  dyi           !< inverse grid spacing in the second dimension [m^-1]
    62     REAL(dp)              ::  dzi           !< inverse grid spacing in the third dimension [m^-1]
    6387    REAL(dp)              ::  lx            !< domain length in the first dimension [m]
    6488    REAL(dp)              ::  ly            !< domain length in the second dimension [m]
    65     REAL(dp)              ::  lz            !< domain length in the third dimension [m]
    6689    REAL(dp)              ::  x0            !< x coordinate of PALM-4U domain projection centre, i.e. location of zero distortion
    6790    REAL(dp)              ::  y0            !< y coordinate of PALM-4U domain projection centre, i.e. location of zwro distortion
     
    6992    REAL(dp), ALLOCATABLE ::  x(:)          !< coordinates of cell centers in x direction [m]
    7093    REAL(dp), ALLOCATABLE ::  y(:)          !< coordinates of cell centers in y direction [m]
    71     REAL(dp), ALLOCATABLE ::  z(:)          !< coordinates of cell centers in z direction [m]
     94    REAL(dp), POINTER    ::  z(:)          !< coordinates of cell centers in z direction [m]
    7295    REAL(dp), ALLOCATABLE ::  h(:,:,:)      !< heights grid point for intermediate grids [m]
    7396    REAL(dp), POINTER     ::  hhl(:,:,:)    !< heights of half layers (cell faces) above sea level in COSMO-DE, read in from
     
    7699    REAL(dp), ALLOCATABLE ::  xu(:)         !< coordinates of cell faces in x direction [m]
    77100    REAL(dp), ALLOCATABLE ::  yv(:)         !< coordinates of cell faces in y direction [m]
    78     REAL(dp), ALLOCATABLE ::  zw(:)         !< coordinates of cell faces in z direction [m]
     101    REAL(dp), POINTER    ::  zw(:)         !< coordinates of cell faces in z direction [m]
    79102    REAL(dp), ALLOCATABLE ::  lat(:)        !< rotated-pole latitudes of scalars (cell centers) of the COSMO-DE grid [rad]
    80103    REAL(dp), ALLOCATABLE ::  lon(:)        !< rotated-pole longitudes of scalars (cell centres) of the COSMO-DE grid [rad]
     
    89112    REAL(dp), ALLOCATABLE ::  w_horiz(:,:,:)   !< weights for bilinear horizontal interpolation
    90113    REAL(dp), ALLOCATABLE ::  w_verti(:,:,:,:) !< weights for linear vertical interpolation
    91  END TYPE
     114 END TYPE grid_definition
    92115
    93116
     
    103126    INTEGER               ::  dimvarids_soil(3)!< NetCDF IDs of the grid coordinates for soil points x, y, depth
    104127    REAL(dp), POINTER     ::  time(:)       ! vector of output time steps
    105  END TYPE
     128 END TYPE nc_file
    106129
    107130
     
    123146    CHARACTER(LEN=SNAME)                  ::  kind                      !< Kind of grid
    124147    CHARACTER(LEN=SNAME)                  ::  task                      !< Processing task that generates this variable, e.g. 'interpolate_2d' or 'average profile'
    125     LOGICAL                               ::  to_be_processed = .FALSE. !< Inifor flag indicating whether variable shall be processed
    126     LOGICAL                               ::  is_read = .FALSE.         !< Inifor flag indicating whether variable has been read
    127     LOGICAL                               ::  is_upside_down  = .FALSE. !< Inifor flag indicating whether variable shall be processed
     148    LOGICAL                               ::  to_be_processed = .FALSE. !< INIFOR flag indicating whether variable shall be processed
     149    LOGICAL                               ::  is_read = .FALSE.         !< INIFOR flag indicating whether variable has been read
     150    LOGICAL                               ::  is_upside_down  = .FALSE. !< INIFOR flag indicating whether variable shall be processed
    128151    TYPE(grid_definition), POINTER        ::  grid                      !< Pointer to the corresponding output grid
    129152    TYPE(grid_definition), POINTER        ::  intermediate_grid         !< Pointer to the corresponding intermediate grid
  • TabularUnified palm/trunk/UTIL/inifor/src/util.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Improved real-to-string conversion
    2324!
    2425!
     
    4344        ONLY :  C_CHAR, C_INT, C_PTR, C_SIZE_T
    4445    USE defs,                                                                  &
    45         ONLY :  dp, PI, DATE
     46        ONLY :  dp, PI, DATE, SNAME
    4647
    4748    IMPLICIT NONE
     
    279280    ! Convert a real number to a string in scientific notation
    280281    ! showing four significant digits.
    281     CHARACTER(LEN=11) FUNCTION real_to_str(val, format)
     282    CHARACTER(LEN=SNAME) FUNCTION real_to_str(val, format)
    282283
    283284        REAL(dp), INTENT(IN)                   ::  val
     
    285286
    286287        IF (PRESENT(format))  THEN
    287            WRITE(real_to_str, TRIM(format)) val
     288           WRITE(real_to_str, format) val
    288289        ELSE
    289290           WRITE(real_to_str, '(E11.4)') val
    290            real_to_str = ADJUSTL(real_to_str)
    291291        END IF
     292        real_to_str = ADJUSTL(real_to_str)
    292293
    293294    END FUNCTION real_to_str
  • TabularUnified palm/trunk/UTIL/inifor/tests/test-boundaries.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Updated test for new PALM grid strechting
    2324!
    2425!
     
    5455    TYPE(grid_definition)           ::  boundary_grid
    5556
    56     REAL ::  dx, dy, dz, lx, ly, lz, x(2), y(10), z(10)
     57    REAL ::  dx, dy, dz, lx, ly, lz, x(2), y(10)
     58    REAL, TARGET :: z(10)
    5759
    5860    CALL begin_test(title, res)
     
    7981          xmin = x(i), xmax = x(i),                                            &
    8082          ymin =  0.5 * dy, ymax = ly - 0.5 * dy,                              &
    81           zmin =  0.5 * dz, zmax = lz - 0.5 * dz,                              &
    8283          x0 = 0.0, y0 = 0.0, z0 = 0.0,                                        &
    83           nx = 0, ny = ny, nz = nz,                                            &
    84           dx = dx, dy = dy, dz = dz )
     84          nx = 0, ny = ny, nz = nz, z = z)
     85         
    8586   
    8687       ! Assert
     
    103104    TYPE(grid_definition), INTENT(INOUT) ::  grid
    104105
    105     DEALLOCATE( grid % x, grid % y, grid % z )
     106    DEALLOCATE( grid % x, grid % y )
    106107    DEALLOCATE( grid % kk )
    107108    DEALLOCATE( grid % w_verti )
  • TabularUnified palm/trunk/UTIL/inifor/tests/test-grid.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Updated test for new PALM grid strechting
    2324!
    2425!
     
    4142 PROGRAM test_grid
    4243
    43     USE grid, ONLY :  grid_definition, init_grid_definition
     44    USE grid, ONLY :  grid_definition, init_grid_definition, dx, dy, dz
    4445    USE test_utils
    4546   
     
    4950    LOGICAL                     ::  res
    5051
    51     TYPE(grid_definition) ::  mygrid
    52     INTEGER               ::  i
    53     INTEGER, PARAMETER    ::  nx = 9,   ny = 19,   nz = 29
    54     REAL, PARAMETER       ::  lx = 100., ly = 200., lz = 300.
    55     REAL, DIMENSION(0:nx) ::  x, xu
    56     REAL, DIMENSION(0:ny) ::  y, yv
    57     REAL, DIMENSION(0:nz) ::  z, zw
     52    TYPE(grid_definition)   ::  mygrid
     53    INTEGER                 ::  i
     54    INTEGER, PARAMETER      ::  nx = 9,   ny = 19,   nz = 29
     55    REAL, PARAMETER         ::  lx = 100., ly = 200., lz = 300.
     56    REAL, DIMENSION(0:nx)   ::  x, xu
     57    REAL, DIMENSION(0:ny)   ::  y, yv
     58    REAL, DIMENSION(1:nz)   ::  z
     59    REAL, DIMENSION(1:nz-1) ::  zw
    5860
    5961    CALL begin_test(title, res)
    6062
    6163    ! Arange
     64    dx = lx / (nx + 1)
     65    DO i = 0, nx
     66       xu(i) = real(i) / (nx+1) * lx
     67       x(i)  = 0.5*dx + xu(i)
     68    END DO
     69
     70    dy = ly / (ny + 1)
     71    DO i = 0, ny
     72       yv(i) = real(i) / (ny+1) * ly
     73       y(i)  = 0.5*dy + yv(i)
     74    END DO
     75
     76    dz(:) = lz / (nz + 1)
     77    DO i = 1, nz
     78       IF (i < nz)  zw(i) = real(i) / (nz+1) * lz
     79       z(i) = 0.5*dz(1) + zw(i)
     80    END DO
     81
     82    ! Act
    6283    CALL init_grid_definition('palm', grid = mygrid,                           &
    6384                              xmin = 0., xmax = lx,                            &
    6485                              ymin = 0., ymax = ly,                            &
    65                               zmin = 0., zmax = lz,                            &
    6686                              x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
    67                               nx = nx, ny = ny, nz = nz)
    68 
    69     ! Act
    70     DO i = 0, nx
    71        xu(i) = real(i) / (nx+1) * lx
    72        x(i)  = 0.5*mygrid%dx + xu(i)
    73     END DO
    74     DO i = 0, ny
    75        yv(i) = real(i) / (ny+1) * ly
    76        y(i)  = 0.5*mygrid%dy + yv(i)
    77     END DO
    78     DO i = 0, nz
    79        zw(i) = real(i) / (nz+1) * lz
    80        z(i)  = 0.5*mygrid%dz + zw(i)
    81     END DO
     87                              nx = nx, ny = ny, nz = nz,                       &
     88                              z = z, zw = zw)
    8289
    8390    ! Assert coordinates match
     
    8592    res = res .AND. assert_equal(xu(1:), mygrid%xu, "xu")
    8693    res = res .AND. assert_equal(y,      mygrid%y,  "y" )
    87     res = res .AND. assert_equal(yv(1:), mygrid%yv, "yu")
     94    res = res .AND. assert_equal(yv(1:), mygrid%yv, "yv")
    8895    res = res .AND. assert_equal(z,      mygrid%z,  "z" )
    89     res = res .AND. assert_equal(zw(1:), mygrid%zw, "zu")
     96    res = res .AND. assert_equal(zw(1:), mygrid%zw, "zw")
    9097
    9198    CALL end_test(title, res)
  • TabularUnified palm/trunk/UTIL/inifor/tests/test-input-files.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
    23 !
     23! New test for negative start_hour and greater-than-one step_hour
     24!
    2425!
    2526! Former revisions:
     
    4445        ONLY :  PATH
    4546    USE grid,                                                                  &
    46         ONLY :  input_file_list
     47        ONLY :  get_input_file_list
    4748    USE test_utils
    4849   
    4950    IMPLICIT NONE
    5051
    51     CHARACTER(LEN=50)                              ::  title
     52    CHARACTER(LEN=60)                              ::  title
    5253    CHARACTER(LEN=PATH), ALLOCATABLE, DIMENSION(:) ::  file_list, ref_list
    5354    LOGICAL                                        ::  res
    54     INTEGER                                        ::  i     
     55    INTEGER                                        ::  i
    5556
    5657    title = "input files - daylight saving to standard time"
     
    7071
    7172    ! Act
    72     CALL input_file_list(start_date_string='2017102823',                       &
    73                          start_hour=0, end_hour=5, step_hour=1,                &
    74                          path='./', prefix="laf", suffix='-test',              &
    75                          file_list=file_list)
     73    CALL get_input_file_list(start_date_string='2017102823',                   &
     74                             start_hour=0, end_hour=5, step_hour=1,            &
     75                             path='./', prefix="laf", suffix='-test',          &
     76                             file_list=file_list)
    7677
    7778    ! Assert
     
    9596
    9697    ! Act
    97     CALL input_file_list(start_date_string='2016022823',                       &
    98                          start_hour=0, end_hour=1, step_hour=1,                &
    99                          path='./', prefix="laf", suffix='-test',              &
    100                          file_list=file_list)
     98    CALL get_input_file_list(start_date_string='2016022823',                   &
     99                             start_hour=0, end_hour=1, step_hour=1,            &
     100                             path='./', prefix="laf", suffix='-test',          &
     101                             file_list=file_list)
     102
     103    ! Assert
     104    DO i = 1, 2
     105       res = res .AND. (TRIM(ref_list(i)) .EQ. TRIM(file_list(i)))
     106    END DO
     107
     108    DEALLOCATE( ref_list, file_list )
     109    CALL end_test(title, res)
     110
     111
     112
     113    title = "input files - negative start_hour and step_hour > 1 hour"
     114    CALL begin_test(title, res)
     115
     116    ! Arange
     117    ! ...a date range that inlcudes a leap day (29. Feb. 2016) which should be
     118    ! inlcuded in UTC time stamps.
     119    ALLOCATE( ref_list(4) )
     120    ref_list(1)  = './laf2017102823-test.nc'
     121    ref_list(2)  = './laf2017102901-test.nc'
     122    ref_list(3)  = './laf2017102903-test.nc'
     123    ref_list(4)  = './laf2017102904-test.nc'
     124
     125    ! Act
     126    CALL get_input_file_list(start_date_string='2017102901',                   &
     127                             start_hour=-2, end_hour=3, step_hour=2,           &
     128                             path='./', prefix="laf", suffix='-test',          &
     129                             file_list=file_list)
     130
     131    PRINT *, file_list
    101132
    102133    ! Assert
  • TabularUnified palm/trunk/UTIL/inifor/tests/test-interpolation.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
    23 !
     23! Updated test for new grid_definition
     24!
    2425!
    2526! Former revisions:
     
    7677                              xmin = -5.0 * TO_RADIANS, xmax = 5.5 * TO_RADIANS, &
    7778                              ymin = -5.0 * TO_RADIANS, ymax = 6.5 * TO_RADIANS, &
    78                               zmin =  0.0, zmax = 10.0,                        &
    7979                              x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
    8080                              nx = nlon-1, ny = nlat-1, nz = nlev-1)
     
    8686    res = assert_equal( (/cosmo_grid%lat(0), cosmo_grid % lon(0),              &
    8787                          cosmo_grid%lat(2), cosmo_grid % lon(2),              &
    88                           cosmo_grid%dx*TO_DEGREES, cosmo_grid%dy*TO_DEGREES/),&
     88                          (cosmo_grid%lon(1) - cosmo_grid%lon(0))*TO_DEGREES,  &
     89                          (cosmo_grid%lat(1) - cosmo_grid%lat(0))*TO_DEGREES/),&
    8990                        (/-5.0 * TO_RADIANS, -5.0 * TO_RADIANS,                &
    9091                           6.5 * TO_RADIANS,  5.5 * TO_RADIANS,                &
     
    9798                              xmin = 0.0, xmax = 1.0,                          &
    9899                              ymin = 0.0, ymax = 1.0,                          &
    99                               zmin = 0.0, zmax = 1.0,                          &
    100100                              x0 = 0.0, y0 = 0.0, z0 = 0.0,                    &
    101101                              nx = 1, ny = 1, nz = 1)
     
    127127    ! Act
    128128    CALL find_horizontal_neighbours(cosmo_grid % lat, cosmo_grid % lon,        &
    129        cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat, palm_grid % clon, &
    130        palm_grid % ii, palm_grid % jj)
     129                                    palm_grid % clat, palm_grid % clon,        &
     130                                    palm_grid % ii, palm_grid % jj)
    131131
    132132    ! Assert
     
    178178    ! Act
    179179    CALL find_horizontal_neighbours(cosmo_grid % lat, cosmo_grid % lon,        &
    180        cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat, palm_grid % clon, &
    181        palm_grid % ii, palm_grid % jj)
     180                                    palm_grid % clat, palm_grid % clon,        &
     181                                    palm_grid % ii, palm_grid % jj)
    182182
    183183    CALL compute_horizontal_interp_weights(cosmo_grid % lat, cosmo_grid % lon, &
    184        cosmo_grid % dxi, cosmo_grid % dyi, palm_grid % clat,                   &
    185        palm_grid % clon, palm_grid % ii, palm_grid % jj, palm_grid % w_horiz)
     184                                           palm_grid % clat, palm_grid % clon, &
     185                                           palm_grid % ii, palm_grid % jj,     &
     186                                           palm_grid % w_horiz)
    186187
    187188    ! Assert
  • TabularUnified palm/trunk/UTIL/inifor/tests/test-prototype.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
    23 !
     23! Added usage hints
    2424!
    2525! Former revisions:
     
    5151
    5252    ! Arange
     53    !define parameters and reference values
    5354
    5455    ! Act
     56    !compute result
    5557
    5658    ! Assert
     59    !res = res .AND. assert_equal(<result_array>, <reference_array>, 'description')
    5760
    5861    CALL end_test(title, res)
  • TabularUnified palm/trunk/UTIL/inifor/tests/util.f90

    r2718 r3182  
    2121! Current revisions:
    2222! -----------------
     23! Expose error measure as parameter in assert_equal()
    2324!
    2425!
     
    7475    END SUBROUTINE end_test
    7576
    76     LOGICAL FUNCTION assert_equal(a, b, msg)
     77    LOGICAL FUNCTION assert_equal(a, b, msg, ratio)
     78       REAL, OPTIONAL, INTENT(IN)     ::  ratio
    7779       REAL, DIMENSION(:), INTENT(IN) ::  a, b
    78        CHARACTER(LEN=*), INTENT(IN)   :: msg
     80       CHARACTER(LEN=*), INTENT(IN)   ::  msg
    7981
    80        assert_equal = assert(a, b, 'eq')
     82       IF ( PRESENT(ratio) )  THEN
     83           assert_equal = assert(a, b, 'eq', ratio)
     84       ELSE
     85           assert_equal = assert(a, b, 'eq')
     86       END IF
     87
    8188       IF (assert_equal .eqv. .TRUE.)  THEN
    8289           PRINT *, "Equality assertion for ", msg, " was successful."
     
    8895    END FUNCTION assert_equal
    8996
    90     LOGICAL FUNCTION assert(a, b, mode, eps)
     97    LOGICAL FUNCTION assert(a, b, mode, ratio)
    9198
    9299       REAL, DIMENSION(:), INTENT(IN) ::  a, b
    93        REAL, OPTIONAL, INTENT(IN)     ::  eps
     100       REAL, OPTIONAL, INTENT(IN)     ::  ratio
    94101       CHARACTER(LEN=*), INTENT(IN)   ::  mode
    95102
     
    98105
    99106       max_rel_diff = 10 * EPSILON(1.0)
    100        IF (PRESENT(eps)) max_rel_diff = eps
     107       IF (PRESENT(ratio)) max_rel_diff = ratio
    101108
    102109       SELECT CASE( TRIM(mode) )
Note: See TracChangeset for help on using the changeset viewer.