LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 01-28-2009, 03:39 PM   #1
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Rep: Reputation: 0
Fortran compiler on suse11


hi

i am new to linux......i installed fortran77 using Yast and it indicates that its installed.when i check the respositories..i dont see the gcc fort4.3...am i supposed to see it? also where do i get the manual for beginners to start with fortran compilers.

thanks
 
Old 01-28-2009, 04:02 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Which package did you install exactly? If using the search form in Yast and type "fortran" you end up with gcc43-fortran, which provides the gfortran compiler. To start using it, just write a simple code and try it out:
Code:
gfortran code.f90
If you are looking for a very basic introduction to Fortran, I can suggest this guide from ITS at University of Durham. Feel free to ask if you encounter any problem. Programming questions have to be posted in the Programming forum for a better visibility.
 
Old 01-29-2009, 02:24 AM   #3
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Programming

i have installed SUSE10.2

you are right Yast I get gcc43-fortran.

About the code...i tried it on the terminal , but it says "no such file or diretotry"

Thanks for the fortran guide
 
Old 01-29-2009, 03:35 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by vovo View Post
About the code...i tried it on the terminal , but it says "no such file or diretotry"
Of course. Mine was just an example of a dummy command line. If you want to test it out put the following code in a file named code.f90:
Code:
PROGRAM hello
  IMPLICIT NONE
  CHARACTER(LEN=12):: string = 'Hello vovo!'
  WRITE(*,*) string
  string = 'How are you?'
  WRITE(*,*) string
END PROGRAM hello
then from the directory where the file is saved, do the following two commands:
Code:
# gfortran code.f90
# ./a.out
Congratulations, you did run your first Fortran program!

Just out of curiosity: you stated in the OP that you run on opensuse 11... why have you downgraded to 10.2?
 
Old 02-03-2009, 07:21 AM   #5
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
i made amistake....its suse11.0
 
Old 02-03-2009, 07:23 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Ok. Have you tried the simple example I posted? Does it work?
 
Old 02-04-2009, 03:38 PM   #7
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
yeap.....but i could not run it.I believe, i have to make it a textfile first....then save it as a textfile.Now when i do ls.....i can see it but when i try to run it .using gfortran code.90...its says :

/usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld:code.90: file format not recognized; treating as linker script
/usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld:code.90:1: syntax error
collect2: ld returned 1 exit status

by the way i used vim .......newfile in the terminal.On emacs i saved it as test22.
Does it have to be on a directory
 
Old 02-04-2009, 11:26 PM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
code.90: file format not recognized
This is because fortran compilers in general are very picky about the file names. They have a bunch of extensions which recognize as fortran programs, the other are discarded. In short, just change the extension to .f90 and the trick is done!
 
Old 02-07-2009, 02:32 PM   #9
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
i am trying formating......for integers, its refusing me to use e.g.i3
At line 10 of file money.f90 (unit = 5, file = 'stdin')
Fortran runtime error: Expected INTEGER for item 2 in formatted transfer, gotCHARACTER
(2x,i3,a4,f6.2)
^



Thanks

Last edited by vovo; 02-07-2009 at 02:57 PM.
 
Old 02-07-2009, 02:46 PM   #10
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
what is the right syntax to use for an output filename...instead of out.dat....to see only the output file not the contents on the screen.
Thanks
 
Old 02-07-2009, 03:21 PM   #11
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by vovo View Post
At line 10 of file money.f90 (unit = 5, file = 'stdin')
Fortran runtime error: Expected INTEGER for item 2 in formatted transfer, gotCHARACTER
(2x,i3,a4,f6.2)
This means that in the read/write statement where you use the format (2x,i3,a4,f6.2) you put a character as the first argument in place of the expected integer. For example:
Code:
      write(*,10) 'c','fg',78.4
  10  format(2x,i3,a4,f6.2)
the write statement above tries to put a 'c' whereas it expects an integer number because of the format specification.
 
Old 02-07-2009, 03:23 PM   #12
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by vovo View Post
what is the right syntax to use for an output filename...instead of out.dat....to see only the output file not the contents on the screen.
Thanks
Sorry... I don't understand this question. Where out.dat comes from? Please, post the code you're talking about, otherwise it's difficult for us to guess how it is and where the problem comes from. Thanks.
 
Old 02-09-2009, 03:47 PM   #13
vovo
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
the program is supposed to write the output ONLY TO A FILE not on the screen, so i am supposed to use:
open(1,file='out.dat').......
by the way....i have been using ./a.out to run my output,so if i wanna name my outputfile so that i dont get confused, but i can see all my outputs as files, what do i use......i want my output to have the same filename as the program.....
Thanks
 
Old 02-10-2009, 04:46 AM   #14
lauer
Member
 
Registered: Aug 2003
Location: Germany
Distribution: openSuSE
Posts: 61

Rep: Reputation: 16
Is this a fortran progamming course
 
Old 02-10-2009, 09:39 AM   #15
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
When you open a file for writing, chose a unit at least greater than 6 or even better a two-digit unit number. The first six units are reserved to some default I/O devices, for example unit 5 is standard input (the terminal) and unit 6 is standard output (the terminal). So use for example
Code:
open(11, file='out.dat')
If you want to determine automatically the name of the output file, based on the name of the executable, you have first to read it using the getarg() function and retrieving argument 0. For example
Code:
PROGRAM test
IMPLICIT NONE
CHARACTER(len=20):: string0
CHARACTER(len=25):: string1
CALL GETARG(0,string0)
string1 = TRIM(string0)//'.dat'
OPEN(11,file=string1)
WRITE(11,*) 'write something now'
CLOSE(11)
END PROGRAM test
this will create an output file called test.dat provided the executable file is simply called test.

Finally to give a name different than a.out to the executable file, you can just rename it at your pleasure or use the -o option to specify it during the compilation.
 
  


Reply



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
fortran compiler sarayazdani Linux - Software 1 09-20-2008 11:59 AM
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
Fortran compiler serafimg Ubuntu 1 01-28-2007 02:19 PM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM
Fortran Compiler bob10a Linux - Software 14 07-19-2003 04:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 08: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
Open Source Consulting | Domain Registration