MOM6
MOM_obsolete_params.F90
1 !> Methods for testing for, and list of, obsolete run-time parameters.
3 
4 ! This file is part of MOM6. See LICENSE.md for the license.
5 ! This module was first conceived and written by Robert Hallberg, July 2010.
6 
7 use mom_error_handler, only : mom_error, fatal, warning, is_root_pe
9 
10 implicit none ; private
11 
12 #include <MOM_memory.h>
13 
14 public find_obsolete_params
15 public obsolete_logical, obsolete_int, obsolete_real, obsolete_char
16 
17 contains
18 
19 !> Scans input parameter file for list obsolete parameters.
20 subroutine find_obsolete_params(param_file)
21  type(param_file_type), intent(in) :: param_file !< Structure containing parameter file data.
22  ! Local variables
23  character(len=40) :: mdl = "find_obsolete_params" ! This module's name.
24 ! This include declares and sets the variable "version".
25 #include "version_variable.h"
26  integer :: test_int, l_seg, nseg
27  logical :: test_logic, test_logic2, test_logic3, split
28  character(len=40) :: temp_string
29 
30  if (.not.is_root_pe()) return
31 
32  call obsolete_int(param_file, "NTSTEP", &
33  hint="Instead use DT_THERM to set the thermodynamic time-step.")
34 
35  call obsolete_logical(param_file, "JACOBIAN_PGF", .false., &
36  hint="Instead use ANALYTIC_FV_PGF.")
37 
38  call obsolete_logical(param_file, "SADOURNY", &
39  hint="Instead use CORIOLIS_SCHEME='SADOURNY'.")
40 
41  call obsolete_logical(param_file, "ARITHMETIC_BT_THICK", &
42  hint="Instead use BT_THICK_SCHEME='ARITHMETIC'.")
43 
44  call obsolete_logical(param_file, "HYBRID_BT_THICK", &
45  hint="Instead use BT_THICK_SCHEME='HYBRID'.")
46 
47  call obsolete_logical(param_file, "BT_CONT_BT_THICK", &
48  hint="Instead use BT_THICK_SCHEME='FROM_BT_CONT'.")
49 
50  call obsolete_logical(param_file, "APPLY_OBC_U", &
51  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
52  call obsolete_logical(param_file, "APPLY_OBC_V", &
53  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
54  call obsolete_logical(param_file, "APPLY_OBC_V_FLATHER_NORTH", &
55  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
56  call obsolete_logical(param_file, "APPLY_OBC_V_FLATHER_SOUTH", &
57  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
58  call obsolete_logical(param_file, "APPLY_OBC_U_FLATHER_EAST", &
59  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
60  call obsolete_logical(param_file, "APPLY_OBC_U_FLATHER_WEST", &
61  hint="Instead use OBC_NUMBER_SEGMENTS>0 and use the new segments protocol.")
62  call obsolete_char(param_file, "OBC_CONFIG", &
63  hint="Instead use OBC_USER_CONFIG and use the new segments protocol.")
64  call obsolete_char(param_file, "READ_OBC_ETA", &
65  hint="Instead use OBC_SEGMENT_XXX_DATA.")
66  call obsolete_char(param_file, "READ_OBC_UV", &
67  hint="Instead use OBC_SEGMENT_XXX_DATA.")
68  call obsolete_char(param_file, "READ_OBC_TS", &
69  hint="Instead use OBC_SEGMENT_XXX_DATA.")
70  call obsolete_char(param_file, "EXTEND_OBC_SEGMENTS", &
71  hint="This option is no longer needed, nor supported.")
72  call obsolete_char(param_file, "MEKE_VISCOSITY_COEFF", &
73  hint="This option has been replaced by MEKE_VISCOSITY_COEFF_KU and \n" //&
74  " MEKE_VISCOSITY_COEFF_AU. Please set these parameters instead.")
75  nseg = 0
76  call read_param(param_file, "OBC_NUMBER_OF_SEGMENTS", nseg)
77  do l_seg = 1,nseg
78  write(temp_string(1:22),"('OBC_SEGMENT_',i3.3,'_TNUDGE')") l_seg
79  call obsolete_real(param_file, temp_string, &
80  hint="Instead use OBC_SEGMENT_xxx_VELOCITY_NUDGING_TIMESCALES.")
81  enddo
82 
83  test_logic3 = .true. ; call read_param(param_file,"ENABLE_THERMODYNAMICS",test_logic3)
84  test_logic = .true. ; call read_param(param_file,"TEMPERATURE",test_logic)
85  test_logic2 = .false. ; call read_param(param_file,"TEMPERATURE",test_logic2)
86  if (test_logic .eqv. test_logic2) then ; if (test_logic .eqv. test_logic3) then
87  call mom_error(warning, "find_obsolete_params: "// &
88  "TEMPERATURE is an obsolete run-time flag, but is set consistently with \n"//&
89  " ENABLE_THERMODYNAMICS.")
90  else
91  call mom_error(fatal, "find_obsolete_params: "// &
92  "TEMPERATURE is an obsolete run-time flag. Use ENABLE_THERMODYNAMICS instead.")
93  endif ; endif
94 
95  test_logic = test_logic3 ; call read_param(param_file,"NONLINEAR_EOS",test_logic)
96  if (test_logic .neqv. test_logic3) then
97  call mom_error(warning, "find_obsolete_params: "// &
98  "NONLINEAR_EOS is an obsolete option. Instead define " // &
99  "USE_EOS to use an equation of state to calculate density.")
100  endif
101 
102 ! test_logic = .true. ; call read_param(param_file,"USE_RIVER_HEAT_CONTENT",test_logic)
103 ! test_logic2 = .false. ; call read_param(param_file,"USE_RIVER_HEAT_CONTENT",test_logic2)
104 ! if (test_logic .eqv. test_logic2) call MOM_ERROR(FATAL, "find_obsolete_params: "// &
105 ! "USE_RIVER_HEAT_CONTENT, is an obsolete run-time flag.")
106 
107 ! test_logic = .true. ; call read_param(param_file,"USE_CALVING_HEAT_CONTENT",test_logic)
108 ! test_logic2 = .false. ; call read_param(param_file,"USE_CALVING_HEAT_CONTENT",test_logic2)
109 ! if (test_logic .eqv. test_logic2) call MOM_ERROR(FATAL, "find_obsolete_params: "// &
110 ! "USE_CALVING_HEAT_CONTENT, is an obsolete run-time flag.")
111 
112  call obsolete_int(param_file, "NXTOT")
113  call obsolete_int(param_file, "NYTOT")
114  call obsolete_int(param_file, "NZ")
115  call obsolete_int(param_file, "NXPROC")
116  call obsolete_int(param_file, "NYPROC")
117  call obsolete_int(param_file, "NXPROC_IO")
118  call obsolete_int(param_file, "NYPROC_IO")
119  call obsolete_int(param_file, "NXHALO")
120  call obsolete_int(param_file, "NYHALO")
121  call obsolete_int(param_file, "ML_PRESORT_NZ_CONV_ADJ")
122 
123  call obsolete_int(param_file, "NIPROC_IO", hint="Use IO_LAYOUT=#,# instead.")
124  call obsolete_int(param_file, "NJPROC_IO", hint="Use IO_LAYOUT=#,# instead.")
125 
126  call obsolete_real(param_file, "BT_COR_SLOW_RATE", 0.0)
127  call obsolete_real(param_file, "BT_COR_FRAC", 1.0)
128 
129  call obsolete_logical(param_file, "MASK_MASSLESS_TRACERS", .false.)
130 
131  call obsolete_logical(param_file, "BT_INCLUDE_UDHDT", .false.)
132 
133  call obsolete_logical(param_file, "RIGA_SET_DIFFUSIVITY", .false.)
134  call obsolete_logical(param_file, "RIGA_ITIDE_BUGS", .false.)
135  call obsolete_logical(param_file, "RIGA_ENTRAINMENT_FOIBLES", .false.)
136  call obsolete_logical(param_file, "RIGA_TRACER_DIFFUSE_BUGS", .false.)
137  call obsolete_logical(param_file, "RIGA_KAPPA_SHEAR_BUGS1", .false.)
138  call obsolete_logical(param_file, "RIGA_KAPPA_SHEAR_BUGS2", .false.)
139  call obsolete_logical(param_file, "CONT_PPM_RIGA_BUGS", .false.)
140  call obsolete_logical(param_file, "USE_REPRODUCING_SUM", .true.)
141  call obsolete_logical(param_file, "SLOW_BITWISE_GLOBAL_FORCING_SUMS", .false.)
142  call obsolete_logical(param_file, "ALWAYS_WRITE_GEOM")
143  call obsolete_real(param_file, "I_ZETA")
144 
145  call obsolete_logical(param_file, "REF_COMPRESS_3D")
146  call obsolete_char(param_file, "COMPRESS_FILE")
147  call obsolete_char(param_file, "REF_COMPRESS_FILE_TEMP")
148  call obsolete_char(param_file, "REF_COMPRESS_FILE_SALT")
149  call obsolete_char(param_file, "REF_COMPRESS_FILE_DEPTH")
150  call obsolete_char(param_file, "DIAG_REMAP_Z_GRID_DEF", "Use NUM_DIAG_COORDS, DIAG_COORDS and DIAG_COORD_DEF_Z")
151 
152  call obsolete_logical(param_file, "OLD_RESTRAT_PARAM", .false.)
153  call obsolete_real(param_file, "ML_RESTRAT_COEF", 0.0)
154  call obsolete_logical(param_file, "FULL_THICKNESSDIFFUSE", .true.)
155  call obsolete_logical(param_file, "DIFFUSE_ISOPYCNALS", .true.)
156 
157  call obsolete_logical(param_file, "MOREL_PEN_SW")
158  call obsolete_logical(param_file, "MANIZZA_PEN_SW")
159 
160  call obsolete_logical(param_file, "USE_H2000_SHEAR_MIXING", .false.)
161  call obsolete_real(param_file, "SHEARMIX_LAT_EQ", 0.0)
162  call obsolete_real(param_file, "RINO_CRIT_EQ")
163  call obsolete_real(param_file, "SHEARMIX_RATE_EQ")
164 
165  call obsolete_real(param_file, "VSTAR_SCALE_FACTOR", hint="Use EPBL_VEL_SCALE_FACTOR instead.")
166  call obsolete_logical(param_file, "ORIG_MLD_ITERATION", .false.)
167 
168  call obsolete_logical(param_file, "CONTINUITY_PPM", .true.)
169 
170  call obsolete_logical(param_file, "USE_LOCAL_PREF", .true.)
171  call obsolete_logical(param_file, "USE_LOCAL_PREF_CORRECT", .true.)
172  test_logic = .false. ; call read_param(param_file, "USE_JACKSON_PARAM", test_logic)
173  call obsolete_logical(param_file, "RINOMIX", test_logic)
174  call obsolete_logical(param_file, "NORMALIZED_SUM_OUT", .true.)
175 
176  call obsolete_real(param_file, "RLAY_RANGE")
177  call obsolete_real(param_file, "RLAY_REF")
178 
179  call obsolete_real(param_file, "HMIX")
180  call obsolete_real(param_file, "VSTAR_SCALE_COEF")
181  call obsolete_real(param_file, "ZSTAR_RIGID_SURFACE_THRESHOLD")
182 
183  test_int = -1 ; call read_param(param_file,"ML_RADIATION_CODING",test_int)
184  if (test_int == 1) call mom_error(fatal, "find_obsolete_params: "// &
185  "ML_RADIATION_CODING is an obsolete option and the code previously "//&
186  "used by setting it to 1 has been eliminated.")
187  if (test_int /= -1) call mom_error(warning, "find_obsolete_params: "// &
188  "ML_RADIATION_CODING is an obsolete option.")
189 
190  ! Test for inconsistent parameter settings.
191  split = .true. ; test_logic = .false.
192  call read_param(param_file,"SPLIT",split)
193  call read_param(param_file,"DYNAMIC_SURFACE_PRESSURE",test_logic)
194  if (test_logic .and. .not.split) call mom_error(fatal, &
195  "find_obsolete_params: #define DYNAMIC_SURFACE_PRESSURE is not yet "//&
196  "implemented without #define SPLIT.")
197 
198  call obsolete_logical(param_file, "USE_LEGACY_SPLIT", .false.)
199 
200  call obsolete_logical(param_file, "FLUX_BT_COUPLING", .false.)
201  call obsolete_logical(param_file, "READJUST_BT_TRANS", .false.)
202  call obsolete_logical(param_file, "RESCALE_BT_FACE_AREAS", .false.)
203  call obsolete_logical(param_file, "APPLY_BT_DRAG", .true.)
204  call obsolete_real(param_file, "BT_MASS_SOURCE_LIMIT", 0.0)
205 
206  call obsolete_int(param_file, "SEAMOUNT_LENGTH_SCALE", hint="Use SEAMOUNT_X_LENGTH_SCALE instead.")
207 
208  call obsolete_logical(param_file, "MSTAR_FIXED", hint="Instead use MSTAR_MODE.")
209  call obsolete_logical(param_file, "USE_VISBECK_SLOPE_BUG", .false.)
210 
211  call obsolete_real(param_file, "MIN_Z_DIAG_INTERVAL")
212  call obsolete_char(param_file, "Z_OUTPUT_GRID_FILE")
213 
214  ! Write the file version number to the model log.
215  call log_version(param_file, mdl, version)
216 
217 end subroutine find_obsolete_params
218 
219 !> Test for presence of obsolete LOGICAL in parameter file.
220 subroutine obsolete_logical(param_file, varname, warning_val, hint)
221  type(param_file_type), intent(in) :: param_file !< Structure containing parameter file data.
222  character(len=*), intent(in) :: varname !< Name of obsolete LOGICAL parameter.
223  logical, optional, intent(in) :: warning_val !< An allowed value that causes a warning instead of an error.
224  character(len=*), optional, intent(in) :: hint !< A hint to the user about what to do.
225  ! Local variables
226  logical :: test_logic, fatal_err
227  character(len=128) :: hint_msg
228 
229  test_logic = .false. ; call read_param(param_file, varname,test_logic)
230  fatal_err = .true.
231  if (present(warning_val)) fatal_err = (warning_val .neqv. .true.)
232  hint_msg = " " ; if (present(hint)) hint_msg = hint
233 
234  if (test_logic) then
235  if (fatal_err) then
236  call mom_error(fatal, "MOM_obsolete_params: "//trim(varname)// &
237  " is an obsolete run-time flag, and should not be used. "// &
238  trim(hint_msg))
239  else
240  call mom_error(warning, "MOM_obsolete_params: "//trim(varname)// &
241  " is an obsolete run-time flag. "//trim(hint_msg))
242  endif
243  endif
244 
245  test_logic = .true. ; call read_param(param_file, varname, test_logic)
246  fatal_err = .true.
247  if (present(warning_val)) fatal_err = (warning_val .neqv. .false.)
248 
249  if (.not.test_logic) then
250  if (fatal_err) then
251  call mom_error(fatal, "MOM_obsolete_params: "//trim(varname)// &
252  " is an obsolete run-time flag, and should not be used. "// &
253  trim(hint_msg))
254  else
255  call mom_error(warning, "MOM_obsolete_params: "//trim(varname)// &
256  " is an obsolete run-time flag. "//trim(hint_msg))
257  endif
258  endif
259 
260 end subroutine obsolete_logical
261 
262 !> Test for presence of obsolete STRING in parameter file.
263 subroutine obsolete_char(param_file, varname, hint)
264  type(param_file_type), intent(in) :: param_file !< Structure containing parameter file data.
265  character(len=*), intent(in) :: varname !< Name of obsolete STRING parameter.
266  character(len=*), optional, intent(in) :: hint !< A hint to the user about what to do.
267  ! Local variables
268  character(len=200) :: test_string, hint_msg
269 
270  test_string = ''; call read_param(param_file, varname, test_string)
271  hint_msg = " " ; if (present(hint)) hint_msg = hint
272 
273  if (len_trim(test_string) > 0) call mom_error(fatal, &
274  "MOM_obsolete_params: "//trim(varname)// &
275  " is an obsolete run-time flag, and should not be used. "// &
276  trim(hint_msg))
277 
278 end subroutine obsolete_char
279 
280 !> Test for presence of obsolete REAL in parameter file.
281 subroutine obsolete_real(param_file, varname, warning_val, hint)
282  type(param_file_type), intent(in) :: param_file !< Structure containing parameter file data.
283  character(len=*), intent(in) :: varname !< Name of obsolete REAL parameter.
284  real, optional, intent(in) :: warning_val !< An allowed value that causes a warning instead of an error.
285  character(len=*), optional, intent(in) :: hint !< A hint to the user about what to do.
286  ! Local variables
287  real :: test_val, warn_val
288  character(len=128) :: hint_msg
289 
290  test_val = -9e35; call read_param(param_file, varname, test_val)
291  warn_val = -9e35; if (present(warning_val)) warn_val = warning_val
292  hint_msg = " " ; if (present(hint)) hint_msg = hint
293 
294  if (test_val /= -9e35) then
295  if (test_val == warn_val) then
296  call mom_error(warning, "MOM_obsolete_params: "//trim(varname)// &
297  " is an obsolete run-time flag. "//trim(hint_msg))
298  else
299  call mom_error(fatal, "MOM_obsolete_params: "//trim(varname)// &
300  " is an obsolete run-time flag, and should not be used. "// &
301  trim(hint_msg))
302  endif
303  endif
304 end subroutine obsolete_real
305 
306 !> Test for presence of obsolete INTEGER in parameter file.
307 subroutine obsolete_int(param_file, varname, warning_val, hint)
308  type(param_file_type), intent(in) :: param_file !< Structure containing parameter file data.
309  character(len=*), intent(in) :: varname !< Name of obsolete INTEGER parameter.
310  integer, optional, intent(in) :: warning_val !< An allowed value that causes a warning instead of an error.
311  character(len=*), optional, intent(in) :: hint !< A hint to the user about what to do.
312  ! Local variables
313  integer :: test_val, warn_val
314  character(len=128) :: hint_msg
315 
316  test_val = -123456788; call read_param(param_file, varname, test_val)
317  warn_val = -123456788; if (present(warning_val)) warn_val = warning_val
318  hint_msg = " " ; if (present(hint)) hint_msg = hint
319 
320  if (test_val /= -123456788) then
321  if (test_val == warn_val) then
322  call mom_error(warning, "MOM_obsolete_params: "//trim(varname)// &
323  " is an obsolete run-time flag. "//trim(hint_msg))
324  else
325  call mom_error(fatal, "MOM_obsolete_params: "//trim(varname)// &
326  " is an obsolete run-time flag, and should not be used. "// &
327  trim(hint_msg))
328  endif
329  endif
330 end subroutine obsolete_int
331 
332 end module mom_obsolete_params
mom_file_parser::log_version
An overloaded interface to log version information about modules.
Definition: MOM_file_parser.F90:109
mom_file_parser::param_file_type
A structure that can be parsed to read and document run-time parameters.
Definition: MOM_file_parser.F90:54
mom_file_parser
The MOM6 facility to parse input files for runtime parameters.
Definition: MOM_file_parser.F90:2
mom_obsolete_params
Methods for testing for, and list of, obsolete run-time parameters.
Definition: MOM_obsolete_params.F90:2
mom_error_handler
Routines for error handling and I/O management.
Definition: MOM_error_handler.F90:2
mom_file_parser::read_param
An overloaded interface to read various types of parameters.
Definition: MOM_file_parser.F90:90