Skip to content

Commit acf1739

Browse files
committed
SeaState: Add OMP critical around file open
`!$ OMP critical` directives were added to all other modules in the 3.5.5 updates, but new modules don't include these
1 parent 840be1f commit acf1739

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

modules/seastate/src/SeaState_Input.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ subroutine SeaSt_ParseInput( InputFileName, OutRootName, defWtrDens, defWtrDpth,
271271
if (Failed()) return;
272272

273273
! WvKinFile
274-
call ParseVar( FileInfo_In, CurLine, 'WvKinFile', InputFileData%Waves%WvKinFile, ErrStat2, ErrMsg2, UnEc )
274+
call ParseVar( FileInfo_In, CurLine, 'WvKinFile', InputFileData%Waves%WvKinFile, ErrStat2, ErrMsg2, UnEc, IsPath=.true. )
275275
if (Failed()) return;
276276

277277
!-------------------------------------------------------------------------------------------------

modules/seastate/src/SeaState_Output.f90

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,12 @@ SUBROUTINE SeaStOut_WriteWvKinFiles( Rootname, SeaSt_Prog, WaveField, WaveDT, X_
280280

281281
DO iFile = 1,7
282282

283-
CALL GetNewUnit( UnWv )
284283

285284
WvName = TRIM(Rootname) // TRIM(extension(iFile))
285+
!$OMP critical(fileopen)
286+
CALL GetNewUnit( UnWv )
286287
CALL OpenFOutFile ( UnWv, WvName, ErrStat, ErrMsg )
288+
!$OMP end critical(fileopen)
287289
IF (ErrStat >=AbortErrLev) RETURN
288290

289291
call WriteWvKinHeader( UnWv, iFile, Delim, SeaSt_Prog, waveDT, -z_gridPts(1), NGrid, deltaGrid )
@@ -330,11 +332,11 @@ SUBROUTINE SeaStOut_WriteWvKinFiles( Rootname, SeaSt_Prog, WaveField, WaveDT, X_
330332
END DO
331333

332334
! WaveElevation Grid
333-
334-
CALL GetNewUnit( UnWv )
335-
336335
WvName = TRIM(Rootname) // '.Elev'
336+
!$OMP critical(fileopen)
337+
CALL GetNewUnit( UnWv )
337338
CALL OpenFOutFile ( UnWv, WvName, ErrStat, ErrMsg )
339+
!$OMP end critical(fileopen)
338340
IF (ErrStat >=AbortErrLev) RETURN
339341

340342

@@ -444,13 +446,15 @@ subroutine SeaStOut_WriteWaveElev0( Rootname, NStepWave, NGrid, WaveElev1, WaveE
444446
ErrMsg = ""
445447
Frmt = '(F12.4,ES12.4e2)'
446448
Frmt2 = '(2(A12))'
447-
CALL GetNewUnit( UnWv )
448449

449450

450451
WvName = TRIM(Rootname) // '.Elev'
451452
i = NGrid(1) / 2 + 1
452453
j = NGrid(2) / 2 + 1
454+
!$OMP critical(fileopen)
455+
CALL GetNewUnit( UnWv )
453456
CALL OpenFOutFile ( UnWv, WvName, ErrStat, ErrMsg )
457+
!$OMP end critical(fileopen)
454458
IF (ErrStat >=AbortErrLev) RETURN
455459
! WRITE (UnWv,'(A)', IOSTAT=ErrStat) 'This wave elevation (0,0) file was generated by '//TRIM( SeaSt_Prog%Name )//&
456460
! ' '//TRIM( SeaSt_Prog%Ver )//' on '//CurDate()//' at '//CurTime()//'.'
@@ -718,9 +722,11 @@ SUBROUTINE SeaStOut_OpenOutput( SeaSt_ProgDesc, OutRootName, p, InitOut, ErrSta
718722

719723
! Open the file for output
720724
OutFileName = TRIM(OutRootName)//'.out'
725+
726+
!$OMP critical(fileopen)
721727
CALL GetNewUnit( p%UnOutFile )
722-
723728
CALL OpenFOutFile ( p%UnOutFile, OutFileName, ErrStat, ErrMsg )
729+
!$OMP end critical(fileopen)
724730
IF (ErrStat >=AbortErrLev) RETURN
725731

726732

@@ -1011,9 +1017,11 @@ SUBROUTINE SeaStOut_WrSummaryFile(InitInp, InputFileData, p, ErrStat, ErrMsg )
10111017

10121018
SummaryName = trim(InitInp%OutRootName)//'.sum'
10131019
UnSum = -1
1014-
CALL GetNewUnit( UnSum )
10151020

1021+
!$OMP critical(fileopen)
1022+
CALL GetNewUnit( UnSum )
10161023
CALL OpenFOutFile ( UnSum, SummaryName, ErrStat2, ErrMsg2 )
1024+
!$OMP end critical(fileopen)
10171025
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
10181026
IF (ErrStat >=AbortErrLev) RETURN
10191027

modules/seastate/src/UserWaves.f90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ SUBROUTINE WaveElev_ReadFile ( InitInp, WaveElevData, ErrStat, ErrMsg )
144144
ErrStat = ErrID_None
145145
ErrMsg = ""
146146

147-
! Get a unit number for reading in the file
148-
CALL GetNewUnit( WaveElevUnit )
149-
150147
! Assemble the filename for the wave elevation data.
151148
WaveElevData%FileName = TRIM(InitInp%WvKinFile)//'.Elev'
152149

153150
! Open the file containing the wave elevation timeseries
151+
!$OMP critical(fileopen)
152+
CALL GetNewUnit( WaveElevUnit )
154153
CALL OpenFInpFile( WaveElevUnit, WaveElevData%FileName, ErrStatTmp, ErrMsgTmp )
154+
!$OMP end critical(fileopen)
155155
CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat,ErrMsg, RoutineName)
156156
IF (ErrStat >= AbortErrLev) THEN
157157
CLOSE ( WaveElevUnit )
@@ -492,11 +492,13 @@ SUBROUTINE UserWaves_Init ( InitInp, InitOut, WaveField, ErrStat, ErrMsg )
492492

493493
! Read the first file and set the initial values of the
494494
DO iFile = 1,7
495-
CALL GetNewUnit( UnWv )
496495

497496
FileName = TRIM(InitInp%WvKinFile) // TRIM(extension(iFile))
498497

498+
!$OMP critical(fileopen)
499+
CALL GetNewUnit( UnWv )
499500
CALL OpenFInpFile ( UnWv, FileName, ErrStatTmp, ErrMsgTmp )
501+
!$OMP end critical(fileopen)
500502
IF ( ErrStatTmp /= 0 ) THEN
501503
ErrMsgTmp = 'Failed to open wave kinematics file, ' // TRIM(FileName)
502504
CALL SetErrStat( ErrID_Fatal, ErrMsgTmp, ErrStat, ErrMsg, RoutineName )
@@ -552,11 +554,13 @@ SUBROUTINE UserWaves_Init ( InitInp, InitOut, WaveField, ErrStat, ErrMsg )
552554
end do
553555

554556
! WaveElev
555-
CALL GetNewUnit( UnWv )
556557

557558
FileName = TRIM(InitInp%WvKinFile) // '.Elev'
558559

560+
!$OMP critical(fileopen)
561+
CALL GetNewUnit( UnWv )
559562
CALL OpenFInpFile ( UnWv, FileName, ErrStatTmp, ErrMsgTmp )
563+
!$OMP end critical(fileopen)
560564
IF ( ErrStatTmp /= 0 ) THEN
561565
ErrMsgTmp = 'Failed to open wave elevation file, ' // TRIM(FileName)
562566
CALL SetErrStat( ErrID_Fatal, ErrMsgTmp, ErrStat, ErrMsg, RoutineName )
@@ -691,14 +695,14 @@ SUBROUTINE WaveComp_ReadFile ( InitInp, WaveDOmega, WaveCompData, ErrStat, ErrMs
691695
ErrStat = ErrID_None
692696
ErrMsg = ""
693697

694-
! Get a unit number for reading in the file
695-
CALL GetNewUnit( WaveCompUnit )
696-
697698
! Assemble the filename for the wave component data.
698699
WaveCompData%FileName = TRIM(InitInp%WvKinFile)
699700

700701
! Open the file containing the list of wave components
702+
!$OMP critical(fileopen)
703+
CALL GetNewUnit( WaveCompUnit )
701704
CALL OpenFInpFile( WaveCompUnit, WaveCompData%FileName, ErrStatTmp, ErrMsgTmp )
705+
!$OMP end critical(fileopen)
702706
CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat,ErrMsg, RoutineName)
703707
IF (ErrStat >= AbortErrLev) THEN
704708
CALL CleanUpError()

0 commit comments

Comments
 (0)