00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #define SED_CONSTANTS_PROC_NAME "constants"
00022 #define EH_LOG_DOMAIN SED_CONSTANTS_PROC_NAME
00023
00024 #include <stdio.h>
00025 #include <math.h>
00026 #include <utils/utils.h>
00027 #include <sed/sed_sedflux.h>
00028 #include "my_processes.h"
00029
00030 Sed_process_info
00031 run_constants( Sed_process proc , Sed_cube prof )
00032 {
00033 Constants_t* data = sed_process_user_data(proc);
00034 Sed_process_info info = SED_EMPTY_INFO;
00035
00036 {
00037 Sed_constants c;
00038 double cube_age = sed_cube_age_in_years( prof );
00039
00040 c.gravity = eh_input_val_eval( data->gravity , cube_age );
00041 c.rho_sea_h2o = eh_input_val_eval( data->rho_sea_h2o , cube_age );
00042 c.rho_h2o = eh_input_val_eval( data->rho_h2o , cube_age );
00043 c.salinity = eh_input_val_eval( data->salinity , cube_age );
00044 c.rho_quartz = eh_input_val_eval( data->rho_quartz , cube_age );
00045 c.rho_mantle = eh_input_val_eval( data->rho_mantle , cube_age );
00046
00047 set_cube_set_constants( prof , c );
00048 }
00049
00050 sed_set_gravity ( sed_cube_constants(prof).gravity );
00051 sed_set_rho_sea_water ( sed_cube_constants(prof).rho_sea_h2o );
00052 sed_set_rho_fresh_water( sed_cube_constants(prof).rho_h2o );
00053 sed_set_sea_salinity ( sed_cube_constants(prof).salinity );
00054 sed_set_rho_quartz ( sed_cube_constants(prof).rho_quartz );
00055 sed_set_rho_mantle ( sed_cube_constants(prof).rho_mantle );
00056
00057 eh_message( "time : %f" , sed_cube_age_in_years(prof) );
00058 eh_message( "gravity : %f" , sed_cube_constants(prof).gravity );
00059 eh_message( "density of sea water : %f" , sed_cube_constants(prof).rho_sea_h2o );
00060 eh_message( "density of water : %f" , sed_cube_constants(prof).rho_h2o );
00061 eh_message( "density of quartz : %f" , sed_cube_constants(prof).rho_quartz );
00062 eh_message( "density of mantle : %f" , sed_cube_constants(prof).rho_mantle );
00063
00064 return info;
00065 }
00066
00067 #define S_KEY_CONST_GRAVITY "acceleration due to gravity"
00068 #define S_KEY_CONST_RHO_SEA_H2O "density of sea water"
00069 #define S_KEY_CONST_RHO_H2O "density of fresh water"
00070
00071
00072 #define S_KEY_CONST_SALINITY "ocean salinity"
00073 #define S_KEY_CONST_RHO_QUARTZ "density of quartz"
00074 #define S_KEY_CONST_RHO_MANTLE "density of mantle"
00075
00076 gboolean
00077 init_constants( Sed_process p , Eh_symbol_table tab , GError** error )
00078 {
00079 Constants_t* data = sed_process_new_user_data( p , Constants_t );
00080 GError* tmp_err = NULL;
00081 gboolean is_ok = TRUE;
00082
00083 eh_return_val_if_fail( error==NULL || *error==NULL , FALSE );
00084
00085 if ( !tmp_err ) data->gravity = eh_symbol_table_input_value( tab , S_KEY_CONST_GRAVITY , &tmp_err );
00086 if ( !tmp_err ) data->rho_sea_h2o = eh_symbol_table_input_value( tab , S_KEY_CONST_RHO_SEA_H2O , &tmp_err );
00087 if ( !tmp_err ) data->rho_h2o = eh_symbol_table_input_value( tab , S_KEY_CONST_RHO_H2O , &tmp_err );
00088 if ( !tmp_err ) data->salinity = eh_symbol_table_input_value( tab , S_KEY_CONST_SALINITY , &tmp_err );
00089 if ( !tmp_err ) data->rho_quartz = eh_symbol_table_input_value( tab , S_KEY_CONST_RHO_QUARTZ , &tmp_err );
00090 if ( !tmp_err ) data->rho_mantle = eh_symbol_table_input_value( tab , S_KEY_CONST_RHO_MANTLE , &tmp_err );
00091
00092 if ( tmp_err )
00093 {
00094 g_propagate_error( error , tmp_err );
00095 is_ok = FALSE;
00096 }
00097
00098 return is_ok;
00099 }
00100
00101 gboolean
00102 destroy_constants( Sed_process p )
00103 {
00104 if ( p )
00105 {
00106 Constants_t* data = sed_process_user_data( p );
00107
00108 if ( data )
00109 {
00110 eh_input_val_destroy( data->gravity );
00111 eh_input_val_destroy( data->rho_sea_h2o );
00112 eh_input_val_destroy( data->rho_h2o );
00113 eh_input_val_destroy( data->salinity );
00114 eh_input_val_destroy( data->rho_quartz );
00115 eh_input_val_destroy( data->rho_mantle );
00116 eh_free ( data );
00117 }
00118 }
00119
00120 return TRUE;
00121 }