Changeset efdb01a in flex_extract.git for python/install.py
- Timestamp:
- May 9, 2018, 12:15:00 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 991df6a
- Parents:
- 02c8c50
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/install.py
- Property mode changed from 100644 to 100755
r02c8c50 refdb01a 64 64 localpythonpath=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 65 65 sys.path.append(localpythonpath) 66 from UIO Tools import UIOFiles66 from UIOFiles import UIOFiles 67 67 from string import strip 68 68 from argparse import ArgumentParser,ArgumentDefaultsHelpFormatter 69 69 from GribTools import GribTools 70 from FlexpartTools import ECFlexpart, Control, install_args_and_control70 from Control import Control 71 71 from getMARSdata import getMARSdata 72 72 from prepareFLEXPART import prepareFLEXPART 73 from ECFlexpart import ECFlexpart 73 74 74 75 # ------------------------------------------------------------------------------ 75 76 # FUNCTIONS 76 77 # ------------------------------------------------------------------------------ 78 def install_args_and_control(): 79 ''' 80 @Description: 81 Assigns the command line arguments for installation and reads 82 control file content. Apply default values for non mentioned arguments. 83 84 @Input: 85 <nothing> 86 87 @Return: 88 args: instance of ArgumentParser 89 Contains the commandline arguments from script/program call. 90 91 c: instance of class Control 92 Contains all necessary information of a control file. The parameters 93 are: DAY1, DAY2, DTIME, MAXSTEP, TYPE, TIME, STEP, CLASS, STREAM, 94 NUMBER, EXPVER, GRID, LEFT, LOWER, UPPER, RIGHT, LEVEL, LEVELIST, 95 RESOL, GAUSS, ACCURACY, OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, 96 SMOOTH, FORMAT, ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, 97 ECFSDIR, MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR 98 For more information about format and content of the parameter see 99 documentation. 100 ''' 101 parser = ArgumentParser(description='Install ECMWFDATA software locally or \ 102 on ECMWF machines', 103 formatter_class=ArgumentDefaultsHelpFormatter) 104 105 parser.add_argument('--target', dest='install_target', 106 help="Valid targets: local | ecgate | cca , \ 107 the latter two are at ECMWF") 108 parser.add_argument("--makefile", dest="makefile", 109 help='Name of Makefile to use for compiling CONVERT2') 110 parser.add_argument("--ecuid", dest="ecuid", 111 help='user id at ECMWF') 112 parser.add_argument("--ecgid", dest="ecgid", 113 help='group id at ECMWF') 114 parser.add_argument("--gateway", dest="gateway", 115 help='name of local gateway server') 116 parser.add_argument("--destination", dest="destination", 117 help='ecaccess destination, e.g. leo@genericSftp') 118 119 parser.add_argument("--flexpart_root_scripts", dest="flexpart_root_scripts", 120 help="FLEXPART root directory on ECMWF servers \ 121 (to find grib2flexpart and COMMAND file)\n\ 122 Normally ECMWFDATA resides in the scripts directory \ 123 of the FLEXPART distribution, thus the:") 124 125 # arguments for job submission to ECMWF, only needed by submit.py 126 parser.add_argument("--job_template", dest='job_template', 127 default="job.temp.o", 128 help="job template file for submission to ECMWF") 129 130 parser.add_argument("--controlfile", dest="controlfile", 131 default='CONTROL.temp', 132 help="file with control parameters") 133 134 args = parser.parse_args() 135 136 try: 137 c = Control(args.controlfile) 138 except: 139 print('Could not read control file "' + args.controlfile + '"') 140 print('Either it does not exist or its syntax is wrong.') 141 print('Try "' + sys.argv[0].split('/')[-1] + 142 ' -h" to print usage information') 143 exit(1) 144 145 if args.install_target != 'local': 146 if (args.ecgid is None or args.ecuid is None or args.gateway is None 147 or args.destination is None): 148 print('Please enter your ECMWF user id and group id as well as \ 149 the \nname of the local gateway and the ectrans \ 150 destination ') 151 print('with command line options --ecuid --ecgid \ 152 --gateway --destination') 153 print('Try "' + sys.argv[0].split('/')[-1] + 154 ' -h" to print usage information') 155 print('Please consult ecaccess documentation or ECMWF user support \ 156 for further details') 157 sys.exit(1) 158 else: 159 c.ecuid = args.ecuid 160 c.ecgid = args.ecgid 161 c.gateway = args.gateway 162 c.destination = args.destination 163 164 try: 165 c.makefile = args.makefile 166 except: 167 pass 168 169 if args.install_target == 'local': 170 if args.flexpart_root_scripts is None: 171 c.flexpart_root_scripts = '../' 172 else: 173 c.flexpart_root_scripts = args.flexpart_root_scripts 174 175 if args.install_target != 'local': 176 if args.flexpart_root_scripts is None: 177 c.ec_flexpart_root_scripts = '${HOME}' 178 else: 179 c.ec_flexpart_root_scripts = args.flexpart_root_scripts 180 181 return args, c 182 183 77 184 def main(): 78 185 ''' … … 139 246 c.ecuid + 'flex_ecmwf.$Jobname.$Job_ID.out' 140 247 if 'export PATH=${PATH}:' in data: 141 data += c.ec_flexpart_root_scripts + '/ECMWFDATA7. 0/python'248 data += c.ec_flexpart_root_scripts + '/ECMWFDATA7.1/python' 142 249 if 'cat>>' in data or 'cat >>' in data: 143 250 i = data.index('>') … … 171 278 os.chdir('/') 172 279 p = subprocess.check_call(['tar', '-cvf', 173 ecd + '../ECMWFDATA7. 0.tar',280 ecd + '../ECMWFDATA7.1.tar', 174 281 ecd + 'python', 175 282 ecd + 'grib_templates', 176 283 ecd + 'src']) 177 284 try: 178 os.makedirs(c.flexpart_root_scripts + '/ECMWFDATA7. 0')285 os.makedirs(c.flexpart_root_scripts + '/ECMWFDATA7.1') 179 286 except: 180 287 pass 181 os.chdir(c.flexpart_root_scripts + '/ECMWFDATA7. 0')288 os.chdir(c.flexpart_root_scripts + '/ECMWFDATA7.1') 182 289 p = subprocess.check_call(['tar', '-xvf', 183 ecd + '../ECMWFDATA7. 0.tar'])184 os.chdir(c.flexpart_root_scripts + '/ECMWFDATA7. 0/src')290 ecd + '../ECMWFDATA7.1.tar']) 291 os.chdir(c.flexpart_root_scripts + '/ECMWFDATA7.1/src') 185 292 186 293 os.chdir('../src') 187 print(('install ECMWFDATA7. 0software on ' + target + ' in directory '294 print(('install ECMWFDATA7.1 software on ' + target + ' in directory ' 188 295 + os.getcwd())) 189 296 if c.makefile is None: … … 197 304 print(('Using makefile: ' + makefile)) 198 305 p = subprocess.check_call(['make', '-f', makefile]) 199 p = subprocess.check_call(['ls', '-l',' 306 p = subprocess.check_call(['ls', '-l','CONVERT2']) 200 307 except: 201 308 print('compile failed - please edit ' + makefile + 202 309 ' or try another Makefile in the src directory.') 203 print('most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB \204 and EMOSLIB must be adapted.')310 print('most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB ' 311 'and EMOSLIB must be adapted.') 205 312 print('Available Makefiles:') 206 313 print(glob.glob('Makefile*')) … … 209 316 os.chdir('/') 210 317 p = subprocess.check_call(['tar', '-cvf', 211 ecd + '../ECMWFDATA7. 0.tar',318 ecd + '../ECMWFDATA7.1.tar', 212 319 ecd + 'python', 213 320 ecd + 'grib_templates', … … 215 322 try: 216 323 p = subprocess.check_call(['ecaccess-file-put', 217 ecd + '../ECMWFDATA7. 0.tar',218 'ecgate:/ scratch/ms/' + c.ecgid + '/' +219 c.ecuid + '/ECMWFDATA7. 0.tar'])324 ecd + '../ECMWFDATA7.1.tar', 325 'ecgate:/home/ms/' + c.ecgid + '/' + 326 c.ecuid + '/ECMWFDATA7.1.tar']) 220 327 except: 221 328 print('ecaccess-file-put failed! Probably the eccert key has expired.') … … 225 332 target, 226 333 ecd + 'python/compilejob.ksh']) 227 print('compilejob.ksh has been submitted to ecgate for \228 installation in ' + c.ec_flexpart_root_scripts +229 '/ECMWFDATA7. 0')230 print('You should get an email with subject flexcompile within \231 the next few minutes')334 print('compilejob.ksh has been submitted to ecgate for ' 335 'installation in ' + c.ec_flexpart_root_scripts + 336 '/ECMWFDATA7.1') 337 print('You should get an email with subject flexcompile within ' 338 'the next few minutes') 232 339 233 340 elif target.lower() == 'cca': 234 341 os.chdir('/') 235 342 p = subprocess.check_call(['tar', '-cvf', 236 ecd + '../ECMWFDATA7. 0.tar',343 ecd + '../ECMWFDATA7.1.tar', 237 344 ecd + 'python', 238 345 ecd + 'grib_templates', … … 240 347 try: 241 348 p = subprocess.check_call(['ecaccess-file-put', 242 ecd + '../ECMWFDATA7. 0.tar',243 'cca:/ scratch/ms/' + c.ecgid + '/' +244 c.ecuid + '/ECMWFDATA7. 0.tar'])349 ecd + '../ECMWFDATA7.1.tar', 350 'cca:/home/ms/' + c.ecgid + '/' + 351 c.ecuid + '/ECMWFDATA7.1.tar']) 245 352 except: 246 print('ecaccess-file-put failed! \247 Probably the eccert key has expired.')353 print('ecaccess-file-put failed! ' 354 'Probably the eccert key has expired.') 248 355 exit(1) 249 356 … … 251 358 '-queueName', 252 359 target, 253 ecd + 'python/compilejob.ksh']) )360 ecd + 'python/compilejob.ksh']) 254 361 print('compilejob.ksh has been submitted to cca for installation in ' + 255 c.ec_flexpart_root_scripts + '/ECMWFDATA7. 0')256 print('You should get an email with subject flexcompile \257 within the next few minutes')362 c.ec_flexpart_root_scripts + '/ECMWFDATA7.1') 363 print('You should get an email with subject flexcompile ' 364 'within the next few minutes') 258 365 259 366 else:
Note: See TracChangeset
for help on using the changeset viewer.