Skip to content

Commit f892fc4

Browse files
rem1776rem1776
andauthored
fixes for gaussian topog type option (#340)
* set uninitialized value in create_gaussian_topog * fix wrong variable in loop * fix loop variable again --------- Co-authored-by: rem1776 <Ryan.Mulhall@noaa.gov>
1 parent 92c085d commit f892fc4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/make_topog/topog.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ void create_gaussian_topog(int nx, int ny, const double *x, const double *y, dou
108108
double bump_height, bump_scale, xcent, ycent, arg, bottom;
109109
double xe, xw, ys, yn;
110110
double *xt, *yt;
111-
int i, j, nxp, nyp;
111+
int i, j, nxp;
112+
113+
nxp = nx + 1;
112114

113115
xt = (double *)malloc(nx*ny*sizeof(double));
114116
yt = (double *)malloc(nx*ny*sizeof(double));
@@ -142,7 +144,7 @@ void create_gaussian_topog(int nx, int ny, const double *x, const double *y, dou
142144
printf("The ocean floor rises with a slope of %f meters/deg towards the east and %f "
143145
" meters/deg to the north.", slope_x, slope_y) ;
144146

145-
for(j=0;i<nx*ny;j++){
147+
for(i=0;i<nx*ny;i++){
146148
arg = pow(xt[i]-xcent,2) + pow(yt[i]-ycent,2);
147149
bottom = bottom_depth - bump_height*exp(-arg/pow(bump_scale,2));
148150
bottom = bottom - slope_x*(xt[i]-xw)- slope_y*(yt[i]-ys);

0 commit comments

Comments
 (0)