Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5bd85ff
Fix line length issue with MPI_WRAPPER when using gfortran
JamieJQuinn Sep 30, 2021
cecf9bc
Flag very dangerous and confusing line in tests
JamieJQuinn Sep 30, 2021
c4dbba2
Add test for reading with MPI
JamieJQuinn Oct 19, 2021
f1fb37a
Reading real and complex numbers working with MPI reader
JamieJQuinn Oct 19, 2021
5ffaaf2
Reading BLACS-distributed array now works with MPI reader
JamieJQuinn Oct 19, 2021
55af7d6
Refactor MPI writer to not use manual offset counting
JamieJQuinn Oct 19, 2021
344ce55
Properly reset file view
JamieJQuinn Oct 19, 2021
73ff373
Remove MPI version of divided_slice_read
JamieJQuinn Oct 19, 2021
ffa1ea9
Better align file opening lines to see read/write and type of io hand…
JamieJQuinn Oct 19, 2021
8d64a50
Refector for clarity
JamieJQuinn Oct 19, 2021
d2fcec5
Refactor bookend byte handling & implement direct access
JamieJQuinn Oct 21, 2021
0462578
Implement MPI IO for everything except ext field
JamieJQuinn Oct 21, 2021
9b702bb
Implement iohandlers in matelem reading
JamieJQuinn Oct 21, 2021
ccaf0c3
Switch to calling openFile function to allocate the correct ioHandler…
JamieJQuinn Oct 22, 2021
eb36d05
Fix incorrect reader being used
JamieJQuinn Oct 22, 2021
a0593f5
Run benchmark with MPI if makefile called with USE_MPI
JamieJQuinn Oct 22, 2021
076b878
Merge branch 'feature/unit-testing' into enable-reading-matelem-chk
JamieJQuinn Oct 26, 2021
0d7e987
Remove -ppn option from mpirun in regression benchmark; not portable
JamieJQuinn Oct 26, 2021
5be51d5
Tidy tabs
JamieJQuinn Oct 26, 2021
49ebf93
Decouple unit tests from TROVE build
JamieJQuinn Oct 28, 2021
74247df
Actually error when running mpi tests without compiling with mpi
JamieJQuinn Oct 28, 2021
3fdbce4
Clean up initialisation of distributed array
JamieJQuinn Oct 28, 2021
c8a1132
Create true column distributed array on the stack, not the heap
JamieJQuinn Oct 28, 2021
184554d
Add test for MPI column reads
JamieJQuinn Oct 28, 2021
0119b55
End make early if USE_MPI is anything but 0 or 1
JamieJQuinn Nov 4, 2021
da5887b
Cleanup use of USE_MPI in makefile
JamieJQuinn Nov 4, 2021
8b74b82
Fix use of USE_MPI in regression test scripts
JamieJQuinn Nov 4, 2021
bc19005
Add seek and column reading to io handlers
JamieJQuinn Nov 4, 2021
ab460d8
Save access to class in FTN io handler
JamieJQuinn Nov 4, 2021
e33353e
Remove commented out lines from perturbation.f90
JamieJQuinn Nov 4, 2021
8e272c5
Remove unecessary io handlers outside of PTrestore_rot_kinetic_matrix…
JamieJQuinn Nov 4, 2021
d4222a8
Remove legacy commas
JamieJQuinn Nov 4, 2021
b3e1740
Make bookend offset in seek more readable
JamieJQuinn Nov 4, 2021
b6f2b43
Remove commented out code
JamieJQuinn Nov 4, 2021
4b81817
Reader works with MPI + MPIIO for matelem.chk
JamieJQuinn Nov 5, 2021
f926cd6
Remove debug code
JamieJQuinn Nov 5, 2021
3af457d
Ensure there's something to seek over when seeking through a file
JamieJQuinn Nov 5, 2021
10c9b46
Remove mpi from PTrestore...
JamieJQuinn Nov 5, 2021
de6e11f
Fix error messages in PTstore_icontr_cnu
JamieJQuinn Nov 5, 2021
e61da6b
Fix MPI_INT_SIZE when mpi not enabled
JamieJQuinn Nov 5, 2021
61d812d
Rename PTrestore function
JamieJQuinn Nov 8, 2021
e7ab0fe
Remove checks for MPIIO surrounding PTrestore
JamieJQuinn Nov 8, 2021
a845712
tidy up perturbation
JamieJQuinn Nov 8, 2021
6650279
Fix possibly disjoint file pointers in mpi writer
JamieJQuinn Nov 8, 2021
c0523ad
Remove uneccessary MPI_Datatype
JamieJQuinn Nov 8, 2021
dd65520
Fix incorrect reading of g_rot
JamieJQuinn Nov 8, 2021
cc91f2d
Remove pointless bookend check
JamieJQuinn Nov 8, 2021
bd09c5d
Fix names of tests
JamieJQuinn Nov 8, 2021
769bdfa
Fix non-mpi parts of PTrestore
JamieJQuinn Nov 8, 2021
8d18f42
Only try running MPI unit tests if USE_MPI set in makefile
JamieJQuinn Nov 9, 2021
82fef80
Fix error in makefile
JamieJQuinn Nov 9, 2021
a1ec156
Remove non-portable mpirun argument
JamieJQuinn Nov 9, 2021
42f09e8
Remove another non-portable mpirun flag
JamieJQuinn Nov 9, 2021
6937f0f
Move test of intensity files to run after tests of other files so we …
JamieJQuinn Nov 9, 2021
71eeda3
Add test for seeking while reading a file using MPI
JamieJQuinn Nov 10, 2021
9150e26
Ensure we use the correct MPI wrapper with intel compilers
JamieJQuinn Nov 10, 2021
ecfac19
Fix issue with differing offsets in different processes
JamieJQuinn Nov 11, 2021
57adeed
Move MPI split errorto correct place
JamieJQuinn Nov 11, 2021
9c3b88a
Transition MPIIO slice implementation to use ioHandlers
JamieJQuinn Nov 11, 2021
a653467
Use only one call for handling slice read/write
JamieJQuinn Nov 11, 2021
6a5a9f5
Fix unallocated array access
JamieJQuinn Nov 12, 2021
034e4e4
Use assumed size array for reading/writing slices. This fixes segfault.
JamieJQuinn Nov 12, 2021
3d185e7
Fix mismatch in integer kind passed to file seek
JamieJQuinn Jan 4, 2022
2f5a572
Transition MPIIO implementation of external matelem handling to use i…
JamieJQuinn Nov 11, 2021
f9b6d44
Ensure external field handling is same for MPI and non-MPI versions o…
JamieJQuinn Nov 11, 2021
0d95174
Remove some unused MPIIO sections
JamieJQuinn Nov 22, 2021
0aaa8cf
Fix bug in reading extfield.chk
JamieJQuinn Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions io_factory.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module io_factory
use mpi_aux
use io_handler_base
use io_handler_ftn
#ifdef TROVE_USE_MPI_
use io_handler_mpi
#endif
use errors
implicit none

contains
subroutine allocateHandler(ioHandler)
class(ioHandlerBase), allocatable, intent(out) :: ioHandler
#ifdef TROVE_USE_MPI_
if (blacs_size > 1) then
! Only allocate MPI IO when compiled with MPI *and*
! running with more than one MPI process
allocate(ioHandlerMPI::ioHandler)
else
allocate(ioHandlerFTN::ioHandler)
endif
#else
allocate(ioHandlerFTN::ioHandler)
#endif
end subroutine

subroutine openFile(ioHandler, filename, err, action, position, status, form, access)
class(ioHandlerBase), allocatable, intent(out) :: ioHandler
character (len = *), intent(in) :: filename
type(ErrorType), intent(inout) :: err
character (len = *), intent(in) :: action
character (len = *), intent(in), optional :: position, status, form, access

call allocateHandler(ioHandler)
call ioHandler%open(filename, err, action, position, status, form, access)
end subroutine
end module
24 changes: 23 additions & 1 deletion io_handler_base.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ module io_handler_base
type, abstract :: ioHandlerBase
contains
procedure(open), deferred :: open
procedure(seek), deferred :: seek
generic :: write => writeScalar, write1DArray, write2DArray, write2DArrayDistBlacs, write2DArrayDistColumn
procedure(writeScalar), deferred :: writeScalar
procedure(write1DArray), deferred :: write1DArray
procedure(write2DArray), deferred :: write2DArray
procedure(write2DArrayDistBlacs), deferred :: write2DArrayDistBlacs
procedure(write2DArrayDistColumn), deferred :: write2DArrayDistColumn
generic :: read => readScalar, read1DArray, read2DArray
generic :: read => readScalar, read1DArray, read2DArray, read2DArrayDistBlacs, read2DArrayDistColumn
procedure(readScalar), deferred :: readScalar
procedure(read1DArray), deferred :: read1DArray
procedure(read2DArray), deferred :: read2DArray
procedure(read2DArrayDistBlacs), deferred :: read2DArrayDistBlacs
procedure(read2DArrayDistColumn), deferred :: read2DArrayDistColumn
end type ioHandlerBase

abstract interface
Expand Down Expand Up @@ -74,6 +77,25 @@ subroutine read2DArray(this, object)
class(ioHandlerBase) :: this
class(*), dimension(:,:), intent(out) :: object
end subroutine
subroutine read2DArrayDistBlacs(this, object, descr, block_type)
import ioHandlerBase
import MPI_Datatype
class(ioHandlerBase) :: this
class(*), dimension(:,:), intent(out) :: object
integer, intent(in) :: descr(9) ! Description array outputted from co_block_type_init
type(MPI_Datatype), intent(in) :: block_type
end subroutine
subroutine read2DArrayDistColumn(this, object, dimen)
import ioHandlerBase
class(ioHandlerBase) :: this
class(*), intent(out) :: object(:,:)
integer, intent(in) :: dimen ! Dimension of entire distributed array
end subroutine
subroutine seek(this, offset)
import ioHandlerBase
class(ioHandlerBase) :: this
integer, intent(in) :: offset
end subroutine
end interface

private
Expand Down
139 changes: 94 additions & 45 deletions io_handler_ftn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module io_handler_ftn
integer :: iounit = 0
integer :: stat = 0
logical :: isOpen = .false.
character (len=20) :: accessVal
contains
procedure :: writeScalar => writeScalarFTN
procedure :: write1DArray => write1DArrayFTN
Expand All @@ -21,32 +22,20 @@ module io_handler_ftn
procedure :: readScalar => readScalarFTN
procedure :: read1DArray => read1DArrayFTN
procedure :: read2DArray => read2DArrayFTN
procedure :: read2DArrayDistBlacs => read2DArrayDistBlacsFTN
procedure :: read2DArrayDistColumn => read2DArrayDistColumnFTN
procedure :: open
procedure :: close
procedure :: seek
final :: destroyIoHandlerFTN
end type ioHandlerFTN

! Constructor
interface ioHandlerFTN
procedure :: newIoHandlerFTN
end interface ioHandlerFTN

private

public :: ioHandlerFTN

contains

type(ioHandlerFTN) function newIoHandlerFTN(fname, err, action, position, status, form, access) result(this)
! writer FTN constructor
type(ErrorType), intent(inout) :: err
character (len = *), intent(in) :: fname
character (len = *), intent(in) :: action
character (len = *), intent(in), optional :: position, status, form, access

call this%open(fname, err, action, position, status, form, access)
end function

subroutine destroyIoHandlerFTN(this)
type(ioHandlerFTN) :: this
call this%close()
Expand Down Expand Up @@ -83,17 +72,21 @@ subroutine open(this, fname, err, action, position, status, form, access)
end if

if (present(access)) then
accessVal = access
this%accessVal = access
else
accessVal = 'sequential'
end if
this%accessVal = 'sequential'
endif

print *, "FTN: Opening ", trim(fname), " with ", \
trim(positionVal), " ", trim(statusVal), " ", trim(formVal), " ", trim(accessVal)
print *, "FTN: Opening ", trim(fname), " with ", &
trim(action), " ", &
trim(positionVal), " ", &
trim(statusVal), " ", &
trim(formVal), " ", &
trim(this%accessVal)

open(newunit=this%iounit, action=action,\
form=formVal, position=positionVal, status=statusVal, file=fname,\
iostat=this%stat)
open(newunit=this%iounit, action=action, &
form=formVal, position=positionVal, status=statusVal, &
access=this%accessVal, file=fname, iostat=this%stat)

if (this%stat == 0) then
this%isOpen = .true.
Expand All @@ -110,10 +103,23 @@ subroutine close(this)
endif
end subroutine

subroutine seek(this, offset)
class(ioHandlerFTN) :: this
INTEGER, PARAMETER :: SEEK_SET = 0, SEEK_CUR = 1, SEEK_END = 2
integer, intent(in) :: offset
integer :: total_offset

if (trim(this%accessVal) == "sequential" .and. offset .ne. 0) then
! Add two bookend offsets
total_offset = offset + 2*4
endif
call fseek(this%iounit, total_offset, SEEK_CUR)
end subroutine

subroutine writeScalarFTN(this, object)
class(ioHandlerFTN) :: this
class(*), intent(in) :: object
print *, "writing scalar object with FTN IO"

select type(object)
type is (integer)
write(this%iounit) object
Expand All @@ -122,16 +128,16 @@ subroutine writeScalarFTN(this, object)
type is (complex)
write(this%iounit) object
type is (character(len=*))
write(this%iounit) object
write(this%iounit) trim(object)
class default
print *, "ERROR: Tried to write unsupported type"
stop "ioHandlerFTN%writeScalarFTN: Tried to write unsupported type"
end select
end subroutine

subroutine write1DArrayFTN(this, object)
class(ioHandlerFTN) :: this
class(*), dimension(:), intent(in) :: object
print *, "writing 1D array with FTN IO"

select type(object)
type is (integer)
write(this%iounit) object
Expand All @@ -140,14 +146,14 @@ subroutine write1DArrayFTN(this, object)
type is (complex)
write(this%iounit) object
class default
print *, "ERROR: Tried to write unsupported type"
stop "ioHandlerFTN%write1DArrayFTN: Tried to write unsupported type"
end select
end subroutine

subroutine write2DArrayFTN(this, object)
class(ioHandlerFTN) :: this
class(*), dimension(:,:), intent(in) :: object
print *, "writing 2D array with FTN IO"

select type(object)
type is (integer(int32))
write(this%iounit) object
Expand All @@ -162,7 +168,7 @@ subroutine write2DArrayFTN(this, object)
type is (complex(kind=8))
write(this%iounit) object
class default
print *, "ERROR: Tried to write unsupported type"
stop "ioHandlerFTN%write2DArrayFTN: Tried to write unsupported type"
end select
end subroutine

Expand Down Expand Up @@ -192,48 +198,91 @@ subroutine write2DArrayDistColumnFTN(this, object, mdimen)
subroutine readScalarFTN(this, object)
class(ioHandlerFTN) :: this
class(*), intent(out) :: object
print *, "reading object with FTN IO"

select type(object)
type is (integer)
type is (integer(int32))
read(this%iounit) object
type is (real)
type is (integer(int64))
read(this%iounit) object
type is (complex)
type is (real(real32))
read(this%iounit) object
type is (real(real64))
read(this%iounit) object
type is (complex(kind=4))
read(this%iounit) object
type is (complex(kind=8))
read(this%iounit) object
type is (character(len=*))
read(this%iounit) object
class default
print *, "Unsupported type!"
stop "ioHandlerFTN%readScalarFTN: Tried to read unsupported type"
end select
end subroutine

subroutine read1DArrayFTN(this, object)
class(ioHandlerFTN) :: this
class(*), dimension(:), intent(out) :: object
print *, "reading 1D array with FTN IO"

select type(object)
type is (integer)
type is (integer(int32))
read(this%iounit) object
type is (real)
type is (integer(int64))
read(this%iounit) object
type is (complex)
type is (real(real32))
read(this%iounit) object
type is (real(real64))
read(this%iounit) object
type is (complex(kind=4))
read(this%iounit) object
type is (complex(kind=8))
read(this%iounit) object
class default
print *, "Unsupported type!"
stop "ioHandlerFTN%read1DArrayFTN: Tried to read unsupported type"
end select
end subroutine

subroutine read2DArrayFTN(this, object)
class(ioHandlerFTN) :: this
class(*), dimension(:,:), intent(out) :: object
print *, "reading 2D array with FTN IO"

select type(object)
type is (integer)
type is (integer(int32))
read(this%iounit) object
type is (real)
type is (integer(int64))
read(this%iounit) object
type is (complex)
type is (real(real32))
read(this%iounit) object
type is (real(real64))
read(this%iounit) object
type is (complex(kind=4))
read(this%iounit) object
type is (complex(kind=8))
read(this%iounit) object
class default
print *, "Unsupported type!"
stop "ioHandlerFTN%read2DArrayFTN: Tried to read unsupported type"
end select
end subroutine

subroutine read2DArrayDistBlacsFTN(this, object, descr, block_type)
! Read blacs-distributed arrays

class(ioHandlerFTN) :: this
class(*), dimension(:,:), intent(out) :: object
integer, intent(in) :: descr(9) ! Description array outputted from co_block_type_init
type(MPI_Datatype), intent(in) :: block_type

! Using the fortran io_handler means array isn't distributed, just read normally
call this%read2DArray(object)
end subroutine

subroutine read2DArrayDistColumnFTN(this, object, dimen)
! read arrays distributed as columns using co_distr_data

class(ioHandlerFTN) :: this
class(*), dimension(:,:), intent(out) :: object
integer, intent(in) :: dimen

! Using the fortran io_handler means array isn't distributed, just read normally
call this%read2DArray(object)
end subroutine
end module
Loading