From 113d627f942e0fe6fafb880112e043713942c894 Mon Sep 17 00:00:00 2001
From: Pedro Costa
Date: Mon, 22 Jul 2024 15:59:25 +0200
Subject: [PATCH] Fixes possible race condition.
Co-authored-by: Maochao Xiao
---
src/main.f90 | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main.f90 b/src/main.f90
index a7d3d11d..ec8ab670 100644
--- a/src/main.f90
+++ b/src/main.f90
@@ -323,6 +323,7 @@ program cans
! post-process and write initial condition
!
write(fldnum,'(i7.7)') istep
+ !$acc wait ! not needed but to prevent possible future issues
!$acc update self(u,v,w,p)
include 'out1d.h90'
include 'out2d.h90'
@@ -514,14 +515,17 @@ program cans
end if
write(fldnum,'(i7.7)') istep
if(mod(istep,iout1d) == 0) then
+ !$acc wait
!$acc update self(u,v,w,p)
include 'out1d.h90'
end if
if(mod(istep,iout2d) == 0) then
+ !$acc wait
!$acc update self(u,v,w,p)
include 'out2d.h90'
end if
if(mod(istep,iout3d) == 0) then
+ !$acc wait
!$acc update self(u,v,w,p)
include 'out3d.h90'
end if
@@ -541,6 +545,7 @@ program cans
call out0d(trim(datadir)//'log_checkpoints.out',3,var)
end if
end if
+ !$acc wait
!$acc update self(u,v,w,p)
call load_all('w',trim(datadir)//trim(filename),MPI_COMM_WORLD,ng,[1,1,1],lo,hi,u,v,w,p,time,istep)
if(.not.is_overwrite_save) then