On Aug 19, 2016, at 2:30 PM, Matt Thompson <fort...@gmail.com> wrote:
> 
> I'm slowly trying to learn and transition to 'use mpi_f08'. So, I'm writing 
> various things and I noticed that this triggers an error:
> 
> program hello_world
>    use mpi_f08
>    implicit none
>    type(MPI_Comm) :: comm = MPI_COMM_NULL
> end program hello_world
> 
> when compiled (Open MPI 2.0.0 with GCC 6.1):
> 
> (380) $ mpifort test1.F90 
> test1.F90:7:27:
> 
>     type(MPI_Comm) :: comm = MPI_COMM_NULL
>                            1
> Error: Parameter ‘mpi_comm_null’ at (1) has not been declared or is a 
> variable, which does not reduce to a constant expression
> 
> Why is that? Obviously, I can just do:
> 
>    type(MPI_Comm) :: comm
>    comm = MPI_COMM_NULL
> 
> and that works just fine (note MPI_COMM_NULL doesn't seem to be special as 
> MPI_COMM_WORLD triggers the same error). 

I am *not* a Fortran expert, but I believe the difference between the two is:

1. The first one is a compile-time assignment.  And you can only do those with 
constants.  MPI_COMM_NULL is not a compile-time constant, hence, you get an 
error.

2. The second one is a run-time assignment.  You can do that between any 
compatible entities, and so that works.

> I'm just wondering why the first doesn't work, for my own edification. I 
> tried reading through the Standard, but my eyes started watering after a bit 
> (though that might have been the neon green cover). Is it related to the fact 
> that when one declares:
> 
>    type(MPI_Comm) :: comm
> 
> that the comm == MPI_COMM_WORLD evaluates to .TRUE.? I discovered that once 
> when I was printing some stuff.

That might well be a coincidence.  type(MPI_Comm) is not a boolean type, so I'm 
not sure how you compared it to .true.

-- 
Jeff Squyres
jsquy...@cisco.com
For corporate legal information go to: 
http://www.cisco.com/web/about/doing_business/legal/cri/

_______________________________________________
users mailing list
users@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/users

Reply via email to