Ccm_info can be used to obtain the process id (0-num_procs) for each process and the total number of processes in an application num_procs. Also, it can obtain information about the data types supported by the package. Ccm_info returns: the number of data types supported, the number of bytes used for each type, a text description of the types and a Fortran 90 kind for the types. Kind is the value returned by the Fortran 90 intrinsic KIND function.
Fortran kind values are opaque. Kinds should only be used internally to a program. A particular value for a kind on one machine might not imply the same data type on another machine. In particular, the following is NOT a portable way to get an eight byte real:
REAL(8) :: x
The portable way to get a real with a particular precision is to specify the required precision with the selected_real_kind function call as shown below:
integer, parameter:: b8 = selected_real_kind(14) REAL(b8) :: x
This provides a real type with 14 digits of precision.
So of what use are the kind values returned from this routine? First, all datum types in the module are defined in terms of kinds returned from selected_real_kind. Kinds can be compared. You can use this to determine if the module supports a real type with a particular precision.
For example....
integer, parameter:: b8 = selected_real_kind(14) real(b8) :: x ... ... call ccm_info(my_id=myid,num_procs=numprocs, & n_types=ntypes, & sizes=my_sizes, & kinds=my_kinds, & names=my_names) do i=1,ntypes if(my_kinds(i) .eq. b8 .and. scan(my_names(i),"real") .ne. 0)then write(*,*)my_names(i)," uses ",my_sizes(i)," bytes" endif enddo"
Will print the "name" of the type if there is a match. The second example given below is an expansion on this snippet.
|
[ccm_home:~/ccm/source] % ccm_info_x1
hello from 0 of 4
hello from 1 of 4
hello from 2 of 4
hello from 3 of 4
[ccm_home:~/ccm/source] %
The call to ccm_init initializes the communication package. The program gets the id and total number of tasks from ccm_info and prints the values. The call to ccm_close closes the communication package. |
|
[ccm_home:~/ccm/source] % ccm_info_x1
type = real short size= 4 kind = 4
type = real long size= 8 kind = 8
type = complex short size= 8 kind = 4
type = complex long size= 16 kind = 8
type = integer default size= 4 kind = 4
type = logical default size= 4 kind = 4
type = character default size= 4 kind = 1
default real has kind 4 on this machine
double precision has kind 8 on this machine
[ccm_home:~/ccm/source] %
The call to ccm_init initializes the communication package. The program calls ccm_info to find out the number of data types supported by the package. This value is used to allocate the arrays to hold the additional information. Ccm_init is called again to fill the arrays. The information is then printed. For a comparison, the kind for the default real and double precision is printed. The call to ccm_close closes the communication package. |