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