Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

works only with WRITE(*,*)

diedro
Beginner
416 Views
dear all,
I wrote e fortran code that use listes and pointers.
It is:
[bash]DO jp = LISTPART(ii,jj)%current%value IF(.NOT. dlist_move_next(LISTPART(ii,jj))) EXIT CALL KERNEL(rp(:,ip),rp(:,jp),lij,W,dW,xij,tk) r = SQRT( (rp(1,ip)-rp(1,jp))**2.d0 + (rp(2,ip)-rp(2,jp))**2.d0) ENDDO[/bash] it does not work, I get asegmentation fault.
The strange things is that if I use a WRITE in the do cycle like
[bash]WRITE(*,*) R[/bash] it works
could someone explam me why?
is it a unix problem?
thanks a lot to everyone

0 Kudos
4 Replies
mecej4
Honored Contributor III
416 Views
When you insert a WRITE statement into the middle of a block of code, and the program behavior changes, it is most often because the code is buggy. A WRITE statement may inhibit certain optimizations, and/or change the way in which the bug manifests itself.

A worse situation is one in which the program seems to work correctly for a long time, and insertion of a WRITE statement breaks the program.

You have to locate the segmentation fault and trace back to the causes of the segmentation fault. Such a task can be sometimes very difficult and time-consuming, especially if the size of the code is appreciable and someone else wrote the code.

I have no idea as to what you mean by "Unix problem". A standard-conforming Fortran program should work on any supported/supporting platform.
0 Kudos
jimdempseyatthecove
Honored Contributor III
416 Views
Are/is dlist_move_next and/or KERNEL recursive?

Does the error occur in debug build?

Have you tried adding the diagnostics? (gen-interfaces, uninitialized variables, and subscript error checking)

Jim Dempsey
0 Kudos
diedro
Beginner
416 Views
dear you,
thank you, I found the error. It was a wrong allocation in Kernel subroutine.
a question, what do you mean for diagnostics?
is it a way to compile in order to understand if there are some error?
thanks a lot
0 Kudos
jimdempseyatthecove
Honored Contributor III
416 Views
I am not in my Linux environment now, the Windows options of interest are:
(Linux options may have different spelling but same functionality present)

-check:bounds (array subscripts out of bounds testing)
-check:uninit(uninitialized (scalar) variables, arrays are not tested)
-gen-interfaces (generates .MOD files with sub/fun interfaces)
-warn:interfaces (uses .MOD files with sub/fun interfaces and verifies callers)

if compiling fixe format also consider

-warn:truncated_source (fixed souce defaults to 72 columns w/ no warning on truncation)

The correct compiler options should be listed in the documentation.

On Windows

ifort -?

displays the command line options. It may do the same thing on Linux.

Jim Dempsey
0 Kudos
Reply