Coder Social home page Coder Social logo

sebastiandyrda / guide_vscode-fortran Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jhenneberg/guide_vscode-fortran

0.0 0.0 0.0 16 KB

A comprehensive guide on how to set up a complete development environment for Fortran in Visual Studio Code.

Fortran 100.00%

guide_vscode-fortran's Introduction

Introduction

Fortran is not well supported by a lot of IDEs. Microsoft Visual Studio has syntax highlighting but missing a lot of great features, when it comes to auto completion, signature help, find and peek references. Visual Studio Code in comparison has some great extensions and is running on MacOs, Linux and Windows.

This small Guide should help you to setup a full development environment for Fortran.

Visual Studio Code

Settings

If you are working with Fortran in the fixed-column format it is useful to setup rulers at the relevant columns. Add this to your settings.json:

"[fortran_fixed-form]": {
    "editor.rulers": [
        6,
        73
    ]
},

Visual Studio Code Extensions

There are some extensions that are very useful. Modern Fortran can be used for syntax highlighting and snippets. For features like Signature help or GoTo/Peek definition and much more FORTRAN IntelliSense should be installed. If you also want to debug, you have to download the extension Fortran Breakpoint Support.

Modern Fortran

Overview

Settings

Basic symbol functionality or hover information is also provided by Modern Fortran. Using Modern Fortran and FORTRAN IntelliSense simultaneously those should be deactivated in your settings.json:

"fortran.provideCompletion": false,
"fortran.provideSymbols": false,
"fortran.provideHover": false,

FORTRAN IntelliSense

Overview

This Extension needs the fortran-language-server to operate because it is just an interface for the fortran-language-server which can be used by different IDEs. It is written in python

Requirements

  1. Install python
  2. Install pip
  3. Install fortran-Language-server

Settings

To setup the fortran-language-server a file named .fortls is needed in your workspace in Visual Studio Code. It is written in JSON. Example .fortls:

{
  "mod_dirs": [
    "src",
    "ins"
  ],
  "excl_paths": ["src/Debug", "src/Release"],
  "excl_suffixes": [".u2d", ".vfproj", ".sln", ".txt"],
  "lowercase_intrinsics": false,
  "debug_log": false
}

Fortran Breakpoint Support

  • Description:

Add breakpoint support for fortran [https://github.com/ekibun/FortranBreaker]

Build & Debug

In general you have to define a tasks.json for the build and link process and a launch.json to start to debug.

Also have a look at: https://code.visualstudio.com/docs/editor/debugging

Install compiler

  • Windows: gfortran via MinGW for example
  • Linux: sudo apt-get install gfortran, sudo pacman -S gcc-fortran
  • OSX:

Create launch.json:

{
  "version": "2.0.0",
  "configurations": [
    {
      "name": "Debug Fortran & build",
      "type": "cppdbg",
      "request": "launch",
      "targetArchitecture": "x86",
      "program": "${workspaceRoot}\\${fileBasenameNoExtension}.exe",
      "miDebuggerPath": "gdb.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceRoot}",
      "externalConsole": true,
      "preLaunchTask": "build_gfortran"
    }
  ]
}

Create tasks.json

The gfortran compiler should be accessible via the command line.

Create tasks.json:

{
  "version": "2.0.0",
  "_runner": "terminal",
  "tasks":[
    {
      "label": "build_gfortran",
      "type": "shell",
      "windows": {
        "command": "gfortran"
      },
      "linux": {
        "command": "gfortran"
      },
      "osx": {
        "command": "gfortran"
      },
      "args": [
        "-g",
        "${file}",
        "-o",
        "${workspaceRoot}\\${fileBasenameNoExtension}.exe"
      ]
    }
  ],
}

Debugging

Click on the debug symbol in Visual Studio Code, choose the debug configuration and press start.

guide_vscode-fortran's People

Contributors

jhenneberg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.