Dear Monks, I am an aeronautical engineer (structural) and I use a finite element analysis software called PATRAN/NASTRAN. After every analysis this software generates result files (text) with ".f06" extention. These files can be very large and many depending on the model that is being analysed.

When this software is used to analyse composite elements, it creates results for FAILURE INDICES, and prints results for each element and each ply.

I was using a perl program that was opening these files (280 MB) each and processing the files and extracting the information that I wanted in about an hour. The files were about 1.6 GB in size. Then someone found this FORTRAN program that does the same thing in about ten minutes.

I just can not understand what it is doing so differently that it does the job much faster than my perl program does.

my code is something like this:
open file while(<FH>){ extract info, print, } close FH;
and here is an example section from one one of the .f06 files:
11150505 STRAIN 1 1.0088 -12 + 0.0369 1 + MARCH 10, 2003 MSC.NASTRAN 5/15/00 PAGE 8077 2011-ULTIMATE,_UP_BM,_-55,_MINP + 0 + SUBCOM 2011 F A I L U R E I N D I C E S F O R L A Y E R E D C O +M P O S I T E E L E M E N T S ( Q U A D 4 ) ELEMENT FAILURE PLY FP=FAILURE INDEX FOR PLY FB=FAILURE IN +DEX FOR BONDING FAILURE INDEX FOR ELEMENT FLAG ID THEORY ID (DIRECT STRESSES/STRAINS) (INTER-LAMIN +AR STRESSES) MAX OF FP,FB FOR ALL PLIES 2 0.0000 -2 + 0.0630 3 0.9486 -12 + 0.0914 4 0.0000 -2 + 0.1108 5 0.0172 -1 + 0.1108 6 0.0000 -2 + 0.0914 7 0.5449 -12 + 0.0630 8 0.0000 -2 + 0.0369 9 0.4847 -12 + 1.0088 *** 11150506 STRAIN 1 0.4050 -12 + 0.0339 2 0.0000 -2 + 0.0577 3 0.4086 -12 + 0.0831 4 0.4104 -12 + 0.1043 5 0.0000 -12 + 0.1179 6 0.4140 -12 + 0.1306 7 0.0000 -12 + 0.1374 8 0.0000 -12 + 0.1408 9 0.4195 -12 + 0.1408 10 0.0000 -12 + 0.1374 11 0.0000 -12 + 0.1306 12 0.4249 -12 + 0.1179 13 0.0000 -12 + 0.1043 14 0.4285 -12 + 0.0831 15 0.4303 -12 + 0.0577 16 0.0000 -12 + 0.0339 17 0.4340 -12 + 0.4340 1 + MARCH 10, 2003 MSC.NASTRAN 5/15/00 PAGE 8078 2011-ULTIMATE,_UP_BM,_-55,_MINP + 0 + SUBCOM 2011 F A I L U R E I N D I C E S F O R L A Y E R E D C O +M P O S I T E E L E M E N T S ( Q U A D 4 ) ELEMENT FAILURE PLY FP=FAILURE INDEX FOR PLY FB=FAILURE IN +DEX FOR BONDING FAILURE INDEX FOR ELEMENT FLAG ID THEORY ID (DIRECT STRESSES/STRAINS) (INTER-LAMIN +AR STRESSES) MAX OF FP,FB FOR ALL PLIES 11150507 STRAIN 1 0.2949 -12 + 0.0455 2 0.0001 -12 + 0.0792 3 0.3250 -12 + 0.1133 4 0.3400 -12 + 0.1418 5 0.0000 -12 + 0.1610 6 0.3701 -12 + 0.1781 7 0.0000 -12 + 0.1877 8 0.0000 -12 + 0.1925 9 0.4152 -12 + 0.1925 10 0.0000 -2 + 0.1877 11 0.0000 -2 + 0.1781 12 0.4603 -12 + 0.1610 13 0.0000 -12 + 0.1418 14 0.4903 -12 + 0.1133 15 0.5054 -12 + 0.0792 16 0.0000 -12 + 0.0455 17 0.5354 -12 + 0.5354 11150508 STRAIN 1 0.2814 -2 + 0.0564 2 0.0001 -12 + 0.0981 3 0.2392 -2 + 0.1404 4 0.2181 -2 + 0.1757 5 0.0000 -12 + 0.1995 6 0.1759 -2 + 0.2207 7 0.0000 -12 + 0.2326 8 0.0000 -12 + 0.2386 1 + MARCH 10, 2003 MSC.NASTRAN 5/15/00 PAGE 8079 2011-ULTIMATE,_UP_BM,_-55,_MINP

20030524 Edit by Corion: Added READMORE tag


In reply to Fast reading and processing from a text file - Perl vs. FORTRAN by ozgurp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.