#
#
#
nParam = 3
functional = "Fnone"
#
#* making the jobs files of each replica:
import os
import subprocess
#
lista = subprocess.run(['ls'], stdout=subprocess.PIPE).stdout.decode('utf-8')
lista = lista.split("\n")
repDicList = []
for ele in lista:
	if "cR_" in ele: repDicList.append( ele )
for ele in repDicList: print(ele) # debug line
#
for ele in repDicList: os.system(f"cd {ele} ; python saveOutParameters-2.0.py; cd ..; echo")
#
from pprint import pprint, pformat
#
paramModelOPT = {} # OUT DICT
#
for index, targetOPT in enumerate( repDicList ):
	repNum = index + 1

	dictIDlabel = f"np{nParam}_{functional}_rep{repNum:02d}" # input 'none' to proceed with defalut name, or any name to label this specifi dictionary

	#* loding the new parameters dictionary:
	file = open(f'{targetOPT}/newParametersModelOPT.py','r') 
	exec(file.read())
	file.close()

	#* updating the parametersModelOPT dictionary:
	#pprint(paramModelOPT,width=400) # debug line
	#print(pformat(paramModelOPT,width=400)) # debug line

	for newKey in newParamModelOPT:
	    dictIDlabel = newKey.split('Bulk')[0].replace('opt',f"optBulk{dictIDlabel}")
	    paramModelOPT[dictIDlabel] = newParamModelOPT[newKey]
	    #print(newKey, dictIDlabel) # debug line

fileData = "newParamModelOPT =\\\n"
fileData += pformat(paramModelOPT,width=4500)
#print(fileData)  # debug line
file = open('newParametersModelOPT.py','w')
file.write(fileData)
file.close()