Changeset 2fb99de in flex_extract.git for python/prepare_flexpart.py


Ignore:
Timestamp:
Sep 20, 2018, 11:56:37 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
5d42acd
Parents:
3232589
Message:

introduced config with path definitions and changed py files accordingly; Installation works; some tests were added for tarball making; Problems in submission to ecgate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/prepare_flexpart.py

    r54a8a01 r2fb99de  
    5757import sys
    5858import socket
    59 import _config
    6059
    6160# software specific classes and modules from flex_extract
     61import _config
    6262from UioFiles import UioFiles
    6363from tools import clean_up, get_cmdline_arguments, read_ecenv
     
    7070except ImportError:
    7171    ecapi = False
    72 
    73 # add path to pythonpath so that python finds its buddies
    74 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath(
    75     inspect.getfile(inspect.currentframe())))
    76 if LOCAL_PYTHON_PATH not in sys.path:
    77     sys.path.append(LOCAL_PYTHON_PATH)
    78 
    7972
    8073# ------------------------------------------------------------------------------
     
    10093        c = ControlFile(args.controlfile)
    10194    except IOError:
    102         try:
    103             c = ControlFile(LOCAL_PYTHON_PATH + args.controlfile)
    104         except IOError:
    105             print 'Could not read CONTROL file "' + args.controlfile + '"'
    106             print 'Either it does not exist or its syntax is wrong.'
    107             print 'Try "' + sys.argv[0].split('/')[-1] + \
    108                   ' -h" to print usage information'
    109             sys.exit(1)
     95        print('Could not read CONTROL file "' + args.controlfile + '"')
     96        print('Either it does not exist or its syntax is wrong.')
     97        print('Try "' + sys.argv[0].split('/')[-1] + \
     98              ' -h" to print usage information')
     99        sys.exit(1)
    110100
    111     env_parameter = read_ecenv(c.ecmwfdatadir + 'python/ECMWF_ENV')
     101    env_parameter = read_ecenv(_config.PATH_ECMWF_ENV)
    112102    c.assign_args_to_control(args, env_parameter)
    113103    c.assign_envs_to_control(env_parameter)
    114     c.check_conditions()
     104    c.check_conditions(args.queue)
    115105    prepare_flexpart(args.ppid, c)
    116106
     
    170160        start = start - datetime.timedelta(days=1)
    171161
    172     print 'Prepare ' + start.strftime("%Y%m%d") + \
    173            "/to/" + end.strftime("%Y%m%d")
     162    print('Prepare ' + start.strftime("%Y%m%d") +
     163           "/to/" + end.strftime("%Y%m%d"))
    174164
    175165    # create output dir if necessary
     
    182172    # deaccumulate the flux data
    183173    flexpart = EcFlexpart(c, fluxes=True)
    184     flexpart.write_namelist(c, 'fort.4')
     174    flexpart.write_namelist(c, _config.FILE_NAMELIST)
    185175    flexpart.deacc_fluxes(inputfiles, c)
    186176
     
    197187    # otherwise delete temporary files
    198188    if int(c.debug) != 0:
    199         print '\nTemporary files left intact'
     189        print('\nTemporary files left intact')
    200190    else:
    201191        clean_up(c)
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG