program FITSsave implicit none integer :: status, bitpix, naxis, naxes(2) ! status ... FITS status (0=no error) ! naxis .. number of axes in the image (we set =2) ! naxes .. dimensions of the image (2-element array) real, dimension(:,:), allocatable :: d ! data matrix character(len=666) :: name = 'image.fits' ! name .. fill with name of the image to create ! aux real :: x,y,r integer :: i,j ! set dimensions of the new image naxis = 2 naxes = (/ 100,100 /) ! set bitpix of the image (try: 8,16,32 and -32) bitpix = -32 ! create a data storage (allocate memory) for the image allocate(d(naxes(1),naxes(2))) ! fill image with values do i = 1, naxes(1) do j = 1, naxes(2) ! rectangular coordinates ! the left bottom pixel has 1,1 x = i y = j ! distance from origin r = sqrt(x**2 + y**2) ! set value d(i,j) = cos(r/5.0) !d(i,j) = besj0(r/5.0) ! uncomment for J0 (Bessel function of zero kind) ! J0 represents diffraction on cylindrical aperture end do end do ! save the data status = 0 call ftinit(26,name,1,status) call ftphps(26,bitpix,naxis,naxes,status) call ftp2de(26,1,naxes(1),naxes(1),naxes(2),d,status) call ftclos(26,status) ! free allocated memory deallocate(d) end program FITSsave