Configure compiler options using Gfortran on VScode

I am using VScode (the most recent version) and Gfortran (12.2.0), on Windows 11, to learn Fortran 90-2008. I have installed the extensions “Modern Fortran”, “Code Runner”, and “C/C++”, so I can compile and run my .f90 program easily with a single click, and all works fine.

However, I cannot find WHERE to declare compiler options, like “-fcheck=all -g -O0 -fbacktrace” on the extensions’ configurations, so when I click on “Run code” (on VScode), it would compile with those options by default. Could you guys help me? Thanks in advance!

Code Runner’s settings.json

1 Like

Welcome to the Discourse @steelclam.
If you are using the Modern Fortran pre-release version you don’t need Code runners to compile, run and/or debug individual Fortran files.
Open the vscode settings and add your options, to fortran.linter.extraArgs like this

"fortran.linter.extraArgs": [
    "-fdefault-real-8",
    "-fdefault-double-8",
    "-Wunused-variable",
    "-Wunused-dummy-argument"
  ]

Note: put one argument per string.
If you want to use Code Runner I would suggest you have a quick read at their settings/examples

2 Likes

Thanks a lot!! I’ll give a try and say if it works.