Debian Codegraph @

doc/example/compiler-etc-dependencies/homebrewed/foo/common

raw
1 # Common stuff for "foo" modulefiles
2 # Using "homebrewed flavors" strategy
3 #
4 # This file expects the following Tcl variables to have been
5 # previously set:
6 # version: version of foo
7
8 # Declare the path where the packages are installed
9 # The reference to the environment variable is a hack
10 # for this example; normally one would hard code a path
11 set rootdir $::env(MOD_GIT_ROOTDIR)
12 set swroot $rootdir/doc/example/compiler-etc-dependencies/dummy-sw-root
13
14 # Also get location of and load common procedures
15 # This is a hack for the cookbook examples, in production
16 # one should either
17 # 1) declare the procedures in a site config file (preferred)
18 # 2) hardcode the path to $tcllibdir and common_utilities.tcl
19 set tcllibdir $rootdir/doc/example/compiler-etc-dependencies/tcllib
20 source $tcllibdir/common_utilities.tcl
21
22 proc ModulesHelp { } {
23 global version
24 puts stderr "
25 foo: Test dummy version of foo $version
26
27 For testing packages depending on compilers/MPI
28
29 "
30 }
31
32 module-whatis "Dummy foo $version"
33
34 # Figure out what compiler we have loaded
35 # Will default to and load default compiler if none loaded
36 set ctag [ GetLoadedCompiler 1 1 1 ]
37
38 # Figure out what MPI we have loaded
39 # We do NOT want to default to intelmpi if intel compiler loaded
40 set mtag [ GetLoadedMPI ]
41 # Set mtag it nompi if no MPI library found loaded
42 if { $mtag eq {} } { set mtag nompi }
43 # Set mtag to intelmpi if intelmpi/default found loaded
44 if { $mtag eq {intelmpi/default} } { set mtag intelmpi }
45
46 # Compute the installation prefix
47 set pkgroot $swroot/foo
48 set vroot $pkgroot/$version
49 set prefix $vroot/$ctag/$mtag
50
51 # Make sure there is a build for this foo version/compiler/MPI library
52 # I.e. that the prefix exists
53 if ![ file exists $prefix ] {
54 # Not built for this compiler/MPI, alert user and abort
55 PrintLoadError "
56 foo/$version does not appear to be built for compiler $ctag and MPI $mtag
57
58 Please select a different openmpi version or different compiler/MPI library combination.
59 "
60 }
61
62 # We need to prereq the compiler to allow autohandling to work
63 prereq $ctag
64 # and the MPI library if used
65 if { $mtag ne {nompi} } {
66 # We currently require one to load intelmpi to use Intel MPI with
67 # intel compilers. So we prereq on intelmpi as well
68 # But if not, we could place the prereq below in an if-then block
69 # so is only executed if mtag != intelmpi
70 prereq $mtag
71 }
72
73 # Set environment variables
74 setenv FOO_DIR $prefix
75
76 set bindir $prefix/bin
77 set libdir $prefix/lib
78 set incdir $prefix/include
79
80 prepend-path PATH $bindir
81 prepend-path LIBRARY_PATH $libdir
82 prepend-path LD_LIBRARY_PATH $libdir
83 prepend-path CPATH $incdir
84
85 conflict foo