This tag should be used for questions related to the Fortran products from NAG: the Fortran compiler (nagfor); the debugger; NAG Fortran builder; and the mathematical and statistical library. Questions about the Fortran language should also include the more general Fortran tag.
Questions tagged [nag-fortran]
15 questions
3
votes
1 answer
Memory leak in the assignment using Intel Fortran compiler
Consider the following minimal working example:
module lib
type FG_t
real,allocatable::g(:)
contains
procedure,private::FG_Assign
generic::assignment(=)=>FG_Assign
end type
interface operator(-)
…

V T
- 103
- 7
3
votes
1 answer
Conflict between defined assignment and intrinsic assignment (with nagfor)?
Intrinsic polymorphic assignment is a recent feature of some Fortran compilers (e.g. ifort 18, nagfor 6.2) that is not available in older versions (e.g. ifort 17, gfortran 6.3). A well-known solution that works with these older versions is to use a…

R. Hassani
- 155
- 8
3
votes
1 answer
User-defined errors with nagfor preprocessor
I'm trying to abort compilation if an unsupported fortran compiler is used. The nagfor preprocessor defines the macro NAGFOR, so I wrote the following test program:
program foo
implicit none
#ifdef NAGFOR
PRINT *, "Hello from…

John
- 207
- 1
- 7
2
votes
1 answer
Relative include paths of different Fortran preprocessors
Consider the following directory tree:
test.F90
test/
├─ a.inc
└─ b.inc
With the following file contents:
test.F90:
#include "test/a.inc"
end
a.inc:
#if defined(__GFORTRAN__) | defined(__PGI) | defined(__NVCOMPILER)
# include "b.inc"
#else
# …

V T
- 103
- 7
2
votes
1 answer
Bound checking for empty arrays --- behavior of various compilers
Update 20210914: Absoft support confirms that the behavior of af95 / af90 described below is unintended and indeed a bug. Absoft developers will work to resolve it. The other compilers act correctly in this regard. Thank @Vladimir F for the answer,…

Nuno
- 256
- 1
- 11
2
votes
1 answer
Link to NAG library with -lnag
I'm trying to compile my first program which uses the NAG library, the following:
program naginfo
use nag_f77_a_chapter
implicit none
write(*,*) 'Calling NAG identification routine'
write(*,*)
call a00aaf
end program…

Pak Fent L'indkio
- 25
- 2
2
votes
1 answer
How to list predefined preprocessor variables with nagfor
I'd like to get a list of the preprocessor variables that are predefined when using the nagfor Fortran compiler. The equivalent with gfortran is
gfortran -E -dM foo.F90
but with
nagfor -F -Wp,-dM foo.F90
I get
NAG Fortran Compiler Release…

John
- 207
- 1
- 7
2
votes
1 answer
Function returns different answers with same arguments
I'm transitioning from MATLAB to Fortran and encountering all sorts of weird behaviors I'd never expect from MATLAB. Here's one that's got me puzzled:
Program pruebanormal
double precision :: g01eaf, x, y
character :: T*1
integer ::…

DrG
- 151
- 1
- 7
1
vote
0 answers
What is the first version of gfortran / ifort / nagfor / g95 that supports ieee_arithmetic?
I would like to decide whether ieee_arithmetic is supported by the Fortran compiler being used. I suppose this can be done, for example, in the preprocessing by checking some macros. To do this, I would like to know the following.
What is the first…

Nuno
- 256
- 1
- 11
1
vote
2 answers
How to handle an optional group in a Fortran Namelist
I am working with a code originally written in Fortran 77 that makes use of namelists (supported by compiler extension at the time of its writing - this feature only became standard in Fortran 90) for reading input files. The namelist input files…

jbdv
- 1,263
- 1
- 11
- 18
1
vote
1 answer
Complications With Elemental Subroutines in Fortran
The Question
Are there any complications when marking a subroutine as elemental? This page seems to suggest so, but doesn't elaborate what they might be.
Note: I am tagging multiple fortran versions because I want to know if there are differences…

jvriesem
- 1,859
- 3
- 18
- 40
1
vote
1 answer
Procedure pointer returned from a function with nagfor
I try to use procedure pointers as a return of a function in Fortran. The following minimal code works with gfortran (tested with 4.8.1) but not with nagfor (NAG 6.0):
function foo() result(f_p)
implicit none
procedure(), pointer :: f_p
f_p =>…

Jonas Lindert
- 13
- 2
1
vote
0 answers
Mex Fortran with nagfor, only calls functions
I am trying something that is not supported.
I want to use the NAG Fortran compiler (release 5.3.1) to mex a Fortran file.
Using the command:
nagfor -ideclient -abi=64 -compatible -fpp -I"C:\Program Files\MATLAB\R2013b\extern\include" -Wl,-shared…

Hugo
- 159
- 2
- 11
0
votes
1 answer
Confusing type checking report by NAG Fortran
Consider the following Fortran code:
program kinds_demo
use iso_fortran_env, only: REAL64, INT32
integer(int32), parameter :: n=10
real(real64) :: A(n, n)
complex(real64) :: B(n, n)
real(real64) :: tr, u(n*n), v(n*n)
a=1.0D0
…

yarchik
- 336
- 1
- 8
0
votes
1 answer
"Uninitialised value was created by a stack allocation" with NAG fortran 6.2
I'm getting a very strange behavior with the latest release of the NAG Fortran Compiler Release 6.2(Chiyoda) Build 6214. When using ifort or gfortran is everything ok, and even with NAG Fortran Compiler Release 6.1(Tozai) Build 6136. The following…

Rodrigo Carvalho
- 21
- 2