function TRMM_3B42(args)
say
say '-------------------------------------'
say 'starting GrADS script TRMM_3B42.gs...'
say '-------------------------------------'
say
*
*  references:
*   /home/cjs/fms.ana/GAMDT/intensity/work/regrid.write/fwrite/TRMM_3B42.gs
*   http://grads.iges.org/grads/gadoc/gradcomdsdfwrite.html
*   http://grads.iges.org/grads/gadoc/gradcomdsetsdfwrite.html
*
'reinit'
*
*  assign GrADS script input arguments to local variables
*
*  TRMM input netCDF file parameters:
*
TRMM_ifile       = subwrd(args,1)  ;* filename path
TRMM_ifile_undef = subwrd(args,2)  ;* _FillValue
GrADS_yy         = subwrd(args,3)  ;* year for GrADS ddf
GrADS_month      = subwrd(args,4)  ;* month for GrADS ddf
GrADS_dd         = subwrd(args,5)  ;* day for GrADS ddf
GrADS_hh         = subwrd(args,6)  ;* hour for GrADS ddf
*
*  TRMM output netCDF file parameters:
*
TRMM_ofile       = subwrd(args,7)  ;* filename
TRMM_ofile_nlon  = subwrd(args,8)  ;* number of regrid longitudes
TRMM_ofile_lon1  = subwrd(args,9)  ;* starting regrid longitude
TRMM_ofile_dlon  = subwrd(args,10) ;* regrid longitude spacing
TRMM_ofile_nlat  = subwrd(args,11) ;* number of regrid latitudes
TRMM_ofile_lat1  = subwrd(args,12) ;* starting regrid latitude
TRMM_ofile_dlat  = subwrd(args,13) ;* regrid latitude spacing
*
*  input netCDF file
*
say
say 'TRMM_ifile: 'TRMM_ifile
say
*
*  make coordinates 4D; reference:
*  http://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html#Coordinate%20Systems
*
*  make a GrADS "xdfopen" descriptor file for input netCDF file to define
*  the "z" and "t" axes following advice of Jennifer Adams in her 3/30/10
*  email replies to my posts to the GrADS Users Forum...
*
TRMM_ddf = 'TRMM_3B42.xdf'
*
*  define GrADS descriptor file time level
*
GrADS_t0 = ''GrADS_hh'Z'GrADS_dd''GrADS_month''GrADS_yy''
say 'GrADS_t0 = 'GrADS_t0
*
*  reference: use of "lon" as a dummy "zdef" and "tdef" dimension axis name
*             follows advice of Jennifer Adams 3/30/10 email reply to my question
*
'!rm -f 'TRMM_ddf
res = write (''TRMM_ddf'','dset 'TRMM_ifile'')
res = write (''TRMM_ddf'','zdef lon 1 levels 0')
res = write (''TRMM_ddf'','tdef lon 1 linear 'GrADS_t0' 1mn') ;* use smallest "dt" available...
res = close (''TRMM_ddf'')
status = sublin(res,1)
if( status != 0 )
  say
  say '"'TRMM_ddf'" status number = 'status
  say 'exiting script...'
  say
  exit
endif
'xdfopen 'TRMM_ddf
'q ctlinfo'
say
say result
say
say 'define TRMM 3B42 domain using TRMM 3B42 dataset world lat/lon coordinates limits'
say 'regrid to model grid within TRMM 3B42 dataset world lat/lon coordinates limits'
say

'set lon 0.125 359.875'
'set lat -49.875 49.875'
'set z 1'
'set t 1'

'q dims'
say result
*
*  define local precipitation variable for regridding...
*
'precip = precipitation'
*
*  regrid locally-defined precipitation variable...
*  reference: http://opengrads.org/doc/udxt/re/re.html
*
nlon = TRMM_ofile_nlon ; lon1 = TRMM_ofile_lon1 ; dlon = TRMM_ofile_dlon
nlat = TRMM_ofile_nlat ; lat1 = TRMM_ofile_lat1 ; dlat = TRMM_ofile_dlat
*
regrid_function = 're(precip,'nlon','linear','lon1','dlon','nlat','linear','lat1','dlat','ba')'
say
say 'rprecip = 'regrid_function
say
'define rprecip = 'regrid_function
say
say 'sdfwrite local regridded precipitation variable "rprecip"...'
say
*  
*  http://grads.iges.org/grads/gadoc/gradcomdsetsdfwrite.html
*  http://grads.iges.org/grads/gadoc/gradcomdqsdfwrite.html
*  http://grads.iges.org/grads/gadoc/gradcomdsetsdfattr.html
*
'set sdfwrite -4d 'TRMM_ofile
'set sdfattr level String long_name height above surface'
'set sdfattr level String units m'
'set sdfattr rprecip double _FillValue 'TRMM_ifile_undef
'set sdfattr rprecip String long_name regridded precipitation'
'set sdfattr rprecip String definition 'regrid_function
'set sdfattr rprecip String units mm/h'
'set undef 'TRMM_ifile_undef ;* change from default -9.99e8 to use source netCDF file undef
'q dims'
say result
'q sdfwrite'
say result
'sdfwrite rprecip'
say
say '-------------------------------------'
say '...exiting GrADS script TRMM_3B42.gs'
say '-------------------------------------'
say

return
