<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_fc3_to_hdf5(fc3, filename='fc3.hdf5', p2s_map=None, compression=None):
 """Write third-order force constants in hdf5 format. Parameters force_constants : ndarray Force constants shape=(n_satom, n_satom, n_satom, 3, 3, 3) or (n_patom, n_satom, n_satom,3,3,3), dtype=double filename : str Filename to be used. p2s_map : ndarray, optional Primitive atom indices in supercell index system shape=(n_patom,), dtype=intc compression : str or int, optional h5py's lossless compression filters (e.g., "gzip", "lzf"). See the detail at docstring of h5py.Group.create_dataset. Default is None. """


    with h5py.File(filename, 'w') as w:
        w.create_dataset('fc3', data=fc3, compression=compression)
        if p2s_map is not None:
            w.create_dataset('p2s_map', data=p2s_map)