I'm trying to compile my first program which uses the NAG library, the following:
write(*,*) 'Calling NAG identification routine'
end program naginfo
f95 -o naginfo naginfo.f90 -lnag
Fatal Error: Can't open module file ‘nag_f77_a_chapter.mod’ for reading at (1): The directory does not exist
This is just a long explanation of the francescalus's comment.
-lnag only adds the library code to the already compiled program when linking all compiled pieces together. It has no effect during compilation and hence no effect on the error message you see.
The compiler must see the information about the NAG library modules. That is usually stored in module files with the
.mod extension. Compilers normally only search for these in the current directory or in the system's include directories.
You can instruct the compiler to search in a different directory by using a special compiler flag. that may differ between different compilers, but is typically
-I followed by the directory where the library stores its
Be adviced that the
.mod files in the library are only compatible with the same compiler that was used to create them by the library vendor.