print("EpsValue_polymer_graft: ", epsarr_pg[eps])

            if ana_flag == 'smd':

                print("Generating SMD initial conditions ..")
                #------Create SMD work directory-----------------------

                traj_workdir = workdir3
                smd_workdir = traj_workdir + '/smd_main'
                if not os.path.isdir(smd_workdir):
                    os.mkdir(smd_workdir)

                #------All copying/manipulations-----------------------

                print("Finding latest archived restart file..")
                refyle = find_recent_file(traj_workdir, res_prefix)

                if refyle == "nil":
                    print("no restart file found in ", traj_workdir)
                    continue
                else:
                    os.chdir(smd_workdir)
                    print("Creating datafile..")
                    cpy_main_files(traj_workdir, smd_workdir, refyle)
                    lmp_execfile = lmp_execdir + '/' + lmp_fylename
                    create_datafyle(lmp_execfile, refyle, smd_fylename)

                for fylcnt in range(len(fyls_main)):
                    cpy_main_files(srclmpdir, smd_workdir, fyls_main[fylcnt])

                cpy_main_files(lmp_execdir, smd_workdir, lmp_fylename)
            else:

                print("%s\t %g\t %d\t %s\t %d\t" %
                      ("Restarting simulation for pdi/nfree/arch/casenum",
                       pdi_free, free_chains[ifree], fylstr,
                       ncases_pdi[caselen]))
                if not os.path.isdir(workdir_subpdi):
                    print(workdir_subpdi, "not found")
                    continue

                os.chdir(workdir_subpdi)
                destdir = os.getcwd()

                os.chdir(workdir_subpdi)
                print("Current path: ", workdir_subpdi)
                latest_restfyl = find_recent_file(destdir, archive_file_style)
                delimited_vals = re.split("\W+|_", latest_restfyl)
                timeval = delimited_vals[len(delimited_vals) - 2]
                print("timeval", timeval)

                if int(timeval) > maxtime:
                    print('Max time reached: ', timeval, maxtime)
                    continue

                elif int(timeval) > equiltime:

                    print('Running production cycle..')
                    for fyllist in range(len(lmp_long)):
                        cpy_main_files(lmpdir, destdir, lmp_long[fyllist])

                    fylename = destdir + '/lmp_mesabi'
            if list_of_files == []:
                begin_fresh = 1 #No files here to start with
                print("No files found in: ", destdir)
                print("Beginning new simulation")
                start_from_beginning(maindir,srclmp,lmp_execdir,destdir,\
                                     data_fname,temp,polywtperc,rcut,blist,\
                                     alist,k_phi,wlccheck,anglstyl,nchains,\
                                     polydens,graftMW,initcom,nmons[bblen],\
                                     graftarr[glen],epsarr_gg[eps],graftopt,\
                                     geninp_list,begin_fresh,key_eps_pg,\
                                     epsval_pg)
                
                
            else:

                latest_restfyl = find_recent_file(destdir,restname)

                #restart file should be of type archive_*
                # check whether archive files are present

                if latest_restfyl == "nil": 
                    restflag = -1 
                    print("ERROR: Could not find restart files")
                    continue
                else:
                    delimited_vals = re.split("\W+|_",latest_restfyl)
                    timeval = delimited_vals[len(delimited_vals)-1] 
                    if int(timeval) < min_equilsteps: 
                        print("ERROR: Timestep<",min_equilsteps)
                        continue
                    else:
            os.chdir(workdir3)
            destdir = os.getcwd()

            print("Currently in: ", destdir)

            list_of_files = glob.glob('*')

            if list_of_files == []:
                print("No files here: Check path")
                continue

            else:

                trajflag = 1  #trajectory found=1
                flagstr = -1  #is a string = 1
                latest_trajfyl = find_recent_file(destdir, dumpname)
                #dumpfile should be of type dump_stage_*
                if latest_trajfyl == "nil":
                    trajflag = -1
                else:
                    delimited_vals = re.split("\W+|_", latest_trajfyl)
                    timeval = delimited_vals[len(delimited_vals) - 2]
                    #check whether the dumpfile is dump_stage1.*
                    flagstr = check_integer(timeval)
                    if flagstr == 1:
                        print("Did not find matching dumpfile, restarting")
                        trajflag = -1
                    elif int(timeval) < 1000000:
                        print("Timestep less than 1000000, restarting")
                        trajflag = -1
                    else: