#%Module

# NOTE: This is an automatically-generated file!  (generated by the
# Open MPI RPM).  Any changes made here will be lost a) if the RPM is
# uninstalled, or b) if the RPM is upgraded or uninstalled.

proc ModulesHelp { } {
   puts stderr "This module adds Open MPI pgi-8.0 1.3.0 to various paths"
}

module-whatis   "Sets up Open MPI pgi-8.0 1.3.0 in your environment"

# We check to see if any incompatible intel compilers are loaded
if {[module-info mode load] && ![module-info mode remove]} {
  if {[info exists env(LOADEDMODULES)]} {
    set envloaded [split $env(LOADEDMODULES) ":"]
    foreach mod [lsort -decreasing $envloaded] {
      set mmod "$mod/"
      # if an mpich module and it is different from us - then it conflicts, easy
      if {[string first "openmpi/" $mmod] == 0 && [string first "openmpi/pgi-8.0/1.3.0/64" $mmod] != 0 } {
        puts stderr "Conflicting module $mod - removing before inserting requested module openmpi/pgi-8.0/1.3.0/64"
        module unload $mod
      }
    }
    foreach conflicts [ split "mpich/ mpich2/ lam/ intel/" " " ] {
      set envloaded [split $env(LOADEDMODULES) ":"]
      foreach mod [lsort -decreasing $envloaded] {
        set mmod "$mod/"
        if {[string first $conflicts $mmod] == 0} {
          puts stderr "Conflicting module $mmod - removing before inserting requested module openmpi/pgi-8.0/1.3.0/64"
          module unload $mod
          }
      }
    }
  }
}


module load pgi/8/64
prepend-path PATH "/usr/local/openmpi/1.3.0/pgi80/x86_64/bin"
prepend-path LD_LIBRARY_PATH "/usr/local/openmpi/1.3.0/pgi80/x86_64/lib64:/usr/local/pgi/lib64/openmpi-pgi"
prepend-path MANPATH "/usr/local/openmpi/1.3.0/pgi80/x86_64/man"
append-path -delim { } LOCAL_LDFLAGS "-L/usr/local/openmpi/1.3.0/pgi80/x86_64/lib64 -L/usr/local/pgi/lib64/openmpi-pgi"
append-path -delim { } LOCAL_INCLUDE "-L/usr/local/pgi/include"
