; set desired region to be 0'd latS = 0 latN = 10 lonW = 10 lonE = 30 system("/bin/rm -f wrfbiochemi_d03_ZERO.nc") ; remove any pre-existing file fout = addfile ("wrfbiochemi_d03_ZERO.nc" , "c") f = addfile ("wrfbiochemi_d03.nc" , "r") copy_VarAtts (f, fout) ; copy file attributes xlat2d = f->XLAT(0,:,:) xlon2d = d->XLONG(0,:,:) ji = region_ind (xlat2d,xlon2d, latS, latN, lonW, lonE) jStrt = ji(0) ; lat start jLast = ji(1) ; lat last iStrt = ji(2) ; lon start iLast = ji(3) ; lon las vNames = getfilevarnames (f) ; get names of all variables on file nNames = dimsizes (vNames) ; number of variables on the file print (vNames) ; print all variable names on file do n=0,nNames-1 ; loop thru each variable v := f->$vNames(n)$ ; read the varible to memory vdim := dimsizes(v) ; dimension size of the variable vrank= dimsizes(vdim) ; rank [ie: number of dimensions] if (vrank.ge.3.and.(vNames(n).ne."XLAT" .and. vNames(n).ne."XLONG")) then vtype = typeof(v) if (vtype.eq."integer") then if (vrank.eq.3) then v(:,jStrt:jLast,iStrt:iLast) = 0 else v(:,:,jStrt:jLast,iStrt:iLast) = 0 end if elseif (vtype.eq."float") then if (vrank.eq.3) then v(:,jStrt:jLast,iStrt:iLast) = 0.0 else v(:,:,jStrt:jLast,iStrt:iLast) = 0.0 end if elseif (vtype.eq."double") then if (vrank.eq.3) then v(:,jStrt:jLast,iStrt:iLast) = 0.0d0 else v(:,:,jStrt:jLast,iStrt:iLast) = 0.0 end if end if end if fout->$vNames(n)$ = v end do