Skip to content. Skip to navigation

ICTP Portal

Sections
You are here: Home Manuals on-line PGI Compiler pghpf_ug PGHPF Compiler User's Guide - 9 Modules
Personal tools
Document Actions

PGHPF Compiler User's Guide - 9 Modules

<< << " border=0> >> > " border=0> Title Contents Index Home Help

9 Modules


This chapter covers the PGHPF implementation of Fortran 90 modules.The PGHPF compiler supports Fortran 90 modules. Modules can be independently compiled and used within programs using the USE statement. Use of Fortran 90 modules causes the compiler to create a filename.mod file in the current directory ( a .mod file). This file contains all the information the compiler needs concerning interface specifications and the data types for the routines defined in the module. When a program, routine, or another module encounters the USE statement, the .mod file is read and "included" in the program, using the scope rules defined in Fortran 90 for USE association. If you are using separate modules, this creates another step in the program development process. When a module is compiled, both a .mod and a .o file are created. The .mod file is used when a USE statement is encountered, and the .o file is used when the program is loaded.

For example, if module1.hpf contains a module with several procedures, and test1.hpf contains a USE statement that uses module1, the compilation would involve the steps.


% pghpf -c module1.hpf
% pghpf -otest1 test1.hpf module1.o

The search for a .mod file includes the following directories:

1. Each -I directory specified on the command-line.

2. The directory containing the file that contains the USE statement
(the current working directory.)

3. The standard include area.

Using the -I command-line option directories can be added to the search path for .mod files.

9.1 Modules with Generic Interfaces

The 2.0 and newer versions of PGHPF support modules with generic procedures. For example, the following is a valid module which defines FUNC_ANY taking either a real or an integer argument.



MODULE A

INTERFACE FUNC_ANY
MODULE PROCEDURE FUNC1
MODULE PROCEDURE FUNC2
END INTERFACE

CONTAINS
FUNCTION FUNC1(R)
INTEGER R
END FUNCTION
FUNCTION FUNC2(R)
REAL R
END FUNCTION
END MODULE A
PROGRAM B
USE A
X = FUNC_ANY(1) ! func1
Y = FUNC_ANY(1.0) ! func2
END

9.2 LIB3F Procedures

An include file is sent with the PGHPF distribution. This include file is named lib3f.h. Using the lib3f.h include file, programs can call standard 3F routines available on many platforms (refer to section 7.4 for more information). The statement:


INCLUDE "lib3f.h"

is required when using 3F procedures.

 


<< << " border=0> >> > " border=0> Title Contents Index Home Help

Powered by Plone This site conforms to the following standards: