17 echo [ ERROR - $D ] $* >&2
20 function downloadLFN {
23 local LOCAL=${PWD}/`basename ${LFN}`
25 info "getting file size and computing sendReceiveTimeout"
26 size=`lfc-ls -l ${LFN} | awk -F' ' '{print $5}'`
27 sendReceiveTimeout=`echo $[${size}/150/1024]`
28 if [ "$sendReceiveTimeout" = "" ] || [ $sendReceiveTimeout -le 900 ]; then echo "sendReceiveTimeout empty or too small, setting it to 900s"; sendReceiveTimeout=900; else echo "sendReceiveTimeout is $sendReceiveTimeout"; fi;
29 info "Removing file ${LOCAL} in case it is already here"
32 info "Checking if the file is on local SE ${VO_BIOMED_DEFAULT_SE}"
33 local closeSURL=`lcg-lr lfn:${LFN} | grep ${VO_BIOMED_DEFAULT_SE}`
34 if [ "${closeSURL}" != "" ]
36 info "It is. Trying to download the file from there"
37 LINE="lcg-cp -v --connect-timeout 10 --sendreceive-timeout $sendReceiveTimeout --bdii-timeout 10 --srm-timeout 30 ${closeSURL} file:${LOCAL}"
42 info "lcg-cp worked fine"
43 lcg_source=`cat lcg-log | awk -F"://" '/Trying SURL srm/ {print $2}' | awk -F"/" '{print $1}'|awk -F":" '{print $1}'`;
44 lcg_destination=`hostname`;
45 lcg_time=`cat lcg-log | awk '/Transfer took/ {print $3$4}'`;
46 info "DownloadCommand=lcg-cp Source=$lcg_source Destination=$lcg_destination Size=$size Time=$lcg_time";
49 error "It failed, falling back on regular lcg-cp"
52 info "It's not, falling back on regular lcg-cp"
55 info "Downloading file ${LFN}..."
56 LINE="lcg-cp -v --connect-timeout 10 --sendreceive-timeout $sendReceiveTimeout --bdii-timeout 10 --srm-timeout 30 lfn:${LFN} file:${LOCAL}"
61 info "lcg-cp worked fine"
62 lcg_source=`cat lcg-log | awk -F"://" '/Trying SURL srm/ {print $2}' | awk -F"/" '{print $1}'|awk -F":" '{print $1}'`;
63 lcg_destination=`hostname`;
64 lcg_time=`cat lcg-log | awk '/Transfer took/ {print $3$4}'`;
65 info "DownloadCommand=lcg-cp Source=$lcg_source Destination=$lcg_destination Size=$size Time=$lcg_time";
76 COMM_LINE=`echo "${@:2:$(($#-2))}"`
77 # Command-line construction #
79 #echo "COMM line is $COMM_LINE"
80 #remove flags starting with --
81 #BOUTIQUES_ARGS="$(echo ${COMM_LINE} | sed 's/[--][[:alpha:]]*/,/g')"
82 BOUTIQUES_ARGS="$(echo ${COMM_LINE} | sed 's/ , /, /g')"
84 #BOUTIQUES_ARGS="$(echo ${BOUTIQUES_ARGS} | sed 's/^,, //g')"
85 BOUTIQUES_COMMAND_LINE="octave --silent --eval \"SimuPBI_circle_func(${BOUTIQUES_ARGS})\""
86 echo "Boutiques COMM line is $BOUTIQUES_COMMAND_LINE"
89 #WARNING Cheating here : we know that outputs are written in dirOut
91 # Command-line execution #
93 cat << DOCKERJOB > .dockerjob.sh
96 ${BOUTIQUES_COMMAND_LINE}
100 chmod 755 .dockerjob.sh
101 #.dockerjob.sh script needs to be found in the workdir, ten we need to cd to /CreaPhase to be able to execute SimuPBI_circle_func
102 docker run --rm -v $PWD:/gasw-dir -v $PWD/$DIROUT:/CreaPhase/$DIROUT -v $PWD/../cache:$PWD/../cache -w /gasw-dir -u `id -u`:`id -g` camarasu/creaphase ./.dockerjob.sh
106 echo "CreaPhase execution failed!"
110 tar -czvf result.tgz $DIROUT
113 echo "Execution of CreaPhase completed."