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

Bug in atparse script #2199

Closed
zhanglikate opened this issue Mar 19, 2024 · 1 comment · Fixed by #2202
Closed

Bug in atparse script #2199

zhanglikate opened this issue Mar 19, 2024 · 1 comment · Fixed by #2202
Labels
bug Something isn't working

Comments

@zhanglikate
Copy link

What is wrong?

It seems there's a mistake in the atparse script. The issue lies in how the while loop is structured within the atparse function. Specifically, the loop termination condition [[ "$__after" == "$__text" ]] may not always work as expected, leading to premature termination of the loop and missing the last line. So the last line in the file of diag_table_aod is always missing in the finale diag_table, which results in the missing of sea salt AOD in the diagnostic output.

Steps to reproduce

In the run directory, you can see that the last line of diag_table is always missing compared to the diag_table_template

Additional information

"gfs_phys", "DU_AOD_550", "du_aod550", "fv3_history2d", "all", .false., "none", 2
"gfs_phys", "SU_AOD_550", "su_aod550", "fv3_history2d", "all", .false., "none", 2
"gfs_phys", "BC_AOD_550", "bc_aod550", "fv3_history2d", "all", .false., "none", 2
"gfs_phys", "OC_AOD_550", "oc_aod550", "fv3_history2d", "all", .false., "none", 2
"gfs_phys", "SS_AOD_550", "ss_aod550", "fv3_history2d", "all", .false., "none", 2
The last line is always missing in the diag_table

Do you have a proposed solution?
In the atparse script, I've changed the while loop condition to while IFS= read -r __text || [ -n "$__text" ], which ensures that the loop continues until the input is fully consumed, even if the last line doesn't end with a newline character. It works well to solve the issue.

@SamuelTrahanNOAA
Copy link
Collaborator

SamuelTrahanNOAA commented Mar 21, 2024

Your fix would have spawned a subprocess. The atparse.bash is carefully written not to spawn subprocesses. I have a slightly different fix here:

Plus, it has lots of comments and an updated test program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants