- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can only get this to work if the function is included in a module. I want them in a library.
Could not figure out how to attach example files, so here is cut and paste:
function rot1(x) result(m)
real(8), intent(IN) :: x
real(8), dimension(3,3) :: m
m(1,1) = x
m(1,2) = 0
m(1,3) = 0
m(2,1) = 0
m(2,2) = x
m(2,3) = 0
m(3,1) = 0
m(3,2) = 0
m(3,3) = x
end function rot1
PROGRAM AGRAV
real(8), dimension(3,3) :: T
write(6,*) 'before call'
T = rot1(1.D0)
write(6,*) 'after call'
write(6,*) 'T =', T
END
Why won't this program build?
------ Build started: Project: Agrav, Configuration: Release Win32 ------
Compiling with Intel(R) Visual Fortran Compiler XE 13.0.1.119 [IA-32]...
AGRAV.F
Linking...
AGRAV.obj : error LNK2019: unresolved external symbol _ROT1@4 referenced in function _MAIN__
Release/agrav.exe : fatal error LNK1120: 1 unresolved externals
Build log written to "file://C:\Workspace\ast-suite\Agrav\BUILD\Agrav\Release\BuildLog.htm"
Agrav - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The function returns an array. This requires an explicit interface to be visible. When you had the function in a module, that provided the interface. There's no reason you can't put it in a module and then in a library - but the caller will need to use the module. See https://software.intel.com/en-us/blogs/2012/01/05/doctor-fortran-gets-explicit-again
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page