portedportable, not yet portedexecuted, not portableexecutable, not hit by this run
| 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. | |
| 7 | module MOM_obsolete_diagnostics | |
| 8 | ||
| 9 | use MOM_diag_mediator, only : diag_ctrl, found_in_diagtable | |
| 10 | use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe | |
| 11 | use MOM_file_parser, only : param_file_type, log_version, get_param | |
| 12 | ||
| 13 | implicit none ; private | |
| 14 | ||
| 15 | #include <MOM_memory.h> | |
| 16 | ||
| 17 | public register_obsolete_diagnostics | |
| 18 | ||
| 19 | contains | |
| 20 | ||
| 21 | !> Scan through the diag_table searching for obsolete parameters and issue informational | |
| 22 | !! messages and optionallly a FATAL error. | |
| 23 | 1 | subroutine 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 | 1 | 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 | 1 | "cause a FATAL error rather than issue a WARNING.", default=.true.) |
| 37 | ||
| 38 | 1 | foundEntry = .false. |
| 39 | ! Each obsolete entry, with replacement name is available. | |
| 40 | 1 | if (diag_found(diag, 'Net_Heat', 'net_heat_surface or net_heat_coupler')) foundEntry = .true. |
| 41 | 1 | if (diag_found(diag, 'PmE', 'PRCmE')) foundEntry = .true. |
| 42 | 1 | if (diag_found(diag, 'froz_precip', 'fprec')) foundEntry = .true. |
| 43 | 1 | if (diag_found(diag, 'liq_precip', 'lprec')) foundEntry = .true. |
| 44 | 1 | if (diag_found(diag, 'virt_precip', 'vprec')) foundEntry = .true. |
| 45 | 1 | if (diag_found(diag, 'froz_runoff', 'frunoff')) foundEntry = .true. |
| 46 | 1 | if (diag_found(diag, 'liq_runoff', 'lrunoff')) foundEntry = .true. |
| 47 | 1 | if (diag_found(diag, 'calving_heat_content', 'heat_content_frunoff')) foundEntry = .true. |
| 48 | 1 | if (diag_found(diag, 'precip_heat_content', 'heat_content_lprec')) foundEntry = .true. |
| 49 | 1 | if (diag_found(diag, 'evap_heat_content', 'heat_content_massout')) foundEntry = .true. |
| 50 | 1 | if (diag_found(diag, 'runoff_heat_content', 'heat_content_lrunoff')) foundEntry = .true. |
| 51 | 1 | if (diag_found(diag, 'latent_fprec')) foundEntry = .true. |
| 52 | 1 | if (diag_found(diag, 'latent_calve')) foundEntry = .true. |
| 53 | 1 | if (diag_found(diag, 'heat_rest', 'heat_restore')) foundEntry = .true. |
| 54 | 1 | if (diag_found(diag, 'KPP_dTdt', 'KPP_NLT_dTdt')) foundEntry = .true. |
| 55 | 1 | if (diag_found(diag, 'KPP_dSdt', 'KPP_NLT_dSdt')) foundEntry = .true. |
| 56 | ||
| 57 | 1 | if (causeFatal) then ; errType = FATAL |
| 58 | 0 | else ; errType = WARNING ; endif |
| 59 | 1 | if (foundEntry .and. is_root_pe()) & |
| 60 | 0 | call MOM_error(errType, 'MOM_obsolete_diagnostics: Obsolete diagnostics found in diag_table.') |
| 61 | ||
| 62 | 1 | end subroutine register_obsolete_diagnostics |
| 63 | ||
| 64 | !> Determines whether an obsolete parameter appears in the diag_table. | |
| 65 | 16 | logical 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 | 32 | diag_found = found_in_diagtable(diag, varName) |
| 71 | ||
| 72 | 16 | if (diag_found .and. is_root_pe()) then |
| 73 | 0 | if (present(newVarName)) then |
| 74 | call MOM_error(WARNING, 'MOM_obsolete_params: '//'diag_table entry "'// & | |
| 75 | 0 | trim(varName)//'" found. Use ''"'//trim(newVarName)//'" instead.' ) |
| 76 | else | |
| 77 | call MOM_error(WARNING, 'MOM_obsolete_params: '//'diag_table entry "'// & | |
| 78 | 0 | trim(varName)//'" is obsolete.' ) |
| 79 | endif | |
| 80 | endif | |
| 81 | ||
| 82 | 32 | end function diag_found |
| 83 | ||
| 84 | 0 | end module MOM_obsolete_diagnostics |