Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4831)
+++ 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
