ld-archer / E_FEM

This is the repository for the English version of the Future Elderly Model, originally developed at the Leonard D. Schaeffer Center for Health Policy and Microsimulation.
MIT License
3 stars 1 forks source link

Missing model error when trying to compile FEM #107

Open ld-archer opened 1 year ago

ld-archer commented 1 year ago

I have cloned a fresh copy of the EFEM repo to my new PC, and when running make FEM, getting the following error:

mpicxx   -DHAVE_CXX_IOSTREAM -DHAVE_NAMESPACE_STD -D__FEM_UNIX__   -Wall -Werror -O3 -MMD -ffast-math -msse2 -c FEM_CPP/CrossSectionalModule.cpp -o FEM_CPP/optimized/CrossSectionalModule.o
FEM_CPP/CrossSectionalModule.cpp: In member function ‘virtual void CrossSectionalModule::setModelProvider(IModelProvider*)’:
FEM_CPP/CrossSectionalModule.cpp:190:32: error: catching polymorphic type ‘class fem_exception’ by value [-Werror=catch-value=]
  190 |         } catch (fem_exception e) {
      |                                ^
FEM_CPP/CrossSectionalModule.cpp:198:40: error: catching polymorphic type ‘class fem_exception’ by value [-Werror=catch-value=]
  198 |                 } catch (fem_exception e) {
      |                                        ^
cc1plus: all warnings being treated as errors
make: *** [fem.makefile:37: FEM_CPP/optimized/CrossSectionalModule.o] Error 1

I have followed the error from this function in CrossSectionalModule.cpp...:

void CrossSectionalModule::setModelProvider(IModelProvider* modp) {
    std::ostringstream ss;

    mp = modp;
    if(mp == NULL)
        return;

    try {
        sscalc.setModelProvider(mp);
    } catch (fem_exception e) {
        ss << e.what();
    }

    std::vector<Vars::Vars_t>::iterator it;
    for(it = vars_to_model.begin(); it != vars_to_model.end() && ss.str().length() == 0; ++it) {    
        try {
            models[*it] = mp->get(VarsInfo::labelOf(*it));
        } catch (fem_exception e) {
            ss << this->description() << " needs model " << VarsInfo::labelOf(*it);
        }
    }
    if(ss.str().length() > 0)
        throw fem_exception(ss.str().c_str());
}

...to this function in SSCalculator.cpp:

void SSCalculator::setModelProvider(IModelProvider* mp) {
    try {
        isret_wd_model = mp->get("isret_wd");
    } catch (fem_exception e) {
        throw fem_exception("Social Security Calculator needs isret_wd model");
    }
}

These are all warnings from the compile process, which with the inclusion of the -Werror flag cause a failure - -Werror tells the compiler to treat all warnings as errors. I think this is something to do with the order of compilation, where the file that should set the paths to the models is not being run before the files that rely on these paths. The order of compilation is also different on my laptop, but I haven't been able to figure out why. The laptop order is seemingly random (but I suspect set somewhere), whereas my PC runs things in alphabetical order. Also I copied over the FEM object from my laptop when moving to the PC, which I suspect is why the model compiled and ran previously.

In any case, I have been able to compile and run the model by removing the -Werror flag and accepting the warnings without throwing an error. I sort of remember having to do this a long time ago, so hopefully this is the last of this particular error. I'm opening this issue with a WARNING flag, so that I can come back to this if any other problems arise.