Page 1 of 1
Simple UDF question
Posted: 21 Dec 2016, 18:53
by Estiivan
I have a file called MyLibrary_ver2.f90 (edited from some tutorial):
Code: Select all
FUNCTION MyFunctionVer2()
USE DefUtils
TYPE(Model_t) :: Model
print *, 'Hei Solverilta'
END FUNCTION MyFunctionVer2
Then I gave a command
Code: Select all
elmerf90 -o MyLibrary_ver2.so MyLibrary_ver2.f90
and a file called MyLibrary_ver2.so was created to same folder as was .f90 file.
How can I call this function from Elmer? As I understand something like
Code: Select all
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
should be written in .sif file. But where should it put there? Also, should .so file be in some specific folder?
Re: Simple UDF question
Posted: 22 Dec 2016, 09:54
by annier
Hi Estiivan,
1.
Estiivan wrote: But where should it put there?
The Real Procedure should be put in the section of the sif where it is to be called.
If it is a Material property related procedure (function), then call it from:
Code: Select all
Material n
...
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
...
End
If it is a function for BCs (Boundary Condition), call it as:
Code: Select all
Boundary condition n
...
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
...
End
n = 1, 2, 3, 4, ...
and so on and so on...
2.
Estiivan wrote:Also, should .so file be in some specific folder?
The shared object file is put in the same folder with your solver input file (sif) file.
Yours Sincerely,
Anil Kunwar
Re: Simple UDF question
Posted: 29 Dec 2016, 17:02
by Estiivan
Hi annier!
Any suggestions to which block I should place my
Code: Select all
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
call to my function? As this is not exactly material or BC function, I think.
With regards,
Estiivan
Re: Simple UDF question
Posted: 30 Dec 2016, 11:46
by raback
Hi
You cannot change the API. A function should return a value. Maybe the solver API would better suit your needs here. Then you would create a new solver block and place the procedure name there.
-Peter