PGI compiler extension function in Fortran

Hi,

I have found that there is some PGI compiler extension function to get the id of a gang/vector, like ‘omp_get_thread_num’ in openmp. This is __pgi_gangidx. I could find a example from:
https://stackoverflow.com/questions/48350062/how-can-i-find-the-id-of-a-gang-in-openacc

But what is the corresponding syntex in Fortran?
The reason I want to use it is that I need to make a allocatable array private to gang. I need to append a additional dimension to the array and create on device. It 's pretty similar to https://stackoverflow.com/questions/44029157/openacc-private-2d-array

Instead of making the addition dimension to the the number of trip count, I just want it to be number of gangs. Could some one help?
Thanks!

Hi wenscarl2017,

It’s the same syntax in Fortran. Just use the OpenACC module (i.e. “use openacc”) to get the interfaces.

Though instead of using a PGI extension, you may consider blocking the loop so that it’s two loops, a blocked outer loop corresponding to the gang size, and an inner loop to compute the elements within a block. It will make your code more portable.

Hope this helps,
Mat