omuse
omuse copied to clipboard
Fix POP restart from omuse provided data
- POP internally has two versions of the prognostic variables:
old
andcurrent
. Previous implementation only exposed thecurrent
one in getter, and setter functions duplicated the data in bothold
andcurrent
POP arrays. New implementation uses suffixes_old
and_cur
to get/setold
andcurrent
respectively, while a_all
suffix is implemented to keep the previous behavior:
will copy ONLY thechannel.copy_attributes(["xvel_cur"])
current
data between two instances.
will copy ONLY thechannel.copy_attributes(["xvel_old"])
old
data between two instances.
will copy thechannel.copy_attributes(["xvel_all"])
current
data into bothold
andcurrent
between two instances. - when restarting a POP instance from data provided through the Omuse mechanism described above, one need to specify:
to ensure a smooth restart.p.parameters.ts_option = "amuse" p.parameters.pressure_correction = False
@Sbte can you get a look at this ? It should include the changes we discussed at IMAU the other day.
It seems like a lot of code duplication to me. Would it be possible to add an extra oldtime
argument to all Fortran setters and getters, such that they can be implemented in Python as something like
def set_node_barotropic_vel_oldtime(self, i, j, vx, vy):
return self.set_node_barotropic_vel(i, j, vx, vy, True)
def set_node_barotropic_vel_curtime(self, i, j, vx, vy):
return self.set_node_barotropic_vel(i, j, vx, vy, False)
def set_node_barotropic_vel(self, i, j, vx, vy):
return self.set_node_barotropic_vel(i, j, vx, vy, True)
return self.set_node_barotropic_vel(i, j, vx, vy, False)
def get_node_barotropic_vel_oldtime(self, i, j):
return self.get_node_barotropic_vel(i, j, True)
def get_node_barotropic_vel_curtime(self, i, j):
return self.get_node_barotropic_vel(i, j, False)
def get_node_barotropic_vel(self, i, j):
return self.get_node_barotropic_vel(i, j, False)
Not sure if this is possible, but it avoids the code duplication.
Also, please squash the fixes into earlier commits. You can easily do this with git rebase -i
and then use fixup
.
@Sbte I agree, way too much duplication but I can't seem to make a more generic version work within the Amuse interface stuff. I'd rather go with this for now so you can use it, and revisit later when I have a better grasp of how to make that work.
Yeah, that's probably a good idea. I'll test it next week and then merge it if it works.
Note that this way of handling the _all
attributes also duplicates them in the data files, which is not optimal.
Is it necessary that ts_option
can only be set from the INITIALIZED
state? This is not required for reinit_gradp
for instance.
Model time does not seem to be stored anywhere. Is that fixable in a reasonable amount of time? If not I don't think it matters.
Handling of time is cumbersome in POP. If you really need to sync time, the easiest way is to set it to your desired value in the namelist input file.
After commit 21f01c0, all the _all
variables have been removed, reducing code duplication and extra disk space. The current time variable are accessible without extension:
channel.copy_attributes(["xvel"])
Both xvel
and xvel_old
have to be copied to mimic the previous behavior. For ssh
the guess pressure also have to copied (on top of ssh
and ssh_old
):
channel.copy_attributes(["ssh_guess"])
@Sbte Let me know if you think this is ready to merge or if you see something else to update.