Contents - Index
Example .FDL External Procedure in FORTRAN
Creating an external procedure with Digital Visual FORTRAN 6.5 or other FORTRAN compilers is most easily done within the Microsoft Developer Studio environment or other similar products. Click here to see how a FORTRAN External DLL can be written using the open source GNU Compiler Collection.
A new project workspace is selected as a Dynamic Link Library. The FORTRAN sources file(s) are inserted into the workspace and compiled with the standard options. Note that the two !DEC$ATTRIBUTES directives should be included in the main program, as noted above. The output filename in the Link settings should be set to MYPROC.FDL where MYPROC is the name that will be used in the EES Call statement. Alternatively, the default filename MYPROC.DLL should be changed to MYPROC.FDL after building the dynamic link library project.
The simple FORTRAN program listed below provides the product, dividend, sum, and difference of two input values. This program should provide a model for writing EES procedures in FORTRAN. The code for the GCC compiler differs slightly.
Listing of the FORTRAN MDASF Program
C. The following two lines are specific to Digital Visual Fortran 5 and Compaq Fortran Compilers
!DEC$ATTRIBUTES ALIAS:'MDASF' :: MDASF
!DEC$ATTRIBUTES DLLEXPORT :: MDASF
INTEGER(4) MODE, NINPUTS, NOUTPUTS
REAL(8) INPUTS(50), OUTPUTS(50)
IF (MODE.EQ.-1) GOTO 900
IF (NINPUTS.NE.2) GOTO 100
IF (NOUTPUTS.NE.4) GOTO 200
C. DO CALCULATIONS
IF (ABS(Y).LE.1E-9) GOTO 300
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
C. MESSAGE. IF S IS DEFINED, EES WILL DISPLAY THE STRING IN THE
C. ERROR MESSAGE. THE C AT THE END OF THE STRING INDICATES C-STYLE
C. S='MDASF REQUIRES 2 INPUTS'C
S='MDASF EXPECTS TO PROVIDE 4 OUTPUTS'C
S='DIVISION BY ZERO IN MDASF'C
C. PROVIDE AN EXAMPLE OF THE CALLING FORMAT WHEN MODE=-1
The following statement in an EES program will call this file.
CALL MDASF(X,Y : M, D, A, S)