diff --git a/tools/01_NAO_generation/Generate_Orbital_AllInOne.sh b/tools/01_NAO_generation/Generate_Orbital_AllInOne.sh index 95d323c43d4..4165739f0cf 100755 --- a/tools/01_NAO_generation/Generate_Orbital_AllInOne.sh +++ b/tools/01_NAO_generation/Generate_Orbital_AllInOne.sh @@ -1,33 +1,33 @@ #!/bin/bash -# author mohan +# author mohan # edit by Pengfei Li 2013-6-4 # maintained by WenShuai Zhang (since 2016-11-30) with changelog: # 1. fix bugs when reading "ORBITAL_INPUT" for lines begin with "#" or " ". -# 2. add support for generating orbital with multi different types of structures together, +# 2. add support for generating orbital with multi different types of structures together, # such as dimer STRU & tetramer STRU and so on. # 3. add support for opt_orb_pytorch_dpsi generator args=$@ -if [ "$args" == "--help" -o "$args" == "-h" ] ; then - echo " Usage: ./ThisScript.sh " - echo " Example: ./generate_orbital.sh ORBITAL_INPUT_MixSTRU " - echo " If no , This script will use the default name for input file: ORBITAL_INPUT " - echo " " - exit -elif [ ! -z $1 ] && [ -f $1 ] ; then - InputFile=$1 -elif [ -f 'ORBITAL_INPUT' ] ; then - echo " Can't find specified input file, use default: ORBITAL_INPUT " - InputFile="ORBITAL_INPUT" +if [ "$args" == "--help" -o "$args" == "-h" ]; then + echo " Usage: ./ThisScript.sh " + echo " Example: ./generate_orbital.sh ORBITAL_INPUT_MixSTRU " + echo " If no , This script will use the default name for input file: ORBITAL_INPUT " + echo " " + exit +elif [ ! -z $1 ] && [ -f $1 ]; then + InputFile=$1 +elif [ -f 'ORBITAL_INPUT' ]; then + echo " Can't find specified input file, use default: ORBITAL_INPUT " + InputFile="ORBITAL_INPUT" else - echo " Can't find specified input file or default file: ORBITAL_INPUT" - echo " see help by '-h' " - echo " " - exit + echo " Can't find specified input file or default file: ORBITAL_INPUT" + echo " see help by '-h' " + echo " " + exit fi -if [ -z $InputFile ]; then - echo " Can't find input file" - exit; +if [ -z $InputFile ]; then + echo " Can't find input file" + exit fi # echo " " @@ -37,480 +37,445 @@ echo " * Start to Generate Orbital for LCAO * " echo " * * " echo " ********************************************************* " -function completelyNewCalc(){ - echo " " - echo " Completely New SIA Calculation ... " - mkdir -p Old - if ( test -f "ORBITAL_RESULTS.txt" ); then - echo " Move Old Orbital files: ORBITAL_RESULTS.txt to Old/" - mv "ORBITAL_RESULTS.txt" Old/ - echo " Move Old INPUT files: INPUT to Old/" - mv "INPUT" Old/ - fi +function completelyNewCalc() { + echo " " + echo " Completely New SIA Calculation ... " + mkdir -p Old + if (test -f "ORBITAL_RESULTS.txt"); then + echo " Move Old Orbital files: ORBITAL_RESULTS.txt to Old/" + mv "ORBITAL_RESULTS.txt" Old/ + echo " Move Old INPUT files: INPUT to Old/" + mv "INPUT" Old/ + fi } -time_start=`date +%s` +time_start=$(date +%s) #----------------------------------------------------------------- # -# (0.0) fixed parameters +# (0.0) fixed parameters # #----------------------------------------------------------------- -mass=1 #not used yet. -lat0=20 #in a.u - +mass=1 #not used yet. +lat0=20 #in a.u echo " InputFile = $InputFile" #----------------------------------------------------------------- # (0.0) get EXE_mpi #----------------------------------------------------------------- -EXE_mpi=`grep -E "^\s*EXE_mpi" $InputFile | awk -F "EXE_mpi" '{print $2}' ` -EXE_mpi=`echo $EXE_mpi` +EXE_mpi=$(grep -E "^\s*EXE_mpi" $InputFile | awk -F "EXE_mpi" '{print $2}') +EXE_mpi=$(echo $EXE_mpi) if [ -z "$EXE_mpi" ]; then - cpu_num=8 - hostfpath="myhosts" - #hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts" - grep slots $hostfpath > /dev/null - if [ $? = 0 ] ; then # has "slots" in file: $hostfpath - cpu_num=`cat $hostfpath |cut -d "=" -f 2-3|awk '{sum += $1};END {print sum}'` - else - cpu_num=`cat $hostfpath |wc -l` - fi - echo " cpu_num = $cpu_num" - echo " hostfpath = $hostfpath" - EXE_mpi="mpirun -np $cpu_num -hostfile ../$hostfpath " + cpu_num=8 + hostfpath="myhosts" + #hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts" + grep slots $hostfpath >/dev/null + if [ $? = 0 ]; then # has "slots" in file: $hostfpath + cpu_num=$(cat $hostfpath | cut -d "=" -f 2-3 | awk '{sum += $1};END {print sum}') + else + cpu_num=$(cat $hostfpath | wc -l) + fi + echo " cpu_num = $cpu_num" + echo " hostfpath = $hostfpath" + EXE_mpi="mpirun -np $cpu_num -hostfile ../$hostfpath " fi -echo " EXE_mpi = $EXE_mpi " -Host_List=( `$EXE_mpi hostname 2>/dev/null` ) -Host1_List=( `echo ${Host_List[@]} | grep -o "$Host_List"` ) -Host1_NCore=${#Host1_List[@]} -echo " Host1_NCore = $Host1_NCore" -if [ $Host1_NCore -lt 1 ]; then - echo " error at getting Host1_NCore, program exiting ... " - exit 1 +echo " EXE_mpi = $EXE_mpi " +Host_List=($($EXE_mpi hostname 2>/dev/null)) +Host1_List=($(echo ${Host_List[@]} | grep -o "$Host_List")) +Host1_NCore=${#Host1_List[@]} +echo " Host1_NCore = $Host1_NCore" +if [ $Host1_NCore -lt 1 ]; then + echo " error at getting Host1_NCore, program exiting ... " + exit 1 fi - #----------------------------------------------------------------- # (0.1) input parameters #----------------------------------------------------------------- # (0.1.1) get exe -EXE_pw=`grep -E "^\s*EXE_pw" $InputFile | awk -F "EXE_pw" '{print $0}' | awk '{print $2}'` -echo " EXE_pw = $EXE_pw " +EXE_pw=$(grep -E "^\s*EXE_pw" $InputFile | awk -F "EXE_pw" '{print $0}' | awk '{print $2}') +echo " EXE_pw = $EXE_pw " # (0.1.2)get SIA -EXE_orbital=`grep -E "^\s*EXE_orbital" $InputFile | awk -F "EXE_orbital" '{print $0}' | awk '{print $2}'` +EXE_orbital=$(grep -E "^\s*EXE_orbital" $InputFile | awk -F "EXE_orbital" '{print $0}' | awk '{print $2}') chmod +x "$EXE_orbital" - # (0.1.3)get the targets element and id -targets=`grep -E "^\s*targets" $InputFile | awk -F "targets" '{print $0}' | awk '{print $2}'` -echo " targets = $targets" - - +targets=$(grep -E "^\s*targets" $InputFile | awk -F "targets" '{print $0}' | awk '{print $2}') +echo " targets = $targets" #----------------------------------------------------------------- # (1) big cicle, cicle of targets #----------------------------------------------------------------- -for name in $targets; -do - -#echo "name=$name" -element=`echo "$name" | awk -F "_" '{print $2}'` -#echo "element=$element" -id=`echo "$name" | awk -F "_" '{print $1}'` -#echo "id=$id" - -# (0.1.6)get the pseudo_dir -Pseudo_dir=`grep -E "^\s*Pseudo_dir" $InputFile | awk -F "Pseudo_dir" '{print $0}' | awk '{print $2}'` -echo " Pseudo_dir = $Pseudo_dir " - -# (0.1.12) get the ecut -ecut=`grep -E "^\s*Ecut" $InputFile | awk -F "Ecut" '{print $0}' | awk '{print $2}'` -echo " ecut = $ecut" - -# (0.1.13) get the info about rcut,pseudo -#info_r=`grep -E "^\s*Rcut" $InputFile | awk -F "Rcut" '{print $0}' | awk '{print $2}'` -#rcut_number=`echo "$info_r" | awk '// {print NF}'` -info_r=( `grep -E "^\s*Rcut" $InputFile | awk -F "Rcut|#" '{print $2 }'` ) -rcut_number=${#info_r[@]} -echo " rcut_number = $rcut_number, info_r = ( ${info_r[@]} )" - -# (0.1.14) get the pseudopotential -pseudofile=`grep -E "^\s*Pseudo " $InputFile | awk -F "Pseudo " '{print $0}' | awk '{print $2}'` -echo " Pseudo = $pseudofile" - -# (0.1.15) get the smearing -smearing_sigma=`grep -E "^\s*smearing_sigma " $InputFile | awk -F "smearing_sigma " '{print $0}' | awk '{print $2}'` -echo " smearing_sigma = $smearing_sigma" - - -# -# (0.1.7)get maxL S P D -maxL=`grep -E "^\s*maxL" $InputFile | awk -F "maxL" '{print $0}' | awk '{print $2}'` - -#if ( test $maxL = 0 ) // mohan's scheme -#then -#S_MIN=1 -#P_MIN=" " -#D_MIN=" " -#elif ( test $maxL = 1 ) -#then -#S_MIN=1 -#P_MIN=1 -#D_MIN=" " -#else -#S_MIN=1 -#P_MIN=1 -#D_MIN=1 -#fi - - -# (0.x.x) check info (include Level) for each STRU -nSTRU=`grep -E "^\s*BLSTRU" $InputFile | wc -l` -#nSTRU=`grep -o "^\s*ListSTRU\s*[^#]*" W/ORBITAL_INPUT_DZP |wc -w |awk '{print $1-1}'` -if [[ "$nSTRU" == "0" ]] ; then - nSTRU=`grep -E "^\s*Dis" $InputFile | wc -l` - if [ "$nSTRU" != "1" ]; then - echo "error: input file has more than one line for Dis argument, please use the BLSTRU* " +for name in $targets; do + + #echo "name=$name" + element=$(echo "$name" | awk -F "_" '{print $2}') + #echo "element=$element" + id=$(echo "$name" | awk -F "_" '{print $1}') + #echo "id=$id" + + # (0.1.6)get the pseudo_dir + Pseudo_dir=$(grep -E "^\s*Pseudo_dir" $InputFile | awk -F "Pseudo_dir" '{print $0}' | awk '{print $2}') + echo " Pseudo_dir = $Pseudo_dir " + + # (0.1.12) get the ecut + ecut=$(grep -E "^\s*Ecut" $InputFile | awk -F "Ecut" '{print $0}' | awk '{print $2}') + echo " ecut = $ecut" + + # (0.1.13) get the info about rcut,pseudo + #info_r=`grep -E "^\s*Rcut" $InputFile | awk -F "Rcut" '{print $0}' | awk '{print $2}'` + #rcut_number=`echo "$info_r" | awk '// {print NF}'` + info_r=($(grep -E "^\s*Rcut" $InputFile | awk -F "Rcut|#" '{print $2 }')) + rcut_number=${#info_r[@]} + echo " rcut_number = $rcut_number, info_r = ( ${info_r[@]} )" + + # (0.1.14) get the pseudopotential + pseudofile=$(grep -E "^\s*Pseudo " $InputFile | awk -F "Pseudo " '{print $0}' | awk '{print $2}') + echo " Pseudo = $pseudofile" + + # (0.1.15) get the smearing + smearing_sigma=$(grep -E "^\s*smearing_sigma " $InputFile | awk -F "smearing_sigma " '{print $0}' | awk '{print $2}') + echo " smearing_sigma = $smearing_sigma" + + # + # (0.1.7)get maxL S P D + maxL=$(grep -E "^\s*maxL" $InputFile | awk -F "maxL" '{print $0}' | awk '{print $2}') + + #if ( test $maxL = 0 ) // mohan's scheme + #then + #S_MIN=1 + #P_MIN=" " + #D_MIN=" " + #elif ( test $maxL = 1 ) + #then + #S_MIN=1 + #P_MIN=1 + #D_MIN=" " + #else + #S_MIN=1 + #P_MIN=1 + #D_MIN=1 + #fi + + # (0.x.x) check info (include Level) for each STRU + nSTRU=$(grep -E "^\s*BLSTRU" $InputFile | wc -l) + #nSTRU=`grep -o "^\s*ListSTRU\s*[^#]*" W/ORBITAL_INPUT_DZP |wc -w |awk '{print $1-1}'` + if [[ "$nSTRU" == "0" ]]; then + nSTRU=$(grep -E "^\s*Dis" $InputFile | wc -l) + if [ "$nSTRU" != "1" ]; then + echo "error: input file has more than one line for Dis argument, please use the BLSTRU* " fi -fi -echo " nSTRU = $nSTRU" -# -LevelBegin[0]=0 -EndLevel[0]=0 -SkipSTRU[0]=0 -RestartSTRU[0]=0 -ListSTRU[0]=" " -for((iSTRU=1;iSTRU<=$nSTRU;iSTRU++)) -do - ListSTRU[iSTRU]=`grep -E "^\s*ListSTRU " $InputFile |awk -F "ListSTRU" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + fi + echo " nSTRU = $nSTRU" + # + LevelBegin[0]=0 + EndLevel[0]=0 + SkipSTRU[0]=0 + RestartSTRU[0]=0 + ListSTRU[0]=" " + for ((iSTRU = 1; iSTRU <= $nSTRU; iSTRU++)); do + ListSTRU[iSTRU]=$(grep -E "^\s*ListSTRU " $InputFile | awk -F "ListSTRU" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') ListSTRU[iSTRU]=${ListSTRU[iSTRU]:-dimer} echo " STRU[$iSTRU] = ${ListSTRU[iSTRU]}" - - BLSTRU[iSTRU]=`grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}'` - if [[ -z "${BLSTRU[iSTRU]}" ]] && [[ "$iSTRU=1" ]] ; then - BLSTRU[iSTRU]=`grep -E "^\s*Dis" $InputFile | awk -F "Dis" '{print $2}'` + BLSTRU[iSTRU]=$(grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}') + if [[ -z "${BLSTRU[iSTRU]}" ]] && [[ "$iSTRU=1" ]]; then + BLSTRU[iSTRU]=$(grep -E "^\s*Dis" $InputFile | awk -F "Dis" '{print $2}') fi - BL_number[iSTRU]=`echo "${BLSTRU[iSTRU]}" | awk '// {print NF}'` + BL_number[iSTRU]=$(echo "${BLSTRU[iSTRU]}" | awk '// {print NF}') # (0.1.11) calculate the number of different dimers or trimers. #BLSTRU=`grep "Dis1" $InputFile | awk -F "Dis1" '{print $2}'` #BL_number=`echo "$BLSTRU" | awk '// {print NF}'` echo " BL_number[$iSTRU] = ${BL_number[iSTRU]}" - echo " BLSTRU[$iSTRU] =" ${BLSTRU[iSTRU]} " :Bond Length for each STRU" - - EndLevel[iSTRU]=`grep -E "^\s*Level" $InputFile |awk -F "Level" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + echo " BLSTRU[$iSTRU] =" ${BLSTRU[iSTRU]} " :Bond Length for each STRU" + + EndLevel[iSTRU]=$(grep -E "^\s*Level" $InputFile | awk -F "Level" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') echo " EndLevel[$iSTRU] = ${EndLevel[iSTRU]}" - BeginLevel[iSTRU]=`grep -E "^\s*BeginLevel" $InputFile |awk -F "BeginLevel" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + BeginLevel[iSTRU]=$(grep -E "^\s*BeginLevel" $InputFile | awk -F "BeginLevel" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') echo " BeginLevel[$iSTRU] = ${BeginLevel[iSTRU]:-auto/default}" - + # (0.1.4)get the nbands - nbands[iSTRU]=`grep -E "^\s*nbands" $InputFile | awk -F "nbands" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + nbands[iSTRU]=$(grep -E "^\s*nbands" $InputFile | awk -F "nbands" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') echo " nbands[$iSTRU] = ${nbands[iSTRU]}" - + # (0.1.5)get the ref_bands - ref_bands[iSTRU]=`grep -E "^\s*ref_bands" $InputFile | awk -F "$ref_bands" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + ref_bands[iSTRU]=$(grep -E "^\s*ref_bands" $InputFile | awk -F "$ref_bands" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') echo " ref_bands[$iSTRU] = ${ref_bands[iSTRU]}" - RestartSTRU[iSTRU]=`grep -E "^\s*RestartSTRU" $InputFile \\ - | awk -F "$RestartSTRU" '{print $0}' \\ - | awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + RestartSTRU[iSTRU]=$(grep -E "^\s*RestartSTRU" $InputFile | + awk -F "$RestartSTRU" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') echo " RestartSTRU[$iSTRU] = ${RestartSTRU[iSTRU]:-auto/default}" #if [ ! -n "${RestartSTRU[iSTRU]}" ]; then # RestartSTRU[iSTRU]=0 # echo " set RestartSTRU[$iSTRU]=0 " #fi - SkipSTRU[iSTRU]=0 - if ( test -n "`grep -E "^\s*SkipSTRU" $InputFile`" ); then - SkipSTRU[iSTRU]=`grep -E "^\s*SkipSTRU" $InputFile \\ - | awk -F "$SkipSTRU" '{print $0}' \\ - | awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` + if (test -n "$(grep -E "^\s*SkipSTRU" $InputFile)"); then + SkipSTRU[iSTRU]=$(grep -E "^\s*SkipSTRU" $InputFile | + awk -F "$SkipSTRU" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') fi echo " SkipSTRU[$iSTRU] = ${SkipSTRU[iSTRU]}" -done # first cicle of iSTRU -if [ "$nSTRU" == "1" ]; then - SkipSTRU[1]=0 -fi - -# (0.1.8)get the level -#Level=`grep "Level" $InputFile | awk -F "level" '{print $0}' | awk '{print $2}'` -#echo "__Level=$Level" - - -# (0.1.9)get every level`s lmax s p d f g -Llevels[1]=`grep -E "^\s*level1" $InputFile | awk -F "level1" '{print $2}'` -Llevels[2]=`grep -E "^\s*level2" $InputFile | awk -F "level2" '{print $2}'` -Llevels[3]=`grep -E "^\s*level3" $InputFile | awk -F "level3" '{print $2}'` -Llevels[4]=`grep -E "^\s*level4" $InputFile | awk -F "level4" '{print $2}'` -Llevels[5]=`grep -E "^\s*level5" $InputFile | awk -F "level5" '{print $2}'` -Llevels[6]=`grep -E "^\s*level6" $InputFile | awk -F "level6" '{print $2}'` -Llevels[7]=`grep -E "^\s*level7" $InputFile | awk -F "level7" '{print $2}'` -Llevels[8]=`grep -E "^\s*level8" $InputFile | awk -F "level8" '{print $2}'` -Llevels[9]=`grep -E "^\s*level9" $InputFile | awk -F "level9" '{print $2}'` - - -# (0.1.10)get some parameters for METROPOLIS -Start_tem_S_in=`grep -E "^\s*Start_tem_S" $InputFile \\ - | awk -F "Start_tem_S" '{print $0}' | awk '{print $2}'` -if ( test $Start_tem_S_in != " ") -then -Start_tem_S=$Start_tem_S_in -else -Start_tem_S=1.0e-4 #default -fi - - -Start_tem_K_in=`grep -E "^\s*Start_tem_K" $InputFile \\ - | awk -F "Start_tem_K" '{print $0}' | awk '{print $2}'` -if ( test $Start_tem_K_in != " " ) -then -Start_tem_K=$Start_tem_K_in -else -Start_tem_K=1.0e-2 #default -fi - -Step_S_in=`grep -E "^\s*Step_S" $InputFile \\ - | awk -F "Step_S" '{print $0}' | awk '{print $2}'` -if ( test $Step_S_in != " " ) -then -Step_S=$Step_S_in -else -Step_S=30 #default -fi - -Step_K_in=`grep -E "^\s*Step_K" $InputFile \\ - | awk -F "Step_K" '{print $0}' | awk '{print $2}'` -if ( test $Step_K_in != " ") -then -Step_K=$Step_K_in -else -Step_K=20 #default -fi - -Delta_kappa_in=`grep -E "^\s*Delta_kappa" $InputFile \\ - | awk -F "Delta_kappa" '{print $0}' | awk '{print $2}'` -Delta_kappa=$Delta_kappa_in -#echo " Delta_kappa=$Delta_kappa" - - - -# (1.1) output which element you want to calculate -echo " -------------------------------------------------------> $element" - -# (1.2) make the dir, the name is 'name' -if ( test -d $name ) -then - echo " The dir exist: $name" -else - echo " Make dir: $name" - mkdir $name -fi - -# (1.3) enter the name dir -cd $name - -## (1.4) another big cicle come: the rcut cicle. -count_r=1 -while [ $count_r -le $rcut_number ] -do - ### (1.4.1) - #rcut=`echo "$info_r" | awk '{print $'$count_r'}' ` - rcut=${info_r[count_r-1]} - echo " |run cicle: rcut=$rcut" - - - - ### (1.4.1.5) enter the third big cicle: iSTRU + done # first cicle of iSTRU + if [ "$nSTRU" == "1" ]; then + SkipSTRU[1]=0 + fi + + # (0.1.8)get the level + #Level=`grep "Level" $InputFile | awk -F "level" '{print $0}' | awk '{print $2}'` + #echo "__Level=$Level" + + # (0.1.9)get every level`s lmax s p d f g + Llevels[1]=$(grep -E "^\s*level1" $InputFile | awk -F "level1" '{print $2}') + Llevels[2]=$(grep -E "^\s*level2" $InputFile | awk -F "level2" '{print $2}') + Llevels[3]=$(grep -E "^\s*level3" $InputFile | awk -F "level3" '{print $2}') + Llevels[4]=$(grep -E "^\s*level4" $InputFile | awk -F "level4" '{print $2}') + Llevels[5]=$(grep -E "^\s*level5" $InputFile | awk -F "level5" '{print $2}') + Llevels[6]=$(grep -E "^\s*level6" $InputFile | awk -F "level6" '{print $2}') + Llevels[7]=$(grep -E "^\s*level7" $InputFile | awk -F "level7" '{print $2}') + Llevels[8]=$(grep -E "^\s*level8" $InputFile | awk -F "level8" '{print $2}') + Llevels[9]=$(grep -E "^\s*level9" $InputFile | awk -F "level9" '{print $2}') + + # (0.1.10)get some parameters for METROPOLIS + Start_tem_S_in=$(grep -E "^\s*Start_tem_S" $InputFile | + awk -F "Start_tem_S" '{print $0}' | awk '{print $2}') + if (test $Start_tem_S_in != " "); then + Start_tem_S=$Start_tem_S_in + else + Start_tem_S=1.0e-4 #default + fi + + Start_tem_K_in=$(grep -E "^\s*Start_tem_K" $InputFile | + awk -F "Start_tem_K" '{print $0}' | awk '{print $2}') + if (test $Start_tem_K_in != " "); then + Start_tem_K=$Start_tem_K_in + else + Start_tem_K=1.0e-2 #default + fi + + Step_S_in=$(grep -E "^\s*Step_S" $InputFile | + awk -F "Step_S" '{print $0}' | awk '{print $2}') + if (test $Step_S_in != " "); then + Step_S=$Step_S_in + else + Step_S=30 #default + fi + + Step_K_in=$(grep -E "^\s*Step_K" $InputFile | + awk -F "Step_K" '{print $0}' | awk '{print $2}') + if (test $Step_K_in != " "); then + Step_K=$Step_K_in + else + Step_K=20 #default + fi + + Delta_kappa_in=$(grep -E "^\s*Delta_kappa" $InputFile | + awk -F "Delta_kappa" '{print $0}' | awk '{print $2}') + Delta_kappa=$Delta_kappa_in + #echo " Delta_kappa=$Delta_kappa" + + # (1.1) output which element you want to calculate + echo " -------------------------------------------------------> $element" + + # (1.2) make the dir, the name is 'name' + if (test -d $name); then + echo " The dir exist: $name" + else + echo " Make dir: $name" + mkdir $name + fi + + # (1.3) enter the name dir + cd $name + + ## (1.4) another big cicle come: the rcut cicle. + count_r=1 + while [ $count_r -le $rcut_number ]; do + ### (1.4.1) + #rcut=`echo "$info_r" | awk '{print $'$count_r'}' ` + rcut=${info_r[count_r - 1]} + echo " |run cicle: rcut=$rcut" + + ### (1.4.1.5) enter the third big cicle: iSTRU echo " nSTRU = $nSTRU " - for((iSTRU=1;iSTRU<=$nSTRU;iSTRU++)) - do - if ( test ${SkipSTRU[iSTRU]} -eq 1 ); then + for ((iSTRU = 1; iSTRU <= $nSTRU; iSTRU++)); do + if (test ${SkipSTRU[iSTRU]} -eq 1); then echo " |skip cicle: iSTRU=$iSTRU" - continue; - fi - echo " |run cicle: iSTRU=$iSTRU" - - - - ### (1.4.3) mkdir of rcut - test -d $rcut || mkdir $rcut - # (1.4.3.1) - cd $rcut - - iSTRULeft=`expr $iSTRU \- 1` - if [ "${BeginLevel[iSTRU]}" == "" ] ; then - BeginLevel[$iSTRU]=$((${EndLevel[iSTRULeft]}+1)) - echo -e "\n not found BeginLevel[$iSTRU], use: EndLevel[iSTRULeft]+1" + continue + fi + echo " |run cicle: iSTRU=$iSTRU" + + ### (1.4.3) mkdir of rcut + test -d $rcut || mkdir $rcut + # (1.4.3.1) + cd $rcut + + iSTRULeft=$(expr $iSTRU \- 1) + if [ "${BeginLevel[iSTRU]}" == "" ]; then + BeginLevel[$iSTRU]=$((${EndLevel[iSTRULeft]} + 1)) + echo -e "\n not found BeginLevel[$iSTRU], use: EndLevel[iSTRULeft]+1" + fi + echo -e "\n BeginLevel[iSTRU]=${BeginLevel[iSTRU]}, EndLevel[iSTRU]=${EndLevel[iSTRU]} " + + ### set if restart from previous SIA runs + ### if ( test SkipSTRU[`expr $iSTRU - 1`] -eq 1 ) ; then + #ifRestart=${RestartSTRU[$iSTRU]} + if [ "${RestartSTRU[$iSTRU]}" == "" ]; then + if [ $iSTRU -gt 1 ]; then + RestartSTRU[$iSTRU]=1 + else + RestartSTRU[$iSTRU]=0 fi - echo -e "\n BeginLevel[iSTRU]=${BeginLevel[iSTRU]}, EndLevel[iSTRU]=${EndLevel[iSTRU]} " - - - - ### set if restart from previous SIA runs - ### if ( test SkipSTRU[`expr $iSTRU - 1`] -eq 1 ) ; then - #ifRestart=${RestartSTRU[$iSTRU]} - if [ "${RestartSTRU[$iSTRU]}" == "" ] ; then - if [ $iSTRU -gt 1 ] ; then - RestartSTRU[$iSTRU]=1 - else - RestartSTRU[$iSTRU]=0 + fi + + echo " RestartSTRU[$iSTRU] = ${RestartSTRU[$iSTRU]} " + if [ ${RestartSTRU[$iSTRU]} -eq 0 ]; then + completelyNewCalc + else + if [ $iSTRU -gt 1 ]; then + + echo " " + echo " Current *.dat/*.txt ... will be considered previous calculation results of STRU${iSTRULeft} " + # + #if [ -f "ORBITAL_RESULTS.txt" ] ; then + # echo " Found file: ORBITAL_RESULTS.txt, continue ... " + #else + # echo " Can't find: ORBITAL_RESULTS.txt, exiting ... " + # exit + #fi + # + # + if [ ! -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then + echo " Move Previous Orbital files and Rename as STRU${iSTRULeft}.*" + # + if (test -f "ORBITAL_RESULTS.txt"); then + mv "ORBITAL_RESULTS.txt" "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" fi - fi - - - echo " RestartSTRU[$iSTRU] = ${RestartSTRU[$iSTRU]} " - if [ ${RestartSTRU[$iSTRU]} -eq 0 ] ; then - completelyNewCalc - else - if [ $iSTRU -gt 1 ]; then - - echo " " - echo " Current *.dat/*.txt ... will be considered previous calculation results of STRU${iSTRULeft} " - # - #if [ -f "ORBITAL_RESULTS.txt" ] ; then - # echo " Found file: ORBITAL_RESULTS.txt, continue ... " - #else - # echo " Can't find: ORBITAL_RESULTS.txt, exiting ... " - # exit - #fi - # - # - if [ ! -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then - echo " Move Previous Orbital files and Rename as STRU${iSTRULeft}.*" - # - if ( test -f "ORBITAL_RESULTS.txt" ); then - mv "ORBITAL_RESULTS.txt" "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" - fi - # - if ( test -f "INPUT" ); then - mv "INPUT" "STRU${iSTRULeft}.INPUT" - fi - # - if ( test -f "ORBITAL_${id}U.dat" ); then - mv "ORBITAL_${id}U.dat" "STRU${iSTRULeft}.ORBITAL_${id}U.dat" - fi - # - if ( test -f "ORBITAL_${id}L.dat" ); then - mv "ORBITAL_${id}L.dat" "STRU${iSTRULeft}.ORBITAL_${id}L.dat" - fi - # - if ( test -f "ORBITAL_ECUT.txt" ); then - mv "ORBITAL_ECUT.txt" "STRU${iSTRULeft}.ORBITAL_ECUT.txt" - fi - # - if ( test -f "ORBITAL_KINETIC.txt" ); then - mv "ORBITAL_KINETIC.txt" "STRU${iSTRULeft}.ORBITAL_KINETIC.txt" - fi - # - if ( test -f "ORBITAL_PLOTL.dat" ); then - mv "ORBITAL_PLOTL.dat" "STRU${iSTRULeft}.ORBITAL_PLOTL.dat" - fi - # - if ( test -f "ORBITAL_PLOTU.dat" ); then - mv "ORBITAL_PLOTU.dat" "STRU${iSTRULeft}.ORBITAL_PLOTU.dat" - fi - # - if ( test -f "ORBITAL_PLOTUK.dat" ); then - mv "ORBITAL_PLOTUK.dat" "STRU${iSTRULeft}.ORBITAL_PLOTUK.dat" - fi - # - if ( test -f "running_1.txt" ); then - mv "running_1.txt" "STRU${iSTRULeft}.running_1.txt" - fi - # - fi - # - if [ -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ] ; then - echo " Found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, copy as ORBITAL_RESULTS.txt ... " - cp -ap "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" "ORBITAL_RESULTS.txt" - else - echo " Not found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, exiting ... " - exit - fi - else - echo " Current *.dat/*.txt ... will be considered previous calc. results of STRU${iSTRU} " - echo " Before SIA Calculation: mv ... & cp ... " - echo " Move: INPUT/*.dat/*.txt to Old/ " - mkdir -p Old - # - if ( test -f "INPUT" ); then - mv "INPUT" "Old/INPUT" - fi - if ( test -f "ORBITAL_${id}U.dat" ); then - mv "ORBITAL_${id}U.dat" "Old/ORBITAL_${id}U.dat" - fi - if ( test -f "ORBITAL_${id}L.dat" ); then - mv "ORBITAL_${id}L.dat" "Old/ORBITAL_${id}L.dat" - fi - if ( test -f "ORBITAL_ECUT.txt" ); then - mv "ORBITAL_ECUT.txt" "Old/ORBITAL_ECUT.txt" - fi - if ( test -f "ORBITAL_KINETIC.txt" ); then - mv "ORBITAL_KINETIC.txt" "Old/ORBITAL_KINETIC.txt" - fi - if ( test -f "ORBITAL_PLOTL.dat" ); then - mv "ORBITAL_PLOTL.dat" "Old/ORBITAL_PLOTL.dat" - fi - if ( test -f "ORBITAL_PLOTU.dat" ); then - mv "ORBITAL_PLOTU.dat" "Old/ORBITAL_PLOTU.dat" - fi - if ( test -f "ORBITAL_PLOTUK.dat" ); then - mv "ORBITAL_PLOTUK.dat" "Old/ORBITAL_PLOTUK.dat" - fi - if ( test -f "running_1.txt" ); then - mv "running_1.txt" "Old/running_1.txt" - fi - # - echo " Copy ORBITAL_RESULTS.txt to Old/ " - if ( test -f "ORBITAL_RESULTS.txt" ); then - cp -avp "ORBITAL_RESULTS.txt" "Old/ORBITAL_RESULTS.txt" - fi - # - echo " Start (SIA) Calculation:" + # + if (test -f "INPUT"); then + mv "INPUT" "STRU${iSTRULeft}.INPUT" + fi + # + if (test -f "ORBITAL_${id}U.dat"); then + mv "ORBITAL_${id}U.dat" "STRU${iSTRULeft}.ORBITAL_${id}U.dat" + fi + # + if (test -f "ORBITAL_${id}L.dat"); then + mv "ORBITAL_${id}L.dat" "STRU${iSTRULeft}.ORBITAL_${id}L.dat" + fi + # + if (test -f "ORBITAL_ECUT.txt"); then + mv "ORBITAL_ECUT.txt" "STRU${iSTRULeft}.ORBITAL_ECUT.txt" + fi + # + if (test -f "ORBITAL_KINETIC.txt"); then + mv "ORBITAL_KINETIC.txt" "STRU${iSTRULeft}.ORBITAL_KINETIC.txt" fi - echo " " - echo " Restart from Previous Result: ORBITAL_RESULTS.txt " - if [ -f "ORBITAL_RESULTS.txt" ] ; then - echo " Found file: ORBITAL_RESULTS.txt " - else - echo " Not found file: ORBITAL_RESULTS.txt, exiting ... " - exit + # + if (test -f "ORBITAL_PLOTL.dat"); then + mv "ORBITAL_PLOTL.dat" "STRU${iSTRULeft}.ORBITAL_PLOTL.dat" fi - fi # which:: if [ ${RestartSTRU[$iSTRU]} -eq 0 ] ; then + # + if (test -f "ORBITAL_PLOTU.dat"); then + mv "ORBITAL_PLOTU.dat" "STRU${iSTRULeft}.ORBITAL_PLOTU.dat" + fi + # + if (test -f "ORBITAL_PLOTUK.dat"); then + mv "ORBITAL_PLOTUK.dat" "STRU${iSTRULeft}.ORBITAL_PLOTUK.dat" + fi + # + if (test -f "running_1.txt"); then + mv "running_1.txt" "STRU${iSTRULeft}.running_1.txt" + fi + # + fi + # + if [ -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then + echo " Found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, copy as ORBITAL_RESULTS.txt ... " + cp -ap "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" "ORBITAL_RESULTS.txt" + else + echo " Not found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, exiting ... " + exit + fi + else + echo " Current *.dat/*.txt ... will be considered previous calc. results of STRU${iSTRU} " + echo " Before SIA Calculation: mv ... & cp ... " + echo " Move: INPUT/*.dat/*.txt to Old/ " + mkdir -p Old + # + if (test -f "INPUT"); then + mv "INPUT" "Old/INPUT" + fi + if (test -f "ORBITAL_${id}U.dat"); then + mv "ORBITAL_${id}U.dat" "Old/ORBITAL_${id}U.dat" + fi + if (test -f "ORBITAL_${id}L.dat"); then + mv "ORBITAL_${id}L.dat" "Old/ORBITAL_${id}L.dat" + fi + if (test -f "ORBITAL_ECUT.txt"); then + mv "ORBITAL_ECUT.txt" "Old/ORBITAL_ECUT.txt" + fi + if (test -f "ORBITAL_KINETIC.txt"); then + mv "ORBITAL_KINETIC.txt" "Old/ORBITAL_KINETIC.txt" + fi + if (test -f "ORBITAL_PLOTL.dat"); then + mv "ORBITAL_PLOTL.dat" "Old/ORBITAL_PLOTL.dat" + fi + if (test -f "ORBITAL_PLOTU.dat"); then + mv "ORBITAL_PLOTU.dat" "Old/ORBITAL_PLOTU.dat" + fi + if (test -f "ORBITAL_PLOTUK.dat"); then + mv "ORBITAL_PLOTUK.dat" "Old/ORBITAL_PLOTUK.dat" + fi + if (test -f "running_1.txt"); then + mv "running_1.txt" "Old/running_1.txt" + fi + # + echo " Copy ORBITAL_RESULTS.txt to Old/ " + if (test -f "ORBITAL_RESULTS.txt"); then + cp -avp "ORBITAL_RESULTS.txt" "Old/ORBITAL_RESULTS.txt" + fi + # + echo " Start (SIA) Calculation:" + fi echo " " - - - - ### (1.4.3.5) exit the rcut dir - cd .. - - - - #### (1.4.2) enter the forth big cicle : Bond Length. - count=1 - while [ $count -le ${BL_number[iSTRU]} ] - do - - # (1.4.2.0) calculate the Bond Length for iSTRU - BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count'}' ` - dis1=$(echo "scale=5;$BL * 0.86603 "|bc) - dis2=$(echo "scale=5;$BL * 0.5 "|bc) - dis3=$(echo "scale=5;$BL * 0.81649 "|bc) - dis4=$(echo "scale=5;$BL * 0.28867 "|bc) - echo " |run cicle: BL=$BL" - -if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then -na=2 -cat > $name.stru << EOF + echo " Restart from Previous Result: ORBITAL_RESULTS.txt " + if [ -f "ORBITAL_RESULTS.txt" ]; then + echo " Found file: ORBITAL_RESULTS.txt " + else + echo " Not found file: ORBITAL_RESULTS.txt, exiting ... " + exit + fi + fi # which:: if [ ${RestartSTRU[$iSTRU]} -eq 0 ] ; then + echo " " + + ### (1.4.3.5) exit the rcut dir + cd .. + + #### (1.4.2) enter the forth big cicle : Bond Length. + count=1 + while [ $count -le ${BL_number[iSTRU]} ]; do + + # (1.4.2.0) calculate the Bond Length for iSTRU + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count'}') + dis1=$(echo "scale=5;$BL * 0.86603 " | bc) + dis2=$(echo "scale=5;$BL * 0.5 " | bc) + dis3=$(echo "scale=5;$BL * 0.81649 " | bc) + dis4=$(echo "scale=5;$BL * 0.28867 " | bc) + echo " |run cicle: BL=$BL" + + if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then + na=2 + cat >$name.stru < $name.stru << EOF + elif [ "${ListSTRU[iSTRU]}" == "trimer" ]; then + na=3 + cat >$name.stru < $name.stru << EOF + elif [ "${ListSTRU[iSTRU]}" == "tetramer" ]; then + na=4 + cat >$name.stru < KPOINTS << EOF + # (1.4.2.2) get KPOINTS + cat >KPOINTS < INPUTw << EOF + # (1.4.2.3) get INPUTw + cat >INPUTw < INPUTs << EOF -# INPUT_ORBITAL_INFORMATION -# -# 1 // smooth or not -# 0.1 // smearing_sigma -# $ecut // energy cutoff for spherical bessel functions(Ry) -# $rcut // cutoff of wavefunctions(a.u.) -# 1.0e-12 // tolerence -# -# EOF - - -# (1.4.2.5) get INPUT -cat > INPUT << EOF + # (1.4.2.4) get INPUTs + # cat > INPUTs << EOF + # INPUT_ORBITAL_INFORMATION + # + # 1 // smooth or not + # 0.1 // smearing_sigma + # $ecut // energy cutoff for spherical bessel functions(Ry) + # $rcut // cutoff of wavefunctions(a.u.) + # 1.0e-12 // tolerence + # + # EOF + + # (1.4.2.5) get INPUT + cat >INPUT < /dev/null 2>&1 ; then - echo " Skip_Calculation: $EXE_mpi $EXE_pw" - else - # (1.4.2.6) - #test -e ../node_openmpi && cp ../node_openmpi . - #------------- - #on Dirac - #------------- - #/opt/openmpi/bin/mpirun -np $cpu_number -machinefile node_openmpi $exe - #------------- - #on Einstein - #------------- - #mpiexec -np $cpu_num -machinefile node_openmpi $EXE_pw - #mpiexec -np $1 -machinefile $EXE_pw - - #exit - #mpiexec -n 12 -machinefile $PBS_NODEFILE $EXE_pw >> Log.txt - #mpirun -np $cpu_num $EXE_pw - #mpirun -hostfile "../$hostfpath" $EXE_pw - #mpirun -np $cpu_num -hostfile "../$hostfpath" $EXE_pw - - echo " $EXE_mpi $EXE_pw " - $EXE_mpi $EXE_pw - - #mv test.0.dat OUT.$element-$rcut-$BL/orb_matrix.0.dat - #mv test.1.dat OUT.$element-$rcut-$BL/orb_matrix.1.dat - #echo " Skip_Calculation: $EXE_mpi $EXE_pw" + pwd + if [ ${RestartSTRU[$iSTRU]} -eq 2 ]; then # grep -E "^\s*RestartSTRU" ../$InputFile > /dev/null 2>&1 ; then + echo " Skip_Calculation: $EXE_mpi $EXE_pw" + else + # (1.4.2.6) + #test -e ../node_openmpi && cp ../node_openmpi . + #------------- + #on Dirac + #------------- + #/opt/openmpi/bin/mpirun -np $cpu_number -machinefile node_openmpi $exe + #------------- + #on Einstein + #------------- + #mpiexec -np $cpu_num -machinefile node_openmpi $EXE_pw + #mpiexec -np $1 -machinefile $EXE_pw + + #exit + #mpiexec -n 12 -machinefile $PBS_NODEFILE $EXE_pw >> Log.txt + #mpirun -np $cpu_num $EXE_pw + #mpirun -hostfile "../$hostfpath" $EXE_pw + #mpirun -np $cpu_num -hostfile "../$hostfpath" $EXE_pw + + echo " $EXE_mpi $EXE_pw " + $EXE_mpi $EXE_pw + + #mv test.0.dat OUT.$element-$rcut-$BL/orb_matrix.0.dat + #mv test.1.dat OUT.$element-$rcut-$BL/orb_matrix.1.dat + #echo " Skip_Calculation: $EXE_mpi $EXE_pw" fi echo "" + #### end cicle (1.4.2): Bond Length + done + # (1.4.3.1) + cd $rcut - #### end cicle (1.4.2): Bond Length - done - - - - # (1.4.3.1) - cd $rcut + ###if [ "${EXE_orbital##*.}" != "py" ]; + if [ "${EXE_orbital:0-3:3}" != ".py" ]; then + echo -e " Using Simulated Annealing Method \n" - - - ###if [ "${EXE_orbital##*.}" != "py" ]; - if [ "${EXE_orbital:0-3:3}" != ".py" ]; - then - echo -e " Using Simulated Annealing Method \n" - - ### (1.4.3.2) prepare for the INPUT file -cat > INPUT << EOF + ### (1.4.3.2) prepare for the INPUT file + cat >INPUT < 1 // if or not calculate the spillage. 1/0 -$(( ${RestartSTRU[$iSTRU]} > 0 )) // restart or not. 1/0 +$((${RestartSTRU[$iSTRU]} > 0)) // restart or not. 1/0 1 // if or not output the file. 1/0 ${BL_number[iSTRU]} // number of structures. EOF -# (1.4.3.3) input the file names -count_files=1 -while [ $count_files -le ${BL_number[iSTRU]} ] -do - BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' ` - cat >> INPUT << EOF + # (1.4.3.3) input the file names + count_files=1 + while [ $count_files -le ${BL_number[iSTRU]} ]; do + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + cat >>INPUT < @@ -753,33 +707,29 @@ ${ref_bands[$iSTRU]} // int, the ed band index(> INPUT << EOF + cat >>INPUT < ${EndLevel[$iSTRU]} // Number of levels. label / na / skip / lmax / each L / EOF - -for((i=1;i<=${EndLevel[iSTRU]};i++)) -do - if [ $i -ge ${BeginLevel[iSTRU]} -a $i -le ${EndLevel[iSTRU]} ] - then - leveltype="new " - else - leveltype="skip" - fi -#echo "leveltype=$leveltype" -cat >> INPUT << EOF + for ((i = 1; i <= ${EndLevel[iSTRU]}; i++)); do + if [ $i -ge ${BeginLevel[iSTRU]} -a $i -le ${EndLevel[iSTRU]} ]; then + leveltype="new " + else + leveltype="skip" + fi + #echo "leveltype=$leveltype" + cat >>INPUT <> INPUT << EOF + cat >>INPUT < EOF -cat >> INPUT << EOF + cat >>INPUT < 0.01 //dr(a.u.) of uniform mesh. Attention!!dr will affect kinetic energy minmized largely. -6 //xmin @@ -807,26 +757,13 @@ cat >> INPUT << EOF EOF + elif [ "${EXE_orbital:0-12:12}" == "dpsi/main.py" ]; then # begin from if [ "${EXE_orbital:0-3:3}" != ".py" ]; + echo -e " Using PyTorch Gradient Method V2 (include dpsi) \n" + ### len(dis[info["input"]["element"]]), + ### (1.4.3.2) prepare INPUT file in json for PyTorch program - - - - - - - - - - - - elif [ "${EXE_orbital:0-12:12}" == "dpsi/main.py" ]; then # begin from if [ "${EXE_orbital:0-3:3}" != ".py" ]; - echo -e " Using PyTorch Gradient Method V2 (include dpsi) \n" - - ### len(dis[info["input"]["element"]]), - ### (1.4.3.2) prepare INPUT file in json for PyTorch program - -cat > INPUT << EOF + cat >INPUT < INPUT << EOF [ EOF -count_files=1 -while [ $count_files -lt ${BL_number[iSTRU]} ] -do - BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' ` - cat >> INPUT << EOF + count_files=1 + while [ $count_files -lt ${BL_number[iSTRU]} ]; do + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + let count_files++ + done + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF [ EOF -count_files=1 -while [ $count_files -lt ${BL_number[iSTRU]} ] -do - BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' ` - cat >> INPUT << EOF + count_files=1 + while [ $count_files -lt ${BL_number[iSTRU]} ]; do + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + let count_files++ + done + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + cat >>INPUT <> INPUT << EOF "$element": [ EOF + if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then + lr_value=0.0001 + else + lr_value=0.01 + fi + echo " iSTRULeft: $iSTRULeft, iSTRU: $iSTRU " + echo " BeginLevel[STRUs]: (${BeginLevel[@]}) " + echo " EndLevel[STRUs]: (${EndLevel[@]}) " + #if [ $ifRestart -eq 0 ] ; then + # C_init_from_file="false" + #elif [ $ifRestart -eq 1 ] ; then + # C_init_from_file="true" + #fi + + LValueMax=0 + for LValue in {0..4}; do + numL[$LValue]=0 + done -if [ ${RestartSTRU[$iSTRU]} -ge 1 ] ; then - lr_value=0.0001 -else - lr_value=0.01 -fi -echo " iSTRULeft: $iSTRULeft, iSTRU: $iSTRU " -echo " BeginLevel[STRUs]: (${BeginLevel[@]}) " -echo " EndLevel[STRUs]: (${EndLevel[@]}) " -#if [ $ifRestart -eq 0 ] ; then -# C_init_from_file="false" -#elif [ $ifRestart -eq 1 ] ; then -# C_init_from_file="true" -#fi - - -LValueMax=0 -for LValue in {0..4} ; -do - numL[$LValue]=0 -done - -for((i=1;i<=${EndLevel[iSTRU]};i++)) -do - #if [ $i -le ${EndLevel[iSTRULeft]} ]; - #then - # C_init_from_file="true" - # #echo " Level:$i, C_init_from_file = " $C_init_from_file - #fi - - Llevels_i=( ${Llevels[i]} ) - for LValue in {0..4} ; - do - nAdd=${Llevels_i[$LValue+1]} - #echo " nAdd = $nAdd" - if [ "$nAdd" != "" ]; then - numL[$LValue]=$(( ${numL[$LValue]} + $nAdd )) - - if [ $LValueMax -lt $LValue ]; then + for ((i = 1; i <= ${EndLevel[iSTRU]}; i++)); do + #if [ $i -le ${EndLevel[iSTRULeft]} ]; + #then + # C_init_from_file="true" + # #echo " Level:$i, C_init_from_file = " $C_init_from_file + #fi + + Llevels_i=(${Llevels[i]}) + for LValue in {0..4}; do + nAdd=${Llevels_i[$LValue + 1]} + #echo " nAdd = $nAdd" + if [ "$nAdd" != "" ]; then + numL[$LValue]=$((${numL[$LValue]} + $nAdd)) + + if [ $LValueMax -lt $LValue ]; then LValueMax=$LValue + fi fi - fi - done -done -echo " numL = ${numL[@]}, LValueMax = $LValueMax " + done + done + echo " numL = ${numL[@]}, LValueMax = $LValueMax " -for((LValue=0; LValue<${LValueMax}; LValue++)) -do - cat >> INPUT << EOF + for ((LValue = 0; LValue < ${LValueMax}; LValue++)); do + cat >>INPUT <> INPUT << EOF + cat >>INPUT <> INPUT << EOF + for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do + cat >>INPUT <> INPUT << EOF + done + cat >>INPUT <> INPUT << EOF + if [ 2 -ge 1 ]; then + cat >>INPUT <> INPUT << EOF - `printf %.0f ${ref_bands[iSTRU]}`, + for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do + cat >>INPUT <> INPUT << EOF - `printf %.0f ${ref_bands[iSTRU]}` + done + cat >>INPUT <> INPUT << EOF + else + cat >>INPUT <> INPUT << EOF + cat >>INPUT <> INPUT << EOF + C_init_file="ORBITAL_RESULTS.txt" + if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then ## [ "$C_init_from_file" == "true" ]; then + cat >>INPUT <> INPUT << EOF + echo -e " init_from_file : true, \n C_init_file : $C_init_file, \n opt_C_read: false\n" + elif [ ${RestartSTRU[$iSTRU]} -eq 0 ]; then + cat >>INPUT <> INPUT << EOF + cat >>INPUT < INPUT << EOF + cat >INPUT <> INPUT << EOF + count_files=1 + while [ $count_files -lt ${BL_number[iSTRU]} ]; do + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + let count_files++ + done + BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF "$element": [ EOF + echo " iSTRULeft: $iSTRULeft, iSTRU: $iSTRU " + echo " BeginLevel[STRUs]: (${BeginLevel[@]}) " + echo " EndLevel[STRUs]: (${EndLevel[@]}) " + #if [ $ifRestart -eq 0 ] ; then + # C_init_from_file="false" + #elif [ $ifRestart -eq 1 ] ; then + # C_init_from_file="true" + #fi + + LValueMax=0 + for LValue in {0..4}; do + numL[$LValue]=0 + done -echo " iSTRULeft: $iSTRULeft, iSTRU: $iSTRU " -echo " BeginLevel[STRUs]: (${BeginLevel[@]}) " -echo " EndLevel[STRUs]: (${EndLevel[@]}) " -#if [ $ifRestart -eq 0 ] ; then -# C_init_from_file="false" -#elif [ $ifRestart -eq 1 ] ; then -# C_init_from_file="true" -#fi - -LValueMax=0 -for LValue in {0..4} ; -do - numL[$LValue]=0 -done - -for((i=1;i<=${EndLevel[iSTRU]};i++)) -do - #if [ $i -le ${EndLevel[iSTRULeft]} ]; - #then - # C_init_from_file="true" - # #echo " Level:$i, C_init_from_file = " $C_init_from_file - #fi - - Llevels_i=( ${Llevels[i]} ) - for LValue in {0..4} ; - do - nAdd=${Llevels_i[$LValue+1]} - #echo " nAdd = $nAdd" - if [ "$nAdd" != "" ]; then - numL[$LValue]=$(( ${numL[$LValue]} + $nAdd )) - - if [ $LValueMax -lt $LValue ]; then + for ((i = 1; i <= ${EndLevel[iSTRU]}; i++)); do + #if [ $i -le ${EndLevel[iSTRULeft]} ]; + #then + # C_init_from_file="true" + # #echo " Level:$i, C_init_from_file = " $C_init_from_file + #fi + + Llevels_i=(${Llevels[i]}) + for LValue in {0..4}; do + nAdd=${Llevels_i[$LValue + 1]} + #echo " nAdd = $nAdd" + if [ "$nAdd" != "" ]; then + numL[$LValue]=$((${numL[$LValue]} + $nAdd)) + + if [ $LValueMax -lt $LValue ]; then LValueMax=$LValue + fi fi - fi - done -done -echo " numL = ${numL[@]}, LValueMax = $LValueMax " - + done + done + echo " numL = ${numL[@]}, LValueMax = $LValueMax " -for((LValue=0; LValue<${LValueMax}; LValue++)) -do - cat >> INPUT << EOF + for ((LValue = 0; LValue < ${LValueMax}; LValue++)); do + cat >>INPUT <> INPUT << EOF + done + cat >>INPUT <> INPUT << EOF + for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do + cat >>INPUT <> INPUT << EOF + done + cat >>INPUT <> INPUT << EOF + for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do + cat >>INPUT <> INPUT << EOF + done + if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then + lr_value=0.0001 + else + lr_value=0.01 + fi + cat >>INPUT <> INPUT << EOF + C_init_file="ORBITAL_RESULTS.txt" + if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then ## [ "$C_init_from_file" == "true" ]; then + cat >>INPUT <> INPUT << EOF + echo -e " init_from_file : true \n C_init_file : $C_init_file \n " + elif [ ${RestartSTRU[$iSTRU]} -eq 0 ]; then + cat >>INPUT <> INPUT << EOF + cat >>INPUT <> Log.txt - echo " Run $EXE_orbital" + export OMP_NUM_THREADS=$Host1_NCore + echo " Set OMP_NUM_THREADS = $OMP_NUM_THREADS " + echo " Python2 Version: " $(which python2) + echo " Python3 Version: " $(which python3) echo "" - $EXE_orbital - #mpirun -np cpu_num $EXE_orbital + fi # begin from: if [ "${EXE_orbital:0-3:3}" != ".py" ]; + #cat INPUT + #mpiexec -n 1 -machinefile $PBS_NODEFILE $EXE_orbital >> Log.txt + echo " Run $EXE_orbital" + echo "" + $EXE_orbital + #mpirun -np cpu_num $EXE_orbital - if [ "${EXE_orbital:0-3:3}" == ".py" ]; then - echo "" - unset OMP_NUM_THREADS - echo " unset OMP_NUM_THREADS " - #... - #echo " Back to Python2: " `which python2` - #echo " Back to Python3: " `which python3` - sleep 1 - fi - - #exit - - ### (1.4.3.5) exit the rcut dir - cd .. - ### end cicle (1.4.1.5): iSTRU - done - - - -let count_r++ -## end cicle (1.4): rcut -done - - - -# (1.5) exit the name dir. -cd .. + if [ "${EXE_orbital:0-3:3}" == ".py" ]; then + echo "" + unset OMP_NUM_THREADS + echo " unset OMP_NUM_THREADS " + #... + #echo " Back to Python2: " `which python2` + #echo " Back to Python3: " `which python3` + sleep 1 + fi + + #exit + + ### (1.4.3.5) exit the rcut dir + cd .. + ### end cicle (1.4.1.5): iSTRU + done + + let count_r++ + ## end cicle (1.4): rcut + done + + # (1.5) exit the name dir. + cd .. done # end cicle (1): targets -time_end=`date +%s` -time_passed=$(($time_end - $time_start)) +time_end=$(date +%s) +time_passed=$(($time_end - $time_start)) echo -e " Total Time: $time_passed \n" - diff --git a/tools/01_NAO_generation/SIAB/tests_p/p.sh b/tools/01_NAO_generation/SIAB/tests_p/p.sh index 8e958557ec7..64116c33fca 100644 --- a/tools/01_NAO_generation/SIAB/tests_p/p.sh +++ b/tools/01_NAO_generation/SIAB/tests_p/p.sh @@ -1,4 +1,3 @@ #!/bin/sh #/share/data2/openmpi-gnu/bin/mpirun -np $1 -machinefile node_openmpi ../042.MCSP_p.exe /opt/openmpi-intel9/bin/mpirun -np $1 -machinefile node_openmpi ../042.MCSP_p.exe - diff --git a/tools/01_NAO_generation/SIAB/tests_s/s.sh b/tools/01_NAO_generation/SIAB/tests_s/s.sh index 225b61ca0d0..be9318c7929 100644 --- a/tools/01_NAO_generation/SIAB/tests_s/s.sh +++ b/tools/01_NAO_generation/SIAB/tests_s/s.sh @@ -1,3 +1,3 @@ #!/bin/sh #/share/apps/mpich/1.2.7-gnu/bin/mpirun -machinefile node -np $1 ./fp_mpi.x $2 -../046.MCSP_s.exe +../046.MCSP_s.exe diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh index 50b7e779ce4..1ff346ba6d3 100755 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh @@ -1,33 +1,33 @@ #!/bin/bash -# author mohan +# author mohan # edit by Pengfei Li 2013-6-4 # edit by WenShuai Zhang (2016-11-30) with changelog: # 1. fix bugs when read "ORBITAL_INPUT" for lines begin with "#" or " ". -# 2. add support for generating orbital with multi different types of structures together, +# 2. add support for generating orbital with multi different types of structures together, # such as dimer STRU & tetramer STRU and so on. # args=$@ -if [ "$args" == "--help" -o "$args" == "-h" ] ; then - echo " Usage: ./ThisScript.sh " - echo " Example: ./generate_orbital.sh ORBITAL_INPUT_MixSTRU " - echo " If no , use default input file: ORBITAL_INPUT" - echo " " - exit -elif [ ! -z $1 ] && [ -f $1 ] ; then - InputFile=$1 -elif [ -f 'ORBITAL_INPUT' ] ; then - echo " Can't find specified input file, use default: ORBITAL_INPUT " - InputFile="ORBITAL_INPUT" +if [ "$args" == "--help" -o "$args" == "-h" ]; then + echo " Usage: ./ThisScript.sh " + echo " Example: ./generate_orbital.sh ORBITAL_INPUT_MixSTRU " + echo " If no , use default input file: ORBITAL_INPUT" + echo " " + exit +elif [ ! -z $1 ] && [ -f $1 ]; then + InputFile=$1 +elif [ -f 'ORBITAL_INPUT' ]; then + echo " Can't find specified input file, use default: ORBITAL_INPUT " + InputFile="ORBITAL_INPUT" else - echo " Can't find specified input file or default file: ORBITAL_INPUT" - echo " see help by '-h' " - echo " " - exit + echo " Can't find specified input file or default file: ORBITAL_INPUT" + echo " see help by '-h' " + echo " " + exit fi echo " InputFile='$InputFile'" -if [ -z $InputFile ]; then - echo " Can't find input file" - exit; +if [ -z $InputFile ]; then + echo " Can't find input file" + exit fi # echo " " @@ -38,371 +38,348 @@ echo " * * " echo " ********************************************************* " #----------------------------------------------------------------- # -# (0.0) fixed parameters +# (0.0) fixed parameters # #----------------------------------------------------------------- -mass=1 #not used yet. -lat0=20 #in a.u - +mass=1 #not used yet. +lat0=20 #in a.u #----------------------------------------------------------------- # # (0.1) input parameters # #----------------------------------------------------------------- -EXE_mpi="`grep -E "^\s*EXE_mpi" $InputFile | awk -F "EXE_mpi" '{print $2}' `" +EXE_mpi="$(grep -E "^\s*EXE_mpi" $InputFile | awk -F "EXE_mpi" '{print $2}')" if [ -z "$EXE_mpi" ]; then - cpu_num=8 - hostfpath="myhosts" - #hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts" - grep slots $hostfpath > /dev/null - if [ $? = 0 ] ; then # has "slots" in file: $hostfpath - cpu_num=`cat $hostfpath |cut -d "=" -f 2-3|awk '{sum += $1};END {print sum}'` - else - cpu_num=`cat $hostfpath |wc -l` - fi - echo " cpu_num=$cpu_num" - echo " hostfpath=$hostfpath" - EXE_mpi="mpirun -np $cpu_num -hostfile ../$hostfpath " + cpu_num=8 + hostfpath="myhosts" + #hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts" + grep slots $hostfpath >/dev/null + if [ $? = 0 ]; then # has "slots" in file: $hostfpath + cpu_num=$(cat $hostfpath | cut -d "=" -f 2-3 | awk '{sum += $1};END {print sum}') + else + cpu_num=$(cat $hostfpath | wc -l) + fi + echo " cpu_num=$cpu_num" + echo " hostfpath=$hostfpath" + EXE_mpi="mpirun -np $cpu_num -hostfile ../$hostfpath " fi -echo " EXE_mpi = $EXE_mpi" +echo " EXE_mpi = $EXE_mpi" # (0.1.1) get exe -EXE_pw=`grep -E "^\s*EXE_pw" $InputFile | awk -F "EXE_pw" '{print $0}' | awk '{print $2}'` +EXE_pw=$(grep -E "^\s*EXE_pw" $InputFile | awk -F "EXE_pw" '{print $0}' | awk '{print $2}') # (0.1.2)get SIA -EXE_orbital=`grep -E "^\s*EXE_orbital" $InputFile | awk -F "EXE_orbital" '{print $0}' | awk '{print $2}'` +EXE_orbital=$(grep -E "^\s*EXE_orbital" $InputFile | awk -F "EXE_orbital" '{print $0}' | awk '{print $2}') # (0.1.3)get the targets element and id -targets=`grep -E "^\s*targets" $InputFile | awk -F "targets" '{print $0}' | awk '{print $2}'` -echo " targets = $targets" +targets=$(grep -E "^\s*targets" $InputFile | awk -F "targets" '{print $0}' | awk '{print $2}') +echo " targets = $targets" for name in $targets; do -#echo "name=$name" -element=`echo "$name" | awk -F "_" '{print $2}'` -#echo "element=$element" -id=`echo "$name" | awk -F "_" '{print $1}'` -#echo "id=$id" - -# (0.1.6)get the pseudo_dir -pseudo_dir=`grep -E "^\s*Pseudo_dir" $InputFile | awk -F "Pseudo_dir" '{print $0}' | awk '{print $2}'` - -# (0.1.12) get the ecut -ecut=`grep -E "^\s*Ecut" $InputFile | awk -F "Ecut" '{print $0}' | awk '{print $2}'` -echo " ecut = $ecut" - -# (0.1.13) get the info about rcut,pseudo -info_r=`grep -E "^\s*Rcut" $InputFile | awk -F "Rcut" '{print $0}' | awk '{print $2}'` -rcut_number=`echo "$info_r" | awk '// {print NF}'` -echo " rcut_number = $rcut_number, info_r =" $info_r - -# (0.1.14) get the pseudopotential -pseudofile=`grep -E "^\s*Pseudo " $InputFile | awk -F "Pseudo " '{print $0}' | awk '{print $2}'` -echo " pseudo = $pseudofile" - -# (0.1.15) get the smearing -smearing_sigma=`grep -E "^\s*smearing_sigma " $InputFile | awk -F "smearing_sigma " '{print $0}' | awk '{print $2}'` -echo " smearing_sigma = $smearing_sigma" - - -# -# (0.1.7)get maxL S P D -maxL=`grep -E "^\s*maxL" $InputFile | awk -F "maxL" '{print $0}' | awk '{print $2}'` - -#if ( test $maxL = 0 ) // mohan's scheme -#then -#S_MIN=1 -#P_MIN=" " -#D_MIN=" " -#elif ( test $maxL = 1 ) -#then -#S_MIN=1 -#P_MIN=1 -#D_MIN=" " -#else -#S_MIN=1 -#P_MIN=1 -#D_MIN=1 -#fi - - -# (0.x.x) check info (include Level) for each STRU -NSTRU=`grep -E "^\s*BLSTRU" $InputFile | wc -l` -echo " NSTRU = $NSTRU" -# -LevelEnd[0]=0 -SkipSTRU[0]=0 -ListSTRU[0]=" " -for((iSTRU=1;iSTRU<=$NSTRU;iSTRU++)) -do - -ListSTRU[iSTRU]=`grep -E "^\s*ListSTRU " $InputFile |awk -F "ListSTRU" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` -echo " STRU[$iSTRU] = ${ListSTRU[iSTRU]}" - - -info[iSTRU]=`grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}'` -BL_number[iSTRU]=`echo "${info[iSTRU]}" | awk '// {print NF}'` - -# (0.1.11) calculate the number of different dimers or trimers. -#info=`grep "Dis1" $InputFile | awk -F "Dis1" '{print $2}'` -#BL_number=`echo "$info" | awk '// {print NF}'` -echo " BL_number[$iSTRU] = ${BL_number[iSTRU]}, info[$iSTRU] =" ${info[iSTRU]} - -LevelEnd[iSTRU]=`grep -E "^\s*Level" $InputFile |awk -F "Level" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` -echo " LevelEnd[$iSTRU] = ${LevelEnd[iSTRU]}" - -# (0.1.4)get the nbands -nbands[iSTRU]=`grep -E "^\s*nbands" $InputFile | awk -F "nbands" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` -echo " nbands[$iSTRU] = ${nbands[iSTRU]}" - -# (0.1.5)get the ref_bands -ref_bands[iSTRU]=`grep -E "^\s*ref_bands" $InputFile | awk -F "$ref_bands" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` -echo " ref_bands[$iSTRU] = ${ref_bands[iSTRU]}" - - -SkipSTRU[iSTRU]=0 -if ( test -n "`grep -E "^\s*SkipSTRU" $InputFile`" ); then -SkipSTRU[iSTRU]=`grep -E "^\s*SkipSTRU" $InputFile | awk -F "$SkipSTRU" '{print $0}' \\ - |awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'` -fi -echo " SkipSTRU[$iSTRU] = ${SkipSTRU[iSTRU]}" -done # first cicle of iSTRU -if [ "$NSTRU" == "1" ]; then - SkipSTRU[1]=0 -fi - -# (0.1.8)get the level -#Level=`grep "Level" $InputFile | awk -F "level" '{print $0}' | awk '{print $2}'` -#echo "__Level=$Level" - - -# (0.1.9)get every level`s lmax s p d f g -L[1]=`grep -E "^\s*level1" $InputFile | awk -F "level1" '{print $2}'` -L[2]=`grep -E "^\s*level2" $InputFile | awk -F "level2" '{print $2}'` -L[3]=`grep -E "^\s*level3" $InputFile | awk -F "level3" '{print $2}'` -L[4]=`grep -E "^\s*level4" $InputFile | awk -F "level4" '{print $2}'` -L[5]=`grep -E "^\s*level5" $InputFile | awk -F "level5" '{print $2}'` -L[6]=`grep -E "^\s*level6" $InputFile | awk -F "level6" '{print $2}'` -L[7]=`grep -E "^\s*level7" $InputFile | awk -F "level7" '{print $2}'` -L[8]=`grep -E "^\s*level8" $InputFile | awk -F "level8" '{print $2}'` -L[9]=`grep -E "^\s*level9" $InputFile | awk -F "level9" '{print $2}'` - - -# (0.1.10)get some parameters for METROPOLIS -Start_tem_S_in=`grep -E "^\s*Start_tem_S" $InputFile \\ - | awk -F "Start_tem_S" '{print $0}' | awk '{print $2}'` -if ( test $Start_tem_S_in != " ") -then -Start_tem_S=$Start_tem_S_in -else -Start_tem_S=1.0e-4 #default -fi - - -Start_tem_K_in=`grep -E "^\s*Start_tem_K" $InputFile \\ - | awk -F "Start_tem_K" '{print $0}' | awk '{print $2}'` -if ( test $Start_tem_K_in != " " ) -then -Start_tem_K=$Start_tem_K_in -else -Start_tem_K=1.0e-2 #default -fi - -Step_S_in=`grep -E "^\s*Step_S" $InputFile \\ - | awk -F "Step_S" '{print $0}' | awk '{print $2}'` -if ( test $Step_S_in != " " ) -then -Step_S=$Step_S_in -else -Step_S=20 #default -fi - -Step_K_in=`grep -E "^\s*Step_K" $InputFile \\ - | awk -F "Step_K" '{print $0}' | awk '{print $2}'` -if ( test $Step_K_in != " ") -then -Step_K=$Step_K_in -else -Step_K=15 #default -fi - -Delta_kappa_in=`grep -E "^\s*Delta_kappa" $InputFile \\ - | awk -F "Delta_kappa" '{print $0}' | awk '{print $2}'` -Delta_kappa=$Delta_kappa_in -#echo " Delta_kappa=$Delta_kappa" - - -#----------------------------------------------------------------- -# -# (1) big cicle, cicle of targets -# -#----------------------------------------------------------------- - -# (1.1) output which element you want to calculate -echo " -------------------------------------------------------> $element" - -# (1.2) make the dir, the name is 'name' -if ( test -d $name ) -then - echo " The dir exist: $name" -else - echo " Make dir: $name" - mkdir $name -fi - -# (1.3) enter the name dir -cd $name - -# (1.4) another big cicle come: the rcut cicle. -count_r=1 -while [ $count_r -le $rcut_number ] -do - # (1.4.1) - rcut=`echo "$info_r" | awk '{print $'$count_r'}' ` - echo " |run cicle: rcut=$rcut" - + #echo "name=$name" + element=$(echo "$name" | awk -F "_" '{print $2}') + #echo "element=$element" + id=$(echo "$name" | awk -F "_" '{print $1}') + #echo "id=$id" + + # (0.1.6)get the pseudo_dir + pseudo_dir=$(grep -E "^\s*Pseudo_dir" $InputFile | awk -F "Pseudo_dir" '{print $0}' | awk '{print $2}') + + # (0.1.12) get the ecut + ecut=$(grep -E "^\s*Ecut" $InputFile | awk -F "Ecut" '{print $0}' | awk '{print $2}') + echo " ecut = $ecut" + + # (0.1.13) get the info about rcut,pseudo + info_r=$(grep -E "^\s*Rcut" $InputFile | awk -F "Rcut" '{print $0}' | awk '{print $2}') + rcut_number=$(echo "$info_r" | awk '// {print NF}') + echo " rcut_number = $rcut_number, info_r =" $info_r + + # (0.1.14) get the pseudopotential + pseudofile=$(grep -E "^\s*Pseudo " $InputFile | awk -F "Pseudo " '{print $0}' | awk '{print $2}') + echo " pseudo = $pseudofile" + + # (0.1.15) get the smearing + smearing_sigma=$(grep -E "^\s*smearing_sigma " $InputFile | awk -F "smearing_sigma " '{print $0}' | awk '{print $2}') + echo " smearing_sigma = $smearing_sigma" + + # + # (0.1.7)get maxL S P D + maxL=$(grep -E "^\s*maxL" $InputFile | awk -F "maxL" '{print $0}' | awk '{print $2}') + + #if ( test $maxL = 0 ) // mohan's scheme + #then + #S_MIN=1 + #P_MIN=" " + #D_MIN=" " + #elif ( test $maxL = 1 ) + #then + #S_MIN=1 + #P_MIN=1 + #D_MIN=" " + #else + #S_MIN=1 + #P_MIN=1 + #D_MIN=1 + #fi + + # (0.x.x) check info (include Level) for each STRU + NSTRU=$(grep -E "^\s*BLSTRU" $InputFile | wc -l) + echo " NSTRU = $NSTRU" + # + LevelEnd[0]=0 + SkipSTRU[0]=0 + ListSTRU[0]=" " + for ((iSTRU = 1; iSTRU <= $NSTRU; iSTRU++)); do + + ListSTRU[iSTRU]=$(grep -E "^\s*ListSTRU " $InputFile | awk -F "ListSTRU" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') + echo " STRU[$iSTRU] = ${ListSTRU[iSTRU]}" + + info[iSTRU]=$(grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}') + BL_number[iSTRU]=$(echo "${info[iSTRU]}" | awk '// {print NF}') + + # (0.1.11) calculate the number of different dimers or trimers. + #info=`grep "Dis1" $InputFile | awk -F "Dis1" '{print $2}'` + #BL_number=`echo "$info" | awk '// {print NF}'` + echo " BL_number[$iSTRU] = ${BL_number[iSTRU]}, info[$iSTRU] =" ${info[iSTRU]} + + LevelEnd[iSTRU]=$(grep -E "^\s*Level" $InputFile | awk -F "Level" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') + echo " LevelEnd[$iSTRU] = ${LevelEnd[iSTRU]}" + + # (0.1.4)get the nbands + nbands[iSTRU]=$(grep -E "^\s*nbands" $InputFile | awk -F "nbands" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') + echo " nbands[$iSTRU] = ${nbands[iSTRU]}" + + # (0.1.5)get the ref_bands + ref_bands[iSTRU]=$(grep -E "^\s*ref_bands" $InputFile | awk -F "$ref_bands" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') + echo " ref_bands[$iSTRU] = ${ref_bands[iSTRU]}" + + SkipSTRU[iSTRU]=0 + if (test -n "$(grep -E "^\s*SkipSTRU" $InputFile)"); then + SkipSTRU[iSTRU]=$(grep -E "^\s*SkipSTRU" $InputFile | awk -F "$SkipSTRU" '{print $0}' | + awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }') + fi + echo " SkipSTRU[$iSTRU] = ${SkipSTRU[iSTRU]}" + done # first cicle of iSTRU + if [ "$NSTRU" == "1" ]; then + SkipSTRU[1]=0 + fi + + # (0.1.8)get the level + #Level=`grep "Level" $InputFile | awk -F "level" '{print $0}' | awk '{print $2}'` + #echo "__Level=$Level" + + # (0.1.9)get every level`s lmax s p d f g + L[1]=$(grep -E "^\s*level1" $InputFile | awk -F "level1" '{print $2}') + L[2]=$(grep -E "^\s*level2" $InputFile | awk -F "level2" '{print $2}') + L[3]=$(grep -E "^\s*level3" $InputFile | awk -F "level3" '{print $2}') + L[4]=$(grep -E "^\s*level4" $InputFile | awk -F "level4" '{print $2}') + L[5]=$(grep -E "^\s*level5" $InputFile | awk -F "level5" '{print $2}') + L[6]=$(grep -E "^\s*level6" $InputFile | awk -F "level6" '{print $2}') + L[7]=$(grep -E "^\s*level7" $InputFile | awk -F "level7" '{print $2}') + L[8]=$(grep -E "^\s*level8" $InputFile | awk -F "level8" '{print $2}') + L[9]=$(grep -E "^\s*level9" $InputFile | awk -F "level9" '{print $2}') + + # (0.1.10)get some parameters for METROPOLIS + Start_tem_S_in=$(grep -E "^\s*Start_tem_S" $InputFile | + awk -F "Start_tem_S" '{print $0}' | awk '{print $2}') + if (test $Start_tem_S_in != " "); then + Start_tem_S=$Start_tem_S_in + else + Start_tem_S=1.0e-4 #default + fi + + Start_tem_K_in=$(grep -E "^\s*Start_tem_K" $InputFile | + awk -F "Start_tem_K" '{print $0}' | awk '{print $2}') + if (test $Start_tem_K_in != " "); then + Start_tem_K=$Start_tem_K_in + else + Start_tem_K=1.0e-2 #default + fi + + Step_S_in=$(grep -E "^\s*Step_S" $InputFile | + awk -F "Step_S" '{print $0}' | awk '{print $2}') + if (test $Step_S_in != " "); then + Step_S=$Step_S_in + else + Step_S=20 #default + fi + + Step_K_in=$(grep -E "^\s*Step_K" $InputFile | + awk -F "Step_K" '{print $0}' | awk '{print $2}') + if (test $Step_K_in != " "); then + Step_K=$Step_K_in + else + Step_K=15 #default + fi + + Delta_kappa_in=$(grep -E "^\s*Delta_kappa" $InputFile | + awk -F "Delta_kappa" '{print $0}' | awk '{print $2}') + Delta_kappa=$Delta_kappa_in + #echo " Delta_kappa=$Delta_kappa" + + #----------------------------------------------------------------- + # + # (1) big cicle, cicle of targets + # + #----------------------------------------------------------------- + + # (1.1) output which element you want to calculate + echo " -------------------------------------------------------> $element" + + # (1.2) make the dir, the name is 'name' + if (test -d $name); then + echo " The dir exist: $name" + else + echo " Make dir: $name" + mkdir $name + fi + + # (1.3) enter the name dir + cd $name + + # (1.4) another big cicle come: the rcut cicle. + count_r=1 + while [ $count_r -le $rcut_number ]; do + # (1.4.1) + rcut=$(echo "$info_r" | awk '{print $'$count_r'}') + echo " |run cicle: rcut=$rcut" # (1.x.x)enter the third big cicle: each iSTRU - for((iSTRU=1;iSTRU<=$NSTRU;iSTRU++)) - do - if ( test ${SkipSTRU[iSTRU]} -eq 1 ); then + for ((iSTRU = 1; iSTRU <= $NSTRU; iSTRU++)); do + if (test ${SkipSTRU[iSTRU]} -eq 1); then echo " |skip cicle: iSTRU=$iSTRU" - continue; - fi - echo " |run cicle: iSTRU=$iSTRU" - - # (1.4.2) enter the forth big cicle : each Bond Length. - count=1 - while [ $count -le ${BL_number[iSTRU]} ] - do - - # (1.4.2.0) calculate the Bond Length for iSTRU - BL=`echo "${info[iSTRU]}" | awk '{print $'$count'}' ` - dis1=$(echo "scale=5;$BL * 0.86603 "|bc) - dis2=$(echo "scale=5;$BL * 0.5 "|bc) - dis3=$(echo "scale=5;$BL * 0.81649 "|bc) - dis4=$(echo "scale=5;$BL * 0.28867 "|bc) - echo " |run cicle: BL=$BL" - - - -# (1.4.2.1) get the" structures" - -#if ( test $iSTRU = 2 ) -#then -#na=4 -#cat > $name.stru << EOF -#ATOMIC_SPECIES -#$element $mass $pseudofile -#LATTICE_CONSTANT -#$lat0 // add lattice constant(a.u.) -#LATTICE_VECTORS -#1 0 0 -#0 1 0 -#0 0 1 -#ATOMIC_POSITIONS -#Cartesian_angstrom //Cartesian or Direct coordinate. -#$element //Element Label -#0.0 //starting magnetism -#4 //number of atoms -#0.0 0.0 0.0 0 0 0 // crystal coor. -#0.0 0.0 $BL 0 0 0 -#0.0 $dis1 $dis2 0 0 0 -#$dis3 $dis4 $dis2 0 0 0 -#EOF -# -##na=3 -##cat > $name.stru << EOF -##ATOMIC_SPECIES -##$element $mass $pseudofile -##LATTICE_CONSTANT -##$lat0 // add lattice constant(a.u.) -##LATTICE_VECTORS -##1 0 0 -##0 1 0 -##0 0 1 -##ATOMIC_POSITIONS -##Cartesian_angstrom //Cartesian or Direct coordinate. -##$element //Element Label -##0.0 //starting magnetism -##3 //number of atoms -##0.0 0.0 0.0 0 0 0 // crystal coor. -##0.0 0.0 $BL 0 0 0 -##0.0 $dis1 $dis2 0 0 0 -##EOF -## -##na=2 -##cat > $name.stru << EOF -##ATOMIC_SPECIES -##$element $mass $pseudofile -##LATTICE_CONSTANT -##$lat0 // add lattice constant(a.u.) -##LATTICE_VECTORS -##1 0 0 -##0 1 0 -##0 0 1 -##ATOMIC_POSITIONS -##Cartesian_angstrom //Cartesian or Direct coordinate. -##$element //Element Label -##0.0 //starting magnetism -##2 //number of atoms -##0.0 0.0 0.0 0 0 0 // crystal coor. -##0.0 0.0 $BL 0 0 0 -##EOF -# -#elif ( test $element = Na -o $element = Li -o $element = K -o $element = Ca -o $element = Cs -o $element = Ba -o $element = Rb -o $element = Sr ) -#then -#na=3 -#cat > $name.stru << EOF -#ATOMIC_SPECIES -#$element $mass $pseudofile -#LATTICE_CONSTANT -#$lat0 // add lattice constant(a.u.) -#LATTICE_VECTORS -#1 0 0 -#0 1 0 -#0 0 1 -#ATOMIC_POSITIONS -#Cartesian_angstrom //Cartesian or Direct coordinate. -#$element //Element Label -#0.0 //starting magnetism -#3 //number of atoms -#0.0 0.0 0.0 0 0 0 // crystal coor. -#0.0 0.0 $BL 0 0 0 -#0.0 $dis1 $dis2 0 0 0 -#EOF -# -#else -#na=2 -#cat > $name.stru << EOF -#ATOMIC_SPECIES -#$element $mass $pseudofile -#LATTICE_CONSTANT -#$lat0 // add lattice constant(a.u.) -#LATTICE_VECTORS -#1 0 0 -#0 1 0 -#0 0 1 -#ATOMIC_POSITIONS -#Cartesian_angstrom //Cartesian or Direct coordinate. -#$element //Element Label -#0.0 //starting magnetism -#2 //number of atoms -#0.0 0.0 0.0 0 0 0 // crystal coor. -#0.0 0.0 $BL 0 0 0 -#EOF -#fi -#echo " na=$na" - - - -if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then -na=2 -cat > $name.stru << EOF + continue + fi + echo " |run cicle: iSTRU=$iSTRU" + + # (1.4.2) enter the forth big cicle : each Bond Length. + count=1 + while [ $count -le ${BL_number[iSTRU]} ]; do + + # (1.4.2.0) calculate the Bond Length for iSTRU + BL=$(echo "${info[iSTRU]}" | awk '{print $'$count'}') + dis1=$(echo "scale=5;$BL * 0.86603 " | bc) + dis2=$(echo "scale=5;$BL * 0.5 " | bc) + dis3=$(echo "scale=5;$BL * 0.81649 " | bc) + dis4=$(echo "scale=5;$BL * 0.28867 " | bc) + echo " |run cicle: BL=$BL" + + # (1.4.2.1) get the" structures" + + #if ( test $iSTRU = 2 ) + #then + #na=4 + #cat > $name.stru << EOF + #ATOMIC_SPECIES + #$element $mass $pseudofile + #LATTICE_CONSTANT + #$lat0 // add lattice constant(a.u.) + #LATTICE_VECTORS + #1 0 0 + #0 1 0 + #0 0 1 + #ATOMIC_POSITIONS + #Cartesian_angstrom //Cartesian or Direct coordinate. + #$element //Element Label + #0.0 //starting magnetism + #4 //number of atoms + #0.0 0.0 0.0 0 0 0 // crystal coor. + #0.0 0.0 $BL 0 0 0 + #0.0 $dis1 $dis2 0 0 0 + #$dis3 $dis4 $dis2 0 0 0 + #EOF + # + ##na=3 + ##cat > $name.stru << EOF + ##ATOMIC_SPECIES + ##$element $mass $pseudofile + ##LATTICE_CONSTANT + ##$lat0 // add lattice constant(a.u.) + ##LATTICE_VECTORS + ##1 0 0 + ##0 1 0 + ##0 0 1 + ##ATOMIC_POSITIONS + ##Cartesian_angstrom //Cartesian or Direct coordinate. + ##$element //Element Label + ##0.0 //starting magnetism + ##3 //number of atoms + ##0.0 0.0 0.0 0 0 0 // crystal coor. + ##0.0 0.0 $BL 0 0 0 + ##0.0 $dis1 $dis2 0 0 0 + ##EOF + ## + ##na=2 + ##cat > $name.stru << EOF + ##ATOMIC_SPECIES + ##$element $mass $pseudofile + ##LATTICE_CONSTANT + ##$lat0 // add lattice constant(a.u.) + ##LATTICE_VECTORS + ##1 0 0 + ##0 1 0 + ##0 0 1 + ##ATOMIC_POSITIONS + ##Cartesian_angstrom //Cartesian or Direct coordinate. + ##$element //Element Label + ##0.0 //starting magnetism + ##2 //number of atoms + ##0.0 0.0 0.0 0 0 0 // crystal coor. + ##0.0 0.0 $BL 0 0 0 + ##EOF + # + #elif ( test $element = Na -o $element = Li -o $element = K -o $element = Ca -o $element = Cs -o $element = Ba -o $element = Rb -o $element = Sr ) + #then + #na=3 + #cat > $name.stru << EOF + #ATOMIC_SPECIES + #$element $mass $pseudofile + #LATTICE_CONSTANT + #$lat0 // add lattice constant(a.u.) + #LATTICE_VECTORS + #1 0 0 + #0 1 0 + #0 0 1 + #ATOMIC_POSITIONS + #Cartesian_angstrom //Cartesian or Direct coordinate. + #$element //Element Label + #0.0 //starting magnetism + #3 //number of atoms + #0.0 0.0 0.0 0 0 0 // crystal coor. + #0.0 0.0 $BL 0 0 0 + #0.0 $dis1 $dis2 0 0 0 + #EOF + # + #else + #na=2 + #cat > $name.stru << EOF + #ATOMIC_SPECIES + #$element $mass $pseudofile + #LATTICE_CONSTANT + #$lat0 // add lattice constant(a.u.) + #LATTICE_VECTORS + #1 0 0 + #0 1 0 + #0 0 1 + #ATOMIC_POSITIONS + #Cartesian_angstrom //Cartesian or Direct coordinate. + #$element //Element Label + #0.0 //starting magnetism + #2 //number of atoms + #0.0 0.0 0.0 0 0 0 // crystal coor. + #0.0 0.0 $BL 0 0 0 + #EOF + #fi + #echo " na=$na" + + if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then + na=2 + cat >$name.stru < $name.stru << EOF + elif [ "${ListSTRU[iSTRU]}" == "trimer" ]; then + na=3 + cat >$name.stru < $name.stru << EOF + elif [ "${ListSTRU[iSTRU]}" == "tetramer" ]; then + na=4 + cat >$name.stru < KPOINTS << EOF + # (1.4.2.2) get KPOINTS + cat >KPOINTS < INPUTw << EOF + # (1.4.2.3) get INPUTw + cat >INPUTw < INPUTs << EOF + # (1.4.2.4) get INPUTs + cat >INPUTs < 1 // smooth or not @@ -495,9 +470,8 @@ $rcut // cutoff of wavefunctions(a.u.) EOF - -# (1.4.2.5) get INPUT -cat > INPUT << EOF + # (1.4.2.5) get INPUT + cat >INPUT <> Log.txt -#mpirun -np $cpu_num $EXE_pw -#mpirun -hostfile "../$hostfpath" $EXE_pw -#mpirun -np $cpu_num -hostfile "../$hostfpath" $EXE_pw - - - -#$EXE_mpi $EXE_pw - - - -# end (1.4.2), Bond Length cicle -done - - -### (1.4.3) mkdir of rcut -test -d $rcut || mkdir $rcut -# (1.4.3.1) -cd $rcut - -iSTRULeft=`expr $iSTRU \- 1` -echo " iSTRULeft=$iSTRULeft, LevelEnd[$iSTRULeft]=${LevelEnd[iSTRULeft]} " - -### set if restart from previous SIA runs -#if ( test SkipSTRU[`expr $iSTRU - 1`] -eq 1 ) ; then -if ( test $iSTRU -gt 1 ) ; then - isrestart=1 - - echo " " - echo " Restart from Previous SIA Calculation ... " - echo " " - # - #if [ -f "ORBITAL_RESULTS.txt" ] ; then - # echo " Found file: ORBITAL_RESULTS.txt, continue ... " - #else - # echo " Can't find: ORBITAL_RESULTS.txt, exiting ... " - # exit - #fi - # - # - if [ ! -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then - echo " Move Old Orbital files and Rename as STRU${iSTRULeft}.*" + let count++ + + # (1.4.2.6) + #test -e ../node_openmpi && cp ../node_openmpi . + #------------- + #on Dirac + #------------- + #/opt/openmpi/bin/mpirun -np $cpu_number -machinefile node_openmpi $exe + #------------- + #on Einstein + #------------- + #mpiexec -np $cpu_num -machinefile node_openmpi $EXE_pw + #mpiexec -np $1 -machinefile $EXE_pw + + #echo "skip $EXE_pw" + #exit + #mpiexec -n 12 -machinefile $PBS_NODEFILE $EXE_pw >> Log.txt + #mpirun -np $cpu_num $EXE_pw + #mpirun -hostfile "../$hostfpath" $EXE_pw + #mpirun -np $cpu_num -hostfile "../$hostfpath" $EXE_pw + + #$EXE_mpi $EXE_pw + + # end (1.4.2), Bond Length cicle + done + + ### (1.4.3) mkdir of rcut + test -d $rcut || mkdir $rcut + # (1.4.3.1) + cd $rcut + + iSTRULeft=$(expr $iSTRU \- 1) + echo " iSTRULeft=$iSTRULeft, LevelEnd[$iSTRULeft]=${LevelEnd[iSTRULeft]} " + + ### set if restart from previous SIA runs + #if ( test SkipSTRU[`expr $iSTRU - 1`] -eq 1 ) ; then + if (test $iSTRU -gt 1); then + isrestart=1 + + echo " " + echo " Restart from Previous SIA Calculation ... " + echo " " # - if ( test -f "ORBITAL_RESULTS.txt" ); then - mv "ORBITAL_RESULTS.txt" "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" - fi - # - if ( test -f "INPUT" ); then - mv "INPUT" "STRU${iSTRULeft}.INPUT" - fi - # - if ( test -f "ORBITAL_${id}U.dat" ); then - mv "ORBITAL_${id}U.dat" "STRU${iSTRULeft}.ORBITAL_${id}U.dat" - fi - # - if ( test -f "ORBITAL_${id}L.dat" ); then - mv "ORBITAL_${id}L.dat" "STRU${iSTRULeft}.ORBITAL_${id}L.dat" - fi + #if [ -f "ORBITAL_RESULTS.txt" ] ; then + # echo " Found file: ORBITAL_RESULTS.txt, continue ... " + #else + # echo " Can't find: ORBITAL_RESULTS.txt, exiting ... " + # exit + #fi # - if ( test -f "ORBITAL_ECUT.txt" ); then - mv "ORBITAL_ECUT.txt" "STRU${iSTRULeft}.ORBITAL_ECUT.txt" - fi - # - if ( test -f "ORBITAL_KINETIC.txt" ); then - mv "ORBITAL_KINETIC.txt" "STRU${iSTRULeft}.ORBITAL_KINETIC.txt" - fi - # - if ( test -f "ORBITAL_PLOTL.dat" ); then - mv "ORBITAL_PLOTL.dat" "STRU${iSTRULeft}.ORBITAL_PLOTL.dat" - fi - # - if ( test -f "ORBITAL_PLOTU.dat" ); then - mv "ORBITAL_PLOTU.dat" "STRU${iSTRULeft}.ORBITAL_PLOTU.dat" - fi # - if ( test -f "ORBITAL_PLOTUK.dat" ); then - mv "ORBITAL_PLOTUK.dat" "STRU${iSTRULeft}.ORBITAL_PLOTUK.dat" + if [ ! -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then + echo " Move Old Orbital files and Rename as STRU${iSTRULeft}.*" + # + if (test -f "ORBITAL_RESULTS.txt"); then + mv "ORBITAL_RESULTS.txt" "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" + fi + # + if (test -f "INPUT"); then + mv "INPUT" "STRU${iSTRULeft}.INPUT" + fi + # + if (test -f "ORBITAL_${id}U.dat"); then + mv "ORBITAL_${id}U.dat" "STRU${iSTRULeft}.ORBITAL_${id}U.dat" + fi + # + if (test -f "ORBITAL_${id}L.dat"); then + mv "ORBITAL_${id}L.dat" "STRU${iSTRULeft}.ORBITAL_${id}L.dat" + fi + # + if (test -f "ORBITAL_ECUT.txt"); then + mv "ORBITAL_ECUT.txt" "STRU${iSTRULeft}.ORBITAL_ECUT.txt" + fi + # + if (test -f "ORBITAL_KINETIC.txt"); then + mv "ORBITAL_KINETIC.txt" "STRU${iSTRULeft}.ORBITAL_KINETIC.txt" + fi + # + if (test -f "ORBITAL_PLOTL.dat"); then + mv "ORBITAL_PLOTL.dat" "STRU${iSTRULeft}.ORBITAL_PLOTL.dat" + fi + # + if (test -f "ORBITAL_PLOTU.dat"); then + mv "ORBITAL_PLOTU.dat" "STRU${iSTRULeft}.ORBITAL_PLOTU.dat" + fi + # + if (test -f "ORBITAL_PLOTUK.dat"); then + mv "ORBITAL_PLOTUK.dat" "STRU${iSTRULeft}.ORBITAL_PLOTUK.dat" + fi + # + if (test -f "running_1.txt"); then + mv "running_1.txt" "STRU${iSTRULeft}.running_1.txt" + fi + # fi # - if ( test -f "running_1.txt" ); then - mv "running_1.txt" "STRU${iSTRULeft}.running_1.txt" + if [ -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ]; then + echo " Found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, copy as ORBITAL_RESULTS.txt ... " + cp -avp "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" "ORBITAL_RESULTS.txt" + else + echo " Not found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, exiting ... " + exit fi - # - fi - # - if [ -f "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" ] ; then - echo " Found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, copy as ORBITAL_RESULTS.txt ... " - cp -avp "STRU${iSTRULeft}.ORBITAL_RESULTS.txt" "ORBITAL_RESULTS.txt" - else - echo " Not found file: STRU${iSTRULeft}.ORBITAL_RESULTS.txt, exiting ... " - exit - fi -# -else - echo " " - echo " Completely New SIA Calculation ... " - echo " " - isrestart=0 -fi -#echo "isrestart=$isrestart" - - - -#if [ "${EXE_orbital##*.}" != "py" ]; -if [ "${EXE_orbital:0-3:3}" != ".py" ]; -then - echo ok ; - -else - : -fi - - - -### (1.4.3.2) prepare for the INPUT file -cat > INPUT << EOF + # + else + echo " " + echo " Completely New SIA Calculation ... " + echo " " + isrestart=0 + fi + #echo "isrestart=$isrestart" + + #if [ "${EXE_orbital##*.}" != "py" ]; + if [ "${EXE_orbital:0-3:3}" != ".py" ]; then + echo ok + + else + : + fi + + ### (1.4.3.2) prepare for the INPUT file + cat >INPUT < 1 // if or not calculate the spillage. 1/0 $isrestart // restart or not. 1/0 @@ -666,18 +628,17 @@ $isrestart // restart or not. 1/0 ${BL_number[iSTRU]} // number of structures. EOF -# (1.4.3.3) input the file names -count_files=1 -while [ $count_files -le ${BL_number[iSTRU]} ] -do -BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' ` -cat >> INPUT << EOF + # (1.4.3.3) input the file names + count_files=1 + while [ $count_files -le ${BL_number[iSTRU]} ]; do + BL=$(echo "${info[iSTRU]}" | awk '{print $'$count_files'}') + cat >>INPUT <> INPUT << EOF + cat >>INPUT < @@ -725,33 +686,29 @@ ${ref_bands[iSTRU]} // int, the ed band index(> INPUT << EOF + cat >>INPUT < ${LevelEnd[iSTRU]} // Number of levels. label / na / skip / lmax / each L / EOF - -for((i=1;i<=${LevelEnd[iSTRU]};i++)) -do -if ( test $i -gt ${LevelEnd[iSTRULeft]} ) -then - leveltype="new " -else - leveltype="skip" -fi -#echo "leveltype=$leveltype" -cat >> INPUT << EOF + for ((i = 1; i <= ${LevelEnd[iSTRU]}; i++)); do + if (test $i -gt ${LevelEnd[iSTRULeft]}); then + leveltype="new " + else + leveltype="skip" + fi + #echo "leveltype=$leveltype" + cat >>INPUT <> INPUT << EOF + cat >>INPUT < EOF -cat >> INPUT << EOF + cat >>INPUT < 0.01 //dr(a.u.) of uniform mesh. Attention!!dr will affect kinetic energy minmized largely. -6 //xmin @@ -779,29 +736,23 @@ cat >> INPUT << EOF EOF + #mpiexec -n 1 -machinefile $PBS_NODEFILE $EXE_orbital >> Log.txt + $EXE_orbital + #mpirun -np cpu_num $EXE_orbital -#mpiexec -n 1 -machinefile $PBS_NODEFILE $EXE_orbital >> Log.txt + # (1.4.3.5) exit the rcut dir + cd .. -$EXE_orbital -#mpirun -np cpu_num $EXE_orbital + # cicle iSTRU + done + let count_r++ + # end(1.4), rcut cicle + done - -# (1.4.3.5) exit the rcut dir -cd .. - -# cicle iSTRU -done - - -let count_r++ -# end(1.4), rcut cicle -done - -# (1.5) exit the name dir. -cd .. + # (1.5) exit the name dir. + cd .. done # end targets cicle - diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh index 4e31613c6fe..0eafea01387 100644 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh @@ -5,4 +5,4 @@ #BSUB -m node151 export OMP_NUM_THREADS=8 EXEC=/home/nic/wszhang/eclipse_project/abacus-NewGit/ABACUS.1.0.0/tools/tools_exx/opt_orb_pytorch/main.py -python3 $EXEC > running_stdout.log +python3 $EXEC >running_stdout.log diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh index 94e084b9efa..b4544067787 100755 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh @@ -2,10 +2,10 @@ #bsub -q idle -E ./pre_run.sh -oo %J.log touch 000 -if [ $((`date +%s`%20)) -le 10 ]; then - echo `date +%s` " requeue" >> 001 - exit 1 +if [ $(($(date +%s) % 20)) -le 10 ]; then + echo $(date +%s) " requeue" >>001 + exit 1 else - echo `date +%s` " run" >> 001 - exit 0 + echo $(date +%s) " run" >>001 + exit 0 fi diff --git a/tools/04_windows_installation/provision.sh b/tools/04_windows_installation/provision.sh index 03b95cb759e..75b2d967e35 100644 --- a/tools/04_windows_installation/provision.sh +++ b/tools/04_windows_installation/provision.sh @@ -14,38 +14,38 @@ VERSION_SPEC="${ABACUS_VERSION:-}" # is pinned with "="; anything containing an operator (>=, <, etc.) or a # comma is passed through as-is. if [ -z "$VERSION_SPEC" ]; then - ABACUS_PKG="abacus" + ABACUS_PKG="abacus" elif echo "$VERSION_SPEC" | grep -qE '[<>=!,* ]'; then - ABACUS_PKG="abacus $VERSION_SPEC" + ABACUS_PKG="abacus $VERSION_SPEC" else - ABACUS_PKG="abacus=$VERSION_SPEC" + ABACUS_PKG="abacus=$VERSION_SPEC" fi if [ "$CHINA_MIRROR" = "1" ]; then - MINIFORGE_URL="https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh" - CONDA_FORGE_CHANNEL="https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge" + MINIFORGE_URL="https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh" + CONDA_FORGE_CHANNEL="https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge" else - MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" - CONDA_FORGE_CHANNEL="conda-forge" + MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" + CONDA_FORGE_CHANNEL="conda-forge" fi log() { printf '[provision] %s\n' "$*"; } if [ "$(id -u)" -ne 0 ]; then - echo "[provision] Must run as root." >&2 - exit 1 + echo "[provision] Must run as root." >&2 + exit 1 fi if [ "$CHINA_MIRROR" = "1" ]; then - log "China mirror mode: using TUNA (Tsinghua) for apt / Miniforge / conda-forge." - if [ -f /etc/apt/sources.list ] && grep -qE 'archive\.ubuntu\.com|security\.ubuntu\.com' /etc/apt/sources.list; then - log "Rewriting /etc/apt/sources.list to TUNA (backup at sources.list.orig)..." - cp -n /etc/apt/sources.list /etc/apt/sources.list.orig - sed -i \ - -e 's|http://archive.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \ - -e 's|http://security.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \ - /etc/apt/sources.list - fi + log "China mirror mode: using TUNA (Tsinghua) for apt / Miniforge / conda-forge." + if [ -f /etc/apt/sources.list ] && grep -qE 'archive\.ubuntu\.com|security\.ubuntu\.com' /etc/apt/sources.list; then + log "Rewriting /etc/apt/sources.list to TUNA (backup at sources.list.orig)..." + cp -n /etc/apt/sources.list /etc/apt/sources.list.orig + sed -i \ + -e 's|http://archive.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \ + -e 's|http://security.ubuntu.com/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \ + /etc/apt/sources.list + fi fi log "Installing apt prerequisites (apt-get update + curl/ca-certs/bzip2)..." @@ -54,38 +54,38 @@ apt-get update apt-get install -y --no-install-recommends curl ca-certificates bzip2 if [ ! -x "$MINIFORGE_DIR/bin/conda" ]; then - log "Downloading Miniforge installer (~80 MB)..." - tmp="$(mktemp --suffix=.sh)" - trap 'rm -f "$tmp"' EXIT - curl -fL --progress-bar -o "$tmp" "$MINIFORGE_URL" - log "Installing Miniforge into $MINIFORGE_DIR..." - # Run the installer via its own shebang (dash on Ubuntu) rather than - # `bash installer.sh`. Some Miniforge builds have a sourced-check that - # misfires under bash and aborts with "Please run using bash/dash/...". - chmod +x "$tmp" - "$tmp" -b -p "$MINIFORGE_DIR" - rm -f "$tmp" - trap - EXIT + log "Downloading Miniforge installer (~80 MB)..." + tmp="$(mktemp --suffix=.sh)" + trap 'rm -f "$tmp"' EXIT + curl -fL --progress-bar -o "$tmp" "$MINIFORGE_URL" + log "Installing Miniforge into $MINIFORGE_DIR..." + # Run the installer via its own shebang (dash on Ubuntu) rather than + # `bash installer.sh`. Some Miniforge builds have a sourced-check that + # misfires under bash and aborts with "Please run using bash/dash/...". + chmod +x "$tmp" + "$tmp" -b -p "$MINIFORGE_DIR" + rm -f "$tmp" + trap - EXIT else - log "Miniforge already present at $MINIFORGE_DIR." + log "Miniforge already present at $MINIFORGE_DIR." fi # shellcheck disable=SC1091 source "$MINIFORGE_DIR/etc/profile.d/conda.sh" if conda env list | awk 'NF && $1 !~ /^#/ {print $1}' | grep -qx "$ENV_NAME"; then - log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." - # shellcheck disable=SC2086 - conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG + log "Updating existing env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." + # shellcheck disable=SC2086 + conda install -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG else - log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." - # shellcheck disable=SC2086 - conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG + log "Creating env '$ENV_NAME' (channel: $CONDA_FORGE_CHANNEL, package: $ABACUS_PKG)..." + # shellcheck disable=SC2086 + conda create -n "$ENV_NAME" -y --override-channels -c "$CONDA_FORGE_CHANNEL" $ABACUS_PKG fi log "Installing system launchers..." -cat > /usr/local/bin/abacus </usr/local/bin/abacus < /usr/local/bin/abacus-mpi </usr/local/bin/abacus-mpi </dev/null 2>&1; then - /usr/local/bin/abacus --version || true + /usr/local/bin/abacus --version || true elif [ -x "$ENV_BIN/abacus" ]; then - log "abacus binary present at $ENV_BIN/abacus (no --version flag)." + log "abacus binary present at $ENV_BIN/abacus (no --version flag)." else - log "WARNING: abacus binary not found after install." - exit 1 + log "WARNING: abacus binary not found after install." + exit 1 fi log "Done."