Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0p3p8d #101

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 66 additions & 20 deletions src/ModelConfigurations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ folder=joinpath(pwd(),"tmp1")

MC=MITgcm_config(inputs=params,folder=folder)

#providing executable (optional)
#push!(MC.inputs[:setup][:main],(:exe => joinpath(pwd(),"mitgcmuv")))

#providing input folder (optional)
#push!(MC.inputs[:setup][:main],(:input_folder => joinpath(pwd(),"input_folder")))

#modifying run time options (optional)
#MC.inputs[:pkg][:PACKAGES][:useECCO]=false

Expand All @@ -28,7 +34,7 @@ launch(MC)
```
"""
function setup_ECCO4!(config::MITgcm_config)
if !haskey(config.inputs[:setup],:build)
if !haskey(config.inputs[:setup][:main],:exe)
println("downloading MITgcm ... ")
u0="https://github.com/MITgcm/MITgcm"; p0=joinpath(config,"MITgcm")
@suppress run(`$(git()) clone --depth 1 --branch checkpoint68o $(u0) $(p0)`)
Expand All @@ -39,15 +45,31 @@ function setup_ECCO4!(config::MITgcm_config)
p2=joinpath(p1,"ECCOv4")
mkdir(p1); mv(p0,p2)
p3=joinpath(p2,"build")
P=OrderedDict(:path=>p3,:options=>"-mods=../code -mpi",:exe=>"mitgcmuv")
push!(config.inputs[:setup],(:build => P))
#push!(config.inputs[:setup][:main],(:command => "mpirun -np 96 mitgcmuv"))
push!(config.inputs[:setup][:main],(:command => "qsub job.csh"))
println("creating job submission script ...")
p=joinpath(pathof(config),"run")
f=joinpath(p,"submit.csh")
create_script(p,f)
n3="mitgcmuv"
else
p3=dirname(config.inputs[:setup][:main][:exe])
n3=basename(config.inputs[:setup][:main][:exe])
end
P=OrderedDict(:path=>p3,:options=>"-mods=../code -mpi",:exe=>n3)
push!(config.inputs[:setup],(:build => P))
#push!(config.inputs[:setup][:main],(:command => "mpirun -np 96 mitgcmuv"))
push!(config.inputs[:setup][:main],(:command => "qsub job.csh"))
println("creating job submission script ...")
p=joinpath(pathof(config),"run")
f=joinpath(p,"submit.csh")
create_script(p,f)

if haskey(config.inputs[:setup][:main],:input_folder)
p=config.inputs[:setup][:main][:input_folder]
else
p=ECCO4_inputs.download_input_folder(config)
end
if isdir(p)
f=readdir(p)
pth_run=joinpath(pathof(config),"run")
[symlink(joinpath(p,f[i]),joinpath(pth_run,f[i])) for i in 1:length(f)]
end

return true
end

Expand All @@ -56,21 +78,22 @@ end
module ECCO4_inputs

using Dataverse, ClimateModels.DataFrames, ClimateModels.CSV
export get_list, get_files
import MITgcm: MITgcm_config
export get_list, get_files, download_input_folder

##

list0=[
"doi:10.7910/DVN/PICCRE,documentation,inputs_baseline2",
"doi:10.7910/DVN/PICCRE,documentation,",
"doi:10.7910/DVN/9WYSZF,surface forcing fields,forcing_baseline2",
"doi:10.7910/DVN/7XYXSF,model initialization,inputs_baseline2",
"doi:10.7910/DVN/GNOREE,in situ T-S profiles,inputs_baseline2",
"doi:10.7910/DVN/MEDQWY,sea level anomaly,inputs_baseline2",
"doi:10.7910/DVN/L3OQT0,sea surface temperature,inputs_baseline2",
"doi:10.7910/DVN/DKXQHO,ice cover fraction,inputs_baseline2",
"doi:10.7910/DVN/F8BCRF,surface wind stress,inputs_baseline2",
"doi:10.7910/DVN/SYZMUX,bottom pressure,inputs_baseline2",
"doi:10.7910/DVN/H2Q1ND,miscellaneous,inputs_baseline2"];
"doi:10.7910/DVN/7XYXSF,model initialization,",
"doi:10.7910/DVN/GNOREE,in situ T-S profiles,",
"doi:10.7910/DVN/MEDQWY,sea level anomaly,",
"doi:10.7910/DVN/L3OQT0,sea surface temperature,",
"doi:10.7910/DVN/DKXQHO,ice cover fraction,",
"doi:10.7910/DVN/F8BCRF,surface wind stress,",
"doi:10.7910/DVN/SYZMUX,bottom pressure,",
"doi:10.7910/DVN/H2Q1ND,miscellaneous,"];

fil0=joinpath(tempdir(),"Dataverse_list.csv")

Expand Down Expand Up @@ -114,7 +137,7 @@ function get_list(list1::DataFrame,name::String)
end

"""
get_files(list1::DataFrame,nam1::String)
get_files(list1::DataFrame,nam1::String,path1::String)

Create a list of Dataverse files from folder with specified `name`.

Expand All @@ -138,6 +161,29 @@ function get_files(list1::DataFrame,nam1::String,path1::String)
path3
end

"""
download_input_folder(config::MITgcm_config)
"""
function download_input_folder(config::MITgcm_config)
p=joinpath(config,"input_folder")
mkdir(p)
list1=ECCO4_inputs.get_list()
nam1="model initialization"
ECCO4_inputs.get_files(list1,nam1,p)
nam1="surface forcing fields"
ECCO4_inputs.get_files(list1,nam1,p)
if config.inputs[:pkg][:PACKAGES][:useECCO]
list2=["sea level anomaly","sea surface temperature",
"ice cover fraction","surface wind stress","bottom pressure"]
[ECCO4_inputs.get_files(list1,nam2,p) for nam2 in list2]
end
if config.inputs[:pkg][:PACKAGES][:useProfiles]
nam1="in situ T-S profiles"
ECCO4_inputs.get_files(list1,nam1,p)
end
p
end

end

module ECCO4_testreport
Expand Down
40 changes: 21 additions & 19 deletions src/ModelSteps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,32 @@ end
build(config::MITgcm_config)

Build the model using `genmake2`, `make depend`, and `make`. The first two link all
code files, headers, etc in the `build/` folder before compiling the model
code files, headers, etc in the `build/` folder before compiling the model.

(part of the climate model interface as specialized for `MITgcm`)
Note : this is skipped if `config.inputs[:setup][:main][:exe]` is specified.
"""
function build(config::MITgcm_config)
try
if !haskey(config.inputs[:setup][:main],:exe)
try
pth=pwd()
catch e
cd()
end
pth=pwd()
catch e
cd()
end
pth=pwd()
cd(config.inputs[:setup][:build][:path])
opt=config.inputs[:setup][:build][:options]
opt=Cmd(convert(Vector{String}, split(opt)))
try
@suppress run(`../../../tools/genmake2 $(opt)`)
@suppress run(`make clean`)
@suppress run(`make depend`)
@suppress run(`make -j 4`)
catch e
println("model compilation may have failed")
cd(config.inputs[:setup][:build][:path])
opt=config.inputs[:setup][:build][:options]
opt=Cmd(convert(Vector{String}, split(opt)))
try
@suppress run(`../../../tools/genmake2 $(opt)`)
@suppress run(`make clean`)
@suppress run(`make depend`)
@suppress run(`make -j 4`)
catch e
println("model compilation may have failed")
end
cd(pth)
return true
end
cd(pth)
return true
end

"""
Expand Down
9 changes: 4 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ MITgcm_download()
@test isa(Γ,NamedTuple)

#
fil=joinpath(@__DIR__,"..","examples","configurations","OCCA2.toml")
MC=MITgcm_config(inputs=read_toml(fil))
MC=MITgcm_config(inputs=read_toml(:OCCA2))
push!(MC.inputs[:setup][:main],(:input_folder => tempname()))
@suppress setup(MC)
@test MC.inputs[:setup][:build][:exe]=="mitgcmuv"

list1=ECCO4_inputs.get_list()
nam1="documentation"
@suppress ECCO4_inputs.get_files(list1,nam1,pathof(MC))
fil=joinpath(MC,"inputs_baseline2","README.pdf")
@suppress ECCO4_inputs.get_files(list1,nam1,joinpath(MC,"run"))
fil=joinpath(MC,"run","README.pdf")
@test isfile(fil)

ref_file=joinpath(MC,"MITgcm","mysetups","ECCOv4","test","testreport_baseline2.csv")
Expand Down
Loading