https://github.com/codemeapixel/speed-converter
A modern Fortran project using Gfortran and/or FPM to convert between km/h and mph.
https://github.com/codemeapixel/speed-converter
Last synced: 24 days ago
JSON representation
A modern Fortran project using Gfortran and/or FPM to convert between km/h and mph.
- Host: GitHub
- URL: https://github.com/codemeapixel/speed-converter
- Owner: CodeMeAPixel
- License: mit
- Created: 2025-08-08T00:35:08.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2025-08-08T03:01:40.000Z (7 months ago)
- Last Synced: 2025-12-09T23:52:53.599Z (3 months ago)
- Language: Fortran
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Speed Converter
A **modern Fortran** project using **FPM (Fortran Package Manager)** to convert between **km/h** and **mph**.
> [!NOTE]
> This project was created as my introduction to Fortran.
> Itβs a small but complete example that uses **modern Fortran features**, modular design, and unit testing.
---
## β¨ Features
- π Convert from **km/h β mph** and **mph β km/h**
- π₯ Interactive **command-line interface**
- π§ͺ Comprehensive **unit tests** for accuracy
- π¦ Structured for **FPM** (Fortran Package Manager)
- β
Written with **explicit interfaces** and `implicit none`
---
## π Prerequisites
- **gfortran** (GNU Fortran compiler)
- **FPM** (*FPM build/run support is in progress β see below for manual build steps*)
---
## π Building and Running
> [!CAUTION]
> FPM support is being worked on.
> For now, please build manually with **gfortran**.
### Build and Run (Manual)
```bash
# Build the conversion module
gfortran -c src/convert.f90 -J build
# Build the main application
gfortran -c app/main.f90 -I build
gfortran -o speed-converter convert.o main.o
# Run the application
./speed-converter
```
### Build and Run Tests (Manual)
```bash
# Build tests
gfortran -c test/test_convert.f90 -I build
gfortran -o test_runner convert.o test_convert.o
# Run tests
./test_runner
```
### FPM Commands (Coming Soon)
```bash
# Will be available once FPM setup is complete
# fpm run
# fpm test
# fpm build
```
---
## π Usage
When running the application, enter a **speed value** followed by the **unit**:
```
Enter speed value and unit (e.g., "100 kmh" or "60 mph"): 100 kmh
100.00 km/h = 62.14 mph
```
**Supported units:**
- `kmh` or `km/h` β kilometers per hour
- `mph` β miles per hour
---
## π Project Structure
```
speed-converter/
βββ fpm.toml # FPM configuration
βββ src/
β βββ convert.f90 # Conversion functions module
βββ app/
β βββ main.f90 # Main application
βββ test/
β βββ test_convert.f90 # Unit tests
βββ README.md # This file
```
---
## π Conversion Formula
The project uses the standard factor:
**1 km/h = 0.621371 mph**
---
## π§ͺ Testing
The included tests verify:
- β
Conversion accuracy with known values
- β
Edge cases (e.g., zero values)
- β
Round-trip conversions
- β
Reciprocal relationships
Run tests:
```bash
# Manual method
gfortran -c test/test_convert.f90 -I build
gfortran -o test_runner convert.o test_convert.o
./test_runner
# With FPM (coming soon)
# fpm test
```