Silverfrost Forums

Welcome to our forums

Creating a dll trouble

11 Dec 2006 5:50 #1421

I am having trouble creating a dll to call from EES (engineering equation solver). In the past, I have created in MS VFortran and Compaq VF the following:

The trouble is - what do I use change the !MS$attributes alias and dllexport to generate the same dll.

Any help is greatly appriciated! Chris

SUBROUTINE MDASF(S,MODE,NINPUTS,INPUTS,NOUTPUTS,OUTPUTS)

  1. The following two lines are specific to Microsoft Visual Fortran !MS$ATTRIBUTES ALIAS:'MDASF' :: MDASF !MS$ATTRIBUTES DLLEXPORT :: MDASF INTEGER(4) MODE, NINPUTS, NOUTPUTS REAL(8) INPUTS(50), OUTPUTS(50) CHARACTER(255) S

  2. IF (MODE.EQ.-1) GOTO 900
    IF (NINPUTS.NE.2) GOTO 100
    IF (NOUTPUTS.NE.4) GOTO 200
    
  3. DO CALCULATIONS X=INPUTS(1)

    Y=INPUTS(2) IF (ABS(Y).LE.1E-9) GOTO 300 OUTPUTS(1)=X*Y OUTPUTS(2)=X/Y OUTPUTS(3)=X+Y OUTPUTS(4)=X-Y MODE=0 S=''C RETURN 100 CONTINUE

  4. ERROR: THE NUMBER OF INPUTS ISN'T WHAT THIS SUBROUTINE EXPECTS

  5. NOTE: SET MODE>0 IF AN ERROR IS DETECTED. IF S IS EQUAL TO A

  6. NULL STRING, THEN EES WILL DISPLAY THE MODE NUMBER IN AN ERROR

  7. MESSAGE. IF S IS DEFINED, EES WILL DISPLAY THE STRING IN THE

  8. ERROR MESSAGE. THE C AT THE END OF THE STRING INDICATES C-STYLE

  9. S='MDASF REQUIRES 2 INPUTS'C MODE=1 RETURN 200 CONTINUE S='MDASF EXPECTS TO PROVIDE 4 OUTPUTS'C MODE=2 RETURN 300 CONTINUE S='DIVISION BY ZERO IN MDASF'C MODE=3 RETURN 900 CONTINUE

  10. PROVIDE AN EXAMPLE OF THE CALLING FORMAT WHEN MODE=-1 S='CALL MDASF(X,Y:A,B,C,D)'C RETURN END

The following statement in an EES program will call this file.

CALL MDASF(X,Y : M, D, A, S)

11 Dec 2006 8:00 #1425

FTN95 has its own set of comment embedded directives that are listed in the help file ftn95.chm. Under Win32 there is no alias mechanism unless you use the advanced features of the linker SLINK. By default all names are exported in upper chase.

The simplest way to create an appropriate DLL is to use EXPORTALL in the SLINK commands. This is available as a project setting from both Visual Studio and Plato.

If you are accessing a third party DLL then it is likely that it has been created using the STDCALL protocol. In this case you should use /IMPORT_LIB <dllname> on the command line. Alternatively, when creating a project in Plato, you can add a 'Reference' and use its Properties dialog to make it 'STDCALL'.

Please login to reply.