G5NR Data Access Guide: Difference between revisions
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
===== Fortran ===== | ===== Fortran ===== | ||
This is a simple program to read the field 'T' (air temperature) from collection http://opendap.nccs.nasa.gov:9090/dods/OSSE/GEOS-5.12/BETA9/0.5000_deg/inst/inst01hr_3d_T_Cv and compute its minimum and maximum. | |||
<code> | |||
program g5nr_reader | |||
use netcdf ! for reading the NR files | |||
implicit none | |||
! File names | |||
! ---------- | |||
character(len=256) :: T_file | |||
! Global, 4D arrays: (lon,lat,lev,time) | |||
! ------------------------------------- | |||
real, pointer :: T(:,:,:,:) => null() | |||
! Miscellaneous | |||
! ------------- | |||
integer :: ierr | |||
integer :: im, jm, lm | |||
integer :: ncid, varid | |||
integer :: start(4), count(4) | |||
! For now hard code file names and dimensions | |||
! ------------------------------------------- | |||
im = 720 | |||
jm = 361 | |||
lm = 72 | |||
T_file = "http://opendap.nccs.nasa.gov:9090/dods/OSSE/GEOS-5.12/BETA9/0.5000_deg/inst/inst01hr_3d_T_Cv" | |||
! Allocate the Global 4-D arrays with only 1 time level | |||
! ----------------------------------------------------- | |||
allocate(T(im,jm,lm,1)) | |||
! Hypercube for reading one 1 array for a given time | |||
! ------------------------------------------------- | |||
start = (/ 1, 1, 1, 37 /) ! time level 37 | |||
count = (/ im, jm, lm, 1 /) ! 1 time level, 3D (lon,lat,lev) array | |||
! Read the data file | |||
! ------------------ | |||
write(*,*)'Reading T' | |||
call check( nf90_open(T_file,NF90_NOWRITE,ncid), "opening T file") | |||
call check( nf90_inq_varid(ncid,"t",varid), "getting T varid") | |||
call check( nf90_get_var(ncid,varid,T,start=start,count=count), "reading T") | |||
call check( nf90_close(ncid), "closing T file") | |||
! Orint min/max of arrays | |||
! ----------------------- | |||
write(*,*)'T: ', maxval(T),minval(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 | |||
</code> | |||
===== Shmem example ===== | ===== Shmem example ===== |
Revision as of 08:14, 16 October 2014
Background
File spec
Model config
Getting data
ftp, http
Download tool
opendap
Client access
Programming
C
Fortran
This is a simple program to read the field 'T' (air temperature) from collection http://opendap.nccs.nasa.gov:9090/dods/OSSE/GEOS-5.12/BETA9/0.5000_deg/inst/inst01hr_3d_T_Cv and compute its minimum and maximum.
program g5nr_reader
use netcdf ! for reading the NR files
implicit none
! File names
! ----------
character(len=256) :: T_file
! Global, 4D arrays: (lon,lat,lev,time)
! -------------------------------------
real, pointer :: T(:,:,:,:) => null()
! Miscellaneous
! -------------
integer :: ierr
integer :: im, jm, lm
integer :: ncid, varid
integer :: start(4), count(4)
! For now hard code file names and dimensions
! -------------------------------------------
im = 720
jm = 361
lm = 72
T_file = "http://opendap.nccs.nasa.gov:9090/dods/OSSE/GEOS-5.12/BETA9/0.5000_deg/inst/inst01hr_3d_T_Cv"
! Allocate the Global 4-D arrays with only 1 time level
! -----------------------------------------------------
allocate(T(im,jm,lm,1))
! Hypercube for reading one 1 array for a given time
! -------------------------------------------------
start = (/ 1, 1, 1, 37 /) ! time level 37
count = (/ im, jm, lm, 1 /) ! 1 time level, 3D (lon,lat,lev) array
! Read the data file
! ------------------
write(*,*)'Reading T'
call check( nf90_open(T_file,NF90_NOWRITE,ncid), "opening T file")
call check( nf90_inq_varid(ncid,"t",varid), "getting T varid")
call check( nf90_get_var(ncid,varid,T,start=start,count=count), "reading T")
call check( nf90_close(ncid), "closing T file")
! Orint min/max of arrays
! -----------------------
write(*,*)'T: ', maxval(T),minval(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
Shmem example
Free clients
Python
NCL
IDV
IDV is an OPeNDAP tool that can access and display the nature run data. In our OPenDAP server, all files are time aggregated, so they appear as a single dataset for each location.
This is an example to open and display 'tlml' (surface air temperature) from the collection 'inst01hr_2d_met1_Cx'. The OPenDAP URL for this dataset is http://opendap.nccs.nasa.gov:80/dods/OSSE/GEOS-5.12/BETA9/0.5000_deg/inst/inst01hr_2d_met1_Cx. The following steps are valid for IDV version 5.0u1 running on a Linux desktop.
From the 'Dashboard' panel
- Select Data Choosers -> URLS.In the URL field, enter the above OPenDAP URL and click on 'Add Source'
- Select Field Selector and choose 'surface_air_temperature'. The 'Times' tab lists all the available timestamps for this data. At this point, one can select specific times and regions (subsetting) from the 'Times' and 'region' tabs. Click on 'Create Display'.