[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #DZA-901582]: Reading a character variable from a netcdf file



> Hi,
> I want to read a character variable (Times) from a netcdf file. The
> sample of the netcdf file is given below. I am also attaching the part
> of the program to do this job. But, at the execution time, following
> error is coming.
> Also I need to put that character value in another netcdf file.
> Please help me in this regard.
>
> Thanks
> Sujata
>
> SAMPLE:
>
> netcdf wrfinput_d01_arw {
> dimensions:
> Time = UNLIMITED ; // (1 currently)
> DateStrLen = 19 ;
> west_east = 697 ;
> south_north = 429 ;
> bottom_top = 50 ;
> bottom_top_stag = 51 ;
> soil_layers_stag = 5 ;
> west_east_stag = 698 ;
> south_north_stag = 430 ;
> land_cat_stag = 24 ;
> soil_cat_stag = 16 ;
> variables:
> char Times(Time, DateStrLen) ;
>
> PROGRAM:
> sttime = '2007-10-15_00:00:00'
> !-----Reading the character value from a netcdf file---------------
> ncid  = ncopn(input_file, NCNOWRIT, rcode)
> tcid  = ncvid(ncid, 'Times', rcode)
> call ncvgtc(ncid, tcid, 'sttime',19, rcode)
> print*,' TIME is', sttime
> call ncclos(ncid, rcode)
> !------------------------------------------------------------------
>
> AT EXECUTION TIME:
> NCVGTC: : Index exceeds dimension bound
>
>

Howdy Sujata!

Your arguments for ncvgtc are incorrect. As you can see from the documentation
(http://www.unidata.ucar.edu/software/netcdf/guide_9.html#SEC65) there are
seven arguments for this function.

I suggest that you want something like:

integer start(1), count(1)

start(1) = 1
count(1) = 1
call ncvgtc(ncid, tcid, start, count, sttime, 19, rcode)

I confess that I have not tried this.

Have you considered moving from the v2 api to the v3 api? You might find it
helpful (but it makes no difference with respect to your current question.)

Please let me know if this doesn't help.

Thanks,

Ed

Ticket Details
===================
Ticket ID: DZA-901582
Department: Support netCDF
Priority: Normal
Status: Closed