c MAIN.F - NSIDC DATA
c NOTE: dr = arctic OUTPUT data
c dg = NSIDC INPUT data
c km = 12 months:: DATA put into tracer1 in snapshot
c user has to set ig/jg
c user has to set nyr: number of years to be interpolated
c snapshot contains data from FINAL year read into dr array
c (IE: only ONE snapshot made, but all interp. data is
c written to file called dd.dta, which can be used
c for further processing at a later date.)
c
parameter(ig=80,jg=58) ! dimensions of NSIDC grid
parameter(ir=91,jr=67,m=12,nyr=46)
c
real xlon(ig,jg),xlat(ig,jg)
real xt(ir),yt(jr),zt(m)
real dg(ig,jg,m,nyr), dr(ir,jr,m,nyr),temp(ir,jr,m)
integer kmtg(ig,jg), kmtr(ir,jr)
c USER definitions
pi = 4.*atan(1.)
phir = pi/4.
thetar = -pi/2.
psir = -pi/2.
cell=111.1774734
c
c METHOD of Interpolation:
c if method = 1, use gaussian interp
c if method = 2, use witch interp
c if method = 3, use nearest neighbor interp
c
method =2
radius = 0.5
c
c TO CHANGE YEAR(s) TO BE READ BY GDATA.F,
c YOU MUST MODIFY nskip PARAMETER
c SKIP 1901 TO 1948, INCLUSIVE
nskip = 48
c Number of years to be interpolated is determined
c by PARAMETER NYR
c
c get GEOGRAPHICAL data (NSIDC)
call gdata(dg,xlon,xlat,kmtg,ig,jg,m,nskip,nyr)
write(*,*) 'GDATA'
c get ROTATED data (arctic model)
call rdata(xt,yt,zt,kmtr,ir,jr,m)
write(*,*) 'RDATA'
c DO INTERPOLATION for ALL MONTHS AT ONCE
call intp(dg,xlon,xlat,ig,jg,
> dr,xt,yt,ir,jr,phir,thetar,
> psir,kmtg,kmtr,m,nyr,method,radius)
write(*,*) 'IDATA'
c
c A data file will be written which includes all interpolated
c data values for the years specified above.
open(22,file='nsidc_w.R150',form='unformatted')
do n=1,nyr
iyr = 1900+n+nskip
do i=1,ir
do j=1,jr
do k=1,m
temp(i,j,k) = dr(i,j,k,n)
enddo
enddo
enddo
write(22) iyr, temp
enddo
close(22)
end