I figured it out.
In the real application, I also did not have the 'use' statement, and there
was an IMPLICIT statement causing the omp_get_max_threads() function to be
automatically compiled as a real function instead of as integer, and the
integers were automatically promoted to 8-byte using -i8.
Once I added the 'use omp_lib' statement, the compiler caught the mis-match.
Just to verify, I did add the 'use omp_lib' statement and ran the test
program by itself. I do get '4' as expected regardless of whether or not I
run the program under MPI.
So there is no OpenMPI-related issue. I thought it was OpenMPI-related
because, after commenting out the MPI calls, I got the right answer. But
this was probably just a coincidence.
Thanks,
Ed
I did not have the 'use' statement.
-Original Message-
From: users-boun...@open-mpi.org [mailto:users-boun...@open-mpi.org] On
Behalf Of Reuti
Sent: Thursday, April 04, 2013 7:13 AM
To: Open MPI Users
Subject: Re: [OMPI users] Confused on simple MPI/OpenMP program
Hi,
Am 04.04.2013 um 04:35 schrieb Ed Blosch:
> Consider this Fortran program snippet:
>
> program test
use omp_lib
include 'mpif.h'
might be missing.
> ! everybody except rank=0 exits.
> call mpi_init(ierr)
> call mpi_comm_rank(MPI_COMM_WORLD,irank,ierr)
> if (irank /= 0) then
>call mpi_finalize(ierr)
>stop
> endif
>
> ! rank 0 tries to set number of OpenMP threads to 4 call
> omp_set_num_threads(4) nthreads = omp_get_max_threads() print*,
> "nthreads = ", nthreads
>
> call mpi_finalize(ierr)
>
> end program test
>
> It is compiled like this: 'mpif90 -o test -O2 -openmp test.f90'
> (Intel
> 11.x)
>
> When I run it like this: mpirun -np 2 ./test
>
> The output is: "nthreads = 0"
>
> Does that make sense? I was expecting 4.
>
> If I comment out the MPI lines and run the program serially (but still
> compiled with mpif90), then I get the expected output value 4.
Nope, for me it's still 0 then.
-- Reuti
> I'm sure I must be overlooking something basic here. Please enlighten me.
> Does this have anything to do with how I've configured OpenMPI?
>
> Thanks,
>
> Ed
>
>
> ___
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users
___
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users