EDmodel / ED2

Ecosystem Demography Model
78 stars 112 forks source link

SIGFPE Fault: structural_growth.f90 #109

Closed crollinson closed 9 years ago

crollinson commented 9 years ago

Received at end of the first month of run (June) while spinning up from bare ground. Haven't dug into it yet since quite a few things have changed since the spring. Running with GROWTH_RESP_SCHEME = 0 (a new setting from my old runs).

Program received signal 8 (SIGFPE): Floating-point exception.

Backtrace for this error:

crollinson commented 9 years ago

A potential source of the error from uninitialized variables (found in the compiling output): ed_init_full_history.F90:3443: warning: 'sidx' may be used uninitialized in this function

pidx is used similarly defined in lines above, but here's where the error is being thrown: cpoly%disturbance_memory( 1,sidx,isi) = tmp_dist_memory(1,2,isi) cpoly%disturbance_memory( 1,pidx,isi) = tmp_dist_memory(1,3,isi)

anybody know what sidx is? @mpaiao this is in lines of code marked as something brought in when you made a bunch of changes all the way back in November.

another thing that keeps popping up as an error is from this line (ed_state_vars, line 9088, i is uninitialized): allind = (/ (i,i=1,isize) /) I'm not sure what this means, but I'm guessing in this case it's okay. maybe?

I'm not convinced either of these are the source of the error, but I figured uninitialized values are always worth looking into.

mpaiao commented 9 years ago

@crollinson thanks for catching it, this is a bug for sure. The second select case near line 3420 should be one to define sidx instead of a copy/paste of the pidx case... I will think through this and submit a pull request with the fix.

This bug should only cause problems in case someone uses -S- files generated by older versions of ED (before I changed the number of dist_types) and runs the current version in 'HISTORY' mode.

crollinson commented 9 years ago

Based on reverting to previous commits, I've determined this is coming from pull request #95

My guess is that because I'm spinning up from bare ground, the initial ba_in when things are updating at the end of the month is 0.

@DanielNScott I'm going to keep digging to see if there's any easy fix, but if you have any suggestions for where to look or what might be happening, I'd really appreciate it.

crollinson commented 9 years ago

Here's a couple weird updates: 1) If I start on or after June 1, it crashes trying to transition to the next month; starting in May, I made it to the November-December transition 2) I've been running with the hybrid integrator; if I try with RK4 integration, I get the following error immediately:

Program received signal 8 (SIGFPE): Floating-point exception.

Backtrace for this error:

3) Furthermore, if I turn vegetation dynamics OFF (IVEGT_DYNAMICS=0), I still get the same errors with there seeming to be something magical about starting the runs in May that lets it get through the month

mpaiao commented 9 years ago

From previous experience, random crashes like these are likely to be uninitialised variables... Probably a good idea to compile with debugging flags. If you are using ifort, I recommend using "-ftrapuv -fpe0 -no-ftz".

crollinson commented 9 years ago

One more update for the day, this one requires thoughts from the peanut gallery, particularly @mdietze:

Proximate cause of the crash: input dbh of 0 causes a basal area of 0. This happens when bdead = 0, which seems possible for new individuals depending on when the allocation happens (if I recall correctly, it happens once per year, on June 1 for hardwoods)

Potential Solutions: 1) Set minimum DBH or bdead threshold (bdead is used to calculate DBH) -- this makes things go through just fine and seems like a reasonable solution, so it's more a matter of which one to set threshold on.
2) calculate DBH off of bdead PLUS bsapwooda (so total wood biomass rather than just bdead; I'm guessing there's a reason this wasn't done before though) 3) bump the cohort termination step up to at the end of structural growth rather than reproduction (this might also help with some fiss/fuse issues I've seen) 4) make hardwoods follow the scheme of conifers and have a continuous woody biomass allocation; I remember Mike mentioning that this was way more complicated that it seems though, so I'm hesitant to try it)

One last thought: bdead is the basis for a lot of things in fuse_fiss_utils (which looked to do some wonky in some previous spinups I did), so maybe that's the place to look at more?

mdietze commented 9 years ago

That shouldn't happen because the minimum recruit size should ensure that bdead and dbh are >0. This shouldn't require a new threshold, just the enforcement of an existing threshold

crollinson commented 9 years ago

problem solved: see pull request #111

crollinson commented 9 years ago

pull request #111 helped the issue for summer, but still get the same fate for some sites in fall. Also receiving some energetics issues, so it looks like something is still wrong with dbalive_dt:

At line 169 of file ed_therm_lib.f90 Fortran runtime error: Array reference out of bounds for array 'csite', lower bound of dimension 1 exceeded (0 < 1) Backtrace for this error:

DanielNScott commented 9 years ago

Hey @crollinson, I just reviewed this and it looks like it didn't actually have anything to do w/ #95 right?

crollinson commented 9 years ago

@DanielNScott, correct -- the VLEAF thing turned out to be a minor housekeeping error.

The original error came from #88 and the secondary errors that occur later in the season came from my grass scheme not working so well.

DanielNScott commented 9 years ago

@crollinson Cool, thanks for letting me know. I just wanted to check out the crash-producing error I had introduced (if it had existed). Good catch on the write error.