#!/usr/bin/perl -w
#
use File::Copy;
use Time::Local;


BEGIN
  {
  $ENV{LD_LIBRARY_PATH}="LD_LIBRARY_PATH:/data/starfs1/libs/netcdf-4.2/lib:/data/starfs1/libs/hdf5-1.8.7/lib";
  #$ENV{LD_LIBRARY_PATH}="LD_LIBRARY_PATH:/data/starfs1/libs/netcdf-4.7.0/lib:/data/starfs1/libs/hdf5-1.10.6/lib";
  }

$source_dir      = "/data/data065/nprovs/gas/ozone/OzoneCollocationFileBuilder";
$work_dir        = "/data/data065/nprovs/gas/ozone/OzoneCollocationFileBuilder";
$collocation_dir = "/data/data599/gas/ozone/collocations";

# If the collocation directory does not exist

# This script copies data from multiple GOES ABI netCDF files into an GDDF

#print "\n\nProcessing the GOES data\n\n";

chdir($work_dir);




# Date range

$first_date = 20230803;
$last_date  = 20230803;
#$first_date = 20230508;
#$last_date  = 20230508;

$output_file = sprintf("/data/data065/nprovs/gas/ozone/OzoneCollocationFileBuilder/ozone_collocations.nc");

unlink $output_file;

symlink $collocation_dir, "in.dir" or warn "Cannot link $collocation_dir to in.dir";
symlink $output_file, "out.file", or warn "Cannot link $output_file to out.file";

system $source_dir . "/OzoneCollocationFileBuilder.x " . $first_date . " " . $last_date;

unlink "out.file" or warn "Cannot unlink out.file";
unlink "in.dir" or warn "Cannot unlink in.dir";


# end of file
