I am writing a large hydrological model for which I require to divide the program in many modules incorporated in individual files. I am questioning what will be an efficient and readable approach to share the modules across the numerous files?
I found that for e.g.
Include(“Filename.jl”)in every module is clean but not the fastest especially when I need to perform loops (which will call include many times.)
I found that an efficient way is to
include(FileName)in the MAIN() program and then to export modules as variables.
eg. EVAPOTRANSPIRATION(, evaporation, transpiration, ...)
It works but it is not elegant, so I am questioning if there is a more elegant way of sharing modules?
Below is an example which works:
module main include(“Evaporation.jl”) include(“Transpiration.jl”) include("EvapoTranspiration.jl") function MAIN(Et) for i =1:10 return EvapoTranspiration = evapoTranspiration.EVAPOTRANSPIRATION(Et * i, evaporation, transpiration) end end end
module evapoTranspiration export EVAPOTRANSPIRATION function EVAPOTRANSPIRATION(Et, evaporation, transpiration) EvapoTranspiration = evaporation.EVAPORATION(Et)+transpiration.TRANSPIRATION(i * Et) end end
module evaporation export EVAPORATION function EVAPORATION(Et) return Evaporation = Et * 0.3 end end
module transpiration export TRANSPIRATION function TRANSPIRATION(Et) return Transpiration = ET * 0.5 end end