This is how to run fortran on mac. This is a public repository for students at DTU to implement Fortran on macOs. Mainly used in the course FEM. Disclaimer, I take no responibility for malware or any other faults to your computer. The guide works for M chips aswell.
STEPS for making fortran using MacOS.
-
I reccomend using VS code and download fortran extension. https://code.visualstudio.com/ <--- VS code https://marketplace.visualstudio.com/items?itemName=Gimly81.fortran <- extension
-
Download homebrew, follow this guide: https://brew.sh/
-
Use homebrew to install fortran, follow this guide: https://formulae.brew.sh/formula/gcc
-
When thats done download or fork this repository, guide to how: https://docs.github.com/en/get-started/quickstart/fork-a-repo
-
To run the fortran code use the key-shortcuts command + shift + B, needs to be done a couple of times. NB! if you get, Fatal Error: Cannot open module file 'filename' for reading at (1): No such file or directory. or something similar. Just try command + shift + B a couple of more times. Fortran needs to create some .mod files to work.
-
In the terminal you should se "Hello World, fortran on mac".
If you see the print Hello World, you have sucsessfully installed fortran on mac. For DTU students
- Unzip the code given by lecturer
- import it into the Day5basisCode folder.
- go into .vscode folder then into the tasks.json file.
- Uncomment lines 17-30
- delete lines 8-16
- delete the hello.f90 and hello_program files from the folder.
- command + shift + b, follow instructions in terminal :)
TIPS: If you encour error copy your code and error message to chatgpt ;)