PISM, A Parallel Ice Sheet Model  stable v0.5
src/verif/tests/simpleL.c
Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2007 Ed Bueler
00003   
00004    This file is part of PISM.
00005   
00006    PISM is free software; you can redistribute it and/or modify it under the
00007    terms of the GNU General Public License as published by the Free Software
00008    Foundation; either version 2 of the License, or (at your option) any later
00009    version.
00010   
00011    PISM is distributed in the hope that it will be useful, but WITHOUT ANY
00012    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014    details.
00015   
00016    You should have received a copy of the GNU General Public License
00017    along with PISM; if not, write to the Free Software
00018    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 */
00020 
00021 /*  STANDARD DIALOGUE:
00022 
00023 $ ./simpleL
00024 Enter  r  (in km; e.g. 0.0):   0.0
00025 Results from Test L:
00026   H =  3782.88760 (m)   b = -500.00000 (m)   a =  0.30000 (m/a)
00027 
00028 */
00029 
00030 #include <stdio.h>
00031 #include "exactTestL.h"
00032 
00033 int main() {
00034 
00035   double       r, H, b, a;
00036   int          scanret;
00037   const double secpera=31556926.0;  /* seconds per year; 365.2422 days */
00038 
00039   double EPS_ABS[] = { 1.0e-12, 1.0e-9, 1.0e-7 };
00040   double EPS_REL[] = { 0.0, 1.0e-14, 1.0e-11 }; 
00041   
00042   printf("Enter  r  (in km; e.g. 0.0):   ");
00043   scanret = scanf("%lf",&r);
00044   if (scanret != 1) {
00045     printf("... input error; exiting\n"); 
00046     return 1;
00047   }
00048 
00049   exactL(r*1000.0,&H,&b,&a,EPS_ABS[0],EPS_REL[0],1);
00050 
00051   printf("Results from Test L:\n");
00052   printf("     H = %11.5f (m)   b = %10.5f (m)   a = %8.5f (m/a)\n",
00053          H,b,a*secpera);
00054 
00055 #define COMMENTARY 0
00056 #if COMMENTARY
00057   printf("(*COMMENTARY*\n Above were produced with RK Cash-Karp method and default (tight) tolerances\n");
00058   printf(" EPS_ABS = %e, EPS_REL = %e.\n",EPS_ABS[0],EPS_REL[0]);
00059   printf(" Here is a table of values of H using alternative methods and tolerances:\n");
00060   int method,i,j; 
00061   for (method=1; method<5; method++) {
00062     printf("   method = %d  (1=rkck,2=rk2,3=rk4,4=rk8pd):\n",method);  
00063     for (i=0; i<3; i++) {
00064       for (j=0; j<3; j++) {
00065         if ((method == 2) && (j == 0)) {
00066           printf("     EPS_ABS = %e, EPS_REL = %e:    <method hangs for this EPS_REL>\n",
00067                  EPS_ABS[i],EPS_REL[j]);
00068         } else {
00069           exactL(r*1000.0,&H,&b,&a,EPS_ABS[i],EPS_REL[j],method);
00070           printf("     EPS_ABS = %e, EPS_REL = %e:    H = %17.11f\n",EPS_ABS[i],EPS_REL[j],H);
00071         }
00072       }
00073     }
00074   }
00075   printf(" *END COMMENTARY*)\n");
00076 #endif
00077 
00078 
00079 #define GRAPHABLE 0
00080 #if GRAPHABLE
00081 /*
00082     produce profile and bed graphs from this data.
00083     e.g. saving output in file "rHba.sce", editing out above stuff, 
00084     running scilab, do "exec('rHba.sce')" in scilab   
00085 */
00086 #define N 751
00087   int k;
00088   double rr[N];
00089   double HH[N],bb[N],aa[N];
00090   for (k= 0; k<N; k++) {
00091     rr[k] = 750000.0 - 1000.0 * k;
00092   }
00093   exactL_list(rr,N,HH,bb,aa);
00094   printf("\n  rHba = [\n");
00095   for (k = 0; k<N; k++) {
00096     printf("%10.3f  %11.5f  %10.5f  %8.5f\n",
00097            rr[k]/1000.0,HH[k],bb[k],aa[k]*secpera);
00098   }
00099   printf("];\n\n plot(rHba(:,1),rHba(:,2)+rHba(:,3),rHba(:,1),rHba(:,3))\n");
00100 #endif
00101 
00102   return 0;
00103 }
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines