Changeset 4868


Ignore:
Timestamp:
Feb 8, 2021 10:07:43 AM (4 years ago)
Author:
raasch
Message:

Height of level k=0 for the u,v-grid is always set 0.0

File:
1 edited

Legend:

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

    r4828 r4868  
    2424! -----------------
    2525! $Id$
     26! Height of level k=0 for the u,v-grid is always set 0.0,
     27! small changes to follow coding standard
     28!
     29! 4828 2021-01-05 11:21:41Z Giersch
    2630! Bugfix in building mapping when static driver is available but no actual building is present
    2731! within the model domain
     
    161165               dz_stretch_factor_array, dz_stretch_level, dz_stretch_level_end,                    &
    162166               dz_stretch_level_end_index, dz_stretch_level_start_index,                           &
    163                dz_stretch_level_start, ibc_uv_b, message_string,                                   &
     167               dz_stretch_level_start, message_string,                                             &
    164168               number_stretch_level_end,                                                           &
    165169               number_stretch_level_start,                                                         &
     
    386390
    387391!
    388 !--    Grid for atmosphere with surface at z=0 (k=0, w-grid).
    389 !--    First compute the u- and v-levels. In case of dirichlet bc for u and v the first u/v- and
    390 !--    w-level (k=0) are defined at same height (z=0).
    391 !--    The second u-level (k=1) corresponds to the top of the surface layer. In case of symmetric
    392 !--    boundaries (closed channel flow), the first grid point is always at z=0.
    393        IF ( ibc_uv_b == 0  .OR.  ibc_uv_b == 2  .OR.  topography == 'closed_channel' )  THEN
    394           zu(0) = 0.0_wp
    395        ELSE
    396           zu(0) = - dz(1) * 0.5_wp
    397        ENDIF
    398 
    399        zu(1) =   dz(1) * 0.5_wp
     392!--    Grid for atmosphere with surface at z=0. This corresponds to k=0 on the w-grid AND
     393!--    the u-grid.
     394!--    First compute the u- and v-levels.
     395!--    The second u-level (k=1) corresponds to the top of the surface layer.
     396       zu(0) = 0.0_wp
     397       zu(1) = dz(1) * 0.5_wp
    400398
    401399!
     
    430428          dz_level_end = ABS( zu(k) - dz_stretch_level_end(n) )
    431429
    432           IF ( dz_level_end  < dz(n+1)/3.0 )  THEN
     430          IF ( dz_level_end  <  dz(n+1) / 3.0 )  THEN
    433431             zu(k) = dz_stretch_level_end(n)
    434432             dz_stretched = dz(n+1)
     
    572570!
    573571!--    Compute the w-levels. They are always staggered half-way between the corresponding u-levels,
    574 !--    except in case of dirichlet bc for u and v at the ground. In this case the first u- and
     572!--    except for u and v at the ground. In this case the first u- and
    575573!--    w-level are defined at same height. The top w-level (nzt+1) is not used but set for
    576 !--    consistency, since w and all scalar variables are defined up tp nzt+1.
     574!--    consistency, since w and all scalar variables are defined up to nzt+1.
    577575       zw(nzt+1) = dz(1)
    578576       zw(nzt)   = 0.0_wp
     
    582580
    583581!
    584 !--    In case of dirichlet bc for u and v the first u- and w-level are defined at same height.
    585        IF ( ibc_uv_b == 0 ) THEN
    586           zu(0) = zw(0)
    587        ENDIF
     582!--    Like for the atmosphere, the first u-grid and w-grid-level are defined at same height.
     583       zu(0) = zw(0)
    588584
    589585    ENDIF !End of defining the vertical grid levels
     
    822818!--    Second branch for stretching from fine to rough
    823819       ELSEIF ( dz(n) < dz(n+1) )  THEN
     820
    824821          DO WHILE ( stretch_factor_1 <= stretch_factor_upper_limit )
    825822
     
    853850
    854851       ELSE
     852
    855853          message_string= 'Two adjacent values of dz must be different'
    856854          CALL message( 'init_grid', 'PA0228', 1, 2, 0, 6, 0 )
     
    872870
    873871       ENDIF
     872
    874873    ENDDO
    875874
     
    12801279!-- Topography input via ASCII format.
    12811280    ELSE
    1282        ocean_offset     = MERGE( zw(0), 0.0_wp, ocean_mode )
     1281
     1282       ocean_offset = MERGE( zw(0), 0.0_wp, ocean_mode )
    12831283!
    12841284!--    Initialize topography bit 0 (indicates obstacle) everywhere to zero and clear all grid points
     
    13051305          ENDDO
    13061306       ENDDO
     1307
    13071308    ENDIF
    13081309
     
    13531354    INTEGER(iwp) ::  num_wall   !< number of surrounding vertical walls for a single grid point
    13541355
    1355     INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE            ::  topo_tmp          !< temporary 3D-topography used to fill holes
    1356     INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  topo_3d           !< 3D-topography array merging buildings and
    1357                                                                                  !< orography
     1356    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE            ::  topo_tmp  !< temporary 3D-topography used to fill holes
     1357    INTEGER(iwp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  topo_3d   !< 3D-topography array merging buildings and
     1358                                                                         !< orography
    13581359
    13591360    LOGICAL      ::  filled = .FALSE. !< flag indicating if holes were filled
     
    17901791
    17911792       CASE ( 'tunnel' )
    1792 
    17931793!
    17941794!--       Tunnel height
     
    20752075    ENDIF
    20762076
    2077 
    20782077 END SUBROUTINE init_topo
     2078
    20792079
    20802080 SUBROUTINE set_topo_flags(topo)
     
    21262126          ENDDO
    21272127
    2128           DO k = nzb, nzt
     2128          DO  k = nzb, nzt
    21292129!
    21302130!--          w grid
     
    21452145!-- Set outer array for scalars to mask near-surface grid points. Note, on basis of flag 24 futher
    21462146!-- flags will be derived which are used to control production of subgrid TKE production near walls.
    2147 
    21482147    ALLOCATE( wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    21492148    wall_flags_total_0 = 0
    21502149
    2151     DO i = nxl, nxr
    2152        DO j = nys, nyn
    2153           DO k = nzb, nzt+1
     2150    DO  i = nxl, nxr
     2151       DO  j = nys, nyn
     2152          DO  k = nzb, nzt+1
    21542153             wall_flags_total_0(k,j,i) = IOR( wall_flags_total_0(k,j,i), wall_flags_static_0(k,j,i) )
    21552154          ENDDO
     
    21592158    CALL exchange_horiz_int( wall_flags_total_0, nys, nyn, nxl, nxr, nzt, nbgp )
    21602159
    2161     DO i = nxl, nxr
    2162        DO j = nys, nyn
    2163           DO k = nzb, nzt+1
     2160    DO  i = nxl, nxr
     2161       DO  j = nys, nyn
     2162          DO  k = nzb, nzt+1
    21642163             IF ( BTEST( wall_flags_total_0(k,j-1,i), 0 )    .AND.                                 &
    21652164                  BTEST( wall_flags_total_0(k,j+1,i), 0 )    .AND.                                 &
     
    21762175!
    21772176!-- Set further special flags
    2178     DO i = nxl, nxr
    2179        DO j = nys, nyn
    2180           DO k = nzb, nzt+1
     2177    DO  i = nxl, nxr
     2178       DO  j = nys, nyn
     2179          DO  k = nzb, nzt+1
    21812180!
    21822181!--          scalar grid, former nzb_diff_s_inner.
     
    22052204
    22062205
    2207           DO k = nzb+1, nzt
     2206          DO  k = nzb+1, nzt
    22082207!
    22092208!--          Special flag on u grid, former nzb_u_inner + 1, required for disturb_field and
     
    22542253!
    22552254!--       Flags indicating downward facing walls
    2256           DO k = nzb+1, nzt+1
     2255          DO  k = nzb+1, nzt+1
    22572256!
    22582257!--          Scalar grid
     
    22782277!
    22792278!--       Flags indicating upward facing walls
    2280           DO k = nzb, nzt
     2279          DO  k = nzb, nzt
    22812280!
    22822281!--          Upward facing wall on scalar grid
     
    23312330!--       species or aerosols.
    23322331          IF ( scalar_advec == 'ws-scheme' )  THEN
    2333              DO k = nzb, nzt
     2332             DO  k = nzb, nzt
    23342333                IF ( BTEST( wall_flags_total_0(k,j,i), 0 )  .AND. (                                &
    23352334                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i-1), 0 ) )  .OR.              &
     
    23642363       wall_flags_static_0(nzb,:,:) = IBSET( wall_flags_static_0(nzb,:,:), 5 )
    23652364    ELSE
    2366        DO i = nxl, nxr
    2367           DO j = nys, nyn
    2368              DO k = nzb, nzt+1
     2365       DO  i = nxl, nxr
     2366          DO  j = nys, nyn
     2367             DO  k = nzb, nzt+1
    23692368!
    23702369!--             Natural terrain grid point
     
    23772376!
    23782377!-- Building grid points.
    2379     DO i = nxl, nxr
    2380        DO j = nys, nyn
    2381           DO k = nzb, nzt+1
     2378    DO  i = nxl, nxr
     2379       DO  j = nys, nyn
     2380          DO  k = nzb, nzt+1
    23822381             IF ( BTEST( topo(k,j,i), 2 ) )                                                        &
    23832382                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 6 )
     
    23872386!
    23882387!-- Set flag 4, indicating new topography grid points due to filtering.
    2389     DO i = nxl, nxr
    2390        DO j = nys, nyn
    2391           DO k = nzb, nzt+1
     2388    DO  i = nxl, nxr
     2389       DO  j = nys, nyn
     2390          DO  k = nzb, nzt+1
    23922391             IF ( BTEST( topo(k,j,i), 4 ) )                                                        &
    23932392                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 4 )
     
    23982397    CALL exchange_horiz_int( wall_flags_static_0, nys, nyn, nxl, nxr, nzt, nbgp )
    23992398
    2400     DO i = nxl, nxr
    2401        DO j = nys, nyn
    2402           DO k = nzb, nzt+1
     2399    DO  i = nxl, nxr
     2400       DO  j = nys, nyn
     2401          DO  k = nzb, nzt+1
    24032402             wall_flags_total_0(k,j,i) = IOR( wall_flags_total_0(k,j,i), wall_flags_static_0(k,j,i) )
    24042403          ENDDO
Note: See TracChangeset for help on using the changeset viewer.