rachanaj has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I am trying to use the MPI module for the first time. I use the following command:

$>mpirun -np 1 mpitest.pl

and get the following error:

: bad interpreter: No such file or directorypitest.pl: /usr/local/bin/perl

The code is attached below:
#!/usr/bin/perl use Parallel::MPI qw(:all); # Start up MPI MPI_Init(); # Find out process rank $my_rank = MPI_Comm_rank(MPI_COMM_WORLD); # Find out number of processes $num_procs = MPI_Comm_size(MPI_COMM_WORLD); $infilename = "sequences.txt"; open(INFILE, $infilename); @sequences = <INFILE>; close(INFILE); $num_seq = $#sequences + 1; $seq_per_file = int $num_seq / $num_procs; $start_seq = $my_rank * $seq_per_file; if ($my_rank < $num_procs) { $end_seq = ($my_rank + 1) * $seq_per_file - 1; } else #deal with last processor separately { $end_seq = $num_seq; } foreach ($start_seq..$end_seq) { ; #Stuff to do with sequences } MPI_Finalize();

Any ideas about the problem are welcome.
Thanks
-Rachana

Replies are listed 'Best First'.
Re: MPI Module
by muntfish (Chaplain) on Nov 26, 2004 at 10:28 UTC

    As BUU already suggested, this is probably because /usr/local/bin/perl does not exist. What is curious though, is that your code says #!/usr/bin/perl not #!/usr/local/bin/perl ...? Maybe that was just a typo/cut'n'paste error on your part. If not then I'm not sure what's going on.

    One other thing that could cause this error is some spurious CR/LF characters on the end of the #! line. For example if you developed the Perl script on a Windows machine then FTPed it to your Unix box, but forgot to transfer it in ASCII mode, then the #! line will have an ASCII-13 at the end which confuses most Unix shells. Some Unix editors (I think EMACS does this) will show this up as: #!/usr/bin/perl^M . Not sure if that's the problem in this case but it's something to look out for.


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
Re: MPI Module
by BUU (Prior) on Nov 26, 2004 at 10:16 UTC
    The error you quote: bad interpreter: No such file or directorypitest.pl: /usr/local/bin/perl is not a perl error, it is a bash (or possibly some other shell) that is attempting to run the interpreter specified on the shebang line of the file. The specified interpreter doesn't exist, so it errors.