ccm_info

CCM information

Routine:

ccm_info

Purpose:

Return information about the CCM package.

Minumal calling sequence:

call ccm_info()

Required Arguments:

NONE

Call with all Optional Arguments:

call ccm_info(my_id,num_procs,n_types,sizes,kinds,names,the_err)
my_id :: integer, intent (out).
A unique number for each task in a parallel application, 0 to numprocs-1
num_procs :: integer, intent (out).
Number to the tasks in a parallel application.
n_types :: integer, intent (out).
Number of data types supported by the implementation of the CCM package.
sizes :: integer rank one array of size(n_types), intent (out).
An array holding the number of bytes used for each data type.
kinds :: integer rank one array of size(n_types), intent (out).
An array holding the Fortran 90 kind associated with each data type.
names :: character (len=20) rank one array of size(n_types), intent (out).
An array holding of strings that describe the data types.
the_error :: integer, intent (out).
Error code 0 - success, != 0 failure.
See Specifying Optional Arguments for the syntax for using optional arguments.

Notes:

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.

First Example:


program ccm_info_x1
    use ccm
    integer :: my_id,num_procs
    call ccm_init()
    call ccm_info(my_id,num_procs)
    write(*,fmt="(""hello from "",i6,"" of "",i6)") my_id,num_procs
    call ccm_close()
end program

Example output on 4 processors


[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.



Second Example:


program ccm_info_x2
    use ccm
    integer, parameter:: b8 = selected_real_kind(14)
    real(b8) :: x
    real :: y
    double precision :: z
    integer,allocatable :: my_kinds(:),my_sizes(:)
    integer :: ntypes,i
    character(len=20),allocatable:: my_names(:)
    call ccm_init(myid)
    call ccm_info(n_types=ntypes)
    allocate(my_sizes(ntypes),my_kinds(ntypes),my_names(ntypes))
    call ccm_info(my_id=myid,num_procs=numprocs,&
                  n_types=ntypes,&
                  sizes=my_sizes,&
                  kinds=my_kinds,&
                  names=my_names)
! actual values for kinds are specific to a machine type and are not portable
    do i=1,ntypes
      if(myid .eq. 0)write(*,*)" type = ",my_names(i),"  size= ",my_sizes(i),"kind = ",my_kinds(i)
    enddo
    if(myid .eq. 0)then
      write(*,*)"    default real has kind ",kind(y), " on this machine"
      write(*,*)"double precision has kind ",kind(z), " on this machine"
    endif
    call ccm_close()
end program

Example output on 4 processors


[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.

Error conditions:


Back to API and user's guide