Commit a944f914 authored by Daniel Wortmann's avatar Daniel Wortmann

Refactoring to make directory juDFT a standalone libraray

parent 73bbd502
......@@ -79,7 +79,8 @@ if (${FLEUR_USE_SERIAL})
add_executable(fleur ${fleur_SRC} ${c_filesFleur})
target_compile_definitions(fleur PUBLIC ${FLEUR_DEFINITIONS})
target_link_libraries(fleur ${FLEUR_LIBRARIES})
set_target_properties(fleur PROPERTIES Fortran_MODULE_DIRECTORY fleur_modules COMPILE_OPTIONS -Ifleur_modules)
target_link_libraries(fleur juDFT)
set_target_properties(fleur PROPERTIES Fortran_MODULE_DIRECTORY fleur_modules COMPILE_OPTIONS "-IjuDFT_modules -Ifleur_modules")
#inpgen executable
add_executable(inpgen ${inpgen_F77} ${inpgen_F90} ${juDFT_SRC_F90} ${c_filesInpgen})
target_compile_definitions(inpgen PUBLIC ${FLEUR_DEFINITIONS})
......
......@@ -32,5 +32,6 @@ io/writeOutParameters.f90
io/xsf_io.f90
io/xmlIntWrapFort.f90
io/xmlOutput.F90
io/iomatrix_hdf.F90
)
This diff is collapsed.
set(fleur_F77 ${fleur_F77}
)
if (${FLEUR_USE_HDF5})
set(fleur_F90 ${fleur_F90}
set(judft_HDF
juDFT/hdf_accessprp.F90
juDFT/hdf_tools.F90
juDFT/hdf_tools_attr.F90
......@@ -10,8 +8,12 @@ juDFT/hdf_tools_misc.F90
juDFT/hdf_tools_rw.F90
juDFT/hdf_tools_rw_var.F90
juDFT/hdf_tools_stride.F90)
else()
set(judft_HDF "")
endif()
set(fleur_F90 ${fleur_F90}
add_library(juDFT STATIC
${judft_HDF}
juDFT/usage_data.F90
juDFT/info.F90
juDFT/init.F90
......@@ -21,4 +23,9 @@ juDFT/string.f90
juDFT/time.F90
juDFT/args.F90
juDFT/sysinfo.F90
main/fleur_arguments.F90
juDFT/xmlOutput.F90
)
target_compile_definitions(juDFT PUBLIC ${FLEUR_DEFINITIONS})
target_link_libraries(juDFT ${FLEUR_LIBRARIES})
set_target_properties(juDFT PROPERTIES Fortran_MODULE_DIRECTORY juDFT_modules COMPILE_OPTIONS -IjuDFT_modules)
......@@ -37,6 +37,8 @@ module m_hdf_accessprp
character(len=128)::path
#ifdef CPP_HDFMPI
INCLUDE 'mpif.h'
LOGICAL :: l_mpi
CALL MPI_INITALIZED(l_mpi,ierr)
#endif
IF (.not.present(setupfile)) THEN
......@@ -61,7 +63,11 @@ module m_hdf_accessprp
readloop:DO
filename="default"
#ifdef CPP_HDFMPI
driver="mpiio"
IF (l_mpi) THEN
driver="mpiio"
ELSE
driver='default'
ENDIF
#else
driver="default"
#endif
......@@ -96,6 +102,7 @@ module m_hdf_accessprp
cycle readloop
ENDIF
#ifdef CPP_HDFMPI
IF (l_mpi) THEN
CALL MPI_BARRIER(MPI_COMM_WORLD,hdferr)
IF (index(driver,"mpiio")==1) THEN
!create info object
......@@ -122,6 +129,7 @@ module m_hdf_accessprp
if (alignment>0) CALL h5pset_alignment_f(access_prp(n), INT(0,hsize_t),alignment, hdferr)
cycle readloop
ENDIF
ENDIF
#endif
write(0,*) "Driver name unkown:",driver
call judft_error("Unkown driver",calledby="gf_io2dmat")
......
......@@ -301,8 +301,14 @@
#ifdef CPP_HDFMPI
INCLUDE 'mpif.h'
INTEGER::hdferr
CALL h5pcreate_f(H5P_DATASET_XFER_F, trans, hdferr)
CALL h5pset_dxpl_mpio_f(trans,H5FD_MPIO_INDEPENDENT_F,hdferr)
LOGICAL::l_mpi
CALL MPI_INITIALIZED(l_mpi,hdferr)
IF (l_mpi) THEN
CALL h5pcreate_f(H5P_DATASET_XFER_F, trans, hdferr)
CALL h5pset_dxpl_mpio_f(trans,H5FD_MPIO_INDEPENDENT_F,hdferr)
ELSE
trans=H5P_DEFAULT_f
ENDIF
#else
trans=H5P_DEFAULT_f
#endif
......@@ -352,8 +358,12 @@
#ifdef CPP_HDFMPI
include 'mpif.h'
INTEGER :: irank,nerr
CALL MPI_COMM_rank(MPI_COMM_WORLD,irank,nerr)
WRITE(pe,"(i4,a)") irank,":"
LOGICAL :: l_mpi
CALL MPI_INITIALIZED(l_mpi,nerr)
IF (l_mpi) THEN
CALL MPI_COMM_rank(MPI_COMM_WORLD,irank,nerr)
WRITE(pe,"(i4,a)") irank,":"
ENDIF
#endif
n = 500
IF (err>=0) RETURN
......
......@@ -18,8 +18,8 @@ contains
integer:: irank=0,ierr
#ifdef CPP_MPI
include 'mpif.h'
logical:: l_mpi=.true.
LOGICAL:: l_mpi
CALL mpi_initialized(l_mpi,ierr)
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,ierr)
#else
logical :: l_mpi=.false.
......
......@@ -47,9 +47,14 @@
#ifdef CPP_MPI
include "mpif.h"
INTEGER:: irank,ierr
CALL MPI_COMM_RANK (MPI_COMM_WORLD,irank,ierr)
WRITE(0,*) "Signal ",signal," detected on PE:",irank
LOGICAL:: mpi_init
CALL MPI_initialized(mpi_init,ierr)
IF (mpi_init) THEN
CALL MPI_COMM_RANK (MPI_COMM_WORLD,irank,ierr)
WRITE(0,*) "Signal ",signal," detected on PE:",irank
ELSE
WRITE(0,*) "Signal detected:",signal
END IF
#else
WRITE(0,*) "Signal detected:",signal
#endif
......@@ -62,7 +67,7 @@
CALL writetimes()
CALL PRINT_memory_info(0,.true.)
#ifdef CPP_MPI
CALL MPI_ABORT(MPI_COMM_WORLD,ierr)
IF (mpi_init) CALL MPI_ABORT(MPI_COMM_WORLD,ierr)
#endif
STOP "Signal"
intel_signal_handler=0
......
......@@ -50,7 +50,7 @@ CONTAINS
SUBROUTINE juDFT_error(message,calledby,hint,no,warning,file,line)
USE m_judft_usage
USE m_xmloutput
USE m_judft_xmloutput
IMPLICIT NONE
CHARACTER*(*),INTENT(IN) :: message
CHARACTER*(*),OPTIONAL,INTENT(IN) :: calledby,hint
......@@ -60,13 +60,21 @@ CONTAINS
INTEGER,INTENT(IN),OPTIONAL :: line
LOGICAL :: callstop,warn,first_pe
LOGICAL :: l_mpi=.FALSE.
INTEGER :: isize,irank,e,i
CHARACTER(len=100),ALLOCATABLE::message_list(:)
#ifdef CPP_MPI
include 'mpif.h'
LOGICAL :: first_parallel
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,e)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD,isize,e)
CALL MPI_INITALIZED(l_mpi,e)
IF (l_mpi) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,e)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD,isize,e)
ELSE
first_pe=.TRUE.
isize=1
irank=0
ENDIF
#else
first_pe=.TRUE.
isize=1
......@@ -87,7 +95,7 @@ CONTAINS
ENDIF
#ifdef CPP_MPI
CALL collect_messages(message,message_list,first_pe)
if (l_mpi) CALL collect_messages(message,message_list,first_pe)
#endif
IF (first_pe) THEN
......@@ -114,18 +122,20 @@ CONTAINS
ENDIF
ENDIF
#ifdef CPP_MPI
WRITE(0,'(a,i0,a,i0)') "Error from PE:",irank,"/",isize
first_parallel=.TRUE.
DO i=0,isize-1
IF (i==irank) CYCLE
IF (LEN_TRIM(message_list(i))>1)THEN
IF (first_parallel) THEN
WRITE(0,'(2a)') "Other PEs with error messages:"
first_parallel=.FALSE.
IF (l_mpi) THEN
WRITE(0,'(a,i0,a,i0)') "Error from PE:",irank,"/",isize
first_parallel=.TRUE.
DO i=0,isize-1
IF (i==irank) CYCLE
IF (LEN_TRIM(message_list(i))>1)THEN
IF (first_parallel) THEN
WRITE(0,'(2a)') "Other PEs with error messages:"
first_parallel=.FALSE.
END IF
WRITE(0,'(a,i4,2a)') " ",i,"-",message_list(i)
END IF
WRITE(0,'(a,i4,2a)') " ",i,"-",message_list(i)
END IF
END DO
END DO
END IF
#endif
WRITE(0,'(2a)') "*****************************************"
......@@ -174,18 +184,20 @@ CONTAINS
SUBROUTINE juDFT_END(message, irank, l_endXML)
! If irank is present every mpi process has to call this routine.
! Otherwise only a single mpi process is allowed to call the routine.
USE m_xmlOutput
USE m_judft_xmlOutput
USE m_judft_usage
IMPLICIT NONE
#ifdef CPP_MPI
INCLUDE 'mpif.h'
INTEGER :: ierr
#endif
CHARACTER*(*), INTENT(IN) :: message
INTEGER, OPTIONAL, INTENT(IN) :: irank
LOGICAL, OPTIONAL, INTENT(IN) :: l_endXML
LOGICAL l_endXML_local
LOGICAL :: l_mpi=.false.
#ifdef CPP_MPI
INCLUDE 'mpif.h'
INTEGER :: ierr
CALL MPI_INITALIZED(l_mpi,ierr)
#endif
l_endXML_local = .TRUE.
IF(PRESENT(l_endXML)) THEN
......@@ -211,13 +223,15 @@ CONTAINS
CALL print_memory_info(0,.true.)
CALL send_usage_data()
#ifdef CPP_MPI
IF(PRESENT(irank)) THEN
write (*,*) "Going into post send barrier"
CALL MPI_BARRIER(MPI_COMM_WORLD,ierr)
CALL MPI_FINALIZE(ierr)
ELSE
CALL juDFT_STOP(0)
END IF
IF (l_mpi) THEN
IF(PRESENT(irank)) THEN
WRITE (*,*) "Going into post send barrier"
CALL MPI_BARRIER(MPI_COMM_WORLD,ierr)
CALL MPI_FINALIZE(ierr)
ELSE
CALL juDFT_STOP(0)
END IF
ENDIF
#endif
STOP 'OK'
END SUBROUTINE juDFT_END
......@@ -227,16 +241,16 @@ CONTAINS
SUBROUTINE juDFT_stop(errorCode)
#ifdef __INTEL_COMPILER
USE ifcore
#endif
#ifdef CPP_MPI
INCLUDE 'mpif.h'
#endif
INTEGER, OPTIONAL, INTENT(IN) :: errorCode
INTEGER :: error
LOGICAL :: calltrace
LOGICAL,ALLOCATABLE::a(:)
LOGICAL :: l_mpi=.FALSE.
#ifdef CPP_MPI
INTEGER :: ierr
INCLUDE 'mpif.h'
CALL mpi_initialized(l_mpi,ierr)
#endif
error = 0
......@@ -258,14 +272,16 @@ CONTAINS
ENDIF
#if defined(CPP_MPI)
IF(error.EQ.0) THEN
WRITE(0,*) ""
WRITE(0,*) "Terminating all MPI processes."
WRITE(0,*) "Note: This is a normal procedure."
WRITE(0,*) " Error messages in the following lines can be ignored."
WRITE(0,*) ""
END IF
CALL MPI_ABORT(MPI_COMM_WORLD,error,ierr)
IF (l_mpi) THEN
IF(error.EQ.0) THEN
WRITE(0,*) ""
WRITE(0,*) "Terminating all MPI processes."
WRITE(0,*) "Note: This is a normal procedure."
WRITE(0,*) " Error messages in the following lines can be ignored."
WRITE(0,*) ""
END IF
CALL MPI_ABORT(MPI_COMM_WORLD,error,ierr)
ENDIF
#endif
STOP 'juDFT-STOPPED'
END SUBROUTINE juDFT_stop
......
......@@ -23,9 +23,15 @@ CONTAINS
LOGICAL,INTENT(IN),OPTIONAL :: maxmem
CHARACTER(LEN=1024):: line
INTEGER :: err,irank
LOGICAL :: l_mpi=.FALSE.
#ifdef CPP_MPI
INCLUDE 'mpif.h'
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,err)
CALL mpi_initialized(l_mpi,err)
IF (l_mpi) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,err)
ELSE
irank=0
ENDIF
#else
irank=0
#endif
......@@ -80,7 +86,7 @@ CONTAINS
SUBROUTINE checkstack()
CHARACTER(LEN=10):: l1,l2,l3,l4
INTEGER :: err
LOGICAL :: unlimited
LOGICAL :: unlimited,l_mpi
#ifdef CPP_MPI
include 'mpif.h'
INTEGER:: ierr,irank
......@@ -97,7 +103,9 @@ CONTAINS
ENDDO
999 CLOSE(99,IOSTAT=err)
#ifdef CPP_MPI
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,ierr)
CALL mpi_initialized(l_mpi,ierr)
irank=0
if (l_mpi) CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,ierr)
IF (irank.NE.0) THEN
IF (.NOT.unlimited) WRITE(*,*)"Warning, stacksize limited at PE:",irank
RETURN
......
......@@ -12,7 +12,7 @@ MODULE m_juDFT_time
! called with suitable names for timers
! Daniel Wortmann, Fri Sep 6 11:53:08 2002
!*****************************************************************
USE m_xmlOutput
USE m_judft_xmlOutput
IMPLICIT NONE
! List of different timers
PRIVATE
......@@ -95,10 +95,6 @@ CONTAINS
INTEGER, INTENT(IN), OPTIONAL :: line
INTEGER::n
#ifdef CPP_MPI
INTEGER::irank, ierr
INCLUDE 'mpif.h'
#endif
IF (PRESENT(file)) lastfile = file
IF (PRESENT(line)) lastline = line
IF (.NOT. ASSOCIATED(current_timer)) THEN
......@@ -158,13 +154,19 @@ CONTAINS
CHARACTER(LEN=*), INTENT(IN):: startstop, name
#ifdef CPP_MPI
INTEGER::irank, ierr
LOGICAL:: l_mpi
INCLUDE 'mpif.h'
#endif
IF (.NOT. l_debug) RETURN
if (debugtimestart < 0) debugtimestart = cputime()
#ifdef CPP_MPI
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, ierr)
WRITE (*, "(i3,3a,f20.2,5x,a)") irank, startstop, name, " at:", cputime() - debugtimestart, memory_usage_string()
CALL MPI_INITALIZED(l_mpi,ierr)
IF (l_mpi) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, ierr)
WRITE (*, "(i3,3a,f20.2,5x,a)") irank, startstop, name, " at:", cputime() - debugtimestart, memory_usage_string()
ELSE
WRITE (*, "(3a,f20.2,5x,a)") startstop, name, " at:", cputime() - debugtimestart, memory_usage_string()
ENDIF
#else
WRITE (*, "(3a,f20.2,5x,a)") startstop, name, " at:", cputime() - debugtimestart, memory_usage_string()
#endif
......@@ -353,9 +355,10 @@ CONTAINS
CHARACTER(len=:), allocatable :: json_str
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err, isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
INTEGER::err,isize
LOGICAL:: l_mpi
CALL mpi_initialized(l_mpi,err)
if (l_mpi) CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
#endif
IF (.NOT. ASSOCIATED(globaltimer)) RETURN !write nothing if no timing recorded
l_out = .FALSE.
......@@ -376,8 +379,10 @@ CONTAINS
WRITE (fn, "('Total execution time: ',i0,'sec, minimal timing printed:',i0,'sec')") &
INT(globaltimer%time), INT(min_time*globaltimer%time)
#ifdef CPP_MPI
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, isize, err)
WRITE (fn, *) "Program used ", isize, " PE"
IF (l_mpi) THEN
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, isize, err)
WRITE (fn, *) "Program used ", isize, " PE"
ENDIF
#endif
CALL priv_writetimes(globaltimer, 1, fn)
......@@ -410,8 +415,9 @@ CONTAINS
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err, isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
LOGICAL:: l_mpi
CALL mpi_initialized(l_mpi,err)
IF (l_mpi) CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
#endif
IF (irank .NE. 0) RETURN
......@@ -486,7 +492,9 @@ CONTAINS
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err, isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
LOGICAL:: l_mpi
CALL mpi_initialized(l_mpi,err)
if (l_mpi) CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
#endif
IF (.NOT. l_cont) RETURN !stop anyway
......@@ -519,8 +527,9 @@ CONTAINS
#ifdef CPP_MPI
INCLUDE "mpif.h"
INTEGER::err, isize
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
LOGICAL:: l_mpi
CALL mpi_initialized(l_mpi,err)
if (l_mpi) CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, err)
#endif
!Check if not enough time for another iteration is left
......
......@@ -88,9 +88,12 @@ CONTAINS
INTEGER(8) :: r
#ifdef CPP_MPI
INCLUDE 'mpif.h'
CALL MPI_COMM_RANK(MPI_COMM_WORLD,i,ierr)
IF (i.NE.0) RETURN
LOGICAL MPI_init
CALL MPI_INITALIZED(mpi_init,ierr)
IF (mpi_init) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD,i,ierr)
IF (i.NE.0) RETURN
ENDIF
#endif
!#ifdef CPP_ALLOW_USAGE_DATA
......
This diff is collapsed.
......@@ -6,7 +6,6 @@ main/fleur.F90
main/fleur_init.F90
main/fleur_job.F90
main/fleur_help.F90
main/fleur_arguments.F90
main/fleur_info.f90
main/mix.F90
main/optional.F90
......
......@@ -117,7 +117,7 @@
input%gw_neigd = 0
!-t3e
IF (mpi%irank.EQ.0) THEN
CALL startXMLOutput()
CALL startFleur_XMLOutput()
IF (judft_was_argument("-info")) THEN
CLOSE(6)
OPEN (6,status='SCRATCH')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment