Statistics
| Branch: | Tag: | Revision:

dockonsurf / modules / launch_cp2k_molecule_seule.sh @ 454be75d

History | View | Annotate | Download (2.2 kB)

1
#!/bin/bash
2

    
3
molecule=$1
4
max_qw=$2
5

    
6
n="$(find ${Molecule_results_path}/${molecule}_confs/xyz_files/${molecule}*.xyz | wc -l)"
7

    
8
if [ ! -d "${Molecule_results_path}/${molecule}" ]
9
then mkdir ${Molecule_results_path}/${molecule}
10
else 
11
	print 'problem there is already a directory for this molecule'
12
	exit
13
fi
14

    
15
mkdir ${Molecule_results_path}/${molecule}/${molecule}_1
16
cd ${Molecule_results_path}/${molecule}/${molecule}_1
17
sed "/PROJECT_NAME/c\PROJECT_NAME ${molecule}" ${CP2K_input_molecule} > ${Molecule_results_path}/${molecule}/${molecule}_1/${molecule}.inp
18
sed "s/XXXX/${molecule}/g" ${CP2K_sub} > ${Molecule_results_path}/${molecule}/${molecule}_1/cp2k_gamma.j
19
cp ${Molecule_results_path}/${molecule}_confs/xyz_files/${molecule}_1.xyz ${Molecule_results_path}/${molecule}/${molecule}_1/coord.xyz
20
new_job_id=$(qsub cp2k_gamma.j | awk '{print $3}')
21
echo "Submitted job $new_job_id"
22
jobs_owned+=($new_job_id)
23
queued_jobs=1
24

    
25
for ((i=2; i<=n; i++)) ; do
26
	mkdir ${Molecule_results_path}/${molecule}/${molecule}_$i
27
	cd ${Molecule_results_path}/${molecule}/${molecule}_$i
28
	ln ${Molecule_results_path}/${molecule}/${molecule}_1/cp2k_gamma.j .
29
	ln ${Molecule_results_path}/${molecule}/${molecule}_1/${molecule}.inp .
30
	cp ${Molecule_results_path}/${molecule}_confs/xyz_files/${molecule}_${i}.xyz coord.xyz
31
  while [ "$queued_jobs" -ge $max_qw ]; do
32
    sleep 30
33
    queued_jobs=0
34
    for job in ${jobs_owned[@]} ; do
35
      queued_jobs=$((queued_jobs+$(qstat | grep $job | grep -c " qw ")))
36
    done
37
  done
38
  new_job_id=$(qsub cp2k_gamma.j | awk '{print $3}')
39
  echo "Submitted job $new_job_id"
40
  jobs_owned+=($new_job_id)
41
  queued_jobs=$((queued_jobs+1))
42
done
43

    
44
### Attente jusqu'à ce que tous les calculs aient fini
45
go_on=true
46
while [ $go_on == true ]; do
47
  all_jobs=`qstat | tail -n+3 | awk '{print $1}'`
48
  for j1 in ${jobs_owned[@]} ; do
49
    for j2 in ${all_jobs[@]}; do
50
      if [ $j1 == $j2 ]; then
51
        sleep 30
52
        continue 3
53
      fi
54
    done
55
  done
56
  echo "loop finished"
57
  go_on=false
58
done
59

    
60
for dir in ${Molecule_results_path}/${molecule}/${molecule}_*; do
61
	n_line="$(grep -n "i =" ${dir}/*-pos-1.xyz | awk 'END{print}' | awk 'NF=1{print}' | awk 'sub(".$", "")')"
62
  n_line_1="$(expr $n_line - 1)"
63
	awk -v ligne="$n_line_1" 'NR>=ligne{print}' ${dir}/*-pos-1.xyz > ${dir}/last_geo.xyz
64
done