MPI_TAG_UB for openmpi/2.1.1

  • Fortran
  • Thread starter pachomba
  • Start date
  • Tags
    Fortran
So I suggest that you declare VALUE as INTEGER instead of INTEGER (KIND=MPI_ADDRESS_KIND) and print/write it after the MPI_COMM_GET_ATTR call.In summary, the conversation discusses getting the parameter MPI_TAG_UB for openmpi and using the routine MPI_COMM_GET_ATTR to do so. It is suggested to use "use mpi" in the code and compile it using mpifort. The code should include a print/write statement to show the value of MPI_TAG_UB and the argument MAXTAG should be removed. It is also recommended to declare VALUE as INTEGER instead of INTEGER (KIND=MPI_ADDRESS_KIND) as the upper bound for tags is never smaller than 32767. The error "shmem: posix: filef
  • #1
3
0
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!
 
  • #2
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
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
~/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
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
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.
 

Suggested for: MPI_TAG_UB for openmpi/2.1.1

2
Replies
60
Views
2K
Replies
12
Views
739
Replies
2
Views
603
Replies
8
Views
771
Replies
4
Views
817
2
Replies
37
Views
2K
Replies
8
Views
2K
Replies
12
Views
1K
Replies
17
Views
4K
Back
Top