The follow (contrived) code illustrates a problem that I would like to 
overcome.  The problem seems to be one of getting the contents of a module 
seen by multiple processors.  Is there any solution other than stripping 
the functions out of the module, putting them into a separate file and then 
using require().  Any suggestions appreciated.

addprocs(3)
using NLsolve

function fixed_point_system(x,f)

  f[1] = x[1].^2.0+x[2].^2.0+1.0
  f[2] = x[1]-0.7*x[2]-0.7

  return f

end

function solve_fixed_point_system(init,tol)

  z1 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol)
  z2 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol)
  z3 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol)
  z4 = @spawn nlsolve(fixed_point_system, init, xtol = tol, ftol = tol)

  z1 = fetch(z1)
  z2 = fetch(z2)
  z3 = fetch(z3)
  z4 = fetch(z4)

  z = (z1.zero+z2.zero+z3.zero+z4.zero)/4

  return z

end

const tol = 1e-12
init = [0.2, 1.0]

fixed_point = solve_fixed_point_system(init,tol)
println(fixed_point)

Reply via email to