Software Archive
Read-only legacy content
17061 Discussions

How can i pass integer and reals as characters for MPI?

Intel_C_Intel
Employee
243 Views
I'm trying to compile some fortran routines that use MPI. A few routines have arguments declared as character type, but some calling routines pass integers or reals. When linking, i get several unresolved external errors due to the argument mismatches. Is there any simple way to solve this problem?

Example:

subroutine MPSNDA(totid,msgtyp,lmsg,msg,mid,err)
implicit none
integer totid,msgtyp,lmsg,mid,err
character*1 msg(lmsg)

but the 1st call is:

CALL MPSNDA(TOTID,NMSG+P,IINT*LBFI,IBUF(1,SNDBUF),MIDS1,INFO)

where IBUF is declared as an integer array. Later in the same routine MPSNDA is called as:

CALL MPSNDA(TOTID,NMSG+P+NPROC,IREAL*LBFR,RBUF(1,SNDBUF),
& MIDS2,INFO)

where RBUF is declared as a double precission array.

Thanks in advance
cheers
-joe
0 Kudos
5 Replies
Steven_L_Intel1
Employee
243 Views
We'd have to know what the MPI routine expected. If it was using CVF defaults, it would need two different routines to accept both CHARACTER and REAL. More likely, it just wants the data passed by reference, so you'd need an INTERFACE block that declares the routine and argument to be by reference. Another option, I think, is to pass the CHARACTER data using %REF(arg).

Steve
0 Kudos
Intel_C_Intel
Employee
243 Views
Thanks for your reply Steve!

The routines have been written by another group, and compile and run on numerous unix platforms. I'm trying to get a single processor version of the code to run under win nt. Part of the package (VECFEM at http://www.massey.ac.nz/~lgrosz/vecfem/) includes versions for both single and multi processor linux platforms. The single-processor linux version of MPSNDA is just a dummy routine, show here:

C:::::      ,,,,,MPSNDA... 
C 
C 
C 
C********************************************************************** 
C        1         2         3         4         5         6         7* 
C********************************************************************** 
C**                                                                 *** 
C**                                                                 *** 
      SUBROUTINE  MPSNDA(TOTID,MSGTYP,LMSG,MSG,MID,ERR) 
C**                                                                 *** 
C**                                                                 *** 
C********************************************************************** 
C**                                                                 *** 
C**      MPSNDA is here a dummy routine                             *** 
C**                                                                 *** 
C********************************************************************** 
C**                                                                 *** 
      IMPLICIT NONE 
C**                                                                 *** 
C**-----------------------------------------------------------------*** 
C**                                                                 *** 
C**      FORMAL PARAMETERS :                                        *** 
C**      -----------------                                          *** 
C**                                                                 *** 
C**                                                                *** 
      INTEGER           TOTID,MSGTYP,LMSG,MID,ERR 
 
      CHARACTER*1       MSG(LMSG) 
C**                                                                 *** 
C**-----------------------------------------------------------------*** 
C**                                                                 *** 
C**   LIST OF FORMAL PARAMETERS :                                   *** 
C**   -------------------------                                     *** 
C**                                                                 *** 
C--------I------I-----I------------------------------------------------ 
C NAME   I TYPE I I/O I     MEANING 
C--------I------I-----I------------------------------------------------ 
C--------I------I-----I------------------------------------------------ 
C TOTID  I  I   I in  I  id of the target process 
C--------I------I-----I------------------------------------------------ 
C MSGTYP I  I   I in  I  message type 
C--------I------I-----I------------------------------------------------ 
C LMSG   I  I   I in  I  length of the message (in bytes) 
C--------I------I-----I------------------------------------------------ 
C MSG    I  C*1 I in  I  the message                  array : MSG(LMSG) 
C--------I------I-----I------------------------------------------------ 
C MID    I  I   I out I  message id (has to handed over to MPSNDW) 
C--------I------I-----I------------------------------------------------ 
C ERR    I  I   I out I  error numbe
r 
C--------I------I-----I------------------------------------------------ 
C**                                                                 *** 
C**-----------------------------------------------------------------*** 
C**                                                                 *** 
C 
C**** START OF CALCULATION 
C     ------------------ 
C 
      print *,' This routine (mpsnda) should not be entered if you' 
      print *,' run LINSOL on 
0 Kudos
Intel_C_Intel
Employee
243 Views
here is the rest of my post that got cut off:
C**** START OF CALCULATION 
C     ------------------ 
C 
      print *,' This routine (mpsnda) should not be entered if you' 
      print *,' run LINSOL on one processor. If you run LINSOL on ' 
      print *,' more than one processor, then you have to link the' 
      print *,' library MPI={PVM,PARMACS,NX2,MPL} and not the library' 
      print *,' nocomm. Therefore the program is stopped (bang).' 
      stop 
C 
C**** END OF CALCULATION 
C     ------------------ 
C 
      R E T U R N 
C-----END OF MPSNDA---------------------------------------------------- 
      E    N    D 
 


While the multi processor version calls a routine from the MPI library. As you can see above, MPSNDA should not even be called if only one processor is specified. Presumably, gnu fortran has no problem compiling and linking code that has argument mismatches, but CVF does. For now, I just need to get CVF to ignore the argument mismatches, as the routine will not even be called. The difficulty is that MPSNDA is called where the argument msg may be declared as integer, real, or character in the calling routine. There are several hundred calls to MPSNDA and similar routines, so it would be preferable to modify MPSNDA.

In the future, i plan on getting the multiprocessor version to run, but for now, this is not a concern.

thanks again.
-joe
0 Kudos
Steven_L_Intel1
Employee
243 Views
Quick and dirty method - Compile everything with /iface:cref/iface:nomixed_str_len_arg (These are options under Settings..Fortran..External Routines)

Steve
0 Kudos
Intel_C_Intel
Employee
243 Views
thats what i needed.

mucho gracious steve!

-joe
0 Kudos
Reply