Differences

This shows you the differences between two versions of the page.

sep:software:ratfor90 [2008/07/22 20:02]
altheyab
sep:software:ratfor90 [2015/05/27 02:06] (current)
Line 1: Line 1:
====== Ratfor90 ====== ====== Ratfor90 ======
-You can download ratfor90 from {{:sep:software:ratfor90.tar.gz| here}}. +  * You can download ratfor90 from {{:sep:software:ratfor90.tar.gz| here}}.
-==== Introduction/Description ====+
 +\\
 +==== Introduction/Description ====
** "Ratfor" ** is a dialect of Fortran that is more concise than raw Fortran. The newest Ratfor "compiler",  ratfor90  is a simple preprocesor program written in Perl that inputs an attractive Fortran-like dialect and outputs Fortran90. Mainly, the preprocessor produces Fortran statements like " end do ", "end if", "end program", and "end module", from the Ratfor "}". Ratfor source is about 25-30% smaller than the equivalent Fortran making it equivalently more readable. ** "Ratfor" ** is a dialect of Fortran that is more concise than raw Fortran. The newest Ratfor "compiler",  ratfor90  is a simple preprocesor program written in Perl that inputs an attractive Fortran-like dialect and outputs Fortran90. Mainly, the preprocessor produces Fortran statements like " end do ", "end if", "end program", and "end module", from the Ratfor "}". Ratfor source is about 25-30% smaller than the equivalent Fortran making it equivalently more readable.
Line 15: Line 16:
Indentation in Ratfor is used for readability. It is not part of the Ratfor language. Choose your own style. There are two **pitfall**s associated with indentation. The beginner's pitfall is to assume that a "do" loop ends where the indentation ends. The loop actually ends after the first statement. A larger scope for the "do" loop is made by enclosing multiple statements in braces. The other pitfall arises in any construction like "if() ... if() ... else". The "else" goes with the last "if()" regardless of indentation. If you want the "else" with the earlier "if()", you must use braces like "if() { if() ... } else ...". Indentation in Ratfor is used for readability. It is not part of the Ratfor language. Choose your own style. There are two **pitfall**s associated with indentation. The beginner's pitfall is to assume that a "do" loop ends where the indentation ends. The loop actually ends after the first statement. A larger scope for the "do" loop is made by enclosing multiple statements in braces. The other pitfall arises in any construction like "if() ... if() ... else". The "else" goes with the last "if()" regardless of indentation. If you want the "else" with the earlier "if()", you must use braces like "if() { if() ... } else ...".
-==== Changes and general backward compatibility issues ==== 
 +\\
 +==== Changes and general backward compatibility issues ====
There are two rarely used features of Ratfor77 that were not implemented in Ratfor90. " break 2 " which escapes from { {   } }. This feature can easily be replaced by the loop naming features supported in Fortran90. Ratfor77 allows & and | for the logical operators && and ||. While attractive, it is not part of the C family of languages and we had to drop it because Fortran90 adopts & for line continuation. There are two rarely used features of Ratfor77 that were not implemented in Ratfor90. " break 2 " which escapes from { {   } }. This feature can easily be replaced by the loop naming features supported in Fortran90. Ratfor77 allows & and | for the logical operators && and ||. While attractive, it is not part of the C family of languages and we had to drop it because Fortran90 adopts & for line continuation.
Line 23: Line 25:
In Ratfor90 bracketed "type, subroutine, function," and "module procedures" are interpreted. In some ways this a further step towards the C, C++, Java model. It makes complicated modules, subroutines inside subroutines, and other advanced features of Fortran90 easier to interpret. Ratfor90 recognizes "a+=b" as "a=a+b" and the similar construct "-=". Ratfor90 has better error messages than Ratfor77. Besides using stderr, a new file ("ratfor_problem") marks the difficulty. In addition, the output of Ratfor90 is much more [[#Sample Output| readable]] than the Ratfor77 version. In Ratfor90 bracketed "type, subroutine, function," and "module procedures" are interpreted. In some ways this a further step towards the C, C++, Java model. It makes complicated modules, subroutines inside subroutines, and other advanced features of Fortran90 easier to interpret. Ratfor90 recognizes "a+=b" as "a=a+b" and the similar construct "-=". Ratfor90 has better error messages than Ratfor77. Besides using stderr, a new file ("ratfor_problem") marks the difficulty. In addition, the output of Ratfor90 is much more [[#Sample Output| readable]] than the Ratfor77 version.
 +\\
==== SEP-specific backward compatibility issues ==== ==== SEP-specific backward compatibility issues ====
SEP has a considerable amount of legacy Ratfor77 code which used two home-grown preprocessors to get around Fortran77's memory allocation problems. Ratfor90 allows the conventions established by these preprocessors, interpreting them into standard Fortran90. SEP has a considerable amount of legacy Ratfor77 code which used two home-grown preprocessors to get around Fortran77's memory allocation problems. Ratfor90 allows the conventions established by these preprocessors, interpreting them into standard Fortran90.
 +
=== Memory allocation in subroutines === === Memory allocation in subroutines ===
Line 37: Line 41:
" real*4 data(n1,n2,n3), convolution(j+k-1)". " real*4 data(n1,n2,n3), convolution(j+k-1)".
 +\\
==== Examples ==== ==== Examples ====
Below are two simple Ratfor subroutines for finding the signum function sgn(x) = |x| ("signum()"), and ("tcaf") a fortran90 module that uses overloading to transient convolution. \\ Below are two simple Ratfor subroutines for finding the signum function sgn(x) = |x| ("signum()"), and ("tcaf") a fortran90 module that uses overloading to transient convolution. \\
-=== Math funcion === 
-\\+=== Math funcion ===
=== Transient convolution === === Transient convolution ===
 +
=== The main program environment === === The main program environment ===
"Ratfor90" supports some traditional SEP local memory allocation and data base I/O statements. In addition it calls an essential seplib initialization routine " initpar()", organizes the self-doc, and simplifies data-cube input. The basic syntax for memory allocation is "allocate: real x(n1,n2)". "Ratfor90" translates this syntax into a call to dynamically allocate a "allocatable" array. See the on-line self-documentation or the manual pages for full details. Following is a complete Ratfor program for a simple task: "Ratfor90" supports some traditional SEP local memory allocation and data base I/O statements. In addition it calls an essential seplib initialization routine " initpar()", organizes the self-doc, and simplifies data-cube input. The basic syntax for memory allocation is "allocate: real x(n1,n2)". "Ratfor90" translates this syntax into a call to dynamically allocate a "allocatable" array. See the on-line self-documentation or the manual pages for full details. Following is a complete Ratfor program for a simple task:
 +<code fortran90>
  #  out.H   #  out.H
  #   #
Line 72: Line 77:
  call srite( 'out', x, 4*n1*n2)   call srite( 'out', x, 4*n1*n2)
  return;        end   return;        end
 +</code>
 +\\
==== Downloading/Installing ==== ==== Downloading/Installing ====
Line 90: Line 97:
These rules are an updated version of the SEP makefile rules so if you have downloaded a previous version you will still need to download this version. These rules are an updated version of the SEP makefile rules so if you have downloaded a previous version you will still need to download this version.
 +\\
==== Sample Output ==== ==== Sample Output ====
Here is a Ratfor90 code that serves no useful purpose other than demonstrating a number of the features of ratfor Here is a Ratfor90 code that serves no useful purpose other than demonstrating a number of the features of ratfor
 +<code fortran90>
  #   #
  #   #
Line 170: Line 178:
    write(0,*) input     write(0,*) input
  end program   end program
 +</code>
----- +\\
====  References  ==== ====  References  ====
Claerbout, J., 1990, Introduction to "seplib" and SEP utility software: **SEP-70**, 413-436. \\  Claerbout, J., 1986, A canonical program library: **SEP-50**, 281-290. \\  Cole, S., and Dellinger, J., Vplot: SEP's plot language: **SEP-60**, 349-389. \\ \\ Claerbout, J., 1990, Introduction to "seplib" and SEP utility software: **SEP-70**, 413-436. \\  Claerbout, J., 1986, A canonical program library: **SEP-50**, 281-290. \\  Cole, S., and Dellinger, J., Vplot: SEP's plot language: **SEP-60**, 349-389. \\ \\
-{{page>sep:footer}}+\\ \\ 
 +{{page>share:footer&nofooter&noeditbtn}} 
/web/html/data/attic/sep/software/ratfor90.1216756959.txt.gz · Last modified: 2015/05/26 22:41 (external edit)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0