From 9a51b6bb1add619440ec2f83ecebc36812d609ae Mon Sep 17 00:00:00 2001 From: cpenadep Date: Thu, 1 Sep 2022 10:51:38 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Deleted=20=C2=BA=20typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/script.sh b/script.sh index c88b0cc..82a4254 100755 --- a/script.sh +++ b/script.sh @@ -278,7 +278,6 @@ Create_metrics() #Generating function list in case of missing if ! test -f "extrae_functions_for_xml.txt"; then - ยบ rm gmon* 2> /dev/null echo "Runing Nemo with 2 cores to obtain function data..." echo -- GitLab From fe4efd0d06527d0cc5867aa1ad3c130603c3bf1e Mon Sep 17 00:00:00 2001 From: cpenadep Date: Thu, 1 Sep 2022 15:30:31 +0200 Subject: [PATCH 2/4] Initial Torque manager added --- Job_Creator.py | 40 +++++++++++++++++++++++++++++++++++++++- script.sh | 27 +++++++++++++++++++-------- 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/Job_Creator.py b/Job_Creator.py index 15330c8..4d9f46e 100644 --- a/Job_Creator.py +++ b/Job_Creator.py @@ -117,6 +117,41 @@ def create_job_lsf(args): lsf_job.write(line) +def create_job_torque(args): + file_name = args.file_name + time = args.set_time + cores = args.set_core + name = args.job_name + cores_per_node = args.set_core_per_node + queue = args.set_queue + workload = args.set_workload + nodes = (cores//cores_per_node)+1 + hours = time // 60 + minutes = time % 60 + file = ["#!/bin/bash \n", + "############################################################################### \n", + "#PBS -o "+str(name)+".out \n#PBS -e "+str(name)+".err \n" + "#PBS --constraint=perfparanoid \n"] + + if cores is not None: + file.append("#PBS -l nodes"+str(nodes)":ppn=" + str(cores) + "\n") + if time is not None and not 0: + file.append("#PBS -l cput=" + str(hours)+":"+str(minutes)+ ":00\n") + if name is not None: + file.append("#PBS -N " + name + "\n") + if queue is not None and not len(queue) == 0: + file.append("#PBS -q " + queue + "\n") + + if workload is not None: + file.append("\n") + for work in workload: + file.append(str(work) + "") + + with open(file_name, "w") as torque_job: + for line in file: + torque_job.write(line) + + def modify_job(args): file_name = args.file_name time = args.set_time @@ -148,6 +183,8 @@ if __name__ == "__main__": args.file_name = args.file_name if args.file_name.count(".slurm") else args.file_name + ".slurm" elif args.scheduler == "lsf": args.file_name = args.file_name if args.file_name.count(".lsf") else args.file_name + ".lsf" + elif args.scheduler == "torque": + args.file_name = args.file_name if args.file_name.count(".torque") else args.file_name + ".torque" if os.path.exists(str(args.file_name)): os.remove(str(args.file_name)) @@ -156,4 +193,5 @@ if __name__ == "__main__": create_job_slurm(args) elif args.scheduler == "lsf": create_job_lsf(args) - + elif args.scheduler == "torque": + create_job_torque(args) diff --git a/script.sh b/script.sh index 82a4254..9a4911f 100755 --- a/script.sh +++ b/script.sh @@ -32,22 +32,31 @@ Job_completed() { if [ "$Jobs_scheduler" == "slurm" ]; then local id1=${1##* } - sleep .5 + sleep 5 if ! scontrol show job $id1 | grep -q 'JobState=COMPLETED'; then Completed=false else Completed=true fi - else - local id1=${head -n1 1 | cut -d'<' -f2 | cut -d'>' -f1} - sleep .5 + elif [ "$Jobs_scheduler" == "lsf" ]; then + local id1=$(head -n1 1 | cut -d'<' -f2 | cut -d'>' -f1) + sleep 5 if ! bjobs -l $id | grep -q 'Status '; then Completed=false else Completed=true fi - fi + elif [ "$Jobs_scheduler" == "torque" ]; then + local id1=$(head -n1 $1 | awk '{ print $3 }') + sleep 5 + if ! qstat f $id | grep -q 'exit_status = 0'; then + Completed=false + else + Completed=true + fi + + } @@ -98,7 +107,7 @@ Test_arguments() exit 1 fi # scheduler correct? - if [ "$Jobs_scheduler" != "slurm" ] && [ "$Jobs_scheduler" != "lsf" ]; then + if [ "$Jobs_scheduler" != "slurm" ] && [ "$Jobs_scheduler" != "lsf" ] && [ "$Jobs_scheduler" != "torque" ]; then echo "$Jobs_scheduler is not a valid scheduler" echo exit 1 @@ -133,8 +142,10 @@ Test_arguments() # Creating auxiliar vars for submiting jobs if [ "$Jobs_scheduler" == "slurm" ]; then job="sbatch" - else - job="bsub" + elif [ "$Jobs_scheduler" == "lsf" ] + job="qsub" + elif [ "$Jobs_scheduler" == "torque" ] + job="" fi -- GitLab From a313905c0cd2c3a98660e2753450b3feba9620ff Mon Sep 17 00:00:00 2001 From: cpenadep Date: Thu, 1 Sep 2022 15:52:03 +0200 Subject: [PATCH 3/4] Fixed mistakes in principal files --- Job_Creator.py | 6 +++--- script.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Job_Creator.py b/Job_Creator.py index 4d9f46e..dc70f90 100644 --- a/Job_Creator.py +++ b/Job_Creator.py @@ -134,9 +134,9 @@ def create_job_torque(args): "#PBS --constraint=perfparanoid \n"] if cores is not None: - file.append("#PBS -l nodes"+str(nodes)":ppn=" + str(cores) + "\n") + file.append("#PBS -l nodes" + str(nodes) + ":ppn=" + str(cores) + "\n") if time is not None and not 0: - file.append("#PBS -l cput=" + str(hours)+":"+str(minutes)+ ":00\n") + file.append("#PBS -l cput=" + str(hours) + ":"+str(minutes)+ ":00\n") if name is not None: file.append("#PBS -N " + name + "\n") if queue is not None and not len(queue) == 0: @@ -194,4 +194,4 @@ if __name__ == "__main__": elif args.scheduler == "lsf": create_job_lsf(args) elif args.scheduler == "torque": - create_job_torque(args) + create_job_torque(args) diff --git a/script.sh b/script.sh index 9a4911f..65193fd 100755 --- a/script.sh +++ b/script.sh @@ -55,7 +55,7 @@ Job_completed() else Completed=true fi - + fi } @@ -142,10 +142,10 @@ Test_arguments() # Creating auxiliar vars for submiting jobs if [ "$Jobs_scheduler" == "slurm" ]; then job="sbatch" - elif [ "$Jobs_scheduler" == "lsf" ] + elif [ "$Jobs_scheduler" == "lsf" ]; then + job="bsub" + elif [ "$Jobs_scheduler" == "torque" ]; then job="qsub" - elif [ "$Jobs_scheduler" == "torque" ] - job="" fi -- GitLab From 063b8b5afc70ffded273c14317b382a1264658b0 Mon Sep 17 00:00:00 2001 From: cpenadep Date: Mon, 5 Sep 2022 13:08:19 +0200 Subject: [PATCH 4/4] Now namelist are not overwritten with the copy only the nemo binary --- config.bash | 2 +- script.sh | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/config.bash b/config.bash index 8d0f4c8..aa4ad29 100644 --- a/config.bash +++ b/config.bash @@ -19,7 +19,7 @@ Jobs_queue=debug # Compilation_compile: When false only compiles NEMO if arch file lacks the needed flags, when true always compiles NEMO. # Compilation_ref: Reference configuration # Compilation_arch: Architecture used (without the -arch sufix and the .fcm) -# Compilation_name: Name of the new configutation +# Compilation_name: Name of the new configutation (Important to not be an existing one) # Compilation_sub: Add or remove subcomponents diff --git a/script.sh b/script.sh index 65193fd..8f6d240 100755 --- a/script.sh +++ b/script.sh @@ -252,30 +252,25 @@ Test_Comp() fi - #Rename the namelist_cfg if exists in order to not overwrite it - if test -f "namelist_cfg"; then - mv namelist_cfg namelist_cfg_old - cd "$dir" || echo "Error original dir doesn't exist" exit - cp "${Nemo_path}"/cfgs/"${name_cfg}"/EXP00/* . - rm namelist_cfg - mv namelist_cfg_old namelist_cfg - else - cd "$dir" || echo "Error original dir doesn't exist" exit - cp "${Nemo_path}"/cfgs/"${name_cfg}"/EXP00/* . - fi + #Copy all the EXP00 data but don't overwrite namelist just the executable + cd "$dir" || echo "Error original dir doesn't exist" exit + cp -n "${Nemo_path}"/cfgs/"${name_cfg}"/EXP00/* . + cp "${Nemo_path}"/cfgs/"${name_cfg}"/EXP00/nemo . if [[ $comp_cfg == "-d OCE del_key 'key_si3 key_top'" ]]; then sed -i '/_def_nemo-ice.xml\|def_nemo-pisces.xml/d' context_nemo.xml #DELETE ICE AND PISCES CONTEXT (NOT USED) fi - #Solving NEMO 4.2 Errors - sed -i 's|ln_zdfiwm * = .true.|ln_zdfiwm = .false.|g' namelist_cfg #CHANGE DUE TO NON EXISTING FILES + #Solving NEMO input file common errors + if test -f "weights_core_orca2_bicubic_noc.nc"; then mv weights_core_orca2_bicubic_noc.nc weights_core2_orca2_bicub.nc #RENAME WRONG NAMED FILES fi + if test -f "weights_core_orca2_bilinear_noc.nc"; then mv weights_core_orca2_bilinear_noc.nc weights_core2_orca2_bilin.nc #RENAME WRONG NAMED FILES fi + } @@ -297,7 +292,8 @@ Create_metrics() state2=$("$job" --wait run."$Jobs_scheduler") Job_completed "$state2" if [ $Completed == false ]; then - echo "Nemo execution failed no gprof files generated look at run.err for more info" + echo "Nemo execution failed look at run.err and ocean.output for more info" + echo "Remember that the namelist files are now the default, change theme in order to fit with the input files in the dir " echo exit 1 else -- GitLab