#!/bin/tcsh

#  script for generating a climatological chlorophyll field for the 0.1 tripole
#    grid from SeaWiFS 4096x2048 monthly average data.
#    written by Mathew Maltrud, LANL, April 18, 2008.

#  first, convert the netcdf file to double precision direct access binary

./cdf_to_bin << eod > out1
4096,2048,12
Chlor1998-2003avg_01-12.nc
Chlor1998-2003avg_01-12.r8
CHLOR
0
0
eod

#  next, extend the field into missing points to account for differing
#    coastlines between data and model grids.  we don't want to do too many
#    iterations on the laplacian smoother since missing points aren't
#    just land, but also places where there shouldn't be any chlorophyll.

@ num_iters = 20
set out_file = Chlor1998-2003avg_01-12.extended_$num_iters'iters.r8'

./extend_3d_field << eod > out2
4096,2048,12
Chlor1998-2003avg_01-12.r8
$out_file
0.
$num_iters
eod


#  finally, do the conservative mapping to the model grid

set in_file = $out_file

./interp_3d_scalar << eod > out3
$in_file
Chlor1998-2003avg_01-12.0.1_tripole.r8
rmp_SeaWiFS_to_0.1tripoleT.nc
12
eod
