Skip to content

Commit

Permalink
Merge branch 'improvement.f2003.move_alloc' into 'master.dev'
Browse files Browse the repository at this point in the history
Use Fortran2003 MOVE_ALLOC functionality

See merge request piclas/piclas!698
  • Loading branch information
scopplestone committed Oct 10, 2022
2 parents 9035e70 + 0ba3f2e commit 5ea01c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
25 changes: 25 additions & 0 deletions CMakeListsMachine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,31 @@ ELSE()
ENDIF()
ENDIF()

# =========================================================================
# CHECK SUPPORT FOR VARIOUS FORTRAN (2003,2008) FEATURES
# =========================================================================
INCLUDE(CheckSourceCompiles)
CHECK_SOURCE_COMPILES(Fortran
"MODULE F03MOD
IMPLICIT NONE
PRIVATE
CONTAINS
! Check for MOVE_ALLOC feature
SUBROUTINE F03_MOVE_ALLOC()
REAL,ALLOCATABLE::a(:,:),b(:,:)
ALLOCATE(a(3,3))
CALL MOVE_ALLOC(a,b)
END SUBROUTINE F03_MOVE_ALLOC
END MODULE F03MOD

PROGRAM F03PROG
END"
Fortran2003Check)

IF(NOT Fortran2003Check)
MESSAGE(ERROR "Failed to compile basic Fortran2003 programm! Please ensure your compiler is up-to-date!")
ENDIF()

MESSAGE(STATUS "Compiling with [${CMAKE_Fortran_COMPILER_ID}] (v${CMAKE_Fortran_COMPILER_VERSION}) fortran compiler using [${PICLAS_INSTRUCTION}] instruction")

# =========================================================================
Expand Down
32 changes: 6 additions & 26 deletions src/particles/restart/particle_readin.f90
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,7 @@ SUBROUTINE ParticleReadin()
DO iProc = 2,nProcessors
MPIoffsetPartRecv(iProc) = SUM(MPInPartRecv(1:iProc-1))
END DO

DEALLOCATE(PartInt)
ALLOCATE(PartInt(PartIntSize,FirstElemInd:LastElemInd))
PartInt = PartIntTmp
DEALLOCATE(PartIntTmp)
CALL MOVE_ALLOC(PartIntTmp,PartInt)
PartIntExists = .TRUE.

locnPart = PartInt(ELEM_LastPartInd,LastElemInd)-PartInt(ELEM_FirstPartInd,FirstElemInd)
Expand All @@ -308,12 +304,8 @@ SUBROUTINE ParticleReadin()
! Communicate PartData over MPI
CALL MPI_ALLTOALLV(PartData,counts_send,disp_send,MPI_STRUCT,PartDataTmp,counts_recv,disp_recv,MPI_STRUCT,MPI_COMM_WORLD,iError)
END ASSOCIATE

DEALLOCATE(PartData)
ALLOCATE(PartData(PartDataSize,offsetnPart+1_IK:offsetnPart+locnPart))
PartData = PartDataTmp
DEALLOCATE(PartDataTmp)
PartDataExists = .TRUE.
CALL MOVE_ALLOC(PartDataTmp,PartData)
PartDataExists = .TRUE.

! ------------------------------------------------
! DSMC-specific arrays
Expand All @@ -337,11 +329,7 @@ SUBROUTINE ParticleReadin()
! Communicate VibQuantData over MPI
CALL MPI_ALLTOALLV(VibQuantData,counts_send,disp_send,MPI_STRUCT,VibQuantDataTmp,counts_recv,disp_recv,MPI_STRUCT,MPI_COMM_WORLD,iError)
END ASSOCIATE

DEALLOCATE(VibQuantData)
ALLOCATE(VibQuantData(MaxQuantNum,offsetnPart+1_IK:offsetnPart+locnPart))
VibQuantData = VibQuantDataTmp
DEALLOCATE(VibQuantDataTmp)
CALL MOVE_ALLOC(VibQuantDataTmp,VibQuantData)
END IF

! Electronic
Expand All @@ -363,11 +351,7 @@ SUBROUTINE ParticleReadin()
! Communicate ElecDistriData over MPI
CALL MPI_ALLTOALLV(ElecDistriData,counts_send,disp_send,MPI_STRUCT,ElecDistriDataTmp,counts_recv,disp_recv,MPI_STRUCT,MPI_COMM_WORLD,iError)
END ASSOCIATE

DEALLOCATE(ElecDistriData)
ALLOCATE(ElecDistriData(MaxElecQuant,offsetnPart+1_IK:offsetnPart+locnPart))
ElecDistriData = ElecDistriDataTmp
DEALLOCATE(ElecDistriDataTmp)
CALL MOVE_ALLOC(ElecDistriDataTmp,ElecDistriData)
END IF

! Ambipolar Diffusion
Expand All @@ -389,11 +373,7 @@ SUBROUTINE ParticleReadin()
! Communicate AD_Data over MPI
CALL MPI_ALLTOALLV(AD_Data,counts_send,disp_send,MPI_STRUCT,AD_DataTmp,counts_recv,disp_recv,MPI_STRUCT,MPI_COMM_WORLD,iError)
END ASSOCIATE

DEALLOCATE(AD_Data)
ALLOCATE(AD_Data(3,offsetnPart+1_IK:offsetnPart+locnPart))
AD_Data = AD_DataTmp
DEALLOCATE(AD_DataTmp)
CALL MOVE_ALLOC(AD_DataTmp,AD_Data)
END IF
END IF ! useDSMC

Expand Down
6 changes: 1 addition & 5 deletions src/restart/restart_field.f90
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,7 @@ SUBROUTINE FieldRestart()
CALL MPI_TYPE_COMMIT(MPI_STRUCT,iError)
CALL MPI_ALLTOALLV(U,counts_send,disp_send,MPI_STRUCT,UTmp,counts_recv,disp_recv,MPI_STRUCT,MPI_COMM_WORLD,iError)
END ASSOCIATE

DEALLOCATE(U)
ALLOCATE(U(PP_nVar,0:PP_N,0:PP_N,0:PP_N,nElems))
U = UTmp
DEALLOCATE(UTmp)
CALL MOVE_ALLOC(UTmp,U)
END IF ! ALLOCATED(U)
#endif /*USE_HDG*/

Expand Down

0 comments on commit 5ea01c4

Please sign in to comment.