Re: [netcdfgroup] NetCDF: Start+count exceeds dimension bound

Hello Dave,

Thanks for the rapid response.

I'm on pc with the ubuntu 9.10 and the netCDF 4.0.1, downloaded from the
netCDF page.

Change the kind of variable doesn't seem to help, because i have already
tried with a lot of different types.

Together with this mail i send 3 files, the program, the input and the
output, the .nc file.

Thanks for everything,
Ricardo Torres




>Ricardo,
>
>I do not see the problem right off.  In this statement:

>   real(KIND=8) , allocatable:: data_out(:,:,:)


>Try using "double precision" instead of real(KIND=8). I am not an expert
>on kind parameters, but I think using a straight integer 8 is compiler
>dependent and can lead to trouble.

>If that doesn't work, then please show the output from "ncdump
>netCDFyxz.nc" after the program halts, and we can take a closer look.

>What platform and version of Netcdf are you using?

>Dave Allured
>CU/CIRES Climate Diagnostics Center (CDC)
>http://cires.colorado.edu/science/centers/cdc/
>NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
>http://www.esrl.noaa.gov/psd/psd1/

Attachment: netCDFyxz.nc
Description: Cdf file

9       5       9   
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.64
4.66
4.69
4.71
4.74
4.77
4.80
4.83
4.86
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.66
4.68
4.71
4.74
4.76
4.79
4.83
4.86
4.89
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.68
4.70
4.73
4.76
4.79
4.82
4.85
4.89
4.92
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.71
4.73
4.76
4.79
4.82
4.85
4.88
4.92
4.95
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.73
4.75
4.78
4.81
4.85
4.88
4.91
4.95
4.98
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.75
4.78
4.81
4.84
4.87
4.90
4.93
4.96
5.00
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.77
4.80
4.83
4.85
4.88
4.91
4.94
4.98
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.79
4.81
4.84
4.86
4.89
4.93
4.96
5.00
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
1.50
4.80
4.82
4.84
4.87
4.90
4.94
4.97
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
5.75
Program transf_netCDF
use netcdf
Implicit None 

 ! This is the name of the data file we will create.
 Character (len = *), parameter :: FILE_NAME = "netCDFyxz.nc"
 
 ! We are writing 4D data
 integer, parameter :: NDIMS = 3
 
 
 ! When we create netCDF files, variables and dimensions, we get back
 ! an ID for each one.
 integer :: ncid, varid, dimids(NDIMS)
 integer :: x_dimid, y_dimid, z_dimid
  
 !Integer, parameter :: ni=3 , nj=3 , nk=3
  
 ! This is the data array we will write. It will just be filled with
 ! a progression of integers for this example.
 real , allocatable:: data_out(:,:,:)
 
 
 Integer :: i ,j ,k ,a
 Integer :: ni, nj, nk
 Real :: v 
 Character :: vfile3d 
 integer:: error


open(50,file="vfile.p",status="old")    !Aqui terá de ser alterado o nome do 
ficheiro a ser lido

read(50,*) ni ,nj ,nk


ALLOCATE ( data_out(ni,nj,nk) , stat=error )


  if (error /= 0) then 
     print*, "Nao foi possivel alocar o espaço para o array"
     stop
  end if

!data_out = (/ ni, nj, nk /)

!Print*, "ni,nk,nj - numero de pontos nas direcções y (S-N), x (O-E) e Z 
(vertical)" 
! i->y / k->x / j->z
!read(*,*) ni ,nk ,nj


      do i=1, ni
            do j=1, nj
                  do k=1, nk
                        
                        read(50,*) v
                        print*, v
                        data_out(i,j,k)= (v) 
                        print*, data_out.
                  end do
            end do
      end do



  ! Create the netCDF file. The nf90_clobber parameter tells netCDF to
  ! overwrite this file, if it already exists.
  a=1
  call check( nf90_create(FILE_NAME, NF90_CLOBBER, ncid) )

  ! Define the dimensions. NetCDF will hand back an ID for each. 
  a=2
  call check( nf90_def_dim(ncid, "x", nk, x_dimid) )
  a=3
  call check( nf90_def_dim(ncid, "y", ni, y_dimid) )
  a=4
  call check( nf90_def_dim(ncid, "z", nj, z_dimid) )

  ! The dimids array is used to pass the IDs of the dimensions of
  ! the variables. Note that in fortran arrays are stored in
  ! column-major format.
  dimids =  (/ x_dimid, y_dimid , z_dimid /)

  ! Define the variable. The type of the variable in this case is
  ! NF90_INT (4-byte integer).
  a=5
  call check( nf90_def_var(ncid, "data", NF90_double, dimids, varid) )

  ! End define mode. This tells netCDF we are done defining metadata.
  a=6
  call check( nf90_enddef(ncid) )
  

  ! Write the pretend data to the file. Although netCDF supports
  ! reading and writing subsets of data, in this case we write all the
  ! data in one operation.
  a=7
  call check( nf90_put_var(ncid, varid, data_out) )

  ! Close the file. This frees up any internal netCDF resources
  ! associated with the file, and flushes any buffers.
  a=8
  call check( nf90_close(ncid) )

  print *, "*** SUCCESS writing example file netCDFyxz.nc! "
  
deallocate(data_out)

contains
  subroutine check(status)
    integer, intent ( in) :: status
    
    if(status /= nf90_noerr) then 
      print*, a
      print *, trim(nf90_strerror(status))
      stop "Stopped"
    end if
  end subroutine check  
  
end program transf_netCDF
  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: