Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-04-2015, 03:17 PM   #1
Registered: Mar 2014
Posts: 444

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, 07:44 AM   #2
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
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
module math
  implicit none
  real, parameter :: e = 2.71828182
program main
  use math, only : e
  implicit none
  print*, "Euler's constant =", e


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 08:19 PM
[SOLVED] Difficulty with gfortran compile error. AlexBB Linux - Newbie 3 12-20-2014 12:54 PM
[SOLVED] Gfortran module file AlexBB Linux - Newbie 7 11-16-2014 01:53 PM
gfortran slax module shoshia Slackware 2 08-04-2014 03:34 PM
Gfortran compile error aukuntin Linux From Scratch 2 01-28-2007 09:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 AM.

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