-
Notifications
You must be signed in to change notification settings - Fork 59
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
Streaming filter #675
Streaming filter #675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is a step toward an interesting new capability for on-line detection of periodic signals. I definitely appreciate the direction that this is going, but I think that there are number of issues that should be addressed before this can be added to the MOM6 code base.
-
Whenever we add new diagnostic capabilities, we always make sure that they do not have an adverse impact on simulations where they are not used. Usually this is done by adding a logical flag to avoid the extra calculations related to the diagnostic when they are not being used. Please add a run-time logical flag (perhaps using a diagnostic id) to determine whether
Filt_accum()
is called frombtstep()
. -
The 4 pointers
um2
,uk1
,vm2
, andvk1
are temporary local variables inbtstep()
, but I do not see where they are actually being used, either in subsequent model calculations or in any diagnostics. What is their purpose? Should this PR be revised so that these fields are optionally output somewhere? -
Inside of
Filt_accum()
, the code is working on the entire array size, including the halo regions. However, we do not generally guarantee that there are valid values throughout the halo regions, and there could be NaNs, which could be problematic. Elsewhere in the MOM6 code, we only work on the computational domain plus a specified (via an argument) halo size, and the same should perhaps be done here. This would require more extensive integration of this code with the MOM6 infrastructure (e.g., in the use of the contents of ahor_index_type
argument) and it might require different versions ofFilt_accum()
for various horizontal locations (e.g., tracer points vs. u-points vs. v-points), but I think that it would be safer. -
Rather than having a
streaming_filter_CS
that consists of a linked list of theFilt_node
types for each of the filtered variables, have you considered having the calling routine set up (via a call to a revisedfilt_register
) and store a separateFilt_node
type for each of the fields that it is working on? I don't see how that approach would lose any generality, and it would simplify a lot of the complexity of this code that tries to figure out which node to work on with each call toFilt_accum()
. There may be something that I am missing with this suggestion, but if so that might be useful to layout in the conversation surrounding this PR.
I may raise other issues after these first 4 have been addressed, but for now these seem to me like the most prominent issues raised by this very promising pull request.
84bc0ad
to
caae653
Compare
Thanks for the comments. Please see below for my point-by-point reply.
Run-time flags have been added for the M2 and K1 filters separately.
My intention is to use them for implementing the frequency-dependent internal wave drag, but this involves some major modification of the way that the linear wave drag is implemented in the
I thought it would be okay for
I'm not very familiar of how this works. Is there an example that I can follow?
Actually, one reason that I use
Yes, you're right. I simplified the code by removing the master control structure, and now each filter has its own control structure.
|
The filtering is a point-wise operation. It does not involve any spatial differentiation or integration. Results at a grid point will not be affected by the results of its neighbouring points in any way, if this was your concern when you raised the issue of halo regions, @Hallberg-NOAA. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev/gfdl #675 +/- ##
============================================
+ Coverage 36.99% 37.01% +0.02%
============================================
Files 272 274 +2
Lines 82403 82591 +188
Branches 15413 15450 +37
============================================
+ Hits 30487 30575 +88
- Misses 46226 46295 +69
- Partials 5690 5721 +31 ☔ View full report in Codecov by Sentry. |
Thank you for these revisions, which mostly address the concerns I raised with the review of the previous version. I do see from the code that this is a point-wise filter, and so what happens at one point will not impact others. The one concern is that if there are NaNs (from uninitialized values) in the halo regions, doing any calculations with them can lead to an exception that will cause the model to abort (depending on compiler settings), even if they don't actually impact any subsequent values. This is most common when the model is compiled for debugging, but having the model come down due to a fake problem can be very annoying when trying to debug a real problem. If we knew that the fields that are being filtered are always being initialized (e.g, to 0), this would not be an issue, but there is no way to guarantee that this will always be true. Examples where we use a |
Hi @Hallberg-NOAA, I followed what's been done in |
4d25356
to
d1104af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With these changes, this is all looking good to me. Thank you for this contribution, @c2xu, and your patience as we sorted out the details of this PR.
In the MOM_streaming_filter module, a system of two coupled ODEs is configured as a streaming band-pass filter that takes the broadband model output as the input and returns the filtered signal at a user specified tidal frequency as the output. It is capable of detecting the instantaneous tidal signals while the model is running, and can be used to impose frequency-dependent wave drag or to de-tide model output. An example of filtering the M2 and K1 barotropic velocities is provided in the MOM_barotropic module.
Fixed dimensional inconsistency of the om2 and ok1 parameters.
Added runtime flags for the M2 and K1 filters. Simplified the code by removing the control structure of the linked list, and now each filter has its own control structure.
Minor fix on documentation
Filter equations reformulated.
Using hor_index_type argument to avoid calculation in halo regions.
Bug fix.
Minor update on the M2 and K1 frequencies.
Using non-static-memory allocation for s1 and u1.
d1104af
to
cda34b1
Compare
Gaea regression: https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/jobs/137854 ✔️ 🟡 Squash-merging these 9 commits. |
In the MOM_streaming_filter module, a system of two coupled ODEs is configured as a streaming band-pass filter that takes the broadband model output as the input and returns the filtered signal at a user specified tidal frequency as the output. It is capable of detecting the instantaneous tidal signals while the model is running, and can be used to impose frequency-dependent wave drag or to de-tide model output. An example of filtering the M2 and K1 barotropic velocities is provided in the MOM_barotropic module.