I’m no programmer, i didn’t work with fortran until now, as for C i have just a very basic idea. OpenACC i have no clue also.
But still i wanted to play a bit with openacc. I had a fractal example in C (or c++ i have no clue which one) that outputs a fractal in text. The program is multicore CPU. and it works.
I wanted to change it for openacc but it seems that complex type is not supported by pgi in c. Seems that fortran has no issues with it.
After trying and trying and trying and trying i changed the code a bit
so the code looks like this
program test integer,parameter :: width=100 ,height=100 integer :: maxiter complex :: center,span,begin character(len=99) :: char_a,char_b,char_c integer :: x,y,n,a,b complex :: c character (len=1) :: ch character (len = *), parameter::charset = ".,c8M@jawrpogOQEPGJ"; real :: temp integer::testare,line complex::temp3 integer::temp4 character(len=1),dimension(height,width)::lines character(len=height*width)::string center=(-0.7, 0) span=(2.7, -1*(4/3.0)*2.7*height/width) begin = center-span/2.0 maxiter = 100000 ch=" " !$acc parallel loop do line=0,height-1 do x=0,width-1 c = begin + CMPLX(x * span%re / (width +1), line * span%im / (height+1)) n=0 temp3=c temp4=0 testare=0 do n=0,maxiter-1 if (abs(temp3)>=2) then testare=1 else temp3=temp3*temp3+c end if if (testare==0) temp4=temp4+1 end do n=temp4 if (n == maxiter) n = 0 ch = " " if(n > 0) then lines(line+1,x+1)=charset(mod(n,len(charset))+1:mod(n,len(charset))+1) else ! lines(line+1,x+1)=ch <---give error lines(line+1,x+1)=" " end if end do end do !$acc end loop do line=1,height do x=1,width write(*,'(a,$)') lines(line,x) !<---give error end do print*,"|" end do end program test
the problem is that if i try to compile it as it is now i get Unsupported local variable error
If i comment the write line from last loop i can compile the code. and it seems it works. i have no clue if it does since i can’t see the result.
Compiling it without -acc the code works without problems.
It seems that lines(a,b) does not accept values from another variable and i can’t read values from it after the loop is done.
What am i doing wrong?
Is there any openacc guide for noobies?