__editor_maybe_static int load_board_direct(struct board *cur_board, FILE *fp, int data_size, int savegame, int version) { int num_robots, num_scrolls, num_sensors, num_robots_active; int overlay_mode, size, board_width, board_height, i; int viewport_x, viewport_y, viewport_width, viewport_height; int truncated = 0; struct robot *cur_robot; struct scroll *cur_scroll; struct sensor *cur_sensor; char *test_buffer; int board_location = ftell(fp); cur_board->num_robots = 0; cur_board->num_robots_allocated = 0; cur_board->num_robots_active = 0; cur_board->num_scrolls = 0; cur_board->num_scrolls_allocated = 0; cur_board->num_sensors = 0; cur_board->num_sensors_allocated = 0; cur_board->robot_list = NULL; cur_board->robot_list_name_sorted = NULL; cur_board->sensor_list = NULL; cur_board->scroll_list = NULL; // Initialize some fields that may no longer be loaded // from the board file itself.. cur_board->last_key = '?'; cur_board->num_input = 0; cur_board->input_size = 0; cur_board->input_string[0] = 0; cur_board->player_last_dir = 0x10; cur_board->bottom_mesg[0] = 0; cur_board->b_mesg_timer = 0; cur_board->lazwall_start = 7; cur_board->b_mesg_row = 24; cur_board->b_mesg_col = -1; cur_board->scroll_x = 0; cur_board->scroll_y = 0; cur_board->locked_x = -1; cur_board->locked_y = -1; cur_board->volume = 255; cur_board->volume_inc = 0; cur_board->volume_target = 255; // board_mode, unused if(fgetc(fp) == EOF) { val_error(WORLD_BOARD_MISSING, board_location); return VAL_MISSING; } overlay_mode = fgetc(fp); if(!overlay_mode) { int overlay_width; int overlay_height; overlay_mode = fgetc(fp); overlay_width = fgetw(fp); overlay_height = fgetw(fp); size = overlay_width * overlay_height; if((size < 1) || (size > MAX_BOARD_SIZE)) goto err_invalid; cur_board->overlay = cmalloc(size); cur_board->overlay_color = cmalloc(size); if(load_RLE2_plane(cur_board->overlay, fp, size)) goto err_freeoverlay; test_buffer = cmalloc(1024); free(test_buffer); // Skip sizes if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->overlay_color, fp, size)) goto err_freeoverlay; test_buffer = cmalloc(1024); free(test_buffer); } else { overlay_mode = 0; // Undo that last get fseek(fp, -1, SEEK_CUR); } cur_board->overlay_mode = overlay_mode; board_width = fgetw(fp); board_height = fgetw(fp); cur_board->board_width = board_width; cur_board->board_height = board_height; size = board_width * board_height; if((size < 1) || (size > MAX_BOARD_SIZE)) goto err_freeoverlay; cur_board->level_id = cmalloc(size); cur_board->level_color = cmalloc(size); cur_board->level_param = cmalloc(size); cur_board->level_under_id = cmalloc(size); cur_board->level_under_color = cmalloc(size); cur_board->level_under_param = cmalloc(size); if(load_RLE2_plane(cur_board->level_id, fp, size)) goto err_freeboard; if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->level_color, fp, size)) goto err_freeboard; if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->level_param, fp, size)) goto err_freeboard; if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->level_under_id, fp, size)) goto err_freeboard; if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->level_under_color, fp, size)) goto err_freeboard; if(fseek(fp, 4, SEEK_CUR) || load_RLE2_plane(cur_board->level_under_param, fp, size)) goto err_freeboard; // Load board parameters if(version < 0x0253) { fread(cur_board->mod_playing, LEGACY_MOD_FILENAME_MAX, 1, fp); cur_board->mod_playing[LEGACY_MOD_FILENAME_MAX] = 0; } else { size_t len = fgetw(fp); if(len >= MAX_PATH) len = MAX_PATH - 1; fread(cur_board->mod_playing, len, 1, fp); cur_board->mod_playing[len] = 0; } viewport_x = fgetc(fp); viewport_y = fgetc(fp); viewport_width = fgetc(fp); viewport_height = fgetc(fp); if( (viewport_x < 0) || (viewport_x > 79) || (viewport_y < 0) || (viewport_y > 24) || (viewport_width < 1) || (viewport_width > 80) || (viewport_height < 1) || (viewport_height > 25)) goto err_invalid; cur_board->viewport_x = viewport_x; cur_board->viewport_y = viewport_y; cur_board->viewport_width = viewport_width; cur_board->viewport_height = viewport_height; cur_board->can_shoot = fgetc(fp); cur_board->can_bomb = fgetc(fp); cur_board->fire_burn_brown = fgetc(fp); cur_board->fire_burn_space = fgetc(fp); cur_board->fire_burn_fakes = fgetc(fp); cur_board->fire_burn_trees = fgetc(fp); cur_board->explosions_leave = fgetc(fp); cur_board->save_mode = fgetc(fp); cur_board->forest_becomes = fgetc(fp); cur_board->collect_bombs = fgetc(fp); cur_board->fire_burns = fgetc(fp); for(i = 0; i < 4; i++) { cur_board->board_dir[i] = fgetc(fp); } cur_board->restart_if_zapped = fgetc(fp); cur_board->time_limit = fgetw(fp); if(version < 0x0253) { cur_board->last_key = fgetc(fp); cur_board->num_input = fgetw(fp); cur_board->input_size = fgetc(fp); fread(cur_board->input_string, LEGACY_INPUT_STRING_MAX + 1, 1, fp); cur_board->input_string[LEGACY_INPUT_STRING_MAX] = 0; cur_board->player_last_dir = fgetc(fp); fread(cur_board->bottom_mesg, LEGACY_BOTTOM_MESG_MAX + 1, 1, fp); cur_board->bottom_mesg[LEGACY_BOTTOM_MESG_MAX] = 0; cur_board->b_mesg_timer = fgetc(fp); cur_board->lazwall_start = fgetc(fp); cur_board->b_mesg_row = fgetc(fp); cur_board->b_mesg_col = (signed char)fgetc(fp); cur_board->scroll_x = (signed short)fgetw(fp); cur_board->scroll_y = (signed short)fgetw(fp); cur_board->locked_x = (signed short)fgetw(fp); cur_board->locked_y = (signed short)fgetw(fp); } else if(savegame) { size_t len; cur_board->last_key = fgetc(fp); cur_board->num_input = fgetw(fp); cur_board->input_size = fgetw(fp); len = fgetw(fp); if(len >= ROBOT_MAX_TR) len = ROBOT_MAX_TR - 1; fread(cur_board->input_string, len, 1, fp); cur_board->input_string[len] = 0; cur_board->player_last_dir = fgetc(fp); len = fgetw(fp); if(len >= ROBOT_MAX_TR) len = ROBOT_MAX_TR - 1; fread(cur_board->bottom_mesg, len, 1, fp); cur_board->bottom_mesg[len] = 0; cur_board->b_mesg_timer = fgetc(fp); cur_board->lazwall_start = fgetc(fp); cur_board->b_mesg_row = fgetc(fp); cur_board->b_mesg_col = (signed char)fgetc(fp); cur_board->scroll_x = (signed short)fgetw(fp); cur_board->scroll_y = (signed short)fgetw(fp); cur_board->locked_x = (signed short)fgetw(fp); cur_board->locked_y = (signed short)fgetw(fp); } cur_board->player_ns_locked = fgetc(fp); cur_board->player_ew_locked = fgetc(fp); cur_board->player_attack_locked = fgetc(fp); if(version < 0x0253 || savegame) { cur_board->volume = fgetc(fp); cur_board->volume_inc = fgetc(fp); cur_board->volume_target = fgetc(fp); } /***************/ /* Load robots */ /***************/ num_robots = fgetc(fp); num_robots_active = 0; if(num_robots == EOF) truncated = 1; // EOF/crazy value check if((num_robots < 0) || (num_robots > 255) || (num_robots > size)) goto board_scan; cur_board->robot_list = ccalloc(num_robots + 1, sizeof(struct robot *)); // Also allocate for name sorted list cur_board->robot_list_name_sorted = ccalloc(num_robots, sizeof(struct robot *)); // Any null objects being placed will later be optimized out if(num_robots) { for(i = 1; i <= num_robots; i++) { // Make sure there's robots to load here int length_check = fgetw(fp); fseek(fp, -2, SEEK_CUR); if(length_check < 0) { // Send off the error and then tell validation to shut up for now val_error(WORLD_ROBOT_MISSING, ftell(fp)); set_validation_suppression(1); truncated = 1; } cur_robot = load_robot_allocate(fp, savegame, version); if(cur_robot->used) { cur_board->robot_list[i] = cur_robot; cur_board->robot_list_name_sorted[num_robots_active] = cur_robot; num_robots_active++; } else { // We don't need no null robot clear_robot(cur_robot); cur_board->robot_list[i] = NULL; } } } set_validation_suppression(-1); if(num_robots_active > 0) { if(num_robots_active != num_robots) { cur_board->robot_list_name_sorted = crealloc(cur_board->robot_list_name_sorted, sizeof(struct robot *) * num_robots_active); } qsort(cur_board->robot_list_name_sorted, num_robots_active, sizeof(struct robot *), cmp_robots); } else { free(cur_board->robot_list_name_sorted); cur_board->robot_list_name_sorted = NULL; } cur_board->num_robots = num_robots; cur_board->num_robots_allocated = num_robots; cur_board->num_robots_active = num_robots_active; /****************/ /* Load scrolls */ /****************/ num_scrolls = fgetc(fp); if(num_scrolls == EOF) truncated = 1; if((num_scrolls < 0) || (num_scrolls > 255) || (num_robots + num_scrolls > size)) goto board_scan; cur_board->scroll_list = ccalloc(num_scrolls + 1, sizeof(struct scroll *)); if(num_scrolls) { for(i = 1; i <= num_scrolls; i++) { cur_scroll = load_scroll_allocate(fp); if(cur_scroll->used) cur_board->scroll_list[i] = cur_scroll; else clear_scroll(cur_scroll); } } cur_board->num_scrolls = num_scrolls; cur_board->num_scrolls_allocated = num_scrolls; /****************/ /* Load sensors */ /****************/ num_sensors = fgetc(fp); if(num_sensors == EOF) truncated = 1; if((num_sensors < 0) || (num_sensors > 255) || (num_scrolls + num_sensors + num_robots > size)) goto board_scan; cur_board->sensor_list = ccalloc(num_sensors + 1, sizeof(struct sensor *)); if(num_sensors) { for(i = 1; i <= num_sensors; i++) { cur_sensor = load_sensor_allocate(fp); if(cur_sensor->used) cur_board->sensor_list[i] = cur_sensor; else clear_sensor(cur_sensor); } } cur_board->num_sensors = num_sensors; cur_board->num_sensors_allocated = num_sensors; board_scan: // Now do a board scan to make sure there aren't more than the data told us. { int robot_count = 0, scroll_count = 0, sensor_count = 0; char err_mesg[80] = { 0 }; for(i = 0; i < (board_width * board_height); i++) { if(cur_board->level_id[i] > 127) cur_board->level_id[i] = CUSTOM_BLOCK; if(cur_board->level_under_id[i] > 127) cur_board->level_under_id[i] = CUSTOM_FLOOR; switch(cur_board->level_id[i]) { case ROBOT: case ROBOT_PUSHABLE: { robot_count++; if(robot_count > cur_board->num_robots) { cur_board->level_id[i] = CUSTOM_BLOCK; cur_board->level_param[i] = 'R'; cur_board->level_color[i] = 0xCF; } break; } case SIGN: case SCROLL: { scroll_count++; if(scroll_count > cur_board->num_scrolls) { cur_board->level_id[i] = CUSTOM_BLOCK; cur_board->level_param[i] = 'S'; cur_board->level_color[i] = 0xCF; } } case SENSOR: { // Wait, I forgot. Nobody cares about sensors. //sensor_count++; if(sensor_count > cur_board->num_sensors) { cur_board->level_id[i] = CUSTOM_FLOOR; cur_board->level_param[i] = 'S'; cur_board->level_color[i] = 0xDF; } } } } if(robot_count > cur_board->num_robots) { snprintf(err_mesg, 80, "Board @ %Xh: found %i robots; expected %i", board_location, robot_count, cur_board->num_robots); error(err_mesg, 1, 8, 0); } if(scroll_count > cur_board->num_scrolls) { snprintf(err_mesg, 80, "Board @ %Xh: found %i scrolls/signs; expected %i", board_location, scroll_count, cur_board->num_scrolls); error(err_mesg, 1, 8, 0); } // This won't be reached but I'll leave it anyway. if(sensor_count > cur_board->num_sensors) { snprintf(err_mesg, 80, "Board @ %Xh: found %i sensors; expected %i", board_location, sensor_count, cur_board->num_sensors); error(err_mesg, 1, 8, 0); } if(err_mesg[0]) error("Any extra robots/scrolls/signs were replaced", 1, 8, 0); } if(truncated == 1) val_error(WORLD_BOARD_TRUNCATED_SAFE, board_location); return VAL_SUCCESS; err_freeboard: free(cur_board->level_id); free(cur_board->level_color); free(cur_board->level_param); free(cur_board->level_under_id); free(cur_board->level_under_color); free(cur_board->level_under_param); err_freeoverlay: if(overlay_mode) { free(cur_board->overlay); free(cur_board->overlay_color); } err_invalid: val_error(WORLD_BOARD_CORRUPT, board_location); return VAL_INVALID; }
__editor_maybe_static void __set_config_from_file( find_change_option find_change_handler, void *conf, const char *conf_file_name) { char current_char, *input_position, *output_position, *use_extended_buffer; int line_size, extended_size, extended_allocate_size = 512; char line_buffer_alternate[256], line_buffer[256]; int extended_buffer_offset, peek_char; char *extended_buffer; char *equals_position, *value; FILE *conf_file; conf_file = fopen(conf_file_name, "rb"); if(!conf_file) return; extended_buffer = cmalloc(extended_allocate_size); while(fsafegets(line_buffer_alternate, 255, conf_file)) { if(line_buffer_alternate[0] != '#') { input_position = line_buffer_alternate; output_position = line_buffer; equals_position = NULL; do { current_char = *input_position; if(!isspace((int)current_char)) { if((current_char == '\\') && (input_position[1] == 's')) { input_position++; current_char = ' '; } if((current_char == '=') && (equals_position == NULL)) equals_position = output_position; *output_position = current_char; output_position++; } input_position++; } while(current_char); if(equals_position) { *equals_position = 0; value = equals_position + 1; } else { value = (char *)"1"; } if(line_buffer[0]) { // There might be extended information too - get it. peek_char = fgetc(conf_file); extended_size = 0; extended_buffer_offset = 0; use_extended_buffer = NULL; while((peek_char == ' ') || (peek_char == '\t')) { // Extended data line use_extended_buffer = extended_buffer; if(fsafegets(line_buffer_alternate, 254, conf_file)) { line_size = (int)strlen(line_buffer_alternate); line_buffer_alternate[line_size] = '\n'; line_size++; extended_size += line_size; if(extended_size >= extended_allocate_size) { extended_allocate_size *= 2; extended_buffer = crealloc(extended_buffer, extended_allocate_size); } strcpy(extended_buffer + extended_buffer_offset, line_buffer_alternate); extended_buffer_offset += line_size; } peek_char = fgetc(conf_file); } ungetc(peek_char, conf_file); find_change_handler(conf, line_buffer, value, use_extended_buffer); } } } free(extended_buffer); fclose(conf_file); }
void set_atm_params(DICT_WORD atm_dict[],int num_atm_dict, char fun_key[],char filename[], int jmol_typ,int jres, int jres_off, CPATOM_MAPS *cpatom_maps,MDATOM_MAPS *atommaps, BUILD_INTRA *build_intra,MDCLATOMS_INFO *clatoms_info, MDGHOST_ATOMS *ghost_atoms,MDCONSTRNT *mdconstrnt) /*=======================================================================*/ {/*begin routine*/ /*=======================================================================*/ /* Local Variables */ NAME site; int i,iii,num,num2,num3,num4,iatm_ind,imask,index,num1; int itype,iatm_ind_sm,ifound; double dnum; /*=======================================================================*/ /* I) Check for missing key words */ for(i=1;i<=num_atm_dict;i++){ if(atm_dict[i].iuset==0 && atm_dict[i].key_type==1){ keyword_miss(atm_dict,filename,fun_key,i);} }/*endfor*/ /*=======================================================================*/ /* II) Get atm index */ sscanf(atm_dict[2].keyarg,"%d",&iatm_ind); index = 2; if(iatm_ind>build_intra->natmind_1res_now||iatm_ind<0){ keyarg_barf(atm_dict,filename,fun_key,index);} imask = build_intra->mask_atm[iatm_ind]; /*=======================================================================*/ /*=======================================================================*/ if(imask>0){ /*=======================================================================*/ /* III) Get rejiggered atm index */ /*-----------------------------------------------------------------------*/ iatm_ind = (build_intra->index_atm)[iatm_ind]; if(iatm_ind>build_intra->natm_1res_now||iatm_ind<0){ keyarg_barf(atm_dict,filename,fun_key,index);} build_intra->iatm_ind_chk[iatm_ind]++; iatm_ind_sm = iatm_ind; iatm_ind = iatm_ind + clatoms_info->natm_tot; /*=======================================================================*/ /* IV) Fill the dictionary with words */ /*-----------------------------------------------------------------------*/ /* 3) \mass{} */ sscanf(atm_dict[3].keyarg,"%lg",&dnum); index = 3; if(dnum<=0.0){ keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ clatoms_info->mass[iatm_ind] = dnum; /*--------------------------------------------------------------------*/ /* 4) \charge{} */ sscanf(atm_dict[4].keyarg,"%lg",&dnum); clatoms_info->q[iatm_ind] = dnum; /*--------------------------------------------------------------------*/ /* 5) \alpha_pol{} */ sscanf(atm_dict[5].keyarg,"%lg",&dnum); index = 5; if(dnum<0.0){ keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ clatoms_info->alp_pol[iatm_ind] = dnum; /*--------------------------------------------------------------------*/ /* 6) \b_neut{} */ sscanf(atm_dict[6].keyarg,"%lg",&dnum); clatoms_info->b_neut[iatm_ind] = dnum; /*--------------------------------------------------------------------*/ /* 7) \valence{} */ sscanf(atm_dict[7].keyarg,"%d",&num); build_intra->bond_site[iatm_ind_sm].valence = num; index = 7; if(num<0||num>MAX_VALENCE){ keyarg_barf(atm_dict,filename,fun_key,index);} /*--------------------------------------------------------------------*/ /* 8) \improper_def{} */ strcpy(build_intra->strip1,atm_dict[8].keyarg); parse_improp(build_intra->strip1,build_intra->strip2,&num1,&num2,&num3, &num4); build_intra->bond_site[iatm_ind_sm].improper_ind[1]=num1+1; build_intra->bond_site[iatm_ind_sm].improper_ind[2]=num2+1; build_intra->bond_site[iatm_ind_sm].improper_ind[3]=num3+1; build_intra->bond_site[iatm_ind_sm].improper_ind[4]=num4+1; index = 8; if((num1+num2+num3+num4)!=0&&(num1+num2+num3+num4)!=6){ keyarg_barf(atm_dict,filename,fun_key,index);} if((num1+num2+num3+num4)==6){ if(num1<0||num1>3||num2<0||num2>3||num3<0||num3>3||num4<0||num4>3|| num1==num2||num1==num3||num2==num3||num1==num4||num2==num4|| num3==num4){ keyarg_barf(atm_dict,filename,fun_key,index);}} /*--------------------------------------------------------------------*/ /* 9) \bond_site_1{} */ strcpy(build_intra->strip1,atm_dict[9].keyarg); parse_bond_site(build_intra->strip1,build_intra->strip2,site,&num2,&num3); strcpy(build_intra->bond_site[iatm_ind_sm].bond_site_name[1],site); build_intra->bond_site[iatm_ind_sm].branch_1[1] = num2; build_intra->bond_site[iatm_ind_sm].branch_2[1] = num3; index = 9; if(strlen(site)==0||num2<-1||num3<-1||num2>MAX_VALENCE||num3>MAX_VALENCE){ keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ /*--------------------------------------------------------------------*/ /* 10) \bond_site_2{} */ strcpy(build_intra->strip1,atm_dict[10].keyarg); parse_bond_site(build_intra->strip1,build_intra->strip2,site,&num2,&num3); strcpy(build_intra->bond_site[iatm_ind_sm].bond_site_name[2],site); build_intra->bond_site[iatm_ind_sm].branch_1[2] = num2; build_intra->bond_site[iatm_ind_sm].branch_2[2] = num3; index = 10; if(strlen(site)==0||num2<-1||num3<-1||num2>MAX_VALENCE||num3>MAX_VALENCE){ keyarg_barf(atm_dict,filename,fun_key,index); } /*---------------------------------------------------------------------*/ /* 11) \bond_site_3{} */ strcpy(build_intra->strip1,atm_dict[11].keyarg); parse_bond_site(build_intra->strip1,build_intra->strip2,site,&num2,&num3); strcpy(build_intra->bond_site[iatm_ind_sm].bond_site_name[3],site); build_intra->bond_site[iatm_ind_sm].branch_1[3] = num2; build_intra->bond_site[iatm_ind_sm].branch_2[3] = num3; index = 11; if(strlen(site)==0||num2<-1||num3<-1||num2>MAX_VALENCE||num3>MAX_VALENCE){ keyarg_barf(atm_dict,filename,fun_key,index);} /*---------------------------------------------------------------------*/ /* 12) \bond_site_4{} */ strcpy(build_intra->strip1,atm_dict[12].keyarg); parse_bond_site(build_intra->strip1,build_intra->strip2,site,&num2,&num3); strcpy(build_intra->bond_site[iatm_ind_sm].bond_site_name[4],site); build_intra->bond_site[iatm_ind_sm].branch_1[4] = num2; build_intra->bond_site[iatm_ind_sm].branch_2[4] = num3; index = 12; if(strlen(site)==0||num2<-1||num3<-1||num2>MAX_VALENCE||num3>MAX_VALENCE){ keyarg_barf(atm_dict,filename,fun_key,index);} /*------------------------------------------------------------------------*/ /* 15) \cp_atom{} */ ifound = 0; if(strcasecmp(atm_dict[15].keyarg,"yes")==0){ ifound=1;cpatom_maps->cp_atm_flag[iatm_ind] = 1; } if(strcasecmp(atm_dict[15].keyarg,"no")==0){ ifound=1;cpatom_maps->cp_atm_flag[iatm_ind] = 0; } /*--------------------------------------------------------------------*/ /* 13) \cp_valence_up{} */ cpatom_maps->cp_vlnc_up[iatm_ind] = 0; if(atm_dict[13].iuset==1){ sscanf(atm_dict[13].keyarg,"%d",&num); cpatom_maps->cp_vlnc_up[iatm_ind] = num; }/*endif*/ if(atm_dict[13].iuset==0 && cpatom_maps->cp_atm_flag[iatm_ind]==1){ index = 13; keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ /*--------------------------------------------------------------------*/ /* 14) \cp_valence_dn{} */ cpatom_maps->cp_vlnc_dn[iatm_ind] = cpatom_maps->cp_vlnc_up[iatm_ind]; if(atm_dict[14].iuset == 1){ sscanf(atm_dict[14].keyarg,"%d",&num); cpatom_maps->cp_vlnc_dn[iatm_ind] = num; }/*endif*/ /*------------------------------------------------------------------------*/ /* 16) /def_ghost1{} */ ghost_atoms->ighost_flag[iatm_ind] = 0; if(atm_dict[16].iuset!=0){ set_ghost(ghost_atoms,clatoms_info,atommaps,build_intra, atm_dict,num_atm_dict, filename,fun_key,iatm_ind); }/*endif*/ /*------------------------------------------------------------------------*/ /* 17) \label{} */ index = 16+NCOEF_GHOST_MAX; ifound = 0; if(strcasecmp(atm_dict[index].keyarg,"standard")==0){ ifound=1;mdconstrnt->atom_label[iatm_ind] = 0; } if(strcasecmp(atm_dict[index].keyarg,"backbone")==0){ ifound=1;mdconstrnt->atom_label[iatm_ind] = 1; } if(strcasecmp(atm_dict[index].keyarg,"sidechain")==0){ ifound=1;mdconstrnt->atom_label[iatm_ind] = 2; } if(ifound==0){ keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ /*--------------------------------------------------------------------*/ /* 18+NCOEF_GHOST_MAX) \cp_valence_true_up{} */ cpatom_maps->cp_vlnc_true_up[iatm_ind] = cpatom_maps->cp_vlnc_up[iatm_ind]; if(atm_dict[18+NCOEF_GHOST_MAX].iuset == 1){ sscanf(atm_dict[18+NCOEF_GHOST_MAX].keyarg,"%d",&num); cpatom_maps->cp_vlnc_true_up[iatm_ind] = num; if (num>cpatom_maps->cp_vlnc_up[iatm_ind]){ index = 18+NCOEF_GHOST_MAX; keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ }/*endif*/ /*--------------------------------------------------------------------*/ /* 19+NCOEF_GHOST_MAX) \cp_valence_true_dn{} */ cpatom_maps->cp_vlnc_true_dn[iatm_ind] = cpatom_maps->cp_vlnc_true_up[iatm_ind]; if(atm_dict[19+NCOEF_GHOST_MAX].iuset == 1){ sscanf(atm_dict[19+NCOEF_GHOST_MAX].keyarg,"%d",&num); cpatom_maps->cp_vlnc_true_dn[iatm_ind] = num; if (num>cpatom_maps->cp_vlnc_dn[iatm_ind]){ index = 19+NCOEF_GHOST_MAX; keyarg_barf(atm_dict,filename,fun_key,index); }/*endif*/ }/*endif*/ /*------------------------------------------------------------------------*/ /*====================================================================*/ /* IV) Do up atom types */ itype = atommaps->natm_typ + 1; for(i=1;i<=atommaps->natm_typ;i++){ if(strcasecmp(atm_dict[1].keyarg,atommaps->atm_typ[i])==0) itype=i; } /*endfor*/ if(itype>build_intra->natm_typ_max){ build_intra->natm_typ_max+=NMEM_MIN; atommaps->atm_typ = (NAME *) crealloc(&(atommaps->atm_typ[1]), (build_intra->natm_typ_max)*sizeof(NAME),"set_atm_params")-1; }/*endif*/ if(itype==atommaps->natm_typ+1){ atommaps->natm_typ+=1; strcpy(atommaps->atm_typ[itype],atm_dict[1].keyarg); }/*endif*/ /*====================================================================*/ /* V) Do up types */ atommaps->iatm_mol_typ[iatm_ind] = jmol_typ; atommaps->iatm_mol_num[iatm_ind] = 1; atommaps->iatm_res_num[iatm_ind] = jres; atommaps->iatm_atm_typ[iatm_ind] = itype; atommaps->iatm_res_typ[iatm_ind] = atommaps->ires_typ_jres_jmol_typ[jres+jres_off]; /*====================================================================*/ /*====================================================================*/ } /*endif (imask>0) */ /*======================================================================*/ } /*end routine*/
int cFunctionalsVecToVec::myConfigureInstance() { int i,j; cComponentManager *_compman = getCompMan(); if (_compman != NULL) { int nTp = _compman->getNtypes(); nFunctTp = 0; for (i=0; i<nTp; i++) { const char * tp = _compman->getComponentType(i,1); if (tp!=NULL) { if (!strncmp(tp,"cFunctional",11)&&strcmp(tp,COMPONENT_NAME_CFUNCTIONALSVECTOVEC)) { // find beginning "cFunctional" but not our own type (cFunctinals) const char *fn = tp+11; if (nFunctTpAlloc == nFunctTp) { // realloc: functTp = (char **)crealloc( functTp, sizeof(char*)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc ); functTpI = (int *)crealloc( functTpI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc ); functI = (int *)crealloc( functI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc ); functN = (int *)crealloc( functN, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc ); functObj = (cFunctionalComponent **)crealloc( functObj, sizeof(cFunctionalComponent *)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc ); nFunctTpAlloc += N_BLOCK_ALLOC; } functTp[nFunctTp] = strdup(fn); functTpI[nFunctTp] = i; nFunctTp++; } } } } SMILE_DBG(2,"(inst '%s') found %i cFunctionalXXXX component types.",getInstName(),nFunctTp); // fetch enabled functionals list nFunctionalsEnabled = getArraySize("functionalsEnabled"); nFunctValues = 0; requireSorted = 0; for (i=0; i<nFunctionalsEnabled; i++) { const char *fname = getStr_f(myvprint("functionalsEnabled[%i]",i)); char *tpname = myvprint("cFunctional%s",fname); for (j=0; j<nFunctTp; j++) { if (!strcmp(functTp[j],fname)) { functI[i] = j; break; } } // TODO: find duplicates in functionalsEnabled Array!!! if (j<nFunctTp) { // and create corresponding component instances... SMILE_DBG(3,"(inst '%s') creating Functional object 'cFunctional%s'.",fname); char *_tmp = myvprint("%s.%s",getInstName(),fname); cFunctionalComponent * tmp = (cFunctionalComponent *)(_compman->createComponent)(_tmp,tpname); free(_tmp); if (tmp==NULL) OUT_OF_MEMORY; tmp->setComponentEnvironment(_compman, -1, this); functN[i] = tmp->getNoutputValues(); requireSorted += tmp->getRequireSorted(); nFunctValues += functN[i]; functObj[i] = tmp; //functTp[i] = strdup(fname); } else { SMILE_ERR(1,"(inst '%s') Functional object '%s' specified in 'functionalsEnabled' array, however no type 'cFunctional%s' exists!",getInstName(),fname,fname); functObj[i] = NULL; functN[i] = 0; free(tpname); return 0; //functTp[i] = NULL; } free(tpname); } if (requireSorted) SMILE_DBG(2,"%i Functional components require sorted data.",requireSorted); return cVectorProcessor::myConfigureInstance(); }
void set_onfo_params(DICT_WORD *intra_dict,int num_intra_dict, char *fun_key,char *file_name,int jmol_typ, MDCLATOMS_INFO *clatoms_info,MDATOM_MAPS *atommaps, MDONFO *onfo,NULL_INTER_PARSE *null_inter_parse, BUILD_INTRA *build_intra, int iresidue, int ires_off) /*==========================================================================*/ {/*begin routine */ int num,index,ifound,igo; int itype1,itype2; int iatm_ind1,iatm_ind2; int imask1,imask2; int i,itype; /*=======================================================================*/ /* I) Check for missing key words*/ for(i=1;i<=2;i++){ if(intra_dict[i].iuset==0 && intra_dict[i].key_type==1){ keyword_miss(intra_dict,file_name,fun_key,i);} } /*endfor*/ /*=======================================================================*/ /* II) Fill the dictionary with words */ /*-----------------------------------------------------------------------*/ /* 1) \atom1{} */ index = 1; sscanf(intra_dict[1].keyarg,"%d",&num); iatm_ind1 = num; if(iatm_ind1>build_intra->natmind_1res_now||iatm_ind1<0){ keyarg_barf(intra_dict,file_name,fun_key,index);} imask1 = build_intra->mask_atm[iatm_ind1]; if(imask1>0)iatm_ind1 = build_intra->index_atm[iatm_ind1]; /*------------------------------------------------------------------------*/ /* 2) \atom2{} */ index = 2; sscanf(intra_dict[2].keyarg,"%d",&num); iatm_ind2 = num; if(iatm_ind2>build_intra->natmind_1res_now||iatm_ind2<0){ keyarg_barf(intra_dict,file_name,fun_key,index);} imask2 = build_intra->mask_atm[iatm_ind2]; if(imask2>0)iatm_ind2 = build_intra->index_atm[iatm_ind2]; /*-----------------------------------------------------------------------*/ /* 5) \modifier{} */ index = 5; ifound = 0; if(strcasecmp(intra_dict[5].keyarg,"on")==0) {ifound = 1;} if(strcasecmp(intra_dict[5].keyarg,"off")==0){ifound = 2;} if(ifound==0){ keyarg_barf(intra_dict,file_name,fun_key,index); } /*-----------------------------------------------------------------------*/ /* 6) bond type */ igo = imask1*imask2; if(igo==1){ itype1 = atommaps->iatm_atm_typ[(clatoms_info->natm_tot+iatm_ind1)]; itype2 = atommaps->iatm_atm_typ[(clatoms_info->natm_tot+iatm_ind2)]; strcpy(build_intra->confo_typ_now->atm1,atommaps->atm_typ[itype1]); strcpy(build_intra->confo_typ_now->atm2,atommaps->atm_typ[itype2]); strcpy(build_intra->confo_typ_now->label,intra_dict[6].keyarg); }/*endif*/ /*======================================================================*/ /* III) Spread onfos */ if(ifound==1&&igo==1){ /*---------------------------------------------------------------------*/ /* A) Add more space */ if(onfo->num+1 > build_intra->nonfo_max){ build_intra->nonfo_max += NMEM_MIN; onfo->j1 =(int *) crealloc(&(onfo->j1)[1], build_intra->nonfo_max*sizeof(int),"set_onfo_params")-1; onfo->j2 =(int *) crealloc(&(onfo->j2)[1], build_intra->nonfo_max*sizeof(int),"set_onfo_params")-1; onfo->jtyp =(int *) crealloc(&(onfo->jtyp)[1], build_intra->nonfo_max*sizeof(int),"set_onfo_params")-1; }/*endif*/ /*--------------------------------------------------------------------*/ /* C) Check type */ itype = (onfo->ntyp)+1; for(i=1;i<=onfo->ntyp;i++){ if((strcasecmp(build_intra->confo_typ[i].atm1, build_intra->confo_typ_now->atm1)==0) &&(strcasecmp(build_intra->confo_typ[i].atm2, build_intra->confo_typ_now->atm2)==0) &&(strcasecmp(build_intra->confo_typ[i].label, build_intra->confo_typ_now->label)==0)) {itype=i;} if((strcasecmp(build_intra->confo_typ[i].atm1, build_intra->confo_typ_now->atm2)==0) &&(strcasecmp(build_intra->confo_typ[i].atm2, build_intra->confo_typ_now->atm1)==0) &&(strcasecmp(build_intra->confo_typ[i].label, build_intra->confo_typ_now->label)==0)) {itype=i;} }/*endfor*/ /*---------------------------------------------------------------------*/ /* D) Add space */ if(itype>build_intra->nonfo_typ_max){ build_intra->nonfo_typ_max += NMEM_MIN; build_intra->confo_typ = (CBOND *) crealloc(&(build_intra->confo_typ)[1], build_intra->nonfo_typ_max*sizeof(CBOND),"set_onfo_params")-1; }/*endif*/ /*---------------------------------------------------------------------*/ /* E) Add a type */ if(itype==(onfo->ntyp)+1){ onfo->ntyp+=1; strcpy(build_intra->confo_typ[itype].atm1, build_intra->confo_typ_now->atm1); strcpy(build_intra->confo_typ[itype].atm2, build_intra->confo_typ_now->atm2); strcpy(build_intra->confo_typ[itype].label, build_intra->confo_typ_now->label); }/*endif*/ /*---------------------------------------------------------------------*/ /* B) Spread */ onfo->num += 1; onfo->j1[onfo->num] = iatm_ind1 + clatoms_info->natm_tot; onfo->j2[onfo->num] = iatm_ind2 + clatoms_info->natm_tot; onfo->jtyp[onfo->num] = itype; }/*endif*/ /*======================================================================*/ /* V) Spread nul onfos */ if(ifound==3&&igo==1){ /*--------------------------------------------------------------------*/ /* A) Add more space */ if(null_inter_parse->nonfo_nul+1 > build_intra->nonfo_nul_max){ build_intra->nonfo_nul_max += NMEM_MIN; null_inter_parse->jonfo1_nul = (int *) crealloc(&(null_inter_parse->jonfo1_nul)[1], build_intra->nonfo_nul_max*sizeof(int),"set_onfo_params")-1; null_inter_parse->jonfo2_nul = (int *) crealloc(&(null_inter_parse->jonfo2_nul)[1], build_intra->nonfo_nul_max*sizeof(int),"set_onfo_params")-1; }/*endif*/ /*--------------------------------------------------------------------*/ /* B) Spread */ null_inter_parse->nonfo_nul += 1; null_inter_parse->jonfo1_nul[null_inter_parse->nonfo_nul] = iatm_ind1 + clatoms_info->natm_tot; null_inter_parse->jonfo2_nul[null_inter_parse->nonfo_nul] = iatm_ind2 + clatoms_info->natm_tot; }/*endif*/ /*----------------------------------------------------------------------*/ }/*end routine*/
void set_ghost(MDGHOST_ATOMS *ghost_atoms,MDCLATOMS_INFO *clatoms_info, MDATOM_MAPS *atommaps,BUILD_INTRA *build_intra, DICT_WORD *atm_dict,int num_atm_dict, char *filename,char *fun_key,int iatm_ind) /*==========================================================================*/ { /*begin routine*/ /*==========================================================================*/ /* Local Variables */ int nstrip=NCOEF_GHOST_MAX,imask; int numg[NCOEF_GHOST_MAX1],index,i; double anumg[NCOEF_GHOST_MAX1]; int nghost_old,ncomp_old,nghost; int nghost_new,ncomp_new,ncomp,iii; /*==========================================================================*/ /* I) Strip out indices of Ghost atoms */ ncomp = 0;index=16; /*INDEX for GHOST*/ for(i=1;i<=nstrip;i++){ if(atm_dict[index].iuset==0){break;} ncomp = i; strcpy(build_intra->strip1,atm_dict[index].keyarg); parse_ghost(build_intra->strip1,build_intra->strip2,&numg[i],&anumg[i]); index++; }/*endfor*/ /*==========================================================================*/ /* II) Check Mask of indices making up Ghost atoms and rejigger them*/ index = 16; for(i=1;i<=ncomp;i++){ if((numg[i]<=0)||(numg[i]>build_intra->natmind_1res_now)){ keyarg_barf(atm_dict,filename,fun_key,index);} imask = build_intra->mask_atm[numg[i]]; if(imask==0){ PRINTF("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n"); PRINTF("You have managed to nuke one of the atoms making \n"); PRINTF("up a ghost atom without nuking the ghost atom, \n"); PRINTF("itself, in residue file %s\n",filename); PRINTF("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n"); FFLUSH(stdout); EXIT(1); }/*endif*/ numg[i] = build_intra->index_atm[numg[i]]; if(numg[i]>build_intra->natm_1res_now||numg[i]<0){ keyarg_barf(atm_dict,filename,fun_key,index);} numg[i] += clatoms_info->natm_tot; index++; }/*endfor*/ /*==========================================================================*/ /* III) Memory allocation */ if(ncomp>0){ ghost_atoms->nghost_tot++; build_intra->nghost_now++; nghost = ghost_atoms->nghost_tot; if(nghost > build_intra->nghost_tot_max){ nghost_old = build_intra->nghost_tot_max; ncomp_old = NCOEF_GHOST_MAX; build_intra->nghost_tot_max+=NMEM_MIN; nghost_new = build_intra->nghost_tot_max; ncomp_new = NCOEF_GHOST_MAX; ghost_atoms->ighost_map = (int *) crealloc( &(ghost_atoms->ighost_map)[1],nghost_new*sizeof(int),"set_ghost")-1; ghost_atoms->natm_comp = (int *) crealloc( &(ghost_atoms->natm_comp)[1],nghost_new*sizeof(int),"set_ghost")-1; ghost_atoms->ighost_map = (int *) crealloc( &(ghost_atoms->ighost_map)[1],nghost_new*sizeof(int),"set_ghost")-1; ghost_atoms->iatm_comp = creall_int_mat(ghost_atoms->iatm_comp, 1,ncomp_old,1,nghost_old, 1,ncomp_new,1,nghost_new,"set_ghost"); ghost_atoms->coef = creall_mat(ghost_atoms->coef, 1,ncomp_old,1,nghost_old, 1,ncomp_new,1,nghost_new,"set_ghost"); }/*endif*/ }/*endif*/ if(ncomp>NCOEF_GHOST_MAX){ PRINTF("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n"); PRINTF("You have managed to use too many ghost_defs!!!\n"); PRINTF("Technical support was too tired to do the \n"); PRINTF("heinous work necessary to support an arbitray number.\n"); PRINTF("Wait for the next upgrade you power tool. \n"); PRINTF("@@@@@@@@@@@@@@@@@@@@_error_@@@@@@@@@@@@@@@@@@@@\n"); FFLUSH(stdout); EXIT(1); }/*endif*/ /*==========================================================================*/ /* IV) Assign Ghosts parameters */ if(ncomp>0){ ghost_atoms->ighost_flag[iatm_ind] = nghost; ghost_atoms->natm_comp_max = MAX(ghost_atoms->natm_comp_max,ncomp); ghost_atoms->ighost_map[nghost] = iatm_ind; ghost_atoms->natm_comp[nghost] = ncomp; for(i=1;i<=ncomp;i++){ ghost_atoms->iatm_comp[i][nghost] = numg[i]; ghost_atoms->coef[i][nghost] = anumg[i]; }/*endfor*/ }/*endif*/ /*--------------------------------------------------------------------------*/ }/*end routine */
void reallocate_intra_list(CLATOMS_INFO *clatoms_info,GHOST_ATOMS *ghost_atoms, ATOMMAPS *atommaps, BUILD_INTRA *build_intra,BONDED *bonded, NULL_INTER_PARSE *null_inter_parse, int jmol_typ, int nbond_pow_add,int nbond_con_add,int nbond_null_add, int nbend_pow_add,int nbend_con_add,int nbend_null_add, int ntors_pow_add,int ntors_con_add,int ntors_null_add, int nonfo_add,int nonfo_null_add,int nbend_bnd_add, int natm_add,int nghost_add,int nfreeze_add,int ngrp_43_add, int ngrp_33_add,int ngrp_watt_33_add,int ngrp_21_add, int ngrp_23_add,int ngrp_46_add) /*==========================================================================*/ /* Begin routine */ { /*begin routine */ /*==========================================================================*/ int nmol,nmol1,mem_add_now,iii; int nfreeze_old,nfreeze_new; int nghost_new,nghost_old,ncomp_new,ncomp_old; /*==========================================================================*/ /* I) Reallocate the atoms */ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*natm_add; if(clatoms_info->natm_tot+nmol1 > build_intra->natm_tot_max){ mem_add_now = clatoms_info->natm_tot+nmol1 - build_intra->natm_tot_max; build_intra->natm_tot_max += MAX(mem_add_now,NMEM_MIN); clatoms_info->mass = (double *)crealloc(&((clatoms_info->mass[1])), build_intra->natm_tot_max* sizeof(double))-1; clatoms_info->q = (double *)crealloc(&((clatoms_info->q[1])), build_intra->natm_tot_max* sizeof(double))-1; clatoms_info->cp_vlnc_up = (int *)crealloc(&((clatoms_info->cp_vlnc_up[1])), build_intra->natm_tot_max* sizeof(int))-1; clatoms_info->cp_vlnc_dn = (int *)crealloc(&((clatoms_info->cp_vlnc_dn[1])), build_intra->natm_tot_max* sizeof(int))-1; clatoms_info->cp_atm_flag = (int *)crealloc(&((clatoms_info->cp_atm_flag[1])), build_intra->natm_tot_max* sizeof(int))-1; clatoms_info->alp_pol = (double *)crealloc(&((clatoms_info->alp_pol[1])), build_intra->natm_tot_max* sizeof(double))-1; clatoms_info->b_neut = (double *)crealloc(&((clatoms_info->b_neut[1])), build_intra->natm_tot_max* sizeof(double))-1; clatoms_info->text_atm =(double *)crealloc(&((clatoms_info->text_atm[1])), build_intra->natm_tot_max* sizeof(double))-1; atommaps->iatm_mol_typ = (int *) crealloc(&(atommaps->iatm_mol_typ[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->iatm_atm_typ = (int *) crealloc(&(atommaps->iatm_atm_typ[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->iatm_res_typ = (int *) crealloc(&(atommaps->iatm_res_typ[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->iatm_mol_num = (int *) crealloc(&(atommaps->iatm_mol_num[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->iatm_res_num = (int *) crealloc(&(atommaps->iatm_res_num[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->ighost_flag = (int *)crealloc(&(atommaps->ighost_flag[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->freeze_flag = (int *)crealloc(&(atommaps->freeze_flag[1]), build_intra->natm_tot_max* sizeof(int))-1; atommaps->atom_label = (int *)crealloc(&(atommaps->atom_label[1]), build_intra->natm_tot_max* sizeof(int))-1; }/*endif*/ /*==========================================================================*/ /* I) Reallocate the ghosts */ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*nghost_add; if(ghost_atoms->nghost_tot+nmol1 > build_intra->nghost_tot_max){ nghost_old = build_intra->nghost_tot_max; ncomp_old = NCOEF_GHOST_MAX; build_intra->nghost_tot_max+= MAX((ghost_atoms->nghost_tot+nmol1-build_intra->nghost_tot_max),NMEM_MIN); nghost_new = build_intra->nghost_tot_max; ncomp_new = NCOEF_GHOST_MAX; ghost_atoms->ighost_map = (int *) crealloc( &(ghost_atoms->ighost_map)[1], nghost_new*sizeof(int))-1; ghost_atoms->natm_comp = (int *) crealloc( &(ghost_atoms->natm_comp)[1], nghost_new*sizeof(int))-1; ghost_atoms->iatm_comp = creall_int_mat(ghost_atoms->iatm_comp, 1,ncomp_old,1,nghost_old, 1,ncomp_new,1,nghost_new); ghost_atoms->coef = creall_mat(ghost_atoms->coef, 1,ncomp_old,1,nghost_old, 1,ncomp_new,1,nghost_new); }/*endif*/ /*==========================================================================*/ /* I) Reallocate the freeze */ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*nfreeze_add; if(atommaps->nfreeze+nmol1 > build_intra->nfreeze_max){ nfreeze_old = build_intra->nfreeze_max; build_intra->nfreeze_max+= MAX((atommaps->nfreeze+nmol1-build_intra->nfreeze_max),NMEM_MIN); nfreeze_new = build_intra->nfreeze_max; atommaps->freeze_map = (int *) crealloc( &(atommaps->freeze_map)[1], nfreeze_new*sizeof(int))-1; }/*endif*/ /*==========================================================================*/ /* I) Reallocate the grpcons */ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_21_add; if(bonded->grp_bond_con.num_21+nmol1 > build_intra->ngrp_21_max){ build_intra->ngrp_21_max += MAX((bonded->grp_bond_con.num_21+nmol1-build_intra->ngrp_21_max),NMEM_MIN); bonded->grp_bond_con.j1_21 = (int *) crealloc(&(bonded->grp_bond_con.j1_21)[1], build_intra->ngrp_21_max*sizeof(int))-1; bonded->grp_bond_con.j2_21 = (int *) crealloc(&(bonded->grp_bond_con.j2_21)[1], build_intra->ngrp_21_max*sizeof(int))-1; bonded->grp_bond_con.jtyp_21 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_21)[1], build_intra->ngrp_21_max*sizeof(int))-1; }/*endif*/ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_23_add; if(bonded->grp_bond_con.num_23+nmol1 > build_intra->ngrp_23_max){ build_intra->ngrp_23_max += MAX((bonded->grp_bond_con.num_23+nmol1-build_intra->ngrp_23_max),NMEM_MIN); bonded->grp_bond_con.j1_23 = (int *) crealloc(&(bonded->grp_bond_con.j1_23)[1], build_intra->ngrp_23_max*sizeof(int))-1; bonded->grp_bond_con.j2_23 = (int *) crealloc(&(bonded->grp_bond_con.j2_23)[1], build_intra->ngrp_23_max*sizeof(int))-1; bonded->grp_bond_con.j3_23 = (int *) crealloc(&(bonded->grp_bond_con.j3_23)[1], build_intra->ngrp_23_max*sizeof(int))-1; bonded->grp_bond_con.jtyp_23 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_23)[1], build_intra->ngrp_23_max*sizeof(int))-1; }/*endif*/ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_33_add; if(bonded->grp_bond_con.num_33+nmol1 > build_intra->ngrp_33_max){ build_intra->ngrp_33_max += MAX((bonded->grp_bond_con.num_33+nmol1-build_intra->ngrp_33_max),NMEM_MIN); bonded->grp_bond_con.j1_33 = (int *) crealloc(&(bonded->grp_bond_con.j1_33)[1], build_intra->ngrp_33_max*sizeof(int))-1; bonded->grp_bond_con.j2_33 = (int *) crealloc(&(bonded->grp_bond_con.j2_33)[1], build_intra->ngrp_33_max*sizeof(int))-1; bonded->grp_bond_con.j3_33 = (int *) crealloc(&(bonded->grp_bond_con.j3_33)[1], build_intra->ngrp_33_max*sizeof(int))-1; bonded->grp_bond_con.jtyp_33 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_33)[1], build_intra->ngrp_33_max*sizeof(int))-1; }/*endif*/ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_watt_33_add; if(bonded->grp_bond_watts.num_33+nmol1 > build_intra->ngrp_watt_33_max){ build_intra->ngrp_watt_33_max += MAX((bonded->grp_bond_watts.num_33+nmol1-build_intra->ngrp_watt_33_max), NMEM_MIN); bonded->grp_bond_watts.j1_33 = (int *) crealloc(&(bonded->grp_bond_watts.j1_33)[1], build_intra->ngrp_watt_33_max*sizeof(int))-1; bonded->grp_bond_watts.j2_33 = (int *) crealloc(&(bonded->grp_bond_watts.j2_33)[1], build_intra->ngrp_watt_33_max*sizeof(int))-1; bonded->grp_bond_watts.j3_33 = (int *) crealloc(&(bonded->grp_bond_watts.j3_33)[1], build_intra->ngrp_watt_33_max*sizeof(int))-1; bonded->grp_bond_watts.jtyp_33 = (int *) crealloc(&(bonded->grp_bond_watts.jtyp_33)[1], build_intra->ngrp_watt_33_max*sizeof(int))-1; }/*endif*/ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_43_add; if(bonded->grp_bond_con.num_43+nmol1 > build_intra->ngrp_43_max){ build_intra->ngrp_43_max += MAX((bonded->grp_bond_con.num_43+nmol1-build_intra->ngrp_43_max),NMEM_MIN); bonded->grp_bond_con.j1_43 = (int *) crealloc(&(bonded->grp_bond_con.j1_43)[1], build_intra->ngrp_43_max*sizeof(int))-1; bonded->grp_bond_con.j2_43 = (int *) crealloc(&(bonded->grp_bond_con.j2_43)[1], build_intra->ngrp_43_max*sizeof(int))-1; bonded->grp_bond_con.j3_43 = (int *) crealloc(&(bonded->grp_bond_con.j3_43)[1], build_intra->ngrp_43_max*sizeof(int))-1; bonded->grp_bond_con.j4_43 = (int *) crealloc(&(bonded->grp_bond_con.j4_43)[1], build_intra->ngrp_43_max*sizeof(int))-1; bonded->grp_bond_con.jtyp_43 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_43)[1], build_intra->ngrp_43_max*sizeof(int))-1; }/*endif*/ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*ngrp_46_add; if(bonded->grp_bond_con.num_46+nmol1 > build_intra->ngrp_46_max){ build_intra->ngrp_46_max += MAX((bonded->grp_bond_con.num_46+nmol1-build_intra->ngrp_46_max),NMEM_MIN); bonded->grp_bond_con.j1_46 = (int *) crealloc(&(bonded->grp_bond_con.j1_46)[1], build_intra->ngrp_46_max*sizeof(int))-1; bonded->grp_bond_con.j2_46 = (int *) crealloc(&(bonded->grp_bond_con.j2_46)[1], build_intra->ngrp_46_max*sizeof(int))-1; bonded->grp_bond_con.j3_46 = (int *) crealloc(&(bonded->grp_bond_con.j3_46)[1], build_intra->ngrp_46_max*sizeof(int))-1; bonded->grp_bond_con.j4_46 = (int *) crealloc(&(bonded->grp_bond_con.j4_46)[1], build_intra->ngrp_46_max*sizeof(int))-1; bonded->grp_bond_con.jtyp_46 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_46)[1], build_intra->ngrp_46_max*sizeof(int))-1; }/*endif*/ /*===========================================================================*/ /* I) Reallocate the bonds */ nmol = atommaps->nmol_jmol_typ[jmol_typ]; nmol1 = (nmol-1)*nbond_pow_add; if(bonded->bond.npow+nmol1 > build_intra->nbond_pow_max){ build_intra->nbond_pow_max += MAX((bonded->bond.npow+nmol1-build_intra->nbond_pow_max),NMEM_MIN); bonded->bond.j1_pow = (int *)crealloc(&(bonded->bond.j1_pow)[1], build_intra->nbond_pow_max*sizeof(int))-1; bonded->bond.j2_pow = (int *)crealloc(&(bonded->bond.j2_pow)[1], build_intra->nbond_pow_max*sizeof(int))-1; bonded->bond.jtyp_pow=(int *)crealloc(&(bonded->bond.jtyp_pow)[1], build_intra->nbond_pow_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*nbond_con_add; if(bonded->bond.ncon+nmol1 > build_intra->nbond_con_max){ build_intra->nbond_con_max += MAX((bonded->bond.ncon+nmol1-build_intra->nbond_con_max),NMEM_MIN); bonded->bond.j1_con = (int *)crealloc(&(bonded->bond.j1_con)[1], build_intra->nbond_con_max*sizeof(int))-1; bonded->bond.j2_con = (int *)crealloc(&(bonded->bond.j2_con)[1], build_intra->nbond_con_max*sizeof(int))-1; bonded->bond.jtyp_con=(int *)crealloc(&(bonded->bond.jtyp_con)[1], build_intra->nbond_con_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*nbond_null_add; if((null_inter_parse->nbond_nul)+nmol1 > build_intra->nbond_nul_max) { build_intra->nbond_nul_max += MAX((null_inter_parse->nbond_nul+nmol1-build_intra->nbond_nul_max),NMEM_MIN); null_inter_parse->jbond1_nul = (int *) crealloc(&(null_inter_parse->jbond1_nul)[1], build_intra->nbond_nul_max*sizeof(int))-1; null_inter_parse->jbond2_nul = (int *) crealloc(&(null_inter_parse->jbond2_nul)[1], build_intra->nbond_nul_max*sizeof(int))-1; } /*endif*/ /*====================================================================*/ /* II) Reallocate the bends */ nmol1 = (nmol-1)*nbend_pow_add; if(bonded->bend.npow+nmol1 > build_intra->nbend_pow_max){ build_intra->nbend_pow_max += MAX((bonded->bend.npow+nmol1-build_intra->nbend_pow_max),NMEM_MIN); bonded->bend.j1_pow =(int*)crealloc(&(bonded->bend.j1_pow)[1], build_intra->nbend_pow_max*sizeof(int))-1; bonded->bend.j2_pow =(int*)crealloc(&(bonded->bend.j2_pow)[1], build_intra->nbend_pow_max*sizeof(int))-1; bonded->bend.j3_pow =(int*)crealloc(&(bonded->bend.j3_pow)[1], build_intra->nbend_pow_max*sizeof(int))-1; bonded->bend.jtyp_pow=(int*)crealloc(&(bonded->bend.jtyp_pow)[1], build_intra->nbend_pow_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*nbend_con_add; if(bonded->bend.ncon+nmol1 > build_intra->nbend_con_max){ build_intra->nbend_con_max += MAX((bonded->bend.ncon+nmol1-build_intra->nbend_con_max),NMEM_MIN); bonded->bend.j1_con = (int *)crealloc(&(bonded->bend.j1_con)[1], build_intra->nbend_con_max*sizeof(int))-1; bonded->bend.j2_con = (int *)crealloc(&(bonded->bend.j2_con)[1], build_intra->nbend_con_max*sizeof(int))-1; bonded->bend.jtyp_con=(int *)crealloc(&(bonded->bend.jtyp_con)[1], build_intra->nbend_con_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*nbend_null_add; if(null_inter_parse->nbend_nul+nmol1 > build_intra->nbend_nul_max){ build_intra->nbend_nul_max += MAX((null_inter_parse->nbend_nul+nmol1-build_intra->nbend_nul_max),NMEM_MIN); null_inter_parse->jbend1_nul = (int *) crealloc(&(null_inter_parse->jbend1_nul)[1], build_intra->nbend_nul_max*sizeof(int))-1; null_inter_parse->jbend2_nul = (int *) crealloc(&(null_inter_parse->jbend2_nul)[1], build_intra->nbend_nul_max*sizeof(int))-1; null_inter_parse->jbend3_nul = (int *) crealloc(&(null_inter_parse->jbend3_nul)[1], build_intra->nbend_nul_max*sizeof(int))-1; } /*endif*/ /*====================================================================*/ /* IV) Reallocate the torsions */ nmol1 = (nmol-1)*ntors_pow_add; if((bonded->tors.npow)+nmol1 > build_intra->ntors_pow_max){ build_intra->ntors_pow_max += MAX((bonded->tors.npow+nmol1-build_intra->ntors_pow_max),NMEM_MIN); bonded->tors.j1_pow =(int*)crealloc(&(bonded->tors.j1_pow)[1], build_intra->ntors_pow_max*sizeof(int))-1; bonded->tors.j2_pow =(int*)crealloc(&(bonded->tors.j2_pow)[1], build_intra->ntors_pow_max*sizeof(int))-1; bonded->tors.j3_pow =(int*)crealloc(&(bonded->tors.j3_pow)[1], build_intra->ntors_pow_max*sizeof(int))-1; bonded->tors.j4_pow =(int*)crealloc(&(bonded->tors.j4_pow)[1], build_intra->ntors_pow_max*sizeof(int))-1; bonded->tors.jtyp_pow=(int*)crealloc(&(bonded->tors.jtyp_pow)[1], build_intra->ntors_pow_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*ntors_con_add; if(bonded->tors.ncon+nmol1 > build_intra->ntors_con_max){ build_intra->ntors_con_max += MAX((bonded->tors.ncon+nmol1-build_intra->ntors_con_max),NMEM_MIN); bonded->tors.j1_con = (int *) crealloc(&(bonded->tors.j1_con)[1], build_intra->ntors_con_max*sizeof(int))-1; bonded->tors.j2_con = (int *) crealloc(&(bonded->tors.j2_con)[1], build_intra->ntors_con_max*sizeof(int))-1; bonded->tors.j3_con = (int *) crealloc(&(bonded->tors.j3_con)[1], build_intra->ntors_con_max*sizeof(int))-1; bonded->tors.j4_con = (int *) crealloc(&(bonded->tors.j4_con)[1], build_intra->ntors_con_max*sizeof(int))-1; bonded->tors.jtyp_con=(int *) crealloc(&(bonded->tors.jtyp_con)[1], build_intra->ntors_con_max*sizeof(int))-1; } /* endif */ nmol1 = (nmol-1)*ntors_null_add; if(null_inter_parse->ntors_nul+nmol1 > build_intra->ntors_nul_max){ build_intra->ntors_nul_max += MAX((null_inter_parse->ntors_nul+nmol1-build_intra->ntors_nul_max),NMEM_MIN); null_inter_parse->jtors1_nul = (int *) crealloc(&(null_inter_parse->jtors1_nul[1]), build_intra->ntors_nul_max*sizeof(int))-1; null_inter_parse->jtors2_nul = (int *) crealloc(&(null_inter_parse->jtors2_nul[1]), build_intra->ntors_nul_max*sizeof(int))-1; null_inter_parse->jtors3_nul = (int *) crealloc(&(null_inter_parse->jtors3_nul[1]), build_intra->ntors_nul_max*sizeof(int))-1; null_inter_parse->jtors4_nul = (int *) crealloc(&(null_inter_parse->jtors4_nul[1]), build_intra->ntors_nul_max*sizeof(int))-1; } /*endif*/ /*====================================================================*/ /* V) Reallocate the torsions */ nmol1 = (nmol-1)*nonfo_add; if(bonded->onfo.num+nmol1 > build_intra->nonfo_max){ build_intra->nonfo_max += MAX((bonded->onfo.num+nmol1-build_intra->nonfo_max),NMEM_MIN); bonded->onfo.j1 =(int *) crealloc(&(bonded->onfo.j1)[1], build_intra->nonfo_max*sizeof(int))-1; bonded->onfo.j2 =(int *) crealloc(&(bonded->onfo.j2)[1], build_intra->nonfo_max*sizeof(int))-1; bonded->onfo.jtyp =(int *) crealloc(&(bonded->onfo.jtyp)[1], build_intra->nonfo_max*sizeof(int))-1; }/*endif*/ nmol1 = (nmol-1)*nonfo_null_add; if(null_inter_parse->nonfo_nul+nmol1 > build_intra->nonfo_nul_max){ build_intra->nonfo_nul_max += MAX((null_inter_parse->nonfo_nul+nmol1-build_intra->nonfo_nul_max),NMEM_MIN); null_inter_parse->jonfo1_nul = (int *) crealloc(&(null_inter_parse->jonfo1_nul)[1], build_intra->nonfo_nul_max*sizeof(int))-1; null_inter_parse->jonfo2_nul = (int *) crealloc(&(null_inter_parse->jonfo2_nul)[1], build_intra->nonfo_nul_max*sizeof(int))-1; }/*endif*/ /*====================================================================*/ /* VI) Reallocate the Uri-Bradleys */ nmol1 = (nmol-1)*nbend_bnd_add; if(bonded->bend_bnd.num+nmol1 > build_intra->nbend_bnd_max){ mem_add_now = bonded->bend_bnd.num+nmol1-build_intra->nbend_bnd_max; build_intra->nbend_bnd_max += MAX(mem_add_now,NMEM_MIN); bonded->bend_bnd.j1 =(int*)crealloc(&(bonded->bend_bnd.j1)[1], build_intra->nbend_bnd_max*sizeof(int))-1; bonded->bend_bnd.j2 =(int*)crealloc(&(bonded->bend_bnd.j2)[1], build_intra->nbend_bnd_max*sizeof(int))-1; bonded->bend_bnd.j3 =(int*)crealloc(&(bonded->bend_bnd.j3)[1], build_intra->nbend_bnd_max*sizeof(int))-1; bonded->bend_bnd.jtyp=(int*)crealloc(&(bonded->bend_bnd.jtyp)[1], build_intra->nbend_bnd_max*sizeof(int))-1; }/*endif*/ /*==========================================================================*/ } /*end routine*/
void change_board_size(struct board *src_board, int new_width, int new_height) { int board_width = src_board->board_width; int board_height = src_board->board_height; if(new_width == 0) new_width = 1; if(new_height == 0) new_height = 1; if((board_width != new_width) || (board_height != new_height)) { char *level_id = src_board->level_id; char *level_color = src_board->level_color; char *level_param = src_board->level_param; char *level_under_id = src_board->level_under_id; char *level_under_color = src_board->level_under_color; char *level_under_param = src_board->level_under_param; char *overlay = src_board->overlay; char *overlay_color = src_board->overlay_color; int overlay_mode = src_board->overlay_mode; int board_size = board_width * board_height; int new_size = new_width * new_height; int i; // Shrinking height? Remove any robots/scrolls/sensors from excess lines if(new_height < board_height) { int offset; int check_id; for(offset = new_height * board_width; offset < board_size; offset++) { check_id = level_id[offset]; if(check_id == 122) clear_sensor_id(src_board, level_param[offset]); else if((check_id == 126) || (check_id == 125)) clear_scroll_id(src_board, level_param[offset]); else if((check_id == 123) || (check_id == 124)) clear_robot_id(src_board, level_param[offset]); } } if(new_width < board_width) { // Take out pieces from each width, then reallocate. // Only do this for the current height or the new height, whichever is // less. int src_offset, dest_offset; int max_height = new_height; int check_id, offset; if(new_height > board_height) max_height = board_height; for(i = 0, src_offset = 0, dest_offset = 0; i < max_height; i++, src_offset += board_width, dest_offset += new_width) { // First, remove any robots/scrolls/sensors from excess chunks for(offset = src_offset + new_width; offset < src_offset + board_width; offset++) { check_id = level_id[offset]; if(check_id == 122) clear_sensor_id(src_board, level_param[offset]); else if((check_id == 126) || (check_id == 125)) clear_scroll_id(src_board, level_param[offset]); else if((check_id == 123) || (check_id == 124)) clear_robot_id(src_board, level_param[offset]); } memmove(level_id + dest_offset, level_id + src_offset, new_width); memmove(level_param + dest_offset, level_param + src_offset, new_width); memmove(level_color + dest_offset, level_color + src_offset, new_width); memmove(level_under_id + dest_offset, level_under_id + src_offset, new_width); memmove(level_under_param + dest_offset, level_under_param + src_offset, new_width); memmove(level_under_color + dest_offset, level_under_color + src_offset, new_width); } // Resize layers src_board->level_id = crealloc(level_id, new_size); src_board->level_color = crealloc(level_color, new_size); src_board->level_param = crealloc(level_param, new_size); src_board->level_under_id = crealloc(level_under_id, new_size); src_board->level_under_color = crealloc(level_under_color, new_size); src_board->level_under_param = crealloc(level_under_param, new_size); level_id = src_board->level_id; level_color = src_board->level_color; level_param = src_board->level_param; level_under_id = src_board->level_under_id; level_under_color = src_board->level_under_color; level_under_param = src_board->level_under_param; // Do the overlay too, if it exists if(overlay_mode) { for(i = 0, src_offset = 0, dest_offset = 0; i < max_height; i++, src_offset += board_width, dest_offset += new_width) { memmove(overlay + dest_offset, overlay + src_offset, new_width); memmove(overlay_color + dest_offset, overlay_color + src_offset, new_width); } src_board->overlay = crealloc(overlay, new_size); src_board->overlay_color = crealloc(overlay_color, new_size); overlay = src_board->overlay; overlay_color = src_board->overlay_color; } } else if(new_width > board_width) { // Reallocate first, then copy over pieces, padding in widths // Only do this for the current height or the new height, whichever is // less. int src_offset, dest_offset; int max_height = new_height; int width_difference = new_width - board_width; if(new_height > board_height) max_height = board_height; // Resize first this time. src_board->level_id = crealloc(level_id, new_size); src_board->level_color = crealloc(level_color, new_size); src_board->level_param = crealloc(level_param, new_size); src_board->level_under_id = crealloc(level_under_id, new_size); src_board->level_under_color = crealloc(level_under_color, new_size); src_board->level_under_param = crealloc(level_under_param, new_size); // Resize the overlay too, if it exists if(overlay_mode) { src_board->overlay = crealloc(overlay, new_size); src_board->overlay_color = crealloc(overlay_color, new_size); overlay = src_board->overlay; overlay_color = src_board->overlay_color; } level_id = src_board->level_id; level_color = src_board->level_color; level_param = src_board->level_param; level_under_id = src_board->level_under_id; level_under_color = src_board->level_under_color; level_under_param = src_board->level_under_param; // And start at the end instead of the beginning src_offset = board_width * (max_height - 1); dest_offset = new_width * (max_height - 1); for(i = 0; i < max_height; i++, src_offset -= board_width, dest_offset -= new_width) { memmove(level_id + dest_offset, level_id + src_offset, board_width); memmove(level_param + dest_offset, level_param + src_offset, board_width); memmove(level_color + dest_offset, level_color + src_offset, board_width); memmove(level_under_id + dest_offset, level_under_id + src_offset, board_width); memmove(level_under_param + dest_offset, level_under_param + src_offset, board_width); memmove(level_under_color + dest_offset, level_under_color + src_offset, board_width); // And fill in the remainder with blanks memset(level_id + dest_offset + board_width, 0, width_difference); memset(level_param + dest_offset + board_width, 0, width_difference); memset(level_color + dest_offset + board_width, 7, width_difference); memset(level_under_id + dest_offset + board_width, 0, width_difference); memset(level_under_param + dest_offset + board_width, 0, width_difference); memset(level_under_color + dest_offset + board_width, 7, width_difference); } src_offset = board_width * (max_height - 1); dest_offset = new_width * (max_height - 1); // Do the overlay too, if it exists if(overlay_mode) { for(i = 0; i < max_height; i++, src_offset -= board_width, dest_offset -= new_width) { memmove(overlay + dest_offset, overlay + src_offset, board_width); memmove(overlay_color + dest_offset, overlay_color + src_offset, board_width); // And fill in the remainder with blanks memset(overlay + dest_offset + board_width, 32, width_difference); memset(overlay_color + dest_offset + board_width, 7, width_difference); } } } else { // Width remains the same, just a straight resize src_board->level_id = crealloc(level_id, new_size); src_board->level_color = crealloc(level_color, new_size); src_board->level_param = crealloc(level_param, new_size); src_board->level_under_id = crealloc(level_under_id, new_size); src_board->level_under_color = crealloc(level_under_color, new_size); src_board->level_under_param = crealloc(level_under_param, new_size); // Resize the overlay too, if it exists if(overlay_mode) { src_board->overlay = crealloc(overlay, new_size); src_board->overlay_color = crealloc(overlay_color, new_size); } level_id = src_board->level_id; level_color = src_board->level_color; level_param = src_board->level_param; level_under_id = src_board->level_under_id; level_under_color = src_board->level_under_color; level_under_param = src_board->level_under_param; overlay = src_board->overlay; overlay_color = src_board->overlay_color; } // Fill in any blanks if(new_height > board_height) { int offset = new_width * board_height; int size_difference = new_size - offset; memset(level_id + offset, 0, size_difference); memset(level_param + offset, 0, size_difference); memset(level_color + offset, 7, size_difference); memset(level_under_id + offset, 0, size_difference); memset(level_under_param + offset, 0, size_difference); memset(level_under_color + offset, 7, size_difference); if(overlay_mode) { memset(overlay + offset, 32, size_difference); memset(overlay_color + offset, 7, size_difference); } } // Set the new sizes src_board->board_width = new_width; src_board->board_height = new_height; } }
__editor_maybe_static void load_board_direct(struct board *cur_board, FILE *fp, int savegame, int version) { int num_robots, num_scrolls, num_sensors, num_robots_active; int overlay_mode, size, board_width, board_height, i; struct robot *cur_robot; struct scroll *cur_scroll; struct sensor *cur_sensor; char *test_buffer; // Initialize some fields that may no longer be loaded // from the board file itself.. cur_board->last_key = '?'; cur_board->num_input = 0; cur_board->input_size = 0; cur_board->input_string[0] = 0; cur_board->player_last_dir = 0x10; cur_board->bottom_mesg[0] = 0; cur_board->b_mesg_timer = 0; cur_board->lazwall_start = 7; cur_board->b_mesg_row = 24; cur_board->b_mesg_col = -1; cur_board->scroll_x = 0; cur_board->scroll_y = 0; cur_board->locked_x = -1; cur_board->locked_y = -1; cur_board->volume = 255; cur_board->volume_inc = 0; cur_board->volume_target = 255; // board_mode, unused fgetc(fp); overlay_mode = fgetc(fp); if(!overlay_mode) { int overlay_width; int overlay_height; overlay_mode = fgetc(fp); overlay_width = fgetw(fp); overlay_height = fgetw(fp); size = overlay_width * overlay_height; cur_board->overlay = cmalloc(size); cur_board->overlay_color = cmalloc(size); load_RLE2_plane(cur_board->overlay, fp, size); test_buffer = cmalloc(1024); free(test_buffer); // Skip sizes fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->overlay_color, fp, size); test_buffer = cmalloc(1024); free(test_buffer); } else { overlay_mode = 0; // Undo that last get fseek(fp, -1, SEEK_CUR); } cur_board->overlay_mode = overlay_mode; board_width = fgetw(fp); board_height = fgetw(fp); cur_board->board_width = board_width; cur_board->board_height = board_height; size = board_width * board_height; cur_board->level_id = cmalloc(size); cur_board->level_color = cmalloc(size); cur_board->level_param = cmalloc(size); cur_board->level_under_id = cmalloc(size); cur_board->level_under_color = cmalloc(size); cur_board->level_under_param = cmalloc(size); load_RLE2_plane(cur_board->level_id, fp, size); fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->level_color, fp, size); fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->level_param, fp, size); fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->level_under_id, fp, size); fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->level_under_color, fp, size); fseek(fp, 4, SEEK_CUR); load_RLE2_plane(cur_board->level_under_param, fp, size); // Load board parameters if(version < 0x0253) { fread(cur_board->mod_playing, LEGACY_MOD_FILENAME_MAX, 1, fp); cur_board->mod_playing[LEGACY_MOD_FILENAME_MAX] = 0; } else { size_t len = fgetw(fp); if(len >= MAX_PATH) len = MAX_PATH - 1; fread(cur_board->mod_playing, len, 1, fp); cur_board->mod_playing[len] = 0; } cur_board->viewport_x = fgetc(fp); cur_board->viewport_y = fgetc(fp); cur_board->viewport_width = fgetc(fp); cur_board->viewport_height = fgetc(fp); cur_board->can_shoot = fgetc(fp); cur_board->can_bomb = fgetc(fp); cur_board->fire_burn_brown = fgetc(fp); cur_board->fire_burn_space = fgetc(fp); cur_board->fire_burn_fakes = fgetc(fp); cur_board->fire_burn_trees = fgetc(fp); cur_board->explosions_leave = fgetc(fp); cur_board->save_mode = fgetc(fp); cur_board->forest_becomes = fgetc(fp); cur_board->collect_bombs = fgetc(fp); cur_board->fire_burns = fgetc(fp); for(i = 0; i < 4; i++) { cur_board->board_dir[i] = fgetc(fp); } cur_board->restart_if_zapped = fgetc(fp); cur_board->time_limit = fgetw(fp); if(version < 0x0253) { cur_board->last_key = fgetc(fp); cur_board->num_input = fgetw(fp); cur_board->input_size = fgetc(fp); fread(cur_board->input_string, LEGACY_INPUT_STRING_MAX + 1, 1, fp); cur_board->input_string[LEGACY_INPUT_STRING_MAX] = 0; cur_board->player_last_dir = fgetc(fp); fread(cur_board->bottom_mesg, LEGACY_BOTTOM_MESG_MAX + 1, 1, fp); cur_board->bottom_mesg[LEGACY_BOTTOM_MESG_MAX] = 0; cur_board->b_mesg_timer = fgetc(fp); cur_board->lazwall_start = fgetc(fp); cur_board->b_mesg_row = fgetc(fp); cur_board->b_mesg_col = (signed char)fgetc(fp); cur_board->scroll_x = (signed short)fgetw(fp); cur_board->scroll_y = (signed short)fgetw(fp); cur_board->locked_x = (signed short)fgetw(fp); cur_board->locked_y = (signed short)fgetw(fp); } else if(savegame) { size_t len; cur_board->last_key = fgetc(fp); cur_board->num_input = fgetw(fp); cur_board->input_size = fgetw(fp); len = fgetw(fp); if(len >= ROBOT_MAX_TR) len = ROBOT_MAX_TR - 1; fread(cur_board->input_string, len, 1, fp); cur_board->input_string[len] = 0; cur_board->player_last_dir = fgetc(fp); len = fgetw(fp); if(len >= ROBOT_MAX_TR) len = ROBOT_MAX_TR - 1; fread(cur_board->bottom_mesg, len, 1, fp); cur_board->bottom_mesg[len] = 0; cur_board->b_mesg_timer = fgetc(fp); cur_board->lazwall_start = fgetc(fp); cur_board->b_mesg_row = fgetc(fp); cur_board->b_mesg_col = (signed char)fgetc(fp); cur_board->scroll_x = (signed short)fgetw(fp); cur_board->scroll_y = (signed short)fgetw(fp); cur_board->locked_x = (signed short)fgetw(fp); cur_board->locked_y = (signed short)fgetw(fp); } cur_board->player_ns_locked = fgetc(fp); cur_board->player_ew_locked = fgetc(fp); cur_board->player_attack_locked = fgetc(fp); if(version < 0x0253 || savegame) { cur_board->volume = fgetc(fp); cur_board->volume_inc = fgetc(fp); cur_board->volume_target = fgetc(fp); } // Load robots num_robots = fgetc(fp); num_robots_active = 0; cur_board->robot_list = ccalloc(num_robots + 1, sizeof(struct robot *)); // Also allocate for name sorted list cur_board->robot_list_name_sorted = ccalloc(num_robots, sizeof(struct robot *)); // Any null objects being placed will later be optimized out if(num_robots) { for(i = 1; i <= num_robots; i++) { cur_robot = load_robot_allocate(fp, savegame, version); if(cur_robot->used) { cur_board->robot_list[i] = cur_robot; cur_board->robot_list_name_sorted[num_robots_active] = cur_robot; num_robots_active++; } else { // We don't need no null robot clear_robot(cur_robot); cur_board->robot_list[i] = NULL; } } } if(num_robots_active) { if(num_robots_active != num_robots) { cur_board->robot_list_name_sorted = crealloc(cur_board->robot_list_name_sorted, sizeof(struct robot *) * num_robots_active); } qsort(cur_board->robot_list_name_sorted, num_robots_active, sizeof(struct robot *), cmp_robots); } else { free(cur_board->robot_list_name_sorted); cur_board->robot_list_name_sorted = NULL; } cur_board->num_robots = num_robots; cur_board->num_robots_allocated = num_robots; cur_board->num_robots_active = num_robots_active; // Load scrolls num_scrolls = fgetc(fp); cur_board->scroll_list = ccalloc(num_scrolls + 1, sizeof(struct scroll *)); if(num_scrolls) { for(i = 1; i <= num_scrolls; i++) { cur_scroll = load_scroll_allocate(fp); if(cur_scroll->used) cur_board->scroll_list[i] = cur_scroll; else clear_scroll(cur_scroll); } } cur_board->num_scrolls = num_scrolls; cur_board->num_scrolls_allocated = num_scrolls; // Load sensors num_sensors = fgetc(fp); cur_board->sensor_list = ccalloc(num_sensors + 1, sizeof(struct sensor *)); if(num_sensors) { for(i = 1; i <= num_sensors; i++) { cur_sensor = load_sensor_allocate(fp); if(cur_sensor->used) cur_board->sensor_list[i] = cur_sensor; else clear_sensor(cur_sensor); } } cur_board->num_sensors = num_sensors; cur_board->num_sensors_allocated = num_sensors; }
void fetch_freeze(CLASS_PARSE *class_parse, ATOMMAPS *atommaps, BUILD_INTRA *build_intra, START_INDEX *start_index, CLATOMS_INFO *clatoms_info, int jmol_typ) /*==========================================================================*/ /*begin routine*/{ /*==========================================================================*/ /* Define Local variable */ int i,iii,nfreeze_now,iresidue_off,nresidue,count; int count_atm,ires; double *mass = clatoms_info->mass; /*==========================================================================*/ /* I) No atoms frozen */ if(class_parse->mol_freeze_opt[jmol_typ]==0){ for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ atommaps->freeze_flag[i] = 0; }/*endfor*/ }/*endif*/ /*==========================================================================*/ /* II) All atoms frozen */ if(class_parse->mol_freeze_opt[jmol_typ]==1){ for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ atommaps->freeze_flag[i] = atommaps->nfreeze+i-start_index->natm; }/*endfor*/ nfreeze_now = clatoms_info->natm_tot - start_index->natm; atommaps->nfreeze += nfreeze_now; if((atommaps->nfreeze) > build_intra->nfreeze_max){ build_intra->nfreeze_max += MAX(NMEM_MIN,nfreeze_now); atommaps->freeze_map = (int *) crealloc(&(atommaps->freeze_map[1]), build_intra->nfreeze_max* sizeof(int))-1; }/*endif*/ for(i=start_index->nfreeze+1;i<=atommaps->nfreeze;i++){ atommaps->freeze_map[i] = start_index->natm+i-start_index->nfreeze; }/*endfor*/ /* Do the degrees of freedom for each molecule */ iresidue_off = atommaps->jres_jmol_typ_strt[jmol_typ]-1; atommaps->nfree_1mol_jmol_typ[jmol_typ] = 0; atommaps->icons_jmol_typ[jmol_typ] = 0; nresidue = MAX(atommaps->nres_1mol_jmol_typ[jmol_typ],1); for(i=1;i<=nresidue;i++){ atommaps->nfree_jres_jmol_typ[(iresidue_off+i)] = 0.0; /*endfor*/} }/*endif*/ /*==========================================================================*/ /* III) Backbone atoms frozen */ if(class_parse->mol_freeze_opt[jmol_typ]==2){ /* Count the freeze map and fill the freeze_flag list */ nfreeze_now = atommaps->nfreeze; for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ if(atommaps->atom_label[i] == 1){ nfreeze_now++; atommaps->freeze_flag[i] = i; }/*endif*/ }/*endfor*/ /* Realloc the freeze map */ if(nfreeze_now > build_intra->nfreeze_max){ build_intra->nfreeze_max += MAX(NMEM_MIN,nfreeze_now-atommaps->nfreeze); atommaps->freeze_map = (int *) crealloc(&(atommaps->freeze_map[1]), build_intra->nfreeze_max* sizeof(int))-1; }/*endif*/ /* Fill the freeze map and do the degrees of freedom for each molecule */ count = 0; count_atm = 0; iresidue_off = atommaps->jres_jmol_typ_strt[jmol_typ]-1; ires = iresidue_off+1; for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ count_atm++; if(count_atm > atommaps->natm_jres_jmol_typ[ires]){ count_atm = 1; ires++; }/*endif*/ if(atommaps->atom_label[i] == 1){ count++; atommaps->freeze_map[(atommaps->nfreeze+count)] = i; atommaps->nfree_1mol_jmol_typ[jmol_typ] -= 3; atommaps->nfree_jres_jmol_typ[ires] -= 3; }/*endif*/ }/*endfor*/ atommaps->nfreeze = nfreeze_now; #ifdef DEBUG for(i=1;i<=atommaps->nfreeze;i++){ printf("This is present freeze map %d\n",atommaps->freeze_map[i]); scanf("%d",&iii); } printf("This is molecule degrees of freedom %d\n", atommaps->nfree_1mol_jmol_typ[jmol_typ]); scanf("%d",&iii); nresidue = MAX(atommaps->nres_1mol_jmol_typ[jmol_typ],1); for(i=1;i<=nresidue;i++){ printf("This is residue degrees of freedom %d %d\n", atommaps->nfree_jres_jmol_typ[i+iresidue_off],i); scanf("%d",&iii); } #endif }/*endif*/ /*==========================================================================*/ /* IV) All Heavy atoms frozen */ if(class_parse->mol_freeze_opt[jmol_typ]==3){ /* Count the freeze map and fill the freeze_flag list */ nfreeze_now = atommaps->nfreeze; for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ if(mass[i] > 1.5){ nfreeze_now++; atommaps->freeze_flag[i] = i; }/*endif*/ }/*endfor*/ /* Realloc the freeze map */ if(nfreeze_now > build_intra->nfreeze_max){ printf(" reallocing freeze_map \n"); build_intra->nfreeze_max += MAX(NMEM_MIN,nfreeze_now-atommaps->nfreeze); atommaps->freeze_map = (int *) crealloc(&(atommaps->freeze_map[1]), build_intra->nfreeze_max* sizeof(int))-1; }/*endif*/ /* Fill the freeze map and do the degrees of freedom for each molecule */ count = 0; count_atm = 0; iresidue_off = atommaps->jres_jmol_typ_strt[jmol_typ]-1; ires = iresidue_off+1; for(i=start_index->natm+1;i<=clatoms_info->natm_tot;i++){ count_atm++; if(count_atm > atommaps->natm_jres_jmol_typ[ires]){ count_atm = 1; ires++; }/*endif*/ if(mass[i] > 1.5){ count++; atommaps->freeze_map[(atommaps->nfreeze+count)] = i; atommaps->nfree_1mol_jmol_typ[jmol_typ] -= 3; atommaps->nfree_jres_jmol_typ[ires] -= 3; }/*endif*/ }/*endfor*/ atommaps->nfreeze = nfreeze_now; /* printf("nfreeze_now %d \n",nfreeze_now); printf("exiting from fetch_freeze \n"); exit(1); */ }/*endif*/ /*--------------------------------------------------------------------------*/ }/*end routine*/
void close_intra_params(CLATOMS_INFO *clatoms_info,CLATOMS_POS *clatoms_pos, GHOST_ATOMS *ghost_atoms, ATOMMAPS *atommaps, BUILD_INTRA *build_intra, BONDED *bonded, NULL_INTER_PARSE *null_inter_parse, double *tot_memory,SIMOPTS *simopts,int np_forc) /*=======================================================================*/ /* Begin routine */ {/*begin routine*/ /*=======================================================================*/ /* Local Variables */ int i,ntyp_pow,iii,nsec,inow,know; double now_memory; int natm_typ_mall; int natm_mall; int nghost_mall; int nfreeze_mall; int ncomp_mall; int nchrg_mall; int ngrp_21_mall; int ngrp_typ_21_mall; int ngrp_33_mall; int ngrp_typ_33_mall; int ngrp_watt_33_mall; int ngrp_typ_watt_33_mall; int ngrp_43_mall; int ngrp_typ_43_mall; int ngrp_23_mall; int ngrp_typ_23_mall; int ngrp_46_mall; int ngrp_typ_46_mall; int nbond_pow_mall; int nbond_typ_pow_mall; int nbond_con_mall; int nbond_typ_con_mall; int nbend_pow_mall; int nbend_typ_pow_mall; int nbend_con_mall; int nbend_typ_con_mall; int nbend_bnd_mall; int nbend_bnd_typ_mall; int ntors_pow_mall; int ntors_typ_pow_mall; int ntors_con_mall; int ntors_typ_con_mall; int nonfo_mall; int nonfo_typ_mall; int pimd_on; int nghost_old,nfreeze_old,ncomp_old; int pi_beads = clatoms_info->pi_beads; int pimd_freez_typ = atommaps->pimd_freez_typ; /*======================================================================*/ /* 0) Make the length of each vector an odd number */ nghost_old = build_intra->nghost_tot_max; nfreeze_old = build_intra->nfreeze_max; ncomp_old = NCOEF_GHOST_MAX; natm_mall = clatoms_info->natm_tot; natm_typ_mall = atommaps->natm_typ; nghost_mall = ghost_atoms->nghost_tot; nfreeze_mall = atommaps->nfreeze; ncomp_mall = ghost_atoms->natm_comp_max; ngrp_21_mall = bonded->grp_bond_con.num_21; ngrp_33_mall = bonded->grp_bond_con.num_33; ngrp_watt_33_mall = bonded->grp_bond_watts.num_33; ngrp_43_mall = bonded->grp_bond_con.num_43; ngrp_23_mall = bonded->grp_bond_con.num_23; ngrp_46_mall = bonded->grp_bond_con.num_46; ngrp_typ_21_mall = bonded->grp_bond_con.ntyp_21; ngrp_typ_33_mall = bonded->grp_bond_con.ntyp_33; ngrp_typ_watt_33_mall = bonded->grp_bond_watts.ntyp_33; ngrp_typ_43_mall = bonded->grp_bond_con.ntyp_43; ngrp_typ_23_mall = bonded->grp_bond_con.ntyp_23; ngrp_typ_46_mall = bonded->grp_bond_con.ntyp_46; nbond_pow_mall = bonded->bond.npow; nbond_typ_pow_mall = bonded->bond.ntyp_pow; nbond_con_mall = bonded->bond.ncon; nbond_typ_con_mall = bonded->bond.ntyp_con; nbend_pow_mall = bonded->bend.npow; nbend_typ_pow_mall = bonded->bend.ntyp_pow; nbend_con_mall = bonded->bend.ncon; nbend_typ_con_mall = bonded->bend.ntyp_con; nbend_bnd_mall = bonded->bend_bnd.num; nbend_bnd_typ_mall = bonded->bend_bnd.ntyp; ntors_pow_mall = bonded->tors.npow; ntors_typ_pow_mall = bonded->tors.ntyp_pow; ntors_con_mall = bonded->tors.ncon; ntors_typ_con_mall = bonded->tors.ntyp_con; nonfo_mall = bonded->onfo.num; nonfo_typ_mall = bonded->onfo.ntyp; if((natm_mall % 2)==0){natm_mall += 1;} nsec=natm_mall/np_forc; if((natm_mall%np_forc)!=0){nsec++;} natm_mall = nsec*np_forc; if((natm_typ_mall % 2)==0){natm_typ_mall += 1;} if(((nghost_mall % 2)==0) &&(nghost_mall !=0)){nghost_mall++;} if(((nfreeze_mall % 2)==0) &&(nfreeze_mall !=0)){nfreeze_mall++;} if(((ncomp_mall % 2)==0) &&(ncomp_mall !=0)){ncomp_mall++;} if(((ngrp_21_mall % 2)==0) &&(ngrp_21_mall !=0)){ngrp_21_mall++;} if(((ngrp_33_mall % 2)==0) &&(ngrp_33_mall !=0)){ngrp_33_mall++;} if(((ngrp_watt_33_mall % 2)==0) &&(ngrp_watt_33_mall !=0)){ngrp_watt_33_mall++;} if(((ngrp_43_mall % 2)==0) &&(ngrp_43_mall !=0)){ngrp_43_mall++;} if(((ngrp_23_mall % 2)==0) &&(ngrp_23_mall !=0)){ngrp_23_mall++;} if(((ngrp_46_mall % 2)==0) &&(ngrp_46_mall !=0)){ngrp_46_mall++;} if(((ngrp_typ_21_mall % 2)==0) &&(ngrp_typ_21_mall !=0)){ngrp_typ_21_mall++;} if(((ngrp_typ_33_mall % 2)==0) &&(ngrp_typ_33_mall !=0)){ngrp_typ_33_mall++;} if(((ngrp_typ_watt_33_mall % 2)==0) &&(ngrp_typ_watt_33_mall !=0)){ngrp_typ_watt_33_mall++;} if(((ngrp_typ_43_mall % 2)==0) &&(ngrp_typ_43_mall !=0)){ngrp_typ_43_mall++;} if(((ngrp_typ_23_mall % 2)==0) &&(ngrp_typ_23_mall !=0)){ngrp_typ_23_mall++;} if(((ngrp_typ_46_mall % 2)==0) &&(ngrp_typ_46_mall !=0)){ngrp_typ_46_mall++;} if(((nbond_pow_mall % 2)==0) &&(nbond_pow_mall !=0)){nbond_pow_mall += 1;} if(((nbond_typ_pow_mall % 2)==0) &&(nbond_typ_pow_mall !=0)){nbond_typ_pow_mall+= 1;} if(((nbond_con_mall % 2)==0) &&(nbond_con_mall !=0)){nbond_pow_mall += 1;} if(((nbond_typ_con_mall % 2)==0) &&(nbond_typ_con_mall !=0)){nbond_typ_pow_mall+= 1;} if(((nbend_pow_mall % 2)==0) &&(nbend_pow_mall !=0)){nbend_pow_mall += 1;} if(((nbend_typ_pow_mall % 2)==0) &&(nbend_typ_pow_mall !=0)){nbend_typ_pow_mall+= 1;} if(((nbend_con_mall % 2)==0) &&(nbend_con_mall !=0)){nbend_pow_mall += 1;} if(((nbend_typ_con_mall % 2)==0) &&(nbend_typ_con_mall !=0)){nbend_typ_pow_mall+= 1;} if(((nbend_bnd_mall % 2)==0) &&(nbend_bnd_mall !=0)){nbend_bnd_mall += 1;} if(((nbend_bnd_typ_mall % 2)==0) &&(nbend_bnd_typ_mall !=0)){nbend_bnd_typ_mall+= 1;} if(((ntors_pow_mall % 2)==0) &&(ntors_pow_mall !=0)){ntors_pow_mall += 1;} if(((ntors_typ_pow_mall % 2)==0) &&(ntors_typ_pow_mall !=0)){ntors_typ_pow_mall+= 1;} if(((ntors_con_mall % 2)==0) &&(ntors_con_mall !=0)){ntors_pow_mall += 1;} if(((ntors_typ_con_mall % 2)==0) &&(ntors_typ_con_mall !=0)){ntors_typ_pow_mall+= 1;} if(((nonfo_mall % 2)==0) &&(nonfo_mall !=0)){nonfo_mall += 1;} if(((nonfo_typ_mall % 2)==0) &&(nonfo_typ_mall !=0)){nonfo_typ_mall += 1;} /*======================================================================*/ /* I) Atm stuff: Note constrain flag set here */ /* and charged atoms are counted */ bonded->constrnt.iconstrnt=0; if(bonded->bond.ncon > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_con.num_21 > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_con.num_23 > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_con.num_33 > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_watts.num_33 > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_con.num_43 > 0) bonded->constrnt.iconstrnt=1; if(bonded->grp_bond_con.num_46 > 0) bonded->constrnt.iconstrnt=1; if(bonded->bend.ncon > 0) bonded->constrnt.iconstrnt=1; if(bonded->tors.ncon > 0) bonded->constrnt.iconstrnt=1; clatoms_info->ichrg = (int *)cmalloc(natm_mall*sizeof(int))-1; clatoms_info->nfree = 0; clatoms_info->nfree_pimd = 0; for(i=1;i<=atommaps->nmol_typ;i++){ inow = atommaps->nfree_1mol_jmol_typ[i] *atommaps->nmol_jmol_typ[i]; know = 3*atommaps->natm_1mol_jmol_typ[i] *atommaps->nmol_jmol_typ[i]; clatoms_info->nfree += inow; if(pimd_freez_typ==2){ clatoms_info->nfree_pimd += inow*pi_beads; }else{ clatoms_info->nfree_pimd += (inow + know*(pi_beads-1)); }/*endif*/ }/*endfor*/ clatoms_info->nchrg = 0; for(i=1;i<=clatoms_info->natm_tot;i++){ clatoms_info->mass[i] *= PROT_MASS; if(clatoms_info->q[i] != 0) { clatoms_info->nchrg++; clatoms_info->ichrg[(clatoms_info->nchrg)] = i; } } nchrg_mall = clatoms_info->nchrg; if((nchrg_mall % 2)==0){nchrg_mall += 1;} now_memory = ((double)(((natm_mall)*sizeof(double)*13+sizeof(int)*4)+ natm_typ_mall*(sizeof(double)*0+sizeof(int)*25)) *1.e-06); *tot_memory += now_memory; printf("Atom allocation: %g Mbytes; Total memory: %g Mbytes\n", now_memory,*tot_memory); atommaps->atm_typ = (NAME *)crealloc(&(atommaps->atm_typ)[1], natm_typ_mall*sizeof(NAME))-1; clatoms_info->mass = (double *)crealloc(&(clatoms_info->mass)[1], natm_mall*sizeof(double))-1; clatoms_info->q = (double *)crealloc(&(clatoms_info->q)[1], natm_mall*sizeof(double))-1; clatoms_info->cp_vlnc_up = (int *)crealloc(&(clatoms_info->cp_vlnc_up)[1], natm_mall*sizeof(int))-1; clatoms_info->cp_vlnc_dn = (int *)crealloc(&(clatoms_info->cp_vlnc_dn)[1], natm_mall*sizeof(int))-1; clatoms_info->cp_atm_flag = (int *)crealloc(&(clatoms_info->cp_atm_flag)[1], natm_mall*sizeof(int))-1; clatoms_info->ichrg = (int *)crealloc(&(clatoms_info->ichrg)[1], nchrg_mall*sizeof(int))-1; clatoms_info->alp_pol = (double *)crealloc(&(clatoms_info->alp_pol)[1], natm_mall*sizeof(double))-1; clatoms_info->b_neut = (double *)crealloc(&(clatoms_info->b_neut)[1], natm_mall*sizeof(double))-1; clatoms_info->text_atm = (double *)crealloc(&(clatoms_info->text_atm)[1], natm_mall*sizeof(double))-1; atommaps->iatm_mol_typ = (int *)crealloc(&(atommaps->iatm_mol_typ)[1], natm_mall*sizeof(int))-1; atommaps->iatm_atm_typ = (int *)crealloc(&(atommaps->iatm_atm_typ)[1], natm_mall*sizeof(int))-1; atommaps->iatm_res_typ = (int *)crealloc(&(atommaps->iatm_res_typ)[1], natm_mall*sizeof(int))-1; atommaps->iatm_mol_num = (int *)crealloc(&(atommaps->iatm_mol_num)[1], natm_mall*sizeof(int))-1; atommaps->iatm_res_num = (int *)crealloc(&(atommaps->iatm_res_num)[1], natm_mall*sizeof(int))-1; pimd_on = simopts->pimd + simopts->cp_pimd + simopts->cp_wave_pimd + simopts->cp_wave_min_pimd + simopts->debug_pimd + simopts->debug_cp_pimd; clatoms_info->xold= (double *)cmalloc(natm_mall*sizeof(double))-1; clatoms_info->yold= (double *)cmalloc(natm_mall*sizeof(double))-1; clatoms_info->zold= (double *)cmalloc(natm_mall*sizeof(double))-1; if(pi_beads>1||pimd_on==1){ clatoms_info->xmod = (double *)cmalloc(natm_mall*sizeof(double))-1; clatoms_info->ymod = (double *)cmalloc(natm_mall*sizeof(double))-1; clatoms_info->zmod = (double *)cmalloc(natm_mall*sizeof(double))-1; }/*endif*/ if(clatoms_info->pi_beads>1||pimd_on==1){ clatoms_info->prekf = (double *)cmalloc(natm_mall*sizeof(double))-1; } clatoms_info->roll_sc = (double *)cmalloc(natm_mall*sizeof(double))-1; /*========================================================================*/ /* I) Ghost_atm stuff */ ghost_atoms->ighost_map = (int *) crealloc(&(ghost_atoms->ighost_map)[1], nghost_mall*sizeof(int))-1; ghost_atoms->natm_comp = (int *) crealloc(&(ghost_atoms->natm_comp)[1], nghost_mall*sizeof(int))-1; atommaps->ighost_flag = (int *) crealloc(&(atommaps->ighost_flag)[1], natm_mall*sizeof(int))-1; /* need to set up reallocate matrix */ ghost_atoms->iatm_comp = creall_int_mat(ghost_atoms->iatm_comp, 1,ncomp_old ,1,nghost_old, 1,ncomp_mall,1,nghost_mall); ghost_atoms->coef = creall_mat(ghost_atoms->coef, 1,ncomp_old ,1,nghost_old, 1,ncomp_mall,1,nghost_mall); /*========================================================================*/ /* I) Freeze_atm stuff */ atommaps->freeze_map = (int *) crealloc(&(atommaps->freeze_map)[1], nfreeze_mall*sizeof(int))-1; atommaps->freeze_flag = (int *) crealloc(&(atommaps->freeze_flag)[1], natm_mall*sizeof(int))-1; atommaps->atom_label = (int *) crealloc(&(atommaps->atom_label)[1], natm_mall*sizeof(int))-1; /*========================================================================*/ /* II) Grp constrnts */ bonded->grp_bond_con.j1_21 = (int *)crealloc(&(bonded->grp_bond_con.j1_21)[1], ngrp_21_mall*sizeof(int))-1; bonded->grp_bond_con.j2_21 = (int *) crealloc(&(bonded->grp_bond_con.j2_21)[1], ngrp_21_mall*sizeof(int))-1; bonded->grp_bond_con.jtyp_21 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_21)[1], ngrp_21_mall*sizeof(int))-1; bonded->grp_bond_con.j1_33 = (int *)crealloc(&(bonded->grp_bond_con.j1_33)[1], ngrp_33_mall*sizeof(int))-1; bonded->grp_bond_con.j2_33 = (int *) crealloc(&(bonded->grp_bond_con.j2_33)[1], ngrp_33_mall*sizeof(int))-1; bonded->grp_bond_con.j3_33 = (int *) crealloc(&(bonded->grp_bond_con.j3_33)[1], ngrp_33_mall*sizeof(int))-1; bonded->grp_bond_con.jtyp_33 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_33)[1], ngrp_33_mall*sizeof(int))-1; bonded->grp_bond_watts.j1_33 = (int *)crealloc(&(bonded->grp_bond_watts.j1_33)[1], ngrp_watt_33_mall*sizeof(int))-1; bonded->grp_bond_watts.j2_33 = (int *) crealloc(&(bonded->grp_bond_watts.j2_33)[1], ngrp_watt_33_mall*sizeof(int))-1; bonded->grp_bond_watts.j3_33 = (int *) crealloc(&(bonded->grp_bond_watts.j3_33)[1], ngrp_watt_33_mall*sizeof(int))-1; bonded->grp_bond_watts.jtyp_33 = (int *) crealloc(&(bonded->grp_bond_watts.jtyp_33)[1], ngrp_watt_33_mall*sizeof(int))-1; bonded->grp_bond_con.j1_23 = (int *) crealloc(&(bonded->grp_bond_con.j1_23)[1], ngrp_23_mall*sizeof(int))-1; bonded->grp_bond_con.j2_23 = (int *) crealloc(&(bonded->grp_bond_con.j2_23)[1], ngrp_23_mall*sizeof(int))-1; bonded->grp_bond_con.j3_23 = (int *) crealloc(&(bonded->grp_bond_con.j3_23)[1], ngrp_23_mall*sizeof(int))-1; bonded->grp_bond_con.jtyp_23 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_23)[1], ngrp_23_mall*sizeof(int))-1; bonded->grp_bond_con.j1_43 = (int *)crealloc(&(bonded->grp_bond_con.j1_43)[1], ngrp_43_mall*sizeof(int))-1; bonded->grp_bond_con.j2_43 = (int *) crealloc(&(bonded->grp_bond_con.j2_43)[1], ngrp_43_mall*sizeof(int))-1; bonded->grp_bond_con.j3_43 = (int *) crealloc(&(bonded->grp_bond_con.j3_43)[1], ngrp_43_mall*sizeof(int))-1; bonded->grp_bond_con.j4_43 = (int *) crealloc(&(bonded->grp_bond_con.j4_43)[1], ngrp_43_mall*sizeof(int))-1; bonded->grp_bond_con.jtyp_43 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_43)[1], ngrp_43_mall*sizeof(int))-1; bonded->grp_bond_con.j1_46 = (int *) crealloc(&(bonded->grp_bond_con.j1_46)[1], ngrp_46_mall*sizeof(int))-1; bonded->grp_bond_con.j2_46 = (int *) crealloc(&(bonded->grp_bond_con.j2_46)[1], ngrp_46_mall*sizeof(int))-1; bonded->grp_bond_con.j3_46 = (int *) crealloc(&(bonded->grp_bond_con.j3_46)[1], ngrp_46_mall*sizeof(int))-1; bonded->grp_bond_con.j4_46 = (int *) crealloc(&(bonded->grp_bond_con.j4_46)[1], ngrp_46_mall*sizeof(int))-1; bonded->grp_bond_con.jtyp_46 = (int *) crealloc(&(bonded->grp_bond_con.jtyp_46)[1], ngrp_46_mall*sizeof(int))-1; bonded->grp_bond_con.al_21 = cmall_mat(1,1,1,ngrp_21_mall); bonded->grp_bond_con.al_33 = cmall_mat(1,3,1,ngrp_33_mall); bonded->grp_bond_con.al_43 = cmall_mat(1,3,1,ngrp_43_mall); bonded->grp_bond_con.al_23 = cmall_mat(1,2,1,ngrp_23_mall); bonded->grp_bond_con.al_46 = cmall_mat(1,6,1,ngrp_46_mall); bonded->grp_bond_con.eq_21 = cmall_mat(1,1,1,ngrp_typ_21_mall); bonded->grp_bond_con.eq_33 = cmall_mat(1,3,1,ngrp_typ_33_mall); bonded->grp_bond_watts.eq_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_con.eq_43 = cmall_mat(1,3,1,ngrp_typ_43_mall); bonded->grp_bond_con.eq_23 = cmall_mat(1,2,1,ngrp_typ_23_mall); bonded->grp_bond_con.eq_46 = cmall_mat(1,6,1,ngrp_typ_46_mall); bonded->grp_bond_watts.cos_thet0_2 = (double *)malloc(ngrp_typ_watt_33_mall*sizeof(int))-1; bonded->grp_bond_watts.sin_thet0_2 = (double *)malloc(ngrp_typ_watt_33_mall*sizeof(int))-1; bonded->grp_bond_watts.c_0_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_1_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_2_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_3_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_4_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_5_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.c_6_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_0_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_1_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_2_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_3_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_4_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_5_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); bonded->grp_bond_watts.dc_6_33 = cmall_mat(1,3,1,ngrp_typ_watt_33_mall); /*======================================================================*/ /* II) Bonds */ now_memory = ((nbond_pow_mall)*(sizeof(double)*0+sizeof(int)*3)+ (nbond_con_mall)*(sizeof(double)*1 + sizeof(int)*3)+ (nbond_typ_pow_mall)*(sizeof(double)*14+ sizeof(int)*0 )+ (nbond_typ_con_mall)*(sizeof(double)*1 + sizeof(int)*0)+ (nbend_pow_mall)*(sizeof(double)*0 + sizeof(int)*4)+ (nbend_typ_pow_mall)*(sizeof(double)*29+ sizeof(int)*0)+ (nbend_con_mall)*(sizeof(double)*1 + sizeof(int)*4)+ (nbend_typ_con_mall)*(sizeof(double)*1 + sizeof(int)*0)+ (nbend_bnd_mall)*(sizeof(double)*0 + sizeof(int)*4)+ (nbend_bnd_typ_mall)*(sizeof(double)*44 + sizeof(int)*0)+ (ntors_pow_mall)*(sizeof(double)*0 + sizeof(int)*5)+ (ntors_con_mall)*(sizeof(double)*1 + sizeof(int)*5)+ (ntors_typ_pow_mall)*(sizeof(double)*30 + sizeof(int)*0)+ (nonfo_mall)*(sizeof(double)*0 + sizeof(int)*3)+ (nonfo_typ_mall)*(sizeof(double)*3 + sizeof(int)*0) )*1.e-06; *tot_memory += now_memory; printf("Intramolecular allocation: %g Mbytes; Total memory: %g Mbytes\n", now_memory,*tot_memory); ntyp_pow = nbond_typ_pow_mall; bonded->bond.j1_pow = (int *) crealloc(&(bonded->bond.j1_pow)[1], nbond_pow_mall*sizeof(int))-1; bonded->bond.j2_pow = (int *) crealloc(&(bonded->bond.j2_pow)[1], nbond_pow_mall*sizeof(int))-1; bonded->bond.jtyp_pow = (int *)crealloc(&(bonded->bond.jtyp_pow)[1], nbond_pow_mall*sizeof(int))-1; bonded->bond.j1_con = (int *) crealloc(&(bonded->bond.j1_con)[1], nbond_con_mall*sizeof(int))-1; bonded->bond.j2_con = (int *) crealloc(&(bonded->bond.j2_con)[1], nbond_con_mall*sizeof(int))-1; bonded->bond.jtyp_con = (int *)crealloc(&(bonded->bond.jtyp_con)[1], nbond_con_mall*sizeof(int))-1; bonded->bond.al_con = (double *)cmalloc(nbond_con_mall*sizeof(double))-1; bonded->bond.eq_pow = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.eq_pow_res = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.c_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.dc_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bond.eq_con = (double *)cmalloc(nbond_typ_con_mall *sizeof(double))-1; null_inter_parse->jbond1_nul= (int *) crealloc(&(null_inter_parse->jbond1_nul)[1], null_inter_parse->nbond_nul*sizeof(int))-1; null_inter_parse->jbond2_nul= (int *) crealloc(&(null_inter_parse->jbond2_nul)[1], null_inter_parse->nbond_nul*sizeof(int))-1; /*=======================================================================*/ /* III) Bends */ ntyp_pow = nbend_typ_pow_mall; bonded->bend.j1_pow = (int *) crealloc(&(bonded->bend.j1_pow)[1], nbend_pow_mall*sizeof(int))-1; bonded->bend.j2_pow = (int *) crealloc(&(bonded->bend.j2_pow)[1], nbend_pow_mall*sizeof(int))-1; bonded->bend.j3_pow = (int *) crealloc(&(bonded->bend.j3_pow)[1], nbend_pow_mall*sizeof(int))-1; bonded->bend.jtyp_pow = (int *)crealloc(&(bonded->bend.jtyp_pow)[1], nbend_pow_mall*sizeof(int))-1; bonded->bend.j1_con = (int *) crealloc(&(bonded->bend.j1_con)[1], nbend_con_mall*sizeof(int))-1; bonded->bend.j2_con = (int *) crealloc(&(bonded->bend.j2_con)[1], nbend_con_mall*sizeof(int))-1; bonded->bend.j3_con = (int *) crealloc(&(bonded->bend.j3_con)[1], nbend_con_mall*sizeof(int))-1; bonded->bend.jtyp_con = (int *)crealloc(&(bonded->bend.jtyp_con)[1], nbend_con_mall*sizeof(int))-1; bonded->bend.eq_pow = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.c_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.s_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.dc_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.ds_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->bend.eq_con = (double *)cmalloc(nbend_typ_con_mall *sizeof(double))-1; bonded->bend.al_con = (double *)cmalloc(nbend_con_mall *sizeof(double))-1; null_inter_parse->jbend1_nul= (int *) crealloc(&(null_inter_parse->jbend1_nul)[1], null_inter_parse->nbend_nul*sizeof(int))-1; null_inter_parse->jbend2_nul= (int *) crealloc(&(null_inter_parse->jbend2_nul)[1], null_inter_parse->nbend_nul*sizeof(int))-1; null_inter_parse->jbend3_nul= (int *) crealloc(&(null_inter_parse->jbend3_nul)[1], null_inter_parse->nbend_nul*sizeof(int))-1; /*=======================================================================*/ /* III) Bend_bnds */ bonded->bend_bnd.j1 = (int *) crealloc(&(bonded->bend_bnd.j1)[1], nbend_bnd_mall*sizeof(int))-1; bonded->bend_bnd.j2 = (int *) crealloc(&(bonded->bend_bnd.j2)[1], nbend_bnd_mall*sizeof(int))-1; bonded->bend_bnd.j3 = (int *) crealloc(&(bonded->bend_bnd.j3)[1], nbend_bnd_mall*sizeof(int))-1; bonded->bend_bnd.jtyp = (int *)crealloc(&(bonded->bend_bnd.jtyp)[1], nbend_bnd_mall*sizeof(int))-1; bonded->bend_bnd.eq_bond = (double *)cmalloc(nbend_bnd_typ_mall* sizeof(double))-1; bonded->bend_bnd.eq_bend = (double *)cmalloc(nbend_bnd_typ_mall* sizeof(double))-1; bonded->bend_bnd.cbond_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbond_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbond_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.cbend_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.sbend_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dcbend_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_0 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_1 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_2 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_3 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_4 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_5 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; bonded->bend_bnd.dsbend_6 = (double *)cmalloc(nbend_bnd_typ_mall *sizeof(double))-1; /*======================================================================*/ /* IV) Tors */ ntyp_pow = ntors_typ_pow_mall; bonded->tors.j1_pow = (int *) crealloc(&(bonded->tors.j1_pow)[1], ntors_pow_mall*sizeof(int))-1; bonded->tors.j2_pow = (int *) crealloc(&(bonded->tors.j2_pow)[1], ntors_pow_mall*sizeof(int))-1; bonded->tors.j3_pow = (int *) crealloc(&(bonded->tors.j3_pow)[1], ntors_pow_mall*sizeof(int))-1; bonded->tors.j4_pow = (int *) crealloc(&(bonded->tors.j4_pow)[1], ntors_pow_mall*sizeof(int))-1; bonded->tors.jtyp_pow = (int *)crealloc(&(bonded->tors.jtyp_pow)[1], ntors_pow_mall*sizeof(int))-1; bonded->tors.j1_con = (int *) crealloc(&(bonded->tors.j1_con)[1], ntors_con_mall*sizeof(int))-1; bonded->tors.j2_con = (int *) crealloc(&(bonded->tors.j2_con)[1], ntors_con_mall*sizeof(int))-1; bonded->tors.j3_con = (int *) crealloc(&(bonded->tors.j3_con)[1], ntors_con_mall*sizeof(int))-1; bonded->tors.j4_con = (int *) crealloc(&(bonded->tors.j4_con)[1], ntors_con_mall*sizeof(int))-1; bonded->tors.jtyp_con = (int *)crealloc(&(bonded->tors.jtyp_con)[1], ntors_con_mall*sizeof(int))-1; bonded->tors.al_con = (double *)cmalloc(ntors_con_mall *sizeof(double))-1; bonded->tors.eq_pow = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.c_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.s_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.dc_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_0 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_1 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_2 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_3 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_4 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_5 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.ds_6 = (double *)cmalloc(ntyp_pow*sizeof(double))-1; bonded->tors.eq_con = (double *)cmalloc(ntors_typ_pow_mall *sizeof(double))-1; null_inter_parse->jtors1_nul= (int *) crealloc(&(null_inter_parse->jtors1_nul)[1], null_inter_parse->ntors_nul*sizeof(int))-1; null_inter_parse->jtors2_nul= (int *) crealloc(&(null_inter_parse->jtors2_nul)[1], null_inter_parse->ntors_nul*sizeof(int))-1; null_inter_parse->jtors3_nul= (int *) crealloc(&(null_inter_parse->jtors3_nul)[1], null_inter_parse->ntors_nul*sizeof(int))-1; null_inter_parse->jtors4_nul= (int *) crealloc(&(null_inter_parse->jtors4_nul)[1], null_inter_parse->ntors_nul*sizeof(int))-1; /*=======================================================================*/ /* V) Onfo */ bonded->onfo.j1 = (int *) crealloc(&(bonded->onfo.j1)[1], nonfo_mall*sizeof(int))-1; bonded->onfo.j2 = (int *) crealloc(&(bonded->onfo.j2)[1], nonfo_mall*sizeof(int))-1; bonded->onfo.jtyp = (int *) crealloc(&(bonded->onfo.jtyp)[1], nonfo_mall*sizeof(int))-1; bonded->onfo.feps = (double *)cmalloc(nonfo_typ_mall*sizeof(double))-1; bonded->onfo.s6 = (double *)cmalloc(nonfo_typ_mall*sizeof(double))-1; bonded->onfo.sc = (double *)cmalloc(nonfo_typ_mall*sizeof(double))-1; null_inter_parse->jonfo1_nul= (int *) crealloc(&(null_inter_parse->jonfo1_nul)[1], null_inter_parse->nonfo_nul*sizeof(int))-1; null_inter_parse->jonfo2_nul = (int *) crealloc(&(null_inter_parse->jonfo2_nul)[1], null_inter_parse->nonfo_nul*sizeof(int))-1; /*=======================================================================*/ /* V) Assign mall variables */ clatoms_info->natm_mall = natm_mall; clatoms_info->nchrg_mall = nchrg_mall; ghost_atoms->nghost_mall = nghost_mall; ghost_atoms->ncomp_mall = ncomp_mall; atommaps->nfreeze_mall = nfreeze_mall; atommaps->natm_typ_mall = natm_typ_mall; bonded->bond.nbond_pow_mall = nbond_pow_mall; bonded->bond.nbond_typ_pow_mall = nbond_typ_pow_mall; bonded->bond.nbond_con_mall = nbond_con_mall; bonded->bond.nbond_typ_con_mall = nbond_typ_con_mall; bonded->grp_bond_con.ngrp_21_mall = ngrp_21_mall; bonded->grp_bond_watts.ngrp_33_mall = ngrp_watt_33_mall; bonded->grp_bond_con.ngrp_33_mall = ngrp_33_mall; bonded->grp_bond_con.ngrp_43_mall = ngrp_43_mall; bonded->grp_bond_con.ngrp_23_mall = ngrp_23_mall; bonded->grp_bond_con.ngrp_46_mall = ngrp_46_mall; bonded->grp_bond_con.ngrp_typ_21_mall = ngrp_typ_21_mall; bonded->grp_bond_con.ngrp_typ_33_mall = ngrp_typ_33_mall; bonded->grp_bond_watts.ngrp_typ_33_mall = ngrp_typ_watt_33_mall; bonded->grp_bond_con.ngrp_typ_43_mall = ngrp_typ_43_mall; bonded->grp_bond_con.ngrp_typ_23_mall = ngrp_typ_23_mall; bonded->grp_bond_con.ngrp_typ_46_mall = ngrp_typ_46_mall; bonded->bend.nbend_con_mall = nbend_con_mall; bonded->bend.nbend_typ_con_mall = nbend_typ_con_mall; bonded->bend.nbend_pow_mall = nbend_pow_mall; bonded->bend.nbend_typ_pow_mall = nbend_typ_pow_mall; bonded->bend_bnd.nbend_bnd_mall = nbend_bnd_mall; bonded->bend_bnd.nbend_bnd_typ_mall = nbend_bnd_typ_mall; bonded->tors.ntors_pow_mall = ntors_pow_mall; bonded->tors.ntors_typ_pow_mall = ntors_typ_pow_mall; bonded->tors.ntors_con_mall = ntors_con_mall; bonded->tors.ntors_typ_con_mall = ntors_typ_con_mall; bonded->onfo.nonfo_mall = nonfo_mall; bonded->onfo.nonfo_typ_mall = nonfo_typ_mall; /*-----------------------------------------------------------------------*/ }/*end routine*/