|
Home /
Products /
Software Developer Tools /
NAGWare f95 Compiler / FAQs
NAGWare f95 Compiler FAQ
Questions
- What does the warning "TAB format input" mean? [answer]
- What does the warning message "Byte count on numeric data type" mean? [answer]
- What does "Buffer overflow on output" mean? [answer]
- Why is the error message "KIND value does not specify a valid representation method" appearing (other compilers do not have this problem)? [answer]
- Which C compiler do I need? [answer]
- Is there a SYSTEM function? [answer]
- Is NAGWare f95 binary compatible with another vendor's f77? [answer]
- How do I link my f95-compiled program with an f77-compiled library? [answer]
- How do I link my f77-compiled main program with an f95-compiled library? [answer]
- Does NAGWare f95 support MPICH? [answer]
- NAGWare f95 rejects my legacy F77 code, what should I do? [answer]
- How can I use CDABS, DCMPLX, DCONJG, DIMAG and DREAL? [answer]
- How can I use the DTIME and ETIME functions? [answer]
- My colleague cannot run my f95-compiled program because the executable requires the NAGWare f95 shareable library which is not installed on his machine? [answer]
- How can I change f95's default options? [answer]
- What level of optimisation should I use for best performance? [answer]
- Does the f95 compiler support 128-bit REALs? [answer]
- When doing mixed-language programming, what are the functions f90_init() and f90_io_finish()? [answer]
Answers
- What does the warning "TAB format input" mean? [Top]
TAB format is an extension to Fortran 77, and operates when TAB characters are found in fixed form source files. This is used, for example, to skip over the label field in fixed source format code. Because it is an extension, a warning message is produced. This format is a bit complicated, and not recommended for new programs (use free form source instead).
- What does the warning message "Byte count on numeric data type" mean? [Top]
This is an extension to Fortran 77 that has become obsolete with Fortran 90. The numeric data type is followed by an asterisk and the number of bytes indicating the size of the data type.
Instead of specifying the number of bytes, Fortran 90 has KINDs of each datatype, and intrinsic functions for choosing a kind based on the desired properties (SELECTED_INT_KIND and SELECTED_REAL_KIND). NAGWare f95 also provides a module, F90_KIND, which has named constants for convenient kind selection. The equivalence between byte sizes and kinds using these names is as follows.
INTEGER*1 |
Integer(int8) |
INTEGER*2 |
Integer(int16) |
INTEGER*4 |
Integer(int32) |
INTEGER*8 |
Integer(int64) |
REAL*4 |
Real(real32) |
REAL*8 |
Real(real64) |
COMPLEX*8 |
Complex(real32) |
COMPLEX*16 |
Complex(real64) |
The kind of an integer or real constant is specified by appending an underscore and the kind value (or name); e.g. 120_int8 is an 8-bit integer constant, and 3.14159265358979323846264_real64 is a 64-bit real value.
- What does "Buffer overflow on output" mean? [Top]
This means that your program attempted a formatted write, in a single record, with more bytes than will fit into the file buffer for that unit.
The default buffer size for formatted i/o is 1024 characters.
To increase the buffer size you can use the RECL= keyword in the OPEN statement for the file you wish to write. For example:
OPEN(13,FILE="myfile",FORM="formatted",RECL=2048)
will establish a buffer size of 2048 bytes on unit 13.
-
Why is the error message "KIND value does not specify a valid representation method" appearing (other compilers do not have this problem)? [Top]
The numbering of KINDs depends on the compiler. There are at least two obvious methods: sequential (1 to N, where N is the number of kinds) and byte (use the number of bytes for integer and real). NAGWare f95 (and some other compilers) by default uses sequential kind numbering, so single and double precision real are REAL(1) and REAL(2), not REAL(4) and REAL(8). The disadvantage of the "byte" scheme is that the COMPLEX setting is the number of bytes for each part, i.e. half the total, which can be confusing.
The option -kind=sequential specifies the default sequential scheme and -kind=byte may be used for alternative byte scheme.
-
Which C compiler do we need? [Top]
Most of the NAGWare f95 ports use the C compiler which is supplied with the machine that it is used on. On Linux and the Mac this is gcc.
On Sun (SPARC) Solaris, either the Sun C Compiler or the GNU C Compiler may be used. You must specify which C compiler you have when you purchase NAGWare f95 (the implementations are different).
On Windows the relevant C compiler (MinGW gcc) is bundled with NAGWare f95.
- Is there a SYSTEM function? [Top]
Yes. The NAGWare f95 Compiler has a number of built-in modules to provide
access to a large number of Posix system calls. In order to access these,
the appropriate module must be USEd. The SYSTEM routine is in the
F90_UNIX_PROC module. The following is a very simple example of how to
use SYSTEM.
program sys
use f90_unix_proc
call system('pwd')
end program sys
-
Is NAGWare f95 binary compatible with another vendor's f77? [Top]
NAGWare f95 has limited binary compatibility with these Fortran 77 compilers:
- HP f77 (only when -f77 option used)
- IBM xlf (only when -f77 option used)
- Sun f77
- g77 on FreeBSD and Linux (the -f77 option must be used if any procedure names contain underscores)
Limitations:
- Functions returning COMPLEX values are not binary compatible unless the -f77 option is used when compiling with f95.
- I/O to a single logical unit should be done entirely within f95 or entirely within f77; since they have different i/o libraries and i/o buffers things will get very confused if you try to read from or write to the same file from both languages at once.
- With HP and IBM, f77 routines with names matching C language keywords or library functions are not visible from NAGWare f95 and vice versa.
-
How do I link my f95-compiled program with an f77-compiled library? [Top]
You need to mention the runtime support libraries used by the f77 compiler on the command line used for linking.
Commonly, this means something like:
f95 myprog.o myf77lib.a -lU77 -lI77 -lF77
One can usually discover which libraries are necessary by using the (vendor-specific) option to f77 which displays the linking command.
- How do I link my f77-compiled main program with an f95-compiled library? [Top]
You need to specify the NAGWare f95 runtime library on the f77 command used for linking, for example:
f77 /usr/local/lib/nagware/quickfit.o myf77prog.o myf90lib.a \
/usr/local/lib/nagware/libf98.a -lm
- Does NAGWare f95 support MPICH? [Top]
MPICH 1.2.6 has full support for NAGWare f95. Make sure NAGWare f95 is
accessible via your PATH environment variable and run "configure"
with the "--with-f95nag" option, e.g.
./configure -prefix=/usr/local/mpich-1.2.6 --with-f95nag
-
NAGWare f95 rejects my legacy F77 code, what should I do? [Top]
The NAGWare f95 Compiler carries out a strict check for conformance to the Fortran 95 standard and also carries out a large number of checks for obviously incorrect code. While this is the correct behaviour for a compiler when new code is being developed, it is sometimes necessary to reduce the stringency of error checking to allow older code written
to lower standards to compile. There are a number of compiler options to compile such legacy code.
-dusty
Downgrades a number of common errors found in legacy code to
warnings. Hence compilation can continue and also these warnings can
be turned off by -w. This option implies -mismatch_all.
-mismatch
Downgrades errors resulting from mismatch in argument lists to
warnings. Calls to routines in the same file must still be correct.
-mismatch_all
As -mismatch but even incorrect calls to routines in the
same file are accepted.
-
How can I use CDABS, DCMPLX, DCONJG, DIMAG and DREAL? [Top]
These are not standard Fortran 95 intrinsic functions, but a large number of compilers support this. In order to remain standard conforming NAGWare f95 only provides access to these functions, if the -dcfuns option is specified. We recommend that these functions be converted to standard Fortran using the following table.
CDABS(A) |
ABS(A) |
DCMPLX(X,Y) |
CMPLX(X,Y,KIND=KIND(0d0)) |
DCONJG(Z) |
CONJG(Z) |
DIMAG(Z) |
AIMAG(Z) |
DREAL(Z) |
REAL(Z) or DBLE(Z) |
-
How can I use the DTIME and ETIME functions? [Top]
These functions are not standard Fortran 95. We recommend use of the
standard Fortran intrinsic subroutines CPU_TIME and SYSTEM_CLOCK. Two
versions of each function are provided below, one in standard Fortran
(and thus will work on any Fortran 95 compiler), the other uses the
NAGWare f95 interface to Posix. Simply add the chosen version of
the function to your code.
! DTIME in standard Fortran
real function dtime(time)
real time(2)
double precision,save :: last_time = 0
double precision this_time
intrinsic cpu_time
call cpu_time(this_time)
time(1) = this_time - last_time
time(2) = 0
dtime = time(1)
last_time = this_time
end
! DTIME via NAGWare f95 Posix
real function dtime(time)
use f90_unix_env,only:tms,times
real time(2)
type(tms),save :: lastbuf
logical :: start = .true.
type(tms) buffer
integer junk
junk = times(buffer)
if (start) then
lastbuf%utime = 0
lastbuf%stime = 0
start = .false.
end if
time(1) = buffer%utime - lastbuf%utime
time(2) = buffer%stime - lastbuf%stime
dtime = time(1) + time(2)
lastbuf = buffer
end
! ETIME in standard Fortran
real function etime(time)
real time(2)
call cpu_time(etime)
time(1) = etime
time(2) = 0
end
! ETIME via NAGWare f95 Posix
real function etime(time)
use f90_unix_env,only:tms,times
real time(2)
type(tms) buffer
integer junk
junk = times(buffer)
time(1) = buffer%utime
time(2) = buffer%stime
etime = buffer%utime + buffer%stime
end
-
My colleague cannot run my f95-compiled program because the executable requires the NAGWare f95 shareable library which is not installed on his machine? [Top]
The default is to link to the shareable run time library
(i.e. -Bdynamic). The -Bstatic
option (not available on all systems) will link all libraries
statically resulting in a large executable. In most circumstances the
-unsharedf95 option is the solution, linking only the
NAGWare f95 run time library statically. Other libraries including
the C run time library will be linked dynamically resulting in a
smaller executable.
-
How can I change f95's default options? [Top]
If you installed f95 to the default place: /usr/local/bin or /opt/NAGWare/bin
- Check that f95 is an executable program. Move f95 from
/usr/local/bin to /usr/local/lib/NAGWare (on most systems) or
/opt/NAGWare/bin to /opt/NAGWare/lib (on Suns).
- Replace /usr/local/bin/f95 or /opt/NAGWare/bin/f95 by the
appropriate one of the following scripts.
Most systems
#!/bin/sh
/usr/local/lib/NAGWare/f95 -Qpath /usr/local/lib/NAGWare "$@"
Suns
#!/bin/sh
/opt/NAGWare/lib/f95 -Qpath /opt/NAGWare/lib "$@"
You can add any default options to this script, e.g to change the default C compiler to /export/compilers/bin/cc insert the following option into the script
"-Wc=/export/compilers/bin/cc"
just before '"$@"'.
If you did not install f95 to the default place simply add the new default options to the f95 script created by INSTALL in the bin directory.
-
What level of optimisation should I use for best performance? [Top]
Please see the separate Performance Tips page for advice.
-
Does the f95 compiler support 128-bit REALs? [Top]
128-bit REALs (Quadruple Precision) are available for:
- Sun SPARC Solaris, product code NPSOL51NA
At present, this is the only system which supports this. We hope to introduce this feature on more platforms soon.
-
When doing mixed-language programming, what are the functions f90_init() and f90_io_finish()? [Top]
These functions are needed when the main program is in C instead of Fortran. The f90_init function initialises the Fortran environment, including the floating-point status, command-line arguments, and i/o subsystem. The f90_io_finish function writes the contents of all the Fortran output buffers to their files, and closes all the Fortran files. The following example shows how to use these functions.
int main(int argc,char *argv[])
{
f90_init( argc, argv );
/* At this point Fortran routines can be safely called. */
f90_io_finish();
return 0;
}
|