# Parrallel programming

**URL:** <https://discourse.julialang.org/t/parrallel-programming/41659>\
**Category:** General Usage\
**Tags:** package, proposal, plotting, diffeq\
**Created:** [June 18, 2020, 9:47am UTC](https://discourse.julialang.org/t/parrallel-programming/41659 "2020-06-18T09:47:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyacykcharel](https://avatars.discourse-cdn.com/v4/letter/h/58956e/32.png) [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Post date:** [June 18, 2020, 9:47am UTC](https://discourse.julialang.org/t/parrallel-programming/41659/1 "2020-06-18T09:47:22Z")

</div>

| hello im trying to to a parallel compuing but it is not workig can someone please correct this code for me thans? | |
| --- | --- |

using Distributed  
addprocs(1)  
nprocs()  
procs()  
workers()  
nworkers()  
@everywhere using DistributedArrays  
@everywhere using SharedArrays  
@everywhere using LinearAlgebra  
using Plots  
n=100

@everywhere function Creating\_Matrix\_A\_b(n)  
A = dzeros((n-1)^2,(n-1)^2)

```
#write diagonal block matrices
@distributed (+) for k=1:n-1
    @distributed (+) for l=1:n-1
        A[CartesianIndex.((k-1)*(n-1)+l,(k-1)*(n-1)+l)] .= 4
    end

    @distributed (+) for l=2:n-1
        A[CartesianIndex.((k-1)*(n-1)+l-1,(k-1)*(n-1)+l)] .= -1
        A[CartesianIndex.((k-1)*(n-1)+l,(k-1)*(n-1)+l-1)] .= -1
    end
end

#write upper/lower diagonal block matrices
@distributed (+) for k=2:n-1
    for l=1:n-1
        A[CartesianIndex.((k-2)*(n-1)+l,(k-1)*(n-1)+l)] = -1
        A[CartesianIndex.((k-1)*(n-1)+l,(k-2)*(n-1)+l)] = -1
    end
end

b = 1/n^2 * ones((n-1)^2,1)
return [A,b]

```

end

(A,b)  
#Solve Poisson-equation using dense matrix

#solve linear system  
z = A\b

#add boundary values for graphical output  
Z = [zeros(1,n+1); [zeros(n-1,1) reshape(z,(n-1,n-1)) zeros(n-1,1)]; zeros(1,n+1)]

##add boundary values for graphical output  
#Z=zeros(n+1,n+1);

# 

#for k=1:n-1  
#for l=1:n-1  
#Z[CartesianIndex.(k+1,l+1)] .= z[(k-1)\*(n-1)+l]  
#end  
#end

#plot result  
h = 1.0/n  
x = collect(0:h:1)  
y = collect(0:h:1)  
pyplot()  
surface(x,y,Z,)

title!(“Solution of Poisson Equation”)  
xlabel!(“x”)  
ylabel!(“y”)[quote=“hyacykcharel, post:1, topic:41659, full:true”]

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 18, 2020, 11:04am UTC](https://discourse.julialang.org/t/parrallel-programming/41659/2 "2020-06-18T11:04:04Z")

</div>

Welcome to the community. You are very unlikely to get help if you post such a large amount of code and with such messy formatting. Try breaking the problem down into smaller pieces and ask for help on a concrete problem. In particular, provide a small code snippet that reproduces the error you get so that people can copy and paste it into their own REPL. See this topic

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
