From ff2977b892a01fe4ffb0c0bf1f77488c71a3f07e Mon Sep 17 00:00:00 2001 From: Sarah Williamson Date: Tue, 19 Sep 2023 10:39:18 -0500 Subject: [PATCH] Adding new runid Changed the id and path of the output to match the way SpeedyWeather does it --- Manifest.toml | 117 ++++++++++++++++++++++++++++++++++---- src/default_parameters.jl | 2 +- src/output.jl | 53 +++++++---------- 3 files changed, 130 insertions(+), 42 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index c17f380..99dd13a 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,5 +1,12 @@ # This file is machine-generated - editing it directly is not advised +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.1" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + [[AxisAlgorithms]] deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"] git-tree-sha1 = "a4d07a1c313392a77042855df46c5f534076fab9" @@ -15,6 +22,11 @@ git-tree-sha1 = "46cf2c1668ad07aba5a9d331bdeea994a1f13856" uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" version = "1.0.1" +[[CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.0.5+1" + [[Conda]] deps = ["JSON", "VersionParsing"] git-tree-sha1 = "7a58bb32ce5d85f8bf7559aa7c2842f9aecf52fc" @@ -40,6 +52,14 @@ version = "0.2.3" deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" + [[Formatting]] deps = ["Printf"] git-tree-sha1 = "a0c901c29c0e7c763342751c0a94211d56c0de5c" @@ -62,15 +82,30 @@ git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e" uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.21.0" +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.4" + +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "8.0.1+1" + [[LibGit2]] -deps = ["Printf"] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.11.0+1" + [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[LinearAlgebra]] -deps = ["Libdl"] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[Logging]] @@ -80,20 +115,38 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.2+1" + [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2023.1.10" + [[NetCDF]] deps = ["BinDeps", "CondaBinDeps", "DiskArrays", "Formatting", "Libdl"] git-tree-sha1 = "0c6a63d16e9261bf2fa4eecbab575ae7e7fef11c" uuid = "30363a11-5582-574a-97bb-aa9a979735b9" version = "0.10.2" +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" + [[OffsetArrays]] git-tree-sha1 = "930db8ef90483570107f2396b1ffc6680f08e8b7" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" version = "1.0.4" +[[OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.23+2" + [[OrderedCollections]] deps = ["Random", "Serialization", "Test"] git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" @@ -101,10 +154,10 @@ uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" version = "1.1.0" [[Parameters]] -deps = ["OrderedCollections"] -git-tree-sha1 = "b62b2558efb1eef1fa44e4be5ff58a515c287e38" +deps = ["OrderedCollections", "UnPack"] +git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe" uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a" -version = "0.12.0" +version = "0.12.3" [[Parsers]] deps = ["Dates", "Test"] @@ -113,19 +166,20 @@ uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" version = "1.0.2" [[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.10.0" [[Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" [[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets"] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[Random]] -deps = ["Serialization"] +deps = ["SHA"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[Ratios]] @@ -135,6 +189,7 @@ version = "0.4.0" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -147,8 +202,9 @@ uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[SparseArrays]] -deps = ["LinearAlgebra", "Random"] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.10.0" [[StaticArrays]] deps = ["LinearAlgebra", "Random", "Statistics"] @@ -159,9 +215,25 @@ version = "0.12.2" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.9.0" + +[[SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "7.2.0+1" + +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.3" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.0" [[Test]] -deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[URIParser]] @@ -174,6 +246,11 @@ version = "0.4.1" deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +[[UnPack]] +git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b" +uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" +version = "1.0.2" + [[Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" @@ -187,3 +264,23 @@ deps = ["LinearAlgebra", "SparseArrays"] git-tree-sha1 = "28ffe06d28b1ba8fdb2f36ec7bb079fac81bac0d" uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6" version = "0.5.2" + +[[Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.13+1" + +[[libblastrampoline_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.8.0+1" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.52.0+1" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+2" diff --git a/src/default_parameters.jl b/src/default_parameters.jl index 570faa5..6cc301c 100644 --- a/src/default_parameters.jl +++ b/src/default_parameters.jl @@ -112,7 +112,7 @@ # INITIAL CONDITIONS initial_cond::String="rest" # "rest" or "ncfile" for restart from file - initpath::String=outpath # folder where to pick the restart files from + path::String=outpath # folder where to pick the restart files from init_run_id::Int=0 # run id for restart from run number init_starti::Int=-1 # timestep to start from (-1 meaning last) get_id_mode::String="continue" # How to determine the run id: "continue" or "fill" diff --git a/src/output.jl b/src/output.jl index 3d271a4..49449ac 100644 --- a/src/output.jl +++ b/src/output.jl @@ -172,41 +172,32 @@ end """Checks output folders to determine a 4-digit run id number.""" function get_run_id_path(S::ModelSetup) - @unpack output,outpath,get_id_mode = S.parameters + @unpack output,outpath,get_id_mode,path = S.parameters if output - runlist = filter(x->startswith(x,"run"),readdir(outpath)) - existing_runs = [parse(Int,id[4:end]) for id in runlist] + + pattern = r"run_\d\d\d\d" # run_???? in regex + runlist = filter(x->startswith(x,pattern),readdir(path)) + runlist = filter(x->endswith( x,pattern),runlist) + existing_runs = [parse(Int,id[5:end]) for id in runlist] + + # get the run id from existing folders if length(existing_runs) == 0 # if no runfolder exists yet - runpath = joinpath(outpath,"run0000") - mkdir(runpath) - return 0,runpath - else # create next folder - if get_id_mode == "fill" # find the smallest gap in runfolders - run_id = gap(existing_runs) - runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id)) - mkdir(runpath) - - elseif get_id_mode == "specific" # specify the run_id as input argument - @unpack run_id = S.parameters - runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id)) - try # create folder if not existent - mkdir(runpath) - catch # else rm folder and create new one - rm(runpath,recursive=true) - mkdir(runpath) - end - - elseif get_id_mode == "continue" # find largest folder and count one up - run_id = maximum(existing_runs)+1 - runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id)) - mkdir(runpath) - else - throw(error("Order '$get_id_mode' is not valid for get_run_id_path(), choose continue or fill.")) - end - return run_id,runpath + run_id = 1 # start with run_0001 + else + run_id = maximum(existing_runs)+1 # next run gets id +1 end + + id = @sprintf("%04d",run_id) + + run_id2 = string("run_",id) + run_path = joinpath(path,run_id2) + @assert !(run_id2 in readdir(path)) "Run folder $run_path already exists." + mkdir(run_path) # actually create the folder + + return run_id, run_path + else return 0,"no runpath" end -end +end \ No newline at end of file