source: branches/UKMO/r6232_tracer_advection/NEMOGCM/EXTERNAL/IOIPSL/tools/rebuild @ 9295

Last change on this file since 9295 was 9295, checked in by jcastill, 3 years ago

Remove svn keywords

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/ksh
2#
3#$Id: rebuild 2281 2010-10-15 14:21:13Z smasson $
4#
5# This software is governed by the CeCILL license
6# See IOIPSL/IOIPSL_License_CeCILL.txt
7#---------------------------------------------------------------------
8# @(#)Rebuild IOIPSL domains
9#---------------------------------------------------------------------
10function rebuild_Usage
11{
12print - "
13\"${b_n}\"
14  rebuild a model_file from several input files.
15Each input file contains the model_data for a domain.
16
17Usage :
18  ${b_n} [-h]
19  ${b_n} [-v level] [-f] -o output_file_name input_file_names
20
21Options :
22  -h         : help
23  -v O/1/2/3 : verbose mode (verbosity increasing with level)
24  -f         : executing mode
25               (execute the program even if the number of input files
26                is not equal to the total number of domains)
27"
28}
29#-
30#set -xv
31#-
32# Extract the calling sequence of the script (d_n/b_n)
33#-
34d_n=${0%/*}; b_n=${0##*/};
35#-
36# Retrieving the options
37#-
38r_v='0'; r_f='noforce'; r_o="";
39while getopts :hv:fo: V
40 do
41  case $V in
42   (h) rebuild_Usage; exit 0;;
43   (v) r_v=${OPTARG};;
44   (f) r_f='force';;
45   (o) r_o=${OPTARG};;
46   (:) print -u2 "${b_n} : missing value for option $OPTARG"; exit 2;;
47   (\?) print -u2 "${b_n} : option $OPTARG not supported"; exit 2;;
48  esac
49 done
50shift $(($OPTIND-1));
51#-
52# Validate the -v option
53#-
54case ${r_v} in
55  ( 0 | 1 | 2 | 3 );;
56  ("") r_v='0';;
57  (*)
58    print -u2 "${b_n} :";
59    print -u2 "Invalid verbosity level requested : ${r_v}";
60    print -u2 "(must be 0, 1, 2 or 3)";
61    exit 1;;
62esac
63#-
64# Validate the number of arguments
65#-
66[[ ${#} < 1 ]] && \
67 {
68  print -u2 "${b_n} : Too few arguments have been specified. (Use -h)";
69  exit 3;
70 }
71#-
72# Check for the output file name
73#-
74[[ -z ${r_o} ]] && \
75 {
76  r_o='rebuilt_file.nc';
77  print -u2 - "
78   ${b_n} : output_file_name not specified. (Use -h)
79            rebuilt_file.nc should be created."
80 }
81#-
82# Validate the names of the input files
83#-
84for i in $*;
85 do
86  [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;}
87 done
88#-
89# Create the information file for the program
90#-
91echo ${r_v} > tmp.$$;
92echo ${r_f} >> tmp.$$;
93echo $((${#}+1)) >> tmp.$$;
94for i in $*;
95 do echo ${i} >> tmp.$$;
96 done
97echo ${r_o} >> tmp.$$;
98#-
99# Create the output file
100#-
101${d_n}/flio_rbld.exe < tmp.$$
102r_c=$?
103#-
104# Clear
105#-
106rm -f tmp.$$
107#-
108# End
109#-
110exit ${r_c};
Note: See TracBrowser for help on using the repository browser.