-
Notifications
You must be signed in to change notification settings - Fork 35
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
fix missing or mis-matched variable types in nst_water_prop #126
fix missing or mis-matched variable types in nst_water_prop #126
Conversation
* add one,zero and half * fix instances of reals compared to integer and integers used in real expressions
* fix type mis-match in call to int_epn using parameter zero in module_nst_model
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.
The changes are fine to me.
@XuLi-NOAA @Qingfu-Liu I'm still finding issues w/ some of the nst modules. I don't know if either of you can explain. In It is used here as an argument to the function The function is
Does this seem right? It appears as the function |
I've found the reference to gravity forumla 1980. If sinlat is the argument passed in to sfc_nst.f, it seems clear that the grv function should be:
|
physics/module_nst_water_prop.f90
Outdated
@@ -12,6 +12,8 @@ module module_nst_water_prop | |||
public :: rhocoef,density,sw_rad,sw_rad_aw,sw_rad_sum,sw_rad_upper,sw_rad_upper_aw,sw_rad_skin,grv,solar_time_from_julian,compjd, & | |||
sw_ps_9b,sw_ps_9b_aw,get_dtzm_point,get_dtzm_2d | |||
|
|||
integer, parameter :: kp = kind_phys |
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.
I know this probably predates your work, but why use two fields for the same thing and reference both throughout the code?
My suggestion(s) would be to modify the include statement:
- use machine, only : kind_phys
- use machine, only : kp =>kind_phys
and use kp in the code.
OR replace all instances of kp with kind_phys.
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.
Yes, I can definitely do that. I prefer use machine, only : kp =>kind_phys
and then using as you say only kp. Mostly I was following what seemed typical style since I don't work on the ccpp side much.
This surely looks correct to me. |
Denise, Yes, there is a bug here, as reminded by Aron Wang some time ago. The best way to handle it is to modify the code in sfc_nst.f, as follows: add "alat" to the declaration: real(kind=kind_phys) t12,alon,alat,tsea,sstc,dta,dtz and then change grav = grv(sinlat(i)) to be
Denise, You are revivew it really carefully. Can you include the above changes into your PR? Thanks! Xu |
@XuLi-NOAA Thanks for confirming. Yes, it is small error at low latitude, but at 45N, the error is about 0.26 % (9.806 vs 9.7803). I actually propose this fix, which eliminates the need to convert from sinlat->lat in sfc_nst.f
|
Yes, what you proposed means no need to convert sinlat to lat in sfc_nst.f. However, this conversion occurs at multi-places in the code, since only sinlat but not lat is available (not sure why). The code consistency in all the subroutiones needs to be considered as well. |
@XuLi-NOAA The only use of the function
|
True, grv is only used in sfc_nst.f. I meant sinlat and asin(sinlat). |
@dustinswales Most tests fail comparison if I fix the Also, would it be OK if I cleaned up the old "column 6" continuations in the various nst modules for this PR? |
physics/module_nst_parameters.f90
Outdated
,rvrdm1 => con_fvirt & | ||
,rd => con_rd & | ||
,rocp => con_rocp & !< r/cp | ||
use physcons, only: & |
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.
Note to self: this file only has whitespace changes
@@ -33,7 +33,7 @@ | |||
|
|||
!> This module contains some of the most frequently used math and physics |
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.
Note to self: whitespace only
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.
Looks fine to me. The whitespace changes improve the formatting IMO, so it's OK.
@grantfirl Thanks. What do you think about the issue of the column 6 continuations? I'd like to clean that up too, but that is a lot of white-space also. And I still have a fix to make for Dustin. I'm always curious why the values of |
@DeniseWorthen |
Thanks @dustinswales. I think in general for UWM, my preference is to always keep baseline changing PRs as distinct as possible for ease of going back and isolating where something might have been introduced. We wouldn't want to revert the change for the grv function of course, but it does make ensure the type-variable changes do not impact answers. We could always combine this PR w/ any other that does not change baselines. For the precision, I think I'd just like to remove the _kp and use _kind_phys where needed, I think that is the fewest changes. There doesn't seem to be any preferred standard...in fact just grepping turned up this one:
|
I would applaud efforts to remove line 6 continuations in f/F90 files. As for redefining zero and one, this is done throughout physics and could therefore be put in the host-defined physical parameters (or somewhere else?) and passed in everywhere. I don't know if it's worth the effort to clean all of that up or not. If you feel strongly about doing it for just NSST, then go ahead, I suppose. |
@grantfirl Thanks. I'll limit myself to the NST modules for any changes. |
* remove continuation lines in column 6 and rename files as f90 * remove unused variables and make only needed variables, routines or procedures public * move use statements to module level, remove implicit none and use statements in SRs
@grantfirl I've pushed changes which remove the continuation lines, and I've tested it again and it is B4B. But I changed the names from ".f" to ".f90" and git is not showing the files as renamed. Instead, the .f files show deleted and the .f90 files show added. I'm not sure how to have folks review....I could perhaps temporarily commit the new .f90 files as .f files? |
Since the changes are B4B, and it has already been reviewed, I'll just go ahead and review commit f8e1601 using a code difference software on my local machine. It's not a big deal, I don't think. |
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.
@mkavulich @Qingfu-Liu I reviewed changes from commit f8e1601 by checking out the previous commit from @DeniseWorthen 's branch, saving the old sft_nst_*.f files, checking out the latest commit, and then inspecting changes via the Meld software. The changes can be classified as: 1) moving module use
statements to the module level rather than the subroutine level, 2) using zero
, one
, etc defined in module_nst_parameters rather than locally, 3) removing the column 6 line continutation (mostly in the declaration section, but some in the main subroutine body for long math operations or function calls), 4) cleaning up whitespace so that it is much more consistent for if
blocks, loops, etc.
You're welcome to do the same to review the changes, but since it is B4B, it's probably not worth your time to replicate.
@grantfirl ufs-wm PR #1993 has finished with the regression testing. Are you able to merge this PR for us, please? |
by adding
zero
andone
as parameter(kind_phys) variables.Additional cleanup of various nst-related source code:
For #125, initial testing found two non-reproducing baselines with this change. However retesting at 6397387 has shown all UWM baselines are B4B (see ufs-community/ufs-weather-model#1993 for logs)