Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Reading in an ASCII file written by a FORTRAN program

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97517] Reading in an ASCII file written by a FORTRAN program
  • From: hayes.tyler at gmail.com
  • Date: Sat, 14 Mar 2009 18:13:04 -0500 (EST)

Hello All:

I didn't want to hijack another's thread about reading in fixed format
files into Mathematica and I  was wondering if there is a way to read
FORTRAN written data.

For my thesis used FORTRAN code for my number
crunching, and used function calls to DISLIN to visualize that data.
Now I have Mathematica, whose graphics capabilities are well beyond
anything I could previously do, I would like to recreate and improve
those graphs. The way I created the files of data (which I always used
a .d extension, but it doesn't matter what that would be called) is
demonstrated below. Please note, this is NOT binary data, but text
output with no FORMAT. For example:

My FORTRAN code writes out:

      open(unit=30,name=fnout,status='old')

      write(30,'(a20)') fnmod
      write(30,'(a20)') fnstr
      write(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu,
     & tminn,tstepp,itime,TBIS,bulkms,ntm,ncycle,pdcy
      write(30,*) ptrad
      write(30,'(a1)') respfb
      write(30,*) (timi(n), n=1,nfault)
      write(30,*) (taub(n), n=1,nfault)
      write(30,*) (delts(n), n=1,nf)
      write(30,*) (cfr(n), n=1,nfault)
      write(30,*) (dfr(n), n=1,nfault)
      write(30,*) (slpdf(n), n=1,nf2)
      write(30,*) (slpv(n), n=1,nfault)
      write(30,*) (rhofcc(n), n=1,nfault)
      write(30,*) (islip(n), n=1,nfault)

(NOTE: not all variables are the same length, some are strings, some
doubles, etc.)

I subsequently read back the data into FORTRAN as:

      open(unit=30,name=fnin,status='old')

      read(30,'(a20)') fnmod
      read(30,'(a20)') fnstr
      read(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu,
     & tminn,tstepp,ntime,TBIS,bulkms,ntm,ncycle,pdcy
      read(30,*) ptrad
      read(30,'(a1)') respfb
      read(30,*) (timi(n), n=1,nfault)
      read(30,*) (taub(n), n=1,nfault)
      read(30,*) (delts(n), n=1,nf)
      read(30,*) (cfr(n), n=1,nfault)
      read(30,*) (dfr(n), n=1,nfault)
      read(30,*) (slpdf(n), n=1,nf2)
      read(30,*) (slpv(n), n=1,nfault)
      read(30,*) (rhofcc(n), n=1,nfault)
      read(30,*) (islip(n), n=1,nfault)

So, the big question then is: How would I go about reading in the
above unformatted Fortran file within Mathematica?

Thanks for any advice you may have.

Cheers,

t.


  • Prev by Date: Re: Comparing Corresponding Columns of Two Matrices
  • Next by Date: Re: Re: Return Ambiguity
  • Previous by thread: Re: Re: Weird NMinimize behaviour
  • Next by thread: Re: Reading in an ASCII file written by a FORTRAN program