milankl / ShallowWaters.jl

A type-flexible shallow water model that can run with 16-bit arithmetic.
MIT License
115 stars 20 forks source link

Output error fix #167

Closed swilliamson7 closed 10 months ago

swilliamson7 commented 1 year ago

I think this fixes that output error I was getting before. I basically changed the function get_run_id_path to return a run_id and a run_path in the same way that SpeedyWeather does it like you suggested. It seems to be working for me now but you should probably still check, just in case

milankl commented 1 year ago

I've also removed the Manifest.toml, I know that was in the folder before, but that shouldn't be commited, hence my changes to the .gitignore file. Still the CI fails for some reason

milankl commented 1 year ago

ERROR: LoadError: LoadError: libnetcdf not properly installed. Please run Pkg.build("NetCDF") ouuuuh?

swilliamson7 commented 1 year ago

ERROR: LoadError: LoadError: libnetcdf not properly installed. Please run Pkg.build("NetCDF") ouuuuh?

I've had this happen to me before with other functions, I have no idea why. Sometimes it'll tell me something is wrong with SparseArrays for example

swilliamson7 commented 1 year ago

This output function still works for me, and fixed the mess up with path,

function get_run_id_path(S::ModelSetup)

    @unpack output,outpath,get_id_mode = S.parameters

    if output

        pattern = r"run_\d\d\d\d"               # run_???? in regex
        runlist = filter(x->startswith(x,pattern),readdir(outpath))
        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
            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(outpath,run_id2)
        @assert !(run_id2 in readdir(outpath)) "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
milankl commented 11 months ago

Note sure why there's a precompile error with libnetcdf. Can you check whether the tests pass locally?