Skip to content

Commit 09c8afa

Browse files
committed
Call endrun if streams advance is being called from inside a OMP parallel loop
1 parent fabf7e4 commit 09c8afa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cpl/share_esmf/CTSMForce2DStreamBaseType.F90

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,16 @@ subroutine Advance(this)
278278
integer :: sec ! seconds into current date for nstep+1
279279
integer :: mcdate ! Current model date (yyyymmdd)
280280
integer :: rc ! Error return code
281-
281+
#ifdef _OPENMP
282+
logical, external :: omp_in_parallel
283+
#endif
284+
285+
#ifdef _OPENMP
286+
if ( omp_in_parallel() )then
287+
call endrun( 'CTSM forcing Streams Advance is being called from within an OMP loop and should NOT be', &
288+
file=sourcefile, line=__LINE__ )
289+
end if
290+
#endif
282291
! Advance sdat stream
283292
call get_curr_date(year, mon, day, sec)
284293
mcdate = year*10000 + mon*100 + day

0 commit comments

Comments
 (0)