ahay/src/authoring-sf-programs-f77
Claude Code and agent skill by ahay/src
- community
Checking that the SKILL.md file is still in the repository.
Use when authoring a Madagascar sf* main program in Fortran 77.
Install
npx vskill@latest install ahay/src/authoring-sf-programs-f77SKILL.md
When to use
Use this skill for Madagascar processing programs in Fortran 77 fixed-format (file extension .f, program named M<Name>.f). Typical scenarios: maintaining legacy fixed-format code, porting existing F77 algorithms, or working with research groups that standardize on gfortran -std=legacy or ifort.
F77 vs F90 key differences:
| Aspect | F77 | F90 | |
|---|---|---|---|
| Source format | Fixed-format; code starts at column 7 | Free-format | |
| Continuation | Any non-space/zero char in column 6 | & at end of line | |
| File extension | M<name>.f | M<name>.f90 | |
| Comments | C or * in column 1 | ! anywhere | |
| Loops | do 10 i=1,n … 10 continue | do i=1,n … end do |
For shared conventions (SConstruct rules, self-doc headers, naming) see skills/authoring-sf-programs/.
Skeleton
Minimal F77 program derived from api/f77/Testfile.f and api/f77/test/clip.f. Columns 1-6 are reserved; statement body starts at column 7; continuation marker goes in column 6.
Column layout reminder:
API cheat sheet
All calls go through the librsff wrapper (fortran.c + cfortran.h). Functions returning a value must be declared with the appropriate Fortran type.
Init and file handles — declare file handles as integer*8:
| Call | Returns | Purpose | |
|---|---|---|---|
call sf_init() | — | Initialize Madagascar (must be first) | |
sf_input("in") | integer*8 | Open named input RSF file | |
sf_output("out") | integer*8 | Open named output RSF file | |
call sf_fileclose(f) | — | Close file handle | |
call sf_close() | — | Finalize I/O |
History reads — declare as logical; .false. means key absent:
| Call | Purpose | |
|---|---|---|
sf_histint(f,"n1",i) | Read integer header key | |
sf_histfloat(f,"d1",x) | Read float header key | |
sf_histbool(f,"key",b) | Read logical header key | |
sf_histstring(f,"label") | Read string (function returning character*) |
History writes (call subroutines, no return value):
| Call | Purpose | |
|---|---|---|
call sf_putint(f,"n2",i) | Write integer to output header | |
call sf_putfloat(f,"d2",x) | Write float | |
call sf_putstring(f,"label",str) | Write string |
Command-line param reads — declare as logical; .true. if key found:
| Call | Purpose | |
|---|---|---|
sf_getint("niter",i) | Read integer param | |
sf_getfloat("clip",x) | Read float param | |
sf_getfloats("d",xv,n) | Read n floats | |
sf_getbool("verb",b) | Read yes/no param | |
sf_getstring("tag") | Read string (function) |
Data I/O (call subroutines):
| Call | Purpose | |
|---|---|---|
call sf_floatread(buf, n, f) | Read n floats from f | |
call sf_floatwrite(buf, n, f) | Write n floats to f | |
call sf_intread(buf, n, f) | Read n integers | |
call sf_intwrite(buf, n, f) | Write n integers | |
call sf_complexread(buf, n, f) | Read n complex values | |
call sf_complexwrite(buf, n, f) | Write n complex values |
Utility:
| Call | Returns | Purpose | |
|---|---|---|---|
sf_leftsize(f, dim) | integer*8 | Elements past dimension dim | |
sf_gettype(f) | integer | Data type code (3 = float) | |
call sf_error("msg") | — | Print and abort | |
call sf_warning("msg") | — | Print, continue |
Build integration
The F77 API builds only when f77 appears in the SCons API list (api/f77/SConstruct):
- Detects compiler via
env.get('F77'); sets-DGFORTRANor
-DINTEL_COMPILER accordingly.
- Compiles
fortran.c(withcfortran.h) intofortran.o. - Bundles into
librsff.a(static library) and installs tolib/. - User programs link against both
librsffand corelibrsf.
Typical user SConstruct snippet:
cfortran.h handles name-mangling: gfortran (single underscore) vs f2c-style (double underscore) via compile-time defines.
Pointers
Files in /Users/jgoai/m8r/src/api/f77/:
| File | Description | |
|---|---|---|
fortran.c | C wrapper; FCALLSC* macros expose every sf_* function to F77 | |
cfortran.h | Third-party (Burkhard Burow/DESY) Fortran↔C name-mangling header | |
Testfile.f | Smoke-test: open in/out, read 100-float traces, write them back | |
Testgetpar.f | Exercises all param-read calls (sf_getint, sf_getfloat, etc.) | |
SConstruct | Builds librsff.a, installs to lib/, compiles test programs | |
test/clip.f | Complete real program: float clipping with header inspection | |
test/SConstruct | SCons build for the test/ example programs |
Shared conventions
General Madagascar conventions (self-documentation strings, parameter help, SCons Program builder, installation targets) are in:
F77-specific reminders:
- Declare
sf_input,sf_output,sf_leftsize,sf_filesizeasinteger*8
— file handles and offsets are 64-bit on modern systems.
- Declare param-query functions (
sf_getint,sf_histfloat, …) aslogical
to test them in if (.not. …) guards.
- Use
implicit none— F77 implicit typing silently mapsi-nto integer
and the rest to real, hiding declaration bugs.
- Continuation: place the continuation character in column 6 only.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/authoring-sf-programs-f77/SKILL.md
Popularity
- Repository stars
- 352
- Repository forks
- 191
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ahay/src/authoring-sf-programs-f77)