Possible solution for compilation error in occigen
Code version: Commit 7abc038e...
Error: "error: jump to case label" following that "error: crosses initialization of ‘fargOCA::real rhill’" in gasDisk.cpp.
Problem:
The problem is that variables declared in one case are still visible in the subsequent cases unless an explicit { } block is used, but they will not be initialized because the initialization code belongs to another case.
Solution: wrapping each "case" in an explicit block {} after "switch" and initialize of rhill and rp in each case. You could also move out the initialization from the switch statement.
Source: https://stackoverflow.com/questions/5685471/error-jump-to-case-label#
Piece of the original code: `
switch(*disk().physic().label.advection) {
case LA_RADIUS:
for (int i = 0; i < nr; i++) {
for (int h = 0; h < ni; h++){
for (int j = 0; j < ns; j++) {
int l = j+h*ns+i*ns*ni;
field[l] = (Rmed[i]-grid.shape().radiusMin)/(grid.shape().radiusMax-grid.shape().radiusMin);
}
}
}
break;
case LA_HILL:
real rp = pos.norm();
real rhill = rp * std::pow( p.mass()/3., 1./3 );
for (int i = 0; i < nr; i++) {
for (int h = 0; h < ni; h++){
for (int j = 0; j < ns; j++) {
int l = j+h*ns+i*ns*ni;
real abs = Rmed[i] * sinPhiMed[h] * cos(thetaMed[j]);
real ord= Rmed[i] * sinPhiMed[h] * sin(thetaMed[j]);
real zco = Rmed[i] * cosPhiMed[h];
real distance = sqrt( (abs - xp)*(abs - xp) + (ord - yp)*(ord - yp)+(zco-zp)*(zco-zp));
field[l] = distance < 0.2*rhill ? 1 : 0;
}
}
}
break;
case LA_SHELL:
for (int i = 0; i < nr; i++) {
for (int h = 0; h < ni; h++){
for (int j = 0; j < ns; j++) {
int l = j+h*ns+i*ns*ni;
real abs = Rmed[i] * sinPhiMed[h] * cos(thetaMed[j]);
real ord= Rmed[i] * sinPhiMed[h] * sin(thetaMed[j]);
real zco = Rmed[i] * cosPhiMed[h];
real distance = sqrt( (abs - xp)*(abs - xp) + (ord - yp)*(ord - yp)+(zco-zp)*(zco-zp));
field[l] = (distance > 0.2*rhill && distance < 0.5*rhill) ? 1 : 0;
}
}
}
}
`