{"id":18854375,"url":"https://github.com/urbanjost/m_anything","last_synced_at":"2026-02-05T04:33:46.885Z","repository":{"id":117557611,"uuid":"438957914","full_name":"urbanjost/M_anything","owner":"urbanjost","description":"Use polymorphism to allow promoting, casting and molding intrinsic types","archived":false,"fork":false,"pushed_at":"2024-11-16T01:40:37.000Z","size":2330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-23T05:13:48.712Z","etag":null,"topics":["casting","fortran","fortran-package-manager"],"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/urbanjost.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2021-12-16T11:00:40.000Z","updated_at":"2024-11-16T01:40:40.000Z","dependencies_parsed_at":"2024-11-16T00:32:28.900Z","dependency_job_id":null,"html_url":"https://github.com/urbanjost/M_anything","commit_stats":{"total_commits":45,"total_committers":1,"mean_commits":45.0,"dds":0.0,"last_synced_commit":"d46042c6f0f1977cd0e376d6fdb3043f54fda538"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/urbanjost/M_anything","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_anything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_anything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_anything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_anything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbanjost","download_url":"https://codeload.github.com/urbanjost/M_anything/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_anything/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264507300,"owners_count":23619189,"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":["casting","fortran","fortran-package-manager"],"created_at":"2024-11-08T03:48:03.635Z","updated_at":"2026-02-05T04:33:46.843Z","avatar_url":"https://github.com/urbanjost.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Name\n   M_anything(3fm) - [M_anything] procedures that use polymorphism to allow arguments of different types generically\n   (LICENSE:MIT)\n\n## Synopsis\n    use M_anything,only : anyscalar_to_string  \n    use M_anything,only : anyscalar_to_int64   \n    use M_anything,only : anyscalar_to_real    \n    use M_anything,only : anyscalar_to_real128 \n    use M_anything,only : anyscalar_to_double \n    use M_anything,only : anything_to_bytes\n    use M_anything,only : anyinteger_to_string  \n    use M_anything,only : bytes_to_anything\n    use M_anything,only : empty, assignment(=) \n\u003c!--\n![toc](docs/workaround.svg)\n--\u003e\n## Description\n\n  Generic routines are generally more efficient than casting but can generate a\n  large amount of duplicate code. These procedures show how to use casting \n  instead for input parameters. Future versions of Fortran are planned to allow\n  for templating as another alternative.\n\n    anyscalar_to_string     convert intrinsic types to a a string\n    anyscalar_to_int64      convert integer parameter of any kind to 64-bit integer\n    anyscalar_to_real       convert integer or real parameter of any kind to real\n    anyscalar_to_real128    convert integer or real parameter of any kind to real128\n    anyscalar_to_double     convert integer or real parameter of any kind to doubleprecision\n    anyinteger_to_string    convert integer parameter of any kind to string\n    anything_to_bytes       convert anything to bytes\n    empty                   create an empty array\n\n## Example\n  Sample program:\n```fortran\n      program demo_anyscalar_to_double\n      use, intrinsic :: iso_fortran_env, only : int8, int16, int32, int64\n      use, intrinsic :: iso_fortran_env, only : real32, real64, real128\n      implicit none\n         ! call same function with many scalar input types\n         write(*,*)squareall(2_int8)\n         write(*,*)squareall(2_int16)\n         write(*,*)squareall(2_int32)\n         write(*,*)squareall(2_int64)\n         write(*,*)squareall(2.0_real32)\n         write(*,*)squareall(2.0_real64)\n         write(*,*)squareall(2.0_real128)\n      contains\n\n      function squareall(invalue) result (dvalue)\n      use M_anything, only : anyscalar_to_double\n      class(*),intent(in)  :: invalue\n      doubleprecision      :: invalue_local\n      doubleprecision      :: dvalue\n         invalue_local=anyscalar_to_double(invalue)\n         dvalue=invalue_local*invalue_local\n      end function squareall\n\n      end program demo_anyscalar_to_double\n```\n    Results:\n\n```text\n        4.00000000000000\n        4.00000000000000\n        4.00000000000000\n        4.00000000000000\n        4.00000000000000\n        4.00000000000000\n        4.00000000000000\n```\n## Author\n   John S. Urban\n\n## License\n   MIT\n\n---\n![gmake](docs/images/gnu.gif)\n---\n\n## Building the Module Using make(1)\n     git clone https://github.com/urbanjost/M_anything.git\n     cd M_anything/src\n     # change Makefile if not using one of the listed compilers\n     \n     # for gfortran\n     make clean\n     make F90=gfortran gfortran\n     \n     # for ifort\n     make clean\n     make F90=ifort ifort\n\n     # REMOVE REFERENCES TO 128-BIT REALS\n     # for nvfortran\n     make clean\n     make F90=nvfortran nvfortran\n\nThis will compile the Fortran module and basic example\nprogram that exercise the routine.\n\n---\n![-](docs/images/fpm_logo.gif)\n---\n\n## Build and Test with fpm\n\n   Alternatively, download the github repository and build it with\n   fpm ( as described at [Fortran Package Manager](https://github.com/fortran-lang/fpm) )\n\n   ```bash\n        git clone https://github.com/urbanjost/M_anything.git\n        cd M_anything\n        fpm run \"*\"\n        fpm run --example \"*\"\n        fpm test\n   ```\n\n   or just list it as a dependency in your fpm.toml project file.\n\n```toml\n        [dependencies]\n        M_anything        = { git = \"https://github.com/urbanjost/M_anything.git\" }\n```\n\n---\n![docs](docs/images/docs.gif)\n---\n\n## Documentation\n\n### User\n![man-pages](docs/images/manpages.gif)\n\n   - a simple index to the man-pages in HTML form for the\n   [routines](https://urbanjost.github.io/M_anything/man3.html) \n\n   - A single page that uses javascript to combine all the HTML\n     descriptions of the man-pages is at \n     [BOOK_M_anything](https://urbanjost.github.io/M_anything/BOOK_M_anything.html).\n\n   - There are man-pages in the repository download in the docs/ directory\n     that may be installed on ULS (Unix-Like Systems).\n\n   + [manpages.zip](https://urbanjost.github.io/M_anything/manpages.zip)\n   + [manpages.tgz](https://urbanjost.github.io/M_anything/manpages.tgz)\n\n   - [CHANGELOG](docs/CHANGELOG.md) provides a history of significant changes\n\n### Developer\n   - [ford(1) output](https://urbanjost.github.io/M_anything/fpm-ford/index.html).\n   - [doxygen(1) output](https://urbanjost.github.io/M_anything/doxygen_out/html/index.html).\n   - [github action status](docs/STATUS.md) \n\u003c!--\n---\n## Pedigree\n\n---\n![-](docs/images/ref.gif)\n---\n\n## References\n\n   * [RFC-4122](https://tools.ietf.org/html/rfc4122)\n   * [FOX](http://fortranwiki.org/fortran/show/FoX)\n--\u003e\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_anything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbanjost%2Fm_anything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_anything/lists"}