Re: Bug or newbie error???

Hi Jeff,
Happy Holidays to you and yours.

The program does have exponentiation in it, but when I compiled using "-O1" option, the problem went away.  Then I took that option off and recompiled and it works just fine.  Who knows????

Have you had a chance to look at the problem displaying structure elements in debug?  I'm at a standstill until that's resolved.

Don

Re: Bug or newbie error???

Don,

I have started looking into it, and there does appear to be some issues under certain circumstances. Have you tried Simply Fortran 2.18?  There were some case sensitivity issues that could cause certain variables, including structure elements, to not appear.  Additionally, could you post the the definition of your derived type?  There does seem to be issues with derived types that are "deep," or contain additional derived types.  Still trying to resolve those.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

Here is the module establishing the some of the structures.

    !
! Module Hydro_Set establishes arrays and variables for the input/output hydrographs
!
Module A_Hydro_Mod
!
Implicit None
!
Type Hydro_In
    Real(8), Allocatable :: HydTime(:)        ! Variable time for hydrograph
    Real(8), Allocatable :: Hyd(:)            ! Inflow Hydrograph
    Real(8)              :: DeltaT            ! Time increment of hydrograph
    Real(8)              :: StartTime         ! Starting time of first non-zero hydrograph value
    Real(8)              :: PeakQ             ! Peak of the inflow hydrograph
    Real(8)              :: TimeQ             ! Time of peak, inflow hydrograph
    Real(8)              :: Duration          ! Duration of flow, inflow hydrograph
    Real(8)              :: StorVol           ! Storage volume, ac. ft. of outflow hydrograph
    Integer(4)           :: nHydPts           ! Number of points in the inflow hydrograph
    Integer(4)           :: nPeak             ! Hydrograph pointer to peak
    Character(10)        :: HydID             ! Hydrograph Identifier
End Type Hydro_In
Type (Hydro_In) :: Hin
    !
Type Hydro_Out
    Real(8), Allocatable :: Hyd(:)            ! Outflow Hydrograph
    Real(8), Allocatable :: Elev(:)           ! Outflow elevations at discharges
    Real(8), Allocatable :: HydCtl(:)         ! Hydraulic Control computed in QBreach
    Real(8)              :: DeltaT            ! Time increment of hydrograph
    Real(8)              :: StartTime         ! Starting time of first non-zero hydrograph value
    Real(8)              :: PeakQ             ! Peak of the outflow hydrograph
    Real(8)              :: TimeQ             ! Time of peak, outflow hydrograph
    Real(8)              :: Duration          ! Duration of flow, outflow hydrograph
    Real(8)              :: StorVol           ! Storage volume, ac. ft. of outflow hydrograph
    Integer(4)           :: nHydPts           ! Number of points in the outflow hydrograph
    Integer(4)           :: nPeak             ! Hydrograph pointer to peak
    Character(10)        :: HydID             ! Hydrograph Identifier
End Type Hydro_Out
Type (Hydro_Out)         :: Hout
!
Integer(4)               :: Incr              ! Increment for hydrograph records
Integer(4)               :: LastPoint         ! Pointer to last inflow hyd. value greater than baseflow
Integer(4)               :: LowHyd            ! Low column number on Hyd Record
Integer(4)               :: HiHyd             ! High column number of Hyd Record
Integer(4)               :: nPkIn             ! Index to Max. inflow value
Integer(4), Parameter    :: LimitIn = 10000   ! Maximum number of inflow hydrograph points.
Integer(4), Parameter    :: LimitOut = 50000  ! Maximum number of outflow hydrograph points.
!
Real(8), Parameter       :: BFTolrance=0.0005 ! Tolerance factor for base flow
Real(8)                  :: PctPeak           ! Percent of peak used to control output
                                              !   (default value is 0.001)
Real(8)                  :: Cutoff            ! Hydrograph cutoff value in cfs.
Real(8)                  :: ElevIn            ! Elevation of peak inflow
Real(8)                  :: VolOut            ! Volume at peak outflow
Real(8)                  :: VolIn             ! Volume at peak outflow
Real(8)                  :: QpeakIn           ! Peak of inflow hydrograph
Real(8)                  :: QpeakOut          ! Peak outflow
Real(8)                  :: TimeIn            ! Time of inflow peak
Real(8)                  :: TimeOut           ! Time of outflow peak
Real(8)                  :: BFVolume          ! Storage volume at base flow or QRF
Real(8)                  :: BaseFlow          ! Reservoir base flow (value of first given inflow)
Real(8)                  :: BFElev            ! Elevation at base flow or QRF
Real(8)                  :: QRF               ! Quick Return Flow (Last point of hydrograph)
Real(8)                  :: RefElev           ! User-given elevation for Drawdown
Real(8)                  :: RefPct            ! Percentage of flow to stop Drawdown
Real(8)                  :: RefTime           ! User-given Drawdown time (default = 240 hrs)
!
Logical(1)               :: NoHyd             ! If true, no hydrograph entered
!
End Module A_Hydro_Mod


I reference the structure element as "Hin%nHydPts" or "Hout%nHydPts".

Re: Bug or newbie error???

BTW -- forgot to say I'm using 2.18 build 1781.

Re: Bug or newbie error???

Hi Jeff,
More information for you.  It seems the *indeterminate* displays whenever I highlight an allocated array element.  Non-allocated arrays display the selected element just fine.
Don

Re: Bug or newbie error???

Don,

That explains the issue you're seeing.  The debugger currently does not support examining the contents of allocated elements.  We're using the GNU Debugger within Simply Fortran, and it does not yet support Fortran allocated arrays.  I would expect support to be present in a few more months.  Patches have been submitted, but not accepted yet.

This lack of support has been a long outstanding issue.  I understand the frustration of users, and we're working to possibly incorporate patches into our distribution of the GNU Debugger.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

Thanks, Jeff.
Looks like I'll be creating a bunch of dummy variables to be able to view results.  If anyone else is having this problem, tell them to turn off optimization, otherwise the dummies get optimized out.
Don

Re: Bug or newbie error???

If you would like to add the patches and release it as a beta version, I would be happy to provide some testing time.
Don

Re: Bug or newbie error???

Don,

I'm currently testing a version of the debugger that does support viewing allocated array elements.  I'm only concerned about stability at this point as the entire code base of the debugger that supports this is a development version (as opposed to the "stable" releases we ship).  It wouldn't help if the debugger just randomly crashed constantly.  I will keep everyone updated, though.  This missing feature is frustrating to all our users.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

Thanks, Jeff.  Patience it is.....

Re: Bug or newbie error???

Now if we had the little window into the debugger, we could inspect such arrays using gdb's print command.

p x(1)
p x(10)  ... etc

Do you know if this is just a limitation in the current version for arrays only with the allocatable attribute or does it apply to deferred arrays generally (e.g. with the pointer attribute)?

--
David

Re: Bug or newbie error???

If you're using an exponential function, you might want to consider an alternative algorithm like the one below:

    ! ------------------------------------------------------------------
    Function FXP(x)
    !--- Fxponential function
    !--- Fast Exponential FXP() - F.W. Perrella, Ph.D. (2014)

        IMPLICIT NONE

        REAL(dp), INTENT(IN) :: x
        REAL(dp) :: x0,x1,x2,x3,x4,FXP
        REAL(dp), PARAMETER :: xa = 0.5, xb = 65535., xc = 256., xd = 1.

        x1 = (xb + x)/xb
        x2 = x1**xc
        x3 = x2**xc
        x4 = xd + (xa*x*x/xb)*(xd + (xa*x + xa*xa*x*x - x)/xb)
        FXP = x3*x4
    End Function FXP
    ! ------------------------------------------------------------------

Although it's not quite as accurate as the intrinsic function EXP(), FXP() is stable and may be accurate enough for your application.

Frank

Re: Bug or newbie error???

davidb wrote:

Now if we had the little window into the debugger, we could inspect such arrays using gdb's print command.

p x(1)
p x(10)  ... etc

Actually, if the array is allocatable, the above will not work in current versions of the GNU Debugger.  Simply Fortran is effectively doing the above (but not exactly, of course), and it will not work.  The GNU Debugger does not currently understand allocatable arrays in Fortran.

davidb wrote:

Do you know if this is just a limitation in the current version for arrays only with the allocatable attribute or does it apply to deferred arrays generally (e.g. with the pointer attribute)?

I believe the shortcoming extends to pointers that are allocated.  If they point at a statically declared target, they should work.

All of this trouble should be gone this week, though, when 2.19 is released.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

drfrank wrote:

If you're using an exponential function, you might want to consider an alternative algorithm like the one below:

The exponential in the runtime library tends to be problematic for some reason.  I'll have to look into it far deeper.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

Hi all,

I checked the program and it does use EXP.  So I added Dr. Frank's FXP.  I get the same results with either function.  So, EXP doesn't seem to be causing any problem.  But thanks to all for you suggestions.

Don

Re: Bug or newbie error???

One other question.  In Compaq fortran there is an end-of-file function, i.e. EOF(unit) where "unit" is  the device designation.  I can't find an equivalent in gfortran.  Is there one?

Don

Re: Bug or newbie error???

Don,

I'm not aware of such a function in GNU Fortran.  The standards-compliant method is to check the value of IOSTAT after each read.  There is a helper function as of Fortran 2003 called IS_IOSTAT_END that should make things easier.  Have a look at https://gcc.gnu.org/onlinedocs/gfortran … 5fEND.html to see a short example.

Jeff Armstrong
Approximatrix, LLC

Re: Bug or newbie error???

Thanks, Jeff - I'll follow up on it.
Don