[cig-commits] r19103 - seismo/2D/SPECFEM2D/trunk/src/specfem2D

dkomati1 at geodynamics.org dkomati1 at geodynamics.org
Thu Oct 20 14:56:08 PDT 2011


Author: dkomati1
Date: 2011-10-20 14:56:08 -0700 (Thu, 20 Oct 2011)
New Revision: 19103

Modified:
   seismo/2D/SPECFEM2D/trunk/src/specfem2D/specfem2D.F90
   seismo/2D/SPECFEM2D/trunk/src/specfem2D/write_jpeg_image.c
Log:
fixed a bug in JPEG file names: there were trailing white spaces in the file name written to disk


Modified: seismo/2D/SPECFEM2D/trunk/src/specfem2D/specfem2D.F90
===================================================================
--- seismo/2D/SPECFEM2D/trunk/src/specfem2D/specfem2D.F90	2011-10-20 19:23:42 UTC (rev 19102)
+++ seismo/2D/SPECFEM2D/trunk/src/specfem2D/specfem2D.F90	2011-10-20 21:56:08 UTC (rev 19103)
@@ -403,7 +403,7 @@
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: &
     accelw_poroelastic,velocw_poroelastic,displw_poroelastic
   real(kind=CUSTOM_REAL), dimension(:,:), allocatable :: &
-    accels_poroelastic_adj_coupling, accelw_poroelastic_adj_coupling      
+    accels_poroelastic_adj_coupling, accelw_poroelastic_adj_coupling
   double precision, dimension(:), allocatable :: porosity,tortuosity
   double precision, dimension(:,:), allocatable :: density,permeability
 

Modified: seismo/2D/SPECFEM2D/trunk/src/specfem2D/write_jpeg_image.c
===================================================================
--- seismo/2D/SPECFEM2D/trunk/src/specfem2D/write_jpeg_image.c	2011-10-20 19:23:42 UTC (rev 19102)
+++ seismo/2D/SPECFEM2D/trunk/src/specfem2D/write_jpeg_image.c	2011-10-20 21:56:08 UTC (rev 19103)
@@ -31,6 +31,21 @@
 
   /* this is a pointer to one row of image data */
   JSAMPROW row_pointer[1];
+
+// DK DK trim white spaces in filename coming from Fortran call
+// DK DK taken from http://stackoverflow.com/questions/122616/how-do-i-trim-leading-trailing-whitespace-in-a-standard-way
+  char *end;
+
+  // Trim leading space
+  while(isspace(*filename)) filename++;
+
+  // Trim trailing space
+  end = filename + strlen(filename) - 1;
+  while(end > filename && isspace(*end)) end--;
+
+  // Write new null terminator
+  *(end+1) = 0;
+
   FILE *outfile = fopen( filename, "wb" );
 
   if ( !outfile )



More information about the CIG-COMMITS mailing list