[1987] | 1 | !> @posix_calls_from_fortran.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1987] | 4 | ! |
---|
[2000] | 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. |
---|
[1987] | 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 | ! |
---|
[2696] | 14 | ! You should have received a copy of the GNU General Public License along with |
---|
[1987] | 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1987] | 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ----------------- |
---|
| 22 | ! |
---|
[2001] | 23 | ! |
---|
[1987] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
[2716] | 26 | ! $Id: posix_calls_from_fortran.f90 2696 2017-12-14 17:12:51Z kanani $ |
---|
[4182] | 27 | ! Corrected "Former revisions" section |
---|
| 28 | ! |
---|
| 29 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
[3554] | 30 | ! add variable description |
---|
| 31 | ! |
---|
[4182] | 32 | ! 1986 2016-08-10 14:07:17Z gronemeier |
---|
| 33 | ! Initial revision |
---|
[2716] | 34 | ! |
---|
[1987] | 35 | ! Description: |
---|
| 36 | ! ------------ |
---|
| 37 | !> Collection of POSIX-command calls for Fortran |
---|
| 38 | !------------------------------------------------------------------------------! |
---|
| 39 | MODULE posix_calls_from_fortran |
---|
| 40 | |
---|
| 41 | USE, INTRINSIC :: iso_c_binding, ONLY: c_int |
---|
| 42 | |
---|
| 43 | IMPLICIT none |
---|
| 44 | |
---|
| 45 | PRIVATE |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | INTERFACE |
---|
[3554] | 49 | ! |
---|
| 50 | !-- Sleep function from C library |
---|
[1987] | 51 | FUNCTION fsleep( seconds ) BIND( C, NAME='sleep' ) |
---|
| 52 | IMPORT |
---|
| 53 | INTEGER(c_int) :: fsleep |
---|
| 54 | INTEGER(c_int), INTENT(IN), VALUE :: seconds |
---|
| 55 | END FUNCTION fsleep |
---|
| 56 | |
---|
| 57 | END INTERFACE |
---|
| 58 | |
---|
| 59 | INTERFACE fortran_sleep |
---|
| 60 | MODULE PROCEDURE fortran_sleep |
---|
| 61 | END INTERFACE fortran_sleep |
---|
| 62 | |
---|
| 63 | PUBLIC fortran_sleep |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | CONTAINS |
---|
| 67 | |
---|
| 68 | !------------------------------------------------------------------------------! |
---|
| 69 | ! Description: |
---|
| 70 | ! ------------ |
---|
| 71 | !> Wait a specified amount of seconds |
---|
| 72 | !------------------------------------------------------------------------------! |
---|
[3554] | 73 | SUBROUTINE fortran_sleep( seconds ) |
---|
[1987] | 74 | |
---|
[3554] | 75 | INTEGER, INTENT(IN) :: seconds !< seconds to wait |
---|
[1987] | 76 | |
---|
[3554] | 77 | INTEGER(c_int) :: seconds_in_c !< same as seconds |
---|
| 78 | INTEGER(c_int) :: sleep_return_value !< returned value to sleep |
---|
[1987] | 79 | |
---|
[3554] | 80 | seconds_in_c = seconds |
---|
[1987] | 81 | |
---|
[3554] | 82 | sleep_return_value = fsleep( seconds_in_c ) |
---|
[1987] | 83 | |
---|
[3554] | 84 | END SUBROUTINE fortran_sleep |
---|
[1987] | 85 | |
---|
| 86 | END MODULE posix_calls_from_fortran |
---|