MOM5
MOM5 copied to clipboard
Potential code bug: Diagnostics of shortwave radiation and its four components are shifted by half a grid cell
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
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?
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
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.
@russfiedler thanks. Let's close the issue for now.
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.