Version 6 (modified by 10 years ago) ( diff ) | ,
---|
Introduction
The idea is that comparing integers in C++ is easier and faster than comparing strings. So each model input is assigned an enum. In the code you will see IceVolumeAboveFloatationEnum
but the code interpret this word as the integer 682. Each enum has a number associated to it automatically by the compiler. See this wikipedia page for more info.
Add a new Enum
If you want to add a new Enum, the ONLY file that needs to be changed is src/c/shared/Enum/EnumDefinitions.h`. Open it with you favorite editor (vim) and add your new Enum. Make sure that:
- It does not already exist (the compiler will tell you anyway)
- It finishes with
Enum,
Then you can run a synchronization script that will update the matlab and python Enum, StringToEnum and EnumToString automatically:
cd $ISSM_DIR/src/c/shared/Enum/ ./Synchronize.sh
You will then need to recompile the entire trunk (not just src/c), and there is no need to reconfigure:
cd $ISSM_DIR/ make install
Checking in the changes
In order to commit the new Enum, you will need to svn add
the new matlab file in $ISSM_DIR/src/m/enum
, and then commit all the files in $ISSM_DIR/src/m/enum
and $ISSM_DIR/src/c/shared/Enum
NB : if you want to check if your Enum is added, you can type it in Matlab and it has to return a number.
NB 2 : if you are developing and making modifications on the source files on a cluster like GreenPlanet, when you want to add an Enum, don't forget to update on your local machine the folders $ISSM_DIR/src/m/enum
and $ISSM_DIR/src/c/shared/Enum
because the Matlab software you are using is on your local machine.