I downloaded Brew, and downloaded GCC from it. I didn't know what file to use, so I went with a text editor file that I renamed FortranTest.f90
Ran it in the compiler and and got this error:
1 | {\rtf1\ansi\ansicpg1252\cocoartf2759
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:2:2:
2 | \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:2:74:
2 | \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:3:2:
3 | {\colortbl;\red255\green255\blue255;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:3:13:
3 | {\colortbl;\red255\green255\blue255;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:3:37:
3 | {\colortbl;\red255\green255\blue255;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:4:2:
4 | {\*\expandedcolortbl;;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:4:23:
4 | {\*\expandedcolortbl;;}
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:5:2:
5 | \margl1440\margr1440\vieww11520\viewh8400\viewkind0
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:6:2:
6 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:8:2:
8 | \f0\fs24 \cf0 program f90_Test\
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:9:1:
9 | \
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:11:1:
11 | \
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:12:14:
12 | print *, TEXT\
| 1
Error: Syntax error in PRINT statement at (1)
/Users/BLANK/Desktop/FortranTest.f90:13:1:
13 | \
| 1
Error: Invalid character in name at (1)
/Users/BLANK/Desktop/FortranTest.f90:14:21:
14 | end program f90_Test}
| 1
Error: Syntax error in END PROGRAM statement at (1)
The EXACT error (I copied it) please help! Tell me if I did it wrong!
The file contents were:
program f90_Test
char TEXT = "HELLO WORLD"
print *, TEXT
end program f90_Test
You have saved your file as a .rtf
document, then renamed it to .f90
. This means, your compiler received gibberish instead of Fortran code. You have to save it as plain text in the first place, or use some conversion tool. Rich Text (.rtf
) documents contain formatting instructions that tell your editor which fonts you want to use, where to bold, etc... and it is not something a Fortran compiler can understand.
To that end — TextEdit is a very bad choice for a code editor. Popular choices on Mac are nano
, vim
, emacs
, Visual Studio Code, TextMate, Sublime Text, and more. Your Mac comes with nano
and vim
preinstalled. nano
compared to vim
is like a tricycle compared to a space shuttle: both get you places, but one is much more powerful — and complicated — than the other.