Why is gfortran on my mac continuously printing 'y' instead of 'Hello'?

  • Fortran
  • Thread starter Nicolaus
  • Start date
  • Tags
    Gfortran Mac
In summary, the user is having trouble running a program after downloading gfortran on their Mac. They suspect that the issue may be related to a unix command called "test" and suggest renaming the program to avoid conflicts. Another user confirms this as a common issue for programmers on *nix-style systems.
  • #1
Nicolaus
73
0
I just downloaded gfortran on my mac and I'm having an issue running the program.
For example, when I run the following using .f90,

program test
write (*,*) "Hello"
end program test

the computer, seemingly infinitely, spews out y's:
y
y
y
y
y
y
y
..
 
Technology news on Phys.org
  • #2
This is a guess, but it once caught me out on a Unix system, and the Mac OS is basically unix plus a lot of advertising hype :smile:

There is a unix command called "test" (in fact several different commands all called "test", depending what shell you are running etc). So you might not be running your program at all!

Try renaming it "mytest" or whatever.
 
  • #3
AlephZero's guess is a very solid one.

Up to my experience every programmer working on *nix-style systems sooner or later runs into this, so
"Welcome to the club, Nikolaus!" :smile:
 

Related to Why is gfortran on my mac continuously printing 'y' instead of 'Hello'?

1. How do I download gfortran on my Mac?

To download gfortran on your Mac, you can go to the official GNU Fortran website and follow the instructions for downloading and installation. Alternatively, you can use a package manager like Homebrew to install gfortran.

2. How do I compile and run a Fortran program on my Mac?

To compile and run a Fortran program on your Mac, you can use the gfortran compiler. First, navigate to the directory where your program is saved using the terminal. Then, use the command "gfortran -o output_file input_file.f90" to compile your program. Finally, use the command "./output_file" to run your program.

3. How do I check which version of gfortran I have on my Mac?

You can check which version of gfortran you have on your Mac by opening the terminal and typing "gfortran --version". This will display the version of gfortran you have installed on your system.

4. Can I use gfortran to compile and run programs written in other languages?

No, gfortran is specifically designed for compiling and running Fortran programs. It cannot be used to compile or run programs written in other languages.

5. How do I troubleshoot common errors when using gfortran on my Mac?

If you encounter errors while using gfortran on your Mac, there are a few steps you can take to troubleshoot the issue. First, make sure you have the latest version of gfortran installed. Then, check for any typos or syntax errors in your code. You can also try searching online for the specific error message you received to see if there are any known solutions. Additionally, you can consult the gfortran documentation for troubleshooting tips and techniques.

Similar threads

  • Programming and Computer Science
Replies
1
Views
629
Replies
3
Views
388
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
7
Views
580
  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
3
Replies
89
Views
4K
  • Programming and Computer Science
Replies
9
Views
880
  • Programming and Computer Science
Replies
7
Views
9K
Back
Top