⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_callable_contour_cbind.c

📁 this file is contain important facts aboute different programming langueges.
💻 C
字号:
/*
      Copyright (c) 1999,2000, Compaq Computer Corporation

      See the file "license.terms" for information on usage and redistribution
      of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/

/*
 *
 *  Test program for callable PM contour plots from C under VMS
 *  using Postmini C language binding.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "callable_postmini_cbind.h"

int main(int argc, char *argv[])
{

      float *data2d;    /* (pointer to) 2D data to be plotted */
      float x[100];     /* X coordinates */
      float y[100];     /* Y coordinates */
      int nx, ny;       /* Number of points in X and Y */
 
      int ierr;         /* Return status */
      int ilu;          /* FORTRAN logical unit for I/O (normally 6) */
      int linter;       /* Interactive (PM_TRUE) or noninteractive (PM_FALSE) */
      int linear;       /* PM_TRUE if quantity varies on linear scale,
                           or PM_FALSE if quantity varies on log scale */
      char *title;      /* Title of plot */
      char *quantity;   /* Name of quantity */
      char *units;      /* Units of quantity */
      char *pmifile;    /* Pointer to name of PMI file written after call
                           to PmContour */
      char pfile[81];   /* Local storage for PMI filename */

      float rfloat[1];  /* Dummy arrays for PmSetDefault */
      int   iint[1];
      int   llog[1]; 
      int i, j;

      /* Create data set */ 
      nx = 10;
      ny = 20;
      for(i=0; i<nx; i++) {
         x[i] = ((float) i)/10.0;
      }
      for(j=0; j<ny; j++) {
         y[j] = ((float) j)/10.0;
      }
      data2d = malloc(nx*ny*sizeof(float));
      if( data2d == NULL ) {
         perror("malloc");
         exit(EXIT_FAILURE);
      }
      /* Create data in slices along "x" direction.
         This essentially creates the array in FORTRAN 2D array order */
      for(j=0; j<ny; j++) {
         for(i=0; i<nx; i++) {
            data2d[i+j*nx] = (float)(i)*(float)(j);
         }
      }

      title = "Test of callable contour interface";
      quantity = "ImaginaryData";
      units = "cm^{-3}";
      /* Quantity varies linearly */
      linear = PM_TRUE;
      /* FORTRAN logical unit for user interaction */
      ilu    = 6;
      /* Interactive or non-interactive */
      linter = PM_TRUE;
      /* Title */
      title = "Test of callable contour interface";
      /* Function returns name of PMI file created with settings that
         user made */
      /* NOTE: the C binding has a different calling interface than
         the FORTRAN version. It is assumed that the data array is
         *exactly* the size specified by nx*ny. */
      pmifile = PmContour(data2d, x, y, nx, ny,
                          title, quantity, units,
                          linear, ilu, linter, "");

      /* Copy pmifile to local storage */
      strncpy(pfile,pmifile,80);

      /* Use previous PMI file to control plot, returned by last call */
      printf("Calling PM under PMI file control\n");

      pmifile = PmContour(data2d, x, y, nx, ny,
                          title, quantity, units,
                          linear, ilu, linter, pfile);

      /* Now plot to file */
      printf("Making hardcopy\n");
      /* Plot non-interactively */
      linter = PM_FALSE;
     /* Hardcopy filename is "quantity" with extension depending on
         hardcopy device. Yeah, yeah, this is stupid. I can change
         it if you want...  */
      /* Code "1" means "set hardcopy device type" */
      i = 1;
      ierr = PmSetDefault(i,rfloat,iint,llog,"color_postscript");

      pmifile = PmContour(data2d, x, y, nx, ny,
                          title, quantity, units,
                          linear, ilu, linter, "");

      /* Close graphics cleanly */
      PmClose();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -