ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/cms_cmssw.py
(Generate patch)

Comparing COMP/CRAB/python/cms_cmssw.py (file contents):
Revision 1.128 by fanzago, Thu Oct 11 16:23:44 2007 UTC vs.
Revision 1.144 by mcinquil, Tue Dec 4 18:53:36 2007 UTC

# Line 13 | Line 13 | class Cmssw(JobType):
13          JobType.__init__(self, 'CMSSW')
14          common.logger.debug(3,'CMSSW::__init__')
15  
16 +        self.argsList = []
17 +
18          self._params = {}
19          self.cfg_params = cfg_params
18
20          # init BlackWhiteListParser
21          self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
22  
# Line 28 | Line 29 | class Cmssw(JobType):
29          self.ncjobs = ncjobs
30  
31          log = common.logger
32 <        
32 >
33          self.scram = Scram.Scram(cfg_params)
34          self.additional_inbox_files = []
35          self.scriptExe = ''
# Line 37 | Line 38 | class Cmssw(JobType):
38          self.tgz_name = 'default.tgz'
39          self.additional_tgz_name = 'additional.tgz'
40          self.scriptName = 'CMSSW.sh'
41 <        self.pset = ''      #scrip use case Da  
41 >        self.pset = ''      #scrip use case Da
42          self.datasetPath = '' #scrip use case Da
43  
44          # set FJR file name
45          self.fjrFileName = 'crab_fjr.xml'
46  
47          self.version = self.scram.getSWVersion()
48 <        
48 >
49          #
50          # Try to block creation in case of arch/version mismatch
51          #
# Line 52 | Line 53 | class Cmssw(JobType):
53          a = string.split(self.version, "_")
54  
55          if int(a[1]) == 1 and (int(a[2]) < 5 and self.executable_arch.find('slc4') == 0):
56 <            msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
57 <            raise CrabException(msg)
56 >            msg = "Warning: You are using %s version of CMSSW  with %s architecture. \n--> Did you compile your libraries with SLC3? Otherwise you can find some problems running on SLC4 Grid nodes.\n"%(self.version, self.executable_arch)
57 >            common.logger.message(msg)
58          if int(a[1]) == 1 and (int(a[2]) >= 5 and self.executable_arch.find('slc3') == 0):
59              msg = "Error: CMS does not support %s with %s architecture"%(self.version, self.executable_arch)
60              raise CrabException(msg)
61 <        
61 >
62          common.taskDB.setDict('codeVersion',self.version)
63          self.setParam_('application', self.version)
64  
65          ### collect Data cards
66  
66        ## get DBS mode
67        try:
68            self.use_dbs_1 = int(self.cfg_params['CMSSW.use_dbs_1'])
69        except KeyError:
70            self.use_dbs_1 = 0
71            
67          try:
68              tmp =  cfg_params['CMSSW.datasetpath']
69              log.debug(6, "CMSSW::CMSSW(): datasetPath = "+tmp)
# Line 79 | Line 74 | class Cmssw(JobType):
74                  self.datasetPath = tmp
75                  self.selectNoInput = 0
76          except KeyError:
77 <            msg = "Error: datasetpath not defined "  
77 >            msg = "Error: datasetpath not defined "
78              raise CrabException(msg)
79  
80          # ML monitoring
# Line 92 | Line 87 | class Cmssw(JobType):
87                  datasetpath_split = self.datasetPath.split("/")
88                  # standard style
89                  self.setParam_('datasetFull', self.datasetPath)
90 <                if self.use_dbs_1 == 1 :
91 <                    self.setParam_('dataset', datasetpath_split[1])
97 <                    self.setParam_('owner', datasetpath_split[-1])
98 <                else:
99 <                    self.setParam_('dataset', datasetpath_split[1])
100 <                    self.setParam_('owner', datasetpath_split[2])
90 >                self.setParam_('dataset', datasetpath_split[1])
91 >                self.setParam_('owner', datasetpath_split[2])
92              except:
93                  self.setParam_('dataset', self.datasetPath)
94                  self.setParam_('owner', self.datasetPath)
95 <                
95 >
96          self.setTaskid_()
97          self.setParam_('taskId', self.cfg_params['taskId'])
98  
# Line 124 | Line 115 | class Cmssw(JobType):
115          try:
116              self.pset = cfg_params['CMSSW.pset']
117              log.debug(6, "Cmssw::Cmssw(): PSet file = "+self.pset)
118 <            if self.pset.lower() != 'none' :
118 >            if self.pset.lower() != 'none' :
119                  if (not os.path.exists(self.pset)):
120                      raise CrabException("User defined PSet file "+self.pset+" does not exist")
121              else:
# Line 216 | Line 207 | class Cmssw(JobType):
207          except KeyError:
208              self.eventsPerJob = -1
209              self.selectEventsPerJob = 0
210 <    
210 >
211          ## number of jobs
212          try:
213              self.theNumberOfJobs =int( cfg_params['CMSSW.number_of_jobs'])
# Line 232 | Line 223 | class Cmssw(JobType):
223              self.total_number_of_events = 0
224              self.selectTotalNumberEvents = 0
225  
226 <        if self.pset != None: #CarlosDaniele
226 >        if self.pset != None: #CarlosDaniele
227               if ( (self.selectTotalNumberEvents + self.selectEventsPerJob + self.selectNumberOfJobs) != 2 ):
228                   msg = 'Must define exactly two of total_number_of_events, events_per_job, or number_of_jobs.'
229                   raise CrabException(msg)
# Line 272 | Line 263 | class Cmssw(JobType):
263              self.firstRun = None
264              common.logger.debug(5,"No first run given")
265          if self.pset != None: #CarlosDaniele
266 <            ver = string.split(self.version,"_")
276 <            if (int(ver[1])>=1 and int(ver[2])>=5):
277 <                import PsetManipulator150 as pp
278 <            else:
279 <                import PsetManipulator as pp
266 >            import PsetManipulator as pp
267              PsetEdit = pp.PsetManipulator(self.pset) #Daniele Pset
268  
269          #DBSDLS-start
270 <        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
270 >        ## Initialize the variables that are extracted from DBS/DLS and needed in other places of the code
271          self.maxEvents=0  # max events available   ( --> check the requested nb. of evts in Creator.py)
272          self.DBSPaths={}  # all dbs paths requested ( --> input to the site local discovery script)
273          self.jobDestination=[]  # Site destination(s) for each job (list of lists)
# Line 289 | Line 276 | class Cmssw(JobType):
276          blockSites = {}
277          if self.datasetPath:
278              blockSites = self.DataDiscoveryAndLocation(cfg_params)
279 <        #DBSDLS-end          
279 >        #DBSDLS-end
280  
281          self.tgzNameWithPath = self.getTarBall(self.executable)
282 <    
282 >
283          ## Select Splitting
284 <        if self.selectNoInput:
284 >        if self.selectNoInput:
285              if self.pset == None: #CarlosDaniele
286                  self.jobSplittingForScript()
287              else:
# Line 307 | Line 294 | class Cmssw(JobType):
294              try:
295                  if (self.datasetPath): # standard job
296                      # allow to processa a fraction of events in a file
297 <                    PsetEdit.inputModule("INPUT")
298 <                    PsetEdit.maxEvent("INPUTMAXEVENTS")
299 <                    PsetEdit.skipEvent("INPUTSKIPEVENTS")
297 >                    PsetEdit.inputModule("INPUTFILE")
298 >                    PsetEdit.maxEvent(0)
299 >                    PsetEdit.skipEvent(0)
300                  else:  # pythia like job
301                      PsetEdit.maxEvent(self.eventsPerJob)
302                      if (self.firstRun):
303 <                        PsetEdit.pythiaFirstRun("INPUTFIRSTRUN")  #First Run
303 >                        PsetEdit.pythiaFirstRun(0)  #First Run
304                      if (self.sourceSeed) :
305 <                        PsetEdit.pythiaSeed("INPUT")
305 >                        PsetEdit.pythiaSeed(0)
306                          if (self.sourceSeedVtx) :
307 <                            PsetEdit.vtxSeed("INPUTVTX")
307 >                            PsetEdit.vtxSeed(0)
308                          if (self.sourceSeedG4) :
309 <                            PsetEdit.g4Seed("INPUTG4")
309 >                            PsetEdit.g4Seed(0)
310                          if (self.sourceSeedMix) :
311 <                            PsetEdit.mixSeed("INPUTMIX")
311 >                            PsetEdit.mixSeed(0)
312                  # add FrameworkJobReport to parameter-set
313                  PsetEdit.addCrabFJR(self.fjrFileName)
314                  PsetEdit.psetWriter(self.configFilename())
# Line 332 | Line 319 | class Cmssw(JobType):
319      def DataDiscoveryAndLocation(self, cfg_params):
320  
321          import DataDiscovery
335        import DataDiscovery_DBS2
322          import DataLocation
323          common.logger.debug(10,"CMSSW::DataDiscoveryAndLocation()")
324  
# Line 342 | Line 328 | class Cmssw(JobType):
328          common.logger.message("Contacting Data Discovery Services ...")
329          try:
330  
331 <            if self.use_dbs_1 == 1 :
346 <                self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
347 <            else :
348 <                self.pubdata=DataDiscovery_DBS2.DataDiscovery_DBS2(datasetPath, cfg_params)
331 >            self.pubdata=DataDiscovery.DataDiscovery(datasetPath, cfg_params)
332              self.pubdata.fetchDBSInfo()
333  
334          except DataDiscovery.NotExistingDatasetError, ex :
# Line 357 | Line 340 | class Cmssw(JobType):
340          except DataDiscovery.DataDiscoveryError, ex:
341              msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
342              raise CrabException(msg)
360        except DataDiscovery_DBS2.NotExistingDatasetError_DBS2, ex :
361            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
362            raise CrabException(msg)
363        except DataDiscovery_DBS2.NoDataTierinProvenanceError_DBS2, ex :
364            msg = 'ERROR ***: failed Data Discovery in DBS : %s'%ex.getErrorMessage()
365            raise CrabException(msg)
366        except DataDiscovery_DBS2.DataDiscoveryError_DBS2, ex:
367            msg = 'ERROR ***: failed Data Discovery in DBS :  %s'%ex.getErrorMessage()
368            raise CrabException(msg)
343  
344          self.filesbyblock=self.pubdata.getFiles()
345          self.eventsbyblock=self.pubdata.getEventsPerBlock()
346          self.eventsbyfile=self.pubdata.getEventsPerFile()
347  
348          ## get max number of events
349 <        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
349 >        self.maxEvents=self.pubdata.getMaxEvents() ##  self.maxEvents used in Creator.py
350  
351          ## Contact the DLS and build a list of sites hosting the fileblocks
352          try:
# Line 381 | Line 355 | class Cmssw(JobType):
355          except DataLocation.DataLocationError , ex:
356              msg = 'ERROR ***: failed Data Location in DLS \n %s '%ex.getErrorMessage()
357              raise CrabException(msg)
358 <        
358 >
359  
360          sites = dataloc.getSites()
361          allSites = []
# Line 395 | Line 369 | class Cmssw(JobType):
369          common.logger.message("Requested dataset: " + datasetPath + " has " + str(self.maxEvents) + " events in " + str(len(self.filesbyblock.keys())) + " blocks.\n")
370  
371          return sites
372 <    
372 >
373 >    def setArgsList(self, argsList):
374 >        self.argsList = argsList
375 >
376      def jobSplittingByBlocks(self, blockSites):
377          """
378          Perform job splitting. Jobs run over an integer number of files
# Line 445 | Line 422 | class Cmssw(JobType):
422              totalNumberOfJobs = 999999999
423          else :
424              totalNumberOfJobs = self.ncjobs
425 <            
425 >
426  
427          blocks = blockSites.keys()
428          blockCount = 0
# Line 465 | Line 442 | class Cmssw(JobType):
442              blockCount += 1
443              if block not in jobsOfBlock.keys() :
444                  jobsOfBlock[block] = []
445 <            
445 >
446              if self.eventsbyblock.has_key(block) :
447                  numEventsInBlock = self.eventsbyblock[block]
448                  common.logger.debug(5,'Events in Block File '+str(numEventsInBlock))
449 <            
449 >
450                  files = self.filesbyblock[block]
451                  numFilesInBlock = len(files)
452                  if (numFilesInBlock <= 0):
# Line 477 | Line 454 | class Cmssw(JobType):
454                  fileCount = 0
455  
456                  # ---- New block => New job ---- #
457 <                parString = "\\{"
457 >                parString = ""
458                  # counter for number of events in files currently worked on
459                  filesEventCount = 0
460                  # flag if next while loop should touch new file
461                  newFile = 1
462                  # job event counter
463                  jobSkipEventCount = 0
464 <            
464 >
465                  # ---- Iterate over the files in the block until we've met the requested ---- #
466                  # ---- total # of events or we've gone over all the files in this block  ---- #
467                  while ( (eventsRemaining > 0) and (fileCount < numFilesInBlock) and (jobCount < totalNumberOfJobs) ):
# Line 500 | Line 477 | class Cmssw(JobType):
477                              newFile = 0
478                          except KeyError:
479                              common.logger.message("File "+str(file)+" has unknown number of events: skipping")
480 <                        
480 >
481  
482                      # if less events in file remain than eventsPerJobRequested
483                      if ( filesEventCount - jobSkipEventCount < eventsPerJobRequested ) :
# Line 509 | Line 486 | class Cmssw(JobType):
486                              # end job using last file, use remaining events in block
487                              # close job and touch new file
488                              fullString = parString[:-2]
512                            fullString += '\\}'
489                              list_of_lists.append([fullString,str(-1),str(jobSkipEventCount)])
490                              common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(filesEventCount - jobSkipEventCount)+" events (last file in block).")
491                              self.jobDestination.append(blockSites[block])
# Line 522 | Line 498 | class Cmssw(JobType):
498                              eventsRemaining = eventsRemaining - filesEventCount + jobSkipEventCount
499                              jobSkipEventCount = 0
500                              # reset file
501 <                            parString = "\\{"
501 >                            parString = ""
502                              filesEventCount = 0
503                              newFile = 1
504                              fileCount += 1
# Line 534 | Line 510 | class Cmssw(JobType):
510                      elif ( filesEventCount - jobSkipEventCount == eventsPerJobRequested ) :
511                          # close job and touch new file
512                          fullString = parString[:-2]
537                        fullString += '\\}'
513                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
514                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
515                          self.jobDestination.append(blockSites[block])
# Line 546 | Line 521 | class Cmssw(JobType):
521                          eventsRemaining = eventsRemaining - eventsPerJobRequested
522                          jobSkipEventCount = 0
523                          # reset file
524 <                        parString = "\\{"
524 >                        parString = ""
525                          filesEventCount = 0
526                          newFile = 1
527                          fileCount += 1
528 <                        
528 >
529                      # if more events in file remain than eventsPerJobRequested
530                      else :
531                          # close job but don't touch new file
532                          fullString = parString[:-2]
558                        fullString += '\\}'
533                          list_of_lists.append([fullString,str(eventsPerJobRequested),str(jobSkipEventCount)])
534                          common.logger.debug(3,"Job "+str(jobCount+1)+" can run over "+str(eventsPerJobRequested)+" events.")
535                          self.jobDestination.append(blockSites[block])
# Line 570 | Line 544 | class Cmssw(JobType):
544                          jobSkipEventCount = eventsPerJobRequested - (filesEventCount - jobSkipEventCount - self.eventsbyfile[file])
545                          # remove all but the last file
546                          filesEventCount = self.eventsbyfile[file]
547 <                        parString = "\\{"
547 >                        parString = ""
548                          parString += '\\\"' + file + '\\\"\,'
549                      pass # END if
550                  pass # END while (iterate over files in the block)
# Line 579 | Line 553 | class Cmssw(JobType):
553          if (eventsRemaining > 0 and jobCount < totalNumberOfJobs ):
554              common.logger.message("Could not run on all requested events because some blocks not hosted at allowed sites.")
555          common.logger.message(str(jobCount)+" job(s) can run on "+str(totalEventCount)+" events.\n")
556 <        
556 >
557          # screen output
558          screenOutput = "List of jobs and available destination sites:\n\n"
559  
# Line 593 | Line 567 | class Cmssw(JobType):
567                  blockCounter += 1
568                  screenOutput += "Block %5i: jobs %20s: sites: %s\n" % (blockCounter,spanRanges(jobsOfBlock[block]),','.join(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)))
569                  if len(self.blackWhiteListParser.checkWhiteList(self.blackWhiteListParser.checkBlackList(blockSites[block],block),block)) == 0:
570 <                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
570 >                    noSiteBlock.append( spanRanges(jobsOfBlock[block]) )
571                      bloskNoSite.append( blockCounter )
572 <        
572 >
573          common.logger.message(screenOutput)
574          if len(noSiteBlock) > 0 and len(bloskNoSite) > 0:
575              msg = 'WARNING: No sites are hosting any part of data for block:\n                '
# Line 621 | Line 595 | class Cmssw(JobType):
595          Perform job splitting based on number of event per job
596          """
597          common.logger.debug(5,'Splitting per events')
598 <        common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
599 <        common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
600 <        common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
598 >
599 >        if (self.selectEventsPerJob):
600 >            common.logger.message('Required '+str(self.eventsPerJob)+' events per job ')
601 >        if (self.selectNumberOfJobs):
602 >            common.logger.message('Required '+str(self.theNumberOfJobs)+' jobs in total ')
603 >        if (self.selectTotalNumberEvents):
604 >            common.logger.message('Required '+str(self.total_number_of_events)+' events in total ')
605  
606          if (self.total_number_of_events < 0):
607              msg='Cannot split jobs per Events with "-1" as total number of events'
# Line 632 | Line 610 | class Cmssw(JobType):
610          if (self.selectEventsPerJob):
611              if (self.selectTotalNumberEvents):
612                  self.total_number_of_jobs = int(self.total_number_of_events/self.eventsPerJob)
613 <            elif(self.selectNumberOfJobs) :  
613 >            elif(self.selectNumberOfJobs) :
614                  self.total_number_of_jobs =self.theNumberOfJobs
615 <                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
615 >                self.total_number_of_events =int(self.theNumberOfJobs*self.eventsPerJob)
616  
617          elif (self.selectNumberOfJobs) :
618              self.total_number_of_jobs = self.theNumberOfJobs
619              self.eventsPerJob = int(self.total_number_of_events/self.total_number_of_jobs)
620 <
620 >
621          common.logger.debug(5,'N jobs  '+str(self.total_number_of_jobs))
622  
623          # is there any remainder?
# Line 655 | Line 633 | class Cmssw(JobType):
633          self.list_of_args = []
634          for i in range(self.total_number_of_jobs):
635              ## Since there is no input, any site is good
636 <           # self.jobDestination.append(["Any"])
659 <            self.jobDestination.append([""]) #must be empty to write correctly the xml
636 >            self.jobDestination.append([""]) #must be empty to write correctly the xml
637              args=[]
638              if (self.firstRun):
639 <                    ## pythia first run
663 <                #self.list_of_args.append([(str(self.firstRun)+str(i))])
639 >                ## pythia first run
640                  args.append(str(self.firstRun)+str(i))
665            else:
666                ## no first run
667                #self.list_of_args.append([str(i)])
668                args.append(str(i))
641              if (self.sourceSeed):
642                  args.append(str(self.sourceSeed)+str(i))
643                  if (self.sourceSeedVtx):
# Line 674 | Line 646 | class Cmssw(JobType):
646                  if (self.sourceSeedG4):
647                      ## + G4 random seed
648                      args.append(str(self.sourceSeedG4)+str(i))
649 <                if (self.sourceSeedMix):    
649 >                if (self.sourceSeedMix):
650                      ## + Mix random seed
651                      args.append(str(self.sourceSeedMix)+str(i))
652                  pass
653              pass
654              self.list_of_args.append(args)
655          pass
684            
685        # print self.list_of_args
656  
657          return
658  
# Line 711 | Line 681 | class Cmssw(JobType):
681          return
682  
683      def split(self, jobParams):
684 <
684 >
685          common.jobDB.load()
686          #### Fabio
687          njobs = self.total_number_of_jobs
# Line 719 | Line 689 | class Cmssw(JobType):
689          # create the empty structure
690          for i in range(njobs):
691              jobParams.append("")
692 <        
692 >
693          for job in range(njobs):
694              jobParams[job] = arglist[job]
695              # print str(arglist[job])
# Line 730 | Line 700 | class Cmssw(JobType):
700  
701          common.jobDB.save()
702          return
703 <    
703 >
704      def getJobTypeArguments(self, nj, sched):
705          result = ''
706          for i in common.jobDB.arguments(nj):
707              result=result+str(i)+" "
708          return result
709 <  
709 >
710      def numberOfJobs(self):
711          # Fabio
712          return self.total_number_of_jobs
# Line 745 | Line 715 | class Cmssw(JobType):
715          """
716          Return the TarBall with lib and exe
717          """
718 <        
718 >
719          # if it exist, just return it
720          #
721          # Marco. Let's start to use relative path for Boss XML files
# Line 768 | Line 738 | class Cmssw(JobType):
738          # print "swVersion = ", swVersion
739          swReleaseTop = self.scram.getReleaseTop_()
740          #print "swReleaseTop = ", swReleaseTop
741 <        
741 >
742          ## check if working area is release top
743          if swReleaseTop == '' or swArea == swReleaseTop:
744              return
# Line 781 | Line 751 | class Cmssw(JobType):
751                  exeWithPath = self.scram.findFile_(executable)
752                  if ( not exeWithPath ):
753                      raise CrabException('User executable '+executable+' not found')
754 <    
754 >
755                  ## then check if it's private or not
756                  if exeWithPath.find(swReleaseTop) == -1:
757                      # the exe is private, so we must ship
# Line 790 | Line 760 | class Cmssw(JobType):
760                      # distinguish case when script is in user project area or given by full path somewhere else
761                      if exeWithPath.find(path) >= 0 :
762                          exe = string.replace(exeWithPath, path,'')
763 <                        tar.add(path+exe,os.path.basename(executable))
763 >                        tar.add(path+exe,exe)
764                      else :
765                          tar.add(exeWithPath,os.path.basename(executable))
766                      pass
767                  else:
768                      # the exe is from release, we'll find it on WN
769                      pass
770 <    
770 >
771              ## Now get the libraries: only those in local working area
772              libDir = 'lib'
773              lib = swArea+'/' +libDir
774              common.logger.debug(5,"lib "+lib+" to be tarred")
775              if os.path.exists(lib):
776                  tar.add(lib,libDir)
777 <    
777 >
778              ## Now check if module dir is present
779              moduleDir = 'module'
780              module = swArea + '/' + moduleDir
# Line 830 | Line 800 | class Cmssw(JobType):
800              prodcommonPath = os.environ['CRABDIR'] + '/' + 'ProdCommon'
801              if os.path.isdir(prodcommonPath):
802                  tar.add(prodcommonPath,prodcommonDir)
803 <            #############################    
804 <        
803 >            #############################
804 >
805              common.logger.debug(5,"Files added to "+self.tgzNameWithPath+" : "+str(tar.getnames()))
806              tar.close()
807          except :
# Line 843 | Line 813 | class Cmssw(JobType):
813              raise CrabException('Input sandbox size of ' + str(float(tarballinfo.st_size)/1024.0/1024.0) + ' MB is larger than the allowed ' + str(self.MaxTarBallSize) + ' MB input sandbox limit and not supported by the used GRID submission system. Please make sure that no unnecessary files are in all data directories in your local CMSSW project area as they are automatically packed into the input sandbox.')
814  
815          ## create tar-ball with ML stuff
816 <        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
816 >        self.MLtgzfile =  common.work_space.pathForTgz()+'share/MLfiles.tgz'
817          try:
818              tar = tarfile.open(self.MLtgzfile, "w:gz")
819              path=os.environ['CRABDIR'] + '/python/'
# Line 853 | Line 823 | class Cmssw(JobType):
823              tar.close()
824          except :
825              raise CrabException('Could not create ML files tar-ball')
826 <        
826 >
827          return
828 <        
828 >
829      def additionalInputFileTgz(self):
830          """
831          Put all additional files into a tar ball and return its name
# Line 875 | Line 845 | class Cmssw(JobType):
845          the execution environment for the job 'nj'.
846          """
847          # Prepare JobType-independent part
848 <        txt = ''
849 <  
850 <        ## OLI_Daniele at this level  middleware already known
881 <
882 <        txt += 'if [ $middleware == LCG ]; then \n'
883 <        txt += '    echo "### First set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
884 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
885 <        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
848 >        txt = ''
849 >        txt += 'echo ">>> setup environment"\n'
850 >        txt += 'if [ $middleware == LCG ]; then \n'
851          txt += self.wsSetupCMSLCGEnvironment_()
852          txt += 'elif [ $middleware == OSG ]; then\n'
853          txt += '    WORKING_DIR=`/bin/mktemp  -d $OSG_WN_TMP/cms_XXXXXXXXXXXX`\n'
854 <        txt += '    echo "Created working directory: $WORKING_DIR"\n'
890 <        txt += '    if [ ! -d $WORKING_DIR ] ;then\n'
854 >        txt += '    if [ ! $? == 0 ] ;then\n'
855          txt += '        echo "SET_CMS_ENV 10016 ==> OSG $WORKING_DIR could not be created on WN `hostname`"\n'
856 <        txt += '    echo "JOB_EXIT_STATUS = 10016"\n'
857 <        txt += '    echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
858 <        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
895 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
896 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
897 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
856 >        txt += '        echo "JOB_EXIT_STATUS = 10016"\n'
857 >        txt += '        echo "JobExitCode=10016" | tee -a $RUNTIME_AREA/$repo\n'
858 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
859          txt += '        exit 1\n'
860          txt += '    fi\n'
861 +        txt += '    echo ">>> Created working directory: $WORKING_DIR"\n'
862          txt += '\n'
863          txt += '    echo "Change to working directory: $WORKING_DIR"\n'
864          txt += '    cd $WORKING_DIR\n'
865 <        txt += self.wsSetupCMSOSGEnvironment_()
866 <        txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
867 <        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
865 >        txt += '    echo ">>> current directory (WORKING_DIR): $WORKING_DIR"\n'
866 >        txt += self.wsSetupCMSOSGEnvironment_()
867 >        #txt += '    echo "### Set SCRAM ARCH to ' + self.executable_arch + ' ###"\n'
868 >        #txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
869          txt += 'fi\n'
870  
871          # Prepare JobType-specific part
872          scram = self.scram.commandName()
873          txt += '\n\n'
874 <        txt += 'echo "### SPECIFIC JOB SETUP ENVIRONMENT ###"\n'
874 >        txt += 'echo ">>> specific cmssw setup environment:"\n'
875 >        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
876          txt += scram+' project CMSSW '+self.version+'\n'
877          txt += 'status=$?\n'
878          txt += 'if [ $status != 0 ] ; then\n'
879 <        txt += '   echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
880 <        txt += '   echo "JOB_EXIT_STATUS = 10034"\n'
881 <        txt += '   echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
882 <        txt += '   dumpStatus $RUNTIME_AREA/$repo\n'
919 <        txt += '   rm -f $RUNTIME_AREA/$repo \n'
920 <        txt += '   echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
921 <        txt += '   echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
922 <        ## OLI_Daniele
879 >        txt += '    echo "SET_EXE_ENV 10034 ==>ERROR CMSSW '+self.version+' not found on `hostname`" \n'
880 >        txt += '    echo "JOB_EXIT_STATUS = 10034"\n'
881 >        txt += '    echo "JobExitCode=10034" | tee -a $RUNTIME_AREA/$repo\n'
882 >        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
883          txt += '    if [ $middleware == OSG ]; then \n'
924        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
884          txt += '        cd $RUNTIME_AREA\n'
885 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
886 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
887          txt += '        /bin/rm -rf $WORKING_DIR\n'
888          txt += '        if [ -d $WORKING_DIR ] ;then\n'
889          txt += '            echo "SET_CMS_ENV 10018 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after CMSSW CMSSW_0_6_1 not found on `hostname`"\n'
890          txt += '            echo "JOB_EXIT_STATUS = 10018"\n'
891          txt += '            echo "JobExitCode=10018" | tee -a $RUNTIME_AREA/$repo\n'
892          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
932        txt += '            rm -f $RUNTIME_AREA/$repo \n'
933        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
934        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
893          txt += '        fi\n'
894          txt += '    fi \n'
895 <        txt += '   exit 1 \n'
895 >        txt += '    exit 1 \n'
896          txt += 'fi \n'
939        txt += 'echo "CMSSW_VERSION =  '+self.version+'"\n'
897          txt += 'cd '+self.version+'\n'
898          ########## FEDE FOR DBS2 ######################
899          txt += 'SOFTWARE_DIR=`pwd`\n'
900 <        txt += 'echo SOFTWARE_DIR=$SOFTWARE_DIR \n'
900 >        txt += 'echo ">>> current directory (SOFTWARE_DIR): $SOFTWARE_DIR" \n'
901          ###############################################
902          ### needed grep for bug in scramv1 ###
903          txt += scram+' runtime -sh\n'
904          txt += 'eval `'+scram+' runtime -sh | grep -v SCRAMRT_LSB_JOBNAME`\n'
905          txt += 'echo $PATH\n'
949
906          # Handle the arguments:
907          txt += "\n"
908          txt += "## number of arguments (first argument always jobnumber)\n"
909          txt += "\n"
910 < #        txt += "narg=$#\n"
955 <        txt += "if [ $nargs -lt 2 ]\n"
910 >        txt += "if [ $nargs -lt "+str(len(self.argsList[nj].split()))+" ]\n"
911          txt += "then\n"
912          txt += "    echo 'SET_EXE_ENV 1 ==> ERROR Too few arguments' +$nargs+ \n"
913          txt += '    echo "JOB_EXIT_STATUS = 50113"\n'
914          txt += '    echo "JobExitCode=50113" | tee -a $RUNTIME_AREA/$repo\n'
915          txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
961        txt += '    rm -f $RUNTIME_AREA/$repo \n'
962        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
963        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
964        ## OLI_Daniele
916          txt += '    if [ $middleware == OSG ]; then \n'
966        txt += '        echo "Remove working directory: $WORKING_DIR"\n'
917          txt += '        cd $RUNTIME_AREA\n'
918 +        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
919 +        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
920          txt += '        /bin/rm -rf $WORKING_DIR\n'
921          txt += '        if [ -d $WORKING_DIR ] ;then\n'
922          txt += '            echo "SET_EXE_ENV 50114 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Too few arguments for CRAB job wrapper"\n'
923          txt += '            echo "JOB_EXIT_STATUS = 50114"\n'
924          txt += '            echo "JobExitCode=50114" | tee -a $RUNTIME_AREA/$repo\n'
925          txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
974        txt += '            rm -f $RUNTIME_AREA/$repo \n'
975        txt += '            echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
976        txt += '            echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
926          txt += '        fi\n'
927          txt += '    fi \n'
928          txt += "    exit 1\n"
# Line 983 | Line 932 | class Cmssw(JobType):
932          # Prepare job-specific part
933          job = common.job_list[nj]
934          ### FEDE FOR DBS OUTPUT PUBLICATION
935 <        if (self.datasetPath):
935 >        if (self.datasetPath):
936              txt += '\n'
937              txt += 'DatasetPath='+self.datasetPath+'\n'
938  
939              datasetpath_split = self.datasetPath.split("/")
940 <            
940 >
941              txt += 'PrimaryDataset='+datasetpath_split[1]+'\n'
942              txt += 'DataTier='+datasetpath_split[2]+'\n'
994            #txt += 'ProcessedDataset='+datasetpath_split[3]+'\n'
943              txt += 'ApplicationFamily=cmsRun\n'
944  
945          else:
946              txt += 'DatasetPath=MCDataTier\n'
947              txt += 'PrimaryDataset=null\n'
948              txt += 'DataTier=null\n'
1001            #txt += 'ProcessedDataset=null\n'
949              txt += 'ApplicationFamily=MCDataTier\n'
950          if self.pset != None: #CarlosDaniele
951              pset = os.path.basename(job.configFilename())
952              txt += '\n'
953              txt += 'cp  $RUNTIME_AREA/'+pset+' .\n'
954              if (self.datasetPath): # standard job
1008                #txt += 'InputFiles=$2\n'
955                  txt += 'InputFiles=${args[1]}\n'
956                  txt += 'MaxEvents=${args[2]}\n'
957                  txt += 'SkipEvents=${args[3]}\n'
958                  txt += 'echo "Inputfiles:<$InputFiles>"\n'
959 <                txt += 'sed "s#{\'INPUT\'}#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
959 >                txt += 'sed "s#\'INPUTFILE\'#$InputFiles#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
960                  txt += 'echo "MaxEvents:<$MaxEvents>"\n'
961 <                txt += 'sed "s#INPUTMAXEVENTS#$MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
961 >                txt += 'sed "s#int32 input = 0#int32 input = $MaxEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
962                  txt += 'echo "SkipEvents:<$SkipEvents>"\n'
963 <                txt += 'sed "s#INPUTSKIPEVENTS#$SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
963 >                txt += 'sed "s#uint32 skipEvents = 0#uint32 skipEvents = $SkipEvents#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
964              else:  # pythia like job
965                  seedIndex=1
966                  if (self.firstRun):
967                      txt += 'FirstRun=${args['+str(seedIndex)+']}\n'
968                      txt += 'echo "FirstRun: <$FirstRun>"\n'
969 <                    txt += 'sed "s#\<INPUTFIRSTRUN\>#$FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
969 >                    txt += 'sed "s#uint32 firstRun = 0#uint32 firstRun = $FirstRun#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
970                      seedIndex=seedIndex+1
971  
972                  if (self.sourceSeed):
973                      txt += 'Seed=${args['+str(seedIndex)+']}\n'
974 <                    txt += 'sed "s#\<INPUT\>#$Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
974 >                    txt += 'sed "s#uint32 sourceSeed = 0#uint32 sourceSeed = $Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
975                      seedIndex=seedIndex+1
976                      ## the following seeds are not always present
977                      if (self.sourceSeedVtx):
978                          txt += 'VtxSeed=${args['+str(seedIndex)+']}\n'
979                          txt += 'echo "VtxSeed: <$VtxSeed>"\n'
980 <                        txt += 'sed "s#\<INPUTVTX\>#$VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
980 >                        txt += 'sed "s#uint32 VtxSmeared = 0#uint32 VtxSmeared = $VtxSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
981                          seedIndex += 1
982                      if (self.sourceSeedG4):
983                          txt += 'G4Seed=${args['+str(seedIndex)+']}\n'
984                          txt += 'echo "G4Seed: <$G4Seed>"\n'
985 <                        txt += 'sed "s#\<INPUTG4\>#$G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
985 >                        txt += 'sed "s#uint32 g4SimHits = 0#uint32 g4SimHits = $G4Seed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
986                          seedIndex += 1
987                      if (self.sourceSeedMix):
988                          txt += 'mixSeed=${args['+str(seedIndex)+']}\n'
989                          txt += 'echo "MixSeed: <$mixSeed>"\n'
990 <                        txt += 'sed "s#\<INPUTMIX\>#$mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
990 >                        txt += 'sed "s#uint32 mix = 0#uint32 mix = $mixSeed#" '+pset+' > tmp && mv -f tmp '+pset+'\n'
991                          seedIndex += 1
992                      pass
993                  pass
# Line 1051 | Line 997 | class Cmssw(JobType):
997              txt += 'if [ -e $RUNTIME_AREA/'+self.additional_tgz_name+' ] ; then\n'
998              txt += '  tar xzvf $RUNTIME_AREA/'+self.additional_tgz_name+'\n'
999              txt += 'fi\n'
1000 <            pass
1000 >            pass
1001  
1002          if self.pset != None: #CarlosDaniele
1057            txt += 'echo "### END JOB SETUP ENVIRONMENT ###"\n\n'
1058        
1003              txt += '\n'
1004              txt += 'echo "***** cat pset.cfg *********"\n'
1005              txt += 'cat pset.cfg\n'
# Line 1064 | Line 1008 | class Cmssw(JobType):
1008              ### FEDE FOR DBS OUTPUT PUBLICATION
1009              txt += 'PSETHASH=`EdmConfigHash < pset.cfg` \n'
1010              txt += 'echo "PSETHASH = $PSETHASH" \n'
1011 <            ##############
1011 >            ##############
1012              txt += '\n'
1069            # txt += 'echo "***** cat pset1.cfg *********"\n'
1070            # txt += 'cat pset1.cfg\n'
1071            # txt += 'echo "****** end pset1.cfg ********"\n'
1013          return txt
1014  
1015      def wsBuildExe(self, nj=0):
# Line 1080 | Line 1021 | class Cmssw(JobType):
1021          txt = ""
1022  
1023          if os.path.isfile(self.tgzNameWithPath):
1024 <            txt += 'echo "tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'"\n'
1024 >            txt += 'echo ">>> tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+' :" \n'
1025              txt += 'tar xzvf $RUNTIME_AREA/'+os.path.basename(self.tgzNameWithPath)+'\n'
1026              txt += 'untar_status=$? \n'
1027              txt += 'if [ $untar_status -ne 0 ]; then \n'
# Line 1088 | Line 1029 | class Cmssw(JobType):
1029              txt += '   echo "JOB_EXIT_STATUS = $untar_status" \n'
1030              txt += '   echo "JobExitCode=$untar_status" | tee -a $RUNTIME_AREA/$repo\n'
1031              txt += '   if [ $middleware == OSG ]; then \n'
1091            txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1032              txt += '       cd $RUNTIME_AREA\n'
1033 +            txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1034 +            txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1035              txt += '       /bin/rm -rf $WORKING_DIR\n'
1036              txt += '       if [ -d $WORKING_DIR ] ;then\n'
1037              txt += '           echo "SET_EXE 50999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after Untarring .tgz file failed"\n'
1038              txt += '           echo "JOB_EXIT_STATUS = 50999"\n'
1039              txt += '           echo "JobExitCode=50999" | tee -a $RUNTIME_AREA/$repo\n'
1040              txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1099            txt += '           rm -f $RUNTIME_AREA/$repo \n'
1100            txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1101            txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1041              txt += '       fi\n'
1042              txt += '   fi \n'
1043              txt += '   \n'
# Line 1107 | Line 1046 | class Cmssw(JobType):
1046              txt += '   echo "Successful untar" \n'
1047              txt += 'fi \n'
1048              txt += '\n'
1049 <            txt += 'echo "Include ProdAgentApi and PRODCOMMON in PYTHONPATH"\n'
1049 >            txt += 'echo ">>> Include ProdAgentApi and PRODCOMMON in PYTHONPATH:"\n'
1050              txt += 'if [ -z "$PYTHONPATH" ]; then\n'
1051              #### FEDE FOR DBS OUTPUT PUBLICATION
1052              txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon\n'
1114            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon\n'
1115            #txt += '   export PYTHONPATH=ProdAgentApi\n'
1053              txt += 'else\n'
1054              txt += '   export PYTHONPATH=$SOFTWARE_DIR/ProdAgentApi:$SOFTWARE_DIR/ProdCommon:${PYTHONPATH}\n'
1118            #txt += '   export PYTHONPATH=`pwd`/ProdAgentApi:`pwd`/ProdCommon:${PYTHONPATH}\n'
1119            #txt += '   export PYTHONPATH=ProdAgentApi:${PYTHONPATH}\n'
1055              txt += 'echo "PYTHONPATH=$PYTHONPATH"\n'
1056 <            ###################  
1056 >            ###################
1057              txt += 'fi\n'
1058              txt += '\n'
1059  
1060              pass
1061 <        
1061 >
1062          return txt
1063  
1064      def modifySteeringCards(self, nj):
1065          """
1066 <        modify the card provided by the user,
1066 >        modify the card provided by the user,
1067          writing a new card into share dir
1068          """
1069 <        
1069 >
1070      def executableName(self):
1071          if self.scriptExe: #CarlosDaniele
1072              return "sh "
# Line 1142 | Line 1077 | class Cmssw(JobType):
1077          if self.scriptExe:#CarlosDaniele
1078              return   self.scriptExe + " $NJob"
1079          else:
1080 <            # if >= CMSSW_1_5_X, add -e
1080 >            # if >= CMSSW_1_5_X, add -j crab_fjr.xml
1081              version_array = self.scram.getSWVersion().split('_')
1082              major = 0
1083              minor = 0
# Line 1150 | Line 1085 | class Cmssw(JobType):
1085                  major = int(version_array[1])
1086                  minor = int(version_array[2])
1087              except:
1088 <                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"  
1088 >                msg = "Cannot parse CMSSW version string: " + "_".join(version_array) + " for major and minor release number!"
1089                  raise CrabException(msg)
1090              if major >= 1 and minor >= 5 :
1091 <                return " -e -p pset.cfg"
1091 >                return " -j " + self.fjrFileName + " -p pset.cfg"
1092              else:
1093                  return " -p pset.cfg"
1094  
# Line 1185 | Line 1120 | class Cmssw(JobType):
1120  
1121          ## User Declared output files
1122          for out in (self.output_file+self.output_file_sandbox):
1123 <            n_out = nj + 1
1123 >            n_out = nj + 1
1124              out_box.append(self.numberFile_(out,str(n_out)))
1125          return out_box
1126  
# Line 1201 | Line 1136 | class Cmssw(JobType):
1136          """
1137  
1138          txt = '\n'
1139 <        txt += '# directory content\n'
1139 >        txt += 'echo" >>> directory content:"\n'
1140          txt += 'ls \n'
1141 +        txt = '\n'
1142  
1143          txt += 'output_exit_status=0\n'
1144 <        
1144 >
1145          for fileWithSuffix in (self.output_file_sandbox):
1146              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1147              txt += '\n'
1148              txt += '# check output file\n'
1149              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1150 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1151 <            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1150 >            #txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1151 >            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1152 >            #txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1153 >            txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1154              txt += 'else\n'
1155              txt += '    exit_status=60302\n'
1156              txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
# Line 1222 | Line 1160 | class Cmssw(JobType):
1160                  txt += '        echo "Processing of job output failed" > $RUNTIME_AREA/'+output_file_num+'\n'
1161                  txt += '    fi \n'
1162              txt += 'fi\n'
1163 <        
1163 >
1164          for fileWithSuffix in (self.output_file):
1165              output_file_num = self.numberFile_(fileWithSuffix, '$NJob')
1166              txt += '\n'
1167              txt += '# check output file\n'
1168              txt += 'if [ -e ./'+fileWithSuffix+' ] ; then\n'
1169 <            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1170 <            txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1169 >            #txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA\n'
1170 >            txt += '    mv '+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1171 >            #txt += '    cp $RUNTIME_AREA/'+fileWithSuffix+' $RUNTIME_AREA/'+output_file_num+'\n'
1172 >            txt += '    ln -s $RUNTIME_AREA/'+output_file_num+' $RUNTIME_AREA/'+fileWithSuffix+'\n'
1173              txt += 'else\n'
1174              txt += '    exit_status=60302\n'
1175              txt += '    echo "ERROR: Problem with output file '+fileWithSuffix+'"\n'
# Line 1244 | Line 1184 | class Cmssw(JobType):
1184          file_list = []
1185          for fileWithSuffix in (self.output_file):
1186               file_list.append(self.numberFile_(fileWithSuffix, '$NJob'))
1187 <            
1187 >
1188          txt += 'file_list="'+string.join(file_list,' ')+'"\n'
1189          txt += 'cd $RUNTIME_AREA\n'
1190 +        txt += 'echo ">>> current directory (RUNTIME_AREA):  $RUNTIME_AREA"\n'
1191          return txt
1192  
1193      def numberFile_(self, file, txt):
# Line 1264 | Line 1205 | class Cmssw(JobType):
1205              result = name + '_' + txt + "." + ext
1206          else:
1207              result = name + '_' + txt
1208 <        
1208 >
1209          return result
1210  
1211      def getRequirements(self, nj=[]):
1212          """
1213 <        return job requirements to add to jdl files
1213 >        return job requirements to add to jdl files
1214          """
1215          req = ''
1216          if self.version:
# Line 1291 | Line 1232 | class Cmssw(JobType):
1232          """ return the config filename """
1233          return self.name()+'.cfg'
1234  
1294    ### OLI_DANIELE
1235      def wsSetupCMSOSGEnvironment_(self):
1236          """
1237          Returns part of a job script which is prepares
1238          the execution environment and which is common for all CMS jobs.
1239          """
1240 <        txt = '\n'
1241 <        txt += '   echo "### SETUP CMS OSG  ENVIRONMENT ###"\n'
1242 <        txt += '   if [ -f $GRID3_APP_DIR/cmssoft/cmsset_default.sh ] ;then\n'
1243 <        txt += '      # Use $GRID3_APP_DIR/cmssoft/cmsset_default.sh to setup cms software\n'
1244 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1305 <        txt += '       source $GRID3_APP_DIR/cmssoft/cmsset_default.sh '+self.version+'\n'
1306 <        txt += '   elif [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1240 >        txt = '    echo ">>> setup CMS OSG environment:"\n'
1241 >        txt += '    echo "set SCRAM ARCH to ' + self.executable_arch + '"\n'
1242 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1243 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1244 >        txt += '    if [ -f $OSG_APP/cmssoft/cms/cmsset_default.sh ] ;then\n'
1245          txt += '      # Use $OSG_APP/cmssoft/cms/cmsset_default.sh to setup cms software\n'
1246 <        txt += '       export SCRAM_ARCH='+self.executable_arch+'\n'
1247 <        txt += '       source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1248 <        txt += '   else\n'
1249 <        txt += '       echo "SET_CMS_ENV 10020 ==> ERROR $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1250 <        txt += '       echo "JOB_EXIT_STATUS = 10020"\n'
1251 <        txt += '       echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1314 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1315 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1316 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1317 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1318 <        txt += '       exit 1\n'
1246 >        txt += '        source $OSG_APP/cmssoft/cms/cmsset_default.sh '+self.version+'\n'
1247 >        txt += '    else\n'
1248 >        txt += '        echo "SET_CMS_ENV 10020 ==> ERROR $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1249 >        txt += '        echo "JOB_EXIT_STATUS = 10020"\n'
1250 >        txt += '        echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1251 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1252          txt += '\n'
1253 <        txt += '       echo "Remove working directory: $WORKING_DIR"\n'
1254 <        txt += '       cd $RUNTIME_AREA\n'
1255 <        txt += '       /bin/rm -rf $WORKING_DIR\n'
1256 <        txt += '       if [ -d $WORKING_DIR ] ;then\n'
1257 <        txt += '           echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $GRID3_APP_DIR/cmssoft/cmsset_default.sh and $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1258 <        txt += '           echo "JOB_EXIT_STATUS = 10017"\n'
1259 <        txt += '           echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1260 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1261 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1262 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1330 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1331 <        txt += '       fi\n'
1253 >        txt += '        cd $RUNTIME_AREA\n'
1254 >        txt += '        echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1255 >        txt += '        echo ">>> Remove working directory: $WORKING_DIR"\n'
1256 >        txt += '        /bin/rm -rf $WORKING_DIR\n'
1257 >        txt += '        if [ -d $WORKING_DIR ] ;then\n'
1258 >        txt += '            echo "SET_CMS_ENV 10017 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after $OSG_APP/cmssoft/cms/cmsset_default.sh file not found"\n'
1259 >        txt += '            echo "JOB_EXIT_STATUS = 10017"\n'
1260 >        txt += '            echo "JobExitCode=10017" | tee -a $RUNTIME_AREA/$repo\n'
1261 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1262 >        txt += '        fi\n'
1263          txt += '\n'
1264 <        txt += '       exit 1\n'
1265 <        txt += '   fi\n'
1264 >        txt += '        exit 1\n'
1265 >        txt += '    fi\n'
1266          txt += '\n'
1267 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1268 <        txt += '   echo " END SETUP CMS OSG  ENVIRONMENT "\n'
1267 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1268 >        txt += '    echo "SCRAM_ARCH = $SCRAM_ARCH"\n'
1269  
1270          return txt
1271 <
1271 >
1272      ### OLI_DANIELE
1273      def wsSetupCMSLCGEnvironment_(self):
1274          """
1275          Returns part of a job script which is prepares
1276          the execution environment and which is common for all CMS jobs.
1277          """
1278 <        txt  = '   \n'
1279 <        txt += '   echo " ### SETUP CMS LCG  ENVIRONMENT ### "\n'
1280 <        txt += '   if [ ! $VO_CMS_SW_DIR ] ;then\n'
1281 <        txt += '       echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1282 <        txt += '       echo "JOB_EXIT_STATUS = 10031" \n'
1283 <        txt += '       echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1284 <        txt += '       dumpStatus $RUNTIME_AREA/$repo\n'
1285 <        txt += '       rm -f $RUNTIME_AREA/$repo \n'
1286 <        txt += '       echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1287 <        txt += '       echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1288 <        txt += '       exit 1\n'
1289 <        txt += '   else\n'
1290 <        txt += '       echo "Sourcing environment... "\n'
1291 <        txt += '       if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1292 <        txt += '           echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1293 <        txt += '           echo "JOB_EXIT_STATUS = 10020"\n'
1294 <        txt += '           echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1295 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1296 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1297 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1298 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1299 <        txt += '           exit 1\n'
1300 <        txt += '       fi\n'
1301 <        txt += '       echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1302 <        txt += '       source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1303 <        txt += '       result=$?\n'
1304 <        txt += '       if [ $result -ne 0 ]; then\n'
1305 <        txt += '           echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1306 <        txt += '           echo "JOB_EXIT_STATUS = 10032"\n'
1307 <        txt += '           echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1308 <        txt += '           dumpStatus $RUNTIME_AREA/$repo\n'
1309 <        txt += '           rm -f $RUNTIME_AREA/$repo \n'
1379 <        txt += '           echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1380 <        txt += '           echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1381 <        txt += '           exit 1\n'
1382 <        txt += '       fi\n'
1383 <        txt += '   fi\n'
1384 <        txt += '   \n'
1385 <        txt += '   echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1386 <        txt += '   echo "### END SETUP CMS LCG ENVIRONMENT ###"\n'
1278 >        txt = '    echo ">>> setup CMS LCG environment:"\n'
1279 >        txt += '    echo "set SCRAM ARCH and BUILD_ARCH to ' + self.executable_arch + ' ###"\n'
1280 >        txt += '    export SCRAM_ARCH='+self.executable_arch+'\n'
1281 >        txt += '    export BUILD_ARCH='+self.executable_arch+'\n'
1282 >        txt += '    if [ ! $VO_CMS_SW_DIR ] ;then\n'
1283 >        txt += '        echo "SET_CMS_ENV 10031 ==> ERROR CMS software dir not found on WN `hostname`"\n'
1284 >        txt += '        echo "JOB_EXIT_STATUS = 10031" \n'
1285 >        txt += '        echo "JobExitCode=10031" | tee -a $RUNTIME_AREA/$repo\n'
1286 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1287 >        txt += '        exit 1\n'
1288 >        txt += '    else\n'
1289 >        txt += '        echo "Sourcing environment... "\n'
1290 >        txt += '        if [ ! -s $VO_CMS_SW_DIR/cmsset_default.sh ] ;then\n'
1291 >        txt += '            echo "SET_CMS_ENV 10020 ==> ERROR cmsset_default.sh file not found into dir $VO_CMS_SW_DIR"\n'
1292 >        txt += '            echo "JOB_EXIT_STATUS = 10020"\n'
1293 >        txt += '            echo "JobExitCode=10020" | tee -a $RUNTIME_AREA/$repo\n'
1294 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1295 >        txt += '            exit 1\n'
1296 >        txt += '        fi\n'
1297 >        txt += '        echo "sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1298 >        txt += '        source $VO_CMS_SW_DIR/cmsset_default.sh\n'
1299 >        txt += '        result=$?\n'
1300 >        txt += '        if [ $result -ne 0 ]; then\n'
1301 >        txt += '            echo "SET_CMS_ENV 10032 ==> ERROR problem sourcing $VO_CMS_SW_DIR/cmsset_default.sh"\n'
1302 >        txt += '            echo "JOB_EXIT_STATUS = 10032"\n'
1303 >        txt += '            echo "JobExitCode=10032" | tee -a $RUNTIME_AREA/$repo\n'
1304 >        txt += '            dumpStatus $RUNTIME_AREA/$repo\n'
1305 >        txt += '            exit 1\n'
1306 >        txt += '        fi\n'
1307 >        txt += '    fi\n'
1308 >        txt += '    \n'
1309 >        txt += '    echo "SET_CMS_ENV 0 ==> setup cms environment ok"\n'
1310          return txt
1311  
1312 <    ### FEDE FOR DBS OUTPUT PUBLICATION
1312 >    ### FEDE FOR DBS OUTPUT PUBLICATION
1313      def modifyReport(self, nj):
1314          """
1315 <        insert the part of the script that modifies the FrameworkJob Report
1315 >        insert the part of the script that modifies the FrameworkJob Report
1316          """
1317  
1318 <        txt = ''
1318 >        txt = ''
1319          try:
1320 <            publish_data = int(self.cfg_params['USER.publish_data'])          
1320 >            publish_data = int(self.cfg_params['USER.publish_data'])
1321          except KeyError:
1322              publish_data = 0
1323 <        if (publish_data == 1):  
1324 <            txt += 'echo "Modify Job Report" \n'
1402 <            #txt += 'chmod a+x $RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1323 >        if (publish_data == 1):
1324 >            txt += 'echo ">>> Modify Job Report:" \n'
1325              ################ FEDE FOR DBS2 #############################################
1326              txt += 'chmod a+x $SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py\n'
1327              #############################################################################
1406            #try:
1407            #    publish_data = int(self.cfg_params['USER.publish_data'])          
1408            #except KeyError:
1409            #    publish_data = 0
1328  
1329              txt += 'if [ -z "$SE" ]; then\n'
1330              txt += '    SE="" \n'
1331 <            txt += 'fi \n'
1331 >            txt += 'fi \n'
1332              txt += 'if [ -z "$SE_PATH" ]; then\n'
1333              txt += '    SE_PATH="" \n'
1334 <            txt += 'fi \n'
1335 <            txt += 'echo "SE = $SE"\n'
1334 >            txt += 'fi \n'
1335 >            txt += 'echo "SE = $SE"\n'
1336              txt += 'echo "SE_PATH = $SE_PATH"\n'
1337  
1420        #if (publish_data == 1):  
1421            #processedDataset = self.cfg_params['USER.processed_datasetname']
1338              processedDataset = self.cfg_params['USER.publish_data_name']
1339              txt += 'ProcessedDataset='+processedDataset+'\n'
1340              #### LFN=/store/user/<user>/processedDataset_PSETHASH
1341              txt += 'if [ "$SE_PATH" == "" ]; then\n'
1342              #### FEDE: added slash in LFN ##############
1343              txt += '    FOR_LFN=/copy_problems/ \n'
1344 <            txt += 'else \n'
1344 >            txt += 'else \n'
1345              txt += '    tmp=`echo $SE_PATH | awk -F \'store\' \'{print$2}\'` \n'
1346              #####  FEDE TO BE CHANGED, BECAUSE STORE IS HARDCODED!!!! ########
1347              txt += '    FOR_LFN=/store$tmp \n'
1348 <            txt += 'fi \n'
1348 >            txt += 'fi \n'
1349              txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1350              txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1351              txt += 'echo "CMSSW_VERSION = $CMSSW_VERSION"\n\n'
1352 <            #txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1353 <            txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1352 >            #txt += 'echo "$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1353 >            txt += 'echo "$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH"\n'
1354              txt += '$SOFTWARE_DIR/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1355              #txt += '$RUNTIME_AREA/'+self.version+'/ProdAgentApi/FwkJobRep/ModifyJobReport.py crab_fjr_$NJob.xml $NJob $FOR_LFN $PrimaryDataset $DataTier $ProcessedDataset $ApplicationFamily $executable $CMSSW_VERSION $PSETHASH $SE $SE_PATH\n'
1356 <      
1356 >
1357              txt += 'modifyReport_result=$?\n'
1358              txt += 'echo modifyReport_result = $modifyReport_result\n'
1359              txt += 'if [ $modifyReport_result -ne 0 ]; then\n'
# Line 1448 | Line 1364 | class Cmssw(JobType):
1364              txt += 'fi\n'
1365          else:
1366              txt += 'echo "no data publication required"\n'
1451            #txt += 'ProcessedDataset=no_data_to_publish \n'
1452            #### FEDE: added slash in LFN ##############
1453            #txt += 'FOR_LFN=/local/ \n'
1454            #txt += 'echo "ProcessedDataset = $ProcessedDataset"\n'
1455            #txt += 'echo "FOR_LFN = $FOR_LFN" \n'
1367          return txt
1368  
1369      def cleanEnv(self):
1370 <        ### OLI_DANIELE
1371 <        txt = ''
1461 <        txt += 'if [ $middleware == OSG ]; then\n'  
1370 >        txt = ''
1371 >        txt += 'if [ $middleware == OSG ]; then\n'
1372          txt += '    cd $RUNTIME_AREA\n'
1373 <        txt += '    echo "Remove working directory: $WORKING_DIR"\n'
1373 >        txt += '    echo ">>> current directory (RUNTIME_AREA): $RUNTIME_AREA"\n'
1374 >        txt += '    echo ">>> Remove working directory: $WORKING_DIR"\n'
1375          txt += '    /bin/rm -rf $WORKING_DIR\n'
1376          txt += '    if [ -d $WORKING_DIR ] ;then\n'
1377 <        txt += '              echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1378 <        txt += '              echo "JOB_EXIT_STATUS = 60999"\n'
1379 <        txt += '              echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1380 <        txt += '              dumpStatus $RUNTIME_AREA/$repo\n'
1470 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
1471 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
1472 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
1377 >        txt += '        echo "SET_EXE 60999 ==> OSG $WORKING_DIR could not be deleted on WN `hostname` after cleanup of WN"\n'
1378 >        txt += '        echo "JOB_EXIT_STATUS = 60999"\n'
1379 >        txt += '        echo "JobExitCode=60999" | tee -a $RUNTIME_AREA/$repo\n'
1380 >        txt += '        dumpStatus $RUNTIME_AREA/$repo\n'
1381          txt += '    fi\n'
1382          txt += 'fi\n'
1383          txt += '\n'
# Line 1483 | Line 1391 | class Cmssw(JobType):
1391  
1392      def setTaskid_(self):
1393          self._taskId = self.cfg_params['taskId']
1394 <        
1394 >
1395      def getTaskid(self):
1396          return self._taskId
1397  
# Line 1501 | Line 1409 | class Cmssw(JobType):
1409          """
1410          check the dimension of the output files
1411          """
1412 <        txt = 'echo "*****************************************"\n'
1505 <        txt += 'echo "** Starting output sandbox limit check **"\n'
1506 <        txt += 'echo "*****************************************"\n'
1412 >        txt = 'echo ">>> Starting output sandbox limit check :"\n'
1413          allOutFiles = ""
1414          listOutFiles = []
1415 +        txt += 'stdoutFile=`ls | grep *stdout` \n'
1416 +        txt += 'stderrFile=`ls | grep *stderr` \n'
1417          for fileOut in (self.output_file+self.output_file_sandbox):
1418               if fileOut.find('crab_fjr') == -1:
1419 <                 allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob')
1419 >                 allOutFiles = allOutFiles + " " + self.numberFile_(fileOut, '$NJob') + " $stdoutFile $stderrFile"
1420                   listOutFiles.append(self.numberFile_(fileOut, '$NJob'))
1421          txt += 'echo "OUTPUT files: '+str(allOutFiles)+'";\n'
1422          txt += 'ls -gGhrta;\n'
# Line 1527 | Line 1435 | class Cmssw(JobType):
1435          txt += 'if [ $limit -lt $sum ]; then\n'
1436          txt += '    echo "WARNING: output files have to big size - something will be lost;"\n'
1437          txt += '    echo "         checking the output file sizes..."\n'
1530        """
1531        txt += '    dim=0;\n'
1532        txt += '    exclude=0;\n'
1533        txt += '    for files in '+str(allOutFiles)+' ; do\n'
1534        txt += '        sumTemp=0;\n'
1535        txt += '        for file2 in '+str(allOutFiles)+' ; do\n'
1536        txt += '            if [ $file != $file2 ]; then\n'
1537        txt += '                tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1538        txt += '                sumTemp=`expr $sumTemp + $tt`;\n'
1539        txt += '            fi\n'
1540        txt += '        done\n'
1541        txt += '        if [ $sumTemp -lt $limit ]; then\n'
1542        txt += '            if [ $dim -lt $sumTemp ]; then\n'
1543        txt += '                dim=$sumTemp;\n'
1544        txt += '                exclude=$file;\n'
1545        txt += '            fi\n'
1546        txt += '        fi\n'
1547        txt += '    done\n'
1548        txt += '    echo "Dimension calculated: $dim"; echo "File to exclude: $exclude";\n'
1549        """
1438          txt += '    tot=0;\n'
1439 <        txt += '    for file2 in '+str(allOutFiles)+' ; do\n'
1440 <        txt += '        tt=`ls -gGrta $file2 | awk \'{ print $3 }\';`\n'
1439 >        txt += '    for filefile in '+str(allOutFiles)+' ; do\n'
1440 >        txt += '        dimFile=`ls -gGrta $filefile | awk \'{ print $3 }\';`\n'
1441          txt += '        tot=`expr $tot + $tt`;\n'
1442 <        txt += '        if [ $limit -lt $tot ]; then\n'
1443 <        txt += '            tot=`expr $tot - $tt`;\n'
1444 <        txt += '            fileLast=$file;\n'
1445 <        txt += '            break;\n'
1446 <        txt += '        fi\n'
1447 <        txt += '    done\n'
1448 <        txt += '    echo "Dimension calculated: $tot"; echo "First file to exclude: $file";\n'
1449 <        txt += '    flag=0;\n'    
1562 <        txt += '    for filess in '+str(allOutFiles)+' ; do\n'
1563 <        txt += '        if [ $fileLast = $filess ]; then\n'
1564 <        txt += '            flag=1;\n'
1565 <        txt += '        fi\n'
1566 <        txt += '        if [ $flag -eq 1 ]; then\n'
1567 <        txt += '            rm -f $filess;\n'
1442 >        txt += '        if [ $limit -lt $dimFile ]; then\n'
1443 >        txt += '            echo "deleting file: $filefile";\n'
1444 >        txt += '            rm -f $filefile\n'
1445 >        txt += '        elif [ $limit -lt $tot ]; then\n'
1446 >        txt += '            echo "deleting file: $filefile";\n'
1447 >        txt += '            rm -f $filefile\n'
1448 >        txt += '        else\n'
1449 >        txt += '            echo "saving file: $filefile"\n'
1450          txt += '        fi\n'
1451          txt += '    done\n'
1452 +
1453          txt += '    ls -agGhrt;\n'
1454          txt += '    echo "WARNING: output files are too big in dimension: can not put in the output_sandbox.";\n'
1455          txt += '    echo "JOB_EXIT_STATUS = 70000";\n'
# Line 1574 | Line 1457 | class Cmssw(JobType):
1457          txt += 'else'
1458          txt += '    echo "Total Output dimension $sum is fine.";\n'
1459          txt += 'fi\n'
1460 <        txt += 'echo "*****************************************"\n'
1578 <        txt += 'echo "*** Ending output sandbox limit check ***"\n'
1579 <        txt += 'echo "*****************************************"\n'
1460 >        txt += 'echo "Ending output sandbox limit check"\n'
1461          return txt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines