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

[netCDF #KZD-970215]: [netcdfgroup] f77 interface oddity



Hi Harry,
 
> I use the Fortran-77 library to access NetCDF files. don't ask me why
> - I must have done something bad in a previous life.
> 
> Anyway, I'm currently working with GCM data from CERA, in particular
> the new ENSEMBLES E1 stabilization runs.
> 
> All working fine, until I get to the HadGEM2 runs:
> 
> 1. Program asks for the variable ID for 'lat' - gets '3'.
> 
> 2. Program asks for the data from variable '3' - gets data for
> time_bnds!
> 
> If I do an ncdump, lat is the FOURTH variable. But the first is
> 'height', which is scalar. Output from 'ncdump -h follows.
> 
> Is the F77 library ignoring scalar variables? Program working fine
> for all other models.

I can't reproduce the problem you are seeing.  When I create the netCDF
file using ncgen and your CDL output, then run ncdump on the result, it
shows everything is read correctly.  A little program to print the variable
ID for 'lat' returns 4, as it should:

      program kzd
      implicit none
      include 'netcdf.inc'

      character*(*) FILE_NAME
      parameter (FILE_NAME='HADGEM2_E1_1_MM_pr_1-1201.nc')

      integer ncid, varid, retval

      retval = nf_open(FILE_NAME, NF_NOWRITE, ncid)
      if (retval .ne. nf_noerr) call handle_err(retval)

      retval = nf_inq_varid(ncid, 'lat', varid)
      if (retval .ne. nf_noerr) call handle_err(retval)

      print *, 'lat id = ', varid

      retval = nf_close(ncid)
      if (retval .ne. nf_noerr) call handle_err(retval)

      end

      subroutine handle_err(errcode)
      implicit none
      include 'netcdf.inc'
      integer errcode

      print *, 'Error: ', nf_strerror(errcode)
      stop 2
      end

--Russ


> Harry
> Ian "Harry" Harris
> Climatic Research Unit
> School of Environmental Sciences
> University of East Anglia
> Norwich NR4 7TJ
> United Kingdom
> 
> ncdump -h HADGEM2_E1_1_MM_pr_1-1201.nc
> netcdf HADGEM2_E1_1_MM_pr_1-1201 {
> dimensions:
> time = UNLIMITED ; // (1201 currently)
> bound = 2 ;
> lat = 145 ;
> lon = 192 ;
> variables:
> float height ;
> height:missing_value = 1.e+20f ;
> height:name = "height" ;
> height:positive = "up" ;
> height:long_name = "height" ;
> height:standard_name = "height" ;
> height:units = "m" ;
> height:axis = "Z" ;
> float time(time) ;
> time:bounds = "time_bnds" ;
> time:long_name = "Time" ;
> time:standard_name = "time" ;
> time:units = "days since 1970-01-01 00:00:00" ;
> time:calendar = "360_day" ;
> time:axis = "T" ;
> float time_bnds(time, bound) ;
> float lat(lat) ;
> lat:bounds = "lat_bnds" ;
> lat:point_spacing = "even" ;
> lat:long_name = "Latitude" ;
> lat:standard_name = "latitude" ;
> lat:units = "degrees_north" ;
> lat:axis = "Y" ;
> float lat_bnds(lat, bound) ;
> float lon(lon) ;
> lon:bounds = "lon_bnds" ;
> lon:point_spacing = "even" ;
> lon:long_name = "Longitude" ;
> lon:standard_name = "longitude" ;
> lon:axis = "X" ;
> lon:units = "degrees_east" ;
> lon:modulo = 360.f ;
> lon:topology = "circular" ;
> float lon_bnds(lon, bound) ;
> float pr(time, lat, lon) ;
> pr:comment = "Small negative data values generated
> by the model are reset to zero" ;
> pr:long_name = "Precipitation [time:mean; Mean over
> one month sampling all time steps.]" ;
> pr:standard_name = "precipitation_flux" ;
> pr:missing_value = -1.073742e+09f ;
> pr:coordinates = "height" ;
> pr:units = "kg m-2 s-1" ;
> pr:stash_section = 5 ;
> pr:stash_item = 216 ;
> pr:stash_model = 1 ;
> pr:cell_methods = "time:mean" ;
> pr:name = "Precipitation" ;
> pr:lookup_source = "defaults (cdunifpp V0.11)" ;
> pr:stash_mapping = "m01s05i216" ;
> 
> // global attributes:
> :Conventions = "CF-1.0" ;
> :mean_type = "Mean over one month sampling all time
> steps." ;
> :title = "ENSEMBLES Stream Two:ense1_1:mm" ;
> :institution = "Met Office Hadley Centre" ;
> :source = "HadGEM2AO" ;
> :contact = "Tim Johns:address@hidden" ;
> :history = "Thu Feb 26 08:36:10 2009: /usr/local/
> badc/linux/suse10/nco/bin/ncrcat
> METO_HadGEM2AO_ense1_1_mm_pr_199912010000-200912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_200912010000-201912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_201912010000-202912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_202912010000-203912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_203912010000-204912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_204912010000-205912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_205912010000-206912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_206912010000-207912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_207912010000-208912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_208912010000-209912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr_209912010000-210912010000.nc
> METO_HadGEM2AO_ense1_1_mm_pr.nc\n",
> "Exported from MetO MaitreD/MASS data
> archive to BADC in native PP format: Converted to netCDF at BADC
> using BADC HadGEM Virtual Variable Suite version 0.2.1" ;
> :comment = "Start from a point (Dec 1 1999) taken
> from the end of the 20c3m_1 experiment and run to the end of the 21st
> century. Anthropogenic forcings were changed through the run to
> reflect the ENSEMBLES E1 scenario, i.e. changes in: CO2, CH4, N2O,
> CFC11*, CFC12, Ozone, Vegetation Distribution, Sulphur-cycle
> Emissions, Soot Emissions, Biomass Emissions. No variations in solar
> radiation and volcanic aerosols. (In this experiment CFC11* or
> equivalent-CFC11 is used to represent other halocarbon gases apart
> from CFC12)." ;
> :references = "Collins et al. 2008, Hadley Centre
> Technical Note no. 74: Bellouin et al. 2007, Hadley Centre Technical
> Note no. 73: Johns et al. 2006, J. Climate, 19(7), 1327-1353: Martin
> et al. 2006, J. Climate, 19(7), 1274-1301: Ringer et al. 2006, J.
> Climate, 19(7), 1302-1326: Stott et al. 2006, J. Climate, 19(12),
> 2763-2782: Royer et al. 2008, Report No: D2A.0.4; Project: GOCE-
> CT-2003-505539: Lowe et al. 2008, Submitted to EOS: McLaren et al.
> 2006, J. Geophys. Res., 111, C12014" ;
> :nco_openmp_thread_number = 1 ;
> }
> 
> _______________________________________________
> netcdfgroup mailing list
> address@hidden
> For list information or to unsubscribe,  visit: 
> http://www.unidata.ucar.edu/mailing_lists/
> 
> 

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: KZD-970215
Department: Support netCDF
Priority: Normal
Status: Closed