MOM_obsolete_diagnostics.F90

1! This file is part of MOM6, the Modular Ocean Model version 6.
2! See the LICENSE file for licensing information.
3! SPDX-License-Identifier: Apache-2.0
4
5!> Provides a mechanism for recording diagnostic variables that are no longer
6!! valid, along with their replacement name if appropriate.
8
10use mom_error_handler, only : mom_error, fatal, warning, is_root_pe
11use mom_file_parser, only : param_file_type, log_version, get_param
12
13implicit none ; private
14
15#include <MOM_memory.h>
16
18
19contains
20
21!> Scan through the diag_table searching for obsolete parameters and issue informational
22!! messages and optionallly a FATAL error.
23subroutine register_obsolete_diagnostics(param_file, diag)
24 type(param_file_type), intent(in) :: param_file !< The parameter file handle.
25 type(diag_ctrl), intent(in) :: diag !< A structure used to control diagnostics.
26! This include declares and sets the variable "version".
27#include "version_variable.h"
28 ! Local variables
29 character(len=40) :: mdl = "MOM_obsolete_diagnostics" !< This module's name.
30 logical :: foundentry, causefatal
31 integer :: errtype
32
33 call log_version(param_file, mdl, version)
34 call get_param(param_file, mdl, "OBSOLETE_DIAGNOSTIC_IS_FATAL", causefatal, &
35 "If an obsolete diagnostic variable appears in the diag_table, "// &
36 "cause a FATAL error rather than issue a WARNING.", default=.true.)
37
38 foundentry = .false.
39 ! Each obsolete entry, with replacement name is available.
40 if (diag_found(diag, 'Net_Heat', 'net_heat_surface or net_heat_coupler')) foundentry = .true.
41 if (diag_found(diag, 'PmE', 'PRCmE')) foundentry = .true.
42 if (diag_found(diag, 'froz_precip', 'fprec')) foundentry = .true.
43 if (diag_found(diag, 'liq_precip', 'lprec')) foundentry = .true.
44 if (diag_found(diag, 'virt_precip', 'vprec')) foundentry = .true.
45 if (diag_found(diag, 'froz_runoff', 'frunoff')) foundentry = .true.
46 if (diag_found(diag, 'liq_runoff', 'lrunoff')) foundentry = .true.
47 if (diag_found(diag, 'calving_heat_content', 'heat_content_frunoff')) foundentry = .true.
48 if (diag_found(diag, 'precip_heat_content', 'heat_content_lprec')) foundentry = .true.
49 if (diag_found(diag, 'evap_heat_content', 'heat_content_massout')) foundentry = .true.
50 if (diag_found(diag, 'runoff_heat_content', 'heat_content_lrunoff')) foundentry = .true.
51 if (diag_found(diag, 'latent_fprec')) foundentry = .true.
52 if (diag_found(diag, 'latent_calve')) foundentry = .true.
53 if (diag_found(diag, 'heat_rest', 'heat_restore')) foundentry = .true.
54 if (diag_found(diag, 'KPP_dTdt', 'KPP_NLT_dTdt')) foundentry = .true.
55 if (diag_found(diag, 'KPP_dSdt', 'KPP_NLT_dSdt')) foundentry = .true.
56
57 if (causefatal) then ; errtype = fatal
58 else ; errtype = warning ; endif
59 if (foundentry .and. is_root_pe()) &
60 call mom_error(errtype, 'MOM_obsolete_diagnostics: Obsolete diagnostics found in diag_table.')
61
63
64!> Determines whether an obsolete parameter appears in the diag_table.
65logical function diag_found(diag, varName, newVarName)
66 type(diag_ctrl), intent(in) :: diag !< A structure used to control diagnostics.
67 character(len=*), intent(in) :: varname !< The obsolete diagnostic name
68 character(len=*), optional, intent(in) :: newvarname !< The valid name of this diagnostic
69
70 diag_found = found_in_diagtable(diag, varname)
71
72 if (diag_found .and. is_root_pe()) then
73 if (present(newvarname)) then
74 call mom_error(warning, 'MOM_obsolete_params: '//'diag_table entry "'// &
75 trim(varname)//'" found. Use ''"'//trim(newvarname)//'" instead.' )
76 else
77 call mom_error(warning, 'MOM_obsolete_params: '//'diag_table entry "'// &
78 trim(varname)//'" is obsolete.' )
79 endif
80 endif
81
82end function diag_found
83