Index: /palm/trunk/SOURCE/bulk_cloud_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Enable 3D data output also with 64-bit precision
 !
@@ -664,54 +668,60 @@
 !> Parin for &bulk_cloud_parameters for the bulk cloud module
 !--------------------------------------------------------------------------------------------------!
-    SUBROUTINE bcm_parin
-
-
-       IMPLICIT NONE
-
-       CHARACTER (LEN=80)  ::  line  !< dummy string that contains the current line of the parameter
-                                     !< file
-
-       NAMELIST /bulk_cloud_parameters/                                                            &
-          aerosol_bulk,                                                                            &
-          bulk_cloud_model,                                                                        &
-          c_sedimentation,                                                                         &
-          call_microphysics_at_all_substeps,                                                       &
-          cloud_scheme,                                                                            &
-          cloud_water_sedimentation,                                                               &
-          collision_turbulence,                                                                    &
-          curvature_solution_effects_bulk,                                                         &
-          dry_aerosol_radius,                                                                      &
-          graupel,                                                                                 &
-          ice_crystal_sedimentation,                                                               &
-          in_init,                                                                                 &
-          limiter_sedimentation,                                                                   &
-          microphysics_ice_phase,                                                                  &
-          na_init,                                                                                 &
-          nc_const,                                                                                &
-          sigma_bulk,                                                                              &
-          snow,                                                                                    &
-          start_ice_microphysics,                                                                  &
-          ventilation_effect
-
-       line = ' '
-!
-!--    Try to find bulk cloud module namelist
-       REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&bulk_cloud_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-!
-!--    Read user-defined namelist
-       READ ( 11, bulk_cloud_parameters )
-!
-!--    Set flag that indicates that the bulk cloud module is switched on
-       !bulk_cloud_model = .TRUE.
-
-10     CONTINUE
-
-
-    END SUBROUTINE bcm_parin
+ SUBROUTINE bcm_parin
+
+
+    IMPLICIT NONE
+
+    CHARACTER(LEN=100)  ::  line  !< Dummy string that contains the current line of the parameter
+                                  !< file
+
+    INTEGER(iwp)  ::  io_status   !< Status after reading the namelist file
+
+
+    NAMELIST /bulk_cloud_parameters/                                                               &
+       aerosol_bulk,                                                                               &
+       bulk_cloud_model,                                                                           &
+       c_sedimentation,                                                                            &
+       call_microphysics_at_all_substeps,                                                          &
+       cloud_scheme,                                                                               &
+       cloud_water_sedimentation,                                                                  &
+       collision_turbulence,                                                                       &
+       curvature_solution_effects_bulk,                                                            &
+       dry_aerosol_radius,                                                                         &
+       graupel,                                                                                    &
+       ice_crystal_sedimentation,                                                                  &
+       in_init,                                                                                    &
+       limiter_sedimentation,                                                                      &
+       microphysics_ice_phase,                                                                     &
+       na_init,                                                                                    &
+       nc_const,                                                                                   &
+       sigma_bulk,                                                                                 &
+       snow,                                                                                       &
+       start_ice_microphysics,                                                                     &
+       ventilation_effect
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, bulk_cloud_parameters, IOSTAT=io_status )
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    bulk_cloud_parameters namelist was found and read correctly. Set flag that
+!--    bulk_cloud_model_mod is switched on.
+       bulk_cloud_model = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    bulk_cloud_parameters namelist was found, but contained errors. Print an error message
+!--    containing the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'bulk_cloud_parameters', line )
+
+    ENDIF
+
+ END SUBROUTINE bcm_parin
 
 
Index: /palm/trunk/SOURCE/dynamics_mod.f90
===================================================================
--- /palm/trunk/SOURCE/dynamics_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/dynamics_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Enable 3D data output also with 64-bit precision
 !
@@ -336,33 +340,30 @@
 
 
-    CHARACTER (LEN=80)  ::  line  !< dummy string that contains the current line of the parameter file
-
-    NAMELIST /dynamics_parameters/                                                                 &
-       dynamics_module_enabled
-
-
-    line = ' '
-!
-!-- Try to find module-specific namelist
-    REWIND ( 11 )
-    line = ' '
-    DO   WHILE ( INDEX( line, '&dynamics_parameters' ) == 0 )
-       READ ( 11, '(A)', END=12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!-- Set default module switch to true
+    CHARACTER(LEN=100)  ::  line  !< dummy string that contains the current line of the parameter
+                                  !< file
+    INTEGER(iwp)  ::  io_status   !< status after reading the namelist file
+
+    
+    NAMELIST /dynamics_parameters/  dynamics_module_enabled
+
+!
+!-- Set default module switch to true.
     dynamics_module_enabled = .TRUE.
 
-!-- Read user-defined namelist
-    READ ( 11, dynamics_parameters, ERR = 10 )
-
-    GOTO 12
-
-10  BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'dynamics_parameters', line )
-
-12  CONTINUE
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, dynamics_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status > 0 )  THEN
+!
+!--    dynamics_parameters namelist was found, but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'dynamics_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE dynamics_parin
Index: /palm/trunk/SOURCE/gust_mod.f90
===================================================================
--- /palm/trunk/SOURCE/gust_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/gust_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Enable 3D data output also with 64-bit precision
 !
@@ -213,34 +217,40 @@
 !> Parin for &gust_parameters for gust module
 !--------------------------------------------------------------------------------------------------!
-    SUBROUTINE gust_parin
-
-
-       IMPLICIT NONE
-
-       CHARACTER (LEN=80)  ::  line  !< dummy string that contains the current line of the parameter file
-
-       NAMELIST /gust_parameters/                                                                  &
-          gust_module_enabled
-
-       line = ' '
-!
-!--    Try to find gust module package
-       REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&gust_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-!
-!--    Read user-defined namelist
-       READ ( 11, gust_parameters )
-!
-!--    Set flag that indicates that the gust module is switched on
+ SUBROUTINE gust_parin
+
+
+    IMPLICIT NONE
+
+    CHARACTER(LEN=100)  ::  line  !< dummy string that contains the current line of the parameter
+                                  !< file
+    INTEGER(iwp)  ::  io_status   !< status after reading the namelist file
+
+
+    NAMELIST /gust_parameters/  gust_module_enabled
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, gust_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    gust_parameters namelist was found and read correctly. Set flag that indicates that the gust
+!--    module is switched on.
        gust_module_enabled = .TRUE.
 
-10     CONTINUE
-
-
-    END SUBROUTINE gust_parin
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    gust_parameters namelist was found, but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'gust_parameters', line )
+
+    ENDIF
+
+ END SUBROUTINE gust_parin
 
 
Index: /palm/trunk/SOURCE/indoor_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4842)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Change parameters for summer_pars and winter_pars (responsible: S. Rissmann)
 !
@@ -1903,5 +1907,5 @@
         CASE ( 'im_t_indoor_wall_win' )
            unit = 'K'
-           
+
         CASE ( 'im_t_indoor_wall' )
            unit = 'K'
@@ -2123,25 +2127,34 @@
 
 
-    CHARACTER (LEN=80) ::  line  !< string containing current line of file PARIN
+    CHARACTER(LEN=100) ::  line  !< string containing current line of file PARIN
+
+    INTEGER(iwp)  ::  io_status  !< status after reading the namelist file
+
 
     NAMELIST /indoor_parameters/  indoor_during_spinup,                                            &
                                   initial_indoor_temperature
 
-
-!
-!-- Try to find indoor model package
-    REWIND ( 11 )
-    line = ' '
-    DO  WHILE ( INDEX( line, '&indoor_parameters' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, indoor_parameters )
-!
-!-- Set flag that indicates that the indoor model is switched on
-    indoor_model = .TRUE.
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, indoor_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    indoor_parameters namelist was found and read correctly. Set flag that indicates that the
+!--    indoor model is switched on.
+       indoor_model = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    indoor_parameters namelist was found, but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'indoor_parameters', line )
+
+    ENDIF
 
 !
@@ -2156,6 +2169,4 @@
 !        ENDIF
 
- 10 CONTINUE
-
  END SUBROUTINE im_parin
 
Index: /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4842)
@@ -24,4 +24,9 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprecated namelist removed
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! output of particle time series added
 !
@@ -569,65 +574,7 @@
  SUBROUTINE lpm_parin
 
-    CHARACTER (LEN=80) ::  line  !<
-
-    NAMELIST /particles_par/                                                                       &
-       aero_species,                                                                               &
-       aero_type,                                                                                  &
-       aero_weight,                                                                                &
-       alloc_factor,                                                                               &
-       bc_par_b,                                                                                   &
-       bc_par_lr,                                                                                  &
-       bc_par_ns,                                                                                  &
-       bc_par_t,                                                                                   &
-       collision_kernel,                                                                           &
-       curvature_solution_effects,                                                                 &
-       deallocate_memory,                                                                          &
-       density_ratio,                                                                              &
-       dissipation_classes,                                                                        &
-       dt_dopts,                                                                                   &
-       dt_min_part,                                                                                &
-       dt_prel,                                                                                    &
-       dt_write_particle_data,                                                                     &
-       end_time_prel,                                                                              &
-       initial_weighting_factor,                                                                   &
-       log_sigma,                                                                                  &
-       max_number_particles_per_gridbox,                                                           &
-       merging,                                                                                    &
-       na,                                                                                         &
-       number_concentration,                                                                       &
-       number_of_particle_groups,                                                                  &
-       number_particles_per_gridbox,                                                               &
-       particles_per_point,                                                                        &
-       particle_advection_start,                                                                   &
-       particle_advection_interpolation,                                                           &
-       particle_maximum_age,                                                                       &
-       pdx,                                                                                        &
-       pdy,                                                                                        &
-       pdz,                                                                                        &
-       psb,                                                                                        &
-       psl,                                                                                        &
-       psn,                                                                                        &
-       psr,                                                                                        &
-       pss,                                                                                        &
-       pst,                                                                                        &
-       radius,                                                                                     &
-       radius_classes,                                                                             &
-       radius_merge,                                                                               &
-       radius_split,                                                                               &
-       random_start_position,                                                                      &
-       read_particles_from_restartfile,                                                            &
-       rm,                                                                                         &
-       seed_follows_topography,                                                                    &
-       splitting,                                                                                  &
-       splitting_factor,                                                                           &
-       splitting_factor_max,                                                                       &
-       splitting_function,                                                                         &
-       splitting_mode,                                                                             &
-       step_dealloc,                                                                               &
-       use_sgs_for_particles,                                                                      &
-       vertical_particle_advection,                                                                &
-       weight_factor_merge,                                                                        &
-       weight_factor_split,                                                                        &
-       write_particle_statistics
+    CHARACTER(LEN=100) ::  line  !< string containing current line of file PARIN
+
+    INTEGER(iwp) ::  io_status  !< status after reading the namelist file
 
     NAMELIST /particle_parameters/                                                                 &
@@ -699,59 +646,27 @@
 
 !
-!-- Position the namelist-file at the beginning (it was already opened in parin), search for the
-!-- namelist-group of the package and position the file at this line. Do the same for each
-!-- optionally used package.
-    line = ' '
-
-!
-!-- Try to find particles package
-    REWIND ( 11 )
-    line = ' '
-    DO   WHILE ( INDEX( line, '&particle_parameters' ) == 0 )
-       READ ( 11, '(A)', END=12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-!
-!-- Read user-defined namelist
-    READ ( 11, particle_parameters, ERR = 10 )
-!
-!-- Set flag that indicates that particles are switched on
-    particle_advection = .TRUE.
-
-    GOTO 14
-
-10  BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'particle_parameters', line )
-!
-!-- Try to find particles package (old namelist)
-12  REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&particles_par' ) == 0 )
-       READ ( 11, '(A)', END=14 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-!
-!-- Read user-defined namelist
-    READ ( 11, particles_par, ERR = 13, END = 14 )
-
-    message_string = 'namelist particles_par is deprecated and will be ' //                        &
-                     'removed in near future. Please use namelist ' //                             &
-                     'particle_parameters instead'
-    CALL message( 'package_parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-!
-!-- Set flag that indicates that particles are switched on
-    particle_advection = .TRUE.
-
-    GOTO 14
-
-13    BACKSPACE( 11 )
-       READ( 11 , '(A)') line
-       CALL parin_fail_message( 'particles_par', line )
-
-14 CONTINUE
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, particle_parameters, IOSTAT=io_status )
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    particle_parameters namelist was found and read correctly. Set flag that indicates that
+!--    particles are switched on.
+       particle_advection = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    particle_parameters namelist was found, but contained errors. Print an error message
+!--    including the line that caused the error.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'particle_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE lpm_parin
+
 
 !--------------------------------------------------------------------------------------------------!
Index: /palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4842)
@@ -24,4 +24,9 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprecated namelist removed
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Enable 3D data output also with 64-bit precision
 !
@@ -4995,55 +5000,10 @@
  SUBROUTINE lsm_parin
 
-    USE control_parameters,                                                                        &
-        ONLY:  message_string
-
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-    NAMELIST /lsm_par/         aero_resist_kray,                                                   &
-                               alpha_vangenuchten,                                                 &
-                               c_surface,                                                          &
-                               canopy_resistance_coefficient,                                      &
-                               constant_roughness,                                                 &
-                               conserve_water_content,                                             &
-                               deep_soil_temperature,                                              &
-                               dz_soil,                                                            &
-                               f_shortwave_incoming,                                               &
-                               field_capacity,                                                     &
-                               hydraulic_conductivity,                                             &
-                               l_vangenuchten,                                                     &
-                               lambda_surface_stable,                                              &
-                               lambda_surface_unstable,                                            &
-                               leaf_area_index,                                                    &
-                               min_canopy_resistance,                                              &
-                               min_soil_resistance,                                                &
-                               n_vangenuchten,                                                     &
-                               pavement_depth_level,                                               &
-                               pavement_heat_capacity,                                             &
-                               pavement_heat_conduct,                                              &
-                               pavement_type,                                                      &
-                               residual_moisture,                                                  &
-                               root_fraction,                                                      &
-                               saturation_moisture,                                                &
-                               skip_time_do_lsm,                                                   &
-                               soil_moisture,                                                      &
-                               soil_temperature,                                                   &
-                               soil_type,                                                          &
-                               surface_type,                                                       &
-                               vegetation_coverage,                                                &
-                               vegetation_type,                                                    &
-                               water_temperature,                                                  &
-                               water_type,                                                         &
-                               wilting_point,                                                      &
-                               z0_pavement,                                                        &
-                               z0_vegetation,                                                      &
-                               z0_water,                                                           &
-                               z0h_pavement,                                                       &
-                               z0h_vegetation,                                                     &
-                               z0h_water,                                                          &
-                               z0q_pavement,                                                       &
-                               z0q_vegetation,                                                     &
-                               z0q_water
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter
+                                 !< file
+    INTEGER(iwp)  ::  io_status  !< status after reading the nameslist file
+
 
     NAMELIST /land_surface_parameters/  aero_resist_kray,                                          &
@@ -5092,59 +5052,26 @@
                                         z0q_water
 
-    line = ' '
-
-!
-!-- Try to find land surface model package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&land_surface_parameters' ) == 0 )
-       READ ( 11, '(A)', END=12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, land_surface_parameters, ERR = 10 )
-
-!
-!-- Set flag that indicates that the land surface model is switched on
-    land_surface = .TRUE.
-
-    GOTO 14
-
-10  BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'land_surface_parameters', line )
-!
-!-- Try to find old namelist
-12  REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&lsm_par' ) == 0 )
-       READ ( 11, '(A)', END=14 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, lsm_par, ERR = 13, END = 14 )
-
-    message_string = 'namelist lsm_par is deprecated and will be ' //                              &
-                     'removed in near future. Please use namelist ' //                             &
-                     'land_surface_parameters instead'
-    CALL message( 'lsm_parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-!
-!-- Set flag that indicates that the land surface model is switched on
-    land_surface = .TRUE.
-
-    GOTO 14
-
-13  BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'lsm_par', line )
-
-
-14  CONTINUE
-
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, land_surface_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    land_surface_parameters namelist was found and read correctly. Set flag that indicates that
+!--    the land surface model is switched on.
+       land_surface = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    land_surface_parameters namelist was found but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'land_surface_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE lsm_parin
Index: /palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! file re-formatted to follow the PALM coding standard
 !
@@ -3655,5 +3659,8 @@
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !<
+    CHARACTER(LEN=100) ::  line  !< dummy string for current line in namelist file
+
+    INTEGER(iwp)  ::  io_status  !< status after reading the namelist file
+
 
     NAMELIST /agent_parameters/  a_rand_target,                                                    &
@@ -3699,26 +3706,25 @@
 
 !
-!-- Try to find agent package
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
     REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&agent_parameters' ) == 0 )
-       READ ( 11, '(A)', END=20 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, agent_parameters, ERR = 10, END = 20 )
-
-!
-!-- Set flag that indicates that agents are switched on
-    agents_active = .TRUE.
-    GOTO 20
-
-10    BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'agent_parameters', line )
-
-20    CONTINUE
+    READ ( 11, agent_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    agent_parameters namelist was found and read correctly. Set flag that indicates that agents
+!--    are switched on.
+       agents_active = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    agent_parameters namelist was found but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'agent_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE mas_parin
Index: /palm/trunk/SOURCE/nesting_offl_mod.f90
===================================================================
--- /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4834 2021-01-07 10:28:00Z raasch
 ! file re-formatted to follow the PALM coding standard
 !
@@ -2448,34 +2452,29 @@
  SUBROUTINE nesting_offl_parin
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-
-    NAMELIST /nesting_offl_parameters/   nesting_offline
-
-    line = ' '
-
-!
-!-- Try to find stg package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&nesting_offl_parameters' ) == 0 )
-       READ ( 11, '(A)', END=20 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, nesting_offl_parameters, ERR = 10, END = 20 )
-
-    GOTO 20
-
-10    BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'nesting_offl_parameters', line )
-
-20    CONTINUE
-
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
+
+
+    NAMELIST /nesting_offl_parameters/  nesting_offline
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, nesting_offl_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status > 0 )  THEN
+!
+!--    nesting_offl_parameters namelist was found but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'nesting_offl_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE nesting_offl_parin
+
 
 !--------------------------------------------------------------------------------------------------!
@@ -2500,4 +2499,5 @@
 
  END SUBROUTINE nesting_offl_header
+
 
 !--------------------------------------------------------------------------------------------------!
Index: /palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- /palm/trunk/SOURCE/ocean_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/ocean_mod.f90	(revision 4842)
@@ -24,4 +24,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! file re-formatted to follow the PALM coding standard
 !
@@ -572,37 +576,48 @@
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-
-    NAMELIST /ocean_parameters/  bc_sa_t, bottom_salinityflux, salinity, sa_surface,               &
-                                 sa_vertical_gradient, sa_vertical_gradient_level,                 &
-                                 stokes_waveheight, stokes_wavelength, surface_cooling_spinup_time,&
-                                 top_salinityflux, wall_salinityflux, wave_breaking
-
-!
-!-- Try to find the namelist
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&ocean_parameters' ) == 0 )
-       READ ( 11, '(A)', END=12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, ocean_parameters, ERR = 10 )
-!
-!-- Set switch that enables PALM's ocean mode
-    ocean_mode = .TRUE.
-
-    GOTO 12
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'ocean_parameters', line )
-
- 12 CONTINUE
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter
+                                 !< file
+    INTEGER(iwp)  ::  io_status  !< status after reading the namelist file
+
+
+    NAMELIST /ocean_parameters/  bc_sa_t,                                                          &
+                                 bottom_salinityflux,                                              &
+                                 salinity,                                                         &
+                                 sa_surface,                                                       &
+                                 sa_vertical_gradient,                                             &
+                                 sa_vertical_gradient_level,                                       &
+                                 stokes_waveheight,                                                &
+                                 stokes_wavelength,                                                &
+                                 surface_cooling_spinup_time,                                      &
+                                 top_salinityflux,                                                 &
+                                 wall_salinityflux,                                                &
+                                 wave_breaking
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist called
+!-- ocean_parameters.
+    REWIND( 11 )
+    READ( 11, ocean_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    ocean_parameters namelist was found and read correctly. Set switch that enables PALM's ocean
+!--    mode.
+       ocean_mode = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    ocean_parameters namelist was found but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'ocean_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE ocean_parin
+
 
 !--------------------------------------------------------------------------------------------------!
Index: /palm/trunk/SOURCE/parin.f90
===================================================================
--- /palm/trunk/SOURCE/parin.f90	(revision 4841)
+++ /palm/trunk/SOURCE/parin.f90	(revision 4842)
@@ -24,4 +24,9 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprecated namelists removed
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! file re-formatted to follow the PALM coding standard
 !
@@ -162,196 +167,12 @@
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter
+                                 !< file
 
     INTEGER(iwp) ::  global_id      !< process id with respect to MPI_COMM_WORLD
     INTEGER(iwp) ::  global_procs   !< # of procs with respect to MPI_COMM_WORLD
     INTEGER(iwp) ::  i              !<
-    INTEGER(iwp) ::  ioerr          !< error flag for open/read/write
-
-    NAMELIST /inipar/  alpha_surface,                                                              &
-                       approximation,                                                              &
-                       bc_e_b,                                                                     &
-                       bc_lr,                                                                      &
-                       bc_ns,                                                                      &
-                       bc_p_b,                                                                     &
-                       bc_p_t,                                                                     &
-                       bc_pt_b,                                                                    &
-                       bc_pt_t,                                                                    &
-                       bc_q_b,                                                                     &
-                       bc_q_t,                                                                     &
-                       bc_s_b,                                                                     &
-                       bc_s_t,                                                                     &
-                       bc_uv_b,                                                                    &
-                       bc_uv_t,                                                                    &
-                       building_height,                                                            &
-                       building_length_x,                                                          &
-                       building_length_y,                                                          &
-                       building_wall_left,                                                         &
-                       building_wall_south,                                                        &
-                       calc_soil_moisture_during_spinup,                                           &
-                       call_psolver_at_all_substeps,                                               &
-                       canyon_height,                                                              &
-                       canyon_wall_left,                                                           &
-                       canyon_wall_south,                                                          &
-                       canyon_width_x,                                                             &
-                       canyon_width_y,                                                             &
-                       cfl_factor,                                                                 &
-                       check_realistic_q,                                                          &
-                       cloud_droplets,                                                             &
-                       collective_wait,                                                            &
-                       complex_terrain,                                                            &
-                       conserve_volume_flow,                                                       &
-                       conserve_volume_flow_mode,                                                  &
-                       constant_flux_layer,                                                        &
-                       coupling_start_time,                                                        &
-                       cycle_mg,                                                                   &
-                       damp_level_1d,                                                              &
-                       data_output_during_spinup,                                                  &
-                       dissipation_1d,                                                             &
-                       dp_external,                                                                &
-                       dp_level_b,                                                                 &
-                       dp_smooth,                                                                  &
-                       dpdxy,                                                                      &
-                       dt,                                                                         &
-                       dt_pr_1d,                                                                   &
-                       dt_run_control_1d,                                                          &
-                       dt_spinup,                                                                  &
-                       dx,                                                                         &
-                       dy,                                                                         &
-                       dz,                                                                         &
-                       dz_max,                                                                     &
-                       dz_stretch_factor,                                                          &
-                       dz_stretch_level,                                                           &
-                       dz_stretch_level_end,                                                       &
-                       dz_stretch_level_start,                                                     &
-                       e_init,                                                                     &
-                       e_min,                                                                      &
-                       end_time_1d,                                                                &
-                       ensemble_member_nr,                                                         &
-                       fft_method,                                                                 &
-                       flux_input_mode,                                                            &
-                       flux_output_mode,                                                           &
-                       galilei_transformation,                                                     &
-                       humidity,                                                                   &
-                       inflow_damping_height,                                                      &
-                       inflow_damping_width,                                                       &
-                       inflow_disturbance_begin,                                                   &
-                       inflow_disturbance_end,                                                     &
-                       initializing_actions,                                                       &
-                       km_constant,                                                                &
-                       large_scale_forcing,                                                        &
-                       large_scale_subsidence,                                                     &
-                       latitude,                                                                   &
-                       longitude,                                                                  &
-                       loop_optimization,                                                          &
-                       lsf_exception,                                                              &
-                       masking_method,                                                             &
-                       mg_cycles,                                                                  &
-                       mg_switch_to_pe0_level,                                                     &
-                       mixing_length_1d,                                                           &
-                       momentum_advec,                                                             &
-                       monotonic_limiter_z,                                                        &
-                       netcdf_precision,                                                           &
-                       neutral,                                                                    &
-                       ngsrb,                                                                      &
-                       nsor,                                                                       &
-                       nsor_ini,                                                                   &
-                       nudging,                                                                    &
-                       nx,                                                                         &
-                       ny,                                                                         &
-                       nz,                                                                         &
-                       ocean_mode,                                                                 &
-                       omega,                                                                      &
-                       omega_sor,                                                                  &
-                       origin_date_time,                                                           &
-                       outflow_source_plane,                                                       &
-                       passive_scalar,                                                             &
-                       prandtl_number,                                                             &
-                       psolver,                                                                    &
-                       pt_damping_factor,                                                          &
-                       pt_damping_width,                                                           &
-                       pt_reference,                                                               &
-                       pt_surface,                                                                 &
-                       pt_surface_heating_rate,                                                    &
-                       pt_surface_initial_change,                                                  &
-                       pt_vertical_gradient,                                                       &
-                       pt_vertical_gradient_level,                                                 &
-                       q_surface,                                                                  &
-                       q_surface_initial_change,                                                   &
-                       q_vertical_gradient,                                                        &
-                       q_vertical_gradient_level,                                                  &
-                       random_generator,                                                           &
-                       random_heatflux,                                                            &
-                       rans_const_c,                                                               &
-                       rans_const_sigma,                                                           &
-                       rayleigh_damping_factor,                                                    &
-                       rayleigh_damping_height,                                                    &
-                       recycling_method_for_thermodynamic_quantities,                              &
-                       recycling_width,                                                            &
-                       reference_state,                                                            &
-                       residual_limit,                                                             &
-                       rotation_angle,                                                             &
-                       roughness_length,                                                           &
-                       scalar_advec,                                                               &
-                       scalar_rayleigh_damping,                                                    &
-                       spinup_time,                                                                &
-                       spinup_pt_amplitude,                                                        &
-                       spinup_pt_mean,                                                             &
-                       statistic_regions,                                                          &
-                       subs_vertical_gradient,                                                     &
-                       subs_vertical_gradient_level,                                               &
-                       surface_heatflux,                                                           &
-                       surface_pressure,                                                           &
-                       surface_scalarflux,                                                         &
-                       surface_waterflux,                                                          &
-                       s_surface,                                                                  &
-                       s_surface_initial_change,                                                   &
-                       s_vertical_gradient,                                                        &
-                       s_vertical_gradient_level,                                                  &
-                       timestep_scheme,                                                            &
-                       topography,                                                                 &
-                       topography_grid_convention,                                                 &
-                       top_heatflux,                                                               &
-                       top_momentumflux_u,                                                         &
-                       top_momentumflux_v,                                                         &
-                       top_scalarflux,                                                             &
-                       transpose_compute_overlap,                                                  &
-                       tunnel_height,                                                              &
-                       tunnel_length,                                                              &
-                       tunnel_wall_depth,                                                          &
-                       tunnel_width_x,                                                             &
-                       tunnel_width_y,                                                             &
-                       turbulence_closure,                                                         &
-                       turbulent_inflow,                                                           &
-                       turbulent_outflow,                                                          &
-                       u_bulk,                                                                     &
-                       u_profile,                                                                  &
-                       ug_surface,                                                                 &
-                       ug_vertical_gradient,                                                       &
-                       ug_vertical_gradient_level,                                                 &
-                       use_cmax,                                                                   &
-                       use_fixed_date,                                                             &
-                       use_fixed_time,                                                             &
-                       use_free_convection_scaling,                                                &
-                       use_ug_for_galilei_tr,                                                      &
-                       use_subsidence_tendencies,                                                  &
-                       use_surface_fluxes,                                                         &
-                       use_top_fluxes,                                                             &
-                       use_upstream_for_tke,                                                       &
-                       uv_heights,                                                                 &
-                       v_bulk,                                                                     &
-                       v_profile,                                                                  &
-                       vdi_checks,                                                                 &
-                       vg_surface,                                                                 &
-                       vg_vertical_gradient,                                                       &
-                       vg_vertical_gradient_level,                                                 &
-                       wall_adjustment,                                                            &
-                       wall_heatflux,                                                              &
-                       wall_humidityflux,                                                          &
-                       wall_scalarflux,                                                            &
-                       y_shift,                                                                    &
-                       zeta_max,                                                                   &
-                       zeta_min,                                                                   &
-                       z0h_factor
+    INTEGER(iwp) ::  io_status      !< status after reading the namelist files
+
 
     NAMELIST /initialization_parameters/  alpha_surface,                                           &
@@ -541,74 +362,4 @@
                                           z0h_factor
 
-    NAMELIST /d3par/  averaging_interval,                                                          &
-                      averaging_interval_pr,                                                       &
-                      cpu_log_barrierwait,                                                         &
-                      create_disturbances,                                                         &
-                      cross_profiles,                                                              &
-                      data_output,                                                                 &
-                      data_output_2d_on_each_pe,                                                   &
-                      data_output_masks,                                                           &
-                      data_output_pr,                                                              &
-                      debug_output,                                                                &
-                      debug_output_timestep,                                                       &
-                      disturbance_amplitude,                                                       &
-                      disturbance_energy_limit,                                                    &
-                      disturbance_level_b,                                                         &
-                      disturbance_level_t,                                                         &
-                      do2d_at_begin,                                                               &
-                      do3d_at_begin,                                                               &
-                      dt,                                                                          &
-                      dt_averaging_input,                                                          &
-                      dt_averaging_input_pr,                                                       &
-                      dt_coupling,                                                                 &
-                      dt_data_output,                                                              &
-                      dt_data_output_av,                                                           &
-                      dt_disturb,                                                                  &
-                      dt_domask,                                                                   &
-                      dt_dopr,                                                                     &
-                      dt_dopr_listing,                                                             &
-                      dt_dots,                                                                     &
-                      dt_do2d_xy,                                                                  &
-                      dt_do2d_xz,                                                                  &
-                      dt_do2d_yz,                                                                  &
-                      dt_do3d,                                                                     &
-                      dt_max,                                                                      &
-                      dt_restart,                                                                  &
-                      dt_run_control,                                                              &
-                      end_time,                                                                    &
-                      force_print_header,                                                          &
-                      mask_k_over_surface,                                                         &
-                      mask_scale_x,                                                                &
-                      mask_scale_y,                                                                &
-                      mask_scale_z,                                                                &
-                      mask_x,                                                                      &
-                      mask_y,                                                                      &
-                      mask_z,                                                                      &
-                      mask_x_loop,                                                                 &
-                      mask_y_loop,                                                                 &
-                      mask_z_loop,                                                                 &
-                      netcdf_data_format,                                                          &
-                      netcdf_deflate,                                                              &
-                      normalizing_region,                                                          &
-                      npex,                                                                        &
-                      npey,                                                                        &
-                      nz_do3d,                                                                     &
-                      profile_columns,                                                             &
-                      profile_rows,                                                                &
-                      restart_time,                                                                &
-                      section_xy,                                                                  &
-                      section_xz,                                                                  &
-                      section_yz,                                                                  &
-                      skip_time_data_output,                                                       &
-                      skip_time_data_output_av,                                                    &
-                      skip_time_dopr,                                                              &
-                      skip_time_do2d_xy,                                                           &
-                      skip_time_do2d_xz,                                                           &
-                      skip_time_do2d_yz,                                                           &
-                      skip_time_do3d,                                                              &
-                      skip_time_domask,                                                            &
-                      synchronous_exchange,                                                        &
-                      termination_time_needed
-
     NAMELIST /runtime_parameters/  averaging_interval,                                             &
                                    averaging_interval_pr,                                          &
@@ -699,18 +450,17 @@
     CALL location_message( 'reading environment parameters from ENVPAR', 'start' )
 
-    OPEN( 90, FILE='ENVPAR', STATUS='OLD', FORM='FORMATTED', IOSTAT=ioerr )
-
-    IF ( ioerr /= 0 )  THEN
+    OPEN( 90, FILE='ENVPAR', STATUS='OLD', FORM='FORMATTED', IOSTAT=io_status )
+
+    IF ( io_status /= 0 )  THEN
        message_string = 'local file ENVPAR not found' //                                           &
                         '&some variables for steering may not be properly set'
        CALL message( 'parin', 'PA0276', 0, 1, 0, 6, 0 )
     ELSE
-       READ( 90, envpar, IOSTAT=ioerr )
-       IF ( ioerr < 0 )  THEN
+       READ( 90, envpar, IOSTAT=io_status )
+       IF ( io_status < 0 )  THEN
           message_string = 'no envpar-NAMELIST found in local file '  //                           &
-                           'ENVPAR& or some variables for steering may '  //   &
-                           'not be properly set'
+                           'ENVPAR& or some variables for steering may not be properly set'
           CALL message( 'parin', 'PA0278', 0, 1, 0, 6, 0 )
-       ELSEIF ( ioerr > 0 )  THEN
+       ELSEIF ( io_status > 0 )  THEN
           message_string = 'errors in local file ENVPAR' //                                        &
                            '&some variables for steering may not be properly set'
@@ -730,74 +480,40 @@
 !
 !-- Read the control parameters for initialization.
-!-- The namelist "inipar" must be provided in the NAMELIST-file.
-    READ ( 11, initialization_parameters, ERR=10, END=11 )
-    GOTO 14
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'initialization_parameters', line )
-
- 11 REWIND ( 11 )
-    READ( 11, inipar, ERR=12, END=13 )
-
-    message_string = 'namelist inipar is deprecated and will be ' //                               &
-                     'removed in near future. & Please use namelist ' //                           &
-                     'initialization_parameters instead'
-    CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
-
-    GOTO 14
-
- 12 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'inipar', line )
-
- 13 message_string = 'no initialization_parameters-namelist found'
-    CALL message( 'parin', 'PA0272', 1, 2, 0, 6, 0 )
-
+!-- The namelist "initialisation_parameters" must be provided in the NAMELIST-file.
+    READ( 11, initialization_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status > 0 )  THEN
+!
+!--    initialisation_parameters namelist was found but countained errors. Print an error message
+!-     including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'initialization_parameters', line )
+
+    ELSEIF ( io_status < 0 )  THEN
+!
+!--    initialisation_parametes namelist was not found. Return a message.
+       message_string = 'no initialization_parameters-namelist found'
+       CALL message( 'parin', 'PA0272', 1, 2, 0, 6, 0 )
+
+    ENDIF
 !
 !-- Try to read runtime parameters given by the user for this run (namelist "runtime_parameters").
 !-- The namelist "runtime_parmeters" can be omitted. In that case default values are used for the
 !-- parameters.
- 14 line = ' '
-
     REWIND( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
-       READ( 11, '(A)', END=16 )  line
-    ENDDO
-    BACKSPACE( 11 )
-
-!
-!-- Read namelist
-    READ( 11, runtime_parameters, ERR = 15 )
-    GOTO 18
-
- 15 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'runtime_parameters', line )
-
- 16 REWIND( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&d3par' ) == 0 )
-       READ( 11, '(A)', END=18 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ( 11, d3par, ERR = 17, END = 18 )
-
-    message_string = 'namelist d3par is deprecated and will be ' //                                &
-                     'removed in near future. &Please use namelist ' //                            &
-                     'runtime_parameters instead'
-    CALL message( 'parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-    GOTO 18
-
- 17 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'd3par', line )
-
- 18 CONTINUE
+    READ( 11, runtime_parameters, IOSTAT=io_status )
+
+    IF ( io_status > 0 )  THEN
+!
+!--    Namelist runtime_parameters was found but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'runtime_parameters', line )
+
+    ENDIF
 
 !
Index: /palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4842)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprecaed namelist name removed
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! file re-formatted to follow the PALM coding standard
 !
@@ -1550,93 +1555,51 @@
 !> Parin for &plant_canopy_parameters for plant canopy model
 !--------------------------------------------------------------------------------------------------!
-    SUBROUTINE pcm_parin
-
-       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-       NAMELIST /plant_canopy_parameters/  alpha_lad,                                              &
-                                           beta_lad,                                               &
-                                           canopy_drag_coeff,                                      &
-                                           canopy_mode,                                            &
-                                           cthf,                                                   &
-                                           lad_surface,                                            &
-                                           lad_type_coef,                                          &
-                                           lad_vertical_gradient,                                  &
-                                           lad_vertical_gradient_level,                            &
-                                           lai_beta,                                               &
-                                           leaf_scalar_exch_coeff,                                 &
-                                           leaf_surface_conc,                                      &
-                                           pch_index,                                              &
-                                           plant_canopy_transpiration
-
-       NAMELIST /canopy_par/               alpha_lad,                                              &
-                                           beta_lad,                                               &
-                                           canopy_drag_coeff,                                      &
-                                           canopy_mode,                                            &
-                                           cthf,                                                   &
-                                           lad_surface,                                            &
-                                           lad_type_coef,                                          &
-                                           lad_vertical_gradient,                                  &
-                                           lad_vertical_gradient_level,                            &
-                                           lai_beta,                                               &
-                                           leaf_scalar_exch_coeff,                                 &
-                                           leaf_surface_conc,                                      &
-                                           pch_index,                                              &
-                                           plant_canopy_transpiration
-
-       line = ' '
-
-!
-!--    Try to find plant-canopy model package
-       REWIND( 11 )
-       line = ' '
-       DO WHILE ( INDEX( line, '&plant_canopy_parameters' ) == 0 )
-          READ( 11, '(A)', END=12 )  line
-       ENDDO
+ SUBROUTINE pcm_parin
+
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
+
+
+    NAMELIST /plant_canopy_parameters/  alpha_lad,                                                 &
+                                        beta_lad,                                                  &
+                                        canopy_drag_coeff,                                         &
+                                        canopy_mode,                                               &
+                                        cthf,                                                      &
+                                        lad_surface,                                               &
+                                        lad_type_coef,                                             &
+                                        lad_vertical_gradient,                                     &
+                                        lad_vertical_gradient_level,                               &
+                                        lai_beta,                                                  &
+                                        leaf_scalar_exch_coeff,                                    &
+                                        leaf_surface_conc,                                         &
+                                        pch_index,                                                 &
+                                        plant_canopy_transpiration
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the user-defined namelist
+!-- plant_canopy_parameters.
+    REWIND( 11 )
+    READ( 11, plant_canopy_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    plant_canopy_parameters namelist was found and read correctly. Set flag that indicates that
+!--    the plant-canopy model is switched on.
+       plant_canopy = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    plant_canopy_parameters namelist was found but contained errors. Print an error message
+!--    including the line that caused the problem.
        BACKSPACE( 11 )
-
-!
-!--    Read user-defined namelist
-       READ( 11, plant_canopy_parameters, ERR = 10 )
-
-!
-!--    Set flag that indicates that the plant-canopy model is switched on
-       plant_canopy = .TRUE.
-
-       GOTO 14
-
- 10    BACKSPACE( 11 )
-       READ( 11 , '(A)') line
+       READ( 11 , '(A)' ) line
        CALL parin_fail_message( 'plant_canopy_parameters', line )
-!
-!--    Try to find old namelist
- 12    REWIND( 11 )
-       line = ' '
-       DO WHILE ( INDEX( line, '&canopy_par' ) == 0 )
-          READ( 11, '(A)', END=14 )  line
-       ENDDO
-       BACKSPACE( 11 )
-
-!
-!--    Read user-defined namelist
-       READ( 11, canopy_par, ERR = 13, END = 14 )
-
-       message_string = 'namelist canopy_par is deprecated and will be ' //                        &
-                        'removed in near future. Please use namelist ' //                          &
-                        'plant_canopy_parameters instead'
-       CALL message( 'pcm_parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-!
-!--    Set flag that indicates that the plant-canopy model is switched on
-       plant_canopy = .TRUE.
-
-       GOTO 14
-
- 13    BACKSPACE( 11 )
-       READ( 11 , '(A)') line
-       CALL parin_fail_message( 'canopy_par', line )
-
- 14    CONTINUE
-
-    END SUBROUTINE pcm_parin
+
+    ENDIF
+
+ END SUBROUTINE pcm_parin
 
 
Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4842)
@@ -27,5 +27,10 @@
 ! -----------------
 ! $Id$
-! openmp bugfix: some missing arrays added to reduction clause 
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprectaed namelist name removed
+!
+! 4836 2021-01-07 13:58:12Z raasch
+! openmp bugfix: some missing arrays added to reduction clause
 !
 ! 4824 2020-12-12 20:45:23Z moh.hefny
@@ -717,34 +722,34 @@
                                    0.06_wp, 0.06_wp, 0.06_wp,            & !  1 - ocean
                                    0.19_wp, 0.28_wp, 0.09_wp,            & !  2 - mixed farming, tall grassland
-                                   0.23_wp, 0.33_wp, 0.11_wp,            & !  3 - tall/medium grassland 
-                                   0.23_wp, 0.33_wp, 0.11_wp,            & !  4 - evergreen shrubland 
-                                   0.25_wp, 0.34_wp, 0.14_wp,            & !  5 - short grassland/meadow/shrubland 
-                                   0.14_wp, 0.22_wp, 0.06_wp,            & !  6 - evergreen needleleaf forest 
-                                   0.17_wp, 0.27_wp, 0.06_wp,            & !  7 - mixed deciduous forest 
-                                   0.19_wp, 0.31_wp, 0.06_wp,            & !  8 - deciduous forest 
+                                   0.23_wp, 0.33_wp, 0.11_wp,            & !  3 - tall/medium grassland
+                                   0.23_wp, 0.33_wp, 0.11_wp,            & !  4 - evergreen shrubland
+                                   0.25_wp, 0.34_wp, 0.14_wp,            & !  5 - short grassland/meadow/shrubland
+                                   0.14_wp, 0.22_wp, 0.06_wp,            & !  6 - evergreen needleleaf forest
+                                   0.17_wp, 0.27_wp, 0.06_wp,            & !  7 - mixed deciduous forest
+                                   0.19_wp, 0.31_wp, 0.06_wp,            & !  8 - deciduous forest
                                    0.14_wp, 0.22_wp, 0.06_wp,            & !  9 - tropical evergreen broadleaved forest
-                                   0.18_wp, 0.28_wp, 0.06_wp,            & ! 10 - medium/tall grassland/woodland 
-                                   0.43_wp, 0.51_wp, 0.35_wp,            & ! 11 - desert, sandy 
-                                   0.32_wp, 0.40_wp, 0.24_wp,            & ! 12 - desert, rocky 
-                                   0.19_wp, 0.27_wp, 0.10_wp,            & ! 13 - tundra 
-                                   0.77_wp, 0.65_wp, 0.90_wp,            & ! 14 - land ice 
-                                   0.77_wp, 0.65_wp, 0.90_wp,            & ! 15 - sea ice 
-                                   0.82_wp, 0.70_wp, 0.95_wp,            & ! 16 - snow 
-                                   0.08_wp, 0.08_wp, 0.08_wp,            & ! 17 - bare soil 
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 18 - asphalt/concrete mix 
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 19 - asphalt (asphalt concrete) 
-                                   0.30_wp, 0.30_wp, 0.30_wp,            & ! 20 - concrete (Portland concrete) 
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 21 - sett 
+                                   0.18_wp, 0.28_wp, 0.06_wp,            & ! 10 - medium/tall grassland/woodland
+                                   0.43_wp, 0.51_wp, 0.35_wp,            & ! 11 - desert, sandy
+                                   0.32_wp, 0.40_wp, 0.24_wp,            & ! 12 - desert, rocky
+                                   0.19_wp, 0.27_wp, 0.10_wp,            & ! 13 - tundra
+                                   0.77_wp, 0.65_wp, 0.90_wp,            & ! 14 - land ice
+                                   0.77_wp, 0.65_wp, 0.90_wp,            & ! 15 - sea ice
+                                   0.82_wp, 0.70_wp, 0.95_wp,            & ! 16 - snow
+                                   0.08_wp, 0.08_wp, 0.08_wp,            & ! 17 - bare soil
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 18 - asphalt/concrete mix
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 19 - asphalt (asphalt concrete)
+                                   0.30_wp, 0.30_wp, 0.30_wp,            & ! 20 - concrete (Portland concrete)
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 21 - sett
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 22 - paving stones
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 23 - cobblestone 
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 23 - cobblestone
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 24 - metal
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 25 - wood
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 26 - gravel
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 27 - fine gravel 
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 28 - pebblestone 
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 27 - fine gravel
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 28 - pebblestone
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 29 - woodchips
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 30 - tartan (sports)
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 31 - artificial turf (sports)
-                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 32 - clay (sports) 
+                                   0.17_wp, 0.17_wp, 0.17_wp,            & ! 32 - clay (sports)
                                    0.17_wp, 0.17_wp, 0.17_wp,            & ! 33 - building (dummy)
                                    0.60_wp, 0.60_wp, 0.60_wp,            & ! 34 - building wall type 1 - reflecting facade
@@ -4105,42 +4110,9 @@
  SUBROUTINE radiation_parin
 
-
     IMPLICIT NONE
 
-    CHARACTER(LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-    NAMELIST /radiation_par/   albedo,                                                             &
-                               albedo_lw_dif,                                                      &
-                               albedo_lw_dir,                                                      &
-                               albedo_sw_dif,                                                      &
-                               albedo_sw_dir,                                                      &
-                               albedo_type,                                                        &
-                               bufsize_alltoall,                                                   &
-                               constant_albedo,                                                    &
-                               dt_radiation,                                                       &
-                               emissivity,                                                         &
-                               lw_radiation,                                                       &
-                               max_raytracing_dist,                                                &
-                               min_irrf_value,                                                     &
-                               mrt_geom,                                                           &
-                               mrt_geom_params,                                                    &
-                               mrt_include_sw,                                                     &
-                               mrt_nlevels,                                                        &
-                               mrt_skip_roof,                                                      &
-                               net_radiation,                                                      &
-                               nrefsteps,                                                          &
-                               plant_lw_interact,                                                  &
-                               rad_angular_discretization,                                         &
-                               radiation_interactions_on,                                          &
-                               radiation_scheme,                                                   &
-                               raytrace_discrete_azims,                                            &
-                               raytrace_discrete_elevs,                                            &
-                               raytrace_mpi_rma,                                                   &
-                               trace_fluxes_above,                                                 &
-                               skip_time_do_radiation,                                             &
-                               surface_reflections,                                                &
-                               svfnorm_report_thresh,                                              &
-                               sw_radiation,                                                       &
-                               unscheduled_radiation_calls
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
 
 
@@ -4179,62 +4151,26 @@
                                     unscheduled_radiation_calls
 
-    line = ' '
-
-!
-!-- Try to find radiation model namelist
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
     REWIND( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&radiation_parameters' ) == 0 )
-       READ( 11, '(A)', END = 12 )  line
-    ENDDO
-    BACKSPACE( 11 )
-
-!
-!-- Read user-defined namelist
-    READ( 11, radiation_parameters, ERR = 10 )
-
-!
-!-- Set flag that indicates that the radiation model is switched on
-    radiation = .TRUE.
-
-    GOTO 14
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'radiation_parameters', line )
-!
-!-- Try to find old namelist
- 12 REWIND( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&radiation_par' ) == 0 )
-       READ( 11, '(A)', END = 14 )  line
-    ENDDO
-    BACKSPACE( 11 )
-
-!
-!-- Read user-defined namelist
-    READ( 11, radiation_par, ERR = 13, END = 14 )
-
-    message_string = 'namelist radiation_par is deprecated and will be removed in near future. '// &
-                     'Please use namelist radiation_parameters instead'
-    CALL message( 'radiation_parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-!
-!-- Set flag that indicates that the radiation model is switched on
-    radiation = .TRUE.
-
-    IF ( .NOT.  radiation_interactions_on  .AND.  surface_reflections )  THEN
-       message_string = 'surface_reflections is allowed only when ' //                             &
-                        'radiation_interactions_on is set to TRUE'
-       CALL message( 'radiation_parin', 'PA0293',1, 2, 0, 6, 0 )
+    READ( 11, radiation_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    radiation_parameters namelist was found and read correctly. Set flag that indicates that the
+!--    radiation model is switched on.
+       radiation = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    radiation_parameters namelist was found but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'radiation_parameters', line )
+
     ENDIF
-
-    GOTO 14
-
- 13 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'radiation_par', line )
-
- 14 CONTINUE
 
  END SUBROUTINE radiation_parin
Index: /palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- /palm/trunk/SOURCE/salsa_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/salsa_mod.f90	(revision 4842)
@@ -3,7 +3,7 @@
 ! This file is part of PALM-4U.
 !
-! PALM-4U is free software: you can redistribute it and/or modify it under the 
-! terms of the GNU General Public License as published by the Free Software 
-! Foundation, either version 3 of the License, or (at your option) any later 
+! PALM-4U is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
 ! version.
 !
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Bugfix in obtaining the correct timestamp in case of restart runs
 !
@@ -39,43 +43,43 @@
 ! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
-! 
+!
 ! 4535 2020-05-15 12:07:23Z raasch
 ! bugfix for restart data format query
-! 
+!
 ! 4527 2020-05-11 09:39:55Z monakurppa
 ! Correct a bug in salsa_wrd_global and salsa_check_data_output,
 ! and add reglim to be read/written in the restart data
-! 
+!
 ! 4525 2020-05-10 17:05:07Z raasch
 ! added reading/writing of global restart data,
 ! added reading/writing restart data with MPI-IO,
 ! variable write_binary_salsa removed
-! 
+!
 ! 4512 2020-04-30 12:55:34Z monakurppa
 ! Fixed a bug in component_index_constructor: index out of bounds if all chemical
 ! components are used
-! 
+!
 ! 4508 2020-04-24 13:32:20Z raasch
 ! decycling replaced by explicit setting of lateral boundary conditions (Siggi)
-! 
+!
 ! 4487 2020-04-03 09:38:20Z raasch
 ! bugfix for subroutine calls that contain the decycle_salsa switches as arguments
-! 
+!
 ! 4481 2020-03-31 18:55:54Z maronga
 ! Bug fix to the previous commit: the logical switch monotonic_limiter_z missing
 ! from advec_s_ws in salsa_tendency_ij
-! 
+!
 ! 4478 2020-03-27 14:06:23Z monakurppa
 ! Bug fixes:
 ! - call salsa_driver in salsa_init also for the ghost points
 ! - decycle flags missing from advec_s_ws call in salsa_tendency
-! 
+!
 ! 4457 2020-03-11 14:20:43Z raasch
 ! use statement for exchange horiz added
-! 
+!
 ! 4442 2020-03-04 19:21:13Z suehring
-! Change order of dimension in surface array %frac to allow for better 
+! Change order of dimension in surface array %frac to allow for better
 ! vectorization.
-! 
+!
 ! 4441 2020-03-04 19:20:35Z suehring
 ! Bug fixes and reformatting for the restart data and averaged data output
@@ -86,8 +90,8 @@
 !   chemical components: set to 4d arrays instead of separate arrays
 ! - add allocation checks for averaged data output arrays
-! 
+!
 ! 4416 2020-02-20 17:53:57Z monakurppa
 ! Time index error in salsa_emission_setup
-! 
+!
 ! 4380 2020-01-17 23:39:51Z monakurppa
 ! - Error in saving the surface fluxes in an array that is applied in the
@@ -95,32 +99,32 @@
 ! - Corrections in the header: aerosol bin diameters and lower bin limits not
 !   printed correctly
-! 
+!
 ! 4364 2020-01-08 02:12:31Z monakurppa
 ! Set time coordinate in the input data relative to origin_time rather than to
 ! 00:00:00 UTC
-! 
+!
 ! 4360 2020-01-07 11:25:50Z suehring
 ! Introduction of wall_flags_total_0, which currently sets bits based on static
 ! topography information used in wall_flags_static_0
-! 
+!
 ! 4342 2019-12-16 13:49:14Z Giersch
 ! cdc replaced by canopy_drag_coeff
-! 
+!
 ! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
-! 
+!
 ! 4315 2019-12-02 09:20:07Z monakurppa
 ! Add an additional check for the time dimension PIDS_SALSA in
 ! salsa_emission_setup and correct some error message identifiers.
-! 
+!
 ! 4298 2019-11-21 15:59:16Z suehring
 ! Bugfix, close netcdf input files after reading
-! 
+!
 ! 4295 2019-11-14 06:15:31Z monakurppa
-! 
-! 
+!
+!
 ! 4280 2019-10-29 14:34:15Z monakurppa
 ! Corrected a bug in boundary conditions and fac_dt in offline nesting
-! 
+!
 ! 4273 2019-10-24 13:40:54Z monakurppa
 ! - Rename nest_salsa to nesting_salsa
@@ -129,5 +133,5 @@
 !   chemistry module is applied
 ! - Set the default value of nesting_salsa and nesting_offline_salsa to .TRUE.
-! 
+!
 ! 4272 2019-10-23 15:18:57Z schwenkel
 ! Further modularization of boundary conditions: moved boundary conditions to
@@ -144,24 +148,24 @@
 ! - Reformat salsa emission data with LOD=2: size distribution given for each
 !   emission category
-! 
+!
 ! 4268 2019-10-17 11:29:38Z schwenkel
 ! Moving module specific boundary conditions from time_integration to module
-! 
+!
 ! 4256 2019-10-07 10:08:52Z monakurppa
 ! Document previous changes: use global variables nx, ny and nz in salsa_header
-! 
+!
 ! 4227 2019-09-10 18:04:34Z gronemeier
 ! implement new palm_date_time_mod
-! 
+!
 ! 4226 2019-09-10 17:03:24Z suehring
 ! Netcdf input routine for dimension length renamed
-! 
+!
 ! 4182 2019-08-22 15:20:23Z scharf
 ! Corrected "Former revisions" section
-! 
+!
 ! 4167 2019-08-16 11:01:48Z suehring
-! Changed behaviour of masked output over surface to follow terrain and ignore 
+! Changed behaviour of masked output over surface to follow terrain and ignore
 ! buildings (J.Resler, T.Gronemeier)
-! 
+!
 ! 4131 2019-08-02 11:06:18Z monakurppa
 ! - Add "salsa_" before each salsa output variable
@@ -174,5 +178,5 @@
 ! - Add the z-dimension for gaseous emissions to correspond the implementation
 !   in the chemistry module
-! 
+!
 ! 4118 2019-07-25 16:11:45Z suehring
 ! - When Dirichlet condition is applied in decycling, the boundary conditions are
@@ -189,25 +193,25 @@
 !   This is done to overcome high concentration peaks due to stationary numerical
 !   oscillations caused by horizontal advection discretization.
-! 
+!
 ! 4117 2019-07-25 08:54:02Z monakurppa
-! Pass integer flag array as well as boundary flags to WS scalar advection 
+! Pass integer flag array as well as boundary flags to WS scalar advection
 ! routine
-! 
+!
 ! 4109 2019-07-22 17:00:34Z suehring
-! Slightly revise setting of boundary conditions at horizontal walls, use 
+! Slightly revise setting of boundary conditions at horizontal walls, use
 ! data-structure offset index instead of pre-calculate it for each facing
-! 
+!
 ! 4079 2019-07-09 18:04:41Z suehring
-! Application of monotonic flux limiter for the vertical scalar advection 
-! up to the topography top (only for the cache-optimized version at the 
+! Application of monotonic flux limiter for the vertical scalar advection
+! up to the topography top (only for the cache-optimized version at the
 ! moment).
-! 
+!
 ! 4069 2019-07-01 14:05:51Z Giersch
-! Masked output running index mid has been introduced as a local variable to 
+! Masked output running index mid has been introduced as a local variable to
 ! avoid runtime error (Loop variable has been modified) in time_integration
-! 
+!
 ! 4058 2019-06-27 15:25:42Z knoop
 ! Bugfix: to_be_resorted was uninitialized in case of s_H2O in 3d_data_averaging
-! 
+!
 ! 4012 2019-05-31 15:19:05Z monakurppa
 ! Merge salsa branch to trunk. List of changes:
@@ -221,5 +225,5 @@
 ! - stuff from salsa_util_mod.f90 moved into salsa_mod.f90
 ! - calls for closing the netcdf input files added
-! 
+!
 ! 3956 2019-05-07 12:32:52Z monakurppa
 ! - Conceptual bug in depo_surf correct for urban and land surface model
@@ -229,8 +233,8 @@
 !   salsa_exchange_horiz_bounds after calling salsa_driver only when needed
 !   (i.e. every dt_salsa).
-! 
+!
 ! 3924 2019-04-23 09:33:06Z monakurppa
 ! Correct a bug introduced by the previous update.
-! 
+!
 ! 3899 2019-04-16 14:05:27Z monakurppa
 ! - remove unnecessary error / location messages
@@ -239,10 +243,10 @@
 !
 ! 3885 2019-04-11 11:29:34Z kanani
-! Changes related to global restructuring of location messages and introduction 
+! Changes related to global restructuring of location messages and introduction
 ! of additional debug messages
-! 
+!
 ! 3876 2019-04-08 18:41:49Z knoop
 ! Introduced salsa_actions module interface
-! 
+!
 ! 3871 2019-04-08 14:38:39Z knoop
 ! Major changes in formatting, performance and data input structure (see branch
@@ -255,5 +259,5 @@
 !   surface_aerosol_flux, aerosol_flux_dpg/sigmag/mass_fracs_a/mass_fracs_b.
 ! - All emissions are now implemented as surface fluxes! No 3D sources anymore.
-! - Update the emission information by calling salsa_emission_update if 
+! - Update the emission information by calling salsa_emission_update if
 !   skip_time_do_salsa >= time_since_reference_point and
 !   next_aero_emission_update <= time_since_reference_point
@@ -280,17 +284,17 @@
 ! - Removed tailing white spaces and unused variables
 ! - Change error message to start by PA instead of SA
-! 
+!
 ! 3833 2019-03-28 15:04:04Z forkel
-! added USE chem_gasphase_mod for nvar, nspec and spc_names 
-! 
+! added USE chem_gasphase_mod for nvar, nspec and spc_names
+!
 ! 3787 2019-03-07 08:43:54Z raasch
 ! unused variables removed
-! 
+!
 ! 3780 2019-03-05 11:19:45Z forkel
 ! unused variable for file index removed from rrd-subroutines parameter list
-! 
+!
 ! 3685 2019-01-21 01:02:11Z knoop
 ! Some interface calls moved to module_interface + cleanup
-! 
+!
 ! 3655 2019-01-07 16:51:22Z knoop
 ! Implementation of the PALM module interface
@@ -438,6 +442,6 @@
         (/0.0,   0.056, 0.0,   0.056, 0.056, 0.042, 0.056, -99., 0.042,0.014,0.056, -99., -99., -99., 0.056/)
 !
-!-- Constants for the dry deposition model by Zhang et al. (2001): 
-!-- empirical constants "alpha" and "gamma" and characteristic radius "A" for 
+!-- Constants for the dry deposition model by Zhang et al. (2001):
+!-- empirical constants "alpha" and "gamma" and characteristic radius "A" for
 !-- each land use category (15) and season (5)
     REAL(wp), DIMENSION(1:15), PARAMETER :: alpha_z01 = &
@@ -445,5 +449,5 @@
     REAL(wp), DIMENSION(1:15), PARAMETER :: gamma_z01 = &
         (/0.56, 0.58, 0.56, 0.56, 0.56, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.50, 0.50, 0.56/)
-    REAL(wp), DIMENSION(1:15,1:5), PARAMETER :: A_z01 =  RESHAPE( (/& 
+    REAL(wp), DIMENSION(1:15,1:5), PARAMETER :: A_z01 =  RESHAPE( (/&
          2.0, 5.0, 2.0,  5.0, 5.0, 2.0, 2.0, -99., -99., 10.0, 10.0, -99., -99., -99., 10.0,&  ! SC1
          2.0, 5.0, 2.0,  5.0, 5.0, 2.0, 2.0, -99., -99., 10.0, 10.0, -99., -99., -99., 10.0,&  ! SC2
@@ -1113,9 +1117,9 @@
  CONTAINS
 
-!------------------------------------------------------------------------------!
+!-------------------  -----------------------------------------------------------------------------!
 ! Description:
 ! ------------
 !> Parin for &salsa_par for new modules
-!------------------------------------------------------------------------------!
+!---------------------                    ---------------------------------------------------------!
  SUBROUTINE salsa_parin
 
@@ -1125,80 +1129,88 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=80) ::  line   !< dummy string that contains the current line of parameter file
+    CHARACTER(LEN=100) ::  line   !< dummy string that contains the current line of parameter file
 
     INTEGER(iwp) ::  i                 !< loop index
+    INTEGER(iwp) ::  io_status         !< status after reading the namelist file
     INTEGER(iwp) ::  max_pr_salsa_tmp  !< dummy variable
 
-    NAMELIST /salsa_parameters/      aerosol_flux_dpg,                         &
-                                     aerosol_flux_mass_fracs_a,                &
-                                     aerosol_flux_mass_fracs_b,                &
-                                     aerosol_flux_sigmag,                      &
-                                     advect_particle_water,                    &
-                                     bc_aer_b,                                 &
-                                     bc_aer_l,                                 &
-                                     bc_aer_n,                                 &
-                                     bc_aer_r,                                 &
-                                     bc_aer_s,                                 &
-                                     bc_aer_t,                                 &
-                                     depo_pcm_par,                             &
-                                     depo_pcm_type,                            &
-                                     depo_surf_par,                            &
-                                     dpg,                                      &
-                                     dt_salsa,                                 &
-                                     emiss_factor_main,                        &
-                                     emiss_factor_side,                        &
-                                     feedback_to_palm,                         &
-                                     h2so4_init,                               &
-                                     hno3_init,                                &
-                                     listspec,                                 &
-                                     main_street_id,                           &
-                                     mass_fracs_a,                             &
-                                     mass_fracs_b,                             &
-                                     max_street_id,                            &
-                                     n_lognorm,                                &
-                                     nbin,                                     &
-                                     nesting_salsa,                            &
-                                     nesting_offline_salsa,                    &
-                                     nf2a,                                     &
-                                     nh3_init,                                 &
-                                     nj3,                                      &
-                                     nlcnd,                                    &
-                                     nlcndgas,                                 &
-                                     nlcndh2oae,                               &
-                                     nlcoag,                                   &
-                                     nldepo,                                   &
-                                     nldepo_pcm,                               &
-                                     nldepo_surf,                              &
-                                     nldistupdate,                             &
-                                     nsnucl,                                   &
-                                     ocnv_init,                                &
-                                     ocsv_init,                                &
-                                     reglim,                                   &
-                                     salsa,                                    &
-                                     salsa_emission_mode,                      &
-                                     season_z01,                               &
-                                     sigmag,                                   &
-                                     side_street_id,                           &
-                                     skip_time_do_salsa,                       &
-                                     surface_aerosol_flux,                     &
+    NAMELIST /salsa_parameters/      aerosol_flux_dpg,                                             &
+                                     aerosol_flux_mass_fracs_a,                                    &
+                                     aerosol_flux_mass_fracs_b,                                    &
+                                     aerosol_flux_sigmag,                                          &
+                                     advect_particle_water,                                        &
+                                     bc_aer_b,                                                     &
+                                     bc_aer_l,                                                     &
+                                     bc_aer_n,                                                     &
+                                     bc_aer_r,                                                     &
+                                     bc_aer_s,                                                     &
+                                     bc_aer_t,                                                     &
+                                     depo_pcm_par,                                                 &
+                                     depo_pcm_type,                                                &
+                                     depo_surf_par,                                                &
+                                     dpg,                                                          &
+                                     dt_salsa,                                                     &
+                                     emiss_factor_main,                                            &
+                                     emiss_factor_side,                                            &
+                                     feedback_to_palm,                                             &
+                                     h2so4_init,                                                   &
+                                     hno3_init,                                                    &
+                                     listspec,                                                     &
+                                     main_street_id,                                               &
+                                     mass_fracs_a,                                                 &
+                                     mass_fracs_b,                                                 &
+                                     max_street_id,                                                &
+                                     n_lognorm,                                                    &
+                                     nbin,                                                         &
+                                     nesting_salsa,                                                &
+                                     nesting_offline_salsa,                                        &
+                                     nf2a,                                                         &
+                                     nh3_init,                                                     &
+                                     nj3,                                                          &
+                                     nlcnd,                                                        &
+                                     nlcndgas,                                                     &
+                                     nlcndh2oae,                                                   &
+                                     nlcoag,                                                       &
+                                     nldepo,                                                       &
+                                     nldepo_pcm,                                                   &
+                                     nldepo_surf,                                                  &
+                                     nldistupdate,                                                 &
+                                     nsnucl,                                                       &
+                                     ocnv_init,                                                    &
+                                     ocsv_init,                                                    &
+                                     reglim,                                                       &
+                                     salsa,                                                        &
+                                     salsa_emission_mode,                                          &
+                                     season_z01,                                                   &
+                                     sigmag,                                                       &
+                                     side_street_id,                                               &
+                                     skip_time_do_salsa,                                           &
+                                     surface_aerosol_flux,                                         &
                                      van_der_waals_coagc
 
-    line = ' '
-!
-!-- Try to find salsa package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&salsa_parameters' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-!
-!-- Read user-defined namelist
-    READ ( 11, salsa_parameters )
-!
-!-- Enable salsa (salsa switch in modules.f90)
-    salsa = .TRUE.
-
- 10 CONTINUE
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, salsa_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    salsa_parameters namelist was found and read correctly. Enable salsa (salsa switch in
+!--    modules.f90)
+       salsa = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    salsa_parameters namelist was found but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'salsa_parameters', line )
+
+    ENDIF
+
 !
 !-- Update the number of output profiles
@@ -1212,4 +1224,5 @@
 
  END SUBROUTINE salsa_parin
+
 
 !------------------------------------------------------------------------------!
@@ -1445,5 +1458,5 @@
 
     IMPLICIT NONE
- 
+
     INTEGER(iwp), INTENT(IN) ::  io   !< Unit of the output file
 !
@@ -1748,5 +1761,5 @@
 !-- (number concentration (#/m3) )
 !
-!-- If chemistry is on, read gas phase concentrations from there. Otherwise, 
+!-- If chemistry is on, read gas phase concentrations from there. Otherwise,
 !-- allocate salsa_gas array.
 
@@ -1822,5 +1835,5 @@
        ENDDO
 !
-!--    Vertical surfaces: northward (l=0), southward (l=1), eastward (l=2) and 
+!--    Vertical surfaces: northward (l=0), southward (l=1), eastward (l=2) and
 !--    westward (l=3) facing
        DO  l = 0, 3
@@ -1999,6 +2012,6 @@
 ! Description:
 ! ------------
-!> Initializes particle size distribution grid by calculating size bin limits 
-!> and mid-size for *dry* particles in each bin. Called from salsa_initialize 
+!> Initializes particle size distribution grid by calculating size bin limits
+!> and mid-size for *dry* particles in each bin. Called from salsa_initialize
 !> (only at the beginning of simulation).
 !> Size distribution described using:
@@ -2009,7 +2022,7 @@
 !> based on given subrange size limits and bin number.
 !
-!> Mona changed 06/2017: Use geometric mean diameter to describe the mean 
+!> Mona changed 06/2017: Use geometric mean diameter to describe the mean
 !> particle diameter in a size bin, not the arithmeric mean which clearly
-!> overestimates the total particle volume concentration. 
+!> overestimates the total particle volume concentration.
 !
 !> Coded by:
@@ -2089,5 +2102,5 @@
 !> Initilize altitude-dependent aerosol size distributions and compositions.
 !>
-!> Mona added 06/2017: Correct the number and mass concentrations by normalizing 
+!> Mona added 06/2017: Correct the number and mass concentrations by normalizing
 !< by the given total number and mass concentration.
 !>
@@ -2268,5 +2281,5 @@
              CALL get_variable( id_dyn, 'Dmid', pr_dmid )
 !
-!--          Check whether the sectional representation conform to the one 
+!--          Check whether the sectional representation conform to the one
 !--          applied in the model
              IF ( ANY( ABS( ( aero(1:nbins_aerosol)%dmid - pr_dmid ) /                             &
@@ -2323,5 +2336,5 @@
              message_string = 'Error in initialising mass fractions of chemical components. ' //   &
                               'Check that all chemical components are included in parameter file!'
-             CALL message( 'salsa_mod: aerosol_init', 'PA0606', 2, 2, 0, 6, 0 ) 
+             CALL message( 'salsa_mod: aerosol_init', 'PA0606', 2, 2, 0, 6, 0 )
           ENDIF
 !
@@ -2550,5 +2563,5 @@
                    ENDIF
                    ib = ib+1
-                ENDDO 
+                ENDDO
              ENDIF
           ENDDO !< k
@@ -2593,5 +2606,5 @@
 ! Description:
 ! ------------
-!> Create a lognormal size distribution and discretise to a sectional 
+!> Create a lognormal size distribution and discretise to a sectional
 !> representation.
 !------------------------------------------------------------------------------!
@@ -2687,5 +2700,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--          Regime 2a:
@@ -2717,5 +2730,5 @@
                    IF ( prunmode == 1 )  THEN
                       aerosol_mass(ic)%init(k) = MAX( 0.0_wp, pmf2b(k) ) * ( 1.0_wp - pnf2a(k) ) * &
-                                                 pndist(k,ib) * pcore(ib) * prho 
+                                                 pndist(k,ib) * pcore(ib) * prho
                    ENDIF
                    ib = ib + 1
@@ -3630,9 +3643,9 @@
 ! Description:
 ! ------------
-!> Performs necessary unit and dimension conversion between the host model and 
+!> Performs necessary unit and dimension conversion between the host model and
 !> SALSA module, and calls the main SALSA routine.
 !> Partially adobted form the original SALSA boxmodel version.
 !> Now takes masses in as kg/kg from LES!! Converted to m3/m3 for SALSA
-!> 05/2016 Juha: This routine is still pretty much in its original shape. 
+!> 05/2016 Juha: This routine is still pretty much in its original shape.
 !>               It's dumb as a mule and twice as ugly, so implementation of
 !>               an improved solution is necessary sooner or later.
@@ -3752,5 +3765,5 @@
 !
 !--    Set volume concentrations:
-!--    Sulphate (SO4) or sulphuric acid H2SO4 
+!--    Sulphate (SO4) or sulphuric acid H2SO4
        IF ( index_so4 > 0 )  THEN
           vc = 1
@@ -3820,5 +3833,5 @@
        IF ( index_no > 0 )  THEN
           vc = 6
-          str = ( index_no-1 ) * nbins_aerosol + 1 
+          str = ( index_no-1 ) * nbins_aerosol + 1
           endi = index_no * nbins_aerosol
           ic = 1
@@ -3859,5 +3872,5 @@
        aero_old(1:nbins_aerosol)%volc(vc) = lo_aero(1:nbins_aerosol)%volc(vc)
 !
-!--    Number concentrations (numc) and particle sizes 
+!--    Number concentrations (numc) and particle sizes
 !--    (dwet = wet diameter, core = dry volume)
        DO  ib = 1, nbins_aerosol
@@ -4114,5 +4127,5 @@
 !
 !-- Set surfaces and wall fluxes due to deposition
-    IF ( lsdepo  .AND.  lsdepo_surf  .AND.  prunmode == 3 )  THEN 
+    IF ( lsdepo  .AND.  lsdepo_surf  .AND.  prunmode == 3 )  THEN
        IF ( .NOT. land_surface  .AND.  .NOT. urban_surface )  THEN
           CALL depo_surf( i, j, surf_def_h(0), vd, schmidt_num, kvis, in_u, .TRUE. )
@@ -4189,12 +4202,12 @@
 
  END SUBROUTINE set_salsa_runtime
- 
+
 !------------------------------------------------------------------------------!
 ! Description:
 ! ------------
-!> Calculates the absolute temperature (using hydrostatic pressure), saturation 
-!> vapour pressure and mixing ratio over water, relative humidity and air 
+!> Calculates the absolute temperature (using hydrostatic pressure), saturation
+!> vapour pressure and mixing ratio over water, relative humidity and air
 !> density needed in the SALSA model.
-!> NOTE, no saturation adjustment takes place -> the resulting water vapour 
+!> NOTE, no saturation adjustment takes place -> the resulting water vapour
 !> mixing ratio can be supersaturated, allowing the microphysical calculations
 !> in SALSA.
@@ -4254,5 +4267,5 @@
 ! Description:
 ! ------------
-!> Calculates ambient sizes of particles by equilibrating soluble fraction of 
+!> Calculates ambient sizes of particles by equilibrating soluble fraction of
 !> particles with water using the ZSR method (Stokes and Robinson, 1966).
 !> Method:
@@ -4260,21 +4273,21 @@
 !> - (ammonium) sulphate (100%)
 !> - sea salt (100 %)
-!> - organic carbon (epsoc * 100%) 
+!> - organic carbon (epsoc * 100%)
 !> Exact thermodynamic considerations neglected.
-!> - If particles contain no sea salt, calculation according to sulphate 
+!> - If particles contain no sea salt, calculation according to sulphate
 !>   properties
-!> - If contain sea salt but no sulphate, calculation according to sea salt 
+!> - If contain sea salt but no sulphate, calculation according to sea salt
 !>   properties
-!> - If contain both sulphate and sea salt -> the molar fraction of these 
+!> - If contain both sulphate and sea salt -> the molar fraction of these
 !>   compounds determines which one of them is used as the basis of calculation.
-!> If sulphate and sea salt coexist in a particle, it is assumed that the Cl is 
-!> replaced by sulphate; thus only either sulphate + organics or sea salt + 
+!> If sulphate and sea salt coexist in a particle, it is assumed that the Cl is
+!> replaced by sulphate; thus only either sulphate + organics or sea salt +
 !> organics is included in the calculation of soluble fraction.
-!> Molality parameterizations taken from Table 1 of Tang: Thermodynamic and 
-!> optical properties of mixed-salt aerosols of atmospheric importance, 
+!> Molality parameterizations taken from Table 1 of Tang: Thermodynamic and
+!> optical properties of mixed-salt aerosols of atmospheric importance,
 !> J. Geophys. Res., 102 (D2), 1883-1893 (1997)
 !
 !> Coded by:
-!> Hannele Korhonen (FMI) 2005 
+!> Hannele Korhonen (FMI) 2005
 !> Harri Kokkola (FMI) 2006
 !> Matti Niskanen(FMI) 2012
@@ -4282,5 +4295,5 @@
 !> Modified for the new aerosol datatype, Juha Tonttila (FMI) 2014
 !
-!> fxm: should sea salt form a solid particle when prh is very low (even though 
+!> fxm: should sea salt form a solid particle when prh is very low (even though
 !> it could be mixed with e.g. sulphate)?
 !> fxm: crashes if no sulphate or sea salt
@@ -4335,5 +4348,5 @@
           zvpart(6:7) = paero(ib)%volc(6:7) / paero(ib)%numc
 !
-!--       Total volume and wet diameter of one dry particle 
+!--       Total volume and wet diameter of one dry particle
           zcore = SUM( zvpart(1:2) )
           zdwet = paero(ib)%dwet
@@ -4345,5 +4358,5 @@
              zaw = MAX( 1.0E-3_wp, zrh / zke ) ! To avoid underflow
 !
-!--          Binary molalities (mol/kg): 
+!--          Binary molalities (mol/kg):
 !--          Sulphate
              zbinmol(1) = 1.1065495E+2_wp - 3.6759197E+2_wp * zaw + 5.0462934E+2_wp * zaw**2 -     &
@@ -4367,10 +4380,10 @@
                        zcore / api6 )**0.33333333_wp
 !
-!--          Kelvin effect (Eq. 10.85 in in Seinfeld and Pandis (2006)). Avoid 
+!--          Kelvin effect (Eq. 10.85 in in Seinfeld and Pandis (2006)). Avoid
 !--          overflow.
              zke = EXP( MIN( 50.0_wp, 4.0_wp * surfw0 * amvh2so4 / ( abo * ptemp *  zdwet ) ) )
 
              counti = counti + 1
-             IF ( counti > 1000 )  THEN 
+             IF ( counti > 1000 )  THEN
                 message_string = 'Subrange 1: no convergence!'
                 CALL message( 'salsa_mod: equilibration', 'PA0617', 1, 2, 0, 6, 0 )
@@ -4378,5 +4391,5 @@
           ENDDO
 !
-!--       Instead of lwc, use the volume concentration of water from now on 
+!--       Instead of lwc, use the volume concentration of water from now on
 !--       (easy to convert...)
           paero(ib)%volc(8) = zlwc / arhoh2o
@@ -4438,5 +4451,5 @@
                              6.210577919E+1_wp * zaw**2 + 5.510176187E+2_wp * zaw**3 -             &
                              1.460055286E+3_wp * zaw**4 + 1.894467542E+3_wp * zaw**5 -             &
-                             1.220611402E+3_wp * zaw**6 + 3.098597737E+2_wp * zaw**7 
+                             1.220611402E+3_wp * zaw**6 + 3.098597737E+2_wp * zaw**7
 !--             Sea salt (natrium chloride)
                 zbinmol(5) = 5.875248E+1_wp - 1.8781997E+2_wp * zaw + 2.7211377E+2_wp * zaw**2 -   &
@@ -4457,5 +4470,5 @@
 
                 counti = counti + 1
-                IF ( counti > 1000 )  THEN 
+                IF ( counti > 1000 )  THEN
                    message_string = 'Subrange 2: no convergence!'
                 CALL message( 'salsa_mod: equilibration', 'PA0618', 1, 2, 0, 6, 0 )
@@ -4482,5 +4495,5 @@
 !> Description:
 !> ------------
-!> Calculation of the settling velocity vc (m/s) per aerosol size bin and 
+!> Calculation of the settling velocity vc (m/s) per aerosol size bin and
 !> deposition on plant canopy (lsdepo_pcm).
 !
@@ -4750,5 +4763,5 @@
 !> Calculate the dry deposition on horizontal and vertical surfaces. Implement
 !> as a surface flux.
-!> @todo aerodynamic resistance ignored for now (not important for 
+!> @todo aerodynamic resistance ignored for now (not important for
 !        high-resolution simulations)
 !------------------------------------------------------------------------------!
@@ -5010,10 +5023,10 @@
 ! ------------
 !> Calculates particle loss and change in size distribution due to (Brownian)
-!> coagulation. Only for particles with dwet < 30 micrometres. 
+!> coagulation. Only for particles with dwet < 30 micrometres.
 !
 !> Method:
 !> Semi-implicit, non-iterative method: (Jacobson, 1994)
 !> Volume concentrations of the smaller colliding particles added to the bin of
-!> the larger colliding particles. Start from first bin and use the updated 
+!> the larger colliding particles. Start from first bin and use the updated
 !> number and volume for calculation of following bins. NB! Our bin numbering
 !> does not follow particle size in subrange 2.
@@ -5028,5 +5041,5 @@
 !> Exact coagulation coefficients for each pressure level are scaled according
 !> to current particle wet size (linear scaling).
-!> Bins are organized in terms of the dry size of the condensation nucleus, 
+!> Bins are organized in terms of the dry size of the condensation nucleus,
 !> while coagulation kernell is calculated with the actual hydrometeor
 !> size.
@@ -5078,5 +5091,5 @@
 !--    CoagSink ~ Dp in continuum subrange --> 'effective' number conc. of coarse particles
 
-!-- 2) Updating coagulation coefficients 
+!-- 2) Updating coagulation coefficients
 !
 !-- Aerosol mass (kg). Density of 1500 kg/m3 assumed
@@ -5268,5 +5281,5 @@
     mfp = ( 1.656E-10_wp * temp + 1.828E-8_wp ) * ( p_0 + 1325.0_wp ) / pres
 !
-!-- 2) Slip correction factor for small particles 
+!-- 2) Slip correction factor for small particles
     knud = 2.0_wp * EXP( LOG(mfp) - LOG(diam) )! Knudsen number for air (15.23)
 !
@@ -5325,10 +5338,10 @@
 ! Description:
 ! ------------
-!> Calculates the change in particle volume and gas phase 
+!> Calculates the change in particle volume and gas phase
 !> concentrations due to nucleation, condensation and dissolutional growth.
 !
 !> Sulphuric acid and organic vapour: only condensation and no evaporation.
 !
-!> New gas and aerosol phase concentrations calculated according to Jacobson 
+!> New gas and aerosol phase concentrations calculated according to Jacobson
 !> (1997): Numerical techniques to solve condensational and dissolutional growth
 !> equations when growth is coupled to reversible reactions, Aerosol Sci. Tech.,
@@ -5336,5 +5349,5 @@
 !
 !> Following parameterization has been used:
-!> Molecular diffusion coefficient of condensing vapour (m2/s) 
+!> Molecular diffusion coefficient of condensing vapour (m2/s)
 !> (Reid et al. (1987): Properties of gases and liquids, McGraw-Hill, New York.)
 !> D = {1.d-7*sqrt(1/M_air + 1/M_gas)*T^1.75} / &
@@ -5343,5 +5356,5 @@
 !> d_air = 19.70  : diffusion volume of air
 !> M_h2so4 = 98.08 : molar mass of h2so4 (g/mol)
-!> d_h2so4 = 51.96  : diffusion volume of h2so4 
+!> d_h2so4 = 51.96  : diffusion volume of h2so4
 !
 !> Called from main aerosol model
@@ -5447,5 +5460,5 @@
        zknud(ss:ee) = 2.0_wp * zmfp / paero(ss:ee)%dwet
 !
-!--    Transitional correction factor: aerosol + gas (the semi-empirical Fuchs- Sutugin 
+!--    Transitional correction factor: aerosol + gas (the semi-empirical Fuchs- Sutugin
 !--    interpolation function (Fuchs and Sutugin, 1971))
        zbeta = ( zknud + 1.0_wp ) / ( 0.377_wp * zknud + 1.0_wp + 4.0_wp / ( 3.0_wp * massacc ) *  &
@@ -5459,5 +5472,5 @@
                  * paero(start_subrange_1a:start_subrange_1a+1)%dwet)
 !
-!--    Collision rate (mass-transfer coefficient): gases on aerosols (1/s) (Eq. 16.64 in 
+!--    Collision rate (mass-transfer coefficient): gases on aerosols (1/s) (Eq. 16.64 in
 !--    Jacobson (2005))
        ss = start_subrange_1a
@@ -5475,5 +5488,5 @@
 !--    5) Changes in gas-phase concentrations and particle volume
 !
-!--    5.1) Organic vapours 
+!--    5.1) Organic vapours
 !
 !--    5.1.1) Non-volatile organic compound: condenses onto all bins
@@ -5527,5 +5540,5 @@
 !
 !--       Change in gas concentration (#/m3)
-          zdvap3 = pcocsv - zcvap_new3 
+          zdvap3 = pcocsv - zcvap_new3
 !
 !--       Updated gas concentration (#/m3)
@@ -5590,5 +5603,5 @@
 !
 !-- Condensation of water vapour
-    IF ( lscndh2oae )  THEN 
+    IF ( lscndh2oae )  THEN
        CALL gpparth2o( paero, ptemp, ppres, pcs, pcw, ptstep )
     ENDIF
@@ -5600,5 +5613,5 @@
 ! ------------
 !> Calculates the particle number and volume increase, and gas-phase
-!> concentration decrease due to nucleation subsequent growth to detectable size 
+!> concentration decrease due to nucleation subsequent growth to detectable size
 !> of 3 nm.
 !
@@ -5659,5 +5672,5 @@
     REAL(wp) ::  zdelta_vap   !< change of H2SO4 and organic vapour concentration (#/m3)
     REAL(wp) ::  zdfvap       !< air diffusion coefficient (m2/s)
-    REAL(wp) ::  zdmean       !< mean diameter of existing particles (m) 
+    REAL(wp) ::  zdmean       !< mean diameter of existing particles (m)
     REAL(wp) ::  zeta         !< constant: proportional to ratio of CS/GR (m)
                               !< (condensation sink / growth rate)
@@ -5674,5 +5687,5 @@
     REAL(wp) ::  zlambda      !< parameter for adjusting the growth rate due to self-coagulation
     REAL(wp) ::  zm_c         !< particle mass (kg) for c = critical (1nm)
-    REAL(wp) ::  zm_para      !< Parameter m for calculating the coagulation sink (Eq. 5&6 in 
+    REAL(wp) ::  zm_para      !< Parameter m for calculating the coagulation sink (Eq. 5&6 in
                               !< Lehtinen et al. 2007)
     REAL(wp) ::  zm_x         !< particle mass (kg) for x = 3nm
@@ -5684,5 +5697,5 @@
     REAL(wp) ::  znsa         !< number of H2SO4 molecules in critical cluster
 
-    REAL(wp), INTENT(in) ::  pc_nh3   !< ammonia concentration (#/m3) 
+    REAL(wp), INTENT(in) ::  pc_nh3   !< ammonia concentration (#/m3)
     REAL(wp), INTENT(in) ::  pc_ocnv  !< conc. of non-volatile OC (#/m3)
     REAL(wp), INTENT(in) ::  pc_sa    !< sulphuric acid conc. (#/m3)
@@ -5812,5 +5825,5 @@
           znsa    = 1.0_wp
 !
-!--    Heteromolecular nucleation, J~[H2SO4]*[ORG] 
+!--    Heteromolecular nucleation, J~[H2SO4]*[ORG]
 !--    (See Paasonen et al. (2010), Atmos. Chem. Phys., 10, 11223-11242.)
        CASE(7)
@@ -5864,5 +5877,5 @@
 !
 !-- 2.1) Check that there is enough H2SO4 and organic vapour to produce the nucleation
-    IF ( nsnucl <= 4 )  THEN 
+    IF ( nsnucl <= 4 )  THEN
 !
 !--    If the chosen nucleation scheme is 1-4, nucleation occurs only due to H2SO4. All of the total
@@ -5881,5 +5894,5 @@
           pxocnv = 0.0_wp
        ELSE
-          pxsa   = pc_sa * znsa / ( pc_sa * znsa + pc_ocnv * znoc ) 
+          pxsa   = pc_sa * znsa / ( pc_sa * znsa + pc_ocnv * znoc )
           pxocnv = pc_ocnv * znoc / ( pc_sa * znsa + pc_ocnv * znoc )
        ENDIF
@@ -6009,5 +6022,5 @@
                    ( 3.0_wp * z_r_c2 * zgamma_f_2 ) - z_r_c2
        zomega_2x = ( ( z_r_x2 + zgamma_f_2 )**3 - ( z_r_x2**2 + zgamma_f_2 )**1.5_wp ) /           &
-                   ( 3.0_wp * z_r_x2 * zgamma_f_2 ) - z_r_x2 
+                   ( 3.0_wp * z_r_x2 * zgamma_f_2 ) - z_r_x2
 !
 !--    The distance (m) at which the two fluxes are matched (condensation and coagulation sinks)
@@ -6025,5 +6038,5 @@
        zcoags_x = MAX( 1.0E-20_wp, SUM( z_k_x2 * paero(:)%numc ) )
 !
-!--    Parameter m for calculating the coagulation sink onto background particles (Eq. 5&6 in 
+!--    Parameter m for calculating the coagulation sink onto background particles (Eq. 5&6 in
 !--    Lehtinen et al. 2007)
        zm_para = LOG( zcoags_x / zcoags_c ) / LOG( reglim(1) / zdcrit )
@@ -6041,5 +6054,5 @@
        ELSEIF ( nj3 == 3 )  THEN  ! Anttila et al. (2010): coagulation sink and self-coag.
 !
-!--       If air is polluted, the self-coagulation becomes important. Self-coagulation of small 
+!--       If air is polluted, the self-coagulation becomes important. Self-coagulation of small
 !--       particles < 3 nm.
 !
@@ -6198,8 +6211,8 @@
 !
 !-- Nucleation rate in #/(cm3 s)
-    pnuc_rate = EXP( pnuc_rate ) 
+    pnuc_rate = EXP( pnuc_rate )
 !
 !-- Check the validity of parameterization
-    IF ( pnuc_rate < 1.0E-7_wp )  THEN 
+    IF ( pnuc_rate < 1.0E-7_wp )  THEN
        pnuc_rate = 0.0_wp
        pd_crit   = 1.0E-9_wp
@@ -6252,5 +6265,5 @@
 !
 !-- 6) Organic compounds not involved when binary nucleation is assumed
-    pn_crit_ocnv = 0.0_wp   ! number of organic molecules 
+    pn_crit_ocnv = 0.0_wp   ! number of organic molecules
     pk_sa        = 1.0_wp   ! if = 1, H2SO4 involved in nucleation
     pk_ocnv      = 0.0_wp   ! if = 1, organic compounds involved
@@ -6299,5 +6312,5 @@
 
  END SUBROUTINE binnucl
- 
+
 !------------------------------------------------------------------------------!
 ! Description:
@@ -6353,5 +6366,5 @@
     zlogsa  = LOG( pc_sa )
 !
-!-- 2) Nucleation rate (Eq. 7 in Napari et al., 2002: Parameterization of 
+!-- 2) Nucleation rate (Eq. 7 in Napari et al., 2002: Parameterization of
 !--    ternary nucleation of sulfuric acid - ammonia - water.
     zlnj = - 84.7551114741543_wp + 0.3117595133628944_wp * prh +                                   &
@@ -6461,7 +6474,7 @@
 ! Description:
 ! ------------
-!> Function z_n_nuc_tayl is connected to the calculation of self-coagualtion of 
+!> Function z_n_nuc_tayl is connected to the calculation of self-coagualtion of
 !> small particles. It calculates number of the particles in the size range
-!> [zdcrit,dx] using Taylor-expansion (please note that the expansion is not 
+!> [zdcrit,dx] using Taylor-expansion (please note that the expansion is not
 !> valid for certain rational numbers, e.g. -4/3 and -3/2)
 !------------------------------------------------------------------------------!
@@ -6506,7 +6519,7 @@
 ! Description:
 ! ------------
-!> Calculates the condensation of water vapour on aerosol particles. Follows the 
+!> Calculates the condensation of water vapour on aerosol particles. Follows the
 !> analytical predictor method by Jacobson (2005).
-!> For equations, see Jacobson (2005), Fundamentals of atmospheric modelling 
+!> For equations, see Jacobson (2005), Fundamentals of atmospheric modelling
 !> (2nd edition).
 !------------------------------------------------------------------------------!
@@ -6690,5 +6703,5 @@
 ! Description:
 ! ------------
-!> Calculates the activity coefficient of liquid water 
+!> Calculates the activity coefficient of liquid water
 !------------------------------------------------------------------------------!
  REAL(wp) FUNCTION acth2o( ppart, pcw )
@@ -6723,13 +6736,13 @@
 ! Description:
 ! ------------
-!> Calculates the dissolutional growth of particles (i.e. gas transfers to a 
-!> particle surface and dissolves in liquid water on the surface). Treated here 
-!> as a non-equilibrium (time-dependent) process. Gases: HNO3 and NH3 
+!> Calculates the dissolutional growth of particles (i.e. gas transfers to a
+!> particle surface and dissolves in liquid water on the surface). Treated here
+!> as a non-equilibrium (time-dependent) process. Gases: HNO3 and NH3
 !> (Chapter 17.14 in Jacobson, 2005).
 !
-!> Called from subroutine condensation. 
+!> Called from subroutine condensation.
 !> Coded by:
 !> Harri Kokkola (FMI)
-!------------------------------------------------------------------------------! 
+!------------------------------------------------------------------------------!
  SUBROUTINE gpparthno3( ppres, ptemp, paero, pghno3, pgnh3, pcw, pcs, pbeta, ptstep )
 
@@ -7270,9 +7283,9 @@
                                          !< 1: HNO3, 2: HCL, 3: NH4+/H+ (NH3), 4: HHSO4**2/H2SO4,
                                          !< 5: H2SO4**3/HHSO4**2, 6: NH4HSO2, 7: HHSO4
-    REAL(wp), DIMENSION(:) ::  ions      !< ion molarities (mol/m3): 1: H+, 2: NH4+, 3: Na+, 
+    REAL(wp), DIMENSION(:) ::  ions      !< ion molarities (mol/m3): 1: H+, 2: NH4+, 3: Na+,
                                          !< 4: SO4(2-), 5: HSO4-, 6: NO3-, 7: Cl-
-    REAL(wp), DIMENSION(7) ::  ions_mol  !< ion molalities (mol/kg): 1: H+, 2: NH4+, 3: Na+, 
+    REAL(wp), DIMENSION(7) ::  ions_mol  !< ion molalities (mol/kg): 1: H+, 2: NH4+, 3: Na+,
                                          !< 4: SO4(2-), 5: HSO4-, 6: NO3-, 7: Cl-
-    REAL(wp), DIMENSION(:) ::  mols_out  !< ion molality output (mol/kg): 1: H+, 2: NH4+, 3: Na+, 
+    REAL(wp), DIMENSION(:) ::  mols_out  !< ion molality output (mol/kg): 1: H+, 2: NH4+, 3: Na+,
                                          !< 4: SO4(2-), 5: HSO4-, 6: NO3-, 7: Cl-
 !
@@ -7560,5 +7573,5 @@
                       sodium_nitrate_eq_frac * nano3_h2so4 + sodium_chloride_eq_frac * nacl_h2so4
 
-       gamma_h2so4 = EXP( ln_h2so4_act )    ! molal activity coefficient 
+       gamma_h2so4 = EXP( ln_h2so4_act )    ! molal activity coefficient
 !
 !--    Export activity coefficients
@@ -7589,5 +7602,5 @@
        ENDIF
 !
-!--    Calculate the new hydrogen ion, bisulphate ion and sulphate ion 
+!--    Calculate the new hydrogen ion, bisulphate ion and sulphate ion
 !--    concentration
        h_real    = ions(1)
@@ -7615,7 +7628,7 @@
 !-- 4) ACTIVITY COEFFICIENTS -for vapour pressures of HNO3,HCL and NH3
 !
-!-- This section evaluates activity coefficients and vapour pressures using the water content 
+!-- This section evaluates activity coefficients and vapour pressures using the water content
 !-- calculated above) for each inorganic condensing species: a - HNO3, b - NH3, c - HCL.
-!-- The following procedure is used: Zaveri et al (2005) found that one could express the variation 
+!-- The following procedure is used: Zaveri et al (2005) found that one could express the variation
 !-- of activity coefficients linearly in log-space if equivalent mole fractions were used.
 !-- So, by a taylor series expansion LOG( activity coefficient ) =
@@ -7927,11 +7940,11 @@
 !> Update the particle size distribution. Put particles into corrects bins.
 !>
-!> Moving-centre method assumed, i.e. particles are allowed to grow to their 
-!> exact size as long as they are not crossing the fixed diameter bin limits. 
-!> If the particles in a size bin cross the lower or upper diameter limit, they 
+!> Moving-centre method assumed, i.e. particles are allowed to grow to their
+!> exact size as long as they are not crossing the fixed diameter bin limits.
+!> If the particles in a size bin cross the lower or upper diameter limit, they
 !> are all moved to the adjacent diameter bin and their volume is averaged with
-!> the particles in the new bin, which then get a new diameter. 
-!
-!> Moving-centre method minimises numerical diffusion. 
+!> the particles in the new bin, which then get a new diameter.
+!
+!> Moving-centre method minimises numerical diffusion.
 !------------------------------------------------------------------------------!
  SUBROUTINE distr_update( paero )
@@ -7996,6 +8009,6 @@
 !
 !--          If size bin has not grown, cycle.
-!--          Changed by Mona: compare to the arithmetic mean volume, as done originally. Now 
-!--          particle volume is derived from the geometric mean diameter, not arithmetic (see 
+!--          Changed by Mona: compare to the arithmetic mean volume, as done originally. Now
+!--          particle volume is derived from the geometric mean diameter, not arithmetic (see
 !--          SUBROUTINE set_sizebins).
              IF ( zvpart <= api6 * ( ( aero(ib)%vhilim + aero(ib)%vlolim ) / ( 2.0_wp * api6 ) ) ) &
@@ -9537,7 +9550,7 @@
     REAL(wp), DIMENSION(:), INTENT(out) ::  mconc  !< total dry or wet mass concentration
 
-!-- Number of components 
+!-- Number of components
     IF ( itype == 'dry' )  THEN
-       iend = prtcl%ncomp - 1 
+       iend = prtcl%ncomp - 1
     ELSE IF ( itype == 'wet' )  THEN
        iend = prtcl%ncomp
@@ -10027,5 +10040,5 @@
                    message_string = 'end_time of the simulation exceeds the time dimension in ' // &
                                     'the salsa input file.'
-                   CALL message( 'salsa_emission_setup', 'PA0692', 1, 2, 0, 6, 0 ) 
+                   CALL message( 'salsa_emission_setup', 'PA0692', 1, 2, 0, 6, 0 )
                 ENDIF
 !
@@ -10093,5 +10106,5 @@
                 inn = def_modes%cat_input_to_model(in)
 !
-!--             Calculate the number concentration (1/m3) of a log-normal size distribution 
+!--             Calculate the number concentration (1/m3) of a log-normal size distribution
 !--             following Jacobson (2005): Eq 13.25.
                 def_modes%ntot_table = 6.0_wp * def_modes%pm_frac_table(:,inn) / ( pi *            &
@@ -10643,5 +10656,5 @@
                                           MAX( time_since_reference_point, 0.0_wp ) ), DIM = 1 ) - 1
 !
-!--    Allocate the data input array always before reading in the data and deallocate after (NOTE 
+!--    Allocate the data input array always before reading in the data and deallocate after (NOTE
 !--    that "preprocessed" input data array is applied now here)
        ALLOCATE( dum_var_5d(1,1,nys:nyn,nxl:nxr,1:chem_emission_att%n_emiss_species) )
@@ -11762,5 +11775,5 @@
 !
 !--                         Diameter in micrometres
-                            mean_d = 1.0E+6_wp * ra_dry(k,j,i,ib) * 2.0_wp 
+                            mean_d = 1.0E+6_wp * ra_dry(k,j,i,ib) * 2.0_wp
 !
 !--                         Deposition factor: alveolar
@@ -12112,5 +12125,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( nbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -12146,5 +12159,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( mbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -12225,5 +12238,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ldsa_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12256,5 +12269,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( nufp_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12285,5 +12298,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ntot_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12305,5 +12318,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12318,5 +12331,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm01_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12338,5 +12351,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12351,5 +12364,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm25_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12371,5 +12384,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12402,5 +12415,5 @@
                             ENDDO
                             local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),      &
-                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -12434,5 +12447,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -12585,5 +12598,5 @@
                    ENDDO
                 ENDDO
-             ELSE 
+             ELSE
                 DO  i = 1, mask_size_l(mid,1)
                    DO  j = 1, mask_size_l(mid,2)
@@ -12666,5 +12679,5 @@
                       ENDDO
                    ENDDO
-                ELSE 
+                ELSE
                    DO  i = 1, mask_size_l(mid,1)
                       DO  j = 1, mask_size_l(mid,2)
@@ -12755,5 +12768,5 @@
                       ENDDO
                    ENDDO
-                ENDDO 
+                ENDDO
                 IF ( .NOT. mask_surface(mid) )  THEN
                    DO  i = 1, mask_size_l(mid,1)
@@ -12764,5 +12777,5 @@
                       ENDDO
                    ENDDO
-                ELSE 
+                ELSE
                    DO  i = 1, mask_size_l(mid,1)
                       DO  j = 1, mask_size_l(mid,2)
@@ -12807,5 +12820,5 @@
                       ENDDO
                    ENDDO
-                ENDDO 
+                ENDDO
                 IF ( .NOT. mask_surface(mid) )  THEN
                    DO  i = 1, mask_size_l(mid,1)
@@ -12816,5 +12829,5 @@
                       ENDDO
                    ENDDO
-                ELSE 
+                ELSE
                    DO  i = 1, mask_size_l(mid,1)
                       DO  j = 1, mask_size_l(mid,2)
@@ -12868,5 +12881,5 @@
                       ENDDO
                    ENDDO
-                ELSE 
+                ELSE
                    DO  i = 1, mask_size_l(mid,1)
                       DO  j = 1, mask_size_l(mid,2)
@@ -12911,5 +12924,5 @@
                       ENDDO
                    ENDDO
-                ENDDO 
+                ENDDO
                 IF ( .NOT. mask_surface(mid) )  THEN
                    DO  i = 1, mask_size_l(mid,1)
@@ -12920,5 +12933,5 @@
                       ENDDO
                    ENDDO
-                ELSE 
+                ELSE
                    DO  i = 1, mask_size_l(mid,1)
                       DO  j = 1, mask_size_l(mid,2)
@@ -13098,5 +13111,5 @@
 ! Description:
 ! ------------
-!> Creates index tables for different (aerosol) components 
+!> Creates index tables for different (aerosol) components
 !------------------------------------------------------------------------------!
  SUBROUTINE component_index_constructor( self, ncomp, nlist, listcomp )
@@ -13583,5 +13596,5 @@
           message_string = 'end_time of the simulation exceeds the time dimension in the dynamic'//&
                            ' input file.'
-          CALL message( 'salsa_nesting_offl_init', 'PA0690', 1, 2, 0, 6, 0 ) 
+          CALL message( 'salsa_nesting_offl_init', 'PA0690', 1, 2, 0, 6, 0 )
        ENDIF
 
@@ -13747,5 +13760,5 @@
           CALL message( 'salsa_mod: salsa_nesting_offl_input', 'PA0693', 2, 2, 0, 6, 0 )
        ENDIF
-       
+
        CALL close_input_file( salsa_nest_offl%id_dynamic )
 #endif
Index: /palm/trunk/SOURCE/spectra_mod.f90
===================================================================
--- /palm/trunk/SOURCE/spectra_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/spectra_mod.f90	(revision 4842)
@@ -25,4 +25,9 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more,
+! deprecated namelist removed
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! support for MPI Fortran77 interface (mpif.h) removed
 !
@@ -146,17 +151,12 @@
 
     USE control_parameters,                                                                        &
-        ONLY:  dt_data_output,                                                                     &
-               message_string
+        ONLY:  dt_data_output
 
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-    NAMELIST /spectra_par/  averaging_interval_sp,                                                 &
-                            comp_spectra_level,                                                    &
-                            data_output_sp,                                                        &
-                            dt_dosp,                                                               &
-                            skip_time_dosp,                                                        &
-                            spectra_direction
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
+
 
     NAMELIST /spectra_parameters/                                                                  &
@@ -168,69 +168,30 @@
                             spectra_direction
 !
-!-- Position the namelist-file at the beginning (it was already opened in parin), search for the
-!-- namelist-group of the package and position the file at this line.
-    line = ' '
-
-!
-!-- Try to find the spectra package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&spectra_parameters' ) == 0 )
-       READ ( 11, '(A)', END=12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, spectra_parameters, ERR = 10 )
-
-!
-!-- Default setting of dt_dosp here (instead of check_parameters), because its current value is
-!-- needed in init_pegrid
-    IF ( dt_dosp == 9999999.9_wp )  dt_dosp = dt_data_output
-
-!
-!-- Set general switch that spectra shall be calculated
-    calculate_spectra = .TRUE.
-
-    GOTO 14
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'spectra_parameters', line )
-!
-!-- Try to find the old namelist
- 12 REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&spectra_par' ) == 0 )
-       READ ( 11, '(A)', END=14 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, spectra_par, ERR = 13, END = 14 )
-
-
-    message_string = 'namelist spectra_par is deprecated and will be removed in near future.' //   &
-                     ' Please use namelist spectra_parameters instead'
-    CALL message( 'spectra_parin', 'PA0487', 0, 1, 0, 6, 0 )
-!
-!-- Default setting of dt_dosp here (instead of check_parameters), because its current value is
-!-- needed in init_pegrid
-    IF ( dt_dosp == 9999999.9_wp )  dt_dosp = dt_data_output
-
-!
-!-- Set general switch that spectra shall be calculated
-    calculate_spectra = .TRUE.
-
-    GOTO 14
-
- 13 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'spectra_par', line )
-
-
- 14 CONTINUE
+!-- Position the namelist-file at the beginning (it was already opened in parin), and try to read
+!-- the namelist.
+    REWIND( 11 )
+    READ( 11, spectra_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    spectra_parameters namelist was found and read correctly.
+!--    Default setting of dt_dosp here (instead of check_parameters), because its current value is
+!--    needed in init_pegrid.
+       IF ( dt_dosp == 9999999.9_wp )  dt_dosp = dt_data_output
+!
+!--    Set general switch that spectra shall be calculated.
+       calculate_spectra = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    spectra_parameters namelist was found but contained errors. Print an error message including
+!--    the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'spectra_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE spectra_parin
Index: /palm/trunk/SOURCE/surface_data_output_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4842)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Bugfix: correct the down-ward surf_lsm index in the routine surface_data_output_collect_2d
 !
@@ -4205,36 +4209,39 @@
     IMPLICIT NONE
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-
-    NAMELIST /surface_data_output_parameters/ averaging_interval_surf, data_output_surf,           &
-                                              dt_dosurf, dt_dosurf_av, skip_time_dosurf,           &
-                                              skip_time_dosurf_av, to_netcdf, to_vtk
-
-    line = ' '
-
-!
-!-- Try to find the namelist
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&surface_data_output_parameters' ) == 0 )
-       READ ( 11, '(A)', END=14 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, surface_data_output_parameters, ERR = 10 )
-!
-!-- Set flag that indicates that surface data output is switched on
-    surface_output = .TRUE.
-    GOTO 14
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'surface_data_output_parameters', line )
-
- 14 CONTINUE
-
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
+
+
+    NAMELIST /surface_data_output_parameters/  averaging_interval_surf,                            &
+                                               data_output_surf,                                   &
+                                               dt_dosurf,                                          &
+                                               dt_dosurf_av,                                       &
+                                               skip_time_dosurf,                                   &
+                                               skip_time_dosurf_av,                                &
+                                               to_netcdf,                                          &
+                                               to_vtk
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, surface_data_output_parameters, IOSTAT=io_status )
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    surface_data_output_parameters namelist was found and read correctly. Set flag that indicates
+!--    that surface data output is switched on.
+       surface_output = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    surface_data_output_parameters namelist was found but contained errors. Print an error
+!--    message including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'surface_data_output_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE surface_data_output_parin
Index: /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 4842)
@@ -25,13 +25,17 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Implementation of downward facing USM and LSM surfaces
 !
 ! 4647 2020-08-24 16:36:18Z suehring
-! Change default value of synthetic turbulence adjustment as well as compute_velocity_seeds_local 
-! By default, the random-seed computation is now distributed among several cores. Especially for 
+! Change default value of synthetic turbulence adjustment as well as compute_velocity_seeds_local
+! By default, the random-seed computation is now distributed among several cores. Especially for
 ! large length scales this is significantly faster.
 !
 ! 4640 2020-08-11 16:28:32Z suehring
-! - to avoid that the correction term in r11/r22 computation becomes unrealistically high, limit 
+! - to avoid that the correction term in r11/r22 computation becomes unrealistically high, limit
 !   Obukhov length (term is not valid for near neutral conditions)
 ! - to avoid unrealistically large perturbations, change computation of r21 so that this resembles
@@ -44,5 +48,5 @@
 ! Bugfix in initialization from ASCII file - x-length scales at the bottom boundary were not
 ! initialized properly
-! 
+!
 ! 4566 2020-06-16 10:11:51Z suehring
 ! - revise parametrization for reynolds-stress components, turbulent length- and time scales
@@ -50,8 +54,8 @@
 ! - change default value of time interval to adjust turbulence parametrization
 ! - bugfix in computation of amplitude-tensor (vertical flux of horizontal momentum)
-! 
+!
 ! 4562 2020-06-12 08:38:47Z raasch
 ! Parts of r4559 re-formatted
-! 
+!
 ! 4559 2020-06-11 08:51:48Z raasch
 ! File re-formatted to follow the PALM coding standard
@@ -784,7 +788,7 @@
     ENDIF
 !
-!-- Assign initial profiles. Note, this is only required if turbulent inflow from the left is 
+!-- Assign initial profiles. Note, this is only required if turbulent inflow from the left is
 !-- desired, not in case of any of the nesting (offline or self nesting) approaches.
-    IF ( .NOT. nesting_offline  .AND.  .NOT.  child_domain )  THEN 
+    IF ( .NOT. nesting_offline  .AND.  .NOT.  child_domain )  THEN
        u_init = mean_inflow_profiles(:,1)
        v_init = mean_inflow_profiles(:,2)
@@ -1209,6 +1213,7 @@
  SUBROUTINE stg_parin
 
-    CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
 
     NAMELIST /stg_par/  dt_stg_adjust,                                                             &
@@ -1217,28 +1222,27 @@
                         compute_velocity_seeds_local
 
-    line = ' '
-!
-!-- Try to find stg package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&stg_par' ) == 0 )
-       READ ( 11, '(A)', END = 20 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, stg_par, ERR = 10, END = 20 )
-
-!
-!-- Set flag that indicates that the synthetic turbulence generator is switched on
-    syn_turb_gen = .TRUE.
-    GOTO 20
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'stg_par', line )
-
- 20 CONTINUE
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, stg_par, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    stg_par namelist was found and read correctly. Set flag that indicates that the synthetic
+!--    turbulence generator is switched on.
+       syn_turb_gen = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    stg_par namelist was found but contained errors. Print an error message including the line
+!--    that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)') line
+       CALL parin_fail_message( 'stg_par', line )
+
+    ENDIF
 
  END SUBROUTINE stg_parin
@@ -1807,5 +1811,5 @@
        ENDDO
     ENDDO
-    
+
 #if defined( __parallel )
 !
@@ -1937,5 +1941,5 @@
     REAL(wp), DIMENSION(-mergp_x:mergp_x,nzb:nzt+1) :: b_x     !< filter function in x-direction
     REAL(wp), DIMENSION(-mergp_z:mergp_z,nzb:nzt+1) :: b_z     !< filter function in z-direction
-    
+
     REAL(wp), DIMENSION(nzb_y_stg:nzt_y_stg+1,nxl:nxr) :: f_n_l   !<  local velocity seed
     REAL(wp), DIMENSION(nzb:nzt+1,nxl:nxr)             :: f_n     !<  velocity seed
@@ -1982,5 +1986,5 @@
        ENDDO
     ENDDO
-    
+
 #if defined( __parallel )
 !
@@ -2082,5 +2086,5 @@
 ! Description:
 ! ------------
-!> Parametrization of the Reynolds-stress componentes, turbulent length- and time scales. The 
+!> Parametrization of the Reynolds-stress componentes, turbulent length- and time scales. The
 !> parametrization follows Brost et al. (1982) with modifications described in Rotach et al. (1996),
 !> which is applied in state-of-the-art dispserion modelling.
@@ -2165,5 +2169,5 @@
 !
 !--    u'w' and v'w'. After calculation of the longitudinal and crosswind component
-!--    these are projected along the x- and y-direction. Note, it is assumed that 
+!--    these are projected along the x- and y-direction. Note, it is assumed that
 !--    the flux within the boundary points opposite to the vertical gradient.
        rlon2 = scale_us**2 * ( zzi - 1.0_wp )
@@ -2298,5 +2302,5 @@
     DO  k = nzb+1, nzt+1
        IF ( r11(k) > 10E-6_wp )  THEN
-          a11(k) = SQRT( r11(k) ) 
+          a11(k) = SQRT( r11(k) )
           a21(k) = r21(k) / a11(k)
           a31(k) = r31(k) / a11(k)
@@ -2308,9 +2312,9 @@
     ENDDO
     DO  k = nzb+1, nzt+1
-       a22(k) = r22(k) - a21(k)**2 
+       a22(k) = r22(k) - a21(k)**2
        IF ( a22(k) > 10E-6_wp )  THEN
           a22(k) = SQRT( a22(k) )
           a32(k) = ( r32(k) - a21(k) * a31(k) ) / a22(k)
-       ELSE 
+       ELSE
           a22(k) = 10E-8_wp
           a32(k) = 10E-8_wp
@@ -2355,10 +2359,10 @@
     CALL calc_scaling_variables
 !
-!-- Parametrize Reynolds-stress tensor. Parametrization follows Brost et al. (1982) with 
+!-- Parametrize Reynolds-stress tensor. Parametrization follows Brost et al. (1982) with
 !-- modifications described in Rotach et al. (1996) and is based on boundary-layer depth, friction
-!-- velocity and velocity scale. 
+!-- velocity and velocity scale.
     CALL parametrize_turbulence
 !
-!-- Calculate coefficient matrix from Reynolds stress tensor  
+!-- Calculate coefficient matrix from Reynolds stress tensor
 !-- (Lund rotation)
     CALL calc_coeff_matrix
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4842)
@@ -27,6 +27,10 @@
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4831 2021-01-06 17:55:14Z suehring
 ! Bugfix in checking output variables with suffix indicating the surface facing
-! 
+!
 ! 4828 2021-01-05 11:21:41Z Giersch
 ! Deactivated A/C cooling capacity for office buildings built before year 2000.
@@ -43,8 +47,8 @@
 ! - bugfix in openmp directive
 ! - make t_green_h and t_green_v public (required in indoor model)
-! 
+!
 ! 4747 2020-10-16 09:19:57Z pavelkrc
 ! Fix window absorptivity calculation (correctly account for 2-sided reflection)
-! 
+!
 ! 4738 2020-10-14 08:05:07Z maronga
 ! Updating building data base (on behalf of Sascha Rissmann)
@@ -111,14 +115,14 @@
 ! 4602 2020-07-14 14:49:45Z suehring
 ! Add missing initialization of albedo type with values given from static input file
-! 
+!
 ! 4581 2020-06-29 08:49:58Z suehring
 ! Missing initialization in case of cyclic_fill runs
-! 
+!
 ! 4535 2020-05-15 12:07:23Z raasch
 ! bugfix for restart data format query
-! 
+!
 ! 4517 2020-05-03 14:29:30Z raasch
 ! added restart with MPI-IO for reading local arrays
-! 
+!
 ! 4510 2020-04-29 14:19:18Z raasch
 ! Further re-formatting to follow the PALM coding standard
@@ -318,5 +322,5 @@
 !> -------------
 !> @todo Revise sorting of building_pars
-!> @todo Revise initialization when building_pars / building_surface_pars are provided - 
+!> @todo Revise initialization when building_pars / building_surface_pars are provided -
 !>       intialization is not consistent to building_pars
 !> @todo Revise flux conversion in energy-balance solver
@@ -5813,18 +5817,7 @@
     IMPLICIT NONE
 
-    CHARACTER(LEN=80)  ::  line  !< string containing current line of file PARIN
-
-    NAMELIST /urban_surface_par/                                                                   &
-                        building_type,                                                             &
-                        roof_category,                                                             &
-                        roof_inner_temperature,                                                    &
-                        roughness_concrete,                                                        &
-                        soil_inner_temperature,                                                    &
-                        urban_surface,                                                             &
-                        usm_wall_mod,                                                              &
-                        wall_category,                                                             &
-                        wall_inner_temperature,                                                    &
-                        window_inner_temperature
-
+    CHARACTER(LEN=100)  ::  line  !< string containing current line of file PARIN
+
+    INTEGER(iwp) ::  io_status    !< status after reading the namelist file
 
     NAMELIST /urban_surface_parameters/                                                            &
@@ -5843,55 +5836,25 @@
 
 !
-!-- Try to find urban surface model package
-    REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&urban_surface_parameters' ) == 0 )
-       READ ( 11, '(A)', END = 12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, urban_surface_parameters, ERR = 10 )
-
-!
-!-- Set flag that indicates that the urban surface model is switched on
-    urban_surface = .TRUE.
-
-    GOTO 14
-
- 10 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'urban_surface_parameters', line )
-!
-!-- Try to find old namelist
- 12 REWIND ( 11 )
-    line = ' '
-    DO WHILE ( INDEX( line, '&urban_surface_par' ) == 0 )
-       READ ( 11, '(A)', END = 14 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, urban_surface_par, ERR = 13, END = 14 )
-
-    message_string = 'namelist urban_surface_par is deprecated and will be removed in near ' //    &
-                     'future. Please use namelist urban_surface_parameters instead'
-    CALL message( 'usm_parin', 'PA0487', 0, 1, 0, 6, 0 )
-
-!
-!-- Set flag that indicates that the urban surface model is switched on
-    urban_surface = .TRUE.
-
-    GOTO 14
-
- 13 BACKSPACE( 11 )
-    READ( 11 , '(A)') line
-    CALL parin_fail_message( 'urban_surface_par', line )
-
-
- 14 CONTINUE
-
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, urban_surface_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    urban_surface_parameters namelist was found and read correctly. Set flag that indicates that
+!--    the urban surface model is switched on.
+       urban_surface = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    urban_surface_parameters namelist was found but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
+       CALL parin_fail_message( 'urban_surface_parameters', line )
+
+    ENDIF
 
  END SUBROUTINE usm_parin
@@ -7584,8 +7547,8 @@
        1512000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       0.81_wp,        &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       0.81_wp,        &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        0.81_wp,        &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
-       293.15_wp,      &  !< parameter 13  - [K] indoor target winter temperature 
+       293.15_wp,      &  !< parameter 13  - [K] indoor target winter temperature
        0.93_wp,        &  !< parameter 14  - [-] wall emissivity above ground floor level
        0.86_wp,        &  !< parameter 15  - [-] green emissivity above ground floor level
@@ -7726,5 +7689,5 @@
                         /)
 
-    building_pars(:,2) = (/                                                                        &                        
+    building_pars(:,2) = (/                                                                        &
        0.75_wp,        &  !< parameter 0   - [-] wall fraction above ground floor level
        0.25_wp,        &  !< parameter 1   - [-] window fraction above ground floor level
@@ -7737,5 +7700,5 @@
        2112000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       0.046_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       0.046_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        2.1_wp,         &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
@@ -7879,5 +7842,5 @@
                         /)
 
-    building_pars(:,3) = (/                                                                        &                        
+    building_pars(:,3) = (/                                                                        &
        0.71_wp,        &  !< parameter 0   - [-] wall fraction above ground floor level
        0.29_wp,        &  !< parameter 1   - [-] window fraction above ground floor level
@@ -7890,5 +7853,5 @@
        1344000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       0.035_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       0.035_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        0.68_wp,        &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
@@ -8009,5 +7972,5 @@
        4.5_wp,         &  !< parameter 127 - [m2/m2] ratio internal surface/floor area
        40.0_wp,        &  !< parameter 128 - [W] maximal heating capacity
-       0.0_wp,         &  !< parameter 129 - [W] maximal cooling capacity 
+       0.0_wp,         &  !< parameter 129 - [W] maximal cooling capacity
        0.0_wp,         &  !< parameter 130 - [W/m2] additional internal heat gains dependent on occupancy of the room
        4.2_wp,         &  !< parameter 131 - [W/m2] basic internal heat gains without occupancy of the room
@@ -8043,5 +8006,5 @@
        1512000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       0.81_wp,        &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       0.81_wp,        &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        0.81_wp,        &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
@@ -8156,5 +8119,5 @@
        2.9_wp,         &  !< parameter 121 - [W/(m2*K)] u-value windows
        1.0_wp,         &  !< parameter 122 - [1/h] basic airflow without occupancy of the room for - summer 1.0_wp, winter 0.2
-       1.0_wp,         &  !< parameter 123 - [1/h] additional airflow dependent on occupancy of the room for - summer 1.0_wp, winter 0.8  
+       1.0_wp,         &  !< parameter 123 - [1/h] additional airflow dependent on occupancy of the room for - summer 1.0_wp, winter 0.8
        0.0_wp,         &  !< parameter 124 - [-] heat recovery efficiency
        3.0_wp,         &  !< parameter 125 - [m2/m2] dynamic parameter specific effective surface
@@ -8196,5 +8159,5 @@
        2112000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       2.1_wp,         &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       2.1_wp,         &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        0.046_wp,       &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
@@ -8308,5 +8271,5 @@
        0.7_wp,         &  !< parameter 120 - [-] g-value windows
        1.7_wp,         &  !< parameter 121 - [W/(m2*K)] u-value windows
-       1.0_wp,         &  !< parameter 122 - [1/h] basic airflow without occupancy of the room for - summer 1.0_wp, winter 0.2 
+       1.0_wp,         &  !< parameter 122 - [1/h] basic airflow without occupancy of the room for - summer 1.0_wp, winter 0.2
        1.0_wp,         &  !< parameter 123 - [1/h] additional airflow dependent on occupancy of the room for - summer 1.0_wp, winter 0.8
        0.0_wp,         &  !< parameter 124 - [-] heat recovery efficiency
@@ -8349,5 +8312,5 @@
        1344000.0_wp,   &  !< parameter 8   - [J/(m3*K)] heat capacity 3rd wall layer above ground floor level
        0.93_wp,        &  !< parameter 9   - [W/(m*K)] thermal conductivity 1st wall layer (outside) above ground floor level
-       0.035_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level       
+       0.035_wp,       &  !< parameter 10  - [W/(m*K)] thermal conductivity 2nd wall layer above ground floor level
        0.68_wp,        &  !< parameter 11  - [W/(m*K)] thermal conductivity 3rd wall layer above ground floor level
        299.15_wp,      &  !< parameter 12  - [K] indoor target summer temperature
@@ -8630,5 +8593,5 @@
       1848000.0_wp,    &  !< parameter 136 - [J/(m3*K)] heat capacity 4th wall layer (downside) above ground floor level
       1.0_wp,          &  !< parameter 137 - [W/(m*K)] thermal conductivity 4th wall layer (downside) above ground floor level
-      1848000.0_wp,    &  !< parameter 138 - [J/(m3*K)] heat capacity 4th wall layer (downside) ground floor level 
+      1848000.0_wp,    &  !< parameter 138 - [J/(m3*K)] heat capacity 4th wall layer (downside) ground floor level
       1.0_wp,          &  !< parameter 139 - [W/(m*K)] thermal conductivity 4th wall layer (downside) ground floor level
       1848000.0_wp,    &  !< parameter 140 - [J/(m3*K)] heat capacity 4th wall layer (downside) ground plate
Index: /palm/trunk/SOURCE/virtual_flight_mod.f90
===================================================================
--- /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 4841)
+++ /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 4842)
@@ -20,17 +20,21 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! reading of namelist file and actions in case of namelist errors revised so that statement labels
+! and goto statements are not required any more
+!
+! 4828 2021-01-05 11:21:41Z Giersch
 ! Bugfix, use time_since_reference_point instead of simulated_time
-! 
+!
 ! 4535 2020-05-15 12:07:23Z raasch
 ! bugfix for restart data format query
-! 
+!
 ! 4522 2020-05-06 14:17:05Z suehring
 ! Modularize user_init_flight in order to provide an explicit interface.
-! 
+!
 ! 4497 2020-04-15 10:20:51Z raasch
 ! file re-formatted to follow the PALM coding standard
@@ -39,5 +43,5 @@
 ! 4495 2020-04-13 20:11:20Z raasch
 ! restart data handling with MPI-IO added
-! 
+!
 ! 4360 2020-01-07 11:25:50Z suehring
 ! Corrected "Former revisions" section
@@ -226,23 +230,9 @@
  SUBROUTINE flight_parin
 
-    USE control_parameters,                                                                        &
-        ONLY:  message_string
-
     IMPLICIT NONE
 
-    CHARACTER(LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
-
-    NAMELIST /flight_par/ flight_angle,                                                            &
-                          flight_begin,                                                            &
-                          flight_end,                                                              &
-                          flight_level,                                                            &
-                          leg_mode,                                                                &
-                          max_elev_change,                                                         &
-                          rate_of_climb,                                                           &
-                          speed_agl,                                                               &
-                          x_end,                                                                   &
-                          x_start,                                                                 &
-                          y_end,                                                                   &
-                          y_start
+    CHARACTER(LEN=100) ::  line  !< dummy string that contains the current line of the parameter file
+
+    INTEGER(iwp) ::  io_status   !< status after reading the namelist file
 
 
@@ -259,55 +249,30 @@
                                          y_end,                                                    &
                                          y_start
-!
-!-- Try to find the namelist flight_par
-    REWIND ( 11 )
-    line = ' '
-    DO  WHILE ( INDEX( line, '&virtual_flight_parameters' ) == 0 )
-       READ ( 11, '(A)', END = 12 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, virtual_flight_parameters, ERR = 10 )
-!
-!-- Set switch so that virtual flights shall be carried out
-    virtual_flight = .TRUE.
-
-    GOTO 14
-
- 10    BACKSPACE( 11 )
-       READ( 11 , '(A)') line
+
+!
+!-- Move to the beginning of the namelist file and try to find and read the namelist.
+    REWIND( 11 )
+    READ( 11, virtual_flight_parameters, IOSTAT=io_status )
+
+!
+!-- Action depending on the READ status
+    IF ( io_status == 0 )  THEN
+!
+!--    virtual_flight_parameters namelist was found and read correctly. Set switch that virtual
+!--    flights are carried out.
+       virtual_flight = .TRUE.
+
+    ELSEIF ( io_status > 0 )  THEN
+!
+!--    virtual_flight_parameters namelist was found, but contained errors. Print an error message
+!--    including the line that caused the problem.
+       BACKSPACE( 11 )
+       READ( 11 , '(A)' ) line
        CALL parin_fail_message( 'virtual_flight_parameters', line )
-!
-!--    Try to find the old namelist
- 12    REWIND ( 11 )
-       line = ' '
-       DO  WHILE ( INDEX( line, '&flight_par' ) == 0 )
-          READ ( 11, '(A)', END = 14 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!-- Read namelist
-    READ ( 11, flight_par, ERR = 13, END = 14 )
-
-    message_string = 'namelist flight_par is deprecated and will be ' //                           &
-                     'removed in near future.& Please use namelist ' //                            &
-                     'virtual_flight_parameters instead'
-    CALL message( 'flight_parin', 'PA0487', 0, 1, 0, 6, 0 )
-!
-!-- Set switch so that virtual flights shall be carried out
-    virtual_flight = .TRUE.
-
-    GOTO 14
-
- 13    BACKSPACE( 11 )
-       READ( 11 , '(A)') line
-       CALL parin_fail_message( 'flight_par', line )
-
- 14    CONTINUE
+
+    ENDIF
 
  END SUBROUTINE flight_parin
+
 
 !--------------------------------------------------------------------------------------------------!
Index: /palm/trunk/TESTS/cases/topo_from_ASCII_file/INPUT/topo_from_ASCII_file_p3d
===================================================================
--- /palm/trunk/TESTS/cases/topo_from_ASCII_file/INPUT/topo_from_ASCII_file_p3d	(revision 4841)
+++ /palm/trunk/TESTS/cases/topo_from_ASCII_file/INPUT/topo_from_ASCII_file_p3d	(revision 4842)
@@ -1,3 +1,4 @@
- &inipar nx = 39, ny = 39, nz = 40,
+ &initialization_parameters
+         nx = 39, ny = 39, nz = 40,
          dx = 2.0, dy = 2.0, dz = 2.0,
 
@@ -20,5 +21,6 @@
          topography_grid_convention = 'cell_center',  / ! default
 
- &d3par  end_time                  =    900.0,
+ &runtime_parameters
+         end_time                  =    900.0,
          termination_time_needed   =    900.0,
 
