It sounds like your grid engine cluster is configured with the queues in posix_compliant mode and /bin/csh as the default shell. In posix_compliant mode the initial #! is ignored and you need to specify the shell via a command line switch or with a suitable #$ directive. Adding the following line to your script should work:
#$ -S /bin/bash