# Modules and files

**URL:** <https://discourse.julialang.org/t/modules-and-files/36330>\
**Category:** General Usage\
**Created:** [March 22, 2020, 2:05am UTC](https://discourse.julialang.org/t/modules-and-files/36330 "2020-03-22T02:05:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinhphunguyen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinhphunguyen/32/16316_2.png) [@vinhphunguyen](https://discourse.julialang.org/u/vinhphunguyen)\
**Post date:** [March 22, 2020, 2:05am UTC](https://discourse.julialang.org/t/modules-and-files/36330/1 "2020-03-22T02:05:42Z")

</div>

Hi all,

I have this code with 3 files: MaterialPoint.jl for module MaterialPoint as follows

```julia
   module MaterialPoint
   using LinearAlgebra
   export mpmMaterialPoint_2D_Classic,createMaterialDomain_Circle
   	mutable struct mpmMaterialPoint_2D_Classic
       end
       function createMaterialDomain_Circle(fCenter::Array{Float64}, fRadius::Float64, fOffset::Float64)
      end
end

```

And file Grid.jl implements the module Grid as

```nohighlight
module Grid
using MaterialPoint 
struct mpmGrid
end
function getAdjacentGridPoints(thisMaterialPoint::mpmMaterialPoint_2D_Classic,
                                   thisGrid::mpmGrid)
end
 export getAdjacentGridPoints
 export mpmGrid
end

```

And the final file, Main.jl, uses modules Grid and MaterialPoint:

```julia
push!(LOAD_PATH,"/Users/vingu/Dropbox/JuliaCodes/Classic_2D_2Disk/")
using Printf
using Grid
using MaterialPoint
using Basis

function mpmMain()
   thisGrid = Grid.mpmGrid(1.0, 1.0, 21, 21)
   thisMaterialDomain_01 = MaterialPoint.createMaterialDomain_Circle([0.2; 0.2], 0.2, fOffset)
   thisAdjacentGridPoints = getAdjacentGridPoints(thisMaterialPoint, thisGrid)
end

```

My question is: why I had to write Grid.mpmGrid(1.0, 1.0, 21, 21), not mpmGrid(1.0, 1.0, 21, 21) as I exported mpmGrid???

Note that thisAdjacentGridPoints = getAdjacentGridPoints(thisMaterialPoint, thisGrid) works fine without explicitly using Grid.getAdjacent…

Thanks,  
P

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 22, 2020, 7:05am UTC](https://discourse.julialang.org/t/modules-and-files/36330/2 "2020-03-22T07:05:28Z")

</div>

Please quote your code (you can edit your post).

> [@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 …

---

<div class="post-metadata">

**Author:** ![vinhphunguyen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinhphunguyen/32/16316_2.png) [@vinhphunguyen](https://discourse.julialang.org/u/vinhphunguyen)\
**Post date:** [March 22, 2020, 9:54am UTC](https://discourse.julialang.org/t/modules-and-files/36330/3 "2020-03-22T09:54:37Z")

</div>

Thanks a lot. I edited my post.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 22, 2020, 11:40am UTC](https://discourse.julialang.org/t/modules-and-files/36330/4 "2020-03-22T11:40:35Z")

</div>

This should work — eg consider this MWE:

```julia
julia> push!(LOAD_PATH, pwd());

julia> using Grid
[Info: Precompiling Grid [top-level]

julia> mpmGrid()
mpmGrid()

shell> cat Grid.jl
module Grid
export mpmGrid
struct mpmGrid end
end

```

I am wondering if this is a workflow problem: did you save `Grid.jl` before loading (if you worked on it), if or whether you are using Revise.jl.

---

<div class="post-metadata">

**Author:** ![vinhphunguyen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinhphunguyen/32/16316_2.png) [@vinhphunguyen](https://discourse.julialang.org/u/vinhphunguyen)\
**Post date:** [March 22, 2020, 5:57pm UTC](https://discourse.julialang.org/t/modules-and-files/36330/5 "2020-03-22T17:57:01Z")

</div>

Yes, it works. Probably due to Juno as I am new to it. Thanks.
