def export_matrices(hdf5_file, op2_model):
    """exports the matrices to HDF5"""
    if len(op2_model.matrices):
        matrix_group = hdf5_file.create_group('matrices')
        for key, matrix in sorted(op2_model.matrices.items()):
            matrixi_group = matrix_group.create_group(key.encode('latin-1'))
            if hasattr(matrix, 'export_to_hdf5'):
                matrix.export_to_hdf5(matrixi_group, op2_model.log)
            else:
                msg = 'HDF5: key=%r type=%s cannot be exported' % (key, str
                    (type(matrix)))
                op2_model.log.warning(msg)
                raise NotImplementedError(msg)
