Index: main.c
===================================================================
--- main.c	(revisión: 33497)
+++ main.c	(copia de trabajo)
@@ -36,9 +36,11 @@
 {
 
     /* Variables' declarations */
-    int nsply, nsplx, nlines, nrows, ncols, subregion_row, subregion_col;
+    int nsply, nsplx, nlines, nrows, ncols;
+    int nsubregion_col, nsubregion_row, subregion_row, subregion_col;
     int last_row, last_column, grid, bilin, ext, flag_auxiliar, cross;	/* booleans */
     double passoN, passoE, lambda, mean;
+    double N_extension, E_extension, orloE, orloN;
 
     char *mapset, *dvr, *db, *vector, *map, table_name[1024], title[64];
 
@@ -215,7 +217,7 @@
 
     if (vector && map)
 	G_fatal_error(_("Choose either vector or raster output, not both"));
-#ifdef nodef
+#ifdef notdef
     if (!vector && !map && !cross_corr_flag->answer)
 	G_fatal_error(_("No raster nor vector output"));
 #endif
@@ -353,6 +355,17 @@
     /* Interpolation begins */
     G_debug(1, "Interpolation()");
 
+    if (map) {
+	nrows = G_window_rows();
+	ncols = G_window_cols();
+
+	if (!G_alloc_matrix(nrows, ncols))
+	    G_fatal_error(_
+			  ("Interpolation: The region resolution is too high: "
+			   "%d cells. Consider to change it."),
+			  nrows * ncols);
+    }
+
     /* Open driver and database */
     driver = db_start_driver_open_database(dvr, db);
     if (driver == NULL)
@@ -367,21 +380,11 @@
     Vect_region_box(&elaboration_reg, &general_box);
 
     /* Alloc raster matrix */
-    if (raster) {
-	double nrows_ncols;
+    if (map)
+	if (!(raster_matrix = G_alloc_matrix(nrows, ncols)))
+	    G_fatal_error(_("Cannot allocate memory for auxiliar matrix."
+			    "Consider changing region resolution"));
 
-	nrows = G_window_rows();
-	ncols = G_window_cols();
-	nrows_ncols = (double)nrows *ncols;
-
-	if ((nrows_ncols) > 30000000)	/* about 5500x5500 cells */
-	    G_fatal_error(_("Interpolation: The region resolution is too high: %d cells. "
-			   "Consider to change it."), nrows_ncols);
-
-	/*raster_matrix = G_alloc_fmatrix (nrows, ncols);  Is it neccesary a double precision?? */
-	raster_matrix = G_alloc_matrix(nrows, ncols);
-    }
-
     /* Fixxing parameters of the elaboration region */
     P_zero_dim(&dims);		/* Set to zero the dim struct */
     dims.latoE = NSPLX_MAX * passoE;
@@ -389,6 +392,18 @@
     dims.overlap = OVERLAP_SIZE * passoE;
     P_get_orlo(bilin, &dims, passoE, passoN);	/* Set the last two dim elements */
 
+    N_extension = original_reg.ns_res * original_reg.rows;
+    E_extension = original_reg.ew_res * original_reg.cols;
+    orloE = dims.latoE - dims.overlap - 2 * dims.orlo_h;
+    orloN = dims.latoN - dims.overlap - 2 * dims.orlo_v;
+    nsubregion_col = 2 + ((E_extension - dims.latoE) / orloE);
+    nsubregion_row = 2 + ((N_extension - dims.latoN) / orloN);
+
+    if (nsubregion_col < 0)
+	nsubregion_col = 0;
+    if (nsubregion_row < 0)
+	nsubregion_row = 0;
+
     /* Creating line and categories structs */
     points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
@@ -403,6 +418,7 @@
 
     elaboration_reg.south = original_reg.north;
 
+    G_percent(0, 1, 10);
     subregion_row = 0;
     last_row = FALSE;
     while (last_row == FALSE) {	/* For each row */
@@ -441,6 +457,7 @@
 	subregion_col = 0;
 	while (last_column == FALSE) {	/* For each column */
 	    int npoints = 0;
+            int nsubzones = 0, subzone = 0;
 
 	    subregion_col++;
 	    P_set_regions(&elaboration_reg, &general_box, &overlap_box, dims,
@@ -518,6 +535,8 @@
 		    if (bspline_field > 0) {
 			int cat, ival, ret, type;
 
+			if (!(type & GV_POINTS))
+			    continue;
 			cat = observ[i].cat;
 			if (cat < 0)
 			    continue;
@@ -670,6 +689,14 @@
 		}
 		G_free_ivector(lineVect);
 	    }
+	    else
+		G_warning(_("No data within this subzone. "
+			    "Consider changing the spline step."));
+
+            subzone = (subregion_row - 1) * nsubregion_col + subregion_col;
+            nsubzones = nsubregion_row * nsubregion_col;
+	    G_percent(subzone, nsubzones, 10);
+
 	}			/*! END WHILE; last_column = TRUE */
     }				/*! END WHILE; last_row = TRUE */
 

