Changeset 257 for IOIPSL/trunk/tools/rebuild
- Timestamp:
- 02/21/08 11:44:35 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
IOIPSL/trunk/tools/rebuild
r82 r257 4 4 # @(#)Rebuild IOIPSL domains 5 5 #--------------------------------------------------------------------- 6 function rebuild_Usage 7 { 8 print - " 9 \"${b_n}\" 10 rebuild a model_file from several input files. 11 Each input file contains the model_data for a domain. 12 13 Usage : 14 ${b_n} [-h] 15 ${b_n} [-v level] [-f] -o output_file_name input_file_names 16 17 Options : 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 } 6 25 #- 7 26 #set -xv 8 27 #- 9 # Extract the calling sequence forthe script (d_n/b_n)28 # Extract the calling sequence of the script (d_n/b_n) 10 29 #- 11 d_n=$ (dirname $0); b_n=$(basename $0);30 d_n=${0%/*}; b_n=${0##*/}; 12 31 #- 13 # Retrieving and validation ofthe options32 # Retrieving the options 14 33 #- 15 r_v=' silencious'; r_f='noforce'; r_o="";16 while getopts :hv fo: V34 r_v='0'; r_f='noforce'; r_o=""; 35 while getopts :hv:fo: V 17 36 do 18 37 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';; 38 (h) rebuild_Usage; exit 0;; 39 (v) r_v=${OPTARG};; 34 40 (f) r_f='force';; 35 41 (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;; 42 (:) print -u2 "${b_n} : missing value for option $OPTARG"; exit 2;; 43 (\?) print -u2 "${b_n} : option $OPTARG not supported"; exit 2;; 40 44 esac 41 45 done 42 46 shift $(($OPTIND-1)); 43 47 #- 48 # Validate the -v option 49 #- 50 case ${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;; 58 esac 59 #- 44 60 # Validate the number of arguments 45 61 #- 46 if [ ${#} -lt 1 ]; then 47 echo ${b_n}' : Too few arguments have been specified. (Use -h)' 1>&2; 62 [[ ${#} < 1 ]] && \ 63 { 64 print -u2 "${b_n} : Too few arguments have been specified. (Use -h)"; 48 65 exit 3; 49 fi 66 } 50 67 #- 51 68 # Check for the output file name 52 69 #- 53 if [ '\?'${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'59 fi; 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 } 60 77 #- 61 78 # Validate the names of the input files 62 79 #- 63 qi=0;64 80 for i in $*; 65 do ((qi=qi+1)); 66 [ ${qi} -le ${#} ] && [ ! -f ${i} ] && \ 67 { echo "${i} unreachable ..."; exit 3;} 81 do 82 [[ ! -f ${i} ]] && { echo "${i} unreachable ..."; exit 3;} 68 83 done 69 84 #- … … 72 87 echo ${r_v} > tmp.$$; 73 88 echo ${r_f} >> tmp.$$; 74 ((qi=$#+1)); 75 echo ${qi} >> tmp.$$; 89 echo $((${#}+1)) >> tmp.$$; 76 90 for i in $*; 77 91 do echo ${i} >> tmp.$$;
Note: See TracChangeset
for help on using the changeset viewer.