Changeset 991df6a in flex_extract.git for python/install.py
- Timestamp:
- May 14, 2018, 10:11:29 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 812283d
- Parents:
- efdb01a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/install.py
refdb01a r991df6a 3 3 #************************************************************************ 4 4 # TODO AP 5 #AP6 # - Functionality Provided is not correct for this file7 5 # - localpythonpath should not be set in module load section! 8 6 # - create a class Installation and divide installation in 3 subdefs for … … 10 8 # - Change History ist nicht angepasst ans File! Original geben lassen 11 9 #************************************************************************ 12 """ 13 @Author: Anne Fouilloux (University of Oslo) 14 15 @Date: October 2014 16 17 @ChangeHistory: 18 November 2015 - Leopold Haimberger (University of Vienna): 19 - using the WebAPI also for general MARS retrievals 20 - job submission on ecgate and cca 21 - job templates suitable for twice daily operational dissemination 22 - dividing retrievals of longer periods into digestable chunks 23 - retrieve also longer term forecasts, not only analyses and 24 short term forecast data 25 - conversion into GRIB2 26 - conversion into .fp format for faster execution of FLEXPART 27 28 February 2018 - Anne Philipp (University of Vienna): 29 - applied PEP8 style guide 30 - added documentation 31 32 @License: 33 (C) Copyright 2014 UIO. 34 35 This software is licensed under the terms of the Apache Licence Version 2.0 36 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 37 38 @Requirements: 39 - A standard python 2.6 or 2.7 installation 40 - dateutils 41 - matplotlib (optional, for debugging) 42 - ECMWF specific packages, all available from https://software.ecmwf.int/ 43 ECMWF WebMARS, gribAPI with python enabled, emoslib and 44 ecaccess web toolkit 45 46 @Description: 47 Further documentation may be obtained from www.flexpart.eu. 48 49 Functionality provided: 50 Prepare input 3D-wind fields in hybrid coordinates + 51 surface fields for FLEXPART runs 52 """ 10 #******************************************************************************* 11 # @Author: Leopold Haimberger (University of Vienna) 12 # 13 # @Date: November 2015 14 # 15 # @Change History: 16 # 17 # February 2018 - Anne Philipp (University of Vienna): 18 # - applied PEP8 style guide 19 # - added documentation 20 # 21 # @License: 22 # (C) Copyright 2015-2018. 23 # 24 # This software is licensed under the terms of the Apache Licence Version 2.0 25 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 26 # 27 # @Program Functionality: 28 # Depending on the selected installation environment (locally or on the 29 # ECMWF server ecgate or cca) the program extracts the commandline 30 # arguments and the CONTROL file parameter and prepares the corresponding 31 # environment. The necessary files are collected in a tar-ball and placed 32 # at the target location. There its untared, the environment variables will 33 # be set and the Fortran code will be compiled. If the ECMWF environment is 34 # selected a job script is prepared and submitted for the remaining 35 # configurations after putting the tar-ball to the target ECMWF server. 36 # 37 # @Program Content: 38 # - main 39 # - install_args_and_control 40 # - install_via_gateway 41 # 42 #******************************************************************************* 43 53 44 # ------------------------------------------------------------------------------ 54 45 # MODULES 55 46 # ------------------------------------------------------------------------------ 56 import calendar57 import shutil58 47 import datetime 59 import time 60 import os,sys,glob 48 import os 49 import sys 50 import glob 61 51 import subprocess 62 52 import inspect 63 # add path to submit.py to pythonpath so that python finds its buddies64 localpythonpath=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))65 sys.path.append(localpythonpath)66 from UIOFiles import UIOFiles67 from string import strip68 53 from argparse import ArgumentParser,ArgumentDefaultsHelpFormatter 69 from GribTools import GribTools 70 from Control import Control 71 from getMARSdata import getMARSdata 72 from prepareFLEXPART import prepareFLEXPART 73 from ECFlexpart import ECFlexpart 54 55 # add path to pythonpath so that python finds its buddies 56 localpythonpath = os.path.dirname(os.path.abspath( 57 inspect.getfile(inspect.currentframe()))) 58 if localpythonpath not in sys.path: 59 sys.path.append(localpythonpath) 60 61 # software specific classes and modules from flex_extract 62 from ControlFile import ControlFile 74 63 75 64 # ------------------------------------------------------------------------------ 76 65 # FUNCTIONS 77 66 # ------------------------------------------------------------------------------ 67 def main(): 68 ''' 69 @Description: 70 Controls the installation process. Calls the installation function 71 if target is specified. 72 73 @Intput: 74 <nothing> 75 76 @Return: 77 <nothing> 78 ''' 79 80 os.chdir(localpythonpath) 81 args, c = install_args_and_control() 82 83 if args.install_target is not None: 84 install_via_gateway(c, args.install_target) 85 else: 86 print('Please specify installation target (local|ecgate|cca)') 87 print('use -h or --help for help') 88 89 sys.exit() 90 91 return 92 93 78 94 def install_args_and_control(): 79 95 ''' 80 96 @Description: 81 97 Assigns the command line arguments for installation and reads 82 controlfile content. Apply default values for non mentioned arguments.98 CONTROL file content. Apply default values for non mentioned arguments. 83 99 84 100 @Input: … … 89 105 Contains the commandline arguments from script/program call. 90 106 91 c: instance of class Control 92 Contains all necessary information of a controlfile. The parameters107 c: instance of class ControlFile 108 Contains all necessary information of a CONTROL file. The parameters 93 109 are: DAY1, DAY2, DTIME, MAXSTEP, TYPE, TIME, STEP, CLASS, STREAM, 94 110 NUMBER, EXPVER, GRID, LEFT, LOWER, UPPER, RIGHT, LEVEL, LEVELIST, … … 130 146 parser.add_argument("--controlfile", dest="controlfile", 131 147 default='CONTROL.temp', 132 help="file with controlparameters")148 help="file with CONTROL parameters") 133 149 134 150 args = parser.parse_args() 135 151 136 152 try: 137 c = Control (args.controlfile)153 c = ControlFile(args.controlfile) 138 154 except: 139 print('Could not read controlfile "' + args.controlfile + '"')155 print('Could not read CONTROL file "' + args.controlfile + '"') 140 156 print('Either it does not exist or its syntax is wrong.') 141 157 print('Try "' + sys.argv[0].split('/')[-1] + … … 182 198 183 199 184 def main():185 '''186 '''187 os.chdir(localpythonpath)188 args, c = install_args_and_control()189 if args.install_target is not None:190 install_via_gateway(c, args.install_target)191 else:192 print('Please specify installation target (local|ecgate|cca)')193 print('use -h or --help for help')194 sys.exit()195 196 200 def install_via_gateway(c, target): 197 201 ''' 202 @Description: 203 Perform the actual installation on local machine or prepare data 204 transfer to remote gate and submit a job script which will 205 install everything on the remote gate. 206 207 @Input: 208 c: instance of class ControlFile 209 Contains all necessary information of a CONTROL file. The parameters 210 are: DAY1, DAY2, DTIME, MAXSTEP, TYPE, TIME, STEP, CLASS, STREAM, 211 NUMBER, EXPVER, GRID, LEFT, LOWER, UPPER, RIGHT, LEVEL, LEVELIST, 212 RESOL, GAUSS, ACCURACY, OMEGA, OMEGADIFF, ETA, ETADIFF, DPDETA, 213 SMOOTH, FORMAT, ADDPAR, WRF, CWC, PREFIX, ECSTORAGE, ECTRANS, 214 ECFSDIR, MAILOPS, MAILFAIL, GRIB2FLEXPART, FLEXPARTDIR 215 For more information about format and content of the parameter see 216 documentation. 217 218 target: string 219 The target where the installation should be processed. 220 E.g. "local", "ecgate" or "cca" 221 222 @Return: 223 <nothing> 224 ''' 198 225 ecd = c.ecmwfdatadir 199 226 template = ecd + 'python/compilejob.temp'
Note: See TracChangeset
for help on using the changeset viewer.