I want to use XDMF file to store my dolfinx::fem:::function, and use is later, but I couldn’t find any functions similar to read_checkpoint like legacy_DOLFIN in this page DOLFINx XDMF.

Does anyone know what functional will be suitable in my case, I just need to store a single function.
Thanks in advance.

Currently it is only supported in Python through ADIOS4DOLFINx.
There has been several proposals to GSOC 2024 regarding porting it to C++.
We will keep you posted if we get any of them accepted.

I tried your proposed solution with methods snapshot_checkpoint_write and snapshot_checkpoint_read, it works perfectly when importing the fem function.
However, I noticed a problem on the tabulation side of the DOFs, which results, in my case, in uncosistency from the physical point of view in case I want to exploit the imported function for new analysis.
Consider, for example, a classic magnetostatic problem in which you have a DG0 function for the current density J in a coil with very small cross section (cylindrical reference system).
Let J1 be the function before export and J2 the imported one, I get:

I get an assertion error for dofs tabulation and using J2 for a new magnetostatic analysis results in a different magnetic flux map than expected precisely because of the different dofs tabulation.
I would also need to have the same tabulation of dofs between the two functions.

How can I solve this problem? Thank you in advance.

Please provide a minimal reproducible example.
It is unclear to me why you have a new function space J2, as snapshot_checkpoint is meant to be used with the same space it was written with, see the presentation in the previous post