Ignore:
Timestamp:
Apr 15, 2020 10:20:51 AM (4 years ago)
Author:
raasch
Message:

last bugfix deactivated because of compile problems, files re-formatted to follow the PALM coding standard

File:
1 edited

Legend:

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

    r4481 r4497  
    11!> @file vdi_internal_controls.f90
    2 !--------------------------------------------------------------------------------!
     2!--------------------------------------------------------------------------------------------------!
    33! This file is part of the PALM model system.
    44!
    5 ! PALM is free software: you can redistribute it and/or modify it under the
    6 ! terms of the GNU General Public License as published by the Free Software
    7 ! Foundation, either version 3 of the License, or (at your option) any later
    8 ! version.
    9 !
    10 ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
    11 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    12 ! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    13 !
    14 ! You should have received a copy of the GNU General Public License along with
    15 ! PALM. If not, see <http://www.gnu.org/licenses/>.
    16 !
    17 ! Copyright 2019-2020 Leibniz Universitaet Hannover
    18 !--------------------------------------------------------------------------------!
     5! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General
     6! Public License as published by the Free Software Foundation, either version 3 of the License, or
     7! (at your option) any later version.
     8!
     9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
     10! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     11! Public License for more details.
     12!
     13! You should have received a copy of the GNU General Public License along with PALM. If not, see
     14! <http://www.gnu.org/licenses/>.
     15!
     16! Copyright 1997-2020 Leibniz Universitaet Hannover
     17!--------------------------------------------------------------------------------------------------!
     18!
    1919!
    2020! Current revisions:
     
    2525! -----------------
    2626! $Id$
     27! file re-formatted to follow the PALM coding standard
     28!
     29!
     30! 4481 2020-03-31 18:55:54Z maronga
    2731! missing preprocessor directive added
    28 ! 
     32!
    2933! 4346 2019-12-18 11:55:56Z motisi
    30 ! Introduction of wall_flags_total_0, which currently sets bits based on static
    31 ! topography information used in wall_flags_static_0
    32 ! 
     34! Introduction of wall_flags_total_0, which currently sets bits based on static topography
     35! information used in wall_flags_static_0
     36!
    3337! 4329 2019-12-10 15:46:36Z motisi
    3438! Renamed wall_flags_0 to wall_flags_static_0
    35 ! 
     39!
    3640! 4182 2019-08-22 15:20:23Z scharf
    3741! added "Authors" section
    38 ! 
     42!
    3943! 4175 2019-08-20 13:19:16Z gronemeier
    4044! bugfix: removed unused variables
     
    5054! Description:
    5155! ------------
    52 !> According to VDI Guideline 3783 Part 9, internal assessment have to be
    53 !> carried out within the program for the model to be considered as evaluated.
    54 !------------------------------------------------------------------------------!
     56!> According to VDI Guideline 3783 Part 9, internal assessment has to be carried out within the
     57!> program for the model to be considered as evaluated.
     58!--------------------------------------------------------------------------------------------------!
    5559 MODULE vdi_internal_controls
    5660
    57     USE arrays_3d,                          &
    58         ONLY:  dzw,                         &
    59                pt,                          &
    60                q,                           &
    61                u,                           &
    62                u_p,                         &
    63                v,                           &
     61    USE arrays_3d,                                                                                 &
     62        ONLY:  dzw,                                                                                &
     63               pt,                                                                                 &
     64               q,                                                                                  &
     65               u,                                                                                  &
     66               u_p,                                                                                &
     67               v,                                                                                  &
    6468               w
    6569
    66     USE control_parameters,                 &
    67         ONLY:  bc_dirichlet_l,              &
    68                bc_dirichlet_n,              &
    69                bc_dirichlet_r,              &
    70                bc_dirichlet_s,              &
    71                bc_lr_cyc,                   &
    72                bc_ns_cyc,                   &
    73                humidity,                    &
    74                end_time,                    &
    75                message_string,              &
    76                neutral,                     &
     70    USE control_parameters,                                                                        &
     71        ONLY:  bc_dirichlet_l,                                                                     &
     72               bc_dirichlet_n,                                                                     &
     73               bc_dirichlet_r,                                                                     &
     74               bc_dirichlet_s,                                                                     &
     75               bc_lr_cyc,                                                                          &
     76               bc_ns_cyc,                                                                          &
     77               end_time,                                                                           &
     78               humidity,                                                                           &
     79               message_string,                                                                     &
     80               neutral,                                                                            &
    7781               time_since_reference_point
    7882
    79     USE indices,                            &
    80         ONLY:  nx,                          &
    81                nxl,                         &
    82                nxlg,                        &
    83                nxr,                         &
    84                nxrg,                        &
    85                ny,                          &
    86                nyn,                         &
    87                nyng,                        &
    88                nys,                         &
    89                nysg,                        &
    90                nzb,                         &
    91                nzt,                         &
     83    USE indices,                                                                                   &
     84        ONLY:  nx,                                                                                 &
     85               nxl,                                                                                &
     86               nxlg,                                                                               &
     87               nxr,                                                                                &
     88               nxrg,                                                                               &
     89               ny,                                                                                 &
     90               nyn,                                                                                &
     91               nyng,                                                                               &
     92               nys,                                                                                &
     93               nysg,                                                                               &
     94               nzb,                                                                                &
     95               nzt,                                                                                &
    9296               wall_flags_total_0
    9397
     
    9599
    96100#if defined( __parallel )
    97     USE pegrid,                             &
    98         ONLY:  collective_wait,             &
    99                comm2d,                      &
    100                ierr,                        &
    101                MPI_DOUBLE_PRECISION,        &
    102                MPI_INTEGER,                 &
    103                MPI_MAX,                     &
    104                MPI_SUM,                     &
     101    USE pegrid,                                                                                    &
     102        ONLY:  collective_wait,                                                                    &
     103               comm2d,                                                                             &
     104               ierr,                                                                               &
     105               MPI_DOUBLE_PRECISION,                                                               &
     106               MPI_INTEGER,                                                                        &
     107               MPI_MAX,                                                                            &
     108               MPI_SUM,                                                                            &
    105109               myid
    106110#else
    107     USE pegrid,                             &
     111    USE pegrid,                                                                                    &
    108112        ONLY:  myid
    109113#endif
    110114
    111115
    112     USE grid_variables,                     &
    113         ONLY:  dx,                          &
     116    USE grid_variables,                                                                            &
     117        ONLY:  dx,                                                                                 &
    114118               dy
    115119
    116     USE pmc_interface,                      &
     120    USE pmc_interface,                                                                             &
    117121        ONLY: nested_run
    118122
    119123    IMPLICIT NONE
    120    
     124
    121125    INTEGER(iwp) ::  internal_count = 0  !< counts calls to this module
    122126
     
    151155!
    152156!-- Public functions
    153     PUBLIC          &
     157    PUBLIC                                                                                         &
    154158       vdi_actions
    155159
     
    157161 CONTAINS
    158162
    159 !------------------------------------------------------------------------------!
     163!--------------------------------------------------------------------------------------------------!
    160164! Description:
    161165! ------------
    162166!> Call for all grid points
    163167!> @todo Add proper description
    164 !------------------------------------------------------------------------------!
     168!--------------------------------------------------------------------------------------------------!
    165169 SUBROUTINE vdi_actions( location )
    166170
    167     CHARACTER (LEN=*), INTENT(IN) ::  location  !< call location string
     171    CHARACTER(LEN=*), INTENT(IN) ::  location  !< call location string
    168172
    169173
     
    173177
    174178          internal_count = internal_count + 1
    175        
     179
    176180          CALL vdi_2_deltat_wave
    177181
     
    191195
    192196 END SUBROUTINE vdi_actions
    193 !------------------------------------------------------------------------------!
     197!--------------------------------------------------------------------------------------------------!
    194198! Description:
    195199! ------------
    196 !> At a control grid point in the interior of the model domain,
    197 !> 2 * deltat waves are not to be generated with increasing simulation time.
    198 !------------------------------------------------------------------------------!
     200!> At a control grid point in the interior of the model domain, 2 * delta t waves are not to be
     201!> generated with increasing simulation time.
     202!--------------------------------------------------------------------------------------------------!
    199203 SUBROUTINE vdi_2_deltat_wave
    200204
    201205    INTEGER(iwp) ::  count_wave = 0  !< counts the number of consecutive waves
    202     INTEGER(iwp) ::  count_time = 0  !< counter, so that the waves follow each other without gaps
    203     INTEGER(iwp) ::  cgp_i = 0       !< x coordinate of the control grid point for testing 2deltat waves
    204     INTEGER(iwp) ::  cgp_j = 0       !< y coordinate of the control grid point for testing 2deltat waves
    205     INTEGER(iwp) ::  cgp_k = 0       !< z coordinate of the control grid point for testing 2deltat waves
    206 
    207     INTEGER(iwp), DIMENSION(4) ::  sig_arr = (/ 0, 0, 0, 0/)  !< indicates an increase(1) or a decrease (0) of u in the last four time steps
     206    INTEGER(iwp) ::  count_time = 0  !< counter, so that the waves follow one another without gaps
     207    INTEGER(iwp) ::  cgp_i      = 0  !< x coordinate of the control grid point for testing 2 delta t waves
     208    INTEGER(iwp) ::  cgp_j      = 0  !< y coordinate of the control grid point for testing 2 delta t waves
     209    INTEGER(iwp) ::  cgp_k      = 0  !< z coordinate of the control grid point for testing 2 delta t waves
     210
     211    INTEGER(iwp), DIMENSION(4) ::  sig_arr = (/ 0, 0, 0, 0 /)  !< indicates an increase(1) or a decrease (0)
     212                                                               !< of u in the last four time steps
    208213
    209214    REAL(wp) ::  random  !< random number
     
    222227!
    223228!--       If there is topography in the entire grid column, a new x coordinate is chosen
    224           IF ( cgp_k >= nzt-1 )  THEN
     229          IF ( cgp_k >= nzt -1 )  THEN
    225230             CALL RANDOM_NUMBER( random )
    226231             cgp_i = nxl + FLOOR( ( nxr + 1 - nxl ) * random )
     
    230235    ENDIF
    231236
    232     CALL testing_2_deltat_wave( u_p(cgp_k,cgp_j,cgp_i), u(cgp_k,cgp_j,cgp_i), &
     237    CALL testing_2_deltat_wave( u_p(cgp_k,cgp_j,cgp_i), u(cgp_k,cgp_j,cgp_i),                      &
    233238                                sig_arr, count_wave, count_time )
    234239
     
    236241
    237242
    238 !------------------------------------------------------------------------------!
     243!--------------------------------------------------------------------------------------------------!
    239244! Description:
    240245! ------------
    241 !> In this subroutine a quantity quant is tested for 2 delta t waves.
    242 !> For this, the size must have a wave-shaped course over 4*4 time steps
    243 !> and the amplitude of the wave has to be greater than the change of quant with
    244 !> increasing time.
    245 !------------------------------------------------------------------------------!
    246 SUBROUTINE testing_2_deltat_wave( quant_p_r, quant_r, sig_arr, count_wave, count_time )
     246!> In this subroutine the quantity quant is tested for 2 delta t waves. For this, the size must have
     247!> a wave-shaped course over 4*4 time steps and the amplitude of the wave has to be greater than the
     248!> change of quant with increasing time.
     249!--------------------------------------------------------------------------------------------------!
     250 SUBROUTINE testing_2_deltat_wave( quant_p_r, quant_r, sig_arr, count_wave, count_time )
    247251
    248252    INTEGER(iwp), INTENT(INOUT) ::  count_wave        !< counts the number of consecutive waves
    249     INTEGER(iwp), INTENT(INOUT) ::  count_time        !< counter, so that the waves follow each other without gaps
     253    INTEGER(iwp), INTENT(INOUT) ::  count_time        !< counter, so that the waves follow one another without gaps
    250254    INTEGER(iwp), PARAMETER     ::  number_wave = 10  !< number of consecutive waves that are not allowed
    251255
    252     REAL(wp), INTENT(IN) ::  quant_p_r                !< quantity from the previous time step as a real
    253     REAL(wp), INTENT(IN) ::  quant_r                  !< quantity as a real
    254     REAL(wp)             ::  quant_rel = 0.0_wp       !< rel. change of the quantity to the previous time step
    255 
    256     INTEGER(iwp), DIMENSION(4), INTENT(INOUT) ::  sig_arr !< indicates an increase(1) or a decrease (0) of
    257                                                           !> quantity quant in the last four time steps
     256    INTEGER(iwp), DIMENSION(4), INTENT(INOUT) ::  sig_arr  !< indicates an increase (1) or a decrease (0) of
     257                                                           !> quantity quant in the last four time steps
     258
     259    REAL(wp), INTENT(IN) ::  quant_p_r           !< quantity from the previous time step as a real
     260    REAL(wp), INTENT(IN) ::  quant_r             !< quantity as a real
     261    REAL(wp)             ::  quant_rel = 0.0_wp  !< rel. change of the quantity to the previous time step
     262
     263
    258264
    259265
     
    267273
    268274!
    269 !-- With this criterion 2 delta t waves are detected if the amplitude of
    270 !-- the wave is greater than the change of quant with increasing time
     275!-- With this criterion 2 delta t waves are detected if the amplitude of the wave is greater than
     276!-- the change of quant with increasing time
    271277    IF ( ALL( sig_arr(1:4) == (/ 1, 0, 1, 0 /) )  .AND.  quant_rel > 0.01 )  THEN
    272278
     
    297303
    298304
    299 !------------------------------------------------------------------------------!
     305!--------------------------------------------------------------------------------------------------!
    300306! Description:
    301307! ------------
    302 !> In this internal assessment the maxima of standarddifferences of the
    303 !> meteorological variables, computed layer by layer will be checked.
    304 !> The maxima should not to remain at the open edges of the model or
    305 !> travel from there into the interior of the domain with increasing
    306 !> simulation time.
     308!> In this internal assessment the maxima of standard differences of the meteorological variables,
     309!> computed layer by layer will be checked. The maxima should not remain at the open edges of the
     310!> model or travel from there into the interior of the domain with increasing simulation time.
    307311!> @todo try to reduce repeating code.
    308 !------------------------------------------------------------------------------!
    309 SUBROUTINE vdi_standard_differences
    310 
    311     INTEGER(iwp) ::  position_u_deviation = 0     !< position of the maximum of the standard deviation of u
    312     INTEGER(iwp) ::  position_u_deviation_p = 0   !< position of the maximum of the standard deviation of u to the previous time step
    313     INTEGER(iwp) ::  position_u_deviation_pp = 0  !< position of the maximum of the standard deviation of u two time steps ago
    314     INTEGER(iwp) ::  position_v_deviation = 0     !< position of the maximum of the standard deviation of v
    315     INTEGER(iwp) ::  position_v_deviation_p = 0   !< position of the maximum of the standard deviation of v to the previous time step
    316     INTEGER(iwp) ::  position_v_deviation_pp = 0  !< position of the maximum of the standard deviation of v two time steps ago
    317     INTEGER(iwp) ::  position_w_deviation = 0     !< position of the maximum of the standard deviation of w
    318     INTEGER(iwp) ::  position_w_deviation_p = 0   !< position of the maximum of the standard deviation of w to the previous time step
    319     INTEGER(iwp) ::  position_w_deviation_pp = 0  !< position of the maximum of the standard deviation of w two time steps ago
    320     INTEGER(iwp) ::  position_pt_deviation = 0    !< position of the maximum of the standard deviation of pt
    321     INTEGER(iwp) ::  position_pt_deviation_p = 0  !< position of the maximum of the standard deviation of pt to the previous time step
    322     INTEGER(iwp) ::  position_pt_deviation_pp = 0 !< position of the maximum of the standard deviation of pt two time steps ago
    323     INTEGER(iwp) ::  position_q_deviation = 0     !< position of the maximum of the standard deviation of q
    324     INTEGER(iwp) ::  position_q_deviation_p = 0   !< position of the maximum of the standard deviation of q to the previous time step
    325     INTEGER(iwp) ::  position_q_deviation_pp = 0  !< position of the maximum of the standard deviation of q two time steps ago
    326 
    327     REAL(wp), DIMENSION(nzb:nzt+1) ::  u_deviation  !< standard deviation of u depending on k
    328     REAL(wp), DIMENSION(nzb:nzt+1) ::  v_deviation  !< standard deviation of v depending on k
    329     REAL(wp), DIMENSION(nzb:nzt+1) ::  w_deviation  !< standard deviation of w depending on k
    330     REAL(wp), DIMENSION(nzb:nzt+1) ::  pt_deviation !< standard deviation of pt depending on k
    331     REAL(wp), DIMENSION(nzb:nzt+1) ::  q_deviation  !< standard deviation of q depending on k
     312!--------------------------------------------------------------------------------------------------!
     313 SUBROUTINE vdi_standard_differences
     314
     315    INTEGER(iwp) ::  position_pt_deviation    = 0  !< position of the maximum of the standard deviation of pt
     316    INTEGER(iwp) ::  position_pt_deviation_p  = 0  !< position of the maximum of the standard deviation of pt
     317                                                   !< to the previous time step
     318    INTEGER(iwp) ::  position_pt_deviation_pp = 0  !< position of the maximum of the standard deviation of pt two time steps ago
     319    INTEGER(iwp) ::  position_q_deviation     = 0  !< position of the maximum of the standard deviation of q
     320    INTEGER(iwp) ::  position_q_deviation_p   = 0  !< position of the maximum of the standard deviation of q to
     321                                                   !< the previous time step
     322    INTEGER(iwp) ::  position_q_deviation_pp  = 0  !< position of the maximum of the standard deviation of q two time steps ago
     323    INTEGER(iwp) ::  position_u_deviation     = 0  !< position of the maximum of the standard deviation of u
     324    INTEGER(iwp) ::  position_u_deviation_p   = 0  !< position of the maximum of the standard deviation of u to
     325                                                   !< the previous time step
     326    INTEGER(iwp) ::  position_u_deviation_pp  = 0  !< position of the maximum of the standard deviation of u two time steps ago
     327    INTEGER(iwp) ::  position_v_deviation     = 0  !< position of the maximum of the standard deviation of v
     328    INTEGER(iwp) ::  position_v_deviation_p   = 0  !< position of the maximum of the standard deviation of v
     329                                                   !< to the previous time step
     330    INTEGER(iwp) ::  position_v_deviation_pp  = 0  !< position of the maximum of the standard deviation of v two time steps ago
     331    INTEGER(iwp) ::  position_w_deviation     = 0  !< position of the maximum of the standard deviation of w
     332    INTEGER(iwp) ::  position_w_deviation_p   = 0  !< position of the maximum of the standard deviation of w
     333                                                   !< to the previous time step
     334    INTEGER(iwp) ::  position_w_deviation_pp  = 0  !< position of the maximum of the standard deviation of w two time steps ago
     335
     336    REAL(wp), DIMENSION(nzb:nzt+1) ::  pt_deviation  !< standard deviation of pt depending on k
     337    REAL(wp), DIMENSION(nzb:nzt+1) ::  q_deviation   !< standard deviation of q depending on k
     338    REAL(wp), DIMENSION(nzb:nzt+1) ::  u_deviation   !< standard deviation of u depending on k
     339    REAL(wp), DIMENSION(nzb:nzt+1) ::  v_deviation   !< standard deviation of v depending on k
     340    REAL(wp), DIMENSION(nzb:nzt+1) ::  w_deviation   !< standard deviation of w depending on k
    332341
    333342!
     
    337346!
    338347!-- Determination of the position of the maximum
    339     position_u_deviation = MAXLOC( u_deviation, DIM=1 )
     348    position_u_deviation = MAXLOC( u_deviation, DIM = 1 )
    340349
    341350!
     
    354363!
    355364!-- Determination of the position of the maximum
    356     position_v_deviation = MAXLOC( v_deviation, DIM=1 )
     365    position_v_deviation = MAXLOC( v_deviation, DIM = 1 )
    357366
    358367!
     
    371380!
    372381!-- Determination of the position of the maximum
    373     position_w_deviation = MAXLOC( w_deviation, DIM=1 )
     382    position_w_deviation = MAXLOC( w_deviation, DIM = 1 )
    374383
    375384!
     
    389398!
    390399!--    Determination of the position of the maximum
    391        position_pt_deviation = MAXLOC( pt_deviation, DIM=1 )
     400       position_pt_deviation = MAXLOC( pt_deviation, DIM = 1 )
    392401
    393402!
    394403!--    Check the position of the maximum of the standard deviation of pt
    395404       IF ( internal_count > 2 )  THEN
    396           CALL check_position( position_pt_deviation,   &
    397                                position_pt_deviation_p, &
     405          CALL check_position( position_pt_deviation,                                              &
     406                               position_pt_deviation_p,                                            &
    398407                               position_pt_deviation_pp )
    399408       ENDIF
     
    411420!
    412421!--    Determination of the position of the maximum
    413        position_q_deviation = MAXLOC( q_deviation, DIM=1 )
     422       position_q_deviation = MAXLOC( q_deviation, DIM = 1 )
    414423
    415424!
    416425!--    Check the position of the maximum of the standard deviation of q
    417426       IF ( internal_count > 2 )  THEN
    418           CALL check_position( position_q_deviation,   &
    419                                position_q_deviation_p, &
     427          CALL check_position( position_q_deviation,                                               &
     428                               position_q_deviation_p,                                             &
    420429                               position_q_deviation_pp )
    421430       ENDIF
     
    426435    ENDIF
    427436
    428 END SUBROUTINE vdi_standard_differences
    429 
    430 
    431 !------------------------------------------------------------------------------!
     437 END SUBROUTINE vdi_standard_differences
     438
     439
     440!--------------------------------------------------------------------------------------------------!
    432441! Description:
    433442! ------------
    434443!> Calculation of the standard deviation
    435 !------------------------------------------------------------------------------!
    436 SUBROUTINE calc_standard_deviation( quant, std_deviation, quant_type )
     444!--------------------------------------------------------------------------------------------------!
     445 SUBROUTINE calc_standard_deviation( quant, std_deviation, quant_type )
    437446
    438447    INTEGER(iwp)             ::  i           !< loop index
     
    468477             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), quant_type ) )
    469478             quant_av_k_l(k) = quant_av_k_l(k) + quant(k,j,i) * flag
    470              count_2d_l(k)   = count_2d_l(k) + INT( flag, KIND=iwp )
     479             count_2d_l(k)   = count_2d_l(k) + INT( flag, KIND = iwp )
    471480          ENDDO
    472481       ENDDO
     
    474483
    475484#if defined( __parallel )
    476     CALL MPI_ALLREDUCE( quant_av_k_l, quant_av_k, nzt+1-nzb+1, &
    477                         MPI_REAL, MPI_SUM, comm2d, ierr )
    478 
    479     CALL MPI_ALLREDUCE( count_2d_l, count_2d, nzt+1-nzb+1,     &
    480                         MPI_INTEGER, MPI_SUM, comm2d, ierr )
     485    CALL MPI_ALLREDUCE( quant_av_k_l, quant_av_k, nzt+1 - nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
     486
     487    CALL MPI_ALLREDUCE( count_2d_l, count_2d, nzt+1 - nzb+1, MPI_INTEGER, MPI_SUM, comm2d, ierr )
    481488#else
    482489    quant_av_k = quant_av_k_l
     
    485492
    486493    DO  k = nzb+1, nzt+1
    487        quant_av_k(k) = quant_av_k(k) / REAL( count_2d(k), KIND=wp )
     494       quant_av_k(k) = quant_av_k(k) / REAL( count_2d(k), KIND = wp )
    488495    ENDDO
    489496
     
    491498       DO  j = nys, nyn
    492499          DO  k = nzb+1, nzt+1
    493              std_deviation_l(k) = std_deviation_l(k)                  &
    494                                 + ( quant(k,j,i) - quant_av_k(k) )**2 &
    495                                 * MERGE( 1.0_wp, 0.0_wp,              &
    496                                          BTEST( wall_flags_total_0(k,j,i), quant_type ) )
     500             std_deviation_l(k) = std_deviation_l(k)                                               &
     501                                + ( quant(k,j,i) - quant_av_k(k) )**2                              &
     502                                * MERGE( 1.0_wp, 0.0_wp,                                           &
     503                                  BTEST( wall_flags_total_0(k,j,i), quant_type ) )
    497504          ENDDO
    498505       ENDDO
     
    501508
    502509#if defined( __parallel )
    503     CALL MPI_ALLREDUCE( std_deviation_l, std_deviation, nzt+1-nzb+1, &
    504                         MPI_REAL, MPI_SUM, comm2d, ierr )
     510    CALL MPI_ALLREDUCE( std_deviation_l, std_deviation, nzt+1-nzb+1, MPI_REAL, MPI_SUM, comm2d, ierr )
    505511#else
    506512    std_deviation = std_deviation_l
     
    508514
    509515    DO  k = nzb+1, nzt+1
    510        std_deviation(k) = SQRT( std_deviation(k) / REAL( count_2d(k), KIND=wp ) )
     516       std_deviation(k) = SQRT( std_deviation(k) / REAL( count_2d(k), KIND = wp ) )
    511517    ENDDO
    512518
    513 END SUBROUTINE calc_standard_deviation
    514 
    515 
    516 !------------------------------------------------------------------------------!
     519 END SUBROUTINE calc_standard_deviation
     520
     521
     522!--------------------------------------------------------------------------------------------------!
    517523! Description:
    518524! ------------
    519 !> Tests for the position of the maxima of the standard deviation.
    520 !> If the maxima remain at the open edges of the model or travel from
    521 !> the open edges into the interior of the domain with increasing
     525!> Tests for the position of the maxima of the standard deviation. If the maxima remain at the open
     526!> edges of the model or travel from the open edges into the interior of the domain with increasing
    522527!> simulation time, the simulation should be aborted.
    523 !------------------------------------------------------------------------------!
     528!--------------------------------------------------------------------------------------------------!
    524529 SUBROUTINE check_position( position_std_deviation, position_std_deviation_p, &
    525530                            position_std_deviation_pp )
     
    530535
    531536
    532     IF ( position_std_deviation == nzt    .AND.  &
    533          position_std_deviation_p == nzt  .AND.  &
    534          position_std_deviation_pp == nzt        )  THEN
    535        message_string = 'The maxima of the standard deviation remain ' // &
    536                         'at the open edges of the model.'
     537    IF ( position_std_deviation == nzt    .AND.                                                    &
     538         position_std_deviation_p == nzt  .AND.                                                    &
     539         position_std_deviation_pp == nzt       )  THEN
     540       message_string = 'The maxima of the standard deviation' //                                  &
     541                        'remain at the open edges of the model.'
    537542       CALL message( 'vdi_standard_differences', 'PA0663', 1, 2, 0, 6, 0 )
    538543    ENDIF
    539544
    540     IF ( position_std_deviation == nzt-2    .AND. &
    541          position_std_deviation_p == nzt-1  .AND. &
     545    IF ( position_std_deviation == nzt-2    .AND.                                                  &
     546         position_std_deviation_p == nzt-1  .AND.                                                  &
    542547         position_std_deviation_pp == nzt         )  THEN
    543        message_string = 'The maxima of the standard deviation travel ' // &
    544                         'from the open edges into the interior ' //       &
     548       message_string = 'The maxima of the standard deviation travel ' //                          &
     549                        'from the open edges into the interior ' //                                &
    545550                        'of the domain with increasing simulation time.'
    546551       CALL message( 'vdi_standard_differences', 'PA0664', 1, 2, 0, 6, 0 )
    547552    ENDIF
    548553
    549 END SUBROUTINE check_position
    550 
    551 
    552 !------------------------------------------------------------------------------!
     554 END SUBROUTINE check_position
     555
     556
     557!--------------------------------------------------------------------------------------------------!
    553558! Description:
    554559! ------------
    555 !> In this control it will be checked, if the means of the meteorological
    556 !> variables over the model grid are not to exhibit 2 deltat waves or
    557 !> monotonic increase or decrease with increasing simulation time.
    558 !------------------------------------------------------------------------------!
    559 SUBROUTINE vdi_domain_averages
    560 
    561    INTEGER(iwp) ::  mono_count_u = 0   !< counter for monotonic decrease or increase of u
    562    INTEGER(iwp) ::  mono_count_v = 0   !< counter for monotonic decrease or increase of v
    563    INTEGER(iwp) ::  mono_count_w = 0   !< counter for monotonic decrease or increase of w
    564    INTEGER(iwp) ::  mono_count_q = 0   !< counter for monotonic decrease or increase of q
    565    INTEGER(iwp) ::  mono_count_pt = 0  !< counter for monotonic decrease or increase of pt
    566    INTEGER(iwp) ::  count_time_u = 0   !< counter, so that the waves of u follow each other without gaps
    567    INTEGER(iwp) ::  count_time_v = 0   !< counter, so that the waves of v follow each other without gaps
    568    INTEGER(iwp) ::  count_time_w = 0   !< counter, so that the waves of w follow each other without gaps
    569    INTEGER(iwp) ::  count_time_q = 0   !< counter, so that the waves of q follow each other without gaps
    570    INTEGER(iwp) ::  count_time_pt = 0  !< counter, so that the waves of pt follow each other without gaps
    571    INTEGER(iwp) ::  count_wave_u = 0   !< counts the number of consecutive waves of u
    572    INTEGER(iwp) ::  count_wave_v = 0   !< counts the number of consecutive waves of v
    573    INTEGER(iwp) ::  count_wave_w = 0   !< counts the number of consecutive waves of w
    574    INTEGER(iwp) ::  count_wave_q = 0   !< counts the number of consecutive waves of q
    575    INTEGER(iwp) ::  count_wave_pt = 0  !< counts the number of consecutive waves of pt
    576 
    577    INTEGER(iwp), DIMENSION(4) ::  sig_u_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0) of u in the last four time steps
    578    INTEGER(iwp), DIMENSION(4) ::  sig_v_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0) of v in the last four time steps
    579    INTEGER(iwp), DIMENSION(4) ::  sig_w_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0) of w in the last four time steps
    580    INTEGER(iwp), DIMENSION(4) ::  sig_q_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0) of q in the last four time steps
    581    INTEGER(iwp), DIMENSION(4) ::  sig_pt_arr = (/ 0, 0, 0, 0/)  !< indicates an increase(1) or a decrease (0) of pt in the last four time steps
    582 
    583    REAL(wp) ::  u_av = 0.0_wp     !< Mean of u
    584    REAL(wp) ::  u_av_p = 0.0_wp   !< Mean of u at the previous time step
    585    REAL(wp) ::  v_av = 0.0_wp     !< Mean of v
    586    REAL(wp) ::  v_av_p = 0.0_wp   !< Mean of v at the previous time step
    587    REAL(wp) ::  w_av = 0.0_wp     !< Mean of w
    588    REAL(wp) ::  w_av_p = 0.0_wp   !< Mean of w at the previous time step
    589    REAL(wp) ::  q_av = 0.0_wp     !< Mean of q
    590    REAL(wp) ::  q_av_p = 0.0_wp   !< Mean of q at the previous time step
    591    REAL(wp) ::  pt_av = 0.0_wp    !< Mean of pt
    592    REAL(wp) ::  pt_av_p = 0.0_wp  !< Mean of pt at the previous time step
     560!> In this control it will be checked, if the means of the meteorological variables over the model
     561!> grid are not to exhibit 2 delta t waves or monotonic increase or decrease with increasing
     562!> simulation time.
     563!--------------------------------------------------------------------------------------------------!
     564 SUBROUTINE vdi_domain_averages
     565
     566    INTEGER(iwp) ::  count_time_u  = 0  !< counter, so that the waves of u follow each other without gaps
     567    INTEGER(iwp) ::  count_time_v  = 0  !< counter, so that the waves of v follow each other without gaps
     568    INTEGER(iwp) ::  count_time_w  = 0  !< counter, so that the waves of w follow each other without gaps
     569    INTEGER(iwp) ::  count_time_q  = 0  !< counter, so that the waves of q follow each other without gaps
     570    INTEGER(iwp) ::  count_time_pt = 0  !< counter, so that the waves of pt follow each other without gaps
     571    INTEGER(iwp) ::  count_wave_u  = 0  !< counts the number of consecutive waves of u
     572    INTEGER(iwp) ::  count_wave_v  = 0  !< counts the number of consecutive waves of v
     573    INTEGER(iwp) ::  count_wave_w  = 0  !< counts the number of consecutive waves of w
     574    INTEGER(iwp) ::  count_wave_q  = 0  !< counts the number of consecutive waves of q
     575    INTEGER(iwp) ::  count_wave_pt = 0  !< counts the number of consecutive waves of pt
     576    INTEGER(iwp) ::  mono_count_u  = 0  !< counter for monotonic decrease or increase of u
     577    INTEGER(iwp) ::  mono_count_v  = 0  !< counter for monotonic decrease or increase of v
     578    INTEGER(iwp) ::  mono_count_w  = 0  !< counter for monotonic decrease or increase of w
     579    INTEGER(iwp) ::  mono_count_q  = 0  !< counter for monotonic decrease or increase of q
     580    INTEGER(iwp) ::  mono_count_pt = 0  !< counter for monotonic decrease or increase of pt
     581
     582    INTEGER(iwp), DIMENSION(4) ::  sig_u_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0)
     583                                                                 !< of u in the last four time steps
     584    INTEGER(iwp), DIMENSION(4) ::  sig_v_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0)
     585                                                                 !< of v in the last four time steps
     586    INTEGER(iwp), DIMENSION(4) ::  sig_w_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0)
     587                                                                 !< of w in the last four time steps
     588    INTEGER(iwp), DIMENSION(4) ::  sig_q_arr = (/ 0, 0, 0, 0/)   !< indicates an increase(1) or a decrease (0)
     589                                                                 !< of q in the last four time steps
     590    INTEGER(iwp), DIMENSION(4) ::  sig_pt_arr = (/ 0, 0, 0, 0/)  !< indicates an increase(1) or a decrease (0)
     591                                                                 !< of pt in the last four time steps
     592
     593    REAL(wp) ::  pt_av = 0.0_wp    !< Mean of pt
     594    REAL(wp) ::  pt_av_p = 0.0_wp  !< Mean of pt at the previous time step
     595    REAL(wp) ::  q_av = 0.0_wp     !< Mean of q
     596    REAL(wp) ::  q_av_p = 0.0_wp   !< Mean of q at the previous time step
     597    REAL(wp) ::  u_av = 0.0_wp     !< Mean of u
     598    REAL(wp) ::  u_av_p = 0.0_wp   !< Mean of u at the previous time step
     599    REAL(wp) ::  v_av = 0.0_wp     !< Mean of v
     600    REAL(wp) ::  v_av_p = 0.0_wp   !< Mean of v at the previous time step
     601    REAL(wp) ::  w_av = 0.0_wp     !< Mean of w
     602    REAL(wp) ::  w_av_p = 0.0_wp   !< Mean of w at the previous time step
    593603
    594604!
     
    626636    ENDIF
    627637
    628     IF ( time_since_reference_point >= end_time  .AND.   &
     638    IF ( time_since_reference_point >= end_time  .AND.                                             &
    629639         mono_count_u > 0.9_wp * internal_count )  THEN
    630640
    631        message_string = 'Monotonic decrease or increase with ' // &
    632                         'increasing simulation time for u'
     641       message_string = 'Monotonic decrease or increase with increasing simulation time for u'
    633642       CALL message( 'vdi_domain_averages', 'PA0665', 0, 1, 0, 6, 0 )
    634643    ENDIF
     
    640649    ENDIF
    641650
    642     IF ( time_since_reference_point >= end_time  .AND.   &
     651    IF ( time_since_reference_point >= end_time  .AND.                                             &
    643652         mono_count_v > 0.9_wp * internal_count )  THEN
    644        message_string = 'Monotonic decrease or increase with ' // &
    645                         'increasing simulation time for v'
     653       message_string = 'Monotonic decrease or increase with increasing simulation time for v'
    646654       CALL message( 'vdi_domain_averages', 'PA0665', 0, 1, 0, 6, 0 )
    647655    ENDIF
     
    653661    ENDIF
    654662
    655     IF ( time_since_reference_point >= end_time  .AND.   &
     663    IF ( time_since_reference_point >= end_time  .AND.                                             &
    656664         mono_count_w > 0.9_wp * internal_count )  THEN
    657        message_string = 'Monotonic decrease or increase with ' // &
    658                         'increasing simulation time for w'
     665       message_string = 'Monotonic decrease or increase with increasing simulation time for w'
    659666       CALL message( 'vdi_domain_averages', 'PA0665', 0, 1, 0, 6, 0 )
    660667    ENDIF
     
    667674       ENDIF
    668675
    669        IF ( time_since_reference_point >= end_time  .AND.    &
     676       IF ( time_since_reference_point >= end_time  .AND.                                          &
    670677            mono_count_pt > 0.9_wp * internal_count )  THEN
    671           message_string = 'Monotonic decrease or increase with ' // &
    672                            'increasing simulation time for pt'
     678          message_string = 'Monotonic decrease or increase with increasing simulation time for pt'
    673679          CALL message( 'vdi_domain_averages', 'PA0665', 0, 1, 0, 6, 0 )
    674680       ENDIF
     
    682688       ENDIF
    683689
    684        IF ( time_since_reference_point >= end_time  .AND.   &
     690       IF ( time_since_reference_point >= end_time  .AND.                                          &
    685691            mono_count_q > 0.9_wp * internal_count )  THEN
    686           message_string = 'Monotonic decrease or increase with ' // &
    687                            'increasing simulation time for q'
     692          message_string = 'Monotonic decrease or increase with increasing simulation time for q'
    688693          CALL message( 'vdi_domain_averages', 'PA0665', 0, 1, 0, 6, 0 )
    689694       ENDIF
     
    707712
    708713
    709 !------------------------------------------------------------------------------!
     714!--------------------------------------------------------------------------------------------------!
    710715! Description:
    711716! ------------
    712717!> Calculate the average of a quantity 'quant'.
    713 !------------------------------------------------------------------------------!
     718!--------------------------------------------------------------------------------------------------!
    714719 SUBROUTINE calc_average( quant, quant_av, quant_type )
    715720
    716     INTEGER(iwp) ::  average_count = 0    !< counter for averaging
     721    INTEGER(iwp) ::  average_count   = 0  !< counter for averaging
    717722    INTEGER(iwp) ::  average_count_l = 0  !< counter for averaging (local)
    718723    INTEGER      ::  i                    !< loop index
     
    721726    INTEGER(iwp) ::  quant_type           !< bit position (1 for u, 2 for v, 3 for w and 0 for scalar)
    722727
    723     REAL(wp) ::  flag                     !< flag indicating atmosphere (1) or wall (0) grid point
    724     REAL(wp) ::  quant_av                 !< average of the quantity quant
    725     REAL(wp) ::  quant_av_l = 0.0_wp      !< average of the quantity quant (local)
    726 
    727     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  quant
     728    REAL(wp) ::  flag                 !< flag indicating atmosphere (1) or wall (0) grid point
     729    REAL(wp) ::  quant_av             !< average of the quantity quant
     730    REAL(wp) ::  quant_av_l = 0.0_wp  !< average of the quantity quant (local)
     731
     732    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  quant  !<
    728733
    729734!
     
    736741            flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), quant_type ) )
    737742            quant_av_l = quant_av_l + quant(k,j,i) * flag
    738             average_count_l = average_count_l + INT( flag, KIND=iwp )
     743            average_count_l = average_count_l + INT( flag, KIND = iwp )
    739744         ENDDO
    740745      ENDDO
     
    742747
    743748#if defined( __parallel )
    744     CALL MPI_ALLREDUCE( quant_av_l, quant_av, 1,        &
    745                         MPI_REAL, MPI_SUM, comm2d, ierr )
    746     CALL MPI_ALLREDUCE( average_count_l, average_count, 1, &
    747                         MPI_INTEGER, MPI_SUM, comm2d, ierr )
     749    CALL MPI_ALLREDUCE( quant_av_l, quant_av, 1, MPI_REAL, MPI_SUM, comm2d, ierr )
     750    CALL MPI_ALLREDUCE( average_count_l, average_count, 1, MPI_INTEGER, MPI_SUM, comm2d, ierr )
    748751#else
    749752    quant_av = quant_av_l
     
    756759
    757760
    758 !------------------------------------------------------------------------------!
     761!--------------------------------------------------------------------------------------------------!
    759762! Description:
    760763! ------------
    761764!> Testing for conservation of mass.
    762 !------------------------------------------------------------------------------!
     765!--------------------------------------------------------------------------------------------------!
    763766 SUBROUTINE vdi_conservation_of_mass
    764767
    765     INTEGER(iwp) ::  i              !< loop index
    766     INTEGER(iwp) ::  j              !< loop index
    767     INTEGER(iwp) ::  k              !< loop index
     768    INTEGER(iwp) ::  i  !< loop index
     769    INTEGER(iwp) ::  j  !< loop index
     770    INTEGER(iwp) ::  k  !< loop index
    768771
    769772    REAL(wp)     ::  sum_mass_flux  !< sum of the mass flow
    770773
     774    REAL(wp), DIMENSION(1:3) ::  volume_flow    !< volume flow
    771775    REAL(wp), DIMENSION(1:3) ::  volume_flow_l  !< volume flow (local)
    772     REAL(wp), DIMENSION(1:3) ::  volume_flow    !< volume flow
    773776
    774777
     
    783786       DO  j = nys, nyn
    784787          DO  k = nzb+1, nzt
    785              volume_flow_l(1) = volume_flow_l(1)                        &
    786                               + u(k,j,i) * dzw(k) * dy                  &
    787                               * MERGE( 1.0_wp, 0.0_wp,                  &
    788                                  BTEST( wall_flags_total_0(k,j,i), 1 )  &
    789                                      )
     788             volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzw(k) * dy                          &
     789                                * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
    790790          ENDDO
    791791       ENDDO
    792792    ENDIF
    793 ! 
     793!
    794794!-- Sum up the volume flow through the right boundary
    795795    IF ( nxr == nx )  THEN
     
    797797       DO  j = nys, nyn
    798798          DO  k = nzb+1, nzt
    799              volume_flow_l(1) = volume_flow_l(1)                        &
    800                               - u(k,j,i) * dzw(k) * dy                  &
    801                               * MERGE( 1.0_wp, 0.0_wp,                  &
    802                                  BTEST( wall_flags_total_0(k,j,i), 1 )  &
    803                                      )
     799             volume_flow_l(1) = volume_flow_l(1) - u(k,j,i) * dzw(k) * dy                          &
     800                                * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
    804801          ENDDO
    805802       ENDDO
     
    812809       DO  i = nxl, nxr
    813810          DO  k = nzb+1, nzt
    814              volume_flow_l(2) = volume_flow_l(2)                        &
    815                               + v(k,j,i) * dzw(k) * dx                  &
    816                               * MERGE( 1.0_wp, 0.0_wp,                  &
    817                                  BTEST( wall_flags_total_0(k,j,i), 2 )  &
    818                                      )
     811             volume_flow_l(2) = volume_flow_l(2) + v(k,j,i) * dzw(k) * dx                          &
     812                                * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
    819813          ENDDO
    820814       ENDDO
     
    826820       DO  i = nxl, nxr
    827821          DO  k = nzb+1, nzt
    828              volume_flow_l(2) = volume_flow_l(2)                        &
    829                               - v(k,j,i) * dzw(k) * dx                  &
    830                               * MERGE( 1.0_wp, 0.0_wp,                  &
    831                                  BTEST( wall_flags_total_0(k,j,i), 2 )  &
    832                                      )
     822             volume_flow_l(2) = volume_flow_l(2) - v(k,j,i) * dzw(k) * dx                          &
     823                                * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
    833824          ENDDO
    834825       ENDDO
     
    857848   ENDIF
    858849
    859 END SUBROUTINE vdi_conservation_of_mass
    860 
    861 
    862 !------------------------------------------------------------------------------!
     850 END SUBROUTINE vdi_conservation_of_mass
     851
     852
     853!--------------------------------------------------------------------------------------------------!
    863854! Description:
    864855! ------------
    865 !> The results will be checked for exceedance the specified limits.
    866 !> The controls are performed at every time step and at every grid point.
    867 !> No wind component is allowed to have a magnitude greater than ten times
    868 !> the maximum wind velocity at the approach flow profile (Vdi 3783 part 9).
    869 !> Note, that the supersaturation can not be higher than 10%. Therefore, no
    870 !> test is required.
    871 !------------------------------------------------------------------------------!
    872 SUBROUTINE vdi_plausible_values
    873 
    874     INTEGER(iwp) ::  i          !< loop index
    875     INTEGER(iwp) ::  j          !< loop index
    876     INTEGER(iwp) ::  k          !< loop index
    877 
     856!> The results will be checked for exceedance of the specified limits. The controls are performed at
     857!> every time step and at every grid point. No wind component is allowed to have a magnitude greater
     858!> than ten times the maximum wind velocity at the approach flow profile (Vdi 3783 part 9).
     859!> Note, that the supersaturation can not be higher than 10%. Therefore, no test is required.
     860!--------------------------------------------------------------------------------------------------!
     861 SUBROUTINE vdi_plausible_values
     862
     863    INTEGER(iwp) ::  i  !< loop index
     864    INTEGER(iwp) ::  j  !< loop index
     865    INTEGER(iwp) ::  k  !< loop index
     866
     867    REAL(wp)     :: max_uv      !< maximum speed of all edges
    878868    REAL(wp)     :: max_uv_l_l  !< maximum speed at the left edge (local)
    879869    REAL(wp)     :: max_uv_l    !< maximum speed at the left edge
     870    REAL(wp)     :: max_uv_n_l  !< maximum speed at the north edge (local)
     871    REAL(wp)     :: max_uv_n    !< maximum speed at the north edge
    880872    REAL(wp)     :: max_uv_r_l  !< maximum speed at the right edge (local)
    881873    REAL(wp)     :: max_uv_r    !< maximum speed at the right edge
    882874    REAL(wp)     :: max_uv_s_l  !< maximum speed at the south edge (local)
    883875    REAL(wp)     :: max_uv_s    !< maximum speed at the south edge
    884     REAL(wp)     :: max_uv_n_l  !< maximum speed at the north edge (local)
    885     REAL(wp)     :: max_uv_n    !< maximum speed at the north edge
    886     REAL(wp)     :: max_uv      !< maximum speed of all edges
    887 
    888     REAL(wp), DIMENSION(4)                 ::  max_arr    !<
    889     REAL(wp), DIMENSION(:), ALLOCATABLE    ::  uv         !< wind velocity at the approach flow
    890     REAL(wp), DIMENSION(:), ALLOCATABLE    ::  uv_l       !< wind velocity at the approach flow (local)
     876
     877    REAL(wp), DIMENSION(4)                 ::  max_arr  !<
     878    REAL(wp), DIMENSION(:), ALLOCATABLE    ::  uv       !< wind velocity at the approach flow
     879    REAL(wp), DIMENSION(:), ALLOCATABLE    ::  uv_l     !< wind velocity at the approach flow (local)
    891880
    892881    REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn) ::  uv_l_nest  !< wind profile at the left edge (nesting)
     
    916905       IF ( nxl == 0 )  THEN
    917906          i = nxl
    918           DO j = nys, nyn
    919              DO k = nzb, nzt+1
    920                 uv_l_nest(k,j) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2  &
    921                                      + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2  )
     907          DO  j = nys, nyn
     908             DO  k = nzb, nzt+1
     909                uv_l_nest(k,j) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2                   &
     910                                     + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2 )
    922911             ENDDO
    923912          ENDDO
     
    926915!
    927916!--    Right boundary
    928        IF( nxr == nx )  THEN
     917       IF ( nxr == nx )  THEN
    929918          i = nxr
    930           DO j = nys, nyn
    931              DO k = nzb, nzt+1
    932                 uv_r_nest(k,j) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2  &
    933                                      + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2  )
     919          DO  j = nys, nyn
     920             DO  k = nzb, nzt+1
     921                uv_r_nest(k,j) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2                   &
     922                                     + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2 )
    934923
    935924             ENDDO
     
    941930       IF ( nys == 0 )  THEN
    942931          j = nys
    943           DO i = nxl, nxr
    944              DO k = nzb, nzt+1
    945                 uv_s_nest(k,i) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2  &
    946                                      + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2  )
     932          DO  i = nxl, nxr
     933             DO  k = nzb, nzt+1
     934                uv_s_nest(k,i) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2                   &
     935                                     + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2 )
    947936             ENDDO
    948937          ENDDO
     
    953942       IF ( nyn == ny )  THEN
    954943          j = nyn
    955           DO i = nxl, nxr
    956              DO k = nzb, nzt+1
    957                 uv_n_nest(k,i) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2  &
    958                                      + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2  )
     944          DO  i = nxl, nxr
     945             DO  k = nzb, nzt+1
     946                uv_n_nest(k,i) = SQRT( ( 0.5_wp * ( u(k,j,i-1) + u(k,j,i) ) )**2                   &
     947                                     + ( 0.5_wp * ( v(k,j-1,i) + v(k,j,i) ) )**2 )
    959948
    960949             ENDDO
     
    983972          IF ( nxl == 0  .AND.  nys == 0 )  THEN
    984973             DO  k = nzb, nzt+1
    985                 uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2  &
    986                               + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2  )
     974                uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2                           &
     975                              + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2 )
    987976             ENDDO
    988977          ENDIF
     
    993982          IF ( nxl == 0 .AND. nys == 0 )  THEN
    994983             DO  k = nzb, nzt+1
    995                 uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2  &
    996                               + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2  )
     984                uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2                           &
     985                              + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2 )
    997986             ENDDO
    998987          ENDIF
     
    1001990          IF ( nxr == nx .AND. nys == 0 )  THEN
    1002991             DO  k = nzb, nzt+1
    1003                 uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,nxr) + u(k,0,nxr+1) ) )**2  &
    1004                               + ( 0.5_wp * ( v(k,-1,nxr) + v(k,0,nxr) ) )**2   )
     992                uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,nxr) + u(k,0,nxr+1) ) )**2                      &
     993                              + ( 0.5_wp * ( v(k,-1,nxr) + v(k,0,nxr) ) )**2 )
    1005994             ENDDO
    1006995          ENDIF
     
    1010999          IF ( nxl == 0 .AND. nyn == ny )  THEN
    10111000             DO  k = nzb, nzt+1
    1012                 uv_l(k) = SQRT( ( 0.5_wp * ( u(k,nyn,-1) + u(k,nyn,0) ) )**2  &
     1001                uv_l(k) = SQRT( ( 0.5_wp * ( u(k,nyn,-1) + u(k,nyn,0) ) )**2                       &
    10131002                              + ( 0.5_wp * ( v(k,nyn+1,0) + v(k,nyn,0) ) )**2 )
    10141003             ENDDO
     
    10181007          IF ( nxl == 0 .AND. nys == 0 )  THEN
    10191008             DO  k = nzb, nzt+1
    1020                 uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2  &
    1021                               + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2  )
     1009                uv_l(k) = SQRT( ( 0.5_wp * ( u(k,0,-1) + u(k,0,0) ) )**2                           &
     1010                              + ( 0.5_wp * ( v(k,-1,0) + v(k,0,0) ) )**2 )
    10221011             ENDDO
    10231012          ENDIF
     
    10351024
    10361025!
    1037 !-- Test for exceedance the specified limits
    1038     message_string = 'A wind component have a magnitude greater ' //  &
    1039                      'than ten times the maximum wind velocity ' //   &
    1040                      'at the approach flow profile.'
     1026!-- Test for exceedance of the specified limits
     1027    message_string = 'A wind component have a magnitude greater than ten times the maximum' //     &
     1028                     'wind velocity at the approach flow profile.'
    10411029
    10421030    IF ( MAXVAL( ABS( u ) ) > 10.0_wp * max_uv )  THEN
     
    10551043!-- Test if the potential temperature lies between 220 K and 330 K
    10561044    IF ( MAXVAL( pt ) > 330.0_wp .OR. MAXVAL( pt ) < 220.0_wp )  THEN
    1057        message_string = 'The potential temperature does not lie ' //  &
    1058                         'between 220 K and 330 K.'
     1045       message_string = 'The potential temperature does not lie between 220 K and 330 K.'
    10591046       CALL message( 'vdi_plausible_values', 'PA0668', 2, 2, myid, 6, 0 )
    10601047    ENDIF
Note: See TracChangeset for help on using the changeset viewer.