Ignore:
Timestamp:
Mar 31, 2012, 2:47:12 PM (13 years ago)
Author:
davies
Message:

balanced_dev: fixed stack overflow problem, & new 'transect plot'
routine in util.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/gareth/experimental/balanced_dev/swb2_domain_ext.c

    r8359 r8375  
    787787  double dqv[3], qmin, qmax, hmin, hmax, bedmax, stagemin;
    788788  double hc, h0, h1, h2, beta_tmp, hfactor;
    789   double xmom_centroid_store[number_of_elements], ymom_centroid_store[number_of_elements], dk, dv0, dv1, dv2, de[3];
    790   double stage_centroid_store[number_of_elements];
    791    
     789  double dk, dv0, dv1, dv2, de[3];
     790  //double xmom_centroid_store[number_of_elements], ymom_centroid_store[number_of_elements]
     791  //double stage_centroid_store[number_of_elements];
     792 
     793  double *xmom_centroid_store, *ymom_centroid_store, *stage_centroid_store;
     794
     795  // Use malloc to avoid putting these variables on the stack, which can cause
     796  // segfaults in large model runs
     797  xmom_centroid_store = malloc(number_of_elements*sizeof(double));
     798  ymom_centroid_store = malloc(number_of_elements*sizeof(double));
     799  stage_centroid_store = malloc(number_of_elements*sizeof(double));
     800 
    792801  if(extrapolate_velocity_second_order==1){
    793802      // Replace momentum centroid with velocity centroid to allow velocity
     
    819828
    820829    if (number_of_boundaries[k]==3)
     830    //if (0==0)
    821831    {
    822832      // No neighbours, set gradient on the triangle to zero
     
    13661376      }
    13671377  }
     1378
     1379  free(xmom_centroid_store);
     1380  free(ymom_centroid_store);
     1381  free(stage_centroid_store);
    13681382
    13691383  return 0;
     
    18591873  number_of_elements = stage_centroid_values -> dimensions[0]; 
    18601874
     1875  //printf("In C before Extrapolate");
     1876  //e=1;
    18611877  // Call underlying computational routine
    18621878  e = _extrapolate_second_order_edge_sw(number_of_elements,
     
    18841900                   extrapolate_velocity_second_order);
    18851901
     1902  //printf("In C before edges-to-vertices");
    18861903
    18871904  //Extrapolate from edges to vertices
     
    18961913                                      (double *) elevation_vertex_values -> data,
    18971914                                      extrapolate_velocity_second_order);
     1915  //printf("In C after edges-to-vertices");
    18981916
    18991917  if (e == -1) {
Note: See TracChangeset for help on using the changeset viewer.