How to Retrieve the Value of MPI_TAG_UB in openmpi/2.1.1 Using Fortran?

  • Context: Fortran 
  • Thread starter Thread starter pachomba
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary

Discussion Overview

The discussion revolves around retrieving the value of MPI_TAG_UB in OpenMPI version 2.1.1 using Fortran. Participants explore the use of the MPI_COMM_GET_ATTR routine and address various compilation and execution errors encountered in the process.

Discussion Character

  • Technical explanation
  • Homework-related
  • Debate/contested

Main Points Raised

  • One participant seeks to retrieve the MPI_TAG_UB value but encounters compilation errors related to the declaration of MPI_ADDRESS_KIND.
  • Another participant suggests including "use mpi" at the beginning of the code to resolve the issue with MPI constants.
  • After modifying the code, the original poster faces an undefined reference error for `mpi_comm_get_attr_`, prompting a suggestion to compile using mpifort instead of gfortran.
  • Following successful compilation with mpifort, the participant reports a runtime error related to POSIX file name search, indicating a potential issue with how the program is launched.
  • There are discussions about the need to add output statements to display the value of MPI_TAG_UB and a correction regarding the number of arguments passed to MPI_COMM_GET_ATTR.
  • One participant questions the assumption that VALUE should be 7, noting that the MPI standard specifies a minimum upper bound on tags of 32767.

Areas of Agreement / Disagreement

Participants generally agree on the need for proper linking to the MPI library and the necessity of including output statements in the code. However, there are differing views on the expected value of MPI_TAG_UB and the correct usage of the MPI_COMM_GET_ATTR function, indicating unresolved aspects of the discussion.

Contextual Notes

There are unresolved issues regarding the specific implementation-dependent error encountered during execution and the assumptions made about the expected value of MPI_TAG_UB. Additionally, the discussion highlights potential missing elements in the code that could affect its functionality.

pachomba
Messages
3
Reaction score
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!
 
Technology news on Phys.org
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.
 
DrClaude said:
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.
 
pachomba said:
~/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
 
DrClaude said:
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?
 
pachomba said:
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.)
pachomba said:
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.)

pachomba said:
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 19 ·
Replies
19
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K