Skip to content

Commit

Permalink
Cleaner exits
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuMoalic committed May 26, 2023
1 parent 41fdf68 commit 3f59e2d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetBusy() bool {
}

// Cleanly exits the simulation, assuring all output is flushed.
func Close() {
func CleanExit() {
if outputdir == "" {
return
}
Expand Down
2 changes: 1 addition & 1 deletion engine/gofiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ func InitAndClose() func() {
GoServe(*Flag_webui_addr)

return func() {
Close()
CleanExit()
}
}
3 changes: 2 additions & 1 deletion engine/od.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package engine

import (
"fmt"
"os"
"strings"

"github.com/MathieuMoalic/amumax/httpfs"
Expand Down Expand Up @@ -43,7 +44,7 @@ func InitIO(inputfile, od string) {
// cursed error check, not sure how to do better
if fmt.Sprint(err) == fmt.Sprintf("mkdir %s: file exists", od) {
LogErr(fmt.Sprintf("Directory `%s` exists, skipping `%s` because of --skip-exist flag.", od, inputfile))
Exit()
os.Exit(0)
} else {
util.FatalErr(err)
}
Expand Down
3 changes: 1 addition & 2 deletions engine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func adaptDt(corr float64) {
util.AssertMsg(Dt_si > 0, fmt.Sprint("Time step too small: ", Dt_si))
}


// Run the simulation for a number of seconds.
func RunWithoutPrecession(seconds float64) {
prevPrecess := Precess
Expand Down Expand Up @@ -256,6 +255,6 @@ func SanityCheck() {
}

func Exit() {
Close()
CleanExit()
os.Exit(0)
}
2 changes: 1 addition & 1 deletion engine/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func Vector(x, y, z float64) data.Vector {
func Expect(msg string, have, want, maxError float64) {
if math.IsNaN(have) || math.IsNaN(want) || math.Abs(have-want) > maxError {
LogOut(msg, ":", " have: ", have, " want: ", want, "±", maxError)
Close()
CleanExit()
os.Exit(1)
} else {
LogOut(msg, ":", have, "OK")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func main() {
os.Exit(0)
}

defer engine.Close() // flushes pending output, if any
defer engine.CleanExit() // flushes pending output, if any

if *flag_vet {
vet()
Expand Down

0 comments on commit 3f59e2d

Please sign in to comment.