This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e4d4da
commit c9cbd63
Showing
4 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
! file_io.f90 | ||
|
||
!> @brief This module contains routines to support file I/O operations. | ||
module file_io | ||
use iso_fortran_env | ||
use ferror | ||
implicit none | ||
private | ||
public :: file_manager | ||
|
||
! ****************************************************************************** | ||
! TYPES | ||
! ------------------------------------------------------------------------------ | ||
!> @brief Defines a base type for managint file I/O. | ||
type file_manager | ||
private | ||
!> @brief The unit value. | ||
integer(int32) :: m_unit = -1 | ||
!> @brief Delete file upon closing? | ||
logical :: m_deleteOnClose = .false. | ||
contains | ||
procedure, public :: get_unit => fm_get_unit | ||
end type | ||
|
||
! ****************************************************************************** | ||
! INTERFACES | ||
! ------------------------------------------------------------------------------ | ||
interface | ||
module function fm_get_unit(this) result(rst) | ||
class(file_manager), intent(inout) :: this | ||
integer(int32) :: rst | ||
end function | ||
end interface | ||
|
||
! ------------------------------------------------------------------------------ | ||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
! file_io_fm.f90 | ||
|
||
submodule (file_io) file_io_tfm | ||
contains | ||
! ------------------------------------------------------------------------------ | ||
!> @brief Returns the unit value. | ||
!! | ||
!! @param[in,out] this The file_manager object. | ||
!! | ||
!! @return The Fortran unit value for this stream. | ||
module function fm_get_unit(this) result(rst) | ||
! Arguments | ||
class(file_manager), intent(inout) :: this | ||
integer(int32) :: rst | ||
|
||
! Parameters | ||
integer(int32), parameter :: min_unit = 10 | ||
integer(int32), parameter :: max_unit = 1000 | ||
|
||
! Local Variables | ||
logical :: opened | ||
integer(int32) :: i | ||
|
||
! Process | ||
if (this%m_unit == -1) then | ||
do i = min_unit, max_unit | ||
inquire(unit = i, opened = opened) | ||
if (.not.opened) then | ||
this%m_unit = i | ||
exit | ||
end if | ||
end do | ||
end if | ||
rst = this%m_unit | ||
end function | ||
|
||
! ------------------------------------------------------------------------------ | ||
|
||
! ------------------------------------------------------------------------------ | ||
|
||
! ------------------------------------------------------------------------------ | ||
|
||
! ------------------------------------------------------------------------------ | ||
|
||
! ------------------------------------------------------------------------------ | ||
|
||
! ------------------------------------------------------------------------------ | ||
end submodule |