def fields(fieldfile, only_header=False, only_istep=False):
<EOL>if not fieldfile.is_file():<EOL><INDENT>return None<EOL><DEDENT>header = {}<EOL>with fieldfile.open('<STR_LIT:rb>') as fid:<EOL><INDENT>readbin = partial(_readbin, fid)<EOL>magic = readbin()<EOL>if magic > <NUM_LIT>:  <EOL><INDENT>magic -= <NUM_LIT><EOL>readbin()  <EOL>readbin = partial(readbin, file64=True)<EOL><DEDENT>nval = <NUM_LIT:1><EOL>if magic > <NUM_LIT>:<EOL><INDENT>nval = <NUM_LIT:4><EOL><DEDENT>elif magic > <NUM_LIT>:<EOL><INDENT>nval = <NUM_LIT:3><EOL><DEDENT>magic %= <NUM_LIT:100><EOL>header['<STR_LIT>'] = int(magic >= <NUM_LIT:9> and nval == <NUM_LIT:4>)<EOL>header['<STR_LIT>'] = readbin(nwords=<NUM_LIT:3>)<EOL>header['<STR_LIT>'] = readbin() if magic >= <NUM_LIT:7> else <NUM_LIT:1><EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>', <NUM_LIT:2>)<EOL>header['<STR_LIT>'] = readbin(nwords=<NUM_LIT:3>)  <EOL>header['<STR_LIT>'] = readbin() if magic >= <NUM_LIT:8> else <NUM_LIT:1>  <EOL>if magic >= <NUM_LIT:2>:<EOL><INDENT>header['<STR_LIT>'] = readbin('<STR_LIT:f>', header['<STR_LIT>'][<NUM_LIT:2>] * <NUM_LIT:2> + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>header['<STR_LIT>'] = np.array(range(<NUM_LIT:0>, header['<STR_LIT>'][<NUM_LIT:2>] * <NUM_LIT:2> + <NUM_LIT:1>))* <NUM_LIT:0.5> / header['<STR_LIT>'][<NUM_LIT:2>]<EOL><DEDENT>header['<STR_LIT>'] = np.resize(header['<STR_LIT>'], (header['<STR_LIT>'][<NUM_LIT:2>] + <NUM_LIT:1>, <NUM_LIT:2>))<EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>') if magic >= <NUM_LIT:7> else None<EOL>header['<STR_LIT>'] = readbin() if magic >= <NUM_LIT:3> else <NUM_LIT:0><EOL>if only_istep:<EOL><INDENT>return header['<STR_LIT>']<EOL><DEDENT>header['<STR_LIT>'] = readbin('<STR_LIT:f>') if magic >= <NUM_LIT:3> else <NUM_LIT:0><EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>') if magic >= <NUM_LIT:5> else <NUM_LIT:0><EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>') if magic >= <NUM_LIT:6> else <NUM_LIT:1><EOL>if magic >= <NUM_LIT:4>:<EOL><INDENT>header['<STR_LIT>'] = readbin('<STR_LIT:f>', header['<STR_LIT>'][<NUM_LIT:0>])<EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>', header['<STR_LIT>'][<NUM_LIT:1>])<EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>', header['<STR_LIT>'][<NUM_LIT:2>])<EOL><DEDENT>else:<EOL><INDENT>raise ParsingError(fieldfile,<EOL>'<STR_LIT>')<EOL><DEDENT>if only_header:<EOL><INDENT>return header<EOL><DEDENT>npc = header['<STR_LIT>'] // header['<STR_LIT>']<EOL>nbk = header['<STR_LIT>'] // header['<STR_LIT>']<EOL>npi = (npc[<NUM_LIT:0>] + header['<STR_LIT>']) * (npc[<NUM_LIT:1>] + header['<STR_LIT>']) * npc[<NUM_LIT:2>] *nbk * nval<EOL>header['<STR_LIT>'] = readbin('<STR_LIT:f>') if nval > <NUM_LIT:1> else <NUM_LIT:1><EOL>flds = np.zeros((nval,<EOL>header['<STR_LIT>'][<NUM_LIT:0>] + header['<STR_LIT>'],<EOL>header['<STR_LIT>'][<NUM_LIT:1>] + header['<STR_LIT>'],<EOL>header['<STR_LIT>'][<NUM_LIT:2>],<EOL>header['<STR_LIT>']))<EOL>for icpu in product(range(header['<STR_LIT>']),<EOL>range(header['<STR_LIT>'][<NUM_LIT:2>]),<EOL>range(header['<STR_LIT>'][<NUM_LIT:1>]),<EOL>range(header['<STR_LIT>'][<NUM_LIT:0>])):<EOL><INDENT>data_cpu = readbin('<STR_LIT:f>', npi) * header['<STR_LIT>']<EOL>flds[:,<EOL>icpu[<NUM_LIT:3>] * npc[<NUM_LIT:0>]:(icpu[<NUM_LIT:3>] + <NUM_LIT:1>) * npc[<NUM_LIT:0>] + header['<STR_LIT>'],  <EOL>icpu[<NUM_LIT:2>] * npc[<NUM_LIT:1>]:(icpu[<NUM_LIT:2>] + <NUM_LIT:1>) * npc[<NUM_LIT:1>] + header['<STR_LIT>'],  <EOL>icpu[<NUM_LIT:1>] * npc[<NUM_LIT:2>]:(icpu[<NUM_LIT:1>] + <NUM_LIT:1>) * npc[<NUM_LIT:2>],  <EOL>icpu[<NUM_LIT:0>] * nbk:(icpu[<NUM_LIT:0>] + <NUM_LIT:1>) * nbk  <EOL>] = np.transpose(data_cpu.reshape(<EOL>(nbk, npc[<NUM_LIT:2>], npc[<NUM_LIT:1>] + header['<STR_LIT>'],<EOL>npc[<NUM_LIT:0>] + header['<STR_LIT>'], nval)))<EOL><DEDENT><DEDENT>return header, flds<EOL>
Extract fields data.

    Args:
        fieldfile (:class:`pathlib.Path`): path of the binary field file.
        only_header (bool): when True (and :data:`only_istep` is False), only
            :data:`header` is returned.
        only_istep (bool): when True, only :data:`istep` is returned.

    Returns:
        depends on flags.: :obj:`int`: istep
            If :data:`only_istep` is True, this function returns the time step
            at which the binary file was written.
        :obj:`dict`: header
            Else, if :data:`only_header` is True, this function returns a dict
            containing the header informations of the binary file.
        :class:`numpy.array`: fields
            Else, this function returns the tuple :data:`(header, fields)`.
            :data:`fields` is an array of scalar fields indexed by variable,
            x-direction, y-direction, z-direction, block.