00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #define SED_SQUALL_PROC_NAME "squall"
00022 #define EH_LOG_DOMAIN SED_SQUALL_PROC_NAME
00023
00024 #include <stdio.h>
00025 #include <math.h>
00026 #include <string.h>
00027 #include <glib.h>
00028 #include <utils/utils.h>
00029 #include <sed/sed_sedflux.h>
00030 #include <squall.h>
00031 #include "my_processes.h"
00032
00033 #include "sedflux.h"
00034
00035 Sed_process_info
00036 run_squall( Sed_process proc , Sed_cube prof )
00037 {
00038 Squall_t * data = sed_process_user_data(proc);
00039 Sed_process_info info = SED_EMPTY_INFO;
00040 double t=0, dt, total_t;
00041
00042
00043
00044
00045
00046
00047
00048 total_t = data->squall_duration;
00049 dt = data->dt;
00050
00051
00052
00053
00054 eh_message( "squall : %s" , "start" );
00055 eh_message( "time : %f" , sed_cube_age_in_years(prof) );
00056 eh_message( "time step : %f" , data->dt );
00057 eh_message( "no. of time steps : %f" , total_t/data->dt );
00058 eh_message( "wave height : %f" , sed_cube_wave_height(prof) );
00059 eh_message( "wave length : %f" , sed_cube_wave_length(prof) );
00060 eh_message( "wave period : %f" , sed_cube_wave_period(prof) );
00061
00062 do
00063 {
00064 if ( t+dt>total_t )
00065 dt = total_t-t;
00066 if ( !squall( prof , dt ) )
00067 {
00068 eh_message( "squall : %s" , "done" );
00069 return info;
00070 }
00071 t += dt;
00072 }
00073 while ( t<total_t );
00074
00075 eh_message( "squall : %s" , "done" );
00076
00077 return info;
00078 }
00079
00080 #define S_KEY_TIME_STEP "time step"
00081 #define S_KEY_TIME_FRACTION "duration of squall"
00082
00083 gboolean
00084 init_squall( Sed_process p , Eh_symbol_table tab , GError** error )
00085 {
00086 Squall_t* data = sed_process_new_user_data( p , Squall_t );
00087 GError* tmp_err = NULL;
00088 gchar** err_s = NULL;
00089 gboolean is_ok = TRUE;
00090
00091 eh_return_val_if_fail( error==NULL || *error==NULL , FALSE );
00092
00093
00094 data->dt = eh_symbol_table_time_value( tab , S_KEY_TIME_STEP );
00095 data->squall_duration = eh_symbol_table_time_value( tab , S_KEY_TIME_FRACTION );
00096
00097 eh_check_to_s( data->dt>=0. , "Time step positive" , &err_s );
00098 eh_check_to_s( data->squall_duration>=0. , "Duration of squall positive" , &err_s );
00099
00100 if ( !tmp_err && err_s )
00101 eh_set_error_strv( &tmp_err , SEDFLUX_ERROR , SEDFLUX_ERROR_BAD_PARAM , err_s );
00102
00103 if ( tmp_err )
00104 {
00105 g_propagate_error( error , tmp_err );
00106 is_ok = FALSE;
00107 }
00108
00109 return is_ok;
00110 }
00111
00112 gboolean
00113 destroy_squall( Sed_process p )
00114 {
00115 if ( p )
00116 {
00117 Squall_t* data = sed_process_user_data( p );
00118
00119 if ( data ) eh_free( data );
00120 }
00121
00122 return TRUE;
00123 }
00124