{"id":15460231,"url":"https://github.com/synkevych/dockerize-simflex","last_synced_at":"2026-01-07T22:03:18.398Z","repository":{"id":132013505,"uuid":"590605304","full_name":"Synkevych/dockerize-simflex","owner":"Synkevych","description":"Flexpart 10.4 conternization with SIMFLEX (Source Inversion ModuleFLEXPART)","archived":false,"fork":false,"pushed_at":"2024-03-04T21:11:13.000Z","size":3384,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-18T19:54:32.492Z","etag":null,"topics":["flexpart","flexpart-model"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Synkevych.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-18T19:43:43.000Z","updated_at":"2024-03-20T10:55:13.000Z","dependencies_parsed_at":"2024-10-01T23:21:13.845Z","dependency_job_id":"7de07fc2-ae81-4894-bb6f-12adc81002df","html_url":"https://github.com/Synkevych/dockerize-simflex","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synkevych%2Fdockerize-simflex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synkevych%2Fdockerize-simflex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synkevych%2Fdockerize-simflex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synkevych%2Fdockerize-simflex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Synkevych","download_url":"https://codeload.github.com/Synkevych/dockerize-simflex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246014226,"owners_count":20709775,"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":["flexpart","flexpart-model"],"created_at":"2024-10-01T23:21:05.136Z","updated_at":"2026-01-07T22:03:13.379Z","avatar_url":"https://github.com/Synkevych.png","language":"Fortran","readme":"# dockerize-simflex\n\n- [dockerize-simflex](#dockerize-simflex)\n  - [Flexpart](#flexpart)\n  - [How to test that docker image work](#how-to-test-that-docker-image-work)\n  - [How parsing works](#how-parsing-works)\n  - [How to use](#how-to-use)\n  - [Changes from the origin](#changes-from-the-origin)\n    - [Changes in Flexpart](#changes-in-flexpart)\n  - [Parallelizing using Message Passing Interface (MPI)](#parallelizing-using-message-passing-interface-mpi)\n  - [Performance test](#performance-test)\n    - [Debugging](#debugging)\n  - [Resources](#resources)\n\nFlexpart containerization with simflex.\nSIMFLEX – Source Inversion Module-FLEXPART.  \nTo make Flexpart work you should install all required libraries and provide the required inputs. This project is created to make it easy and isolated from your work environment.\n\n## Flexpart\n\nFLEXPART (“FLEXible PARTicle dispersion model”) is a Lagrangian transport and dispersion model suitable for simulating a large range of atmospheric transport processes. Apart from transport and turbulent diffusion, it is able to simulate dry and wet deposition, decay, linear chemistry; it can be used in forward or backward mode, with defined sources, or in a domain-filling setting. It can be used from local to global scale.\n\n## How to test that docker image work\n\nTested for compatibility with 3 cores; if more than 3 cores are provided, an error will occur after the first calculation. In OpenStack, you can utilize `$(nproc)` to utilize all available cores.\n\n```sh\n# Assuming you are in the root folder of the git repository\ncp -rf flexpart_v10.4/test 1;\ndocker build -t simflex:beta -f Dockerfile .;\ncd 1;\nmkdir results;\ndocker run --privileged -d -v \"$PWD\":/data/ -v \"$PWD/results/\":/series/ --name calculation_$(basename \"$(pwd)\") simflex:beta\n```\n\n## How parsing works\n\n1. Creating COMMAND file for Flexpart inputs\n\n![Command file](/docs/command.png)\n\n2. Creating OUTGRID file for flexpart inputs\n\n![Outgrid file](/docs/outgrid.png)\n\n3. Creating simflexinp.nml and measurem.csv for simflex inputs\n\n![Simflexinp.nml file](/docs/simflexinp.png)\n\n4. Creating RELEASES file for flexpart on each iteration\n\n![Releases file](/docs/releases.png)\n\n5. Creating or updating table_srs_paths.txt file for simflex on each iteration\n\n![Table_srs_paths file](/docs/table_srs_paths.png)\n\n## How to use\n\n1. Build the image locally in the `dockerize-simflex` folder: `docker build -t simflex:v1 .`  \n2. Prepare input data for the calculation. Create a folder for example `1` and `input` inside it, then put there two files: `measurements.txt` and `options.xml`, also create folder `series` for Flexpart output in the same path that `1` has.  \n3. Run the calculations by running the container using created image and input data, to run container on all available CPUs use `--privileged` argument: `docker run --privileged -d -v --name=simflex \"$PWD\":/data/ simflex:v1`  \n4. To connect to the running container use: `docker exec -it simflex /bin/bash`  \n5. After calculations simflex output files will be located in `data/output/Nuclide-name`, these folders are generated by simflex.  \n6. Delete container, all data inside the container will be lost: `docker rm --volumes simflex`  \n\nDescription of the processes inside the container:\nAs input data used two files: `measurements.txt` and `options.xml` which are located in the `/data/input/` folder. The main script `run.sh` will parse these files and create all required files for Flexpart and Simflex. After that, the calculation will start. The output data will be located in the `/data/output/`  and `/series/series_id/` folders. After the calculation is complete, the container will be stopped.\nAll process logs will be located in the `/data/calculations.log` file or you can use `docker logs -t container_id` command.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eOther useful commands:\u003c/b\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\nCopy grib file to the docker container if you have them locally: `docker cp /path/grib.tar.gz container_id:/data/grib_data/`  \nInteract with an image without calculation (all changes and data will be lost after you disconnect): `docker run --rm -it --entrypoint bash simflex:v1`  \nConnect to the container without calculations(for example test purpose): `docker run -it --name simflex --entrypoint /bin/bash simflex:v1`\nCopy files/folders from the container to current local locations: `docker cp simflex:/data/calculation .`  \nIf the calculation didn't complete successfully use the logs file to understand the problem: `docker logs -t simflex`  \nAll calculations are also available on your machine(tested on Linux) because we copy all calculations to volume, but first, you need to get volumes ID: `docker container inspect simflex | grep Source | awk -F\\\" '{print $4}'`\nSimflex output files inside the container will be located in the `/data/output/Nuclide-name/`, use this value as a path to your folder with all information:  \n![volumes name and folders](/docs/volume_location.png)\nDelete image: `docker image rm simflex:v1`  \nDelete all images that are not used: `docker image prune -f`  \nIncrease performance by adding more cores and memory  \n`docker inspect 345cb4176398 | grep Source` get the path where the input data is located  \n`head ../input/measurements.txt | grep '^99;1;8' \u0026\u0026 head ../../4/input/measurements.txt | grep '^4;1;8'` - different between two files  \n`docker rm $(docker ps -q --filter \"status=exited\")` remove all exited containers\n\u003c/details\u003e\n\n## Changes from the origin\n\n### Changes in Flexpart\n\n1. File \u003cpar_mod.f90\u003e\n\n```\n141 - integer,parameter :: nxmax=361,nymax=181,nuvzmax=138,nwzmax=138,nzmax=138\n141 + integer,parameter :: nxmax=721,nymax=361,nuvzmax=138,nwzmax=138,nzmax=138 ! 0.5 degree 138 level\n\n198 - integer,parameter :: maxreceptor=20 ! maximum number of receptor points\n198 + integer,parameter :: maxreceptor=200\n\n207 - integer,parameter :: maxpart=100000 ! Maximum number of particles\n207 + integer,parameter :: maxpart=7500000\n\n208 -  integer,parameter :: maxspec=1 ! Maximum number of chemical species per release\n208 + integer,parameter :: maxspec=6\n```\n\n2. File \u003cmakefile\u003e in line 75 added the following:\n\n```\nINCPATH1 = /usr/include\nINCPATH2 = /usr/include\nLIBPATH1 = /usr/lib\nF90 = gfortran\n```\n\n## Parallelizing using Message Passing Interface (MPI)\n\nThe model scales well up to using 256 processors, with a parallel efficiency greater than 75 % for up to 64 processes on multiple nodes in runs with very large numbers of particles. The deviation from 100 % efficiency is almost entirely due to the remaining nonparallelized parts of the code, suggesting a large potential for further speedup. A new turbulence scheme for the convective boundary layer has been developed that considers the skewness in the vertical velocity distribution (updrafts and downdrafts) and vertical gradients in air density. FLEXPART is the only model available considering both effects, making it highly accurate for small-scale applications, e.g., to quantify dispersion in the vicinity of a point source.\n\nOpen Multi-Processing ([OpenMP](http://www.openmp.org/))\n\n\u003e make [-j] mpi ncf=yes - Compile parallel FLEXPART_MPI  \n\u003e make [-j] serial ncf=yes - Compile serial FLEXPART\n\n## Performance test\n\n- Simulation direction – backward\n- Species №18 or Ru-106\n- Input IBDATE 20200418, IBTIME 000000, IEDATE 20200421, IETIME 130010 (other paramethers in [test](/flexpart_v10.4/test/) folder)\n- Time does not include the time of downloading **grib_data** so calculation time would be increased\n\n|Where|System|Type|Model name|CPU(s)|RAM|Loutstep|Parts|Calc Times|\n|-|-|-|:-:|:-:|:-:|:-:|:-:|:-|\n|Docker|macOS|MPI|Apple M1(ARM64)|8|8Gb|3600|10000|1d, 18:26:27.673187|\n|Docker|Ubuntu 18.04.4|Serial|Intel Xeon CPU E5335 2.0GHs(15)|8|15.66GiB|3600|10000|17:40:18.740042|\n|Docker|Windows 10|Serial|Intel Core i5-8250U 1.6GHs(142)|8|16Gb|3600|10000|10:53:27.204476|\n|Docker|Ubuntu 18.04.4|MPI|Intel Xeon CPU E5335 2.0GHs(15)|8|15.66GiB|3600|10000|3:44:23.769362|\n|Docker|Windows 10|MPI|Intel Core i5-8250U 1.6GHs(142)|4|10Gb|3600|10000|1:47:01.369211|\n|Docker|Windows 10|MPI|Intel Core i5-8250U 1.6GHs(142)|8|16Gb|3600|10000|1:45:34.842323|\n|Server|Ubuntu 18.04|MPI|Intel Xeon Gold 6240 2.6GHz(85)|72|187G|3600|10000|1:02:03.195422|\n\n\u003e Serial - single core, MPI – multiply core using open-mpi  \n\u003e CPUs value shows all cores virtual and real\n\n### Debugging\n\n- [x] Change the user to root if you want to install/change something\n- [ ] Use command `docker run -d -it --entrypoint=\"/bin/bash\" -v \"$PWD\":/data/ -v /home/flexpart/series/:/series/ simflex:final` to connect to the container without calculations(for example test purpose)\n- [ ] And then use `docker exec -it simflex /bin/bash` to connect to the running container\n\nCommand `docker inspect -f '{{.State.ExitCode}}' container_name`.\nIf the container after calculation has *ExitCode 0* then everything is ok, if *ExitCode 1* then something went wrong while calculation, container should be restarted, if *ExitCode 2* then something went wrong with user files and user should be informed about it.\n\n## Resources\n\n\u003chttps://gmd.copernicus.org/articles/12/4955/2019/\u003e  \n[Flexpart v10.4 instalation process](https://www.jianshu.com/p/6bc7cee6c9bf)  \n[FLEXPART installation notes](http://paisheng.me/2018/08/10/FLEXPART_INSTALLATION_NOTE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynkevych%2Fdockerize-simflex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynkevych%2Fdockerize-simflex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynkevych%2Fdockerize-simflex/lists"}