Reading input parameters from a text file

No, that’s a data structure.

For example, suppose you wanted to change the parameters in a loop. Or generate and save an ensemble of thousands of different parameter sets. A data structure can be updated dynamically or stored in an array, but a module is not designed for this.

I second @JoshuaLampert’s comment above:

  • Structure your code to provide functions and pass data via parameters (possibly packaging related parameters into data structures for convenience), not as scripts where the parameters are global variables.
  • Create a Julia package+module to hold your simulation functions and data structure definitions (but not the parameter values from individual runs). See Best practise: organising code in Julia - #2 by stevengj
  • The prototypical way of saving parameters is probably a Julia script (that imports your module for the simulation functions, and then calls the functions with particular parameter values).
  • Once you have parameters packed into Julia data structures, you can also save them into any compatible file format, e.g. JLD files or JSON.
3 Likes