With no acc routine info when calling subroutines from other fortran files

Hello,

I’m new to openacc and currently suffering this issue and I cannot make it.

A part of code is here, where i_simu_innerloop and mac_em2 are two subroutines defined from other source files.
!$acc loop private(k)
DO k=1,ngen,1
CALL i_simu_innerloop(k,S_Steps,flagF1)
CALL mac_em2(k,S_Steps)
mac_ang(k,S_Steps+1)=mac_ang(k,S_Steps)+&
h_sol1dmac_ang(k,S_Steps)
mac_spd(k,S_Steps+1)=mac_spd(k,S_Steps)+&
h_sol1
dmac_spd(k,S_Steps)
!IF (k==1) THEN
! PRINT *,I_Steps,S_Steps,&
! mac_ang(k,S_Steps+1),mac_spd(k,S_Steps+1)
!ENDIF
edprime(k,S_Steps+1)=edprime(k,S_Steps)
eqprime(k,S_Steps+1)=eqprime(k,S_Steps)
CALL mac_em1(k,S_Steps+1)
END DO

So the compiler gave me errors like this:
PGF90-S-0155-Procedures called in a compute region must have acc routine information: i_simu_innerloop (main.f: 285)
PGF90-S-0155-Procedures called in a compute region must have acc routine information: i_simu_innerloop (main.f: 268)
PGF90-S-0155-Procedures called in a compute region must have acc routine information: mac_em1 (main.f: 258)
222, Accelerator region ignored
258, Accelerator restriction: call to ‘mac_em1’ with no acc routine information
268, Accelerator restriction: call to ‘i_simu_innerloop’ with no acc routine information
285, Accelerator restriction: call to ‘i_simu_innerloop’ with no acc routine information
0 inform, 0 warnings, 4 severes, 0 fatal for main
make: *** [main.o] Error 2

If anyone can help with it.

Hi dacongi,

You’ll want to use the OpenACC “routine” directive so the compiler can create device callable versions of these routines.

If you’re using F77 style calling conventions, you’ll need to add the directive twice. Once in the definition of the subroutine so the compiler knows to create the device version, and once in the caller routine so the compiler knows that there exists a device routine.

Something like:

subroutine i_simu_innerloop(k,S_Steps,flagF1)
!$acc routine seq
... variable declaration ...
... body of the routine ...
end subroutine i_simu_innerloop

subroutine mac_em2(k,S_Steps)
!$acc routine seq
... variable declaration ...
... body of the routine ...
end subroutine mac_em2

In the caller:

subroutine foo (...)
 ... variable declaration ...
!$acc routine(i_simu_innerloop) seq
!$acc routine(mac_em2) seq
... body of subroutine ...
!$acc loop private(k)
DO k=1,ngen,1
CALL i_simu_innerloop(k,S_Steps,flagF1)
CALL mac_em2(k,S_Steps)
...

If these subroutines are in and interface, you don’t need the named routine in “foo”, but add the “routine” directive in the interface (as well as the definition)

If these subroutines are in a module, then you only need to add “routine” to the definition.

Hope this helps,
Mat

Hi Mkcolg,

Thank you for your reply, it did work however my program still has some troubles to be figured out.

Thank you so much for the info.