def WriteModulesFile(modules, version, sdir):
    """ Write the contents of the Modules file """
    modules.write('#%Module\n\n')
    modules.write('proc ModulesHelp { } {\n')
    modules.write(
        """    puts stderr "This module sets the path and environment variables for slepc-%s\"
"""
         % version)
    modules.write(
        '    puts stderr "     see https://slepc.upv.es/ for more information"\n'
        )
    modules.write('    puts stderr ""\n}\n')
    modules.write(
        """module-whatis "SLEPc - Scalable Library for Eigenvalue Problem Computations"

"""
        )
    modules.write('module load petsc\n')
    modules.write('set slepc_dir %s\n' % sdir)
    modules.write('setenv SLEPC_DIR $slepc_dir\n')
