{ "info": { "author": "Francesc Verdugo", "author_email": "fverdugo@cimne.upc.edu", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: MacOS", "Operating System :: POSIX :: Linux", "Programming Language :: Fortran", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# jin2for - Generate FORTRAN source files from jinja2 templates\n\n[![pipeline status](https://gitlab.com/fverdugo/jin2for/badges/master/pipeline.svg)](https://gitlab.com/fverdugo/jin2for/commits/master)\n[![coverage report](https://gitlab.com/fverdugo/jin2for/badges/master/coverage.svg)](https://gitlab.com/fverdugo/jin2for/commits/master)\n[![coverage report](https://img.shields.io/pypi/pyversions/jin2for.svg)](https://pypi.org/project/jin2for/)\n[![coverage report](https://img.shields.io/pypi/v/jin2for.svg)](https://pypi.org/project/jin2for/)\n\n# Why\n\nThe FORTRAN programing language has not a built-in templating engine like C++ does.\nIn concequence, it is not unusual to end-up needing to write code like this one\n\n```fortran\nfunction sum_i2(a,b) result (c)\n implicit none\n integer(2), intent(in) :: a\n integer(2), intent(in) :: b\n integer(2) :: c\n c = a + b\nend function\n\nfunction sum_i4(a,b) result (c)\n implicit none\n integer(4), intent(in) :: a\n integer(4), intent(in) :: b\n integer(4) :: c\n c = a + b\nend function\n\nfunction sum_i8(a,b) result (c)\n implicit none\n integer(8), intent(in) :: a\n integer(8), intent(in) :: b\n integer(8) :: c\n c = a + b\nend function\n```\n\nThe standard approach to circumvent code repetition is to use pre-processor directives.\nHowever, the functionality of the preprocessor is quite limited and this approach often\nleads to criptic code that is difficult to read.\n\nThe goal of `jin2for` is to facilitate the usage of [jinja2](http://jinja.pocoo.org/) as a more flexible preprocessor in FORTRAN projects.\n[jinja2](http://jinja.pocoo.org/) is a mature, powerful, and flexible templeting engine that allows to write templates like this one:\n\n``` fortran\n{% for ip in [2, 4, 8] %}\nfunction sum_i{{ip}}(a,b) result (c)\n implicit none\n integer({{ip}}), intent(in) :: a\n integer({{ip}}), intent(in) :: b\n integer({{ip}}) :: c\n c = a + b\nend function\n{% endfor %}\n```\n\nIf you store this templated code in a file, say `foo.t90`, and compile it with `jin2for`\n\n```bash\n$ jin2for foo.t90\n```\nyou will obtain a file `foo.f90` that contains piece of FORTRAN code shown at the beginning of this README file.\nInternally, `jin2for` uses the [jinja2](http://jinja.pocoo.org/) engine to render the templates. So, any valid [jinja2](http://jinja.pocoo.org/) template can be processed in this way.\n\n## jin2for is environment aware\n\n`jin2for` predefines a number of useful python objects that can be used as template parameters.\n\nFor instance, if we want to generate the previous `sum` function for all the integer\ntypes available in the installed `gfortran` compiler, we can use the predefined `integer_types` object. \nCreate a file `sum_ints.t90` containing this template:\n\n``` fortran\n{% for t in integer_types %}\nfunction sum_{{t.alias}}(a,b) result (c)\n implicit none\n {{t.decl}}, intent(in) :: a\n {{t.decl}}, intent(in) :: b\n {{t.decl}} :: c\n c = a + b\nend function\n{% endfor %}\n```\n\nand compile it with\n\n```bash\n$ jin2for --generate-for gfortran sum_ints.t90\n```\n\n`jin2for` will find out for you which are the supported integer kinds of the installed `gfortran` compiler\nand render the template only for those kinds.\n\n## Installation\n\n`jin2for` is a command line application written in Python 3 and distributed via [pypi.org](https://pypi.org/project/jin2for/).\n\nIt can be installed using pip:\n\n```bash\n$ pip install jin2for\n```\n\nIf you obtain any installation error, make sure that you are using Python 3, e.g.,\n\n```bash\n$ python3 -m pip install jin2for\n```\n\nThe latest development version can be installed manually from soruce:\n\n```bash\n$ git clone https://gitlab.com/fverdugo/jin2for\n$ cd jin2for\n$ python3 setup.py test # optional\n$ python3 setup.py install\n```\n\n## Usage\n\n### Basic usage\n\nThe basic command line interface (CLI) ressembles to the one of the GNU and Intel compilers. For instance, \n\n```bash\n$ jin2for file1.t90 file2.t90\n```\nwill \"compile\" (i.e., render) the [jinja2](http://jinja.pocoo.org/) template files `file1.t90` and `file2.t90` into the FORTRAN source files `file1.f90` and `file2.f90`.\nBy default, `jin2for` will replace the extension of the input files to `.f90` to generate the output file names.\n\nThe files `file1.t90` and `file2.t90` are allowed to include or import some other [jinja2](http://jinja.pocoo.org/) templates containing, e.g., macros or definitions.\nIf these included template files are located in a folder,\nnamely `folder/for/included/templates`, different from the current working directory, `jin2for` has to be informed with the `-I` flag:\n\n```bash\n$ jin2for -I folder/for/included/templates file1.t90 file2.t90\n```\n\n### More advanced usage\n\nSee documentation\n\n## Documentation\n\nFor the template syntax, see the official [jinja2 documentation](http://jinja.pocoo.org/).\n\nFor the full CLI reference:\n\n```bash\n$ jin2for -h\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.com/fverdugo/jin2for", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "jin2for", "package_url": "https://pypi.org/project/jin2for/", "platform": "", "project_url": "https://pypi.org/project/jin2for/", "project_urls": { "Homepage": "https://gitlab.com/fverdugo/jin2for" }, "release_url": "https://pypi.org/project/jin2for/0.1.0/", "requires_dist": [ "argparse", "jinja2" ], "requires_python": "", "summary": "A jinja2-based template engine for FORTRAN projects", "version": "0.1.0" }, "last_serial": 4920876, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a4dfafab3efa470d8fd86b8d15e984b8", "sha256": "4a9be0d6f69ebef449bf12cd6d53a95fe97a5ecdc04f334048c007730edbbcc8" }, "downloads": -1, "filename": "jin2for-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a4dfafab3efa470d8fd86b8d15e984b8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17177, "upload_time": "2019-03-09T09:27:27", "url": "https://files.pythonhosted.org/packages/3c/d5/48403612edff5c7902dedd6e2175fa795b512bb93ebbef72096d949166ed/jin2for-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4584e283065dc68ffa5f786d8d856ae2", "sha256": "03742d13471d5ba64313287dc8c200acec23f884784cb58b1ea8778f1c42ed3b" }, "downloads": -1, "filename": "jin2for-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4584e283065dc68ffa5f786d8d856ae2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4142, "upload_time": "2019-03-09T09:27:30", "url": "https://files.pythonhosted.org/packages/7a/fc/88f291c1cdd4bdf3d8dec2affe678f8089f4fcd9bc375b4fcd89bace1408/jin2for-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "9c81732e596d16a15c804ffca6ac513e", "sha256": "97eeed2bcf8ffa68c33a124457705139207bf981691b43f8732b1cd8a804fed9" }, "downloads": -1, "filename": "jin2for-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9c81732e596d16a15c804ffca6ac513e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19091, "upload_time": "2019-03-10T09:35:02", "url": "https://files.pythonhosted.org/packages/7c/3e/f2dedcec0e5e64d2d1889b0b69af259050d184a7e1595f04d36e0314fc2e/jin2for-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5435b12ae82ebf21d69f0237b3d25028", "sha256": "481814882980452ac09d8ac41d2271ad2b3369b222faddb09a47e8b1ffea201e" }, "downloads": -1, "filename": "jin2for-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5435b12ae82ebf21d69f0237b3d25028", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6104, "upload_time": "2019-03-10T09:35:04", "url": "https://files.pythonhosted.org/packages/f4/c8/4859fbfc32cac39a14cab6ab1fb6e76b3e11ce3ce7958d30eead9b8adbc1/jin2for-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9c81732e596d16a15c804ffca6ac513e", "sha256": "97eeed2bcf8ffa68c33a124457705139207bf981691b43f8732b1cd8a804fed9" }, "downloads": -1, "filename": "jin2for-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9c81732e596d16a15c804ffca6ac513e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19091, "upload_time": "2019-03-10T09:35:02", "url": "https://files.pythonhosted.org/packages/7c/3e/f2dedcec0e5e64d2d1889b0b69af259050d184a7e1595f04d36e0314fc2e/jin2for-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5435b12ae82ebf21d69f0237b3d25028", "sha256": "481814882980452ac09d8ac41d2271ad2b3369b222faddb09a47e8b1ffea201e" }, "downloads": -1, "filename": "jin2for-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5435b12ae82ebf21d69f0237b3d25028", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6104, "upload_time": "2019-03-10T09:35:04", "url": "https://files.pythonhosted.org/packages/f4/c8/4859fbfc32cac39a14cab6ab1fb6e76b3e11ce3ce7958d30eead9b8adbc1/jin2for-0.1.0.tar.gz" } ] }