I am trying to parallelize a code using OpenMP. In order to test my results, I compile as following: (my file is called hecese_OpenMP.f90
)
gfortran -O3 -g -fopenmp hecese_OpenMP.f90 -o hecese_OpenMP
and execute with:
./hecese_OpenMP
In this case, I get logical values (temperature values):
0.0000000000000000 783.49759312323954
4.9999999999999996E-006 783.97754329856036
9.9999999999999991E-006 784.46409277472367
1.4999999999999999E-005 784.93610174094374
1.9999999999999998E-005 785.40356531164821
2.4999999999999998E-005 785.86244125304006
2.9999999999999997E-005 786.31543982367702
3.4999999999999997E-005 786.76028899490404
3.9999999999999996E-005 787.19919935749363
4.4999999999999996E-005 787.62967799732780
4.9999999999999996E-005 788.05430483965176
5.4999999999999995E-005 788.47014285857574
5.9999999999999995E-005 788.88020246536769
6.4999999999999994E-005 789.28114213978677
6.9999999999999994E-005 789.67635992390058
7.4999999999999993E-005 790.06216152696709
7.9999999999999993E-005 790.44228749976969
8.4999999999999993E-005 790.81272956777650
8.9999999999999992E-005 791.17754135728615
9.4999999999999992E-005 791.53241936895017
9.9999999999999991E-005 791.88172053640665
1.0499999999999999E-004 792.22084724600575
1.0999999999999999E-004 792.55446522757518
1.1499999999999999E-004 792.87767333202453
1.1999999999999999E-004 793.19545920221628
1.2500000000000000E-004 793.50260538260022
1.3000000000000002E-004 793.80443633151526
1.3500000000000003E-004 794.09540506217127
When trying to compile with the flag -fbounds-check as following:
gfortran -O3 -g -fbounds-check -fopenmp hecese_OpenMP.f90 -o hecese_OpenMP
and executing as usual, I get strange temperature values(illogical):
0.0000000000000000 3.3678051568814173E+080
4.9999999999999996E-006 2.0735511943440867E+080
9.9999999999999991E-006 1.3676510585758991E+080
1.4999999999999999E-005 8.8222276938810882E+079
1.9999999999999998E-005 5.7108837929115938E+079
2.4999999999999998E-005 3.6529924583454717E+079
2.9999999999999997E-005 2.3293108079294771E+079
3.4999999999999997E-005 1.4700467727884548E+079
3.9999999999999996E-005 9.2409585880233678E+078
4.4999999999999996E-005 5.7484421298339787E+078
4.9999999999999996E-005 3.5604809767646989E+078
5.4999999999999995E-005 2.1807048749261957E+078
5.9999999999999995E-005 1.3291540309955299E+078
6.4999999999999994E-005 8.0025674937017744E+077
6.9999999999999994E-005 4.7911693804323633E+077
7.4999999999999993E-005 2.8296567608841817E+077
7.9999999999999993E-005 1.6599764239864436E+077
8.4999999999999993E-005 9.5877223899911227E+076
8.9999999999999992E-005 5.4907601600220782E+076
9.4999999999999992E-005 3.0867706571011204E+076
9.9999999999999991E-005 1.7152374444148965E+076
1.0499999999999999E-004 9.3084530138270176E+075
1.0999999999999999E-004 4.9628366027261650E+075
1.1499999999999999E-004 2.5578832649607984E+075
1.1999999999999999E-004 1.2769186604807401E+075
1.2500000000000000E-004 6.0034678612971150E+074
1.3000000000000002E-004 2.6103218948330567E+074
1.3500000000000003E-004 9.5395112603841788E+073
1.4000000000000004E-004 2.1614190086226482E+073
1.4500000000000006E-004 -8.3254384174910055E+072
I thought -fbounds-check
was a debugging flag which adds a check that the array index is within the bounds of the array every time an array element is accessed.
Does it intervene in the computations I make in my code ? As you can see from the results, there is a huge difference between the values obtained from the 2 compilations.
I only added the flag.
If you change the compilation options the compiler will perform different optimizations and operations, which occur under the hood.
The most likely case is that you have unsafe access to memory somewhere in your code, likely an overflow