Skip to content

total heat flux doesn't match sum of 4 components in HR5 ocean grib2 file #103

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

Open
jiandewang opened this issue Mar 26, 2025 · 17 comments
Open
Assignees

Comments

@jiandewang
Copy link

What is wrong?

During the verification of HR5 ocean results, Sulagna and I noticed that the total heat flux (THFLX) doesn't match sum of 4 components in HR5 ocean grib2 file. Heat flux in ocean is defined as positive downward for all SW, LW, latent and sensible heat. The summation of them shouldn't involved any sign change. Attached two plots are from THFLX and the summation of 4 components. We compared the 4 components with the original netcdf file's variables and they all match. So we suspect there is sign issue in the summation.

I have a sample file on HERA: /scratch1/NCEPDEV/climate/Jiande.Wang/working/scratch/HR5-NHF

What should have happened?

they should match

Image

Image

What machines are impacted?

All or N/A

What global-workflow hash are you using?

HR5

Steps to reproduce

run HR5
check ocean grib2 file

Additional information

No response

Do you have a proposed solution?

No response

@aerorahul aerorahul transferred this issue from NOAA-EMC/global-workflow Mar 26, 2025
@aerorahul
Copy link
Contributor

@jiandewang
I suspect this is likely a bug in the fortran code.
We have not yet fully transitioned to the fortran code that writes out grib2 output in the workflow.
Perhaps you can verify this by running a standalone case of this executable and isolating the origin of the bug either in the interpolation, or transfer into grib2.
Many thanks

@JessicaMeixner-NOAA
Copy link
Contributor

FYI @AminIlia-NOAA

@yangfanglin
Copy link
Contributor

Is this only a product issue or also a bug in model forecast ? Is it possible THFLX is computed with time-averaged fluxes while the individual components are instantaneous values ?

@jiandewang
Copy link
Author

I am sure this has nothing to do with the model as we don't output total heat flux in ocean. The total HF in grib2 file must be re-calaulated (summation) in post job.

@jiandewang
Copy link
Author

@aerorahul in current post code or script, it must have something like "THF=SW+LW+LH+SH". There is no need to do any sign changes as the 4 components are all defined in the same direction. I suspect right now it is "SW+LW-LH-LH" or something similiar to it which is not correct.

@DavidHuber-NOAA
Copy link
Contributor

Here is the documentation in regdiag.f:

! 4. sfc_hflux (THFLX) = Total net heat, i.e. !
! dswrfavesfc-uswrfavesfc+dlwrfavesfc-ulwrfavesfc-lhtflsfc-shtflsfc in flx !

And here are the calculations:

LwLatSens is read in from the Ocean product files:

status = nf_inq_varid(ncid, 'LwLatSens',id_sfc_hflux)

status = nf_get_var_real(ncid, id_sfc_hflux, LwLatSens) !sfc_hflux

then total shortwave is added to it
sfcflx=SW+LwLatSens

What does MOM6 sum to calculate LwLatSens?

@aerorahul
Copy link
Contributor

@DavidHuber-NOAA
The workflow no longer uses this code. Instead it uses code from ocnicepost.fd.

@jiandewang
Copy link
Author

Here is the documentation in regdiag.f:

gfs-utils/src/reg2grb2.fd/regdiag.f

Lines 42 to 43 in 58f7901

! 4. sfc_hflux (THFLX) = Total net heat, i.e. !
! dswrfavesfc-uswrfavesfc+dlwrfavesfc-ulwrfavesfc-lhtflsfc-shtflsfc in flx !
And here are the calculations:

LwLatSens is read in from the Ocean product files:

gfs-utils/src/reg2grb2.fd/regdiag.f

Line 92 in 58f7901

status = nf_inq_varid(ncid, 'LwLatSens',id_sfc_hflux)

gfs-utils/src/reg2grb2.fd/regdiag.f

Line 118 in 58f7901

status = nf_get_var_real(ncid, id_sfc_hflux, LwLatSens) !sfc_hflux

then total shortwave is added to it
gfs-utils/src/reg2grb2.fd/regdiag.f

Line 138 in 58f7901

sfcflx=SW+LwLatSens
What does MOM6 sum to calculate LwLatSens?

this code looks correct, but I guess it isn't being used in HR5

@JessicaMeixner-NOAA
Copy link
Contributor

@jiandewang can you look at the experiment output here: /lfs/h2/emc/ptmp/emc.global/RETRO_GFSv17/comroot/retrotestgfs03/gfs.20230418/12/products/ocean/grib2/0p25

and see if things are looking okay there?

@jiandewang
Copy link
Author

@JessicaMeixner-NOAA sure, will take a look when I arrive in office

@jiandewang
Copy link
Author

@JessicaMeixner-NOAA just had a quick check for your file on wcoss2, same issue

@jiandewang
Copy link
Author

@DavidHuber-NOAA The workflow no longer uses this code. Instead it uses code from ocnicepost.fd.

where is the script that convert it to grib2 ? I don't see issue in FORTRAN code. Total HF must be calculated in script as this variable doesn't exist in netcdf file.

@JessicaMeixner-NOAA
Copy link
Contributor

@AminIlia-NOAA Can you point @jiandewang in the right direction?

@aerorahul
Copy link
Contributor

oceanice_nc2grib2.sh is being used presently. The functions in the above script are replicated from here because the functions here will only work for wcoss2, for a specific date and a specific target grid.

@jiandewang
Copy link
Author

I know the reason now:
https://github.com/NOAA-EMC/global-workflow/blob/develop/ush/oceanice_nc2grib2.sh#L131
here it treats LW+LH+SH as total HF which is not correct.

@AminIlia-NOAA
Copy link
Contributor

I can fix this issue in my grib2 writer code. But first I should be the only owner of all ocean ice product related codes both in gfs-utils and workflow.

@AminIlia-NOAA
Copy link
Contributor

I sent a PR for gfs-utils side fix. https://github.com/NOAA-EMC/gfs-utils/pull/105/files

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

6 participants