Changeset 25b14be in flex_extract.git for source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/submit.py
- Timestamp:
- Sep 23, 2018, 11:40:28 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 4971f63
- Parents:
- 5d42acd
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/submit.py
r2fb99de r25b14be 16 16 # - added documentation 17 17 # - minor changes in programming style (for consistence) 18 # - changed path names to variables from config file 19 # - added option for writing mars requests to extra file 20 # additionally,as option without submitting the mars jobs 18 21 # 19 22 # @License: … … 48 51 # software specific classes and modules from flex_extract 49 52 import _config 50 from tools import normal_exit, get_cmdline_arguments, submit_job_to_ecserver, \51 read_ecenv52 from get_mars_data import get_mars_data53 from prepare_flexpart import prepare_flexpart54 from ControlFile import ControlFile53 from mods.tools import (normal_exit, get_cmdline_arguments, 54 submit_job_to_ecserver, read_ecenv) 55 from mods.get_mars_data import get_mars_data 56 from mods.prepare_flexpart import prepare_flexpart 57 from classes.ControlFile import ControlFile 55 58 56 59 # ------------------------------------------------------------------------------ … … 73 76 ''' 74 77 75 called_from_dir = os.getcwd()76 77 78 args = get_cmdline_arguments() 78 79 … … 80 81 c = ControlFile(args.controlfile) 81 82 except IOError: 82 try: 83 c = ControlFile(_config.PATH_LOCAL_PYTHON + args.controlfile) 84 except IOError: 85 print 'Could not read CONTROL file "' + args.controlfile + '"' 86 print 'Either it does not exist or its syntax is wrong.' 87 print 'Try "' + sys.argv[0].split('/')[-1] + \ 88 ' -h" to print usage information' 89 sys.exit(1) 90 91 env_parameter = read_ecenv(c.ecmwfdatadir + 'python/ECMWF_ENV') 83 print('Could not read CONTROL file "' + args.controlfile + '"') 84 print('Either it does not exist or its syntax is wrong.') 85 print('Try "' + sys.argv[0].split('/')[-1] + \ 86 ' -h" to print usage information') 87 sys.exit(1) 88 89 env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) 92 90 c.assign_args_to_control(args) 93 91 c.assign_envs_to_control(env_parameter) 94 c.check_conditions( )92 c.check_conditions(args.queue) 95 93 96 94 # on local side 97 95 # on ECMWF server this would also be the local side 96 called_from_dir = os.getcwd() 98 97 if args.queue is None: 99 98 if c.inputdir[0] != '/': … … 107 106 else: 108 107 normal_exit(c.mailfail, 'PRINTING MARS_REQUESTS DONE!') 109 # on ECMWF server108 # send files to ECMWF server and install there 110 109 else: 111 110 submit(args.job_template, c, args.queue) … … 120 119 @Input: 121 120 jtemplate: string 122 Job template file for submission to ECMWF. It contains all necessary 121 Job template file from sub-directory "_templates" for 122 submission to ECMWF. It contains all necessary 123 123 module and variable settings for the ECMWF environment as well as 124 124 the job call and mail report instructions. … … 146 146 147 147 # read template file and get index for CONTROL input 148 with open( jtemplate) as f:148 with open(os.path.join(_config.PATH_TEMPLATES, jtemplate)) as f: 149 149 lftext = f.read().split('\n') 150 150 insert_point = lftext.index('EOF') … … 153 153 # --------- create on demand job script ------------------------------------ 154 154 if c.maxstep > 24: 155 print '---- Pure forecast mode! ----'155 print('---- Pure forecast mode! ----') 156 156 else: 157 print '---- On-demand mode! ----' 158 job_file = jtemplate[:-4] + 'ksh' 157 print('---- On-demand mode! ----') 158 job_file = os.path.join(_config.PATH_JOBSCRIPTS, 159 jtemplate[:-4] + 'ksh') 159 160 clist = c.to_list() 160 161 … … 164 165 f.write('\n'.join(lftextondemand)) 165 166 166 result_code =submit_job_to_ecserver(queue, job_file)167 submit_job_to_ecserver(queue, job_file) 167 168 168 169 else: 169 170 # --------- create operational job script ---------------------------------- 170 print '---- Operational mode! ----'171 job_file = jtemplate[:-5] + 'oper.ksh'172 #colist = []171 print('---- Operational mode! ----') 172 job_file = os.path.join(_config.PATH_JOBSCRIPTS, 173 jtemplate[:-5] + 'oper.ksh') 173 174 174 175 if c.maxstep: … … 190 191 f.write('\n'.join(lftextoper)) 191 192 192 result_code =submit_job_to_ecserver(queue, job_file)193 submit_job_to_ecserver(queue, job_file) 193 194 194 195 # -------------------------------------------------------------------------- 195 print 'You should get an email with subject flex.hostname.pid'196 print('You should get an email with subject flex.hostname.pid') 196 197 197 198 return
Note: See TracChangeset
for help on using the changeset viewer.