Commit 1feb1e2e authored by William F Godoy's avatar William F Godoy

Finding output directories using Glob module

parent bb4ec64c
......@@ -3,6 +3,9 @@ name = "Exio"
uuid = "0525473d-17b7-4fd3-beb1-bf17216ddbac"
version = "0.0.1"
[deps]
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
[compat]
julia = "1"
JuliaFormatter = "0.6.2"
......
......@@ -6,5 +6,6 @@
using Pkg
Pkg.add("JuliaFormatter")
Pkg.add("Glob")
exit()
......@@ -67,45 +67,52 @@ end
- `parameters::Dict{String,String}` : input file to be parsed, absolute path is preferred
"""
function get_independent_variables(extractor::AbstractAmrex, parameters)::Dict
independentVariables = Dict()
# Number of output events,
# get is the safe way. 3rd argument is a default fallback if key not found
maxStepStr = get(parameters, "max_step", "")
if maxStepStr != ""
# safe string conversion to a type
maxStep = parse(Int64, maxStepStr)
plotIntStr = get(parameters, "amr.plot_int", "")
if plotIntStr != ""
plotFrequency = parse(Int64, plotIntStr)
independentVariables["nplots"] = maxStep / plotFrequency
else
throw(NoSuchFieldException("jexio Amrex: Can't find amr.plot_int"))
end
checkIntStr = get(parameters, "amr.check_int", "")
if checkIntStr != ""
checkpointFrequency = parse(Int64, checkIntStr)
independentVariables["ncheckpoints"] = maxStep / checkpointFrequency
else
throw(NoSuchFieldException("jexio Amrex: Can't find amr.check_int"))
independentVariables = Dict()
# Number of output events,
# get is the safe way. 3rd argument is a default fallback if key not found
maxStepStr = get(parameters, "max_step", "")
if maxStepStr != ""
# safe string conversion to a type
maxStep = parse(Int64, maxStepStr)
plotIntStr = get(parameters, "amr.plot_int", "")
if plotIntStr != ""
plotFrequency = parse(Int64, plotIntStr)
independentVariables["amr.nplot_files"] = floor(Int32, maxStep / plotFrequency)
else
throw(NoSuchFieldException("jexio Amrex: Can't find amr.plot_int"))
end
checkIntStr = get(parameters, "amr.check_int", "")
if checkIntStr != ""
checkpointFrequency = parse(Int64, checkIntStr)
independentVariables["amr.ncheck_files"] = floor(Int32, maxStep / checkpointFrequency)
else
throw(NoSuchFieldException("jexio Amrex: Can't find amr.check_int"))
end
end
# Using the dot "." operator to apply it on an element-by-element basis (like a dot product)
# input is a dictionary with key="amr.ncell" and value = {"nx" "ny" "nz"},
# output is nx*ny*nz
# Example:
# input Dict[ "amr.n_cell" => ["16" "16"] ], if key not found return 0
# >ncells
# 256
ncells = prod(parse.(Int64, split(get(parameters, "amr.n_cell", ["0"]))))
independentVariables["amr.ncells"] = ncells
maxLevel = get(parameters, "amr.max_level", "")
independentVariables["amr.max_level"] = maxLevel == "" ? 1 : parse(Int32, maxLevel)
regrid = get(parameters, "amr.regrid_int", "")
independentVariables["amr.regrid_int"] = regrid == "" ? 1 : parse(Int32, regrid)
end
# Using the dot "." operator to apply it on an element-by-element basis (like a dot product)
# input is a dictionary with key="amr.ncell" and value = {"nx" "ny" "nz"},
# output is nx*ny*nz
# Example:
# input Dict[ "amr.n_cell" => ["16" "16"] ], if key not found return 0
# >ncells
# 256
ncells = prod(parse.(Int64, split(get(parameters, "amr.n_cell", ["0"] ) )))
independentVariables["ncells"] = ncells
return independentVariables
return independentVariables
end
import Glob
mutable struct AmrexCastro <: AbstractAmrex
app::String
degreesOfFreedom::Any
......@@ -26,3 +28,24 @@ function init!(extractor::AmrexCastro, outputPrefix::String)
]
extractor.outputPrefix = outputPrefix
end
function get_dependent_variable_datasize(extractor::AmrexCastro)
findDelimiter = findlast("/",extractor.outputPrefix)
println(extractor.outputPrefix)
println(findDelimiter)
searchDirectory = extractor.outputPrefix[ 1: findDelimiter[1]-1 ]
prefix = extractor.outputPrefix[ findDelimiter[1]+1:end]
println("Search directory: ", searchDirectory, " prefix: ", prefix)
outputDirs = Glob.glob( string(prefix,"*"), searchDirectory )
println(outputDirs)
end
......@@ -16,7 +16,7 @@ function test_value(
end
function test_AmrexCastro()
exio = Exio.exio_init("AmrexCastro", ".")
exio = Exio.exio_init("AmrexCastro", "/home/wgodoy/workspace/Castro/Exec/hydro_tests/Sedov/case")
@test typeof(exio) == Exio.ExioH
......@@ -61,11 +61,12 @@ function test_AmrexCastro()
test_value(counter, parameters, "amr.probin_file", "probin.2d.cyl_in_cartcoords")
@test counter == 27
independent_variables = Exio.get_independent_variables(exio.extractor, parameters)
println(independent_variables)
Exio.get_dependent_variable_datasize(exio.extractor)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment