Changeset 4797 for palm


Ignore:
Timestamp:
Nov 26, 2020 4:02:39 PM (3 years ago)
Author:
raasch
Message:

files re-formatted to follow the PALM coding standard

Location:
palm/trunk/SOURCE
Files:
5 edited

Legend:

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

    r4768 r4797  
    11!> @file ocean_mod.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/>.
     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/>.
    1615!
    1716! Copyright 2017-2020 Leibniz Universitaet Hannover
    18 !--------------------------------------------------------------------------------!
     17!--------------------------------------------------------------------------------------------------!
    1918!
    2019! Current revisions:
     
    2524! -----------------
    2625! $Id$
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 4768 2020-11-02 19:11:23Z suehring
    2729! Enable 3D data output also with 64-bit precision
    2830!
     
    3234! 4671 2020-09-09 20:27:58Z pavelkrc
    3335! Implementation of downward facing USM and LSM surfaces
    34 ! 
     36!
    3537! 4535 2020-05-15 12:07:23Z raasch
    3638! bugfix for restart data format query
    37 ! 
     39!
    3840! 4517 2020-05-03 14:29:30Z raasch
    3941! added restart with MPI-IO for reading local arrays
    40 ! 
     42!
    4143! 4495 2020-04-13 20:11:20Z raasch
    4244! restart data handling with MPI-IO added
    43 ! 
     45!
    4446! 4481 2020-03-31 18:55:54Z maronga
    4547! vector directives added to force vectorization on Intel19 compiler
    46 ! 
     48!
    4749! 4346 2019-12-18 11:55:56Z motisi
    48 ! Introduction of wall_flags_total_0, which currently sets bits based on static
    49 ! topography information used in wall_flags_static_0
    50 ! 
     50! Introduction of wall_flags_total_0, which currently sets bits based on static topography
     51! information used in wall_flags_static_0
     52!
    5153! 4329 2019-12-10 15:46:36Z motisi
    5254! Renamed wall_flags_0 to wall_flags_static_0
    53 ! 
     55!
    5456! 4272 2019-10-23 15:18:57Z schwenkel
    55 ! Further modularization of boundary conditions: moved boundary conditions to
    56 ! respective modules
     57! Further modularization of boundary conditions: moved boundary conditions to respective modules
    5758!
    5859! 4196 2019-08-29 11:02:06Z gronemeier
    5960! Consider rotation of model domain for calculating the Stokes drift
    60 ! 
     61!
    6162! 4182 2019-08-22 15:20:23Z scharf
    6263! Corrected "Former revisions" section
    63 ! 
     64!
    6465! 4110 2019-07-22 17:05:21Z suehring
    65 ! Pass integer flag array as well as boundary flags to WS scalar advection
    66 ! routine
    67 !
     66! Pass integer flag array as well as boundary flags to WS scalar advection routine
     67!
    6868! 4109 2019-07-22 17:00:34Z suehring
    6969! implemented ocean_actions
    70 ! 
     70!
    7171! 3767 2019-02-27 08:18:02Z raasch
    72 ! unused variable for file index and tmp_2d removed from rrd-subroutine parameter
    73 ! list
    74 !
     72! unused variable for file index and tmp_2d removed from rrd-subroutine parameter list
     73!
    7574! 3719 2019-02-06 13:10:18Z kanani
    76 ! Changed log_point to log_point_s, otherwise this overlaps with
    77 ! 'all progn.equations' cpu measurement.
    78 ! 
     75! Changed log_point to log_point_s, otherwise this overlaps with 'all progn.equations'
     76! cpu measurement.
     77!
    7978! 3684 2019-01-20 20:20:58Z knoop
    8079! nopointer option removed
     80!
    8181! 3294 2018-10-01 02:37:10Z raasch
    8282! initial revision
     
    8989! Description:
    9090! ------------
    91 !> This module contains relevant code for PALM's ocean mode, e.g. the
    92 !> prognostic equation for salinity, the equation of state for seawater,
    93 !> the Craik Leibovich force (Stokes force), and wave breaking effects
    94 !------------------------------------------------------------------------------!
     91!> This module contains relevant code for PALM's ocean mode, e.g. the prognostic equation for
     92!> salinity, the equation of state for seawater, the Craik Leibovich force (Stokes force), and wave
     93!> breaking effects
     94!--------------------------------------------------------------------------------------------------!
    9595 MODULE ocean_mod
    96  
    97 
    98     USE arrays_3d,                                                             &
    99         ONLY:  prho, prho_1, rho_ocean, rho_1, sa, sa_init, sa_1, sa_2, sa_3,  &
    100                sa_p, tsa_m, flux_l_sa, flux_s_sa, diss_l_sa, diss_s_sa
    101 
    102     USE control_parameters,                                                    &
    103         ONLY:  atmos_ocean_sign, bottom_salinityflux,                          &
    104                constant_top_salinityflux, restart_data_format_output, ocean_mode, top_salinityflux,&
    105                wall_salinityflux, loop_optimization, ws_scheme_sca
     96
     97
     98    USE arrays_3d,                                                                                 &
     99        ONLY:  diss_l_sa, diss_s_sa, flux_l_sa, flux_s_sa, prho, prho_1, rho_1, rho_ocean, sa,     &
     100               sa_1, sa_2, sa_3, sa_init, sa_p, tsa_m
     101
     102    USE control_parameters,                                                                        &
     103        ONLY:  atmos_ocean_sign, bottom_salinityflux, constant_top_salinityflux, loop_optimization,&
     104               ocean_mode, restart_data_format_output, top_salinityflux, wall_salinityflux,        &
     105               ws_scheme_sca
    106106
    107107    USE kinds
    108108
    109     USE pegrid,                                                                &
     109    USE pegrid,                                                                                    &
    110110        ONLY:  threads_per_task
    111111
    112     USE statistics,                                                            &
     112    USE statistics,                                                                                &
    113113        ONLY:  sums_wssas_ws_l
    114114
    115     USE indices,                                                               &
    116         ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0, nbgp
     115    USE indices,                                                                                   &
     116        ONLY:  advc_flags_s, nbgp, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
    117117
    118118    USE restart_data_mpi_io_mod,                                                                   &
     
    120120               wrd_mpi_io_global_array
    121121
    122     USE surface_mod,                                                           &
    123         ONLY:  bc_h, surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v,           &
    124                surf_usm_h, surf_usm_v
     122    USE surface_mod,                                                                               &
     123        ONLY:  bc_h, surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v
    125124
    126125       USE exchange_horiz_mod,                                                                     &
     
    132131    CHARACTER (LEN=20) ::  bc_sa_t = 'neumann'  !< namelist parameter
    133132
    134     INTEGER(iwp) ::  ibc_sa_t   !< integer flag for bc_sa_t
    135     INTEGER(iwp) ::  iran_ocean = -1234567  !< random number used for wave breaking effects
    136 
     133    INTEGER(iwp) ::  ibc_sa_t                                    !< integer flag for bc_sa_t
     134    INTEGER(iwp) ::  iran_ocean = -1234567                       !< random number used for wave breaking effects
    137135    INTEGER(iwp) ::  sa_vertical_gradient_level_ind(10) = -9999  !< grid index values of sa_vertical_gradient_level(s)
    138136
    139137    LOGICAL ::  salinity = .TRUE.             !< switch for using salinity
    140138    LOGICAL ::  stokes_force = .FALSE.        !< switch to switch on the Stokes force
     139    LOGICAL ::  surface_cooling_switched_off = .FALSE.  !< variable to check if surface heat flux has been switched off
    141140    LOGICAL ::  wave_breaking = .FALSE.       !< switch to switch on wave breaking effects
    142     LOGICAL ::  surface_cooling_switched_off = .FALSE.  !< variable to check if surface heat flux has been switched off
    143141
    144142    REAL(wp) ::  alpha_wave_breaking = 3.0_wp !< coefficient for wave breaking generated turbulence from Noh et al. (2004), JPO
     
    153151    REAL(wp) ::  u_star_wave_breaking        !< to store the absolute value of friction velocity at the ocean surface
    154152
    155     REAL(wp), DIMENSION(12), PARAMETER ::  nom =                               &
    156                           (/ 9.9984085444849347D2,   7.3471625860981584D0,     &
    157                             -5.3211231792841769D-2,  3.6492439109814549D-4,    &
    158                              2.5880571023991390D0,  -6.7168282786692354D-3,    &
    159                              1.9203202055760151D-3,  1.1798263740430364D-2,    &
    160                              9.8920219266399117D-8,  4.6996642771754730D-6,    &
    161                             -2.5862187075154352D-8, -3.2921414007960662D-12 /)
    162                           !< constants used in equation of state for seawater
    163 
    164     REAL(wp), DIMENSION(13), PARAMETER ::  den =                               &
    165                           (/ 1.0D0,                  7.2815210113327091D-3,    &
    166                             -4.4787265461983921D-5,  3.3851002965802430D-7,    &
    167                              1.3651202389758572D-10, 1.7632126669040377D-3,    &
    168                             -8.8066583251206474D-6, -1.8832689434804897D-10,   &
    169                              5.7463776745432097D-6,  1.4716275472242334D-9,    &
    170                              6.7103246285651894D-6, -2.4461698007024582D-17,   &
    171                             -9.1534417604289062D-18 /)
    172                           !< constants used in equation of state for seawater
     153    REAL(wp), DIMENSION(12), PARAMETER ::  nom =                                                   &
     154                                              (/ 9.9984085444849347D2,   7.3471625860981584D0,     &
     155                                                -5.3211231792841769D-2,  3.6492439109814549D-4,    &
     156                                                 2.5880571023991390D0,  -6.7168282786692354D-3,    &
     157                                                 1.9203202055760151D-3,  1.1798263740430364D-2,    &
     158                                                 9.8920219266399117D-8,  4.6996642771754730D-6,    &
     159                                                -2.5862187075154352D-8, -3.2921414007960662D-12 /)
     160                                               !< constants used in equation of state for seawater
     161
     162    REAL(wp), DIMENSION(13), PARAMETER ::  den =                                                   &
     163                                              (/ 1.0D0,                  7.2815210113327091D-3,    &
     164                                                -4.4787265461983921D-5,  3.3851002965802430D-7,    &
     165                                                 1.3651202389758572D-10, 1.7632126669040377D-3,    &
     166                                                -8.8066583251206474D-6, -1.8832689434804897D-10,   &
     167                                                 5.7463776745432097D-6,  1.4716275472242334D-9,    &
     168                                                 6.7103246285651894D-6, -2.4461698007024582D-17,   &
     169                                                -9.1534417604289062D-18 /)
     170                                              !< constants used in equation of state for seawater
    173171
    174172    SAVE
    175173
    176     PUBLIC ::  bc_sa_t, ibc_sa_t, prho_reference, sa_surface,                  &
    177                sa_vertical_gradient, sa_vertical_gradient_level,               &
    178                sa_vertical_gradient_level_ind, stokes_force, wave_breaking
     174    PUBLIC ::  bc_sa_t, ibc_sa_t, prho_reference, sa_surface, sa_vertical_gradient,                &
     175               sa_vertical_gradient_level, sa_vertical_gradient_level_ind, stokes_force,           &
     176               wave_breaking
    179177
    180178
     
    285283!
    286284!-- Add INTERFACES that must be available to other modules (alphabetical order)
    287     PUBLIC eqn_state_seawater, ocean_actions, ocean_check_data_output,         &
    288            ocean_check_data_output_pr, ocean_check_parameters,                 &
    289            ocean_data_output_2d, ocean_data_output_3d, ocean_exchange_horiz,   &
    290            ocean_define_netcdf_grid, ocean_header, ocean_init,                 &
    291            ocean_init_arrays, ocean_parin, ocean_prognostic_equations,         &
    292            ocean_swap_timelevel, ocean_rrd_global, ocean_rrd_local,            &
    293            ocean_wrd_global, ocean_wrd_local, ocean_3d_data_averaging,         &
    294            ocean_boundary_conditions, stokes_drift_terms, wave_breaking_term
     285    PUBLIC eqn_state_seawater, ocean_actions, ocean_check_data_output, ocean_check_data_output_pr, &
     286           ocean_check_parameters, ocean_data_output_2d, ocean_data_output_3d,                     &
     287           ocean_exchange_horiz, ocean_define_netcdf_grid, ocean_header, ocean_init,               &
     288           ocean_init_arrays, ocean_parin, ocean_prognostic_equations, ocean_swap_timelevel,       &
     289           ocean_rrd_global, ocean_rrd_local, ocean_wrd_global, ocean_wrd_local,                   &
     290           ocean_3d_data_averaging, ocean_boundary_conditions, stokes_drift_terms,                 &
     291           wave_breaking_term
    295292
    296293
    297294 CONTAINS
    298295
    299 !------------------------------------------------------------------------------!
    300 ! Description:
    301 ! ------------
    302 !> Equation of state for seawater as a function of potential temperature,
    303 !> salinity, and pressure.
     296!--------------------------------------------------------------------------------------------------!
     297! Description:
     298! ------------
     299!> Equation of state for seawater as a function of potential temperature, salinity, and pressure.
    304300!> For coefficients see Jackett et al., 2006: J. Atm. Ocean Tech.
    305301!> eqn_state_seawater calculates the potential density referred at hyp(0).
    306302!> eqn_state_seawater_func calculates density.
    307303!> TODO: so far, routine is not adjusted to use topography
    308 !------------------------------------------------------------------------------!
     304!--------------------------------------------------------------------------------------------------!
    309305 SUBROUTINE eqn_state_seawater
    310306
    311     USE arrays_3d,                                                             &
     307    USE arrays_3d,                                                                                 &
    312308        ONLY:  hyp, prho, pt_p, rho_ocean, sa_p
    313     USE indices,                                                               &
     309    USE indices,                                                                                   &
    314310        ONLY:  nxl, nxr, nyn, nys, nzb, nzt
    315311
     
    355351             sa2  = sa1 * sa1
    356352
    357              pnom = nom(1)           + nom(2)*pt1     + nom(3)*pt2     +       &
    358                     nom(4)*pt3       + nom(5)*sa1     + nom(6)*sa1*pt1 +       &
     353             pnom = nom(1)           + nom(2)*pt1     + nom(3)*pt2     +                           &
     354                    nom(4)*pt3       + nom(5)*sa1     + nom(6)*sa1*pt1 +                           &
    359355                    nom(7)*sa2
    360356
    361              pden = den(1)           + den(2)*pt1     + den(3)*pt2     +       &
    362                     den(4)*pt3       + den(5)*pt4     + den(6)*sa1     +       &
    363                     den(7)*sa1*pt1   + den(8)*sa1*pt3 + den(9)*sa15    +       &
     357             pden = den(1)           + den(2)*pt1     + den(3)*pt2     +                           &
     358                    den(4)*pt3       + den(5)*pt4     + den(6)*sa1     +                           &
     359                    den(7)*sa1*pt1   + den(8)*sa1*pt3 + den(9)*sa15    +                           &
    364360                    den(10)*sa15*pt2
    365361!
     
    367363             prho(k,j,i) = pnom / pden
    368364
    369              pnom = pnom +             nom(8)*p1      + nom(9)*p1*pt2  +       &
     365             pnom = pnom +             nom(8)*p1      + nom(9)*p1*pt2  +                           &
    370366                    nom(10)*p1*sa1   + nom(11)*p2     + nom(12)*p2*pt2
    371367
    372              pden = pden +             den(11)*p1     + den(12)*p2*pt3 +       &
     368             pden = pden +             den(11)*p1     + den(12)*p2*pt3 +                           &
    373369                    den(13)*p3*pt1
    374370
     
    380376
    381377!
    382 !--       Neumann conditions are assumed at top boundary and currently also at
    383 !--       bottom boundary (see comment lines below)
     378!--       Neumann conditions are assumed at top boundary and currently also at bottom boundary
     379!--       (see comment lines below)
    384380          prho(nzt+1,j,i)      = prho(nzt,j,i)
    385381          rho_ocean(nzt+1,j,i) = rho_ocean(nzt,j,i)
     
    411407
    412408
    413 !------------------------------------------------------------------------------!
     409!--------------------------------------------------------------------------------------------------!
    414410! Description:
    415411! ------------
    416412!> Same as above, but for grid point i,j
    417 !------------------------------------------------------------------------------!
     413!--------------------------------------------------------------------------------------------------!
    418414 SUBROUTINE eqn_state_seawater_ij( i, j )
    419415
    420     USE arrays_3d,                                                             &
     416    USE arrays_3d,                                                                                 &
    421417        ONLY:  hyp, prho, pt_p, rho_ocean, sa_p
    422418
    423     USE indices,                                                               &
     419    USE indices,                                                                                   &
    424420        ONLY:  nzb, nzt
    425421
     
    446442    REAL(wp) ::  sa2    !< temporary scalar user for calculating density
    447443
     444
    448445    DO  k = nzb+1, nzt
    449446!
     
    463460       sa2  = sa1 * sa1
    464461
    465        pnom = nom(1)           + nom(2)*pt1     + nom(3)*pt2     +             &
     462       pnom = nom(1)           + nom(2)*pt1     + nom(3)*pt2     +                                 &
    466463              nom(4)*pt3       + nom(5)*sa1     + nom(6)*sa1*pt1 + nom(7)*sa2
    467464
    468        pden = den(1)           + den(2)*pt1     + den(3)*pt2     +             &
    469               den(4)*pt3       + den(5)*pt4     + den(6)*sa1     +             &
    470               den(7)*sa1*pt1   + den(8)*sa1*pt3 + den(9)*sa15    +             &
     465       pden = den(1)           + den(2)*pt1     + den(3)*pt2     +                                 &
     466              den(4)*pt3       + den(5)*pt4     + den(6)*sa1     +                                 &
     467              den(7)*sa1*pt1   + den(8)*sa1*pt3 + den(9)*sa15    +                                 &
    471468              den(10)*sa15*pt2
    472469!
     
    474471       prho(k,j,i) = pnom / pden
    475472
    476        pnom = pnom +             nom(8)*p1      + nom(9)*p1*pt2  +             &
     473       pnom = pnom             + nom(8)*p1      + nom(9)*p1*pt2  +                                 &
    477474              nom(10)*p1*sa1   + nom(11)*p2     + nom(12)*p2*pt2
    478        pden = pden +             den(11)*p1     + den(12)*p2*pt3 +             &
     475
     476       pden = pden             + den(11)*p1     + den(12)*p2*pt3 +                                 &
    479477              den(13)*p3*pt1
    480478
     
    510508
    511509
    512 !------------------------------------------------------------------------------!
     510!--------------------------------------------------------------------------------------------------!
    513511! Description:
    514512! ------------
    515513!> Equation of state for seawater as a function
    516 !------------------------------------------------------------------------------!
     514!--------------------------------------------------------------------------------------------------!
    517515 REAL(wp) FUNCTION eqn_state_seawater_func( p, pt, sa )
    518516
     
    532530    REAL(wp) ::  sa2    !< temporary scalar user for calculating density
    533531
     532
    534533!
    535534!-- Pressure is needed in dbar
     
    549548
    550549
    551     eqn_state_seawater_func =                                                  &
    552          ( nom(1)        + nom(2)*pt1       + nom(3)*pt2    + nom(4)*pt3     + &
    553            nom(5)*sa     + nom(6)*sa*pt1    + nom(7)*sa2    + nom(8)*p1      + &
    554            nom(9)*p1*pt2 + nom(10)*p1*sa    + nom(11)*p2    + nom(12)*p2*pt2   &
    555          ) /                                                                   &
    556          ( den(1)        + den(2)*pt1       + den(3)*pt2    + den(4)*pt3     + &
    557            den(5)*pt4    + den(6)*sa        + den(7)*sa*pt1 + den(8)*sa*pt3  + &
    558            den(9)*sa15   + den(10)*sa15*pt2 + den(11)*p1    + den(12)*p2*pt3 + &
    559            den(13)*p3*pt1                                                      &
    560          )
     550    eqn_state_seawater_func =                                                                      &
     551                             ( nom(1)        + nom(2)*pt1       + nom(3)*pt2    + nom(4)*pt3     + &
     552                               nom(5)*sa     + nom(6)*sa*pt1    + nom(7)*sa2    + nom(8)*p1      + &
     553                               nom(9)*p1*pt2 + nom(10)*p1*sa    + nom(11)*p2    + nom(12)*p2*pt2   &
     554                             ) /                                                                   &
     555                             ( den(1)        + den(2)*pt1       + den(3)*pt2    + den(4)*pt3     + &
     556                               den(5)*pt4    + den(6)*sa        + den(7)*sa*pt1 + den(8)*sa*pt3  + &
     557                               den(9)*sa15   + den(10)*sa15*pt2 + den(11)*p1    + den(12)*p2*pt3 + &
     558                               den(13)*p3*pt1                                                      &
     559                             )
    561560
    562561
     
    564563
    565564
    566 !------------------------------------------------------------------------------!
     565!--------------------------------------------------------------------------------------------------!
    567566! Description:
    568567! ------------
    569568!> Reads the ocean parameters namelist
    570 !------------------------------------------------------------------------------!
     569!--------------------------------------------------------------------------------------------------!
    571570 SUBROUTINE ocean_parin
    572571
     
    576575
    577576
    578     NAMELIST /ocean_parameters/  bc_sa_t, bottom_salinityflux, salinity,       &
    579              sa_surface, sa_vertical_gradient, sa_vertical_gradient_level,     &
    580              stokes_waveheight, stokes_wavelength, surface_cooling_spinup_time,&
    581              top_salinityflux, wall_salinityflux, wave_breaking
     577    NAMELIST /ocean_parameters/  bc_sa_t, bottom_salinityflux, salinity, sa_surface,               &
     578                                 sa_vertical_gradient, sa_vertical_gradient_level,                 &
     579                                 stokes_waveheight, stokes_wavelength, surface_cooling_spinup_time,&
     580                                 top_salinityflux, wall_salinityflux, wave_breaking
    582581
    583582!
     
    607606 END SUBROUTINE ocean_parin
    608607
    609 !------------------------------------------------------------------------------!
     608!--------------------------------------------------------------------------------------------------!
    610609! Description:
    611610! ------------
    612611!> Check parameters routine for the ocean mode
    613 !------------------------------------------------------------------------------!
     612!--------------------------------------------------------------------------------------------------!
    614613 SUBROUTINE ocean_check_parameters
    615614
    616     USE control_parameters,                                                    &
    617         ONLY:  coupling_char, coupling_mode, initializing_actions,             &
    618                message_string, use_top_fluxes
    619 
    620     USE pmc_interface,                                                         &
     615    USE control_parameters,                                                                        &
     616        ONLY:  coupling_char, coupling_mode, initializing_actions, message_string, use_top_fluxes
     617
     618    USE pmc_interface,                                                                             &
    621619        ONLY:  nested_run
    622620
     
    638636!
    639637!-- Check ocean setting
    640     IF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.                           &
    641          TRIM( coupling_char ) == '_O' .AND.                                   &
     638    IF ( TRIM( coupling_mode ) == 'uncoupled'  .AND.  TRIM( coupling_char ) == '_O' .AND.          &
    642639         .NOT. ocean_mode )  THEN
    643640
    644641!
    645 !--    Check whether an (uncoupled) atmospheric run has been declared as an
    646 !--    ocean run (this setting is done via palmrun-option -y)
    647        message_string = 'ocean mode does not allow coupling_char = "' //       &
    648                         TRIM( coupling_char ) // '" set by palmrun-option "-y"'
     642!--    Check whether an (uncoupled) atmospheric run has been declared as an ocean run (this setting
     643!--    is done via palmrun-option -y)
     644       message_string = 'ocean mode does not allow coupling_char = "' // TRIM( coupling_char ) //  &
     645                        '" set by palmrun-option "-y"'
    649646       CALL message( 'ocean_check_parameters', 'PA0317', 1, 2, 0, 6, 0 )
    650647
     
    665662       ibc_sa_t = 1
    666663    ELSE
    667        message_string = 'unknown boundary condition: bc_sa_t = "' //           &
    668                         TRIM( bc_sa_t ) // '"'
     664       message_string = 'unknown boundary condition: bc_sa_t = "' // TRIM( bc_sa_t ) // '"'
    669665       CALL message( 'ocean_check_parameters', 'PA0068', 1, 2, 0, 6, 0 )
    670666    ENDIF
     
    673669
    674670    IF ( .NOT. salinity )  THEN
    675        IF ( ( bottom_salinityflux /= 0.0_wp  .AND.                             &
    676               bottom_salinityflux /= 9999999.9_wp )  .OR.                      &
    677             ( top_salinityflux /= 0.0_wp     .AND.                             &
    678               top_salinityflux /= 9999999.9_wp ) )                             &
     671       IF ( ( bottom_salinityflux /= 0.0_wp  .AND.  bottom_salinityflux /= 9999999.9_wp )  .OR.    &
     672            ( top_salinityflux /= 0.0_wp     .AND.  top_salinityflux /= 9999999.9_wp    ) )        &
    679673       THEN
    680           message_string = 'salinityflux must not be set for ocean run ' //    &
    681                            'without salinity'
     674          message_string = 'salinityflux must not be set for ocean run ' // 'without salinity'
    682675          CALL message( 'ocean_check_parameters', 'PA0509', 1, 2, 0, 6, 0 )
    683676       ENDIF
     
    685678
    686679    IF ( ibc_sa_t == 1  .AND.  top_salinityflux == 9999999.9_wp )  THEN
    687        message_string = 'boundary condition: bc_sa_t = "' //                   &
    688                         TRIM( bc_sa_t ) // '" requires to set top_salinityflux'
     680       message_string = 'boundary condition: bc_sa_t = "' // TRIM( bc_sa_t ) //                    &
     681                        '" requires to set top_salinityflux'
    689682       CALL message( 'ocean_check_parameters', 'PA0069', 1, 2, 0, 6, 0 )
    690683    ENDIF
    691684
    692685!
    693 !-- A fixed salinity at the top implies Dirichlet boundary condition for
    694 !-- salinity. In this case specification of a constant salinity flux is
    695 !-- forbidden.
    696     IF ( ibc_sa_t == 0  .AND.  constant_top_salinityflux  .AND.                &
    697          top_salinityflux /= 0.0_wp )  THEN
    698        message_string = 'boundary condition: bc_sa_t = "' //                   &
    699                         TRIM( bc_sa_t ) // '" is not allowed with ' //         &
    700                         'top_salinityflux /= 0.0'
     686!-- A fixed salinity at the top implies Dirichlet boundary condition for salinity. In this case
     687!-- specification of a constant salinity flux is forbidden.
     688    IF ( ibc_sa_t == 0  .AND.  constant_top_salinityflux  .AND.  top_salinityflux /= 0.0_wp )  THEN
     689       message_string = 'boundary condition: bc_sa_t = "' // TRIM( bc_sa_t ) //                    &
     690                        '" is not allowed with top_salinityflux /= 0.0'
    701691       CALL message( 'ocean_check_parameters', 'PA0070', 1, 2, 0, 6, 0 )
    702692    ENDIF
     
    707697       stokes_force = .TRUE.
    708698    ELSE
    709        IF ( ( stokes_waveheight <= 0.0_wp .AND. stokes_wavelength > 0.0_wp ) &
    710             .OR.                                                               &
    711             ( stokes_waveheight > 0.0_wp .AND. stokes_wavelength <= 0.0_wp ) &
    712             .OR.                                                               &
    713             ( stokes_waveheight < 0.0_wp .AND. stokes_wavelength < 0.0_wp  ) ) &
     699       IF ( ( stokes_waveheight <= 0.0_wp .AND. stokes_wavelength >  0.0_wp )  .OR.                &
     700            ( stokes_waveheight >  0.0_wp .AND. stokes_wavelength <= 0.0_wp )  .OR.                &
     701            ( stokes_waveheight <  0.0_wp .AND. stokes_wavelength <  0.0_wp ) )                    &
    714702       THEN
    715           message_string = 'wrong settings for stokes_wavelength and/or ' //   &
    716                            'stokes_waveheight'
     703          message_string = 'wrong settings for stokes_wavelength and/or stokes_waveheight'
    717704          CALL message( 'ocean_check_parameters', 'PA0460', 1, 2, 0, 6, 0 )
    718705       ENDIF
     
    722709
    723710
    724 !------------------------------------------------------------------------------!
     711!--------------------------------------------------------------------------------------------------!
    725712! Description:
    726713! ------------
    727714!> Check data output.
    728 !------------------------------------------------------------------------------!
     715!--------------------------------------------------------------------------------------------------!
    729716 SUBROUTINE ocean_check_data_output( var, unit )
    730  
     717
    731718    IMPLICIT NONE
    732719
     
    751738
    752739
    753 !------------------------------------------------------------------------------!
     740!--------------------------------------------------------------------------------------------------!
    754741! Description:
    755742! ------------
    756743!> Check data output of profiles
    757 !------------------------------------------------------------------------------!
     744!--------------------------------------------------------------------------------------------------!
    758745 SUBROUTINE ocean_check_data_output_pr( variable, var_count, unit, dopr_unit )
    759746
    760     USE arrays_3d,                                                             &
     747    USE arrays_3d,                                                                                 &
    761748        ONLY:  zu, zw
    762749
    763     USE control_parameters,                                                    &
     750    USE control_parameters,                                                                        &
    764751        ONLY:  data_output_pr
    765752
     
    772759    IMPLICIT NONE
    773760
     761    CHARACTER (LEN=*) ::  dopr_unit !< local value of dopr_unit
    774762    CHARACTER (LEN=*) ::  unit      !<
    775763    CHARACTER (LEN=*) ::  variable  !<
    776     CHARACTER (LEN=*) ::  dopr_unit !< local value of dopr_unit
    777764
    778765    INTEGER(iwp) ::  var_count     !<
     766
    779767
    780768    SELECT CASE ( TRIM( variable ) )
     
    837825
    838826
    839 !------------------------------------------------------------------------------!
     827!--------------------------------------------------------------------------------------------------!
    840828! Description:
    841829! ------------
    842830!> Define appropriate grid for netcdf variables.
    843831!> It is called out from subroutine netcdf.
    844 !------------------------------------------------------------------------------!
     832!--------------------------------------------------------------------------------------------------!
    845833 SUBROUTINE ocean_define_netcdf_grid( var, found, grid_x, grid_y, grid_z )
    846    
     834
    847835    IMPLICIT NONE
    848836
     
    854842    LOGICAL, INTENT(OUT) ::  found   !< flag if output variable is found
    855843
     844
    856845    found  = .TRUE.
    857846
     
    860849    SELECT CASE ( TRIM( var ) )
    861850
    862        CASE ( 'rho_sea_water', 'rho_sea_water_xy', 'rho_sea_water_xz', &
    863               'rho_sea_water_yz', 'sa', 'sa_xy', 'sa_xz', 'sa_yz' )
     851       CASE ( 'rho_sea_water', 'rho_sea_water_xy', 'rho_sea_water_xz', 'rho_sea_water_yz', 'sa',   &
     852              'sa_xy', 'sa_xz', 'sa_yz' )
    864853          grid_x = 'x'
    865854          grid_y = 'y'
     
    877866
    878867
    879 !------------------------------------------------------------------------------!
     868!--------------------------------------------------------------------------------------------------!
    880869! Description:
    881870! ------------
    882871!> Average 3D data.
    883 !------------------------------------------------------------------------------!
     872!--------------------------------------------------------------------------------------------------!
    884873 SUBROUTINE ocean_3d_data_averaging( mode, variable )
    885  
    886 
    887     USE arrays_3d,                                                             &
     874
     875
     876    USE arrays_3d,                                                                                 &
    888877        ONLY:  rho_ocean, sa
    889878
    890     USE averaging,                                                             &
     879    USE averaging,                                                                                 &
    891880        ONLY:  rho_ocean_av, sa_av
    892881
    893     USE control_parameters,                                                    &
     882    USE control_parameters,                                                                        &
    894883        ONLY:  average_count_3d
    895884
    896     USE indices,                                                               &
     885    USE indices,                                                                                   &
    897886        ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt
    898887
     
    905894    INTEGER(iwp) ::  j   !< loop index
    906895    INTEGER(iwp) ::  k   !< loop index
     896
    907897
    908898    IF ( mode == 'allocate' )  THEN
     
    936926                   DO  j = nysg, nyng
    937927                      DO  k = nzb, nzt+1
    938                          rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) +           &
    939                                                rho_ocean(k,j,i)
     928                         rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) + rho_ocean(k,j,i)
    940929                      ENDDO
    941930                   ENDDO
     
    964953
    965954          CASE ( 'rho_sea_water' )
    966              IF ( ALLOCATED( rho_ocean_av ) ) THEN
     955             IF ( ALLOCATED( rho_ocean_av ) )  THEN
    967956                DO  i = nxlg, nxrg
    968957                   DO  j = nysg, nyng
    969958                      DO  k = nzb, nzt+1
    970                          rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) /           &
     959                         rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) /                               &
    971960                                               REAL( average_count_3d, KIND=wp )
    972961                      ENDDO
     
    976965
    977966          CASE ( 'sa' )
    978              IF ( ALLOCATED( sa_av ) ) THEN
     967             IF ( ALLOCATED( sa_av ) )  THEN
    979968                DO  i = nxlg, nxrg
    980969                   DO  j = nysg, nyng
    981970                      DO  k = nzb, nzt+1
    982                          sa_av(k,j,i) = sa_av(k,j,i) /                         &
    983                                         REAL( average_count_3d, KIND=wp )
     971                         sa_av(k,j,i) = sa_av(k,j,i) / REAL( average_count_3d, KIND=wp )
    984972                      ENDDO
    985973                   ENDDO
     
    994982
    995983
    996 !------------------------------------------------------------------------------!
     984!--------------------------------------------------------------------------------------------------!
    997985! Description:
    998986! ------------
    999987!> Define 2D output variables.
    1000 !------------------------------------------------------------------------------!
    1001  SUBROUTINE ocean_data_output_2d( av, variable, found, grid, mode, local_pf,   &
    1002                                   nzb_do, nzt_do )
    1003  
    1004     USE arrays_3d,                                                             &
     988!--------------------------------------------------------------------------------------------------!
     989 SUBROUTINE ocean_data_output_2d( av, variable, found, grid, mode, local_pf, nzb_do, nzt_do )
     990
     991    USE arrays_3d,                                                                                 &
    1005992        ONLY:  rho_ocean, sa
    1006993
    1007     USE averaging,                                                             &
     994    USE averaging,                                                                                 &
    1008995        ONLY:  rho_ocean_av, sa_av
    1009996
    1010     USE indices,                                                               &
    1011         ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,            &
    1012               wall_flags_total_0
     997    USE indices,                                                                                   &
     998        ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, wall_flags_total_0
    1013999
    10141000    IMPLICIT NONE
     
    10311017    REAL(wp) ::  fill_value = -999.0_wp  !< value for the _FillValue attribute
    10321018
    1033     REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) ::  local_pf !< local
    1034        !< array to which output data is resorted to
     1019    REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) ::  local_pf !< local array to which output data is resorted to
    10351020
    10361021    REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !< points to selected output variable
    1037    
     1022
     1023
    10381024    found = .TRUE.
    10391025    resorted = .FALSE.
     
    10481034             to_be_resorted => rho_ocean
    10491035          ELSE
    1050              IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN
     1036             IF ( .NOT. ALLOCATED( rho_ocean_av ) )  THEN
    10511037                ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    10521038                rho_ocean_av = REAL( fill_value, KIND = wp )
     
    10591045             to_be_resorted => sa
    10601046          ELSE
    1061              IF ( .NOT. ALLOCATED( sa_av ) ) THEN
     1047             IF ( .NOT. ALLOCATED( sa_av ) )  THEN
    10621048                ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    10631049                sa_av = REAL( fill_value, KIND = wp )
     
    10771063          DO  j = nys, nyn
    10781064             DO  k = nzb_do, nzt_do
    1079                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
    1080                                    REAL( fill_value, KIND = wp ),              &
    1081                                    BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
     1065                local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value, KIND = wp ),     &
     1066                                         BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
    10821067             ENDDO
    10831068          ENDDO
     
    10851070       resorted = .TRUE.
    10861071    ENDIF
    1087  
     1072
    10881073 END SUBROUTINE ocean_data_output_2d
    10891074
    1090  
    1091 !------------------------------------------------------------------------------!
     1075
     1076!--------------------------------------------------------------------------------------------------!
    10921077! Description:
    10931078! ------------
    10941079!> Define 3D output variables.
    1095 !------------------------------------------------------------------------------!
     1080!--------------------------------------------------------------------------------------------------!
    10961081 SUBROUTINE ocean_data_output_3d( av, variable, found, local_pf, nzb_do, nzt_do )
    1097  
    1098 
    1099     USE arrays_3d,                                                             &
     1082
     1083
     1084    USE arrays_3d,                                                                                 &
    11001085        ONLY:  rho_ocean, sa
    11011086
    1102     USE averaging,                                                             &
     1087    USE averaging,                                                                                 &
    11031088        ONLY:  rho_ocean_av, sa_av
    11041089
    1105     USE indices,                                                               &
    1106         ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,           &
    1107                wall_flags_total_0
     1090    USE indices,                                                                                   &
     1091        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, wall_flags_total_0
    11081092
    11091093    IMPLICIT NONE
     
    11291113    REAL(wp), DIMENSION(:,:,:), POINTER ::  to_be_resorted  !< points to selected output variable
    11301114
     1115
    11311116    found = .TRUE.
    11321117    resorted = .FALSE.
     
    11411126             to_be_resorted => rho_ocean
    11421127          ELSE
    1143              IF ( .NOT. ALLOCATED( rho_ocean_av ) ) THEN
     1128             IF ( .NOT. ALLOCATED( rho_ocean_av ) )  THEN
    11441129                ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    11451130                rho_ocean_av = REAL( fill_value, KIND = wp )
     
    11521137             to_be_resorted => sa
    11531138          ELSE
    1154              IF ( .NOT. ALLOCATED( sa_av ) ) THEN
     1139             IF ( .NOT. ALLOCATED( sa_av ) )  THEN
    11551140                ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    11561141                sa_av = REAL( fill_value, KIND = wp )
     
    11691154          DO  j = nys, nyn
    11701155             DO  k = nzb_do, nzt_do
    1171                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
    1172                                    REAL( fill_value, KIND = wp ),              &
    1173                                    BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
     1156                local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value, KIND = wp ),     &
     1157                                         BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
    11741158             ENDDO
    11751159          ENDDO
     
    12061190
    12071191
    1208 !------------------------------------------------------------------------------!
     1192!--------------------------------------------------------------------------------------------------!
    12091193! Description:
    12101194! ------------
    12111195!> Header output for ocean parameters
    1212 !------------------------------------------------------------------------------!
     1196!--------------------------------------------------------------------------------------------------!
    12131197 SUBROUTINE ocean_header( io )
    12141198
    1215 
    12161199    IMPLICIT NONE
    12171200
    12181201    INTEGER(iwp), INTENT(IN) ::  io   !< Unit of the output file
     1202
    12191203
    12201204!
     
    12301214    ENDIF
    12311215
    1232 1   FORMAT (//' Ocean settings:'/                                              &
    1233               ' ------------------------------------------'/)
    1234 2   FORMAT ('    --> Craik-Leibovich vortex force and Stokes drift switched',  &
    1235                      ' on'/                                                    &
     12161   FORMAT (//' Ocean settings:'/' ------------------------------------------'/)
     12172   FORMAT ('    --> Craik-Leibovich vortex force and Stokes drift switched',' on'/                &
    12361218            '        waveheight: ',F4.1,' m   wavelength: ',F6.1,' m')
    1237 3   FORMAT ('    --> wave breaking generated turbulence switched on'/          &
    1238             '        alpha:    ',F4.1/                                         &
    1239             '        timescale:',F5.1,' s')
     12193   FORMAT ('    --> wave breaking generated turbulence switched on'/                              &
     1220            '        alpha:    ',F4.1/'        timescale:',F5.1,' s')
    124012214   FORMAT ('    --> prognostic salinity equation is switched off' )
    124112225   FORMAT ('    --> surface heat flux is switched off after ',F8.1,' s')
     
    12441225
    12451226
    1246 !------------------------------------------------------------------------------!
     1227!--------------------------------------------------------------------------------------------------!
    12471228! Description:
    12481229! ------------
    12491230!> Allocate arrays and assign pointers.
    1250 !------------------------------------------------------------------------------!
     1231!--------------------------------------------------------------------------------------------------!
    12511232 SUBROUTINE ocean_init_arrays
    12521233
    1253     USE indices,                                                               &
     1234    USE indices,                                                                                   &
    12541235        ONLY:  nxlg, nxrg, nyn, nyng, nys, nysg, nzb, nzt
    12551236
    12561237    IMPLICIT NONE
    12571238
    1258     ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                           &
    1259               rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                            &
    1260               sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                             &
     1239    ALLOCATE( prho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                               &
     1240              rho_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                &
     1241              sa_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                                                 &
    12611242              sa_3(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     1243
    12621244
    12631245    IF (  salinity )  THEN
     
    12821264
    12831265    prho => prho_1
    1284     rho_ocean  => rho_1  ! routines calc_mean_profile and diffusion_e require
    1285                          ! density to be a pointer
     1266    rho_ocean  => rho_1  ! routines calc_mean_profile and diffusion_e require density to be a pointer
    12861267
    12871268!
     
    12961277
    12971278
    1298 !------------------------------------------------------------------------------!
     1279!--------------------------------------------------------------------------------------------------!
    12991280! Description:
    13001281! ------------
    13011282!> Initialization of quantities needed for the ocean mode
    1302 !------------------------------------------------------------------------------!
     1283!--------------------------------------------------------------------------------------------------!
    13031284 SUBROUTINE ocean_init
    13041285
    13051286
    1306     USE arrays_3d,                                                             &
    1307         ONLY:  dzu, dzw, hyp, pt_init, ref_state, u_stokes_zu, u_stokes_zw,    &
    1308                v_stokes_zu, v_stokes_zw, zu, zw
    1309 
    1310     USE basic_constants_and_equations_mod,                                     &
     1287    USE arrays_3d,                                                                                 &
     1288        ONLY:  dzu, dzw, hyp, pt_init, ref_state, u_stokes_zu, u_stokes_zw, v_stokes_zu,           &
     1289               v_stokes_zw, zu, zw
     1290
     1291    USE basic_constants_and_equations_mod,                                                         &
    13111292        ONLY:  g
    13121293
    1313     USE basic_constants_and_equations_mod,                                     &
     1294    USE basic_constants_and_equations_mod,                                                         &
    13141295        ONLY:  pi
    13151296
    1316     USE control_parameters,                                                    &
    1317         ONLY:  initializing_actions, molecular_viscosity, rho_surface,         &
    1318                rho_reference, surface_pressure, top_momentumflux_u,            &
    1319                top_momentumflux_v, use_single_reference_value
    1320 
    1321     USE indices,                                                               &
     1297    USE control_parameters,                                                                        &
     1298        ONLY:  initializing_actions, molecular_viscosity, rho_surface, rho_reference,              &
     1299               surface_pressure, top_momentumflux_u, top_momentumflux_v, use_single_reference_value
     1300
     1301    USE indices,                                                                                   &
    13221302        ONLY:  nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt
    13231303
    13241304    USE kinds
    13251305
    1326     USE pegrid,                                                                &
     1306    USE pegrid,                                                                                    &
    13271307        ONLY:  myid
    13281308
    1329     USE statistics,                                                            &
     1309    USE statistics,                                                                                &
    13301310        ONLY:  hom, statistic_regions
    13311311
     
    13371317    INTEGER(iwp) ::  n  !< loop index
    13381318
    1339     REAL(wp) ::  alpha !< angle of surface stress
    1340     REAL(wp) ::  dum   !< dummy argument
    1341     REAL(wp) ::  pt_l  !< local scalar for pt used in equation of state function
    1342     REAL(wp) ::  sa_l  !< local scalar for sa used in equation of state function
     1319    REAL(wp) ::  alpha               !< angle of surface stress
     1320    REAL(wp) ::  dum                 !< dummy argument
     1321    REAL(wp) ::  pt_l                !< local scalar for pt used in equation of state function
     1322    REAL(wp) ::  sa_l                !< local scalar for sa used in equation of state function
    13431323    REAL(wp) ::  velocity_amplitude  !< local scalar for amplitude of Stokes drift velocity
    1344     REAL(wp) ::  x     !< temporary variable to store surface stress along x
    1345     REAL(wp) ::  y     !< temporary variable to store surface stress along y
     1324    REAL(wp) ::  x                   !< temporary variable to store surface stress along x
     1325    REAL(wp) ::  y                   !< temporary variable to store surface stress along y
    13461326
    13471327    REAL(wp), DIMENSION(nzb:nzt+1) ::  rho_ocean_init  !< local array for initial density
     
    13511331
    13521332!
    1353 !-- In case of no restart run, calculate the inital salinity profilevcusing the
    1354 !-- given salinity gradients
     1333!-- In case of no restart run, calculate the inital salinity profile using the given salinity
     1334!-- gradients.
    13551335    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
    13561336
    13571337       sa_init = sa_surface
    13581338!
    1359 !--    Last arguments gives back the gradient at top level to be used as
    1360 !--    possible Neumann boundary condition. This is not realized for the ocean
    1361 !--    mode, therefore a dummy argument is used.
     1339!--    Last arguments gives back the gradient at top level to be used as possible Neumann boundary
     1340!--    condition. This is not realized for the ocean mode, therefore a dummy argument is used.
    13621341       IF ( salinity )  THEN
    1363           CALL init_vertical_profiles( sa_vertical_gradient_level_ind,          &
    1364                                        sa_vertical_gradient_level,              &
    1365                                        sa_vertical_gradient, sa_init,           &
     1342          CALL init_vertical_profiles( sa_vertical_gradient_level_ind,                             &
     1343                                       sa_vertical_gradient_level,                                 &
     1344                                       sa_vertical_gradient, sa_init,                              &
    13661345                                       sa_surface, dum )
    13671346       ENDIF
     
    13701349!
    13711350!-- Initialize required 3d-arrays
    1372     IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.            &
     1351    IF ( TRIM( initializing_actions ) /= 'read_restart_data'  .AND.                                &
    13731352         TRIM( initializing_actions ) /= 'cyclic_fill' )  THEN
    13741353!
     
    13951374
    13961375!
    1397 !--    Initialize new time levels (only done in order to set boundary values
    1398 !--    including ghost points)
     1376!--    Initialize new time levels (only done in order to set boundary values including ghost points)
    13991377       sa_p = sa
    14001378!
    1401 !--    Allthough tendency arrays are set in prognostic_equations, they have
    1402 !--    have to be predefined here because they are used (but multiplied with 0)
    1403 !--    there before they are set.
     1379!--    Allthough tendency arrays are set in prognostic_equations, they have to be predefined here
     1380!--    because they are used (but multiplied with 0) there before they are set.
    14041381       tsa_m = 0.0_wp
    14051382
     
    14161393
    14171394!
    1418 !-- Change sign of buoyancy/stability terms because density gradient is used
    1419 !-- instead of the potential temperature gradient to calculate the buoyancy
     1395!-- Change sign of buoyancy/stability terms because density gradient is used instead of the
     1396!-- potential temperature gradient to calculate the buoyancy.
    14201397    atmos_ocean_sign = -1.0_wp
    14211398
    14221399!
    1423 !-- Calculate initial vertical profile of hydrostatic pressure (in Pa)
    1424 !-- and the reference density (used later in buoyancy term)
    1425 !-- First step: Calculate pressure using reference density
     1400!-- Calculate initial vertical profile of hydrostatic pressure (in Pa) and the reference density
     1401!-- (used later in buoyancy term).
     1402!-- First step: Calculate pressure using reference density.
    14261403    hyp(nzt+1) = surface_pressure * 100.0_wp
    14271404    hyp(nzt)   = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1)
     
    14351412
    14361413!
    1437 !-- Second step: Iteratively calculate in situ density (based on presssure)
    1438 !-- and pressure (based on in situ density)
     1414!-- Second step: Iteratively calculate in situ density (based on presssure) and pressure
     1415!-- (based on in situ density)
    14391416    DO  n = 1, 5
    14401417
     
    14561433       hyp(nzt) = hyp(nzt+1) + rho_surface * g * 0.5_wp * dzu(nzt+1)
    14571434       DO  k = nzt-1, 0, -1
    1458           hyp(k) = hyp(k+1) + g * 0.5_wp * ( rho_ocean_init(k)                 &
    1459                                            + rho_ocean_init(k+1) ) * dzu(k+1)
     1435          hyp(k) = hyp(k+1) + g * 0.5_wp * ( rho_ocean_init(k) + rho_ocean_init(k+1) ) * dzu(k+1)
    14601436       ENDDO
    14611437
     
    14701446       pt_l = 0.5_wp * ( pt_init(k) + pt_init(k+1) )
    14711447
    1472        prho_reference = prho_reference + dzu(k+1) * &
    1473                         eqn_state_seawater_func( 0.0_wp, pt_l, sa_l )
     1448       prho_reference = prho_reference + dzu(k+1) * eqn_state_seawater_func( 0.0_wp, pt_l, sa_l )
    14741449
    14751450    ENDDO
     
    14781453
    14791454!
    1480 !-- Calculate the 3d array of initial in situ and potential density,
    1481 !-- based on the initial temperature and salinity profile
     1455!-- Calculate the 3d array of initial in situ and potential density, based on the initial
     1456!-- temperature and salinity profile.
    14821457    CALL eqn_state_seawater
    14831458
     
    15201495       ENDIF
    15211496
    1522        velocity_amplitude = ( pi * stokes_waveheight / stokes_wavelength )**2 *&
     1497       velocity_amplitude = ( pi * stokes_waveheight / stokes_wavelength )**2 *                    &
    15231498                            SQRT( g * stokes_wavelength / ( 2.0_wp * pi ) )
    15241499
    15251500       DO  k = nzb, nzt
    1526           u_stokes_zu(k) = velocity_amplitude * COS( alpha ) *                 &
     1501          u_stokes_zu(k) = velocity_amplitude * COS( alpha ) *                                     &
    15271502                           EXP( 4.0_wp * pi * zu(k) / stokes_wavelength )
    1528           u_stokes_zw(k) = velocity_amplitude * COS( alpha ) *                 &
     1503          u_stokes_zw(k) = velocity_amplitude * COS( alpha ) *                                     &
    15291504                           EXP( 4.0_wp * pi * zw(k) / stokes_wavelength )
    1530           v_stokes_zu(k) = velocity_amplitude * SIN( alpha ) *                 &
     1505          v_stokes_zu(k) = velocity_amplitude * SIN( alpha ) *                                     &
    15311506                           EXP( 4.0_wp * pi * zu(k) / stokes_wavelength )
    15321507          v_stokes_zw(k) = velocity_amplitude * SIN( alpha ) *                 &
     
    15451520!
    15461521!--    Calculate friction velocity at ocean surface
    1547        u_star_wave_breaking = SQRT( SQRT( top_momentumflux_u**2 +              &
    1548                                           top_momentumflux_v**2 ) )
    1549 !
    1550 !--    Set the time scale of random forcing. The vertical grid spacing at the
    1551 !--    ocean surface is assumed as the length scale of turbulence.
     1522       u_star_wave_breaking = SQRT( SQRT( top_momentumflux_u**2 + top_momentumflux_v**2 ) )
     1523!
     1524!--    Set the time scale of random forcing. The vertical grid spacing at the ocean surface is
     1525!--    assumed as the length scale of turbulence.
    15521526!--    Formula follows Noh et al. (2004), JPO
    1553        timescale_wave_breaking = 0.1_wp * dzw(nzt) / alpha_wave_breaking /     &
    1554                                  u_star_wave_breaking
    1555 !
    1556 !--    Set random number seeds differently on the processor cores in order to
    1557 !--    create different random number sequences
     1527       timescale_wave_breaking = 0.1_wp * dzw(nzt) / alpha_wave_breaking / u_star_wave_breaking
     1528!
     1529!--    Set random number seeds differently on the processor cores in order to create different
     1530!--    random number sequences
    15581531       iran_ocean = iran_ocean + myid
    15591532    ENDIF
     
    15621535
    15631536
    1564 !------------------------------------------------------------------------------!
     1537!--------------------------------------------------------------------------------------------------!
    15651538! Description:
    15661539! ------------
    15671540!> Call for all grid points
    1568 !------------------------------------------------------------------------------!
     1541!--------------------------------------------------------------------------------------------------!
    15691542 SUBROUTINE ocean_actions( location )
    15701543
     
    15881561
    15891562
    1590 !------------------------------------------------------------------------------!
     1563!--------------------------------------------------------------------------------------------------!
    15911564! Description:
    15921565! ------------
    15931566!> Call for grid points i,j
    1594 !------------------------------------------------------------------------------!
     1567!--------------------------------------------------------------------------------------------------!
    15951568 SUBROUTINE ocean_actions_ij( i, j, location )
    15961569
    1597 
    1598     INTEGER(iwp),      INTENT(IN) ::  i         !< grid index in x-direction
    1599     INTEGER(iwp),      INTENT(IN) ::  j         !< grid index in y-direction
    16001570    CHARACTER (LEN=*), INTENT(IN) ::  location  !< call location string
    1601     INTEGER(iwp)  ::  dummy  !< call location string
     1571
     1572    INTEGER(iwp)             ::  dummy     !< call location string
     1573    INTEGER(iwp), INTENT(IN) ::  i         !< grid index in x-direction
     1574    INTEGER(iwp), INTENT(IN) ::  j         !< grid index in y-direction
     1575
    16021576
    16031577    IF ( ocean_mode )   dummy = i + j
     
    16191593
    16201594
    1621 !------------------------------------------------------------------------------!
     1595!--------------------------------------------------------------------------------------------------!
    16221596! Description:
    16231597! ------------
    16241598!> Prognostic equation for salinity.
    16251599!> Vector-optimized version
    1626 !------------------------------------------------------------------------------!
     1600!--------------------------------------------------------------------------------------------------!
    16271601 SUBROUTINE ocean_prognostic_equations
    16281602
    1629     USE advec_s_bc_mod,                                                        &
     1603    USE advec_s_bc_mod,                                                                            &
    16301604        ONLY:  advec_s_bc
    16311605
    1632     USE advec_s_pw_mod,                                                        &
     1606    USE advec_s_pw_mod,                                                                            &
    16331607        ONLY:  advec_s_pw
    16341608
    1635     USE advec_s_up_mod,                                                        &
     1609    USE advec_s_up_mod,                                                                            &
    16361610        ONLY:  advec_s_up
    16371611
    1638     USE advec_ws,                                                              &
     1612    USE advec_ws,                                                                                  &
    16391613        ONLY:  advec_s_ws
    16401614
    1641     USE arrays_3d,                                                             &
     1615    USE arrays_3d,                                                                                 &
    16421616        ONLY:  rdf_sc, tend, tsa_m
    16431617
    1644     USE control_parameters,                                                    &
    1645         ONLY:  bc_dirichlet_l,                                                 &
    1646                bc_dirichlet_n,                                                 &
    1647                bc_dirichlet_r,                                                 &
    1648                bc_dirichlet_s,                                                 &
    1649                bc_radiation_l,                                                 &
    1650                bc_radiation_n,                                                 &
    1651                bc_radiation_r,                                                 &
    1652                bc_radiation_s,                                                 &
    1653                dt_3d, intermediate_timestep_count,                             &
    1654                intermediate_timestep_count_max, scalar_advec, simulated_time,  &
    1655                timestep_scheme, tsc, ws_scheme_sca
    1656 
    1657     USE cpulog,                                                                &
     1618    USE control_parameters,                                                                        &
     1619        ONLY:  bc_dirichlet_l,                                                                     &
     1620               bc_dirichlet_n,                                                                     &
     1621               bc_dirichlet_r,                                                                     &
     1622               bc_dirichlet_s,                                                                     &
     1623               bc_radiation_l,                                                                     &
     1624               bc_radiation_n,                                                                     &
     1625               bc_radiation_r,                                                                     &
     1626               bc_radiation_s,                                                                     &
     1627               dt_3d,                                                                              &
     1628               intermediate_timestep_count,                                                        &
     1629               intermediate_timestep_count_max,                                                    &
     1630               scalar_advec,                                                                       &
     1631               simulated_time,                                                                     &
     1632               timestep_scheme,                                                                    &
     1633               tsc,                                                                                &
     1634               ws_scheme_sca
     1635
     1636    USE cpulog,                                                                                    &
    16581637        ONLY:  cpu_log, log_point_s
    16591638
    1660     USE diffusion_s_mod,                                                       &
     1639    USE diffusion_s_mod,                                                                           &
    16611640        ONLY:  diffusion_s
    16621641
     
    16691648    REAL(wp)     ::  sbt     !< weighting factor for sub-time step
    16701649
     1650
    16711651!
    16721652!-- Switch of the surface heat flux, if requested
    16731653    IF ( surface_cooling_spinup_time /= 999999.9_wp )  THEN
    1674        IF ( .NOT. surface_cooling_switched_off  .AND.                          &
     1654       IF ( .NOT. surface_cooling_switched_off  .AND.                                              &
    16751655            simulated_time >= surface_cooling_spinup_time )  THEN
    16761656
     
    16821662
    16831663!
    1684 !-- Compute prognostic equations for the ocean mode
    1685 !-- First, start with salinity
     1664!-- Compute prognostic equations for the ocean mode.
     1665!-- First, start with salinity.
    16861666    IF ( salinity )  THEN
    16871667
     
    17091689          IF ( timestep_scheme(1:5) == 'runge' )  THEN
    17101690             IF ( ws_scheme_sca )  THEN
    1711                 CALL advec_s_ws( advc_flags_s, sa, 'sa',                       &
    1712                                  bc_dirichlet_l  .OR.  bc_radiation_l,         &
    1713                                  bc_dirichlet_n  .OR.  bc_radiation_n,         &
    1714                                  bc_dirichlet_r  .OR.  bc_radiation_r,         &
     1691                CALL advec_s_ws( advc_flags_s, sa, 'sa',                                           &
     1692                                 bc_dirichlet_l  .OR.  bc_radiation_l,                             &
     1693                                 bc_dirichlet_n  .OR.  bc_radiation_n,                             &
     1694                                 bc_dirichlet_r  .OR.  bc_radiation_r,                             &
    17151695                                 bc_dirichlet_s  .OR.  bc_radiation_s )
    17161696             ELSE
     
    17221702       ENDIF
    17231703
    1724        CALL diffusion_s( sa,                                                   &
    1725                          surf_def_h(0)%sasws, surf_def_h(1)%sasws,             &
    1726                          surf_def_h(2)%sasws,                                  &
    1727                          surf_lsm_h(0)%sasws, surf_lsm_h(1)%sasws,             &
    1728                          surf_usm_h(0)%sasws, surf_usm_h(1)%sasws,             &
    1729                          surf_def_v(0)%sasws, surf_def_v(1)%sasws,             &
    1730                          surf_def_v(2)%sasws, surf_def_v(3)%sasws,             &
    1731                          surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,             &
    1732                          surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,             &
    1733                          surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,             &
     1704       CALL diffusion_s( sa,                                                                       &
     1705                         surf_def_h(0)%sasws, surf_def_h(1)%sasws,                                 &
     1706                         surf_def_h(2)%sasws,                                                      &
     1707                         surf_lsm_h(0)%sasws, surf_lsm_h(1)%sasws,                                 &
     1708                         surf_usm_h(0)%sasws, surf_usm_h(1)%sasws,                                 &
     1709                         surf_def_v(0)%sasws, surf_def_v(1)%sasws,                                 &
     1710                         surf_def_v(2)%sasws, surf_def_v(3)%sasws,                                 &
     1711                         surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,                                 &
     1712                         surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,                                 &
     1713                         surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,                                 &
    17341714                         surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
    17351715
     
    17431723             !DIR$ IVDEP
    17441724             DO  k = nzb+1, nzt
    1745                 sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +            &
    1746                                                       tsc(3) * tsa_m(k,j,i) )        &
    1747                                                   - tsc(5) * rdf_sc(k) *             &
    1748                                                     ( sa(k,j,i) - sa_init(k) )       &
    1749                                           )                                          &
    1750                                             * MERGE( 1.0_wp, 0.0_wp,                 &
    1751                                                BTEST( wall_flags_total_0(k,j,i), 0 ) &
     1725                sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) + tsc(3) * tsa_m(k,j,i) )  &
     1726                                            - tsc(5) * rdf_sc(k) * ( sa(k,j,i) - sa_init(k) )      &
     1727                                          )                                                        &
     1728                                            * MERGE( 1.0_wp, 0.0_wp,                               &
     1729                                                     BTEST( wall_flags_total_0(k,j,i), 0 )         &
    17521730                                                   )
    17531731                IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
     
    17671745                ENDDO
    17681746             ENDDO
    1769           ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) &
    1770           THEN
     1747          ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max )  THEN
    17711748             DO  i = nxl, nxr
    17721749                DO  j = nys, nyn
    17731750                   DO  k = nzb+1, nzt
    1774                       tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +              &
    1775                                         5.3125_wp * tsa_m(k,j,i)
     1751                      tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) + 5.3125_wp * tsa_m(k,j,i)
    17761752                   ENDDO
    17771753                ENDDO
     
    17931769
    17941770
    1795 !------------------------------------------------------------------------------!
     1771!--------------------------------------------------------------------------------------------------!
    17961772! Description:
    17971773! ------------
    17981774!> Prognostic equations for ocean mode (so far, salinity only)
    17991775!> Cache-optimized version
    1800 !------------------------------------------------------------------------------!
     1776!--------------------------------------------------------------------------------------------------!
    18011777 SUBROUTINE ocean_prognostic_equations_ij( i, j, i_omp_start, tn )
    18021778
    1803     USE advec_s_pw_mod,                                                        &
     1779    USE advec_s_pw_mod,                                                                            &
    18041780        ONLY:  advec_s_pw
    18051781
    1806     USE advec_s_up_mod,                                                        &
     1782    USE advec_s_up_mod,                                                                            &
    18071783        ONLY:  advec_s_up
    18081784
    1809     USE advec_ws,                                                              &
     1785    USE advec_ws,                                                                                  &
    18101786        ONLY:  advec_s_ws
    18111787
    1812     USE arrays_3d,                                                             &
     1788    USE arrays_3d,                                                                                 &
    18131789        ONLY:  diss_l_sa, diss_s_sa, flux_l_sa, flux_s_sa, rdf_sc, tend, tsa_m
    18141790
    1815     USE control_parameters,                                                    &
    1816         ONLY:  bc_dirichlet_l,                                                 &
    1817                bc_dirichlet_n,                                                 &
    1818                bc_dirichlet_r,                                                 &
    1819                bc_dirichlet_s,                                                 &
    1820                bc_radiation_l,                                                 &
    1821                bc_radiation_n,                                                 &
    1822                bc_radiation_r,                                                 &
    1823                bc_radiation_s,                                                 &
    1824                dt_3d, intermediate_timestep_count,                             &
    1825                intermediate_timestep_count_max, simulated_time,                &
    1826                timestep_scheme, tsc, ws_scheme_sca
    1827 
    1828     USE diffusion_s_mod,                                                       &
     1791    USE control_parameters,                                                                        &
     1792        ONLY:  bc_dirichlet_l,                                                                     &
     1793               bc_dirichlet_n,                                                                     &
     1794               bc_dirichlet_r,                                                                     &
     1795               bc_dirichlet_s,                                                                     &
     1796               bc_radiation_l,                                                                     &
     1797               bc_radiation_n,                                                                     &
     1798               bc_radiation_r,                                                                     &
     1799               bc_radiation_s,                                                                     &
     1800               dt_3d,                                                                              &
     1801               intermediate_timestep_count,                                                        &
     1802               intermediate_timestep_count_max,                                                    &
     1803               simulated_time,                                                                     &
     1804               timestep_scheme,                                                                    &
     1805               tsc,                                                                                &
     1806               ws_scheme_sca
     1807
     1808    USE diffusion_s_mod,                                                                           &
    18291809        ONLY:  diffusion_s
    18301810
     
    18321812
    18331813    INTEGER(iwp) ::  i             !< loop index x direction
    1834     INTEGER(iwp) ::  i_omp_start   !< first loop index of i-loop in calling    &
    1835                                    !< routine prognostic_equations
     1814    INTEGER(iwp) ::  i_omp_start   !< first loop index of i-loop in calling routine prognostic_equations
    18361815    INTEGER(iwp) ::  j             !< loop index y direction
    18371816    INTEGER(iwp) ::  k             !< loop index z direction
     
    18421821!-- Switch of the surface heat flux, if requested
    18431822    IF ( surface_cooling_spinup_time /= 999999.9_wp )  THEN
    1844        IF ( .NOT. surface_cooling_switched_off  .AND.                          &
     1823       IF ( .NOT. surface_cooling_switched_off  .AND.                                              &
    18451824            simulated_time >= surface_cooling_spinup_time )  THEN
    18461825
     
    18521831
    18531832!
    1854 !-- Compute prognostic equations for the ocean mode
    1855 !-- First, start with tendency-terms for salinity
     1833!-- Compute prognostic equations for the ocean mode.
     1834!-- First, start with tendency-terms for salinity.
    18561835    IF ( salinity )  THEN
    18571836
    18581837       tend(:,j,i) = 0.0_wp
    1859        IF ( timestep_scheme(1:5) == 'runge' ) &
    1860        THEN
     1838       IF ( timestep_scheme(1:5) == 'runge' )  THEN
    18611839          IF ( ws_scheme_sca )  THEN
    1862              CALL advec_s_ws( advc_flags_s,                                    &
    1863                               i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa,&
    1864                               diss_l_sa, i_omp_start, tn,                      &
    1865                               bc_dirichlet_l  .OR.  bc_radiation_l,            &
    1866                               bc_dirichlet_n  .OR.  bc_radiation_n,            &
    1867                               bc_dirichlet_r  .OR.  bc_radiation_r,            &
     1840             CALL advec_s_ws( advc_flags_s,                                                        &
     1841                              i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa, diss_l_sa,         &
     1842                              i_omp_start, tn,                                                     &
     1843                              bc_dirichlet_l  .OR.  bc_radiation_l,                                &
     1844                              bc_dirichlet_n  .OR.  bc_radiation_n,                                &
     1845                              bc_dirichlet_r  .OR.  bc_radiation_r,                                &
    18681846                              bc_dirichlet_s  .OR.  bc_radiation_s )
    18691847          ELSE
     
    18731851          CALL advec_s_up( i, j, sa )
    18741852       ENDIF
    1875        CALL diffusion_s( i, j, sa,                                             &
    1876                          surf_def_h(0)%sasws, surf_def_h(1)%sasws,             &
    1877                          surf_def_h(2)%sasws,                                  &
    1878                          surf_lsm_h(0)%sasws, surf_lsm_h(1)%sasws,             &
    1879                          surf_usm_h(0)%sasws, surf_usm_h(1)%sasws,             &
    1880                          surf_def_v(0)%sasws, surf_def_v(1)%sasws,             &
    1881                          surf_def_v(2)%sasws, surf_def_v(3)%sasws,             &
    1882                          surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws,             &
    1883                          surf_lsm_v(2)%sasws, surf_lsm_v(3)%sasws,             &
    1884                          surf_usm_v(0)%sasws, surf_usm_v(1)%sasws,             &
    1885                          surf_usm_v(2)%sasws, surf_usm_v(3)%sasws )
     1853       CALL diffusion_s( i, j, sa,                                                                 &
     1854                         surf_def_h(0)%sasws, surf_def_h(1)%sasws, surf_def_h(2)%sasws,            &
     1855                         surf_lsm_h(0)%sasws, surf_lsm_h(1)%sasws,                                 &
     1856                         surf_usm_h(0)%sasws, surf_usm_h(1)%sasws,                                 &
     1857                         surf_def_v(0)%sasws, surf_def_v(1)%sasws, surf_def_v(2)%sasws,            &
     1858                         surf_def_v(3)%sasws,             &
     1859                         surf_lsm_v(0)%sasws, surf_lsm_v(1)%sasws, surf_lsm_v(2)%sasws,            &
     1860                         surf_lsm_v(3)%sasws,             &
     1861                         surf_usm_v(0)%sasws, surf_usm_v(1)%sasws, surf_usm_v(2)%sasws,            &
     1862                         surf_usm_v(3)%sasws )
    18861863
    18871864!       CALL user_actions( i, j, 'sa-tendency' ) ToDo: find general solution for dependency between modules
     
    18911868       DO  k = nzb+1, nzt
    18921869
    1893           sa_p(k,j,i) = sa(k,j,i) + ( dt_3d *                                  &
    1894                                               ( tsc(2) * tend(k,j,i) +         &
    1895                                                 tsc(3) * tsa_m(k,j,i) )        &
    1896                                     - tsc(5) * rdf_sc(k)                       &
    1897                                              * ( sa(k,j,i) - sa_init(k) )      &
    1898                                     ) * MERGE( 1.0_wp, 0.0_wp,                 &
    1899                                          BTEST( wall_flags_total_0(k,j,i), 0 ) )
     1870          sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * tsa_m(k,j,i) )     &
     1871                                    - tsc(5) * rdf_sc(k) * ( sa(k,j,i) - sa_init(k) )              &
     1872                                    ) * MERGE( 1.0_wp, 0.0_wp,                                     &
     1873                                               BTEST( wall_flags_total_0(k,j,i), 0 )               &
     1874                                             )
    19001875
    19011876          IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
     
    19101885                tsa_m(k,j,i) = tend(k,j,i)
    19111886             ENDDO
    1912           ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max ) &
    1913           THEN
     1887          ELSEIF ( intermediate_timestep_count < intermediate_timestep_count_max )  THEN
    19141888             DO  k = nzb+1, nzt
    1915                 tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) +                    &
    1916                                   5.3125_wp * tsa_m(k,j,i)
     1889                tsa_m(k,j,i) =   -9.5625_wp * tend(k,j,i) + 5.3125_wp * tsa_m(k,j,i)
    19171890             ENDDO
    19181891          ENDIF
     
    19271900 END SUBROUTINE ocean_prognostic_equations_ij
    19281901
    1929 !------------------------------------------------------------------------------!
     1902!--------------------------------------------------------------------------------------------------!
    19301903! Description:
    19311904! ------------
    19321905!> Boundary conditions for ocean model
    1933 !------------------------------------------------------------------------------!
     1906!--------------------------------------------------------------------------------------------------!
    19341907 SUBROUTINE ocean_boundary_conditions
    19351908
     
    19431916
    19441917!
    1945 !--    Boundary conditions for salinity
    1946 !--    Bottom boundary: Neumann condition because salinity flux is always
    1947 !--    given.
     1918!--    Boundary conditions for salinity.
     1919!--    Bottom boundary: Neumann condition because salinity flux is always given.
    19481920       DO  l = 0, 1
    19491921          !$OMP PARALLEL DO PRIVATE( i, j, k )
     
    19651937 END SUBROUTINE ocean_boundary_conditions
    19661938
    1967 !------------------------------------------------------------------------------!
     1939!--------------------------------------------------------------------------------------------------!
    19681940! Description:
    19691941! ------------
    19701942!> Swapping of timelevels.
    1971 !------------------------------------------------------------------------------!
     1943!--------------------------------------------------------------------------------------------------!
    19721944 SUBROUTINE ocean_swap_timelevel( mod_count )
    19731945
     
    19941966
    19951967
    1996 !------------------------------------------------------------------------------!
     1968!--------------------------------------------------------------------------------------------------!
    19971969! Description:
    19981970! ------------
    19991971!> Read module-specific global restart data (Fortran binary format).
    2000 !------------------------------------------------------------------------------!
     1972!--------------------------------------------------------------------------------------------------!
    20011973 SUBROUTINE ocean_rrd_global_ftn( found )
    20021974
    20031975
    2004     USE control_parameters,                                                    &
     1976    USE control_parameters,                                                                        &
    20051977        ONLY: length, restart_string
    20061978
     
    20632035
    20642036
    2065 !------------------------------------------------------------------------------!
     2037!--------------------------------------------------------------------------------------------------!
    20662038! Description:
    20672039! ------------
    20682040!> Read module-specific global restart data (MPI-IO).
    2069 !------------------------------------------------------------------------------!
     2041!--------------------------------------------------------------------------------------------------!
    20702042 SUBROUTINE ocean_rrd_global_mpi
    20712043
     
    20882060
    20892061
    2090 !------------------------------------------------------------------------------!
     2062!--------------------------------------------------------------------------------------------------!
    20912063! Description:
    20922064! ------------
    20932065!> Read module-specific local restart data arrays (Fortran binary format).
    2094 !------------------------------------------------------------------------------!
    2095  SUBROUTINE ocean_rrd_local_ftn( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc,           &
    2096                                  nxr_on_file, nynf, nync, nyn_on_file, nysf,       &
    2097                                  nysc, nys_on_file, tmp_3d, found )
    2098 
    2099     USE averaging,                                                             &
     2066!--------------------------------------------------------------------------------------------------!
     2067 SUBROUTINE ocean_rrd_local_ftn( k, nxlf, nxlc, nxl_on_file, nxrf, nxrc, nxr_on_file, nynf, nync,  &
     2068                                 nyn_on_file, nysf, nysc, nys_on_file, tmp_3d, found )
     2069
     2070    USE averaging,                                                                                 &
    21002071        ONLY:  rho_ocean_av, sa_av
    21012072
    2102     USE control_parameters,                                                    &
     2073    USE control_parameters,                                                                        &
    21032074        ONLY:  length, restart_string
    21042075
    2105     USE indices,                                                               &
     2076    USE indices,                                                                                   &
    21062077        ONLY:  nbgp, nxlg, nxrg, nyng, nysg, nzb, nzt
    21072078
     
    21272098    LOGICAL, INTENT(OUT)  ::  found
    21282099
    2129     REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp) :: tmp_3d   !<
     2100    REAL(wp),                                                                                      &
     2101       DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp)    &
     2102       :: tmp_3d   !<
    21302103
    21312104
     
    21392112          ENDIF
    21402113          IF ( k == 1 )  READ ( 13 )  tmp_3d
    2141           rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =            &
    2142                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     2114          rho_ocean_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                &
     2115                                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    21432116
    21442117       CASE ( 'sa' )
    21452118          IF ( k == 1 )  READ ( 13 )  tmp_3d
    2146           sa(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                      &
    2147                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     2119          sa(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                          &
     2120                                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    21482121
    21492122       CASE ( 'sa_av' )
     
    21522125          ENDIF
    21532126          IF ( k == 1 )  READ ( 13 )  tmp_3d
    2154           sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                   &
    2155                               tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
     2127          sa_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                                       &
     2128                                                   tmp_3d(:,nysf-nbgp:nynf+nbgp,nxlf-nbgp:nxrf+nbgp)
    21562129
    21572130       CASE DEFAULT
     
    21632136
    21642137
    2165 !------------------------------------------------------------------------------!
     2138!--------------------------------------------------------------------------------------------------!
    21662139! Description:
    21672140! ------------
    21682141!> Read module-specific local restart data arrays (MPI-IO).
    2169 !------------------------------------------------------------------------------!
     2142!--------------------------------------------------------------------------------------------------!
    21702143 SUBROUTINE ocean_rrd_local_mpi
    21712144
    2172     USE averaging,                                                             &
     2145    USE averaging,                                                                                 &
    21732146        ONLY:  rho_ocean_av, sa_av
    21742147
    2175     USE indices,                                                               &
     2148    USE indices,                                                                                   &
    21762149        ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt
    21772150
     
    21832156    CALL rd_mpi_io_check_array( 'rho_ocean_av' , found = array_found )
    21842157    IF ( array_found )  THEN
    2185        IF ( .NOT. ALLOCATED( rho_ocean_av ) )  ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
     2158       IF ( .NOT. ALLOCATED( rho_ocean_av ) )                                                      &
     2159          ALLOCATE( rho_ocean_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
    21862160       CALL rrd_mpi_io( 'rho_ocean_av', rho_ocean_av )
    21872161    ENDIF
     
    21982172
    21992173
    2200 !------------------------------------------------------------------------------!
     2174!--------------------------------------------------------------------------------------------------!
    22012175! Description:
    22022176! ------------
    22032177!> This routine writes the respective restart data for the ocean module.
    2204 !------------------------------------------------------------------------------!
     2178!--------------------------------------------------------------------------------------------------!
    22052179 SUBROUTINE ocean_wrd_global
    22062180
     
    22582232       CALL wrd_mpi_io_global_array( 'sa_vertical_gradient', sa_vertical_gradient )
    22592233       CALL wrd_mpi_io_global_array( 'sa_vertical_gradient_level', sa_vertical_gradient_level )
    2260        CALL wrd_mpi_io_global_array( 'sa_vertical_gradient_level_ind', sa_vertical_gradient_level_ind )
     2234       CALL wrd_mpi_io_global_array( 'sa_vertical_gradient_level_ind',                             &
     2235                                     sa_vertical_gradient_level_ind )
    22612236       CALL wrd_mpi_io( 'stokes_waveheight', stokes_waveheight )
    22622237       CALL wrd_mpi_io( 'stokes_wavelength', stokes_wavelength )
     
    22712246
    22722247
    2273 !------------------------------------------------------------------------------!
     2248!--------------------------------------------------------------------------------------------------!
    22742249! Description:
    22752250! ------------
    22762251!> This routine writes the respective restart data for the ocean module.
    2277 !------------------------------------------------------------------------------!
     2252!--------------------------------------------------------------------------------------------------!
    22782253 SUBROUTINE ocean_wrd_local
    22792254
    2280     USE averaging,                                                             &
     2255    USE averaging,                                                                                 &
    22812256        ONLY:  rho_ocean_av, sa_av
    22822257
     
    23102285
    23112286
    2312 !------------------------------------------------------------------------------!
    2313 ! Description:
    2314 ! ------------
    2315 !> This routine calculates the Craik Leibovich vortex force and the additional
    2316 !> effect of the Stokes drift on the Coriolis force
     2287!--------------------------------------------------------------------------------------------------!
     2288! Description:
     2289! ------------
     2290!> This routine calculates the Craik Leibovich vortex force and the additional effect of the Stokes
     2291!> drift on the Coriolis force.
    23172292!> Call for all gridpoints.
    2318 !------------------------------------------------------------------------------!
     2293!--------------------------------------------------------------------------------------------------!
    23192294 SUBROUTINE stokes_drift_terms( component )
    23202295
    2321     USE arrays_3d,                                                             &
    2322         ONLY:  ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu,              &
    2323                v_stokes_zw, w, tend
    2324 
    2325     USE basic_constants_and_equations_mod,                                     &
     2296    USE arrays_3d,                                                                                 &
     2297        ONLY:  ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu, v_stokes_zw, w, tend
     2298
     2299    USE basic_constants_and_equations_mod,                                                         &
    23262300        ONLY:  pi
    23272301
    2328     USE control_parameters,                                                    &
     2302    USE control_parameters,                                                                        &
    23292303        ONLY:  f, fs, message_string, rotation_angle
    23302304
    2331     USE grid_variables,                                                        &
     2305    USE grid_variables,                                                                            &
    23322306        ONLY:  ddx, ddy
    23332307
    2334     USE indices,                                                               &
     2308    USE indices,                                                                                   &
    23352309        ONLY:  nxl, nxr, nys, nysv, nyn, nzb, nzt
    23362310
     
    23442318    REAL(wp)     ::  cos_rot_angle  !< cosine of model rotation angle
    23452319    REAL(wp)     ::  sin_rot_angle  !< sine of model rotation angle
     2320
    23462321
    23472322!
     
    23552330             DO  j = nysv, nyn
    23562331                DO  k = nzb+1, nzt
    2357                    tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * (              &
    2358                                    0.5 * ( v(k,j+1,i) - v(k,j+1,i-1)           &
    2359                                          + v(k,j,i)   - v(k,j,i-1)   ) * ddx   &
    2360                                  - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) )   * ddy   &
    2361                                                                 )              &
     2332                   tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * (                                  &
     2333                                                  0.5 * ( v(k,j+1,i) - v(k,j+1,i-1)                &
     2334                                                        + v(k,j,i)   - v(k,j,i-1)   ) * ddx        &
     2335                                                - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) )   * ddy        &
     2336                                                                )                                  &
    23622337                                 + f * v_stokes_zu(k)
    23632338                ENDDO
     
    23712346             DO  j = nysv, nyn
    23722347                DO  k = nzb+1, nzt
    2373                    tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * (              &
    2374                                    0.5 * ( v(k,j,i+1) - v(k,j,i-1) )   * ddx   &
    2375                                  - 0.5 * ( u(k,j,i) - u(k,j-1,i)               &
    2376                                          + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy   &
     2348                   tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * (                                  &
     2349                                                  0.5 * ( v(k,j,i+1) - v(k,j,i-1) )   * ddx        &
     2350                                                - 0.5 * ( u(k,j,i) - u(k,j-1,i)                    &
     2351                                                        + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy        &
    23772352                                                                )              &
    23782353                                 - f * u_stokes_zu(k)
     
    23932368             DO  j = nys, nyn
    23942369                DO  k = nzb+1, nzt
    2395                    tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) * (              &
    2396                                              0.5 * ( u(k+1,j,i) - u(k,j,i)     &
    2397                                                    + u(k+1,j,i+1) - u(k,j,i+1) &
    2398                                                    ) * ddzu(k+1)               &
    2399                                            - 0.5 * ( w(k,j,i+1) - w(k,j,i-1)   &
    2400                                                    ) * ddx      )              &
    2401                                              - v_stokes_zw(k) * (              &
    2402                                              0.5 * ( w(k,j+1,i) - w(k,j-1,i)   &
    2403                                                    ) * ddy                     &
    2404                                            - 0.5 * ( v(k+1,j,i) - v(k,j,i)     &
    2405                                                    + v(k+1,j+1,i) - v(k,j+1,i) &
    2406                                                    ) * ddzu(k)  )              &
    2407                                            + fs * (                            &
    2408                                                sin_rot_angle * v_stokes_zw(k)  &
    2409                                              + cos_rot_angle * u_stokes_zw(k)  &
    2410                                                   )
     2370                   tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) *   (                                &
     2371                                                   0.5 * ( u(k+1,j,i) - u(k,j,i)                   &
     2372                                                         + u(k+1,j,i+1) - u(k,j,i+1)               &
     2373                                                         ) * ddzu(k+1)                             &
     2374                                                 - 0.5 * ( w(k,j,i+1) - w(k,j,i-1)                 &
     2375                                                         ) * ddx  )                                &
     2376                                             - v_stokes_zw(k) *      (                             &
     2377                                                   0.5 * ( w(k,j+1,i) - w(k,j-1,i)                 &
     2378                                                         ) * ddy                                   &
     2379                                                 - 0.5 * ( v(k+1,j,i) - v(k,j,i)                   &
     2380                                                         + v(k+1,j+1,i) - v(k,j+1,i)               &
     2381                                                         ) * ddzu(k) )                             &
     2382                                              + fs * (   sin_rot_angle * v_stokes_zw(k)            &
     2383                                                       + cos_rot_angle * u_stokes_zw(k)            &
     2384                                                     )
    24112385                ENDDO
    24122386             ENDDO
     
    24142388
    24152389       CASE DEFAULT
    2416           WRITE( message_string, * ) 'wrong component of Stokes force: ',      &
    2417                                      component
     2390          WRITE( message_string, * ) 'wrong component of Stokes force: ', component
    24182391          CALL message( 'stokes_drift_terms', 'PA0091', 1, 2, 0, 6, 0 )
    24192392
     
    24232396
    24242397
    2425 !------------------------------------------------------------------------------!
    2426 ! Description:
    2427 ! ------------
    2428 !> This routine calculates the Craik Leibovich vortex force and the additional
    2429 !> effect of the Stokes drift on the Coriolis force
     2398!--------------------------------------------------------------------------------------------------!
     2399! Description:
     2400! ------------
     2401!> This routine calculates the Craik Leibovich vortex force and the additional effect of the Stokes
     2402!> drift on the Coriolis force.
    24302403!> Call for gridpoints i,j.
    2431 !------------------------------------------------------------------------------!
     2404!--------------------------------------------------------------------------------------------------!
    24322405
    24332406 SUBROUTINE stokes_drift_terms_ij( i, j, component )
    24342407
    2435     USE arrays_3d,                                                             &
    2436         ONLY:  ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu,              &
    2437                v_stokes_zw, w, tend
    2438 
    2439     USE basic_constants_and_equations_mod,                                     &
     2408    USE arrays_3d,                                                                                 &
     2409        ONLY:  ddzu, u, u_stokes_zu, u_stokes_zw, v, v_stokes_zu, v_stokes_zw, w, tend
     2410
     2411    USE basic_constants_and_equations_mod,                                                         &
    24402412        ONLY:  pi
    24412413
    2442     USE control_parameters,                                                    &
     2414    USE control_parameters,                                                                        &
    24432415        ONLY:  f, fs, message_string, rotation_angle
    24442416
    2445     USE grid_variables,                                                        &
     2417    USE grid_variables,                                                                            &
    24462418        ONLY:  ddx, ddy
    24472419
    2448     USE indices,                                                               &
     2420    USE indices,                                                                                   &
    24492421        ONLY:  nzb, nzt
    24502422
     
    24592431    REAL(wp)     ::  sin_rot_angle  !< sine of model rotation angle
    24602432
     2433
    24612434!
    24622435!-- Compute Stokes terms for the respective velocity components
     
    24672440       CASE ( 1 )
    24682441          DO  k = nzb+1, nzt
    2469              tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * (                    &
    2470                                      0.5 * ( v(k,j+1,i) - v(k,j+1,i-1)         &
    2471                                            + v(k,j,i)   - v(k,j,i-1)   ) * ddx &
    2472                                    - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) )   * ddy &
    2473                                                           )                    &
     2442             tend(k,j,i) = tend(k,j,i) + v_stokes_zu(k) * (                                        &
     2443                                              0.5 * ( v(k,j+1,i) - v(k,j+1,i-1)                    &
     2444                                                    + v(k,j,i)   - v(k,j,i-1)   ) * ddx            &
     2445                                            - 0.5 * ( u(k,j+1,i) - u(k,j-1,i) )   * ddy            &
     2446                                                          )                                        &
    24742447                                       + f * v_stokes_zu(k)
    24752448          ENDDO
     
    24782451       CASE ( 2 )
    24792452          DO  k = nzb+1, nzt
    2480              tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * (                    &
    2481                                      0.5 * ( v(k,j,i+1) - v(k,j,i-1) )   * ddx &
    2482                                    - 0.5 * ( u(k,j,i) - u(k,j-1,i)             &
    2483                                            + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy &
    2484                                                           )                    &
     2453             tend(k,j,i) = tend(k,j,i) - u_stokes_zu(k) * (                                        &
     2454                                              0.5 * ( v(k,j,i+1) - v(k,j,i-1) )   * ddx            &
     2455                                            - 0.5 * ( u(k,j,i) - u(k,j-1,i)                        &
     2456                                                    + u(k,j,i+1) - u(k,j-1,i+1) ) * ddy            &
     2457                                                          )                                        &
    24852458                                       - f * u_stokes_zu(k)
    24862459          ENDDO
     
    24962469
    24972470          DO  k = nzb+1, nzt
    2498              tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) * (              &
    2499                                      0.5 * ( u(k+1,j,i) - u(k,j,i)     &
    2500                                                    + u(k+1,j,i+1) - u(k,j,i+1) &
    2501                                                    ) * ddzu(k+1)               &
    2502                                            - 0.5 * ( w(k,j,i+1) - w(k,j,i-1)   &
    2503                                                    ) * ddx )                   &
    2504                                        - v_stokes_zw(k) * (                    &
    2505                                              0.5 * ( w(k,j+1,i) - w(k,j-1,i)   &
    2506                                                    ) * ddy                     &
    2507                                            - 0.5 * ( v(k+1,j,i) - v(k,j,i)     &
    2508                                                    + v(k+1,j+1,i) - v(k,j+1,i) &
    2509                                                    ) * ddzu(k)  )              &
    2510                                        + fs * ( sin_rot_angle * v_stokes_zw(k) &
    2511                                               + cos_rot_angle * u_stokes_zw(k) &
     2471             tend(k,j,i) = tend(k,j,i) + u_stokes_zw(k) * ( 0.5 * ( u(k+1,j,i) - u(k,j,i)          &
     2472                                                                  + u(k+1,j,i+1) - u(k,j,i+1)      &
     2473                                                                  ) * ddzu(k+1)                    &
     2474                                                          - 0.5 * ( w(k,j,i+1) - w(k,j,i-1)        &
     2475                                                                  ) * ddx      )                   &
     2476                                       - v_stokes_zw(k) * ( 0.5 * ( w(k,j+1,i) - w(k,j-1,i)        &
     2477                                                                  ) * ddy                          &
     2478                                                          - 0.5 * ( v(k+1,j,i) - v(k,j,i)          &
     2479                                                                  + v(k+1,j+1,i) - v(k,j+1,i)      &
     2480                                                                  ) * ddzu(k)  )                   &
     2481                                       + fs * ( sin_rot_angle * v_stokes_zw(k)                     &
     2482                                              + cos_rot_angle * u_stokes_zw(k)                     &
    25122483                                              )
    25132484          ENDDO
     
    25222493
    25232494
    2524 !------------------------------------------------------------------------------!
    2525 ! Description:
    2526 ! ------------
    2527 !> This routine calculates turbulence generated by wave breaking near the ocean
    2528 !> surface, following a parameterization given in Noh et al. (2004), JPO
     2495!--------------------------------------------------------------------------------------------------!
     2496! Description:
     2497! ------------
     2498!> This routine calculates turbulence generated by wave breaking near the ocean surface, following
     2499!> a parameterization given in Noh et al. (2004), JPO
    25292500!> Call for all gridpoints.
    2530 !> TODO: so far, this routine only works if the model time step has about the
    2531 !>       same value as the time scale of wave breaking!
    2532 !------------------------------------------------------------------------------!
     2501!> TODO: so far, this routine only works if the model time step has about the same value as the time
     2502!>       scale of wave breaking!
     2503!--------------------------------------------------------------------------------------------------!
    25332504 SUBROUTINE wave_breaking_term( component )
    25342505
    2535     USE arrays_3d,                                                             &
     2506    USE arrays_3d,                                                                                 &
    25362507        ONLY:  u_p, v_p
    25372508
    2538     USE control_parameters,                                                    &
     2509    USE control_parameters,                                                                        &
    25392510        ONLY:  dt_3d, message_string
    25402511
    2541     USE indices,                                                               &
     2512    USE indices,                                                                                   &
    25422513        ONLY:  nxl, nxlu, nxr, nys, nysv, nyn, nzt
    25432514
     
    25482519    INTEGER(iwp) ::  j          !< loop index along y
    25492520
    2550     REAL(wp) ::  random_gauss  !< function that creates a random number with a
    2551                                !< Gaussian distribution
     2521    REAL(wp) ::  random_gauss  !< function that creates a random number with a Gaussian distribution
    25522522
    25532523
     
    25622532          DO  i = nxlu, nxr
    25632533             DO  j = nys, nyn
    2564                 u_p(nzt,j,i) = u_p(nzt,j,i) +                                  &
    2565                                ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) &
    2566                                * alpha_wave_breaking * u_star_wave_breaking    &
     2534                u_p(nzt,j,i) = u_p(nzt,j,i) +                                                      &
     2535                               ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )                     &
     2536                               * alpha_wave_breaking * u_star_wave_breaking                        &
    25672537                               / timescale_wave_breaking * dt_3d
    25682538             ENDDO
     
    25732543          DO  i = nxl, nxr
    25742544             DO  j = nysv, nyn
    2575                 v_p(nzt,j,i) = v_p(nzt,j,i) +                                  &
    2576                                ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp ) &
    2577                                * alpha_wave_breaking * u_star_wave_breaking    &
     2545                v_p(nzt,j,i) = v_p(nzt,j,i) +                                                      &
     2546                               ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )                     &
     2547                               * alpha_wave_breaking * u_star_wave_breaking                        &
    25782548                               / timescale_wave_breaking * dt_3d
    25792549             ENDDO
     
    25812551
    25822552       CASE DEFAULT
    2583           WRITE( message_string, * ) 'wrong component of wave breaking: ',     &
    2584                                      component
     2553          WRITE( message_string, * ) 'wrong component of wave breaking: ', component
    25852554          CALL message( 'stokes_drift_terms', 'PA0466', 1, 2, 0, 6, 0 )
    25862555
     
    25902559
    25912560
    2592 !------------------------------------------------------------------------------!
    2593 ! Description:
    2594 ! ------------
    2595 !> This routine calculates turbulence generated by wave breaking near the ocean
    2596 !> surface, following a parameterization given in Noh et al. (2004), JPO
     2561!--------------------------------------------------------------------------------------------------!
     2562! Description:
     2563! ------------
     2564!> This routine calculates turbulence generated by wave breaking near the ocean surface, following a
     2565!> parameterization given in Noh et al. (2004), JPO
    25972566!> Call for gridpoint i,j.
    2598 !> TODO: so far, this routine only works if the model time step has about the
    2599 !>       same value as the time scale of wave breaking!
    2600 !------------------------------------------------------------------------------!
     2567!> TODO: so far, this routine only works if the model time step has about the same value as the time
     2568!> scale of wave breaking!
     2569!--------------------------------------------------------------------------------------------------!
    26012570 SUBROUTINE wave_breaking_term_ij( i, j, component )
    26022571
    2603     USE arrays_3d,                                                             &
     2572    USE arrays_3d,                                                                                 &
    26042573        ONLY:  u_p, v_p
    26052574
    2606     USE control_parameters,                                                    &
     2575    USE control_parameters,                                                                        &
    26072576        ONLY:  dt_3d, message_string
    26082577
    2609     USE indices,                                                               &
     2578    USE indices,                                                                                   &
    26102579        ONLY:  nzt
    26112580
     
    26162585    INTEGER(iwp) ::  j          !< loop index along y
    26172586
    2618     REAL(wp) ::  random_gauss  !< function that creates a random number with a
    2619                                !< Gaussian distribution
     2587    REAL(wp) ::  random_gauss  !< function that creates a random number with a Gaussian distribution
    26202588
    26212589!
     
    26262594!--    u-/v-component
    26272595       CASE ( 1 )
    2628           u_p(nzt,j,i) = u_p(nzt,j,i) +                                        &
    2629                          ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )       &
    2630                          * alpha_wave_breaking * u_star_wave_breaking          &
     2596          u_p(nzt,j,i) = u_p(nzt,j,i) +                                                            &
     2597                         ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )                           &
     2598                         * alpha_wave_breaking * u_star_wave_breaking                              &
    26312599                         / timescale_wave_breaking * dt_3d
    26322600
    26332601       CASE ( 2 )
    2634           v_p(nzt,j,i) = v_p(nzt,j,i) +                                        &
    2635                          ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )       &
    2636                          * alpha_wave_breaking * u_star_wave_breaking          &
     2602          v_p(nzt,j,i) = v_p(nzt,j,i) +                                                            &
     2603                         ( random_gauss( iran_ocean, 1.0_wp ) - 1.0_wp )                           &
     2604                         * alpha_wave_breaking * u_star_wave_breaking                              &
    26372605                         / timescale_wave_breaking * dt_3d
    26382606
    26392607       CASE DEFAULT
    2640           WRITE( message_string, * ) 'wrong component of wave breaking: ',     &
    2641                                      component
     2608          WRITE( message_string, * ) 'wrong component of wave breaking: ', component
    26422609          CALL message( 'stokes_drift_terms', 'PA0466', 1, 2, 0, 6, 0 )
    26432610
  • palm/trunk/SOURCE/outflow_turbulence.f90

    r4360 r4797  
    11!> @file outflow_turbulence.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.
     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.
    98!
    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.
     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.
    1312!
    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/>.
     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/>.
    1615!
    1716! Copyright 1997-2020 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     17!--------------------------------------------------------------------------------------------------!
    1918!
    2019! Current revisions:
    2120! -----------------
    22 ! 
    23 ! 
     21!
     22!
    2423! Former revisions:
    2524! -----------------
    2625! $Id: outflow_turbulence.f90 3241 2018-09-12 15:02:00Z raasch $
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 3241 2018-09-12 15:02:00Z raasch
    2729! Corrected "Former revisions" section
    28 ! 
     30!
    2931! 3241 2018-09-12 15:02:00Z raasch
    3032! unused variables removed
     
    3234! 2050 2016-11-08 15:00:55Z gronemeier
    3335! Initial version
    34 ! 
     36!
    3537!
    3638! Description:
    3739! ------------
    38 !> Routine based on inflow_turbulence.f90. Copies values of 3d data from a 2d
    39 !> vertical source plane (defined by outflow_source_plane) to the outflow
    40 !> boundary.
    41 !------------------------------------------------------------------------------!
     40!> Routine based on inflow_turbulence.f90. Copies values of 3d data from a 2d vertical source plane
     41!> (defined by outflow_source_plane) to the outflow boundary.
     42!--------------------------------------------------------------------------------------------------!
    4243 SUBROUTINE outflow_turbulence
    4344
    44     USE arrays_3d,                                                             &
     45    USE arrays_3d,                                                                                 &
    4546        ONLY:  e, pt, q, s, u, v, w
    4647
    47     USE control_parameters,                                                    &
     48    USE control_parameters,                                                                        &
    4849        ONLY:  humidity, passive_scalar, outflow_source_plane
    4950
    50     USE cpulog,                                                                &
     51    USE cpulog,                                                                                    &
    5152        ONLY:  cpu_log, log_point
    5253
    53     USE grid_variables,                                                        &
     54    USE grid_variables,                                                                            &
    5455        ONLY:  ddx
    5556
    56     USE indices,                                                               &
     57    USE indices,                                                                                   &
    5758        ONLY:  nbgp, nx, nxr, nyn, nys, nyng, nysg, nzb, nzt
    5859
    5960    USE kinds
    6061
    61     USE pegrid!,                                                                &
     62    USE pegrid!,                                                                                    &
    6263        !ONLY:  comm1dx, id_outflow, id_outflow_source, ierr, myidx, status
    6364
     
    7071    INTEGER(iwp) ::  ngp_ofv  !< number of grid points stored in outflow_val
    7172
    72     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
    73        outflow_val            !< values to be copied to the outflow boundary
     73    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::  outflow_val  !< values to be copied to the outflow boundary
    7474
    7575
     
    9494                outflow_val(k,j,4,l) = pt(k,j,i)
    9595                outflow_val(k,j,5,l) = e(k,j,i)
    96                 IF ( humidity  )                                               &
     96                IF ( humidity  )                                                                   &
    9797                   outflow_val(k,j,6,l) = q(k,j,i)
    98                 IF ( passive_scalar )                                          &
     98                IF ( passive_scalar )                                                              &
    9999                   outflow_val(k,j,7,l) = s(k,j,i)
    100100
     
    115115             outflow_val(k,j,4,l) = pt(k,j,i)
    116116             outflow_val(k,j,5,l) = e(k,j,i)
    117              IF ( humidity  )                                                  &
     117             IF ( humidity  )                                                                      &
    118118                outflow_val(k,j,6,l) = q(k,j,i)
    119              IF ( passive_scalar )                                             &
     119             IF ( passive_scalar )                                                                 &
    120120                outflow_val(k,j,7,l) = s(k,j,i)
    121121
     
    131131    IF ( myidx == id_outflow_source  .AND.  myidx /= id_outflow )  THEN
    132132
    133        CALL MPI_SEND( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,            &
    134                       id_outflow, 1, comm1dx, ierr )
     133       CALL MPI_SEND( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL, id_outflow, 1, comm1dx, ierr )
    135134
    136135    ELSEIF ( myidx /= id_outflow_source  .AND.  myidx == id_outflow )  THEN
    137136
    138137       outflow_val = 0.0_wp
    139        CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,           &
    140                       id_outflow_source, 1, comm1dx, status, ierr )
     138       CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL, id_outflow_source, 1, comm1dx, &
     139                      status, ierr )
    141140
    142141    ENDIF
     
    157156             e(k,j,nx+1:nx+nbgp)  = MAX( e(k,j,nx+1:nx+nbgp), 0.0_wp )
    158157
    159              IF ( humidity )                                                   &
     158             IF ( humidity )                                                                       &
    160159                q(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,6,1:nbgp)
    161              IF ( passive_scalar )                                             &
     160             IF ( passive_scalar )                                                                 &
    162161                s(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,7,1:nbgp)
    163162
  • palm/trunk/SOURCE/palm.f90

    r4539 r4797  
    11! !> @file palm.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/>.
     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/>.
    1615!
    1716! Copyright 1997-2020 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     17!--------------------------------------------------------------------------------------------------!
    1918!
    2019! Current revisions:
    2120! -----------------
    22 ! 
     21!
    2322!
    2423! Former revisions:
    2524! -----------------
    2625! $Id$
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 4539 2020-05-18 14:05:17Z raasch
    2729! log point name changed
    28 ! 
     30!
    2931! 4535 2020-05-15 12:07:23Z raasch
    3032! bugfix for restart data format query
    31 ! 
     33!
    3234! 4496 2020-04-15 08:37:26Z raasch
    3335! bugfix: coupling character added to restart output filename
    34 ! 
     36!
    3537! 4495 2020-04-13 20:11:20Z raasch
    3638! restart data handling with MPI-IO added
    37 ! 
     39!
    3840! 4457 2020-03-11 14:20:43Z raasch
    3941! use statement for exchange horiz added
    40 ! 
     42!
    4143! 4444 2020-03-05 15:59:50Z raasch
    4244! bugfix: cpp-directives for serial mode added
    43 ! 
     45!
    4446! 4414 2020-02-19 20:16:04Z suehring
    4547! Call to module_interface_init_numerics
    46 ! 
     48!
    4749! 4400 2020-02-10 20:32:41Z suehring
    4850! Add interface to initialize data output with dom
    49 ! 
     51!
    5052! 4360 2020-01-07 11:25:50Z suehring
    5153! implement new palm_date_time_mod
    52 ! 
     54!
    5355! 4094 2019-07-12 09:24:21Z gronemeier
    5456! Corrected "Former revisions" section
    55 ! 
     57!
    5658! 4039 2019-06-18 10:32:41Z suehring
    5759! Rename subroutines in module for diagnostic quantities
    58 ! 
     60!
    5961! 4017 2019-06-06 12:16:46Z schwenkel
    6062! new module for calculation and output of diagnostic quantities added
    61 ! 
     63!
    6264! 3885 2019-04-11 11:29:34Z kanani
    63 ! Changes related to global restructuring of location messages and introduction 
     65! Changes related to global restructuring of location messages and introduction
    6466! of additional debug messages
    65 ! 
     67!
    6668! 3761 2019-02-25 15:31:42Z raasch
    6769! unused variable removed
    68 ! 
     70!
    6971! 3719 2019-02-06 13:10:18Z kanani
    7072! Included cpu measurement for wall/soil spinup
    71 ! 
     73!
    7274! 3703 2019-01-29 16:43:53Z knoop
    7375! Some interface calls moved to module_interface + cleanup
    74 ! 
     76!
    7577! 3648 2019-01-02 16:35:46Z suehring
    7678! Rename subroutines for surface-data output
     
    8284! Description:
    8385! ------------
    84 !> Large-Eddy Simulation (LES) model for atmospheric and oceanic boundary-layer
    85 !> flows
     86!> Large-Eddy Simulation (LES) model for atmospheric and oceanic boundary-layer flows,
    8687!> see the PALM homepage https://palm-model.org for further information
    87 !------------------------------------------------------------------------------!
     88!--------------------------------------------------------------------------------------------------!
    8889 PROGRAM palm
    89  
     90
    9091
    9192    USE arrays_3d
    9293
    9394#if defined( __parallel )
    94     USE bulk_cloud_model_mod,                                                  &
     95    USE bulk_cloud_model_mod,                                                                      &
    9596        ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert
    9697#endif
    9798
    98     USE control_parameters,                                                    &
    99         ONLY:  coupling_char, do2d_at_begin, do3d_at_begin, io_blocks,         &
    100                io_group, message_string, restart_data_format_output, runnr, simulated_time_chr, spinup,   &
    101                time_since_reference_point, user_interface_current_revision,    &
     99    USE control_parameters,                                                                        &
     100        ONLY:  coupling_char, do2d_at_begin, do3d_at_begin, io_blocks, io_group, message_string,   &
     101               restart_data_format_output, runnr, simulated_time_chr, spinup,                      &
     102               time_since_reference_point, user_interface_current_revision,                        &
    102103               user_interface_required_revision, version, write_binary
    103104
    104105#if defined( __parallel )
    105     USE control_parameters,                                                    &
    106         ONLY:  child_domain, constant_diffusion, humidity,                     &
    107                initializing_actions, neutral, passive_scalar
    108 #endif
    109 
    110     USE cpulog,                                                                &
    111         ONLY:  cpu_log, log_point, cpu_statistics
    112 
    113 #if defined( __parallel )
    114     USE cpulog,                                                                &
     106    USE control_parameters,                                                                        &
     107        ONLY:  child_domain, constant_diffusion, humidity, initializing_actions, neutral,          &
     108               passive_scalar
     109#endif
     110
     111    USE cpulog,                                                                                    &
     112        ONLY:  cpu_log, cpu_statistics, log_point
     113
     114#if defined( __parallel )
     115    USE cpulog,                                                                                    &
    115116        ONLY:  log_point_s
    116117#endif
    117118
    118     USE diagnostic_output_quantities_mod,                                      &
     119    USE diagnostic_output_quantities_mod,                                                          &
    119120        ONLY:  doq_calculate
    120121
    121122#if defined( __parallel )
    122     USE exchange_horiz_mod,                                                    &
     123    USE exchange_horiz_mod,                                                                        &
    123124        ONLY:  exchange_horiz
    124125
    125     USE indices,                                                               &
     126    USE indices,                                                                                   &
    126127        ONLY:  nbgp
    127128#endif
     
    129130    USE kinds
    130131
    131     USE module_interface,                                                      &
    132         ONLY:  module_interface_init_numerics,                                 &
    133                module_interface_init_output,                                   &
     132    USE module_interface,                                                                          &
     133        ONLY:  module_interface_init_numerics,                                                     &
     134               module_interface_init_output,                                                       &
    134135               module_interface_last_actions
    135136
    136137
    137     USE multi_agent_system_mod,                                                &
     138    USE multi_agent_system_mod,                                                                    &
    138139        ONLY:  agents_active, mas_last_actions
    139140
    140     USE netcdf_data_input_mod,                                                 &
    141         ONLY:  netcdf_data_input_inquire_file, netcdf_data_input_init,         &
     141    USE netcdf_data_input_mod,                                                                     &
     142        ONLY:  netcdf_data_input_inquire_file, netcdf_data_input_init,                             &
    142143               netcdf_data_input_surface_data, netcdf_data_input_topo
    143144
     
    145146
    146147#if defined( __parallel )
    147     USE pmc_particle_interface,                                                &
     148    USE pmc_particle_interface,                                                                    &
    148149        ONLY: pmcp_g_alloc_win
    149150
    150     USE pmc_interface,                                                         &
    151         ONLY:  nested_run, pmci_child_initialize, pmci_init,                   &
    152                pmci_modelconfiguration, pmci_parent_initialize
    153 #endif
    154 
    155     USE restart_data_mpi_io_mod,                                               &
     151    USE pmc_interface,                                                                             &
     152        ONLY:  nested_run, pmci_child_initialize, pmci_init, pmci_modelconfiguration,              &
     153               pmci_parent_initialize
     154#endif
     155
     156    USE restart_data_mpi_io_mod,                                                                   &
    156157        ONLY:  rd_mpi_io_close, rd_mpi_io_open
    157158
    158     USE surface_data_output_mod,                                               &
     159    USE surface_data_output_mod,                                                                   &
    159160        ONLY:  surface_data_output_last_action
    160161
    161     USE write_restart_data_mod,                                                &
     162    USE write_restart_data_mod,                                                                    &
    162163        ONLY:  wrd_global, wrd_local
    163164
     
    172173!-- Local variables
    173174    CHARACTER(LEN=9) ::  time_to_string  !<
    174     INTEGER(iwp)     ::  i               !< loop counter for blocked I/O
     175
     176    INTEGER(iwp)     ::  i                   !< loop counter for blocked I/O
    175177#if defined( __parallel) && defined( _OPENACC )
    176     INTEGER(iwp)     :: local_comm       !< local communicator (shared memory)
    177     INTEGER(iwp)     :: local_num_procs  !< local number of processes
    178     INTEGER(iwp)     :: local_id         !< local id
    179     INTEGER(acc_device_kind) :: device_type !< device type for OpenACC
    180     INTEGER(iwp)     ::  num_devices     !< number of devices visible to OpenACC
    181     INTEGER(iwp)     ::  my_device       !< device used by this process
     178    INTEGER(acc_device_kind) :: device_type      !< device type for OpenACC
     179    INTEGER(iwp)             :: local_comm       !< local communicator (shared memory)
     180    INTEGER(iwp)             :: local_num_procs  !< local number of processes
     181    INTEGER(iwp)             :: local_id         !< local id
     182    INTEGER(iwp)             ::  num_devices     !< number of devices visible to OpenACC
     183    INTEGER(iwp)             ::  my_device       !< device used by this process
    182184#endif
    183185
     
    187189#if defined( __parallel )
    188190!
    189 !-- MPI initialisation. comm2d is preliminary set, because
    190 !-- it will be defined in init_pegrid but is used before in cpu_log.
     191!-- MPI initialisation. comm2d is preliminary set, because it will be defined in init_pegrid but is
     192!-- used before in cpu_log.
    191193    CALL MPI_INIT( ierr )
    192194
    193195!
    194 !-- Initialize the coupling for nested-domain runs
    195 !-- comm_palm is the communicator which includes all PEs (MPI processes)
    196 !-- available for this (nested) model. If it is not a nested run, comm_palm
    197 !-- is returned as MPI_COMM_WORLD
     196!-- Initialize the coupling for nested-domain runs comm_palm is the communicator which includes all
     197!-- PEs (MPI processes) available for this (nested) model. If it is not a nested run, comm_palm is
     198!-- returned as MPI_COMM_WORLD.
    198199    CALL cpu_log( log_point_s(70), 'pmci_init', 'start' )
    199200    CALL pmci_init( comm_palm )
     
    201202    comm2d = comm_palm
    202203!
    203 !-- Get the (preliminary) number of MPI processes and the local PE-id (in case
    204 !-- of a further communicator splitting in init_coupling, these numbers will
    205 !-- be changed in init_pegrid).
     204!-- Get the (preliminary) number of MPI processes and the local PE-id (in case of a further
     205!-- communicator splitting in init_coupling, these numbers will be changed in init_pegrid).
    206206    IF ( nested_run )  THEN
    207207
     
    214214       CALL MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
    215215!
    216 !--    Initialize PE topology in case of coupled atmosphere-ocean runs (comm_palm
    217 !--    will be splitted in init_coupling)
     216!--    Initialize PE topology in case of coupled atmosphere-ocean runs (comm_palm will be splitted
     217!--    in init_coupling)
    218218       CALL init_coupling
    219219    ENDIF
     
    221221#ifdef _OPENACC
    222222!
    223 !-- Select OpenACC device to use in this process. For this find out how many
    224 !-- neighbors there are running on the same node and which id this process is.
     223!-- Select OpenACC device to use in this process. For this find out how many neighbors there are
     224!-- running on the same node and which id this process is.
    225225    IF ( nested_run )  THEN
    226        CALL MPI_COMM_SPLIT_TYPE( comm_palm, MPI_COMM_TYPE_SHARED, 0,           &
    227                                  MPI_INFO_NULL, local_comm, ierr )
     226       CALL MPI_COMM_SPLIT_TYPE( comm_palm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, local_comm,    &
     227                                 ierr )
    228228    ELSE
    229        CALL MPI_COMM_SPLIT_TYPE( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0,      &
    230                                  MPI_INFO_NULL, local_comm, ierr )
     229       CALL MPI_COMM_SPLIT_TYPE( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL,           &
     230                                 local_comm, ierr )
    231231    ENDIF
    232232    CALL MPI_COMM_SIZE( local_comm, local_num_procs, ierr )
     
    234234
    235235!
    236 !-- This loop including the barrier is a workaround for PGI compiler versions
    237 !-- up to and including 18.4. Later releases are able to select their GPUs in
    238 !-- parallel, without running into spurious errors.
     236!-- This loop including the barrier is a workaround for PGI compiler versions up to and including
     237!-- 18.4. Later releases are able to select their GPUs in parallel, without running into spurious
     238!-- errors.
    239239    DO i = 0, local_num_procs-1
    240240       CALL MPI_BARRIER( local_comm, ierr )
     
    267267
    268268!
    269 !-- Initialize dvrp logging. Also, one PE maybe split from the global
    270 !-- communicator for doing the dvrp output. In that case, the number of
    271 !-- PEs available for PALM is reduced by one and communicator comm_palm
    272 !-- is changed respectively.
     269!-- Initialize dvrp logging. Also, one PE maybe split from the global communicator for doing the
     270!-- dvrp output. In that case, the number of PEs available for PALM is reduced by one and
     271!-- communicator comm_palm is changed respectively.
    273272#if defined( __parallel )
    274273    CALL MPI_COMM_RANK( comm_palm, myid, ierr )
     
    281280!
    282281!-- Check for the user's interface version
    283     IF ( user_interface_current_revision /= user_interface_required_revision )  &
    284     THEN
    285        message_string = 'current user-interface revision "' //                  &
    286                         TRIM( user_interface_current_revision ) // '" does ' // &
    287                         'not match the required revision ' //                   &
     282    IF ( user_interface_current_revision /= user_interface_required_revision )  THEN
     283       message_string = 'current user-interface revision "' //                                     &
     284                        TRIM( user_interface_current_revision ) // '" does ' //                    &
     285                        'not match the required revision ' //                                      &
    288286                        TRIM( user_interface_required_revision )
    289287        CALL message( 'palm', 'PA0169', 1, 2, 0, 6, 0 )
     
    297295    CALL netcdf_data_input_inquire_file
    298296!
    299 !-- Read topography input data if required. This is required before the
    300 !-- numerical grid is finally created in init_grid
    301     CALL netcdf_data_input_topo 
    302 !
    303 !-- Generate grid parameters, initialize generic topography and further process
    304 !-- topography information if required
     297!-- Read topography input data if required. This is required before the numerical grid is finally
     298!-- created in init_grid.
     299    CALL netcdf_data_input_topo
     300!
     301!-- Generate grid parameters, initialize generic topography and further process topography
     302!-- information if required.
    305303    CALL init_grid
    306304!
    307 !-- Initialize boundary conditions and numerics such as the multigrid solver or
    308 !-- the advection routine
     305!-- Initialize boundary conditions and numerics such as the multigrid solver or the advection
     306!-- routine
    309307    CALL module_interface_init_numerics
    310308!
    311 !-- Read global attributes if available. 
    312     CALL netcdf_data_input_init
    313 !
    314 !-- Read surface classification data, e.g. vegetation and soil types, water
    315 !-- surfaces, etc., if available. Some of these data is required before
    316 !-- check parameters is invoked.     
     309!-- Read global attributes if available.
     310    CALL netcdf_data_input_init
     311!
     312!-- Read surface classification data, e.g. vegetation and soil types, water surfaces, etc., if
     313!-- available. Some of these data is required before check parameters is invoked.
    317314    CALL netcdf_data_input_surface_data
    318315!
     
    331328!
    332329!--    Receive and interpolate initial data on children.
    333 !--    Child initialization must be made first if the model is both child and
    334 !--    parent if necessary
     330!--    Child initialization must be made first if the model is both child and parent if necessary.
    335331       IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
    336332          CALL pmci_child_initialize
     
    355351                ENDIF
    356352                IF ( bulk_cloud_model  .AND.  microphysics_seifert )  THEN
    357                    CALL exchange_horiz( qr, nbgp ) 
     353                   CALL exchange_horiz( qr, nbgp )
    358354                   CALL exchange_horiz( nr, nbgp )
    359355                ENDIF
     
    374370
    375371!
    376 !-- Integration of the non-atmospheric equations (land surface model, urban
    377 !-- surface model)
     372!-- Integration of the non-atmospheric equations (land surface model, urban surface model)
    378373    IF ( spinup )  THEN
    379374       CALL cpu_log( log_point(41), 'wall/soil spinup', 'start' )
     
    457452
    458453       CALL cpu_log( log_point(22), 'write-restart-data', 'stop' )
    459        
     454
    460455    ENDIF
    461456!
     
    471466    CALL cpu_log( log_point(4), 'last actions', 'start' )
    472467
    473     IF ( myid == 0 .AND. agents_active ) CALL mas_last_actions ! ToDo: move to module_interface
     468    IF ( myid == 0 .AND. agents_active )  CALL mas_last_actions ! ToDo: move to module_interface
    474469
    475470    CALL module_interface_last_actions
     
    482477
    483478!
    484 !-- Write run number to file (used by palmrun to create unified cycle numbers
    485 !-- for output files
     479!-- Write run number to file (used by palmrun to create unified cycle numbers for output files).
    486480    IF ( myid == 0  .AND.  runnr > 0 )  THEN
    487481       OPEN( 90, FILE='RUN_NUMBER', FORM='FORMATTED' )
  • palm/trunk/SOURCE/palm_date_time_mod.f90

    r4680 r4797  
    2424! -----------------
    2525! $Id$
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 4680 2020-09-16 10:20:34Z gronemeier
    2629! Add option to fix date and time; renamed set_reference_date_time to init_date_time
    2730!
     
    3134! 4227 2019-09-10 18:04:34Z gronemeier
    3235! Complete rework of module date_and_time_mod:
    33 !  - renamed module to prevent confusion with
    34 !    FORTRAN Standard routine date_and_time
     36!  - renamed module to prevent confusion with FORTRAN Standard routine date_and_time
    3537!  - introduce date_time_type
    3638!  - add set_reference_date_time
     
    4648! Description:
    4749! ------------
    48 !> This routine calculates all needed information on date and time used by
    49 !> other modules
     50!> This routine calculates all needed information on date and time used by other modules
    5051!>
    5152!> @todo Consider leap seconds
     
    7475    INTEGER(iwp), PARAMETER ::  southward_equinox  = 264_iwp                                !< Sep 21 (leap year: Sep 20)
    7576
     77    CHARACTER(LEN=3), DIMENSION(days_per_week), PARAMETER ::                                       &
     78       weekdays = (/"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"/)                       !< names of weekdays
     79
     80    INTEGER, DIMENSION(months_per_year), PARAMETER ::                                              &
     81       days_per_month_noleapyear = (/31,28,31,30,31,30,31,31,30,31,30,31/)                  !< days for each month (no leap year)
     82
     83    INTEGER, DIMENSION(months_per_year), PARAMETER ::                                              &
     84       days_per_month_leapyear = (/31,29,31,30,31,30,31,31,30,31,30,31/)                    !< days for each month (leap year)
     85
     86    INTEGER, DIMENSION(121), PARAMETER ::  leap_years = &                                   !< list of leap years
     87        (/ 1804_iwp, 1808_iwp, 1812_iwp, 1816_iwp, 1820_iwp, 1824_iwp, 1828_iwp, 1832_iwp,         &
     88           1836_iwp, 1840_iwp, 1844_iwp, 1848_iwp, 1852_iwp, 1856_iwp, 1860_iwp, 1864_iwp,         &
     89           1868_iwp, 1872_iwp, 1876_iwp, 1880_iwp, 1884_iwp, 1888_iwp, 1892_iwp, 1896_iwp,         &
     90           1904_iwp, 1908_iwp, 1912_iwp, 1916_iwp, 1920_iwp, 1924_iwp, 1928_iwp, 1932_iwp,         &
     91           1936_iwp, 1940_iwp, 1944_iwp, 1948_iwp, 1952_iwp, 1956_iwp, 1960_iwp, 1964_iwp,         &
     92           1968_iwp, 1972_iwp, 1976_iwp, 1980_iwp, 1984_iwp, 1988_iwp, 1992_iwp, 1996_iwp,         &
     93           2000_iwp, 2004_iwp, 2008_iwp, 2012_iwp, 2016_iwp, 2020_iwp, 2024_iwp, 2028_iwp,         &
     94           2032_iwp, 2036_iwp, 2040_iwp, 2044_iwp, 2048_iwp, 2052_iwp, 2056_iwp, 2060_iwp,         &
     95           2064_iwp, 2068_iwp, 2072_iwp, 2076_iwp, 2080_iwp, 2084_iwp, 2088_iwp, 2092_iwp,         &
     96           2096_iwp, 2104_iwp, 2108_iwp, 2112_iwp, 2116_iwp, 2120_iwp, 2124_iwp, 2128_iwp,         &
     97           2132_iwp, 2136_iwp, 2140_iwp, 2144_iwp, 2148_iwp, 2152_iwp, 2156_iwp, 2160_iwp,         &
     98           2164_iwp, 2168_iwp, 2172_iwp, 2176_iwp, 2180_iwp, 2184_iwp, 2188_iwp, 2192_iwp,         &
     99           2196_iwp, 2204_iwp, 2208_iwp, 2212_iwp, 2216_iwp, 2220_iwp, 2224_iwp, 2228_iwp,         &
     100           2232_iwp, 2236_iwp, 2240_iwp, 2244_iwp, 2248_iwp, 2252_iwp, 2256_iwp, 2260_iwp,         &
     101           2264_iwp, 2268_iwp, 2272_iwp, 2276_iwp, 2280_iwp, 2284_iwp, 2288_iwp, 2292_iwp,         &
     102           2296_iwp /)
     103
    76104    REAL(wp),     PARAMETER ::  seconds_per_minute = 60.0_wp                                !< seconds in a minute
    77105    REAL(wp),     PARAMETER ::  seconds_per_hour   = seconds_per_minute * minutes_per_hour  !< seconds in an hour
    78106    REAL(wp),     PARAMETER ::  seconds_per_day    = seconds_per_hour * hours_per_day       !< seconds in a day
    79 
    80     CHARACTER(LEN=3), DIMENSION(days_per_week), PARAMETER ::  &
    81        weekdays = (/"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"/)                       !< names of weekdays
    82 
    83     INTEGER, DIMENSION(months_per_year), PARAMETER ::  &
    84        days_per_month_noleapyear = (/31,28,31,30,31,30,31,31,30,31,30,31/)                  !< days for each month (no leap year)
    85 
    86     INTEGER, DIMENSION(months_per_year), PARAMETER ::  &
    87        days_per_month_leapyear = (/31,29,31,30,31,30,31,31,30,31,30,31/)                    !< days for each month (leap year)
    88 
    89     INTEGER, DIMENSION(121), PARAMETER ::  leap_years = &                                   !< list of leap years
    90         (/1804_iwp, 1808_iwp, 1812_iwp, 1816_iwp, 1820_iwp, 1824_iwp, 1828_iwp, 1832_iwp, &
    91           1836_iwp, 1840_iwp, 1844_iwp, 1848_iwp, 1852_iwp, 1856_iwp, 1860_iwp, 1864_iwp, &
    92           1868_iwp, 1872_iwp, 1876_iwp, 1880_iwp, 1884_iwp, 1888_iwp, 1892_iwp, 1896_iwp, &
    93           1904_iwp, 1908_iwp, 1912_iwp, 1916_iwp, 1920_iwp, 1924_iwp, 1928_iwp, 1932_iwp, &
    94           1936_iwp, 1940_iwp, 1944_iwp, 1948_iwp, 1952_iwp, 1956_iwp, 1960_iwp, 1964_iwp, &
    95           1968_iwp, 1972_iwp, 1976_iwp, 1980_iwp, 1984_iwp, 1988_iwp, 1992_iwp, 1996_iwp, &
    96           2000_iwp, 2004_iwp, 2008_iwp, 2012_iwp, 2016_iwp, 2020_iwp, 2024_iwp, 2028_iwp, &
    97           2032_iwp, 2036_iwp, 2040_iwp, 2044_iwp, 2048_iwp, 2052_iwp, 2056_iwp, 2060_iwp, &
    98           2064_iwp, 2068_iwp, 2072_iwp, 2076_iwp, 2080_iwp, 2084_iwp, 2088_iwp, 2092_iwp, &
    99           2096_iwp, 2104_iwp, 2108_iwp, 2112_iwp, 2116_iwp, 2120_iwp, 2124_iwp, 2128_iwp, &
    100           2132_iwp, 2136_iwp, 2140_iwp, 2144_iwp, 2148_iwp, 2152_iwp, 2156_iwp, 2160_iwp, &
    101           2164_iwp, 2168_iwp, 2172_iwp, 2176_iwp, 2180_iwp, 2184_iwp, 2188_iwp, 2192_iwp, &
    102           2196_iwp, 2204_iwp, 2208_iwp, 2212_iwp, 2216_iwp, 2220_iwp, 2224_iwp, 2228_iwp, &
    103           2232_iwp, 2236_iwp, 2240_iwp, 2244_iwp, 2248_iwp, 2252_iwp, 2256_iwp, 2260_iwp, &
    104           2264_iwp, 2268_iwp, 2272_iwp, 2276_iwp, 2280_iwp, 2284_iwp, 2288_iwp, 2292_iwp, &
    105           2296_iwp /)
    106107
    107108!
     
    146147!
    147148!-- Public Interfaces
    148     PUBLIC &
    149        get_date_time, &
     149    PUBLIC                                                                                         &
     150       get_date_time,                                                                              &
    150151       init_date_time
    151152!
    152153!-- Public variables
    153     PUBLIC                 &
    154        date_time_str_len,  &
    155        days_per_week,      &
    156        hours_per_day,      &
    157        minutes_per_hour,   &
    158        months_per_year,    &
    159        northward_equinox,  &
    160        seconds_per_minute, &
    161        seconds_per_hour,   &
    162        seconds_per_day,    &
    163        southward_equinox,  &
     154    PUBLIC                                                                                         &
     155       date_time_str_len,                                                                          &
     156       days_per_week,                                                                              &
     157       hours_per_day,                                                                              &
     158       minutes_per_hour,                                                                           &
     159       months_per_year,                                                                            &
     160       northward_equinox,                                                                          &
     161       seconds_per_minute,                                                                         &
     162       seconds_per_hour,                                                                           &
     163       seconds_per_day,                                                                            &
     164       southward_equinox,                                                                          &
    164165       weekdays
    165166
     
    180181    LOGICAL, INTENT(IN), OPTIONAL ::  use_fixed_date  !< flag to fix date
    181182    LOGICAL, INTENT(IN), OPTIONAL ::  use_fixed_time  !< flag to fix time
     183
    182184!
    183185!-- Check if date and time are already set
     
    185187       !> @note This error should never be observed by a user.
    186188       !>       It can only appear if the code was modified.
    187        WRITE( message_string, * ) 'Multiple calls to init_date_time detected.&' //  &
     189       WRITE( message_string, * ) 'Multiple calls to init_date_time detected.&' //                 &
    188190                                  'This routine must not be called more than once.'
    189191       CALL message( 'init_date_time', 'PA0680', 2, 2, 0, 6, 0 )
     
    212214!> via 'reference_date_time_str' or previously set by calling routine 'init_date_time'.
    213215!--------------------------------------------------------------------------------------------------!
    214  SUBROUTINE get_date_time( time_since_reference, reference_date_time_str,    &
    215                            year, month, day, hour, minute, second, zone,     &
    216                            second_of_day, second_of_year,                    &
    217                            day_of_year, day_of_week, weekday, date_time_str, &
    218                            days_per_month, days_per_year                     )
     216 SUBROUTINE get_date_time( time_since_reference, reference_date_time_str, year, month, day, hour,  &
     217                           minute, second, zone, second_of_day, second_of_year, day_of_year,       &
     218                           day_of_week, weekday, date_time_str, days_per_month, days_per_year )
    219219
    220220    CHARACTER(LEN=date_time_str_len), INTENT(OUT), OPTIONAL ::  date_time_str            !< date-time as string
     
    223223    CHARACTER(LEN=3),                 INTENT(OUT), OPTIONAL ::  weekday                  !< weekday
    224224
    225     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  day              !< day of month
    226     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  day_of_week      !< number of weekday
    227     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  day_of_year      !< day of the year
    228     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  hour             !< hour of day
    229     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  minute           !< minute of hour
    230     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  month            !< month of year
    231     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  year             !< year
    232     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  zone             !< time zone
    233     INTEGER(iwp),                             INTENT(OUT), OPTIONAL ::  days_per_year    !< days per year
     225    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  day              !< day of month
     226    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  day_of_week      !< number of weekday
     227    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  day_of_year      !< day of the year
     228    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  days_per_year    !< days per year
     229    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  hour             !< hour of day
     230    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  minute           !< minute of hour
     231    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  month            !< month of year
     232    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  year             !< year
     233    INTEGER(iwp), INTENT(OUT), OPTIONAL ::  zone             !< time zone
     234
    234235    INTEGER(iwp), DIMENSION(months_per_year), INTENT(OUT), OPTIONAL ::  days_per_month   !< days per year
    235236
     
    247248       !> @note This error should never be observed by a user.
    248249       !>       It can only appear if the code was modified.
    249        WRITE( message_string, * ) 'No reference date-time defined. '//                   &
    250                                   'Returning date-time information is not possible. ' // &
    251                                   'Either specify reference_date_time_str ' //           &
     250       WRITE( message_string, * ) 'No reference date-time defined. '//                             &
     251                                  'Returning date-time information is not possible. ' //           &
     252                                  'Either specify reference_date_time_str ' //                     &
    252253                                  'or set a reference via init_date_time.'
    253254       CALL message( 'get_date_time', 'PA0677', 2, 2, 0, 6, 0 )
     
    273274!--    If date shall be fixed, revert it to the reference date if changed
    274275       IF ( date_is_fixed )  THEN
    275           IF ( date_time%year /= internal_reference_date_time%year  .OR.                          &
    276                get_day_of_year( date_time ) /= get_day_of_year( internal_reference_date_time ) )  &
     276          IF ( date_time%year /= internal_reference_date_time%year  .OR.                           &
     277               get_day_of_year( date_time ) /= get_day_of_year( internal_reference_date_time ) )   &
    277278          THEN
    278279
    279              date_time%year           = internal_reference_date_time%year
    280              date_time%month          = internal_reference_date_time%month
    281              date_time%day            = internal_reference_date_time%day
    282 
    283              date_time = update_leapyear_setting( date_time )
    284 
     280             date_time%year  = internal_reference_date_time%year
     281             date_time%month = internal_reference_date_time%month
     282             date_time%day   = internal_reference_date_time%day
     283             date_time       = update_leapyear_setting( date_time )
    285284             date_time%second_of_year = get_second_of_year( date_time )
    286285
     
    311310          plus_minus = '+'
    312311       ENDIF
    313        WRITE( UNIT = date_time_str,                                                 &
    314               FMT = '(I4,"-",I2.2,"-",I2.2,1X,I2.2,":",I2.2,":",I2.2,1X,A1,I2.2)' ) &
    315           date_time%year, date_time%month, date_time%day,                           &
    316           date_time%hour, date_time%minute, INT( date_time%second ),                &
     312       WRITE( UNIT = date_time_str,                                                                &
     313              FMT = '(I4,"-",I2.2,"-",I2.2,1X,I2.2,":",I2.2,":",I2.2,1X,A1,I2.2)' )                &
     314          date_time%year, date_time%month, date_time%day,                                          &
     315          date_time%hour, date_time%minute, INT( date_time%second ),                               &
    317316          plus_minus, ABS( date_time%zone )
    318317    ENDIF
     
    326325!> Convert a date-time string into a date_time object.
    327326!--------------------------------------------------------------------------------------------------!
    328  FUNCTION convert_string_to_date_time( date_time_str ) RESULT( date_time )
     327 FUNCTION convert_string_to_date_time( date_time_str )  RESULT( date_time )
    329328
    330329    CHARACTER(LEN=date_time_str_len), INTENT(IN) ::  date_time_str  !< date-time as string
     
    337336!-- Decompose string to date-time information
    338337    READ( UNIT = date_time_str( 1: 4), IOSTAT = read_status, FMT = '(I4)'   )  date_time%year
    339     IF ( read_status == 0 )  &
     338    IF ( read_status == 0 )  THEN
    340339       READ( UNIT = date_time_str( 6: 7), IOSTAT = read_status, FMT = '(I2)'   )  date_time%month
    341     IF ( read_status == 0 )  &
     340    ENDIF
     341    IF ( read_status == 0 )  THEN
    342342       READ( UNIT = date_time_str( 9:10), IOSTAT = read_status, FMT = '(I2)'   )  date_time%day
    343     IF ( read_status == 0 )  &
     343    ENDIF
     344    IF ( read_status == 0 )  THEN
    344345       READ( UNIT = date_time_str(12:13), IOSTAT = read_status, FMT = '(I2)'   )  date_time%hour
    345     IF ( read_status == 0 )  &
     346    ENDIF
     347    IF ( read_status == 0 )  THEN
    346348       READ( UNIT = date_time_str(15:16), IOSTAT = read_status, FMT = '(I2)'   )  date_time%minute
    347     IF ( read_status == 0 )  &
     349    ENDIF
     350    IF ( read_status == 0 )  THEN
    348351       READ( UNIT = date_time_str(18:19), IOSTAT = read_status, FMT = '(F2.0)' )  date_time%second
    349     IF ( read_status == 0 )  &
     352    ENDIF
     353    IF ( read_status == 0 )  THEN
    350354       READ( UNIT = date_time_str(21:23), IOSTAT = read_status, FMT = '(I3)'   )  date_time%zone
     355    ENDIF
    351356
    352357    IF ( read_status /= 0 )  THEN
    353        WRITE( message_string, * ) 'Error while converting date-time string. ' //  &
    354                                   'Please check format of date-time string: "' // &
    355                                   TRIM( date_time_str ) // '". ' //               &
     358       WRITE( message_string, * ) 'Error while converting date-time string. ' //                   &
     359                                  'Please check format of date-time string: "' //                  &
     360                                  TRIM( date_time_str ) // '". ' //                                &
    356361                                  'Format must be "YYYY-MM-DD hh:mm:ss ZZZ".'
    357362       CALL message( 'convert_string_to_date_time', 'PA0678', 2, 2, 0, 6, 0 )
     
    367372!
    368373!--    Shift time to UTC and set zone to UTC
    369        date_time = add_date_time( REAL( -1 * date_time%zone, KIND = wp ) &
    370                                   * seconds_per_hour,                    &
     374       date_time = add_date_time( REAL( -1 * date_time%zone, KIND = wp ) * seconds_per_hour,       &
    371375                                  date_time )
    372376       date_time%zone = 0_iwp
     
    401405    date_time%second_of_year = date_time%second_of_year + inc_seconds
    402406!
    403 !-- Check if year changes
     407!-- Check if year changes.
    404408!-- First, if year is reduced
    405409    DO WHILE ( date_time%second_of_year < 0.0_wp )
    406        date_time%year = date_time%year - 1_iwp
    407        date_time = update_leapyear_setting( date_time )
    408        seconds_per_year = REAL( date_time%days_per_year * seconds_per_day, KIND = wp )
     410       date_time%year           = date_time%year - 1_iwp
     411       date_time                = update_leapyear_setting( date_time )
     412       seconds_per_year         = REAL( date_time%days_per_year * seconds_per_day, KIND = wp )
    409413       date_time%second_of_year = date_time%second_of_year + seconds_per_year
    410414    ENDDO
     
    412416!-- Now, if year is increased
    413417    DO WHILE ( date_time%second_of_year > seconds_per_year )
    414        date_time%year = date_time%year + 1_iwp
    415        date_time = update_leapyear_setting( date_time )
     418       date_time%year           = date_time%year + 1_iwp
     419       date_time                = update_leapyear_setting( date_time )
    416420       date_time%second_of_year = date_time%second_of_year - seconds_per_year
    417        seconds_per_year = REAL( date_time%days_per_year * seconds_per_day, KIND = wp )
     421       seconds_per_year         = REAL( date_time%days_per_year * seconds_per_day, KIND = wp )
    418422    ENDDO
    419423!
    420424!-- Based on updated year and second_of_year, update month, day, hour, minute, second
    421425    DO  i = 1, months_per_year
    422        IF ( date_time%second_of_year < SUM( date_time%days_per_month(1:i) ) * seconds_per_day ) &
     426       IF ( date_time%second_of_year < SUM( date_time%days_per_month(1:i) ) * seconds_per_day )    &
    423427       THEN
    424428          date_time%month  = i
    425           seconds_left     = date_time%second_of_year                                &
    426                            - REAL( SUM( date_time%days_per_month(1:i-1) ), KIND=wp ) &
    427                            * seconds_per_day
     429          seconds_left     = date_time%second_of_year                                              &
     430                              - REAL( SUM( date_time%days_per_month(1:i-1) ), KIND=wp )            &
     431                              * seconds_per_day
    428432          date_time%day    = INT( seconds_left / seconds_per_day, KIND = iwp ) + 1_iwp
    429           seconds_left     = seconds_left &
    430                            - REAL( date_time%day - 1_iwp, KIND = wp ) * seconds_per_day
     433          seconds_left     = seconds_left                                                          &
     434                              - REAL( date_time%day - 1_iwp, KIND = wp ) * seconds_per_day
    431435          date_time%hour   = INT( seconds_left / seconds_per_hour, KIND = iwp )
    432436          seconds_left     = seconds_left - REAL( date_time%hour, KIND = wp ) * seconds_per_hour
     
    445449!> Return day of year of given date.
    446450!--------------------------------------------------------------------------------------------------!
    447  FUNCTION get_day_of_year( date_time ) RESULT( day_of_year )
     451 FUNCTION get_day_of_year( date_time )  RESULT( day_of_year )
    448452
    449453    INTEGER(iwp)                     ::  day_of_year         !< day of the year
     
    466470!> Return second of day of given time.
    467471!--------------------------------------------------------------------------------------------------!
    468  FUNCTION get_second_of_day( date_time ) RESULT( second_of_day )
     472 FUNCTION get_second_of_day( date_time )  RESULT( second_of_day )
    469473
    470474    REAL(wp)                         ::  second_of_day  !< second of the day
     
    473477
    474478
    475     second_of_day = date_time%second                                                            &
    476                   + REAL( ( date_time%hour * minutes_per_hour ) + date_time%minute, KIND = wp ) &
    477                   * seconds_per_minute
     479    second_of_day = date_time%second                                                               &
     480                     + REAL( ( date_time%hour * minutes_per_hour ) + date_time%minute, KIND = wp ) &
     481                     * seconds_per_minute
    478482
    479483 END FUNCTION get_second_of_day
     
    485489!> Return second of year of given date-time.
    486490!--------------------------------------------------------------------------------------------------!
    487  FUNCTION get_second_of_year( date_time ) RESULT( second_of_year )
     491 FUNCTION get_second_of_year( date_time )  RESULT( second_of_year )
    488492
    489493    REAL(wp)                         ::  second_of_year  !< second of the year
     
    492496
    493497
    494     second_of_year = get_second_of_day( date_time ) &
    495                    + REAL( get_day_of_year( date_time ) - 1_iwp, KIND = wp ) * seconds_per_day
     498    second_of_year = get_second_of_day( date_time )                                                &
     499                     + REAL( get_day_of_year( date_time ) - 1_iwp, KIND = wp ) * seconds_per_day
    496500
    497501 END FUNCTION get_second_of_year
     
    503507!> Return index of the day of the week of the given date-time.
    504508!--------------------------------------------------------------------------------------------------!
    505  FUNCTION get_day_of_week( date_time_in ) RESULT( day_of_week )
    506 
    507     INTEGER(iwp)                     ::  date_time_internal_reference_day_of_week  !< day of week of reference date
     509 FUNCTION get_day_of_week( date_time_in )  RESULT( day_of_week )
     510
    508511    INTEGER(iwp)                     ::  day_difference                            !< day between given date and reference
    509512    INTEGER(iwp)                     ::  day_of_week                               !< day of the week
     513    INTEGER(iwp)                     ::  date_time_internal_reference_day_of_week  !< day of week of reference date
    510514
    511515    TYPE(date_time_type), INTENT(IN) ::  date_time_in                              !< date of which to get the weekday
     
    548552    ENDIF
    549553!
    550 !-- Remove full weeks of day_difference and shift day_of_week of reference by
    551 !-- remaining days
     554!-- Remove full weeks of day_difference and shift day_of_week of reference by remaining days.
    552555    day_of_week = date_time_internal_reference_day_of_week + MOD( day_difference, days_per_week )
    553556
     
    570573!> Check if given year is a leap year and update days per month accordingly.
    571574!--------------------------------------------------------------------------------------------------!
    572  FUNCTION update_leapyear_setting( date_time_in ) RESULT( date_time_out )
     575 FUNCTION update_leapyear_setting( date_time_in )  RESULT( date_time_out )
    573576
    574577    TYPE(date_time_type), INTENT(IN) ::  date_time_in   !< input date-time
     
    593596! ------------
    594597!> Check if given date and time are valid. Returns 0 if all checks are passed.
    595 !> @todo Revise error message. ATM, gives only last errorneous value even if
    596 !>       multiple values violate the bounds.
    597 !--------------------------------------------------------------------------------------------------!
    598  FUNCTION check_date( date_time, date_time_str ) RESULT( error_code )
     598!> @todo Revise error message. ATM, gives only last errorneous value even if multiple values violate
     599!>       the bounds.
     600!--------------------------------------------------------------------------------------------------!
     601 FUNCTION check_date( date_time, date_time_str )  RESULT( error_code )
    599602
    600603
     
    612615!
    613616!-- Check date
    614     IF ( date_time%month < 1_iwp  .OR.     &
    615          date_time%month > months_per_year )  THEN
     617    IF ( date_time%month < 1_iwp  .OR.  date_time%month > months_per_year )  THEN
    616618       error_code = 2
    617619    ELSE
    618        IF ( date_time%day < 1_iwp  .OR.                               &
     620       IF ( date_time%day < 1_iwp  .OR.                                                            &
    619621            date_time%day > date_time%days_per_month(date_time%month) )  THEN
    620622          error_code = 3
     
    623625!
    624626!-- Check time
    625     IF ( date_time%hour < 0_iwp  .OR.   &
    626          date_time%hour > hours_per_day )  THEN
     627    IF ( date_time%hour < 0_iwp  .OR.  date_time%hour > hours_per_day )  THEN
    627628       error_code = 4
    628629    ELSE
    629         IF ( date_time%minute < 0_iwp  .OR.      &
    630              date_time%minute > minutes_per_hour )  THEN
     630        IF ( date_time%minute < 0_iwp  .OR.  date_time%minute > minutes_per_hour )  THEN
    631631           error_code = 5
    632632        ELSE
    633            IF ( date_time%second < 0.0_wp  .OR.        &
    634                 date_time%second >= seconds_per_minute )  THEN
     633           IF ( date_time%second < 0.0_wp  .OR.  date_time%second >= seconds_per_minute )  THEN
    635634              error_code = 6
    636635           ENDIF
     
    638637    ENDIF
    639638!
    640 !-- Check time zone
     639!-- Check time zone.
    641640!-- Bounds defined by maximum and minimum time zone present on earth
    642     IF ( date_time%zone < -12_iwp  .OR.  &
    643          date_time%zone > 14_iwp )  THEN
     641    IF ( date_time%zone < -12_iwp  .OR.  date_time%zone > 14_iwp )  THEN
    644642       error_code = 7
    645643    ENDIF
     
    647645!-- Raise error if any check is marked invalid
    648646    IF ( error_code /= 0 )  THEN
    649        WRITE( message_string, * ) 'Date-time values out of bounds: "' //                    &
    650                                   TRIM( error_str_list(error_code) ) //                     &
    651                                   '" is out of bounds. Please check date-time string: "' // &
    652                                   TRIM( date_time_str ) // '". ' //                         &
     647       WRITE( message_string, * ) 'Date-time values out of bounds: "' //                           &
     648                                  TRIM( error_str_list(error_code) ) //                            &
     649                                  '" is out of bounds. Please check date-time string: "' //        &
     650                                  TRIM( date_time_str ) // '". ' //                                &
    653651                                  'Format must be "YYYY-MM-DD hh:mm:ss ZZZ".'
    654652       CALL message( 'check_date', 'PA0679', 2, 2, 0, 6, 0 )
  • palm/trunk/SOURCE/parin.f90

    r4783 r4797  
    11!> @file parin.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/>.
     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/>.
    1615!
    1716! Copyright 1997-2020 Leibniz Universitaet Hannover
    18 !------------------------------------------------------------------------------!
     17!--------------------------------------------------------------------------------------------------!
    1918!
    2019! Current revisions:
     
    2524! -----------------
    2625! $Id$
     26! file re-formatted to follow the PALM coding standard
     27!
     28! 4783 2020-11-13 13:58:45Z raasch
    2729! bugfix for reading restart data with MPI-I/O (does not work with blockwise I/O)
    2830!
     
    7678!
    7779! 4022 2019-06-12 11:52:39Z suehring
    78 ! Change default top boundary condition for pressure to Neumann in offline
    79 ! nesting case
     80! Change default top boundary condition for pressure to Neumann in offline nesting case
    8081!
    8182! 4017 2019-06-06 12:16:46Z schwenkel
     
    8384!
    8485! 3885 2019-04-11 11:29:34Z kanani
    85 ! Changes related to global restructuring of location messages and introduction
    86 ! of additional debug messages
     86! Changes related to global restructuring of location messages and introduction of additional debug
     87! messages
    8788!
    8889! 3806 2019-03-21 12:45:50Z raasch
     
    107108!>
    108109!> @todo: Revise max_pr_cs (profiles for chemistry)
    109 !------------------------------------------------------------------------------!
     110!--------------------------------------------------------------------------------------------------!
    110111 SUBROUTINE parin
    111112
    112113
    113     USE arrays_3d,                                                             &
    114         ONLY:  pt_init, q_init, ref_state, s_init, sa_init,                    &
    115                ug, u_init, v_init, vg
     114    USE arrays_3d,                                                                                 &
     115        ONLY:  pt_init, q_init, ref_state, s_init, sa_init, ug, u_init, v_init, vg
    116116
    117117    USE chem_modules
     
    119119    USE control_parameters
    120120
    121     USE cpulog,                                                                &
     121    USE cpulog,                                                                                    &
    122122        ONLY:  cpu_log_barrierwait
    123123
    124     USE grid_variables,                                                        &
     124    USE grid_variables,                                                                            &
    125125        ONLY:  dx, dy
    126126
    127     USE indices,                                                               &
     127    USE indices,                                                                                   &
    128128        ONLY:  nx, ny, nz
    129129
    130130    USE kinds
    131131
    132     USE model_1d_mod,                                                          &
     132    USE model_1d_mod,                                                                              &
    133133        ONLY:  damp_level_1d, dt_pr_1d, dt_run_control_1d, end_time_1d
    134134
    135     USE module_interface,                                                      &
     135    USE module_interface,                                                                          &
    136136        ONLY:  module_interface_parin
    137137
    138     USE netcdf_interface,                                                      &
     138    USE netcdf_interface,                                                                          &
    139139        ONLY:  netcdf_data_format, netcdf_deflate, netcdf_precision
    140140
    141141    USE pegrid
    142142
    143     USE pmc_interface,                                                         &
     143    USE pmc_interface,                                                                             &
    144144        ONLY:  nested_run, nesting_mode
    145145
    146     USE profil_parameter,                                                      &
     146    USE profil_parameter,                                                                          &
    147147        ONLY:  cross_profiles, profile_columns, profile_rows
    148148
    149     USE progress_bar,                                                          &
     149    USE progress_bar,                                                                              &
    150150        ONLY :  progress_bar_disabled
    151151
    152     USE read_restart_data_mod,                                                 &
     152    USE read_restart_data_mod,                                                                     &
    153153        ONLY:  rrd_global
    154154
    155     USE statistics,                                                            &
     155    USE statistics,                                                                                &
    156156        ONLY:  hom, hom_sum, pr_palm, statistic_regions
    157157
    158     USE turbulence_closure_mod,                                                &
     158    USE turbulence_closure_mod,                                                                    &
    159159        ONLY:  rans_const_c, rans_const_sigma
    160160
     
    169169    INTEGER(iwp) ::  ioerr          !< error flag for open/read/write
    170170
    171     NAMELIST /inipar/  alpha_surface, approximation, bc_e_b,     &
    172                        bc_lr, bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b, &
    173              bc_q_t,bc_s_b, bc_s_t, bc_uv_b, bc_uv_t,                 &
    174              building_height, building_length_x,          &
    175              building_length_y, building_wall_left, building_wall_south,       &
    176              calc_soil_moisture_during_spinup,                                 &
    177              call_psolver_at_all_substeps,  &
    178              canyon_height,                                                    &
    179              canyon_width_x, canyon_width_y, canyon_wall_left,                 &
    180              canyon_wall_south, cfl_factor, check_realistic_q, cloud_droplets, &
    181              collective_wait, complex_terrain,           &
    182              conserve_volume_flow,                                             &
    183              conserve_volume_flow_mode, constant_flux_layer,                   &
    184              coupling_start_time,             &
    185              cycle_mg, damp_level_1d,                                          &
    186              data_output_during_spinup,                                        &
    187              origin_date_time,                                                 &
    188              dissipation_1d,                                                   &
    189              dp_external, dp_level_b, dp_smooth, dpdxy,    &
    190              dt, dt_pr_1d, dt_run_control_1d, dt_spinup, dx, dy, dz, dz_max,   &
    191              dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
    192              dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
    193              e_min, fft_method, flux_input_mode, flux_output_mode,             &
    194              galilei_transformation, humidity,                                 &
    195              inflow_damping_height, inflow_damping_width,                      &
    196              inflow_disturbance_begin, inflow_disturbance_end,                 &
    197              initializing_actions, km_constant,                                &
    198              large_scale_forcing, large_scale_subsidence, latitude,            &
    199              longitude,                                 &
    200              loop_optimization, lsf_exception, masking_method, mg_cycles,      &
    201              mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
    202              monotonic_limiter_z,                                              &
    203              netcdf_precision, neutral, ngsrb,                                 &
    204              nsor, nsor_ini, nudging, nx, ny, nz, ocean_mode, omega,           &
    205              omega_sor, outflow_source_plane, passive_scalar,                  &
    206              prandtl_number, psolver, pt_damping_factor,  pt_damping_width,    &
    207              pt_reference, pt_surface, pt_surface_heating_rate,                &
    208              pt_surface_initial_change, pt_vertical_gradient,                  &
    209              pt_vertical_gradient_level, q_surface, q_surface_initial_change,  &
    210              q_vertical_gradient, q_vertical_gradient_level,                   &
    211              random_generator, random_heatflux, rans_const_c, rans_const_sigma,&
    212              rayleigh_damping_factor, rayleigh_damping_height,                 &
    213              recycling_method_for_thermodynamic_quantities, recycling_width,   &
    214              reference_state, residual_limit,                                  &
    215              rotation_angle,                                                   &
    216              roughness_length,                                                 &
    217              scalar_advec,   &
    218              scalar_rayleigh_damping,                              &
    219              spinup_time, spinup_pt_amplitude, spinup_pt_mean,                 &
    220              statistic_regions, subs_vertical_gradient,                        &
    221              subs_vertical_gradient_level, surface_heatflux, surface_pressure, &
    222              surface_scalarflux, surface_waterflux,                            &
    223              s_surface, s_surface_initial_change, s_vertical_gradient,         &
    224              s_vertical_gradient_level, timestep_scheme,                       &
    225              topography, topography_grid_convention, top_heatflux,             &
    226              top_momentumflux_u, top_momentumflux_v,                           &
    227              top_scalarflux, transpose_compute_overlap,                        &
    228              tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,     &
    229              tunnel_wall_depth, turbulence_closure,                            &
    230              turbulent_inflow, turbulent_outflow,                              &
    231              use_subsidence_tendencies, ug_surface, ug_vertical_gradient,      &
    232              use_fixed_date, use_fixed_time,                                   &
    233              use_free_convection_scaling,                                      &
    234              ug_vertical_gradient_level, use_surface_fluxes, use_cmax,         &
    235              use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke,      &
    236              uv_heights, u_bulk, u_profile, vdi_checks, vg_surface,            &
    237              vg_vertical_gradient,  &
    238              vg_vertical_gradient_level, v_bulk, v_profile,&
    239              wall_adjustment, wall_heatflux, wall_humidityflux,                &
    240              wall_scalarflux, y_shift, zeta_max, zeta_min,  &
    241              z0h_factor
    242 
    243     NAMELIST /initialization_parameters/  alpha_surface,                       &
    244              approximation, bc_e_b,                                            &
    245              bc_lr, bc_ns, bc_p_b, bc_p_t, bc_pt_b, bc_pt_t, bc_q_b,           &
    246              bc_q_t,bc_s_b, bc_s_t, bc_uv_b, bc_uv_t,                          &
    247              building_height, building_length_x,                               &
    248              building_length_y, building_wall_left, building_wall_south,       &
    249              calc_soil_moisture_during_spinup,                                 &
    250              call_psolver_at_all_substeps,                                     &
    251              canyon_height,                                                    &
    252              canyon_width_x, canyon_width_y, canyon_wall_left,                 &
    253              canyon_wall_south, cfl_factor, check_realistic_q, cloud_droplets, &
    254              collective_wait, complex_terrain,                                 &
    255              conserve_volume_flow,                                             &
    256              conserve_volume_flow_mode, constant_flux_layer,                   &
    257              coupling_start_time,                                              &
    258              cycle_mg, damp_level_1d,                                          &
    259              data_output_during_spinup,                                        &
    260              origin_date_time,                                                 &
    261              dissipation_1d,                                                   &
    262              dp_external, dp_level_b, dp_smooth, dpdxy,                        &
    263              dt, dt_pr_1d, dt_run_control_1d, dt_spinup, dx, dy, dz, dz_max,   &
    264              dz_stretch_factor, dz_stretch_level, dz_stretch_level_start,      &
    265              dz_stretch_level_end, end_time_1d, ensemble_member_nr, e_init,    &
    266              e_min, fft_method, flux_input_mode, flux_output_mode,             &
    267              galilei_transformation, humidity,                                 &
    268              inflow_damping_height, inflow_damping_width,                      &
    269              inflow_disturbance_begin, inflow_disturbance_end,                 &
    270              initializing_actions, km_constant,                                &
    271              large_scale_forcing, large_scale_subsidence, latitude,            &
    272              longitude,                                                        &
    273              loop_optimization, lsf_exception, masking_method, mg_cycles,      &
    274              mg_switch_to_pe0_level, mixing_length_1d, momentum_advec,         &
    275              monotonic_limiter_z,                                              &
    276              netcdf_precision, neutral, ngsrb,                                 &
    277              nsor, nsor_ini, nudging, nx, ny, nz, ocean_mode, omega,           &
    278              omega_sor, outflow_source_plane, passive_scalar,                  &
    279              prandtl_number, psolver, pt_damping_factor, pt_damping_width,     &
    280              pt_surface_heating_rate, pt_reference, pt_surface,                &
    281              pt_surface_initial_change, pt_vertical_gradient,                  &
    282              pt_vertical_gradient_level, q_surface, q_surface_initial_change,  &
    283              q_vertical_gradient, q_vertical_gradient_level,                   &
    284              random_generator, random_heatflux, rans_const_c, rans_const_sigma,&
    285              rayleigh_damping_factor, rayleigh_damping_height,                 &
    286              recycling_method_for_thermodynamic_quantities, recycling_width,   &
    287              reference_state, residual_limit,                                  &
    288              restart_data_format, restart_data_format_input, restart_data_format_output,           &
    289              rotation_angle,                                                   &
    290              roughness_length, scalar_advec,                                   &
    291              scalar_rayleigh_damping,                                          &
    292              spinup_time, spinup_pt_amplitude, spinup_pt_mean,                 &
    293              statistic_regions, subs_vertical_gradient,                        &
    294              subs_vertical_gradient_level, surface_heatflux, surface_pressure, &
    295              surface_scalarflux, surface_waterflux,                            &
    296              s_surface, s_surface_initial_change, s_vertical_gradient,         &
    297              s_vertical_gradient_level, timestep_scheme,                       &
    298              topography, topography_grid_convention, top_heatflux,             &
    299              top_momentumflux_u, top_momentumflux_v,                           &
    300              top_scalarflux, transpose_compute_overlap,                        &
    301              tunnel_height, tunnel_length, tunnel_width_x, tunnel_width_y,     &
    302              tunnel_wall_depth, turbulence_closure,                            &
    303              turbulent_inflow, turbulent_outflow,                              &
    304              use_subsidence_tendencies, ug_surface, ug_vertical_gradient,      &
    305              ug_vertical_gradient_level, use_surface_fluxes, use_cmax,         &
    306              use_top_fluxes, use_ug_for_galilei_tr, use_upstream_for_tke,      &
    307              use_fixed_date, use_fixed_time,                                   &
    308              use_free_convection_scaling,                                      &
    309              uv_heights, u_bulk, u_profile, vdi_checks,                        &
    310              vg_surface, vg_vertical_gradient,  &
    311              vg_vertical_gradient_level, v_bulk, v_profile,                    &
    312              wall_adjustment, wall_heatflux, wall_humidityflux,                &
    313              wall_scalarflux, y_shift, zeta_max, zeta_min, z0h_factor
    314 
    315     NAMELIST /d3par/  averaging_interval, averaging_interval_pr,               &
    316              cpu_log_barrierwait, create_disturbances,                         &
    317              cross_profiles, data_output, data_output_masks,                   &
    318              data_output_pr, data_output_2d_on_each_pe,                        &
    319              debug_output,                                                     &
    320              debug_output_timestep,                                            &
    321              disturbance_amplitude,                                            &
    322              disturbance_energy_limit, disturbance_level_b,                    &
    323              disturbance_level_t, do2d_at_begin, do3d_at_begin,                &
    324              dt, dt_averaging_input, dt_averaging_input_pr,                    &
    325              dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,       &
    326              dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,         &
    327              dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,              &
    328              dt_run_control,end_time, force_print_header, mask_k_over_surface, &
    329              mask_scale_x,                                                     &
    330              mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop,  &
    331              mask_y_loop, mask_z_loop, netcdf_data_format, netcdf_deflate,     &
    332              normalizing_region, npex, npey, nz_do3d,                          &
    333              profile_columns, profile_rows,     &
    334              restart_time, section_xy, section_xz, section_yz,                 &
    335              skip_time_data_output, skip_time_data_output_av, skip_time_dopr,  &
    336              skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz,          &
    337              skip_time_do3d, skip_time_domask, synchronous_exchange,           &
    338              termination_time_needed
    339 
    340     NAMELIST /runtime_parameters/  averaging_interval, averaging_interval_pr,  &
    341              cpu_log_barrierwait, create_disturbances,                         &
    342              cross_profiles, data_output, data_output_masks,                   &
    343              data_output_pr, data_output_2d_on_each_pe,                        &
    344              debug_output,                                                     &
    345              debug_output_timestep,                                            &
    346              disturbance_amplitude,                                            &
    347              disturbance_energy_limit, disturbance_level_b,                    &
    348              disturbance_level_t, do2d_at_begin, do3d_at_begin,                &
    349              dt, dt_averaging_input, dt_averaging_input_pr,                    &
    350              dt_coupling, dt_data_output, dt_data_output_av, dt_disturb,       &
    351              dt_domask, dt_dopr, dt_dopr_listing, dt_dots, dt_do2d_xy,         &
    352              dt_do2d_xz, dt_do2d_yz, dt_do3d, dt_max, dt_restart,              &
    353              dt_run_control,end_time, force_print_header, mask_k_over_surface, &
    354              mask_scale_x,                                                     &
    355              mask_scale_y, mask_scale_z, mask_x, mask_y, mask_z, mask_x_loop,  &
    356              mask_y_loop, mask_z_loop, netcdf_data_format, netcdf_deflate,     &
    357              normalizing_region, npex, npey, nz_do3d,                          &
    358              profile_columns, profile_rows,     &
    359              restart_time, section_xy, section_xz, section_yz,                 &
    360              restart_data_format, restart_data_format_input, restart_data_format_output,           &
    361              skip_time_data_output, skip_time_data_output_av, skip_time_dopr,  &
    362              skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz,          &
    363              skip_time_do3d, skip_time_domask, synchronous_exchange,           &
    364              termination_time_needed
    365 
    366     NAMELIST /envpar/  progress_bar_disabled, host,                            &
    367                        maximum_cpu_time_allowed, maximum_parallel_io_streams,  &
    368                        read_svf, revision, run_identifier, tasks_per_node,     &
    369                        write_binary, write_svf
    370 
    371 !
    372 !-- First read values of environment variables (this NAMELIST file is
    373 !-- generated by palmrun)
     171    NAMELIST /inipar/  alpha_surface,                                                              &
     172                       approximation,                                                              &
     173                       bc_e_b,                                                                     &
     174                       bc_lr,                                                                      &
     175                       bc_ns,                                                                      &
     176                       bc_p_b,                                                                     &
     177                       bc_p_t,                                                                     &
     178                       bc_pt_b,                                                                    &
     179                       bc_pt_t,                                                                    &
     180                       bc_q_b,                                                                     &
     181                       bc_q_t,                                                                     &
     182                       bc_s_b,                                                                     &
     183                       bc_s_t,                                                                     &
     184                       bc_uv_b,                                                                    &
     185                       bc_uv_t,                                                                    &
     186                       building_height,                                                            &
     187                       building_length_x,                                                          &
     188                       building_length_y,                                                          &
     189                       building_wall_left,                                                         &
     190                       building_wall_south,                                                        &
     191                       calc_soil_moisture_during_spinup,                                           &
     192                       call_psolver_at_all_substeps,                                               &
     193                       canyon_height,                                                              &
     194                       canyon_wall_left,                                                           &
     195                       canyon_wall_south,                                                          &
     196                       canyon_width_x,                                                             &
     197                       canyon_width_y,                                                             &
     198                       cfl_factor,                                                                 &
     199                       check_realistic_q,                                                          &
     200                       cloud_droplets,                                                             &
     201                       collective_wait,                                                            &
     202                       complex_terrain,                                                            &
     203                       conserve_volume_flow,                                                       &
     204                       conserve_volume_flow_mode,                                                  &
     205                       constant_flux_layer,                                                        &
     206                       coupling_start_time,                                                        &
     207                       cycle_mg,                                                                   &
     208                       damp_level_1d,                                                              &
     209                       data_output_during_spinup,                                                  &
     210                       dissipation_1d,                                                             &
     211                       dp_external,                                                                &
     212                       dp_level_b,                                                                 &
     213                       dp_smooth,                                                                  &
     214                       dpdxy,                                                                      &
     215                       dt,                                                                         &
     216                       dt_pr_1d,                                                                   &
     217                       dt_run_control_1d,                                                          &
     218                       dt_spinup,                                                                  &
     219                       dx,                                                                         &
     220                       dy,                                                                         &
     221                       dz,                                                                         &
     222                       dz_max,                                                                     &
     223                       dz_stretch_factor,                                                          &
     224                       dz_stretch_level,                                                           &
     225                       dz_stretch_level_end,                                                       &
     226                       dz_stretch_level_start,                                                     &
     227                       e_init,                                                                     &
     228                       e_min,                                                                      &
     229                       end_time_1d,                                                                &
     230                       ensemble_member_nr,                                                         &
     231                       fft_method,                                                                 &
     232                       flux_input_mode,                                                            &
     233                       flux_output_mode,                                                           &
     234                       galilei_transformation,                                                     &
     235                       humidity,                                                                   &
     236                       inflow_damping_height,                                                      &
     237                       inflow_damping_width,                                                       &
     238                       inflow_disturbance_begin,                                                   &
     239                       inflow_disturbance_end,                                                     &
     240                       initializing_actions,                                                       &
     241                       km_constant,                                                                &
     242                       large_scale_forcing,                                                        &
     243                       large_scale_subsidence,                                                     &
     244                       latitude,                                                                   &
     245                       longitude,                                                                  &
     246                       loop_optimization,                                                          &
     247                       lsf_exception,                                                              &
     248                       masking_method,                                                             &
     249                       mg_cycles,                                                                  &
     250                       mg_switch_to_pe0_level,                                                     &
     251                       mixing_length_1d,                                                           &
     252                       momentum_advec,                                                             &
     253                       monotonic_limiter_z,                                                        &
     254                       netcdf_precision,                                                           &
     255                       neutral,                                                                    &
     256                       ngsrb,                                                                      &
     257                       nsor,                                                                       &
     258                       nsor_ini,                                                                   &
     259                       nudging,                                                                    &
     260                       nx,                                                                         &
     261                       ny,                                                                         &
     262                       nz,                                                                         &
     263                       ocean_mode,                                                                 &
     264                       omega,                                                                      &
     265                       omega_sor,                                                                  &
     266                       origin_date_time,                                                           &
     267                       outflow_source_plane,                                                       &
     268                       passive_scalar,                                                             &
     269                       prandtl_number,                                                             &
     270                       psolver,                                                                    &
     271                       pt_damping_factor,                                                          &
     272                       pt_damping_width,                                                           &
     273                       pt_reference,                                                               &
     274                       pt_surface,                                                                 &
     275                       pt_surface_heating_rate,                                                    &
     276                       pt_surface_initial_change,                                                  &
     277                       pt_vertical_gradient,                                                       &
     278                       pt_vertical_gradient_level,                                                 &
     279                       q_surface,                                                                  &
     280                       q_surface_initial_change,                                                   &
     281                       q_vertical_gradient,                                                        &
     282                       q_vertical_gradient_level,                                                  &
     283                       random_generator,                                                           &
     284                       random_heatflux,                                                            &
     285                       rans_const_c,                                                               &
     286                       rans_const_sigma,                                                           &
     287                       rayleigh_damping_factor,                                                    &
     288                       rayleigh_damping_height,                                                    &
     289                       recycling_method_for_thermodynamic_quantities,                              &
     290                       recycling_width,                                                            &
     291                       reference_state,                                                            &
     292                       residual_limit,                                                             &
     293                       rotation_angle,                                                             &
     294                       roughness_length,                                                           &
     295                       scalar_advec,                                                               &
     296                       scalar_rayleigh_damping,                                                    &
     297                       spinup_time,                                                                &
     298                       spinup_pt_amplitude,                                                        &
     299                       spinup_pt_mean,                                                             &
     300                       statistic_regions,                                                          &
     301                       subs_vertical_gradient,                                                     &
     302                       subs_vertical_gradient_level,                                               &
     303                       surface_heatflux,                                                           &
     304                       surface_pressure,                                                           &
     305                       surface_scalarflux,                                                         &
     306                       surface_waterflux,                                                          &
     307                       s_surface,                                                                  &
     308                       s_surface_initial_change,                                                   &
     309                       s_vertical_gradient,                                                        &
     310                       s_vertical_gradient_level,                                                  &
     311                       timestep_scheme,                                                            &
     312                       topography,                                                                 &
     313                       topography_grid_convention,                                                 &
     314                       top_heatflux,                                                               &
     315                       top_momentumflux_u,                                                         &
     316                       top_momentumflux_v,                                                         &
     317                       top_scalarflux,                                                             &
     318                       transpose_compute_overlap,                                                  &
     319                       tunnel_height,                                                              &
     320                       tunnel_length,                                                              &
     321                       tunnel_wall_depth,                                                          &
     322                       tunnel_width_x,                                                             &
     323                       tunnel_width_y,                                                             &
     324                       turbulence_closure,                                                         &
     325                       turbulent_inflow,                                                           &
     326                       turbulent_outflow,                                                          &
     327                       u_bulk,                                                                     &
     328                       u_profile,                                                                  &
     329                       ug_surface,                                                                 &
     330                       ug_vertical_gradient,                                                       &
     331                       ug_vertical_gradient_level,                                                 &
     332                       use_cmax,                                                                   &
     333                       use_fixed_date,                                                             &
     334                       use_fixed_time,                                                             &
     335                       use_free_convection_scaling,                                                &
     336                       use_ug_for_galilei_tr,                                                      &
     337                       use_subsidence_tendencies,                                                  &
     338                       use_surface_fluxes,                                                         &
     339                       use_top_fluxes,                                                             &
     340                       use_upstream_for_tke,                                                       &
     341                       uv_heights,                                                                 &
     342                       v_bulk,                                                                     &
     343                       v_profile,                                                                  &
     344                       vdi_checks,                                                                 &
     345                       vg_surface,                                                                 &
     346                       vg_vertical_gradient,                                                       &
     347                       vg_vertical_gradient_level,                                                 &
     348                       wall_adjustment,                                                            &
     349                       wall_heatflux,                                                              &
     350                       wall_humidityflux,                                                          &
     351                       wall_scalarflux,                                                            &
     352                       y_shift,                                                                    &
     353                       zeta_max,                                                                   &
     354                       zeta_min,                                                                   &
     355                       z0h_factor
     356
     357    NAMELIST /initialization_parameters/  alpha_surface,                                           &
     358                                          approximation,                                           &
     359                                          bc_e_b,                                                  &
     360                                          bc_lr,                                                   &
     361                                          bc_ns,                                                   &
     362                                          bc_p_b,                                                  &
     363                                          bc_p_t,                                                  &
     364                                          bc_pt_b,                                                 &
     365                                          bc_pt_t,                                                 &
     366                                          bc_q_b,                                                  &
     367                                          bc_q_t,                                                  &
     368                                          bc_s_b,                                                  &
     369                                          bc_s_t,                                                  &
     370                                          bc_uv_b,                                                 &
     371                                          bc_uv_t,                                                 &
     372                                          building_height,                                         &
     373                                          building_length_x,                                       &
     374                                          building_length_y,                                       &
     375                                          building_wall_left,                                      &
     376                                          building_wall_south,                                     &
     377                                          calc_soil_moisture_during_spinup,                        &
     378                                          call_psolver_at_all_substeps,                            &
     379                                          canyon_height,                                           &
     380                                          canyon_wall_left,                                        &
     381                                          canyon_wall_south,                                       &
     382                                          canyon_width_x,                                          &
     383                                          canyon_width_y,                                          &
     384                                          cfl_factor,                                              &
     385                                          check_realistic_q,                                       &
     386                                          cloud_droplets,                                          &
     387                                          collective_wait,                                         &
     388                                          complex_terrain,                                         &
     389                                          conserve_volume_flow,                                    &
     390                                          conserve_volume_flow_mode,                               &
     391                                          constant_flux_layer,                                     &
     392                                          coupling_start_time,                                     &
     393                                          cycle_mg,                                                &
     394                                          damp_level_1d,                                           &
     395                                          data_output_during_spinup,                               &
     396                                          dissipation_1d,                                          &
     397                                          dp_external,                                             &
     398                                          dp_level_b,                                              &
     399                                          dp_smooth, dpdxy,                                        &
     400                                          dt,                                                      &
     401                                          dt_pr_1d,                                                &
     402                                          dt_run_control_1d,                                       &
     403                                          dt_spinup,                                               &
     404                                          dx,                                                      &
     405                                          dy,                                                      &
     406                                          dz,                                                      &
     407                                          dz_max,                                                  &
     408                                          dz_stretch_factor,                                       &
     409                                          dz_stretch_level,                                        &
     410                                          dz_stretch_level_start,                                  &
     411                                          dz_stretch_level_end,                                    &
     412                                          e_init,                                                  &
     413                                          e_min,                                                   &
     414                                          end_time_1d,                                             &
     415                                          ensemble_member_nr,                                      &
     416                                          fft_method,                                              &
     417                                          flux_input_mode,                                         &
     418                                          flux_output_mode,                                        &
     419                                          galilei_transformation,                                  &
     420                                          humidity,                                                &
     421                                          inflow_damping_height,                                   &
     422                                          inflow_damping_width,                                    &
     423                                          inflow_disturbance_begin,                                &
     424                                          inflow_disturbance_end,                                  &
     425                                          initializing_actions,                                    &
     426                                          km_constant,                                             &
     427                                          large_scale_forcing,                                     &
     428                                          large_scale_subsidence,                                  &
     429                                          latitude,                                                &
     430                                          longitude,                                               &
     431                                          loop_optimization,                                       &
     432                                          lsf_exception,                                           &
     433                                          masking_method,                                          &
     434                                          mg_cycles,                                               &
     435                                          mg_switch_to_pe0_level,                                  &
     436                                          mixing_length_1d,                                        &
     437                                          momentum_advec,                                          &
     438                                          monotonic_limiter_z,                                     &
     439                                          netcdf_precision,                                        &
     440                                          neutral,                                                 &
     441                                          ngsrb,                                                   &
     442                                          nsor,                                                    &
     443                                          nsor_ini,                                                &
     444                                          nudging,                                                 &
     445                                          nx,                                                      &
     446                                          ny,                                                      &
     447                                          nz,                                                      &
     448                                          ocean_mode,                                              &
     449                                          omega,                                                   &
     450                                          omega_sor,                                               &
     451                                          origin_date_time,                                        &
     452                                          outflow_source_plane,                                    &
     453                                          passive_scalar,                                          &
     454                                          prandtl_number,                                          &
     455                                          psolver,                                                 &
     456                                          pt_damping_factor,                                       &
     457                                          pt_damping_width,                                        &
     458                                          pt_reference, pt_surface,                                &
     459                                          pt_surface_heating_rate,                                 &
     460                                          pt_surface_initial_change,                               &
     461                                          pt_vertical_gradient,                                    &
     462                                          pt_vertical_gradient_level,                              &
     463                                          q_surface,                                               &
     464                                          q_surface_initial_change,                                &
     465                                          q_vertical_gradient,                                     &
     466                                          q_vertical_gradient_level,                               &
     467                                          random_generator,                                        &
     468                                          random_heatflux,                                         &
     469                                          rans_const_c,                                            &
     470                                          rans_const_sigma,                                        &
     471                                          rayleigh_damping_factor,                                 &
     472                                          rayleigh_damping_height,                                 &
     473                                          recycling_method_for_thermodynamic_quantities,           &
     474                                          recycling_width,                                         &
     475                                          reference_state,                                         &
     476                                          residual_limit,                                          &
     477                                          restart_data_format,                                     &
     478                                          restart_data_format_input,                               &
     479                                          restart_data_format_output,                              &
     480                                          rotation_angle,                                          &
     481                                          roughness_length,                                        &
     482                                          s_surface,                                               &
     483                                          s_surface_initial_change,                                &
     484                                          s_vertical_gradient,                                     &
     485                                          s_vertical_gradient_level,                               &
     486                                          scalar_advec,                                            &
     487                                          scalar_rayleigh_damping,                                 &
     488                                          spinup_time,                                             &
     489                                          spinup_pt_amplitude,                                     &
     490                                          spinup_pt_mean,                                          &
     491                                          statistic_regions,                                       &
     492                                          subs_vertical_gradient,                                  &
     493                                          subs_vertical_gradient_level,                            &
     494                                          surface_heatflux,                                        &
     495                                          surface_pressure,                                        &
     496                                          surface_scalarflux,                                      &
     497                                          surface_waterflux,                                       &
     498                                          timestep_scheme,                                         &
     499                                          topography,                                              &
     500                                          topography_grid_convention,                              &
     501                                          top_heatflux,                                            &
     502                                          top_momentumflux_u,                                      &
     503                                          top_momentumflux_v,                                      &
     504                                          top_scalarflux,                                          &
     505                                          transpose_compute_overlap,                               &
     506                                          tunnel_height,                                           &
     507                                          tunnel_length,                                           &
     508                                          tunnel_wall_depth,                                       &
     509                                          tunnel_width_x,                                          &
     510                                          tunnel_width_y,                                          &
     511                                          turbulence_closure,                                      &
     512                                          turbulent_inflow,                                        &
     513                                          turbulent_outflow,                                       &
     514                                          u_bulk,                                                  &
     515                                          u_profile,                                               &
     516                                          ug_surface,                                              &
     517                                          ug_vertical_gradient,                                    &
     518                                          ug_vertical_gradient_level,                              &
     519                                          use_fixed_date,                                          &
     520                                          use_fixed_time,                                          &
     521                                          use_free_convection_scaling,                             &
     522                                          use_ug_for_galilei_tr,                                   &
     523                                          use_subsidence_tendencies,                               &
     524                                          use_surface_fluxes, use_cmax,                            &
     525                                          use_top_fluxes,                                          &
     526                                          use_upstream_for_tke,                                    &
     527                                          uv_heights,                                              &
     528                                          v_bulk,                                                  &
     529                                          v_profile,                                               &
     530                                          vdi_checks,                                              &
     531                                          vg_surface,                                              &
     532                                          vg_vertical_gradient,                                    &
     533                                          vg_vertical_gradient_level,                              &
     534                                          wall_adjustment,                                         &
     535                                          wall_heatflux,                                           &
     536                                          wall_humidityflux,                                       &
     537                                          wall_scalarflux,                                         &
     538                                          y_shift,                                                 &
     539                                          zeta_max,                                                &
     540                                          zeta_min,                                                &
     541                                          z0h_factor
     542
     543    NAMELIST /d3par/  averaging_interval,                                                          &
     544                      averaging_interval_pr,                                                       &
     545                      cpu_log_barrierwait,                                                         &
     546                      create_disturbances,                                                         &
     547                      cross_profiles,                                                              &
     548                      data_output,                                                                 &
     549                      data_output_2d_on_each_pe,                                                   &
     550                      data_output_masks,                                                           &
     551                      data_output_pr,                                                              &
     552                      debug_output,                                                                &
     553                      debug_output_timestep,                                                       &
     554                      disturbance_amplitude,                                                       &
     555                      disturbance_energy_limit,                                                    &
     556                      disturbance_level_b,                                                         &
     557                      disturbance_level_t,                                                         &
     558                      do2d_at_begin,                                                               &
     559                      do3d_at_begin,                                                               &
     560                      dt,                                                                          &
     561                      dt_averaging_input,                                                          &
     562                      dt_averaging_input_pr,                                                       &
     563                      dt_coupling,                                                                 &
     564                      dt_data_output,                                                              &
     565                      dt_data_output_av,                                                           &
     566                      dt_disturb,                                                                  &
     567                      dt_domask,                                                                   &
     568                      dt_dopr,                                                                     &
     569                      dt_dopr_listing,                                                             &
     570                      dt_dots,                                                                     &
     571                      dt_do2d_xy,                                                                  &
     572                      dt_do2d_xz,                                                                  &
     573                      dt_do2d_yz,                                                                  &
     574                      dt_do3d,                                                                     &
     575                      dt_max,                                                                      &
     576                      dt_restart,                                                                  &
     577                      dt_run_control,                                                              &
     578                      end_time,                                                                    &
     579                      force_print_header,                                                          &
     580                      mask_k_over_surface,                                                         &
     581                      mask_scale_x,                                                                &
     582                      mask_scale_y,                                                                &
     583                      mask_scale_z,                                                                &
     584                      mask_x,                                                                      &
     585                      mask_y,                                                                      &
     586                      mask_z,                                                                      &
     587                      mask_x_loop,                                                                 &
     588                      mask_y_loop,                                                                 &
     589                      mask_z_loop,                                                                 &
     590                      netcdf_data_format,                                                          &
     591                      netcdf_deflate,                                                              &
     592                      normalizing_region,                                                          &
     593                      npex,                                                                        &
     594                      npey,                                                                        &
     595                      nz_do3d,                                                                     &
     596                      profile_columns,                                                             &
     597                      profile_rows,                                                                &
     598                      restart_time,                                                                &
     599                      section_xy,                                                                  &
     600                      section_xz,                                                                  &
     601                      section_yz,                                                                  &
     602                      skip_time_data_output,                                                       &
     603                      skip_time_data_output_av,                                                    &
     604                      skip_time_dopr,                                                              &
     605                      skip_time_do2d_xy,                                                           &
     606                      skip_time_do2d_xz,                                                           &
     607                      skip_time_do2d_yz,                                                           &
     608                      skip_time_do3d,                                                              &
     609                      skip_time_domask,                                                            &
     610                      synchronous_exchange,                                                        &
     611                      termination_time_needed
     612
     613    NAMELIST /runtime_parameters/  averaging_interval,                                             &
     614                                   averaging_interval_pr,                                          &
     615                                   cpu_log_barrierwait,                                            &
     616                                   create_disturbances,                                            &
     617                                   cross_profiles,                                                 &
     618                                   data_output,                                                    &
     619                                   data_output_2d_on_each_pe,                                      &
     620                                   data_output_masks,                                              &
     621                                   data_output_pr,                                                 &
     622                                   debug_output,                                                   &
     623                                   debug_output_timestep,                                          &
     624                                   disturbance_amplitude,                                          &
     625                                   disturbance_energy_limit,                                       &
     626                                   disturbance_level_b,                                            &
     627                                   disturbance_level_t,                                            &
     628                                   do2d_at_begin,                                                  &
     629                                   do3d_at_begin,                                                  &
     630                                   dt,                                                             &
     631                                   dt_averaging_input,                                             &
     632                                   dt_averaging_input_pr,                                          &
     633                                   dt_coupling,                                                    &
     634                                   dt_data_output,                                                 &
     635                                   dt_data_output_av,                                              &
     636                                   dt_disturb,                                                     &
     637                                   dt_domask,                                                      &
     638                                   dt_dopr,                                                        &
     639                                   dt_dopr_listing,                                                &
     640                                   dt_dots,                                                        &
     641                                   dt_do2d_xy,                                                     &
     642                                   dt_do2d_xz,                                                     &
     643                                   dt_do2d_yz,                                                     &
     644                                   dt_do3d,                                                        &
     645                                   dt_max,                                                         &
     646                                   dt_restart,                                                     &
     647                                   dt_run_control,                                                 &
     648                                   end_time,                                                       &
     649                                   force_print_header,                                             &
     650                                   mask_k_over_surface,                                            &
     651                                   mask_scale_x,                                                   &
     652                                   mask_scale_y,                                                   &
     653                                   mask_scale_z,                                                   &
     654                                   mask_x,                                                         &
     655                                   mask_y,                                                         &
     656                                   mask_z,                                                         &
     657                                   mask_x_loop,                                                    &
     658                                   mask_y_loop,                                                    &
     659                                   mask_z_loop,                                                    &
     660                                   netcdf_data_format,                                             &
     661                                   netcdf_deflate,                                                 &
     662                                   normalizing_region,                                             &
     663                                   npex,                                                           &
     664                                   npey,                                                           &
     665                                   nz_do3d,                                                        &
     666                                   profile_columns,                                                &
     667                                   profile_rows,                                                   &
     668                                   restart_time,                                                   &
     669                                   section_xy,                                                     &
     670                                   section_xz,                                                     &
     671                                   section_yz,                                                     &
     672                                   restart_data_format,                                            &
     673                                   restart_data_format_input,                                      &
     674                                   restart_data_format_output,                                     &
     675                                   skip_time_data_output,                                          &
     676                                   skip_time_data_output_av,                                       &
     677                                   skip_time_dopr,                                                 &
     678                                   skip_time_do2d_xy,                                              &
     679                                   skip_time_do2d_xz,                                              &
     680                                   skip_time_do2d_yz,                                              &
     681                                   skip_time_do3d,                                                 &
     682                                   skip_time_domask,                                               &
     683                                   synchronous_exchange,                                           &
     684                                   termination_time_needed
     685
     686    NAMELIST /envpar/  host,                                                                       &
     687                       maximum_cpu_time_allowed,                                                   &
     688                       maximum_parallel_io_streams,                                                &
     689                       progress_bar_disabled,                                                      &
     690                       read_svf,                                                                   &
     691                       revision,                                                                   &
     692                       run_identifier,                                                             &
     693                       tasks_per_node,                                                             &
     694                       write_binary,                                                               &
     695                       write_svf
     696
     697!
     698!-- First read values of environment variables (this NAMELIST file is generated by palmrun)
    374699    CALL location_message( 'reading environment parameters from ENVPAR', 'start' )
    375700
    376     OPEN ( 90, FILE='ENVPAR', STATUS='OLD', FORM='FORMATTED', IOSTAT=ioerr )
     701    OPEN( 90, FILE='ENVPAR', STATUS='OLD', FORM='FORMATTED', IOSTAT=ioerr )
    377702
    378703    IF ( ioerr /= 0 )  THEN
    379        message_string = 'local file ENVPAR not found' //                       &
     704       message_string = 'local file ENVPAR not found' //                                           &
    380705                        '&some variables for steering may not be properly set'
    381706       CALL message( 'parin', 'PA0276', 0, 1, 0, 6, 0 )
    382707    ELSE
    383        READ ( 90, envpar, IOSTAT=ioerr )
     708       READ( 90, envpar, IOSTAT=ioerr )
    384709       IF ( ioerr < 0 )  THEN
    385           message_string = 'no envpar-NAMELIST found in local file '  //       &
     710          message_string = 'no envpar-NAMELIST found in local file '  //                           &
    386711                           'ENVPAR& or some variables for steering may '  //   &
    387712                           'not be properly set'
    388713          CALL message( 'parin', 'PA0278', 0, 1, 0, 6, 0 )
    389714       ELSEIF ( ioerr > 0 )  THEN
    390           message_string = 'errors in local file ENVPAR' //                    &
     715          message_string = 'errors in local file ENVPAR' //                                        &
    391716                           '&some variables for steering may not be properly set'
    392717          CALL message( 'parin', 'PA0277', 0, 1, 0, 6, 0 )
    393718       ENDIF
    394        CLOSE ( 90 )
     719       CLOSE( 90 )
    395720    ENDIF
    396721
     
    414739
    415740 11 REWIND ( 11 )
    416     READ ( 11, inipar, ERR=12, END=13 )
    417 
    418     message_string = 'namelist inipar is deprecated and will be ' //    &
    419                      'removed in near future. & Please use namelist ' // &
     741    READ( 11, inipar, ERR=12, END=13 )
     742
     743    message_string = 'namelist inipar is deprecated and will be ' //                               &
     744                     'removed in near future. & Please use namelist ' //                           &
    420745                     'initialization_parameters instead'
    421746    CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
     
    431756
    432757!
    433 !-- Try to read runtime parameters given by the user for this run
    434 !-- (namelist "runtime_parameters"). The namelist "runtime_parmeters"
    435 !-- can be omitted. In that case default values are used for the
     758!-- Try to read runtime parameters given by the user for this run (namelist "runtime_parameters").
     759!-- The namelist "runtime_parmeters" can be omitted. In that case default values are used for the
    436760!-- parameters.
    437761 14 line = ' '
    438762
    439     REWIND ( 11 )
     763    REWIND( 11 )
    440764    line = ' '
    441765    DO WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
    442        READ ( 11, '(A)', END=16 )  line
     766       READ( 11, '(A)', END=16 )  line
    443767    ENDDO
    444     BACKSPACE ( 11 )
     768    BACKSPACE( 11 )
    445769
    446770!
    447771!-- Read namelist
    448     READ ( 11, runtime_parameters, ERR = 15 )
     772    READ( 11, runtime_parameters, ERR = 15 )
    449773    GOTO 18
    450774
     
    453777    CALL parin_fail_message( 'runtime_parameters', line )
    454778
    455  16 REWIND ( 11 )
     779 16 REWIND( 11 )
    456780    line = ' '
    457781    DO WHILE ( INDEX( line, '&d3par' ) == 0 )
    458        READ ( 11, '(A)', END=18 )  line
     782       READ( 11, '(A)', END=18 )  line
    459783    ENDDO
    460784    BACKSPACE ( 11 )
     
    462786!
    463787!-- Read namelist
    464     READ ( 11, d3par, ERR = 17, END = 18 )
    465 
    466     message_string = 'namelist d3par is deprecated and will be ' //      &
    467                      'removed in near future. &Please use namelist ' //   &
     788    READ( 11, d3par, ERR = 17, END = 18 )
     789
     790    message_string = 'namelist d3par is deprecated and will be ' //                                &
     791                     'removed in near future. &Please use namelist ' //                            &
    468792                     'runtime_parameters instead'
    469793    CALL message( 'parin', 'PA0487', 0, 1, 0, 6, 0 )
     
    483807!
    484808!-- Calculate the number of groups into which parallel I/O is split.
    485 !-- The default for files which are opened by all PEs (or where each
    486 !-- PE opens his own independent file) is, that all PEs are doing input/output
    487 !-- in parallel at the same time. This might cause performance or even more
    488 !-- severe problems depending on the configuration of the underlying file
     809!-- The default for files which are opened by all PEs (or where each PE opens its own independent
     810!-- file) is, that all PEs are doing input/output in parallel at the same time. This might cause
     811!-- performance or even more severe problems depending on the configuration of the underlying file
    489812!-- system.
    490 !-- Calculation of the number of blocks and the I/O group must be based on all
    491 !-- PEs involved in this run. Since myid and numprocs are related to the
    492 !-- comm2d communicator, which gives only a subset of all PEs in case of
    493 !-- nested runs, that information must be inquired again from the global
     813!-- Calculation of the number of blocks and the I/O group must be based on all PEs involved in this
     814!-- run. Since myid and numprocs are related to the comm2d communicator, which gives only a subset
     815!-- of all PEs in case of nested runs, that information must be inquired again from the global
    494816!-- communicator.
    495817!-- First, set the default:
     
    501823    global_procs = 1
    502824#endif
    503     IF ( maximum_parallel_io_streams == -1  .OR.                               &
    504          maximum_parallel_io_streams > global_procs )  THEN
     825    IF ( maximum_parallel_io_streams == -1  .OR.  maximum_parallel_io_streams > global_procs )  THEN
    505826       maximum_parallel_io_streams = global_procs
    506827    ENDIF
    507828!
    508 !-- Now calculate the number of io_blocks and the io_group to which the
    509 !-- respective PE belongs. I/O of the groups is done in serial, but in parallel
    510 !-- for all PEs belonging to the same group.
     829!-- Now calculate the number of io_blocks and the io_group to which the respective PE belongs. I/O
     830!-- of the groups is done in serial, but in parallel for all PEs belonging to the same group.
    511831    io_blocks = global_procs / maximum_parallel_io_streams
    512832    io_group  = MOD( global_id+1, io_blocks )
    513833
    514834!
    515 !-- If required, read control parameters from restart file (produced by
    516 !-- a prior run). All PEs are reading from file created by PE0 (see
    517 !-- check_open)
     835!-- If required, read control parameters from restart file (produced by a prior run). All PEs are
     836!-- reading from file created by PE0 (see check_open)
    518837    IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
    519838
    520839!
    521 !--    If not set by the user in the runtime parameters, the data format for restart
    522 !--    input needs to be set now! This is normally done later in check parameters.
    523        IF ( TRIM( restart_data_format ) /= 'fortran_binary'  .AND.                           &
    524             TRIM( restart_data_format ) /= 'mpi'             .AND.                           &
     840!--    If not set by the user in the runtime parameters, the data format for restart input needs to
     841!--    be set now! This is normally done later in check parameters.
     842       IF ( TRIM( restart_data_format ) /= 'fortran_binary'  .AND.                                 &
     843            TRIM( restart_data_format ) /= 'mpi'             .AND.                                 &
    525844            TRIM( restart_data_format ) /= 'mpi_shared_memory' )  THEN
    526845          message_string = 'illegal restart data format "' // TRIM( restart_data_format ) // '"'
     
    553872       runnr = runnr + 1
    554873!
    555 !--    In case of a restart run, the number of user-defined profiles on
    556 !--    the restart file (already stored in max_pr_user) has to match the
    557 !--    one given for the current run. max_pr_user_tmp is calculated in
    558 !--    user_parin and max_pr_user is read in via rrd_global.
     874!--    In case of a restart run, the number of user-defined profiles on the restart file (already
     875!--    stored in max_pr_user) has to match the one given for the current run. max_pr_user_tmp is
     876!--    calculated in user_parin and max_pr_user is read in via rrd_global.
    559877       IF ( max_pr_user /= max_pr_user_tmp )  THEN
    560           WRITE( message_string, * ) 'the number of user-defined ',      &
    561                  'profiles given in data_output_pr (', max_pr_user_tmp,   &
    562                  ') does not match the one ',                             &
    563                  'found in the restart file (', max_pr_user, ')'
     878          WRITE( message_string, * ) 'the number of user-defined ',                                &
     879                                     'profiles given in data_output_pr (', max_pr_user_tmp,        &
     880                                     ') does not match the one ',                                  &
     881                                     'found in the restart file (', max_pr_user, ')'
    564882          CALL message( 'user_parin', 'UI0009', 1, 2, 0, 6, 0 )
    565883       ENDIF
     
    569887!
    570888!-- Activate spinup
    571     IF ( land_surface .OR. urban_surface )  THEN
     889    IF ( land_surface  .OR. urban_surface )  THEN
    572890       IF ( spinup_time > 0.0_wp )  THEN
    573891          coupling_start_time = spinup_time
     
    579897          IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
    580898             spinup = .TRUE.
    581           ELSEIF (        TRIM( initializing_actions ) == 'read_restart_data'      &
    582                    .AND.  time_since_reference_point > 0.0_wp )  THEN
     899          ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data'  .AND.                      &
     900                   time_since_reference_point > 0.0_wp )  THEN
    583901             data_output_during_spinup = .FALSE.  !< required for correct ntdim calculation
    584902                                                  !< in check_parameters for restart run
     
    593911    IF ( nested_run )  THEN
    594912       IF ( nesting_mode == 'vertical' )  THEN
    595           IF (bc_lr /= 'cyclic' .OR. bc_ns /= 'cyclic' )  THEN
    596              WRITE ( message_string, *) 'bc_lr and bc_ns were set to ,', &
    597                      'cyclic for vertical nesting'
     913          IF ( bc_lr /= 'cyclic'  .OR. bc_ns /= 'cyclic' )  THEN
     914             WRITE ( message_string, *) 'bc_lr and bc_ns were set to ,',                           &
     915                                        'cyclic for vertical nesting'
    598916             CALL message( 'parin', 'PA0428', 0, 0, 0, 6, 0 )
    599917             bc_lr   = 'cyclic'
     
    609927          ENDIF
    610928!
    611 !--    For other nesting modes only set boundary conditions for
    612 !--    nested domains.
     929!--    For other nesting modes only set boundary conditions for nested domains.
    613930       ELSE
    614931          IF ( child_domain )  THEN
     
    625942    ENDIF
    626943!
    627 !-- Set boundary conditions also in case the model is offline-nested in
    628 !-- larger-scale models.
     944!-- Set boundary conditions also in case the model is offline-nested in larger-scale models.
    629945    IF ( nesting_offline )  THEN
    630946       bc_lr    = 'nesting_offline'
     
    639955
    640956!
    641 !-- In case of nested runs, make sure that initializing_actions =
    642 !-- 'set_constant_profiles' even though the constant-profiles
    643 !-- initializations for the prognostic variables will be overwritten
    644 !-- by pmci_child_initialize and pmci_parent_initialize. This is,
    645 !-- however, important e.g. to make sure that diagnostic variables
    646 !-- are set properly. An exception is made in case of restart runs and
    647 !-- if user decides to do everything by its own.
    648     IF ( child_domain  .AND.  .NOT. (                                    &
    649          TRIM( initializing_actions ) == 'read_restart_data'      .OR.   &
    650          TRIM( initializing_actions ) == 'set_constant_profiles'  .OR.   &
    651          TRIM( initializing_actions ) == 'by_user' ) )  THEN
    652        message_string = 'initializing_actions = ' //                     &
    653                         TRIM( initializing_actions ) // ' has been ' //  &
    654                         'changed to set_constant_profiles in child ' //  &
    655                         'domain.'
     957!-- In case of nested runs, make sure that initializing_actions = 'set_constant_profiles' even
     958!-- though the constant-profiles initializations for the prognostic variables will be overwritten by
     959!-- pmci_child_initialize and pmci_parent_initialize. This is, however, important e.g. to make sure
     960!-- that diagnostic variables are set properly. An exception is made in case of restart runs and if
     961!-- user decides to do everything by its own.
     962    IF ( child_domain  .AND.  .NOT. ( TRIM( initializing_actions ) == 'read_restart_data'     .OR. &
     963                                      TRIM( initializing_actions ) == 'set_constant_profiles' .OR. &
     964                                      TRIM( initializing_actions ) == 'by_user' )                  &
     965                                    )  THEN
     966       message_string = 'initializing_actions = ' // TRIM( initializing_actions ) //               &
     967                        ' has been ' // 'changed to set_constant_profiles in child ' // 'domain.'
    656968       CALL message( 'parin', 'PA0492', 0, 0, 0, 6, 0 )
    657969
     
    659971    ENDIF
    660972!
    661 !-- Check validity of lateral boundary conditions. This has to be done
    662 !-- here because they are already used in init_pegrid and init_grid and
    663 !-- therefore cannot be check in check_parameters
    664     IF ( bc_lr /= 'cyclic'  .AND.  bc_lr /= 'dirichlet/radiation'  .AND. &
    665          bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'  .AND. &
     973!-- Check validity of lateral boundary conditions. This has to be done here because they are already
     974!-- used in init_pegrid and init_grid and therefore cannot be check in check_parameters
     975    IF ( bc_lr /= 'cyclic'               .AND.  bc_lr /= 'dirichlet/radiation'  .AND.              &
     976         bc_lr /= 'radiation/dirichlet'  .AND.  bc_lr /= 'nested'               .AND.              &
    666977         bc_lr /= 'nesting_offline' )  THEN
    667        message_string = 'unknown boundary condition: bc_lr = "' // &
    668                         TRIM( bc_lr ) // '"'
     978       message_string = 'unknown boundary condition: bc_lr = "' // TRIM( bc_lr ) // '"'
    669979       CALL message( 'parin', 'PA0049', 1, 2, 0, 6, 0 )
    670980    ENDIF
    671     IF ( bc_ns /= 'cyclic'  .AND.  bc_ns /= 'dirichlet/radiation'  .AND. &
    672          bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'  .AND. &
     981    IF ( bc_ns /= 'cyclic'               .AND.  bc_ns /= 'dirichlet/radiation'  .AND.              &
     982         bc_ns /= 'radiation/dirichlet'  .AND.  bc_ns /= 'nested'               .AND.              &
    673983         bc_ns /= 'nesting_offline' )  THEN
    674        message_string = 'unknown boundary condition: bc_ns = "' // &
    675                         TRIM( bc_ns ) // '"'
     984       message_string = 'unknown boundary condition: bc_ns = "' // TRIM( bc_ns ) // '"'
    676985       CALL message( 'parin', 'PA0050', 1, 2, 0, 6, 0 )
    677986    ENDIF
     
    686995!
    687996!-- Radiation-Dirichlet conditions are allowed along one of the horizontal directions only.
    688 !-- In general, such conditions along x and y may work, but require a) some code changes
    689 !-- (e.g. concerning allocation of c_u, c_v ... arrays), and b) a careful model setup by the
    690 !-- user, in order to guarantee that there is a clearly defined outflow at two sides.
     997!-- In general, such conditions along x and y may work, but require a) some code changes (e.g.
     998!-- concerning allocation of c_u, c_v ... arrays), and b) a careful model setup by the user, in
     999!-- order to guarantee that there is a clearly defined outflow at two sides.
    6911000!-- Otherwise, the radiation condition may produce wrong results.
    6921001    IF ( ( bc_lr_dirrad .OR. bc_lr_raddir )  .AND.  ( bc_ns_dirrad .OR. bc_ns_raddir ) )  THEN
    693        message_string = 'bc_lr = "' // TRIM( bc_lr ) // '" and bc_ns = "' //                 &
    694                         TRIM( bc_ns ) // '" are not allowed to be set at the same time'
     1002       message_string = 'bc_lr = "' // TRIM( bc_lr ) // '" and bc_ns = "' // TRIM( bc_ns ) //      &
     1003                        '" are not allowed to be set at the same time'
    6951004       CALL message( 'parin', 'PA0589', 1, 2, 0, 6, 0 )
    6961005    ENDIF
    6971006!
    698 !-- Check in case of initial run, if the grid point numbers are well
    699 !-- defined and allocate some arrays which are already needed in
    700 !-- init_pegrid or check_parameters. During restart jobs, these arrays
    701 !-- will be allocated in rrd_global. All other arrays are allocated
    702 !-- in init_3d_model.
     1007!-- Check in case of initial run, if the grid point numbers are well defined and allocate some
     1008!-- arrays which are already needed in init_pegrid or check_parameters. During restart jobs, these
     1009!-- arrays will be allocated in rrd_global. All other arrays are allocated in init_3d_model.
    7031010    IF ( TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
    7041011
    7051012       IF ( nx <= 0 )  THEN
    706           WRITE( message_string, * ) 'no value or wrong value given',    &
    707                                      ' for nx: nx=', nx
     1013          WRITE( message_string, * ) 'no value or wrong value given', ' for nx: nx=', nx
    7081014          CALL message( 'parin', 'PA0273', 1, 2, 0, 6, 0 )
    7091015       ENDIF
    7101016       IF ( ny <= 0 )  THEN
    711           WRITE( message_string, * ) 'no value or wrong value given',    &
    712                                      ' for ny: ny=', ny
     1017          WRITE( message_string, * ) 'no value or wrong value given', ' for ny: ny=', ny
    7131018          CALL message( 'parin', 'PA0274', 1, 2, 0, 6, 0 )
    7141019       ENDIF
    7151020       IF ( nz <= 0 )  THEN
    716           WRITE( message_string, * ) 'no value or wrong value given',    &
    717                                      ' for nz: nz=', nz
     1021          WRITE( message_string, * ) 'no value or wrong value given', ' for nz: nz=', nz
    7181022          CALL message( 'parin', 'PA0275', 1, 2, 0, 6, 0 )
    7191023       ENDIF
    7201024
    7211025!
    722 !--    As a side condition, routine flow_statistics require at least 14
    723 !--    vertical grid levels (they are used to store time-series data)
     1026!--    As a side condition, routine flow_statistics require at least 14 vertical grid levels (they
     1027!--    are used to store time-series data)
    7241028!>     @todo   Remove this restriction
    7251029       IF ( nz < 14 )  THEN
     
    7291033
    7301034!
    731 !--    ATTENTION: in case of changes to the following statement please
    732 !--               also check the allocate statement in routine rrd_global
    733        ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),        &
    734                  ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),         &
    735                  u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),             &
    736                  hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),  &
     1035!--    ATTENTION: in case of changes to the following statement please also check the allocate
     1036!--               statement in routine rrd_global
     1037       ALLOCATE( pt_init(0:nz+1), q_init(0:nz+1), s_init(0:nz+1),                                  &
     1038                 ref_state(0:nz+1), sa_init(0:nz+1), ug(0:nz+1),                                   &
     1039                 u_init(0:nz+1), v_init(0:nz+1), vg(0:nz+1),                                       &
     1040                 hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions),     &
    7371041                 hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
    7381042
Note: See TracChangeset for help on using the changeset viewer.