source: palm/trunk/SOURCE/user_parin.f90 @ 3246

Last change on this file since 3246 was 3246, checked in by sward, 4 years ago

Added error handling for wrong input parameters

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1!> @file user_parin.f90
2!------------------------------------------------------------------------------!
3! This file is part of the PALM model system.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2018 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: user_parin.f90 3246 2018-09-13 15:14:50Z sward $
27! Added error handling for input namelist via parin_fail_message
28!
29! 3240 2018-09-12 12:04:40Z Giersch
30! The check that controls the number of user-defined profiles on the restart file
31! with the one given for the current run has been removed.
32!
33! 3189 2018-08-06 13:18:55Z Giersch
34! Indent revised
35!
36! 3174 2018-07-26 13:46:50Z Giersch
37! userpar in READ statement has been changed to user_parameters
38!
39! 3049 2018-05-29 13:52:36Z Giersch
40! Error messages revised
41!
42! 3045 2018-05-28 07:55:41Z Giersch
43! renamed userpar to user_parameters
44!
45! 2718 2018-01-02 08:49:38Z maronga
46! Corrected "Former revisions" section
47!
48! 2696 2017-12-14 17:12:51Z kanani
49! Change in file header (GPL part)
50!
51! 2512 2017-10-04 08:26:59Z raasch
52! current interface revision number number set to r2512
53!
54! 2298 2017-06-29 09:28:18Z raasch
55! user interface current revision updated
56!
57! 2101 2017-01-05 16:42:31Z suehring
58!
59! 2000 2016-08-20 18:09:15Z knoop
60! Forced header and separation lines into 80 columns
61!
62! 1833 2016-04-07 14:23:03Z raasch
63! required interface revision changed
64!
65! 1783 2016-03-06 18:36:17Z raasch
66! required interface revision changed
67!
68! 1682 2015-10-07 23:56:08Z knoop
69! Code annotations made doxygen readable
70!
71! 1668 2015-09-23 13:45:36Z raasch
72! current interface revision number number set to r1663
73!
74! 1666 2015-09-23 07:31:10Z raasch
75! interface revision number is set to blank
76!
77! 1320 2014-03-20 08:40:49Z raasch
78! kind-parameters added to all INTEGER and REAL declaration statements,
79! kinds are defined in new module kinds,
80! old module precision_kind is removed,
81! revision history before 2012 removed,
82! comment fields (!:) to be used for variable explanations added to
83! all variable declaration statements
84!
85! 1036 2012-10-22 13:43:42Z raasch
86! code put under GPL (PALM 3.9)
87!
88! 931 2012-06-08 15:09:28Z maronga
89! Re-enabled check for max_pr_user
90!
91! 841 2012-02-28 12:29:49Z maronga
92! Bugfix: disable max_pr_user check during prior namelist file check
93!
94! 217 2008-12-09 18:00:48Z letzel
95! +topography_grid_convention
96! Former file user_interface.f90 split into one file per subroutine
97!
98! Description:
99! ------------
100!> Interface to read user-defined namelist-parameters.
101!------------------------------------------------------------------------------!
102 SUBROUTINE user_parin
103 
104
105    USE control_parameters
106   
107    USE kinds
108   
109    USE pegrid
110   
111    USE statistics
112   
113    USE user
114
115    IMPLICIT NONE
116
117    CHARACTER (LEN=80) ::  line   !<
118
119    INTEGER(iwp) ::  i                 !<
120    INTEGER(iwp) ::  j                 !<
121
122
123    NAMELIST /userpar/  data_output_pr_user, data_output_user, region,         &
124                        data_output_masks_user
125                       
126                       
127    NAMELIST /user_parameters/  data_output_pr_user, data_output_user, region, &
128                        data_output_masks_user
129
130!
131!-- Set revision number of this default interface version. It will be checked within
132!-- the main program (palm). Please change the revision number in case that the
133!-- current revision does not match with previous revisions (e.g. if routines
134!-- have been added/deleted or if parameter lists in subroutines have been changed).
135    user_interface_current_revision = 'r2512'
136
137!
138!-- Position the namelist-file at the beginning (it was already opened in
139!-- parin), search for user-defined namelist-group ("userpar", but any other
140!-- name can be choosed) and position the file at this line.
141    REWIND ( 11 )
142
143    line = ' '
144    DO   WHILE ( INDEX( line, '&user_parameters' ) == 0 )
145       READ ( 11, '(A)', END=12 )  line
146    ENDDO
147    BACKSPACE ( 11 )
148
149!
150!-- Read user-defined namelist
151    READ ( 11, user_parameters, ERR = 10 )
152
153    user_defined_namelist_found = .TRUE.
154
155    GOTO 14
156
15710  BACKSPACE( 11 )
158    READ( 11 ,fmt='(A)') line
159    CALL parin_fail_message ( 'user_parameters', line )
160
16112  REWIND ( 11 )
162
163    line = ' ' 
164    DO   WHILE ( INDEX( line, '&userpar' ) == 0 )
165       READ ( 11, '(A)', END=14 )  line
166    ENDDO
167    BACKSPACE ( 11 )
168
169!
170!-- Read user-defined namelist
171    READ ( 11, userpar, ERR = 13, END = 14 )
172
173    message_string = 'namelist userpar is deprecated and will be ' //          &
174                     'removed in near future. &Please use namelist ' //        &
175                     'user_parameters instead' 
176    CALL message( 'user_parin', 'PA0487', 0, 1, 0, 6, 0 )
177
178    user_defined_namelist_found = .TRUE.
179
180    GOTO 14
181
18213  BACKSPACE( 11 )
183    READ( 11 ,fmt='(A)') line
184    CALL parin_fail_message ( 'userpar', line )
185
18614 CONTINUE
187
188!
189!-- Determine the number of user-defined profiles and append them to the
190!-- standard data output (data_output_pr)
191    IF ( user_defined_namelist_found )  THEN
192       IF ( data_output_pr_user(1) /= ' ' )  THEN
193          i = 1
194          DO  WHILE ( data_output_pr(i) /= ' '  .AND.  i <= 100 )
195             i = i + 1
196          ENDDO
197          j = 1
198          DO  WHILE ( data_output_pr_user(j) /= ' '  .AND.  j <= 100 )
199             data_output_pr(i) = data_output_pr_user(j)
200             max_pr_user_tmp   = max_pr_user_tmp + 1
201             i = i + 1
202             j = j + 1
203          ENDDO
204       ENDIF
205    ENDIF
206 
207    RETURN
208
209 END SUBROUTINE user_parin
210
Note: See TracBrowser for help on using the repository browser.