Define application-specific environment variables

You can use application profiles to pass application-specific tuning and runtime parameters to the application by defining application-specific environment variables. Once an environment variable is set, it applies for each job that uses the same application profile. This provides a simple way of extending application profiles to include additional information.

Environment variables can also be used with MPI to pass application-specific tuning or runtime parameters to MPI jobs. For example, when using a specific MPI version and trying to get the best performance for Abaqus, you need to turn on specific flags and settings which must be in both the mpirun command line and in the Abaqus launcher. Both mpirun and Abaqus allow you to define switches and options within an environment variable, so you can set both of these in the application profile and they are used automatically.

To set your own environment variables for each application, use the ENV_VARS parameter in lsb.applications. The value for ENV_VARS also applies to the job’s pre-execution and post-execution environment. For example, a license key can be accessed by passing the license key location to the job.

To use ENV_VARS in an application profile:

  1. Configure the ENV_VARS parameter in lsb.applications.

  2. Run badmin reconfig to have the changes take effect.

  3. Optional: Run bapp –l to verify that the application is created and the variables are set:

    bapp -l myapp
    -- Test abc, solution 123
       NJOBS     PEND      RUN    SSUSP    USUSP      RSV
           0        0        0        0        0        0
    ENV_VARS: "TEST_FRUIT='apple',TEST_CAR='civic'"
  4. Submit your job to the application.

    admin@hostA: bsub -I -app myapp 'echo $TEST_FRUIT'
    Job <316> is submitted to default queue <interactive>
    <<Waiting for dispatch...>>
    <<Starting on hostA>>

When changing the value for ENV_VARS, note the following:

  • Once the job is running, you cannot change the defined values for any of the variables. However, you can still change them while the job is in PEND state.

  • If you change the value for ENV_VARS before a checkpointed job resumes but after the initial job has run, then the job will use the new value for ENV_VARS.

  • If you change the value for ENV_VARS then requeue a running job, the job will use the new value for ENV_VARS during the next run.

  • Any variable set in the user’s environment will overwrite the value in ENV_VARS. The application profile value will overwrite the execution host environment value.

  • If the same environment variable is named multiple times in ENV_VARS and given different values, the last value in the list will be the one which takes effect.

  • Do not redefine existing LSF environment variables in ENV_VARS.