MPI_TAG_UB for openmpi/2.1.1

  • #1
3
0

Main Question or Discussion Point

Hello,
I am trying to get the parameter MPI_TAG_UB for openmpi (I am using version 2.1.1). I know I need to use the routine MPI_COMM_GET_ATTR, but I have no idea how to do that, I never used fortran in my life. Following this link (https://www.mpi-forum.org/docs/mpi-2.2/mpi22-report/node369.htm) I tried this:

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE

! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, KEYVAL, VALUE, FLAG, IERR)

I put that in a file test.f90, then did gfortran test.f90 -o test.out, but I got this error message:

Error: Parameter 'mpi_address_kind' at (1) has not been declared or is a variable, which does not reduce to a constant expression
Error: Unexpected end of file in 'test.f90'

So I have no idea what I'm doing. Did someone ever retrieved the value of MPI_TAG_UB for some MPI implementation?
Thanks!
 

Answers and Replies

  • #2
DrClaude
Mentor
7,163
3,308
MPI constants are of course not part of Fortran, so the compiler doesn't know what to do with MPI_ADDRESS_KIND.

Try
Fortran:
use mpi
at the beginning of your code.
 
  • #3
3
0
MPI constants are of course not part of Fortran, so the compiler doesn't know what to do with MPI_ADDRESS_KIND.

Try
Fortran:
use mpi
at the beginning of your code.
Thank you very much DrClaude, I tired that and I got this error:
Error: Unexpected end of file in 'test.f90'

Then I tried including "PROGRAM test" and "END PROGRAM test" at the beginning and end of the script, and I got this error:
~/tmp/cc3b6Lod.o: In function `MAIN__':
test.f90:(.text+0x34): undefined reference to `mpi_comm_get_attr_'
collect2: ld returned 1 exit status

I know it must be a very basic thing I'm not doing, I plan to learn some fortran in the future but for now I just need to get that MPI_TAG_UB value.
Truly appreciate any help.
 
  • #4
DrClaude
Mentor
7,163
3,308
~/tmp/cc3b6Lod.o: In function `MAIN__':
test.f90:(.text+0x34): undefined reference to `mpi_comm_get_attr_'
collect2: ld returned 1 exit status
That's because your not linking to the MPI library. The easiest way to do this is to compile using mpifort instead of gfortran (it will still use gfortran, but will correctly link). See https://www.open-mpi.org/faq/?category=mpi-apps
 
  • #5
3
0
That's because your not linking to the MPI library. The easiest way to do this is to compile using mpifort instead of gfortran (it will still use gfortran, but will correctly link). See https://www.open-mpi.org/faq/?category=mpi-apps
Thank you Dr, I was able to compile the program with mpifort, now the program looks like this:

PROGRAM test
include 'mpif.h'

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE
! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_INIT(IERR)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, MPI_TAG_UB, MAXTAG, VALUE, FLAG, IERR)

END PROGRAM test

but when I run it I get this error now:

shmem: posix: file name search - max attempts exceeded.cannot continue with posix.

I guess I need to add an include 'something' line at the beginning? Also, is this going to actually tell me what the value of MPI_TAG_UB is?
 
  • #6
DrClaude
Mentor
7,163
3,308
PROGRAM test
include 'mpif.h'

LOGICAL FLAG
INTEGER IERR
INTEGER (KIND=MPI_ADDRESS_KIND) VALUE
! Upon successful return, VALUE == 7 (sign extended)
CALL MPI_INIT(IERR)
CALL MPI_COMM_GET_ATTR(MPI_COMM_WORLD, MPI_TAG_UB, MAXTAG, VALUE, FLAG, IERR)

END PROGRAM test
That program has no output. you have to add a print (or write) statement to show the value of VALUE. Also, when posting code, please use CODE tags (you can get them automatically by clicking on the + in the bar above the text area and choosing </> Code.)


shmem: posix: file name search - max attempts exceeded.cannot continue with posix.
This appears to be an implementation-dependent error. How are you launching the program? (Often, you need a launcher to execute correctly in parallel, such as mpirun.)

Also, is this going to actually tell me what the value of MPI_TAG_UB is?
As I wrote above, the program as is will have no output. Looking at the specification soft MPI_COMM_GET_ATTR, you have one argument too many. You should remove MAXTAG. Also, I don't understand why you think that VALUE should be 7, because the MPI standard specifies that the upper bound on tags is never smaller than 32767.
 

Related Threads on MPI_TAG_UB for openmpi/2.1.1

  • Last Post
Replies
3
Views
6K
Replies
11
Views
8K
Replies
4
Views
2K
Replies
3
Views
2K
Replies
8
Views
2K
  • Last Post
Replies
4
Views
659
  • Last Post
Replies
10
Views
2K
  • Last Post
Replies
9
Views
3K
  • Last Post
8
Replies
177
Views
55K
  • Last Post
Replies
1
Views
1K
Top