mpi_dist_forcetheorem.F90 2.01 KB
Newer Older
1 2 3 4 5 6 7 8
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

MODULE m_mpi_dist_forcetheorem
CONTAINS
9
#ifndef CPP_OLDINTEL
10
  SUBROUTINE mpi_dist_forcetheorem(mpi,forcetheo)
11 12
    USE m_types_mpi
    USE m_types_forcetheo, ONLY: t_forcetheo
13
    USE m_types_forcetheo_extended
14 15 16 17 18 19 20 21 22 23 24 25 26 27
    IMPLICIT NONE
    TYPE(t_mpi),INTENT(in)::mpi
    CLASS(t_forcetheo),ALLOCATABLE,INTENT(INOUT)::forcetheo

    INTEGER::t,ierr
#ifdef CPP_MPI
    INCLUDE 'mpif.h'
    
    IF (mpi%irank==0) THEN
       SELECT TYPE(forcetheo)
       TYPE IS (t_forcetheo)
          t=1
       TYPE IS (t_forcetheo_mae)
          t=2
28 29 30 31 32 33
       TYPE IS (t_forcetheo_ssdisp)
          t=3
       TYPE IS (t_forcetheo_dmi)
          t=4
       TYPE IS (t_forcetheo_jij)
          t=5
34 35 36 37
       END SELECT
    ENDIF   
    CALL MPI_BCAST(t,1,MPI_INTEGER,0,mpi%mpi_comm,ierr)
    IF (mpi%irank.NE.0) THEN
38
       IF (ALLOCATED(forcetheo)) DEALLOCATE(forcetheo)
39
       SELECT CASE (t)
40
       CASE(1)
41 42 43
          ALLOCATE(t_forcetheo::forcetheo)
       CASE(2)
          ALLOCATE(t_forcetheo_mae::forcetheo)
44 45 46 47 48 49
       CASE(3)
          ALLOCATE(t_forcetheo_ssdisp::forcetheo)
       CASE(4)
          ALLOCATE(t_forcetheo_dmi::forcetheo)
       CASE(5)
          ALLOCATE(t_forcetheo_jij::forcetheo)
50 51 52 53 54 55 56
       END SELECT
    END IF

    !now we have the correct type, now we have to distribute the data
    SELECT TYPE(forcetheo)
    TYPE IS (t_forcetheo_mae)
       CALL forcetheo%dist(mpi)
57 58 59 60 61 62
    TYPE IS (t_forcetheo_ssdisp)
       CALL forcetheo%dist(mpi)
    TYPE IS (t_forcetheo_dmi)
       CALL forcetheo%dist(mpi)
    TYPE IS (t_forcetheo_jij)
       CALL forcetheo%dist(mpi)
63 64 65
    END SELECT
#endif
  END SUBROUTINE mpi_dist_forcetheorem
66 67 68
#else
#endif

69
END MODULE m_mpi_dist_forcetheorem