Interestingly, the code compiles on a Unix machine with the intel compiler. But it does not work on a windows machine (Cygwin) and the GNU compiler. The function I am calling is basically a link to a function in a library written in C. Could it be that the problem is in the compilation of this external library? Are there any special things one should remember when using gfortran and linking to external (C/C++) libraries. Or when compiling these libraries?