ccm_unique

CCM unique name generation

Routine:

ccm_unique

Purpose:

Initialize the CCM package.

Minumal calling sequence:

call ccm_unique(name)

Required Arguments:

name :: character(len >= 10), intent (out)
A unique name for each task in a parallel application.

Call with all Optional Arguments:

call ccm_unique(name,base)
base :: character(len *), intent (in)
A base for the unique name. len(name) >= len(base)+6
See Specifying Optional Arguments for the syntax for using optional arguments.

Notes:

Ccm_unique provides a unique name based on on task id. The default name is "out_" with the task id appended. The default name can be changed by specifing a base for the name. The output name can be used as a file name. The example below shows how to generate a name based on the time of running and task id.

First Example:


program ccm_unique_x1
    use ccm
    implicit none
    integer :: myid
    character (len=20) :: my_name,new_name
    character (len=9) :: date_str
    integer :: value(8)
    call ccm_init(myid)
    call ccm_unique(my_name)
    write(*,*)"the default name for ",myid," is ",my_name
    open(20,file=my_name)
    write(20,*)"the default name for ",myid," is ",my_name
    call date_and_time(values=value)
    call ccm_bcast(value)
!                               month    day      hour     minute
    write(date_str,"(4i2.2,a1)")value(2),value(3),value(5),value(6),'.'
    call ccm_unique(new_name,date_str)
    write(*,*)"name based on date for ",myid," is ",new_name
    call ccm_close()
end program

Example output on 4 processors


[ccm_home:~/ccm/source] % ccm_init_x1
 the default name for   0  is out_00000           
 name based on date for   0  is 05141544.00000      
 the default name for   2  is out_00002           
 name based on date for   2  is 05141544.00002      
 the default name for   1  is out_00001           
 name based on date for   1  is 05141544.00001      
 the default name for   3  is out_00003           
 name based on date for   3  is 05141544.00003      
 
      
[ccm_home:~/ccm/source] % cat out_*
 the default name for   0  is out_00000           
 the default name for   1  is out_00001           
 the default name for   2  is out_00002           
 the default name for   3  is out_00003           
[ccm_home:~/ccm/source] % 

The call to ccm_init initializes the communication package. The default name for the each task is obtained by calling ccm_unique. A file is created with this name and the written to. Next the date is obtained using date_and_time. The values are broadcast so that all tasks have the same date. The month, day, hour, and minute values are written to a string, date_str. Date_str is used to generate a name based on time and task id. The new name is printed. The call to ccm_close closes the communication package.

Error conditions:

NONE

Back to API and user's guide