Beispiel #1
0
int
main( int argc, const char *argv[] )
{
    int   i, j, k;
    int   npts = 0;
    PLFLT xextreme[10][2];
    PLFLT yextreme[10][2];
    PLFLT x0[10];
    PLFLT y0[10];

// Parse and process command line arguments

    (void) plparseopts( &argc, argv, PL_PARSE_FULL );

// Initialize plplot

    plssub( 3, 3 );
    plinit();

    xextreme[0][0] = -120.0; xextreme[0][1] = 120.0; yextreme[0][0] = -120.0; yextreme[0][1] = 120.0;
    xextreme[1][0] = -120.0; xextreme[1][1] = 120.0; yextreme[1][0] = 20.0; yextreme[1][1] = 120.0;
    xextreme[2][0] = -120.0; xextreme[2][1] = 120.0; yextreme[2][0] = -20.0; yextreme[2][1] = 120.0;
    xextreme[3][0] = -80.0; xextreme[3][1] = 80.0; yextreme[3][0] = -20.0; yextreme[3][1] = 120.0;
    xextreme[4][0] = -220.0; xextreme[4][1] = -120.0; yextreme[4][0] = -120.0; yextreme[4][1] = 120.0;
    xextreme[5][0] = -20.0; xextreme[5][1] = 20.0; yextreme[5][0] = -120.0; yextreme[5][1] = 120.0;
    xextreme[6][0] = -20.0; xextreme[6][1] = 20.0; yextreme[6][0] = -20.0; yextreme[6][1] = 20.0;
    xextreme[7][0] = -80.0; xextreme[7][1] = 80.0; yextreme[7][0] = -80.0; yextreme[7][1] = 80.0;
    xextreme[8][0] = 20.0; xextreme[8][1] = 120.0; yextreme[8][0] = -120.0; yextreme[8][1] = 120.0;

    for ( k = 0; k < 2; k++ )
    {
        for ( j = 0; j < 4; j++ )
        {
            if ( j == 0 )
            {
// Polygon 1: a diamond
                x0[0] = 0; y0[0] = -100;
                x0[1] = -100; y0[1] = 0;
                x0[2] = 0; y0[2] = 100;
                x0[3] = 100; y0[3] = 0;
                npts  = 4;
            }
            if ( j == 1 )
            {
// Polygon 1: a diamond - reverse direction
                x0[3] = 0; y0[3] = -100;
                x0[2] = -100; y0[2] = 0;
                x0[1] = 0; y0[1] = 100;
                x0[0] = 100; y0[0] = 0;
                npts  = 4;
            }
            if ( j == 2 )
            {
// Polygon 2: a square with punctures
                x0[0] = -100; y0[0] = -100;
                x0[1] = -100; y0[1] = -80;
                x0[2] = 80; y0[2] = 0;
                x0[3] = -100; y0[3] = 80;
                x0[4] = -100; y0[4] = 100;
                x0[5] = -80; y0[5] = 100;
                x0[6] = 0; y0[6] = 80;
                x0[7] = 80; y0[7] = 100;
                x0[8] = 100; y0[8] = 100;
                x0[9] = 100; y0[9] = -100;
                npts  = 10;
            }
            if ( j == 3 )
            {
// Polygon 2: a square with punctures - reversed direction
                x0[9] = -100; y0[9] = -100;
                x0[8] = -100; y0[8] = -80;
                x0[7] = 80; y0[7] = 0;
                x0[6] = -100; y0[6] = 80;
                x0[5] = -100; y0[5] = 100;
                x0[4] = -80; y0[4] = 100;
                x0[3] = 0; y0[3] = 80;
                x0[2] = 80; y0[2] = 100;
                x0[1] = 100; y0[1] = 100;
                x0[0] = 100; y0[0] = -100;
                npts  = 10;
            }

            for ( i = 0; i < 9; i++ )
            {
                pladv( 0 );
                plvsta();
                plwind( xextreme[i][0], xextreme[i][1], yextreme[i][0], yextreme[i][1] );

                plcol0( 2 );
                plbox( "bc", 1.0, 0, "bcnv", 10.0, 0 );
                plcol0( 1 );
                plpsty( 0 );
                if ( k == 0 )
                    plfill( npts, x0, y0 );
                else
                    plgradient( npts, x0, y0, 45. );
                plcol0( 2 );
                pllsty( 1 );
                plline( npts, x0, y0 );
            }
        }
    }

// Don't forget to call plend() to finish off!

    plend();
    exit( 0 );
}
Beispiel #2
0
int
main(int argc, char *argv[])
{
  PLFLT *x, *y, *z, *clev;
  PLFLT *xg, *yg, **zg, **szg;
  PLFLT zmin, zmax, lzm, lzM;
  long ct;
  int i, j, k;
  PLINT alg;
  char ylab[40], xlab[40];
  char *title[] = {"Cubic Spline Approximation",
		   "Delaunay Linear Interpolation",
		   "Natural Neighbors Interpolation",
		   "KNN Inv. Distance Weighted",
		   "3NN Linear Interpolation",
		   "4NN Around Inv. Dist. Weighted"};

  PLFLT opt[] = {0., 0., 0., 0., 0., 0.};

  xm = ym = -0.2;
  xM = yM = 0.8;

  plMergeOpts(options, "x21c options", NULL);
  plparseopts(&argc, argv, PL_PARSE_FULL);

  opt[2] = wmin;
  opt[3] = (PLFLT) knn_order;
  opt[4] = threshold;

  /* Initialize plplot */

  plinit();

  create_data(&x, &y, &z, pts); /* the sampled data */
  zmin = z[0];
  zmax = z[0];
  for (i=1; i<pts; i++) {
    if (z[i] > zmax)
      zmax = z[i];
    if (z[i] < zmin)
      zmin = z[i];
  }

  create_grid(&xg, xp, &yg, yp); /* grid the data at */
  plAlloc2dGrid(&zg, xp, yp); /* the output grided data */
  clev = (PLFLT *) malloc(nl * sizeof(PLFLT));

  sprintf(xlab, "Npts=%d gridx=%d gridy=%d", pts, xp, yp);
  plcol0(1);
  plenv(xm, xM, ym, yM, 2, 0);
  plcol0(15);
  pllab(xlab, "", "The original data");
  plcol0(2);
  plpoin(pts, x, y, 5);
  pladv(0);

  plssub(3,2);

  for (k=0; k<2; k++) {
    pladv(0);
    for (alg=1; alg<7; alg++) {

      ct = clock();
      plgriddata(x, y, z, pts, xg, xp, yg, yp, zg, alg, opt[alg-1]);
      sprintf(xlab, "time=%d ms", (clock() - ct)/1000);
      sprintf(ylab, "opt=%.3f", opt[alg-1]);

      /* - CSA can generate NaNs (only interpolates?!).
       * - DTLI and NNI can generate NaNs for points outside the convex hull
       *      of the data points.
       * - NNLI can generate NaNs if a sufficiently thick triangle is not found
       *
       * PLplot should be NaN/Inf aware, but changing it now is quite a job...
       * so, instead of not plotting the NaN regions, a weighted average over
       * the neighbors is done.
       */

      if (alg == GRID_CSA || alg == GRID_DTLI || alg == GRID_NNLI || alg == GRID_NNI) {
	int ii, jj;
	PLFLT dist, d;

	for (i=0; i<xp; i++) {
	  for (j=0; j<yp; j++) {
	    if (isnan(zg[i][j])) { /* average (IDW) over the 8 neighbors */

	      zg[i][j] = 0.; dist = 0.;

	      for (ii=i-1; ii<=i+1 && ii<xp; ii++) {
		for (jj=j-1; jj<=j+1 && jj<yp; jj++) {
		  if (ii >= 0 && jj >= 0 && !isnan(zg[ii][jj])) {
		    d = (abs(ii-i) + abs(jj-j)) == 1 ? 1. : 1.4142;
		    zg[i][j] += zg[ii][jj]/(d*d);
		    dist += d;
		  }
		}
	      }
	      if (dist != 0.)
		zg[i][j] /= dist;
	      else
		zg[i][j] = zmin;

	    }
	  }
	}
      }

      plMinMax2dGrid(zg, xp, yp, &lzM, &lzm);

      plcol0(1);
      pladv(alg);

      if (k == 0) {

	lzm = MIN(lzm, zmin);
	lzM = MAX(lzM, zmax);
	for (i=0; i<nl; i++)
	  clev[i] = lzm + (lzM-lzm)/(nl-1)*i;

	plenv0(xm, xM, ym, yM, 2, 0);
	plcol0(15);
	pllab(xlab, ylab, title[alg-1]);
	plshades(zg, xp, yp, NULL, xm, xM, ym, yM,
		 clev, nl, 1, 0, 1, plfill, 1, NULL, NULL);
	plcol0(2);
      } else {

	for (i=0; i<nl; i++)
	  clev[i] = lzm + (lzM-lzm)/(nl-1)*i;

	cmap1_init();
	plvpor(0.0, 1.0, 0.0, 0.9);
	plwind(-1.0, 1.0, -1.0, 1.5);
	/*
	 * For the comparition to be fair, all plots should have the
	 * same z values, but to get the max/min of the data generated
	 * by all algorithms would imply two passes. Keep it simple.
	 *
	 * plw3d(1., 1., 1., xm, xM, ym, yM, zmin, zmax, 30, -60);
	 */

	plw3d(1., 1., 1., xm, xM, ym, yM, lzm, lzM, 30, -60);
	plbox3("bnstu", ylab, 0.0, 0,
	       "bnstu", xlab, 0.0, 0,
	       "bcdmnstuv", "", 0.0, 4);
	plcol0(15);
	pllab("", "", title[alg-1]);
	plot3dc(xg, yg, zg, xp, yp, DRAW_LINEXY | MAG_COLOR | BASE_CONT, clev, nl);
      }
    }
  }

  plend();

  free_data(x, y, z);
  free_grid(xg, yg);
  free((void *)clev);
  plFree2dGrid(zg, xp, yp);
}
Beispiel #3
0
int main() {                                                    
  
  // http://cdiac.ornl.gov/pns/current_ghg.html
  const double c_co2 = 390;
  const double c_n2o = 0.32;
  const double c_co = 0.1;
  const double c_ch4 = 1.775;
  const double c_o2 = 20.9e+4;
  
  
  const double cp=1004;  /* J/kg K */
  const double deltat=3600.0*4.0;  /* s */
  const double Ra=287; /* J/kg K */

  int timesteps = 0;
  int ilev=0;
  int ilyr=0;
  const int nlyr=20;  /* Number of Layers */
  const int nlev=nlyr+1;
  int instabil=FALSE;

  int status;
  
  
  

  const double deltap=PSURF/nlyr;
  const double kappa=Ra/cp;
  
  double *p=calloc(nlev,sizeof(double));
  double *T=calloc(nlyr,sizeof(double));
  double *theta=calloc(nlev,sizeof(double));
  double *plyr=calloc(nlyr,sizeof(double));
  double *z=calloc(nlev,sizeof(double));
  double *zlyr=calloc(nlyr,sizeof(double));
  double *deltazlyr=calloc(nlyr,sizeof(double));
  double *deltazlev=calloc(nlev,sizeof(double));
  double *h2o=calloc(nlyr,sizeof(double));
  double *o3=calloc(nlyr,sizeof(double));
  
  double ***dtaumol;
  double **wgt;
  double *wavelength;
  int nbnd=0;
  int *nch;
  int iv;
  int iq;
  
  double *tmplev=calloc(nlev, sizeof(double)); /* temporary vector with length lev */
  double *tmplyr=calloc(nlyr, sizeof(double)); /* temporary vector with length lyr */
  
  double *eup=calloc(nlev, sizeof(double));
  double *edn=calloc(nlev, sizeof(double));
  double *euptmp=calloc(nlev, sizeof(double));
  double *edntmp=calloc(nlev, sizeof(double));
  double *edirtmp=calloc(nlev, sizeof(double));
  double *enet=calloc(nlyr, sizeof(double));

  double *deltaTday=calloc(nlyr, sizeof(double));
  double *deltaT=calloc(nlyr, sizeof(double));
  
  //------------- Define variables for Rodents---------------//
  
  const double gr_albedo=0.3; /* 1 */
  
  const int mu_counterlimit = (int)(24.0 * 3600 / deltat);
  double* const mu_0 = calloc(mu_counterlimit, sizeof(double));
  int mu_counter;

  // --- start mu_0
  {
  double mu_weight = 0;

  for(mu_counter=0; mu_counter < mu_counterlimit; mu_counter++) {
    mu_0[mu_counter] = cos( 2.0*M_PI / mu_counterlimit * (mu_counter + mu_counter+1) / 2.0 );
    if(mu_0[mu_counter] > 0)
      mu_weight += mu_0[mu_counter];
  }
  // weight needs to be adjusted such that it is 0.5 for half of the steps (day-only)
  mu_weight = mu_weight / (mu_counterlimit/2.0 * 0.5);

  for(mu_counter=0; mu_counter < mu_counterlimit; mu_counter++) {
    mu_0[mu_counter] = mu_0[mu_counter] / mu_weight;
    printf("mu_0[%d] = %e\n", mu_counter, mu_0[mu_counter]);
  }
  mu_counter = 0;
  
  }
  // --- end mu_0
  
  double* S_0;
  double* omega_0=calloc(nlyr,sizeof(double));
  double* gassy=calloc(nlyr,sizeof(double));
  double* f=calloc(nlyr,sizeof(double));
  
  
  for(ilyr=0; ilyr<nlyr; ilyr++) {
   omega_0[ilyr] = 0.f;
   gassy[ilyr] = 0; //0.85f;
   f[ilyr] = 0; //0.8f;
  }
  
  {
    double *temp1, *temp2, *temp3;
    int temp4;
      status=read_4c_file("mstrnx.data/solar.dat", &temp1, &temp2, &temp3, &S_0, &temp4);
      if (status !=0) {
      printf("Error reading Solar.dat\n");
      return EXIT_FAILURE;
      }
      
      free(temp1);
      free(temp2);
      free(temp3);
  } 
  
  //--------------------- Plot color -------------------------//

#ifndef _NOPLOT
  plscolbg (255, 255, 255);   /* background color white */
  plscol0  (15, 0, 0, 0);     /* set color 15 to black  */
  plsdev ("xwin"); /* if not called, the user is asked! */
  plinit ();
  
  plssub(2,2);
#endif
  
  //--------------------- Calculate pressure for layers and levels -------------//

  for(ilev=0; ilev<nlev; ilev++) {                              /* Calculation of the Pressure at the Levels p[ilev] */
    p[ilev]=PSURF*ilev/(nlev-1);
  }
    
  for(ilyr=0; ilyr<nlyr; ilyr++) {                            /* Calculation of the Pressure in the Layers*/
    plyr[ilyr]= 0.5*(p[ilyr]+p[ilyr+1]);
  }
   
  
  //----------------------- Reading afglus ------------------------//
  
  {
    
    double *ztemp;
    double *ptemp;
    double *Ttemp;
    double *h2otemp;
    double *o3temp;

    int status;
    int ntemp;
    int itemp;
    unsigned int mintemp = 0;
    unsigned int mintemp2 = 0;
    
    status = read_5c_file("mstrnx.data/afglus.atm", &ztemp, &ptemp, &Ttemp, &h2otemp, &o3temp, &ntemp);
    if (status !=0) {
      printf("Error reading Temperature profile\n");
      return EXIT_FAILURE;
    }

    /*
      for (itemp=0; itemp<ntemp; itemp++) {
      printf("itemp = %d, ztemp = %f, ptemp = %f, Ttemp = %f, h2otemp = %f, o3temp = %f\n", itemp, ztemp[itemp], ptemp[itemp], Ttemp[itemp], h2otemp[itemp], o3temp[itemp]);
      }
    */  
    
    //-------------------- Interpolate T, h2o and o3 to layers --------------//
    
    for (ilyr=0; ilyr<nlyr; ilyr++) {
      // printf("ilev = %d, searching for %f\n", ilyr, plyr[ilyr]);
      for (itemp=0; itemp<ntemp; itemp++) {
	if ( abs(ptemp[mintemp]- plyr[ilyr])>abs(ptemp[itemp]-plyr[ilyr])) {
	  mintemp=itemp;
	}
      }
      if (ptemp[mintemp]<plyr[ilyr]) {
	mintemp2 = mintemp+1;
      }
      else {
	mintemp2 = mintemp-1;
      }
      // printf("\tmintemp  = %d,\tp = %f\n", mintemp, ptemp[mintemp]);
      // printf("\tmintemp2 = %d,\tp = %f\n", mintemp2, ptemp[mintemp2]);

      const double weight2 = abs(ptemp[mintemp]-plyr[ilyr]);
      const double weight1 = abs(ptemp[mintemp2]-plyr[ilyr]);
      const double norm = weight1 + weight2;
      
      /* T in levels?!?! */
      T[ilyr] = Ttemp[mintemp]*weight1 + Ttemp[mintemp2]*weight2;
      T[ilyr] /= norm;
      
      h2o[ilyr] = h2otemp[mintemp]*weight1 + h2otemp[mintemp2]*weight2;
      h2o[ilyr] /= norm;

      o3[ilyr] = o3temp[mintemp]*weight1 + o3temp[mintemp2]*weight2;
      o3[ilyr] /= norm;
    }
  }
  
  
  for (ilyr=0; ilyr<nlyr; ilyr++)  {
    printf("ilyr = %d, plyr = %f,\tT = %f,\th2o = %f,\to3 = %f\n", ilyr, plyr[ilyr], T[ilyr], h2o[ilyr], o3[ilyr]);
  }
  
  /* 
     for (ilyr=0; ilyr<nlyr; ilyr++)  {
     printf("T[%d] = %f\n", ilyr, T[ilyr]);
     }
     for (ilyr=0; ilyr<nlyr; ilyr++)  {
     printf("o3[%d] = %f\n", ilyr, o3[ilyr]);
     }
     for (ilyr=0; ilyr<nlyr; ilyr++)  {
     printf("h2o[%d] = %f\n", ilyr, h2o[ilyr]);
     }
  */
  
   
  
  
  //--------------------------------- Starting while-loop ----------------------------------//
  //----------------------------------------------------------------------------------------//
  
  while (timesteps*deltat<TIME_MAX) {
    // printf("\nNew time %d: T = %f\n", (int)(timesteps*deltat), T[nlyr-1]);
    timesteps++;
  
    for(ilev=0; ilev<nlev; ilev++) {                    /* Reseting edn, eup and enet */
      edn[ilev] = 0;
      eup[ilev] = 0;
      if(ilev < nlyr) //enet is defined for ilyr only
        enet[ilev]=0;
    }
    
    
    //--------------------- Calculate z ----------------------//
    
    for (ilyr=0;ilyr<nlyr; ilyr++) {                         /* z for layers */
      deltazlyr[ilyr]=(Ra*T[ilyr]*deltap)/(plyr[ilyr]*g);  
    }
      
    zlyr[nlyr-1]=0; //check this one time
    for (ilyr=nlyr-2; ilyr >= 0; ilyr--) {
      zlyr[ilyr]=zlyr[ilyr+1]+deltazlyr[ilyr];
    }
      
     
    for (ilev=0;ilev<nlev-1; ilev++) {                      /* z for levels */
      deltazlev[ilev]=(Ra*T[ilev]*deltap)/(plyr[ilev]*g);  
    }
      
    z[nlev-1]=0;
    for (ilev=nlev-2; ilev >= 0; ilev--) {
      z[ilev]=z[ilev+1]+deltazlev[ilev];
     
    }
      
      
      
    //--------------------- Use k-distribution ---------------------//
      
    /* mu_0 is defined for a 8-part cycle of the earth, i.e. a timestep of 3 hours! */
    if(++mu_counter == mu_counterlimit)
      mu_counter = 0;

    //calculate it every two days!
    if((timesteps-1) % 10 == 0)
      //warning, wavelength is in nm!
      status = ck_mstrnx (z, plyr, T, h2o, o3, nlev, /*lyrflag*/ 1, c_co2, c_n2o, c_co, c_ch4, c_o2, &dtaumol, &wgt, &wavelength, &nbnd, &nch);
    
    for(iv=0; iv<nbnd; iv++) {
      //printf("iv = %d, wavelength = %e, S0 = %e\n", iv, wavelength[iv], S_0[iv]);
	  
      
      //------------- Use schwarzschild and sum edn eup --------//
	
      
      for(iq=0; iq<nch[iv]; iq++) {
	schwarzschild2(dtaumol[iv][iq], T, nlev, T[nlyr-1], edntmp, euptmp, wavelength[iv]*1e-6,wavelength[iv+1]*1e-6, tmplev, tmplyr);	

	for(ilev=0; ilev<nlev; ilev++) {
	  edn[ilev] += edntmp[ilev]*wgt[iv][iq];
	  eup[ilev] += euptmp[ilev]*wgt[iv][iq];
	  //printf("ilev = %d, iv = %d of %d, iq = %d of %d, wgt = %e, edntmp = %e, euptmp = %e\n", ilev, iv, nbnd, iq, nch[iv], wgt[iv][iq], edntmp[ilev], euptmp[ilev]);
	}
	
	//------------------- Include Rodents---------------------//  
	if(mu_0[mu_counter] > 0) {
	  rodents_solar(nlyr, dtaumol[iv][iq], omega_0, gassy, f, S_0[iv], mu_0[mu_counter], gr_albedo, edntmp, euptmp, edirtmp);
	  
	  for(ilev=0; ilev<nlev; ilev++) {
	    edn[ilev] += (edntmp[ilev]+edirtmp[ilev])*wgt[iv][iq];
	    eup[ilev] += euptmp[ilev]*wgt[iv][iq];
	    //printf("ilev = %d, iv = %d of %d, iq = %d of %d, wgt = %e, edntmp = %e, euptmp = %e, edirtmp = %e\n", ilev, iv, nbnd, iq, nch[iv], wgt[iv][iq], edntmp[ilev], euptmp[ilev], edirtmp[ilev]);
	  }
	}
      }
    }
     
    //---------------- Calculate enet -----------------------// 
    
    for(ilyr=0; ilyr<nlyr-1; ilyr++) {
      enet[ilyr] = eup[ilyr+1] + edn[ilyr] - eup[ilyr] - edn[ilyr+1];
     
    }

    for (ilev=0; ilev<nlev; ilev++) {
      //printf("ilev = %d, eup = %f, edn = %f\n", ilev, eup[ilev], edn[ilev]);
    }

    //---------------- Calculate temperature gain per layer -----------//
    
    for (ilyr=0; ilyr<nlyr-1; ilyr++)  {
      deltaT[ilyr]=(enet[ilyr]*g*deltat)/((deltap*100.0)*cp);
      T[ilyr] +=deltaT[ilyr];
      //printf("dT[ilyr] = %f\n", ilyr, deltaT[ilyr]);
    }
  
    //----------------Calculate Temperature gain for ground layer ---------//
    
    deltaT[nlyr-1]=((edn[nlyr-1]-eup[nlyr-1])*g*deltat)/((deltap*100.0)*cp);
    T[nlyr-1] += deltaT[nlyr-1];


    //---------- Convert T to theta ------------//
    
    for (ilyr=0; ilyr<nlyr; ilyr++) {                           
      theta[ilyr]=pow(PSURF/plyr[ilyr], kappa)*T[ilyr];
      //printf("%d %f\n", ilyr, theta[ilyr]);
    }
    
    
    //------------ Convection -------------------//
    
    instabil = FALSE;
    
    for (ilyr=0; ilyr<nlyr;ilyr++) {                            /* Testing for Instability */
      if (theta[ilyr+1]>theta[ilyr]) {
	instabil = TRUE;
	break;
      }
    }

    if (instabil) {                                             /* Convection - Sorting of Layers according to theta */
      qsort (theta, nlyr, sizeof(double), sortfunc);
      //  printf ("Konvektion :-)\n");
    }
    
    for (ilyr=0; ilyr<nlyr; ilyr++) {                           /* Conversion from theta to T */
      T[ilyr] = theta[ilyr] /  (pow(PSURF/plyr[ilyr], kappa));

      //printf("%d %f\n", ilyr, theta[ilyr]);
    }

    
    //-------------------- Print every x timestep ------------//
    
    if(timesteps % (int)(10) == 0) {
      printf ("timestep %d\n", timesteps);

      /* Printing time in readable format
       * In order to remove days, hours or minutes
       * just add // in front of the appropriate line
       */
      int time = timesteps*deltat;
      printf("time ");
      printf("%dd = ", (int)(time / 3600 / 24));
      printf("%dh = ", (int)(time / 3600 ));
      printf("%dmin = ", (int)(time / 60 ));
      printf("%ds\n", time);

      printf(" Tsurf=%f\n", T[nlyr-1]);

      for (ilyr=0; ilyr<nlyr; ilyr++) {
	deltaTday[ilyr]=deltaT[ilyr]*86.4/2;
      }

      plotall(nlyr, T, plyr, zlyr, deltaTday);

      /* for (ilyr=0; ilyr<nlyr; ilyr++) { */
      /*   printf("ilyr %d, z=%f,  plyr=%f,theta=%f, T=%f\n", ilyr, z[ilyr], plyr[ilyr],theta[ilyr], T[ilyr]); */
      /* } */

      for (ilyr=0; ilyr<nlyr; ilyr++) {
      	printf("p%f, edn%f, eup%f, enet%f\n", p[ilyr], edn[ilyr], eup[ilyr], enet[ilyr]);
      }
      printf("p%f, edn%f, eup%f\n", p[ilyr], edn[ilyr], eup[ilyr]);
    }
   
  }                                     

  free(tmplyr);
  free(tmplev);
  //----------------- End of while-loop---------------------//
  
  printf("\nTime %d: T = %f\n", (int)(timesteps*deltat), T[nlyr-1]);
  for (ilyr=0; ilyr<nlyr; ilyr++) {
    printf("%d %f\n", ilyr, T[ilyr]);
  }

  printf("\nTsurf=%f\n", T[nlyr-1]);

  return 0;
}
Beispiel #4
0
int
main(int argc, char *argv[])
{
    int i, digmax;
    int xleng0 = 400, yleng0 = 300, xoff0 = 200, yoff0 = 200;
    int xleng1 = 400, yleng1 = 300, xoff1 = 500, yoff1 = 500;

/* Select either TK or DP driver and use a small window */
/* Using DP results in a crash at the end due to some odd cleanup problems */
/* The geometry strings MUST be in writable memory */

    char geometry_master[] = "500x410+100+200";
    char geometry_slave[]  = "500x410+650+200";

    char driver[80];

/* plplot initialization */
/* Parse and process command line arguments */

    (void) plparseopts(&argc, argv, PL_PARSE_FULL);

    plgdev(driver);

    printf("Demo of multiple output streams via the %s driver.\n", driver);
    printf("Running with the second stream as slave to the first.\n");
    printf("\n");

/* Set up first stream */

    plsetopt("geometry", geometry_master);

    plsdev(driver);
    plssub(2, 2);
    plinit();

/* Start next stream */

    plsstrm(1);

/* Turn off pause to make this a slave (must follow master) */

    plsetopt("geometry", geometry_slave);
    plspause(0);
    plsdev(driver);
    plinit();

/* Set up the data & plot */
/* Original case */

    plsstrm(0);

    xscale = 6.;
    yscale = 1.;
    xoff = 0.;
    yoff = 0.;
    plot1();

/* Set up the data & plot */

    xscale = 1.;
    yscale = 1.e+6;
    plot1();

/* Set up the data & plot */

    xscale = 1.;
    yscale = 1.e-6;
    digmax = 2;
    plsyax(digmax, 0);
    plot1();

/* Set up the data & plot */

    xscale = 1.;
    yscale = 0.0014;
    yoff = 0.0185;
    digmax = 5;
    plsyax(digmax, 0);
    plot1();

/* To slave */
/* The pleop() ensures the eop indicator gets lit. */

    plsstrm(1);
    plot4();
    pleop();

/* Back to master */

    plsstrm(0);
    plot2();
    plot3();

/* To slave */

    plsstrm(1);
    plot5();
    pleop();

/* Back to master to wait for user to advance */

    plsstrm(0);
    pleop();

/* Call plend to finish off. */

    plend();
    exit(0);
}