import os N_arr = range(6, 38, 2) sim_pack = 'quest' task = 'hdyn' com_cap = 'mt' prec = 'dp' gen_path = '/data/user/gangap_a/{}_singular/gen_files/'.format(task) sim_path = '/data/user/gangap_a/{}_singular/{}/'.format(task, sim_pack) print(sim_path) # os.chdir(sim_path) print(' ############################ ') print('### Create job scripts folder for package: {}, task: {}, compute cap: {}, precision: {}'.format(sim_pack, task, com_cap, prec)) job_scripts_path = sim_path+'job_scripts_{}_{}'.format(com_cap, prec) print(job_scripts_path) os.mkdir(job_scripts_path) print('### Create job scripts') os.chdir(job_scripts_path) cjs = gen_path+'create_job_script.py {} {} {} {}'.format(sim_pack, task, com_cap, prec) os.system('python3 {}'.format(cjs)) print(' ############################ ') print('### Create bash scripts folder for package: {}, task:{}, compute cap:{}, precision {}'.format(sim_pack, task, com_cap, prec)) bash_scripts_path = sim_path+'bash_scripts_{}_{}'.format(com_cap, prec) os.mkdir(bash_scripts_path) print('### Create bash scripts') os.chdir(bash_scripts_path) cbs = gen_path+'create_bash_script.py {} {} {} {}'.format(sim_pack, task, com_cap, prec) os.system('python3 {}'.format(cbs)) print(' ############################ ') print('### Create output folder') os.mkdir(sim_path+'output_{}_{}'.format(com_cap, prec)) print('### Create error folder') os.mkdir(sim_path+'error_{}_{}'.format(com_cap, prec)) print('### Create data folder') os.mkdir(sim_path+'data_{}_{}'.format(com_cap, prec)) print(' ############################ ') print('### Create run files folder package: {}, task:{}, compute cap:{}, precision {}'.format(sim_pack, task, com_cap, prec)) run_files_path = sim_path+'run_files_{}_{}'.format(com_cap, prec) os.mkdir(run_files_path) sim_parser = input("Enter the python file including the path for the parser: ") os.system('python3 {}'.format(sim_parser)) print(' ############################ ') print('### Generate the CMakeLists.txt file and the bin_{}_{} folder'.format(com_cap, prec)) os.chdir(sim_path) os.mkdir('bin_{}_{}'.format(com_cap, prec)) with open('CMakeLists.txt', 'w') as cml: cml.write('message(STATUS \"Compiling\")\n') cml.write('file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/' + 'run_files_{}_{}/*.cpp)\n'.format(com_cap, prec)) cml.write('foreach( sourcefile ${APP_SOURCES} )\n') cml.write('file(RELATIVE_PATH filename ${CMAKE_SOURCE_DIR}/' + 'run_files_{}_{}'.format(com_cap, prec) + ' ${sourcefile})\n') cml.write('string( REPLACE \".cpp\" \"\" file ${filename} )\n') cml.write('add_executable( ${file} ${sourcefile} )\n') cml.write('target_link_libraries( ${file} PRIVATE iqs)\n') cml.write('set_target_properties(\n') cml.write('${file}\n') cml.write('PROPERTIES\n') cml.write('RUNTIME_OUTPUT_DIRECTORY "' + str("${CMAKE_SOURCE_DIR}") + '/bin_{}_{}\"\n'.format(com_cap, prec)) cml.write(')\n') cml.write('endforeach( sourcefile ${APP_SOURCES} )\n') print(' ############################ ') print('### Create bash scripts to run jobs') os.chdir(sim_path) with open('run_jobs_{}_{}.sh'.format(com_cap, prec), 'w') as f: f.write('path=\"/data/user/gangap_a/{}_singular/{}/job_scripts_{}_{}\"\n'.format(task, sim_pack, com_cap, prec)) f.write('cd $path\n') f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/quest/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/{}_singular/quest/:/home\"\n'.format(task, com_cap, prec, task)) f.write('singularity exec /data/user/gangap_a/singularity_images/qucos_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec)) f.write('for job_script in *.sh; do\n') f.write('echo $job_script;\n') f.write('sbatch $job_script;\n') f.write('done\n')