1 | #!/bin/ksh |
---|
2 | # |
---|
3 | #$Id$ |
---|
4 | # |
---|
5 | # This software is governed by the CeCILL license |
---|
6 | # See IOIPSL/IOIPSL_License_CeCILL.txt |
---|
7 | #--------------------------------------------------------------------- |
---|
8 | # @(#)Rebuild IOIPSL domains |
---|
9 | #--------------------------------------------------------------------- |
---|
10 | function rebuild_Usage |
---|
11 | { |
---|
12 | print - " |
---|
13 | \"${b_n}\" |
---|
14 | rebuild a model_file from several input files. |
---|
15 | Each input file contains the model_data for a domain. |
---|
16 | |
---|
17 | Usage : |
---|
18 | ${b_n} [-h] |
---|
19 | ${b_n} [-v level] [-f] -o output_file_name input_file_names |
---|
20 | |
---|
21 | Options : |
---|
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 | #- |
---|
34 | d_n=${0%/*}; b_n=${0##*/}; |
---|
35 | #- |
---|
36 | # Retrieving the options |
---|
37 | #- |
---|
38 | r_v='0'; r_f='noforce'; r_o=""; |
---|
39 | while 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 |
---|
50 | shift $(($OPTIND-1)); |
---|
51 | #- |
---|
52 | # Validate the -v option |
---|
53 | #- |
---|
54 | case ${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;; |
---|
62 | esac |
---|
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 | #- |
---|
84 | for i in $*; |
---|
85 | do |
---|
86 | [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;} |
---|
87 | done |
---|
88 | #- |
---|
89 | # Create the information file for the program |
---|
90 | #- |
---|
91 | echo ${r_v} > tmp.$$; |
---|
92 | echo ${r_f} >> tmp.$$; |
---|
93 | echo $((${#}+1)) >> tmp.$$; |
---|
94 | for i in $*; |
---|
95 | do echo ${i} >> tmp.$$; |
---|
96 | done |
---|
97 | echo ${r_o} >> tmp.$$; |
---|
98 | #- |
---|
99 | # Create the output file |
---|
100 | #- |
---|
101 | ${d_n}/flio_rbld < tmp.$$ |
---|
102 | #- |
---|
103 | # Clear |
---|
104 | #- |
---|
105 | rm -f tmp.$$ |
---|
106 | #- |
---|
107 | # End |
---|
108 | #- |
---|
109 | exit 0; |
---|