Cuda Fortran Input/output (I/O)

Hi guys, i’m a new user in Cuda Fortran.
Im now trying to read 100 files which contain 500 x 360 data and rewrite the data in another 100 files.

Can some1 show me the way to open and read external file(which contain 500x360) using cuda fortran and gpu??

i have trouble on this because there are no example on cuda fortran I/O in the book and the code below is in FORTRAN. Thx

program test
implicit none
real,dimension(500,360)::A
integer i,j,h,unit_for_input, unit_for_output
character*255 rawdata, newdata !file name

do h=1,100 !open from file 1 to file 100
do i=1,500 ! 500 rows of data
do j=1,360 ! 360 column of data

unit_for_input=h+100
unit_for_output = i+1000

write(rawdata,10) h !varies my file name
10 format(‘rawdata’,i2,’.csv’)
open (unit=unit_for_input, file=rawdata, action=‘read’, status=‘old’)
read(unit_for_input ,*) A(i,j) !read from the input file

write(newdata,20) h !varies my output file name
20 format(‘newdata’,i2,’.csv’)
open (unit=unit_for_output, file=Time , action=‘write’, status=‘unknown’,recl=10000)
write(unit_for_output ,*) A(i,j)

end do
end do
end do

end program test

Hi LHW,

You can’t perform file I/O from device code. You’ll need to read the files from host code and then transfer the data to the device.

  • Mat

Thx Mat. This means i cant utilize GPU in this situation. So i think i’ll just use CPU only instead of both.

Regards
LHW