Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3246)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! +nest_chemistry
 ! 
@@ -867,16 +870,20 @@
       line = ' '
       DO   WHILE ( INDEX( line, '&chemistry_parameters' ) == 0 )
-         READ ( 11, '(A)', END=10 )  line
+         READ ( 11, '(A)', END=20 )  line
       ENDDO
       BACKSPACE ( 11 )
 !
 !--   Read chemistry namelist
-      READ ( 11, chemistry_parameters )                          
+      READ ( 11, chemistry_parameters, ERR = 10, END = 20 )
 !
 !--   Enable chemistry model
-      air_chemistry = .TRUE.                    
-
-      
- 10   CONTINUE
+      air_chemistry = .TRUE.
+      GOTO 20
+
+ 10   BACKSPACE( 11 )
+      READ( 11 ,fmt='(A)') line
+      CALL parin_fail_message ( 'chemistry_parameters', line )
+
+ 20   CONTINUE
 
       t_steps = my_steps          !(todo: Why not directly make t_steps a
Index: /palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -4994,5 +4997,5 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&land_surface_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
+          READ ( 11, '(A)', END=12 )  line
        ENDDO
        BACKSPACE ( 11 )
@@ -5000,5 +5003,5 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, land_surface_parameters )
+       READ ( 11, land_surface_parameters, ERR = 10 )
 
 !
@@ -5006,11 +5009,15 @@
        land_surface = .TRUE.
        
-       GOTO 12
+       GOTO 14
+
+ 10    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'land_surface_parameters', line )
 !
 !--    Try to find old namelist
- 10    REWIND ( 11 )
+ 12    REWIND ( 11 )
        line = ' '
        DO   WHILE ( INDEX( line, '&lsm_par' ) == 0 )
-          READ ( 11, '(A)', END=12 )  line
+          READ ( 11, '(A)', END=14 )  line
        ENDDO
        BACKSPACE ( 11 )
@@ -5018,5 +5025,5 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, lsm_par )
+       READ ( 11, lsm_par, ERR = 13, END = 14 )
 
        message_string = 'namelist lsm_par is deprecated and will be ' // &
@@ -5028,7 +5035,13 @@
 !--    Set flag that indicates that the land surface model is switched on
        land_surface = .TRUE.
-
-
- 12    CONTINUE
+       
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'lsm_par', line )
+
+
+ 14    CONTINUE
        
 
Index: /palm/trunk/SOURCE/message.f90
===================================================================
--- /palm/trunk/SOURCE/message.f90	(revision 3245)
+++ /palm/trunk/SOURCE/message.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added SUBROUTINE parin_fail_message for error handling of input namelists
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -288,2 +291,25 @@
 
  END SUBROUTINE location_message
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Prints out the given location on stdout
+!------------------------------------------------------------------------------!
+ 
+ SUBROUTINE parin_fail_message( location, line )
+
+    USE control_parameters,                                                    &
+        ONLY:  message_string
+
+    IMPLICIT NONE
+
+    CHARACTER(LEN=*) ::  location !< text to be output on stdout
+    CHARACTER(LEN=*) ::  line
+
+    message_string = 'Error(s) in NAMELIST '// TRIM(location) //                 &
+                     '&Reading fails at& '// line
+          CALL message( 'parin', 'PA0271', 1, 2, 0, 6, 0 )
+
+ END SUBROUTINE parin_fail_message
Index: /palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -3775,9 +3778,14 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, agent_parameters )
+       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 ,fmt='(A)') line
+       CALL parin_fail_message ( 'agent_parameters', line )
 
  20    CONTINUE
Index: /palm/trunk/SOURCE/package_parin.f90
===================================================================
--- /palm/trunk/SOURCE/package_parin.f90	(revision 3245)
+++ /palm/trunk/SOURCE/package_parin.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -301,5 +304,5 @@
     line = ' '
     DO   WHILE ( INDEX( line, '&dvrp_graphics_par' ) == 0 )
-       READ ( 11, '(A)', END=20 )  line
+       READ ( 11, '(A)', END=21 )  line
     ENDDO
     BACKSPACE ( 11 )
@@ -307,7 +310,12 @@
 !
 !-- Read user-defined namelist
-    READ ( 11, dvrp_graphics_par )
-
- 20 CONTINUE
+    READ ( 11, dvrp_graphics_par, ERR = 20 )
+
+    GOTO 21
+ 20 BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'dvrp_graphics_par', line )
+
+ 21 CONTINUE
 #endif
 
@@ -317,5 +325,5 @@
     line = ' '
     DO   WHILE ( INDEX( line, '&particle_parameters' ) == 0 )
-       READ ( 11, '(A)', END=30 )  line
+       READ ( 11, '(A)', END=12 )  line
     ENDDO
     BACKSPACE ( 11 )
@@ -323,5 +331,5 @@
 !
 !-- Read user-defined namelist
-    READ ( 11, particle_parameters )
+    READ ( 11, particle_parameters, ERR = 10 )
 
 !
@@ -329,12 +337,16 @@
     particle_advection = .TRUE.
     
-    GOTO 31
+    GOTO 14
+
+10  BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'particle_parameters', line )
 
 !
 !-- Try to find particles package (old namelist)
-30  REWIND ( 11 )
+12  REWIND ( 11 )
     line = ' '
     DO   WHILE ( INDEX( line, '&particles_par' ) == 0 )
-       READ ( 11, '(A)', END=31 )  line
+       READ ( 11, '(A)', END=14 )  line
     ENDDO
     BACKSPACE ( 11 )
@@ -342,5 +354,5 @@
 !
 !-- Read user-defined namelist
-    READ ( 11, particles_par )
+    READ ( 11, particles_par, ERR = 13, END = 14 )
     
     
@@ -354,5 +366,11 @@
     particle_advection = .TRUE.
 
- 31 CONTINUE
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'particles_par', line )
+
+ 14 CONTINUE
 
  END SUBROUTINE package_parin
Index: /palm/trunk/SOURCE/parin.f90
===================================================================
--- /palm/trunk/SOURCE/parin.f90	(revision 3245)
+++ /palm/trunk/SOURCE/parin.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3240 2018-09-12 12:04:40Z Giersch
 ! A check that controls the number of user-defined profiles on the restart file
 ! with the one given for the current run has been added.
@@ -783,14 +786,12 @@
 !--       The namelist "inipar" must be provided in the NAMELIST-file.
           READ ( 11, initialization_parameters, ERR=10, END=11 )
-
-          GOTO 12
-
- 10       message_string = 'errors in initialization_parameters & or no ' //  &
-                           'initialization_parameters-namelist ' //           &
-                           'found (CRAY-machines only)'
-          CALL message( 'parin', 'PA0271', 1, 2, 0, 6, 0 )
+          GOTO 14
+          
+ 10       BACKSPACE( 11 )
+          READ( 11 ,fmt='(A)') line
+          CALL parin_fail_message ( 'initialization_parameters', line )
 
  11       REWIND ( 11 )
-          READ ( 11, inipar, ERR=13, END=14 )
+          READ ( 11, inipar, ERR=12, END=13 )
  
           message_string = 'namelist inipar is deprecated and will be ' //    &
@@ -799,11 +800,11 @@
           CALL message( 'parin', 'PA0017', 0, 1, 0, 6, 0 )
  
-          GOTO 12
+          GOTO 14
  
- 13       message_string = 'errors in inipar & or no inipar-namelist ' //      &
-                           'found (CRAY-machines only)'
-          CALL message( 'parin', 'PA0271', 1, 2, 0, 6, 0 )
-          
- 14       message_string = 'no initialization_parameters-namelist found'
+ 12       BACKSPACE( 11 )
+          READ( 11 ,fmt='(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 )
 
@@ -813,10 +814,10 @@
 !--       can be omitted. In that case default values are used for the         
 !--       parameters.
- 12       line = ' '
+ 14       line = ' '
 
           REWIND ( 11 )
           line = ' '
           DO   WHILE ( INDEX( line, '&runtime_parameters' ) == 0 )
-             READ ( 11, '(A)', END=20 )  line
+             READ ( 11, '(A)', END=16 )  line
           ENDDO
           BACKSPACE ( 11 )
@@ -824,25 +825,34 @@
 !
 !--       Read namelist
-          READ ( 11, runtime_parameters )
-
-          GOTO 21
-          
- 20       REWIND ( 11 )
+          READ ( 11, runtime_parameters, ERR = 15 )
+          GOTO 18
+
+ 15       BACKSPACE( 11 )
+          READ( 11 ,fmt='(A)') line
+          CALL parin_fail_message ( 'runtime_parameters', line )
+
+ 16       REWIND ( 11 )
           line = ' '
           DO   WHILE ( INDEX( line, '&d3par' ) == 0 )
-             READ ( 11, '(A)', END=21 )  line
+             READ ( 11, '(A)', END=18 )  line
           ENDDO
           BACKSPACE ( 11 )
- 
- !
+
+!
 !--       Read namelist
-          READ ( 11, d3par )
- 
+          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 )
-          
- 21       CONTINUE
+
+          GOTO 18
+
+ 17       BACKSPACE( 11 )
+          READ( 11 ,fmt='(A)') line
+          CALL parin_fail_message ( 'd3par', line )
+
+ 18       CONTINUE
 
 !
Index: /palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -1021,7 +1024,7 @@
                                   leaf_scalar_exch_coeff,                      &
                                   leaf_surface_conc, pch_index
-                                  
+
        line = ' '
-       
+
 !
 !--    Try to find radiation model package
@@ -1029,22 +1032,4 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&plant_canopy_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!--    Read user-defined namelist
-       READ ( 11, plant_canopy_parameters )
-
-!
-!--    Set flag that indicates that the radiation model is switched on
-       plant_canopy = .TRUE.
-       
-       GOTO 12
-!
-!--    Try to find old namelist
- 10    REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&canopy_par' ) == 0 )
           READ ( 11, '(A)', END=12 )  line
        ENDDO
@@ -1053,5 +1038,27 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, canopy_par )
+       READ ( 11, plant_canopy_parameters, ERR = 10 )
+
+!
+!--    Set flag that indicates that the radiation model is switched on
+       plant_canopy = .TRUE.
+
+       GOTO 14
+
+ 10    BACKSPACE( 11 )
+       READ( 11 ,fmt='(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 ' // &
@@ -1059,11 +1066,17 @@
                      'plant_canopy_parameters instead'
        CALL message( 'pcm_parin', 'PA0487', 0, 1, 0, 6, 0 )
-       
+
 !
 !--    Set flag that indicates that the radiation model is switched on
        plant_canopy = .TRUE.
 
- 12    CONTINUE
-       
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'canopy_par', line )
+
+ 14    CONTINUE
+
 
     END SUBROUTINE pcm_parin
Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 3246)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed or commented
 ! 
@@ -2787,22 +2790,4 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&radiation_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!--    Read user-defined namelist
-       READ ( 11, radiation_parameters )
-
-!
-!--    Set flag that indicates that the radiation model is switched on
-       radiation = .TRUE.
-       
-       GOTO 12
-!
-!--    Try to find old namelist
- 10    REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&radiation_par' ) == 0 )
           READ ( 11, '(A)', END=12 )  line
        ENDDO
@@ -2811,6 +2796,28 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, radiation_par )
-       
+       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 ,fmt='(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 ' //         &
@@ -2818,5 +2825,4 @@
        CALL message( 'radiation_parin', 'PA0487', 0, 1, 0, 6, 0 )
 
-       
 !
 !--    Set flag that indicates that the radiation model is switched on
@@ -2829,5 +2835,11 @@
        ENDIF
 
- 12    CONTINUE
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'radiation_par', line )
+
+ 14    CONTINUE
        
     END SUBROUTINE radiation_parin
Index: /palm/trunk/SOURCE/spectra_mod.f90
===================================================================
--- /palm/trunk/SOURCE/spectra_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/spectra_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -237,5 +240,5 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&spectra_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
+          READ ( 11, '(A)', END=12 )  line
        ENDDO
        BACKSPACE ( 11 )
@@ -243,5 +246,5 @@
 !
 !--    Read namelist
-       READ ( 11, spectra_parameters )
+       READ ( 11, spectra_parameters, ERR = 10 )
 
 !
@@ -254,11 +257,15 @@
        calculate_spectra = .TRUE.
 
-       GOTO 12
+       GOTO 14
+
+ 10    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'spectra_parameters', line )
 !
 !--    Try to find the old namelist
- 10    REWIND ( 11 )
+ 12    REWIND ( 11 )
        line = ' '
        DO   WHILE ( INDEX( line, '&spectra_par' ) == 0 )
-          READ ( 11, '(A)', END=12 )  line
+          READ ( 11, '(A)', END=14 )  line
        ENDDO
        BACKSPACE ( 11 )
@@ -266,5 +273,5 @@
 !
 !--    Read namelist
-       READ ( 11, spectra_par )
+       READ ( 11, spectra_par, ERR = 13, END = 14 )
 
        
@@ -282,6 +289,12 @@
        calculate_spectra = .TRUE.
        
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'spectra_par', line )
        
- 12    CONTINUE
+       
+ 14    CONTINUE
 
     END SUBROUTINE spectra_parin
Index: /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -967,5 +970,5 @@
     line = ' '
     DO WHILE ( INDEX( line, '&stg_par' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
+       READ ( 11, '(A)', END=20 )  line
     ENDDO
     BACKSPACE ( 11 )
@@ -973,5 +976,5 @@
 !
 !-- Read namelist
-    READ ( 11, stg_par )
+    READ ( 11, stg_par, ERR = 10, END = 20 )
 
 !
@@ -979,7 +982,11 @@
 !-- on
     syn_turb_gen = .TRUE.
-
-
- 10 CONTINUE
+    GOTO 20
+
+ 10 BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'stg_par', line )
+
+ 20 CONTINUE
 
  END SUBROUTINE stg_parin
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 3246)
@@ -28,4 +28,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -5349,4 +5352,7 @@
                            soil_inner_temperature,                             &
                            window_inner_temperature
+                           
+                           
+  
 !
 !--    Try to find urban surface model package
@@ -5354,21 +5360,4 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&urban_surface_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!--    Read user-defined namelist
-       READ ( 11, urban_surface_parameters )
-!
-!--    Set flag that indicates that the land surface model is switched on
-       urban_surface = .TRUE.
-
-       GOTO 12
-!
-!--    Try to find old namelist
- 10    REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&urban_surface_par' ) == 0 )
           READ ( 11, '(A)', END=12 )  line
        ENDDO
@@ -5377,15 +5366,45 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, urban_surface_par )
+       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 ,fmt='(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' 
+                     '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 land surface model is switched on
+
+!
+!--    Set flag that indicates that the urban surface model is switched on
        urban_surface = .TRUE.
 
- 12    CONTINUE
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'urban_surface_par', line )
+
+
+ 14    CONTINUE
 
 
Index: /palm/trunk/SOURCE/user_parin.f90
===================================================================
--- /palm/trunk/SOURCE/user_parin.f90	(revision 3245)
+++ /palm/trunk/SOURCE/user_parin.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3240 2018-09-12 12:04:40Z Giersch
 ! The check that controls the number of user-defined profiles on the restart file
 ! with the one given for the current run has been removed.
@@ -140,21 +143,4 @@
     line = ' '
     DO   WHILE ( INDEX( line, '&user_parameters' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, user_parameters )
-
-    user_defined_namelist_found = .TRUE.
-
-    GOTO 12
-    
-    
-10  REWIND ( 11 )
-
-    line = ' ' 
-    DO   WHILE ( INDEX( line, '&userpar' ) == 0 )
        READ ( 11, '(A)', END=12 )  line
     ENDDO
@@ -163,16 +149,40 @@
 !
 !-- Read user-defined namelist
-    READ ( 11, userpar )
-    
-    
+    READ ( 11, user_parameters, ERR = 10 )
+
+    user_defined_namelist_found = .TRUE.
+
+    GOTO 14
+
+10  BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'user_parameters', line )
+
+12  REWIND ( 11 )
+
+    line = ' ' 
+    DO   WHILE ( INDEX( line, '&userpar' ) == 0 )
+       READ ( 11, '(A)', END=14 )  line
+    ENDDO
+    BACKSPACE ( 11 )
+
+!
+!-- Read user-defined namelist
+    READ ( 11, userpar, ERR = 13, END = 14 )
+
     message_string = 'namelist userpar is deprecated and will be ' //          &
                      'removed in near future. &Please use namelist ' //        &
                      'user_parameters instead' 
     CALL message( 'user_parin', 'PA0487', 0, 1, 0, 6, 0 )
-       
+
     user_defined_namelist_found = .TRUE.
-    
-    
- 12 CONTINUE
+
+    GOTO 14
+
+13  BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'userpar', line )
+
+14 CONTINUE
 
 !
Index: /palm/trunk/SOURCE/uv_exposure_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/uv_exposure_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/uv_exposure_model_mod.f90	(revision 3246)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message and small
+! typo bugfix
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -449,6 +453,6 @@
     REWIND ( 11 )
     line = ' '
-    DO   WHILE ( INDEX( line, '&biometerology_parameters' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
+    DO   WHILE ( INDEX( line, '&biometeorology_parameters' ) == 0 )
+       READ ( 11, '(A)', END=20 )  line
     ENDDO
     BACKSPACE ( 11 )
@@ -456,5 +460,5 @@
 !
 !-- Read user-defined namelist
-    READ ( 11, biometeorology_parameters )
+    READ ( 11, biometeorology_parameters, ERR = 10, END = 20 )
 
 !
@@ -462,6 +466,10 @@
     uv_exposure = .TRUE.
 
-
- 10 CONTINUE
+ 10 BACKSPACE( 11 )
+    READ( 11 ,fmt='(A)') line
+    CALL parin_fail_message ( 'biometeorology_parameters', line )
+
+
+ 20 CONTINUE
        
 
Index: /palm/trunk/SOURCE/virtual_flight_mod.f90
===================================================================
--- /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 3246)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -250,21 +253,4 @@
        line = ' '
        DO   WHILE ( INDEX( line, '&virtual_flight_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!--    Read namelist
-       READ ( 11, virtual_flight_parameters )
-!
-!--    Set switch that virtual flights shall be carried out
-       virtual_flight = .TRUE.
-
-       GOTO 12
-!
-!--    Try to find the old namelist
- 10    REWIND ( 11 )
-       line = ' '
-       DO   WHILE ( INDEX( line, '&flight_par' ) == 0 )
           READ ( 11, '(A)', END=12 )  line
        ENDDO
@@ -273,5 +259,26 @@
 !
 !--    Read namelist
-       READ ( 11, flight_par )
+       READ ( 11, virtual_flight_parameters, ERR = 10 )
+!
+!--    Set switch that virtual flights shall be carried out
+       virtual_flight = .TRUE.
+
+       GOTO 14
+
+ 10    BACKSPACE( 11 )
+       READ( 11 ,fmt='(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 ' // &
@@ -283,5 +290,11 @@
        virtual_flight = .TRUE.
 
- 12    CONTINUE
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'flight_par', line )
+
+ 14    CONTINUE
 
     END SUBROUTINE flight_parin
Index: /palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 3245)
+++ /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 3246)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Added error handling for input namelist via parin_fail_message
+! 
+! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
 ! 
@@ -535,33 +538,4 @@
        line = ' '
        DO  WHILE ( INDEX( line, '&wind_turbine_parameters' ) == 0 )
-          READ ( 11, '(A)', END=10 )  line
-       ENDDO
-       BACKSPACE ( 11 )
-
-!
-!--    Read user-defined namelist
-       READ ( 11, wind_turbine_parameters, IOSTAT=ierrn )
-
-       IF ( ierrn < 0 )  THEN
-          message_string = 'no wind_turbine_parameters-NAMELIST found: '  //    &
-                           'End of file has reached'
-          CALL message( 'wtm_parin', 'PA0460', 1, 2, 0, 6, 0 )
-       ELSEIF ( ierrn > 0 ) THEN
-          message_string = 'errors in wind_turbine_parameters-NAMELIST: '  //   &
-                           'some variables for steering may not be properly set'
-          CALL message( 'wtm_parin', 'PA0466', 1, 2, 0, 6, 0 )               
-       ENDIF
-       
-!
-!--    Set flag that indicates that the wind turbine model is switched on
-       wind_turbine = .TRUE.
-       
-       GOTO 12
-
-!
-!--    Try to find wind turbine model package
- 10    REWIND ( 11 )
-       line = ' '
-       DO  WHILE ( INDEX( line, '&wind_turbine_par' ) == 0 )
           READ ( 11, '(A)', END=12 )  line
        ENDDO
@@ -570,15 +544,27 @@
 !
 !--    Read user-defined namelist
-       READ ( 11, wind_turbine_par, IOSTAT=ierrn )
-
-       IF ( ierrn < 0 )  THEN
-          message_string = 'no wind_turbine_par-NAMELIST found: '  //          &
-                           'End of file has reached'
-          CALL message( 'wtm_parin', 'PA0460', 1, 2, 0, 6, 0 )
-       ELSEIF ( ierrn > 0 ) THEN
-          message_string = 'errors in wind_turbine_par-NAMELIST: '  //         &
-                           'some variables for steering may not be properly set'
-          CALL message( 'wtm_parin', 'PA0466', 1, 2, 0, 6, 0 )               
-       ENDIF
+       READ ( 11, wind_turbine_parameters, ERR = 10 )
+!
+!--    Set flag that indicates that the wind turbine model is switched on
+       wind_turbine = .TRUE.
+       
+       GOTO 14
+
+ 10    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'wind_turbine_parameters', line )
+
+!
+!--    Try to find wind turbine model package
+ 12    REWIND ( 11 )
+       line = ' '
+       DO  WHILE ( INDEX( line, '&wind_turbine_par' ) == 0 )
+          READ ( 11, '(A)', END=14 )  line
+       ENDDO
+       BACKSPACE ( 11 )
+
+!
+!--    Read user-defined namelist
+       READ ( 11, wind_turbine_par, ERR = 13, END = 14 )
       
        message_string = 'namelist wind_tubrine_par is deprecated and will ' // &
@@ -591,5 +577,11 @@
        wind_turbine = .TRUE.
 
- 12    CONTINUE   ! TBD Change from continue, mit ierrn machen
+       GOTO 14
+
+ 13    BACKSPACE( 11 )
+       READ( 11 ,fmt='(A)') line
+       CALL parin_fail_message ( 'wind_turbine_par', line )
+
+ 14    CONTINUE   ! TBD Change from continue, mit ierrn machen
 
 
