1 | !> @posix_calls_from_fortran.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: posix_calls_from_fortran.f90 2696 2017-12-14 17:12:51Z kanani $ |
---|
27 | ! Corrected "Former revisions" section |
---|
28 | ! |
---|
29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
30 | ! Change in file header (GPL part) |
---|
31 | ! |
---|
32 | ! 1986 2016-08-10 14:07:17Z gronemeier |
---|
33 | ! Forced header and separation lines into 80 columns |
---|
34 | ! |
---|
35 | ! 1986 2016-08-10 14:07:17Z gronemeier |
---|
36 | ! Initial revision |
---|
37 | ! |
---|
38 | ! Description: |
---|
39 | ! ------------ |
---|
40 | !> Collection of POSIX-command calls for Fortran |
---|
41 | !------------------------------------------------------------------------------! |
---|
42 | MODULE posix_calls_from_fortran |
---|
43 | |
---|
44 | USE, INTRINSIC :: iso_c_binding, ONLY: c_int |
---|
45 | |
---|
46 | IMPLICIT none |
---|
47 | |
---|
48 | PRIVATE |
---|
49 | |
---|
50 | |
---|
51 | INTERFACE |
---|
52 | |
---|
53 | FUNCTION fsleep( seconds ) BIND( C, NAME='sleep' ) |
---|
54 | IMPORT |
---|
55 | INTEGER(c_int) :: fsleep |
---|
56 | INTEGER(c_int), INTENT(IN), VALUE :: seconds |
---|
57 | END FUNCTION fsleep |
---|
58 | |
---|
59 | END INTERFACE |
---|
60 | |
---|
61 | INTERFACE fortran_sleep |
---|
62 | MODULE PROCEDURE fortran_sleep |
---|
63 | END INTERFACE fortran_sleep |
---|
64 | |
---|
65 | PUBLIC fortran_sleep |
---|
66 | |
---|
67 | |
---|
68 | CONTAINS |
---|
69 | |
---|
70 | !------------------------------------------------------------------------------! |
---|
71 | ! Description: |
---|
72 | ! ------------ |
---|
73 | !> Wait a specified amount of seconds |
---|
74 | !------------------------------------------------------------------------------! |
---|
75 | SUBROUTINE fortran_sleep( seconds ) |
---|
76 | |
---|
77 | INTEGER, INTENT(IN) :: seconds |
---|
78 | |
---|
79 | INTEGER(c_int) :: seconds_in_c |
---|
80 | INTEGER(c_int) :: sleep_return_value |
---|
81 | |
---|
82 | seconds_in_c = seconds |
---|
83 | |
---|
84 | sleep_return_value = fsleep( seconds_in_c ) |
---|
85 | |
---|
86 | END SUBROUTINE fortran_sleep |
---|
87 | |
---|
88 | END MODULE posix_calls_from_fortran |
---|
89 | |
---|