Re: Error in exporting Text to netcdf


>Date: Fri, 14 Jan 2000 10:58:08 -0600
>From: "Peter X. Cao" <xcao@xxxxxxxxxxxxx>
>To: visad-list@xxxxxxxxxxxxx
>Subject: Error in exporting Text to netcdf

In the above message, you wrote:

> Saving Text into netcdf from visad Spreadsheet gives me the following error,
> java.lang.IllegalArgumentException: Not an Array
>         at ucar.netcdf.Attribute.<init>(

I found the problem and fixed it (at least it now passes my little

The correction has been promulgated to the VisAD code.  It will take a
little while before that change becomes generally available, however.

In the meantime, I've enclosed the corrected version of the file
visad/data/netcdf/out/  I suggest that you compile
this file and make it available to your Java environment IN PREFERENCE
TO the corresponding class file in your current visad.jar file.

Please keep me apprised.

Steve Emmerson   <>

--------Begin visad/data/netcdf/out/
 * Copyright 1998, University Corporation for Atmospheric Research
 * All Rights Reserved.
 * See file LICENSE for copying and redistribution conditions.
 * $Id:,v 1.3 2000/01/18 18:56:14 steve Exp $


import ucar.netcdf.Attribute;
import visad.ScalarType;
import visad.Text;

 * The DependentTextVar class adapts textual data in a VisAD data object to
 * a netCDF, dependent-variable, API for the purpose of exporting the data.
 * in an adapted VisAD data object.
    extends     DependentVar
     * The fill-value object.
    private final Character     fillValue;

     * Construct.
     * @param text      The VisAD Text object to be adapted.
     * @param accessor  The means for accessing the individual VisAD
     *                  <code>Text</code> objects of the enclosing
     *                  VisAD data object.
     * @exception BadFormException
     *                  The VisAD data object cannot be adapted to a netCDF API.
    DependentTextVar(Text text, VisADAccessor accessor)
        throws BadFormException
        super(((ScalarType)text.getType()).getName(), Character.TYPE,
            accessor.getDimensions(), myAttributes(), accessor);

        fillValue = getFillValue();

     * Get the netCDF attributes for a DependentTextVar.
     * @return  An array of netCDF Attributes for the variable.
    protected static Attribute[]
        return new Attribute[]
            {new Attribute(
                new String(new char[] {getFillValue().charValue()}))};

     * Return the fill-value.
     * @return  The netCDF fill-value for netCDF character variables.
    protected static Character
        return new Character('\000');

     * Return a netCDF datum identified by position.
     * @param indexes   The netCDF indexes of the desired datum.  Includes all
     *                  adapted dimensions -- including those of all enclosing
     *                  VisAD data objects.
     * @return          A Java Character that contains the data value or the
     *                  appropriate netCDF fill-value if the data is missing.
    public Object
    get(int[] indexes)
        throws IOException
            return getAccessor().get(indexes);
        catch (StringIndexOutOfBoundsException e)
            return fillValue;