[cig-commits] r6236 - mc/3D/CitcomS/trunk/lib

gurnis at geodynamics.org gurnis at geodynamics.org
Mon Mar 12 17:56:07 PDT 2007


Author: gurnis
Date: 2007-03-12 17:56:07 -0700 (Mon, 12 Mar 2007)
New Revision: 6236

Modified:
   mc/3D/CitcomS/trunk/lib/Full_read_input_from_files.c
   mc/3D/CitcomS/trunk/lib/Regional_lith_age_read_files.c
   mc/3D/CitcomS/trunk/lib/Regional_read_input_from_files.c
Log:
Refactored the regional parts of the code so that the age grids are read in from the same code as are the velocity and material files. Moved the guts of Regional_lith_age_read_files.c to Regional_read_input_from_files.c.  This nearly makes the structure of Full and Regional the same -- refactoring that Leif initiated last year

Modified: mc/3D/CitcomS/trunk/lib/Full_read_input_from_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Full_read_input_from_files.c	2007-03-12 23:27:29 UTC (rev 6235)
+++ mc/3D/CitcomS/trunk/lib/Full_read_input_from_files.c	2007-03-13 00:56:07 UTC (rev 6236)
@@ -118,7 +118,7 @@
 	}
 	break;
 
-      case 2:  /* read ages for lithosphere tempperature assimilation */
+      case 2:  /* read ages for lithosphere temperature assimilation */
 	sprintf(output_file1,"%s%0.0f.%d",E->control.lith_age_file,newage1,cap);
 	sprintf(output_file2,"%s%0.0f.%d",E->control.lith_age_file,newage2,cap);
 	fp1=fopen(output_file1,"r");

Modified: mc/3D/CitcomS/trunk/lib/Regional_lith_age_read_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional_lith_age_read_files.c	2007-03-12 23:27:29 UTC (rev 6235)
+++ mc/3D/CitcomS/trunk/lib/Regional_lith_age_read_files.c	2007-03-13 00:56:07 UTC (rev 6236)
@@ -32,82 +32,8 @@
 
 void regional_lith_age_read_files(struct All_variables *E, int output)
 {
-  float find_age_in_MY();
-
-  FILE *fp1, *fp2;
-  float age, newage1, newage2;
-  char output_file1[255],output_file2[255];
-  float inputage1, inputage2;
-  int nox,noz,noy,nox1,noz1,noy1,lev;
-  int i,j,node;
-  int intage, pos_age;
-
-
-  nox=E->mesh.nox;
-  noy=E->mesh.noy;
-  noz=E->mesh.noz;
-  nox1=E->lmesh.nox;
-  noz1=E->lmesh.noz;
-  noy1=E->lmesh.noy;
-  lev=E->mesh.levmax;
-
-  age=find_age_in_MY(E);
-  if(E->parallel.me==0) {
-     fprintf(stderr,"INSIDE regional_lith_age_read_files, age= %g\n",age);
-  }
-
-  if (age < 0.0) { /* age is negative -> use age=0 for input files */
-    intage = 0;
-    newage2 = newage1 = 0.0;
-    pos_age = 0;
-  }
-  else {
-    intage = age;
-    newage1 = 1.0*intage;
-    newage2 = 1.0*intage + 1.0;
-    pos_age = 1;
-  }
-
-  /* read ages for lithosphere tempperature boundary conditions */
-  sprintf(output_file1,"%s%0.0f",E->control.lith_age_file,newage1);
-  sprintf(output_file2,"%s%0.0f",E->control.lith_age_file,newage2);
-  fp1=fopen(output_file1,"r");
-  if (fp1 == NULL) {
-    fprintf(E->fp,"(Problem_related #6) Cannot open %s\n",output_file1);
-    parallel_process_termination();
-  }
-  if (pos_age) {
-    fp2=fopen(output_file2,"r");
-    if (fp2 == NULL) {
-      fprintf(E->fp,"(Problem_related #7) Cannot open %s\n",output_file2);
-    parallel_process_termination();
-    }
-  }
-  if((E->parallel.me==0) && output) {
-    fprintf(E->fp,"Lith_Age: Starting Age = %g, Elapsed time = %g, Current Age = %g\n",E->control.start_age,E->monitor.elapsed_time,age);
-    fprintf(E->fp,"Lith_Age: File1 = %s\n",output_file1);
-    if (pos_age)
-      fprintf(E->fp,"Lith_Age: File2 = %s\n",output_file2);
-    else
-      fprintf(E->fp,"Lith_Age: File2 = No file inputted (negative age)\n");
-  }
-
-  for(i=1;i<=noy;i++)
-    for(j=1;j<=nox;j++) {
-      node=j+(i-1)*nox;
-      fscanf(fp1,"%f",&inputage1);
-      if (pos_age) { /* positive ages - we must interpolate */
-	fscanf(fp2,"%f",&inputage2);
-	E->age_t[node] = (inputage1 + (inputage2-inputage1)/(newage2-newage1)*(age-newage1))/E->data.scalet;
-      }
-      else { /* negative ages - don't do the interpolation */
-	E->age_t[node] = inputage1;
-      }
-    }
-  fclose(fp1);
-  if (pos_age) fclose(fp2);
-
-  return;
+    regional_read_input_files_for_timesteps(E,2,output); /*2 (=action) is for lith_age*/
+    return;
 }
 
 

Modified: mc/3D/CitcomS/trunk/lib/Regional_read_input_from_files.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Regional_read_input_from_files.c	2007-03-12 23:27:29 UTC (rev 6235)
+++ mc/3D/CitcomS/trunk/lib/Regional_read_input_from_files.c	2007-03-13 00:56:07 UTC (rev 6236)
@@ -117,6 +117,30 @@
       }
       break;
 
+      case 2:  /* read ages for lithosphere temperature assimilation */
+        sprintf(output_file1,"%s%0.0f",E->control.lith_age_file,newage1);
+        sprintf(output_file2,"%s%0.0f",E->control.lith_age_file,newage2);
+        fp1=fopen(output_file1,"r");
+        if (fp1 == NULL) {
+          fprintf(E->fp,"(Problem_related #6) Cannot open %s\n",output_file1);
+          exit(8);
+        }
+        if (pos_age) {
+          fp2=fopen(output_file2,"r");
+          if (fp2 == NULL) {
+            fprintf(E->fp,"(Problem_related #7) Cannot open %s\n",output_file2);            exit(8);
+          }
+        }
+        if((E->parallel.me==0) && (output==1))   {
+          fprintf(E->fp,"Age: Starting Age = %g, Elapsed time = %g, Current Age = %g\n",E->control.start_age,E->monitor.elapsed_time,age);
+          fprintf(E->fp,"Age: File1 = %s\n",output_file1);
+          if (pos_age)
+            fprintf(E->fp,"Age: File2 = %s\n",output_file2);
+          else
+            fprintf(E->fp,"Age: File2 = No file inputted (negative age)\n");
+        }
+        break;
+
       case 3:  /* read element materials */
 
         sprintf(output_file1,"%s%0.0f.0",E->control.mat_file,newage1);
@@ -190,6 +214,23 @@
       }
       break;
 
+      case 2:  /* ages for lithosphere temperature assimilation */
+        for(i=1;i<=noy;i++)
+          for(j=1;j<=nox;j++) {
+            node=j+(i-1)*nox;
+            fscanf(fp1,"%f",&inputage1);
+            if (pos_age) { /* positive ages - we must interpolate */
+              fscanf(fp2,"%f",&inputage2);
+              E->age_t[node] = (inputage1 + (inputage2-inputage1)/(newage2-newage1)*(age-newage1))/E->data.scalet;
+            }
+            else { /* negative ages - don't do the interpolation */
+              E->age_t[node] = inputage1;
+            }
+          }
+        fclose(fp1);
+        if (pos_age) fclose(fp2);
+        break;
+
       case 3:  /* read element materials */
 
         VIP1 = (float*) malloc ((emax+1)*sizeof(float));



More information about the cig-commits mailing list