-
Notifications
You must be signed in to change notification settings - Fork 60
Variables and Scopes
Peter Willendrup edited this page Jan 14, 2026
·
8 revisions
Jan. 2025.
The table below describes the variable and parameter types defined in the McCode meta language, and the role they play in the generated code. This is not exhaustive, but describes the most important cases - and conditions for possible name clashes in cogen3.
| what | where | use | symbol C scope | alternative access |
|---|---|---|---|---|
| instr input par | instr file DEFINE INSTRUMENT(type parname=default) |
Runtime control | instrument section of init finally code-generated functions |
INSTRUMENT_GETPAR() macro, instrument->_parameters.parname, _instrument_var.parameters.parname
|
| instr var | instr file DECLARE | Instrument variables, comp init, sim flow control,... |
global (For OpenACC/GPU use, add: #pragma acc declare create(var)#pragma acc update device(var)) |
symbol may be re-initialised locally via instr or comp pars, uservars or local variables |
| user var | instr / comp file USERVARS (become part of _particle) |
Pass particle-dependent info along instrument | EXTEND section of comp trace functions, and cogen'd raytrace functions |
_particle->varname from component trace or cogen'd raytrace functions |
| comp par | comp file DEFINE | Comp initialisation | component init, trace, finally, save and display functions (when called with the appropriate comp var) |
COMP_GETPAR3(type, compname, par),_compname->_parameters.par,COMP_GETPAR(compname,par) for simple types |
| comp var | comp file DECLARE | Comp internal values (pr. instance) |
none |
COMP_GETPAR3(type, compname, var),_comp->_parameters.var,COMP_GETPAR(compname,var) for simple types |
| comp share | comp file SHARE | Common structs / functions pr. comp class | global | symbols may be overridden locally by instr or comp pars, user vars or local variables |