Creating Fortran DLL
Moderators: silvia, selimgunay, Moderators
Creating Fortran DLL
Hi Frank,
The example VS project to create the dll (WindowsDLLs) is for c and c++. I have a Fortran source file for the material model, and also the Fortran compiler. I need to add materialTypes and materialAPI modules in the source folder along with the user material subroutine which uses them. Is that all I need to do to create the dll? Or do I need to also create a project called minPackageFortran similar to that of c and c++? Your input is much appreciated.
Thanks.
Karma
The example VS project to create the dll (WindowsDLLs) is for c and c++. I have a Fortran source file for the material model, and also the Fortran compiler. I need to add materialTypes and materialAPI modules in the source folder along with the user material subroutine which uses them. Is that all I need to do to create the dll? Or do I need to also create a project called minPackageFortran similar to that of c and c++? Your input is much appreciated.
Thanks.
Karma
Thanks for your response. The example project was created using a higher version of Intel compiler. The one that I have is 9.1 so I can't open it.
Anyway, I created a new project with the Dynamic-link Library template. Then added subroutine elasticPPf, materialTypes and materialAPI modules in the source file folder, and try to build it. I got the following compile errors:
1>------ Build started: Project: dm, Configuration: Debug Win32 ------
1>Compiling with Intel Fortran 9.1 C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\...
1>..\..\..\..\..\..\..\..\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(8) : Error: Syntax error, found '(' when expecting one of: ::
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(19) : Error: Syntax error, found '(' when expecting one of: ::
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(11) : Error: An END TYPE statement exists without an associated TYPE statement.
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(28) : Error: An END TYPE statement exists without an associated TYPE statement.
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(2) : Error: Error in opening the Library module file. [ISO_C_BINDING]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(9) : Error: A kind type parameter must be a compile-time constant. [C_DOUBLE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(10) : Error: A kind type parameter must be a compile-time constant. [C_DOUBLE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(20) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(21) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(22) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(23) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(24) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(25) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(26) : Error: This derived type name has not been declared. [C_FUNPTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(27) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(7) : Error: This name does not have a type, and must have an explicit type. [MODELSTATE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(18) : Error: This name does not have a type, and must have an explicit type. [MATOBJECT]
1>compilation aborted for C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f (code 1)
1>
1>Build log written to "file://C:\Documents and Settings\kyonten\My Documents\earthquake_analysis\OpenSees\user material\dm\dm\Debug\BuildLog.htm"
1>dm build failed.
1>
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It is missing the module iso_c_binding. I ran a search and couldn't locate the module. Where can I find it?
Thanks
Anyway, I created a new project with the Dynamic-link Library template. Then added subroutine elasticPPf, materialTypes and materialAPI modules in the source file folder, and try to build it. I got the following compile errors:
1>------ Build started: Project: dm, Configuration: Debug Win32 ------
1>Compiling with Intel Fortran 9.1 C:\Program Files\Intel\Compiler\Fortran\9.1\IA32\...
1>..\..\..\..\..\..\..\..\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(8) : Error: Syntax error, found '(' when expecting one of: ::
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(19) : Error: Syntax error, found '(' when expecting one of: ::
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(11) : Error: An END TYPE statement exists without an associated TYPE statement.
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(28) : Error: An END TYPE statement exists without an associated TYPE statement.
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(2) : Error: Error in opening the Library module file. [ISO_C_BINDING]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(9) : Error: A kind type parameter must be a compile-time constant. [C_DOUBLE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(10) : Error: A kind type parameter must be a compile-time constant. [C_DOUBLE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(20) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(21) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(22) : Error: A kind type parameter must be a compile-time constant. [C_INT]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(23) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(24) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(25) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(26) : Error: This derived type name has not been declared. [C_FUNPTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(27) : Error: This derived type name has not been declared. [C_PTR]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(7) : Error: This name does not have a type, and must have an explicit type. [MODELSTATE]
1>C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f(18) : Error: This name does not have a type, and must have an explicit type. [MATOBJECT]
1>compilation aborted for C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\materialTypes.f (code 1)
1>
1>Build log written to "file://C:\Documents and Settings\kyonten\My Documents\earthquake_analysis\OpenSees\user material\dm\dm\Debug\BuildLog.htm"
1>dm build failed.
1>
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It is missing the module iso_c_binding. I ran a search and couldn't locate the module. Where can I find it?
Thanks
Linking problem!
Hi Frank,
Now I have the latest version of Intel Fortran compiler and am able to open the example fortran project. I tried to build it, but got a linking error that has to do with 'minPackageC.lib.' I located the file, and added it to the source. Then I rebuilt the project and got the same link problem. I even added the 'minPackageC' project to the fortran project, and tried building it, but to no avail. Do I need to take care of some project settings?
Following is the link error I'm getting.
Compiling with Intel(R) Visual Fortran 11.0.072 [IA-32]...
materialTypes.f
materialAPI.f
elasticPPf.f
Compiling manifest to resources...
Linking...
LINK : fatal error LNK1181: cannot open input file 'minPackageC.lib'
Thanks.
Karma
Now I have the latest version of Intel Fortran compiler and am able to open the example fortran project. I tried to build it, but got a linking error that has to do with 'minPackageC.lib.' I located the file, and added it to the source. Then I rebuilt the project and got the same link problem. I even added the 'minPackageC' project to the fortran project, and tried building it, but to no avail. Do I need to take care of some project settings?
Following is the link error I'm getting.
Compiling with Intel(R) Visual Fortran 11.0.072 [IA-32]...
materialTypes.f
materialAPI.f
elasticPPf.f
Compiling manifest to resources...
Linking...
LINK : fatal error LNK1181: cannot open input file 'minPackageC.lib'
Thanks.
Karma
issue resolved
Frank,
I resolved the link error. I needed to set the path properly for the library file. The dll is created successfully. However, I am getting the following warning:
Linking...
Creating library C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\elasticppf.lib and object C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\elasticppf.exp
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
Embedding manifest...
When I use the NODEFAULTLIB I'm getting all sorts of errors so I'm going to ignore the warning. I just wanted to make sure this doesn't cause any problem. It doesn't seem to when I ran the example file in the repository.
Thanks.
I resolved the link error. I needed to set the path properly for the library file. The dll is created successfully. However, I am getting the following warning:
Linking...
Creating library C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\elasticppf.lib and object C:\OpenSees\OpenSees\PACKAGES\NewMaterial\fortran\elasticppf.exp
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
Embedding manifest...
When I use the NODEFAULTLIB I'm getting all sorts of errors so I'm going to ignore the warning. I just wanted to make sure this doesn't cause any problem. It doesn't seem to when I ran the example file in the repository.
Thanks.