From 9c62d482bf566c0f1b4c3e9c590b7a49c5a04a0f Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 15 Mar 2024 16:34:53 -0600 Subject: [PATCH 1/5] More bug fixes in the WAMIT module of HydroDyn associated with wave headings --- modules/hydrodyn/src/WAMIT.f90 | 80 +++++++++++++++------------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/modules/hydrodyn/src/WAMIT.f90 b/modules/hydrodyn/src/WAMIT.f90 index e256247382..e5049a9a8c 100644 --- a/modules/hydrodyn/src/WAMIT.f90 +++ b/modules/hydrodyn/src/WAMIT.f90 @@ -189,7 +189,7 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, ErrS real(ReKi) :: WaveNmbr ! Frequency-dependent wave number COMPLEX(SiKi) :: Fxy ! Phase correction term for Wave excitation forces real(ReKi) :: tmpAngle ! Frequency and heading and platform offset dependent phase shift angle for Euler's Equation e^(-j*tmpAngle) - COMPLEX(SiKi), ALLOCATABLE :: HdroExctn_Local (:,:,:) ! Temporary Frequency- and direction-dependent complex hydrodynamic wave excitation force per unit wave amplitude vector (kg/s^2, kg-m/s^2) + REAL(ReKi) :: RotateZdegOffset ! PtfmRefZtRot converted to degrees ! Error handling CHARACTER(ErrMsgLen) :: ErrMsg2 ! Temporary error message for calls INTEGER(IntKi) :: ErrStat2 ! Temporary error status for calls @@ -954,7 +954,13 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, ErrS ! NOTE: we may end up inadvertantly aborting if the wave direction crosses ! the -Pi / Pi boundary (-180/180 degrees). - IF ( ( p%WaveField%WaveDirMin < HdroWvDir(1) ) .OR. ( p%WaveField%WaveDirMax > HdroWvDir(NInpWvDir) ) ) THEN + ! Need to account for PtfmRefZtRot if NBodyMod=2 (NBody=1 in the case) + IF ( p%NBodyMod == 2 ) THEN + RotateZdegOffset = InitInp%PtfmRefztRot(1)*R2D + ELSE + RotateZdegOffset = 0.0 + END IF + IF ( ( (p%WaveField%WaveDirMin-RotateZdegOffset) HdroWvDir(NInpWvDir) ) ) THEN ErrMsg2 = 'All Wave directions must be within the wave heading angle range available in "' & //TRIM(InitInp%WAMITFile)//'.3" (inclusive).' CALL SetErrStat( ErrID_Fatal, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -1003,46 +1009,35 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, ErrS if ( p%NBodyMod == 2 ) then ! Since NBodyMod = 2, then NBody = 1 for this WAMIT object (this requirement is encoded at the HydroDyn module level) - - allocate ( HdroExctn_Local(NInpFreq, NInpWvDir, 6), STAT=ErrStat2 ) - IF ( ErrStat2 /= 0 ) THEN - CALL SetErrStat( ErrID_Fatal, 'Error allocating memory for the HdroExctn_Local array.', ErrStat, ErrMsg, RoutineName) - CALL Cleanup() - RETURN - END IF - - do K = 1,6 ! Loop through all wave excitation forces and moments - do J = 1, NInpWvDir - TmpCoord(2) = HdroWvDir(J) - InitInp%PtfmRefztRot(1)*R2D ! apply locale Z rotation to heading angle (degrees) - do I = 1, NInpFreq - TmpCoord(1) = HdroFreq(I) - ! Iterpolate to find new coef - call WAMIT_Interp2D_Cplx( TmpCoord, HdroExctn(:,:,K), HdroFreq, HdroWvDir, LastInd2, HdroExctn_Local(I,J,K), ErrStat2, ErrMsg2 ) - end do - end do - end do - - ! Now apply rotation and phase shift + ! HdroWvDir from WAMIT is effectively in the body-local coordinate system. Need to offset HdroWvDir to be back in the global frame + HdroWvDir = HdroWvDir + InitInp%PtfmRefztRot(1)*R2D + ! Now apply rotation and phase shift do J = 1, NInpWvDir do I = 1, NInpFreq - ! Fxy = exp(-j * k(w) * ( X*cos(Beta(w)) + Y*sin(Beta(w)) ) + ! Fxy = exp(-j * k(w) * ( X*cos(Beta(w)) + Y*sin(Beta(w)) ) WaveNmbr = WaveNumber ( HdroFreq(I), InitInp%Gravity, p%WaveField%EffWtrDpth ) tmpAngle = WaveNmbr * ( InitInp%PtfmRefxt(1)*cos(HdroWvDir(J)*D2R) + InitInp%PtfmRefyt(1)*sin(HdroWvDir(J)*D2R) ) TmpRe = cos(tmpAngle) TmpIm = -sin(tmpAngle) Fxy = CMPLX( TmpRe, TmpIm ) - HdroExctn(I,J,1) = Fxy*( HdroExctn_Local(I,J,1)*cos(InitInp%PtfmRefztRot(1)) - HdroExctn_Local(I,J,2)*sin(InitInp%PtfmRefztRot(1)) ) - HdroExctn(I,J,2) = Fxy*( HdroExctn_Local(I,J,1)*sin(InitInp%PtfmRefztRot(1)) + HdroExctn_Local(I,J,2)*cos(InitInp%PtfmRefztRot(1)) ) - HdroExctn(I,J,3) = Fxy*( HdroExctn_Local(I,J,3) ) - HdroExctn(I,J,4) = Fxy*( HdroExctn_Local(I,J,4)*cos(InitInp%PtfmRefztRot(1)) - HdroExctn_Local(I,J,5)*sin(InitInp%PtfmRefztRot(1)) ) - HdroExctn(I,J,5) = Fxy*( HdroExctn_Local(I,J,4)*sin(InitInp%PtfmRefztRot(1)) + HdroExctn_Local(I,J,5)*cos(InitInp%PtfmRefztRot(1)) ) - HdroExctn(I,J,6) = Fxy*( HdroExctn_Local(I,J,6) ) + Ctmp1 = Fxy*( HdroExctn(I,J,1)*cos(InitInp%PtfmRefztRot(1)) - HdroExctn(I,J,2)*sin(InitInp%PtfmRefztRot(1)) ) + Ctmp2 = Fxy*( HdroExctn(I,J,1)*sin(InitInp%PtfmRefztRot(1)) + HdroExctn(I,J,2)*cos(InitInp%PtfmRefztRot(1)) ) + Ctmp4 = Fxy*( HdroExctn(I,J,4)*cos(InitInp%PtfmRefztRot(1)) - HdroExctn(I,J,5)*sin(InitInp%PtfmRefztRot(1)) ) + Ctmp5 = Fxy*( HdroExctn(I,J,4)*sin(InitInp%PtfmRefztRot(1)) + HdroExctn(I,J,5)*cos(InitInp%PtfmRefztRot(1)) ) + + HdroExctn(I,J,1) = Ctmp1 + HdroExctn(I,J,2) = Ctmp2 + HdroExctn(I,J,4) = Ctmp4 + HdroExctn(I,J,5) = Ctmp5 + + HdroExctn(I,J,3) = Fxy*( HdroExctn(I,J,3) ) + HdroExctn(I,J,6) = Fxy*( HdroExctn(I,J,6) ) end do end do - deallocate(HdroExctn_Local) + else ! Apply rotation only for NBodyMod = 1,3 @@ -1204,23 +1199,18 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, ErrS ! Now apply the phase shift in the frequency space - do J = 1, NInpWvDir - do I = 0,p%WaveField%NStepWave2 ! Loop through the positive frequency components (including zero) of the discrete Fourier transform - - ! Compute the frequency of this component: - - Omega = I*p%WaveField%WaveDOmega - ! Fxy = exp(-j * k(w) * ( X*cos(Beta(w)) + Y*sin(Beta(w)) ) - WaveNmbr = WaveNumber ( Omega, InitInp%Gravity, p%WaveField%EffWtrDpth ) - tmpAngle = WaveNmbr * ( InitInp%PtfmRefxt(1)*cos(HdroWvDir(J)*D2R) + InitInp%PtfmRefyt(1)*sin(HdroWvDir(J)*D2R) ) - TmpRe = cos(tmpAngle) - TmpIm = -sin(tmpAngle) - Fxy = CMPLX( TmpRe, TmpIm ) + do I = 0,p%WaveField%NStepWave2 ! Loop through the positive frequency components (including zero) of the discrete Fourier transform - tmpComplexArr(I) = Fxy*CMPLX(p%WaveField%WaveElevC0(1,I), p%WaveField%WaveElevC0(2,I)) - + ! Compute the phase shift of this component, Fxy = exp(-j * k(w) * ( X*cos(Beta(w)) + Y*sin(Beta(w)) ): + Omega = I*p%WaveField%WaveDOmega + WaveNmbr = WaveNumber ( Omega, InitInp%Gravity, p%WaveField%EffWtrDpth ) + tmpAngle = WaveNmbr * ( InitInp%PtfmRefxt(1)*cos(p%WaveField%WaveDirArr(I)*D2R) + InitInp%PtfmRefyt(1)*sin(p%WaveField%WaveDirArr(I)*D2R) ) + TmpRe = cos(tmpAngle) + TmpIm = -sin(tmpAngle) + Fxy = CMPLX( TmpRe, TmpIm ) - end do + ! Apply phase shift + tmpComplexArr(I) = Fxy*CMPLX(p%WaveField%WaveElevC0(1,I), p%WaveField%WaveElevC0(2,I)) end do ! Compute the inverse discrete Fourier transforms to find the time-domain From f782d5e2e27b7236e8afe118227e3d566027e6a8 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 15 Mar 2024 13:07:45 -0600 Subject: [PATCH 2/5] Cherry-pick from commit bb0cf7ea0 --- modules/hydrodyn/src/WAMIT2.f90 | 783 +++++++++----------------------- 1 file changed, 214 insertions(+), 569 deletions(-) diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index 37d8d7f73d..c655352997 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -180,6 +180,10 @@ MODULE WAMIT2 TYPE(W2_InitData4D_Type) :: Data4D !< The 4D type from above END TYPE W2_SumData_Type + INTERFACE CheckWamit2WvHdg + MODULE PROCEDURE CheckWAMIT2WvHdgDiffData + MODULE PROCEDURE CheckWAMIT2WvHdgSumData + END INTERFACE CheckWamit2WvHdg CONTAINS !---------------------------------------------------------------------------------------------------------------------------------- @@ -819,188 +823,10 @@ SUBROUTINE MnDrift_InitCalc( InitInp, p, MnDriftData, MnDriftForce, ErrMsg, ErrS RETURN ENDIF - - - !> 2. Check the data to see if the wave frequencies are present in the QTF data. Since the mean drift term only uses - !! frequencies where \f$ \omega_1=\omega_2 \f$, the data read in from the files must contain the full range of frequencies - !! present in the waves. - - IF ( MnDriftData%DataIs3D ) THEN - - ! Check the low frequency cutoff - IF ( MINVAL( MnDriftData%Data3D%WvFreq1 ) > InitInp%WaveField%WvLowCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(MnDriftData%Data3D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( (MAXVAL(MnDriftData%Data3D%WvFreq1 ) < InitInp%WaveField%WvHiCOffD) ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(MnDriftData%Data3D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE IF ( MnDriftData%DataIs4D ) THEN ! only check if not 3D data. If there is 3D data, we default to using it for calculations - - ! Check the low frequency cutoff - IF ( MINVAL( MnDriftData%Data4D%WvFreq1 ) > InitInp%WaveField%WvLowCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(MnDriftData%Data4D%WvFreq1)))// & - ' rad/s first wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MINVAL( MnDriftData%Data4D%WvFreq2 ) > InitInp%WaveField%WvLowCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(MnDriftData%Data4D%WvFreq2)))// & - ' rad/s for second wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( (MAXVAL(MnDriftData%Data4D%WvFreq1) < InitInp%WaveField%WvHiCOffD) ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(MnDriftData%Data4D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( (MAXVAL(MnDriftData%Data4D%WvFreq2) < InitInp%WaveField%WvHiCOffD) ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(MnDriftData%Data4D%WvFreq1)))// & - ' rad/s second wave period) data in '//TRIM(MnDriftData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffD.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE - ! This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation - CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) - ENDIF - - IF ( ErrStat >= AbortErrLev ) RETURN - - - - !> 3. Check the data to see if the wave directions are present. May need to adjust for the boundary at +/- PI - IF ( MnDriftData%DataIs3D ) THEN - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (MnDriftData%Data3D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(MnDriftData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(MnDriftData%Data3D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (MnDriftData%Data3D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(MnDriftData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(MnDriftData%Data3D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (minval(MnDriftData%data3d%WvDir1) > 150.0_SiKi) .OR. (maxval(MnDriftData%data3d%WvDir1) < -150.0_SiKi) .OR. & - (minval(MnDriftData%data3d%WvDir2) > 150.0_SiKi) .OR. (maxval(MnDriftData%data3d%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(MnDriftData%Data3D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(MnDriftData%Data3D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(MnDriftData%Data3D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(MnDriftData%Data3D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - ELSEIF ( MnDriftData%DataIs4D ) THEN - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (MnDriftData%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(MnDriftData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(MnDriftData%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (MnDriftData%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(MnDriftData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(MnDriftData%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(MnDriftData%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(MnDriftData%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(MnDriftData%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(MnDriftData%Data4D%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( InitInp%WaveField%WaveDirMin < MINVAL(MnDriftData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(MnDriftData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(MnDriftData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(MnDriftData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(MnDriftData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - ELSE - ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation - CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) - ENDIF - + CALL CheckWAMIT2WvHdg(InitInp,MnDriftData,ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) IF ( ErrStat >= AbortErrLev ) RETURN - - !> 4. Check the data to see if we need to convert to 3D arrays before continuing (4D is sparse in any dimension we want and !! frequency diagonal is complete). Only check if we don't have 3D data. @@ -1345,193 +1171,10 @@ SUBROUTINE NewmanApp_InitCalc( InitInp, p, NewmanAppData, NewmanAppForce, ErrMsg ErrStat = ErrID_None ErrStatTmp = ErrID_None - - - !> 1. Check the data to see if the wave frequencies are present in the QTF data. Since Newman's approximation only uses - !! frequencies where \f$ \omega_1=\omega_2 \f$, the data read in from the files must contain the full range of frequencies - !! present in the waves. - IF ( NewmanAppData%DataIs3D ) THEN - - ! Check the low frequency cutoff - IF ( MINVAL( NewmanAppData%Data3D%WvFreq1 ) > InitInp%WaveField%WvLowCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(NewmanAppData%Data3D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( MAXVAL(NewmanAppData%Data3D%WvFreq1 ) < InitInp%WaveField%WvHiCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(NewmanAppData%Data3D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE IF ( NewmanAppData%DataIs4D ) THEN ! only check if not 3D data. If there is 3D data, we default to using it for calculations - - ! Check the low frequency cutoff - IF ( MINVAL( NewmanAppData%Data4D%WvFreq1 ) > InitInp%WaveField%WvLowCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(NewmanAppData%Data4D%WvFreq1)))// & - ' rad/s first wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MINVAL( NewmanAppData%Data4D%WvFreq2 ) > InitInp%WaveField%WvLowCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(NewmanAppData%Data4D%WvFreq2)))// & - ' rad/s for second wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( MAXVAL(NewmanAppData%Data4D%WvFreq1) < InitInp%WaveField%WvHiCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(NewmanAppData%Data4D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MAXVAL(NewmanAppData%Data4D%WvFreq2) < InitInp%WaveField%WvHiCOff ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(NewmanAppData%Data4D%WvFreq1)))// & - ' rad/s second wave period) data in '//TRIM(NewmanAppData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOff.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE - ! This is a catastrophic issue. We should not have called this routine without data that is usable for the NewmanApp calculation - CALL SetErrStat( ErrID_Fatal, ' Newman approximation calculation called without data.',ErrStat,ErrMsg,RoutineName) - ENDIF - + CALL CheckWAMIT2WvHdg(InitInp,NewmanAppData,ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) IF ( ErrStat >= AbortErrLev ) RETURN - - - !> 2. Check the data to see if the wave directions are present. May need to adjust for the boundary at +/- PI - IF ( NewmanAppData%DataIs3D ) THEN - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (NewmanAppData%Data3D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(NewmanAppData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(NewmanAppData%Data3D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (NewmanAppData%Data3D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(NewmanAppData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(NewmanAppData%Data3D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (minval(NewmanAppData%data3d%WvDir1) > 150.0_SiKi) .OR. (maxval(NewmanAppData%data3d%WvDir1) < -150.0_SiKi) .OR. & - (minval(NewmanAppData%data3d%WvDir2) > 150.0_SiKi) .OR. (maxval(NewmanAppData%data3d%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(NewmanAppData%Data3D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(NewmanAppData%Data3D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(NewmanAppData%Data3D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(NewmanAppData%Data3D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - ELSEIF ( NewmanAppData%DataIs4D ) THEN - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (NewmanAppData%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(NewmanAppData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(NewmanAppData%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (NewmanAppData%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(NewmanAppData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(NewmanAppData%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(NewmanAppData%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(NewmanAppData%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(NewmanAppData%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(NewmanAppData%Data4D%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( InitInp%WaveField%WaveDirMin < MINVAL(NewmanAppData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(NewmanAppData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(NewmanAppData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(NewmanAppData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(NewmanAppData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - ELSE - ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the NewmanApp calculation - CALL SetErrStat( ErrID_Fatal, ' Newman approximation calculation called without data.',ErrStat,ErrMsg,RoutineName) - ENDIF - - IF ( ErrStat >= AbortErrLev ) RETURN - - - !> 3. Check the data to see if we need to convert to 3D arrays before continuing (4D is sparse in any dimension we want and !! frequency diagonal is complete). Only check if we don't have 3D data. @@ -2018,110 +1661,10 @@ SUBROUTINE DiffQTF_InitCalc( InitInp, p, DiffQTFData, DiffQTFForce, ErrMsg, ErrS ErrStat = ErrID_None ErrStatTmp = ErrID_None - - !> 1. Check the data to see if the wave frequencies are present in the QTF data. - - IF ( DiffQTFData%DataIs4D ) THEN ! We must have a 4D data set - - ! Check the low frequency cutoff - IF ( MINVAL( DiffQTFData%Data4D%WvFreq1 ) > InitInp%WaveField%WvLowCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(DiffQTFData%Data4D%WvFreq1)))// & - ' rad/s first wave period) data in '//TRIM(DiffQTFData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffD.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MINVAL( DiffQTFData%Data4D%WvFreq2 ) > InitInp%WaveField%WvLowCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(DiffQTFData%Data4D%WvFreq2)))// & - ' rad/s for second wave period) data in '//TRIM(DiffQTFData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffD.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( MAXVAL(DiffQTFData%Data4D%WvFreq1) < InitInp%WaveField%WvHiCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(DiffQTFData%Data4D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(DiffQTFData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffD.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MAXVAL(DiffQTFData%Data4D%WvFreq2) < InitInp%WaveField%WvHiCOffD ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(DiffQTFData%Data4D%WvFreq1)))// & - ' rad/s second wave period) data in '//TRIM(DiffQTFData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffD.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE - ! This is a catastrophic issue. We should not have called this routine without data that is usable for the DiffQTF calculation - CALL SetErrStat( ErrID_Fatal, ' The full Difference QTF method requires 4D data, and was not passed any.',ErrStat,ErrMsg,RoutineName) - ENDIF - + CALL CheckWAMIT2WvHdg(InitInp,DiffQTFData,ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) IF ( ErrStat >= AbortErrLev ) RETURN - - - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (DiffQTFData%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(DiffQTFData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(DiffQTFData%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (DiffQTFData%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(DiffQTFData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(DiffQTFData%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(DiffQTFData%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(DiffQTFData%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(DiffQTFData%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(DiffQTFData%Data4D%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( InitInp%WaveField%WaveDirMin < MINVAL(DiffQTFData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(DiffQTFData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(DiffQTFData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(DiffQTFData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(DiffQTFData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(DiffQTFData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(DiffQTFData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(DiffQTFData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - IF ( ErrStat >= AbortErrLev ) RETURN - - - - !> 4. Now check to make sure we have data that will work. For the 4D data, it must not be sparse. !! To check this, we have to check the load components that we will use. So, we will loop through them !! and set the TmpFlag to true if there is a sparse matrix for one of them. @@ -2524,110 +2067,10 @@ SUBROUTINE SumQTF_InitCalc( InitInp, p, SumQTFData, SumQTFForce, ErrMsg, ErrStat ErrStat = ErrID_None ErrStatTmp = ErrID_None - - !> 1. Check the data to see if the wave frequencies are present in the QTF data. - - IF ( SumQTFData%DataIs4D ) THEN ! We must have a 4D data set - - ! Check the low frequency cutoff - IF ( MINVAL( SumQTFData%Data4D%WvFreq1 ) > InitInp%WaveField%WvLowCOffS ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(SumQTFData%Data4D%WvFreq1)))// & - ' rad/s first wave period) data in '//TRIM(SumQTFData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffS.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MINVAL( SumQTFData%Data4D%WvFreq2 ) > InitInp%WaveField%WvLowCOffS ) THEN - CALL SetErrStat( ErrID_Fatal,' The lowest frequency ( '//TRIM(Num2LStr(MINVAL(SumQTFData%Data4D%WvFreq2)))// & - ' rad/s for second wave period) data in '//TRIM(SumQTFData%Filename)// & - ' is above the low frequency cutoff set by WvLowCOffS.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Check the high frequency cutoff -- using the Difference high frequency cutoff. The first order high frequency - ! cutoff is typically too high for this in most cases. - IF ( MAXVAL(SumQTFData%Data4D%WvFreq1) < InitInp%WaveField%WvHiCOffS ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(SumQTFData%Data4D%WvFreq1)))// & - ' rad/s for first wave period) data in '//TRIM(SumQTFData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffS.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - IF ( MAXVAL(SumQTFData%Data4D%WvFreq2) < InitInp%WaveField%WvHiCOffS ) THEN - CALL SetErrStat( ErrID_Fatal,' The highest frequency ( '//TRIM(Num2LStr(MAXVAL(SumQTFData%Data4D%WvFreq1)))// & - ' rad/s second wave period) data in '//TRIM(SumQTFData%Filename)// & - ' is below the high frequency cutoff set by WvHiCOffS.', & - ErrStat,ErrMsg,RoutineName) - ENDIF - - ELSE - ! This is a catastrophic issue. We should not have called this routine without data that is usable for the SumQTF calculation - CALL SetErrStat( ErrID_Fatal, ' The full Sum QTF method requires 4D data, and was not passed any.',ErrStat,ErrMsg,RoutineName) - ENDIF - + CALL CheckWAMIT2WvHdg(InitInp,SumQTFData,ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) IF ( ErrStat >= AbortErrLev ) RETURN - - - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (SumQTFData%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(SumQTFData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(SumQTFData%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (SumQTFData%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(SumQTFData%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(SumQTFData%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(SumQTFData%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(SumQTFData%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(SumQTFData%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(SumQTFData%Data4D%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( InitInp%WaveField%WaveDirMin < MINVAL(SumQTFData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(SumQTFData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(SumQTFData%Data4D%WvDir1) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(SumQTFData%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( InitInp%WaveField%WaveDirMin < MINVAL(SumQTFData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(SumQTFData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( InitInp%WaveField%WaveDirMax > MAXVAL(SumQTFData%Data4D%WvDir2) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(SumQTFData%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - - IF ( ErrStat >= AbortErrLev ) RETURN - - - - !> 4. Now check to make sure we have data that will work. For the 4D data, it must not be sparse. !! To check this, we have to check the load components that we will use. So, we will loop through them !! and set the TmpFlag to true if there is a sparse matrix for one of them. @@ -5588,6 +5031,208 @@ SUBROUTINE Destroy_InitData4D(Data4D) END SUBROUTINE Destroy_InitData4D +SUBROUTINE CheckWAMIT2WvHdgDiffData(InitInp,W2Data,ErrStat,ErrMsg) + TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine + TYPE(W2_DiffData_Type), INTENT(IN ) :: W2Data + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + + REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg + CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdg' + + ErrStat = ErrID_None + ErrMsg = "" + + IF ( W2Data%DataIs3D ) THEN + + ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. + IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data3D%NumWvDir1 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data3D%WvDir1(1)))//' degrees (first wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data3D%NumWvDir2 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data3D%WvDir2(1)))//' degrees (second wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE + + ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For + ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves + ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), + ! we will issue a warning. + IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & + (minval(W2Data%data3d%WvDir1) > 150.0_SiKi) .OR. (maxval(W2Data%data3d%WvDir1) < -150.0_SiKi) .OR. & + (minval(W2Data%data3d%WvDir2) > 150.0_SiKi) .OR. (maxval(W2Data%data3d%WvDir2) < -150.0_SiKi) ) THEN + CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & + 'direction of interest is near the +/- 180 direction. This is a known issue with '// & + 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) + ENDIF + + ! Now check the limits for the first wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data3D%WvDir1)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data3D%WvDir1)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ! Now check the limits for the second wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data3D%WvDir2)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data3D%WvDir2)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ENDIF + + ELSEIF ( W2Data%DataIs4D ) THEN + + ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. + IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir1 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir2 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE + + ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For + ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves + ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), + ! we will issue a warning. + IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & + (MINVAL(W2Data%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir1) < -150.0_SiKi) .OR. & + (MINVAL(W2Data%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir2) < -150.0_SiKi) ) THEN + CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & + 'direction of interest is near the +/- 180 direction. This is a known issue with '// & + 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) + ENDIF + + ! Now check the limits for the first wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + ! --> FIXME: modify to allow shifting values by TwoPi before comparing + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir1)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir1)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ! Now check the limits for the second wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir2)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir2)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ENDIF + + ELSE + ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation + CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) + ENDIF + + RETURN + +END SUBROUTINE CheckWAMIT2WvHdgDiffData + +SUBROUTINE CheckWAMIT2WvHdgSumData(InitInp,W2Data,ErrStat,ErrMsg) + TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine + TYPE(W2_SumData_Type), INTENT(IN ) :: W2Data + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + + REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg + CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdg' + + ErrStat = ErrID_None + ErrMsg = "" + + ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. + IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir1 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir2 == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & + 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & + 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & + ErrStat,ErrMsg,RoutineName) + ELSE + + ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For + ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves + ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), + ! we will issue a warning. + IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & + (MINVAL(W2Data%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir1) < -150.0_SiKi) .OR. & + (MINVAL(W2Data%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir2) < -150.0_SiKi) ) THEN + CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & + 'direction of interest is near the +/- 180 direction. This is a known issue with '// & + 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) + ENDIF + + ! Now check the limits for the first wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + ! --> FIXME: modify to allow shifting values by TwoPi before comparing + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir1)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir1)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ! Now check the limits for the second wave direction + ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir2)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir2)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& + 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & + ErrStat, ErrMsg, RoutineName) + ENDIF + + ENDIF + + RETURN + +END SUBROUTINE CheckWAMIT2WvHdgSumData + !---------------------------------------------------------------------------------------------------------------------------------- END MODULE WAMIT2 From 074670f38346b8d0eb63599971eacc1314c91554 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 15 Mar 2024 13:54:54 -0600 Subject: [PATCH 3/5] Further reduce code duplication for checking input wave headings in WAMIT2 --- modules/hydrodyn/src/WAMIT2.f90 | 224 +++++++++----------------------- 1 file changed, 62 insertions(+), 162 deletions(-) diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index c655352997..cfdd285ed9 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -5032,128 +5032,55 @@ END SUBROUTINE Destroy_InitData4D SUBROUTINE CheckWAMIT2WvHdgDiffData(InitInp,W2Data,ErrStat,ErrMsg) - TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine - TYPE(W2_DiffData_Type), INTENT(IN ) :: W2Data - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - - REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg - CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdg' - + TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine + TYPE(W2_DiffData_Type), INTENT(IN ) :: W2Data + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + + CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdgDiffData' + INTEGER(IntKi) :: ErrStatTmp + CHARACTER(ErrMsgLen) :: ErrMsgTmp + ErrStat = ErrID_None ErrMsg = "" IF ( W2Data%DataIs3D ) THEN - - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data3D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data3D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data3D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data3D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE - - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (minval(W2Data%data3d%WvDir1) > 150.0_SiKi) .OR. (maxval(W2Data%data3d%WvDir1) < -150.0_SiKi) .OR. & - (minval(W2Data%data3d%WvDir2) > 150.0_SiKi) .OR. (maxval(W2Data%data3d%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data3D%WvDir1)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data3D%WvDir1)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data3D%WvDir2)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data3D%WvDir2)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - - ENDIF - + CALL CheckWvHdg(InitInp,W2Data%Data3D%NumWvDir1,W2Data%data3d%WvDir1,'first',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) + CALL CheckWvHdg(InitInp,W2Data%Data3D%NumWvDir2,W2Data%data3d%WvDir2,'second',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) ELSEIF ( W2Data%DataIs4D ) THEN + CALL CheckWvHdg(InitInp,W2Data%Data4D%NumWvDir1,W2Data%data4D%WvDir1,'first',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) + CALL CheckWvHdg(InitInp,W2Data%Data4D%NumWvDir2,W2Data%data4D%WvDir2,'second',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) + ELSE + ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation + CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) + ENDIF - ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE + RETURN - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For - ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves - ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), - ! we will issue a warning. - IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(W2Data%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(W2Data%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir2) < -150.0_SiKi) ) THEN - CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF +END SUBROUTINE CheckWAMIT2WvHdgDiffData - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir1)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir1)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF +SUBROUTINE CheckWAMIT2WvHdgSumData(InitInp,W2Data,ErrStat,ErrMsg) + TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine + TYPE(W2_SumData_Type), INTENT(IN ) :: W2Data + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg - ! Now check the limits for the second wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir2)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir2)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF + CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdgSumData' + INTEGER(IntKi) :: ErrStatTmp + CHARACTER(ErrMsgLen) :: ErrMsgTmp - ENDIF + ErrStat = ErrID_None + ErrMsg = "" + IF ( W2Data%DataIs4D ) THEN + CALL CheckWvHdg(InitInp,W2Data%Data4D%NumWvDir1,W2Data%data4D%WvDir1,'first',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) + CALL CheckWvHdg(InitInp,W2Data%Data4D%NumWvDir2,W2Data%data4D%WvDir2,'second',ErrStatTmp,ErrMsgTmp) + CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) ELSE ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) @@ -5161,77 +5088,50 @@ SUBROUTINE CheckWAMIT2WvHdgDiffData(InitInp,W2Data,ErrStat,ErrMsg) RETURN -END SUBROUTINE CheckWAMIT2WvHdgDiffData +END SUBROUTINE CheckWAMIT2WvHdgSumData -SUBROUTINE CheckWAMIT2WvHdgSumData(InitInp,W2Data,ErrStat,ErrMsg) - TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine - TYPE(W2_SumData_Type), INTENT(IN ) :: W2Data - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg +SUBROUTINE CheckWvHdg(InitInp,NumWAMITWvDir,WAMITWvDir,WvDirName,ErrStat,ErrMsg) + TYPE(WAMIT2_InitInputType), INTENT(IN ) :: InitInp !< Input data for initialization routine + INTEGER(IntKi), INTENT(IN ) :: NumWAMITWvDir + REAL(SiKi), INTENT(IN ) :: WAMITWvDir(:) + CHARACTER(*), INTENT(IN ) :: WvDirName + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg - REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg - CHARACTER(*), PARAMETER :: RoutineName = 'CheckWAMIT2WvHdg' + REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg ErrStat = ErrID_None - ErrMsg = "" + ErrMsg = "" ! If we are using multidirectional waves, then we should have more than 1 wave direction in the WAMIT file. - IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir1 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir1(1)))//' degrees (first wave direction). '// & - 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) - ELSE IF ( InitInp%WaveField%WaveMultiDir .AND. (W2Data%Data4D%NumWvDir2 == 1) ) THEN - CALL SetErrStat( ErrID_Fatal,' WAMIT output file '//TRIM(W2Data%Filename)//' only contains one wave '// & - 'direction at '//TRIM(Num2LStr(W2Data%Data4D%WvDir2(1)))//' degrees (second wave direction). '// & + IF ( InitInp%WaveField%WaveMultiDir .AND. (NumWAMITWvDir == 1) ) THEN + CALL SetErrStat( ErrID_Fatal,' only contains one '//WvDirName//' wave direction at '//TRIM(Num2LStr(WAMITWvDir(1)))//' degrees'// & 'It cannot be used with multidirectional waves. Set WaveDirMod to 0 to use this file.', & - ErrStat,ErrMsg,RoutineName) + ErrStat,ErrMsg,'') ELSE - ! See Known Issues #1 at the top of this file. There may be problems if the data spans the +/- Pi boundary. For ! now (since time is limited) we will issue a warning if any of the wave directions for multidirectional waves ! or data from the WAMIT file for the wavedirections is close to the +/-pi boundary (>150 degrees, <-150 degrees), ! we will issue a warning. IF ( (InitInp%WaveField%WaveDirMin > 150.0_SiKi) .OR. (InitInp%WaveField%WaveDirMax < -150.0_SiKi) .OR. & - (MINVAL(W2Data%Data4D%WvDir1) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir1) < -150.0_SiKi) .OR. & - (MINVAL(W2Data%Data4D%WvDir2) > 150.0_SiKi) .OR. (MAXVAL(W2Data%Data4D%WvDir2) < -150.0_SiKi) ) THEN + (minval(WAMITWvDir) > 150.0_SiKi) .OR. (maxval(WAMITWvDir) < -150.0_SiKi)) THEN CALL SetErrStat( ErrID_Warn,' There may be issues with how the wave direction data is handled when the wave '// & - 'direction of interest is near the +/- 180 direction. This is a known issue with '// & - 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,RoutineName) - ENDIF - - ! Now check the limits for the first wave direction - ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - ! --> FIXME: modify to allow shifting values by TwoPi before comparing - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir1)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) - ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir1)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the first wave direction.', & - ErrStat, ErrMsg, RoutineName) + 'direction of interest is near the +/- 180 direction. This is a known issue with '// & + 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,'') ENDIF - - ! Now check the limits for the second wave direction + ! Now check the limits for the wave direction ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(W2Data%Data4D%WvDir2)-WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) + IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(WAMITWvDir)-WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' does not contain the minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' for the '//WvDirName//' wave direction.', & + ErrStat, ErrMsg, '') ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(W2Data%Data4D%WvDir2)+WvDirTol) ) THEN - CALL SetErrStat( ErrID_Fatal,' Maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' is not'//& - 'found in the WAMIT data file '//TRIM(W2Data%Filename)//' for the second wave direction.', & - ErrStat, ErrMsg, RoutineName) + IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(WAMITWvDir)+WvDirTol) ) THEN + CALL SetErrStat( ErrID_Fatal,' does not contain the maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' for the '//WvDirName//' wave direction.', & + ErrStat, ErrMsg, '') ENDIF - ENDIF - RETURN - -END SUBROUTINE CheckWAMIT2WvHdgSumData +END SUBROUTINE CheckWvHdg !---------------------------------------------------------------------------------------------------------------------------------- From ce6daa3695fe2efd2ac7da68ccdf338e2a126ce9 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 15 Mar 2024 14:18:51 -0600 Subject: [PATCH 4/5] Account for PtfmRefZtRot when checking the input wave headings in WAMIT2 --- modules/hydrodyn/src/WAMIT2.f90 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index cfdd285ed9..972bf766b0 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -5099,6 +5099,7 @@ SUBROUTINE CheckWvHdg(InitInp,NumWAMITWvDir,WAMITWvDir,WvDirName,ErrStat,ErrMsg) CHARACTER(*), INTENT( OUT) :: ErrMsg REAL(ReKi), PARAMETER :: WvDirTol = 0.001 ! deg + REAL(ReKi) :: RotateZdegOffset ErrStat = ErrID_None ErrMsg = "" @@ -5119,16 +5120,24 @@ SUBROUTINE CheckWvHdg(InitInp,NumWAMITWvDir,WAMITWvDir,WvDirName,ErrStat,ErrMsg) 'direction of interest is near the +/- 180 direction. This is a known issue with '// & 'the WAMIT2 module that has not yet been addressed.',ErrStat,ErrMsg,'') ENDIF + + if (InitInp%NBodyMod==2) then ! Need to account for PtfmRefztRot (the current WAMIT2 module can only contain one body in this case) + RotateZdegOffset = InitInp%PtfmRefztRot(1)*R2D + else + RotateZdegOffset = 0.0 + end if + ! Now check the limits for the wave direction ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-InitInp%PtfmRefY*R2D) < (MINVAL(WAMITWvDir)-WvDirTol) ) THEN + IF ( (InitInp%WaveField%WaveDirMin-RotateZdegOffset-InitInp%PtfmRefY*R2D) < (MINVAL(WAMITWvDir)-WvDirTol) ) THEN CALL SetErrStat( ErrID_Fatal,' does not contain the minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' for the '//WvDirName//' wave direction.', & ErrStat, ErrMsg, '') ENDIF - IF ( (InitInp%WaveField%WaveDirMax-InitInp%PtfmRefY*R2D) > (MAXVAL(WAMITWvDir)+WvDirTol) ) THEN + IF ( (InitInp%WaveField%WaveDirMax-RotateZdegOffset-InitInp%PtfmRefY*R2D) > (MAXVAL(WAMITWvDir)+WvDirTol) ) THEN CALL SetErrStat( ErrID_Fatal,' does not contain the maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' for the '//WvDirName//' wave direction.', & ErrStat, ErrMsg, '') ENDIF + ENDIF END SUBROUTINE CheckWvHdg From 7d7dc7667c1d3ad7ffaca42ccb3ce6c29bc356e8 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 15 Mar 2024 17:34:46 -0600 Subject: [PATCH 5/5] Fix some issue with backporting from f/HDLargeYaw --- modules/hydrodyn/src/WAMIT2.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index 972bf766b0..8cbb1da71e 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -5056,7 +5056,7 @@ SUBROUTINE CheckWAMIT2WvHdgDiffData(InitInp,W2Data,ErrStat,ErrMsg) CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) ELSE ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation - CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) + CALL SetErrStat( ErrID_Fatal, ' Second-order wave-load calculation called without data.',ErrStat,ErrMsg,RoutineName) ENDIF RETURN @@ -5083,7 +5083,7 @@ SUBROUTINE CheckWAMIT2WvHdgSumData(InitInp,W2Data,ErrStat,ErrMsg) CALL SetErrStat(ErrStatTmp,' WAMIT output file '//TRIM(W2Data%Filename)//ErrMsgTmp,ErrStat,ErrMsg,RoutineName) ELSE ! No data. This is a catastrophic issue. We should not have called this routine without data that is usable for the MnDrift calculation - CALL SetErrStat( ErrID_Fatal, ' Mean drift calculation called without data.',ErrStat,ErrMsg,RoutineName) + CALL SetErrStat( ErrID_Fatal, ' Second-order wave-load calculation called without data.',ErrStat,ErrMsg,RoutineName) ENDIF RETURN @@ -5129,11 +5129,11 @@ SUBROUTINE CheckWvHdg(InitInp,NumWAMITWvDir,WAMITWvDir,WvDirName,ErrStat,ErrMsg) ! Now check the limits for the wave direction ! --> FIXME: sometime fix this to handle the above case. See Known Issue #1 at top of file. - IF ( (InitInp%WaveField%WaveDirMin-RotateZdegOffset-InitInp%PtfmRefY*R2D) < (MINVAL(WAMITWvDir)-WvDirTol) ) THEN + IF ( (InitInp%WaveField%WaveDirMin-RotateZdegOffset) < (MINVAL(WAMITWvDir)-WvDirTol) ) THEN CALL SetErrStat( ErrID_Fatal,' does not contain the minimum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMin))//' for the '//WvDirName//' wave direction.', & ErrStat, ErrMsg, '') ENDIF - IF ( (InitInp%WaveField%WaveDirMax-RotateZdegOffset-InitInp%PtfmRefY*R2D) > (MAXVAL(WAMITWvDir)+WvDirTol) ) THEN + IF ( (InitInp%WaveField%WaveDirMax-RotateZdegOffset) > (MAXVAL(WAMITWvDir)+WvDirTol) ) THEN CALL SetErrStat( ErrID_Fatal,' does not contain the maximum wave direction required of '//TRIM(Num2LStr(InitInp%WaveField%WaveDirMax))//' for the '//WvDirName//' wave direction.', & ErrStat, ErrMsg, '') ENDIF