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

Potential code bug: Diagnostics of shortwave radiation and its four components are shifted by half a grid cell #358

Open
dhruvbhagtani opened this issue Dec 2, 2021 · 5 comments

Comments

@dhruvbhagtani
Copy link
Contributor

Hi @russfiedler @aidanheerdegen
We need to run a MOM-solo ocean model. We are trying to decompose the shortwave radiation into four components - (i) visible direct, (ii) visible diffuse, (iii) near-infrared direct, and (iv) near-infrared diffuse. These are needed as inputs to MOM-solo. However, we are suspecting that there is a bug in either ACCESS-OM2 or MOM-solo source code. The diagnostics of these four fluxes are shifted by half a grid cell, and that is causing our model to crash. Here is a simple Jupyter notebook explaining our problem: https://github.com/dhruvbhagtani/varying-surface-forcing/blob/main/Flux_forced_expts/MOM5_swflx_bug.ipynb.

Ccing my supervisors here to keep them in the loop - @AndyHoggANU @navidcy @rmholmes

@russfiedler
Copy link
Collaborator

russfiedler commented Dec 6, 2021

I can't see any immediate problems with the code.
We need to be able to see the input and output files and not just pictures can you place examples of each under /scratch/public/db6174/? Also, how are you reading these in? What does your diag_table look like?

@dhruvbhagtani
Copy link
Contributor Author

Hi Russ

We figured out the issue - it was a mistake on our end. But, we haven't figured why our previous code doesn't work, and maybe your answer to this question will help us: Why is the shortwave flux calculated separately from longwave, sensible and latent heat fluxes? In the end, we are (theoretically) doing the same thing - the indices isc:ied and jsc:jed are modified on the LHS. I ask this because when I compute shortwave flux components (sw_flux_vis_dir, sw_flux_vis_dif, sw_flux_nir_dir and sw_flux_nir_dif) in the way sensible, latent and longwave fluxes are computed, I get an incorrect result for the four fluxes, but when I compute them in a way sw_flux is computed, everything is fine. I am concerned if there is an underlying issue in there. The code snippet I am referring to is here: https://github.com/dhruvbhagtani/MOM5/blob/master/src/mom5/ocean_core/ocean_sbc.F90#L4239-L4290

@russfiedler
Copy link
Collaborator

Shortwave need not come in as a surface flux. You can specify it as a 3D heating and apply it in the appropriate shortwave module so it needs the ability to be treated differently in ocean_sbc.F90. Also, the indices used are iec and jec not ied and jed. Make sure that bounds checking/array shape compatibility is applied in whatever code you are using to compute your fluxes. Make sure that you're using the correct index offset.

I think this issue can be closed as it appears that the problem lies elsewhere and not with MOM.

@navidcy
Copy link

navidcy commented Dec 7, 2021

@russfiedler thanks. Let's close the issue for now.

@dhruvbhagtani
Copy link
Contributor Author

dhruvbhagtani commented Dec 7, 2021

Thanks a lot Russ. I wasn't very careful with the indices! Before we close the issue, when you say that "Shortwave need not come in as a surface flux. You can specify it as a 3D heating and apply it in the appropriate shortwave module so it needs the ability to be treated differently in ocean_sbc.F90 - the code doesn't do anything different. In other words, it doesn't have the provision for taking a 3D flux anyways. To me, both the code snippets are identical - they take an input within an array bound, which is exactly the same. The only difference is that in one case, we use loops, in the other, we don't. Please correct me if I am wrong here. In other words, I don't find any difference whatsoever between the following two
codes

This is exactly how the other three (sensible, latent and longwave) fluxes are computed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants