Page 7 - Demo
P. 7


                                    Interface to FORTRAN%uf09f %uf09f RCP Consult 2023-2025 Page 7If you like use ifx or ifort compiler you just use a different attribute directive!DEC$ ATTRIBUTES DLLEXPORT::FortranFunctionThe variant with a free format FORTRAN source file %u2018FortranSource.f90%u2019 looks like: DEFFUNC(1,1,FortranSAO,\ {Uses function arguments}=FortranFunctionorDEFFUNC(1,FORTRAN,FortranSAO,\ {Uses function arguments}=FortranFunctionHere is source text for gfortranreal*8 function FortranFunction(a,b,c,d,ier) bind(C,name='FortranFunction') implicit none!! Include file with internal STRUREL definitionsinclude 'strurel.hf'!GCC$ ATTRIBUTES DLLEXPORT::FortranFunctiondouble precision, intent(in), value :: a, b, c, dinteger, 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**2ier=0end functionand again for ifx or ifort change attribute directive to!DEC$ ATTRIBUTES DLLEXPORT::FortranFunctionThe user defined function without arguments can be expressed in the Symbolic language of STRUREL as shown below. DEFFUNC(1,1,FortranSAO,\ {Function without arguments}=FortranFunctionorDEFFUNC(1,FORTRAN,FortranSAO,\ {Function without arguments}=FortranFunctionIn this case you need to prepare your source according to the compiler used likereal*8 function FortranFunction(ier) bind(C,name='FortranFunction') implicit none!! Include file with internal STRUREL definitionsinclude 'strurel.hf'!GCC$ ATTRIBUTES DLLEXPORT::FortranFunctioninteger, intent(out) :: ier!# Function without arguments as defined in Symbolic Expressions.FortranFunction = 123.ier=0end function
                                
   1   2   3   4   5   6   7   8   9   10   11