Ai33L / gfs_dynamical_core

Only the dynamical core of the climt repository
https://gfs-dynamical-core.readthedocs.io
Other
3 stars 0 forks source link

Saving a model state #18

Open amhayes231 opened 2 weeks ago

amhayes231 commented 2 weeks ago

Hello, simple question here. Is there a way I can save and reload a model state? Specifically looking at the example full_radiation_gcm_energy_balanced, I want to run it for a day, save it, then reinitialize from that day.

Ai33L commented 2 weeks ago

Hi, the easiest way to do this is to save the my_state dictionary to file. Something like pickle would work well.

To reload model state, just load this dictionary into a variable like X from file and do my_state.update(X). Doing this will update my_state with the saved fields.

Do the .update() after you've created my_state using get_default_state().