program g5nr_reader_global use netcdf ! for reading the NR files implicit none ! File name ! --------- character(len=256) :: T_file ! 4D array: (lon,lat,lev,time) ! ---------------------------- real, allocatable :: T(:,:,:,:) ! global data ! Miscellaneous ! ------------- integer :: ierr integer :: im, jm, lm integer :: ncid, varid integer :: start(4), count(4) ! file name and dimensions ! ------------------------ T_file = "c1440_NR.inst01hr_3d_T_Cv.20060918_0900z.nc4" im = 720 jm = 361 lm = 72 ! Open file and get var id ! ------------------------ call check(nf90_open(T_file,NF90_NOWRITE,ncid), "opening T file") call check(nf90_inq_varid(ncid,"T",varid), "getting T varid") ! Read global temperature data ! ---------------------------- allocate(T(im,jm,lm,1)) ! global 4D array with 1 time level start = [1, 1, 1, 1] count = [im, jm, lm, 1] ! 1 time level, 3D (lon,lat,lev) array write(*,*) 'Reading global T...' call check(nf90_get_var(ncid,varid,T,start=start,count=count), "reading T") write(*,*)'T: ', maxval(T),minval(T) ! close file, release memory call check(nf90_close(ncid), "closing T file") deallocate(T) ! All done ! -------- contains subroutine check(status, loc) integer, intent(in) :: status character(len=*), intent(in) :: loc if(status /= NF90_NOERR) then write (*,*) "Error at ", loc write (*,*) NF90_STRERROR(status) end if end subroutine check end program g5nr_reader_global