anchor.diff:        !   depends on which incident wave kinematics stretching method is being
         !   used:
   
  -      SELECT CASE ( WaveDat%WaveStMod )  ! Which model are we using to extrapolate the incident wave kinematics to the instantaneous free surface?
  +      SELECT CASE ( InitInp%WaveStMod )  ! Which model are we using to extrapolate the incident wave kinematics to the instantaneous free surface?
   
         CASE ( 0 )                 ! None=no stretching.
   
  
positive.code:       !   equal the wave kinematics at the mean sea level.  The wave kinematics
        !   below the mean sea level are left unchanged:
  
           DO I = 0,WaveDat%NStepWave-1       ! Loop through all time steps
  
              DO J = 1,WaveDat%NWaveKin0      ! Loop through all points along a vertical line passing through the platform reference point where the incident wave kinematics will be computed
  
                 IF (   ( WaveDat%WaveKinzi0(J) < -WaveDat%WtrDpth ) .OR. ( WaveDat%WaveKinzi0(J) > WaveDat%WaveElev0(I) ) )  THEN ! .TRUE. if the elevation of the point defined by WaveKinzi0(J) lies below the seabed or above the instantaneous free surface (exclusive)
  
                    WaveDat%WaveDynP0(I,J  )  = 0.0
                    WaveDat%WaveVel0(I,J,:)   = 0.0
                    WaveDat%WaveAcc0(I,J,:)   = 0.0
  
                 ELSEIF ( WaveDat%WaveKinzi0(J) > 0.0                                                                      )  THEN ! .TRUE. if the elevation of the point devined by WaveKinzi0(J) lies between the mean sea level (exclusive) and the instantaneous free surface (inclusive)
  
                    WaveDat%WaveDynP0(I,J  )  = WaveDynP0B (I,NWaveKin0Prime)
                    WaveDat%WaveVel0(I,J,1)   = WaveVel0Hxi(I,NWaveKin0Prime)
                    WaveDat%WaveVel0(I,J,2)   = WaveVel0Hyi(I,NWaveKin0Prime)
                    WaveDat%WaveVel0(I,J,3)   = WaveVel0V  (I,NWaveKin0Prime)
                    WaveDat%WaveAcc0(I,J,1)   = WaveAcc0H  (I,NWaveKin0Prime)*CWaveDir
                    WaveDat%WaveAcc0(I,J,2)   = WaveAcc0H  (I,NWaveKin0Prime)*SWaveDir
                    WaveDat%WaveAcc0(I,J,3)   = WaveAcc0V  (I,NWaveKin0Prime)
  
                 ELSE                                                                                                              ! The elevation of the point defined by WaveKinzi0(J) must lie between the seabed and the mean sea level (inclusive)
  
                    WaveDat%WaveDynP0(I,J  )  = WaveDynP0B (I,J-J_Min+1     )
                    WaveDat%WaveVel0(I,J,1)   = WaveVel0Hxi(I,J-J_Min+1     )
                    WaveDat%WaveVel0(I,J,2)   = WaveVel0Hyi(I,J-J_Min+1     )
                    WaveDat%WaveVel0(I,J,3)   = WaveVel0V  (I,J-J_Min+1     )
                    WaveDat%WaveAcc0(I,J,1)   = WaveAcc0H  (I,J-J_Min+1     )*CWaveDir
                    WaveDat%WaveAcc0(I,J,2)   = WaveAcc0H  (I,J-J_Min+1     )*SWaveDir
                    WaveDat%WaveAcc0(I,J,3)   = WaveAcc0V  (I,J-J_Min+1     )
  
                 ENDIF
  
              ENDDO                   ! J - All points along a vertical line passing through the platform reference point where the incident wave kinematics will be computed
  
           ENDDO                      ! I - All time steps
  
  
  
  
negative.code:       ! Since we have no stretching, the wave kinematics between the seabed and
        !   the mean sea level are left unchanged; below the seabed or above the
        !   mean sea level, the wave kinematics are zero:
           
           DO I = 0,InitOut%NStepWave-1       ! Loop through all time steps
              K = 1
              DO J = 1,InitInp%NWaveKin0      ! Loop through all points where the incident wave kinematics will be computed
                    ! NOTE: We test to 0 instead of MSL2SWL because the locations of WaveKinzi0 and WtrDpth have already been adjusted using MSL2SWL
                 IF (   ( InitInp%WaveKinzi0(J) < -InitInp%WtrDpth ) .OR. ( InitInp%WaveKinzi0(J) > 0.0          ) )  THEN   ! .TRUE. if the elevation of the point defined by WaveKinzi0(J) lies below the seabed or above mean sea level (exclusive)
  
                    InitOut%WaveDynP0(I,J  )  = 0.0
                    InitOut%WaveVel0 (I,J,:)  = 0.0
                    InitOut%WaveAcc0 (I,J,:)  = 0.0
  
                 ELSE                                                                                 ! The elevation of the point defined by WaveKinzi0(J) must lie between the seabed and the mean sea level (inclusive)
  
                    InitOut%WaveDynP0(I,J  )  = WaveDynP0B (I,K     )
                    InitOut%WaveVel0 (I,J,1)  = WaveVel0Hxi(I,K     )
                    InitOut%WaveVel0 (I,J,2)  = WaveVel0Hyi(I,K     )
                    InitOut%WaveVel0 (I,J,3)  = WaveVel0V  (I,K     )
                    InitOut%WaveAcc0 (I,J,1)  = WaveAcc0H  (I,K     )*CWaveDir
                    InitOut%WaveAcc0 (I,J,2)  = WaveAcc0H  (I,K     )*SWaveDir
                    InitOut%WaveAcc0 (I,J,3)  = WaveAcc0V  (I,K     )
                    K = K + 1
                 END IF
  
              END DO                   ! J - All points where the incident wave kinematics will be computed
  
           END DO                      ! I - All time steps
  
  
  
  