LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gfortran linking/compiling with -I and -J flags (https://www.linuxquestions.org/questions/linux-newbie-8/gfortran-linking-compiling-with-i-and-j-flags-4175478622/)

januka 09-26-2013 07:11 AM

gfortran linking/compiling with -I and -J flags
 
I am trying to link and compile a couple of modules that are not in the current directory with a couple of my own .f90 programs and out put the .exe to a folder that is not the current directory. It appears to me that I have to use flags -I and -J when compiling with gfortran but not sure the correct use of these. If anyone can help that would be great. Many thanks!

Here's what I've tried thus far (an example) based on an online tutorial but I am getting the error "Fatal Error: Can't open module file 'spectra.mod' for reading at (1): No such file or directory" in the first line itself. mod1.mod has the correct path declared.

M_PATH=/usr/local/mod
P_PATH=~/Desktop
O_PATH=~/Documents/my_progs

gfortran -c ${P_PATH}/my_prog1.f90 -I${M_PATH}/mod1.mod -o ${O_PATH}/my_prog.o

gfortran -o ${O_PATH}/myprog.exe ${O_PATH}/my_prog.o

januka 09-26-2013 10:56 AM

Solution
 
gfortran -O -I${P_PATH}/example_prog.f90 -L/${M_PATH}/ -lexample.mod -o example.exe

Note:
"-I" in -I${DSKT}/example_prog.f90 is uppercase "ai" and
"-l" in -lexample.mod is lower case "el"


All times are GMT -5. The time now is 12:10 PM.