Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
48 Views

Access violation reading location 0xFFFFFFFFFFFFFFFF.

Jump to solution

The debug statement says nothing is wrong. This is Debug x64 mode in MSVS 2013. Here is the code

Module Horn

  ! Table of random numbers from fitted Pearson Distribution
  ! pseudo random number seed whoich can be changed by user

  Integer(4),parameter::   Rand = 20000
  Integer(4),Save,Public:: sType
  Real(8),Save,Public::    sAvg, sCm2, sCm3, sCm4, sKapa, sBeta1, sBeta2, &
                                       sMin, sMax, sKSVal, sKSStat80, sKSStat90, sKSStat95, &
                                       sKSStat99
  Real(8),Save,Public::    Draw(0:Rand+1)
  Real(8),Save,Public::    rArray(0:Rand+1)

End Module Horn

Subroutine GetRS (myNumRS)
Use Van
Use Horn
Use Howe
Use PearsonGlobals
Use Random
USE, INTRINSIC :: IEEE_EXCEPTIONS

Implicit None

Integer(4), intent(inout) :: myNumRS         <======== this has a value of 5000

Real(8),Save:: w, h, rdm, xx
Real(8),Save:: Diff, box
Integer(4),Save:: L, jk, lp, mm, Limit, iStrt, ErrNo, Last, i
Logical(4),Save:: logic

!   This routine will generate 'myNumRS' pseudo-random variates from
!   one of the Pearson Curve types (pType) which were used to create
!   the CDF and xVals arrays which are used to calculate the pseudo-
!   random variables.

     If ((pType <= 0) .or. (pType >= 9)) Then                    <============= pType = 8
        gMyErrors = 5
        myNumRS = 0
        return
     End If
     raw1 = 0.d0
     raw2 = 0.d0
     raw3 = 0.d0
     raw4 = 0.d0
     iStrt = gTotalRS + 1
     Limit = min(Rand, myNumRS)
     box = 1.d0 / Dble(Limit)
     Diff = Upper - Lower                             <=============== Diff is about 12
     h = Diff / Dble(Nr)
     xx = Dble(MaxIndex)                            <=============== MaxIndex = 1000 and is whare CDF(*) has values
!    draw 'Limit' pseudo-random variables from the Pearson Type Curve
     Do jk = iStrt, Limit
       logic = (1 == 1)
       L = 0
       rdm = RanF(1)                                 <=============  0.0 < rdm < 1.0
       if ((rdm <= 1.d-75) .or. (rdm >= 1.d0)) Then
          gMyErrors = -jk
          return
       End If
       mm = max(1,min(NINT(xx), NINT(xx * rdm)))
       Do lp = Index(mm-1), index(mm+1)
         If ((Cdf(lp) > rdm) .and. logic) Then
           logic = (1 == 3)
           L = lp
           Exit
         End if
       End Do

       ! rdm lies between Cdf(L) and Cdf(L-1)
       w = ((rdm - Cdf(L-1))/(Cdf(L) - Cdf(L-1)))
       If ((w < 0.d0) .or. (w > 1.d0)) Then
          gMyErrors = L
          Return
       End If
       Draw(jk) = w * h + xVal(L-1)
       w = (Draw(jk) - Lower) / Diff
       If ((w < 0.d0) .or. (w > 1.d0)) Then
          gMyErrors = L
          Return
       End If
     End Do
     sMin = 1.d+75
     sMax = - sMin
     do jk = 1, Limit
       rdm = Draw(jk)
       sMin = min(sMin, rdm)
       sMax = max(sMax, rdm)
       raw1 = raw1 + rdm
       raw2 = raw2 + rdm**2
       raw3 = raw3 + rdm**3
       raw4 = raw4 + rdm**4
     end do
     w = Dble(Limit)
     raw1 = raw1 / w
     raw2 = raw2 / w
     raw3 = raw3 / w
     raw4 = raw4 / w
     Call Moments(sAvg, sCm2, sCm3, sCm4, raw1, raw2, raw3, raw4)  <======== converts moments about zero to central moments
     Call GetPT(sAvg, sCm2, sCM3, sCm4, sType, sKapa, ErrNo)
     sBeta1 = scm3*scm3/scm2**3
     sBeta2 = scm4/scm2**2
     gTotalRS = Limit
     do i = 1, Limit
        rArray(i) = Draw(i)
     end do
     Call Shell (Limit, rArray)                       <============ this should order the random sample

...

Subroutine Shell (n,bArray)

Implicit None

Integer(4),Intent(in):: n
Real(8),Intent(inout):: bArray(:)

   Integer(4)::  k, j, ir, i, m
   Real(8)::     tmp

! Shell Sort adapted from the Numerical Recipies in Fortran

   if (n < 2) Return
   m  =  n
   k = 1
   do while(k <= m)
      k = 3 * k + 1
   end do
   do while (k > 1)
      k = k / 3
      do i = k + 1, n
         tmp = bArray(i)                 <======= but error is here with  i = 3281 and n = 5000  <<<< 1st time at this statement
          j = i
          do while(bArray(j-k) > tmp)
             bArray(j) = bArray(j-k)
             j = j - k
             if(j <= k) EXIT
          end do
          bArray(j) = tmp
       end do
    end do
    return

end subroutine Shell

I've tested Shell on some small datasets and no problems.

 

0 Kudos

Accepted Solutions
Highlighted
48 Views

Data corruption would be my

Jump to solution

Data corruption would be my guess. Since you didn't provide a complete program I can't try it myself, but I would suggest building with all run-time checking options on (/check:all) and also /warn:interface. I'd also recommend running under Intel Inspector XE and asking it to do memory use error checking.

Retired 12/31/2016

View solution in original post

0 Kudos
6 Replies
Highlighted
49 Views

Data corruption would be my

Jump to solution

Data corruption would be my guess. Since you didn't provide a complete program I can't try it myself, but I would suggest building with all run-time checking options on (/check:all) and also /warn:interface. I'd also recommend running under Intel Inspector XE and asking it to do memory use error checking.

Retired 12/31/2016

View solution in original post

0 Kudos
Highlighted
48 Views

Your subroutine Shell is

Jump to solution

Your subroutine Shell is using an Assumed-Shape array for bArray(:)

If this subroutine is .NOT. in a module, then you are required to have an interface to the subroutine.

An assumed shape dummy argument is passed an array descriptor

If Shell is called from code that does not know its interface, the argument passed is a reference to the first cell of the array passed (IOW not the reference to an array descriptor)

Jim Dempsey

0 Kudos
Highlighted
New Contributor I
48 Views

Steve,

How do I invoke Intel Inspector XE in MSVS 2013?

Brooks

 

0 Kudos
Highlighted
New Contributor I
48 Views

Steve, you were right. I had

Jump to solution

Steve, you were right. I had a design flaw in the calling program before I went into Shell.

Thanks all,

Brooks

0 Kudos
Highlighted
48 Views

Inspector XE is included in

Jump to solution

Inspector XE is included in "Professional Edition" and "Cluster Edition" of Intel Parallel Studio XE.

Retired 12/31/2016
0 Kudos
Highlighted
New Contributor I
48 Views

Costs too much for me.

Jump to solution

Costs too much for me.

0 Kudos