source: IOIPSL/trunk/tools/rebuild @ 257

Last change on this file since 257 was 257, checked in by bellier, 16 years ago

JB :

rebuild

adding the verbosity level
some lifting

flio_rbld

new algorithm (should be faster)

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