Contents - Index


DLL File Skeleton in FORTRAN

 

The following FORTRAN subprograms will compile into a file having a .DLL filename extension.  When placed in the \USERLIB directory, EES will automatically load this file and, in this case the FORTRAN subroutines, TEST1 and TEST2, will both be callable from EES with EES equations of the form:

CALL TEST1(X,Y:a1,b1,c1,d1)

CALL TEST2(X,Y:a2,b2,c2,d2)

 

 

      SUBROUTINE FDLNames(S)

C  The following two lines are compiler specific

      !DEC$ATTRIBUTES ALIAS:'FDLNames' :: FDLNames

      !DEC$ATTRIBUTES DLLEXPORT :: FDLNames

      IMPLICIT INTEGER(4) (i-k,m-n)

      CHARACTER(255) S

      S='TEST1,TEST2'C

      MODE = 0

      END

 

      SUBROUTINE DLFNames(S)

C  The following two lines are compiler specific

      !DEC$ATTRIBUTES ALIAS:'DLFNames' :: DLFNames

      !DEC$ATTRIBUTES DLLEXPORT :: DLFNames

      IMPLICIT INTEGER(4) (i-k,m-n)

      CHARACTER(255) S

      S=''C

      MODE = 0

      END

 

      SUBROUTINE DLPNames(S)

C  The following two lines are compiler specific

      !DEC$ATTRIBUTES ALIAS:'DLPNames' :: DLPNames

      !DEC$ATTRIBUTES DLLEXPORT :: DLPNames

      IMPLICIT INTEGER(4) (i-k,m-n)

      CHARACTER(255) S

      S=''C

      MODE = 0

      END

 

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

C  The following two lines are compiler specific

      !DEC$ATTRIBUTES ALIAS:'TEST2' :: TEST2

      !DEC$ATTRIBUTES DLLEXPORT :: TEST2

       INTEGER(4) MODE, NINPUTS, NOUTPUTS

       REAL(8) INPUTS(50), OUTPUTS(50)

       CHARACTER(255) S

       IF (MODE.EQ.-1) GOTO 900

       IF (NINPUTS.NE.2) GOTO 100

       IF (NOUTPUTS.NE.4) GOTO 200

C.  DO CALCULATIONS

       X=INPUTS(1)

       Y=INPUTS(2)

       IF (ABS(Y).LE.1E-9) GOTO 300

       OUTPUTS(1)=2*X*Y

       OUTPUTS(2)=2*X/Y

       OUTPUTS(3)=2*(X+Y)

       OUTPUTS(4)=2*(X-Y)

       MODE=0

       S=''C

       RETURN

100    CONTINUE

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

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

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

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

C.  THE C AT THE END OF THE STRING INDICATES C-STYLE 

C.  S='TEST2 REQUIRES 2 INPUTS'C

       MODE=1

       RETURN

200    CONTINUE

       S='TEST2 EXPECTS TO PROVIDE 4 OUTPUTS'C

       MODE=2

       RETURN

300   CONTINUE

       S='DIVISION BY ZERO IN TEST2'C

       MODE=3

       RETURN

900    CONTINUE

C.  PROVIDE AN EXAMPLE OF THE CALLING FORMAT WHEN MODE=-1

       S='CALL TEST2(X,Y:A,B,C,D)'C

       RETURN

       END

 

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

C  The following two lines are compiler specific

      !DEC$ATTRIBUTES ALIAS:'TEST1' :: TEST1

      !DEC$ATTRIBUTES DLLEXPORT :: TEST1

       INTEGER(4) MODE, NINPUTS, NOUTPUTS

       REAL(8) INPUTS(50), OUTPUTS(50)

       CHARACTER(255) S

       IF (MODE.EQ.-1) GOTO 900

       IF (NINPUTS.NE.2) GOTO 100

       IF (NOUTPUTS.NE.4) GOTO 200

C.  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

C.  S='TEST1 REQUIRES 2 INPUTS'C

       MODE=1

       RETURN

200    CONTINUE

       S='TEST1 EXPECTS TO PROVIDE 4 OUTPUTS'C

       MODE=2

       RETURN

300    CONTINUE

       S='DIVISION BY ZERO IN TEST1'C

       MODE=3

       RETURN

900    CONTINUE

C.  PROVIDE AN EXAMPLE OF THE CALLING FORMAT WHEN MODE=-1

       S='CALL TEST1(X,Y:A,B,C,D)'C

       RETURN

       END

 

 

Dynamic Link Libraries