Reputation: 401
Is it possible to compile a user-defined subroutine at run-time and pass it as input to another subroutine which has already been compiled in Fortran?
Upvotes: 0
Views: 70
Reputation: 60008
Short answer: no.
Some languages allow this using some eval()
procedure. The Fortran standard doesn't have any such capability, even though one could imagine such an extension if there were some compiler which was using LLVM or similar runtime systems (or even an interpreter).
All Fortran compilers I know are traditional compilers to machine code and they don't allow anything like that. What you could do, is to save the code to a file, call the Fortran compiler in background to compile a shared library (.dll
or .so
) and then load the library using your operating system specific routines.
Upvotes: 1