MOM6
MOM_obsolete_diagnostics.F90
1 !> Provides a mechanism for recording diagnostic variables that are no longer
2 !! valid, along with their replacement name if appropriate.
4 
5 ! This file is part of MOM6. See LICENSE.md for the license.
6 
7 use mom_error_handler, only : mom_error, fatal, warning, is_root_pe
10 use diag_manager_mod, only : register_static_field_fms=>register_static_field
11 
12 implicit none ; private
13 
14 #include <MOM_memory.h>
15 
16 public register_obsolete_diagnostics
17 
18 contains
19 
20 !> Scan through the diag_table searching for obsolete parameters and issue informational
21 !! messages and optionallly a FATAL error.
22 subroutine register_obsolete_diagnostics(param_file, diag)
23  type(param_file_type), intent(in) :: param_file !< The parameter file handle.
24  type(diag_ctrl), intent(in) :: diag !< A structure used to control diagnostics.
25 ! This include declares and sets the variable "version".
26 #include "version_variable.h"
27  ! Local variables
28  character(len=40) :: mdl = "MOM_obsolete_diagnostics" !< This module's name.
29  logical :: foundentry, causefatal
30  integer :: errtype
31 
32  call log_version(param_file, mdl, version)
33  call get_param(param_file, mdl, "OBSOLETE_DIAGNOSTIC_IS_FATAL", causefatal, &
34  "If an obsolete diagnostic variable appears in the diag_table, "// &
35  "cause a FATAL error rather than issue a WARNING.", default=.true.)
36 
37  foundentry = .false.
38  ! Each obsolete entry, with replacement name is available.
39  if (found_in_diagtable(diag, 'Net_Heat', 'net_heat_surface or net_heat_coupler')) foundentry = .true.
40  if (found_in_diagtable(diag, 'PmE', 'PRCmE')) foundentry = .true.
41  if (found_in_diagtable(diag, 'froz_precip', 'fprec')) foundentry = .true.
42  if (found_in_diagtable(diag, 'liq_precip', 'lprec')) foundentry = .true.
43  if (found_in_diagtable(diag, 'virt_precip', 'vprec')) foundentry = .true.
44  if (found_in_diagtable(diag, 'froz_runoff', 'frunoff')) foundentry = .true.
45  if (found_in_diagtable(diag, 'liq_runoff', 'lrunoff')) foundentry = .true.
46  if (found_in_diagtable(diag, 'calving_heat_content', 'heat_content_frunoff')) foundentry = .true.
47  if (found_in_diagtable(diag, 'precip_heat_content', 'heat_content_lprec')) foundentry = .true.
48  if (found_in_diagtable(diag, 'evap_heat_content', 'heat_content_massout')) foundentry = .true.
49  if (found_in_diagtable(diag, 'runoff_heat_content', 'heat_content_lrunoff')) foundentry = .true.
50  if (found_in_diagtable(diag, 'latent_fprec')) foundentry = .true.
51  if (found_in_diagtable(diag, 'latent_calve')) foundentry = .true.
52  if (found_in_diagtable(diag, 'heat_rest', 'heat_restore')) foundentry = .true.
53  if (found_in_diagtable(diag, 'KPP_dTdt', 'KPP_NLT_dTdt')) foundentry = .true.
54  if (found_in_diagtable(diag, 'KPP_dSdt', 'KPP_NLT_dSdt')) foundentry = .true.
55 
56  if (causefatal) then; errtype = fatal
57  else ; errtype = warning ; endif
58  if (foundentry .and. is_root_pe()) &
59  call mom_error(errtype, 'MOM_obsolete_diagnostics: '//&
60  'Obsolete diagnostics found in diag_table')
61 
62 end subroutine register_obsolete_diagnostics
63 
64 !> Fakes a register of a diagnostic to find out if an obsolete
65 !! parameter appears in the diag_table.
66 logical function found_in_diagtable(diag, varName, newVarName)
67  type(diag_ctrl), intent(in) :: diag !< A structure used to control diagnostics.
68  character(len=*), intent(in) :: varname !< The obsolete diagnostic name
69  character(len=*), optional, intent(in) :: newvarname !< The valid name of this diagnostic
70  ! Local
71  integer :: handle ! Integer handle returned from diag_manager
72 
73  ! We use register_static_field_fms() instead of register_static_field() so
74  ! that the diagnostic does not appear in the available diagnostics list.
75  handle = register_static_field_fms('ocean_model', varname, &
76  diag%axesT1%handles, 'Obsolete parameter', 'N/A')
77 
78  found_in_diagtable = (handle>0)
79 
80  if (handle>0 .and. is_root_pe()) then
81  if (present(newvarname)) then
82  call mom_error(warning, 'MOM_obsolete_params: '// &
83  'diag_table entry "'//trim(varname)//'" found. Use '// &
84  '"'//trim(newvarname)//'" instead.' )
85  else
86  call mom_error(warning, 'MOM_obsolete_params: '// &
87  'diag_table entry "'//trim(varname)//'" is obsolete.' )
88  endif
89  endif
90 
91 end function found_in_diagtable
92 
93 end module mom_obsolete_diagnostics
mom_file_parser::log_version
An overloaded interface to log version information about modules.
Definition: MOM_file_parser.F90:109
mom_diag_mediator
The subroutines here provide convenient wrappers to the fms diag_manager interfaces with additional d...
Definition: MOM_diag_mediator.F90:3
mom_obsolete_diagnostics
Provides a mechanism for recording diagnostic variables that are no longer valid, along with their re...
Definition: MOM_obsolete_diagnostics.F90:3
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::get_param
An overloaded interface to read and log the values of various types of parameters.
Definition: MOM_file_parser.F90:102
mom_file_parser
The MOM6 facility to parse input files for runtime parameters.
Definition: MOM_file_parser.F90:2
mom_error_handler
Routines for error handling and I/O management.
Definition: MOM_error_handler.F90:2
mom_diag_mediator::diag_ctrl
The following data type a list of diagnostic fields an their variants, as well as variables that cont...
Definition: MOM_diag_mediator.F90:239