Visit Jeremy's Blog.
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 04-17-2012, 02:29 PM   #1
LQ Newbie
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
compilation problem

Hi Linux users

I'm new in Linux. I tried to compile a Fortran program in ubuntu 11.10
with gcc. My fortran program is monte_pi. I saved it in the Desktop. But when I changed directory to /home/nagat/Desktop and run
gcc -o monte_pi monte_pi.f . An error appeared to me
gcc:error:monte_pi: no such file or directory
gcc:fatal error:no input file
compilation terminated
please can any one help me to get over this error?
Thanks in advance

Old 04-17-2012, 02:34 PM   #2
LQ Newbie
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
Make sure you are in the correct directory with 'pwd'. Make sure that the file exists with 'ls'. It looks like the compiler cannot find monte_pi.f.
1 members found this post helpful.
Old 04-17-2012, 03:01 PM   #3
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2017 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,737

Rep: Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317
Welcome to LQ.
The file name is monte_pi.f : It's a Fortran program → gcc cannot be used.

Ubuntu 11.10 : 1) sudo apt-get install gfortran
2) gfortran -c monte_pi.f
3) gfortran -o monte_pi monte_pi.o : You get the executable 'monte_pi'.
... Or the simple way (2)(3) : gfortran monte_pi.f -o monte_pi
4) Run the pi test : ./monte_pi
C Program to compute Pi using monte carlo methods

       program monte_pi
       implicit none
       integer niter,i,j
       integer seed 
       real*4 count
       real *8 x,y,pi(100),z
       real*8   rand
C initialize random numbers
       seed = 35791246
       call srand (seed)
       do j= 1,100
          niter = niter+100
          count =0
          do i=1,niter
             z= x*x +y*y
             if (z .le. 1) count =count+1
          end do
          pi(j)= count/niter*4.
          write(*,10) niter,pi(j)
10        format('Number of trials is: 'i5,'  estimate of pi is:',f8.5)
       end do


Last edited by knudfl; 04-17-2012 at 05:37 PM.
1 members found this post helpful.


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
compilation problem rania kamal Linux - Newbie 4 10-08-2008 02:06 PM
compilation problem rania kamal Linux - General 1 09-28-2008 02:57 AM
compilation problem shariefbe Linux - Software 6 08-18-2008 10:12 AM
compilation problem girish_hilage AIX 3 05-31-2006 09:01 AM
C++ Compilation problem with G++ nelnel Programming 6 07-06-2005 10:58 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:43 PM.

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