[Ncep.list.nems.announce] Fwd: intent mismatch (intent(inout) vs no intent at all)

Dusan Jovic dusan.jovic at noaa.gov
Fri Jul 10 14:36:00 UTC 2015


---------- Forwarded message ----------
From: Dusan Jovic <dusan.jovic at noaa.gov>
Date: Apr 17, 2015 4:11 PM
Subject: intent mismatch (intent(inout) vs no intent at all)
To: Mark Iredell <Mark.Iredell at noaa.gov>,"Moorthi, Shrinivas" <shrinivas.moorthi at noaa.gov>
Cc: Tom Black <tom.black at noaa.gov>

> Here is a minimal program that demonstrates the problem when argument's intent is inconsistently specified between actual and dummy argument:
>
> !----------------------------------------------------------------
> module esmf_grid_m
>  type grid
>   integer::igrid
>  end type grid
> end module esmf_grid_m
>
> module esmf_comp_m
>  use esmf_grid_m
> contains
>  subroutine esmf_register(userFunc)
>   implicit none
>   interface
>     subroutine userFunc(g)
>       use esmf_grid_m
>       type(grid)                :: g
> !      type(grid), intent(inout) :: g
>     end subroutine
>   end interface
>
>  end subroutine esmf_register
> end module esmf_comp_m
>
> module esmf
>  use esmf_grid_m
>  use esmf_comp_m
> end module esmf
>
> module model_m
>  contains
>  subroutine model_register(g)
>   use esmf
>   implicit none
> !  type(grid)                :: g
>   type(grid), intent(inout) :: g
>   g%igrid = 10
>  end subroutine model_register
> end module model_m
>
> program nems
>   use esmf
>   use model_m
>   implicit none
>   call esmf_register(model_register)
> end program nems
>
> !----------------------------------------------------------------
>
>
> When I compile this program with the default Intel compiler on theia I do not get any error:
>
> tfe09:/home/Dusan.Jovic> module purge
> tfe09:/home/Dusan.Jovic> module load intel
> tfe09:/home/Dusan.Jovic> ifort -v
> ifort version 14.0.2
> tfe09:/home/Dusan.Jovic> ifort -check all test_intent.f90 
>
> However ifort 15 complains about intent mismatch:
>
> tfe09:/home/Dusan.Jovic> module purge
> tfe09:/home/Dusan.Jovic> module load intel/15.0.0
> tfe09:/home/Dusan.Jovic> ifort -v
> ifort version 15.0.0
> tfe09:/home/Dusan.Jovic> ifort -check all test_intent.f90 
> test_intent.f90(43): error #7061: The characteristics of dummy argument 1 of the associated actual procedure differ from the characteristics of dummy argument 1 of the dummy procedure.   [MODEL_REGISTER]
>   call esmf_register(model_register)
> ---------------------^
> compilation aborted for test_intent.f90 (code 1)
> tfe09:/home/Dusan.Jovic> 
>
> I found similar errors when I was trying to compile nmmb with recent version of gfortran on my Linux box and I fixed the problem (at least some of them which were required for nmmb)  in this commit:
>
> https://svnemc.ncep.noaa.gov/trac/nems/changeset/36346
>
>
> Here is the error message I get from GNU fortran (little more useful):
>
> $ gfortran test_intent.f90 
> test_intent.f90:43.21:
>
>   call esmf_register(model_register)
>                      1
> Error: Interface mismatch in dummy procedure 'userfunc' at (1): INTENT mismatch in argument 'g'
>
>
> So Mark, yes I am now sure that intent(inout) and no intent are two different things (argument attributes) and compilers (at least newer versions) generate different interfaces in these two cases which are not compatible.
>
> Dusan
>



More information about the Ncep.list.nems.announce mailing list