This commit is contained in:
Tyler McGurrin 2025-06-07 02:59:21 -04:00
parent 82a7b04a9b
commit c611f0076b
4 changed files with 45 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vscode/
build/

16
Makefile Normal file
View File

@ -0,0 +1,16 @@
FC=gfortran
BUILD_DIR=build
SRC_DIR=src
.phony: all main clean always
all: always main
main:
$(FC) $(SRC_DIR)/main.f90 -o $(BUILD_DIR)/fcc
always:
mkdir -p $(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR)

3
examples/ret2.c Normal file
View File

@ -0,0 +1,3 @@
int main() {
return 2;
}

24
src/main.f90 Normal file
View File

@ -0,0 +1,24 @@
program main
use f90getopt
implicit none
character(len=*), parameter :: VERSION = '1.0'
integer :: attempts = 1
type(option_s) :: opts(2)
opts(1) = option_s('attempts', .true., 'a')
opts(2) = option_s('version', .false., 'v')
do
select case (getopt('a:v', opts))
case (char(0))
exit
case ('g')
read (optarg, '(i3)') attempts
case ('v')
print '(a, f3.1)', 'version ', VERSION
stop
end select
end do
print '(a, i3)', 'number of attempts: ', attempts
end program main