|
PISM, A Parallel Ice Sheet Model
stable v0.5
|
00001 /* 00002 Copyright (C) 2004-2006 Jed Brown and 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 DIALOG: 00022 user@home:~/pism$ obj/simpleFG 00023 Enter t and r separated by space (or newline) 00024 (in yrs and km, resp.; e.g. 500 500): 00025 500 500 00026 Enter z values sep by space (in m); '-1' to end; e.g. 0 100 500 1500 -1: 00027 0 100 500 1500 -1 00028 00029 Results: 00030 Test F Test G 00031 (functions of r (resp. t and r) only): 00032 H = 1925.295290 (m) H = 2101.899734 (m) 00033 M = -0.010510 (m/a) M = 0.040738 (m/a) 00034 (z= 0.000): 00035 T = 265.122620 (K) T = 267.835036 (K) 00036 U = 0.000000 (m/a) U = 0.000000 (m/a) 00037 w = 0.000000 (m/a) w = 0.000000 (m/a) 00038 Sig = 0.264346 (*) Sig = 1.215392 (*) 00039 Sigc = -0.373726 (*) Sigc = -1.323664 (*) 00040 (z= 100.000): 00041 T = 263.137595 (K) T = 265.849860 (K) 00042 U = 0.661716 (m/a) U = 2.244496 (m/a) 00043 w = 0.000005 (m/a) w = -0.000758 (m/a) 00044 Sig = 0.173915 (*) Sig = 0.817817 (*) 00045 Sigc = -0.306255 (*) Sigc = -1.022931 (*) 00046 (z= 500.000): 00047 T = 255.486095 (K) T = 258.194962 (K) 00048 U = 1.785938 (m/a) U = 6.217140 (m/a) 00049 w = 0.000291 (m/a) w = -0.011984 (m/a) 00050 Sig = 0.028439 (*) Sig = 0.149934 (*) 00051 Sigc = -0.199905 (*) Sigc = -0.340039 (*) 00052 (z= 1500.000): 00053 T = 238.172200 (K) T = 240.856843 (K) 00054 U = 2.036372 (m/a) U = 7.227603 (m/a) 00055 w = 0.002288 (m/a) w = -0.050018 (m/a) 00056 Sig = 0.000029 (*) Sig = 0.000400 (*) 00057 Sigc = -0.193301 (*) Sigc = 0.365908 (*) 00058 (units: (*) = 10^-3 K/a) 00059 */ 00060 00061 #include <stdio.h> 00062 #include <stdlib.h> 00063 #include "exactTestsFG.h" 00064 00065 int main() { 00066 00067 const double SperA=31556926.0; /* seconds per year; 365.2422 days */ 00068 const double Cp=200.0; /* m; magnitude of the perturbation in test G */ 00069 double year, r, HF, MF, HG, MG; 00070 double *z, *TF, *UF, *wF, *SigF, *SigcF, *TG, *UG, *wG, *SigG, *SigcG; 00071 int j, Mz, scanret; 00072 00073 printf("Enter t and r separated by space (or newline)\n"); 00074 printf(" (in yrs and km, resp.; e.g. 500 500):\n"); 00075 scanret = scanf("%lf",&year); 00076 if (scanret != 1) { printf("... input error; exiting\n"); return 1; } 00077 scanret = scanf("%lf",&r); 00078 if (scanret != 1) { printf("... input error; exiting\n"); return 1; } 00079 printf("Enter z values sep by space (in m);"); 00080 printf(" '-1' to end; e.g. 0 100 500 1500 -1:\n"); 00081 00082 z = (double *) malloc(501 * sizeof(double)); 00083 if (z == NULL) { 00084 fprintf(stderr, "\nERROR simpleFG: couldn't allocate memory for z!\n\n"); 00085 return -9999; 00086 } 00087 00088 j=0; 00089 do { 00090 scanret = scanf("%lf",&z[j]); 00091 if (scanret != 1) { printf("... input error; exiting\n"); return 1; } 00092 j++; 00093 if (j>490) printf("\n\n\nWARNING simpleFG: enter -1 to stop soon!!!\n"); 00094 } while (z[j-1]>=0.0); 00095 Mz=j-1; 00096 00097 TF = (double *) malloc((size_t)Mz * sizeof(double)); 00098 UF = (double *) malloc((size_t)Mz * sizeof(double)); 00099 wF = (double *) malloc((size_t)Mz * sizeof(double)); 00100 SigF = (double *) malloc((size_t)Mz * sizeof(double)); 00101 SigcF = (double *) malloc((size_t)Mz * sizeof(double)); 00102 TG = (double *) malloc((size_t)Mz * sizeof(double)); 00103 UG = (double *) malloc((size_t)Mz * sizeof(double)); 00104 wG = (double *) malloc((size_t)Mz * sizeof(double)); 00105 SigG = (double *) malloc((size_t)Mz * sizeof(double)); 00106 SigcG = (double *) malloc((size_t)Mz * sizeof(double)); 00107 if ((TF == NULL) || (UF == NULL) || (wF == NULL) || (SigF == NULL) 00108 || (SigcF == NULL) || (TG == NULL) || (UG == NULL) || (wG == NULL) 00109 || (SigG == NULL) || (SigcG == NULL)) { 00110 fprintf(stderr, "\nERROR simpleFG: couldn't allocate memory!\n\n"); 00111 return -9999; 00112 } 00113 00114 /* evaluate tests F and G */ 00115 bothexact(0.0,r*1000.0,z,Mz,0.0,&HF,&MF,TF,UF,wF,SigF,SigcF); 00116 bothexact(year*SperA,r*1000.0,z,Mz,Cp,&HG,&MG,TG,UG,wG,SigG,SigcG); 00117 00118 printf("\nResults:\n Test F Test G\n"); 00119 printf("(functions of r (resp. t and r) only):\n"); 00120 printf(" H = %12.6f (m) H = %12.6f (m)\n",HF,HG); 00121 printf(" M = %12.6f (m/a) M = %12.6f (m/a)\n", 00122 MF*SperA,MG*SperA); 00123 for (j=0; j<Mz; j++) { 00124 printf("(z=%10.3f):\n",z[j]); 00125 printf(" T = %12.6f (K) T = %12.6f (K)\n",TF[j],TG[j]); 00126 printf(" U = %12.6f (m/a) U = %12.6f (m/a)\n",UF[j]*SperA, 00127 UG[j]*SperA); 00128 printf(" w = %12.6f (m/a) w = %12.6f (m/a)\n",wF[j]*SperA, 00129 wG[j]*SperA); 00130 printf(" Sig = %12.6f (*) Sig = %12.6f (*)\n", 00131 SigF[j]*SperA*1000.0,SigG[j]*SperA*1000.0); 00132 printf(" Sigc = %12.6f (*) Sigc = %12.6f (*)\n", 00133 SigcF[j]*SperA*1000.0,SigcG[j]*SperA*1000.0); 00134 } 00135 printf("(units: (*) = 10^-3 K/a)\n"); 00136 00137 free(z); 00138 free(TF); free(UF); free(wF); free(SigF); free(SigcF); 00139 free(TG); free(UG); free(wG); free(SigG); free(SigcG); 00140 return 0; 00141 }
1.7.5.1