{"id":21934950,"url":"https://github.com/tueda/paramcard","last_synced_at":"2026-02-19T01:03:55.524Z","repository":{"id":65380953,"uuid":"432518071","full_name":"tueda/paramcard","owner":"tueda","description":"Fortran's command-line parameter input made simple.","archived":false,"fork":false,"pushed_at":"2026-01-26T07:40:22.000Z","size":104,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-26T21:52:18.751Z","etag":null,"topics":["command-line","fortran","fortran-library","fortran2008"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tueda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-27T16:59:43.000Z","updated_at":"2026-01-26T07:40:20.000Z","dependencies_parsed_at":"2023-12-28T03:26:52.710Z","dependency_job_id":"df9381c1-09c4-4fc8-b78a-023cc1dd76c0","html_url":"https://github.com/tueda/paramcard","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/tueda/paramcard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tueda%2Fparamcard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tueda%2Fparamcard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tueda%2Fparamcard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tueda%2Fparamcard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tueda","download_url":"https://codeload.github.com/tueda/paramcard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tueda%2Fparamcard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"ssl_error","status_checked_at":"2026-02-19T00:59:36.936Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["command-line","fortran","fortran-library","fortran2008"],"created_at":"2024-11-29T00:17:49.146Z","updated_at":"2026-02-19T01:03:55.490Z","avatar_url":"https://github.com/tueda.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# paramcard\n\n[![Test](https://github.com/tueda/paramcard/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/tueda/paramcard/actions/workflows/test.yml?query=branch:main)\n[![codecov](https://codecov.io/gh/tueda/paramcard/branch/main/graph/badge.svg)](https://codecov.io/gh/tueda/paramcard)\n\nFortran's command-line parameter input made simple.\n\nThis Fortran library provides a simple framework to handle input parameters\ngiven by command-line arguments, like `./a.out a=1 dt=0.01 method=rk45`.\nThese parameters can also be read from specified input files as `./a.out input.txt`.\n\n\n## Example\n\n```fortran\nprogram demo\n    use, intrinsic :: iso_fortran_env, only: dp =\u003e real64\n    use paramcard, only: paramcard_get, paramcard_summary\n    implicit none\n    integer :: a, b\n    real(dp) :: x, y\n    character(:), allocatable :: msg\n\n    call paramcard_get('a', a, 1)\n    call paramcard_get('b', b, 2)\n    call paramcard_get('x', x, 0.3_dp)\n    call paramcard_get('y', y, 0.4_dp)\n    call paramcard_get('msg', msg, '')\n    call paramcard_summary\n\n    print *, 'a + b = ', a + b\n    print *, 'x + y = ', x + y\n    if (msg /= '') print *, msg\nend program demo\n```\nThe `paramcard_get` subroutine takes 3 arguments: `name`, `variable` and `default_value`.\nThey specify the parameter name, the destination variable to store the parameter value\nand the (optional) default value, respectively.\nThe `paramcard_summary` subroutine prints the summary of the input parameters and\nchecks if there are any given parameters that are actually unused in the program.\nThe compiled program will accept command-line arguments like\n`./demo a=101 x=0.6 msg='Hello, World!'`, where parameters are overridden in the form of\n`name=value`. Parameter names are case- and space-insensitive.\nIt is also possible to pass parameters via input text files like\n`./demo input.txt`.\nAn example of an input file is as follows:\n```ini\n# Comment lines start with \"#\" or \"!\".\na = 101\nx = 0.6\nmsg = Hello, World!\n```\nThe output of the above example looks as follows:\n```\na = 101 (default: 1)\nb = 2\nx = 0.59999999999999998 (default: 0.29999999999999999)\ny = 0.40000000000000002\nmsg = Hello, World! (default: )\n a + b =          103\n x + y =    1.0000000000000000\n Hello, World!\n```\n\n\n## Getting started\n\nThe library works with Fortran 2008 compliant compilers.\nBecause this is a single-file library, one can just copy a MIT-licensed file\n[`paramcard.f90`](https://raw.githubusercontent.com/tueda/paramcard/v0.2.3/src/paramcard.f90)\nto one's project:\n```bash\ncurl -O https://raw.githubusercontent.com/tueda/paramcard/v0.2.3/src/paramcard.f90\n```\nAlternatively, one can use this repository as a submodule of one's Git repository:\n```bash\ngit submodule add https://github.com/tueda/paramcard.git extern/paramcard\ngit -C extern/paramcard checkout v0.2.3\n```\nwhich makes the library source available at `extern/paramcard/src/paramcard.f90`.\n\nIntegration with [`fpm`](https://github.com/fortran-lang/fpm) (v0.8.0+) is also available:\n```toml\n[dependencies]\nparamcard = { git = \"https://github.com/tueda/paramcard\", tag = \"v0.2.3\" }\n```\n\n[CMake](https://cmake.org/) (v3.14+) integration with the [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module:\n```cmake\ninclude(FetchContent)\n```\n```cmake\nFetchContent_Declare(\n  paramcard\n  GIT_REPOSITORY https://github.com/tueda/paramcard.git\n  GIT_TAG v0.2.3\n)\nFetchContent_MakeAvailable(paramcard)\nif(paramcard_POPULATED)\n  add_library(paramcard STATIC ${paramcard_SOURCE_DIR}/src/paramcard.f90)\nendif()\n```\n```cmake\ntarget_link_libraries(main PRIVATE paramcard)\n```\n\nIntegration with [`CPM.cmake`](https://github.com/cpm-cmake/CPM.cmake):\n```cmake\nCPMAddPackage(\n  NAME paramcard\n  GIT_REPOSITORY https://github.com/tueda/paramcard\n  VERSION 0.2.3\n  DOWNLOAD_ONLY YES\n)\nif (paramcard_ADDED)\n  add_library(paramcard STATIC ${paramcard_SOURCE_DIR}/src/paramcard.f90)\nendif()\n```\n```cmake\ntarget_link_libraries(main PRIVATE paramcard)\n```\n\n## API\n\nIn the `paramcard` module, the following procedures are available.\n\n### `subroutine paramcard_get(name, variable [, default_value])`\nRead a parameter specified by `name` into `variable`.\n```fortran\ncharacter(len=*), intent(in) :: name\ncharacter(len=:), intent(out), allocatable :: variable\ncharacter(len=*), intent(in), optional :: default_value\n```\n```fortran\ncharacter(len=*), intent(in) :: name\ninteger(kind=int8/int16/int32/int64), intent(out) :: variable\ninteger(kind=int8/int16/int32/int64), intent(in), optional :: default_value\n```\n```fortran\ncharacter(len=*), intent(in) :: name\nreal(kind=real32/real64), intent(out) :: variable\nreal(kind=real32/real64), intent(in), optional :: default_value\n```\n- `name`: the name of the parameter.\n- `variable`: the variable to store the parameter value.\n- `default_value`: the value to be used when the specified parameter is not defined from the input.\nIf the default value is not given, then an undefined parameter leads to an error.\n\n### `subroutine paramcard_set(name, value [, consumed])`\nSet (overwrite) a parameter specified by `name` as `value` for later use.\n```fortran\ncharacter(len=*), intent(in) :: name\ncharacter(len=*), intent(in) :: value\nlogical, intent(in), optional :: consumed\n```\n```fortran\ncharacter(len=*), intent(in) :: name\ninteger(kind=int8/int16/int32/int64), intent(in) :: value\nlogical, intent(in), optional :: consumed\n```\n```fortran\ncharacter(len=*), intent(in) :: name\ninteger(kind=real32/real64), intent(in) :: value\nlogical, intent(in), optional :: consumed\n```\n- `name`: the name of the parameter.\n- `value`: the value to be associated with the parameter.\n- `consumed`: whether this parameter should be considered *consumed (used)* or not. (Default: `.true.`)\n\n### `subroutine paramcard_parse(str)`\nSet a parameter by parsing a string containing `NAME = VALUE`.\n```fortran\ncharacter(len=*), intent(in) :: str\n```\n- `str`: the string to be parsed.\n\n### `subroutine paramcard_summary([options...])`\nPrint the summary of input parameters.\n```fortran\ninteger, optional, intent(in) :: unit\nlogical, optional, intent(in) :: only_changed\nlogical, optional, intent(in) :: show_default\nlogical, optional, intent(in) :: check_unused\ncharacter(len=*), optional, intent(in) :: prefix\n```\n- `unit`: the unit number for the output.\n  (Default: `output_unit`)\n- `only_changed`: print only parameters that are changed from those default values.\n  (Default: `.false.`)\n- `show_default`: print the default values.\n  (Default: `.true.`)\n- `check_unused`: check unused (not-*consumed*) parameters and raise an error if found.\n  (Default: `.true.`)\n- `prefix`: the prefix to each line in the output.\n  (Default: `''`)\n\n### `function paramcard_format(fmt)`\nPerform a string formatting (interpolation) operation.\n```fortran\ncharacter(len=*), intent(in) :: fmt\ncharacter(len=:), allocatable :: result\n```\n- `fmt`: the format to be used.\n  Parameters are substituted by braces, for example, `'I have {n} apples.'`\n- Return `result`: the formatted string.\n\n### `subroutine paramcard_output([options...])`\nWrite output to a file with a format.\nThe output file name and the format are specified by parameters.\nThe output is constructed by using `paramcard_format`.\nThis subroutine does nothing if the file name or the format is empty.\n```fortran\ncharacter(len=*), intent(in), optional :: file_param\ncharacter(len=*), intent(in), optional :: format_param\n```\n- `file_param`: the parameter to specify the output file.\n  (Default: `'output_file'`)\n- `format_param`: the parameter to specify the output format.\n  (Default: `'output_format'`)\n\n\n## Old-fashioned API\n\nWe also provide old-fashioned procedures (with some limitations) that can be used without using the module.\n\n```fortran\n      PROGRAM DEMO77\n      INTEGER A, B\n      DOUBLE PRECISION X, Y\n      CHARACTER*40 MSG\nC\n      CALL PARAMCARD_GET_I('A', A, 1)\n      CALL PARAMCARD_GET_I('B', B, 2)\n      CALL PARAMCARD_GET_D('X', X, 0.3D0)\n      CALL PARAMCARD_GET_D('Y', Y, 0.4D0)\n      CALL PARAMCARD_GET_S('MSG', MSG, '')\n      CALL PARAMCARD_SUMMARY\nC\n      WRITE (*,*) 'A + B = ', A + B\n      WRITE (*,*) 'X + Y = ', X + Y\n      IF (MSG .NE. '') WRITE (*,*) MSG\nC\n      STOP\n      END\n```\n\n### `subroutine paramcard_get_s(name, variable, default_value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ncharacter(len=*), intent(out) :: variable\ncharacter(len=*), intent(in) :: default_value\n```\n\n### `subroutine paramcard_get_i(name, variable, default_value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ninteger, intent(out) :: variable\ninteger, intent(in) :: default_value\n```\n\n### `subroutine paramcard_get_r(name, variable, default_value)`\n```fortran\ncharacter(len=*), intent(in) :: name\nreal, intent(out) :: variable\nreal, intent(in) :: default_value\n```\n\n### `subroutine paramcard_get_d(name, variable, default_value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ndouble precision, intent(out) :: variable\ndouble precision, intent(in) :: default_value\n```\n\n### `subroutine paramcard_set_s(name, value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ncharacter(len=*), intent(in) :: value\n```\n\n### `subroutine paramcard_set_i(name, value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ninteger, intent(in) :: value\n```\n\n### `subroutine paramcard_set_r(name, value)`\n```fortran\ncharacter(len=*), intent(in) :: name\nreal, intent(in) :: value\n```\n\n### `subroutine paramcard_set_d(name, value)`\n```fortran\ncharacter(len=*), intent(in) :: name\ndouble precision, intent(in) :: value\n```\n\n### `subroutine paramcard_summary()`\n\n### `subroutine paramcard_output(file_param, format_param)`\n```fortran\ncharacter(len=*), intent(in) :: file_param\ncharacter(len=*), intent(in) :: format_param\n```\n\n\n## Development\n\n```bash\nbrew install ford gcc git lcov pre-commit python fortran-lang/fortran/fpm\n```\n\n```bash\npre-commit install\n```\n\n```bash\npre-commit run --all-file               # linter, formatter and preprocessor\nfpm test                                # testing\nGCOV=gcov-12 ./scripts/gen-coverage.sh  # coverage report\nford API-doc-FORD-file.md               # documentation\n```\n\n\n## License\n\n[MIT](https://github.com/tueda/paramcard/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftueda%2Fparamcard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftueda%2Fparamcard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftueda%2Fparamcard/lists"}