Changeset 673

Show
Ignore:
Timestamp:
10/15/09 19:03:56 (6 weeks ago)
Author:
kgao
Message:

add ncdump tag -V

Location:
trunk/src/utils/ncdump
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/utils/ncdump/ncdump.c

    r598 r673  
    359359    vnode* vlist = 0;           /* list for vars specified with -v option */ 
    360360    int ncmpi_status;           /* return from netcdf calls */ 
     361    int NC_mode; 
     362    int NC_version; 
    361363 
    362364    ncmpi_status = ncmpi_open(MPI_COMM_WORLD, path, NC_NOWRITE, MPI_INFO_NULL, &ncid); 
     
    364366        error("%s: %s", path, ncmpi_strerror(ncmpi_status)); 
    365367    } 
     368 
    366369    /* 
    367370     * If any vars were specified with -v option, get list of associated 
     
    381384    } 
    382385 
     386    ncmpi_inq_version(ncid, &NC_mode); 
     387    if (specp->version) { 
     388        if (NC_mode == 0x1000)  
     389           Printf ("%s file format: CDF-5 (big variables)\n", specp->name); 
     390        else if (NC_mode == 0x0200)  
     391              Printf ("%s file format: CDF-2 (large file)\n", specp->name); 
     392            else Printf ("%s file format: CDF-1\n", specp->name); 
     393    } else { 
     394 
    383395    Printf ("netcdf %s {\n", specp->name); 
     396 
     397    if (NC_mode == 0x1000)  
     398       Printf ("// file format: CDF-5 (big variables)\n"); 
     399    else if (NC_mode == 0x0200)  
     400           Printf ("// file format: CDF-2 (large file)\n"); 
     401         else Printf ("// file format: CDF-1\n"); 
    384402    /* 
    385403     * get number of dimensions, number of variables, number of global 
     
    514532        } 
    515533    } 
    516      
    517534    Printf ("}\n"); 
     535    } 
    518536    NC_CHECK( 
    519537        ncmpi_close(ncid) ); 
     
    631649          0,                    /* construct netcdf name from file name */ 
    632650          false,                /* print header info only, no data? */ 
     651          false,                /* print CDF version, no data, no header */ 
    633652          false,                /* just print coord vars? */ 
    634653          false,                /* brief  comments in data section? */ 
     
    649668    set_formats(FLT_DIGITS, DBL_DIGITS); /* default for float, double data */ 
    650669 
    651     while ((c = getopt(argc, argv, "b:cf:hl:n:v:d:p:")) != EOF) 
     670    while ((c = getopt(argc, argv, "b:cf:hVl:n:v:d:p:")) != EOF) 
    652671      switch(c) { 
    653672        case 'h':               /* dump header only, no data */ 
    654673          fspec.header_only = true; 
     674          break; 
     675        case 'V':               /* dump CDF version, no data, no header */ 
     676          fspec.version = true; 
    655677          break; 
    656678        case 'c':               /* header, data only for coordinate dims */ 
     
    720742    do {                 
    721743        if (!nameopt) fspec.name = (char *)0; 
    722         if (argc > 0) 
     744        if (argc > 0){ 
    723745          do_ncdump(argv[i], &fspec); 
     746        } 
    724747    } while (++i < argc); 
    725748 
  • trunk/src/utils/ncdump/ncdump.h

    r560 r673  
    5252    boolean header_only;        /* if true, don't print any variable data */ 
    5353 
     54    boolean version;           /* if true, print version*/ 
     55 
    5456    boolean coord_vals;         /* if true, print header and coordinate 
    5557                                 * dimension values (values of variables