|
| 1 | +#!/usr/bin/env bash |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +# (C) Crown copyright Met Office. All rights reserved. |
| 4 | +# The file LICENCE, distributed with this code, contains details of the terms |
| 5 | +# under which the code may be used. |
| 6 | +# ----------------------------------------------------------------------------- |
| 7 | +# NAME |
| 8 | +# build_pp |
| 9 | +# |
| 10 | +# DESCRIPTION |
| 11 | +# Move PostProc application code to executable location within a rose suite |
| 12 | +# |
| 13 | +# ----------------------------------------------------------------------------- |
| 14 | + |
| 15 | +# Fail if environment variables are unset |
| 16 | +set -eu |
| 17 | + |
| 18 | +# Required environment |
| 19 | +PP_SOURCE_DIR=${PP_SOURCE_DIR:=$CYLC_WORKFLOW_RUN_DIR/share/source/moci_postproc} |
| 20 | +PP_TARGET_DIR=${PP_TARGET_DIR:-$CYLC_WORKFLOW_SHARE_DIR/bin} |
| 21 | + |
| 22 | +MOCILIB=${MOCILIB:=true} |
| 23 | +MOCILIB_PATH=${MOCILIB_PATH:=$CYLC_WORKFLOW_RUN_DIR/share/moci/mocilib} |
| 24 | + |
| 25 | +PP_COMPONENTS="atmos nemocice unicicles archive_verify" |
| 26 | +PP_TESTS=${PP_TESTS:=false} |
| 27 | + |
| 28 | +echo [INFO] Building PostProc application from $PP_SOURCE_DIR |
| 29 | +echo [INFO] -- Build location: $PP_TARGET_DIR |
| 30 | + |
| 31 | +if [[ ! -d $PP_SOURCE_DIR ]] ; then |
| 32 | + echo [ERROR] $PP_SOURCE_DIR does not exist >&2 |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | +if [[ ! -d $PP_TARGET_DIR ]] ; then |
| 36 | + echo [INFO] Creating build directory... |
| 37 | + mkdir -p $PP_TARGET_DIR |
| 38 | +fi |
| 39 | + |
| 40 | +# Copy mocilib |
| 41 | +if [[ "$MOCILIB" != true ]] ; then |
| 42 | + echo [INFO] MOCIlib library not installed |
| 43 | +elif [[ -d "$MOCILIB_PATH" ]] ; then |
| 44 | + cp -r $MOCILIB $PP_TARGET_DIR |
| 45 | +else |
| 46 | + echo [ERROR] Failed to find the required \"mocilib\" library >&2 |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | + |
| 50 | +# Copy NEMO tools |
| 51 | +if [[ -d "$PP_SOURCE_DIR/../nemotools" ]] ; then |
| 52 | + cp $PP_SOURCE_DIR/../nemotools/* $PP_TARGET_DIR |
| 53 | +else |
| 54 | + echo [INFO] NEMO iceberg rebuilding tools not available |
| 55 | +fi |
| 56 | + |
| 57 | +# Copy main_pp executable |
| 58 | +mainscr=$PP_SOURCE_DIR/Postprocessing/main_pp.py |
| 59 | +if [[ -f "$mainscr" ]] ; then |
| 60 | + cp $mainscr $PP_TARGET_DIR |
| 61 | +else |
| 62 | + echo [ERROR] Source for PostProc executable $mainscr does not exist >&2 |
| 63 | + exit 1 |
| 64 | +fi |
| 65 | + |
| 66 | +# Copy component directory contents |
| 67 | +src_dirs="common platforms $PP_COMPONENTS" |
| 68 | +if [[ "$PP_TESTS" = true ]] ; then |
| 69 | + src_dirs="$src_dirs unittests" |
| 70 | +fi |
| 71 | +for directory in $src_dirs; do |
| 72 | + if [[ -d $PP_SOURCE_DIR/Postprocessing/$directory ]] ; then |
| 73 | + cp $PP_SOURCE_DIR/Postprocessing/$directory/* $PP_TARGET_DIR |
| 74 | + else |
| 75 | + echo [ERROR] Source for PostProc component $directory does not exist >&2 |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +done |
0 commit comments