Task 210: .F95 File Format
Task 210: .F95 File Format
The .F95 file format is the source code file for the Fortran 95 programming language. It is a text-based format containing code written in Fortran 95 syntax, with no binary structure or headers to decode. The specifications are defined in the ISO/IEC 1539-1:1997 standard for Fortran 95.
- List of all the properties of this file format intrinsic to its file system:
- File extension: .f95 (case-insensitive, but often lowercase).
- File type: Plain text.
- MIME type: text/x-fortran.
- Encoding: Typically ASCII or UTF-8.
- Source form: Free-form (preferred for .f95 to indicate modern Fortran).
- Line length: Up to 132 characters in free-form.
- Continuation lines: Up to 39 in free-form, 19 in fixed-form.
- Continuation character: Ampersand (&) at the end of the line.
- Comment character: Exclamation mark (!).
- Case insensitivity: Keywords and identifiers are case-insensitive.
- Format specifications can be repeated (e.g., for printing arrays).
- Supports allocatable arrays with automatic deallocation.
- Supports pointers and target attributes.
- Supports modules for encapsulation.
- Supports generic procedures and operator overloading.
- Supports pure and elemental procedures.
- Supports array operations and whole-array arithmetic.
- Supports enhanced argument passing (e.g., optional arguments, intent attributes).
- Supports dynamic memory allocation.
- Supports structured data types (derived types).
- Two direct download links for files of format .F95:
- https://www.fortrantutorial.com/downloads/bug.f95
- https://www.fortrantutorial.com/downloads/bugfixed.f95
- Ghost blog embedded HTML javascript for drag n drop .F95 file to dump properties to screen:
Drag and drop .F95 file here
- Python class for open, decode, read, write, and print properties:
class F95Handler:
def __init__(self):
self.properties = [
"File extension: .f95 (case-insensitive, but often lowercase).",
"File type: Plain text.",
"MIME type: text/x-fortran.",
"Encoding: Typically ASCII or UTF-8.",
"Source form: Free-form (preferred for .f95 to indicate modern Fortran).",
"Line length: Up to 132 characters in free-form.",
"Continuation lines: Up to 39 in free-form, 19 in fixed-form.",
"Continuation character: Ampersand (&) at the end of the line.",
"Comment character: Exclamation mark (!).",
"Case insensitivity: Keywords and identifiers are case-insensitive.",
"Format specifications can be repeated (e.g., for printing arrays).",
"Supports allocatable arrays with automatic deallocation.",
"Supports pointers and target attributes.",
"Supports modules for encapsulation.",
"Supports generic procedures and operator overloading.",
"Supports pure and elemental procedures.",
"Supports array operations and whole-array arithmetic.",
"Supports enhanced argument passing (e.g., optional arguments, intent attributes).",
"Supports dynamic memory allocation.",
"Supports structured data types (derived types)."
]
def open_and_print_properties(self, filepath):
try:
with open(filepath, 'r') as f:
content = f.read() # Read/decode as text
print("File opened and read successfully.")
print("F95 Properties:")
for prop in self.properties:
print(prop)
except FileNotFoundError:
print("File not found.")
except Exception as e:
print(f"Error: {e}")
def write_sample_file(self, filepath):
sample_content = """program sample
print *, "Hello from Fortran 95"
end program sample
"""
with open(filepath, 'w') as f:
f.write(sample_content)
print("Sample .F95 file written successfully.")
# Example usage:
# handler = F95Handler()
# handler.open_and_print_properties('example.f95')
# handler.write_sample_file('new.f95')
- Java class for open, decode, read, write, and print properties:
import java.io.*;
public class F95Handler {
private String[] properties = {
"File extension: .f95 (case-insensitive, but often lowercase).",
"File type: Plain text.",
"MIME type: text/x-fortran.",
"Encoding: Typically ASCII or UTF-8.",
"Source form: Free-form (preferred for .f95 to indicate modern Fortran).",
"Line length: Up to 132 characters in free-form.",
"Continuation lines: Up to 39 in free-form, 19 in fixed-form.",
"Continuation character: Ampersand (&) at the end of the line.",
"Comment character: Exclamation mark (!).",
"Case insensitivity: Keywords and identifiers are case-insensitive.",
"Format specifications can be repeated (e.g., for printing arrays).",
"Supports allocatable arrays with automatic deallocation.",
"Supports pointers and target attributes.",
"Supports modules for encapsulation.",
"Supports generic procedures and operator overloading.",
"Supports pure and elemental procedures.",
"Supports array operations and whole-array arithmetic.",
"Supports enhanced argument passing (e.g., optional arguments, intent attributes).",
"Supports dynamic memory allocation.",
"Supports structured data types (derived types)."
};
public void openAndPrintProperties(String filepath) {
try (BufferedReader br = new BufferedReader(new FileReader(filepath))) {
StringBuilder content = new StringBuilder();
String line;
while (line = br.readLine() != null) {
content.append(line).append("\n");
}
System.out.println("File opened and read successfully.");
System.out.println("F95 Properties:");
for (String prop : properties) {
System.out.println(prop);
}
} catch (FileNotFoundException e) {
System.out.println("File not found.");
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
public void writeSampleFile(String filepath) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(filepath))) {
bw.write("program sample\n");
bw.write("print *, \"Hello from Fortran 95\"\n");
bw.write("end program sample\n");
System.out.println("Sample .F95 file written successfully.");
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
// Example usage:
// public static void main(String[] args) {
// F95Handler handler = new F95Handler();
// handler.openAndPrintProperties("example.f95");
// handler.writeSampleFile("new.f95");
// }
}
- Javascript class for open, decode, read, write, and print properties:
class F95Handler {
constructor() {
this.properties = [
"File extension: .f95 (case-insensitive, but often lowercase).",
"File type: Plain text.",
"MIME type: text/x-fortran.",
"Encoding: Typically ASCII or UTF-8.",
"Source form: Free-form (preferred for .f95 to indicate modern Fortran).",
"Line length: Up to 132 characters in free-form.",
"Continuation lines: Up to 39 in free-form, 19 in fixed-form.",
"Continuation character: Ampersand (&) at the end of the line.",
"Comment character: Exclamation mark (!).",
"Case insensitivity: Keywords and identifiers are case-insensitive.",
"Format specifications can be repeated (e.g., for printing arrays).",
"Supports allocatable arrays with automatic deallocation.",
"Supports pointers and target attributes.",
"Supports modules for encapsulation.",
"Supports generic procedures and operator overloading.",
"Supports pure and elemental procedures.",
"Supports array operations and whole-array arithmetic.",
"Supports enhanced argument passing (e.g., optional arguments, intent attributes).",
"Supports dynamic memory allocation.",
"Supports structured data types (derived types)."
];
}
async openAndPrintProperties(filepath) {
// Note: In Node.js, require fs
const fs = require('fs');
try {
const content = fs.readFileSync(filepath, 'utf8'); // Read/decode as text
console.log('File opened and read successfully.');
console.log('F95 Properties:');
this.properties.forEach(prop => console.log(prop));
} catch (err) {
if (err.code === 'ENOENT') {
console.log('File not found.');
} else {
console.log(`Error: ${err.message}`);
}
}
}
writeSampleFile(filepath) {
const fs = require('fs');
const sampleContent = `program sample
print *, "Hello from Fortran 95"
end program sample
`;
try {
fs.writeFileSync(filepath, sampleContent, 'utf8');
console.log('Sample .F95 file written successfully.');
} catch (err) {
console.log(`Error: ${err.message}`);
}
}
}
// Example usage:
// const handler = new F95Handler();
// handler.openAndPrintProperties('example.f95');
// handler.writeSampleFile('new.f95');
- C class for open, decode, read, write, and print properties (using C++ for class support):
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
class F95Handler {
private:
std::vector<std::string> properties = {
"File extension: .f95 (case-insensitive, but often lowercase).",
"File type: Plain text.",
"MIME type: text/x-fortran.",
"Encoding: Typically ASCII or UTF-8.",
"Source form: Free-form (preferred for .f95 to indicate modern Fortran).",
"Line length: Up to 132 characters in free-form.",
"Continuation lines: Up to 39 in free-form, 19 in fixed-form.",
"Continuation character: Ampersand (&) at the end of the line.",
"Comment character: Exclamation mark (!).",
"Case insensitivity: Keywords and identifiers are case-insensitive.",
"Format specifications can be repeated (e.g., for printing arrays).",
"Supports allocatable arrays with automatic deallocation.",
"Supports pointers and target attributes.",
"Supports modules for encapsulation.",
"Supports generic procedures and operator overloading.",
"Supports pure and elemental procedures.",
"Supports array operations and whole-array arithmetic.",
"Supports enhanced argument passing (e.g., optional arguments, intent attributes).",
"Supports dynamic memory allocation.",
"Supports structured data types (derived types)."
};
public:
void openAndPrintProperties(const std::string& filepath) {
std::ifstream file(filepath);
if (!file) {
std::cout << "File not found." << std::endl;
return;
}
std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();
std::cout << "File opened and read successfully." << std::endl;
std::cout << "F95 Properties:" << std::endl;
for (const auto& prop : properties) {
std::cout << prop << std::endl;
}
}
void writeSampleFile(const std::string& filepath) {
std::ofstream file(filepath);
if (!file) {
std::cout << "Error opening file for writing." << std::endl;
return;
}
file << "program sample" << std::endl;
file << "print *, \"Hello from Fortran 95\"" << std::endl;
file << "end program sample" << std::endl;
file.close();
std::cout << "Sample .F95 file written successfully." << std::endl;
}
};
// Example usage:
// int main() {
// F95Handler handler;
// handler.openAndPrintProperties("example.f95");
// handler.writeSampleFile("new.f95");
// return 0;
// }