Git Product home page Git Product logo

indentpatternfortran's Introduction

IndentPatternFortran

General indentation patterns for Fortran.

There are some IDEs in which Fortran is programmed (VS Code, Atom, Code::Blocks...), which allow to insert Fortran source code via extensions or directly. However, the basic procedure remains the same. A pattern is recognized via RegEx and indented further or less. This repository is abstract and only provides a collection of RegEx commands, which can be used further.

Example

Module

MODULE myModule
  USE myOtherModule
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: myType
  PUBLIC :: indent
  PUBLIC :: indentOneLineKeywords

  TYPE :: myType
    INTEGER :: myInt = 0
  CONTAINS
    PROCEDURE, PUBLIC :: myTypeSub
  END TYPE

  INTERFACE indent
    PROCEDURE indent
    PROCEDURE indentIfThenElse
  END INTERFACE
CONTAINS
  SUBROUTINE myTypeSub(this)
    IMPLICIT NONE

    CLASS(this), INTENT(IN) :: myType

    myType%myInt = 10
  END SUBROUTINE myTypeSub

  SUBROUTINE indentIfThenElse(i, j)
    IMPLICIT NONE

    INTEGER, INTENT(IN) :: i
    INTEGER, INTENT(INOUT) :: j

    IF (i > 10) THEN
      j = i
    ELSE IF (i < 6) THEN
      j = 2
    ELSE
      j = -1
    END IF
  END SUBROUTINE indentIfThenElse

  SUBROUTINE indentSelectCase(i, j)
    IMPLICIT NONE

    INTEGER, INTENT(IN) :: i
    INTEGER, INTENT(INOUT) :: j

    SELECT CASE (i)
    CASE (10)
      j = 2 * i
    CASE (6)
      j = i
    CASE DEFAULT
      j = -1
    END SELECT
  END SUBROUTINE indentSelectCase

  SUBROUTINE indentOneLineKeywords(i, j)
    IMPLICIT NONE

    INTEGER, INTENT(IN) :: i(:)
    INTEGER, INTENT(INOUT) :: j(:)

    IF (ALL(i > 10)) j = i

    WHERE (i > 10) &
      j = i

    IF (SIZE(j) >= 4) &
      FORALL (INTEGER :: k = 1:4) &
        j(k) = 1
  END SUBROUTINE indentOneLineKeywords
END MODULE myModule

indentpatternfortran's People

Contributors

jhenneberg avatar

Stargazers

 avatar

Watchers

 avatar  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.