Changeset 4287 for palm


Ignore:
Timestamp:
Nov 1, 2019 2:50:20 PM (16 months ago)
Author:
raasch
Message:

reading of namelist file and actions in case of namelist errors revised so that statement labels and goto statements are not required any more; this revision also removes a previous bug which appeared when the namelist has been commented out in the namelist file

File:
1 edited

Legend:

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

    r4182 r4287  
    2525! -----------------
    2626! $Id$
     27! reading of namelist file and actions in case of namelist errors revised so that statement labels
     28! and goto statements are not required any more; this revision also removes a previous bug
     29! which appeared when the namelist has been commented out in the namelist file
     30!
     31! 4182 2019-08-22 15:20:23Z scharf
    2732! Corrected "Former revisions" section
    2833!
     
    211216 SUBROUTINE user_parin
    212217
    213 
    214     CHARACTER (LEN=80) ::  line   !<
    215 
    216     INTEGER(iwp) ::  i                 !<
     218    CHARACTER (LEN=80) ::  line        !< string containing the last line read from namelist file
     219
     220    INTEGER(iwp) ::  i                 !<
     221    INTEGER(iwp) ::  io_status         !< status after reading the namelist file
    217222    INTEGER(iwp) ::  j                 !<
    218223
    219224
    220     NAMELIST /user_parameters/  &
    221        user_module_enabled, &
    222        data_output_pr_user, &
    223        data_output_user, &
    224        region, &
    225        data_output_masks_user
     225    NAMELIST /user_parameters/                                                                     &
     226       data_output_masks_user,                                                                     &
     227       data_output_pr_user,                                                                        &
     228       data_output_user,                                                                           &
     229       region
    226230
    227231!
     
    240244!
    241245!-- Position the namelist-file at the beginning (it was already opened in
    242 !-- parin), search for user-defined namelist-group ("userpar", but any other
    243 !-- name can be choosed) and position the file at this line.
     246!-- parin), and try to read (find) a namelist named "user_parameters".
    244247    REWIND ( 11 )
    245 
    246     line = ' '
    247     DO WHILE ( INDEX( line, '&user_parameters' ) == 0 )
    248        READ ( 11, '(A)', END=12 )  line
    249     ENDDO
    250     BACKSPACE ( 11 )
    251 
    252 !-- Set default module switch to true
    253     user_module_enabled = .TRUE.
    254 
    255 !-- Read user-defined namelist
    256     READ ( 11, user_parameters, ERR = 10 )
    257 
    258     GOTO 12
    259 
    260 10  BACKSPACE( 11 )
    261     READ( 11 , '(A)') line
    262     CALL parin_fail_message( 'user_parameters', line )
    263 
    264 12  CONTINUE
     248    READ( 11, user_parameters, IOSTAT=io_status )
     249
     250!
     251!-- Actions depending on the READ status
     252    IF ( io_status == 0 )  THEN
     253!
     254!--    User namelist found and correctly read. Set default module switch to true. This activates
     255!--    calls of the user-interface subroutines.
     256       user_module_enabled = .TRUE.
     257
     258    ELSEIF ( io_status > 0 )  THEN
     259!
     260!--    User namelist was found, but contained errors. Print an error message containing the line
     261!--    that caused the problem
     262       BACKSPACE( 11 )
     263       READ( 11 , '(A)') line
     264       CALL parin_fail_message( 'user_parameters', line )
     265
     266    ENDIF
    265267
    266268!
Note: See TracChangeset for help on using the changeset viewer.