{"id":18847694,"url":"https://github.com/aradi/fypp","last_synced_at":"2025-04-04T11:12:34.313Z","repository":{"id":37248838,"uuid":"57034024","full_name":"aradi/fypp","owner":"aradi","description":"Python powered Fortran preprocessor","archived":false,"fork":false,"pushed_at":"2024-07-06T01:28:52.000Z","size":338,"stargazers_count":193,"open_issues_count":19,"forks_count":30,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-28T10:07:05.806Z","etag":null,"topics":["fortran","metaprogramming","preprocessor"],"latest_commit_sha":null,"homepage":"http://fypp.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aradi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-25T10:46:52.000Z","updated_at":"2025-02-17T14:25:15.000Z","dependencies_parsed_at":"2022-08-02T12:07:03.187Z","dependency_job_id":"a6240085-5c01-44ae-864f-29e4ee14c22d","html_url":"https://github.com/aradi/fypp","commit_stats":{"total_commits":250,"total_committers":8,"mean_commits":31.25,"dds":"0.21199999999999997","last_synced_commit":"ead4ade2fad9674ca9f4ff62f22fac83bec69ac9"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aradi%2Ffypp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aradi%2Ffypp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aradi%2Ffypp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aradi%2Ffypp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aradi","download_url":"https://codeload.github.com/aradi/fypp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","metaprogramming","preprocessor"],"created_at":"2024-11-08T03:09:14.643Z","updated_at":"2025-04-04T11:12:34.295Z","avatar_url":"https://github.com/aradi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"*********************************************\nFypp — Python powered Fortran metaprogramming\n*********************************************\n\n.. image:: https://travis-ci.org/aradi/fypp.svg?branch=develop\n           :target: https://travis-ci.org/aradi/fypp\n\nFypp is a Python powered preprocessor. It can be used for any programming\nlanguages but its primary aim is to offer a Fortran preprocessor, which helps to\nextend Fortran with condititional compiling and template metaprogramming\ncapabilities. Instead of introducing its own expression syntax, it uses Python\nexpressions in its preprocessor directives, offering the consistency and\nversatility of Python when formulating metaprogramming tasks. It puts strong\nemphasis on robustness and on neat integration into developing toolchains.\n\nThe project is `hosted on github \u003chttps://github.com/aradi/fypp\u003e`_.\n\n`Detailed DOCUMENTATION \u003chttp://fypp.readthedocs.org\u003e`_ is available on\n`readthedocs.org \u003chttp://fypp.readthedocs.org\u003e`_.\n\nFypp is released under the *BSD 2-clause license*.\n\n\nMain features\n=============\n\n* Definition, evaluation and removal of variables::\n\n    #:if DEBUG \u003e 0\n      print *, \"Some debug information\"\n    #:endif\n\n    #:set LOGLEVEL = 2\n    print *, \"LOGLEVEL: ${LOGLEVEL}$\"\n\n    #:del LOGLEVEL\n\n* Macro definitions and macro calls::\n\n    #:def ASSERT(cond)\n      #:if DEBUG \u003e 0\n        if (.not. ${cond}$) then\n          print *, \"Assert failed in file ${_FILE_}$, line ${_LINE_}$\"\n          error stop\n        end if\n      #:endif\n    #:enddef ASSERT\n\n    ! Invoked via direct call (argument needs no quotation)\n    @:ASSERT(size(myArray) \u003e 0)\n\n    ! Invoked as Python expression (argument needs quotation)\n    $:ASSERT('size(myArray) \u003e 0')\n\n* Conditional output::\n\n    program test\n    #:if defined('WITH_MPI')\n      use mpi\n    #:elif defined('WITH_OPENMP')\n      use openmp\n    #:else\n      use serial\n    #:endif\n\n* Iterated output (e.g. for generating Fortran templates)::\n\n    interface myfunc\n    #:for dtype in ['real', 'dreal', 'complex', 'dcomplex']\n      module procedure myfunc_${dtype}$\n    #:endfor\n    end interface myfunc\n\n* Inline directives::\n\n    logical, parameter :: hasMpi = #{if defined('MPI')}# .true. #{else}# .false. #{endif}#\n\n* Insertion of arbitrary Python expressions::\n\n    character(*), parameter :: comp_date = \"${time.strftime('%Y-%m-%d')}$\"\n\n* Inclusion of files during preprocessing::\n\n    #:include \"macrodefs.fypp\"\n\n* Using Fortran-style continutation lines in preprocessor directives::\n\n    #:if var1 \u003e var2 \u0026\n        \u0026 or var2 \u003e var4\n      print *, \"Doing something here\"\n    #:endif\n\n* Passing (unquoted) multiline string arguments to callables::\n\n    #! Callable needs only string argument\n    #:def DEBUG_CODE(code)\n      #:if DEBUG \u003e 0\n        $:code\n      #:endif\n    #:enddef DEBUG_CODE\n\n    #! Pass code block as first positional argument\n    #:block DEBUG_CODE\n      if (size(array) \u003e 100) then\n        print *, \"DEBUG: spuriously large array\"\n      end if\n    #:endblock DEBUG_CODE\n\n    #! Callable needs also non-string argument types\n    #:def REPEAT_CODE(code, repeat)\n      #:for ind in range(repeat)\n        $:code\n      #:endfor\n    #:enddef REPEAT_CODE\n\n    #! Pass code block as positional argument and 3 as keyword argument \"repeat\"\n    #:block REPEAT_CODE(repeat=3)\n    this will be repeated 3 times\n    #:endblock REPEAT_CODE\n\n* Preprocessor comments::\n\n    #! This will not show up in the output\n    #! Also the newline characters at the end of the lines will be suppressed\n\n* Suppressing the preprocessor output in selected regions::\n\n    #! Definitions are read, but no output (e.g. newlines) will be produced\n    #:mute\n    #:include \"macrodefs.fypp\"\n    #:endmute\n\n* Explicit request for stopping the preprocessor::\n\n    #:if DEBUGLEVEL \u003c 0\n      #:stop 'Negative debug level not allowed!'\n    #:endif\n\n* Easy check for macro parameter sanity::\n\n    #:def mymacro(RANK)\n      #! Macro only works for RANK 1 and above\n      #:assert RANK \u003e 0\n      :\n    #:enddef mymacro\n\n* Line numbering directives in output::\n\n    program test\n    #:if defined('MPI')\n    use mpi\n    #:endif\n    :\n\n  transformed to ::\n\n    # 1 \"test.fypp\" 1\n    program test\n    # 3 \"test.fypp\"\n    use mpi\n    # 5 \"test.fypp\"\n    :\n\n  when variable ``MPI`` is defined and Fypp was instructed to generate line\n  markers.\n\n* Automatic folding of generated lines exceeding line length limit\n\n\nInstalling\n==========\n\nFypp needs a working Python 3 interpreter (Python 3.5 or above).\n\nWhen you install Fypp, you obtain the command line tool ``fypp`` and the Python\nmodule ``fypp.py``. Latter you can import if you want to access the\nfunctionality of Fypp directly from within your Python scripts.\n\n\nInstalling via conda\n--------------------\n\nThe last stable release of Fypp can be easily installed as conda package by\nissuing ::\n\n  conda install -c conda-forge fypp\n\n\nInstalling via pip\n------------------\n\nYou can also use Pythons command line installer ``pip`` in order to download the\nstable release from the `Fypp page on PyPI \u003chttp://pypi.python.org/pypi/fypp\u003e`_\nand install it on your system.\n\nIf you want to install Fypp into the module system of the active Python 3\ninterpreter (typically the case when you are using a Python virtual\nenvironment), issue ::\n\n  pip3 install fypp\n\nAlternatively, you can install Fypp into the user space (under `~/.local`) with\n::\n\n  pip3 install --user fypp\n\n\nInstalling via MSYS2 pacman\n---------------------------\n\nOn Windows you can use the `MSYS2 toolchain \u003chttps://www.msys2.org/\u003e`_ to install\nFypp in a MinGW terminal. To install Fypp use::\n\n  pacman -S mingw-w64-x86_64-python-fypp\n\nMake sure the selected architecture is matching your current MinGW terminal.\nFor all supporting MinGW architectures visit check the package index\n`here \u003chttps://packages.msys2.org/base/mingw-w64-python-fypp\u003e`_.\n\n\nManual install\n--------------\n\nFor a manual install, you can download the source code of the **stable**\nreleases from the `Fypp project website\n\u003chttps://github.com/aradi/fypp/releases\u003e`_.\n\nIf you wish to obtain the latest **development** version, clone the projects\nrepository::\n\n  git clone https://github.com/aradi/fypp.git\n\nand check out the `master` branch.\n\nThe command line tool is a single stand-alone script. You can run it directly\nfrom the source folder ::\n\n  FYPP_SOURCE_FOLDER/bin/fypp\n\nor after copying it from the `bin` folder to any location listed in your `PATH`\nenvironment variable, by just issuing ::\n\n  fypp\n\nThe python module ``fypp.py`` can be found in ``FYP_SOURCE_FOLDER/src``.\n\n\nRunning\n=======\n\nThe Fypp command line tool reads a file, preprocesses it and writes it to\nanother file, so you would typically invoke it like::\n\n  fypp source.fpp source.f90\n\nwhich would process `source.fpp` and write the result to `source.f90`.  If\ninput and output files are not specified, information is read from stdin and\nwritten to stdout.\n\nThe behavior of Fypp can be influenced with various command line options. A\nsummary of all command line options can be obtained by::\n\n  fypp -h\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faradi%2Ffypp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faradi%2Ffypp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faradi%2Ffypp/lists"}