Converting from 32bit to 64 bit application in IVF14

Converting from 32bit to 64 bit application in IVF14

Hi,

I am running into an issue where my 32bit application converted to 64 bit runs into an error related to opening a file dialog box

the lstructsize error is attached in the error.png file and the code for opening the file is given below. The 32 bit application for this exact same code works. Is the error related to the following fileopen dialog box code

Thanks for any help

SUBROUTINE OPEN_INPUT_FILE(CHECKED)

  USE DFLIB
  USE INPUTINFO
  USE DFWINTY
  USE DFWIN
 

  IMPLICIT NONE

  TYPE (T_OPENFILENAME)FRED

  LOGICAL(KIND=4)RET
  INTEGER(KIND=4)IERROR
  !CHARACTER(LEN=26)FILTER(7)
  CHARACTER(LEN=26*7)ALLFILTERS
  CHARACTER(LEN=60)DLGTITLE
  LOGICAL(KIND=4)CHECKED

  CALL UNUSEDQQ(CHECKED)

  ALLFILTERS = ' Input files(*.INP)' // char(0) // &
               '*.INP' // char(0) // &
               'All files(*.*)' // char(0) // &
               '*.*' // char(0) // char(0)
 

  DLGTITLE = 'Choose  INPUT FILE'C

  FRED%LSTRUCTSIZE = (BIT_SIZE(FRED%LSTRUCTSIZE) +        &
                       BIT_SIZE(FRED%HWNDOWNER) +        &
                       BIT_SIZE(FRED%HINSTANCE) +        &
                       BIT_SIZE(FRED%LPSTRFILTER) +        &
                       BIT_SIZE(FRED%LPSTRCUSTOMFILTER) +        &
                       BIT_SIZE(FRED%NMAXCUSTFILTER) +        &
                       BIT_SIZE(FRED%NFILTERINDEX) +        &
                       BIT_SIZE(FRED%LPSTRFILE) +        &
                       BIT_SIZE(FRED%NMAXFILE) +        &
                       BIT_SIZE(FRED%LPSTRFILETITLE) +        &
                       BIT_SIZE(FRED%NMAXFILETITLE) +        &
                       BIT_SIZE(FRED%LPSTRINITIALDIR) +        &
                       BIT_SIZE(FRED%LPSTRTITLE) +        &
                       BIT_SIZE(FRED%FLAGS) +        &
                       BIT_SIZE(FRED%NFILEOFFSET) +        &
                       BIT_SIZE(FRED%NFILEEXTENSION) +        &
                       BIT_SIZE(FRED%LPSTRDEFEXT) +        &
                       BIT_SIZE(FRED%LCUSTDATA) +        &
                       BIT_SIZE(FRED%LPFNHOOK) +        &
                       BIT_SIZE(FRED%LPTEMPLATENAME))/8

  FRED%HWNDOWNER = NULL
  FRED%HINSTANCE = NULL
  FRED%LPSTRFILTER = LOC(ALLFILTERS)
  FRED%LPSTRCUSTOMFILTER = NULL
  FRED%NMAXCUSTFILTER = NULL
  FRED%NFILTERINDEX = 1
  FRED%LPSTRFILE = LOC(ABAQUS_INP) 
  FRED%NMAXFILE = LEN(ABAQUS_INP) 
  FRED%LPSTRFILETITLE = NULL 
  FRED%NMAXFILETITLE = NULL
  FRED%LPSTRINITIALDIR = NULL
  FRED%LPSTRTITLE = LOC(DLGTITLE)
  FRED%FLAGS = NULL 
  FRED%NFILEOFFSET = NULL
  FRED%NFILEEXTENSION = NULL
  FRED%LPSTRDEFEXT = NULL
  FRED%LCUSTDATA = NULL
  FRED%LPFNHOOK = NULL
  FRED%LPTEMPLATENAME = NULL 

  RET = GETOPENFILENAME(FRED)

  CALL COMDLGER(IERROR)

  FILE_INP = .FALSE.
!* CHECK TO SEE IF THE OK BUTTON HAS BEEN PRESSED
  IF(RET .AND. (IERROR == 0))THEN
    if (modify3d_inp.eq. .false.) CALL MODIFY_INPUTFILE_2D
  
    FILE_INP = .TRUE.
  ENDIF

  RETURN
END SUBROUTINE OPEN_INPUT_FILE

AttachmentSize
Download error_1.png23.05 KB
5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

testing

In x64, handles are 64-bit and they are misaligned in your structure, so it will have padding bytes inserting to conform to the ABI. Thus structure size > sum(sizes of individual components) which is therefore invalid.

Change to FRED%LSTRUCTSIZE = SIZEOF(FRED) and you should be able to make progress.

Ditto -- you should use SIZEOF(), much easier.

All handles should be recast as INTEGER(HANDLE) and all pointers as INTEGER(INT_PTR_KIND()).  This will allow your code to work with Win32 and Win64, and the correct sizes for these objects will be adjusted automatically.

And, you may as well get rid of DF* modules, long obsolete, they have been replaced by IF*(same name).

 

Thanks for the help.

It worked

Login to leave a comment.