Working Out a Few Details

Here, at the dusk of 2011, Evil Quark Labs returns in yet another Dr. Who-esque incarnation. This maiden post exists only to confirm that programming language syntax highlighting is indeed operational. If anyone is interested, the plugin that allowed such formatting is called wp-syntax and is based on GeSHi.

The program itself is a test I wrote to familiarize myself with writing binary files inĀ FORTRAN.

     program BinaryWriter
 
      implicit none
 
      integer sizeofint
      integer :: ii, jj, num
      integer :: mat(5,5)
      parameter (sizeofint=4)
 
      num = 5
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C     Currently set up for direct (random) access.
C     Divides dest. file into records of size recl.
C     For direct access must specify which record
C      for each write statement.
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      open(unit=10,
     +     file='bin_mat.bin',
     +     access='direct',
     +     form='UNFORMATTED',
     +     recl=num*num*sizeofint)
 
      do ii = 1, num
       do jj = 1, num
         mat(ii,jj) = ii+jj
       enddo
      enddo
 
      write(10,rec=1) mat
 
      close(10)
      end program BinaryWriter
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

2 Responses to Working Out a Few Details

  1. mr.x says:

    what’s the difference between declaring int as “integer sizeofint” and “integer :: ii, jj, num”? does :: do anything??

    • Kyle says:

      In Fortran 77, variables are declared along the lines of “integer sizeofint”. In Fortran 90 variables are declared along the lines of “integer :: ii,jj,num”. Long story short: ifort accepts either, and I was lazy and not coding uniformly.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">