Page 6 - Demo
P. 6


                                    Interface to FORTRAN%uf09f %uf09f RCP Consult 2023-2025 Page 64. Interaction between STRUREL and FortranA major part of communication with the FORTRAN Interface is usage of source files with extension %u2019.for%u2019 for a fixed format or with extension %u2019.f90%u2019. for a free format. With the classic computer language such as FORTRAN the creation of Add-on is more complex as compared to usage of external engines like PYTHON or others. You need source file compiler, librarian, resource file compiler and linker to create a customized Windows DLL. Using special rules for creation of resource file such a FORTRAN based DLL can be built directly. Then, it will be accepted as so called Buildout Add-on and connected with STRUREL. The integration of Buildout Add-on in STRUREL is provided by using the DEFFUNC keyword in Symboliclanguage.The syntax of DEFFUNC for interaction with such a FORTRAN based Add-on is:DEFFUNC(i, k | l, SAONAME)(PARAMETERLIST){COMMENT}=FUNNAME%uf046 i: ID of the user defined function in Symbolic Interpreter%uf046 k: kind of Add-on as number: 1 %u2013 FORTRANor%uf046 l: language as text: FORTRAN%uf046 SAONAME: name of the Add-on (without extension .sao)%uf046 PARAMETERLIST: lists the parameters the function expects. The names given are arbitrary. The parameter list can be empty or have maximal 16 members.%uf046 COMMENT: some comment (may be omitted)%uf046 FUNNAME: the name of the export function to callThe user defined function with arguments can be expressed in the Symbolic language of STRUREL as shown below. DEFFUNC(1,1,FortranSAO,\ {Uses function arguments}=FortranFunctionorDEFFUNC(1,FORTRAN,FortranSAO,\ {Uses function arguments}=FortranFunctionIf you wish to create an Add-on using gfortran you may prepare a FORTRAN source file%u2018FortranSource.for%u2019 having fixed format with definition of an export function like   real*8 function FortranFunction(a,b,c,d,ier) * bind(C,name='FortranFunction')  implicit none!! Include file with internal STRUREL definitions include 'strurel.hf'!GCC$ ATTRIBUTES DLLEXPORT::FortranFunction double precision, intent(in), value :: a, b, c, d integer, intent(out) :: ier!# Uses function argument values as defined in Symbolic Expressions.!# The sequence is predefined by definition of parameters of DEFFUNC. FortranFunction = a*b/4*c*d**2 ier=0 end function
                                
   1   2   3   4   5   6   7   8   9   10