1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | integer(8) j integer(4) i(2) integer(2) h(4) integer(1) k(8) equivalence (j, i), (j, h), (j, k) j = z'0001020304050607' print 1, 'j = ', j print 2, 'i = ', i print 4, 'h = ', h print 8, 'k = ', k 1 format(A, "z'", z16.16, "'") 2 format(A, 2("z'", z8.8, "'", 1x)) 4 format(A, 4("z'", z4.4, "'", 1x)) 8 format(A, 8("z'", z2.2, "'", 1x)) end |
1 2 3 4 | j = z'0001020304050607' i = z'00010203' z'04050607' h = z'0001' z'0203' z'0405' z'0607' k = z'00' z'01' z'02' z'03' z'04' z'05' z'06' z'07' |
1 2 3 4 | j = z'0001020304050607' i = z'04050607' z'00010203' h = z'0607' z'0405' z'0203' z'0001' k = z'07' z'06' z'05' z'04' z'03' z'02' z'01' z'00' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | subroutine sub1 integer(8) j common /blk/ j j = z'0001020304050607' print 1, 'sub1:', j 1 format(A, "z'", z16.16, "'") end subroutine subroutine sub2 integer(4) i(2) common /blk/ i print 2, 'sub2:', i 2 format(A, 2("z'", z8.8, "'", 1x)) end subroutine program main call sub1 call sub2 end program |
1 2 | sub1: z'0001020304050607' sub2: z'00010203' z'04050607' |
1 2 | sub1: z'0001020304050607' sub2: z'04050607' z'00010203' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | function f(a) double precision a, f real g entry g(a) f = a end function program main interface function f(a) double precision a, f end function function g(a) double precision a real g end function end interface double precision x x = z'0001020304050607' print '(z16.16)', f(x) print '(z8.8)', g(x) end program |
1 2 | 0001020304050607 00010203 |
1 2 | 0001020304050607 04050607 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | program main integer :: i = 1 character(5) :: c = 'abcd' integer(2) :: h = 2 real(8) :: d = 1.0 call hexprint(i, 4) call hexprint(c, 5) call hexprint(h, 2) call hexprint(d, 8) end program subroutine hexprint(buffer, size) character(8) buffer integer size print 100, buffer(1:size) 100 format (z<2 * size>.<2 * size>) end subroutine |
1 2 3 4 | 00000001 6162636420 0002 3FF0000000000000 |
1 2 3 4 | 01000000 6162636420 0200 000000000000F03F |
1 2 3 4 5 6 | character(4) file integer(4) a a = z'61626364' write(file, '(A)') a print *, file end |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |