Skip to content

Commit

Permalink
more documentation work
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 30, 2019
1 parent f9faae9 commit 54db8b2
Showing 1 changed file with 66 additions and 120 deletions.
186 changes: 66 additions & 120 deletions src/flib/pio_support.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
!>
!! @file pio_support.F90
!! @brief internal code for compiler workarounds, aborts and debug functions
!!
!! @file
!! Internal code for compiler workarounds, aborts and debug functions.
!<
module pio_support
use pio_kinds
Expand All @@ -28,10 +27,8 @@ module pio_support
character(len=*), parameter :: modName='pio_support'

contains
!>
!! @public
!! @brief Remove null termination (C-style) from strings for Fortran.
!<
!> Remove null termination (C-style) from strings for Fortran.
!<
subroutine replace_c_null(istr, ilen)
use iso_c_binding, only : C_NULL_CHAR
character(len=*),intent(inout) :: istr
Expand All @@ -48,40 +45,24 @@ subroutine replace_c_null(istr, ilen)
istr(i:slen)=''
end subroutine replace_c_null

!>
!! @public
!! @brief Abort the model for abnormal termination.
!! @param file : File where piodie is called from.
!! @param line : Line number where it is called.
!! @param msg,msg2,msg3,ival1,ival2,ival3,mpirank : Optional argument for error messages.
!<
!>
!! Abort the model for abnormal termination.
!!
!! @param file File where piodie is called from.
!! @param line Line number where it is called.
!! @param msg,msg2,msg3,ival1,ival2,ival3,mpirank : Optional
!! argument for error messages.
!<
subroutine piodie (file,line, msg, ival1, msg2, ival2, msg3, ival3, mpirank)
!-----------------------------------------------------------------------
! Purpose:
!
! Abort the model for abnormal termination
!
! Author: Jim Edwards
!
! Change History
! 20070608 R. Loy added optional args
!-----------------------------------------------------------------------
! $Id$
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
implicit none
!-----------------------------------------------------------------------
!
! Arguments
!
character(len=*), intent(in) :: file
integer,intent(in) :: line
character(len=*), intent(in), optional :: msg,msg2,msg3
integer,intent(in),optional :: ival1,ival2,ival3, mpirank

character(len=*), parameter :: subName=modName//'::pio_die'
integer :: ierr, myrank=-1

if(present(mpirank)) myrank=mpirank

if (present(ival3)) then
Expand All @@ -104,8 +85,8 @@ subroutine piodie (file,line, msg, ival1, msg2, ival2, msg3, ival3, mpirank)


#if defined(CPRXLF) && !defined(BGQ)
close(5) ! needed to prevent batch jobs from hanging in xl__trbk
call xl__trbk()
close(5) ! needed to prevent batch jobs from hanging in xl__trbk
call xl__trbk()
#endif

! passing an argument of 1 to mpi_abort will lead to a STOPALL output
Expand All @@ -118,77 +99,58 @@ subroutine piodie (file,line, msg, ival1, msg2, ival2, msg3, ival3, mpirank)
call abort
#endif


end subroutine piodie

!=============================================
! CheckMPIreturn:
!
! Check and prints an error message
! if an error occured in a MPI subroutine.
!=============================================
!>
!! @public
!! @brief Check and prints an error message if an error occured in an MPI
!! subroutine.
!! @param locmesg : Message to output
!! @param errcode : MPI error code
!! @param file : The file where the error message originated.
!! @param line : The line number where the error message originated.
!<
!>
!! Check and prints an error message if an error occured in an MPI
!! subroutine.
!!
!! @param locmesg Message to output
!! @param errcode MPI error code
!! @param file The file where the error message originated.
!! @param line The line number where the error message originated.
!<
subroutine CheckMPIreturn(locmesg, errcode, file, line)

character(len=*), intent(in) :: locmesg
integer(i4), intent(in) :: errcode
character(len=*),optional :: file
integer, intent(in),optional :: line
character(len=MPI_MAX_ERROR_STRING) :: errorstring

integer(i4) :: errorlen

integer(i4) :: ierr
if (errcode .ne. MPI_SUCCESS) then
call MPI_Error_String(errcode,errorstring,errorlen,ierr)
write(*,*) TRIM(ADJUSTL(locmesg))//errorstring(1:errorlen)
if(present(file).and.present(line)) then
call piodie(file,line)
endif
end if
character(len=*), intent(in) :: locmesg
integer(i4), intent(in) :: errcode
character(len=*),optional :: file
integer, intent(in),optional :: line
character(len=MPI_MAX_ERROR_STRING) :: errorstring

integer(i4) :: errorlen

integer(i4) :: ierr
if (errcode .ne. MPI_SUCCESS) then
call MPI_Error_String(errcode,errorstring,errorlen,ierr)
write(*,*) TRIM(ADJUSTL(locmesg))//errorstring(1:errorlen)
if(present(file).and.present(line)) then
call piodie(file,line)
endif
end if
end subroutine CheckMPIreturn

!>
!! @public
!! @brief Fortran interface to write a mapping file
!! @param file : The file where the decomp map will be written.
!! @param gdims : The dimensions of the data array in memory.
!! @param DOF : The multidimensional array of indexes that describes how
!! data in memory are written to a file.
!! @param comm : The MPI comm index.
!! @param punit : Optional argument that is no longer used.
!<
!>
!! Fortran interface to write a mapping file.
!!
!! @param file : The file where the decomp map will be written.
!! @param gdims : The dimensions of the data array in memory.
!! @param DOF : The multidimensional array of indexes that describes how
!! data in memory are written to a file.
!! @param comm : The MPI comm index.
!! @param punit : Optional argument that is no longer used.
!! @author T Craig
!<
subroutine pio_writedof (file, gdims, DOF, comm, punit)
!-----------------------------------------------------------------------
! Purpose:
!
! Write a DOF to standard format
!
! Author: T Craig
!
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
implicit none
!-----------------------------------------------------------------------
!
! Arguments
!
character(len=*),intent(in) :: file
integer, intent(in) :: gdims(:)
integer(PIO_OFFSET_KIND) ,intent(in) :: dof(:)
integer ,intent(in) :: comm
integer,optional,intent(in) :: punit
integer :: err
integer :: ndims


interface
integer(c_int) function PIOc_writemap_from_f90(file, ndims, gdims, maplen, map, f90_comm) &
Expand All @@ -207,35 +169,21 @@ end function PIOc_writemap_from_f90

end subroutine pio_writedof

!>
!! @public
!! @brief Fortran interface to read a mapping file
!! @param file : The file from where the decomp map is read.
!! @param ndims : The number of dimensions of the data.
!! @param gdims : The actual dimensions of the data (pointer to an integer array of length ndims).
!! @param DOF : Pointer to an integer array where the Decomp map will be stored.
!! @param comm : MPI comm index
!! @param punit : Optional argument that is no longer used.
!<
!>
!! Fortran interface to read a mapping file.
!!
!! @param file The file from where the decomp map is read.
!! @param ndims The number of dimensions of the data.
!! @param gdims The actual dimensions of the data (pointer to an
!! integer array of length ndims).
!! @param DOF Pointer to an integer array where the Decomp map will
!! be stored.
!! @param comm MPI comm index
!! @param punit Optional argument that is no longer used.
!! @author T Craig
!<
subroutine pio_readdof (file, ndims, gdims, DOF, comm, punit)
!-----------------------------------------------------------------------
! Purpose:
!
! Read a DOF to standard format
!
! Author: T Craig
!
! Change History
!
!-----------------------------------------------------------------------
! $Id$
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
implicit none
!-----------------------------------------------------------------------
!
! Arguments
!
character(len=*),intent(in) :: file
integer(PIO_OFFSET_KIND),pointer:: dof(:)
integer ,intent(in) :: comm
Expand All @@ -262,9 +210,7 @@ end function PIOc_readmap_from_f90

call c_f_pointer(tgdims, gdims, (/ndims/))
call c_f_pointer(tmap, DOF, (/maplen/))
! DOF = DOF+1
! DOF = DOF+1
end subroutine pio_readdof



end module pio_support

0 comments on commit 54db8b2

Please sign in to comment.