Question: I am attempting to extract IP Address from a MySQL database using REGEX ina a SELECT statement. When i run the Query in the MySQL console it returns the expected results:

```
SELECT * FROM database.table WHERE field3 REGEXP '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';

```

When I run the same query through a python script it returns results that are not IP Addresses.

```
query = ("SELECT * FROM database.table WHERE field3 REGEXP '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';")

```

Where am I going wrong?

Answer: 
To answer how to add the `avx` flag into compiler options.  

In your case the f77 complier is being picked `gfortran:f77: ./distance.f` < That is the key line.  

You could try specifying `--f77flags=-mavx`
In the comments Warren Weckesser explained that Fortran arrays are stored transposed with regards to the C ones. However, one important implication was not mentioned. To traverse the array in the right order, you have to switch the order of the loops. In C the first index is the outer loop, in Fortran the first index should be the inner loop. You are indexing as `dist(i,j)` so your loops are in wrong order.

But because your `j` loop depends on the `i` loop value, you may have to switch the role of the indexes in your array (transpose it).

Some compilers are able to correct some simple loop ordering for you with high enough level of optimizations.

BTW the `-funroll-loops` is known to be often too aggressive and actually detrimental. Some limits usually should be set.