Silverfrost Forums

Welcome to our forums

Checkmate, .NET, C#, old FTN77 code and long strings

29 Aug 2008 1:44 #3764

We are converting a FTN77 program to .NET in Visual Studio 2008. I am getting a memory overwrite somewhere in the code, so I am trying to use CheckMate instead of Debug as my complier configuration to see if I can find where it is happening. However, now that I have turned on the CheckMate option, I'm getting an exception '405: Reference to undefine character (/FULL_UNDEF)' when I run the program.

We are reading a file in C#, parsing the input into an object, and passing the object to our Fortran code.

      FUNCTION ITEMCALC(TranInObj)
      IMPLICIT NONE
      OBJECT('McGill.FtnLibrary.TranInData') TranInObj
      OBJECT('McGill.FtnLibrary.TranBackData') TranBackObj
      OBJECT('McGill.FtnLibrary.TranBackData') ITEMCALC
      CHARACTER SI*200
      INTEGER*2 I
      REAL*4 MYVALUE

      DO I=1,200
        SI(I:I) = ' '
      ENDDO
      SI = TranObj%SI

C--  Do calculations
      CALL CALCVALUES(SI, MYVALUE)

C--  Return values
      TranBackObj = new@ ('McGill.FtnLibrary.TranBackData')
      TranBackObj%Value = MYVALUE

      ITEMCALC = TranBackObj
      RETURN
      END

C----------------------------------------------------------------------
      SUBROUTINE CALCVALUES(SI, MYVALUE)
      IMPLICIT NONE
      CHARACTER SI*200
      REAL*4 MYVALUE
C--   Local Variables
      CHARACTER TMPSI*200

C--   This is the line where I get the exception
      TMPSI = SI

      VALUE = 0.0
      RETURN
      END

If I put a break point after the do loop in ITEMCALC and look at SI, the watch value shows 200 spaces and then some odd characters and no trailing single quote. This is the value in the watch:

'                                                                                                                                                                                                       藈ग़ૐॢÕ뱏睐

Those characters change after the assignment.

'NOTE VAL=10 INST X                                                                                                                                                                                     �ीૐॢ᱕뱏睐

Shorter character arrays show up fine. I have some that are 4 characters long, and some that are 50 characters long. All of those show up correctly in the watch window.

I get the exception in the CALCVALUES subroutine, where TMPSI=SI. I have replaced the assignment with this do loop:

      DO I=1,200
        TMPSI(I:I)=SI(I:I)
      ENDDO

and I get the exception when I=200.

Is this exception due to the odd characters after the 200th character in the string? It looks like the code is not finding the end of the array, or something of that sort.

Thanks, Jill

29 Aug 2008 6:35 #3765

Jill,

What you are doing is way outside my expertise, but as you have IMPLICIT NONE, don't you have to declare TranObj somewhere - you have TranInObj and TranBackObj, but no TranObj.

Eddie

1 Sep 2008 3:43 #3767

The code that you posted does not compile. Otherwise I might be able to test it for you.

Please login to reply.