- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am experiencing some problems when compiling my code with the -openmp flag, even in parts where there is no OpenMP presents. To illustrate one problem, I wrote the small code below. I'm on Mac OS X 10.6.6 and the problem occurs for me with ifort11.1.067 and also with 12.0.0.085
When I compile in debug mode, using ifort -g -FR test.f90, the program performs as expected: the ASSOCIATED(adata) inside the subroutine alloc returns false and so the array is being allocated, and the subroutine returns. When I add the openmp flag (even though there is no openmp code here) to the compilation options, I get the following output:
inside alloc, testing associated
Adata associated
Size: 1606416640 0
Deallocation with status 173
Allocation with status 0
End program
For some reason, the ASSOCIATED returned a TRUE, and the code continues with deallocating the pointer from which it returns an error code.
Is there something wrong with the code I wrote in terms of Fortran rules, that only shows up when I compile with -openmp? Or is this a compiler bug? By the way, the problem disappears without the -g flag.
Thanks!
[fortran]PROGRAM test IMPLICIT NONE INTERFACE alloc SUBROUTINE alloc(adata,info) IMPLICIT NONE INTEGER, DIMENSION(:,:), POINTER :: adata INTEGER, INTENT(INOUT) :: info END SUBROUTINE alloc END INTERFACE alloc INTEGER, DIMENSION(:,:), POINTER :: Npx INTEGER :: info CALL alloc(Npx,info) DEALLOCATE(Npx) WRITE(*,*) 'End program' END PROGRAM SUBROUTINE alloc(adata,info) IMPLICIT NONE INTEGER, DIMENSION(:,:), POINTER :: adata INTEGER, INTENT(INOUT) :: info WRITE(*,*) 'inside alloc, testing associated' IF(ASSOCIATED(adata)) THEN WRITE(*,*) 'Adata associated' WRITE(*,*) 'Size: ',Size(adata,1),Size(adata,2) DEALLOCATE(adata,STAT=info) WRITE(*,*) 'Deallocation with status ',info NULLIFY(adata) END IF ALLOCATE(adata(10,10),STAT=info) WRITE(*,*) 'Allocation with status ',info END SUBROUTINE alloc[/fortran]
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The association status of your pointer is "undefined", therefore the result of calling ASSOCIATED is also undefined. If you want Npx to start out as unassociated, add => NULL() to its declaration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Steve,
That's it. Calling ASSOCIATED on undefined pointers has not affected my code until now, so I had a hard time finding out that this was what made my code fail with OpenMP. Sinceit's a bad thing to have in my code anyway, I will fix it now. Thanks a lot for your quick answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad to hear it. By the way, I tried using the compiler's Static Security Analysis feature, used in conjunction with Intel Inspector XE, and it identified the uninitialized variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you need thread safe code then youmust notnullify in the declaration because that makes the pointer implicitly persistent und thus thread unsafe(like SAVE).
It's inconvenient butthenullify must be done seperately.
It's inconvenient butthenullify must be done seperately.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page