Hello,
A little late, but as promised, I hereby post my template on how to define User Functions in a DLL:
All User Functions may be used by Elmer, and all User Functions within the DLL may call each other.
I realize that this is not any "news" for seasoned Fortran programmers, but I guess there are other Elmer users, like me, that does not speak Fortran fluently...

In "Initial Conditon", "Boundary Condition", "Material" etc statements in the Case.sif file, these user functions may be called using statements along the line:
- Code: Select all
Material 1
Heat Capacity = Variable Temperature
Real Procedure "UserFunctions.dll" "geHeatCapacity"
End
Here is the User Function Template:
- Code: Select all
! Module Definitions for Modules used by the User Functions: Omit if not needed!
MODULE A
USE DefUtils
IMPLICIT NONE
......
END MODULE A
MODULE B
USE DefUtils
IMPLICIT NONE
......
END MODULE B
! Module Containing the User Function Interface Definitions:
! All Definitions follow the Guidelines for a User Function
! All Definitions listed here, will be Exported out of the DLL and may
! be Used Inide Elmer as a User Function
MODULE UserFunctions
FUNCTION Function_1( Model, n, NotUsed ) RESULT(Value)
USE Types
IMPLICIT None
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: NotUsed, ConstValue
END FUNCTION
FUNCTION Function_2( Model, n, NotUsed ) RESULT(Value)
USE Types
IMPLICIT None
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: NotUsed, ConstValue
END FUNCTION
.........
END MODULE UserFunctions
! Fimally, outside any "scope" the Functions Decalared
! in the Interface above must be implemented
FUNCTION Function_1( Model, n, NotUsed ) RESULT(Value)
! modules needed
USE DefUtils
USE UserFunctions ! Needed if this User Function wants to call another User Function
IMPLICIT None
! variables in function header
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: NotUsed, ConstValue
.......
END FUNCTION Function_1
FUNCTION Function_2( Model, n, NotUsed ) RESULT(Value)
! modules needed
USE DefUtils
USE UserFunctions ! Needed if this User Function wants to call another User Function
IMPLICIT None
! variables in function header
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: NotUsed, ConstValue
.......
END FUNCTION Function_2