Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes to labelling #569

Merged
merged 5 commits into from
Jul 25, 2024
Merged

Bugfixes to labelling #569

merged 5 commits into from
Jul 25, 2024

Conversation

sjboeing
Copy link
Collaborator

Resets the labels on restarts, and fixes a wrong ifdef.

@sjboeing sjboeing requested a review from matt-frey July 24, 2024 22:05
@matt-frey matt-frey added bug Something isn't working 3D Issues and pull requests related to the 3D version labels Jul 25, 2024
src/3d/parcels/parcel_container.f90 Outdated Show resolved Hide resolved
@@ -666,14 +666,16 @@ subroutine read_chunk(first, last, pfirst)
#ifdef ENABLE_LABELS
if (has_dataset(ncid, 'label')) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can just write `l_valid = (l_valid .and. has_dataset(ncid, 'label')). However, you initialise default values. Therefore, this check is not necessary at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit confusing. We do need the old values to be present for successful tracking, even though we overwrite them immediately after we write to file. One advantage of the current syntax is that it is the same as other variables, which makes it easy to read. I suggest adding a note that "existing" labels are needed for tracking. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I can think of circumstances where we have just labels and/or dilution but thought there might be a future or test case use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "We do need the old values to be present for successful tracking, even though we overwrite them immediately after we write to file."? Here, you read parcel attributes. You do not write them. This is used in restarts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we so in a normal (non-restart) run is reinitialise the labels after writing them to disk. The reinitialisation (in the lines below) is important for backward tracking so that we can uniquely identify the "parent" parcel in the previous time-step (and then go backward by iterating this).

However, this iterative tracking relies on dumping the labels in every parcel file. If you want tracking to behave in the same way in a restart as in an uninterrupted run (at least statistically, because of the use of random numbers in merging which is currently not reproducible though we could work on this), you need to ensure that a "label dump" is present in the restart file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we call parcel_default before entering this routine. You can set the labels and dilution there and then do not read in labels and dilution in the read routine at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, y_vorticity misses the logical check l_valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can remove the l_valid checks for now. We can always put it back when needed. Do you mind if I leave the rest as is and get on to other things?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The rest looks fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It should be ready now.

@sjboeing sjboeing merged commit 8ec2fe7 into main Jul 25, 2024
@matt-frey
Copy link
Member

Do we still need this branch?

@sjboeing sjboeing deleted the label_fixes branch July 25, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3D Issues and pull requests related to the 3D version bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants