source: IOIPSL/trunk/tools/rebuild @ 82

Last change on this file since 82 was 82, checked in by bellier, 15 years ago

JB: change ! by # in comment (misstyping)

  • 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#---------------------------------------------------------------------
6#-
7#set -xv
8#-
9# Extract the calling sequence for the script (d_n/b_n)
10#-
11d_n=$(dirname $0); b_n=$(basename $0);
12#-
13# Retrieving and validation of the options
14#-
15r_v='silencious'; r_f='noforce'; r_o="";
16while getopts :hvfo: V
17 do
18  case $V in
19   (h) echo '';
20       echo '"'${b_n}'"';
21       echo '  rebuild a model_file from several input files.';
22       echo 'Each input file contains the model_data for a domain.';
23       echo 'Usage :';
24       echo ${b_n} '[-h]';
25       echo ${b_n} '[-v] [-f] -o output_file_name input_file_names';
26       echo ' -h : this help';
27       echo ' -v : verbose mode';
28       echo ' -f : executing mode';
29       echo '  (execute the program even if the number of input files';
30       echo '   is not equal to the total number of domains)';
31       echo '';
32       exit 0;;
33   (v) r_v='verbose';;
34   (f) r_f='force';;
35   (o) r_o=${OPTARG};;
36   (:)  echo ${b_n}" : option $OPTARG : missing value" 1>&2;
37        exit 2;;
38   (\?) echo ${b_n}" : option $OPTARG : not supported" 1>&2;
39        exit 2;;
40  esac
41 done
42shift $(($OPTIND-1));
43#-
44# Validate the number of arguments
45#-
46if   [ ${#} -lt 1 ]; then
47  echo ${b_n}' : Too few arguments have been specified. (Use -h)' 1>&2;
48  exit 3;
49fi
50#-
51# Check for the output file name
52#-
53if [ '\?'${r_o} = '\?' ]; then
54  echo ' ' 1>&2;
55  echo ${b_n}' : output_file_name not specified. (Use -h)' 1>&2;
56  echo '          "rebuilt_file.nc" should be created.' 1>&2;
57  echo ' ' 1>&2;
58  r_o='rebuilt_file.nc'
59fi;
60#-
61# Validate the names of the input files
62#-
63qi=0;
64for i in $*;
65 do ((qi=qi+1));
66  [ ${qi} -le ${#} ] && [ ! -f ${i} ] && \
67    { echo "${i} unreachable ..."; exit 3;}
68 done
69#-
70# Create the information file for the program
71#-
72echo ${r_v} > tmp.$$;
73echo ${r_f} >> tmp.$$;
74((qi=$#+1));
75echo ${qi} >> tmp.$$;
76for i in $*;
77 do echo ${i} >> tmp.$$;
78 done
79echo ${r_o} >> tmp.$$;
80#-
81# Create the output file
82#-
83${d_n}/flio_rbld < tmp.$$
84#-
85# Clear
86#-
87rm -f tmp.$$
88#-
89# End
90#-
91exit 0;
Note: See TracBrowser for help on using the repository browser.