# autogenerated file, do not modify

from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFChildPackages, MFPackage


class ModflowNam(MFPackage):
    """
    ModflowNam defines a NAM package.

    Parameters
    ----------
    simulation
        Simulation that this package is a part of. Package is automatically
        added to simulation when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    continue_ : keyword
        keyword flag to indicate that the simulation should continue even if one or
        more solutions do not converge.
    nocheck : keyword
        keyword flag to indicate that the model input check routines should not be
        called prior to each time step. checks are performed by default.
    memory_print_option : string
        is a flag that controls printing of detailed memory manager usage to the end of
        the simulation list file.  none means do not print detailed information.
        summary means print only the total memory for each simulation component. all
        means print information for each variable stored in the memory manager. none is
        default if memory_print_option is not specified.
    profile_option : string
        is a flag that controls performance profiling and reporting.  none disables
        profiling. summary means to measure and print a coarse performance profile.
        detail means collect and print information with the highest resolution
        available. none is default if profile_option is not specified.
    maxerrors : integer
        maximum number of errors that will be stored and printed.
    print_input : keyword
        keyword to activate printing of simulation input summaries to the simulation
        list file (mfsim.lst). with this keyword, input summaries will be written for
        those packages that support newer input data model routines.  not all packages
        are supported yet by the newer input data model routines.
    hpc_data : record hpc6 filein hpc6_filename
        Contains data for the hpc package. Data can be passed as a dictionary to the
        hpc package with variable names as keys and package data as values. Data for
        the hpc_data variable is also acceptable. See hpc package documentation for
        more information.
    tdis6 : string
        is the name of the temporal discretization (tdis) input file.
    models : [(mtype, mfname, mname)]
        is the list of model types, model name files, and model names.
        * mtype : string
                is the type of model to add to simulation.
        * mfname : string
                is the file name of the model name file.
        * mname : string
                is the user-assigned name of the model.  The model name cannot exceed 16
                characters and must not have blanks within the name.  The model name is case
                insensitive; any lowercase letters are converted and stored as upper case
                letters.

    exchanges : [(exgtype, exgfile, exgmnamea, exgmnameb)]
        is the list of exchange types, exchange files, and model names.
        * exgtype : string
                is the exchange type.
        * exgfile : string
                is the input file for the exchange.
        * exgmnamea : string
                is the name of the first model that is part of this exchange.
        * exgmnameb : string
                is the name of the second model that is part of this exchange.

    mxiter : integer
        is the maximum number of outer iterations for this solution group.  the default
        value is 1.  if there is only one solution in the solution group, then mxiter
        must be 1.
    solutiongroup : [(slntype, slnfname, slnmnames)]
        is the list of solution types and models in the solution.
        * slntype : string
                is the type of solution.  The Integrated Model Solution (IMS6) and Explicit
                Model Solution (EMS6) are the only supported options in this version.
        * slnfname : string
                name of file containing solution input.
        * slnmnames : [string]
                is the array of model names to add to this solution.  The number of model names
                is determined by the number of model names the user provides on this line.


    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    hpc_filerecord = ListTemplateGenerator(("nam", "options", "hpc_filerecord"))
    models = ListTemplateGenerator(("nam", "models", "models"))
    exchanges = ListTemplateGenerator(("nam", "exchanges", "exchanges"))
    solutiongroup = ListTemplateGenerator(("nam", "solutiongroup", "solutiongroup"))
    package_abbr = "nam"
    _package_type = "nam"
    dfn_file_name = "sim-nam.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name continue",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name nocheck",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name memory_print_option",
            "type string",
            "reader urword",
            "optional true",
            "mf6internal prmem",
        ],
        [
            "block options",
            "name profile_option",
            "type string",
            "reader urword",
            "optional true",
            "mf6internal prprof",
        ],
        [
            "block options",
            "name maxerrors",
            "type integer",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name hpc_filerecord",
            "type record hpc6 filein hpc6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package hpc",
            "construct_data hpc_data",
            "parameter_name hpc_data",
        ],
        [
            "block options",
            "name hpc6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
            "extended true",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name hpc6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged false",
            "extended true",
        ],
        [
            "block timing",
            "name tdis6",
            "preserve_case true",
            "type string",
            "reader urword",
            "optional",
        ],
        [
            "block models",
            "name models",
            "type recarray mtype mfname mname",
            "reader urword",
            "optional",
        ],
        [
            "block models",
            "name mtype",
            "in_record true",
            "type string",
            "tagged false",
            "reader urword",
        ],
        [
            "block models",
            "name mfname",
            "in_record true",
            "type string",
            "preserve_case true",
            "tagged false",
            "reader urword",
        ],
        [
            "block models",
            "name mname",
            "in_record true",
            "type string",
            "tagged false",
            "reader urword",
        ],
        [
            "block exchanges",
            "name exchanges",
            "type recarray exgtype exgfile exgmnamea exgmnameb",
            "reader urword",
            "optional",
        ],
        [
            "block exchanges",
            "name exgtype",
            "in_record true",
            "type string",
            "tagged false",
            "reader urword",
        ],
        [
            "block exchanges",
            "name exgfile",
            "in_record true",
            "type string",
            "preserve_case true",
            "tagged false",
            "reader urword",
        ],
        [
            "block exchanges",
            "name exgmnamea",
            "in_record true",
            "type string",
            "tagged false",
            "reader urword",
        ],
        [
            "block exchanges",
            "name exgmnameb",
            "in_record true",
            "type string",
            "tagged false",
            "reader urword",
        ],
        [
            "block solutiongroup",
            "name group_num",
            "type integer",
            "block_variable true",
            "in_record true",
            "tagged false",
            "shape",
            "reader urword",
        ],
        [
            "block solutiongroup",
            "name mxiter",
            "type integer",
            "reader urword",
            "optional true",
        ],
        [
            "block solutiongroup",
            "name solutiongroup",
            "type recarray slntype slnfname slnmnames",
            "reader urword",
        ],
        [
            "block solutiongroup",
            "name slntype",
            "type string",
            "valid ims6 ems6",
            "in_record true",
            "tagged false",
            "reader urword",
        ],
        [
            "block solutiongroup",
            "name slnfname",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
        ],
        [
            "block solutiongroup",
            "name slnmnames",
            "type string",
            "in_record true",
            "shape (any1d)",
            "tagged false",
            "reader urword",
        ],
    ]

    def __init__(
        self,
        simulation,
        loading_package=False,
        continue_=None,
        nocheck=None,
        memory_print_option=None,
        profile_option=None,
        maxerrors=None,
        print_input=None,
        hpc_data=None,
        tdis6=None,
        models=None,
        exchanges=None,
        mxiter=None,
        solutiongroup=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowNam."""
        super().__init__(
            parent=simulation,
            package_type="nam",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.continue_ = self.build_mfdata("continue", continue_)
        self.nocheck = self.build_mfdata("nocheck", nocheck)
        self.memory_print_option = self.build_mfdata(
            "memory_print_option", memory_print_option
        )
        self.profile_option = self.build_mfdata("profile_option", profile_option)
        self.maxerrors = self.build_mfdata("maxerrors", maxerrors)
        self.print_input = self.build_mfdata("print_input", print_input)
        self._hpc_filerecord = self.build_mfdata("hpc_filerecord", None)
        self.tdis6 = self.build_mfdata("tdis6", tdis6)
        self.models = self.build_mfdata("models", models)
        self.exchanges = self.build_mfdata("exchanges", exchanges)
        self.mxiter = self.build_mfdata("mxiter", mxiter)
        self.solutiongroup = self.build_mfdata("solutiongroup", solutiongroup)

        self._init_complete = True
