-
Notifications
You must be signed in to change notification settings - Fork 313
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
Calculations of local noon assume that longitude is 0 to 360 rather than -180 to 180 #491
Comments
I have a fix for this, that I'm testing. There are still fields that have large changes though. There's also a local time calculation needed for irrigation, that is concerning. So I turned off irrigation for the following test, and still see changes.
|
Discussed this with @swensosc he is going to look into this more, and get back to me. I'm thinking at this point there's likely multiple issues. The behavior he say of the NLDAS grid clearly showed that cime/datm was mishandling Solar. So there might still be issues in cime/datm as well as others in ctsm. My fix will be going in #449. |
OK, looking into this more. Note that COSZEN is only roundoff different between the two cases. COSZEN should be what's driving the distinction between night and day. I'm not seeing the connection that makes this screwed up. But, it does affect a large set of variables and hence makes simulations unusable, for a grid that includes the America's. So I think I should open a new issue that talks about the science issue, as the original issue here was just the local noon calculations, and for that I've got a fix to come in. |
Irrigation changes answers with changing to a function call and with the change from modulo to mod, for certain values. So I'll do a step that's bit for bit and an answer changing one. |
@ekluzek I spent some time this evening looking into your new local time calculation (assuming the SSREsnowmip branch on ESCOMP is up-to-date). The problem is that the get_local_time = secs + nint((lon/degpsec)/real(dtime,r8))*dtime Consider, for example, secs = 60, longitude = 1 degree. Then lon/degpsec = 240, and we should be adding 240 seconds to get the local time. But the division by dtime before taking nint results in: nint(240/1800) = 0, so there ends up being no longitude-based correction to get local time. I'm not sure who originally introduced this division by dtime, but it seems that it shouldn't be there. I see that you introduced a unit test to try to compare the 'irrig' version of local time with the 'standard' version, for a wide range of longitudes and times. Unfortunately, you made a small error in the logic that made this a no-op: You start with secs = 0, which makes do while ( .not. is_end_curr_year() )
@assertEqual( get_local_irrig_time( londeg ), get_local_time( londeg ) )
call advance_timestep()
end do If you change this to start at secs = 1800 rather than 0, you'll see that that unit test flags the two functions as differing significantly. When I changed --- a/src/utils/clm_time_manager.F90
+++ b/src/utils/clm_time_manager.F90
@@ -1509,7 +1509,7 @@ integer function get_local_time( londeg, offset )
call get_curr_date(yr, mon, day, secs, offset )
lon = londeg
if ( lon < 0.0_r8 ) lon = lon + 360.0_r8
- get_local_time = secs + nint((lon/degpsec)/real(dtime,r8))*dtime
+ get_local_time = secs + nint(lon/degpsec)
get_local_time = mod(get_local_time,isecspday)
end function get_local_time the fixed unit test now says the two functions are equivalent. Actually, I only ran with longitude every 1 deg, not every 0.1 deg, because even that took 9 secs on my Mac, and I didn't have the patience to wait 90 sec :-). |
Brief summary of bug
SurfaceRadiationMod.F90, PhotosynthesisMod.F90 and UrbanFluxesMod.F90 all calculate the time for local noon, the way it's coded assumes that the grid has longitude from 0 to 360 and NOT -180 to 180.
General bug information
CTSM version you are using: ctsm1.0.dev009
but goes back to ctsm1.0.dev004
Does this bug cause significantly incorrect results in the model's science? No
Because our standard grids are all on 0 to 360 and NOT -180 to 180.
Configurations affected: Any with grids on -180 to 180
Details of bug
Here's a snippet...
Important details of your setup / configuration so we can reproduce the bug
Also see the cime issue: ESMCI/cime#2778
Here's a note from @swensosc about files that can be used...
"It requires a domain file (and surface data file) with negative longitudes. I've created some here:
/glade/scratch/swensosc/sfcdata/surfdata_0.9x1.25_78pfts_CMIP6_simyr1850_c170824.negative.longitude.nc
/glade/scratch/swensosc/sfcdata/domain.lnd.fv0.9x1.25_gx1v6.090309.negative.longitude.nc
An out of the box f09_g16 clm I case run for 1 month would show the affect."
Important output or errors that show the problem
It doesn't flag an error, it just silently does the wrong thing.
@olyson @barlage
The text was updated successfully, but these errors were encountered: