Skip to content

Commit

Permalink
Merge pull request #21 from JuliaGeodynamics/boriskaus-patch-1
Browse files Browse the repository at this point in the history
Update LaMEM.jl to work on Julia 1.10
  • Loading branch information
boriskaus authored Jan 25, 2024
2 parents 9199c57 + 3ec6443 commit 1044e27
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 23 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/blank.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
fail-fast: false
matrix:
version:
- '1.8'
- '1.9'
- '1.10'
os:
Expand Down Expand Up @@ -47,7 +46,7 @@ jobs:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: '1.8'
version: '1.10'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"julia.environmentPath": "c:\\Users\\Jaime\\OneDrive\\LaMEM\\LaMEM.jl"
"julia.environmentPath": "/Users/kausb/.julia/dev/LaMEM"
}
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ GeoParams = "e018b62d-d9de-4a26-8697-af89c310ae38"
GeophysicalModelGenerator = "3700c31b-fa53-48a6-808a-ef22d5a84742"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
LaMEM_jll = "15d6fa20-f789-5486-b71b-22b4ac8eb1c1"
PETSc_jll = "8fa3689e-f0b9-5420-9873-adf6ccf46f2d"
ReadVTK = "dc215faf-f008-4882-a9f7-a79a826fadc3"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand All @@ -19,8 +18,7 @@ DocStringExtensions = "0.9"
GeoParams = "0.4, 0.5"
GeophysicalModelGenerator = "0.4 - 0.6"
Glob = "1"
LaMEM_jll = "1.2.4 - 1.2.4"
PETSc_jll = "3.16.8 - 3.16.8"
LaMEM_jll = "2.1.3"
ReadVTK = "0.1, 0.2"
Requires = "1.0, 2"
Statistics = "1.0"
Expand Down
7 changes: 6 additions & 1 deletion src/run_lamem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Note: This downloads the BinaryBuilder version of LaMEM, which is not necessarily the latest version of LaMEM
# (or the same as the current repository), since we have to manually update the builds.

using Base.Sys

"""
deactivate_multithreading(cmd)
Expand Down Expand Up @@ -39,7 +41,10 @@ julia> run_lamem(ParamFile, 2, "-nstep_max = 1")
```
"""
function run_lamem(ParamFile::String, cores::Int64=1, args::String=""; wait=true, deactivate_multithreads=true)

if iswindows() & cores>1
cores=1;
println("LaMEM_jll does not support parallel runs on windows; using 1 core instead")
end
if cores==1
# Run LaMEM on a single core, which does not require a working MPI
cmd = `$(LaMEM_jll.LaMEM()) -ParamFile $(ParamFile) $args`
Expand Down
10 changes: 7 additions & 3 deletions src/run_lamem_save_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#
# Note: This downloads the BinaryBuilder version of LaMEM, which is not necessarily the latest version of LaMEM
# (or the same as the current repository), since we have to manually update the builds.

using Base.Sys

function run_lamem_with_log(ParamFile::String, cores::Int64=1, args::String="")

if iswindows() & cores>1
println("LaMEM_jll does not support parallel runs on windows; using 1 core instead")
cores = 1;
end

currdir = pwd()
cd(dirname(abspath(ParamFile)))
ParamFile = splitdir(ParamFile)[2]
Expand Down Expand Up @@ -57,7 +61,7 @@ function run_lamem_save_grid(ParamFile::String, cores::Int64=1; verbose=true)
if cores==1 & verbose==true
return print("No partitioning file required for 1 core model setup \n")
end

ParamFile = abspath(ParamFile)
logoutput = run_lamem_with_log(ParamFile, cores,"-mode save_grid" )
arr = JuliaStringToArray(logoutput)
Expand Down
Binary file not shown.
Binary file added test/markers/mdb.00000000.dat
Binary file not shown.
2 changes: 1 addition & 1 deletion test/read_timestep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Test
Timestep = 1
data, time = Read_LaMEM_timestep(FileName,Timestep)
@test data.fields.phase[1000] 0.0f0
@test data.fields.strain_rate[1][1] -0.0010996389f0
@test data.fields.strain_rate[1][1] -0.0010996389f0 rtol=1e-2

fields = Read_LaMEM_fieldnames(FileName)

Expand Down
16 changes: 8 additions & 8 deletions test/runLaMEM.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test
using Test, Base.Sys

@testset "run LaMEM" begin

Expand All @@ -11,13 +11,13 @@ using Test
println("Falling Block test on 1 core failed")
end



try
out = run_lamem(ParamFile, 4,"-nstep_max 1") # 4 cores
@test isnothing(out)
catch
println("Falling Block test on 4 cores failed")
if !iswindows()
try
out = run_lamem(ParamFile, 4,"-nstep_max 1") # 4 cores
@test isnothing(out)
catch
println("Falling Block test on 4 cores failed")
end
end

# Create a setup using GMG
Expand Down
8 changes: 5 additions & 3 deletions test/run_lamem_save_grid_test.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test
using Test, Base.Sys

@testset "run lamem mode save grid test" begin

Expand All @@ -8,8 +8,10 @@ using Test
out = run_lamem_save_grid(ParamFile, 1) # 1 core
@test isnothing(out)

out = run_lamem_save_grid(ParamFile, 8) # 8 cores
@test out == "ProcessorPartitioning_8cpu_2.2.2.bin"
if !iswindows() # current vers
out = run_lamem_save_grid(ParamFile, 8) # 8 cores
@test out == "ProcessorPartitioning_8cpu_2.2.2.bin"
end


end
3 changes: 2 additions & 1 deletion test/test_julia_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ using GeophysicalModelGenerator
# read last timestep
data,time = Read_LaMEM_timestep(model,last=true);

@test sum(data.fields.velocity[3][:,:,:]) 0.10747005f0 # check Vz
@test sum(data.fields.velocity[3][:,:,:]) 0.10747005f0 rtol=1e-1 # check Vz
# @test sum(data.fields.velocity[3][:,:,:]) ≈ 0.10866211f0 # check Vz

# cleanup the directory
rm(model.Output.out_dir, force=true, recursive=true)
Expand Down

0 comments on commit 1044e27

Please sign in to comment.