Skip to content

Commit

Permalink
LIBSTELL: Cleanup and bugfix for memory in mumaterial
Browse files Browse the repository at this point in the history
  • Loading branch information
lazersos committed Oct 28, 2023
1 parent 3e32f65 commit 5e87e49
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions LIBSTELL/Sources/Modules/mumaterial_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ SUBROUTINE mumaterial_init(getBfld, comm, offset)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Allocate helpers and Neighbors
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NULLIFY(N_store,neighbours)
k = ntet+1
IF (maxNb .gt. 0) k = maxNb+1
#if defined(MPI_OPT)
Expand Down Expand Up @@ -473,7 +474,7 @@ SUBROUTINE mumaterial_init(getBfld, comm, offset)
IF (lcomm) CALL MPI_BARRIER(shar_comm,istat)
#endif

!IF (ASSOCIATED(neighbours)) CALL free_mpi_array2d_int(win_neighbours,neighbours,lcomm)
IF (ASSOCIATED(neighbours)) CALL free_mpi_array2d_int(win_neighbours,neighbours,lcomm)
IF (ASSOCIATED(N_store))CALL free_mpi_array4d_dbl(win_N_store,N_store,lcomm)

RETURN
Expand Down Expand Up @@ -526,6 +527,7 @@ SUBROUTINE mumaterial_iterate_magnetization(lambdaStart, lambdaFac, N1, N_store,
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Allocate Helper Arrays
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
NULLIFY(M_new,chi,Mnorm,Mnorm_old)
#if defined(MPI_OPT)
CALL mpialloc_2d_dbl(M_new,3,ntet,shar_rank,0,shar_comm,win_M_new)
CALL mpialloc_1d_dbl(chi,ntet,shar_rank,0,shar_comm,win_chi)
Expand Down Expand Up @@ -629,14 +631,10 @@ SUBROUTINE mumaterial_iterate_magnetization(lambdaStart, lambdaFac, N1, N_store,
Hnorm = NORM2(H_new)
IF (Hnorm .ne. 0) THEN
CALL mumaterial_getState(stateFunction(state_dex(i_tile))%H, stateFunction(state_dex(i_tile))%M, Hnorm, M_tmp_norm)
!M_new_local(:,i_tile) = M_tmp_norm * H_new / Hnorm
M_new(:,i_tile) = M_tmp_norm * H_new / Hnorm
!chi_local(i_tile) = M_tmp_norm / Hnorm
chi(i_tile) = M_tmp_norm / Hnorm
ELSE
!M_new_local(:,i_tile) = 0
M_new(:,i_tile) = 0
!chi_local(i_tile) = 0
chi(i_tile) = 0
END IF
EXIT
Expand Down

0 comments on commit 5e87e49

Please sign in to comment.