Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

The same code can't run in release mode

Zhanghong_T_
Novice
570 Views

Hi all,

I have the following code:

implicit none

real*8,pointer::test(:)=>null()

call allocatetest(test)

end

subroutine allocatetest(test)

implicit none

real*8,pointer::test(:)

if(associated(test))deallocate(test)

allocate(test(100))

test=0.d0

end subroutine

Could anyone tell me how to modify the code to let it also work in release mode? My working envorinment is: Windows XP+VS.net2005+IVF10

Thanks,

Zhanghong Tang

0 Kudos
5 Replies
Steven_L_Intel1
Employee
570 Views
You need to make an explicit interface for allocatetest visible to the main program because the argument is an assumed-shape array and also because it is a pointer (either of these would trigger the requirement.) I'm astonished it works even in debug mode.

The simplest fix is to structure the program like this:

... call allocatetest (test)
contains
subroutine allocatetest (test)
...
end subroutine allocatetest
end

Making allocatetest a contained procedure provides the explicit interface.

For more information, see my article Doctor Fortran Gets Explicit.
0 Kudos
Zhanghong_T_
Novice
570 Views

Hi Steve,

Thank you very much for your kindly reply. It can work now.

Zhanghong Tang

0 Kudos
Steven_L_Intel1
Employee
570 Views
Oh, and compiling with /gen-interface and /warn: interface would have told you about this. These are now on by default in newly created VS projects in 10.0.
0 Kudos
Zhanghong_T_
Novice
570 Views

Thanks again! But I just work in 10.0 version. Maybe I need to update to 10.0.26?

Thanks,

Zhanghong Tang

0 Kudos
Steven_L_Intel1
Employee
570 Views
Works in 10.0.025 for me:

C:Documents and SettingsSteve>ifort /gen-interface /warn:interface t.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.0
Build 20070426 Package ID: W_FC_P_10.0.025
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

t.f90(5) : Warning: The procedure has a dummy argument that has the ALLOCATABLE,
ASYNCHRONOUS, OPTIONAL, POINTER, TARGET, VALUE or VOLATILE attribute. Required explicit interface is missing from original source. [TEST]
call allocatetest(test)
------------------^
0 Kudos
Reply