-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdouble2single256.f
46 lines (34 loc) · 979 Bytes
/
double2single256.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
program double2single
c THIS PROGRAM CONVERTS DOUBLE TO SINGLE PRECISION
character *256 filein,fileout
double precision, allocatable:: x(:,:,:)
integer:: n,i,j,k
if(iargc().le.1) then
write(*,99)
99 format('usage: double2single <fin> <fout>')
goto 900
endif
call getarg(1,filein)
call getarg(2,fileout)
n=256
allocate (x(n,n,n))
c GET INPUT REAL DATA
open(unit=1,file=filein,form='unformatted')
read(1) n,n,n
read(1) (((x(i,j,k),k=1,n),j=1,n),i=1,n)
c close(1)
c do i=1,n
c do j=1,n
c do k=1,n
c if (x(i,j,k).gt.0.9) x(i,j,k)=1.0
c if (x(i,j,k).le.0.01) x(i,j,k)=0.0
c enddo
c enddo
c enddo
open(unit=52,file=fileout,form="unformatted",status="unknown")
write(52) n,n,n
write(52) (((real(x(i,j,k)),k=1,n),j=1,n),i=1,n)
close(52)
900 continue
stop
end