C+ C NAME: C write_image_grd_p.f C PURPOSE: C Given the ASHI image location cfileo the image pixel parameters, its DSAA values, and the floating image (a itype 14 image) C or more normally the file provided (a type 15 file) with the icirx and iciry parameters, write out the image for use in Surfer C as an F9.2 file. C CATEGORY: C I/O C CALLING SEQUENCE: C call write_image_grd_hp(cfileo,icirx,iciry,cimghead,aimage) C INPUTS: C itype integer Type of file input and output C 14 = read in and write out a grd file with F9.2 floating values C 15 = input and write out a grd file with F9.2 floating values C cfileo character Name of the ASHI image grd output file C icirx integer Maximum number of image brightness values possible for x in the file (generally 2048) C icirx integer Maximum number of image brightness values possible for y in the file (sometimes 2048) C cimghead(5) character Grd file 5 line header C C OUTPUTS: C aimage(icir,icir) real Floating grd image C C FUNCTIONS/SUBROUTINES: C C MODIFICATION HISTORY: C October-2023, Bernard Jackson (UCSD) C- subroutine write_image_grd_hp(cfileo,icirx,iciry,aimage) parameter (ihead = 5) character cfilei*47 ! just in case a 10F9.2 input file to read in itype 14 character cfileo*55 character cimage1*9 character cimghead(ihead)*9 character cimghead2(ihead)*9 character cimagehd*9 real aimage(icirx,iciry) print*,' ' print*, 'Into write_image_grd_hp.f',icirx,iciry print*, 'cfileo is ',cfileo do I=1,icirx do J=1,iciry if(aimage(I,J).gt.10000.0.or.aimage(I,J).lt.-10000.0) aimage(I,J) = 0.0 ! Zero anything too big or too small end do end do distcx = float(icirx)/2.0 ! center of the image in X as determined by coordinate system distcy = float(iciry)/2.0 ! center of the image in Y as determined by coordinate system cimghead2(1) = 'DSAA' cimagehd =' ' write(cimagehd(1:4),'(I4)') icirx write(cimagehd(6:9),'(I4)') iciry cimghead2(2) = cimagehd cimagehd =' ' write(cimagehd(1:1),'(I1)') 0 write(cimagehd(3:6),'(I4)') icirx cimghead2(3) = cimagehd cimagehd =' ' write(cimagehd(1:1),'(I1)') 0 write(cimagehd(3:6),'(I4)') iciry cimghead2(4) = cimagehd cimghead2(5) = '-.05 .05 ' print*, cimghead2(1) print*, cimghead2(2) print*, cimghead2(3) print*, cimghead2(4) print*, cimghead2(5) itype = 15 if(itype.eq.14) then ! used only to read in the same file that is output. otherwise the file is available as input print*, cfileo cfilei = cfileo open (13, file=cfilei,status='old',recl=120,access='sequential',form='formatted',iostat=iReadashi) if(iReadashi.ne.0) then close(13) print *, 'There is no ',cfilei,' file in this subdirectory' stop end if do K=1,5 read (13,'(A)',iostat=iReadashi) cimage1 if(K.eq.1) then if(iReadashi.ne.0.or.cimage1.ne.'DSAA') then close(13) print*,'This is not a grd file - stop!' stop else cimghead2(K) = cimage1 end if else cimghead2(K) = cimage1 end if end do do J=1,iciry read (13,'(10F9.5)',iostat=iReadashi) (aimage(I,J),I=2,icirx) if(iReadashi.ne.0) then close(13) print *, 'This file is corrupt - stop' stop end if C write (*,'(10F8.1)') (aimage(I,J),I=1,NXY) end do close(13) C print*,' ' print*, 'File just read: ',cfilei end if if(itype.eq.15) then print*,' ' print*, 'write out the grd file just input' open (13, file=cfileo,status='new',recl=120,access='sequential',form='formatted',iostat=iReadashi) if(iReadashi.ne.0) then close(13) print*,'Could not open the ',cfileo,' file - stop!' stop end if do J=1,iciry if(J.eq.1) then do K=1,5 write(13,'(A)') cimghead2(K) end do end if if(itype.eq.15) then if(aimage(I,J).gt.99990.) aimage(I,J) = 99990. write(13,'(10F9.5)') (aimage(I,J),I=1,icirx) if(J.eq.iciry) then print*, cfileo,' was written with F9.5 floating values' end if end if end do else C print*,' ' print*, 'This was an output rather than a write of whatever file was input' end if C print*,' ' print*, 'Out of write_image_grd_hp.f' return end