def write_file(self, check=True):
        """
        Write the package file.

        Parameters
        ----------
        check : boolean
            Check package data for common errors. (default True)

        Returns
        -------
        None

        """
        if check:  # allows turning off package checks when writing files at model level
            self.check(f='{}.chk'.format(self.name[0]),
                       verbose=self.parent.verbose, level=1)
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper  # Open file for writing
        f_upw = open(self.fn_path, 'w')
        # Item 0: text
        f_upw.write('{}\n'.format(self.heading))
        # Item 1: IBCFCB, HDRY, NPLPF
        f_upw.write('{0:10d}{1:10.3G}{2:10d}{3:10d}{4:s}\n'.format(self.ipakcb,
                                                                   self.hdry,
                                                                   self.npupw,
                                                                   self.iphdry,
                                                                   self.options))
        # LAYTYP array
        f_upw.write(self.laytyp.string);
        # LAYAVG array
        f_upw.write(self.layavg.string);
        # CHANI array
        f_upw.write(self.chani.string);
        # LAYVKA array
        f_upw.write(self.layvka.string)
        # LAYWET array
        f_upw.write(self.laywet.string);
        # Item 7: WETFCT, IWETIT, IHDWET
        iwetdry = self.laywet.sum()
        if iwetdry > 0:
            raise Exception('LAYWET should be 0 for UPW')
        transient = not self.parent.get_package('DIS').steady.all()
        for k in range(nlay):
            f_upw.write(self.hk[k].get_file_entry())
            if self.chani[k] < 1:
                f_upw.write(self.hani[k].get_file_entry())
            f_upw.write(self.vka[k].get_file_entry())
            if transient == True:
                f_upw.write(self.ss[k].get_file_entry())
                if self.laytyp[k] != 0:
                    f_upw.write(self.sy[k].get_file_entry())
            if self.parent.get_package('DIS').laycbd[k] > 0:
                f_upw.write(self.vkcb[k].get_file_entry())
            if (self.laywet[k] != 0 and self.laytyp[k] != 0):
                f_upw.write(self.laywet[k].get_file_entry())
        f_upw.close()
dataset/ETHPy150Open modflowpy/flopy/flopy/modflow/mfupw.py/ModflowUpw.write_file/original