Module: IO#

Simulation system size, and the size setup subroutine.

The module is to set commonly used double precision variable kind.

Defined Subroutines#

mupro_output_3D#

Subroutine: mupro_output_3D(inFilename, kt, inArr1, inArr2, inArr3, inArr4, inArr5, inArr6, inArr7, inArr8, inArr9, inArrA, inArrB, inArrC)

Write inArrs data to inFilename file through mpi

Important

Note that the parameters inArr1~C should appear in order. For example, if inArr5 passes parameters, inArr1~5 must pass parameters inArr6~C can be omitted

Argument

Type(Intent)

Meaning

inFilename

character(len=8), intent(in)

Prefix name of output file

kt

character(len=8), intent(in)

Infix name of the output file

inArr

real(kind=rdp), dimension(:, :, :), intent(in)

An array that needs to be passed to the solver

When you call a function with the following data, inFilename="out_3D  ",kt=10, The function will generate the following file out_3D.00000010.dat

mupro_input_3D#

Subroutine: mupro_input_3D(inFilename, outArr1, outArr2, outArr3, outArr4, outArr5, outArr6, outArr7, outArr8, outArr9, outArrA, outArrB, outArrC, lineLengthIN)

Looping data from inFilename file using mpi and encapsulating it into an array

Important

Note: outArr is a necessary parameter. When inputting other array parameters at the same time, such as outArr5 and outArr7 , the parameter with the highest number will be detected, and outArr7 will be used as the return parameter. That is, the data read from the file will be returned to outArr7

Argument

Type(Intent)

Meaning

inFilename

character(len=8), intent(in)

The address of the file that needs to be read

outArr

real(kind=rdp), dimension(:, :, :), intent(out)

Location of default data output

lineLengthIN

integer, intent(IN), optional

Determine length of first line

mupro_input_4D#

Subroutine: mupro_input_4D(inFileName, outArr)

Set the corresponding mupro_input_3D interface based on the one-dimensional number of input array parameters

Argument

Type(Intent)

Meaning

inFilename

character(len=8), intent(in)

The address of the file that needs to be read

outArr

real(kind=rdp), dimension(:, :, :), intent(out)

Location of default data output

mupro_output_4D#

Subroutine: mupro_output_4D(inFileName, kt, inArr)

Set the corresponding mupro_output_3D interface based on the one-dimensional number of input array parameters

Argument

Type(Intent)

Meaning

inFilename

character(len=8), intent(in)

Prefix name of output file

kt

character(len=8), intent(in)

Infix name of the output file

inArr

real(kind=rdp), dimension(:, :, :), intent(in)

An array that needs to be passed to the solver

When you call a function with the following data, inFilename="out_4D  ",kt=10, The function will generate the following file out_4D.00000010.dat

mupro_write_data_double#

Write one or more data to a file

Subroutine: mupro_write_data_double(filename, data1, data2, data3, data4, data5, data6)

Argument

Type(Intent)

Meaning

filename

character(*), intent(in) :: filename

The file address where the data is written, if there is one, overwrite it. If there is none, create it

data1

real(kind=8), dimension(:, :, :), intent(in)

Data written to a file

data2~6

real(kind=8), dimension(:, :, :), optional, intent(in)

Data written to a file

Usage#

If you want to write some 3D arrays to a file, please use the mupro_output_3D function and the corresponding mupro_input_3D function to read data from the file into the array. However, please note that the two functions use different file suffixes.

Example#

Test inputting 3D data into a file

program main
    use mod_mupro_io
    use mupro_lib_test
    use mod_mupro_base
    use mod_mupro_fft
    IMPLICIT NONE
    type(type_mupro_SizeContext):: context
    type(type_mupro_FFTContext) :: fft_context
    call prepare_SizeContext(context)
    call mupro_size_setup(context)
    call mupro_fft_setup(fft_context)

    call test_mupro_output_3D()

end program
subroutine prepare_SizeContext(context)
  use mod_mupro_base
  implicit none
  type(type_mupro_SizeContext), intent(inout) ::  context
  context%nx = 128
  context%ny = 128
  context%nz = 60
  context%dx = 1d-9
  context%dy = 1d-9
  context%dz = 1d-9
  context%ns = 22
  context%nf = 33
!   context%kt = 123
!   context%dt0 = 0.001
end subroutine

!	Test inputting 3D data into a file
subroutine test_mupro_output_3D()
    use mod_mupro_base
    use mod_lib_fft
    use mod_mupro_io
    implicit none
    character(len = :), allocatable :: fileName
    integer(kind = idp) :: kt
    integer :: dim1, dim2, dim3, i, j, k
    real(kind = rdp), dimension(Rn3, Rn2, Rn1) :: inArr
    dim1 = size(inArr, 1)
    dim2 = size(inArr, 2)
    dim3 = size(inArr, 3)
    fileName = "out_3D  "
    kt = 10
    do i = 1, dim1
        do j = 1, dim2
            do k = 1, dim3
                inArr(i, j, k) = i + j + k
            end do
        end do
    end do
    call mupro_output_3D(fileName, kt, inArr)
end subroutine test_mupro_output_3D

!	The test will read 3D data from the file
subroutine test_mupro_input_3D()
    use mod_mupro_base
    use mod_lib_fft
    use mod_mupro_io
    implicit none
    real(kind = rdp), allocatable, dimension(:, :, :) :: outArr
    character(len = 8) :: inFilename
    allocate(outArr(Rn3, Rn2, Rn1))
    outArr(:, :, :) = 0

    inFilename = "input3D" ! need prepare a test input file
    call mupro_input_3D(inFilename, outArr)
    print*, outArr
    deallocate(outArr)
end subroutine test_mupro_input_3D