I’m trying to set up Julia to interact with an external program. I need to run the external program a lot and I have access to a cluster so since the external program only uses one core I think it makes sense to distribute the work by running separate instances on several cores at once.
I’m using “@spawnat” to call a Julia function that launches the external program. The main program starts the workers:
### mre.jl main program using Distributed using HDF5 nprocs = 3 if nprocs() < NP addprocs(NP-nprocs()) end @everywhere include("/Users/me/demo.jl") Threads.@threads for i = 1:100 f = @spawnat :any demo(i) end
The secondary function launches the external program (bolsigminus) and saves the data:
function demo(x) input = "/Users/me/new_input_deck.dat" run(`./bolsigminus $input`) h5write("/Users/me/demo"*string(x)*".h5", "Data/xs", x) end
When I run the main program from the REPL it works perfectly. When I run the main program from the command line using
julia -p 3 mre.jl the external program launches on each worker but just stops and exits partway through on the first execution without any error messages. I want it to work from the command line because I’m going to have to submit these to the queue on the cluster.
I’m a newbie so I apologize if the answer is obvious, but I’m baffled. Any suggestions are greatly appreciated!