- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am looking to access subroutines that are in another directory, but I can't figure out how to note what directory they are in when I am compiling my code. I am trying to just do a "hello world" example, so I can modify it for my more complex code.
Here is the folder setup I am trying for.
/user/myname/common_files/numerical_recipes/
.../imsl/
.../custom_routines/
/user/myname/program_A/
/user/myname/program_B/
I want to be able to access common subroutines/modules/*.o files that I have stored and compiled in the first three directories from programs I have in other directories.
I have used the > ifort -c programA.f90 -I/dir/ to point the compiler to where the module is, and that works fine, but when I am trying to compile the entire thing, I don't know how to point it to the object files.
Here is my makefile...
[bash]exectutable_program_a: program_A.o ifort -o executable_program_a program_A.o program_A.o: program_A.f90 ifort -c program_A.f90 -I/path/to/subroutines/module[/bash]
I am getting an error that the object file for the subroutine file can not be located. Any help would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you noted, the compiler accesses module files via the -I option, but the linker's (ld), invoked via ifort, access to routines defined in modules is done by providing the path to .o files relative to make's working directory upon reaching the link rule (e.g. executable_program_a: ). It appears from the rules show the working directory for program_A will be: /user/myname/program_A.
For program_A to resolve references to subroutines defined in modules from your first three directories, you must provide the linker a path to those object files and so your rule becomes something like:
executable_program_a: program_A.o
ifort -o executable_program_a ../common_files/numerical_recipes/*.o ../common_files/imsl/*.o ../common_files/custom_routines/*.o program_A.o
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you noted, the compiler accesses module files via the -I option, but the linker's (ld), invoked via ifort, access to routines defined in modules is done by providing the path to .o files relative to make's working directory upon reaching the link rule (e.g. executable_program_a: ). It appears from the rules show the working directory for program_A will be: /user/myname/program_A.
For program_A to resolve references to subroutines defined in modules from your first three directories, you must provide the linker a path to those object files and so your rule becomes something like:
executable_program_a: program_A.o
ifort -o executable_program_a ../common_files/numerical_recipes/*.o ../common_files/imsl/*.o ../common_files/custom_routines/*.o program_A.o
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page