Task 209: .F90 File Format

Task 209: .F90 File Format

The .F90 file format refers to source code files written in the Fortran 90 programming language. It is a plain text format that adheres to the Fortran 90 standard (ISO/IEC 1539:1991), which specifies the language's syntax, including free-form source layout, module support, and other features introduced beyond FORTRAN 77. Files with this extension typically contain human-readable code and can be opened or edited with any text editor or Fortran compiler, with no binary structure or magic bytes required. The format supports up to 132 characters per line in free-form mode and uses '!' for comments.

  1. The properties of the .F90 file format intrinsic to its file system (e.g., metadata attributes stored by the operating system for the file) include:
  • File name
  • File size (in bytes)
  • Creation timestamp
  • Last modification timestamp
  • Last access timestamp
  • Permissions (e.g., read/write/execute modes, often in octal notation)
  • Owner user ID
  • Owner group ID
  • MIME type (typically text/x-fortran or text/plain)

Note that some properties (e.g., creation timestamp, owner/group) may vary by operating system and may not be fully accessible in all environments (e.g., browser-based JavaScript).

Two direct download links for .F90 files:

Here is the embedded HTML/JavaScript code for a Ghost blog (or any HTML page) that allows drag-and-drop of a .F90 file and dumps the properties to the screen. It uses the browser's File API and displays the available properties (limited by browser security; e.g., no owner/group or full permissions). Save this as an HTML file or embed in a blog post.

F90 File Properties Dumper
Drag and drop a .F90 file here
  1. Here is a Python class that can open a .F90 file, read its content (as plain text, no decoding needed beyond standard file I/O), write new content if desired, and print the properties to the console. It uses os.stat for file system metadata. Assumes the file exists and is accessible.
import os
import time
import stat

class F90File:
    def __init__(self, filepath):
        self.filepath = filepath
        self.stat_info = os.stat(filepath)
        self.content = self.read_content()

    def read_content(self):
        with open(self.filepath, 'r', encoding='utf-8') as f:
            return f.read()

    def write_content(self, new_content):
        with open(self.filepath, 'w', encoding='utf-8') as f:
            f.write(new_content)
        # Update stat after write
        self.stat_info = os.stat(self.filepath)

    def print_properties(self):
        print(f"File name: {os.path.basename(self.filepath)}")
        print(f"File size: {self.stat_info.st_size} bytes")
        print(f"Creation timestamp: {time.ctime(self.stat_info.st_ctime)}")  # On Windows: creation; on Unix: change time
        print(f"Last modification timestamp: {time.ctime(self.stat_info.st_mtime)}")
        print(f"Last access timestamp: {time.ctime(self.stat_info.st_atime)}")
        print(f"Permissions: {oct(self.stat_info.st_mode & 0o777)}")
        print(f"Owner user ID: {self.stat_info.st_uid}")
        print(f"Owner group ID: {self.stat_info.st_gid}")
        print("MIME type: text/x-fortran (assumed; not stored in file system)")

# Example usage:
# f = F90File('example.f90')
# f.print_properties()
# f.write_content('new content')
  1. Here is a Java class that can open a .F90 file, read its content (as plain text), write new content if desired, and print the properties to the console. It uses java.nio.file for metadata. Requires Java 8+.
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Date;

public class F90File {
    private final Path path;
    private BasicFileAttributes attrs;
    private String content;

    public F90File(String filepath) throws IOException {
        this.path = Paths.get(filepath);
        this.attrs = Files.readAttributes(path, BasicFileAttributes.class);
        this.content = readContent();
    }

    private String readContent() throws IOException {
        return new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
    }

    public void writeContent(String newContent) throws IOException {
        Files.write(path, newContent.getBytes(StandardCharsets.UTF_8));
        // Update attributes after write
        this.attrs = Files.readAttributes(path, BasicFileAttributes.class);
    }

    public void printProperties() throws IOException {
        System.out.println("File name: " + path.getFileName());
        System.out.println("File size: " + attrs.size() + " bytes");
        System.out.println("Creation timestamp: " + new Date(attrs.creationTime().toMillis()));
        System.out.println("Last modification timestamp: " + new Date(attrs.lastModifiedTime().toMillis()));
        System.out.println("Last access timestamp: " + new Date(attrs.lastAccessTime().toMillis()));
        try {
            PosixFileAttributes posixAttrs = Files.readAttributes(path, PosixFileAttributes.class);
            System.out.println("Permissions: " + PosixFilePermissions.toString(posixAttrs.permissions()));
            System.out.println("Owner: " + posixAttrs.owner().getName());
            System.out.println("Group: " + posixAttrs.group().getName());
        } catch (UnsupportedOperationException e) {
            System.out.println("Permissions/owner/group not supported on this OS (e.g., Windows)");
        }
        System.out.println("MIME type: text/x-fortran (assumed; use Files.probeContentType for runtime detection if needed)");
    }

    // Example usage:
    // public static void main(String[] args) throws IOException {
    //     F90File f = new F90File("example.f90");
    //     f.printProperties();
    //     f.writeContent("new content");
    // }
}
  1. Here is a JavaScript class (for Node.js) that can open a .F90 file, read its content (as plain text), write new content if desired, and print the properties to the console. It uses the fs module. Run with Node.js.
const fs = require('fs');
const path = require('path');

class F90File {
    constructor(filepath) {
        this.filepath = filepath;
        this.statInfo = fs.statSync(filepath);
        this.content = this.readContent();
    }

    readContent() {
        return fs.readFileSync(this.filepath, 'utf-8');
    }

    writeContent(newContent) {
        fs.writeFileSync(this.filepath, newContent, 'utf-8');
        // Update stat after write
        this.statInfo = fs.statSync(this.filepath);
    }

    printProperties() {
        console.log(`File name: ${path.basename(this.filepath)}`);
        console.log(`File size: ${this.statInfo.size} bytes`);
        console.log(`Creation timestamp: ${this.statInfo.birthtime}`);
        console.log(`Last modification timestamp: ${this.statInfo.mtime}`);
        console.log(`Last access timestamp: ${this.statInfo.atime}`);
        console.log(`Permissions: ${this.statInfo.mode.toString(8).slice(-3)}`);  // Octal last 3 digits
        console.log(`Owner user ID: ${this.statInfo.uid}`);
        console.log(`Owner group ID: ${this.statInfo.gid}`);
        console.log('MIME type: text/x-fortran (assumed; use mime-types module for detection if needed)');
    }
}

// Example usage:
// const f = new F90File('example.f90');
// f.printProperties();
// f.writeContent('new content');
  1. Here is a C++ class that can open a .F90 file, read its content (as plain text), write new content if desired, and print the properties to the console. It uses <sys/stat.h> for metadata and <fstream> for I/O. Compile with g++ or similar (e.g., assumes Unix-like system for full properties).
#include <iostream>
#include <fstream>
#include <string>
#include <sys/stat.h>
#include <ctime>
#include <unistd.h>  // For getuid, etc., if needed

class F90File {
private:
    std::string filepath;
    struct stat statInfo;
    std::string content;

public:
    F90File(const std::string& fp) : filepath(fp) {
        if (stat(filepath.c_str(), &statInfo) != 0) {
            throw std::runtime_error("Failed to get file stats");
        }
        content = readContent();
    }

    std::string readContent() {
        std::ifstream file(filepath);
        if (!file) {
            throw std::runtime_error("Failed to open file for reading");
        }
        return std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
    }

    void writeContent(const std::string& newContent) {
        std::ofstream file(filepath);
        if (!file) {
            throw std::runtime_error("Failed to open file for writing");
        }
        file << newContent;
        // Update stat after write
        if (stat(filepath.c_str(), &statInfo) != 0) {
            throw std::runtime_error("Failed to get updated file stats");
        }
    }

    void printProperties() {
        std::cout << "File name: " << filepath.substr(filepath.find_last_of("/\\") + 1) << std::endl;
        std::cout << "File size: " << statInfo.st_size << " bytes" << std::endl;
        std::cout << "Creation timestamp: " << std::ctime(&statInfo.st_ctime);  // On Unix: change time
        std::cout << "Last modification timestamp: " << std::ctime(&statInfo.st_mtime);
        std::cout << "Last access timestamp: " << std::ctime(&statInfo.st_atime);
        std::cout << "Permissions: " << std::oct << (statInfo.st_mode & 0777) << std::dec << std::endl;
        std::cout << "Owner user ID: " << statInfo.st_uid << std::endl;
        std::cout << "Owner group ID: " << statInfo.st_gid << std::endl;
        std::cout << "MIME type: text/x-fortran (assumed; no standard FS storage)" << std::endl;
    }
};

// Example usage:
// int main() {
//     try {
//         F90File f("example.f90");
//         f.printProperties();
//         f.writeContent("new content");
//     } catch (const std::exception& e) {
//         std::cerr << e.what() << std::endl;
//     }
//     return 0;
// }