# @spawnat with SlurmClusterManager

**URL:** https://discourse.julialang.org/t/spawnat-with-slurmclustermanager/78930
**Category:** General Usage
**Tags:** question, distributed
**Created:** [April 3, 2022, 4:37am UTC](https://discourse.julialang.org/t/spawnat-with-slurmclustermanager/78930 "2022-04-03T04:37:26Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![andrew-saydjari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrew-saydjari/32/19896_2.png) [@andrew-saydjari](https://discourse.julialang.org/u/andrew-saydjari)
#### Post date: [April 3, 2022, 7:06am UTC](https://discourse.julialang.org/t/spawnat-with-slurmclustermanager/78930/2 "2022-04-03T07:06:00Z")

</div>

It seems the following works, though isn’t amazingly pretty. Thoughts appreciated.

```julia
@everywhere begin
    function return_id(x)
        return myid(), gethostname()
    end
end
nworkers = length(workers())
out = pmap(return_id,1:nworkers)
idlst = map(x->x[1],out)
hostlist = map(x->x[2],out)
df = DataFrame(id=idlst,host=hostlist)
gp = groupby(df, :host)
gvec = gp.groups
nodeworkers = []
for i = 1:maximum(gvec)
    push!(nodeworkers,df.id[gvec.==i])
end

```

Then you can manually build the SharedArray across the groups of workers on the same node by iterating over the nodeworkers list made above.

```julia
for subworkers in nodeworkers
    x = SharedArray{Int64}((2,2), init=false, pids=subworkers)
    x .= [1 2; 3 4]
end

```

---

_[View the full topic](https://discourse.julialang.org/t/spawnat-with-slurmclustermanager/78930)._
