Installation/Compilation of a user defined function
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Installation/Compilation of a user defined function
The SIF video tutorial and ElmerProgrammer's tutorial have instructed me to use something of the form:
Heat Source = Variable coordinate 1, coordinate 2, coordinate 3, time
Procedure "MyLibrary" "MyFunction"
where "MyLibrary" is a .f90 file and ""MyFunction" is a FUNCTION in fortran90
Then compile with
$ elmerf90 -o MyLibrary.so MyLibrary.f90 or
> elmerf90 -o MyLibrary.dll MyLibrary.f90
Can you help me by sharing a test file "MyLibrary.so" or "MyLibrary.dll", so that I can learn to compile a .f90 file with elmer in this fashion and test if everything is working?
Thanks
Heat Source = Variable coordinate 1, coordinate 2, coordinate 3, time
Procedure "MyLibrary" "MyFunction"
where "MyLibrary" is a .f90 file and ""MyFunction" is a FUNCTION in fortran90
Then compile with
$ elmerf90 -o MyLibrary.so MyLibrary.f90 or
> elmerf90 -o MyLibrary.dll MyLibrary.f90
Can you help me by sharing a test file "MyLibrary.so" or "MyLibrary.dll", so that I can learn to compile a .f90 file with elmer in this fashion and test if everything is working?
Thanks
-
- Posts: 2301
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: Installation/Compilation of a user defined function
An example of heat as a function of time. You can make whatever functions you need inside the If statements, or make your own branch conditions.
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Re: Installation/Compilation of a user defined function
Thank you so much.
Wow!
I opened your heat.90 on atom the text editor and I'm glad to see the similarities between your code and the fortran tutorial I was watching! I'll review.
In case.sif I understood how you sourced "heat" and "HeatSource" within "heat"
Your help is perfect.
Could you please help me try to compile this on the command line (I'll try Git Bash, Cygwin, and cmd if either do not work)
I have the project ready in a directory /Elmer 9.0-Release/Projects/heatproject
I wonder if I have to save heat.f90 in a specific directory, /heatproject, or if the command-line will be able to find it in /Downloads
Similar question: I wonder if I have to navigate to a specific directory to type $ elmerf90 -o heat.so heat.f90
Wow!
I opened your heat.90 on atom the text editor and I'm glad to see the similarities between your code and the fortran tutorial I was watching! I'll review.
In case.sif I understood how you sourced "heat" and "HeatSource" within "heat"
Your help is perfect.
Could you please help me try to compile this on the command line (I'll try Git Bash, Cygwin, and cmd if either do not work)
I have the project ready in a directory /Elmer 9.0-Release/Projects/heatproject
I wonder if I have to save heat.f90 in a specific directory, /heatproject, or if the command-line will be able to find it in /Downloads
Similar question: I wonder if I have to navigate to a specific directory to type $ elmerf90 -o heat.so heat.f90
-
- Posts: 2301
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: Installation/Compilation of a user defined function
If the user function is in the working directory with the case.sif then the way it is called out in the case.sif will work. Otherwise you have to put the directory path in like
Heat Source = Variable Time
Procedure "/home/myfiles/fea/heat" "HeatSource"
elmerf90 -o heat.so heat.f90 is the compiler supplied by Elmer and must be used for user functions
the elmerf90 is an executable and your path has to be set correctly for the OS to fined it, or you have to fully qualify it
C:\elmer\bin\elmerf90 -o heat.so heat.f90
where C:\elmer\bin is rplaced with the location of the Elmer exectuble files.
Heat Source = Variable Time
Procedure "/home/myfiles/fea/heat" "HeatSource"
elmerf90 -o heat.so heat.f90 is the compiler supplied by Elmer and must be used for user functions
the elmerf90 is an executable and your path has to be set correctly for the OS to fined it, or you have to fully qualify it
C:\elmer\bin\elmerf90 -o heat.so heat.f90
where C:\elmer\bin is rplaced with the location of the Elmer exectuble files.
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Re: Installation/Compilation of a user defined function
This was perfect kevinarden!
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Re: Installation/Compilation of a user defined function
Ok hope you can help me.
I built heat.f90 and placed in in Elmer 9.0 Release/Projects/proj1
I opened Git Bash and navigated to Elmer/bin
I typed elmerf90 heat.f90 -o heat.so
and I get the error
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: syntax error near unexpected token `('
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: ` LIBDIR=C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver'
Please help. Thanks!
I built heat.f90 and placed in in Elmer 9.0 Release/Projects/proj1
I opened Git Bash and navigated to Elmer/bin
I typed elmerf90 heat.f90 -o heat.so
and I get the error
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: syntax error near unexpected token `('
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: ` LIBDIR=C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver'
Please help. Thanks!
-
- Posts: 2301
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: Installation/Compilation of a user defined function
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: syntax error near unexpected token `('
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: ` LIBDIR=C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver'
one line 5 it can't read the (x86) as part of the file name. adding quatations around the filename may work.
LIBDIR="C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver"
/d/Elmer 9.0-Release/Bin/elmerf90: line 5: ` LIBDIR=C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver'
one line 5 it can't read the (x86) as part of the file name. adding quatations around the filename may work.
LIBDIR="C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver"
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Re: Installation/Compilation of a user defined function
I don't know why C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver is being referenced. I do not have a Elmer file in Program Files (x86).
-
- Posts: 2301
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: Installation/Compilation of a user defined function
depending on how elmer was installed on what system the executable files may be located there, elmer90 is trying to find a library named LIBDIR=C:/Program Files (x86)/Elmer/share/elmersolver/../../lib/elmersolver
it can't find it because it can't decipher a file name with () in it.
it can't find it because it can't decipher a file name with () in it.
-
- Posts: 57
- Joined: 14 Mar 2021, 21:01
- Antispam: Yes
Re: Installation/Compilation of a user defined function
Solved: I uninstalled everything, then followed https://www.youtube.com/watch?v=xPDzlGYK_kM. Thanks for helping.