From 6586fd05a7786345a8a6f8f34092ab823aad5b5b Mon Sep 17 00:00:00 2001 From: Andres Manelli Date: Tue, 14 Oct 2014 15:39:40 -0300 Subject: [PATCH] Tags removed, only #OP necessary. No Order to respect --- AwkFiles/extractOps | 40 +++------------------ Scripts/updateRestart | 83 ++++++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 72 deletions(-) diff --git a/AwkFiles/extractOps b/AwkFiles/extractOps index 29560d6..ce07871 100644 --- a/AwkFiles/extractOps +++ b/AwkFiles/extractOps @@ -5,28 +5,10 @@ BEGIN{ ops_N=0 n_ops=1000; - undump="#UDOP_" - n_undump=1000 - - unfix="#UFIX_" - n_unfix=1000 - - op="(#OP_)" + op="(#OP)" n_op=1000 - restart="#ROP_" - n_restart=1000; - - dump="#DOP_" - n_dump=1000 - - thermo="#THOP_" - n_thermo=1000 - - timestep="#TSOP_" - n_timestep=1000 - - run="run[ ]+([0-9]+)" + run="(run)[ ]+([0-9]+)" n_run=1000 thermoinfo="#THERMO_INFO" @@ -37,22 +19,10 @@ BEGIN{ } (m=="match_op"||m=="all")&&match($0,op,str){n_op=NR; print str[1]; ops_N++} -NR==n_op+1&&match($1,"fix",str){print} +NR==n_op+1&&match($1,"fix"){print} NR==n_op+1&&match($1,"(#)",str){print str[1]} -(m=="match_dump"||m=="all")&&match($0,dump,str){n_dump=NR; print} -NR==n_dump+1{print} -(m=="match_restart"||m=="all")&&match($0,restart,str){n_restart=NR; print} -NR==n_restart+1{print $2} -(m=="match_thermo"||m=="all")&&match($0,thermo,str){n_thermo=NR; print} -NR==n_thermo+1{print $2} -(m=="match_timestep"||m=="all")&&match($0,timestep,str){n_timestep=NR; print} -NR==n_timestep+1{print $2} -(m=="match_run"||m=="all")&&match($0,run,str){n_run=NR; print "#RUNOP"; print str[1]} -#NR==n_run+1{print $2} -(m=="match_undump"||m=="all")&&match($0,undump,str){n_undump=NR; print} -NR==n_undump+1{print} -(m=="match_unfix"||m=="all")&&match($0,unfix,str){n_unfix=NR; print} -NR==n_unfix+1{print} +(m=="match_run"||m=="all")&&match($0,run,str){n_run=NR; print str[1]" "str[2]} +(NR>n_op+1)&& !match($0,run,str){print} (m=="match_endthinfo"||m=="all")&&match($0,endthermoinfo,str){n_endthinfo=NR; print} (m=="match_thinfo"||m=="all")&&match($0,thermoinfo,str){n_thinfo=NR; print} (NR>n_thinfo)&&(NR1&&NR<(2+$thindex){print}" ops_tmp)" -#echo "OPS N: $ops_N" -#echo "THINDEX: $thindex" -#echo -e "GLOBAL THERMO:\n$gthermo" +echo "OPS N: $ops_N" +echo "THINDEX: $thindex" +echo -e "GLOBAL THERMO:\n$gthermo" #-- FIND OPERATIONS #OP_X #-- FIND RESTART STEP #ROP_X @@ -74,28 +74,37 @@ gthermo="$(gawk "NR>1&&NR<(2+$thindex){print}" ops_tmp)" #-- FIND THERMO INFO #THOP_X #-- FIND TIMESTEP INFO #TSOP_X #-- FIND RUN STEPS #RUNOP_X -run=() -for (( i = 1; i <= ${ops_N}; i++ )) -do - ops[$i]="$(gawk "NR==($i-1)*16+4+$thindex{print}" ops_tmp)" - dump[$i]="$(gawk "NR==($i-1)*16+6+$thindex{print}" ops_tmp)" - res[$i]="$(gawk "NR==($i-1)*16+8+$thindex{print}" ops_tmp)" - thermo[$i]="$(gawk "NR==($i-1)*16+10+$thindex{print}" ops_tmp)" - tstep[$i]="$(gawk "NR==($i-1)*16+12+$thindex{print}" ops_tmp)" - run[$i]="$(gawk "NR==($i-1)*16+14+$thindex{print}" ops_tmp)" - undump[$i]="$(gawk "NR==($i-1)*16+16+$thindex{print}" ops_tmp)" - unfix[$i]="$(gawk "NR==($i-1)*16+18+$thindex{print}" ops_tmp)" +# TODO: CHANGE BEHAVIOUR, BETWEEN 2 FIXES, WRITE ALL COMMANDS ? +opindex[1]="$(gawk 'match($0,"#OP",str){print NR+1; exit}' ops_tmp)" +ops[1]="$(gawk "NR==${opindex[1]}{print}" ops_tmp)" +for (( i = 2; i <= ${ops_N}; i++ )) +do +#-- SAVE OSP INDEXES ? + opindex[$i]="$(gawk 'NR>'${opindex[$i-1]}'&&match($0,"#OP",str){print NR+1; exit}' ops_tmp)" + ops[$i]="$(gawk "NR==${opindex[$i]}{print}" ops_tmp)" +# echo "OP: ${ops[$i-1]}" + cmdlist[$i-1]="$(gawk "NR>${opindex[$i-1]}&&NR<${opindex[$i]}-1{print}" ops_tmp)" + run[$i-1]="$(gawk 'NR>'${opindex[$i-1]}'&&NR<'${opindex[$i]}-1'&&match($0,"run[ ]+([0-9]+)",s){print s[1]}' ops_tmp)" +# echo -e "Cmd $i :\n${cmdlist[$i-1]}" +# echo "RUN: ${run[$i-1]}" done +#echo "OP: ${ops[$i-1]}" +opindex[$i]="$(gawk 'match($0,"#N_OPS",str){print NR+1; exit}' ops_tmp)" +run[$i-1]="$(gawk 'NR>'${opindex[$i-1]}'&&NR<'${opindex[$i]}-1'&&match($0,"run[ ]+([0-9]+)",s){print s[1]}' ops_tmp)" +cmdlist[$i-1]="$(gawk "NR>${opindex[$i-1]}&&NR<${opindex[$i]}-1{print}" ops_tmp)" +#echo -e "Cmd $i :\n${cmdlist[$i-1]}" +#echo "RUN: ${run[$i-1]}" # WITH THE TMP.RESTART.STEP INFO: -# MATCH THE LAST PARTIAL OPERATION PERFORMED COMPARING WITH RUN STEPS +#-- MATCH THE LAST PARTIAL OPERATION PERFORMED COMPARING WITH RUN STEPS laststep="$(cat ${simupath}/${output_file} | awk 'BEGIN{ go=0}go==1&&match($1,"[0-9]+",step){print $1}go==0&&match($1,"Step"){go=1}go==1&&match($1,"Loop"){go=0}' | gawk 'END{print}')" -#echo "LAST SIMU STEP: $laststep" +echo "LAST SIMU STEP: $laststep" tmprun=0 for (( i = 1; i <= ${ops_N}; i++ )) do tmprun=$(( $tmprun + ${run[$i]} )) + if (( $tmprun > ${lastRestartStep} )) then if [ "${ops[$i]}" == "#" ] @@ -108,8 +117,8 @@ do done fi -# echo "LAST RUN (WHERE RESTART TOOK PLACE): ${ops[$i]}" -# echo "LAST RUN STEP (WHERE RESTART TOOK PLACE): ${run[$i]}" + echo "LAST RUN (WHERE RESTART TOOK PLACE): ${ops[$i]}" + echo "LAST RUN STEP (WHERE RESTART TOOK PLACE): ${run[$i]}" break fi done @@ -119,21 +128,21 @@ done cat "${simupath}/${input_restart_file}" > "${simupath}/${input_file}.restart.${lastRestartStep}.in" input_restart_file="${simupath}/${input_file}.restart.${lastRestartStep}.in" sed -i {'s/\(read_restart[\t ]*\)\(.*\)/\1 tmp.restart.'"${lastRestartStep}"'/'} ${input_restart_file} -#-- PUT THE STEPS LEFT TO COMPLETE THE LAST OPERATION #-- PUT THE OPERATIONS NOT PERFORMED echo "#THERMO_INFO" >> ${input_restart_file} echo -e "${gthermo}" >> ${input_restart_file} echo -e "#END_THERMO_INFO\n" >> ${input_restart_file} -echo -e "#OP_\n${ops[$i]}\n#DOP_\n${dump[$i]}\n#ROP_\nrestart ${res[$i]} tmp.restart.*" >> ${input_restart_file} -echo -e "#THOP_\nthermo ${thermo[$i]}\n#TSOP_\ntimestep ${tstep[$i]}\n#RUNOP_\nrun $(( ${tmprun} - ${lastRestartStep} ))" >> ${input_restart_file} -echo -e "#UDOP_\n${undump[$i]}\n#UFIX_\n${unfix[$i]}\n\n" >> ${input_restart_file} -for (( h = (( $i + 1 )); h <= ${ops_N}; h++ )) + +for (( h = $i; h <= ${ops_N}; h++ )) do - echo -e "#OP_\n${ops[$h]}\n#DOP_\n${dump[$h]}\n#ROP_\nrestart ${res[$h]} tmp.restart.*" >> ${input_restart_file} - echo -e "#THOP_\nthermo ${thermo[$h]}\n#TSOP_\ntimestep ${tstep[$h]}\n#RUNOP_\nrun ${run[$h]}" >> ${input_restart_file} - echo -e "#UDOP_\n${undump[$h]}\n#UFIX_\n${unfix[$h]}\n\n" >> ${input_restart_file} + echo -e "#OP\n${ops[$h]}\n${cmdlist[$h]}\n" >> ${input_restart_file} done +#-- PUT THE STEPS LEFT TO COMPLETE THE LAST OPERATION +sed -i {'1,/\(run[\t ]*\)\(.*\)/s/\(run[\t ]*\)\(.*\)/\1 '"$(( ${tmprun} - ${lastRestartStep} ))"'/'} ${input_restart_file} + +exit 0 + # WITH SIMULIST FILE: #-- FIND THE FIRST SIMULATION AND CHANGE THE INPUT AND OUTPUT gawk -v s=${lastRestartStep} -f AwkFiles/cmdUpdateRestart simuList > simuList_TMP