LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-04-2015, 02:17 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Rep: Reputation: Disabled
GFortran Module must be in a separate file only, otherwise it does not compile. Why?


I am wondering why if I place a GFortran module inside of the same file as the MAIN program it is not recognized by the compiler? I had to move it out into a separate file to be recognized. Then everything compiled. Thanls, - A.
 
Old 01-31-2015, 06:44 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Modules cannot be used until they have been compiled. Normally you would place them in separate files; but they can be in the same file if they precede the code which uses them.

For example, the following code compiles under gfortran 4.7.2
Code:
module math
  implicit none
  real, parameter :: e = 2.71828182
end
program main
  use math, only : e
  implicit none
  print*, "Euler's constant =", e
end
 
  


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
[SOLVED] Gfortran statement does not compile AlexBB Linux - Newbie 38 12-05-2016 07:19 PM
[SOLVED] Difficulty with gfortran compile error. AlexBB Linux - Newbie 3 12-20-2014 11:54 AM
[SOLVED] Gfortran module file AlexBB Linux - Newbie 7 11-16-2014 12:53 PM
gfortran slax module shoshia Slackware 2 08-04-2014 02:34 PM
Gfortran compile error aukuntin Linux From Scratch 2 01-28-2007 08:08 PM


All times are GMT -5. The time now is 07:40 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