- #1
icwchan
- 6
- 0
Hi everyone,
So I'm familiar with the popular advice that global variables should be avoided whenever possible, but I'm wondering how seriously people in scientific programming obey this rule of thumb.
I am current engaged in writing some code for semiconductor transport, and I'm finding that I require a lot of data that needs to accessed practically everywhere in the program (eg. for example, I have a set of wavefunctions that are used in a multitude of different calculations.) I tried avoiding the global route at first, but the argument lists for my subroutines were getting obscenely long (I stopped at around 15 for one of the functions). Finally exasperated with the constant parameter list fiddling and debugging, I gave up and bundled everything up into a (almost) universally accessible module (in case you were wondering, I'm doing the heavy number crunching in Fortran 90 with f2py for use in a python framework).
I'm sure I'm not the first person to encounter this problem, but most of my googling turns up results from CS guys who think global variable users should be drawn and quartered; I hope it's okay to ask for a second opinion here, hopefully from someone experienced in scientific programming... What's the usual approach to passing around large quantities of data internally in a program?
Thank you in advance!
IC
So I'm familiar with the popular advice that global variables should be avoided whenever possible, but I'm wondering how seriously people in scientific programming obey this rule of thumb.
I am current engaged in writing some code for semiconductor transport, and I'm finding that I require a lot of data that needs to accessed practically everywhere in the program (eg. for example, I have a set of wavefunctions that are used in a multitude of different calculations.) I tried avoiding the global route at first, but the argument lists for my subroutines were getting obscenely long (I stopped at around 15 for one of the functions). Finally exasperated with the constant parameter list fiddling and debugging, I gave up and bundled everything up into a (almost) universally accessible module (in case you were wondering, I'm doing the heavy number crunching in Fortran 90 with f2py for use in a python framework).
I'm sure I'm not the first person to encounter this problem, but most of my googling turns up results from CS guys who think global variable users should be drawn and quartered; I hope it's okay to ask for a second opinion here, hopefully from someone experienced in scientific programming... What's the usual approach to passing around large quantities of data internally in a program?
Thank you in advance!
IC