From 2cf904fe49a7b1de6a2e63fa031b674f34c5253a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 28 Feb 2022 18:54:46 +0100 Subject: [PATCH] output to logfile helfulf for debug, especially with MPI --- src/DAMASK_interface.f90 | 3 +-- src/parallelization.f90 | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index f5233f2f0..e958c8a29 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -70,9 +70,8 @@ subroutine DAMASK_interface_init external :: & quit - print'(/,1x,a)', '<<<+- DAMASK_interface init -+>>>' - if(worldrank == 0) open(OUTPUT_UNIT, encoding='UTF-8') ! for special characters in output + print'(/,1x,a)', '<<<+- DAMASK_interface init -+>>>' ! http://patorjk.com/software/taag/#p=display&f=Lean&t=DAMASK%203 #ifdef DEBUG diff --git a/src/parallelization.f90 b/src/parallelization.f90 index 28ad70d94..cea4a8d94 100644 --- a/src/parallelization.f90 +++ b/src/parallelization.f90 @@ -86,17 +86,27 @@ subroutine parallelization_init if (err_MPI /= 0_MPI_INTEGER_KIND) & error stop 'Could not determine worldrank' - if (worldrank == 0) then - print'(/,1x,a)', '<<<+- parallelization init -+>>>' - - call MPI_Get_library_version(MPI_library_version,devNull,err_MPI) - print'(/,1x,a)', trim(MPI_library_version) - call MPI_Get_version(version,subversion,err_MPI) - print'(1x,a,i0,a,i0)', 'MPI standard: ',version,'.',subversion -#ifdef _OPENMP - print'(1x,a,i0)', 'OpenMP version: ',openmp_version +#ifdef LOGFILE + write(rank_str,'(i4.4)') worldrank + open(OUTPUT_UNIT,file='log.'//rank_str,status='replace',encoding='UTF-8') +#else + if (worldrank /= 0) then + close(OUTPUT_UNIT) ! disable output + open(OUTPUT_UNIT,file='/dev/null',status='replace') ! close() alone will leave some temp files in cwd + else + open(OUTPUT_UNIT,encoding='UTF-8') ! for special characters in output + endif +#endif + + print'(/,1x,a)', '<<<+- parallelization init -+>>>' + + call MPI_Get_library_version(MPI_library_version,devNull,err_MPI) + print'(/,1x,a)', trim(MPI_library_version) + call MPI_Get_version(version,subversion,err_MPI) + print'(1x,a,i0,a,i0)', 'MPI standard: ',version,'.',subversion +#ifdef _OPENMP + print'(1x,a,i0)', 'OpenMP version: ',openmp_version #endif - end if call MPI_Comm_size(MPI_COMM_WORLD,worldsize,err_MPI) if (err_MPI /= 0_MPI_INTEGER_KIND) & @@ -121,12 +131,6 @@ subroutine parallelization_init if (typeSize*8_MPI_INTEGER_KIND /= int(storage_size(0.0_pReal),MPI_INTEGER_KIND)) & error stop 'Mismatch between MPI_DOUBLE and DAMASK pReal' - if (worldrank /= 0) then - close(OUTPUT_UNIT) ! disable output - write(rank_str,'(i4.4)') worldrank ! use for MPI debug filenames - open(OUTPUT_UNIT,file='/dev/null',status='replace') ! close() alone will leave some temp files in cwd - endif - !$ call get_environment_variable(name='OMP_NUM_THREADS',value=NumThreadsString,STATUS=got_env) !$ if(got_env /= 0) then !$ print'(1x,a)', 'Could not get $OMP_NUM_THREADS, using default'