static void client_read_trooper(const remote_process_client *client, struct ct_trooper *trooper) { if (!READ_BOOL()) { exit(10006); } memset(trooper, 0xCC, sizeof(*trooper)); trooper->id = READ_INT64(); trooper->position.x = READ_INT32(); trooper->position.y = READ_INT32(); trooper->player_id = READ_INT64(); trooper->teammate_index = READ_INT32(); trooper->is_teammate = READ_BOOL(); trooper->type = READ_ENUM(ct_trooper_type); trooper->stance = READ_ENUM(ct_trooper_stance); trooper->hitpoints = READ_INT32(); trooper->max_hitpoints = READ_INT32(); trooper->action_points = READ_INT32(); trooper->initial_action_points = READ_INT32(); trooper->vision_range = READ_DOUBLE(); trooper->shooting_range = READ_DOUBLE(); trooper->shoot_cost = READ_INT32(); trooper->standing_damage = READ_INT32(); trooper->kneeling_damage = READ_INT32(); trooper->prone_damage = READ_INT32(); trooper->damage = READ_INT32(); trooper->is_holding_grenade = READ_BOOL(); trooper->is_holding_medkit = READ_BOOL(); trooper->is_holding_field_ration = READ_BOOL(); }
int readParameters(int *xlength, double *tau, double *velocityWall, int *x_proc, int *y_proc, int *z_proc, int *timesteps, int *timestepsPerPlotting, int argc, char *argv[]){ double *velocityWall1, *velocityWall2, *velocityWall3; if(argc<2) ERROR("Not enough arguments. At least a path to init file is required."); if(access(argv[1], R_OK) != 0) ERROR("Provided file path either doesn't exist or can not be read."); READ_DOUBLE(argv[1], *tau); velocityWall1=&velocityWall[0]; velocityWall2=&velocityWall[1]; velocityWall3=&velocityWall[2]; READ_DOUBLE(argv[1], *velocityWall1); READ_DOUBLE(argv[1], *velocityWall2); READ_DOUBLE(argv[1], *velocityWall3); READ_INT(argv[1], *xlength); READ_INT(argv[1], *x_proc); READ_INT(argv[1], *y_proc); READ_INT(argv[1], *z_proc); if(*xlength%*x_proc || *xlength%*y_proc || *xlength%*z_proc) ERROR("With the given number of processes per axis x_proc, y_proc, z_proc the domain of the given size xlength can't be divided in equal number of cells per process."); if(*x_proc!=*y_proc || *x_proc!=*z_proc || *y_proc!=*z_proc) ERROR("x_proc, y_proc and z_proc should have the same size"); READ_INT(argv[1], *timesteps); READ_INT(argv[1], *timestepsPerPlotting); return 1; }
void crUnpackExtendProgramEnvParameter4dvARB(void) { GLenum target = READ_DATA(8, GLenum); GLuint index = READ_DATA(12, GLuint); GLdouble params[4]; params[0] = READ_DOUBLE(16); params[1] = READ_DOUBLE(24); params[2] = READ_DOUBLE(32); params[3] = READ_DOUBLE(40); cr_unpackDispatch.ProgramEnvParameter4dvARB(target, index, params); }
void crUnpackExtendProgramNamedParameter4dNV(void) { GLuint id = READ_DATA(8, GLuint); GLsizei len = READ_DATA(12, GLsizei); GLdouble params[4]; GLubyte *name = crAlloc (len); params[0] = READ_DOUBLE(16); params[1] = READ_DOUBLE(24); params[2] = READ_DOUBLE(32); params[3] = READ_DOUBLE(40); crMemcpy(name, DATA_POINTER(48, GLubyte), len); cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]); }
void client_read_game_context(const remote_process_client *client, struct ct_game *game) { VERIFY(READ_ENUM(ct_message_type), MSG_GAME_CONTEXT); if (!READ_BOOL()) { exit(10017); } memset(game, 0xCC, sizeof(struct ct_game)); game->move_count = READ_INT32(); game->last_player_elimination_score = READ_INT32(); game->player_elimination_score = READ_INT32(); game->trooper_elimination_score = READ_INT32(); game->trooper_damage_score_factor = READ_DOUBLE(); game->stance_change_cost = READ_INT32(); game->standing_move_cost = READ_INT32(); game->kneeling_move_cost = READ_INT32(); game->prone_move_cost = READ_INT32(); game->commander_aura_bonus_action_points = READ_INT32(); game->commander_aura_range = READ_DOUBLE(); game->commander_request_enemy_disposition_cost = READ_INT32(); game->commander_request_enemy_disposition_max_offset = READ_INT32(); game->field_medic_heal_cost = READ_INT32(); game->field_medic_heal_bonus_hitpoints = READ_INT32(); game->field_medic_heal_self_bonus_hitpoints = READ_INT32(); game->sniper_standing_stealth_bonus = READ_DOUBLE(); game->sniper_kneeling_stealth_bonus = READ_DOUBLE(); game->sniper_prone_stealth_bonus = READ_DOUBLE(); game->sniper_standing_shooting_range_bonus = READ_DOUBLE(); game->sniper_kneeling_shooting_range_bonus = READ_DOUBLE(); game->sniper_prone_shooting_range_bonus = READ_DOUBLE(); game->scout_stealth_bonus_negation = READ_DOUBLE(); game->grenade_throw_cost = READ_INT32(); game->grenade_throw_range = READ_DOUBLE(); game->grenade_direct_damage = READ_INT32(); game->grenade_collateral_damage = READ_INT32(); game->medikit_use_cost = READ_INT32(); game->medikit_bonus_hitpoints = READ_INT32(); game->medikit_heal_self_bonus_hitpoints = READ_INT32(); game->field_ration_eat_cost = READ_INT32(); game->field_ration_bonus_action_points = READ_INT32(); }
int readParameters(int *xlength, double *tau, double *velocityWall, int *timesteps, int *timestepsPerPlotting, int argc, char *argv[]){ double *velocityWall1, *velocityWall2, *velocityWall3; if(argc<2) ERROR("Not enough arguments. At least a path to init file is required."); if(access(argv[1], R_OK) != 0) ERROR("Provided file path either doesn't exist or can not be read."); READ_DOUBLE(argv[1], *tau); velocityWall1=&velocityWall[0]; velocityWall2=&velocityWall[1]; velocityWall3=&velocityWall[2]; READ_DOUBLE(argv[1], *velocityWall1); READ_DOUBLE(argv[1], *velocityWall2); READ_DOUBLE(argv[1], *velocityWall3); READ_INT(argv[1], *xlength); READ_INT(argv[1], *timesteps); READ_INT(argv[1], *timestepsPerPlotting); return 1; }
int readParameters(int *xlength, double *tau, double *velocityWall, int *timesteps, int *timestepsPerPlotting, int argc, char *argv[]){ /* Checking if there are exactly 2 parameters in the input. Else give Error message. */ if (argc != 2) { printf("You must provide a filename!\n"); return -1; } const char *filename = argv[1]; /* Reading all the input parameters */ READ_INT(filename, *xlength); READ_DOUBLE(filename, *tau); read_double(filename, "vwallx", &velocityWall[0]); read_double(filename, "vwally", &velocityWall[1]); read_double(filename, "vwallz", &velocityWall[2]); READ_INT(filename, *timesteps); READ_INT(filename, *timestepsPerPlotting); return 0; }
vdatum *parse_vdatum_def ( input_string_def *is, ref_frame *(*getrf)(const char *code, int loadref ), vdatum *(*gethrs)(const char *code, int loadref ) ) { char hrscode[CRDSYS_CODE_LEN+1]; char hrsname[CRDSYS_NAME_LEN+1]; char basecode[CRDSYS_CODE_LEN+1]; char geoidname[MAX_FILENAME_LEN+1]; const char *geoidfile; double offset; int isgeoid; int isgrid; vdatum *hrs = 0; ref_frame *baserf = 0; vdatum *basehrs = 0; vdatum_func *hrf = 0; int sts; sts = OK; isgeoid = 0; isgrid = 0; READ_STRING( "code",hrscode,CRDSYS_CODE_LEN ); READ_STRING( "name",hrsname,CRDSYS_NAME_LEN ); READ_STRING( "base height surface code",basecode,CRDSYS_CODE_LEN ); if( test_next_string_field(is,"geoid") ) { isgeoid=1; isgrid=1; READ_STRING("geoid name",geoidname,MAX_FILENAME_LEN); } else if( test_next_string_field(is,"grid") ) { isgrid=1; READ_STRING("offset grid name",geoidname,MAX_FILENAME_LEN); } else { /* Skip optional string "offset" - as originally implemented with * offset assumed and just a float value */ test_next_string_field(is, "offset"); READ_DOUBLE("offset",&offset); } if( isgrid ) { geoidfile = find_relative_file( is->sourcename, geoidname, ".grd" ); if( ! geoidfile ) { char errmess[255]; sprintf(errmess,"Cannot locate geoid file %.120s for vertical datum %.20s", geoidname,hrscode); report_string_error( is, INVALID_DATA, errmess ); sts = INVALID_DATA; } else { hrf=create_grid_vdatum_func( geoidfile, isgeoid ); } } else { hrf=create_offset_vdatum_func( offset ); } if( sts == OK ) { if( isgeoid && getrf ) { baserf=getrf(basecode,1); if( ! baserf ) { char errmess[255]; sprintf(errmess,"Cannot load reference datum %.20s for vertical datum %.20s", basecode,hrscode); report_string_error( is, INVALID_DATA, errmess ); sts = INVALID_DATA; } } else if( gethrs ) { basehrs=gethrs(basecode,1); if( ! basehrs ) { char errmess[255]; sprintf(errmess,"Cannot load underlying vertical datum %.20s for %.20s", basecode,hrscode); report_string_error( is, INVALID_DATA, errmess ); sts = INVALID_DATA; } else { vdatum *base=basehrs; while( base ) { if( _stricmp(base->code,hrscode) == 0 ) { char errmess[80+CRDSYS_CODE_LEN]; strcpy( errmess, "Vertical datum "); strcat( errmess, hrscode ); strcat( errmess, " has a cyclic dependency"); report_string_error( is, INVALID_DATA, errmess ); sts = INVALID_DATA; break; } base=base->basehrs; } } } } if( sts == OK ) { hrs=create_vdatum( hrscode, hrsname, basehrs, baserf, hrf ); if( ! hrs ) { char errmess[80+CRDSYS_CODE_LEN]; strcpy( errmess, "Cannot create vertical datum "); strcat( errmess, hrscode ); report_string_error( is, INVALID_DATA, errmess ); sts=INVALID_DATA; } } if( ! hrs ) { if( basehrs ) delete_vdatum( basehrs ); if( baserf ) delete_ref_frame( baserf ); if( hrf ) delete_vdatum_func( hrf ); } return hrs; }
int read_parameters( const char *szFileName, /* name of the file */ double *Re, /* reynolds number */ double *UI, /* velocity x-direction */ double *VI, /* velocity y-direction */ double *PI, /* pressure */ double *GX, /* gravitation x-direction */ double *GY, /* gravitation y-direction */ double *t_end, /* end time */ double *xlength, /* length of the domain x-dir.*/ double *ylength, /* length of the domain y-dir.*/ double *dt, /* time step */ double *dx, /* length of a cell x-dir. */ double *dy, /* length of a cell y-dir. */ int *imax, /* number of cells x-direction*/ int *jmax, /* number of cells y-direction*/ double *alpha, /* uppwind differencing factor*/ double *omg, /* relaxation factor */ double *tau, /* safety factor for time step*/ int *itermax, /* max. number of iterations */ /* for pressure per time step */ double *eps, /* accuracy bound for pressure*/ double *dt_value, /* time for output */ int *iproc,int *jproc) { READ_DOUBLE( szFileName, *xlength ); READ_DOUBLE( szFileName, *ylength ); READ_DOUBLE( szFileName, *Re ); READ_DOUBLE( szFileName, *t_end ); READ_DOUBLE( szFileName, *dt ); READ_INT ( szFileName, *imax ); READ_INT ( szFileName, *jmax ); READ_DOUBLE( szFileName, *omg ); READ_DOUBLE( szFileName, *eps ); READ_DOUBLE( szFileName, *tau ); READ_DOUBLE( szFileName, *alpha ); READ_INT ( szFileName, *itermax ); READ_DOUBLE( szFileName, *dt_value ); READ_DOUBLE( szFileName, *UI ); READ_DOUBLE( szFileName, *VI ); READ_DOUBLE( szFileName, *GX ); READ_DOUBLE( szFileName, *GY ); READ_DOUBLE( szFileName, *PI ); READ_INT ( szFileName, *iproc ); READ_INT ( szFileName, *jproc ); *dx = *xlength / (double)(*imax); *dy = *ylength / (double)(*jmax); return 1; }
/*-------------------------------------------------------------------------*/ svalue_t * v_sl_exec (svalue_t * sp, int num_arg) /* EFUN sl_exec() * * mixed* sl_exec(string statement, ...) * * Executes the SQL statement <statement> for the current * SQLite database. The SQL statement may contain wildcards like * '?' and '?nnn', where 'nnn' is an integer. These wildcards * can be given as further parameters to sl_exec. With '?nnn' * the number of a specific parameter can be given, the first * parameter has number 1. * * If the statement returns data, sl_exec returns an array * with each row (which is itself an array of columns) as * an element. */ { svalue_t *argp; sqlite_dbs_t *db; sqlite3_stmt *stmt; const char* tail; int err, rows, cols, num; struct sl_exec_cleanup_s * rec_data; vector_t * result; argp = sp - num_arg + 1; /* First argument: the SQL query */ db = find_db (current_object); if (!db) errorf("The current object doesn't have a database open.\n"); err = sqlite3_prepare(db->db, get_txt(argp->u.str), mstrsize(argp->u.str), &stmt, &tail); if(err) { const char* msg = sqlite3_errmsg(db->db); if(stmt) sqlite3_finalize(stmt); errorf("sl_exec: %s\n", msg); /* NOTREACHED */ } /* Now bind all parameters. */ for(argp++, num=1; argp <= sp; argp++, num++) { switch(argp->type) { default: sqlite3_finalize(stmt); errorf("Bad argument %d to sl_exec(): type %s\n", num+1, typename(argp->type)); break; /* NOTREACHED */ case T_FLOAT: sqlite3_bind_double(stmt, num, READ_DOUBLE(argp)); break; case T_NUMBER: if (sizeof(argp->u.number) > 4) sqlite3_bind_int64(stmt, num, argp->u.number); else sqlite3_bind_int(stmt, num, argp->u.number); break; case T_STRING: sqlite3_bind_text(stmt, num, get_txt(argp->u.str), mstrsize(argp->u.str), SQLITE_STATIC); break; } } rows = 0; cols = sqlite3_column_count(stmt); rec_data = xalloc(sizeof(*rec_data)); if(!rec_data) { sqlite3_finalize(stmt); errorf("(sl_exec) Out of memory: (%lu bytes) for cleanup structure\n", (unsigned long) sizeof(*rec_data)); } rec_data->rows = NULL; rec_data->stmt = stmt; sp = push_error_handler(sl_exec_cleanup, &(rec_data->head)); while((err = sqlite3_step(stmt)) == SQLITE_ROW) { int col; sqlite_rows_t *this_row; rows++; this_row = pxalloc(sizeof(*this_row)); if(!this_row) errorf("(sl_exec) Out of memory: (%lu bytes)\n", (unsigned long) sizeof(*this_row)); this_row->last = rec_data->rows; rec_data->rows = this_row; this_row->row = NULL; /* Because allocate_array may throw an error. */ this_row->row = allocate_array(cols); if(!this_row->row) errorf("(sl_exec) Out of memory: row vector\n"); for(col = 0; col < cols; col++) { svalue_t * entry; STORE_DOUBLE_USED; entry = this_row->row->item + col; switch(sqlite3_column_type(stmt, col)) { default: errorf( "sl_exec: Unknown type %d.\n" , sqlite3_column_type(stmt, col)); break; case SQLITE_BLOB: errorf("sl_exec: Blob columns are not supported.\n"); break; case SQLITE_INTEGER: if (sizeof(entry->u.number) >= 8) put_number(entry, sqlite3_column_int64(stmt, col)); else put_number(entry, sqlite3_column_int(stmt, col)); break; case SQLITE_FLOAT: entry->type = T_FLOAT; STORE_DOUBLE(entry, sqlite3_column_double(stmt, col)); break; case SQLITE_TEXT: put_c_n_string( entry , (char *)sqlite3_column_text(stmt, col) , sqlite3_column_bytes(stmt, col)); break; case SQLITE_NULL: /* All elements from this_row->row are initialized to 0. */ break; } } } sqlite3_finalize(stmt); rec_data->stmt = NULL; switch(err) { default: errorf("sl_exec: Unknown return code from sqlite3_step: %d.\n", err); break; case SQLITE_BUSY: errorf("sl_exec: Database is locked.\n"); break; case SQLITE_ERROR: errorf("sl_exec: %s\n", sqlite3_errmsg(db->db)); break; case SQLITE_MISUSE: errorf("sl_exec: sqlite3_step was called inappropriately.\n"); break; case SQLITE_DONE: break; } if(rows) { sqlite_rows_t *this_row; result = allocate_array(rows); if(!result) errorf("(sl_exec) Out of memory: result vector\n"); this_row = rec_data->rows; while(rows--) { put_array(result->item + rows, this_row->row); this_row->row = NULL; this_row = this_row->last; } } else result = NULL; // Pop arguments and our error handler. // Our error handler gets called and cleans the row stuff. sp = pop_n_elems(num_arg + 1, sp) + 1; if(rows) put_array(sp,result); else put_number(sp, 0); return sp; } /* v_sl_exec() */
int readParameters( int *xlength, double *tau, double *bddParams, int *iProc, int *jProc, int *kProc, int *timesteps, int *timestepsPerPlotting, char *problem, char *pgmInput, int argc, char *argv[] ) { /** * The array bddParams has the following structure * bddParams[0] Inflow velocity in x direction * bddParams[1] Inflow velocity in y direction * bddParams[2] Inflow velocity in z direction * bddParams[3] Pressure surplus for PRESSURE_IN cells * bddParams[4] Moving wall velocity in x direction * bddParams[5] Moving wall velocity in y direction * bddParams[6] Moving wall velocity in z direction */ if (argc == 2) { read_string(argv[1], "problem", problem); read_int(argv[1], "xlength", xlength); read_int(argv[1], "ylength", xlength + 1); read_int(argv[1], "zlength", xlength + 2); read_int(argv[1], "iProc", iProc); read_int(argv[1], "jProc", jProc); read_int(argv[1], "kProc" , kProc); READ_DOUBLE(argv[1], *tau); if(!strcmp(problem, "drivenCavity")) { read_double(argv[1], "velocityWallX", bddParams + 4); read_double(argv[1], "velocityWallY", bddParams + 5); read_double(argv[1], "velocityWallZ", bddParams + 6); } else { bddParams[4] = 0.0; bddParams[5] = 0.0; bddParams[6] = 0.0; } if(!strcmp(problem, "tiltedPlate")) { read_double(argv[1], "velocityInflowX", bddParams); read_double(argv[1], "velocityInflowY", bddParams + 1); read_double(argv[1], "velocityInflowZ", bddParams + 2); read_string(argv[1], "pgmInput", pgmInput); } else { bddParams[0] = 0.0; bddParams[1] = 0.0; bddParams[2] = 0.0; strcpy(pgmInput, ""); } if (!strcmp(problem, "flowStep")) { read_double(argv[1], "velocityInflowX", bddParams); read_double(argv[1], "velocityInflowY", bddParams + 1); read_double(argv[1], "velocityInflowZ", bddParams + 2); } if(!strcmp(problem, "planeShearFlow")) { read_double(argv[1], "pressureIn", bddParams + 3); } else { bddParams[3] = 0.0; } READ_INT(argv[1], *timesteps); READ_INT(argv[1], *timestepsPerPlotting); } else { fprintf(stderr, "Usage: %s <input_file>\n", argv[0]); return -1; } return 0; }
int read_parameters( const char *szFileName, /* name of the file */ double *Re, /* reynolds number */ double *UI, /* velocity x-direction */ double *VI, /* velocity y-direction */ double *WI, /* velocity z-direction */ double *PI, /* pressure */ double *GX, /* gravitation x-direction */ double *GY, /* gravitation y-direction */ double *GZ, /* gravitation z-direction */ double *t_end, /* end time */ double *xlength, /* length of the domain x-dir.*/ double *ylength, /* length of the domain y-dir.*/ double *zlength, /* length of the domain z-dir.*/ double *dt, /* time step */ double *dx, /* length of a cell x-dir. */ double *dy, /* length of a cell y-dir. */ double *dz, /* length of a cell z-dir. */ int *imax, /* number of cells x-direction*/ int *jmax, /* number of cells y-direction*/ int *kmax, /* number of cells z-direction*/ double *alpha, /* uppwind differencing factor*/ double *omg, /* relaxation factor */ double *tau, /* safety factor for time step*/ int *itermax, /* max. number of iterations for pressure per time step */ double *eps, /* accuracy bound for pressure*/ double *dt_value, /* time for output */ int *wl, /*initial boundary for left wall*/ int *wr, /*initial boundary for right wall*/ int *wf, /*initial boundary for front wall*/ int *wh, /*initial boundary for back wall*/ int *wt, /*initial boundary for top wall*/ int *wb, /*initial boundary for bottom wall*/ char *problemGeometry, /*problem to solve*/ // double *presLeft, /*pressure at the left wall*/ // double *presRight, /*pressure at the right wall*/ // double *presDelta, /*pressure difference across the domain*/ double *velIN, /*velocity of inflow*/ double *velMW ) /*velocity of wall (in U direction)*/ { READ_DOUBLE( szFileName, *xlength ); READ_DOUBLE( szFileName, *ylength ); READ_DOUBLE( szFileName, *zlength ); READ_INT ( szFileName, *imax ); READ_INT ( szFileName, *jmax ); READ_INT ( szFileName, *kmax ); READ_DOUBLE( szFileName, *dt ); READ_DOUBLE( szFileName, *t_end ); READ_DOUBLE( szFileName, *tau ); READ_DOUBLE( szFileName, *dt_value ); READ_INT ( szFileName, *itermax ); READ_DOUBLE( szFileName, *eps ); READ_DOUBLE( szFileName, *omg ); READ_DOUBLE( szFileName, *alpha ); READ_DOUBLE( szFileName, *Re ); READ_DOUBLE( szFileName, *GX ); READ_DOUBLE( szFileName, *GY ); READ_DOUBLE( szFileName, *GZ ); READ_DOUBLE( szFileName, *PI ); READ_DOUBLE( szFileName, *UI ); READ_DOUBLE( szFileName, *VI ); READ_DOUBLE( szFileName, *WI ); READ_INT ( szFileName, *wl ); READ_INT ( szFileName, *wr ); READ_INT ( szFileName, *wf ); READ_INT ( szFileName, *wh ); READ_INT ( szFileName, *wt ); READ_INT ( szFileName, *wb ); READ_STRING( szFileName, problemGeometry ); /* READ_DOUBLE( szFileName, *presLeft); READ_DOUBLE( szFileName, *presRight); READ_DOUBLE( szFileName, *presDelta); */ READ_DOUBLE( szFileName, *velIN ); double *velMWx = &velMW[0], *velMWy = &velMW[1], *velMWz = &velMW[2]; READ_DOUBLE( szFileName, *velMWx ); READ_DOUBLE( szFileName, *velMWy ); READ_DOUBLE( szFileName, *velMWz ); /*velMW[0] = velMWx; velMW[1] = velMWy; velMW[2] = velMWz;*/ //take care of (in)valid pressure input /*if (*presDelta<=0){ // if (fmin(presLeft, presRight)<0): we dont have pressure input if (fmin(*presLeft, *presRight)>=0){ *presDelta = *presLeft - *presRight; } } else { //deltaP is given if (*presLeft< *presDelta){ if (*presRight<0){ *presLeft = *presDelta; *presRight = 0.0; } else { *presLeft = *presRight + *presDelta; } } else {//pressure on left wall is also given *presRight = *presLeft - *presDelta; } } if (*presDelta>0){ // if pressure given, left and right bound. set to outflow (they probably already are set in the input file, but just in case) *wl = 3; *wr = 3; }*/ *dx = *xlength / (double)(*imax); *dy = *ylength / (double)(*jmax); *dz = *zlength / (double)(*kmax); return 1; }
int read_parameters( const char *szFileName, /* name of the file */ double *Re, /* reynolds number */ double *UI, /* velocity x-direction */ double *VI, /* velocity y-direction */ double *PI, /* pressure */ double *GX, /* gravitation x-direction */ double *GY, /* gravitation y-direction */ double *t_end, /* end time */ double *xlength, /* length of the domain x-dir.*/ double *ylength, /* length of the domain y-dir.*/ double *dt, /* time step */ double *dx, /* length of a cell x-dir. */ double *dy, /* length of a cell y-dir. */ int *imax, /* number of cells x-direction*/ int *jmax, /* number of cells y-direction*/ double *alpha, /* uppwind differencing factor*/ double *omg, /* relaxation factor */ double *tau, /* safety factor for time step*/ int *itermax, /* max. number of iterations */ /* for pressure per time step */ double *eps, /* accuracy bound for pressure*/ double *dt_value, /* time for output */ int *boundrs, /* vector for boundaries */ double *dp, /* dp/dx gradient of pressure */ int *p) /* specification of the problem */ { int *wl,*wb,*wr,*wt; READ_DOUBLE( szFileName, *xlength ); READ_DOUBLE( szFileName, *ylength ); READ_DOUBLE( szFileName, *Re ); READ_DOUBLE( szFileName, *t_end ); READ_DOUBLE( szFileName, *dt ); READ_INT ( szFileName, *imax ); READ_INT ( szFileName, *jmax ); READ_DOUBLE( szFileName, *omg ); READ_DOUBLE( szFileName, *eps ); READ_DOUBLE( szFileName, *tau ); READ_DOUBLE( szFileName, *alpha ); READ_INT ( szFileName, *itermax ); READ_DOUBLE( szFileName, *dt_value ); READ_DOUBLE( szFileName, *UI ); READ_DOUBLE( szFileName, *VI ); READ_DOUBLE( szFileName, *GX ); READ_DOUBLE( szFileName, *GY ); READ_DOUBLE( szFileName, *PI ); /* change here: reading boundaries */ wl = &boundrs[ 0 ]; wr = &boundrs[ 1 ]; wb = &boundrs[ 2 ]; wt = &boundrs[ 3 ]; read_int( szFileName, "wl", wl ); read_int( szFileName, "wr", wr ); read_int( szFileName, "wb", wb ); read_int( szFileName, "wt", wt ); READ_DOUBLE( szFileName, *dp ); READ_INT ( szFileName, *p ); *dx = *xlength / (double)(*imax); *dy = *ylength / (double)(*jmax); return 1; }
coordsys *parse_coordsys_def ( input_string_def *is, ref_frame *(*getrf)(const char *code )) { char cscode[CRDSYS_CODE_LEN+1]; char csname[CRDSYS_NAME_LEN+1]; char rfcode[CRDSYS_CODE_LEN+1]; char typecode[CRDSYS_CODE_LEN+1]; int cstype = CSTP_CARTESIAN; ref_frame *rf = NULL; projection *prj = NULL; coordsys *cs = NULL; char got_range; double range[4]; char *bad = ""; int sts = OK; long loc; READ_STRING( "Coordinate system code",cscode,CRDSYS_CODE_LEN); READ_STRING( "Coordinate system name",csname,CRDSYS_NAME_LEN); loc = get_string_loc( is ); READ_STRING( "Reference frame code", rfcode, CRDSYS_CODE_LEN); if( sts == OK ) { if( _stricmp( rfcode, "REF_FRAME" ) != 0 ) { set_string_loc( is , loc ); rf = parse_ref_frame_def( is, 0, 1 ); if( !rf ) return NULL; } else { READ_STRING( "Reference frame code",rfcode,CRDSYS_CODE_LEN); rf = NULL; } } READ_STRING( "Coordinate system type",typecode,CRDSYS_CODE_LEN); if( sts == OK ) { if( _stricmp( typecode, "GEOCENTRIC" ) == 0 ) { cstype = CSTP_CARTESIAN; } else if( _stricmp( typecode, "GEODETIC" ) == 0 ) { cstype = CSTP_GEODETIC; } else if( _stricmp( typecode, "PROJECTION" ) == 0 ) { cstype = CSTP_PROJECTION; } else { sts = INVALID_DATA; } } if( sts == OK && cstype == CSTP_PROJECTION ) { prj = parse_projection_def( is ); if( !prj ) { if( rf ) delete_ref_frame( rf ); return NULL; } } else { prj = NULL; } got_range = 0; if( sts == OK ) { loc = get_string_loc( is ); READ_STRING( "", typecode, CRDSYS_CODE_LEN ); if( sts != OK || _stricmp(typecode,"RANGE") != 0 ) { set_string_loc( is, loc ); sts = OK; } else { READ_DOUBLE( "valid range", &range[0]); READ_DOUBLE( "valid range", &range[1]); READ_DOUBLE( "valid range", &range[2]); READ_DOUBLE( "valid range", &range[3]); got_range = sts == OK; } } if( sts == OK ) { char test[32]; sts = next_string_field( is, test, 32-1 ) == NO_MORE_DATA ? OK : TOO_MUCH_DATA; if( sts != OK ) { char errmsg[100+CRDSYS_CODE_LEN]; sprintf(errmsg,"Extraneous data \"%s\" in definition of crdsys \"%s\"", test,cscode); report_string_error(is,sts,errmsg); } } if( sts == OK && !rf ) { if( getrf ) rf = (*getrf)(rfcode); if( !rf ) { char errmess[80]; strcpy(errmess,"Cannot load reference frame "); strcat(errmess,rfcode); report_string_error(is,INVALID_DATA,errmess); sts = MISSING_DATA; } } else if( sts != OK ) { char errmess[80]; if( sts == MISSING_DATA ) { strcpy( errmess, bad); strcat( errmess, " is missing" ); } else { strcpy( errmess, "Invalid value for " ); strcat( errmess, bad ); } report_string_error( is, sts, errmess ); } if( sts != OK ) { if( prj ) delete_projection( prj ); if( rf ) delete_ref_frame( rf ); return NULL; } cs = create_coordsys( cscode, csname, cstype, rf, prj ); if( !cs ) return NULL; if( got_range ) define_coordsys_range( cs, range[0], range[1], range[2], range[3] ); return cs; }