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