// This program pre-processes the fetch and depth data needed for the parametric wave code (param_wave.cpp). // It reads in a grid file (fort.14) and calculats fetch rays (cosine averaged), depth values (I.D.W. averaged), // and bottom slopes for all wet nodes in the domain at angular increments (2 deg reccomended) // // By: Samuel Carter Boyd // Date: 04/13/2020 #include #include #include #include #include #include #include #include #include #include using namespace std; char content[10]; double a; double distlon,distlat; double lat0,lon0,dlat1,dlat2,dlat3,dlat4,dlon1,dlon2,dlon3,dlon4; int wet_tot,dry_tot,x,i,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,ii,step1,step2,step3,step4,node1,node_tot,elm_tot; double res; //resolution (meters) for spatial step int Angres; //res (deg) for angular step bool check; double p,p_temp,Eff_res; //IDW power value and cosine weighted angular averaging value double vx[4] = {}; double vy[4] = {}; double dx; //deg lat double dy; //deg lon double xloc[4],yloc[4] = {}; double D,delx,dely,theta; double crossprod1,crossprod2,crossprod3; int contELM1,contELM2,contELM3,contELM4; double w1,w2,w3; vector dephold1,dephold2,dephold3,dephold4; double meanwetlat,meanwetlon,wetlonsum,wetlatsum = 0; double pi = 4*atan(1); double Rearth; double Req=6378137; double Rpo=6356752; double dhav1,dhav2,dhav3,dhav4; int emin1,emax1,emin2,emax2,emin3,emax3,emin4,emax4=0; int line,x1,x2,c,Ftop,Ftop2,Favg,k,k1,k2,num_depths,direction,dir_tot=0; string s; char temp[10]; double g=9.7918; double Eff_top,Eff_bot,Eff_fetch,depth_temp,depth_tot,depth_cur,depth_prev,Eff_depth,denominator,Up; int Ftop,Ftop2,Favg=0; double Dtop,Dtop2,Davg,dconst,Mtop,Mtop2,Mavg=0; int main(){ float clock_t,time_req; time_req=clock(); //initializing the clock for timing tasks //************************************************************************************************ //These are the names of the final output files created for the grid's depth and fetch information //************************************************************************************************ ofstream outfile6("Distance_data_2_deg.txt"); ofstream outfile7("Depth_data_2_deg.txt"); ofstream outfile8("Slope_upwind_2_deg.txt"); ofstream outfile9("p_values_2_deg.txt"); ofstream outfile2("IDW_depths_2_deg.txt"); ofstream outfile1("Eff_fetch_2_deg.txt"); ofstream outfile5("Raw_depth_2_deg.txt"); ifstream infile; infile.open("fort.14"); //name of grid file if(infile.is_open()){ cout<> content){ x=x+1; if(x==2){ elm_tot = atoi(content); } if(x==3){ node_tot = atoi(content); break; } } x=0; infile.close(); cout<> content){ x=x+1; if(x>=4 && x<= 4 + (node_tot*4)){ //4 is from node number(1),lat(2),lon(3),elv(4) i = i+1; a = atof(content); if(((i+0)%4) == 0){ c1=c1+1; elv[c1] = a; } if(((i+1)%4) == 0){ c2=c2+1; lat[c2] = a; } if(((i+2)%4) == 0){ c3=c3+1; lon[c3] = a; } if(((i+3)%4) == 0){ c4=c4+1; node[c4] = a; } } //Element information is being read once code reaches end of regular nodal info if(x >= (4 + (node_tot*4)) && x < (4 + (node_tot*4))+(elm_tot*5)){ ii = ii+1; a = atoi(content); if(((ii+4)%5) == 0){ c7 = c7+1; ELM[c7] = a; } if(((ii+2)%5) == 0){ c8 = c8+1; NE[c8][1] = a; } if(((ii+1)%5) == 0){ c9 = c9+1; NE[c9][2] = a; } if(((ii+0)%5) == 0){ c10 = c10+1; NE[c10][3] = a; } } } infile.close(); //calculating average wet lat and lon in domain for(int j=1; j<=node_tot; j++){ if(elv[j] > 0){ c5=c5+1; wetlatsum = wetlatsum+lat[j]; wetlonsum = wetlonsum+lon[j]; } if(elv[j] < 0){ c6=c6+1; } } //close node_tot loop wet_tot = c5; dry_tot = c6; meanwetlat = wetlatsum/wet_tot; meanwetlon = wetlonsum/wet_tot; cout<<"Mean longitude (wet): "<0 && elv[NE[e][2]]>0 && elv[NE[e][3]]>0){ d12=distlon*sqrt(pow(lon[NE[e][1]]-lon[NE[e][2]],2)+(pow(lat[NE[e][1]]-lat[NE[e][2]],2))); d13=distlon*sqrt(pow(lon[NE[e][1]]-lon[NE[e][3]],2)+(pow(lat[NE[e][1]]-lat[NE[e][3]],2))); d23=distlon*sqrt(pow(lon[NE[e][2]]-lon[NE[e][3]],2)+(pow(lat[NE[e][2]]-lat[NE[e][3]],2))); //cout<<"d12: "<>res; dx = res/distlon; //50m step in lat/lon degrees specified by the step resolution dy = res/distlat; //cout<<"dx("<>Angres; check=false; if(Angres==2 || Angres==5 || Angres==10 || Angres==18 || Angres==30){ check=true; cout<>Angres; if(Angres==2 || Angres==5 || Angres==10 || Angres==18 || Angres==30){ check=true; cout<>p_temp; // VARIABLE WEIGHTING SHOULD NOT BE USED UNTIL A BETTER P-VALUE RELATIONSHIP IS DETERMINED check=false; if(p_temp>0){ check=true; cout<>Up; cout<>p_temp; if(p_temp>0){ check=true; cout<>Eff_res; cout<<"Effective angular averaging will consider "< 0){ //if node is wet startelv=elv[j]; //depth at the start node //*************************************Q1******************************************************************** for(int m=0; m 0){ //while (XP,YP) is wet dephold1.push_back(Pelv1[m]); //stores every Pelv value step1=step1+1; //increment XP and YP 1 step further XP1[m] = lon0 + (dx*cos((pi/180)*(90-(Angres*m))))*step1; YP1[m] = lat0 + (dy*sin((pi/180)*(90-(Angres*m))))*step1; //if first step already taken, compare the 1st neighboring node of the previous containing element //so that the restricted element search is wrt the containing element instead of the start node j //Pelv1 at step1==2 corresponds to the first step's interpolated depth. Calculate slope from start to here //BUT slope values are stored in slopehold array in flipped indexes. Q1<-->Q3 and Q2<-->Q4 because we want //the index to correspond to upwind slope for determining wave breaking if(step1==2){ slopehold[j][m+1]=(startelv-Pelv1[m])/res; //if slope is less than 1/1000 set to 0, this inludes negative slopes (from shallow to deeper water) if(slopehold[j][m+1] < 1/1000){ slopehold[j][m+1]=0; } outfile8<1){ emin1=2*NE[contELM1][1]-floor(.0163*NE[contELM1][1]+1500); emax1=2*NE[contELM1][1]+1500; } if(emin1<1){ emin1=1; } if(emax1>=elm_tot){ emax1=elm_tot; } contELM1 = false; //resent containing element //****Element Search***** //restricted element search according to emin and emax values for(int e=emin1; e<=emax1; e++){ for(int i=1; i<=3; i++){ //vectors of neighboring nodes xloc[i] = lon[NE[e][i]]; yloc[i] = lat[NE[e][i]]; delx = xloc[i] - XP1[m]; dely = yloc[i] - YP1[m]; D = pow((pow(delx,2.0)+pow(dely,2.0)),0.5); theta = atan2(dely,delx); vx[i] = D*cos(theta); vy[i] = D*sin(theta); } //cross products of neighboring node vectors crossprod1 = vx[1]*vy[2] - vy[1]*vx[2]; crossprod2 = vx[2]*vy[3] - vy[2]*vx[3]; crossprod3 = vx[3]*vy[1] - vy[3]*vx[1]; //if cross products are all >= 0, containing ELM if(crossprod1>=0 && crossprod2>=0 && crossprod3>=0){ contELM1 = ELM[e]; //cout<<"R.SearchFound. contELM1: "< 0){ Phold1[m] = Pelv1[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted element search for loop if(contELM1 == false){ //cout<<"Long Search Q1************** steps: "<= 0, containing ELM if(crossprod1>=0 && crossprod2>=0 && crossprod3>=0){ contELM1 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP1[m]-xloc[3])+(xloc[3]-xloc[2])*(YP1[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP1[m]-xloc[3])+(xloc[1]-xloc[3])*(YP1[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv1[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv1[m] > 0){ Phold1[m] = Pelv1[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close for all elements loop //cout<<"!!!!contELM1: "< 0 loop outfile7< 0){ //while (XP,YP) is wet dephold4.push_back(Pelv4[m]); //stores every Pelv value step4=step4+1; XP4[m] = lon0 + (dx*cos((pi/180)*(Angres*m)))*step4; YP4[m] = lat0 - (dy*sin((pi/180)*(Angres*m)))*step4; //if first step already taken, compare the 1st neighboring node of the previous containing element //so that the restricted element search is wrt the containing element instead of the start node j //Pelv4 at step4==2 corresponds to the first step's interpolated depth. Calculate slope from start to here //BUT slope values are stored in slopehold array in flipped indexes. Q1<-->Q3 and Q2<-->Q4 because we want //the index to correspond to upwind slope for determining wave breaking if(step4==2){ slopehold[j][m+Ares2+1]=(startelv-Pelv4[m])/res; //if slope is less than 1/1000 set to 0, this inludes negative slopes (from shallow to deeper water) if(slopehold[j][m+Ares2+1] < 1/1000){ slopehold[j][m+Ares2+1]=0; } outfile8<1){ emin4=2*NE[contELM4][1]-floor(.0163*NE[contELM4][1]+1500); emax4=2*NE[contELM4][1]+1500; } if(emin4<1){ emin4=1; } if(emax4>=elm_tot){ emax4=elm_tot; } contELM4 = false; //resent containing element //****Element Search**** for(int e=emin4; e<=emax4; e++){ for(int i=1; i<=3; i++){ xloc[i] = lon[NE[e][i]]; yloc[i] = lat[NE[e][i]]; delx = xloc[i] - XP4[m]; dely = yloc[i] - YP4[m]; D = pow((pow(delx,2.0)+pow(dely,2.0)),0.5); theta = atan2(dely,delx); vx[i] = D*cos(theta); vy[i] = D*sin(theta); } crossprod1 = vx[1]*vy[2] - vy[1]*vx[2]; crossprod2 = vx[2]*vy[3] - vy[2]*vx[3]; crossprod3 = vx[3]*vy[1] - vy[3]*vx[1]; if(crossprod1>=0 && crossprod2>=0 && crossprod3>=0){ contELM4 = ELM[e]; //****arycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP4[m]-xloc[3])+(xloc[3]-xloc[2])*(YP4[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP4[m]-xloc[3])+(xloc[1]-xloc[3])*(YP4[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv4[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv4[m] > 0){ Phold4[m] = Pelv4[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted elemt search for loop //if no containing element, search all nodes if(contELM4 == false){ //cout<<"Long Search Q4************** steps: "<=0 && crossprod2>=0 && crossprod3>=0){ contELM4 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP4[m]-xloc[3])+(xloc[3]-xloc[2])*(YP4[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP4[m]-xloc[3])+(xloc[1]-xloc[3])*(YP4[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv4[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv4[m] > 0){ Phold4[m] = Pelv4[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted elemt search for loop //cout<<"!!!!contELM4: "< 0 loop outfile7< 0){ //while (XP,YP) is wet dephold3.push_back(Pelv3[m]); //stores every Pelv value step3=step3+1; XP3[m] = lon0 - (dx*cos((pi/180)*(90-(Angres*m))))*step3; YP3[m] = lat0 - (dy*sin((pi/180)*(90-(Angres*m))))*step3; //if first step already taken, compare the 1st neighboring node of the previous containing element //so that the restricted element search is wrt the containing element instead of the start node j //Pelv3 at step3==2 corresponds to the first step's interpolated depth. Calculate slope from start to here //BUT slope values are stored in slopehold array in flipped indexes. Q1<-->Q3 and Q2<-->Q4 because we want //the index to correspond to upwind slope for determining wave breaking if(step3==2){ slopehold[j][m+Ares2+Ares2+1]=(startelv-Pelv3[m])/res; //if slope is less than 1/1000 set to 0, this inludes negative slopes (from shallow to deeper water) if(slopehold[j][m+Ares2+Ares2+1] < 1/1000){ slopehold[j][m+Ares2+Ares2+1]=0; } outfile8<1){ emin3=2*NE[contELM3][1]-floor(.0163*NE[contELM3][1]+1500); emax3=2*NE[contELM3][1]+1500; } if(emin3<1){ emin3=1; } if(emax3>=elm_tot){ emax3=elm_tot; } contELM3 = false; //resent containing element //****Element Search**** for(int e=emin3; e<=emax3; e++){ for(int i=1; i<=3; i++){ xloc[i] = lon[NE[e][i]]; yloc[i] = lat[NE[e][i]]; delx = xloc[i] - XP3[m]; dely = yloc[i] - YP3[m]; D = pow((pow(delx,2.0)+pow(dely,2.0)),0.5); theta = atan2(dely,delx); vx[i] = D*cos(theta); vy[i] = D*sin(theta); } crossprod1 = vx[1]*vy[2] - vy[1]*vx[2]; crossprod2 = vx[2]*vy[3] - vy[2]*vx[3]; crossprod3 = vx[3]*vy[1] - vy[3]*vx[1]; if(crossprod1>=0 && crossprod2>=0 && crossprod3>=0){ contELM3 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP3[m]-xloc[3])+(xloc[3]-xloc[2])*(YP3[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP3[m]-xloc[3])+(xloc[1]-xloc[3])*(YP3[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv3[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv3[m] > 0){ Phold3[m] = Pelv3[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted element search for loop if(contELM3 == false){ //cout<<"Long Search Q3************** steps: "<=0 && crossprod2>=0 && crossprod3>=0){ contELM3 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP3[m]-xloc[3])+(xloc[3]-xloc[2])*(YP3[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP3[m]-xloc[3])+(xloc[1]-xloc[3])*(YP3[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv3[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv3[m] > 0){ Phold3[m] = Pelv3[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted element search for loop //cout<<"!!!!contELM3: "< 0 loop outfile7< 0){ //while (XP,YP) is wet dephold2.push_back(Pelv2[m]); //stores every Pelv value step2=step2+1; XP2[m] = lon0 - (dx*cos((pi/180)*(Angres*m)))*step2; YP2[m] = lat0 + (dy*sin((pi/180)*(Angres*m)))*step2; //if first step already taken, compare the 1st neighboring node of the previous containing element //so that the restricted element search is wrt the containing element instead of the start node j //Pelv1 at step1==2 corresponds to the first step's interpolated depth. Calculate slope from start to here //BUT slope values are stored in slopehold array in flipped indexes. Q1<-->Q3 and Q2<-->Q4 because we want //the index to correspond to upwind slope for determining wave breaking if(step2==2){ slopehold[j][m+Ares2+Ares2+Ares2+1]=(startelv-Pelv2[m])/res; //if slope is less than 1/1000 set to 0, this inludes negative slopes (from shallow to deeper water) if(slopehold[j][m+Ares2+Ares2+Ares2+1] < 1/1000){ slopehold[j][m+Ares2+Ares2+Ares2+1]=0; } outfile8<1){ emin2=2*NE[contELM2][1]-floor(.0163*NE[contELM2][1]+1500); emax2=2*NE[contELM2][1]+1500; } if(emin2<1){ emin2=1; } if(emax2>=elm_tot){ emax2=elm_tot; } contELM2 = false; //resent containing element //****Element Search**** for(int e=emin2; e<=emax2; e++){ for(int i=1; i<=3; i++){ xloc[i] = lon[NE[e][i]]; yloc[i] = lat[NE[e][i]]; delx = xloc[i] - XP2[m]; dely = yloc[i] - YP2[m]; D = pow((pow(delx,2.0)+pow(dely,2.0)),0.5); theta = atan2(dely,delx); vx[i] = D*cos(theta); vy[i] = D*sin(theta); } crossprod1 = vx[1]*vy[2] - vy[1]*vx[2]; crossprod2 = vx[2]*vy[3] - vy[2]*vx[3]; crossprod3 = vx[3]*vy[1] - vy[3]*vx[1]; if(crossprod1>=0 && crossprod2>=0 && crossprod3>=0){ contELM2 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP2[m]-xloc[3])+(xloc[3]-xloc[2])*(YP2[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP2[m]-xloc[3])+(xloc[1]-xloc[3])*(YP2[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv2[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv2[m] > 0){ Phold2[m] = Pelv2[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close restricted element search for loop if(contELM2 == false){ //cout<<"Long Search Q2************** steps: "<=0 && crossprod2>=0 && crossprod3>=0){ contELM2 = ELM[e]; //****Barycentric elevation interpolation**** w1 =((yloc[2]-yloc[3])*(XP2[m]-xloc[3])+(xloc[3]-xloc[2])*(YP2[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w2 =((yloc[3]-yloc[1])*(XP2[m]-xloc[3])+(xloc[1]-xloc[3])*(YP2[m]-yloc[3]))/ ((yloc[2]-yloc[3])*(xloc[1]-xloc[3])+(xloc[3]-xloc[2])*(yloc[1]-yloc[3])); w3 = 1-w1-w2; Pelv2[m] = (w1*elv[NE[e][1]]+w2*elv[NE[e][2]]+w3*elv[NE[e][3]])/(w1+w2+w3); if(Pelv2[m] > 0){ Phold2[m] = Pelv2[m]; //The last wet point } break; //out of for elements loop } //close if(crossprod > 0) } //close all element search for loop //cout<<"!!!!contELM2: "< 0 loop outfile7<3 && line7){ //if the length of line > 7 characters stringstream ss; ss<>content; //read number by number from s as (content) x=0; //indexing variable reset to 0 while(!ss.eof()){ //while values in the line (string ss) ss>>temp; //read each value x=x+1; //indexing variable if(x==1){ //if first number, store value as node number node1=atoi(content); //cout<<"NODE: "<7 } //close if header >3 and <126773 } //close while getline for "Distance_data4.txt" } //close if "Distance_data4.txt" is open else{ cout<<"!!! ERROR Distance_data_2_deg.txt not read!!!"<>content; node_tot=atof(content); //cout<<"Node_tot: "<>temp; dir_tot=atof(temp); //cout<<"Dir_tot: "<2){ //for all other lines x2=x2+1; //indexing variable 2 progress x1=0; //indexing variable 1 reset when there is a new line stringstream ss; ss<>content; while(!ss.eof()){ x2=0; //indexing varriable 2 reset when there is a new value ss>>temp; //read in each value of ss x1=x1+1; //progress indexing variable 1 check=false; //reset boolean check value to false if(x1==1){ //first value is direction (1:4*Ares) direction=atof(temp); check=true; //if the direction value is read, check is reset //to true because you know a new node has been reached } if(check=true && depth_tot!=0){ //if a new node has been reached direction=direction-1; //reset direction to the previous if(direction==0){ //if==0 reset to the last value direction=360/Angres; } //depth averaging scheme d[node1][direction]=depth_tot/denominator; depth_tot=0; //resetting depth_tot to 0 once value is stored denominator=0; } if(x1==2){ //second value is number of depths(needed for averaging) num_depths=atof(temp); } } //close while !ss.eof if(x2==0){ //reading in node number node1=atof(content); outfile9<2){ //skip 2nd line, built into special case, read 3rd line+ in the depths and sum together for average depth_temp = atof(content); depth_tot = depth_tot+(depth_temp/(pow(((x2-1)*res),p))); denominator = denominator+(1/(pow(((x2-1)*res),p))); //cout<<"depth["< 2 } //close while getline } //close if infile2 is_open else{ cout<<"!!! ERROR Depth_data_5_deg.txt not read!!!"<k1){ //direction within Eff_res deg left or right of the current node. for values that go below 1 k1=i+n+(360/Angres); //reset index to //cout<<"k1: "<36 is encountered if(i+n > 360/Angres && i+n-(360/Angres)>k2){ //for values that go above max direction k2=i+n-(360/Angres); //reset index to (1:4) //cout<<"k2: "<0){ Ftop=Ftop+fetch[j][i]; Dtop=Dtop+d[j][i]; if(slopehold[j][i] < 1){ Mtop=Mtop+slopehold[j][i]; } c2=c2+1; if(j>6 && j<10){ //cout<<"slope["<