Example 02 — Read & Inspect Metadata
Reads a 3D spectral dataset and displays all structure fields.
Source Code
program main
use fpl
implicit none
type(nc3d_float_lld_td) :: spectral
character(100) :: inputpath, outputpath
inputpath = "database/test_echam_spectral.nc"
outputpath = "database/spectral.nc"
spectral%varname = "albedo_nir"
spectral%timename = "time"
spectral%lonname = "lon"
spectral%latname = "lat"
call readgrid(inputpath, spectral)
write(*,*) "====== Dataset Information ======="
write(*,'(a13,a25)') "varname : ", spectral%varname
write(*,'(a13,a25)') "timename : ", spectral%timename
write(*,'(a13,a25)') "latname : ", spectral%latname
write(*,'(a13,a25)') "lonname : ", spectral%lonname
write(*,'(a13,a25)') "long_name : ", spectral%long_name
write(*,'(a13,a25)') "varunits : ", spectral%varunits
write(*,'(a13,i4)') "nlons : ", spectral%nlons
write(*,'(a13,i4)') "nlats : ", spectral%nlats
write(*,'(a13,i4)') "ntimes : ", spectral%ntimes
write(*,'(a13,f10.4)')"FillValue : ", spectral%FillValue
call writegrid(outputpath, spectral)
call dealloc(spectral)
end program main
Compile & Run
gfortran -o ex2.out ex2_getinfo.f90 -I/usr/lib64/gfortran/modules/ -lFPL
./ex2.out
Output
====== Dataset Information =======
==================================
Grid 4d info =================================
varname : albedo_nir
timename : time
latname : lat
lonname : lon
long_name : surface albedo NIR range
varunits :
timeunits : year
lonunits : degrees_east
latunits : degrees_north
dimname() : time lat lon
dimunits() : year degrees_north degrees_east
nlons : 192
nlats : 96
ntimes : 8
ndims : 3
vartype : 5
dimid() : 1 2 3
dimsize() : 8 96 192
varids() : 97 57 58
dims() : 3 2 1
FillValue : 0.0000