-
Notifications
You must be signed in to change notification settings - Fork 680
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
Irrigation clean-up: syntax error, derived nml packaging, protect against div by 0 #1149
Conversation
TYPE: bug fix KEYWORDS: irrigation, drip, statement function SOURCE: internal DESCRIPTION OF CHANGES: Problem: In module_irrigation.F, in subroutine sprinkler_irrigation is this line: ``` constants_irrigation=irr_freq*irr_daily_amount/(irr_num_hours*3600*rho(a,kms,b)*dz8w(a,kms,b)*100) ``` It is clear from the rest of the routine, that this is to be treated as a statement function. 1. The line is after the declarations and before the first executable statement. 2. The values of a, b, and kms are not yet defined. 3. The following line _tries_ to use it as a statement function. ``` qr_curr(a,kms,b)=qr_curr(a,kms,b)+irrigation(a,b)*constants_irrigation*dt ``` However, the GNU compiler is segfaulting on the definition of the statement function, because the variables "a" and "b" (among others) are not yet assigned and are likely garbage values. It is segfaulting because it does not recognize this as a proper statement function. Statement functions were declared obsolescent in f95, but we have them in other routines. Solution: Abandon the statement function completely. LIST OF MODIFIED FILES: modified: module_irrigation.F TESTS CONDUCTED: 1. With no mod, with ``` &physics sf_surf_irr_scheme = 3, 3, 3, ``` We get: ``` WRF NUMBER OF TILES = 1 Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: at /wrf/WRF/phys/module_irrigation.f90:140 ``` 2. With the mods, the code runs to completion.
@pedro-jm @weiwangncar @dudhia This needs to be tested QUICKLY. |
@arjanna Can you take a look at this PR? Thanks. If possible, can you check if this affects the results you already have. Thanks. |
@weiwangncar @arjanna |
Jenkins is OK
|
It is correct to move the If you share the branch with me, I can do the changes. Thank you for noticing! |
You should receive an invite. Feel free to pull the davegill:irr=3 down, and then just push right back to it with your commits. Good idea about check_a_mundo, doing the test once. |
Thank you! I will push as soon as I finish the changes |
@arjanna @weiwangncar @dudhia If we have
as opposed to
then we tend to see troubles with nesting, feedback, restarts, etc. We need to have the same variables available to all domains. If it is a problem to have irrigation activated for all domains, we have a couple of options:
We could choose option 2 now for the release. Then you can fix the logic so that in a couple of months when we release v4.2.1, we could put the packaging back in place. |
This I thought was hard to do as the IRRIGATION variable will have different values and might need some special conservative regridding so that the area is conserved. But I am not sure even that would help. For example, irr=3 modifies the a variable in the microhpysics, so the effect is highly non linear.
With the code as it is I used already the restart option, and I never had problems (I checked if there were differences between a restart and one without, and I could see none). If we remove the fields from the restarts I am not sure that the scheme will work properly after the restart. p.s. unfortunately, the commit I did had a problem. I am fixing it now. Sorry! |
@arjanna @weiwangncar @dudhia If we use
there are definitely compilers that have troubles with nested domains for feedback, as there will not be a variable in the coarse grid to hold the information from the fine grid. We hit something similar to this trouble with cumulus schemes years ago, and more recently we had to be careful with the variables packaged for PBL schemes. |
@davegill I suppose this is where we can use a derived namelist to capture if any of the domains is using irrigation, and use it to package variables. |
Wei, |
1. Fix ")" issue, gotta learn to count them 2. allocation of irrigation, now a derived nml option modified: Registry/Registry.EM_COMMON modified: share/module_check_a_mundo.F
@weiwangncar @arjanna @dudhia
(of course, using either option 1 or option 2 works as well for nesting) |
@weiwangncar @dudhia @arjanna |
Wei, |
@davegill I'm ok with this PR. Is there something you need Arianna to look over? |
Arianna, |
@arjanna @weiwangncar @dudhia |
I fixed one last thing, now it gives the same results as my previous tests. Sorry for the delay! |
Arianna, Wei and Jimy, |
@davegill I'm ok with this PR. |
TYPE: bug fix
KEYWORDS: irrigation, drip, statement function
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem 1:
In module_irrigation.F, in subroutine sprinkler_irrigation is this line:
It is clear from the rest of the routine, that this is to be treated as a statement function.
However, the GNU compiler is segfaulting on the definition of the statement function,
because the variables "a" and "b" (again, among others) are not yet assigned and are likely
garbage values. The GNU compiler is segfaulting because it does not recognize this line
as a proper statement function.
Statement functions were declared obsolescent in f95, but we have them in other routines.
Solution 1:
Abandon the statement function completely. The code is actually written to not need a statement
function.
Problem 2:
The user defined integer
irr_num_hours
can be zero, resulting in a divide by zero.Solution 2:
In check_a_mundo, verify that the number of hours to irrigate is >= 0. This handles all three irrigation
options in a single location.
Problem 3:
The irrigation schemes are designed to mostly be activated on the inner-most domain. As with many
physics schemes, ON vs OFF causes troubles for nested domains when packaging of variables is
involved.
Solution 3:
A derived namelist option is utilized. If any domain has an irrigation option activated, then all domains
have the packaged fields allocated.
LIST OF MODIFIED FILES:
modified: module_irrigation.F
modified: Registry/Registry.EM_COMMON
modified: share/module_check_a_mundo.F
TESTS CONDUCTED:
We get the WRF output as: