NAMD Wiki: NamdOnSLURM
NAMD binaries based on the verbs and netlrts Charm++ layers (i.e., those launched with a charmrun binary rather than mpiexec etc.) can use srun directly in place of mpiexec with the charmrun ++mpiexec option as follows:
charmrun ++n $SLURM_NTASKS ++mpiexec ++remote-shell srun namd2
The argument to ++n will be passed to srun via its -n argument. Other srun arguments may be passed as environment variables (see srun manpage) or by writing a wrapper script.
SMP layers require submitting the job with the desired --ntasks-per-node and adding a ++ppn argument to charmrun.