Skip to content

Commit

Permalink
Add cheatsheet and new subroutine/function commands. Sent in by jiho.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.textmate.org/trunk/Bundles/Fortran.tmbundle@8687 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
infininight committed Dec 18, 2007
1 parent 9d1050b commit 69a6947
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Commands/Format Cheat Sheet.tmCommand
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Fortran Format Cheat Sheet"
Markdown.pl "$TM_BUNDLE_SUPPORT/format_syntax.md"
html_footer</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^H</string>
<key>name</key>
<string>Format Cheat Sheet</string>
<key>output</key>
<string>showAsHTML</string>
<key>scope</key>
<string>source.fortran</string>
<key>uuid</key>
<string>46575B73-BDD7-4905-BFCB-2B1C9AA4673D</string>
</dict>
</plist>
28 changes: 28 additions & 0 deletions Commands/Function based on current word.tmCommand
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>echo "function $TM_CURRENT_WORD(\$1)"
echo " \$2, intent(\${3:inout}) :: \$1"
echo " \$4 :: $TM_CURRENT_WORD"
echo " \$0"
echo "end function $TM_CURRENT_WORD"</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>$</string>
<key>name</key>
<string>Function based on current word</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.fortran</string>
<key>uuid</key>
<string>0D6DE4E4-53AF-44E4-B8B8-D4F36FF96F77</string>
</dict>
</plist>
Expand Down
27 changes: 27 additions & 0 deletions Commands/Subroutine based on current word.tmCommand
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>echo "subroutine $TM_CURRENT_WORD(\$1)"
echo " \$2, intent(\${3:inout}) :: \$1"
echo " \$0"
echo "end subroutine $TM_CURRENT_WORD"</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>$</string>
<key>name</key>
<string>Subroutine based on current word</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.fortran</string>
<key>uuid</key>
<string>8806B464-11D1-419E-B883-3727F144FCC5</string>
</dict>
</plist>
Expand Down
83 changes: 83 additions & 0 deletions Support/format_syntax.md
@@ -0,0 +1,83 @@
The `'fmt='` specifier in a `read` or `write` statement can give either the line number of a `format` statement, an actual format string or a `*`, for free format.

# Syntax

A format specifier is a parenthesized string of format descriptors.

<table class="pro_table">
<tr>
<th>Descriptor</th>
<th>Meaning</th>
</tr>

<tr>
<td>I<em>n</em></td>
<td><em>n</em> positions of integer data</td>
</tr>

<tr>
<td>F<em>n</em>.d</td>
<td><em>n</em> positions of real data (with d decimal places) &mdash; Decimal point form</td>
</tr>

<tr>
<td>E<em>n</em>.d</td>
<td><em>n</em> positions of real data (with d decimal places) &mdash; Exponent form</td>
</tr>

<tr>
<td>L<em>n</em></td>
<td><em>n</em> positions of logical data</td>
</tr>

<tr>
<td>A[<em>n</em>]</td>
<td>[<em>n</em> positions of] character data</td>
</tr>

<tr>
<td><em>n</em>X</td>
<td>skip <em>n</em> horizontal positions (X spaces)</td>
</tr>

<tr>
<td>\</td>
<td>skip line</td>
</tr>

<tr>
<td>T<em>c</em></td>
<td>tab to column number <em>c</em></td>
</tr>

</table>

Descriptors, or groups of descriptors, can be repeated by prefixing, or parenthesizing and prefixing, with the number of repeats. For example `I4` can be repeated as `2I4` and `I4,1X` as `2(I4,1X)`.

Plain text strings can be inserted in the format string using double quotes (or two single quotes).

When the variable cannot be printed entirely given the format specified, it is displayed as placeholders (`'*'` usually)

# Examples

NB: &#x2423; is a space

write(*,'(i6,i2)') 3, 2

&#x2423;&#x2423;&#x2423;&#x2423;&#x2423;3&#x2423;2

write(*,'(f10.4,e15.7)') 12.7864, 234.4591

&#x2423;&#x2423;&#x2423;12.7864&#x2423;&#x2423;0.2344591E+03


write(*,'(2x,"record Nº",i2," is ",A6)') 10, 'Philip'

&#x2423;&#x2423;record&#x2423;Nº10&#x2423;is&#x2423;Philip


write(*,'(2X,2(I4,1X),''name '',A4,F13.5,1X,E13.5)') 77778, 3, 'ABCDEFGHI', 14.45, 15.5666666

&#x2423;&#x2423;\*\*\*\*&#x2423;&#x2423;&#x2423;&#x2423;3&#x2423;name&#x2423;ABCD&#x2423;&#x2423;&#x2423;&#x2423;&#x2423;14.45000&#x2423;&#x2423;&#x2423;0.15567E+02


0 comments on commit 69a6947

Please sign in to comment.