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

  • Context: Fortran 
  • Thread starter Thread starter Nicolaus
  • Start date Start date
  • Tags Tags
    Gfortran Mac
Click For Summary
SUMMARY

The issue with gfortran on Mac continuously printing 'y' instead of 'Hello' is due to a naming conflict with the Unix command "test." When the program is named "test," the shell may execute the Unix command instead of the Fortran program. To resolve this, users should rename their Fortran program to something unique, such as "mytest." This problem is common among programmers using *nix-style systems.

PREREQUISITES
  • Familiarity with Fortran programming, specifically gfortran.
  • Understanding of Unix command line and shell behavior.
  • Basic knowledge of file naming conventions in programming.
  • Experience with Mac OS and its Unix-like environment.
NEXT STEPS
  • Learn how to use gfortran effectively for compiling and running Fortran programs.
  • Research Unix command conflicts and how to avoid them in programming.
  • Explore best practices for naming conventions in programming to prevent conflicts.
  • Investigate debugging techniques for identifying shell command issues in Mac OS.
USEFUL FOR

This discussion is beneficial for Fortran developers, Mac OS users, and programmers encountering command conflicts in Unix-like environments.

Nicolaus
Messages
73
Reaction score
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
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.
 
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:
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 7 ·
Replies
7
Views
9K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K