Silverfrost Forums

Welcome to our forums

Runtime error in 64-bit but not 32

28 Mar 2025 6:47 #32024

I have been getting runtime errors when running a program in 64-bit. The following example has taken me about 40 hours to reduce to something that will hopefully be manageable. I believe that the modules and the program may need to be in separate files, so I am displaying them individually.

Module m1
   Type, Public :: t1_t
      Integer   :: iyr
   End Type t1_t
   Character,  Public :: c
   Type(t1_t), Public :: at1
End Module m1


Module m2
   Implicit None
!
Contains
!
 Subroutine s1 ( )
   Use m1, Only: c, at1
   Character     :: c2
   Logical       :: l
   l = .false.
   Call s2 ( l, at1, c, c2 )
   Return
 End Subroutine s1
!
 Subroutine s2 ( l, at1, c, c2 )
   Use m1, Only: t1_t
   Logical,          Intent(In)    :: l
   Type(t1_t),       Intent(InOut) :: at1
   Character(Len=*), Intent(Out)   :: c, c2
   Integer       :: ifail
   c = 'C'
   Call s21 ( 1, l, ifail, c, c2 )
   ifail = 0
   Return
!
 Contains
!
  Subroutine s21 ( kl, l, ifail, c, c2 )
   Integer,                       Intent(In)    :: kl
   Logical,                       Intent(In)    :: l
   Integer,                       Intent(Out)   :: ifail
   Character(Len=*),              Intent(Out)   :: c, c2
   Character(Len=4) :: ctag
   c2 = ' '
   ctag = 'ABC'
   Call s3 ( ctag//' ', [ 'a' ] )
   c = 'F'
   If ( .not.l ) Then
      Continue
   End If
   Return
  End Subroutine s21
 End Subroutine s2
!
 Subroutine s3 ( c, cs )
   Character(Len=*),               Intent(In) :: c
   Character(Len=*), Dimension(:), Intent(In) :: cs
   Return
!
 Contains
!
  Subroutine s31 ( j )
   Integer, Intent(Out) :: j
   j = 1
   Return
  End Subroutine s31
 End Subroutine s3
End Module m2


Program cpt
   Use m2,       Only: s1
   Call s1 ( )
End Program cpt
28 Mar 2025 8:26 #32025

Simon

This code runs without failure for me and I have used separate files and tried various FTN95 build options (/CHECK etc.).

Which version of FTN95 are you using?

Admittedly there is a lot that could go wrong particularly the use of a CONTAINed subroutine within a module subroutine.

Fortran is not a well-structured language and you can only push it so far.

28 Mar 2025 2:59 #32028

Hi Paul,

Hmm, that's curious. I get a crash with the following settings:

/DEBUG /DEFINT_KIND 3

without /DEBUG. The error message I get using /DEBUG is shown below. The last mentioned line, namely line 38, is:

   If ( .not.l ) Then

I am using version 9.10.2.0, but I get the same error with 9.10.0.0. I do not get the error with 9.00.0.

Silverfrost 64-bit exception report on C:\Users\Simon\Documents\cpt\src\batch_sf64\CPT64_batch.exe Fri Mar 13 18:26:12 1970

Access violation (c0000005) at address 7ffd67401899

Within file VCRUNTIME140.dll In memmove at address 699 In CCOPY$ at address D4 Within file CLEARWIN64.DLL Within file CPT64_batch.exe in M2!S2~S21 in line 38, at address 15f in M2!S2 in line 22, at address b9 in M2!S1 in line 11, at address 59 in CPT in line 3, at address 16

RAX = 0000000000000020 RBX = 0000000000000001 RCX = 0000009663794852 RDX = 0000000000000020 RBP = 00000000004060e8 RSI = 0000009663795751 RDI = 0000000000407000 RSP = 000000000240fc30 R8 = 0000009663795751 R9 = 0000000000406101 R10 = 00007ffd673f0000 R11 = 2020202020202020 R12 = 0000000000000000 R13 = 0000000000000002 R14 = 0000000000406100 R15 = 0000009663795752

7ffd67401899) rep_stos_b [/code]

28 Mar 2025 3:28 #32029

The failure is within ClearWin64.dll so make sure that you are accessing a the DLL that is released with the version of FTN95 that you are using.

30 Mar 2025 6:20 #32033

I have removed all routines that were contained within other routines inside a module, and that seems to have successfully resolved some previous failings. Many thanks for the suggestion.

31 Mar 2025 2:55 #32040

... but why was there a conflict with ClearWin+ when no ClearWin+ routines were being used?

31 Mar 2025 4:16 #32043

ClearWin64.dll contains almost all of the FTN95 library functions in addition to the whole of the ClearWin+ library.

For Win32, everything is in salflibc.dll but for x64, the startup code and exception handling is in saflibc64.dll but almost everything else for Fortran is in ClearWin64.dll.

In that sense the name of the DLL is not very helpful.

31 Mar 2025 4:56 #32045

Ok. That makes sense.

Please login to reply.