LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-26-2013, 08:11 AM   #1
januka
LQ Newbie
 
Registered: Sep 2010
Posts: 18

Rep: Reputation: 0
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

Last edited by januka; 09-26-2013 at 09:33 AM.
 
Old 09-26-2013, 11:56 AM   #2
januka
LQ Newbie
 
Registered: Sep 2010
Posts: 18

Original Poster
Rep: Reputation: 0
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"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How much faster can the compiling be if I use the USE flags well? Ben_the1st Gentoo 9 01-07-2010 11:53 AM
gfortran compiling problem, RHEL 4 The_Watcher Linux - Enterprise 1 08-22-2008 12:57 PM
undefined gfortran references when compiling with g77 StudMuffin Linux - Software 4 02-17-2007 07:06 AM
flags for compiling Xlib.h in gcc Maidros Programming 2 06-15-2005 06:00 AM
optimization flags and kernel compiling kpachopoulos Linux - Newbie 2 08-26-2004 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration