Define the name of the process as well as it's log domain. This is necessary so that logging messages will be written to the correct file.
#define SED_NEW_PROCESS_PROC_NAME "new process" #define EH_LOG_DOMAIN SED_NEW_PROCESS_PROC_NAME
Define the function that is called everytime the process is run. The first argument is a pointer to the instance data of this process and the second is the Sed_cube that the process acts on. Initialize the mass balance information.
run_new_process( Sed_process proc , Sed_cube prof ) { New_process_t* data = sed_process_user_data(proc); Sed_process_info info = SED_EMPTY_INFO;
When a process is destroyed, it's run function is called with prof
== NULL to indicate that any allocated resources should be freed.
/* Free resources used by data ... */ /* ... and the data itself */ eh_free( data ); } }
If the instance data has not yet been initialized (and it needs to be), do it here.
}
The process now acts on the Sed_cube. In this case, we change sea level by a user specified amount.
The mass of the Sed_cube is measured before and after the process is run. If any sediment is (intentionally) added or removed from the system, it should be included here.
Define an init_func for your new process. This function is called everytime sedflux initializes a new instance of your process.
param
is unique for each instance of the process. Thus, sedflux is able to run different version of the same process. Declare the functions to run and initialize the new process.
Now that we have created functions to run and initialize our process, we must add it to the list of processes that sedflux will run. We do this in init.c. All that needs to be done here is to add our new process to the process_list variable,
This variable is a list of all the process that sedflux will run (in the order that they will be run!). Each element of the array tells sedflux the name of the process, the size of the process-specific data structure, the function used to initialize the process, and the function used to run the process.
Add the new process to the list. The new process is run after the river process and before the bed load dumping process.
The remainder of the processes.
Include the header file for the new process.
sedflux_SOURCES += run_new_process.c
as well as its header file.
noinst_HEADERS += run_new_process.h