Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

PXFGETGROUPS

POSIX Subroutine: Gets supplementary group IDs. This routine is only available for Linux and macOS.

Module

USE IFPOSIX

CALL PXFGETGROUPS (igidsetsize,igrouplist,ngroups,ierror)

igidsetsize

(Input) INTEGER(4). The number of elements in the igrouplist array.

igrouplist

(Output) INTEGER(4). The array that has the returned supplementary group IDs.

ngroups

(Output) INTEGER(4). The total number of supplementary group IDs for the process.

ierror

(Output) INTEGER(4). The error status.

If successful, ierror is set to zero; otherwise, an error code.

The PXFGETGROUPS subroutine returns, up to size igidsetsize, the supplementary group IDs in array igrouplist. It is unspecified whether the effective group ID of the calling process is included in the returned list. If the size is zero, the list is not modified, but the total number of supplementary group IDs for the process is returned.

Example


program test5
  use ifposix
  implicit none
  integer(4) number_of_groups, ierror, isize,i, igid
  integer(4),allocatable,dimension(:):: igrouplist
  integer(JHANDLE_SIZE) jgroup

  ! Get total number of groups in system
  ! call PXFGETGROUPS with 0
  call PXFGETGROUPS(0, igrouplist, number_of_groups, ierror)
  if(ierror.NE.0) STOP 'Error: first call of PXFGETGROUPS fails'
  print *," The number of groups in system ", number_of_groups

  ! Get Group IDs
  isize = number_of_groups
  ALLOCATE( igrouplist(isize))
  call PXFGETGROUPS(isize, igrouplist, number_of_groups, ierror)
  if(ierror.NE.0) then
     DEALLOCATE(igrouplist)
     STOP 'Error: first call of PXFGETGROUPS fails'
  end if

  print *," Create an instance for structure 'group' "
  call PXFSTRUCTCREATE("group",jgroup, ierror)
  if(ierror.NE.0) then
     DEALLOCATE(igrouplist)
     STOP 'Error: PXFSTRUCTCREATE failed to create an instance of group'
  end if

  do i=1,  number_of_groups
     call PXFGETGRGID( igrouplist(i), jgroup, ierror)
     if(ierror.NE.0) then
       DEALLOCATE(igrouplist)
       call PXFSTRUCTFREE(jgroup, ierror)
       print *,'Error: PXFGETGRGID failed for i=',i," gid=", igrouplist(i)
       STOP 'Abnormal termination'
     end if
     call PRINT_GROUP_INFO(jgroup)
  end do
   
  call PXFGETGID(igid,ierror)
  if(ierror.NE.0) then
     DEALLOCATE(igrouplist)
     call PXFSTRUCTFREE(jgroup, ierror)
     print *,'Error: PXFGETGID failed'
     STOP 'Abnormal termination'
  end if 
  call PXFGETGRGID( igid, jgroup, ierror)
  if(ierror.NE.0) then
     DEALLOCATE(igrouplist)
     call PXFSTRUCTFREE(jgroup, ierror)
     print *,"Error: PXFGETGRGID failed for  gid=", igid
     STOP 'Abnormal termination'
  end if

  call PRINT_GROUP_INFO(jgroup)
  DEALLOCATE(igrouplist) 
  call PXFSTRUCTFREE(jgroup, ierror)
  print *," Program will normal terminated"
  call PXFEXIT(0)
end