{"id":18847820,"url":"https://github.com/interkosmos/fortran-nginx","last_synced_at":"2025-04-14T08:09:54.146Z","repository":{"id":139286022,"uuid":"269636735","full_name":"interkosmos/fortran-nginx","owner":"interkosmos","description":"Fortran 2003 interface bindings to nginx-link-function","archived":false,"fork":false,"pushed_at":"2020-12-15T12:23:05.000Z","size":1061,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T08:09:48.522Z","etag":null,"topics":["fortran","nginx","nginx-link-function","openresty"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interkosmos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-06-05T12:59:31.000Z","updated_at":"2024-02-24T03:35:14.000Z","dependencies_parsed_at":"2023-09-25T01:44:52.245Z","dependency_job_id":"811d2edb-35a2-42f1-b653-b6fef7f1b30d","html_url":"https://github.com/interkosmos/fortran-nginx","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"d5b5faa3bdda4f9c8d09f601f24225f91e4163ee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interkosmos%2Ffortran-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interkosmos","download_url":"https://codeload.github.com/interkosmos/fortran-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843867,"owners_count":21170492,"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","nginx","nginx-link-function","openresty"],"created_at":"2024-11-08T03:09:45.017Z","updated_at":"2025-04-14T08:09:54.123Z","avatar_url":"https://github.com/interkosmos.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fortran-nginx\nA collection of ISO C binding interfaces to the 3rd party module\n[nginx-link-function](https://github.com/Taymindis/nginx-link-function/) for\n[nginx](https://nginx.org/), to write server-side web applications in Fortran\n2003.\n\nShared memory features (`cache`, `palloc`, `shm`, `shmtx`) that allow resource\nsharing between nginx workers are not supported.\n\n## Dependencies\nEither install [nginx](https://nginx.org/) or\n[OpenResty](https://openresty.org/) with the\n[nginx-link-function](https://github.com/Taymindis/nginx-link-function/) module.\n\nOn FreeBSD, build [www/nginx](https://www.freshports.org/www/nginx) with the\n`LINK` option enabled from ports:\n\n```\n# cd /usr/local/ports/www/nginx/\n# make config\n# make\n# make install\n```\n\nOr, just install a package that has been compiled with `LINK`:\n\n```\n# pkg install www/nginx\n# pkg info www/nginx\n```\n\n## Build\nUse the provided `Makefile` to build the static library `libfortran-nginx.a`.\n\n## Example\nYour Fortran web application must implement at least the routines\n`ngx_link_func_init_cycle()` and `ngx_link_func_exit_cycle()`. All routines\ncallable from outside must have the `bind(c)` attribute.\n\n```fortran\n! webapp.f90\nmodule webapp\n    use, intrinsic :: iso_c_binding, only: c_null_char\n    use :: ngx_link_func\n    implicit none\n    logical, save :: is_service_on = .false.\ncontains\n    subroutine ngx_hello(ctx) bind(c)\n        character(len=*), parameter           :: str = 'Hello, from Fortran!'\n        type(ngx_link_func_ctx_t), intent(in) :: ctx\n\n        call ngx_link_func_log_info(ctx, 'Sending response ...' // c_null_char)\n        call ngx_link_func_write_resp(ctx          = ctx, \u0026\n                                      status_code  = int(200, kind=8), \u0026\n                                      status_line  = '200 OK' // c_null_char, \u0026\n                                      content_type = 'text/plain' // c_null_char, \u0026\n                                      resp_content = str // c_null_char, \u0026\n                                      resp_len     = int(len(str), kind=8))\n    end subroutine ngx_hello\n\n    subroutine ngx_link_func_exit_cycle(cyc) bind(c)\n        type(ngx_link_func_cycle_t), intent(in) :: cyc\n\n        call ngx_link_func_cyc_log_info(cyc, 'Shutting down the web app ...' // c_null_char)\n        is_service_on = .false.\n    end subroutine ngx_link_func_exit_cycle\n\n    subroutine ngx_link_func_init_cycle(cyc) bind(c)\n        type(ngx_link_func_cycle_t), intent(in) :: cyc\n\n        call ngx_link_func_cyc_log_info(cyc, 'Starting the web app ...' // c_null_char)\n        is_service_on = .true.\n    end subroutine ngx_link_func_init_cycle\nend module webapp\n```\n\nCompile the shared library `webapp.so` with:\n\n```\n$ gfortran -shared -fPIC -o webapp.so webapp.f90 libfortran-nginx.a\n```\n\nIf you use GNU Fortran, make sure that nginx can find the run-time library\n`libgfortran.so`.\n\nLoad the shared library by setting `ngx_link_func_lib` and `ngx_link_func_call`\nin your `nginx.conf`:\n\n```nginx\n# Load shared library if module is not linked statically:\nload_module \"/usr/local/libexec/nginx/ngx_http_link_func_module.so\";\n\nserver {\n    listen            80;\n    server_name       localhost;\n    ngx_link_func_lib \"/usr/local/etc/nginx/webapp.so\";\n\n    location / {\n        ngx_link_func_call \"ngx_hello\";\n    }\n}\n```\n\nStart the nginx daemon:\n\n```\n# service nginx start\n```\n\nThen, open `http://localhost/` in your web browser.\n\n## Further Examples\nAdditional examples can be found in `examples/`:\n\n  * **hello** returns a basic HTML response.\n  * **laas** (LAPACK as a Service) solves a system of linear equations *A · x = B* using [LAPACK95](https://www.netlib.org/lapack95/).\n  * **plot** returns a plot of the [Lotka-Volterra](https://en.wikipedia.org/wiki/Lotka–Volterra_equations) ODEs in PNG format, using the [DISLIN](http://dislin.de/) library. Pass the initial population sizes through HTTP GET parameters `u` and `v` ([example output](examples/plot/output.png)).\n  * **post** parses HTTP POST parameters.\n\nBuild the examples with:\n\n```\n$ make \u003cname\u003e\n```\n\n## Licence\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterkosmos%2Ffortran-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterkosmos%2Ffortran-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterkosmos%2Ffortran-nginx/lists"}