Guest User

Untitled

a guest
May 27th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. program test
  2.  
  3. character(len=255) format
  4.  
  5. 1 format(9i4)
  6.  
  7. c FORMATTED
  8. open(99,file='form1.txt',form='formatted')
  9. do i=1,1
  10. write(99,1) 1, 2, 3, 4, 5, 6, 7, 8, 9
  11. enddo
  12. close(99)
  13.  
  14. c UNFORMATTED
  15. open(98,file='form2.txt',form='unformatted')
  16. do i=1,1
  17. write(98) 1, 2, 3, 4, 5, 6, 7, 8, 9
  18. enddo
  19. close(98)
  20.  
  21. c DIRECT ACCESS
  22. nrec=sizeof(i)*9
  23. open(97,file='form3.txt',form='unformatted',
  24. & access='direct',recl=nrec)
  25. do i=1,1
  26. write(97,rec=i) 1, 2, 3, 4, 5, 6, 7, 8, 9
  27. enddo
  28. close(97)
  29.  
  30. call system('ls -lh form?.txt')
  31. end
  32.  
  33. -rw-r--r--. 1 user users 37 May 27 17:10 form1.txt
  34. -rw-r--r--. 1 user users 44 May 27 17:10 form2.txt
  35. -rw-r--r--. 1 user users 36 May 27 17:10 form3.txt
  36.  
  37. $ xxd form1.txt
  38. 0000000: 2020 2031 2020 2032 2020 2033 2020 2034 1 2 3 4
  39. 0000010: 2020 2035 2020 2036 2020 2037 2020 2038 5 6 7 8
  40. 0000020: 2020 2039 0a 9.
  41.  
  42. $ xxd form2.txt
  43. 0000000: 2400 0000 0100 0000 0200 0000 0300 0000 $...............
  44. 0000010: 0400 0000 0500 0000 0600 0000 0700 0000 ................
  45. 0000020: 0800 0000 0900 0000 2400 0000 ........$...
  46.  
  47. $ xxd form3.txt
  48. 0000000: 0100 0000 0200 0000 0300 0000 0400 0000 ................
  49. 0000010: 0500 0000 0600 0000 0700 0000 0800 0000 ................
  50. 0000020: 0900 0000 ....
Add Comment
Please, Sign In to add comment