- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all!
I am having a really strange issue with the following code: pratically if I declare a value of elements from REC(4) to REC(7) different from zero I have segmentation fault
....................
[bash]program exat implicit none real*8 start_value, stop_t, start_sec, stop_sec, interval, sat_id real*8 theta_0, theta_punto, psi_0, psi_punto, phi_0, phi_punto real*8 theta, psi, phi real*8 zero, uno real*8 delta_T real*8 q1, q2,q3,q4 real*8 pigreco real*8 REC(9), REC1(9) pigreco=3.141593 zero=0.00 uno=1.50[/bash]
[bash] close(10) close(11) open(10,file='file1',status='unknown',form='binary') open(11,file='file1.txt',status='unknown',form='formatted') REC(1)=pigreco REC(2)=pigreco REC(3)=pigreco REC(4)=zero REC(5)=zero REC(6)=zero REC(7)= zero REC(8)=pigreco REC(9)=pigreco write(*,*) REC[/bash]....This Work
but If I do something like:
[bash]REC(1)=pigreco REC(2)=pigreco REC(3)=pigreco REC(4)=zero REC(5)=zero REC(6)=zero REC(7)= pigreco REC(8)=pigreco REC(9)=pigreco[/bash]
[bash]
[/bash]
[bash]I receive a segmentation fault during execution,[/bash]
[bash]This is really strange and it is driving me out of head.[/bash]
[bash]
[/bash]
[bash]Thanks in advance for your suggests[/bash]
[bash]
[/bash]
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is this the entire contents of your program? What hardware are you running on? What compiler version are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the name of your source file (in particular the file type/extension)?
x.for, x.f are by defaultcompiled as fixed form files. i.e. spaces on left of line are important
x.f90, x.f95 are free form by default.
You can change fixed/free form by way of option switch.
The program you copied to the forum has all the lines squished to the left margin.
In fixed form, this will cause problems.
Normally you will receive many error messages when this happens.
Sometimes you do not (but have problems with running of program).
Jim Dempsey
x.for, x.f are by defaultcompiled as fixed form files. i.e. spaces on left of line are important
x.f90, x.f95 are free form by default.
You can change fixed/free form by way of option switch.
The program you copied to the forum has all the lines squished to the left margin.
In fixed form, this will cause problems.
Normally you will receive many error messages when this happens.
Sometimes you do not (but have problems with running of program).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel Fortran does not recognize .f95 as a Fortran file unless you ask it to. .f90 is the recommended and most widely supported file type for free-form source.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for all you suggestions,
this is the compiler version I have:
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091130 Package ID: m_cprof_p_11.1.080
running on a
10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 a Xserver with snow leopard
I compiled it usingifort -r8 -c EXAT.f90 ; ifort -oEXAT.x EXAT.o
I realized that I don't have the error while I assign value to the vector but when I try to write the vector in a binary file, here the program:
[bash]program exat implicit none real*8 start_value, stop_t, start_sec, stop_sec, interval, sat_id real*8 theta_0, theta_punto, psi_0, psi_punto, phi_0, phi_punto real*8 theta, psi, phi real*8 pigreco, zero, uno real*8 delta_T real*8 q1, q2,q3,q4 real*8, dimension(9):: REC, REC1 start_value=00.00 stop_t=02.00 start_sec=00.00 stop_sec=00.00 interval=0 sat_id=1111111.00 pigreco=3.141593 theta_0= 103.783*180/pigreco theta_punto=-0.005*180/pigreco psi_0=-44.910*180/pigreco psi_punto=0.0108*180/pigreco phi_0=-159.108*180/pigreco phi_punto=-0.254*180/pigreco zero=0.00 uno=1.50 REC(1)=zero REC(2)=sat_id REC(3)=zero REC(4)=zero REC(5)=start_value REC(6)=start_sec REC(7)=stop_t REC(8)=stop_sec REC(9)=interval write(*,*) REC close(10) close(11) open(10,file='file.bin',status='unknown',form='binary') open(11,file='file.txt',status='unknown',form='formatted') write(10) REC write(11, *) rec do delta_T=0,1,1 theta=theta_0 + theta_punto*delta_T psi=psi_0+ psi_punto*delta_T phi=phi_0+ phi_punto*delta_T q1=cos(theta/2)*cos(psi/2)*cos(phi/2)+ sin(theta/2)*sin(psi/2)*sin(phi/2) q2=sin(theta/2)*cos(psi/2)*cos(phi/2)- cos(theta/2)*sin(psi/2)*sin(phi/2) q3=cos(theta/2)*sin(psi/2)*cos(phi/2)+ sin(theta/2)*cos(psi/2)*sin(phi/2) q4=cos(theta/2)*cos(psi/2)*sin(phi/2)-sin(theta/2)*sin(psi/2)*cos(phi/2) end do close(10) close(11) end [/bash]
Now, if I declare the vector as
[bash]REC(1)=start_value REC(2)=sat_id REC(3)=zero REC(4)= zero REC(5)=zero REC(6)=zero REC(7)=zero REC(8)=zero REC(9)=interval[/bash]
The program runs smooth, but if I use something like:
[bash]REC(1)=zero REC(2)=zero REC(3)=zero REC(4)= zero REC(5)=sat_id REC(6)=zero REC(7)=zero REC(8)=zero REC(9)=zero[/bash]
Everything zero exept the 5th element I have segmentation error
I don't understand
Thank you so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An update might correct the problem you are observing.
Out of curiosity, with the failing set of initialization data for REC, following "REC(9) = zero", add "REC1(1) = sat_it" (any non-zero initializer).
Then see if the failure occurs.
Jim Dempsey
Out of curiosity, with the failing set of initialization data for REC, following "REC(9) = zero", add "REC1(1) = sat_it" (any non-zero initializer).
Then see if the failure occurs.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting jimdempseyatthecove
An update might correct the problem you are observing.
Out of curiosity, with the failing set of initialization data for REC, following "REC(9) = zero", add "REC1(1) = sat_it" (any non-zero initializer).
Then see if the failure occurs.
Jim Dempsey
Out of curiosity, with the failing set of initialization data for REC, following "REC(9) = zero", add "REC1(1) = sat_it" (any non-zero initializer).
Then see if the failure occurs.
Jim Dempsey
I tried your suggestion but nothing changed, I don't know how to update and I don't think it is feasable, I just want to create a 64bit array and store it in a binary file, it doesn't work for some error of me, the task doesn't sound so hard in general to hide a bug inside the compiler :)
Thanks
Ciao, Giampiero
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Giampiero,
In testing here:
Windows XP x32 (P4)IVF 11.0.066 Release and Debug builds no error (with either REC initializations)
Windows 7 x64 (Core i7 2600K) IVF 12.0.4.196 as x32 app Release and Debug no error (with either REC initializations), as x64 app Release and Debug no error (with either REC initializations).
IOW non reproducable.
One potential problem area comes to mind. If you compiled without processor detection and with declaring and advanced SSE/AVX requirement (one not supported by your hardware), then you might observe an error due to alignment or missing instruction.
What is your processor and what are your compilation options?
Jim Dempsey
In testing here:
Windows XP x32 (P4)IVF 11.0.066 Release and Debug builds no error (with either REC initializations)
Windows 7 x64 (Core i7 2600K) IVF 12.0.4.196 as x32 app Release and Debug no error (with either REC initializations), as x64 app Release and Debug no error (with either REC initializations).
IOW non reproducable.
One potential problem area comes to mind. If you compiled without processor detection and with declaring and advanced SSE/AVX requirement (one not supported by your hardware), then you might observe an error due to alignment or missing instruction.
What is your processor and what are your compilation options?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I noticed you are running on a Darwin kernel - i.e. Apple (I am on Windows).
Apple versions of compilers tend to produce PIC code (Position Independent Code). I am not sure if IVF does this when compiling on Mac (Darwin). You might search the ISN FORTRAN forums for PIC related problems. This may be an issue already discussed. Hopefully this is a problem that can be "fixed" with the appropriate compiler option and/or linker option.
Jim Dempsey
Apple versions of compilers tend to produce PIC code (Position Independent Code). I am not sure if IVF does this when compiling on Mac (Darwin). You might search the ISN FORTRAN forums for PIC related problems. This may be an issue already discussed. Hopefully this is a problem that can be "fixed" with the appropriate compiler option and/or linker option.
Jim Dempsey

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