@@ -128,14 +128,40 @@ $ fpm run
128
128
pi = 3.14159274
129
129
```
130
130
131
+ Although we have named our program ` hello ` , which is the same name as the
132
+ package name in ` fpm.toml ` , you can name it anything you want as long as it’s
133
+ permitted by the language.
134
+
131
135
Notice that you can run ` fpm run ` , and if the package hasn’t been built yet,
132
136
` fpm build ` will run automatically for you. This is true if the source files
133
137
have been updated since the last build. Thus, if you want to run your
134
138
application, you can skip the ` fpm build ` step, and go straight to ` fpm run ` .
135
139
136
- Although we have named our program ` hello ` , which is the same name as the
137
- package name in ` fpm.toml ` , you can name it anything you want as long as it’s
138
- permitted by the language.
140
+ When running your application using ` fpm run ` , the program's exit code is
141
+ passed by * fpm* back to the operating system. So, it is possible to use Fortran
142
+ numbered ` stop ` and ` error stop ` codes to pass termination reasons back to the terminal.
143
+
144
+ Try running the following app with ` fpm run ` :
145
+
146
+ ``` fortran
147
+ program main
148
+ use math_constants, only: pi
149
+
150
+ real :: angle
151
+
152
+ read(*,*,iostat=ierr) angle
153
+ if (ierr/=0) then
154
+ stop 2 ! Not real
155
+ elseif (angle>pi) then
156
+ stop 1
157
+ else
158
+ stop 0
159
+ endif
160
+ end program main
161
+ ```
162
+
163
+ and then checking that the error code matches. Note that error codes are passed to variable ` $? `
164
+ on Unix/Mac systems, and to environment variable ` %errorlevel% ` on Windows.
139
165
140
166
In this last example, our source file defined a ` math_constants ` module inside
141
167
the same source file as the main program. Let’s see how we can define an * fpm*
0 commit comments