@Override
    public Nc4DSP
    open(String filepath)
            throws DapException
    {
        if(filepath.startsWith("file:")) try {
            XURI xuri = new XURI(filepath);
            filepath = xuri.getPath();
        } catch (URISyntaxException use) {
            throw new DapException("Malformed filepath: " + filepath)
                    .setCode(DapCodes.SC_NOT_FOUND);
        }
        int ret, mode;
        IntByReference ncidp = new IntByReference();
        this.filepath = filepath;
        try {
            mode = NC_NOWRITE;
            Nc4Cursor.errcheck(nc4, ret = nc4.nc_open(this.filepath, mode, ncidp));
            this.ncid = ncidp.getValue();
            // Figure out what kind of file
            IntByReference formatp = new IntByReference();
            Nc4Cursor.errcheck(nc4, ret = nc4.nc_inq_format(ncid, formatp));
            this.format = formatp.getValue();
            if(DEBUG)
                System.out.printf("TestNetcdf: open: %s; ncid=%d; format=%d%n",
                        this.filepath, ncid, this.format);
            // Compile the DMR
            Nc4DMRCompiler dmrcompiler = new Nc4DMRCompiler(this, ncid, dmrfactory);
            setDMR(dmrcompiler.compile());
            if(DEBUG || DUMPDMR) {
                System.err.println("+++++++++++++++++++++");
                System.err.println(printDMR(getDMR()));
                System.err.println("+++++++++++++++++++++");
            }
            return this;
        } catch (Exception t) {
            t.printStackTrace();
        }
        return null;
    }
@ Override public Nc4DSP open ( String filepath ) throws DapException { if ( filepath . startsWith ( "file:" ) ) try { XURI xuri = new XURI ( filepath ) ; filepath = xuri . getPath ( ) ; } catch ( URISyntaxException use ) { throw new DapException ( "Malformed filepath: " + filepath ) . setCode ( DapCodes . SC_NOT_FOUND ) ; } int ret , mode ; IntByReference ncidp = new IntByReference ( ) ; this . filepath = filepath ; try { mode = NC_NOWRITE ; Nc4Cursor . errcheck ( nc4 , ret = nc4 . nc_open ( this . filepath , mode , ncidp ) ) ; this . ncid = ncidp . getValue ( ) ; IntByReference formatp = new IntByReference ( ) ; Nc4Cursor . errcheck ( nc4 , ret = nc4 . nc_inq_format ( ncid , formatp ) ) ; this . format = formatp . getValue ( ) ; if ( DEBUG ) System . out . printf ( "TestNetcdf: open: %s; ncid=%d; format=%d%n" , this . filepath , ncid , this . format ) ; Nc4DMRCompiler dmrcompiler = new Nc4DMRCompiler ( this , ncid , dmrfactory ) ; setDMR ( dmrcompiler . compile ( ) ) ; if ( DEBUG || DUMPDMR ) { System . err . println ( "+++++++++++++++++++++" ) ; System . err . println ( printDMR ( getDMR ( ) ) ) ; System . err . println ( "+++++++++++++++++++++" ) ; } return this ; } catch ( Exception t ) { t . printStackTrace ( ) ; } return null ; }
DSP API