tMerge branch 'master' of github.com:anders-dc/SeaIce.jl - Granular.jl - Julia … | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4ed62a69d63596911dba86daa7272127ba54ab2d | |
parent 3d343ba1df2df9b297c8066fd88da57fc8dbe314 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 16 Jun 2017 13:13:45 -0400 | |
Merge branch 'master' of github.com:anders-dc/SeaIce.jl | |
Diffstat: | |
A seaice-status.sh | 17 +++++++++++++++++ | |
M src/io.jl | 72 +++++++++++++++++++++++++++++… | |
M test/vtk.jl | 2 ++ | |
3 files changed, 91 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/seaice-status.sh b/seaice-status.sh | |
t@@ -0,0 +1,17 @@ | |
+#!/bin/bash | |
+ | |
+# Status script which traverses the subdirectories of the current folder for | |
+# simulations. You may want to add this to your shell's PATH variable. | |
+ | |
+set -e | |
+cmd='julia --color=yes -e "import SeaIce; SeaIce.status()"' | |
+ | |
+if [[ "$1" == "loop" ]]; then | |
+ while true; do | |
+ date | |
+ eval $cmd | |
+ sleep 10 | |
+ done | |
+else | |
+ eval $cmd | |
+fi | |
diff --git a/src/io.jl b/src/io.jl | |
t@@ -112,6 +112,78 @@ function readSimulationStatus(simulation_id::String; | |
return data[3] | |
end | |
+export status | |
+""" | |
+Shows the status of all simulations with output files written under the | |
+specified `folder`, which is the current working directory by default. | |
+""" | |
+function status(folder::String=".", colored_output::Bool=true, | |
+ write_header::Bool=true) | |
+ | |
+ status_files = String[] | |
+ | |
+ if colored_output | |
+ id_color_complete = :green | |
+ id_color_in_progress = :yellow | |
+ time_color = :white | |
+ percentage_color = :blue | |
+ lastfile_color = :cyan | |
+ else | |
+ id_color_complete = :default | |
+ id_color_in_progress = :default | |
+ time_color = :default | |
+ percentage_color = :default | |
+ lastfile_color = :default | |
+ end | |
+ | |
+ for (root, dirs, files) in walkdir(folder, follow_symlinks=false) | |
+ | |
+ for file in files | |
+ if contains(file, ".status.txt") | |
+ push!(status_files, joinpath(root, file)) | |
+ end | |
+ end | |
+ end | |
+ | |
+ if length(status_files) > 0 | |
+ if write_header | |
+ println("--------------------------------------" * | |
+ "--------------------------------------") | |
+ print_with_color(:default, "simulation folder \t") | |
+ print_with_color(time_color, " time \t") | |
+ print_with_color(percentage_color, " completed ") | |
+ print_with_color(lastfile_color, "last file \n") | |
+ println("--------------------------------------" * | |
+ "--------------------------------------") | |
+ end | |
+ | |
+ for file in status_files | |
+ data = readdlm(file) | |
+ id = replace(file, ".status.txt", "") | |
+ id = replace(id, "./", "") | |
+ id = replace(id, r".*/", "") | |
+ time_s = @sprintf "%6.2fs" data[1] | |
+ time_h = @sprintf "%5.1fh" data[1]/(60.*60.) | |
+ percentage = @sprintf "%3.0f%%" data[2] | |
+ lastfile = @sprintf "%5d" data[3] | |
+ if data[2] < 99. | |
+ print_with_color(id_color_in_progress, "$id \t") | |
+ else | |
+ print_with_color(id_color_complete, "$id \t") | |
+ end | |
+ print_with_color(time_color, "$time_s ($time_h) \t") | |
+ print_with_color(percentage_color, "$percentage \t") | |
+ print_with_color(lastfile_color, "$lastfile \n") | |
+ end | |
+ if write_header | |
+ println("--------------------------------------" * | |
+ "--------------------------------------") | |
+ end | |
+ else | |
+ warn("no simulations found in $(pwd())/$folder") | |
+ end | |
+end | |
+ | |
export writeVTK | |
""" | |
Write a VTK file to disk containing all ice floes in the `simulation` in an | |
diff --git a/test/vtk.jl b/test/vtk.jl | |
t@@ -58,6 +58,8 @@ SeaIce.run!(sim, single_step=true) | |
SeaIce.setOutputFileInterval!(sim, 0.1) | |
SeaIce.run!(sim) | |
+SeaIce.status() | |
+ | |
@test readstring(`$(cmd) $(icefloepath)$(cmd_post)`) == icefloechecksum | |
@test readstring(`$(cmd) $(icefloeinteractionpath)$(cmd_post)`) == | |
icefloeinteractionchecksum |