testEightByteGet.f90
Go to the documentation of this file.
program testeightbyteget
use typesizes
use netcdf
implicit none
! netcdf related variables
integer :: ncFileID, dimId, varId
! Local variables
integer, parameter :: numLats = 10
character (len = *), parameter :: fileName = "eightByteIntExample.nc"
integer :: counter
!integer(kind = FourByteInt), dimension(numLats) :: lats
integer(kind = EightByteInt), dimension(numLats) :: lats
! -----
call check(nf90_create(path = trim(filename), cmode = nf90_clobber, ncid = ncfileid))
! Define the dimensions
call check(nf90_def_dim(ncid = ncfileid, name = "lat", len = numlats, dimid = dimid))
! Define the variable
call check(nf90_def_var(ncfileid, "lat", nf90_int, dimids = dimid, varid = varid) )
! Leave define mode
call check(nf90_enddef(ncfileid))
! Write the variable
lats(:) = (/ (counter, counter = 1, numlats) /)
print *, lats
call check(nf90_put_var(ncfileid, varid, lats ))
call check(nf90_close(ncfileid))
! Now read it back in...
lats(:) = 0
call check(nf90_open(path = trim(filename), mode = nf90_nowrite, ncid = ncfileid))
call check(nf90_inq_varid(ncfileid, "lat", varid))
call check(nf90_get_var(ncfileid, varid, lats))
print *, lats
call check(nf90_close(ncfileid))
contains
! Internal subroutine - checks error status after each netcdf, prints out text message each time
! an error code is returned.
subroutine check(status)
integer, intent ( in) :: status
if(status /= nf90_noerr) then
print *, trim(nf90_strerror(status))
end if
end subroutine check
end program testeightbyteget
testeightbyteget
program testeightbyteget
Definition: testEightByteGet.f90:1
netcdf
Definition: netcdf.f90:36
nf90_get_var
Definition: netcdf_overloads.f90:62
check
subroutine check(status)
Definition: testEightByteGet.f90:43
nf90_enddef
integer function nf90_enddef(ncid, h_minfree, v_align, v_minfree, r_align)
Definition: netcdf_file.f90:74
nf90_create
integer function nf90_create(path, cmode, ncid, initialsize, chunksize)
Definition: netcdf3_file.f90:23
nf90_inq_varid
integer function nf90_inq_varid(ncid, name, varid)
Definition: netcdf4_variables.f90:245
typesizes
Definition: typeSizes.f90:30
nf90_def_dim
integer function nf90_def_dim(ncid, name, len, dimid)
Definition: netcdf_dims.f90:6
nf90_open
integer function nf90_open(path, mode, ncid, chunksize)
Definition: netcdf3_file.f90:9
nf90_strerror
character(len=80) function nf90_strerror(ncerr)
Definition: netcdf_file.f90:16
nf90_def_var
Definition: netcdf_overloads.f90:2
nf90_close
integer function nf90_close(ncid)
Definition: netcdf_file.f90:110
nf90_put_var
Definition: netcdf_overloads.f90:27

Return to the Main Unidata NetCDF page.