def write_transient(self, f, single_per=None, forceInternal=False):
    (nr, nc, nl, nper) = self._model.get_nrow_ncol_nlay_nper()
    assert hasattr(f, 'read'), ('MfList.write() error: ' + 'f argument must be a file handle')
    kpers = list(self.data.keys())
    kpers.sort()
    first = kpers[0]
    if (single_per is None):
        loop_over_kpers = list(range(0, max(nper, (max(kpers) + 1))))
    else:
        if (not isinstance(single_per, list)):
            single_per = [single_per]
        loop_over_kpers = single_per
    for kper in loop_over_kpers:
        if (kper < first):
            itmp = 0
            kper_vtype = int
        elif (kper in kpers):
            kper_data = self.__data[kper]
            kper_vtype = self.__vtype[kper]
            if (kper_vtype == str):
                if (not self._model.array_free_format):
                    kper_data = self.__fromfile(kper_data)
                    kper_vtype = np.recarray
                itmp = self.get_itmp(kper)
            if (kper_vtype == np.recarray):
                itmp = kper_data.shape[0]
            elif ((kper_vtype == int) or (kper_vtype is None)):
                itmp = kper_data
        else:
            itmp = (- 1)
            kper_vtype = int
        f.write(' {0:9d} {1:9d} # stress period {2:d}\n'.format(itmp, 0, (kper + 1)))
        isExternal = False
        if (self._model.array_free_format and (self._model.external_path is not None) and (forceInternal is False)):
            isExternal = True
        if self.__binary:
            isExternal = True
        if isExternal:
            if (kper_vtype == np.recarray):
                py_filepath = ''
                if (self._model.model_ws is not None):
                    py_filepath = self._model.model_ws
                if (self._model.external_path is not None):
                    py_filepath = os.path.join(py_filepath, self._model.external_path)
                filename = self.get_filename(kper)
                py_filepath = os.path.join(py_filepath, filename)
                model_filepath = filename
                if (self._model.external_path is not None):
                    model_filepath = os.path.join(self._model.external_path, filename)
                self.__tofile(py_filepath, kper_data)
                kper_vtype = str
                kper_data = model_filepath
        if (kper_vtype == np.recarray):
            name = f.name
            if (self.__binary or (not numpy114)):
                f.close()
                with open(name, 'ab+') as f:
                    self.__tofile(f, kper_data)
                f = open(name, 'a')
            else:
                self.__tofile(f, kper_data)
        elif (kper_vtype == str):
            f.write(('         open/close ' + kper_data))
            if self.__binary:
                f.write(' (BINARY)')
            f.write('\n')
def write_transient(self, f, single_per=None, forceInternal=False):
    (nr, nc, nl, nper) = self._model.get_nrow_ncol_nlay_nper()
    assert hasattr(f, 'read'), ('MfList.write() error: ' + 'f argument must be a file handle')
    kpers = list(self.data.keys())
    kpers.sort()
    first = kpers[0]
    if (single_per is None):
        loop_over_kpers = list(range(0, max(nper, (max(kpers) + 1))))
    else:
        if (not isinstance(single_per, list)):
            single_per = [single_per]
        loop_over_kpers = single_per
    for kper in loop_over_kpers:
        if (kper < first):
            itmp = 0
            kper_vtype = int
        elif (kper in kpers):
            kper_data = self.__data[kper]
            kper_vtype = self.__vtype[kper]
            if (kper_vtype == str):
                if (not self._model.array_free_format):
                    kper_data = self.__fromfile(kper_data)
                    kper_vtype = np.recarray
                itmp = self.get_itmp(kper)
            if (kper_vtype == np.recarray):
                itmp = kper_data.shape[0]
            elif ((kper_vtype == int) or (kper_vtype is None)):
                itmp = kper_data
        else:
            itmp = (- 1)
            kper_vtype = int
        f.write(' {0:9d} {1:9d} # stress period {2:d}\n'.format(itmp, 0, (kper + 1)))
        isExternal = False
        if (self._model.array_free_format and (self._model.external_path is not None) and (forceInternal is False)):
            isExternal = True
        if self.__binary:
            isExternal = True
        if isExternal:
            if (kper_vtype == np.recarray):
                py_filepath = 
                if (self._model.model_ws is not None):
                    py_filepath = self._model.model_ws
                if (self._model.external_path is not None):
                    py_filepath = os.path.join(py_filepath, self._model.external_path)
                filename = self.get_filename(kper)
                py_filepath = os.path.join(py_filepath, filename)
                model_filepath = filename
                if (self._model.external_path is not None):
                    model_filepath = os.path.join(self._model.external_path, filename)
                self.__tofile(py_filepath, kper_data)
                kper_vtype = str
                kper_data = model_filepath
        if (kper_vtype == np.recarray):
            name = f.name
            if (self.__binary or (not numpy114)):
                f.close()
                with open(name, 'ab+') as f:
                    self.__tofile(f, kper_data)
                f = open(name, 'a')
            else:
                self.__tofile(f, kper_data)
        elif (kper_vtype == str):
            f.write(('         open/close ' + kper_data))
            if self.__binary:
                f.write(' (BINARY)')
            f.write('\n')