LinuxQuestions.org
Help answer threads with 0 replies.
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 11-15-2014, 08:48 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
Gfortran module file


Hi there. My environment is Win7==>Oracle VB==>Ubuntu==>Gfortran. I've got a problem. I have a module file which I copied from this .pdf: Numerical Recipes in Fortran 90 Vol 2. I did minimal editing, mostly I removed long decimal places in the constants. Here it is:

Code:
MODULE nrtype
!  Symbolic names for kind types of 4-, 2-, and 1-byte integers:
   INTEGER, PARAMETER :: I4B = SELECTED_INT_KIND(9)
   INTEGER, PARAMETER :: I2B = SELECTED_INT_KIND(4)
   INTEGER, PARAMETER :: I1B = SELECTED_INT_KIND(2)
!  Symbolic names for kind types of single- and double-precision reals:
   INTEGER, PARAMETER :: SP = KIND(1.0)
   INTEGER, PARAMETER :: DP = KIND(1.0D0)
!  Symbolic names for kind types of single- and double-precision complex:
   INTEGER, PARAMETER :: SPC = KIND((1.0,1.0))
   INTEGER, PARAMETER :: DPC = KIND((1.0D0,1.0D0))
!  Symbolic name for kind type of default logical:
   INTEGER, PARAMETER :: LGT = KIND(.true.)
!  Frequently used mathematical constants (with precision to spare):
   REAL(SP), PARAMETER :: PI=3.1415_sp
   REAL(SP), PARAMETER :: PIO2=1.5707_sp
   REAL(SP), PARAMETER :: TWOPI=6.2831_sp
   REAL(SP), PARAMETER :: SQRT2=1.4142_sp
   REAL(SP), PARAMETER :: EULER=0.5772_sp
   REAL(DP), PARAMETER :: PI_D=3.1415_dp
   REAL(DP), PARAMETER :: PIO2_D=1.5707_dp
   REAL(DP), PARAMETER :: TWOPI_D=6.2831_dp
!  Derived data types for sparse matrices, single and double precision 
!  (see use in Chapter B2):
   TYPE sprs2_sp
     INTEGER(I4B) :: n,len
     REAL(SP), DIMENSION(:), POINTER :: val
     INTEGER(I4B), DIMENSION(:), POINTER :: irow
     INTEGER(I4B), DIMENSION(:), POINTER :: jcol
   END TYPE sprs2_sp
   TYPE sprs2_dp
     INTEGER(I4B) :: n,len
     REAL(DP), DIMENSION(:), POINTER :: val
     INTEGER(I4B), DIMENSION(:), POINTER :: irow
     INTEGER(I4B), DIMENSION(:), POINTER :: jcol
   END TYPE sprs2_dp
END MODULE nrtype
This file is supposed to be called by another Fortran 90 file but when it comes to this statement I get an error:

Quote:
USE nrtype; USE nrutil, ONLY : arth,assert,cumprod
1
Fatal Error: File 'nrtype.mod' opened at (1) is not a GFORTRAN module file
The file's name is nrtype.mod. I cannot find anywhere how a GFortran module file should look like. I need help.

Thanks, - A.
 
Old 11-15-2014, 10:18 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
well what version of ubuntu did you install in the virtual machine ?

and what version of Gfortran
90 to present should be in the default gcc FORTRAN compiler
g77 ( yes as in the year 1977) is in the legacy gcc 33


to keep things strait
for f90 code use .f90 as the file extension

also INDENTATION IS VERY IMPORTANT

so as you TYPE the code pay attention to that
-- do NOT "copy / paste" !!!!


you learn by doing

and all CAPS

rename "nrtype.mod" to NRTYPE.MOD

Last edited by John VV; 11-15-2014 at 10:21 PM.
 
Old 11-15-2014, 10:43 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by AlexBB View Post
This file is supposed to be called by another Fortran 90 file but when it comes to this statement I get an error:


The file's name is nrtype.mod. I cannot find anywhere how a GFortran module file should look like. I need help.

Thanks, - A.
Wait - you didn't just type all of that code into a text file and call it "nrtype.mod", did you? It needs to be an .f90 like any other, the .mod is the compiled version. Use gfortran to compile nrtype.f90 into a module, and then you can use it when compiling another code.

Last edited by suicidaleggroll; 11-15-2014 at 10:44 PM.
 
1 members found this post helpful.
Old 11-16-2014, 11:36 AM   #4
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
suicidaleggroll, you are a genius! So, it was a linkage problem. Very cute. I've learnt something important with this post. The problem appears to have been solved. John W, thanks also.
 
Old 11-16-2014, 11:41 AM   #5
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
BTW, I have an unrelated question. Why is it that I often find in Ubuntu directories files with a tilde ("~") at the end. They are duplicates of the files I edit or compile and sometimes I do not see them, but then they appear. Thanks. - A.
 
Old 11-16-2014, 11:43 AM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Chances are whatever text editor you use is auto-saving your files for recovery if the program crashes or the computer locks up or loses power.
 
1 members found this post helpful.
Old 11-16-2014, 01:33 PM   #7
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
suicidaleggroll, I use vim and gedit intermittently. I think yours is a reasonable assumption. I accept it. Thanks. A.
 
Old 11-16-2014, 01:53 PM   #8
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
gedit will auto save the ORIGINAL pre-edit file with a ~

that is a safety measure
 
1 members found this post helpful.
  


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] Where is the error in a Gfortran file? AlexBB Linux - Newbie 3 10-19-2014 12:42 PM
gfortran slax module shoshia Slackware 2 08-04-2014 03:34 PM
Does gfortran has issue working with the file as I/P and O/P ?? parekhharsh_j Linux - Newbie 6 06-17-2011 09:39 AM
Problem to Read Binary File with gfortran kdurgarao Programming 1 10-12-2009 03:26 AM
does the G95 or Gfortran support the concept of "module" in fortran95 ztdep Programming 1 09-08-2005 03:32 PM


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

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