nml_enum Function

public function nml_enum(name, tgt, doc, allowed, units, required, dead_on_ocean_path, retired, retired_hint) result(key)

Construct an enum key restricted to allowed, capturing the current target as default.

retired lists spellings that were legal in an earlier release. They are NOT accepted — they fail loud, quoting retired_hint, so a stale namelist is told what the value is called now instead of being handed the generic allowed-set message.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name
character(len=:), intent(in), pointer :: tgt
character(len=*), intent(in) :: doc
character(len=*), intent(in) :: allowed(:)
character(len=*), intent(in), optional :: units
logical, intent(in), optional :: required
character(len=*), intent(in), optional :: dead_on_ocean_path
character(len=*), intent(in), optional :: retired(:)
character(len=*), intent(in), optional :: retired_hint

Return Value type(nml_enum_key_t)


Called by

proc~~nml_enum~~CalledByGraph proc~nml_enum nml_enum proc~register_boundary register_boundary proc~register_boundary->proc~nml_enum proc~register_epbl register_epbl proc~register_epbl->proc~nml_enum proc~register_logging register_logging proc~register_logging->proc~nml_enum proc~register_ocean_bc register_ocean_bc proc~register_ocean_bc->proc~nml_enum proc~register_ocean_bdrag register_ocean_bdrag proc~register_ocean_bdrag->proc~nml_enum proc~register_ocean_bt register_ocean_bt proc~register_ocean_bt->proc~nml_enum proc~register_ocean_cavity_dyn register_ocean_cavity_dyn proc~register_ocean_cavity_dyn->proc~nml_enum proc~register_ocean_cavity_melt register_ocean_cavity_melt proc~register_ocean_cavity_melt->proc~nml_enum proc~register_ocean_coriolis register_ocean_coriolis proc~register_ocean_coriolis->proc~nml_enum proc~register_ocean_dataovr register_ocean_dataovr proc~register_ocean_dataovr->proc~nml_enum proc~register_ocean_diag register_ocean_diag proc~register_ocean_diag->proc~nml_enum proc~register_ocean_eos register_ocean_eos proc~register_ocean_eos->proc~nml_enum proc~register_ocean_grid register_ocean_grid proc~register_ocean_grid->proc~nml_enum proc~register_ocean_hvisc register_ocean_hvisc proc~register_ocean_hvisc->proc~nml_enum proc~register_ocean_ic register_ocean_ic proc~register_ocean_ic->proc~nml_enum proc~register_ocean_ice_ic register_ocean_ice_ic proc~register_ocean_ice_ic->proc~nml_enum proc~register_ocean_pgf register_ocean_pgf proc~register_ocean_pgf->proc~nml_enum proc~register_ocean_sponge register_ocean_sponge proc~register_ocean_sponge->proc~nml_enum proc~register_ocean_tdrag register_ocean_tdrag proc~register_ocean_tdrag->proc~nml_enum proc~register_ocean_thermo register_ocean_thermo proc~register_ocean_thermo->proc~nml_enum proc~register_ocean_topo register_ocean_topo proc~register_ocean_topo->proc~nml_enum proc~register_ocean_vmix register_ocean_vmix proc~register_ocean_vmix->proc~nml_enum proc~register_ocean_zinit register_ocean_zinit proc~register_ocean_zinit->proc~nml_enum proc~register_porous register_porous proc~register_porous->proc~nml_enum proc~register_sim register_sim proc~register_sim->proc~nml_enum proc~register_vcoord register_vcoord proc~register_vcoord->proc~nml_enum proc~build_rdb_schema build_rdb_schema proc~build_rdb_schema->proc~register_boundary proc~build_rdb_schema->proc~register_epbl proc~build_rdb_schema->proc~register_logging proc~build_rdb_schema->proc~register_ocean_bc proc~build_rdb_schema->proc~register_ocean_bdrag proc~build_rdb_schema->proc~register_ocean_bt proc~build_rdb_schema->proc~register_ocean_cavity_dyn proc~build_rdb_schema->proc~register_ocean_cavity_melt proc~build_rdb_schema->proc~register_ocean_coriolis proc~build_rdb_schema->proc~register_ocean_dataovr proc~build_rdb_schema->proc~register_ocean_diag proc~build_rdb_schema->proc~register_ocean_eos proc~build_rdb_schema->proc~register_ocean_grid proc~build_rdb_schema->proc~register_ocean_hvisc proc~build_rdb_schema->proc~register_ocean_ic proc~build_rdb_schema->proc~register_ocean_ice_ic proc~build_rdb_schema->proc~register_ocean_pgf proc~build_rdb_schema->proc~register_ocean_sponge proc~build_rdb_schema->proc~register_ocean_tdrag proc~build_rdb_schema->proc~register_ocean_thermo proc~build_rdb_schema->proc~register_ocean_topo proc~build_rdb_schema->proc~register_ocean_vmix proc~build_rdb_schema->proc~register_ocean_zinit proc~build_rdb_schema->proc~register_porous proc~build_rdb_schema->proc~register_sim proc~build_rdb_schema->proc~register_vcoord proc~read_config_from_string_impl read_config_from_string_impl proc~read_config_from_string_impl->proc~build_rdb_schema proc~read_config_impl read_config_impl proc~read_config_impl->proc~build_rdb_schema proc~read_config read_config proc~read_config->proc~read_config_impl proc~read_config_from_string read_config_from_string proc~read_config_from_string->proc~read_config_from_string_impl proc~build_pending_handle build_pending_handle proc~build_pending_handle->proc~read_config_from_string

Source Code

   function nml_enum(name, tgt, doc, allowed, units, required, dead_on_ocean_path, &
                     retired, retired_hint) result(key)
      !! Construct an enum key restricted to `allowed`, capturing the
      !! current target as default.
      !!
      !! `retired` lists spellings that were legal in an earlier release.
      !! They are NOT accepted — they fail loud, quoting `retired_hint`,
      !! so a stale namelist is told what the value is called now instead
      !! of being handed the generic allowed-set message.
      character(len=*), intent(in) :: name, doc
      character(len=:), pointer, intent(in) :: tgt
      character(len=*), intent(in) :: allowed(:)
      character(len=*), intent(in), optional :: units
      logical, intent(in), optional :: required
      character(len=*), intent(in), optional :: dead_on_ocean_path
      character(len=*), intent(in), optional :: retired(:)
      character(len=*), intent(in), optional :: retired_hint
      type(nml_enum_key_t) :: key

      key%name = name
      key%doc = doc
      key%units = ""
      if (present(units)) key%units = units
      if (present(required)) key%required = required
      key%dead_reason = ""
      if (present(dead_on_ocean_path)) key%dead_reason = dead_on_ocean_path
      key%tgt => tgt
      key%default = tgt
      ! Explicit allocate + element copy on purpose: the auto-allocating
      ! `key%allowed = allowed` makes NVHPC's str_copy write one byte past
      ! the allocation (heap corruption once enough enums register).
      block
         integer :: i
         allocate (character(len=len(allowed)) :: key%allowed(size(allowed)))
         do i = 1, size(allowed)
            key%allowed(i) = allowed(i)
         end do
      end block
      if (present(retired)) then
         block
            integer :: i
            allocate (character(len=len(retired)) :: key%retired(size(retired)))
            do i = 1, size(retired)
               key%retired(i) = retired(i)
            end do
         end block
      end if
      if (present(retired_hint)) key%retired_hint = retired_hint
   end function nml_enum