JuliaLang / JuliaLang/PackageCompiler.jl

When I run the compiled the APP, the APP dispalys the "UndefVarError" error, and the variable is in the distributed scope. The following is my code.

Open
#746 0 comments 0 reactions 0 assignees View on GitHub
invalid question
Dominant language
Julia
Stars
1.6k
Forks
205
Avg merge
18h 37m
Merged PRs (30d)
7

Description

```julia

VERSION == v"0.7.0" && __precompile__()

module WEM3D

using Distributed
using Artifacts
using MKL_jll

include("CSEMFileIO/CSEMFileIO.jl")

function julia_main()::Cint

addprocs(12)
@eval @everywhere begin
using WEM3D.CSEMFileIO
end

@eval @everywhere begin

workpath = "/home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/"
datafile = workpath * "wemFwdblock0116_pred.dat"
println("Reading data file $(datafile) ...")
#datafile = workpath * datafile
emData = readCSEMData(datafile)

# model file
modfile = workpath * "wemInvblock0116.model"
println("Reading model file $(modfile) ...")
sigBody = 0.1
sigAir = 1e-8
sigWater = 3.3
@time emMesh = readCSEMModel(modfile; sigAir = sigAir, sigWater = sigWater)

end

#
println("Calculating primary field ...")
cputime01 = @elapsed epField = parPrimaryElectricField(emMesh)

return 0

end

end
```
When run this, the running info is:
```shell
From worker 10: Reading data file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemFwdblock0116_pred.dat ...
From worker 10: Reading model file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemInvblock0116.model ...
From worker 9: Reading data file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemFwdblock0116_pred.dat ...
From worker 9: Reading model file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemInvblock0116.model ...
From worker 11: Reading data file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemFwdblock0116_pred.dat ...
From worker 11: Reading model file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemInvblock0116.model ...
From worker 12: Reading data file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemFwdblock0116_pred.dat ...
From worker 12: Reading model file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemInvblock0116.model ...
From worker 13: Reading data file /home/em/julia_workshop/WEM3D/WEM3D/test/wemInv0116/wemFwdblock0116_pred.dat ...
1.809170 seconds (2.50 M allocations: 732.809 MiB, 19.01% gc time, 63.54% compilation time)
Calculating primary field ...
UndefVarError: emMesh not defined
```
But when I run the original julia code, it works well in my workstation. Can you help me to solve the variable scope problem?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the compiled application's julia_main function and its @everywhere blocks, then inspect how emMesh is created before parPrimaryElectricField(emMesh) runs. Reproduce the compiled application and determine whether the distributed-scope setup leaves emMesh unavailable; done means the reported UndefVarError no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
devtools, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.