{"id":40075087,"url":"https://github.com/modern-fortran/tsunami","last_synced_at":"2026-01-19T08:34:16.950Z","repository":{"id":42938213,"uuid":"109404250","full_name":"modern-fortran/tsunami","owner":"modern-fortran","description":"A parallel shallow water equations solver","archived":false,"fork":false,"pushed_at":"2022-01-23T01:19:39.000Z","size":147,"stargazers_count":138,"open_issues_count":3,"forks_count":40,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-01-30T09:13:44.375Z","etag":null,"topics":["book","fortran","shallow-water-equations","tsunami"],"latest_commit_sha":null,"homepage":"https://modern-fortran.github.io/tsunami","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/modern-fortran.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":"2017-11-03T14:20:01.000Z","updated_at":"2024-01-13T10:15:46.000Z","dependencies_parsed_at":"2022-08-23T22:20:48.281Z","dependency_job_id":null,"html_url":"https://github.com/modern-fortran/tsunami","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/modern-fortran/tsunami","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modern-fortran%2Ftsunami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modern-fortran%2Ftsunami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modern-fortran%2Ftsunami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modern-fortran%2Ftsunami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modern-fortran","download_url":"https://codeload.github.com/modern-fortran/tsunami/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modern-fortran%2Ftsunami/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28564019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"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":["book","fortran","shallow-water-equations","tsunami"],"created_at":"2026-01-19T08:34:16.871Z","updated_at":"2026-01-19T08:34:16.943Z","avatar_url":"https://github.com/modern-fortran.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tsunami\n\nA parallel tsunami simulator.\nCompanion running example for [Modern Fortran: Building Efficient Parallel Applications](https://www.manning.com/books/modern-fortran?a_aid=modernfortran\u0026a_bid=2dc4d442).\n\n## Organization\n\n* [**Chapter 2**](https://github.com/modern-fortran/tsunami/tree/master/src/ch02): We implement our first working solver which solves for linear advection of a wave in one dimension.\nFirst encounter with declaration, variables, loops, branches, arithmetic, and writing to console.\n* [**Chapter 3**](https://github.com/modern-fortran/tsunami/tree/master/src/ch03): We refactor our program from Chapter 2 to use procedures -- \na finite difference function and a subroutine to set initial conditions.\n* [**Chapter 4**](https://github.com/modern-fortran/tsunami/tree/master/src/ch04): We refactor our program from Chapter 3 to define the procedures in external modules. \nWe use this opportunity to augment the simulator to solve for non-linear gravity waves.\n* [**Chapter 7**](https://github.com/modern-fortran/tsunami/tree/master/src/ch07): We parallelize the program from Chapter 4 using coarrays and observe the speed up.\n* [**Chapter 8**](https://github.com/modern-fortran/tsunami/tree/master/src/ch08): We refactor our program from Chapter 7 to model our physical quantities (water height and velocity)\nusing a derived type, and implement common arithmetic operations as type-bound methods.\n* [**Chapter 10**](https://github.com/modern-fortran/tsunami/tree/master/src/ch10): We continue working on the code from Chapter 9 and overload the assignment operator to \nautomatically synchronize the data across parallel images on every assignment.\n* [**Chapter 12**](https://github.com/modern-fortran/tsunami/tree/master/src/ch12): In the final chapter, we revisit the parallel code from Chapter 10 and explore how Fortran 2018\nTeams, Events, and Collectives can be used for some more advanced parallel patterns.\n\n## Getting started\n\n### Get the code\n\nYou can get the latest code by cloning the master branch:\n\n```\ngit clone https://github.com/modern-fortran/tsunami\n```\n\nor by downloading it as a [zip file](https://github.com/modern-fortran/tsunami/archive/master.zip).\n\n### Build the code\n\n```\ncd tsunami\nmake -k\n```\n\nYou can compile the tsunami versions in chapters 2, 3, and 4\nwith gfortran alone.\nFor the code in chapters 7, 8, 10, and 12, you'll need the latest\nstable build of OpenCoarrays, which will give you the `caf` \ncompiler wrapper.\n\n### Set up the Python environment for visualization (optional)\n\nPython scripts are provided to visualize tsunami output.\n\n```\npython3 -m venv venv\nsource venv/bin/activate\npip install -U pip\npip install -U -r requirements.txt\n```\n\n## Parallel scaling\n\nFrom Chapter 7 and onward, your tsunami program will be parallel. You may notice\nthat running the program in parallel may be as fast as running it in serial, and\nperhaps even slower. This is because by default, the grid size is small enough\nfor the program to complete in a short time on a single CPU. Specifically, in\nsrc/ch07/tsunami.f90:\n\n```\n  integer(int32), parameter :: grid_size = 100 ! grid size in x\n```\n\nis a very small grid. Further dividing it to multiple CPU cores may not yield\nenough computation load to compensate for the added communication load. Further,\nnear the end of the main time loop, we gather the data to the first image and\nwrite it to screen in every time step:\n\n```\n    ! gather to image 1 and write current state to screen\n    gather(is:ie)[1] = h(ils:ile)\n    sync all\n    if (this_image() == 1) print fmt, n, gather\n```\n\nwhich significantly adds to the communication. Recall that we want to maximize\ncomputation and minimize communication for best parallel scalability results.\n\nTo observe parallel speed-up with your tsunami program with increasing number\nof CPUs, make the following changes to the code:\n\n1. Increase `grid_size`. You can go as high as you want given enough RAM.\n2. Reduce output in the time loop from every time step, to perhaps every 10th\n   or 100th steps. These are just examples; pick the output frequency that\n   works best for you.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodern-fortran%2Ftsunami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodern-fortran%2Ftsunami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodern-fortran%2Ftsunami/lists"}