[cig-commits] r9330 - cs/avm/trunk

tan2 at geodynamics.org tan2 at geodynamics.org
Wed Feb 13 18:07:31 PST 2008


Author: tan2
Date: 2008-02-13 18:07:31 -0800 (Wed, 13 Feb 2008)
New Revision: 9330

Modified:
   cs/avm/trunk/avm-partition.c
   cs/avm/trunk/elastic-models.c
   cs/avm/trunk/elastic-models.h
   cs/avm/trunk/prem-derived-models.c
Log:
Fixed a bug in passing pointers

Modified: cs/avm/trunk/avm-partition.c
===================================================================
--- cs/avm/trunk/avm-partition.c	2008-02-14 02:06:51 UTC (rev 9329)
+++ cs/avm/trunk/avm-partition.c	2008-02-14 02:07:31 UTC (rev 9330)
@@ -66,7 +66,7 @@
 
         /* open input file(s) */
         ifilename = argv[i];
-        fprintf(stderr, "\rReading %s ...   ", ifilename);
+        fprintf(stderr, "Reading %s\n", ifilename);
         in = fopen(ifilename, "r");
         if (!in) {
             fprintf(stderr, "%s: fopen: `%s': ", argv[0], ifilename);
@@ -100,7 +100,7 @@
 
             /* select and setup elastic model for later use */
             select_elastic_model(model_type, num_columns, num_compositions,
-                                 elastic_model, context);
+                                 &elastic_model, &context);
         }
         else {
             if ((old_type != model_type) ||

Modified: cs/avm/trunk/elastic-models.c
===================================================================
--- cs/avm/trunk/elastic-models.c	2008-02-14 02:06:51 UTC (rev 9329)
+++ cs/avm/trunk/elastic-models.c	2008-02-14 02:07:31 UTC (rev 9330)
@@ -55,7 +55,7 @@
  */
 void select_elastic_model(int model_type,
                           int num_columns, int num_compositions,
-                          elastic_model_fn fn, void *context)
+                          elastic_model_fn *fn, void **context)
 {
     /*
      * Select which elastic model to use. The convection is:
@@ -67,17 +67,17 @@
     switch (model_type) {
     case 1:
         /* using modulus derivatives */
-        prem_mod_derv_em_init(num_columns, num_compositions, &context);
-        fn = prem_mod_derv_em;
+        prem_mod_derv_em_init(num_columns, num_compositions, context);
+        *fn = prem_mod_derv_em;
         return;
     case 2:
         /* using velocity derivatives */
-        prem_vel_derv_em_init(num_columns, num_compositions, &context);
-        fn = prem_vel_derv_em;
+        prem_vel_derv_em_init(num_columns, num_compositions, context);
+        *fn = prem_vel_derv_em;
         return;
     case 100:
         /* user defined */
-        fn = user_defined_em;
+        *fn = user_defined_em;
         return;
     default:
         fprintf(stderr, "Error: unknown type of elastic model\n");

Modified: cs/avm/trunk/elastic-models.h
===================================================================
--- cs/avm/trunk/elastic-models.h	2008-02-14 02:06:51 UTC (rev 9329)
+++ cs/avm/trunk/elastic-models.h	2008-02-14 02:07:31 UTC (rev 9330)
@@ -31,4 +31,4 @@
 
 void select_elastic_model(int model_type,
                           int num_columns, int num_compositions,
-                          elastic_model_fn fn, void *context);
+                          elastic_model_fn *fn, void **context);

Modified: cs/avm/trunk/prem-derived-models.c
===================================================================
--- cs/avm/trunk/prem-derived-models.c	2008-02-14 02:06:51 UTC (rev 9329)
+++ cs/avm/trunk/prem-derived-models.c	2008-02-14 02:07:31 UTC (rev 9330)
@@ -103,7 +103,7 @@
                            void **context)
 {
     /* see the comment of fields format in the next function */
-    const int num_required_fields = num_compositions + 5;
+    const int num_required_fields = num_compositions + 4;
 
     int i, j, k;
     int total_columns, num_layers;
@@ -266,7 +266,7 @@
                            void **context)
 {
     /* see the comment of fields format in the next function */
-    const int num_required_fields = num_compositions + 5;
+    const int num_required_fields = num_compositions + 4;
 
     int i, j, k;
     int total_columns, num_layers;
@@ -276,8 +276,8 @@
     FILE *in;
     prem_velocity_derv_t *p;
 
-    /* if *p is NULL, we need to set up the context */
-    if (!(*context)) return;
+    /* if *context is NULL, we need to set up the context */
+    if (*context != NULL) return;
     *context = p = malloc(sizeof(prem_velocity_derv_t));
     p->num_compositions = num_compositions;
 



More information about the cig-commits mailing list