Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
56 Views

CLOG Crashes - Access Violation

Jump to solution

I am using a piece of code that uses CLOG (Complex Natural Logarithm) and it crashes inside CLOG. The message is

Unhandled exception at 0x77c5df76 in IX1Dv3.exe: 0xC0000005: Access violation writing location 0x00230ff0.

According to the pointer in the disassembly, it is trying to push a variable onto the stack when the error occurs.

The argument is an array element, I tried to circumvent the problem by declaring a complex (*8) variable in the subroutine and setting it equal to the array element in question and this does not help.

I am pretty sure that this code ran under the last version of Compaq Visual Fortran when I was using that (probably before 2010).

I am using Intel(R) Visual Fortran Composer XE 2011 Integration for Microsoft Visual Studio* 2010, 12.0.3470.2010, according to Help/About.

I am looking for suggestions. Any ideas?

Thanks in advance,

Charles

0 Kudos

Accepted Solutions
Highlighted
Black Belt Retired Employee
49 Views

I'm wondering if there is memory corruption somewhere else in the program. I can't imagine what would require CLOG to be storing into a non-stack memory location.

The first thing I would do is stop at the call to CLOG, switch to assembly view, and instruction-step-into. I still am skeptical that the error is actually in the CLOG intrinsic itself.

Another technique I would use is to comment out code after the CLOG call and see if the error still happens. I'd then start selectively commenting out code before it to see if that made any difference (understanding that the results would be wrong, but that's not important at this step.)

If the error persisted I would start disabling other code earlier in the program. This usually helped me identify what was going wrong. In my experience, the cause of errors like this were far removed from where the error became visible.

I wrote a small test that calls CLOG and stepped through it - I did not see any general memory writes.

If you can't solve this on your own, pack up a complete reproducing test case, including all sources, build files, data and instructions for running, and submit a ticket to Intel support.

View solution in original post

0 Kudos
21 Replies
Highlighted
Black Belt
49 Views

Realistically, you need to provide sufficient source code to allow us to reproduce the issue before we can provide meaningful advice.

0 Kudos
Highlighted
49 Views
Code is below. Crash point indicated in bold near the bottom of the code segment.
 
MODULE CSMTModel
  INTEGER NL
  REAL, ALLOCATABLE, DIMENSION (:) :: RHOL,D
END MODULE CSMTModel
      SUBROUTINE BIPOL(TM,TE,HS,HE,F,NR,RR,RMIN,NRMAX,MPOL,EH,
     * EHN,C0,LCANCEL)
C for hed source:
C tm=0,moment (amp-m), hs=0, he=0, frequency (hz), number of offsets,
C array in which to put offsets generated, min offset, dimension of offset
C array (looks like not required), mpol=4 for hed, iwd=0 for no printout,
C array to get fields back, array to get field ratios back, complex
C schmucker ratio, apparent resistivity, phase angle)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C  abkuerzungen:
C    vmd=vertikaler magnetischer dipol
C    hmd=horizontaler magnetischer dipol
C    hed=horizontaler elektrischer dipol
C
C  eingabe:
C  tm: magnetisches dipolmoment (amp*m**2)
C  te: elektrisches dipolmoment (amp*m)
C  hs: hoehe des senders (meter) (hs=0 fuer hed)
C  he: hoehe des empfaengers (meter)
C  nl: anzahl der schichten (nl=1: halbraum)
C  rho: schichtwiderstaende (ohm*meter)  (dimension rho(nl))
C  d: schichtmaechtigkeiten (meter)  (dimension d(nl-1))
C  f: frequenz (hertz)
C  rmin: kleinster abstand sender-empfaenger (in meter)
C  nr: anzahl der r-werte, logarithmisch aequidistant 10 werte pro
C    dekade, anfanswert ist rmin
C  nrmax: maximale zahl der r-werte
C  mpol: optionsparameter fuer art des dipols
C    mpol=1: vmd
C    mpol=2: hmd
C    mpol=3: vmd und hmd
C    mpol=4: hed
C    mpol=5: vmd und hed
C    mpol=6: hmd und hed
C    mpol=7: vmd, hmd und hed
C  iwd: schreibparameter
C    iwd=0: ausschreiben unterbleibt
C    iwd=1: ausschreiben der absoluten felder (array eh)
C    iwd=2: ausschreiben der relativen felder (array ehn)
C    iwd=3: ausschreiben der absoluten und relativen felder
C
C  ausgabe:
C  rr: entfernungen der messpunkte vom sender (meter)
C    (dimension rr(nr))
C  eh: absolute felder (complex eh(13,nr))
C    eh(1,n): hr-vmd (nanotesla)
C    eh(2,n): hz-vmd (nanotesla)
C    eh(3,n): ephi-vmd (millivolt/kilometer)
C    eh(4,n): hr-hmd (nanotesla)
C    eh(5,n): hphi-hmd (nanotesla)
C    eh(6,n): hz-hmd (nanotesla)
C    eh(7,n): er-hmd (millivolt/kilometer)
C    eh(8,n): ephi-hmd (millivolt/kilometer)
C    eh(9,n): hr-hed (nanotesla)
C    eh(10,n): hphi-hed (nanotesla)
C    eh(11,n): hz-hed (nanotesla)
C    eh(12,n): er-hed (millivolt/kilometer)
C    eh(13,n): ephi-hed (millivolt/kilometer)
C    ehn: relative felder (complex ehn(13,nr))
C    ehn(1,n): hr/hz0-vmd
C    ehn(2,n): hz/hz0-1-vmd
C    ehn(3,n): ra(er/hphi) (ohm*meter)   phase(er-hphi) (grad)-vmd
C    ehn(4,n): hr/hr0-1-hmd
C    ehn(5,n): hphi/hphi0-1-hmd
C    ehn(6,n): hz/hr0-hmd
C    ehn(7,n): ra(er/hphi) (ohm*meter)   phase(er-hphi) (grad)-hmd
C    ehn(8,n): ra(ephi/hr) (ohm*meter)   phase(ephi-hr) (grad)-hmd
C    ,n): hr/hr0-hed
C    ehn(10,n): hphi/hphi0-hed
C    ehn(11,n): hz/hz0-hed
C    ehn(12,n): ra(er/hphi) (ohm*meter)   phase(er-hphi) (grad)-hmd
C    ehn(13,n): ra(ephi/hr) (ohm*meter)   phase(ephi-hr) (grad)-hmd
C  rhoa: scheinbarer spez. widerstand nach cagniard (ohm-meter)
C    fuer quasihomogenes feld
C  c0: komplexe eindringtiefe nach schmucker fuer quasihomogenes
C    feld (meter)
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
      USE CSMTModel
C      COMMON /RESIST/NL,RHO(10),D(9)
      COMMON /HANKEL/NC,NCNULL,HR(2,100)
      DIMENSION RR(NRMAX)
      COMPLEX EH(13,NRMAX),EHN(13,NRMAX)
      COMPLEX Q1,Q2,QARG
      COMPLEX DELTA(150),DEL0,DEL1,DEL2,EPSIL(150),EPS0,EPS1
      COMPLEX BT,BP,BTP,C,C0,C1,CC,CE
      COMPLEX KELVINMT,I0,I1,K0,K1
      INTEGER VMD,HMD,HED
LOGICAL LEH9,LEH10
      DATA NAUF/0/
C
      PI=3.141592654
      HED=MPOL/4
      HMD=MPOL/2-2*HED
      VMD=MPOL-4*HED-2*HMD
!      IF (HED.EQ.1) HS=0.
      CC=(0.,8.E-7)*PI**2*F
      ZM=HS-HE
      ZP=HS+HE
      C1=CC/RHOL(1)
C
!      NR=MIN0(NR,NRMAX)
      FAC=0.1*ALOG(10.)
      DO 5 N=1,NR
5     RR(N)=RMIN*EXP((N-1)*FAC)
 
C
      IF (ZP.NE.0..OR.NL.NE.1) GOTO 40
C
C  analytische ergebnisse fuer quelle und aufpunkt auf halbraumgrenze
      DO 20 N=1,NR
      R=RR(N)
      C=R*CSQRT(C1)
      CE=CEXP(-C)
      ARG=0.5*CABS(C)
      I0=KELVINMT(ARG,1)
      K0=KELVINMT(ARG,2)
      I1=KELVINMT(ARG,3)
      K1=KELVINMT(ARG,4)
      IF (VMD.EQ.0) GOTO 10
      EH(1,N)=((16.+C**2)*I1*K1-C**2*I0*K0+8.*C*I1*K0-8.)/R**3
      EH(2,N)=2.*((C**3+4.*C**2+9.*C+9.)*CE-9.)/C**2/R**3
      EH(3,N)=2.*(3.-(C**2+3.*C+3.)*CE)/(C*R)**2
   10 IF (HMD.EQ.0) GOTO 15
      EH(4,N)=2.*(2.+(-12.+(12.+12.*C+5.*C**2+C**3)*CE)/C**2)/R**3
      EH(5,N)=2.*(1.+(-3.+(3.+3.*C+C**2)*CE)/C**2)/R**3
      EH(6,N)=-(C**2*(I1*K1-I0*K0)+4.*C*(I1*K0-I0*K1)+16.*I1*K1)/R**3
      EH(7,N)=-2.*I1*K1/R**2
      EH(8,N)=(C*(I1*K0-I0*K1)+6.*I1*K1)/R**2
   15 IF (HED.EQ.0) GOTO 20
      EH(9,N)=-(C*(I1*K0-I0*K1)+6.*I1*K1)/R**2
      EH(10,N)=2.*I1*K1/R**2
      EH(11,N)=2.*(3.-(3.+3.*C+C**2)*CE)/(C*R)**2
      EH(12,N)=-2.*(1.+(1.+C)*CE)/C**2/R
      EH(13,N)=-2.*(2.-(1.+C)*CE)/C**2/R
LCANCEL=LEQNANQ(EH(9,N)) .OR. LEQNANQ(EH(10,N)) .OR.  EH(9,N).EQ.0.
     A .OR. EH(10,N).EQ.0
IF(LCANCEL)RETURN
LEH9=.NOT.LEQNAN(EH(9,N)) .AND. EH(9,N).NE.0.
LEH10=.NOT.LEQNAN(EH(10,N)) .AND. EH(10,N).NE.0.
   20 CONTINUE
      GOTO 220
C
   40 DO 60 N=1,NR
      R=RR(N)
      RM=SQRT(R**2+ZM**2)
      RP=SQRT(R**2+ZP**2)
      IF (VMD.EQ.0) GOTO 50
      EH(1,N)=3.*ZM*R/RM**5
      EH(2,N)=(3.*ZM**2-RM**2)/RM**5
      EH(3,N)=R/RM**3
   50 IF (HMD.EQ.0) GOTO 55
      EH(4,N)=(3.*R**2-RM**2)/RM**5
      EH(5,N)=1./RM**3
      EH(6,N)=3.*ZM*R/RM**5
      EH(7,N)=-ZM/RM**3+ZP/RP**3-1./RP/(RP+ZP)
      EH(8,N)=-ZM/RM**3+1./RP/(RP+ZP)
   55 IF (HED.EQ.0) GOTO 60
      EH(9,N)=ZP/RP**3-1./RP/(RP+ZP)
      EH(10,N)=1./RP/(RP+ZP)
      EH(11,N)=R/RP**3
      EH(12,N)=1./RP
      EH(13,N)=-1./RP
LCANCEL=LEQNANQ(EH(9,N)) .OR. LEQNANQ(EH(10,N)) .OR.  EH(9,N).EQ.0.
     A .OR. EH(10,N).EQ.0
IF(LCANCEL)RETURN
LEH9=.NOT.LEQNAN(EH(9,N)) .AND. EH(9,N).NE.0.
LEH10=.NOT.LEQNAN(EH(10,N)) .AND. EH(10,N).NE.0.
   60 CONTINUE
C  einlesen der filterkoeffizienten und berechnung von hilfs-
C  funktionen delta und epsil im wellenzahlbereich u
      IF (NAUF.EQ.1) GOTO 65
      CALL FILTER
      NAUF=1
   65 NCNR=NC+NR-1
      DO 110 NU=1,NCNR
      N=NCNULL-NC+NU
      U=EXPC(-(N-1)*FAC)/RMIN
      BT=BTP(U,F,1)
      E=EXPC(-U*ZP)
      DELTA(NU)=(BT-U)/(BT+U)*E
      IF (HED.EQ.0) GOTO 110
      BP=BTP(U,F,2)
      Q1=(BP-U)/C1
      Q2=1./(BT+U)
      EPSIL(NU)=2.*(Q1-Q2)
  110 CONTINUE
C
C  hankel-transformierte von hilfsfunktionen ehn(1,n)...ehn(8,n)
      DO 120 N=1,NR
      DO 120 M=1,8
  120 EHN(M,N)=0.
C
      DO 150 N=1,NR
      DO 140 NN=1,NC
      NU=NN+N-1
      MN=NC-NN+1
      NNN=NCNULL-NC+NU
      U=EXPC(-(NNN-1)*FAC)/RMIN
      DEL0=DELTA(NU)
      DEL1=DEL0*U
      DEL2=DEL1*U
      EHN(3,N)=EHN(3,N)+DEL2*HR(1,MN)
      EHN(5,N)=EHN(5,N)+DEL1*HR(2,MN)
      EHN(6,N)=EHN(6,N)+DEL2*HR(2,MN)
      IF (MPOL.EQ.1) GOTO 140
      EHN(2,N)=EHN(2,N)+DEL1*HR(1,MN)
      EHN(4,N)=EHN(4,N)+DEL0*HR(2,MN)
      IF (HED.EQ.0) GOTO 140
      EPS0=EPSIL(NU)
      EPS1=EPS0*U
      EHN(1,N)=EHN(1,N)+DEL0*HR(1,MN)
      EHN(7,N)=EHN(7,N)+EPS1*HR(1,MN)
      EHN(8,N)=EHN(8,N)+EPS0*HR(2,MN)
  140 CONTINUE
      R=RR(N)
      DO 150 M=1,8
  150 EHN(M,N)=EHN(M,N)/R
C
      DO 160 N=1,NR
      R=RR(N)
      RP=SQRT(R**2+ZP**2)
      EHN(7,N)=EHN(7,N)+2./C1*(3.*ZP**2-RP**2)/RP**5
  160 EHN(8,N)=EHN(8,N)+2.*R/C1/RP**3
C
C  berechnung der absoluten felder eh(1,n)...eh(13,n) (noch ohne
C  normierungsfaktoren!)
      DO 210 N=1,NR
      R=RR(N)
      IF (VMD.EQ.0) GOTO 200
      EH(1,N)=EH(1,N)+EHN(6,N)
      EH(2,N)=EH(2,N)-EHN(3,N)
      EH(3,N)=EH(3,N)-EHN(5,N)
  200 IF (HMD.EQ.0) GOTO 205
      EH(4,N)=EH(4,N)+EHN(5,N)/R-EHN(3,N)
      EH(5,N)=EH(5,N)+EHN(5,N)/R
      EH(6,N)=EH(6,N)-EHN(6,N)
      EH(7,N)=EH(7,N)+EHN(4,N)/R
      EH(8,N)=EH(8,N)-EHN(4,N)/R+EHN(2,N)
  205 IF (HED.EQ.0) GOTO 210
      EH(9,N)=EH(9,N)+EHN(4,N)/R-EHN(2,N)
      EH(10,N)=EH(10,N)-EHN(4,N)/R
      EH(11,N)=EH(11,N)-EHN(5,N)
      EH(12,N)=EH(12,N)+EHN(7,N)-EHN(1,N)-EHN(8,N)/R
      EH(13,N)=EH(13,N)-EHN(8,N)/R+EHN(1,N)
LCANCEL=LEQNANQ(EH(9,N)) .OR. LEQNANQ(EH(10,N)) .OR.  EH(9,N).EQ.0.
     A .OR. EH(10,N).EQ.0
IF(LCANCEL)RETURN
LEH9=.NOT.LEQNAN(EH(9,N)) .AND. EH(9,N).NE.0.
LEH10=.NOT.LEQNAN(EH(10,N)) .AND. EH(10,N).NE.0.
  210 CONTINUE
C
C  relative felder ehn(1,n)...eh(13,n) und absolute felder mit
C  normierungen
  220 DO 240 N=1,NR
      R=RR(N)
      RM=SQRT(ZM**2+R**2)
      IF (VMD.EQ.0) GOTO 230
      HNZ=(3.*ZM**2-RM**2)/RM**5
      EHN(1,N)=EH(1,N)/HNZ
      EHN(2,N)=EH(2,N)/HNZ-1.
      EHN(3,N)=EH(3,N)/EH(1,N)
      RHOA=CABS(CC*EHN(3,N)**2)
      PHI=(180./PI)*AIMAG(CLOG(EHN(3,N)))+90.
      EHN(3,N)=CMPLX(RHOA,PHI)
      EH(1,N)=100.*TM*EH(1,N)
      EH(2,N)=100.*TM*EH(2,N)
      EH(3,N)=-TM*CC/(4.*PI)*EH(3,N)*1.E6
C
  230 IF (HMD.EQ.0) GOTO 235
      HNR=(3.*R**2-RM**2)/RM**5
      HNPHI=1./RM**3
      EHN(4,N)=EH(4,N)/HNR-1.
      EHN(5,N)=EH(5,N)/HNPHI-1.
      EHN(6,N)=EH(6,N)/HNR
      EHN(7,N)=-EH(7,N)/EH(5,N)
      EHN(8,N)=EH(8,N)/EH(4,N)
      RHOA=CABS(CC*EHN(7,N)**2)
      PHI=(180./PI)*AIMAG(CLOG(EHN(7,N)))+90.
      EHN(7,N)=CMPLX(RHOA,PHI)
      RHOA=CABS(CC*EHN(8,N)**2)
      PHI=(180./PI)*AIMAG(CLOG(EHN(8,N)))+90.
      EHN(8,N)=CMPLX(RHOA,PHI)
      EH(4,N)=100.*TM*EH(4,N)
      EH(5,N)=100.*TM*EH(5,N)
      EH(6,N)=100.*TM*EH(6,N)
      EH(7,N)=-TM*CC/(4.*PI)*EH(7,N)*1.E6
      EH(8,N)=-TM*CC/(4.*PI)*EH(8,N)*1.E6
C
  235 IF (HED.EQ.0) GOTO 240
      IF(LEH9)EHN(9,N)=EH(9,N)*R**2
      IF(LEH10)EHN(10,N)=EH(10,N)*R**2
      EHN(11,N)=EH(11,N)*R**2
      IF(LEH10)EHN(12,N)=-EH(12,N)/EH(10,N)
      IF(LEH9)EHN(13,N)=EH(13,N)/EH(9,N)
LCANCEL=LEQNANQ(EH(12,N)) .OR. LEQNANQ(EH(13,N))
IF(LCANCEL)RETURN
      RHOA=CABS(CC*EHN(12,N)**2)
!      PHI=(180./PI)*AIMAG(CLOG(EHN(12,N)))+90.
      QARG=EHN(12,N)
      QARG=CLOG(QARG)    ! Crashes Here QARG is (-45.71577,-11063.66)
      PHI=(180./PI)*AIMAG(QARG)+90.  
      EHN(12,N)=CMPLX(RHOA,PHI)
      RHOA=CABS(CC*EHN(13,N)**2)
      PHI=(180./PI)*AIMAG(CLOG(EHN(13,N)))+90.
      EHN(13,N)=CMPLX(RHOA,PHI)
C..   EH(9,N)=100.*TE*EH(9,N)
C..   EH(10,N)=100.*TE*EH(10,N)
C..   EH(11,N)=100.*TE*EH(11,N)
C..   EH(12,N)=-TE*CC/(4.*PI)*EH(12,N)*1.E6
C..   EH(13,N)=-TE*CC/(4.*PI)*EH(13,N)*1.E6
  240 CONTINUE
!      C0=1./BTP(0.,F,1)
!      RHOA=CABS(CC*C0**2)
!      PHI=(180./PI)*AIMAG(CLOG(C0))+90.
RETURN
END
0 Kudos
Highlighted
Valued Contributor III
49 Views

 the clog function is not given a type or an interface, you do not have implicit none so the return value is a default real not type complex.

This is further compounded by passing the return value as an arg also.  Given the program is non-conforming who can tell what guesses the compiler makes and if those guesses are the same as some other compiler made in the past.

0 Kudos
Highlighted
Valued Contributor II
49 Views

Nope, CLOG is a standard specific name for LOG.

 

0 Kudos
Highlighted
49 Views

CLOG is an intrinsic function and the compiler should know exactly what type and number of arguments and also the return type, so I am not buying that argument. The argument is explicitly typed and this is also the return. Also the original code is commented out, also explicitly typed and that crashed as well.

0 Kudos
Highlighted
Black Belt Retired Employee
49 Views

Given that CLOG is a pure function, and thus doesn't write any storage, I am skeptical that it is actually CLOG that is the issue. You should run the program in the debugger and see where it really goes wrong. The traceback may be misleading.

0 Kudos
Highlighted
49 Views

Steve,

Nice to hear from you. You have responded to my questions before, mostly for CVF if I recall correctly.

I am running in the debugger. All is well until I call CLOG. then it breaks and I have to ask for disassembly to see anything. And that is not helpful to me, even though I have written code in PDP -11 Macro (assembly language) and IBM PC assembly language, but that was many years ago.

I am thinking there is some bug in the CLOG. I cannot right now find another explanation for this. The value going in to CLOG is valid (not zero, according to the spec in the documentation) and the argument is recognized by the debugger. Then the crash and error message, and disassembly is the only option and as I said, it is trying to push a variable onto the stack and there is an access violation.

Is there a work around? Problem occurs with both debug and release versions, with release of course there is minimal information.

Charles

0 Kudos
Highlighted
Black Belt
49 Views

The code provided is incomplete - it cannot be compiled and run to demonstrate the problem.

It is easy to make unintentional errors with the use of fixed form source and implicit typing.  There are other warning signs, - e.g. I think I see several cases of integer variables being used in contexts that require a logical.

I wouldn't be pointing the finger at CLOG yet.

0 Kudos
Highlighted
Black Belt
49 Views

Charles, please attach the source code (in Zip or .tgz compressed format) to your reply, or provide a download link to a file in the Cloud. The code that you provided is in mixed format (neither fixed nor free), and posting it in line has possibly mangled the text further.

0 Kudos
Highlighted
Valued Contributor III
49 Views

Well you learn something every day, CLOG is an intrinsic! :-(

 

0 Kudos
Highlighted
Black Belt Retired Employee
50 Views

I'm wondering if there is memory corruption somewhere else in the program. I can't imagine what would require CLOG to be storing into a non-stack memory location.

The first thing I would do is stop at the call to CLOG, switch to assembly view, and instruction-step-into. I still am skeptical that the error is actually in the CLOG intrinsic itself.

Another technique I would use is to comment out code after the CLOG call and see if the error still happens. I'd then start selectively commenting out code before it to see if that made any difference (understanding that the results would be wrong, but that's not important at this step.)

If the error persisted I would start disabling other code earlier in the program. This usually helped me identify what was going wrong. In my experience, the cause of errors like this were far removed from where the error became visible.

I wrote a small test that calls CLOG and stepped through it - I did not see any general memory writes.

If you can't solve this on your own, pack up a complete reproducing test case, including all sources, build files, data and instructions for running, and submit a ticket to Intel support.

View solution in original post

0 Kudos
Highlighted
49 Views

Steve has the best idea so far. I did not write this code, it was given to me maybe 10 or so years ago and I did get it to work then, probably under CVF before I migrated to IVF since CVF does not run under Win 7. I did do some conversion to Fortran 90, replacing a common block with a module, for example.

I will first examine the code carefully for problems that might cause "memory leaks" and see if I can figure it out that way. If not, I will make a small project with just this code and see if that fixes it. If it does, the problem is somewhere else. This is a huge project but in my tests I am using a small portion of it.

BTW, I hate IMPLICIT NONE, FWIW. I have been writing FORTRAN and Fortran 90 code for nearly 50 years and have developed a style that suits me. For the first 25 years or so, IMPLICIT NONE did not exist in my world. Maybe the VAX had it, but I never worked on a VAX and did only minor work on a MicroVAX while in Cologne.

Thanks for all your comments. I will let you know what happens.

0 Kudos
Highlighted
49 Views

I went through and stepped through the code with a fine tooth comb. Now, it still crashes in debug mode, and one of the allocatable real arrays dimensioned (2) changes to a single unsigned character when CLOG is called. So something is really goofy and I cannot find it to date.

The release version seems to run OK, so I am good for now; this part of the code is rarely used and I probably have one prospective customer who wants it and no more.

I did fix the logical that was implicitly typed as integer (I have never known that to be a problem) and I found one variable that was typed differently in two different modules. One was a fairly complicated derived type (structure) and the second was an allocatable real*4 array. I fixed that by changing the name of the array and a number of other minor things, to no avail. Problems like this tend to arise when grabbing code from different authors...

I would have thought the compiler would have caught that. The clue was that it refused to allocate that "array" although it did not generate an error, which I thought was strange. I did manage to crash Visual Studio in the process of looking for the bug.

The code I posted does violate a number of things that I try to follow religiously, like omitting a decimal point so the compiler needs to recognize that I am not really comparing a real variable to an integer, but I doubt that that sort of thing will cause the crash. So I am still at a loss but it is working for now.

Thanks for all your comments and help.

0 Kudos
Highlighted
Valued Contributor III
49 Views

Stoyer, Charles wrote:
......I would have thought the compiler would have caught that. 
....

 Based the old style code posted and implicit typing etc you must be using the compiler with many possible checks switched off which IMO is like using a circular saw without a guard, it cuts the wood just fine but you lose a finger now and then...... more checks == less bugs

anyway, glad you have made some progress....

0 Kudos
Highlighted
New Contributor II
49 Views

Would it be a dumb question to ask if you've turned on runtime checking?

0 Kudos
Highlighted
49 Views

When I was a professor at Mines, I used to claim that there was no such thing as a dumb  question!

Well, I am compiling  and running in the debug mode, so I assume that is what you mean by turning on runtime checking? Most of the time this works really well, but this is one of those rare instances when the runtime error occurs inside of an intrinsic Fortran 90 function, where there is no source code to show the error and assembly language is the only code that can be displayed. I have written assembly both on the PDP-11 RT-11 systems as well as the PC in the DOS days, but it still does not tell me much to look at an assembly dump of intrinsic function code.

Even stepping through the Fortran code in the debugger shows very little. All I see is that an array is suddenly converted into a character variable!

But thanks for asking!

0 Kudos
Highlighted
Black Belt Retired Employee
49 Views

You have memory corruption going on somewhere, and I'd also guess that the stack is involved. As I wrote earlier, the actual culprit is likely to be well before the CLOG call.

0 Kudos
Highlighted
49 Views

That is for sure. We used to call it a "step on bug" where a call to a subroutine passes something different than the subroutine expects and the subroutine clobbers some data or worse. I haven't had time to successfully find the problem but the release version (without runtime checking) does not crash and I have only one (prospective) customer who need this so I am not really worried about urgently solving it right now.

0 Kudos
Highlighted
New Contributor II
49 Views

Does debug mode turn on runtime checking?  I never use debug mode.  It seems to me that it might be useful to try runtime checking with the release version.

0 Kudos