

@staticmethod
def load(f, model, nper=None, ext_unit_dict=None):
    "\n        Load an existing package.\n\n        Parameters\n        ----------\n        f : filename or file handle\n            File to load.\n        model : model object\n            The model object (of type :class:`flopy.modflow.mf.Modflow`) to\n            which this package will be added.\n        nper : int\n            The number of stress periods.  If nper is None, then nper will be\n            obtained from the model object. (default is None).\n        ext_unit_dict : dictionary, optional\n            If the arrays in the file are specified using EXTERNAL,\n            or older style array control records, then `f` should be a file\n            handle.  In this case ext_unit_dict is required, which can be\n            constructed using the function\n            :class:`flopy.utils.mfreadnam.parsenamefile`.\n\n        Returns\n        -------\n        oc : ModflowOc object\n            ModflowOc object.\n\n        Examples\n        --------\n\n        >>> import flopy\n        >>> m = flopy.modflow.Modflow()\n        >>> oc = flopy.modflow.ModflowOc.load('test.oc', m)\n\n        "
    if model.verbose:
        sys.stdout.write('loading oc package file...\n')
    if (nper is None):
        (nrow, ncol, nlay, nper) = model.get_nrow_ncol_nlay_nper()
    ihedfm = 0
    iddnfm = 0
    ihedun = 0
    iddnun = 0
    compact = False
    chedfm = None
    cddnfm = None
    words = []
    wordrec = []
    if (not hasattr(f, 'read')):
        filename = f
        f = open(filename, 'r')
    for line in f:
        lnlst = line.strip().split()
        if (line[0] == '#'):
            continue
        if (lnlst == []):
            continue
        elif (('HEAD' in lnlst[0].upper()) and ('PRINT' in lnlst[1].upper()) and ('FORMAT' in lnlst[2].upper())):
            ihedfm = int(lnlst[3])
        elif (('HEAD' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('FORMAT' in lnlst[2].upper())):
            chedfm = lnlst[3]
        elif (('HEAD' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('UNIT' in lnlst[2].upper())):
            ihedun = int(lnlst[3])
        elif (('DRAWDOWN' in lnlst[0].upper()) and ('PRINT' in lnlst[1].upper()) and ('FORMAT' in lnlst[2].upper())):
            iddnfm = int(lnlst[3])
        elif (('DRAWDOWN' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('FORMAT' in lnlst[2].upper())):
            cddnfm = lnlst[3]
        elif (('DRAWDOWN' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('UNIT' in lnlst[2].upper())):
            iddnun = int(lnlst[3])
        elif (('IBOUND' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('FORMAT' in lnlst[2].upper())):
            cboufm = lnlst[3]
        elif (('IBOUND' in lnlst[0].upper()) and ('SAVE' in lnlst[1].upper()) and ('UNIT' in lnlst[2].upper())):
            ibouun = int(lnlst[3])
        elif ('COMPACT' in lnlst[0].upper()):
            compact = True
        elif ('PERIOD' in lnlst[0].upper()):
            if (len(wordrec) > 3):
                words.append(wordrec)
            iperoc = int(lnlst[1])
            itsoc = int(lnlst[3])
            wordrec = [iperoc, itsoc]
        elif (('PRINT' in lnlst[0].upper()) and ('HEAD' in lnlst[1].upper())):
            wordrec.append('PHEAD')
        elif (('PRINT' in lnlst[0].upper()) and ('DRAWDOWN' in lnlst[1].upper())):
            wordrec.append('PDRAWDOWN')
        elif (('PRINT' in lnlst[0].upper()) and ('BUDGET' in lnlst[1].upper())):
            wordrec.append('PBUDGET')
        elif (('SAVE' in lnlst[0].upper()) and ('HEAD' in lnlst[1].upper())):
            wordrec.append('HEAD')
        elif (('SAVE' in lnlst[0].upper()) and ('DRAWDOWN' in lnlst[1].upper())):
            wordrec.append('DRAWDOWN')
        elif (('SAVE' in lnlst[0].upper()) and ('IBOUND' in lnlst[1].upper())):
            wordrec.append('IBOUND')
        elif (('SAVE' in lnlst[0].upper()) and ('BUDGET' in words[1].upper())):
            wordrec.append('BUDGET')
        else:
            print('Old style oc files not supported for import.')
            print('Convert to words.')
            return ModflowOc88(model)
    if (len(wordrec) > 3):
        words.append(wordrec)
    unitnumber = [14, 51, 52, 53]
    if (ihedun > 0):
        model.add_pop_key_list(ihedun)
    if (iddnun > 0):
        model.add_pop_key_list(iddnun)
    oc = ModflowOc88(model, ihedfm=ihedfm, iddnfm=iddnfm, extension=['oc', 'hds', 'ddn', 'cbc'], unitnumber=unitnumber, words=words, compact=compact, chedfm=chedfm, cddnfm=cddnfm)
    return oc

dataset/ETHPy150Open modflowpy/flopy/flopy/modflow/mfoc88.py ModflowOc88.load/VarMisuse@949/1604 `lnlst`->`words`