Skip to content
Snippets Groups Projects
Forked from Consortium Members / UKMO / GOSI / GOSI
377 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
fcm_internal 17.84 KiB
#!/usr/bin/env perl
#-------------------------------------------------------------------------------
# (C) Crown copyright Met Office. All rights reserved.
# For further details please refer to the file COPYRIGHT.txt
# which you should have received as part of this distribution.
#-------------------------------------------------------------------------------

use strict;
use warnings;

use Fcm::Timer qw{timestamp_command};

# Function declarations
sub catfile;
sub basename;
sub dirname;

# ------------------------------------------------------------------------------

# Module level variables
my %unusual_tool_name = ();

# ------------------------------------------------------------------------------

MAIN: {
  # Name of program
  my $this = basename $0;

  # Arguments
  my $subcommand = shift @ARGV;
  my ($function, $type) = split /:/, $subcommand; 

  my ($srcpackage, $src, $target, $requirepp, @objects, @blockdata);
  
  if ($function eq 'archive') {
    ($target, @objects) = @ARGV;

  } elsif ($function eq 'load') {
    ($srcpackage, $src, $target, @blockdata) = @ARGV;

  } else {
    ($srcpackage, $src, $target, $requirepp) = @ARGV;
  }

  # Set up hash reference for all the required information
  my %info = (
    SRCPACKAGE => $srcpackage,
    SRC        => $src,
    TYPE       => $type,
    TARGET     => $target,
    REQUIREPP  => $requirepp,
    OBJECTS    => \@objects,
    BLOCKDATA  => \@blockdata,
  );

  # Get list of unusual tools
  my $i = 0;
  while (my $label = &get_env ('FCM_UNUSUAL_TOOL_LABEL' . $i)) {
    my $value = &get_env ('FCM_UNUSUAL_TOOL_VALUE' . $i);
    $unusual_tool_name{$label} = $value;
    $i++;
  }

  # Invoke the action
  my $rc = 0;
  if ($function eq 'compile') {
    $rc = &compile (\%info);

  } elsif ($function eq 'load') {
    $rc = &load (\%info);