Ejemplo n.º 1
0
NhlErrorTypes tddtri_W( void )
{
  int *nwid, *ntri, *itwk, imtri;
  ng_size_t mtri, dsizes_rtri[2];
  float *rtri;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid =   (int*)NclGetArgValue(0,4,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  rtri = (float*)NclGetArgValue(1,4,NULL,dsizes_rtri,NULL,NULL,NULL,DONT_CARE);
  ntri =   (int*)NclGetArgValue(2,4,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  itwk =   (int*)NclGetArgValue(3,4,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

  mtri = dsizes_rtri[0];
  if(dsizes_rtri[1] != 10) {
    NhlPError(NhlFATAL, NhlEUNKNOWN, "tddtri: the rightmost dimension of rtri must be 10");
    return(NhlFATAL);
  }
/*
 * Test dimension sizes. 
 */
  if(mtri > INT_MAX) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tddtri: the leftmost dimension of rtri is greater than INT_MAX");
    return(NhlFATAL);
  }
  imtri = (int) mtri;

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tddtri function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tddtri(rtri, imtri, ntri, itwk);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 2
0
NhlErrorTypes tdlbls_W( void )
{
  int *nwid, *ipck;
  float *uvwmn, *uvwmx;
  NrmQuark *uvwn, *uvwi;
  char *cuvwn0, *cuvwi0, *cuvwn1, *cuvwi1, *cuvwn2, *cuvwi2;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid  =    (int*)NclGetArgValue(0,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwmn =  (float*)NclGetArgValue(1,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwmx =  (float*)NclGetArgValue(2,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwn  = (NrmQuark*)NclGetArgValue(3,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwi  = (NrmQuark*)NclGetArgValue(4,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ipck  =    (int*)NclGetArgValue(5,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

  cuvwn0 = NrmQuarkToString(uvwn[0]);
  cuvwi0 = NrmQuarkToString(uvwi[0]);
  cuvwn1 = NrmQuarkToString(uvwn[1]);
  cuvwi1 = NrmQuarkToString(uvwi[1]);
  cuvwn2 = NrmQuarkToString(uvwn[2]);
  cuvwi2 = NrmQuarkToString(uvwi[2]);
/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdlbls function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tdlbls(uvwmn[0], uvwmn[1], uvwmn[2], uvwmx[0], uvwmx[1], uvwmx[2],
           cuvwn0, cuvwn1, cuvwn2, cuvwi0, cuvwi1, cuvwi2, *ipck);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 3
0
NhlErrorTypes tdlbla_W( void )
{
  int *nwid, *iaxs;
  float *xat, *yat, *angd;
  NrmQuark *ilbl, *nlbl;
  char *cilbl, *cnlbl;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid =    (int*)NclGetArgValue(0,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  iaxs =    (int*)NclGetArgValue(1,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ilbl = (NrmQuark*)NclGetArgValue(2,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  nlbl = (NrmQuark*)NclGetArgValue(3,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  xat  =  (float*)NclGetArgValue(4,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  yat  =  (float*)NclGetArgValue(5,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  angd =  (float*)NclGetArgValue(6,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

  cilbl = NrmQuarkToString(*ilbl);
  cnlbl = NrmQuarkToString(*nlbl);

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdlbla function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tdlbla(*iaxs, cilbl, cnlbl, xat[0], xat[1], yat[0], yat[1], *angd);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 4
0
NhlErrorTypes tdplch_W( void )
{
  int *nwid;
  float *xpos, *ypos, *size, *angd, *cntr;
  NrmQuark *chrs;
  char *cchrs;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid =      (int*)NclGetArgValue(0,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  xpos =    (float*)NclGetArgValue(1,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ypos =    (float*)NclGetArgValue(2,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  chrs = (NrmQuark*)NclGetArgValue(3,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  size =    (float*)NclGetArgValue(4,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  angd =    (float*)NclGetArgValue(5,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  cntr =    (float*)NclGetArgValue(6,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

  cchrs = NrmQuarkToString(*chrs);

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdplch function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tdplch(*xpos, *ypos, cchrs, *size, *angd, *cntr);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 5
0
NhlErrorTypes tdgrid_W( void )
{
  int *nwid, *noxs, *noys, *igrd;
  float *xbeg, *xstp, *ybeg, *ystp;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid =   (int*)NclGetArgValue(0,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  xbeg = (float*)NclGetArgValue(1,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  xstp = (float*)NclGetArgValue(2,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  noxs =   (int*)NclGetArgValue(3,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ybeg = (float*)NclGetArgValue(4,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ystp = (float*)NclGetArgValue(5,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  noys =   (int*)NclGetArgValue(6,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  igrd =   (int*)NclGetArgValue(7,8,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdgrid function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tdgrid(*xbeg, *xstp, *noxs, *ybeg, *ystp, *noys, *igrd);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 6
0
NhlErrorTypes tdclrs_W( void )
{
/*
 *  Definte a variable to store the HLU object identifier.
 */
  NclHLUObj tmp_hlu_obj;

  int *nwid, *ibow, *iofc, *iolc, *ilmt;
  float *shde, *shdr;
  int gkswid, grlist, nid;

/*
 * Retrieve parameters.
 *
 * Note any of the pointer parameters can be set to NULL, which
 * implies you don't care about its value. In this example
 * the type parameter is set to NULL because the function
 * is later registered to only accept floating point numbers.
 */
  nwid =    (int*)NclGetArgValue(0,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ibow =    (int*)NclGetArgValue(1,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  shde =  (float*)NclGetArgValue(2,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  shdr =  (float*)NclGetArgValue(3,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  iofc =    (int*)NclGetArgValue(4,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  iolc =    (int*)NclGetArgValue(5,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ilmt =    (int*)NclGetArgValue(6,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid = tmp_hlu_obj->hlu.hlu_id;
/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist,NhlNwkGksWorkId,&gkswid);
  NhlGetValues(nid,grlist);

  gactivate_ws (gkswid);
  c_tdclrs(gkswid, *ibow, *shde, *shdr, *iofc, *iolc, *ilmt);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 7
0
NhlErrorTypes tdgrds_W( void )
{
  int *nwid, *igrt, *ihid;
  float *uvwmin, *uvwmax, *uvwstp;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

/*
 * Retrieve parameters.
 */
  nwid   =   (int*)NclGetArgValue(0,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwmin = (float*)NclGetArgValue(1,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwmax = (float*)NclGetArgValue(2,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  uvwstp = (float*)NclGetArgValue(3,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  igrt   =   (int*)NclGetArgValue(4,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ihid   =   (int*)NclGetArgValue(5,6,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdgrds function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  c_tdgrds(uvwmin[0], uvwmin[1], uvwmin[2], uvwmax[0], uvwmax[1], uvwmax[2],
           uvwstp[0], uvwstp[1], uvwstp[2], *igrt, *ihid);
  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 8
0
Archivo: vc03c.c Proyecto: gavin971/ncl
int main(int argc, char *argv[])
{
    char const *wks_type = "x11";
    int appid,wid,vcid,vfid;
    int rlist,grlist;
    ng_size_t len_dims[3];
    float reflen, ref;
    float x[a][b][c];
    FILE * fd;
    int i,j,k;
/*
 * Generate vector data array
 */
    char  filename[256];   
    const char *dir = _NGGetNCARGEnv("data");
    sprintf( filename, "%s/asc/uvdata0.asc", dir );

    fd = fopen(filename,"r");
       
    for (k = 0; k < a; k++) {
        for (j = 0; j < b; j++) {
            for (i = 0; i < c; i++) {       
                fscanf(fd,"%f", &x[k][j][i]);
            }
        }
    }

/*
 * Initialize the high level utility library
 */
    NhlInitialize();
/*
 * Create an application context. Set the app dir to the current
 * directory so the application looks for a resource file in the working
 * directory. 
 */
    rlist = NhlRLCreate(NhlSETRL);
    grlist = NhlRLCreate(NhlGETRL);
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNappUsrDir,"./");
    NhlCreate(&appid,"vc03",NhlappClass,NhlDEFAULT_APP,rlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
/*
 * Create a meta file workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./vc03c.ncgm");
        NhlCreate(&wid,"vc03Work",
                  NhlncgmWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 * Create an X workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlCreate(&wid,"vc03Work",NhlcairoWindowWorkstationClass,appid,rlist);
    }

    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
/*
 * Create an older-style PostScript workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"vc03c.ps");
        NhlCreate(&wid,"vc03Work",NhlpsWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
/*
 * Create an older-style PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"vc03c.pdf");
        NhlCreate(&wid,"vc03Work",NhlpdfWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
/*
 * Create a cairo PS/PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"vc03c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"vc03Work",NhlcairoDocumentWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 * Create a cairo PNG workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"vc03c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"vc03Work",NhlcairoImageWorkstationClass,appid,rlist);
    }
/*
 * Create a VectorField data object using the data set defined above.
 * By default the array bounds will define the data boundaries (zero-based,
 * as in C language conventions)
 */

    len_dims[0] = a;
    len_dims[1] = b;
    len_dims[2] = c;
    NhlRLClear(rlist);
    NhlRLSetMDFloatArray(rlist,NhlNvfDataArray,&x[0][0][0],3,len_dims);
    NhlRLSetFloat(rlist,NhlNvfXCStartV, -180.0);
    NhlRLSetFloat(rlist,NhlNvfXCEndV, 0.0);
    NhlRLSetFloat(rlist,NhlNvfYCStartV, 0.0);
    NhlRLSetFloat(rlist,NhlNvfYCEndV, 90.0);
    NhlRLSetFloat(rlist,NhlNvfYCStartSubsetV, 20.0);
    NhlRLSetFloat(rlist,NhlNvfYCEndSubsetV, 80.0);
   
    NhlCreate(&vfid,"vectorfield",NhlvectorFieldClass,appid,rlist);

/*
 * Create a VectorPlot object, supplying the VectorField object as data
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString, "Filled Arrow VectorPlot");
    NhlRLSetFloat(rlist,NhlNvcRefMagnitudeF, 20.0);
    NhlRLSetString(rlist,NhlNvcFillArrowsOn, "True");
    NhlRLSetFloat(rlist,NhlNvcMinFracLengthF, 0.2);

    NhlRLSetInteger(rlist,NhlNvcVectorFieldData,vfid);

    NhlCreate(&vcid,"vectorplot",NhlvectorPlotClass,wid,rlist);


    NhlRLClear(grlist);
    NhlRLGetFloat(grlist,NhlNvcRefLengthF,&reflen);
    NhlGetValues(vcid,grlist);

    ref= 1.5 * reflen;    
    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNvcRefLengthF,ref);
    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
           "Variation #1:: Constant Width");
    NhlRLSetFloat(rlist,NhlNvcFillArrowWidthF, 0.15);
    NhlRLSetFloat(rlist,NhlNvcFillArrowMinFracWidthF, 1.0);
    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);


    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
           "Variation #2");
    NhlRLSetFloat(rlist,NhlNvcFillArrowMinFracWidthF,0.25);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadMinFracXF,0.0);
    NhlRLSetFloat(rlist,NhlNvcFillArrowWidthF,0.2);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadXF,0.8);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadInteriorXF,0.7);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadYF,0.2);
    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);


    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Variation #3");
    ref = 1.2 * reflen;    
    NhlRLSetFloat(rlist,NhlNvcRefLengthF,ref);
    NhlRLSetFloat(rlist,NhlNvcFillArrowWidthF,0.3);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadXF,0.4);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadInteriorXF,0.35);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadYF,0.3);

    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Variation #4");
    ref = 1.2 * reflen;    
    NhlRLSetFloat(rlist,NhlNvcRefLengthF,ref);
    NhlRLSetFloat(rlist,NhlNvcFillArrowWidthF,0.2);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadXF,1.0);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadInteriorXF,1.0);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadYF,0.2);

    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Variation #5");
    ref = 0.8 * reflen;    
    NhlRLSetFloat(rlist,NhlNvcRefLengthF,ref);
    NhlRLSetFloat(rlist,NhlNvcFillArrowWidthF,0.2);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadXF,1.5);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadInteriorXF,1.0);
    NhlRLSetFloat(rlist,NhlNvcFillArrowHeadYF,0.5);

    NhlSetValues(vcid,rlist);

    NhlDraw(vcid);
    NhlFrame(wid);
/*
 * Destroy the objects created, close the HLU library and exit.
 */
    NhlDestroy(appid);
    NhlClose();
    exit(0);
}
Ejemplo n.º 9
0
Archivo: cn03c.c Proyecto: gavin971/ncl
int main()
{
    int appid,wid,cnid,dataid,llid;
    int rlist, grlist;
    ng_size_t len_dims[2];
    float xvp,yvp,heightvp,widthvp;
    char const *wks_type = "x11";
    /*
     * Initialize the high level utility library
     */

    NhlInitialize();
    /*
     * Create an application context. Set the app dir to the current directory
     * so the application looks for the resource file the directory it executes
     * from.
     */
    rlist = NhlRLCreate(NhlSETRL);
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNappUsrDir,"./");
    NhlCreate(&appid,"cn03",NhlappClass,NhlDEFAULT_APP,rlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
        /*
         * Create a meta file workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./cn03c.ncgm");
        NhlCreate(&wid,"cn03Work",
                  NhlncgmWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
        /*
         * Create an X workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlCreate(&wid,"cn03Work",
                  NhlcairoWindowWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
        /*
         * Create an older-style PostScript workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"./cn03c.ps");
        NhlCreate(&wid,"cn03Work",
                  NhlpsWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
        /*
         * Create an older-style PDF workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"./cn03c.pdf");
        NhlCreate(&wid,"cn03Work",
                  NhlpdfWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
        /*
         * Create a cairo PS/PDF workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./cn03c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"cn03Work",
                  NhlcairoDocumentWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
        /*
         * Create a cairo PNG workstation.
         */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./cn03c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"cn03Work",
                  NhlcairoImageWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    /*
     * Create a scalar field data object with a linear X dimension representing
     * latitude and an irregular Y dimension representing geopotential height.
     * Define the start and end points of the data, based on the dataset.
     */

    NhlRLClear(rlist);
    len_dims[0] = N, len_dims[1] = M;
    NhlRLSetMDFloatArray(rlist,NhlNsfDataArray,T,2,len_dims);
    NhlRLSetFloatArray(rlist,NhlNsfYArray,level,NhlNumber(level));
    NhlRLSetFloat(rlist,NhlNsfXCStartV,-90.0);
    NhlRLSetFloat(rlist,NhlNsfXCEndV,90.0);
    NhlRLSetFloat(rlist,NhlNsfYCStartV,1000.0);
    NhlRLSetFloat(rlist,NhlNsfYCEndV,100.0);
    NhlCreate(&dataid,"mydata",NhlscalarFieldClass,NhlDEFAULT_APP,
              rlist);
    /*
     * Create a ContourPlot object. Since ContourPlot contains a TickMark object by
     * default, the non-default TickMark resources can be set in the ContourPlot
     * object.
     */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
                   "Profile @ 105~S~o~N~W - Frame 1");
    NhlRLSetInteger(rlist,NhlNcnScalarFieldData,dataid);
    NhlRLSetFloat(rlist,NhlNvpXF,0.125);
    NhlRLSetFloat(rlist,NhlNvpYF,0.85);
    NhlRLSetFloat(rlist,NhlNvpWidthF,0.6);
    NhlRLSetFloat(rlist,NhlNvpHeightF,0.6);
    NhlRLSetFloat(rlist,NhlNcnLevelSpacingF,5.0);
    NhlRLSetInteger(rlist,NhlNtmXBMode,NhlEXPLICIT);
    NhlRLSetInteger(rlist,NhlNtmXBMinorOn,False);
    NhlRLSetFloatArray(rlist,
                       NhlNtmXBValues,labellocs,NhlNumber(labellocs));
    NhlRLSetStringArray(rlist,
                        NhlNtmXBLabels,labels,NhlNumber(labels));
    NhlCreate(&cnid,"ContourPlot1",NhlcontourPlotClass,wid,rlist);

    NhlDraw(cnid);
    NhlFrame(wid);

    /*
     * Color and add dash patterns to the lines, then display a legend
     * listing the line types. The position of the Legend is controlled by
     * resources set in the resource file. Thicken lines.
     * Note that the Legend and LabelBar are provided to the ContourPlot object
     * by its PlotManager (created by default when the ContourPlot object
     * is initialized). Therefore the resources to control them have the
     * prefix 'pm' rather than 'cn'.
     */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
                   "Profile @ 105~S~o~N~W - Frame 2");
    NhlRLSetInteger(rlist,NhlNcnMonoLineColor,False);
    NhlRLSetInteger(rlist,NhlNcnMonoLineDashPattern,False);
    NhlRLSetString(rlist,NhlNpmLegendDisplayMode,"always");
    NhlSetValues(cnid,rlist);

    NhlDraw(cnid);
    NhlFrame(wid);
    /*
     * Turn lines off, and use solid color fill instead.
     * Remove the Legend and display a LabelBar.
     * Turn off line and high/low labels.
     */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
                   "Profile @ 105~S~o~N~W - Frame 3");
    NhlRLSetString(rlist,NhlNcnLinesOn,"false");
    NhlRLSetString(rlist,NhlNcnFillOn,"true");
    NhlRLSetString(rlist,NhlNpmLegendDisplayMode,"never");
    NhlRLSetString(rlist,NhlNpmLabelBarDisplayMode,"always");
    NhlRLSetString(rlist,NhlNcnLineLabelsOn,"false");
    NhlRLSetString(rlist,NhlNcnHighLabelsOn,"false");
    NhlRLSetString(rlist,NhlNcnLowLabelsOn,"false");
    NhlSetValues(cnid,rlist);

    NhlDraw(cnid);
    NhlFrame(wid);

    /*
     * Now show the plot with the Y-Axis linearized, by overlaying the
     * plot on a LogLinPlot object. Retrieve the current view coordinates
     * of the ContourPlot object and pass them on to the LogLinPlot object.
     * Note the LogLinPlot needs to be told the data boundaries.
     */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
                   "Profile @ 105~S~o~N~W - Frame 4");
    NhlSetValues(cnid,rlist);

    grlist = NhlRLCreate(NhlGETRL);
    NhlRLClear(grlist);
    NhlRLGetFloat(grlist,NhlNvpXF,&xvp);
    NhlRLGetFloat(grlist,NhlNvpYF,&yvp);
    NhlRLGetFloat(grlist,NhlNvpWidthF,&widthvp);
    NhlRLGetFloat(grlist,NhlNvpHeightF,&heightvp);
    NhlGetValues(cnid,grlist);

    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNvpXF,xvp);
    NhlRLSetFloat(rlist,NhlNvpYF,yvp);
    NhlRLSetFloat(rlist,NhlNvpWidthF,widthvp);
    NhlRLSetFloat(rlist,NhlNvpHeightF,heightvp);
    NhlRLSetFloat(rlist,NhlNtrXMinF,-90.0);
    NhlRLSetFloat(rlist,NhlNtrXMaxF,90.0);
    NhlRLSetFloat(rlist,NhlNtrYMaxF,1000.0);
    NhlRLSetFloat(rlist,NhlNtrYMinF,100.0);
    NhlRLSetString(rlist,NhlNtrYReverse,"True");
    NhlCreate(&llid,"LogLin1",NhllogLinPlotClass,wid,rlist);

    /*
     * The LogLinPlot becomes the Base Plot, since it controls the coordinate
     * system that we are mapping to. Overlay the ContourPlot object on the base,
     * then plot the LogLinPlot object. Note that you cannot draw the ContourPlot
     * object directly, once it becomes an overlay Plot.
     */
    NhlAddOverlay(llid,cnid,-1);
    NhlDraw(llid);
    NhlFrame(wid);

    NhlDestroy(llid);
    NhlDestroy(dataid);
    NhlDestroy(cnid);
    NhlDestroy(wid);
    NhlDestroy(appid);
    NhlClose();
    exit(0);
}
Ejemplo n.º 10
0
NhlErrorTypes tdcurv_W( void )
{
  int *nwid, *iarh;
  float *ucrv, *vcrv, *wcrv, *arhl, *arhw;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;
  ng_size_t ncrv;
  int incrv;
  ng_size_t dsizes_ucrv[1];
  ng_size_t dsizes_vcrv[1];
  ng_size_t dsizes_wcrv[1];

/*
 * Retrieve parameters.
 */
  nwid   =   (int*)NclGetArgValue(0,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  ucrv   = (float*)NclGetArgValue(1,7,NULL,dsizes_ucrv,NULL,NULL,NULL,DONT_CARE);
  vcrv   = (float*)NclGetArgValue(2,7,NULL,dsizes_vcrv,NULL,NULL,NULL,DONT_CARE);
  wcrv   = (float*)NclGetArgValue(3,7,NULL,dsizes_wcrv,NULL,NULL,NULL,DONT_CARE);
  iarh   =   (int*)NclGetArgValue(4,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  arhl   = (float*)NclGetArgValue(5,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  arhw   = (float*)NclGetArgValue(6,7,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

  if(dsizes_ucrv[0] != dsizes_vcrv[0] || dsizes_ucrv[0] != dsizes_wcrv[0]) {
    NhlPError(NhlFATAL, NhlEUNKNOWN, "tdcurv: ucurv, vcurv, and wcurv must be the same length");
    return(NhlFATAL);
  }
  ncrv = dsizes_ucrv[0];

/*
 * Test dimension sizes. 
 */
  if(ncrv > INT_MAX) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tdcurv: the length of the input arrays are > INT_MAX");
    return(NhlFATAL);
  }
  incrv = (int) ncrv;

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;

/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist, NhlNwkGksWorkId, &gkswid);
  NhlGetValues(nid, grlist);
 
/*
 * The following section activates the workstation, calls the 
 * c_tdcurv function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);
  NGCALLF(tdcurv,TDCURV)(ucrv, vcrv, wcrv, &incrv, iarh, arhl, arhw);

  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 11
0
NhlErrorTypes tdez1d_W( void )
{
  int *nwid, *imrk, *style;
  float *x, *y, *z, *rmrk, *smrk, *rmult, *theta, *phi;
  ng_size_t dsizes_x[1];
  ng_size_t dsizes_y[1];
  ng_size_t dsizes_z[1];
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid, x0;
  NclHLUObj tmp_hlu_obj;
/*
 * Retrieve parameters.
 *
 * Note any of the pointer parameters can be set to NULL, which
 * implies you don't care about its value. In this example
 * the type parameter is set to NULL because the function
 * is later registered to only accept floating point numbers.
 */
  nwid   =   (int*)NclGetArgValue( 0,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  x      = (float*)NclGetArgValue( 1,11,NULL,dsizes_x,NULL,NULL,NULL,DONT_CARE);
  y      = (float*)NclGetArgValue( 2,11,NULL,dsizes_y,NULL,NULL,NULL,DONT_CARE);
  z      = (float*)NclGetArgValue( 3,11,NULL,dsizes_z,NULL,NULL,NULL,DONT_CARE);
  imrk   =   (int*)NclGetArgValue( 4,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  rmrk   = (float*)NclGetArgValue( 5,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  smrk   = (float*)NclGetArgValue( 6,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  rmult  = (float*)NclGetArgValue( 7,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  theta  = (float*)NclGetArgValue( 8,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  phi    = (float*)NclGetArgValue( 9,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  style  =   (int*)NclGetArgValue(10,11,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
/*
 * Check the input sizes.
 */
  if( dsizes_x[0] != dsizes_y[0] || dsizes_x[0] != dsizes_z[0] ) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tdez1d: the length of the x, y, and z arrays must be the same");
    return(NhlFATAL);
  }
  if(dsizes_x[0] > INT_MAX) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tdez1d: dsizes_x[0] = %ld is greater than INT_MAX", dsizes_x[0]);
    return(NhlFATAL);
  }
  x0 = (int) dsizes_x[0];

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
  tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
  nid         = tmp_hlu_obj->hlu.hlu_id;
/*
 * Retrieve the GKS workstation id from the workstation object.
 */
  grlist = NhlRLCreate(NhlGETRL);
  NhlRLClear(grlist);
  NhlRLGetInteger(grlist,NhlNwkGksWorkId,&gkswid);
  NhlGetValues(nid,grlist);
 
/*
 * The following section activates the workstation, calls the 
 * tdez1d function, and then deactivates the workstation.
 */
  gactivate_ws (gkswid);

  NGCALLF(tdez1d,TDEZ1D)(&x0,x,y,z,imrk,rmrk,smrk,rmult,theta,phi,style);

  gdeactivate_ws (gkswid);

  return(NhlNOERROR);
}
Ejemplo n.º 12
0
NhlErrorTypes tdez3d_W( void )
{
  float *x, *y, *z, *u, *value, *up;
  ng_size_t nx, dsizes_x[NCL_MAX_DIMENSIONS];
  ng_size_t ny, dsizes_y[NCL_MAX_DIMENSIONS];
  ng_size_t nz, dsizes_z[NCL_MAX_DIMENSIONS];
  ng_size_t dsizes_u[NCL_MAX_DIMENSIONS];
  float *rmult, *theta, *phi;
  int *nwid, *style;
/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nid;
  NclHLUObj tmp_hlu_obj;

  ng_size_t i, j, k, inx, iny, inz;
/*
 * Retrieve parameters.
 *
 * Note any of the pointer parameters can be set to NULL, which
 * implies you don't care about its value. In this example
 * the type parameter is set to NULL because the function
 * is later registered to only accept floating point numbers.
 */
  nwid  =  (int*)NclGetArgValue(0,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  x     =  (float*)NclGetArgValue(1,10, NULL, dsizes_x, NULL,NULL,NULL,DONT_CARE);
  y     =  (float*)NclGetArgValue(2,10, NULL, dsizes_y, NULL,NULL,NULL,DONT_CARE);
  z     =  (float*)NclGetArgValue(3,10, NULL, dsizes_z, NULL,NULL,NULL,DONT_CARE);
  u     =  (float*)NclGetArgValue(4,10, NULL, dsizes_u, NULL,NULL,NULL,DONT_CARE);
  value = (float*)NclGetArgValue(5,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  rmult = (float*)NclGetArgValue(6,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  theta = (float*)NclGetArgValue(7,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  phi   = (float*)NclGetArgValue(8,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);
  style = (int*)NclGetArgValue(9,10,NULL,NULL,NULL,NULL,NULL,DONT_CARE);

/*
 * Test dimension sizes.
 */
  nx = dsizes_x[0];
  ny = dsizes_y[0];
  nz = dsizes_z[0];
  if((nx > INT_MAX) || (ny > INT_MAX) || (nz > INT_MAX)) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tdez3d: the length of x, y and/or z is greater than INT_MAX");
    return(NhlFATAL);
  }
  inx = (int) nx;
  iny = (int) ny;
  inz = (int) nz;

/*
 * Check input sizes.
 */
  if( (dsizes_u[0] == nx) && (dsizes_u[1] == ny) && (dsizes_u[2] == nz) ) {
/*
 * Reverse the order of the dimensions.
 */
    up = (float *) calloc(nx*ny*nz,sizeof(float));
    for (i = 0; i < nx; i++) {
      for (j = 0; j < ny; j++) { 
        for (k = 0; k < nz; k++) { 
          up[nx*ny*k + j*nx + i] = 
            u[i*nz*ny + nz*j + k];
        }
      }
    }

/*
 *  Determine the NCL identifier for the graphic object in nid.
 */
    tmp_hlu_obj = (NclHLUObj) _NclGetObj(*nwid);
    nid         = tmp_hlu_obj->hlu.hlu_id;
 
/*
 * Retrieve the GKS workstation id from the workstation object.
 */
    grlist = NhlRLCreate(NhlGETRL);
    NhlRLClear(grlist);
    NhlRLGetInteger(grlist,NhlNwkGksWorkId,&gkswid);
    NhlGetValues(nid,grlist);

/*
 * The following section activates the workstation, calls the 
 * c_tdez3d function, and then deactivates the workstation.
 */
    gactivate_ws (gkswid);
    c_tdez3d(nx,ny,nz,x,y,z,up,*value,
             *rmult,*theta,*phi,*style);
    gdeactivate_ws (gkswid);
    free(up);
  }
  else {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"tdez3d: the dimension sizes of u must be the dimension of x by the dimension of y by the dimension of z");
    return(NhlFATAL);
  }
  return(NhlNOERROR);
  
}
Ejemplo n.º 13
0
void guiNhlGetValues(int plotid, int rlid)
{
    NhlGetValues(plotid, rlid);
}
Ejemplo n.º 14
0
NhlErrorTypes ctwrap_W( void )
{
  int *wks;
  float *lat, *lon, *data;
  ng_size_t nlat, nlon, nlon8, dsizes_lat[2], dsizes_lon[2], dsizes_data[2];
  int inlat, inlon, idim, jdim;
  logical *opt;

/*
 * Variables for retrieving workstation information.
 */
  int grlist, gkswid, nwks;
  NclHLUObj tmp_hlu_obj;

/*
 * Work arrays.
 */
  float *rpnt, *rwrk, *xcra, *ycra;
  int *iedg, *itri, *ippp, *ippe, *iwrk, *icra, *iama, *iaai, *iagi;
  int mpnt, medg, mtri, mnop, mnoe, mnot, lrwk, liwk, lama, ncra, ngps;
  int icam, ican, lopn, loen, lotn;

/*
 * Variables for retrieving attributes from "opt".
 */
  logical idbg = False, igrd = False, imsh = False;
  logical icon = True, icol = False, icap = False;
  NrmQuark *MapProjection, *fnam;
  char *cMapProjection, *cnam = NULL;
  int imap = 2, ilev = -1, itim = -1;
  NclAttList  *attr_list;
  NclAtt  attr_obj;
  NclStackEntry   stack_entry;

/*
 * Retrieve parameters.
 */
  wks    =     (int*)NclGetArgValue(0,5, NULL, NULL,NULL,NULL,NULL,DONT_CARE);
  lat    =   (float*)NclGetArgValue(1,5, NULL, dsizes_lat, NULL,NULL,NULL,DONT_CARE);
  lon    =   (float*)NclGetArgValue(2,5, NULL, dsizes_lon, NULL,NULL,NULL,DONT_CARE);
  data   =   (float*)NclGetArgValue(3,5, NULL, dsizes_data, NULL,NULL,NULL,DONT_CARE);
  opt    = (logical*)NclGetArgValue(4,5, NULL,NULL,NULL,NULL,NULL,DONT_CARE);

/*
 * Check input sizes.
 */
  nlat = dsizes_lat[0]; 
  nlon = dsizes_lat[1]; 
  if( dsizes_lon[0]  != nlat || dsizes_lon[1]  != nlon ||
      dsizes_data[0] != nlat || dsizes_data[1] != nlon ) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"ctwrap: the dimension sizes of the lat/lon arrays and the data must be same");
    return(NhlFATAL);
  }

/*
 * Hopefully the number of longitudes is divisible by 8 (the nature of the
 * SEAM grid), so get that number here.
 */
  nlon8 = nlon/8; 

  if ((nlat > INT_MAX) || (nlon > INT_MAX) || (nlon8 > INT_MAX)) {
    NhlPError(NhlFATAL,NhlEUNKNOWN,"ctwrap: one or more input dimension sizes is > INT_MAX");
    return(NhlFATAL);
  }
  inlat = (int) nlat;
  inlon = (int) nlon;
  idim  = jdim = (int) nlon8;

/*
 *  Determine the NCL identifier for the graphic object.
 */
    tmp_hlu_obj = (NclHLUObj) _NclGetObj(*wks);
    nwks        = tmp_hlu_obj->hlu.hlu_id;
/*
 * Retrieve the GKS workstation id from the workstation object.
 */
    grlist = NhlRLCreate(NhlGETRL);
    NhlRLClear(grlist);
    NhlRLGetInteger(grlist,NhlNwkGksWorkId,&gkswid);
    NhlGetValues(nwks,grlist);
/*
 * Activate workstation.
 */
    gactivate_ws (gkswid);
 
/*
 * Create work arrays, lots of them.
 */
    lopn = 5;
    loen = 5;
    lotn = 4;
    mnop = 7352;
    mnoe = 22050;
    mnot = 14700;
    lrwk = 10000;
    liwk = 1000;
    lama = 400000;
    ncra = lama/10;
    icam = 512;             /* could be 1024? */
    ican = 512;             /* could be 1024? */
    ngps = 2;

    mpnt = mnop*lopn;   /*  space for points */
    medg = mnoe*loen;   /*  space for edges  */
    mtri = mnot*lotn;   /*  space for triangles */

    rpnt = (float *)calloc(mpnt,sizeof(float));
    rwrk = (float *)calloc(lrwk,sizeof(float));
    xcra = (float *)calloc(ncra,sizeof(float));
    ycra = (float *)calloc(ncra,sizeof(float));

    iwrk = (int *)calloc(liwk,sizeof(int));
    iama = (int *)calloc(lama,sizeof(int));
    iaai = (int *)calloc(ngps,sizeof(int));
    iagi = (int *)calloc(ngps,sizeof(int));
    icra = (int *)calloc(icam*ican,sizeof(int));
    iedg = (int *)calloc(medg,sizeof(int));
    itri = (int *)calloc(mtri,sizeof(int));
    ippp = (int *)calloc(2*mnop,sizeof(int));
    ippe = (int *)calloc(2*mnoe,sizeof(int));

    if(rpnt == NULL || rwrk == NULL || xcra == NULL || ycra == NULL || 
       iwrk == NULL || iama == NULL || iaai == NULL || iagi == NULL || 
       icra == NULL || iedg == NULL || itri == NULL || ippp == NULL || 
       ippe == NULL) {
      NhlPError(NhlFATAL,NhlEUNKNOWN,"ctwrap: Unable to allocate memory for work arrays");
      return(NhlFATAL);
    }

/* 
 * If "opt" is True, then check if any attributes have been set.
 */
    if(*opt) {
      stack_entry = _NclGetArg(4, 5, DONT_CARE);
      switch (stack_entry.kind) {
      case NclStk_VAR:
        if (stack_entry.u.data_var->var.att_id != -1) {
          attr_obj = (NclAtt) _NclGetObj(stack_entry.u.data_var->var.att_id);
          if (attr_obj == NULL) {
            break;
          }
        }
        else {
/*
 * att_id == -1 ==> no optional args given.
 */
          break;
        }
/* 
 * Get optional arguments.
 */
        if (attr_obj->att.n_atts <= 0) {
          break;
        }
/*
 * Get list of attributes.
 */
        attr_list = attr_obj->att.att_list;
/*
 * Loop through attributes and check them. The current ones recognized are:
 *
 *   "RectangularMesh"
 *   "TriangularMesh"
 *   "LineContours"
 *   "FilledContours"
 *   "CellArray"
 *   "MapProjection"
 *   "FieldName"
 *   "TimeStep"
 *   "Level"
 *   "Debug"
 */
        while (attr_list != NULL) {
/*
 * Check for "RectangularGrid".
 */
          if (!strcmp(attr_list->attname, "RectangularGrid")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'RectangularGrid' attribute must be a logical, defaulting to False.");
            }
            else {
              igrd = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "TriangularMesh".
 */
          if (!strcmp(attr_list->attname, "TriangularMesh")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'TriangularMesh' attribute must be a logical, defaulting to False.");
            }
            else {
              imsh = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "LineContours".
 */
          if (!strcmp(attr_list->attname, "LineContours")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'LineContours' attribute must be a logical, defaulting to True.");
            }
            else {
              icon = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "FilledContours".
 */
          if (!strcmp(attr_list->attname, "FilledContours")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'FilledContours' attribute must be a logical, defaulting to False.");
            }
            else {
              icol = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "CellArray".
 */
          if (!strcmp(attr_list->attname, "CellArray")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'CellArray' attribute must be a logical, defaulting to False.");
            }
            else {
              icap = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "FieldName".
 */
          if (!strcmp(attr_list->attname, "FieldName")) {
            if(attr_list->attvalue->multidval.data_type != NCL_string) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'FieldName' attribute must be a string, ignoring...");
            }
            else {
              fnam = (NrmQuark *) attr_list->attvalue->multidval.val;
              cnam = NrmQuarkToString(*fnam);
            }
          }
/*
 * Check for "TimeStep".
 */
          if (!strcmp(attr_list->attname, "TimeStep")) {
            if(attr_list->attvalue->multidval.data_type != NCL_int) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'TimeStep' attribute must be an integer, defaulting to -1.");
            }
            else {
              itim = *(int*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "Level".
 */
          if (!strcmp(attr_list->attname, "Level")) {
            if(attr_list->attvalue->multidval.data_type != NCL_int) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'Level' attribute must be an integer, defaulting to -1.");
            }
            else {
              ilev = *(int*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "Debug".
 */
          if (!strcmp(attr_list->attname, "Debug")) {
            if(attr_list->attvalue->multidval.data_type != NCL_logical) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'Debug' attribute must be a logical, defaulting to False.");
            }
            else {
              idbg = *(logical*) attr_list->attvalue->multidval.val;
            }
          }

/*
 * Check for "MapProjection".
 */
          if (!strcmp(attr_list->attname, "MapProjection")) {
            if(attr_list->attvalue->multidval.data_type != NCL_string) {
              NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: The 'MapProjection' attribute must be a string, defaulting to 'CylindricalEquidistant.'");
            }
            else {
              MapProjection  = (NrmQuark *) attr_list->attvalue->multidval.val;
              cMapProjection = NrmQuarkToString(*MapProjection);
              if(!strcmp(cMapProjection,"Orthographic")) {
                imap = 1;
              }
              else if(!strcmp(cMapProjection,"CylindricalEquidistant")) {
                imap = 2;
              }
              else if(!strcmp(cMapProjection,"Robinson")) {
                imap = 3;
              }
              else if(!strcmp(cMapProjection,"LambertEqualArea")) {
                imap = 4;
              }
              else {
                NhlPError(NhlWARNING,NhlEUNKNOWN,"ctwrap: Unrecognized value for the 'MapProjection' attribute. Defaulting to 'CylindricalEquidistant'.");
                imap = 2;
              }
            }
          }
          attr_list = attr_list->next;
        }
      default:
        break;
      }
    }
      
    if(cnam == NULL) {
      cnam = (char*)calloc(2,sizeof(char));
      strcpy(cnam,"");
    }

    NGCALLF(ctdriver,CTDRIVER)(&gkswid,lat,lon,data,&inlat,&inlon,&idim,&jdim,
                               rpnt,&mpnt,rwrk,&lrwk,xcra,ycra,&ncra,iwrk,
                               &liwk,iama,&lama,iaai,iagi,&ngps,icra,&icam,
                               &ican,iedg,&medg,itri,&mtri,ippp,&mnop,ippe,
                               &mnoe,&lopn,&loen,&lotn,&igrd,&imsh,&icon,&icol,
                               &icap,&imap,cnam,&itim,&ilev,&idbg,
                               strlen(cnam));
/*
 * Free work arrays. 
 */
    NclFree(rpnt);
    NclFree(rwrk);
    NclFree(xcra);
    NclFree(ycra);
    NclFree(iwrk);
    NclFree(iama);
    NclFree(iaai);
    NclFree(iagi);
    NclFree(icra);
    NclFree(iedg);
    NclFree(itri);
    NclFree(ippp);
    NclFree(ippe);


/*
 * Deactivate workstation.
 */
    gdeactivate_ws (gkswid);

    return(NhlNOERROR);
}
Ejemplo n.º 15
0
Archivo: st02c.c Proyecto: gavin971/ncl
int main(int argc, char *argv[])
{
    char const *wks_type = "x11";
    int appid,wid,stid,vfid;
    int rlist,grlist;
    ng_size_t len_dims[2];
    float stepsize,arrowlength,spacing;
    float U[N][M],V[N][M];

/*
 * Generate vector data arrays
 */
    {
	    float igrid, jgrid;
	    int i,j;
	    igrid = 2.0 * PI / (float) M;
	    jgrid = 2.0 * PI / (float) N;
	    for (j = 0; j < N; j++) {
		    for (i = 0; i < M; i++) {
			    U[j][i] = 10.0 * cos(jgrid * (float) j);
			    V[j][i] = 10.0 * cos(igrid * (float) i);
		    }
	    }
    }

/*
 * Initialize the high level utility library
 */
    NhlInitialize();
/*
 * Create an application context. Set the app dir to the current
 * directory so the application looks for a resource file in the working
 * directory. 
 */
    rlist = NhlRLCreate(NhlSETRL);
    grlist = NhlRLCreate(NhlGETRL);
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNappUsrDir,"./");
    NhlCreate(&appid,"st02",NhlappClass,NhlDEFAULT_APP,rlist);

    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
/*
 * Create a meta file workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./st02c.ncgm");
        NhlCreate(&wid,"st02Work",
                  NhlncgmWorkstationClass,NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 * Create an X workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlCreate(&wid,"st02Work",NhlcairoWindowWorkstationClass,appid,rlist);
    }

    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
/*
 * Create an older-style PostScript workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"st02c.ps");
        NhlCreate(&wid,"st02Work",NhlpsWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
/*
 * Create an older-style PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"st02c.pdf");
        NhlCreate(&wid,"st02Work",NhlpdfWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
/*
 * Create a cairo PS/PDF workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"st02c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"st02Work",NhlcairoDocumentWorkstationClass,appid,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 * Create a cairo PNG workstation.
 */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"st02c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlCreate(&wid,"st02Work",NhlcairoImageWorkstationClass,appid,rlist);
    }
/*
 * Create a VectorField data object using the data set defined above.
 * By default the array bounds will define the data boundaries (zero-based,
 * as in C language conventions)
 */

    len_dims[0] = N;
    len_dims[1] = M;
    NhlRLClear(rlist);
    NhlRLSetMDFloatArray(rlist,NhlNvfUDataArray,&U[0][0],2,len_dims);
    NhlRLSetMDFloatArray(rlist,NhlNvfVDataArray,&V[0][0],2,len_dims);
    NhlCreate(&vfid,"vectorfield",NhlvectorFieldClass,appid,rlist);


/*
 * Create a StreamlinePlot object, supplying the VectorField object as data
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,
		   "Modifying StreamlinePlot resources");
    NhlRLSetInteger(rlist,NhlNstVectorFieldData,vfid);
    NhlCreate(&stid,"streamlineplot",NhlstreamlinePlotClass,wid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);

/* 
 * Get the values of several resources that are set dynamically based
 * on the assumed NDC size of a grid cell. Each of this will be separately
 * modified in the course of this example to illustrate their effect.
 */
      
    NhlRLClear(grlist);
    NhlRLGetFloat(grlist,NhlNstStepSizeF,&stepsize);
    NhlRLGetFloat(grlist,NhlNstArrowLengthF,&arrowlength);
    NhlRLGetFloat(grlist,NhlNstMinLineSpacingF,&spacing);
    NhlGetValues(stid,grlist);

/* 
 * Increase the step size 
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Larger Step Size");
    NhlRLSetFloat(rlist,NhlNstStepSizeF,stepsize * 4.0);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);
/* 
 * Decrease the step size 
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Smaller Step Size");
    NhlRLSetFloat(rlist,NhlNstStepSizeF,stepsize * 0.25);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);

/* 
 * Increase the minimum line spacing 
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Larger Minimum Line Spacing");
    NhlRLSetFloat(rlist,NhlNstStepSizeF,stepsize);
    NhlRLSetFloat(rlist,NhlNstMinLineSpacingF, spacing * 4.0);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);
/* 
 * Decrease the minimum line spacing
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Smaller Minimum Line Spacing");
    NhlRLSetFloat(rlist,NhlNstMinLineSpacingF,spacing * 0.25);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);

/* 
 * Increase the line starting grid stride 
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Larger Line Starting Grid Stride");
    NhlRLSetFloat(rlist,NhlNstMinLineSpacingF,spacing);
    NhlRLSetInteger(rlist,NhlNstLineStartStride,3);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);
/* 
 * Decrease the line starting grid stride
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Smaller Line Starting Grid Stride");
    NhlRLSetInteger(rlist,NhlNstLineStartStride,1);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);

/*
 * Increase the arrow size
 */

    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtiMainString,"Larger Arrows");
    NhlRLSetInteger(rlist,NhlNstLineStartStride,2);
    NhlRLSetFloat(rlist,NhlNstArrowLengthF, arrowlength * 2.0);
    NhlSetValues(stid,rlist);

    NhlDraw(stid);
    NhlFrame(wid);

/*
 * Destroy the objects created, close the HLU library and exit.
 */
    NhlDestroy(appid);
    NhlClose();
    exit(0);
}
Ejemplo n.º 16
0
Archivo: xy17c.c Proyecto: gavin971/ncl
int main ()
{
   char const *wks_type = "x11";
   int i=0, rlist, wks, appid, field1, field2, field3, xy1, xy2, xy3;
   int grlist, datadepid[1];
   int *dspec = datadepid;
   ng_size_t num_dspec;

/*
 *  Create variables to contain data.
 */

   FILE *x1_y3;
   float y [ncurve][npts], lon [npts], u [npts], v [npts], t [npts];
   float y1val [5] = {-90.0 , -80.0, -70.0, -60.0, -50.0};
   float y2val [6] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0};
   float y3val [5] = {-20.0, -10.0, 0.0, 10.0, 20.0};
 
   char *y1lab [5] = {"-90.", "-80.", "-70.", "-60.", "-50."};
   char *y2lab [6] = {"10.", "20.", "30.", "40.", "50.", "60."};
   char *y3lab [5] = {"-20.", "-10.", "0.", "10.", "20."};
   char *file = "xy.asc";

/*
 *  Read ASCII file xy.asc
 */
   x1_y3 = fopen (file,"r");
/*
 *   xy.asc has 4 vars of length 129 longitudes, lon, u, v, t
 *
 *     The data is taken at 43N latitude.  Longitude is an index
 *     1-129 standing for 0 deg - 360 deg in steps of 360/128?
 *     u and v are in m/s, and t is in deg K.
 */

   while (!feof(x1_y3)) {
      fscanf (x1_y3, "%f %f %f %f", &lon[i], &u[i], &v[i], &t[i]);
      i++;
   }

   for (i=0; i < npts; i++)
   {
      lon [i] = (lon[i]- 1.0) * 360.0/128.0;
      t [i] =  (t[i] - 273.15) * 9 / 5 + 32.0 ;
      y [0][i] = u[i];
      y [1][i] = v[i];
      y [2][i] = (t[i] - 273.15) * 9.0 / 5.0 + 32.0;
   }

   NhlInitialize ();
   rlist = NhlRLCreate (NhlSETRL);

/*
 *  Create Application object.  The Application object name is used to
 *  determine the name of the resource file, which is "xy17.res" in this
 *  case. 
 */
 
   NhlRLClear (rlist);
   NhlRLSetInteger (rlist, NhlNappDefaultParent, True);
   NhlRLSetString (rlist, NhlNappUsrDir, "./");
   NhlCreate (&appid, "xy17", NhlappClass, 0, rlist);

/*
 *  If NCGM=1, then open NCGM workstation. 
 */
   if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
      NhlRLClear (rlist);
      NhlRLSetString (rlist, NhlNwkMetaName, "xy17c.ncgm");
      NhlCreate (&wks, "xy17Work", NhlncgmWorkstationClass, 0, rlist);
   }
   else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
/*
 *  Create an X workstation. 
 */
      NhlRLClear (rlist);
      NhlRLSetInteger (rlist, NhlNwkPause, True);
      NhlCreate (&wks, "xy17Work", NhlcairoWindowWorkstationClass, 0, rlist);
   }
   else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
/*
 *  Open PS workstation. 
 */

      NhlRLClear (rlist);
      NhlRLSetString (rlist, NhlNwkPSFileName, "xy17c.ps");
      NhlCreate (&wks, "xy17Work", NhlpsWorkstationClass, 0, rlist);
   }
   else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
/*
 *  Open PDF workstation. 
 */
      NhlRLClear (rlist);
      NhlRLSetString (rlist, NhlNwkPDFFileName, "xy17c.pdf");
      NhlCreate (&wks, "xy17Work", NhlpdfWorkstationClass, 0, rlist);
   }
   else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
            !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
/*
 *  Open cairo PS/PDF workstation. 
 */
      NhlRLClear (rlist);
      NhlRLSetString (rlist, NhlNwkFileName, "xy17c");
      NhlRLSetString (rlist, NhlNwkFormat, (char*)wks_type);
      NhlCreate (&wks, "xy17Work", NhlcairoDocumentWorkstationClass, 0, rlist);
   }
   else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
/*
 *  Open cairo PNG workstation. 
 */
      NhlRLClear (rlist);
      NhlRLSetString (rlist, NhlNwkFileName, "xy17c");
      NhlRLSetString (rlist, NhlNwkFormat, (char*)wks_type);
      NhlCreate (&wks, "xy17Work", NhlcairoImageWorkstationClass, 0, rlist);
   }

/*
 *  Create a coordarrays data object and configure its extents missing
 *  values and at the same time convert it from Degrees K to Degrees F  
 */

   NhlRLClear (rlist);
   NhlRLSetFloatArray (rlist, NhlNcaXArray, lon, 129);
   NhlRLSetFloatArray (rlist, NhlNcaYArray, t, 129);
   NhlCreate (&field1, "field1", NhlcoordArraysClass, appid, rlist);

/*
 *  Create a coordarrays data object and configure its extents missing
 *  values and at the same time convert it from Degrees K to Degrees F
 */

   NhlRLClear (rlist);
   NhlRLSetFloatArray (rlist, NhlNcaXArray, lon, 129);
   NhlRLSetFloatArray (rlist, NhlNcaYArray, u, 129);
   NhlCreate (&field2, "field2", NhlcoordArraysClass, appid, rlist);

/*
 *  Create a coordarrays data object and configure its extents missing
 *  values and at the same time convert it from Degrees K to Degrees F
 */

   NhlRLClear (rlist);
   NhlRLSetFloatArray (rlist, NhlNcaXArray, lon, 129);
   NhlRLSetFloatArray (rlist, NhlNcaYArray, v, 129);
   NhlCreate (&field3, "field3", NhlcoordArraysClass, appid, rlist);

/*
 *  Create XyPlot object for curve 1 and assign data to it
 */

   NhlRLClear (rlist);
   NhlRLSetFloat   (rlist, NhlNvpXF, 0.20);
   NhlRLSetFloat   (rlist, NhlNvpYF, 0.80);
   NhlRLSetFloat   (rlist, NhlNvpWidthF, 0.6);
   NhlRLSetFloat   (rlist, NhlNvpHeightF, 0.2);
   NhlRLSetInteger (rlist, NhlNxyCoordData, field1);
   NhlRLSetString  (rlist, NhlNtrYReverse, "False");
   NhlRLSetFloat   (rlist, NhlNtrYMaxF,  -50.0);
   NhlRLSetFloat   (rlist, NhlNtrYMinF,  -90.0);
   NhlRLSetFloat   (rlist, NhlNtrXMaxF,  360.0);
   NhlRLSetFloat   (rlist, NhlNtrXMinF,   0.0);
   NhlRLSetString  (rlist, NhlNtmYROn, "False");
   NhlRLSetString  (rlist, NhlNtmYUseLeft, "False");
   NhlRLSetString  (rlist, NhlNtmXMajorGrid, "True");
   NhlRLSetString  (rlist, NhlNtmXBLabelsOn, "False");
   NhlRLSetString  (rlist, NhlNtmYLLabelsOn, "True");
   NhlRLSetFloat   (rlist, NhlNtmYLMajorLengthF, 0.01);
   NhlRLSetFloat   (rlist, NhlNtmYLMajorOutwardLengthF, 0.0);
   NhlRLSetString  (rlist, NhlNtmYLMode, "Explicit");
   NhlRLSetFloatArray  (rlist, NhlNtmYLValues, y1val, 5);
   NhlRLSetStringArray (rlist, NhlNtmYLLabels, y1lab, 5);
   NhlRLSetString  (rlist, NhlNtmYLLabelsOn, "True");
   NhlRLSetString (rlist, NhlNtmYLLabelFontColor,"red");
   NhlRLSetString  (rlist, NhlNtiMainString, "Temperature, U, V Stacked Plots");
   NhlRLSetString  (rlist, NhlNtiYAxisString, "Temp (Deg C)");
   NhlRLSetFloat   (rlist, NhlNtiXAxisFontHeightF, 0.02);
   NhlRLSetFloat   (rlist, NhlNtiYAxisFontHeightF, 0.02);
   NhlRLSetString  (rlist, NhlNtiXAxisFont, "helvetica-bold");
   NhlRLSetString  (rlist, NhlNtiYAxisFont, "helvetica-bold");
   NhlRLSetString (rlist, NhlNtiYAxisFontColor,"red");
   NhlRLSetString  (rlist, NhlNtmYRMinorOn, "False");
   NhlRLSetString  (rlist, NhlNtmYLMinorOn, "False");
   NhlCreate(&xy1, "xy1", NhlxyPlotClass, wks, rlist);

/*
 *  Create XyPlot object for curve 2 and assign data to it
 */

   NhlRLClear (rlist);
   NhlRLSetFloat   (rlist, NhlNvpXF, 0.20);
   NhlRLSetFloat   (rlist, NhlNvpYF, 0.60);
   NhlRLSetFloat   (rlist, NhlNvpWidthF, 0.6);
   NhlRLSetFloat   (rlist, NhlNvpHeightF, 0.2);
   NhlRLSetInteger (rlist, NhlNxyCoordData, field2);
   NhlRLSetString  (rlist, NhlNtrYReverse, "False");
   NhlRLSetFloat   (rlist, NhlNtrYMaxF,   60.0);
   NhlRLSetFloat   (rlist, NhlNtrYMinF,   10.0);
   NhlRLSetFloat   (rlist, NhlNtrXMaxF,  360.0);
   NhlRLSetFloat   (rlist, NhlNtrXMinF,   0.0);
   NhlRLSetString  (rlist, NhlNtmYROn, "True");
   NhlRLSetString  (rlist, NhlNtmYLOn, "False");
   NhlRLSetString  (rlist, NhlNtmYUseLeft, "False");
   NhlRLSetString  (rlist, NhlNtmXMajorGrid, "True");
   NhlRLSetString  (rlist, NhlNtmYLLabelsOn, "False");
   NhlRLSetString  (rlist, NhlNtmYRLabelsOn, "True");
   NhlRLSetString  (rlist, NhlNtmYRMode, "Explicit");
   NhlRLSetFloatArray  (rlist, NhlNtmYRValues, y2val, 6);
   NhlRLSetStringArray (rlist, NhlNtmYRLabels, y2lab, 6);
   NhlRLSetString  (rlist, NhlNtmXBLabelsOn, "False");
   NhlRLSetString (rlist, NhlNtmYRLabelFontColor,"green");
   NhlRLSetString  (rlist, NhlNtiYAxisString, "U (m/s)");
   NhlRLSetFloat   (rlist, NhlNtiXAxisFontHeightF, 0.02);
   NhlRLSetFloat   (rlist, NhlNtiYAxisFontHeightF, 0.02);
   NhlRLSetString  (rlist, NhlNtiXAxisFont, "helvetica-bold");
   NhlRLSetString  (rlist, NhlNtiYAxisFont, "helvetica-bold");
   NhlRLSetString (rlist, NhlNtiYAxisFontColor,"green");
   NhlRLSetString  (rlist, NhlNtmYRMinorOn, "False");
   NhlRLSetString  (rlist, NhlNtmYLMinorOn, "False");
   NhlCreate(&xy2, "xy2", NhlxyPlotClass, wks, rlist);

/*
 *  Create XyPlot object for curve 3 and assign data to it
 *
 *  Increase the veiwport so the right scale will be about .15 NDC
 *  right of the other grids.  Plot only the right vertical axis.
 *  .5NDC = 360 deg lon, thus .65NDC = 360+108 deg lon.
 */

   NhlRLClear (rlist);
   NhlRLSetFloat   (rlist, NhlNvpXF, 0.20);
   NhlRLSetFloat   (rlist, NhlNvpYF, 0.40);
   NhlRLSetFloat   (rlist, NhlNvpWidthF, 0.6);
   NhlRLSetFloat   (rlist, NhlNvpHeightF, 0.2);
   NhlRLSetInteger (rlist, NhlNxyCoordData, field3);
   NhlRLSetString  (rlist, NhlNtrYReverse, "False");
   NhlRLSetFloat   (rlist, NhlNtrYMaxF,   20.0);
   NhlRLSetFloat   (rlist, NhlNtrYMinF,  -20.0);
   NhlRLSetFloat   (rlist, NhlNtrXMaxF,  360.0);
   NhlRLSetFloat   (rlist, NhlNtrXMinF,   0.0);
   NhlRLSetString  (rlist, NhlNtmYROn, "False");
   NhlRLSetString  (rlist, NhlNtmYUseLeft, "False");
   NhlRLSetString  (rlist, NhlNtmYLLabelsOn, "True");
   NhlRLSetString  (rlist, NhlNtmXBLabelsOn, "True");
   NhlRLSetString  (rlist, NhlNtmXMajorGrid, "True");
   NhlRLSetFloat   (rlist, NhlNtmYLMajorLengthF, 0.01);
   NhlRLSetFloat   (rlist, NhlNtmYLMajorOutwardLengthF, 0.0);
   NhlRLSetString  (rlist, NhlNtmYLMode, "Explicit");
   NhlRLSetString  (rlist, NhlNtmYLLabelsOn, "True");
   NhlRLSetString (rlist, NhlNtmYLLabelFontColor,"blue");
   NhlRLSetString  (rlist, NhlNtiYAxisString, "V (m/s)");
   NhlRLSetString  (rlist, NhlNtiXAxisString, "Longitude (Degs)");
   NhlRLSetFloat   (rlist, NhlNtiXAxisFontHeightF, 0.02);
   NhlRLSetFloat   (rlist, NhlNtiYAxisFontHeightF, 0.02);
   NhlRLSetString  (rlist, NhlNtiXAxisFont, "helvetica-bold");
   NhlRLSetString  (rlist, NhlNtiYAxisFont, "helvetica-bold");
   NhlRLSetString (rlist, NhlNtiYAxisFontColor,"blue");
   NhlRLSetString  (rlist, NhlNtmYRMinorOn, "False");
   NhlRLSetString  (rlist, NhlNtmYLMinorOn, "False");
   NhlRLSetFloatArray  (rlist, NhlNtmYLValues, y3val, 5);
   NhlRLSetStringArray (rlist, NhlNtmYLLabels, y3lab, 5);
   NhlCreate(&xy3, "xy3", NhlxyPlotClass, wks, rlist);

   grlist = NhlRLCreate (NhlGETRL);
   NhlRLClear (grlist);
   NhlRLGetIntegerArray(grlist,NhlNxyCoordDataSpec,&dspec,&num_dspec);
   NhlGetValues(xy1, grlist);

   NhlRLClear (rlist);
   NhlRLSetInteger (rlist, NhlNxyMonoLineColor, True);
   NhlRLSetString (rlist, NhlNxyLineColor,"red");
   NhlSetValues (dspec[0], rlist);

   NhlRLClear (grlist);
   NhlRLGetIntegerArray(grlist,NhlNxyCoordDataSpec,&dspec,&num_dspec);
   NhlGetValues(xy2, grlist);

   NhlRLClear (rlist);
   NhlRLSetInteger (rlist, NhlNxyMonoLineColor, True);
   NhlRLSetString (rlist, NhlNxyLineColor,"green");
   NhlSetValues (dspec[0], rlist);

   NhlRLClear (grlist);
   NhlRLGetIntegerArray(grlist,NhlNxyCoordDataSpec,&dspec,&num_dspec);
   NhlGetValues(xy3, grlist);

   NhlRLClear (rlist);
   NhlRLSetInteger (rlist, NhlNxyMonoLineColor, True);
   NhlRLSetString (rlist, NhlNxyLineColor,"blue");
   NhlSetValues (dspec[0], rlist);

   NhlDraw(xy1);
   NhlDraw(xy2);
   NhlDraw(xy3);
   NhlFrame(wks);

   NhlDestroy (wks);
   NhlClose();
   exit(0);
}