{"id":13831896,"url":"https://github.com/mapmeld/fortran-machine","last_synced_at":"2026-01-26T20:11:53.406Z","repository":{"id":47403710,"uuid":"60613872","full_name":"mapmeld/fortran-machine","owner":"mapmeld","description":"Finally a Fortran MVC web platform","archived":false,"fork":false,"pushed_at":"2021-09-14T06:43:09.000Z","size":1399,"stargazers_count":808,"open_issues_count":2,"forks_count":43,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-03-05T05:16:03.704Z","etag":null,"topics":["fortran"],"latest_commit_sha":null,"homepage":"https://fortran.io","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapmeld.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}},"created_at":"2016-06-07T13:08:08.000Z","updated_at":"2025-02-22T22:26:26.000Z","dependencies_parsed_at":"2022-08-12T13:23:03.292Z","dependency_job_id":null,"html_url":"https://github.com/mapmeld/fortran-machine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mapmeld/fortran-machine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapmeld%2Ffortran-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapmeld%2Ffortran-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapmeld%2Ffortran-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapmeld%2Ffortran-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapmeld","download_url":"https://codeload.github.com/mapmeld/fortran-machine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapmeld%2Ffortran-machine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28787164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: 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":["fortran"],"created_at":"2024-08-04T10:01:43.950Z","updated_at":"2026-01-26T20:11:53.388Z","avatar_url":"https://github.com/mapmeld.png","language":"Fortran","funding_links":[],"categories":["Fortran","Web"],"sub_categories":[],"readme":"# Fortran.io\n\nAn MVC web stack written in Fortran 90 (so you get arrays, and it's not punchcards)\n\nMajor credit due to:\n\n- authors of \u003ca href=\"http://fortranwiki.org/fortran/show/FLIBS\"\u003eFLIBS\u003c/a\u003e (Arjen Markus and Michael Baudin)\n- Ricolindo Carino and Arjen Markus's Fortran FastCGI program and tutorial - in many ways this started as an update to this tutorial :  http://flibs.sourceforge.net/fortran-fastcgi-nginx.html\n- String utils by George Benthian http://www.gbenthien.net/strings/index.html\n- \u003ca href=\"https://github.com/branning\"\u003ePhilip Branning\u003c/a\u003e for improving and documenting the install process, especially the SQLite parts\n- \u003ca href=\"https://github.com/divVerent\"\u003edivVerent\u003c/a\u003e for fixing a server crash bug due to URL params and SQL\n\n## Create an Ubuntu server\n\nLog in and install dependencies\n\n```\n# update Ubuntu\nsudo apt-get update\nsudo apt-get upgrade\n\n# create the user and home directory\nadduser fortran --gecos \"\"\nusermod -a -G sudo fortran\n\n# switch to new user\nsu fortran\ncd ~\n\n# install git and clone the repo\nsudo apt-get install -y git\ngit clone https://github.com/mapmeld/fortran-machine.git\n\n# Install dependencies\ncd fortran-machine\nsudo ./install_deps_ubu.sh\n```\n\nGo to your IP address - you should see the \"Welcome to nginx!\" page\n\nChange the location in /etc/nginx/sites-available/default :\n\n```\nserver_name 101.101.101.101; \u003c- your IP address\n\nlocation / {\n\troot /home/fortran/fortran-machine;\n\tindex index.html;\n}\n```\n\nRestart nginx to make these settings for real:\n\n```\nsudo service nginx restart\n```\n\nYou should now see the test page on your IP address.\n\n```\nTest doc\n```\n\n## Use Fortran CGI script\n\nLet's go from test page to Fortran script:\n\n```\n# compile the test server\nmake\n```\n\nNow change nginx config /etc/nginx/sites-available/default\n\n```\nlocation / {\n\troot /home/fortran/fortran-machine;\n\tfastcgi_pass 127.0.0.1:9000;\n\tfastcgi_index index.html;\n\tinclude fastcgi_params;\n}\n```\n\nThen run ```sudo service nginx restart```\n\n```\n# spawn the server\nspawn-fcgi -a 127.0.0.1 -p 9000 ./fortran_fcgi\n```\n\n### Restarting the script\n\nAfter changing the source code, you can recompile and restart your server with:\n\n```\n./restart.sh\n```\n\n## Add a static folder\n\nAdd to nginx config /etc/nginx/sites-available/default\n\n```\nlocation /static {\n    root /home/fortran/fortran-machine;\n}\n```\n\nAnd restart nginx\n\n```\nsudo service nginx restart\n```\n\n## Fortran controller\n\nThe controller is written in Fortran in the fortran_fcgi.f90 file:\n\n```fortran\ncase ('/')\n\t! most pages look like this\n\ttemplatefile = 'template/index.jade'\n\tcall jadefile(templatefile, unitNo)\n\ncase ('/search')\n\twrite(unitNo,AFORMAT) '\u003cdiv class=\"container\"\u003e'\n\n\ttemplatefile = 'template/search.jade'\n\tcall jadefile(templatefile, unitNo)\n\n\twrite(unitNo,AFORMAT) '\u003c/div\u003e'\n```\n\n## Jade Templates\n\nIn the template folder, you can write HTML templates similar to Jade or HAML.\n\nIf you want to have a loop or other structure, it's better to create a partial and run the loop in the Fortran controller.\n\n```jade\n.container\n  .col-sm-6\n    h3 Hello #{name}!\n  .col-sm-6\n    h3 Link\n    a(href=\"http://example.com/profile/#{id}\") A link\n```\n\n## SQLite Database\n\nYou can connect to a SQLite database. The example on \u003ca href=\"https://fortran.io\"\u003eFortran.io\u003c/a\u003e\nlets you search through marsupials!\n\nHere's how the getAllMarsupials subroutine loads data into arrays:\n\n```fortran\nsubroutine getAllMarsupials(name, latinName, wikiLink, description)\n\t! columns\n\tcharacter(len=50), dimension(8)\t:: name, latinName, wikiLink, description\n\n\tcall sqlite3_open('marsupials.sqlite3', db)\n\n\tallocate( column(4) )\n\tcall sqlite3_column_query( column(1), 'name', SQLITE_CHAR )\n\tcall sqlite3_column_query( column(2), 'latinName', SQLITE_CHAR )\n\tcall sqlite3_column_query( column(3), 'wikiLink', SQLITE_CHAR )\n\tcall sqlite3_column_query( column(4), 'description', SQLITE_CHAR )\n\n\tcall sqlite3_prepare_select( db, 'marsupials', column, stmt, \"WHERE 1=1 LIMIT 8\")\n\n\ti = 1\n\tdo\n\t\tcall sqlite3_next_row(stmt, column, finished)\n\t\tif (finished) exit\n\n\t\tcall sqlite3_get_column(column(1), name(i))\n\t\tcall sqlite3_get_column(column(2), latinName(i))\n\t\tcall sqlite3_get_column(column(3), wikiLink(i))\n\t\tcall sqlite3_get_column(column(4), description(i))\n\t\ti = i + 1\n\tend do\nendsubroutine\n```\n\nThen in the Fortran controller, you loop through:\n\n```fortran\ncall getAllMarsupials(names, latinNames, wikiLinks, descriptions)\n\ni = 1\ndo\n\tpagevars(1,2) = names(i)\n\tpagevars(2,2) = latinNames(i)\n\tpagevars(3,2) = wikiLinks(i)\n\tpagevars(4,2) = descriptions(i)\n\tif (len(trim(pagevars(1,2))) == 0 .or. i == 5) then\n\t\texit\n\telse\n\t\t! template with string\n\t\ttemplatefile = 'template/result.jade'\n\t\tcall jadetemplate(templatefile, unitNo, pagevars)\n\t\ti = i + 1\n\tendif\nenddo\n```\n\nThen the individual result template:\n\n```jade\n.row\n  .col-sm-12\n    h4\n      a(href=\"https://en.wikipedia.org#{wikiLink}\") #{name}\n    em #{latinName}\n    hr\n    p #{description}\n```\n\n## HTTPS Certificate\n\nDon't forget to get a free HTTPS Certificate using LetsEncrypt!\n\nhttps://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04\n\n# License\n\nThis library, like FLIBS which it's based on, is available under the BSD license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapmeld%2Ffortran-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapmeld%2Ffortran-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapmeld%2Ffortran-machine/lists"}