1 | #!/bin/bash |
---|
2 | |
---|
3 | #Download the ferret script run : |
---|
4 | tmpfname=$1 |
---|
5 | shift 1 |
---|
6 | #Download a shell script to run this ferret script for all files:</B> |
---|
7 | fh="${tmpfname}_prod.bash" |
---|
8 | [ -f $fh ] && \rm -f $fh |
---|
9 | |
---|
10 | DIRS=($@) |
---|
11 | NDIRS=${#DIRS[@]} |
---|
12 | echo "Nb simul " $NDIRS |
---|
13 | |
---|
14 | for thisdir in ${DIRS[@]} ; do |
---|
15 | echo "" |
---|
16 | leadding_sl=$( echo ${thisdir} | grep '.*/$' ) |
---|
17 | if [ X"${leadding_sl}" != X ] ; then |
---|
18 | thisdir=$( echo ${thisdir} | sed -e 's&\(.*\)/$&\1&' ) |
---|
19 | fi |
---|
20 | echo "dir : " ${thisdir} |
---|
21 | wget -nd ${thisdir}/MONITORING/files 2> /dev/null |
---|
22 | RET=$? |
---|
23 | if [ ${RET} -gt 0 ] ; then |
---|
24 | \ls ${thisdir}/MONITORING/files > files |
---|
25 | RET=$? |
---|
26 | if [ ${RET} -gt 0 ] ; then |
---|
27 | echo "Error : can't read ${thisdir} !" |
---|
28 | exit 1 |
---|
29 | fi |
---|
30 | fi |
---|
31 | shortdir=$( basename $thisdir ) |
---|
32 | list_list=(${list_list[@]} ${shortdir}_list) |
---|
33 | mv files ${shortdir}_files |
---|
34 | cat ${shortdir}_files | grep '.*\.nc.*' | sed -e 's/.*">\(.*\)\.nc<.*/\1.nc/' | sort > ${shortdir}_list |
---|
35 | cat ${shortdir}_list >> allfiles |
---|
36 | if [ X"${listsimus[0]}" = X"" ] ; then |
---|
37 | listsimus[0]=${shortdir} |
---|
38 | else |
---|
39 | listsimus=( ${listsimus[@]} ' vs ' ${shortdir} ) |
---|
40 | fi |
---|
41 | done |
---|
42 | echo "" |
---|
43 | listfiles=( $( cat allfiles | sort -u ) ) |
---|
44 | # if [ ${NDIRS} -eq 2 ] ; then |
---|
45 | # diff -C 0 ${list_list[@]} > difffiles |
---|
46 | # else |
---|
47 | # i=0 |
---|
48 | # echo $(( NDIRS - 1 )) |
---|
49 | # while [ $i -lt $(( NDIRS - 1 )) ] ; do |
---|
50 | # diff ${list_list[$i]} ${list_list[$i+1]} > diff_$i |
---|
51 | # i=$i+1 |
---|
52 | # done |
---|
53 | # fi |
---|
54 | echo "Monitoring comparison: ${listsimus[@]}" |
---|
55 | |
---|
56 | # clean |
---|
57 | for thisdir in ${DIRS[@]} ; do |
---|
58 | shortdir=$( basename $thisdir ) |
---|
59 | \rm -f ${shortdir}_list ${shortdir}_files |
---|
60 | done |
---|
61 | \rm allfiles |
---|
62 | |
---|
63 | cmd="#!/bin/bash" |
---|
64 | printf "$cmd\n" >> $fh |
---|
65 | cmd="# Script generated by FEGGsh (Ferret in an EGG in bash)" |
---|
66 | printf "$cmd\n\n" >> $fh |
---|
67 | cmd="#=====================================" |
---|
68 | printf "$cmd\n" >> $fh |
---|
69 | cmd="#### Please modify if needed" |
---|
70 | printf "$cmd\n" >> $fh |
---|
71 | cmd="#. /web/igcmg/.atlas_env_eole3_bash # LSCE (eole3)" |
---|
72 | printf "$cmd\n" >> $fh |
---|
73 | cmd="#. /home/cont003/p86ipsl/.atlas_env_mercure_ksh # CCRT (mercure)" |
---|
74 | printf "$cmd\n" >> $fh |
---|
75 | cmd="#. /home/rech/psl/rpsl035/.atlas_env_ulam_bash # IDRIS (ulam)" |
---|
76 | printf "$cmd\n" >> $fh |
---|
77 | cmd="#. /home/users/brock/.atlas_env_asterix_bash # LSCE (asterix)" |
---|
78 | printf "$cmd\n" >> $fh |
---|
79 | cmd="#. /home/brocksce/.atlas_env_calcul_ksh # IPSL (calcul2)" |
---|
80 | printf "$cmd\n\n" >> $fh |
---|
81 | cmd="#=====================================" |
---|
82 | printf "$cmd\n" >> $fh |
---|
83 | cmd="#### Please modify if needed" |
---|
84 | printf "$cmd\n" >> $fh |
---|
85 | cmd="scriptname=$tmpfname.jnl" |
---|
86 | printf "$cmd\n" >> $fh |
---|
87 | cmd="if ! [[ -f \$scriptname && -s \$scriptname ]] ; then" |
---|
88 | printf "$cmd\n" >> $fh |
---|
89 | cmd=" echo \"Please download the ferret script \$scriptname\"" |
---|
90 | printf "$cmd\n" >> $fh |
---|
91 | cmd="exit" |
---|
92 | printf "$cmd\n" >> $fh |
---|
93 | cmd="fi" |
---|
94 | printf "$cmd\n\n" >> $fh |
---|
95 | cmd="#=====================================" |
---|
96 | printf "$cmd\n" >> $fh |
---|
97 | cmd="colors_keys=( ATM ICE OCE SBG SRF CHM )" |
---|
98 | printf "$cmd\n" >> $fh |
---|
99 | cmd="colors_vals=( AECDFF D4E3E6 6D80FF EEE8AA E7FFAB F0D5F4 )" |
---|
100 | printf "$cmd\n\n" >> $fh |
---|
101 | cmd="function findcolor() {" |
---|
102 | printf "$cmd\n" >> $fh |
---|
103 | cmd="local i=0" |
---|
104 | printf "$cmd\n" >> $fh |
---|
105 | cmd="while [ \$i -lt \${#colors_keys[*]} ] ; do" |
---|
106 | printf "$cmd\n" >> $fh |
---|
107 | cmd=" if [ \"\${colors_keys[\$i]}\" = \"\$1\" ] ; then" |
---|
108 | printf "$cmd\n" >> $fh |
---|
109 | cmd=" findcolor=\${colors_vals[\$i]}" |
---|
110 | printf "$cmd\n" >> $fh |
---|
111 | cmd=" return 1" |
---|
112 | printf "$cmd\n" >> $fh |
---|
113 | cmd=" fi" |
---|
114 | printf "$cmd\n" >> $fh |
---|
115 | cmd=" let i=i+1" |
---|
116 | printf "$cmd\n" >> $fh |
---|
117 | cmd="done" |
---|
118 | printf "$cmd\n" >> $fh |
---|
119 | cmd="findcolor=FFFFFF" |
---|
120 | printf "$cmd\n" >> $fh |
---|
121 | cmd="return 0" |
---|
122 | printf "$cmd\n" >> $fh |
---|
123 | cmd="}" |
---|
124 | printf "$cmd\n\n" >> $fh |
---|
125 | cmd="#=====================================" |
---|
126 | printf "$cmd\n" >> $fh |
---|
127 | cmd="listfiles=(" |
---|
128 | echo "$cmd \\" >> $fh |
---|
129 | for file1 in ${listfiles[*]} ; do |
---|
130 | cmd="$file1 " |
---|
131 | echo "$cmd \\" >> $fh |
---|
132 | done |
---|
133 | cmd=")" |
---|
134 | printf "$cmd\n\n" >> $fh |
---|
135 | cmd="#=====================================" |
---|
136 | printf "$cmd\n" >> $fh |
---|
137 | cmd="outputdir=\${scriptname%%%%.jnl}_prod/images" |
---|
138 | printf "$cmd\n" >> $fh |
---|
139 | cmd="rm -rf \${outputdir}" |
---|
140 | printf "$cmd\n" >> $fh |
---|
141 | cmd="mkdir -p \${outputdir}" |
---|
142 | printf "$cmd\n\n" >> $fh |
---|
143 | cmd="#=====================================" |
---|
144 | printf "$cmd\n" >> $fh |
---|
145 | cmd="for file in \${listfiles[*]} ; do" |
---|
146 | printf "$cmd\n" >> $fh |
---|
147 | cmd=" echo ferret -batch \${outputdir}/\${file%%%%.nc}.gif -script \${scriptname} \${file}" |
---|
148 | printf "$cmd\n" >> $fh |
---|
149 | cmd=" ferret -batch \${outputdir}/\${file%%%%.nc}.gif -script \${scriptname} \${file}" |
---|
150 | printf "$cmd\n\n" >> $fh |
---|
151 | cmd=" prefix=\`echo \${file} | cut -f 1 -d _\`" |
---|
152 | printf "$cmd\n" >> $fh |
---|
153 | cmd=" findcolor \$prefix" |
---|
154 | printf "$cmd\n" >> $fh |
---|
155 | cmd=" convert -geometry 50%%x50%% -bordercolor \"#\${findcolor}\" -border 15x15 \${outputdir}/\${file%%%%.nc}.gif \${outputdir}/\${file%%%%.nc}.jpg" |
---|
156 | printf "$cmd\n" >> $fh |
---|
157 | cmd="done" |
---|
158 | printf "$cmd\n\n" >> $fh |
---|
159 | cmd="#=====================================" |
---|
160 | printf "$cmd\n" >> $fh |
---|
161 | cmd="monitoring01_createindex -t '${listsimus[@]}' \${scriptname%%%%.jnl}_prod" |
---|
162 | # printf "$cmd\n" >> $fh |
---|
163 | # cmd="mv \${scriptname%%%%.jnl}_prod/\${scriptname%%%%.jnl} \${scriptname%%%%.jnl}_prod/index.html" |
---|
164 | printf "$cmd\n\n" >> $fh |
---|
165 | cmd="#=====================================" |
---|
166 | printf "$cmd\n" >> $fh |
---|
167 | cmd="#### Please modify if needed" |
---|
168 | printf "$cmd\n" >> $fh |
---|
169 | cmd="#cp -fR \${scriptname%%%%.jnl}_prod /somewhere/dir" |
---|
170 | printf "$cmd\n\n" >> $fh |
---|
171 | chmod u+x $fh |
---|