From 1ba27cf62d8ae99eeb7cefca0cc36a353002c363 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 9 Mar 2019 10:49:56 +0100 Subject: [PATCH] same reporting style, more error checks --- src/DAMASK_abaqus.f | 29 +++++++++--------- src/DAMASK_interface.f90 | 66 +++++++++++++++++++++++++++------------- src/DAMASK_marc.f90 | 31 ++++++++++--------- 3 files changed, 75 insertions(+), 51 deletions(-) diff --git a/src/DAMASK_abaqus.f b/src/DAMASK_abaqus.f index 95f843ff7..4a5b3f698 100644 --- a/src/DAMASK_abaqus.f +++ b/src/DAMASK_abaqus.f @@ -43,30 +43,31 @@ subroutine DAMASK_interface_init implicit none integer, dimension(8) :: & - dateAndTime ! type default integer + dateAndTime integer :: lenOutDir,ierr character(len=256) :: wd - call date_and_time(values = dateAndTime) - write(6,'(/,a)') ' <<<+- DAMASK_abaqus -+>>>' - write(6,'(/,a)') ' Roters et al., Computational Materials Science 158, 2018, 420-478' - write(6,'(a,/)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' + write(6,'(/,a)') ' <<<+- DAMASK_abaqus init -+>>>' - write(6,'(a,/)') ' Version: '//DAMASKVERSION + write(6,'(/,a)') ' Roters et al., Computational Materials Science 158:420–478, 2018.' + write(6,'(a)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' + + write(6,'(/,a)') ' Version: '//DAMASKVERSION ! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md #if __INTEL_COMPILER >= 1800 - write(6,*) 'Compiled with: ', compiler_version() - write(6,*) 'Compiler options: ', compiler_options() + write(6,'(/,a)') 'Compiled with: '//compiler_version() + write(6,'(a)') 'Compiler options: '//compiler_options() #else - write(6,'(a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& - ', build date :', __INTEL_COMPILER_BUILD_DATE + write(6,'(/,a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& + ', build date :', __INTEL_COMPILER_BUILD_DATE #endif - write(6,*) 'Compiled on ', __DATE__,' at ',__TIME__ + write(6,'(/,a)') ' Compiled on: '//__DATE__//' at '//__TIME__ - write(6,'(a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) + call date_and_time(values = dateAndTime) + write(6,'(/,a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) + write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) call getoutdir(wd, lenOutDir) ierr = CHDIR(wd) @@ -75,8 +76,6 @@ subroutine DAMASK_interface_init call quit(1) endif -#include "compilation_info.f90" - end subroutine DAMASK_interface_init diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index 29596d0a0..16e7108f3 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -45,6 +45,8 @@ subroutine DAMASK_interface_init() use, intrinsic :: & iso_c_binding use PETScSys + use prec, only: & + pReal use system_routines, only: & signalusr1_C, & signalusr2_C, & @@ -101,12 +103,14 @@ subroutine DAMASK_interface_init() threadLevel, & #endif worldrank = 0, & - worldsize = 0 + worldsize = 0, & + typeSize integer, allocatable, dimension(:) :: & chunkPos integer, dimension(8) :: & dateAndTime - PetscErrorCode :: ierr + integer :: mpi_err + PetscErrorCode :: petsc_err external :: & quit @@ -117,16 +121,21 @@ subroutine DAMASK_interface_init() #ifdef _OPENMP ! If openMP is enabled, check if the MPI libary supports it and initialize accordingly. ! Otherwise, the first call to PETSc will do the initialization. - call MPI_Init_Thread(MPI_THREAD_FUNNELED,threadLevel,ierr);CHKERRQ(ierr) + call MPI_Init_Thread(MPI_THREAD_FUNNELED,threadLevel,mpi_err) + if (mpi_err /= 0) call quit(1) if (threadLevel>>' - write(6,'(/,a)') ' Roters et al., Computational Materials Science 158, 2018, 420-478' - write(6,'(a,/)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' - write(6,'(a,/)') ' Version: '//DAMASKVERSION + write(6,'(/,a)') ' Roters et al., Computational Materials Science 158:420–478, 2018.' + write(6,'(a)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' + + write(6,'(/,a)') ' Version: '//DAMASKVERSION ! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md #if defined(__GFORTRAN__) || __INTEL_COMPILER >= 1800 - write(6,*) 'Compiled with: ', compiler_version() - write(6,*) 'Compiler options: ', compiler_options() + write(6,'(/,a)') 'Compiled with: '//compiler_version() + write(6,'(a)') 'Compiler options: '//compiler_options() #elif defined(__INTEL_COMPILER) - write(6,'(a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& - ', build date :', __INTEL_COMPILER_BUILD_DATE + write(6,'(/,a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& + ', build date :', __INTEL_COMPILER_BUILD_DATE #elif defined(__PGI) - write(6,'(a,i4.4,a,i8.8)') ' Compiled with PGI fortran version :', __PGIC__,& - '.', __PGIC_MINOR__ + write(6,'(a,i4.4,a,i8.8)') ' Compiled with PGI fortran version :', __PGIC__,& + '.', __PGIC_MINOR__ #endif - write(6,*) 'Compiled on ', __DATE__,' at ',__TIME__ + write(6,'(/,a)') ' Compiled on: '//__DATE__//' at '//__TIME__ - write(6,'(a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) + call date_and_time(values = dateAndTime) + write(6,'(/,a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) + write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) + + call MPI_Type_size(MPI_INTEGER,typeSize,mpi_err) + if (mpi_err /= 0) call quit(1) + if (typeSize*8 /= bit_size(0)) then + write(6,'(a)') ' Mismatch between MPI and DAMASK integer' + call quit(1) + endif + + call MPI_Type_size(MPI_DOUBLE,typeSize,mpi_err) + if (mpi_err /= 0) call quit(1) + if (typeSize*8 /= storage_size(0.0_pReal)) then + write(6,'(a)') ' Mismatch between MPI and DAMASK real' + call quit(1) + endif call get_command(commandLine) chunkPos = IIO_stringPos(commandLine) @@ -369,7 +393,7 @@ end function getLoadCaseFile function rectifyPath(path) implicit none - character(len=*) :: path + character(len=*) :: path character(len=1024) :: rectifyPath integer :: i,j,k,l diff --git a/src/DAMASK_marc.f90 b/src/DAMASK_marc.f90 index f7317c664..7cd1e2e47 100644 --- a/src/DAMASK_marc.f90 +++ b/src/DAMASK_marc.f90 @@ -54,32 +54,33 @@ subroutine DAMASK_interface_init implicit none integer, dimension(8) :: & - dateAndTime ! type default integer + dateAndTime integer :: ierr character(len=1024) :: wd - call date_and_time(values = dateAndTime) - write(6,'(/,a)') ' <<<+- DAMASK_abaqus -+>>>' - write(6,'(/,a)') ' Roters et al., Computational Materials Science 158, 2018, 420-478' - write(6,'(a,/)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' + write(6,'(/,a)') ' <<<+- DAMASK_marc init -+>>>' - write(6,'(a,/)') ' Version: '//DAMASKVERSION + write(6,'(/,a)') ' Roters et al., Computational Materials Science 158:420–478, 2018.' + write(6,'(a)') ' https://doi.org/10.1016/j.commatsci.2018.04.030' -! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md + write(6,'(/,a)') ' Version: '//DAMASKVERSION + + ! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md #if __INTEL_COMPILER >= 1800 - write(6,*) 'Compiled with: ', compiler_version() - write(6,*) 'Compiler options: ', compiler_options() + write(6,'(/,a)') 'Compiled with: '//compiler_version() + write(6,'(a)') 'Compiler options: '//compiler_options() #else - write(6,'(a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& - ', build date :', __INTEL_COMPILER_BUILD_DATE + write(6,'(/,a,i4.4,a,i8.8)') ' Compiled with Intel fortran version :', __INTEL_COMPILER,& + ', build date :', __INTEL_COMPILER_BUILD_DATE #endif - write(6,*) 'Compiled on ', __DATE__,' at ',__TIME__ + write(6,'(/,a)') ' Compiled on: '//__DATE__//' at '//__TIME__ - write(6,'(a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) - write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) + call date_and_time(values = dateAndTime) + write(6,'(/,a,2(i2.2,a),i4.4)') ' Date: ',dateAndTime(3),'/',dateAndTime(2),'/', dateAndTime(1) + write(6,'(a,2(i2.2,a),i2.2)') ' Time: ',dateAndTime(5),':', dateAndTime(6),':', dateAndTime(7) - inquire(5, name=wd) ! determine inputputfile + inquire(5, name=wd) wd = wd(1:scan(wd,'/',back=.true.)) ierr = CHDIR(wd) if (ierr /= 0) then