repo_name
stringlengths 7
81
| path
stringlengths 4
224
| copies
stringclasses 221
values | size
stringlengths 4
7
| content
stringlengths 975
1.04M
| license
stringclasses 15
values |
---|---|---|---|---|---|
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/deallocate_stat.f90 | 42 | 2831 | ! { dg-do run }
! PR 17792
! PR 21375
! Test that the STAT argument to DEALLOCATE works with POINTERS and
! ALLOCATABLE arrays.
program deallocate_stat
implicit none
integer i
real, pointer :: a1(:), a2(:,:), a3(:,:,:), a4(:,:,:,:), &
& a5(:,:,:,:,:), a6(:,:,:,:,:,:), a7(:,:,:,:,:,:,:)
real, allocatable :: b1(:), b2(:,:), b3(:,:,:), b4(:,:,:,:), &
& b5(:,:,:,:,:), b6(:,:,:,:,:,:), b7(:,:,:,:,:,:,:)
allocate(a1(2), a2(2,2), a3(2,2,2), a4(2,2,2,2), a5(2,2,2,2,2))
allocate(a6(2,2,2,2,2,2), a7(2,2,2,2,2,2,2))
a1 = 1. ; a2 = 2. ; a3 = 3. ; a4 = 4. ; a5 = 5. ; a6 = 6. ; a7 = 7.
i = 13
deallocate(a1, stat=i) ; if (i /= 0) call abort
deallocate(a2, stat=i) ; if (i /= 0) call abort
deallocate(a3, stat=i) ; if (i /= 0) call abort
deallocate(a4, stat=i) ; if (i /= 0) call abort
deallocate(a5, stat=i) ; if (i /= 0) call abort
deallocate(a6, stat=i) ; if (i /= 0) call abort
deallocate(a7, stat=i) ; if (i /= 0) call abort
i = 14
deallocate(a1, stat=i) ; if (i /= 1) call abort
deallocate(a2, stat=i) ; if (i /= 1) call abort
deallocate(a3, stat=i) ; if (i /= 1) call abort
deallocate(a4, stat=i) ; if (i /= 1) call abort
deallocate(a5, stat=i) ; if (i /= 1) call abort
deallocate(a6, stat=i) ; if (i /= 1) call abort
deallocate(a7, stat=i) ; if (i /= 1) call abort
allocate(b1(2), b2(2,2), b3(2,2,2), b4(2,2,2,2), b5(2,2,2,2,2))
allocate(b6(2,2,2,2,2,2), b7(2,2,2,2,2,2,2))
b1 = 1. ; b2 = 2. ; b3 = 3. ; b4 = 4. ; b5 = 5. ; b6 = 6. ; b7 = 7.
i = 13
deallocate(b1, stat=i) ; if (i /= 0) call abort
deallocate(b2, stat=i) ; if (i /= 0) call abort
deallocate(b3, stat=i) ; if (i /= 0) call abort
deallocate(b4, stat=i) ; if (i /= 0) call abort
deallocate(b5, stat=i) ; if (i /= 0) call abort
deallocate(b6, stat=i) ; if (i /= 0) call abort
deallocate(b7, stat=i) ; if (i /= 0) call abort
i = 14
deallocate(b1, stat=i) ; if (i /= 1) call abort
deallocate(b2, stat=i) ; if (i /= 1) call abort
deallocate(b3, stat=i) ; if (i /= 1) call abort
deallocate(b4, stat=i) ; if (i /= 1) call abort
deallocate(b5, stat=i) ; if (i /= 1) call abort
deallocate(b6, stat=i) ; if (i /= 1) call abort
deallocate(b7, stat=i) ; if (i /= 1) call abort
allocate(a1(2), a2(2,2), a3(2,2,2), b4(2,2,2,2), b5(2,2,2,2,2))
allocate(b6(2,2,2,2,2,2))
a1 = 1. ; a2 = 2. ; a3 = 3. ; b4 = 4. ; b5 = 5. ; b6 = 6.
i = 13
deallocate(a1, stat=i) ; if (i /= 0) call abort
deallocate(a2, a1, stat=i) ; if (i /= 1) call abort
deallocate(a1, a3, a2, stat=i) ; if (i /= 2) call abort
deallocate(b4, stat=i) ; if (i /= 0) call abort
deallocate(b4, b5, stat=i) ; if (i /= 1) call abort
deallocate(b4, b5, b6, stat=i) ; if (i /= 2) call abort
end program deallocate_stat
| gpl-2.0 |
rofirrim/gcc-tiny | libgomp/testsuite/libgomp.fortran/vla2.f90 | 202 | 5316 | ! { dg-do run }
call test
contains
subroutine check (x, y, l)
integer :: x, y
logical :: l
l = l .or. x .ne. y
end subroutine check
subroutine foo (c, d, e, f, g, h, i, j, k, n)
use omp_lib
integer :: n
character (len = *) :: c
character (len = n) :: d
integer, dimension (2, 3:5, n) :: e
integer, dimension (2, 3:n, n) :: f
character (len = *), dimension (5, 3:n) :: g
character (len = n), dimension (5, 3:n) :: h
real, dimension (:, :, :) :: i
double precision, dimension (3:, 5:, 7:) :: j
integer, dimension (:, :, :) :: k
logical :: l
integer :: p, q, r
character (len = n) :: s
integer, dimension (2, 3:5, n) :: t
integer, dimension (2, 3:n, n) :: u
character (len = n), dimension (5, 3:n) :: v
character (len = 2 * n + 24) :: w
integer :: x
character (len = 1) :: y
l = .false.
!$omp parallel default (none) private (c, d, e, f, g, h, i, j, k) &
!$omp & private (s, t, u, v) reduction (.or.:l) num_threads (6) &
!$omp private (p, q, r, w, x, y)
x = omp_get_thread_num ()
w = ''
if (x .eq. 0) w = 'thread0thr_number_0THREAD0THR_NUMBER_0'
if (x .eq. 1) w = 'thread1thr_number_1THREAD1THR_NUMBER_1'
if (x .eq. 2) w = 'thread2thr_number_2THREAD2THR_NUMBER_2'
if (x .eq. 3) w = 'thread3thr_number_3THREAD3THR_NUMBER_3'
if (x .eq. 4) w = 'thread4thr_number_4THREAD4THR_NUMBER_4'
if (x .eq. 5) w = 'thread5thr_number_5THREAD5THR_NUMBER_5'
c = w(8:19)
d = w(1:7)
forall (p = 1:2, q = 3:5, r = 1:7) e(p, q, r) = 5 * x + p + q + 2 * r
forall (p = 1:2, q = 3:7, r = 1:7) f(p, q, r) = 25 * x + p + q + 2 * r
forall (p = 1:5, q = 3:7, p + q .le. 8) g(p, q) = w(8:19)
forall (p = 1:5, q = 3:7, p + q .gt. 8) g(p, q) = w(27:38)
forall (p = 1:5, q = 3:7, p + q .le. 8) h(p, q) = w(1:7)
forall (p = 1:5, q = 3:7, p + q .gt. 8) h(p, q) = w(20:26)
forall (p = 3:5, q = 2:6, r = 1:7) i(p - 2, q - 1, r) = (7.5 + x) * p * q * r
forall (p = 3:5, q = 2:6, r = 1:7) j(p, q + 3, r + 6) = (9.5 + x) * p * q * r
forall (p = 1:5, q = 7:7, r = 4:6) k(p, q - 6, r - 3) = 19 + x + p + q + 3 * r
s = w(20:26)
forall (p = 1:2, q = 3:5, r = 1:7) t(p, q, r) = -10 + x + p - q + 2 * r
forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r
forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7)
forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26)
!$omp barrier
y = ''
if (x .eq. 0) y = '0'
if (x .eq. 1) y = '1'
if (x .eq. 2) y = '2'
if (x .eq. 3) y = '3'
if (x .eq. 4) y = '4'
if (x .eq. 5) y = '5'
l = l .or. w(7:7) .ne. y
l = l .or. w(19:19) .ne. y
l = l .or. w(26:26) .ne. y
l = l .or. w(38:38) .ne. y
l = l .or. c .ne. w(8:19)
l = l .or. d .ne. w(1:7)
l = l .or. s .ne. w(20:26)
do 103, p = 1, 2
do 103, q = 3, 7
do 103, r = 1, 7
if (q .lt. 6) l = l .or. e(p, q, r) .ne. 5 * x + p + q + 2 * r
l = l .or. f(p, q, r) .ne. 25 * x + p + q + 2 * r
if (r .lt. 6 .and. q + r .le. 8) l = l .or. g(r, q) .ne. w(8:19)
if (r .lt. 6 .and. q + r .gt. 8) l = l .or. g(r, q) .ne. w(27:38)
if (r .lt. 6 .and. q + r .le. 8) l = l .or. h(r, q) .ne. w(1:7)
if (r .lt. 6 .and. q + r .gt. 8) l = l .or. h(r, q) .ne. w(20:26)
if (q .lt. 6) l = l .or. t(p, q, r) .ne. -10 + x + p - q + 2 * r
l = l .or. u(p, q, r) .ne. 30 - x - p + q - 2 * r
if (r .lt. 6 .and. q + r .le. 8) l = l .or. v(r, q) .ne. w(1:7)
if (r .lt. 6 .and. q + r .gt. 8) l = l .or. v(r, q) .ne. w(20:26)
103 continue
do 104, p = 3, 5
do 104, q = 2, 6
do 104, r = 1, 7
l = l .or. i(p - 2, q - 1, r) .ne. (7.5 + x) * p * q * r
l = l .or. j(p, q + 3, r + 6) .ne. (9.5 + x) * p * q * r
104 continue
do 105, p = 1, 5
do 105, q = 4, 6
l = l .or. k(p, 1, q - 3) .ne. 19 + x + p + 7 + 3 * q
105 continue
call check (size (e, 1), 2, l)
call check (size (e, 2), 3, l)
call check (size (e, 3), 7, l)
call check (size (e), 42, l)
call check (size (f, 1), 2, l)
call check (size (f, 2), 5, l)
call check (size (f, 3), 7, l)
call check (size (f), 70, l)
call check (size (g, 1), 5, l)
call check (size (g, 2), 5, l)
call check (size (g), 25, l)
call check (size (h, 1), 5, l)
call check (size (h, 2), 5, l)
call check (size (h), 25, l)
call check (size (i, 1), 3, l)
call check (size (i, 2), 5, l)
call check (size (i, 3), 7, l)
call check (size (i), 105, l)
call check (size (j, 1), 4, l)
call check (size (j, 2), 5, l)
call check (size (j, 3), 7, l)
call check (size (j), 140, l)
call check (size (k, 1), 5, l)
call check (size (k, 2), 1, l)
call check (size (k, 3), 3, l)
call check (size (k), 15, l)
!$omp end parallel
if (l) call abort
end subroutine foo
subroutine test
character (len = 12) :: c
character (len = 7) :: d
integer, dimension (2, 3:5, 7) :: e
integer, dimension (2, 3:7, 7) :: f
character (len = 12), dimension (5, 3:7) :: g
character (len = 7), dimension (5, 3:7) :: h
real, dimension (3:5, 2:6, 1:7) :: i
double precision, dimension (3:6, 2:6, 1:7) :: j
integer, dimension (1:5, 7:7, 4:6) :: k
integer :: p, q, r
call foo (c, d, e, f, g, h, i, j, k, 7)
end subroutine test
end
| gpl-2.0 |
OpenFAST/OpenFAST | modules/openfast-library/src/FAST_Subs.f90 | 1 | 412450 | !**********************************************************************************************************************************
! FAST_Solver.f90, FAST_Subs.f90, FAST_Lin.f90, and FAST_Mods.f90 make up the FAST glue code in the FAST Modularization Framework.
! FAST_Prog.f90, FAST_Library.f90, FAST_Prog.c are different drivers for this code.
!..................................................................................................................................
! LICENSING
! Copyright (C) 2013-2016 National Renewable Energy Laboratory
!
! This file is part of FAST.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!**********************************************************************************************************************************
MODULE FAST_Subs
USE FAST_Solver
USE FAST_Linear
IMPLICIT NONE
CONTAINS
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! INITIALIZATION ROUTINES
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!> a wrapper routine to call FAST_Initialize a the full-turbine simulation level (makes easier to write top-level driver)
SUBROUTINE FAST_InitializeAll_T( t_initial, TurbID, Turbine, ErrStat, ErrMsg, InFile, ExternInitData )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
INTEGER(IntKi), INTENT(IN ) :: TurbID !< turbine Identifier (1-NumTurbines)
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
CHARACTER(*), OPTIONAL,INTENT(IN ) :: InFile !< A CHARACTER string containing the name of the primary FAST input file (if not present, we'll get it from the command line)
TYPE(FAST_ExternInitType),OPTIONAL,INTENT(IN ) :: ExternInitData !< Initialization input data from an external source (Simulink)
Turbine%TurbID = TurbID
IF (PRESENT(InFile)) THEN
IF (PRESENT(ExternInitData)) THEN
CALL FAST_InitializeAll( t_initial, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, Turbine%SC,&
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg, InFile, ExternInitData )
ELSE
CALL FAST_InitializeAll( t_initial, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, Turbine%SC, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg, InFile )
END IF
ELSE
CALL FAST_InitializeAll( t_initial, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, Turbine%SC, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg )
END IF
END SUBROUTINE FAST_InitializeAll_T
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine to call Init routine for each module. This routine sets all of the init input data for each module.
SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, SC, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat, ErrMsg, InFile, ExternInitData )
use ElastoDyn_Parameters, only: Method_RK4
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(SuperController_Data), INTENT(INOUT) :: SC !< SuperController data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
CHARACTER(*), OPTIONAL, INTENT(IN ) :: InFile !< A CHARACTER string containing the name of the primary FAST input file (if not present, we'll get it from the command line)
TYPE(FAST_ExternInitType), OPTIONAL, INTENT(IN) :: ExternInitData !< Initialization input data from an external source (Simulink)
! local variables
CHARACTER(1024) :: InputFile !< A CHARACTER string containing the name of the primary FAST input file
TYPE(FAST_InitData) :: Init !< Initialization data for all modules
REAL(ReKi) :: AirDens ! air density for initialization/normalization of OpenFOAM data
REAL(DbKi) :: dt_IceD ! tmp dt variable to ensure IceDyn doesn't specify different dt values for different legs (IceDyn instances)
REAL(DbKi) :: dt_BD ! tmp dt variable to ensure BeamDyn doesn't specify different dt values for different instances
INTEGER(IntKi) :: ErrStat2
INTEGER(IntKi) :: IceDim ! dimension we're pre-allocating for number of IceDyn legs/instances
INTEGER(IntKi) :: I ! generic loop counter
INTEGER(IntKi) :: k ! blade loop counter
logical :: CallStart
INTEGER(IntKi) :: NumBl
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_InitializeAll'
!..........
ErrStat = ErrID_None
ErrMsg = ""
y_FAST%UnSum = -1 ! set the summary file unit to -1 to indicate it's not open
y_FAST%UnOu = -1 ! set the text output file unit to -1 to indicate it's not open
y_FAST%UnGra = -1 ! set the binary graphics output file unit to -1 to indicate it's not open
p_FAST%WrVTK = VTK_Unknown ! set this so that we can potentially output VTK information on initialization error
p_FAST%VTK_tWidth = 1 ! initialize in case of error before reading the full file
p_FAST%n_VTKTime = 1 ! initialize in case of error before reading the full file
y_FAST%VTK_LastWaveIndx = 1 ! Start looking for wave data at the first index
y_FAST%VTK_count = 0 ! first VTK file has 0 as output
y_FAST%n_Out = 0 ! set the number of ouptut channels to 0 to indicate there's nothing to write to the binary file
p_FAST%ModuleInitialized = .FALSE. ! (array initialization) no modules are initialized
! Get the current time
CALL DATE_AND_TIME ( Values=m_FAST%StrtTime ) ! Let's time the whole simulation
CALL CPU_TIME ( m_FAST%UsrTime1 ) ! Initial time (this zeros the start time when used as a MATLAB function)
m_FAST%UsrTime1 = MAX( 0.0_ReKi, m_FAST%UsrTime1 ) ! CPU_TIME: If a meaningful time cannot be returned, a processor-dependent negative value is returned
m_FAST%t_global = t_initial - 20. ! initialize this to a number < t_initial for error message in ProgAbort
m_FAST%calcJacobian = .TRUE. ! we need to calculate the Jacobian
m_FAST%NextJacCalcTime = m_FAST%t_global ! We want to calculate the Jacobian on the first step
p_FAST%TDesc = ''
! p_FAST%CheckHSSBrTrqC = .false.
y_FAST%Lin%WindSpeed = 0.0_ReKi
if (present(ExternInitData)) then
CallStart = .not. ExternInitData%FarmIntegration ! .and. ExternInitData%TurbineID == 1
if (ExternInitData%TurbineID > 0) p_FAST%TDesc = 'T'//trim(num2lstr(ExternInitData%TurbineID))
else
CallStart = .true.
end if
! Init NWTC_Library, display copyright and version information:
if (CallStart) then
AbortErrLev = ErrID_Fatal ! Until we read otherwise from the FAST input file, we abort only on FATAL errors
CALL FAST_ProgStart( FAST_Ver )
p_FAST%WrSttsTime = .TRUE.
else
! if we don't call the start data (e.g., from FAST.Farm), we won't override AbortErrLev either
CALL DispNVD( FAST_Ver )
p_FAST%WrSttsTime = .FALSE.
end if
IF (PRESENT(InFile)) THEN
p_FAST%UseDWM = .FALSE.
InputFile = InFile
ELSE
CALL GetInputFileName(InputFile,p_FAST%UseDWM,ErrStat2,ErrMsg2)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF
! ... Open and read input files ...
! also, set turbine reference position for graphics output
if (PRESENT(ExternInitData)) then
p_FAST%TurbinePos = ExternInitData%TurbinePos
if (ExternInitData%FarmIntegration) then ! we're integrating with FAST.Farm
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2, ExternInitData%TMax, OverrideAbortLev=.false., RootName=ExternInitData%RootName )
else
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2, ExternInitData%TMax, ExternInitData%TurbineID ) ! We have the name of the input file and the simulation length from somewhere else (e.g. Simulink)
end if
else
p_FAST%TurbinePos = 0.0_ReKi
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2 ) ! We have the name of the input file from somewhere else (e.g. Simulink)
end if
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
!...............................................................................................................................
p_FAST%dt_module = p_FAST%dt ! initialize time steps for each module
! ........................
! initialize ElastoDyn (must be done first)
! ........................
ALLOCATE( ED%Input( p_FAST%InterpOrder+1 ), ED%InputTimes( p_FAST%InterpOrder+1 ),STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating ED%Input and ED%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
Init%InData_ED%Linearize = p_FAST%Linearize
Init%InData_ED%InputFile = p_FAST%EDFile
IF ( p_FAST%CompAero == Module_AD14 ) THEN
Init%InData_ED%ADInputFile = p_FAST%AeroFile
ELSE
Init%InData_ED%ADInputFile = ""
END IF
Init%InData_ED%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_ED))
Init%InData_ED%CompElast = p_FAST%CompElast == Module_ED
CALL ED_Init( Init%InData_ED, ED%Input(1), ED%p, ED%x(STATE_CURR), ED%xd(STATE_CURR), ED%z(STATE_CURR), ED%OtherSt(STATE_CURR), &
ED%y, ED%m, p_FAST%dt_module( MODULE_ED ), Init%OutData_ED, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_ED) = .TRUE.
CALL SetModuleSubstepTime(Module_ED, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
! bjj: added this check per jmj; perhaps it would be better in ElastoDyn, but I'll leave it here for now:
IF ( p_FAST%TurbineType == Type_Offshore_Floating ) THEN
IF ( ED%p%TowerBsHt < 0.0_ReKi .AND. .NOT. EqualRealNos( ED%p%TowerBsHt, 0.0_ReKi ) ) THEN
CALL SetErrStat(ErrID_Fatal,"ElastoDyn TowerBsHt must not be negative for floating offshore systems.",ErrStat,ErrMsg,RoutineName)
END IF
END IF
allocate( y_FAST%Lin%Modules(MODULE_ED)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(ED).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_ED%LinNames_y)) call move_alloc(Init%OutData_ED%LinNames_y,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%Names_y)
if (allocated(Init%OutData_ED%LinNames_x)) call move_alloc(Init%OutData_ED%LinNames_x,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%Names_x)
if (allocated(Init%OutData_ED%LinNames_u)) call move_alloc(Init%OutData_ED%LinNames_u,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%Names_u)
if (allocated(Init%OutData_ED%RotFrame_y)) call move_alloc(Init%OutData_ED%RotFrame_y,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%RotFrame_y)
if (allocated(Init%OutData_ED%RotFrame_x)) call move_alloc(Init%OutData_ED%RotFrame_x,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%RotFrame_x)
if (allocated(Init%OutData_ED%DerivOrder_x)) call move_alloc(Init%OutData_ED%DerivOrder_x,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%DerivOrder_x)
if (allocated(Init%OutData_ED%RotFrame_u)) call move_alloc(Init%OutData_ED%RotFrame_u,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%RotFrame_u)
if (allocated(Init%OutData_ED%IsLoad_u )) call move_alloc(Init%OutData_ED%IsLoad_u ,y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_ED%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_ED)%Instance(1)%NumOutputs = size(Init%OutData_ED%WriteOutputHdr)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
NumBl = Init%OutData_ED%NumBl
if (p_FAST%CalcSteady) then
if ( EqualRealNos(Init%OutData_ED%RotSpeed, 0.0_ReKi) ) then
p_FAST%TrimCase = TrimCase_none
p_FAST%NLinTimes = 1
p_FAST%LinInterpOrder = 0 ! constant values
elseif ( Init%OutData_ED%isFixed_GenDOF ) then
p_FAST%TrimCase = TrimCase_none
end if
end if
! ........................
! initialize BeamDyn
! ........................
IF ( p_FAST%CompElast == Module_BD ) THEN
p_FAST%nBeams = Init%OutData_ED%NumBl ! initialize number of BeamDyn instances = number of blades
ELSE
p_FAST%nBeams = 0
END IF
ALLOCATE( BD%Input( p_FAST%InterpOrder+1, p_FAST%nBeams ), BD%InputTimes( p_FAST%InterpOrder+1, p_FAST%nBeams ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating BD%Input and BD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( BD%x( p_FAST%nBeams,2), &
BD%xd( p_FAST%nBeams,2), &
BD%z( p_FAST%nBeams,2), &
BD%OtherSt( p_FAST%nBeams,2), &
BD%p( p_FAST%nBeams ), &
BD%u( p_FAST%nBeams ), &
BD%y( p_FAST%nBeams ), &
BD%m( p_FAST%nBeams ), &
Init%OutData_BD(p_FAST%nBeams ), &
STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating BeamDyn state, input, and output data.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF (p_FAST%CompElast == Module_BD) THEN
Init%InData_BD%DynamicSolve = .TRUE. ! FAST can only couple to BeamDyn when dynamic solve is used.
Init%InData_BD%Linearize = p_FAST%Linearize
Init%InData_BD%gravity = (/ 0.0_ReKi, 0.0_ReKi, -Init%OutData_ED%Gravity /) ! "Gravitational acceleration" m/s^2
! now initialize BeamDyn for all beams
dt_BD = p_FAST%dt_module( MODULE_BD )
Init%InData_BD%HubPos = ED%y%HubPtMotion%Position(:,1)
Init%InData_BD%HubRot = ED%y%HubPtMotion%RefOrientation(:,:,1)
p_FAST%BD_OutputSibling = .true.
allocate( y_FAST%Lin%Modules(MODULE_BD)%Instance(p_FAST%nBeams), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(BD).", ErrStat, ErrMsg, RoutineName )
CALL Cleanup()
RETURN
end if
DO k=1,p_FAST%nBeams
Init%InData_BD%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_BD))//TRIM( Num2LStr(k) )
Init%InData_BD%InputFile = p_FAST%BDBldFile(k)
Init%InData_BD%GlbPos = ED%y%BladeRootMotion(k)%Position(:,1) ! {:} - - "Initial Position Vector of the local blade coordinate system"
Init%InData_BD%GlbRot = ED%y%BladeRootMotion(k)%RefOrientation(:,:,1) ! {:}{:} - - "Initial direction cosine matrix of the local blade coordinate system"
Init%InData_BD%RootDisp = ED%y%BladeRootMotion(k)%TranslationDisp(:,1) ! {:} - - "Initial root displacement"
Init%InData_BD%RootOri = ED%y%BladeRootMotion(k)%Orientation(:,:,1) ! {:}{:} - - "Initial root orientation"
Init%InData_BD%RootVel(1:3) = ED%y%BladeRootMotion(k)%TranslationVel(:,1) ! {:} - - "Initial root velocities and angular veolcities"
Init%InData_BD%RootVel(4:6) = ED%y%BladeRootMotion(k)%RotationVel(:,1) ! {:} - - "Initial root velocities and angular veolcities"
CALL BD_Init( Init%InData_BD, BD%Input(1,k), BD%p(k), BD%x(k,STATE_CURR), BD%xd(k,STATE_CURR), BD%z(k,STATE_CURR), &
BD%OtherSt(k,STATE_CURR), BD%y(k), BD%m(k), dt_BD, Init%OutData_BD(k), ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
!bjj: we're going to force this to have the same timestep because I don't want to have to deal with n BD modules with n timesteps.
IF ( k == 1 ) THEN
p_FAST%dt_module( MODULE_BD ) = dt_BD
p_FAST%ModuleInitialized(Module_BD) = .TRUE. ! this really should be once per BD instance, but BD doesn't care so I won't go through the effort to track this
CALL SetModuleSubstepTime(Module_BD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
ELSEIF ( .NOT. EqualRealNos( p_FAST%dt_module( MODULE_BD ),dt_BD )) THEN
CALL SetErrStat(ErrID_Fatal,"All instances of BeamDyn (one per blade) must have the same time step.",ErrStat,ErrMsg,RoutineName)
END IF
! We're going to do fewer computations if the BD input and output meshes that couple to AD are siblings:
if (BD%p(k)%BldMotionNodeLoc /= BD_MESH_QP) p_FAST%BD_OutputSibling = .false.
if (ErrStat>=AbortErrLev) exit !exit this loop so we don't get p_FAST%nBeams of the same errors
if (size(y_FAST%Lin%Modules(MODULE_BD)%Instance) >= k) then ! for aero maps, we only use the first instance:
if (allocated(Init%OutData_BD(k)%LinNames_y)) call move_alloc(Init%OutData_BD(k)%LinNames_y, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%Names_y )
if (allocated(Init%OutData_BD(k)%LinNames_x)) call move_alloc(Init%OutData_BD(k)%LinNames_x, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%Names_x )
if (allocated(Init%OutData_BD(k)%LinNames_u)) call move_alloc(Init%OutData_BD(k)%LinNames_u, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%Names_u )
if (allocated(Init%OutData_BD(k)%RotFrame_y)) call move_alloc(Init%OutData_BD(k)%RotFrame_y, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%RotFrame_y )
if (allocated(Init%OutData_BD(k)%RotFrame_x)) call move_alloc(Init%OutData_BD(k)%RotFrame_x, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%RotFrame_x )
if (allocated(Init%OutData_BD(k)%RotFrame_u)) call move_alloc(Init%OutData_BD(k)%RotFrame_u, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%RotFrame_u )
if (allocated(Init%OutData_BD(k)%IsLoad_u )) call move_alloc(Init%OutData_BD(k)%IsLoad_u , y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%IsLoad_u )
if (allocated(Init%OutData_BD(k)%DerivOrder_x)) call move_alloc(Init%OutData_BD(k)%DerivOrder_x, y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%DerivOrder_x )
if (allocated(Init%OutData_BD(k)%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_BD)%Instance(k)%NumOutputs = size(Init%OutData_BD(k)%WriteOutputHdr)
end if
END DO
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF
! ........................
! initialize AeroDyn
! ........................
ALLOCATE( AD14%Input( p_FAST%InterpOrder+1 ), AD14%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating AD14%Input and AD14%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( AD%Input( p_FAST%InterpOrder+1 ), AD%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating AD%Input and AD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF ( p_FAST%CompAero == Module_AD14 ) THEN
CALL AD_SetInitInput(Init%InData_AD14, Init%OutData_ED, ED%y, p_FAST, ErrStat2, ErrMsg2) ! set the values in Init%InData_AD14
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AD14_Init( Init%InData_AD14, AD14%Input(1), AD14%p, AD14%x(STATE_CURR), AD14%xd(STATE_CURR), AD14%z(STATE_CURR), &
AD14%OtherSt(STATE_CURR), AD14%y, AD14%m, p_FAST%dt_module( MODULE_AD14 ), Init%OutData_AD14, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_AD14) = .TRUE.
CALL SetModuleSubstepTime(Module_AD14, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
! bjj: this really shouldn't be in the FAST glue code, but I'm going to put this check here so people don't use an invalid model
! and send me emails to debug numerical issues in their results.
IF ( AD14%p%TwrProps%PJM_Version .AND. p_FAST%TurbineType == Type_Offshore_Floating ) THEN
CALL SetErrStat(ErrID_Fatal,'AeroDyn v14 tower influence model "NEWTOWER" is invalid for models of floating offshore turbines.',ErrStat,ErrMsg,RoutineName)
END IF
AirDens = Init%OutData_AD14%AirDens
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
allocate(Init%InData_AD%rotors(1), stat=errStat)
if (errStat/=0) then
call SetErrStat( ErrID_Fatal, 'Allocating rotors', errStat, errMsg, RoutineName )
call Cleanup()
return
end if
Init%InData_AD%rotors(1)%NumBlades = NumBl
! set initialization data for AD
CALL AllocAry( Init%InData_AD%rotors(1)%BladeRootPosition, 3, Init%InData_AD%rotors(1)%NumBlades, 'Init%InData_AD%BladeRootPosition', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AllocAry( Init%InData_AD%rotors(1)%BladeRootOrientation,3, 3, Init%InData_AD%rotors(1)%NumBlades, 'Init%InData_AD%BladeRootOrientation', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
Init%InData_AD%Gravity = Init%OutData_ED%Gravity
Init%InData_AD%Linearize = p_FAST%Linearize
Init%InData_AD%InputFile = p_FAST%AeroFile
Init%InData_AD%RootName = p_FAST%OutFileRoot
Init%InData_AD%rotors(1)%HubPosition = ED%y%HubPtMotion%Position(:,1)
Init%InData_AD%rotors(1)%HubOrientation = ED%y%HubPtMotion%RefOrientation(:,:,1)
Init%InData_AD%rotors(1)%NacelleOrientation = ED%y%NacelleMotion%RefOrientation(:,:,1)
do k=1,NumBl
Init%InData_AD%rotors(1)%BladeRootPosition(:,k) = ED%y%BladeRootMotion(k)%Position(:,1)
Init%InData_AD%rotors(1)%BladeRootOrientation(:,:,k) = ED%y%BladeRootMotion(k)%RefOrientation(:,:,1)
end do
CALL AD_Init( Init%InData_AD, AD%Input(1), AD%p, AD%x(STATE_CURR), AD%xd(STATE_CURR), AD%z(STATE_CURR), &
AD%OtherSt(STATE_CURR), AD%y, AD%m, p_FAST%dt_module( MODULE_AD ), Init%OutData_AD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_AD) = .TRUE.
CALL SetModuleSubstepTime(Module_AD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(MODULE_AD)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(AD).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_AD%rotors(1)%LinNames_u )) call move_alloc(Init%OutData_AD%rotors(1)%LinNames_u ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%Names_u )
if (allocated(Init%OutData_AD%rotors(1)%LinNames_y )) call move_alloc(Init%OutData_AD%rotors(1)%LinNames_y ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%Names_y )
if (allocated(Init%OutData_AD%rotors(1)%LinNames_x )) call move_alloc(Init%OutData_AD%rotors(1)%LinNames_x ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%Names_x )
if (allocated(Init%OutData_AD%rotors(1)%RotFrame_u )) call move_alloc(Init%OutData_AD%rotors(1)%RotFrame_u ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%RotFrame_u )
if (allocated(Init%OutData_AD%rotors(1)%RotFrame_y )) call move_alloc(Init%OutData_AD%rotors(1)%RotFrame_y ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%RotFrame_y )
if (allocated(Init%OutData_AD%rotors(1)%RotFrame_x )) call move_alloc(Init%OutData_AD%rotors(1)%RotFrame_x ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%RotFrame_x )
if (allocated(Init%OutData_AD%rotors(1)%IsLoad_u )) call move_alloc(Init%OutData_AD%rotors(1)%IsLoad_u ,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_AD%rotors(1)%DerivOrder_x)) call move_alloc(Init%OutData_AD%rotors(1)%DerivOrder_x,y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%DerivOrder_x )
if (allocated(Init%OutData_AD%rotors(1)%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_AD)%Instance(1)%NumOutputs = size(Init%OutData_AD%rotors(1)%WriteOutputHdr)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
AirDens = Init%OutData_AD%rotors(1)%AirDens
ELSE
AirDens = 0.0_ReKi
END IF ! CompAero
! ........................
! initialize InflowWind
! ........................
ALLOCATE( IfW%Input( p_FAST%InterpOrder+1 ), IfW%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating IfW%Input and IfW%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF ( p_FAST%CompInflow == Module_IfW ) THEN
Init%InData_IfW%Linearize = p_FAST%Linearize
Init%InData_IfW%InputFileName = p_FAST%InflowFile
Init%InData_IfW%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_IfW))
Init%InData_IfW%UseInputFile = .TRUE.
Init%InData_IfW%NumWindPoints = 0
IF ( p_FAST%CompServo == Module_SrvD ) Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + 1
IF ( p_FAST%CompAero == Module_AD14 ) THEN
Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + NumBl * AD14%Input(1)%InputMarkers(1)%NNodes + AD14%Input(1)%Twr_InputMarkers%NNodes
ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + AD%Input(1)%rotors(1)%TowerMotion%NNodes
DO k=1,NumBl
Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + AD%Input(1)%rotors(1)%BladeMotion(k)%NNodes
END DO
if (allocated(AD%OtherSt(STATE_CURR)%WakeLocationPoints)) then
Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + size(AD%OtherSt(STATE_CURR)%WakeLocationPoints,DIM=2)
end if
Init%InData_IfW%NumWindPoints = Init%InData_IfW%NumWindPoints + AD%Input(1)%rotors(1)%NacelleMotion%NNodes ! 1 point
END IF
! lidar
Init%InData_IfW%lidar%Tmax = p_FAST%TMax
Init%InData_IfW%lidar%HubPosition = ED%y%HubPtMotion%Position(:,1)
IF ( PRESENT(ExternInitData) ) THEN
Init%InData_IfW%Use4Dext = ExternInitData%FarmIntegration
if (Init%InData_IfW%Use4Dext) then
Init%InData_IfW%FDext%n = ExternInitData%windGrid_n
Init%InData_IfW%FDext%delta = ExternInitData%windGrid_delta
Init%InData_IfW%FDext%pZero = ExternInitData%windGrid_pZero
end if
! bjj: these lidar inputs should come from an InflowWind input file; I'm hard coding them here for now
Init%InData_IfW%lidar%SensorType = ExternInitData%SensorType
Init%InData_IfW%lidar%LidRadialVel = ExternInitData%LidRadialVel
Init%InData_IfW%lidar%RotorApexOffsetPos = 0.0
Init%InData_IfW%lidar%NumPulseGate = 0
ELSE
Init%InData_IfW%lidar%SensorType = SensorType_None
Init%InData_IfW%Use4Dext = .false.
END IF
CALL InflowWind_Init( Init%InData_IfW, IfW%Input(1), IfW%p, IfW%x(STATE_CURR), IfW%xd(STATE_CURR), IfW%z(STATE_CURR), &
IfW%OtherSt(STATE_CURR), IfW%y, IfW%m, p_FAST%dt_module( MODULE_IfW ), Init%OutData_IfW, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_IfW) = .TRUE.
CALL SetModuleSubstepTime(Module_IfW, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(MODULE_IfW)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(IfW).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_IfW%LinNames_y)) call move_alloc(Init%OutData_IfW%LinNames_y,y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%Names_y )
if (allocated(Init%OutData_IfW%LinNames_u)) call move_alloc(Init%OutData_IfW%LinNames_u,y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%Names_u )
if (allocated(Init%OutData_IfW%RotFrame_y)) call move_alloc(Init%OutData_IfW%RotFrame_y,y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%RotFrame_y )
if (allocated(Init%OutData_IfW%RotFrame_u)) call move_alloc(Init%OutData_IfW%RotFrame_u,y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%RotFrame_u )
if (allocated(Init%OutData_IfW%IsLoad_u )) call move_alloc(Init%OutData_IfW%IsLoad_u ,y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_IfW%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_IfW)%Instance(1)%NumOutputs = size(Init%OutData_IfW%WriteOutputHdr)
y_FAST%Lin%WindSpeed = Init%OutData_IfW%WindFileInfo%MWS
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
ELSEIF ( p_FAST%CompInflow == Module_OpFM ) THEN
IF ( PRESENT(ExternInitData) ) THEN
Init%InData_OpFM%NumSC2Ctrl = ExternInitData%NumSC2Ctrl
Init%InData_OpFM%NumCtrl2SC = ExternInitData%NumCtrl2SC
Init%InData_OpFM%NumActForcePtsBlade = ExternInitData%NumActForcePtsBlade
Init%InData_OpFM%NumActForcePtsTower = ExternInitData%NumActForcePtsTower
ELSE
CALL SetErrStat( ErrID_Fatal, 'OpenFOAM integration can be used only with external input data (not the stand-alone executable).', ErrStat, ErrMsg, RoutineName )
CALL Cleanup()
RETURN
END IF
Init%InData_OpFM%BladeLength = Init%OutData_ED%BladeLength
Init%InData_OpFM%TowerHeight = Init%OutData_ED%TowerHeight
Init%InData_OpFM%TowerBaseHeight = Init%OutData_ED%TowerBaseHeight
ALLOCATE(Init%InData_OpFM%StructBldRNodes( SIZE(Init%OutData_ED%BldRNodes)), STAT=ErrStat2)
Init%InData_OpFM%StructBldRNodes(:) = Init%OutData_ED%BldRNodes(:)
ALLOCATE(Init%InData_OpFM%StructTwrHNodes( SIZE(Init%OutData_ED%TwrHNodes)), STAT=ErrStat2)
Init%InData_OpFM%StructTwrHNodes(:) = Init%OutData_ED%TwrHNodes(:)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating OpFM%InitInput.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
! set up the data structures for integration with OpenFOAM
CALL Init_OpFM( Init%InData_OpFM, p_FAST, AirDens, AD14%Input(1), AD%Input(1), Init%OutData_AD, AD%y, ED%y, OpFM, Init%OutData_OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
!bjj: fix me!!! to do
Init%OutData_IfW%WindFileInfo%MWS = 0.0_ReKi
ELSE
Init%OutData_IfW%WindFileInfo%MWS = 0.0_ReKi
END IF ! CompInflow
! ........................
! initialize SuperController
! ........................
IF ( PRESENT(ExternInitData) ) THEN
Init%InData_SC%NumSC2Ctrl = ExternInitData%NumSC2Ctrl
Init%InData_SC%NumCtrl2SC = ExternInitData%NumCtrl2SC
ELSE
Init%InData_SC%NumSC2Ctrl = 0
Init%InData_SC%NumCtrl2SC = 0
END IF
! set up the data structures for integration with supercontroller
CALL Init_SC( Init%InData_SC, SC, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! some checks for AeroDyn14's Dynamic Inflow with Mean Wind Speed from InflowWind:
! (DO NOT COPY THIS CODE!)
! bjj: AeroDyn14 should not need this rule of thumb; it should check the instantaneous values when the code runs
! ........................
IF ( p_FAST%CompAero == Module_AD14 ) THEN
IF (AD14%p%DynInfl) THEN
IF ( Init%OutData_IfW%WindFileInfo%MWS < 8.0 ) THEN
CALL SetErrStat(ErrID_Fatal,'AeroDyn v14 "DYNINFL" InfModel is invalid for models with wind speeds less than 8 m/s.',ErrStat,ErrMsg,RoutineName)
!CALL SetErrStat(ErrID_Info,'Estimated average inflow wind speed is less than 8 m/s. Dynamic Inflow will be turned off.',ErrStat,ErrMess,RoutineName )
END IF
END IF
END IF
! ........................
! initialize ServoDyn
! ........................
ALLOCATE( SrvD%Input( p_FAST%InterpOrder+1 ), SrvD%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating SrvD%Input and SrvD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF ( p_FAST%CompServo == Module_SrvD ) THEN
Init%InData_SrvD%InputFile = p_FAST%ServoFile
Init%InData_SrvD%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_SrvD))
Init%InData_SrvD%NumBl = NumBl
Init%InData_SrvD%Gravity = (/ 0.0_ReKi, 0.0_ReKi, -Init%OutData_ED%Gravity /) ! "Gravitational acceleration vector" m/s^2
Init%InData_SrvD%NacPosition(1:3) = ED%Input(1)%NacelleLoads%Position(1:3,1)
Init%InData_SrvD%NacOrientation(1:3,1:3) = ED%Input(1)%NacelleLoads%RefOrientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%TwrBasePos = Init%OutData_ED%TwrBasePos
Init%InData_SrvD%TwrBaseOrient = Init%OutData_ED%TwrBaseOrient ! R8Ki
Init%InData_SrvD%PlatformPos(1:3) = ED%y%PlatformPtMesh%Position(1:3,1)
Init%InData_SrvD%PlatformOrient(1:3,1:3) = ED%y%PlatformPtMesh%Orientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%TMax = p_FAST%TMax
Init%InData_SrvD%AirDens = AirDens
Init%InData_SrvD%AvgWindSpeed = Init%OutData_IfW%WindFileInfo%MWS
Init%InData_SrvD%Linearize = p_FAST%Linearize
Init%InData_SrvD%TrimCase = p_FAST%TrimCase
Init%InData_SrvD%TrimGain = p_FAST%TrimGain
Init%InData_SrvD%RotSpeedRef = Init%OutData_ED%RotSpeed
CALL AllocAry( Init%InData_SrvD%BladeRootPosition, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootPosition', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AllocAry( Init%InData_SrvD%BladeRootOrientation,3, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootOrientation', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
do k=1,Init%OutData_ED%NumBl
Init%InData_SrvD%BladeRootPosition(:,k) = ED%y%BladeRootMotion(k)%Position(:,1)
Init%InData_SrvD%BladeRootOrientation(:,:,k) = ED%y%BladeRootMotion(k)%RefOrientation(:,:,1)
enddo
IF ( PRESENT(ExternInitData) ) THEN
Init%InData_SrvD%NumSC2Ctrl = ExternInitData%NumSC2Ctrl
Init%InData_SrvD%NumCtrl2SC = ExternInitData%NumCtrl2SC
ELSE
Init%InData_SrvD%NumSC2Ctrl = 0
Init%InData_SrvD%NumCtrl2SC = 0
END IF
CALL AllocAry(Init%InData_SrvD%BlPitchInit, Init%OutData_ED%NumBl, 'BlPitchInit', ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
if (ErrStat >= abortErrLev) then ! make sure allocatable arrays are valid before setting them
CALL Cleanup()
RETURN
end if
Init%InData_SrvD%BlPitchInit = Init%OutData_ED%BlPitch
CALL SrvD_Init( Init%InData_SrvD, SrvD%Input(1), SrvD%p, SrvD%x(STATE_CURR), SrvD%xd(STATE_CURR), SrvD%z(STATE_CURR), &
SrvD%OtherSt(STATE_CURR), SrvD%y, SrvD%m, p_FAST%dt_module( MODULE_SrvD ), Init%OutData_SrvD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_SrvD) = .TRUE.
!IF ( Init%OutData_SrvD%CouplingScheme == ExplicitLoose ) THEN ... bjj: abort if we're doing anything else!
CALL SetModuleSubstepTime(Module_SrvD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
!! initialize SrvD%y%ElecPwr and SrvD%y%GenTq because they are one timestep different (used as input for the next step)?
allocate( y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(SrvD).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_SrvD%LinNames_y)) call move_alloc(Init%OutData_SrvD%LinNames_y,y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%Names_y )
if (allocated(Init%OutData_SrvD%LinNames_u)) call move_alloc(Init%OutData_SrvD%LinNames_u,y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%Names_u )
if (allocated(Init%OutData_SrvD%RotFrame_y)) call move_alloc(Init%OutData_SrvD%RotFrame_y,y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%RotFrame_y )
if (allocated(Init%OutData_SrvD%RotFrame_u)) call move_alloc(Init%OutData_SrvD%RotFrame_u,y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%RotFrame_u )
if (allocated(Init%OutData_SrvD%IsLoad_u )) call move_alloc(Init%OutData_SrvD%IsLoad_u ,y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_SrvD%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_SrvD)%Instance(1)%NumOutputs = size(Init%OutData_SrvD%WriteOutputHdr)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! some checks for AeroDyn and ElastoDyn inputs with the high-speed shaft brake hack in ElastoDyn:
! (DO NOT COPY THIS CODE!)
! ........................
! bjj: this is a hack to get high-speed shaft braking in FAST v8
IF ( Init%OutData_SrvD%UseHSSBrake ) THEN
IF ( p_FAST%CompAero == Module_AD14 ) THEN
IF ( AD14%p%DYNINFL ) THEN
CALL SetErrStat(ErrID_Fatal,'AeroDyn v14 "DYNINFL" InfModel is invalid for models with high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
END IF
END IF
IF ( ED%p%method == Method_RK4 ) THEN ! bjj: should be using ElastoDyn's Method_ABM4 Method_AB4 parameters
CALL SetErrStat(ErrID_Fatal,'ElastoDyn must use the AB4 or ABM4 integration method to implement high-speed shaft braking.',ErrStat,ErrMsg,RoutineName)
ENDIF
END IF ! Init%OutData_SrvD%UseHSSBrake
END IF
! ........................
! set some VTK parameters required before HydroDyn init (so we can get wave elevations for visualization)
! ........................
! get wave elevation data for visualization
if ( p_FAST%WrVTK > VTK_None ) then
call SetVTKParameters_B4HD(p_FAST, Init%OutData_ED, Init%InData_HD, BD, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
end if
! ........................
! initialize HydroDyn
! ........................
ALLOCATE( HD%Input( p_FAST%InterpOrder+1 ), HD%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating HD%Input and HD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF ( p_FAST%CompHydro == Module_HD ) THEN
Init%InData_HD%Gravity = Init%OutData_ED%Gravity
Init%InData_HD%UseInputFile = .TRUE.
Init%InData_HD%InputFile = p_FAST%HydroFile
Init%InData_HD%OutRootName = p_FAST%OutFileRoot
Init%InData_HD%TMax = p_FAST%TMax
Init%InData_HD%hasIce = p_FAST%CompIce /= Module_None
Init%InData_HD%Linearize = p_FAST%Linearize
! if wave field needs an offset, modify these values (added at request of SOWFA developers):
Init%InData_HD%PtfmLocationX = p_FAST%TurbinePos(1)
Init%InData_HD%PtfmLocationY = p_FAST%TurbinePos(2)
CALL HydroDyn_Init( Init%InData_HD, HD%Input(1), HD%p, HD%x(STATE_CURR), HD%xd(STATE_CURR), HD%z(STATE_CURR), &
HD%OtherSt(STATE_CURR), HD%y, HD%m, p_FAST%dt_module( MODULE_HD ), Init%OutData_HD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_HD) = .TRUE.
CALL SetModuleSubstepTime(Module_HD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(MODULE_HD)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(HD).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_HD%LinNames_y)) call move_alloc(Init%OutData_HD%LinNames_y,y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%Names_y )
if (allocated(Init%OutData_HD%LinNames_u)) call move_alloc(Init%OutData_HD%LinNames_u,y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%Names_u )
if (allocated(Init%OutData_HD%LinNames_x)) call move_alloc(Init%OutData_HD%LinNames_x, y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%Names_x )
if (allocated(Init%OutData_HD%DerivOrder_x)) call move_alloc(Init%OutData_HD%DerivOrder_x,y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%DerivOrder_x)
if (allocated(Init%OutData_HD%IsLoad_u )) call move_alloc(Init%OutData_HD%IsLoad_u ,y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_HD%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_HD)%Instance(1)%NumOutputs = size(Init%OutData_HD%WriteOutputHdr)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF ! CompHydro
! ........................
! initialize SubDyn or ExtPtfm_MCKF
! ........................
ALLOCATE( SD%Input( p_FAST%InterpOrder+1 ), SD%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating SD%Input and SD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( ExtPtfm%Input( p_FAST%InterpOrder+1 ), ExtPtfm%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating ExtPtfm%Input and ExtPtfm%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
IF ( p_FAST%CompSub == Module_SD ) THEN
IF ( p_FAST%CompHydro == Module_HD ) THEN
Init%InData_SD%WtrDpth = Init%OutData_HD%WtrDpth
ELSE
Init%InData_SD%WtrDpth = 0.0_ReKi
END IF
Init%InData_SD%Linearize = p_FAST%Linearize
Init%InData_SD%g = Init%OutData_ED%Gravity
!Ini%tInData_SD%UseInputFile = .TRUE.
Init%InData_SD%SDInputFile = p_FAST%SubFile
Init%InData_SD%RootName = p_FAST%OutFileRoot
Init%InData_SD%TP_RefPoint = ED%y%PlatformPtMesh%Position(:,1) ! "Interface point" where loads will be transferred to
Init%InData_SD%SubRotateZ = 0.0 ! Used by driver to rotate structure around z
CALL SD_Init( Init%InData_SD, SD%Input(1), SD%p, SD%x(STATE_CURR), SD%xd(STATE_CURR), SD%z(STATE_CURR), &
SD%OtherSt(STATE_CURR), SD%y, SD%m, p_FAST%dt_module( MODULE_SD ), Init%OutData_SD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_SD) = .TRUE.
CALL SetModuleSubstepTime(Module_SD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(MODULE_SD)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(SD).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_SD%LinNames_y)) call move_alloc(Init%OutData_SD%LinNames_y,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%Names_y)
if (allocated(Init%OutData_SD%LinNames_x)) call move_alloc(Init%OutData_SD%LinNames_x,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%Names_x)
if (allocated(Init%OutData_SD%LinNames_u)) call move_alloc(Init%OutData_SD%LinNames_u,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%Names_u)
if (allocated(Init%OutData_SD%RotFrame_y)) call move_alloc(Init%OutData_SD%RotFrame_y,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%RotFrame_y)
if (allocated(Init%OutData_SD%RotFrame_x)) call move_alloc(Init%OutData_SD%RotFrame_x,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%RotFrame_x)
if (allocated(Init%OutData_SD%RotFrame_u)) call move_alloc(Init%OutData_SD%RotFrame_u,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%RotFrame_u)
if (allocated(Init%OutData_SD%IsLoad_u )) call move_alloc(Init%OutData_SD%IsLoad_u ,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_SD%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%NumOutputs = size(Init%OutData_SD%WriteOutputHdr)
if (allocated(Init%OutData_SD%DerivOrder_x)) call move_alloc(Init%OutData_SD%DerivOrder_x,y_FAST%Lin%Modules(MODULE_SD)%Instance(1)%DerivOrder_x)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
ELSE IF ( p_FAST%CompSub == Module_ExtPtfm ) THEN
Init%InData_ExtPtfm%InputFile = p_FAST%SubFile
Init%InData_ExtPtfm%RootName = trim(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_ExtPtfm))
Init%InData_ExtPtfm%Linearize = p_FAST%Linearize
Init%InData_ExtPtfm%PtfmRefzt = ED%p%PtfmRefzt ! Required
CALL ExtPtfm_Init( Init%InData_ExtPtfm, ExtPtfm%Input(1), ExtPtfm%p, &
ExtPtfm%x(STATE_CURR), ExtPtfm%xd(STATE_CURR), ExtPtfm%z(STATE_CURR), ExtPtfm%OtherSt(STATE_CURR), &
ExtPtfm%y, ExtPtfm%m, p_FAST%dt_module( MODULE_ExtPtfm ), Init%OutData_ExtPtfm, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(MODULE_ExtPtfm) = .TRUE.
CALL SetModuleSubstepTime(MODULE_ExtPtfm, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(ExtPtfm).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_ExtPtfm%LinNames_y)) call move_alloc(Init%OutData_ExtPtfm%LinNames_y,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%Names_y)
if (allocated(Init%OutData_ExtPtfm%LinNames_x)) call move_alloc(Init%OutData_ExtPtfm%LinNames_x,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%Names_x)
if (allocated(Init%OutData_ExtPtfm%LinNames_u)) call move_alloc(Init%OutData_ExtPtfm%LinNames_u,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%Names_u)
if (allocated(Init%OutData_ExtPtfm%RotFrame_y)) call move_alloc(Init%OutData_ExtPtfm%RotFrame_y,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%RotFrame_y)
if (allocated(Init%OutData_ExtPtfm%RotFrame_x)) call move_alloc(Init%OutData_ExtPtfm%RotFrame_x,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%RotFrame_x)
if (allocated(Init%OutData_ExtPtfm%RotFrame_u)) call move_alloc(Init%OutData_ExtPtfm%RotFrame_u,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%RotFrame_u)
if (allocated(Init%OutData_ExtPtfm%IsLoad_u )) call move_alloc(Init%OutData_ExtPtfm%IsLoad_u ,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_ExtPtfm%WriteOutputHdr)) y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%NumOutputs = size(Init%OutData_ExtPtfm%WriteOutputHdr)
if (allocated(Init%OutData_ExtPtfm%DerivOrder_x)) call move_alloc(Init%OutData_ExtPtfm%DerivOrder_x,y_FAST%Lin%Modules(MODULE_ExtPtfm)%Instance(1)%DerivOrder_x)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF
! ------------------------------
! initialize CompMooring modules
! ------------------------------
ALLOCATE( MAPp%Input( p_FAST%InterpOrder+1 ), MAPp%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating MAPp%Input and MAPp%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( MD%Input( p_FAST%InterpOrder+1 ), MD%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating MD%Input and MD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( FEAM%Input( p_FAST%InterpOrder+1 ), FEAM%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating FEAM%Input and FEAM%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( Orca%Input( p_FAST%InterpOrder+1 ), Orca%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating Orca%Input and Orca%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
! ........................
! initialize MAP
! ........................
IF (p_FAST%CompMooring == Module_MAP) THEN
!bjj: until we modify this, MAP requires HydroDyn to be used. (perhaps we could send air density from AeroDyn or something...)
CALL WrScr(NewLine) !bjj: I'm printing two blank lines here because MAP seems to be writing over the last line on the screen.
! Init%InData_MAP%rootname = p_FAST%OutFileRoot ! Output file name
Init%InData_MAP%gravity = Init%OutData_ED%Gravity ! This need to be according to g used in ElastoDyn
Init%InData_MAP%sea_density = Init%OutData_HD%WtrDens ! This needs to be set according to seawater density in HydroDyn
Init%InData_MAP%depth = Init%OutData_HD%WtrDpth ! This need to be set according to the water depth in HydroDyn
! differences for MAP++
Init%InData_MAP%file_name = p_FAST%MooringFile ! This needs to be set according to what is in the FAST input file.
Init%InData_MAP%summary_file_name = TRIM(p_FAST%OutFileRoot)//'.MAP.sum' ! Output file name
Init%InData_MAP%depth = -Init%OutData_HD%WtrDpth ! This need to be set according to the water depth in HydroDyn
Init%InData_MAP%LinInitInp%Linearize = p_FAST%Linearize
CALL MAP_Init( Init%InData_MAP, MAPp%Input(1), MAPp%p, MAPp%x(STATE_CURR), MAPp%xd(STATE_CURR), MAPp%z(STATE_CURR), MAPp%OtherSt, &
MAPp%y, p_FAST%dt_module( MODULE_MAP ), Init%OutData_MAP, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_MAP) = .TRUE.
CALL SetModuleSubstepTime(Module_MAP, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
allocate( y_FAST%Lin%Modules(Module_MAP)%Instance(1), stat=ErrStat2)
if (ErrStat2 /= 0 ) then
call SetErrStat(ErrID_Fatal, "Error allocating Lin%Modules(MAP).", ErrStat, ErrMsg, RoutineName )
else
if (allocated(Init%OutData_MAP%LinInitOut%LinNames_y)) call move_alloc(Init%OutData_MAP%LinInitOut%LinNames_y,y_FAST%Lin%Modules(Module_MAP)%Instance(1)%Names_y )
if (allocated(Init%OutData_MAP%LinInitOut%LinNames_u)) call move_alloc(Init%OutData_MAP%LinInitOut%LinNames_u,y_FAST%Lin%Modules(Module_MAP)%Instance(1)%Names_u )
if (allocated(Init%OutData_MAP%LinInitOut%IsLoad_u )) call move_alloc(Init%OutData_MAP%LinInitOut%IsLoad_u ,y_FAST%Lin%Modules(Module_MAP)%Instance(1)%IsLoad_u )
if (allocated(Init%OutData_MAP%WriteOutputHdr)) y_FAST%Lin%Modules(Module_MAP)%Instance(1)%NumOutputs = size(Init%OutData_MAP%WriteOutputHdr)
end if
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! initialize MoorDyn
! ........................
ELSEIF (p_FAST%CompMooring == Module_MD) THEN
Init%InData_MD%FileName = p_FAST%MooringFile ! This needs to be set according to what is in the FAST input file.
Init%InData_MD%RootName = p_FAST%OutFileRoot
Init%InData_MD%PtfmInit = Init%OutData_ED%PlatformPos !ED%x(STATE_CURR)%QT(1:6) ! initial position of the platform !bjj: this should come from Init%OutData_ED, not x_ED
Init%InData_MD%g = Init%OutData_ED%Gravity ! This need to be according to g used in ElastoDyn
Init%InData_MD%rhoW = Init%OutData_HD%WtrDens ! This needs to be set according to seawater density in HydroDyn
Init%InData_MD%WtrDepth = Init%OutData_HD%WtrDpth ! This need to be set according to the water depth in HydroDyn
CALL MD_Init( Init%InData_MD, MD%Input(1), MD%p, MD%x(STATE_CURR), MD%xd(STATE_CURR), MD%z(STATE_CURR), &
MD%OtherSt(STATE_CURR), MD%y, MD%m, p_FAST%dt_module( MODULE_MD ), Init%OutData_MD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_MD) = .TRUE.
CALL SetModuleSubstepTime(Module_MD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! initialize FEAM
! ........................
ELSEIF (p_FAST%CompMooring == Module_FEAM) THEN
Init%InData_FEAM%InputFile = p_FAST%MooringFile ! This needs to be set according to what is in the FAST input file.
Init%InData_FEAM%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_FEAM))
Init%InData_FEAM%PtfmInit = Init%OutData_ED%PlatformPos !ED%x(STATE_CURR)%QT(1:6) ! initial position of the platform !bjj: this should come from Init%OutData_ED, not x_ED
Init%InData_FEAM%NStepWave = 1 ! an arbitrary number > 0 (to set the size of the wave data, which currently contains all zero values)
Init%InData_FEAM%gravity = Init%OutData_ED%Gravity ! This need to be according to g used in ElastoDyn
Init%InData_FEAM%WtrDens = Init%OutData_HD%WtrDens ! This needs to be set according to seawater density in HydroDyn
! Init%InData_FEAM%depth = Init%OutData_HD%WtrDpth ! This need to be set according to the water depth in HydroDyn
CALL FEAM_Init( Init%InData_FEAM, FEAM%Input(1), FEAM%p, FEAM%x(STATE_CURR), FEAM%xd(STATE_CURR), FEAM%z(STATE_CURR), &
FEAM%OtherSt(STATE_CURR), FEAM%y, FEAM%m, p_FAST%dt_module( MODULE_FEAM ), Init%OutData_FEAM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_FEAM) = .TRUE.
CALL SetModuleSubstepTime(Module_FEAM, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! initialize OrcaFlex Interface
! ........................
ELSEIF (p_FAST%CompMooring == Module_Orca) THEN
Init%InData_Orca%InputFile = p_FAST%MooringFile
Init%InData_Orca%RootName = p_FAST%OutFileRoot
Init%InData_Orca%TMax = p_FAST%TMax
CALL Orca_Init( Init%InData_Orca, Orca%Input(1), Orca%p, Orca%x(STATE_CURR), Orca%xd(STATE_CURR), Orca%z(STATE_CURR), Orca%OtherSt(STATE_CURR), &
Orca%y, Orca%m, p_FAST%dt_module( MODULE_Orca ), Init%OutData_Orca, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(MODULE_Orca) = .TRUE.
CALL SetModuleSubstepTime(MODULE_Orca, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF
! ------------------------------
! initialize CompIce modules
! ------------------------------
ALLOCATE( IceF%Input( p_FAST%InterpOrder+1 ), IceF%InputTimes( p_FAST%InterpOrder+1 ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating IceF%Input and IceF%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
! We need this to be allocated (else we have issues passing nonallocated arrays and using the first index of Input(),
! but we don't need the space of IceD_MaxLegs if we're not using it.
IF ( p_FAST%CompIce /= Module_IceD ) THEN
IceDim = 1
ELSE
IceDim = IceD_MaxLegs
END IF
! because there may be multiple instances of IceDyn, we'll allocate arrays for that here
! we could allocate these after
ALLOCATE( IceD%Input( p_FAST%InterpOrder+1, IceDim ), IceD%InputTimes( p_FAST%InterpOrder+1, IceDim ), STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating IceD%Input and IceD%InputTimes.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
ALLOCATE( IceD%x( IceDim,2), &
IceD%xd( IceDim,2), &
IceD%z( IceDim,2), &
IceD%OtherSt( IceDim,2), &
IceD%p( IceDim ), &
IceD%u( IceDim ), &
IceD%y( IceDim ), &
IceD%m( IceDim ), &
STAT = ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating IceD state, input, and output data.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
! ........................
! initialize IceFloe
! ........................
IF ( p_FAST%CompIce == Module_IceF ) THEN
Init%InData_IceF%InputFile = p_FAST%IceFile
Init%InData_IceF%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_IceF))
Init%InData_IceF%simLength = p_FAST%TMax !bjj: IceFloe stores this as single-precision (ReKi) TMax is DbKi
Init%InData_IceF%MSL2SWL = Init%OutData_HD%MSL2SWL
Init%InData_IceF%gravity = Init%OutData_ED%Gravity
CALL IceFloe_Init( Init%InData_IceF, IceF%Input(1), IceF%p, IceF%x(STATE_CURR), IceF%xd(STATE_CURR), IceF%z(STATE_CURR), &
IceF%OtherSt(STATE_CURR), IceF%y, IceF%m, p_FAST%dt_module( MODULE_IceF ), Init%OutData_IceF, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_IceF) = .TRUE.
CALL SetModuleSubstepTime(Module_IceF, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
! ........................
! initialize IceDyn
! ........................
ELSEIF ( p_FAST%CompIce == Module_IceD ) THEN
Init%InData_IceD%InputFile = p_FAST%IceFile
Init%InData_IceD%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_IceD))//'1'
Init%InData_IceD%MSL2SWL = Init%OutData_HD%MSL2SWL
Init%InData_IceD%WtrDens = Init%OutData_HD%WtrDens
Init%InData_IceD%gravity = Init%OutData_ED%Gravity
Init%InData_IceD%TMax = p_FAST%TMax
Init%InData_IceD%LegNum = 1
CALL IceD_Init( Init%InData_IceD, IceD%Input(1,1), IceD%p(1), IceD%x(1,STATE_CURR), IceD%xd(1,STATE_CURR), IceD%z(1,STATE_CURR), &
IceD%OtherSt(1,STATE_CURR), IceD%y(1), IceD%m(1), p_FAST%dt_module( MODULE_IceD ), Init%OutData_IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
p_FAST%ModuleInitialized(Module_IceD) = .TRUE.
CALL SetModuleSubstepTime(Module_IceD, p_FAST, y_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
! now initialize IceD for additional legs (if necessary)
dt_IceD = p_FAST%dt_module( MODULE_IceD )
p_FAST%numIceLegs = Init%OutData_IceD%numLegs
IF (p_FAST%numIceLegs > IceD_MaxLegs) THEN
CALL SetErrStat(ErrID_Fatal,'IceDyn-FAST coupling is supported for up to '//TRIM(Num2LStr(IceD_MaxLegs))//' legs, but ' &
//TRIM(Num2LStr(p_FAST%numIceLegs))//' legs were specified.',ErrStat,ErrMsg,RoutineName)
END IF
DO i=2,p_FAST%numIceLegs ! basically, we just need IceDyn to set up its meshes for inputs/outputs and possibly initial values for states
Init%InData_IceD%LegNum = i
Init%InData_IceD%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_IceD))//TRIM(Num2LStr(i))
CALL IceD_Init( Init%InData_IceD, IceD%Input(1,i), IceD%p(i), IceD%x(i,STATE_CURR), IceD%xd(i,STATE_CURR), IceD%z(i,STATE_CURR), &
IceD%OtherSt(i,STATE_CURR), IceD%y(i), IceD%m(i), dt_IceD, Init%OutData_IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
!bjj: we're going to force this to have the same timestep because I don't want to have to deal with n IceD modules with n timesteps.
IF (.NOT. EqualRealNos( p_FAST%dt_module( MODULE_IceD ),dt_IceD )) THEN
CALL SetErrStat(ErrID_Fatal,"All instances of IceDyn (one per support-structure leg) must be the same",ErrStat,ErrMsg,RoutineName)
END IF
END DO
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
END IF
! ........................
! Set up output for glue code (must be done after all modules are initialized so we have their WriteOutput information)
! ........................
CALL FAST_InitOutput( p_FAST, y_FAST, Init, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
! -------------------------------------------------------------------------
! Initialize mesh-mapping data
! -------------------------------------------------------------------------
CALL InitModuleMappings(p_FAST, ED, BD, AD14, AD, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
ELSEIF (ErrStat /= ErrID_None) THEN
! a little work-around in case the mesh mapping info messages get too long
CALL WrScr( NewLine//TRIM(ErrMsg)//NewLine )
ErrStat = ErrID_None
ErrMsg = ""
END IF
! -------------------------------------------------------------------------
! Initialize for linearization:
! -------------------------------------------------------------------------
if ( p_FAST%Linearize ) then
! NOTE: In the following call, we use Init%OutData_AD%BladeProps(1)%NumBlNds as the number of aero nodes on EACH blade, which
! is consistent with the current AD implementation, but if AD changes this, then it must be handled here, too!
if (p_FAST%CompAero == MODULE_AD) then
call Init_Lin(p_FAST, y_FAST, m_FAST, AD, ED, NumBl, Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds, ErrStat2, ErrMsg2)
else
call Init_Lin(p_FAST, y_FAST, m_FAST, AD, ED, NumBl, -1, ErrStat2, ErrMsg2)
endif
call SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
if (ErrStat >= AbortErrLev) then
call Cleanup()
return
end if
end if
! -------------------------------------------------------------------------
! Initialize data for VTK output
! -------------------------------------------------------------------------
if ( p_FAST%WrVTK > VTK_None ) then
call SetVTKParameters(p_FAST, Init%OutData_ED, Init%OutData_AD, Init%InData_HD, Init%OutData_HD, ED, BD, AD, HD, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
end if
! -------------------------------------------------------------------------
! Write initialization data to FAST summary file:
! -------------------------------------------------------------------------
if (p_FAST%SumPrint) then
CALL FAST_WrSum( p_FAST, y_FAST, MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
endif
! -------------------------------------------------------------------------
! other misc variables initialized here:
! -------------------------------------------------------------------------
m_FAST%t_global = t_initial
! Initialize external inputs for first step
if ( p_FAST%CompServo == MODULE_SrvD ) then
m_FAST%ExternInput%GenTrq = SrvD%Input(1)%ExternalGenTrq !0.0_ReKi
m_FAST%ExternInput%ElecPwr = SrvD%Input(1)%ExternalElecPwr
m_FAST%ExternInput%YawPosCom = SrvD%Input(1)%ExternalYawPosCom
m_FAST%ExternInput%YawRateCom = SrvD%Input(1)%ExternalYawRateCom
m_FAST%ExternInput%HSSBrFrac = SrvD%Input(1)%ExternalHSSBrFrac
do i=1,SIZE(SrvD%Input(1)%ExternalBlPitchCom)
m_FAST%ExternInput%BlPitchCom(i) = SrvD%Input(1)%ExternalBlPitchCom(i)
end do
end if
m_FAST%ExternInput%LidarFocus = 1.0_ReKi ! make this non-zero (until we add the initial position in the InflowWind input file)
!...............................................................................................................................
! Destroy initializion data
!...............................................................................................................................
CALL Cleanup()
CONTAINS
SUBROUTINE Cleanup()
!...............................................................................................................................
! Destroy initializion data
!...............................................................................................................................
CALL FAST_DestroyInitData( Init, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
END SUBROUTINE Cleanup
END SUBROUTINE FAST_InitializeAll
!----------------------------------------------------------------------------------------------------------------------------------
!> This function returns a string describing the glue code and some of the compilation options we're using.
FUNCTION GetVersion(ThisProgVer)
! Passed Variables:
TYPE(ProgDesc), INTENT( IN ) :: ThisProgVer !< program name/date/version description
CHARACTER(1024) :: GetVersion !< String containing a description of the compiled precision.
CHARACTER(200) :: git_commit
GetVersion = TRIM(GetNVD(ThisProgVer))//', compiled'
IF ( Cmpl4SFun ) THEN ! FAST has been compiled as an S-Function for Simulink
GetVersion = TRIM(GetVersion)//' as a DLL S-Function for Simulink'
ELSEIF ( Cmpl4LV ) THEN ! FAST has been compiled as a DLL for Labview
GetVersion = TRIM(GetVersion)//' as a DLL for LabVIEW'
ENDIF
GetVersion = TRIM(GetVersion)//' as a '//TRIM(Num2LStr(BITS_IN_ADDR))//'-bit application using'
! determine precision
IF ( ReKi == SiKi ) THEN ! Single precision
GetVersion = TRIM(GetVersion)//' single'
ELSEIF ( ReKi == R8Ki ) THEN ! Double precision
GetVersion = TRIM(GetVersion)// ' double'
ELSE ! Unknown precision
GetVersion = TRIM(GetVersion)//' unknown'
ENDIF
! GetVersion = TRIM(GetVersion)//' precision with '//OS_Desc
GetVersion = TRIM(GetVersion)//' precision'
! add git info
git_commit = QueryGitVersion()
GetVersion = TRIM(GetVersion)//' at commit '//git_commit
RETURN
END FUNCTION GetVersion
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine is called at the start (or restart) of a FAST program (or FAST.Farm). It initializes the NWTC subroutine library,
!! displays the copyright notice, and displays some version information (including addressing scheme and precision).
SUBROUTINE FAST_ProgStart(ThisProgVer)
TYPE(ProgDesc), INTENT(IN) :: ThisProgVer !< program name/date/version description
! ... Initialize NWTC Library (open console, set pi constants) ...
! sets the pi constants, open console for output, etc...
CALL NWTC_Init( ProgNameIN=ThisProgVer%Name, EchoLibVer=.FALSE. )
! Display the copyright notice
CALL DispCopyrightLicense( ThisProgVer%Name )
CALL DispCompileRuntimeInfo
END SUBROUTINE FAST_ProgStart
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine gets the name of the FAST input file from the command line. It also returns a logical indicating if this there
!! was a "DWM" argument after the file name.
SUBROUTINE GetInputFileName(InputFile,UseDWM,ErrStat,ErrMsg)
CHARACTER(*), INTENT(OUT) :: InputFile !< A CHARACTER string containing the name of the primary FAST input file (if not present, we'll get it from the command line)
LOGICAL, INTENT(OUT) :: UseDWM !< whether the last argument from the command line is "DWM"
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message
INTEGER(IntKi) :: ErrStat2 ! local error stat
CHARACTER(1024) :: LastArg ! A second command-line argument that will allow DWM module to be used in AeroDyn
ErrStat = ErrID_None
ErrMsg = ''
UseDWM = .FALSE. ! by default, we're not going to use the DWM module
InputFile = "" ! initialize to empty string to make sure it's input from the command line
CALL CheckArgs( InputFile, ErrStat2, LastArg ) ! if ErrStat2 /= ErrID_None, we'll ignore and deal with the problem when we try to read the input file
IF (LEN_TRIM(InputFile) == 0) THEN ! no input file was specified
ErrStat = ErrID_Fatal
ErrMsg = 'The required input file was not specified on the command line.'
RETURN
END IF
IF (LEN_TRIM(LastArg) > 0) THEN ! see if DWM was specified as the second option
CALL Conv2UC( LastArg )
IF ( TRIM(LastArg) == "DWM" ) THEN
UseDWM = .TRUE.
END IF
END IF
END SUBROUTINE GetInputFileName
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine checks for command-line arguments, gets the root name of the input files
!! (including full path name), and creates the names of the output files.
SUBROUTINE FAST_Init( p, m_FAST, y_FAST, t_initial, InputFile, ErrStat, ErrMsg, TMax, TurbID, OverrideAbortLev, RootName )
IMPLICIT NONE
! Passed variables
TYPE(FAST_ParameterType), INTENT(INOUT) :: p !< The parameter data for the FAST (glue-code) simulation
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< The output data for the FAST (glue-code) simulation
REAL(DbKi), INTENT(IN) :: t_initial !< the beginning time of the simulation
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message
CHARACTER(*), INTENT(IN) :: InputFile !< A CHARACTER string containing the name of the primary FAST input file (if not present, we'll get it from the command line)
REAL(DbKi), INTENT(IN), OPTIONAL :: TMax !< the length of the simulation (from Simulink or FAST.Farm)
INTEGER(IntKi), INTENT(IN), OPTIONAL :: TurbID !< an ID for naming the tubine output file
LOGICAL, INTENT(IN), OPTIONAL :: OverrideAbortLev !< whether or not we should override the abort error level (e.g., FAST.Farm)
CHARACTER(*), INTENT(IN), OPTIONAL :: RootName !< A CHARACTER string containing the root name of FAST output files, overriding normal naming convention
! Local variables
INTEGER :: i ! loop counter
!CHARACTER(1024) :: DirName ! A CHARACTER string containing the path of the current working directory
LOGICAL :: OverrideAbortErrLev
CHARACTER(*), PARAMETER :: RoutineName = "FAST_Init"
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
! Initialize some variables
ErrStat = ErrID_None
ErrMsg = ''
IF (PRESENT(OverrideAbortLev)) THEN
OverrideAbortErrLev = OverrideAbortLev
ELSE
OverrideAbortErrLev = .true.
END IF
!...............................................................................................................................
! Set the root name of the output files based on the input file name
!...............................................................................................................................
if (present(RootName)) then
p%OutFileRoot = RootName
else
! Determine the root name of the primary file (will be used for output files)
CALL GetRoot( InputFile, p%OutFileRoot )
IF ( Cmpl4SFun ) p%OutFileRoot = TRIM( p%OutFileRoot )//'.SFunc'
IF ( PRESENT(TurbID) ) THEN
IF ( TurbID > 0 ) THEN
p%OutFileRoot = TRIM( p%OutFileRoot )//'.T'//TRIM(Num2LStr(TurbID))
END IF
END IF
end if
p%VTK_OutFileRoot = p%OutFileRoot !initialize this here in case of error before it is set later
!...............................................................................................................................
! Initialize the module name/date/version info:
!...............................................................................................................................
y_FAST%Module_Ver( Module_Glue ) = FAST_Ver
DO i=2,NumModules
y_FAST%Module_Ver(i)%Date = 'unknown date'
y_FAST%Module_Ver(i)%Ver = 'unknown version'
END DO
y_FAST%Module_Ver( Module_IfW )%Name = 'InflowWind'
y_FAST%Module_Ver( Module_OpFM )%Name = 'OpenFOAM integration'
y_FAST%Module_Ver( Module_ED )%Name = 'ElastoDyn'
y_FAST%Module_Ver( Module_BD )%Name = 'BeamDyn'
y_FAST%Module_Ver( Module_AD14 )%Name = 'AeroDyn14'
y_FAST%Module_Ver( Module_AD )%Name = 'AeroDyn'
y_FAST%Module_Ver( Module_SrvD )%Name = 'ServoDyn'
y_FAST%Module_Ver( Module_HD )%Name = 'HydroDyn'
y_FAST%Module_Ver( Module_SD )%Name = 'SubDyn'
y_FAST%Module_Ver( Module_ExtPtfm)%Name = 'ExtPtfm_MCKF'
y_FAST%Module_Ver( Module_MAP )%Name = 'MAP'
y_FAST%Module_Ver( Module_FEAM )%Name = 'FEAMooring'
y_FAST%Module_Ver( Module_MD )%Name = 'MoorDyn'
y_FAST%Module_Ver( Module_Orca )%Name = 'OrcaFlexInterface'
y_FAST%Module_Ver( Module_IceF )%Name = 'IceFloe'
y_FAST%Module_Ver( Module_IceD )%Name = 'IceDyn'
y_FAST%Module_Abrev( Module_Glue ) = 'FAST'
y_FAST%Module_Abrev( Module_IfW ) = 'IfW'
y_FAST%Module_Abrev( Module_OpFM ) = 'OpFM'
y_FAST%Module_Abrev( Module_ED ) = 'ED'
y_FAST%Module_Abrev( Module_BD ) = 'BD'
y_FAST%Module_Abrev( Module_AD14 ) = 'AD'
y_FAST%Module_Abrev( Module_AD ) = 'AD'
y_FAST%Module_Abrev( Module_SrvD ) = 'SrvD'
y_FAST%Module_Abrev( Module_HD ) = 'HD'
y_FAST%Module_Abrev( Module_SD ) = 'SD'
y_FAST%Module_Abrev( Module_ExtPtfm) = 'ExtPtfm'
y_FAST%Module_Abrev( Module_MAP ) = 'MAP'
y_FAST%Module_Abrev( Module_FEAM ) = 'FEAM'
y_FAST%Module_Abrev( Module_MD ) = 'MD'
y_FAST%Module_Abrev( Module_Orca ) = 'Orca'
y_FAST%Module_Abrev( Module_IceF ) = 'IceF'
y_FAST%Module_Abrev( Module_IceD ) = 'IceD'
p%n_substeps = 1 ! number of substeps for between modules and global/FAST time
p%BD_OutputSibling = .false.
!...............................................................................................................................
! Read the primary file for the glue code:
!...............................................................................................................................
CALL FAST_ReadPrimaryFile( InputFile, p, m_FAST, OverrideAbortErrLev, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! make sure some linearization variables are consistant
if (.not. p%Linearize) p%CalcSteady = .false.
if (.not. p%CalcSteady) p%TrimCase = TrimCase_none
m_FAST%Lin%FoundSteady = .false.
p%LinInterpOrder = p%InterpOrder ! 1 ! always use linear (or constant) interpolation on rotor?
! overwrite TMax if necessary)
IF (PRESENT(TMax)) THEN
p%TMax = TMax
!p%TMax = MAX( TMax, p%TMax )
END IF
IF ( ErrStat >= AbortErrLev ) RETURN
p%KMax = 1 ! after more checking, we may put this in the input file...
!IF (p%CompIce == Module_IceF) p%KMax = 2
p%SizeJac_Opt1 = 0 ! initialize this vector to zero; after we figure out what size the ED/SD/HD/BD meshes are, we'll fill this
p%numIceLegs = 0 ! initialize number of support-structure legs in contact with ice (IceDyn will set this later)
p%nBeams = 0 ! initialize number of BeamDyn instances (will be set later)
! determine what kind of turbine we're modeling:
IF ( p%CompHydro == Module_HD ) THEN
IF ( p%CompSub == Module_SD ) THEN
p%TurbineType = Type_Offshore_Fixed
ELSE
p%TurbineType = Type_Offshore_Floating
END IF
ELSEIF ( p%CompMooring == Module_Orca ) THEN
p%TurbineType = Type_Offshore_Floating
ELSEIF ( p%CompSub == Module_ExtPtfm ) THEN
p%TurbineType = Type_Offshore_Fixed
ELSE
p%TurbineType = Type_LandBased
END IF
p%n_TMax_m1 = CEILING( ( (p%TMax - t_initial) / p%DT ) ) - 1 ! We're going to go from step 0 to n_TMax (thus the -1 here)
if (p%TMax < 1.0_DbKi) then ! log10(0) gives floating point divide-by-zero error
p%TChanLen = MinChanLen
else
p%TChanLen = max( MinChanLen, int(log10(p%TMax))+7 )
end if
p%OutFmt_t = 'F'//trim(num2lstr( p%TChanLen ))//'.4' ! 'F10.4'
!...............................................................................................................................
! Do some error checking on the inputs (validation):
!...............................................................................................................................
call ValidateInputData(p, m_FAST, ErrStat2, ErrMsg2)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF ( ErrStat >= AbortErrLev ) RETURN
RETURN
END SUBROUTINE FAST_Init
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine validates FAST data.
SUBROUTINE ValidateInputData(p, m_FAST, ErrStat, ErrMsg)
TYPE(FAST_ParameterType), INTENT(INOUT) :: p !< The parameter data for the FAST (glue-code) simulation
TYPE(FAST_MiscVarType), INTENT(IN ) :: m_FAST !< The misc data for the FAST (glue-code) simulation
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message
REAL(DbKi) :: TmpTime ! A temporary variable for error checking
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName='ValidateInputData'
ErrStat = ErrID_None
ErrMsg = ""
IF ( p%TMax < 0.0_DbKi ) THEN
CALL SetErrStat( ErrID_Fatal, 'TMax must not be a negative number.', ErrStat, ErrMsg, RoutineName )
ELSE IF ( p%TMax < p%TStart ) THEN
CALL SetErrStat( ErrID_Fatal, 'TMax must not be less than TStart.', ErrStat, ErrMsg, RoutineName )
END IF
IF ( p%n_ChkptTime < p%n_TMax_m1 ) THEN
if (.NOT. p%WrBinOutFile) CALL SetErrStat( ErrID_Severe, 'It is highly recommended that time-marching output files be generated in binary format when generating checkpoint files.', ErrStat, ErrMsg, RoutineName )
if (p%CompMooring==MODULE_Orca) CALL SetErrStat( ErrID_Fatal, 'Restart capability for OrcaFlexInterface is not supported. Set ChkptTime larger than TMax.', ErrStat, ErrMsg, RoutineName )
! also check for other features that aren't supported with restart (like ServoDyn's user-defined control routines)
END IF
IF ( p%DT <= 0.0_DbKi ) THEN
CALL SetErrStat( ErrID_Fatal, 'DT must be greater than 0.', ErrStat, ErrMsg, RoutineName )
ELSE ! Test DT and TMax to ensure numerical stability -- HINT: see the use of OnePlusEps
TmpTime = p%TMax*EPSILON(p%DT)
IF ( p%DT <= TmpTime ) THEN
CALL SetErrStat( ErrID_Fatal, 'DT must be greater than '//TRIM ( Num2LStr( TmpTime ) )//' seconds.', ErrStat, ErrMsg, RoutineName )
END IF
END IF
! Check that InputFileData%OutFmt is a valid format specifier and will fit over the column headings
CALL ChkRealFmtStr( p%OutFmt, 'OutFmt', p%FmtWidth, ErrStat2, ErrMsg2 )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF ( p%WrTxtOutFile .and. p%FmtWidth < MinChanLen ) CALL SetErrStat( ErrID_Warn, 'OutFmt produces a column width of '// &
TRIM(Num2LStr(p%FmtWidth))//'), which may be too small.', ErrStat, ErrMsg, RoutineName )
IF ( p%WrTxtOutFile .AND. p%TChanLen > ChanLen ) THEN ! ( p%TMax > 9999.999_DbKi )
CALL SetErrStat( ErrID_Warn, 'TMax is too large for a '//trim(num2lstr(ChanLen))//'-character time column in text tabular (time-marching) output files.'// &
' Postprocessors with this limitation may not work.', ErrStat, ErrMsg, RoutineName )
END IF
IF ( p%TStart < 0.0_DbKi ) CALL SetErrStat( ErrID_Fatal, 'TStart must not be less than 0 seconds.', ErrStat, ErrMsg, RoutineName )
! IF ( p%SttsTime <= 0.0_DbKi ) CALL SetErrStat( ErrID_Fatal, 'SttsTime must be greater than 0 seconds.', ErrStat, ErrMsg, RoutineName )
IF ( p%n_SttsTime < 1_IntKi ) CALL SetErrStat( ErrID_Fatal, 'SttsTime must be greater than 0 seconds.', ErrStat, ErrMsg, RoutineName )
IF ( p%n_ChkptTime < 1_IntKi ) CALL SetErrStat( ErrID_Fatal, 'ChkptTime must be greater than 0 seconds.', ErrStat, ErrMsg, RoutineName )
IF ( p%KMax < 1_IntKi ) CALL SetErrStat( ErrID_Fatal, 'KMax must be greater than 0.', ErrStat, ErrMsg, RoutineName )
IF (p%CompElast == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompElast must be 1 (ElastoDyn) or 2 (BeamDyn).', ErrStat, ErrMsg, RoutineName )
IF (p%CompAero == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompAero must be 0 (None), 1 (AeroDyn14), or 2 (AeroDyn).', ErrStat, ErrMsg, RoutineName )
IF (p%CompServo == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompServo must be 0 (None) or 1 (ServoDyn).', ErrStat, ErrMsg, RoutineName )
IF (p%CompHydro == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompHydro must be 0 (None) or 1 (HydroDyn).', ErrStat, ErrMsg, RoutineName )
IF (p%CompSub == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompSub must be 0 (None), 1 (SubDyn), or 2 (ExtPtfm_MCKF).', ErrStat, ErrMsg, RoutineName )
IF (p%CompMooring == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompMooring must be 0 (None), 1 (MAP), 2 (FEAMooring), 3 (MoorDyn), or 4 (OrcaFlex).', ErrStat, ErrMsg, RoutineName )
IF (p%CompIce == Module_Unknown) CALL SetErrStat( ErrID_Fatal, 'CompIce must be 0 (None) or 1 (IceFloe).', ErrStat, ErrMsg, RoutineName )
IF (p%CompHydro /= Module_HD) THEN
IF (p%CompMooring == Module_MAP) THEN
CALL SetErrStat( ErrID_Fatal, 'HydroDyn must be used when MAP is used. Set CompHydro > 0 or CompMooring = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
ELSEIF (p%CompMooring == Module_FEAM) THEN
CALL SetErrStat( ErrID_Fatal, 'HydroDyn must be used when FEAMooring is used. Set CompHydro > 0 or CompMooring = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
ELSEIF (p%CompMooring == Module_MD) THEN
CALL SetErrStat( ErrID_Fatal, 'HydroDyn must be used when MoorDyn is used. Set CompHydro > 0 or CompMooring = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
END IF
ELSE
IF (p%CompMooring == Module_Orca) CALL SetErrStat( ErrID_Fatal, 'HydroDyn cannot be used if OrcaFlex is used. Set CompHydro = 0 or CompMooring < 4 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
IF (p%CompSub == Module_ExtPtfm) CALL SetErrStat( ErrID_Fatal, 'HydroDyn cannot be used if ExtPtfm_MCKF is used. Set CompHydro = 0 or CompSub < 2 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
END IF
IF (p%CompIce == Module_IceF) THEN
IF (p%CompSub /= Module_SD) CALL SetErrStat( ErrID_Fatal, 'SubDyn must be used when IceFloe is used. Set CompSub > 0 or CompIce = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
IF (p%CompHydro /= Module_HD) CALL SetErrStat( ErrID_Fatal, 'HydroDyn must be used when IceFloe is used. Set CompHydro > 0 or CompIce = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
ELSEIF (p%CompIce == Module_IceD) THEN
IF (p%CompSub /= Module_SD) CALL SetErrStat( ErrID_Fatal, 'SubDyn must be used when IceDyn is used. Set CompSub > 0 or CompIce = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
IF (p%CompHydro /= Module_HD) CALL SetErrStat( ErrID_Fatal, 'HydroDyn must be used when IceDyn is used. Set CompHydro > 0 or CompIce = 0 in the FAST input file.', ErrStat, ErrMsg, RoutineName )
END IF
IF (p%CompElast == Module_BD .and. p%CompAero == Module_AD14 ) CALL SetErrStat( ErrID_Fatal, 'AeroDyn14 cannot be used when BeamDyn is used. Change CompAero or CompElast in the FAST input file.', ErrStat, ErrMsg, RoutineName )
! IF ( p%InterpOrder < 0 .OR. p%InterpOrder > 2 ) THEN
IF ( p%InterpOrder < 1 .OR. p%InterpOrder > 2 ) THEN
CALL SetErrStat( ErrID_Fatal, 'InterpOrder must be 1 or 2.', ErrStat, ErrMsg, RoutineName ) ! 5/13/14 bjj: MAS and JMJ compromise for certain integrators is that InterpOrder cannot be 0
p%InterpOrder = 1 ! Avoid problems in error handling by setting this to 0
END IF
IF ( p%NumCrctn < 0_IntKi ) THEN
CALL SetErrStat( ErrID_Fatal, 'NumCrctn must be 0 or greater.', ErrStat, ErrMsg, RoutineName )
END IF
if ( p%WrVTK == VTK_Unknown ) then
call SetErrStat(ErrID_Fatal, 'WrVTK must be 0 (none), 1 (initialization only), 2 (animation), or 3 (mode shapes).', ErrStat, ErrMsg, RoutineName)
else
if ( p%VTK_type == VTK_Unknown ) then
call SetErrStat(ErrID_Fatal, 'VTK_type must be 1 (surfaces), 2 (basic meshes:lines/points), or 3 (all meshes).', ErrStat, ErrMsg, RoutineName)
! note I'm not going to write that 4 (old) is an option
end if
if (p%WrVTK == VTK_ModeShapes .and. .not. p%Linearize) then
call SetErrStat(ErrID_Fatal, 'WrVTK cannot be 3 (mode shapes) when Linearize is false. (Mode shapes require linearization analysis.)', ErrStat, ErrMsg, RoutineName)
end if
end if
if (p%Linearize) then
if (p%CalcSteady) then
if (p%NLinTimes < 1) call SetErrStat(ErrID_Fatal,'NLinTimes must be at least 1 for linearization analysis.',ErrStat, ErrMsg, RoutineName)
if (p%TrimCase /= TrimCase_yaw .and. p%TrimCase /= TrimCase_torque .and. p%TrimCase /= TrimCase_pitch) then
call SetErrStat(ErrID_Fatal,'TrimCase must be either 1, 2, or 3.',ErrStat, ErrMsg, RoutineName)
end if
if (p%TrimTol <= epsilon(p%TrimTol)) call SetErrStat(ErrID_Fatal,'TrimTol must be larger than '//trim(num2lstr(epsilon(p%TrimTol)))//'.',ErrStat, ErrMsg, RoutineName)
if (p%Twr_Kdmp < 0.0_ReKi) call SetErrStat(ErrID_Fatal,'Twr_Kdmp must not be negative.',ErrStat, ErrMsg, RoutineName)
if (p%Bld_Kdmp < 0.0_ReKi) call SetErrStat(ErrID_Fatal,'Bld_Kdmp must not be negative.',ErrStat, ErrMsg, RoutineName)
else
if (.not. allocated(m_FAST%Lin%LinTimes)) then
call SetErrStat(ErrID_Fatal, 'NLinTimes must be at least 1 for linearization analysis.',ErrStat, ErrMsg, RoutineName)
else
do i=1,p%NLinTimes
if (m_FAST%Lin%LinTimes(i) < 0) call SetErrStat(ErrID_Fatal,'LinTimes must be positive values.',ErrStat, ErrMsg, RoutineName)
end do
do i=2,p%NLinTimes
if (m_FAST%Lin%LinTimes(i) <= m_FAST%Lin%LinTimes(i-1)) call SetErrStat(ErrID_Fatal,'LinTimes must be unique values entered in increasing order.',ErrStat, ErrMsg, RoutineName)
end do
if (m_FAST%Lin%LinTimes(p%NLinTimes) > p%TMax) call SetErrStat(ErrID_Info, 'Tmax is less than the last linearization time. Linearization analysis will not be performed after TMax.',ErrStat, ErrMsg, RoutineName)
end if
end if
if (p%LinInputs < LIN_NONE .or. p%LinInputs > LIN_ALL) call SetErrStat(ErrID_Fatal,'LinInputs must be 0, 1, or 2.',ErrStat, ErrMsg, RoutineName)
if (p%LinOutputs < LIN_NONE .or. p%LinOutputs > LIN_ALL) call SetErrStat(ErrID_Fatal,'LinOutputs must be 0, 1, or 2.',ErrStat, ErrMsg, RoutineName)
if (p%LinOutJac) then
if ( p%LinInputs /= LIN_ALL .or. p%LinOutputs /= LIN_ALL) then
call SetErrStat(ErrID_Info,'LinOutJac can be used only when LinInputs=LinOutputs=2.',ErrStat, ErrMsg, RoutineName)
p%LinOutJac = .false.
end if
end if
! now, make sure we haven't asked for any modules that we can't yet linearize:
if (p%CompInflow == MODULE_OpFM) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for the OpenFOAM coupling.',ErrStat, ErrMsg, RoutineName)
if (p%CompAero == MODULE_AD14) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for the AeroDyn v14 module.',ErrStat, ErrMsg, RoutineName)
!if (p%CompSub == MODULE_SD) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for the SubDyn module.',ErrStat, ErrMsg, RoutineName)
if (p%CompSub /= MODULE_None .and. p%CompSub /= MODULE_SD ) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for the ExtPtfm_MCKF substructure module.',ErrStat, ErrMsg, RoutineName)
if (p%CompMooring /= MODULE_None .and. p%CompMooring /= MODULE_MAP) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for the FEAMooring or MoorDyn mooring modules.',ErrStat, ErrMsg, RoutineName)
if (p%CompIce /= MODULE_None) call SetErrStat(ErrID_Fatal,'Linearization is not implemented for any of the ice loading modules.',ErrStat, ErrMsg, RoutineName)
end if
if ( p%TurbineType /= Type_LandBased .and. .not. EqualRealNos(p%TurbinePos(3), 0.0_SiKi) ) then
call SetErrStat(ErrID_Fatal, 'Height of turbine location, TurbinePos(3), must be 0 for offshore turbines.', ErrStat, ErrMsg, RoutineName)
end if
!...............................................................................................................................
! temporary check on p_FAST%DT_out
IF ( .NOT. EqualRealNos( p%DT_out, p%DT ) ) THEN
IF ( p%DT_out < p%DT ) THEN
CALL SetErrStat( ErrID_Fatal, 'DT_out must be at least DT ('//TRIM(Num2LStr(p%DT))//' s).', ErrStat, ErrMsg, RoutineName )
ELSEIF ( .NOT. EqualRealNos( p%DT_out, p%DT * p%n_DT_Out ) ) THEN
CALL SetErrStat( ErrID_Fatal, 'DT_out must be an integer multiple of DT.', ErrStat, ErrMsg, RoutineName )
END IF
END IF
END SUBROUTINE ValidateInputData
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine initializes the output for the glue code, including writing the header for the primary output file.
SUBROUTINE FAST_InitOutput( p_FAST, y_FAST, Init, ErrStat, ErrMsg )
IMPLICIT NONE
! Passed variables
TYPE(FAST_ParameterType), INTENT(IN) :: p_FAST !< Glue-code simulation parameters
TYPE(FAST_OutputFileType), INTENT(INOUT) :: y_FAST !< Glue-code simulation outputs
TYPE(FAST_InitData), INTENT(IN) :: Init !< Initialization data for all modules
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message corresponding to ErrStat
! Local variables.
INTEGER(IntKi) :: I, J ! Generic index for DO loops.
INTEGER(IntKi) :: indxNext ! The index of the next value to be written to an array
INTEGER(IntKi) :: NumOuts ! number of channels to be written to the output file(s)
!......................................................
! Set the description lines to be printed in the output file
!......................................................
y_FAST%FileDescLines(1) = 'Predictions were generated on '//CurDate()//' at '//CurTime()//' using '//TRIM(GetVersion(FAST_Ver))
y_FAST%FileDescLines(2) = 'linked with ' //' '//TRIM(GetNVD(NWTC_Ver )) ! we'll get the rest of the linked modules in the section below
y_FAST%FileDescLines(3) = 'Description from the FAST input file: '//TRIM(p_FAST%FTitle)
!......................................................
! We'll fill out the rest of FileDescLines(2),
! and save the module version info for later use, too:
!......................................................
y_FAST%Module_Ver( Module_ED ) = Init%OutData_ED%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_ED ) ))
IF ( p_FAST%CompElast == Module_BD ) THEN
y_FAST%Module_Ver( Module_BD ) = Init%OutData_BD(1)%Ver ! call copy routine for this type if it every uses dynamic memory
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_BD )))
END IF
IF ( p_FAST%CompInflow == Module_IfW ) THEN
y_FAST%Module_Ver( Module_IfW ) = Init%OutData_IfW%Ver ! call copy routine for this type if it every uses dynamic memory
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_IfW )))
ELSEIF ( p_FAST%CompInflow == Module_OpFM ) THEN
y_FAST%Module_Ver( Module_OpFM ) = Init%OutData_OpFM%Ver ! call copy routine for this type if it every uses dynamic memory
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_OpFM )))
END IF
IF ( p_FAST%CompAero == Module_AD14 ) THEN
y_FAST%Module_Ver( Module_AD14 ) = Init%OutData_AD14%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_AD14 ) ))
ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
y_FAST%Module_Ver( Module_AD ) = Init%OutData_AD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_AD ) ))
END IF
IF ( p_FAST%CompServo == Module_SrvD ) THEN
y_FAST%Module_Ver( Module_SrvD ) = Init%OutData_SrvD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_SrvD )))
END IF
IF ( p_FAST%CompHydro == Module_HD ) THEN
y_FAST%Module_Ver( Module_HD ) = Init%OutData_HD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_HD )))
END IF
IF ( p_FAST%CompSub == Module_SD ) THEN
y_FAST%Module_Ver( Module_SD ) = Init%OutData_SD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_SD )))
ELSE IF ( p_FAST%CompSub == Module_ExtPtfm ) THEN
y_FAST%Module_Ver( Module_ExtPtfm ) = Init%OutData_ExtPtfm%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_ExtPtfm )))
END IF
IF ( p_FAST%CompMooring == Module_MAP ) THEN
y_FAST%Module_Ver( Module_MAP ) = Init%OutData_MAP%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_MAP )))
ELSEIF ( p_FAST%CompMooring == Module_MD ) THEN
y_FAST%Module_Ver( Module_MD ) = Init%OutData_MD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_MD )))
ELSEIF ( p_FAST%CompMooring == Module_FEAM ) THEN
y_FAST%Module_Ver( Module_FEAM ) = Init%OutData_FEAM%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_FEAM )))
ELSEIF ( p_FAST%CompMooring == Module_Orca ) THEN
y_FAST%Module_Ver( Module_Orca ) = Init%OutData_Orca%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_Orca)))
END IF
IF ( p_FAST%CompIce == Module_IceF ) THEN
y_FAST%Module_Ver( Module_IceF ) = Init%OutData_IceF%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_IceF )))
ELSEIF ( p_FAST%CompIce == Module_IceD ) THEN
y_FAST%Module_Ver( Module_IceD ) = Init%OutData_IceD%Ver
y_FAST%FileDescLines(2) = TRIM(y_FAST%FileDescLines(2) ) //'; '//TRIM(GetNVD(y_FAST%Module_Ver( Module_IceD )))
END IF
!......................................................
! Set the number of output columns from each module
!......................................................
y_FAST%numOuts = 0 ! Inintialize entire array
IF ( ALLOCATED( Init%OutData_IfW%WriteOutputHdr ) ) y_FAST%numOuts(Module_IfW) = SIZE(Init%OutData_IfW%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_OpFM%WriteOutputHdr ) ) y_FAST%numOuts(Module_OpFM) = SIZE(Init%OutData_OpFM%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_ED%WriteOutputHdr ) ) y_FAST%numOuts(Module_ED) = SIZE(Init%OutData_ED%WriteOutputHdr)
do i=1,p_FAST%nBeams
IF ( ALLOCATED( Init%OutData_BD(i)%WriteOutputHdr) ) y_FAST%numOuts(Module_BD) = y_FAST%numOuts(Module_BD) + SIZE(Init%OutData_BD(i)%WriteOutputHdr)
end do
!ad14 doesn't have outputs:
y_FAST%numOuts(Module_AD14) = 0
IF ( ALLOCATED( Init%OutData_AD%rotors)) then
IF ( ALLOCATED( Init%OutData_AD%rotors(1)%WriteOutputHdr)) y_FAST%numOuts(Module_AD) = SIZE(Init%OutData_AD%rotors(1)%WriteOutputHdr)
ENDIF
IF ( ALLOCATED( Init%OutData_SrvD%WriteOutputHdr ) ) y_FAST%numOuts(Module_SrvD) = SIZE(Init%OutData_SrvD%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_HD%WriteOutputHdr ) ) y_FAST%numOuts(Module_HD) = SIZE(Init%OutData_HD%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_SD%WriteOutputHdr ) ) y_FAST%numOuts(Module_SD) = SIZE(Init%OutData_SD%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_ExtPtfm%WriteOutputHdr) ) y_FAST%numOuts(Module_ExtPtfm)= SIZE(Init%OutData_ExtPtfm%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_MAP%WriteOutputHdr ) ) y_FAST%numOuts(Module_MAP) = SIZE(Init%OutData_MAP%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_FEAM%WriteOutputHdr ) ) y_FAST%numOuts(Module_FEAM) = SIZE(Init%OutData_FEAM%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_MD%WriteOutputHdr ) ) y_FAST%numOuts(Module_MD) = SIZE(Init%OutData_MD%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_Orca%WriteOutputHdr ) ) y_FAST%numOuts(Module_Orca) = SIZE(Init%OutData_Orca%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_IceF%WriteOutputHdr ) ) y_FAST%numOuts(Module_IceF) = SIZE(Init%OutData_IceF%WriteOutputHdr)
IF ( ALLOCATED( Init%OutData_IceD%WriteOutputHdr ) ) y_FAST%numOuts(Module_IceD) = SIZE(Init%OutData_IceD%WriteOutputHdr)*p_FAST%numIceLegs
!......................................................
! Initialize the output channel names and units
!......................................................
y_FAST%numOuts(Module_Glue) = 1 ! time
NumOuts = SUM( y_FAST%numOuts )
CALL AllocAry( y_FAST%ChannelNames,NumOuts, 'ChannelNames', ErrStat, ErrMsg )
IF ( ErrStat /= ErrID_None ) RETURN
CALL AllocAry( y_FAST%ChannelUnits,NumOuts, 'ChannelUnits', ErrStat, ErrMsg )
IF ( ErrStat /= ErrID_None ) RETURN
! Glue outputs:
y_FAST%ChannelNames(1) = 'Time'
y_FAST%ChannelUnits(1) = '(s)'
indxNext = y_FAST%numOuts(Module_Glue) + 1
DO i=1,y_FAST%numOuts(Module_IfW) !InflowWind
y_FAST%ChannelNames(indxNext) = Init%OutData_IfW%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_IfW%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_OpFM) !OpenFOAM
y_FAST%ChannelNames(indxNext) = Init%OutData_OpFM%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_OpFM%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_ED) !ElastoDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_ED%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_ED%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
IF ( y_FAST%numOuts(Module_BD) > 0_IntKi ) THEN !BeamDyn
do i=1,p_FAST%nBeams
if ( allocated(Init%OutData_BD(i)%WriteOutputHdr) ) then
do j=1,size(Init%OutData_BD(i)%WriteOutputHdr)
y_FAST%ChannelNames(indxNext) = 'B'//TRIM(Num2Lstr(i))//trim(Init%OutData_BD(i)%WriteOutputHdr(j))
y_FAST%ChannelUnits(indxNext) = Init%OutData_BD(i)%WriteOutputUnt(j)
indxNext = indxNext + 1
end do ! j
end if
end do
END IF
! none for AeroDyn14
DO i=1,y_FAST%numOuts(Module_AD) !AeroDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_AD%rotors(1)%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_AD%rotors(1)%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_SrvD) !ServoDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_SrvD%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_SrvD%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_HD) !HydroDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_HD%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_HD%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_SD) !SubDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_SD%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_SD%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_ExtPtfm) !ExtPtfm_MCKF
y_FAST%ChannelNames(indxNext) = Init%OutData_ExtPtfm%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_ExtPtfm%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_MAP) !MAP
y_FAST%ChannelNames(indxNext) = Init%OutData_MAP%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_MAP%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_MD) !MoorDyn
y_FAST%ChannelNames(indxNext) = Init%OutData_MD%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_MD%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_FEAM) !FEAMooring
y_FAST%ChannelNames(indxNext) = Init%OutData_FEAM%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_FEAM%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_Orca) !OrcaFlex
y_FAST%ChannelNames(indxNext) = Init%OutData_Orca%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_Orca%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
DO i=1,y_FAST%numOuts(Module_IceF) !IceFloe
y_FAST%ChannelNames(indxNext) = Init%OutData_IceF%WriteOutputHdr(i)
y_FAST%ChannelUnits(indxNext) = Init%OutData_IceF%WriteOutputUnt(i)
indxNext = indxNext + 1
END DO
IF ( y_FAST%numOuts(Module_IceD) > 0_IntKi ) THEN !IceDyn
DO I=1,p_FAST%numIceLegs
DO J=1,SIZE(Init%OutData_IceD%WriteOutputHdr)
y_FAST%ChannelNames(indxNext) =TRIM(Init%OutData_IceD%WriteOutputHdr(J))//'L'//TRIM(Num2Lstr(I)) !bjj: do we want this "Lx" at the end?
y_FAST%ChannelUnits(indxNext) = Init%OutData_IceD%WriteOutputUnt(J)
indxNext = indxNext + 1
END DO ! J
END DO ! I
END IF
!......................................................
! Open the text output file and print the headers
!......................................................
IF (p_FAST%WrTxtOutFile) THEN
y_FAST%ActualChanLen = max( MinChanLen, p_FAST%FmtWidth )
DO I=1,NumOuts
y_FAST%ActualChanLen = max( y_FAST%ActualChanLen, LEN_TRIM(y_FAST%ChannelNames(I)) )
y_FAST%ActualChanLen = max( y_FAST%ActualChanLen, LEN_TRIM(y_FAST%ChannelUnits(I)) )
ENDDO ! I
y_FAST%OutFmt_a = '"'//p_FAST%Delim//'"'//p_FAST%OutFmt ! format for array elements from individual modules
if (p_FAST%FmtWidth < y_FAST%ActualChanLen) then
y_FAST%OutFmt_a = trim(y_FAST%OutFmt_a)//','//trim(num2lstr(y_FAST%ActualChanLen - p_FAST%FmtWidth))//'x'
end if
CALL GetNewUnit( y_FAST%UnOu, ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
CALL OpenFOutFile ( y_FAST%UnOu, TRIM(p_FAST%OutFileRoot)//'.out', ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
! Add some file information:
WRITE (y_FAST%UnOu,'(/,A)') TRIM( y_FAST%FileDescLines(1) )
WRITE (y_FAST%UnOu,'(1X,A)') TRIM( y_FAST%FileDescLines(2) )
WRITE (y_FAST%UnOu,'()' ) !print a blank line
WRITE (y_FAST%UnOu,'(A)' ) TRIM( y_FAST%FileDescLines(3) )
WRITE (y_FAST%UnOu,'()' ) !print a blank line
!......................................................
! Write the names of the output parameters on one line:
!......................................................
if (p_FAST%Delim /= " ") then ! trim trailing spaces if not space delimited:
CALL WrFileNR ( y_FAST%UnOu, trim(y_FAST%ChannelNames(1)) ) ! first one is time, with a special format
DO I=2,NumOuts
CALL WrFileNR ( y_FAST%UnOu, p_FAST%Delim//trim(y_FAST%ChannelNames(I)) )
ENDDO ! I
else
CALL WrFileNR ( y_FAST%UnOu, y_FAST%ChannelNames(1)(1:p_FAST%TChanLen) ) ! first one is time, with a special format
DO I=2,NumOuts
CALL WrFileNR ( y_FAST%UnOu, p_FAST%Delim//y_FAST%ChannelNames(I)(1:y_FAST%ActualChanLen) )
ENDDO ! I
end if
WRITE (y_FAST%UnOu,'()')
!......................................................
! Write the units of the output parameters on one line:
!......................................................
if (p_FAST%Delim /= " ") then
CALL WrFileNR ( y_FAST%UnOu, trim(y_FAST%ChannelUnits(1)) )
DO I=2,NumOuts
CALL WrFileNR ( y_FAST%UnOu, p_FAST%Delim//trim(y_FAST%ChannelUnits(I)) )
ENDDO ! I
else
CALL WrFileNR ( y_FAST%UnOu, y_FAST%ChannelUnits(1)(1:p_FAST%TChanLen) )
DO I=2,NumOuts
CALL WrFileNR ( y_FAST%UnOu, p_FAST%Delim//y_FAST%ChannelUnits(I)(1:y_FAST%ActualChanLen) )
ENDDO ! I
end if
WRITE (y_FAST%UnOu,'()')
END IF
!......................................................
! Allocate data for binary output file
!......................................................
IF (p_FAST%WrBinOutFile) THEN
! calculate the size of the array of outputs we need to store
y_FAST%NOutSteps = CEILING ( (p_FAST%TMax - p_FAST%TStart) / p_FAST%DT_OUT ) + 1
CALL AllocAry( y_FAST%AllOutData, NumOuts-1, y_FAST%NOutSteps, 'AllOutData', ErrStat, ErrMsg ) ! this does not include the time channel
IF ( ErrStat >= AbortErrLev ) RETURN
y_FAST%AllOutData = 0.0_ReKi
IF ( p_FAST%WrBinMod == FileFmtID_WithTime ) THEN ! we store the entire time array
CALL AllocAry( y_FAST%TimeData, y_FAST%NOutSteps, 'TimeData', ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
ELSE
CALL AllocAry( y_FAST%TimeData, 2_IntKi, 'TimeData', ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
y_FAST%TimeData(1) = 0.0_DbKi ! This is the first output time, which we will set later
y_FAST%TimeData(2) = p_FAST%DT_out ! This is the (constant) time between subsequent writes to the output file
END IF
y_FAST%n_Out = 0 !number of steps actually written to the file
END IF
y_FAST%VTK_count = 0 ! first VTK file has 0 as output
RETURN
END SUBROUTINE FAST_InitOutput
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine reads in the primary FAST input file, does some validation, and places the values it reads in the
!! parameter structure (p). It prints to an echo file if requested.
SUBROUTINE FAST_ReadPrimaryFile( InputFile, p, m_FAST, OverrideAbortErrLev, ErrStat, ErrMsg )
IMPLICIT NONE
! Passed variables
TYPE(FAST_ParameterType), INTENT(INOUT) :: p !< The parameter data for the FAST (glue-code) simulation
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
CHARACTER(*), INTENT(IN) :: InputFile !< Name of the file containing the primary input data
LOGICAL, INTENT(IN) :: OverrideAbortErrLev !< Determines if we should override AbortErrLev
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message
! Local variables:
REAL(DbKi) :: TmpRate ! temporary variable to read VTK_fps before converting to #steps based on DT
REAL(DbKi) :: TmpTime ! temporary variable to read SttsTime and ChkptTime before converting to #steps based on DT
INTEGER(IntKi) :: I ! loop counter
INTEGER(IntKi) :: UnIn ! Unit number for reading file
INTEGER(IntKi) :: UnEc ! I/O unit for echo file. If > 0, file is open for writing.
INTEGER(IntKi) :: IOS ! Temporary Error status
INTEGER(IntKi) :: ErrStat2 ! Temporary Error status
INTEGER(IntKi) :: OutFileFmt ! An integer that indicates what kind of tabular output should be generated (1=text, 2=binary, 3=both)
LOGICAL :: Echo ! Determines if an echo file should be written
LOGICAL :: TabDelim ! Determines if text output should be delimited by tabs (true) or space (false)
CHARACTER(ErrMsgLen) :: ErrMsg2 ! Temporary Error message
CHARACTER(1024) :: PriPath ! Path name of the primary file
CHARACTER(10) :: AbortLevel ! String that indicates which error level should be used to abort the program: WARNING, SEVERE, or FATAL
CHARACTER(30) :: Line ! string for default entry in input file
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_ReadPrimaryFile'
! Initialize some variables:
UnEc = -1
Echo = .FALSE. ! Don't echo until we've read the "Echo" flag
CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located.
! Get an available unit number for the file.
CALL GetNewUnit( UnIn, ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
! Open the Primary input file.
CALL OpenFInpFile ( UnIn, InputFile, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! Read the lines up/including to the "Echo" simulation control variable
! If echo is FALSE, don't write these lines to the echo file.
! If Echo is TRUE, rewind and write on the second try.
I = 1 !set the number of times we've read the file
DO
!-------------------------- HEADER ---------------------------------------------
CALL ReadCom( UnIn, InputFile, 'File header: Module Version (line 1)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
CALL ReadStr( UnIn, InputFile, p%FTitle, 'FTitle', 'File Header: File Description (line 2)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
!---------------------- SIMULATION CONTROL --------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Simulation Control', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! Echo - Echo input data to <RootName>.ech (flag):
CALL ReadVar( UnIn, InputFile, Echo, "Echo", "Echo input data to <RootName>.ech (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF (.NOT. Echo .OR. I > 1) EXIT !exit this loop
! Otherwise, open the echo file, then rewind the input file and echo everything we've read
I = I + 1 ! make sure we do this only once (increment counter that says how many times we've read this file)
CALL OpenEcho ( UnEc, TRIM(p%OutFileRoot)//'.ech', ErrStat2, ErrMsg2, FAST_Ver )
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( UnEc > 0 ) WRITE (UnEc,'(/,A,/)') 'Data from '//TRIM(FAST_Ver%Name)//' primary input file "'//TRIM( InputFile )//'":'
REWIND( UnIn, IOSTAT=ErrStat2 )
IF (ErrStat2 /= 0_IntKi ) THEN
CALL SetErrStat( ErrID_Fatal, 'Error rewinding file "'//TRIM(InputFile)//'".',ErrStat,ErrMsg,RoutineName)
call cleanup()
RETURN
END IF
END DO
CALL WrScr( TRIM(FAST_Ver%Name)//' input file heading:' )
CALL WrScr( ' '//TRIM( p%FTitle ) )
CALL WrScr('')
! AbortLevel - Error level when simulation should abort:
CALL ReadVar( UnIn, InputFile, AbortLevel, "AbortLevel", "Error level when simulation should abort (string)", &
ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF (OverrideAbortErrLev) THEN
! Let's set the abort level here.... knowing that everything before this aborted only on FATAL errors!
CALL Conv2UC( AbortLevel ) !convert to upper case
SELECT CASE( TRIM(AbortLevel) )
CASE ( "WARNING" )
AbortErrLev = ErrID_Warn
CASE ( "SEVERE" )
AbortErrLev = ErrID_Severe
CASE ( "FATAL" )
AbortErrLev = ErrID_Fatal
CASE DEFAULT
CALL SetErrStat( ErrID_Fatal, 'Invalid AbortLevel specified in FAST input file. '// &
'Valid entries are "WARNING", "SEVERE", or "FATAL".',ErrStat,ErrMsg,RoutineName)
call cleanup()
RETURN
END SELECT
END IF
! TMax - Total run time (s):
CALL ReadVar( UnIn, InputFile, p%TMax, "TMax", "Total run time (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! DT - Recommended module time step (s):
CALL ReadVar( UnIn, InputFile, p%DT, "DT", "Recommended module time step (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
if ( EqualRealNos(p%DT, 0.0_DbKi) ) then
! add a fatal error here because we're going to divide by DT later in this routine:
CALL SetErrStat( ErrID_Fatal, 'DT cannot be zero.', ErrStat, ErrMsg, RoutineName)
call cleanup()
return
end if
! InterpOrder - Interpolation order for inputs and outputs {0=nearest neighbor ,1=linear, 2=quadratic}
CALL ReadVar( UnIn, InputFile, p%InterpOrder, "InterpOrder", "Interpolation order "//&
"for inputs and outputs {0=nearest neighbor ,1=linear, 2=quadratic} (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! NumCrctn - Number of predictor-corrector iterations {1=explicit calculation, i.e., no corrections}
CALL ReadVar( UnIn, InputFile, p%NumCrctn, "NumCrctn", "Number of corrections"//&
"{0=explicit calculation, i.e., no corrections} (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! DT_UJac - Time between calls to get Jacobians (s)
CALL ReadVar( UnIn, InputFile, p%DT_UJac, "DT_UJac", "Time between calls to get Jacobians (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! UJacSclFact - Scaling factor used in Jacobians (-)
CALL ReadVar( UnIn, InputFile, p%UJacSclFact, "UJacSclFact", "Scaling factor used in Jacobians (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
!---------------------- FEATURE SWITCHES AND FLAGS --------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Feature Switches and Flags', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! CompElast - Compute structural dynamics (switch) {1=ElastoDyn; 2=ElastoDyn + BeamDyn for blades}:
CALL ReadVar( UnIn, InputFile, p%CompElast, "CompElast", "Compute structural dynamics (switch) {1=ElastoDyn; 2=ElastoDyn + BeamDyn for blades}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompElast == 1 ) THEN
p%CompElast = Module_ED
ELSEIF ( p%CompElast == 2 ) THEN
p%CompElast = Module_BD
ELSE
p%CompElast = Module_Unknown
END IF
! CompInflow - inflow wind velocities (switch) {0=still air; 1=InflowWind}:
CALL ReadVar( UnIn, InputFile, p%CompInflow, "CompInflow", "inflow wind velocities (switch) {0=still air; 1=InflowWind}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompInflow == 0 ) THEN
p%CompInflow = Module_NONE
ELSEIF ( p%CompInflow == 1 ) THEN
p%CompInflow = Module_IfW
ELSEIF ( p%CompInflow == 2 ) THEN
p%CompInflow = Module_OpFM
ELSE
p%CompInflow = Module_Unknown
END IF
! CompAero - Compute aerodynamic loads (switch) {0=None; 1=AeroDyn}:
CALL ReadVar( UnIn, InputFile, p%CompAero, "CompAero", "Compute aerodynamic loads (switch) {0=None; 1=AeroDyn}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompAero == 0 ) THEN
p%CompAero = Module_NONE
ELSEIF ( p%CompAero == 1 ) THEN
p%CompAero = Module_AD14
ELSEIF ( p%CompAero == 2 ) THEN
p%CompAero = Module_AD
ELSE
p%CompAero = Module_Unknown
END IF
! CompServo - Compute control and electrical-drive dynamics (switch) {0=None; 1=ServoDyn}:
CALL ReadVar( UnIn, InputFile, p%CompServo, "CompServo", "Compute control and electrical-drive dynamics (switch) {0=None; 1=ServoDyn}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompServo == 0 ) THEN
p%CompServo = Module_NONE
ELSEIF ( p%CompServo == 1 ) THEN
p%CompServo = Module_SrvD
ELSE
p%CompServo = Module_Unknown
END IF
! CompHydro - Compute hydrodynamic loads (switch) {0=None; 1=HydroDyn}:
CALL ReadVar( UnIn, InputFile, p%CompHydro, "CompHydro", "Compute hydrodynamic loads (switch) {0=None; 1=HydroDyn}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompHydro == 0 ) THEN
p%CompHydro = Module_NONE
ELSEIF ( p%CompHydro == 1 ) THEN
p%CompHydro = Module_HD
ELSE
p%CompHydro = Module_Unknown
END IF
! CompSub - Compute sub-structural dynamics (switch) {0=None; 1=SubDyn; 2=ExtPtfm_MCKF}:
CALL ReadVar( UnIn, InputFile, p%CompSub, "CompSub", "Compute sub-structural dynamics (switch) {0=None; 1=SubDyn}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompSub == 0 ) THEN
p%CompSub = Module_NONE
ELSEIF ( p%CompSub == 1 ) THEN
p%CompSub = Module_SD
ELSEIF ( p%CompSub == 2 ) THEN
p%CompSub = Module_ExtPtfm
ELSE
p%CompSub = Module_Unknown
END IF
! CompMooring - Compute mooring line dynamics (flag):
CALL ReadVar( UnIn, InputFile, p%CompMooring, "CompMooring", "Compute mooring system (switch) {0=None; 1=MAP; 2=FEAMooring; 3=MoorDyn; 4=OrcaFlex}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompMooring == 0 ) THEN
p%CompMooring = Module_NONE
ELSEIF ( p%CompMooring == 1 ) THEN
p%CompMooring = Module_MAP
ELSEIF ( p%CompMooring == 2 ) THEN
p%CompMooring = Module_FEAM
ELSEIF ( p%CompMooring == 3 ) THEN
p%CompMooring = Module_MD
ELSEIF ( p%CompMooring == 4 ) THEN
p%CompMooring = Module_Orca
ELSE
p%CompMooring = Module_Unknown
END IF
! CompIce - Compute ice loads (switch) {0=None; 1=IceFloe}:
CALL ReadVar( UnIn, InputFile, p%CompIce, "CompIce", "Compute ice loads (switch) {0=None; 1=IceFloe}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%CompIce == 0 ) THEN
p%CompIce = Module_NONE
ELSEIF ( p%CompIce == 1 ) THEN
p%CompIce = Module_IceF
ELSEIF ( p%CompIce == 2 ) THEN
p%CompIce = Module_IceD
ELSE
p%CompIce = Module_Unknown
END IF
!---------------------- INPUT FILES ---------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Input Files', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! EDFile - Name of file containing ElastoDyn input parameters (-):
CALL ReadVar( UnIn, InputFile, p%EDFile, "EDFile", "Name of file containing ElastoDyn input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%EDFile ) ) p%EDFile = TRIM(PriPath)//TRIM(p%EDFile)
DO i=1,MaxNBlades
! BDBldFile - Name of file containing BeamDyn blade input parameters (-):
CALL ReadVar( UnIn, InputFile, p%BDBldFile(i), "BDBldFile("//TRIM(num2LStr(i))//")", "Name of file containing BeamDyn blade "//trim(num2lstr(i))//"input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%BDBldFile(i) ) ) p%BDBldFile(i) = TRIM(PriPath)//TRIM(p%BDBldFile(i))
END DO
! InflowFile - Name of file containing inflow wind input parameters (-):
CALL ReadVar( UnIn, InputFile, p%InflowFile, "InflowFile", "Name of file containing inflow wind input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%InflowFile ) ) p%InflowFile = TRIM(PriPath)//TRIM(p%InflowFile)
! AeroFile - Name of file containing aerodynamic input parameters (-):
CALL ReadVar( UnIn, InputFile, p%AeroFile, "AeroFile", "Name of file containing aerodynamic input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%AeroFile ) ) p%AeroFile = TRIM(PriPath)//TRIM(p%AeroFile)
! ServoFile - Name of file containing control and electrical-drive input parameters (-):
CALL ReadVar( UnIn, InputFile, p%ServoFile, "ServoFile", "Name of file containing control and electrical-drive input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%ServoFile ) ) p%ServoFile = TRIM(PriPath)//TRIM(p%ServoFile)
! HydroFile - Name of file containing hydrodynamic input parameters (-):
CALL ReadVar( UnIn, InputFile, p%HydroFile, "HydroFile", "Name of file containing hydrodynamic input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%HydroFile ) ) p%HydroFile = TRIM(PriPath)//TRIM(p%HydroFile)
! SubFile - Name of file containing sub-structural input parameters (-):
CALL ReadVar( UnIn, InputFile, p%SubFile, "SubFile", "Name of file containing sub-structural input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%SubFile ) ) p%SubFile = TRIM(PriPath)//TRIM(p%SubFile)
! MooringFile - Name of file containing mooring system input parameters (-):
CALL ReadVar( UnIn, InputFile, p%MooringFile, "MooringFile", "Name of file containing mooring system input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%MooringFile ) ) p%MooringFile = TRIM(PriPath)//TRIM(p%MooringFile)
! IceFile - Name of file containing ice input parameters (-):
CALL ReadVar( UnIn, InputFile, p%IceFile, "IceFile", "Name of file containing ice input parameters (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( PathIsRelative( p%IceFile ) ) p%IceFile = TRIM(PriPath)//TRIM(p%IceFile)
!---------------------- OUTPUT --------------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Output', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! SumPrint - Print summary data to <RootName>.sum (flag):
CALL ReadVar( UnIn, InputFile, p%SumPrint, "SumPrint", "Print summary data to <RootName>.sum (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! SttsTime - Amount of time between screen status messages (s):
CALL ReadVar( UnIn, InputFile, TmpTime, "SttsTime", "Amount of time between screen status messages (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF (TmpTime > p%TMax) THEN
p%n_SttsTime = HUGE(p%n_SttsTime)
ELSE
p%n_SttsTime = NINT( TmpTime / p%DT )
END IF
! ChkptTime - Amount of time between creating checkpoint files for potential restart (s):
CALL ReadVar( UnIn, InputFile, TmpTime, "ChkptTime", "Amount of time between creating checkpoint files for potential restart (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF (TmpTime > p%TMax) THEN
p%n_ChkptTime = HUGE(p%n_ChkptTime)
ELSE
p%n_ChkptTime = NINT( TmpTime / p%DT )
END IF
! DT_Out - Time step for tabular output (s):
CALL ReadVar( UnIn, InputFile, Line, "DT_Out", "Time step for tabular output (s)", ErrStat2, ErrMsg2, UnEc)
!CALL ReadVar( UnIn, InputFile, p%DT_Out, "DT_Out", "Time step for tabular output (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
CALL Conv2UC( Line )
IF ( INDEX(Line, "DEFAULT" ) == 1 ) THEN
p%DT_Out = p%DT
ELSE
! If it's not "default", read this variable; otherwise use the value in p%DT
READ( Line, *, IOSTAT=IOS) p%DT_Out
CALL CheckIOS ( IOS, InputFile, 'DT_Out', NumType, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
END IF
p%n_DT_Out = NINT( p%DT_Out / p%DT )
! TStart - Time to begin tabular output (s):
CALL ReadVar( UnIn, InputFile, p%TStart, "TStart", "Time to begin tabular output (s)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
!> OutFileFmt - Format for tabular (time-marching) output file (switch) {1: text file [<RootName>.out], 2: binary file [<RootName>.outb], 4: HDF5 [<RootName>.h5], add for combinations}
!!
!! Combinations of output files are possible by adding the values corresponding to each file. The possible combination of options are therefore
!!
!! | `OutFileFmt` | Description |
!! |:------------:|:---------------------------------------------------------------------|
!! | 1 | Text file only `<RootName>.out` |
!! | 2 | Binary file only `<RootName>.outb` |
!! | 3 | Text and binary files |
!! | 4 | uncompressed binary file `<RootName>.outbu` |
!! | 5 | Text and uncompressed binary files |
!! | 6 => 4 | Binary (not written) and uncompressed binary files; same as 4 |
!! | 7 => 5 | Text, Binary (not written), and uncompressed binary files; same as 5 |
!!
! OutFileFmt - Format for tabular (time-marching) output file(s) (1: text file [<RootName>.out], 2: binary file [<RootName>.outb], 3: both) (-):
CALL ReadVar( UnIn, InputFile, OutFileFmt, "OutFileFmt", "Format for tabular (time-marching) output file(s) {0: uncompressed binary and text file, 1: text file [<RootName>.out], 2: compressed binary file [<RootName>.outb], 3: both text and compressed binary, 4: uncompressed binary <RootName>.outb]; add for combinations) (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
if (OutFileFmt == 0) OutFileFmt = 5
! convert integer to binary representation of which file formats to generate:
p%WrTxtOutFile = mod(OutFileFmt,2) == 1
OutFileFmt = OutFileFmt / 2 ! integer division
p%WrBinOutFile = mod(OutFileFmt,2) == 1
OutFileFmt = OutFileFmt / 2 ! integer division
if (mod(OutFileFmt,2) == 1) then
! This is a feature for the regression testing system. It writes binary output stored as uncompressed double floating point data instead of compressed int16 data.
! If the compressed binary version was requested, that will not be generated
if (p%WrBinOutFile) then
call SetErrStat(ErrID_Warn,'Binary compressed file will not be generated because the uncompressed version was also requested.', ErrStat, ErrMsg, RoutineName)
else
p%WrBinOutFile = .true.
end if
p%WrBinMod = FileFmtID_NoCompressWithoutTime ! A format specifier for the binary output file format (3=don't include time channel and do not pack data)
else
p%WrBinMod = FileFmtID_ChanLen_In ! A format specifier for the binary output file format (4=don't include time channel; do include channel width; do pack data)
end if
OutFileFmt = OutFileFmt / 2 ! integer division
if (OutFileFmt /= 0) then
call SetErrStat( ErrID_Fatal, "OutFileFmt must be 0, 1, 2, or 3.",ErrStat,ErrMsg,RoutineName)
call cleanup()
return
end if
! TabDelim - Use tab delimiters in text tabular output file? (flag):
CALL ReadVar( UnIn, InputFile, TabDelim, "TabDelim", "Use tab delimiters in text tabular output file? (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( TabDelim ) THEN
p%Delim = TAB
ELSE
p%Delim = ' '
END IF
! OutFmt - Format used for text tabular output (except time). Resulting field should be 10 characters. (-):
CALL ReadVar( UnIn, InputFile, p%OutFmt, "OutFmt", "Format used for text tabular output (except time). Resulting field should be 10 characters. (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
!---------------------- LINEARIZATION -----------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Linearization', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! Linearize - Linearization analysis (flag)
CALL ReadVar( UnIn, InputFile, p%Linearize, "Linearize", "Linearization analysis (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! CalcSteady - Calculate a steady-state periodic operating point before linearization? [unused if Linearize=False] (flag)
CALL ReadVar( UnIn, InputFile, p%CalcSteady, "CalcSteady", "Calculate a steady-state periodic operating point before linearization? (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! TrimCase - Controller parameter to be trimmed {1:yaw; 2:torque; 3:pitch} [used only if CalcSteady=True] (-)
CALL ReadVar( UnIn, InputFile, p%TrimCase, "TrimCase", "Controller parameter to be trimmed {1:yaw; 2:torque; 3:pitch} (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! TrimTol - Tolerance for the rotational speed convergence [used only if CalcSteady=True] (-)
CALL ReadVar( UnIn, InputFile, p%TrimTol, "TrimTol", "Tolerance for the rotational speed convergence (-)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! TrimGain - Proportional gain for the rotational speed error (>0) [used only if CalcSteady=True] (rad/(rad/s) for yaw or pitch; Nm/(rad/s) for torque)
CALL ReadVar( UnIn, InputFile, p%TrimGain, "TrimGain", "Proportional gain for the rotational speed error (>0) (rad/(rad/s) for yaw or pitch; Nm/(rad/s) for torque)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! Twr_Kdmp - Damping factor for the tower [used only if CalcSteady=True] (N/(m/s))
CALL ReadVar( UnIn, InputFile, p%Twr_Kdmp, "Twr_Kdmp", "Damping factor for the tower (N/(m/s))", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! Bld_Kdmp - Damping factor for the blades [used only if CalcSteady=True] (N/(m/s))
CALL ReadVar( UnIn, InputFile, p%Bld_Kdmp, "Bld_Kdmp", "Damping factor for the blades (N/(m/s))", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! NLinTimes - Number of times to linearize (or number of equally spaced azimuth steps in periodic linearized model) (-) [>=1]
CALL ReadVar( UnIn, InputFile, p%NLinTimes, "NLinTimes", "Number of times to linearize (-) [>=1]", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
if (.not. p%Linearize) then
p%CalcSteady = .false.
p%NLinTimes = 0
end if
! LinTimes - Times to linearize (s) [1 to NLinTimes]
if (.not. p%CalcSteady .and. p%NLinTimes >= 1 ) then
call AllocAry( m_FAST%Lin%LinTimes, p%NLinTimes, 'LinTimes', ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
CALL ReadAry( UnIn, InputFile, m_FAST%Lin%LinTimes, p%NLinTimes, "LinTimes", "Times to linearize (s) [1 to NLinTimes]", ErrStat2, ErrMsg2, UnEc)
else
CALL ReadCom( UnIn, InputFile, 'Times to linearize (s) [1 to NLinTimes] ', ErrStat2, ErrMsg2, UnEc )
end if
CALL SetErrStat( ErrStat2, ErrMsg2,ErrStat,ErrMsg,RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! LinInputs - Include inputs in linearization (switch) {0=none; 1=standard; 2=all module inputs (debug)}
CALL ReadVar( UnIn, InputFile, p%LinInputs, "LinInputs", "Include inputs in linearization (switch) {0=none; 1=standard; 2=all module inputs (debug)}", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! LinOutputs - Include outputs in linearization (switch) (0=none; 1=from OutList(s); 2=all module outputs (debug))
CALL ReadVar( UnIn, InputFile, p%LinOutputs, "LinOutputs", "Include outputs in linearization (switch) (0=none; 1=from OutList(s); 2=all module outputs (debug))", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! LinOutJac - Include full Jacabians in linearization output (for debug) (flag)
CALL ReadVar( UnIn, InputFile, p%LinOutJac, "LinOutJac", "Include full Jacabians in linearization output (for debug) (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! LinOutMod - Write module-level linearization output files in addition to output for full system? (flag)
CALL ReadVar( UnIn, InputFile, p%LinOutMod, "LinOutMod", "Write module-level linearization output files in addition to output for full system? (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
!---------------------- VISUALIZATION -----------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Visualization', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! WrVTK - VTK Visualization data output: (switch) {0=none; 1=initialization data only; 2=animation; 3=mode shapes}:
CALL ReadVar( UnIn, InputFile, p%WrVTK, "WrVTK", "Write VTK visualization files (0=none; 1=initialization data only; 2=animation; 3=mode shapes)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
IF ( p%WrVTK < 0 .OR. p%WrVTK > 3 ) THEN
p%WrVTK = VTK_Unknown
END IF
! VTK_Type - Type of VTK visualization data: (switch) {1=surfaces; 2=basic meshes (lines/points); 3=all meshes (debug)}:
CALL ReadVar( UnIn, InputFile, p%VTK_Type, "VTK_Type", "Type of VTK visualization data: (1=surfaces; 2=basic meshes (lines/points); 3=all meshes)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! immediately convert to values used inside the code:
IF ( p%VTK_Type == 0 ) THEN
p%VTK_Type = VTK_None
ELSEIF ( p%VTK_Type == 1 ) THEN
p%VTK_Type = VTK_Surf
ELSEIF ( p%VTK_Type == 2 ) THEN
p%VTK_Type = VTK_Basic
ELSEIF ( p%VTK_Type == 3 ) THEN
p%VTK_Type = VTK_All
ELSEIF ( p%VTK_Type == 4 ) THEN
p%VTK_Type = VTK_Old
ELSE
p%VTK_Type = VTK_Unknown
END IF
!! equivalent:
!IF ( p%VTK_Type < 0 .OR. p%VTK_Type > 4 ) THEN
! p%VTK_Type = VTK_Unknown
!END IF
! VTK_fields - Write mesh fields to VTK data files? (flag) {true/false}:
CALL ReadVar( UnIn, InputFile, p%VTK_fields, "VTK_fields", "Write mesh fields to VTK data files? (flag)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! VTK_fps - Frame rate for VTK output (frames per second) {will use closest integer multiple of DT}
CALL ReadVar( UnIn, InputFile, p%VTK_fps, "VTK_fps", "Frame rate for VTK output(fps)", ErrStat2, ErrMsg2, UnEc)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if ( ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
! convert frames-per-second to seconds per sample:
if ( EqualRealNos(p%VTK_fps, 0.0_DbKi) ) then
TmpTime = p%TMax + p%DT
else
TmpTime = 1.0_DbKi / p%VTK_fps
end if
! now save the number of time steps between VTK file output:
IF (p%WrVTK == VTK_ModeShapes) THEN
p%n_VTKTime = 1
ELSE IF (TmpTime > p%TMax) THEN
p%n_VTKTime = HUGE(p%n_VTKTime)
ELSE
p%n_VTKTime = NINT( TmpTime / p%DT )
! I'll warn if p%n_VTKTime*p%DT is not TmpTime
IF (p%WrVTK == VTK_Animate) THEN
TmpRate = p%n_VTKTime*p%DT
if (.not. EqualRealNos(TmpRate, TmpTime)) then
call SetErrStat(ErrID_Info, '1/VTK_fps is not an integer multiple of DT. FAST will output VTK information at '//&
trim(num2lstr(1.0_DbKi/TmpRate))//' fps, the closest rate possible.',ErrStat,ErrMsg,RoutineName)
end if
END IF
END IF
call cleanup()
RETURN
CONTAINS
!...............................................................................................................................
subroutine cleanup()
CLOSE( UnIn )
IF ( UnEc > 0 ) CLOSE ( UnEc )
end subroutine cleanup
!...............................................................................................................................
END SUBROUTINE FAST_ReadPrimaryFile
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine sets up some of the information needed for plotting VTK surfaces. It initializes only the data needed before
!! HD initialization. (HD needs some of this data so it can return the wave elevation data we want.)
SUBROUTINE SetVTKParameters_B4HD(p_FAST, InitOutData_ED, InitInData_HD, BD, ErrStat, ErrMsg)
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< The parameters of the glue code
TYPE(ED_InitOutputType), INTENT(IN ) :: InitOutData_ED !< The initialization output from structural dynamics module
TYPE(HydroDyn_InitInputType), INTENT(INOUT) :: InitInData_HD !< The initialization input to HydroDyn
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
REAL(SiKi) :: BladeLength, Width, WidthBy2
REAL(SiKi) :: dx, dy
INTEGER(IntKi) :: i, j, n
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'SetVTKParameters_B4HD'
ErrStat = ErrID_None
ErrMsg = ""
! Get radius for ground (blade length + hub radius):
if ( p_FAST%CompElast == Module_BD ) then
BladeLength = TwoNorm(BD%y(1)%BldMotion%Position(:,1) - BD%y(1)%BldMotion%Position(:,BD%y(1)%BldMotion%Nnodes))
else
BladeLength = InitOutData_ED%BladeLength
end if
p_FAST%VTK_Surface%HubRad = InitOutData_ED%HubRad
p_FAST%VTK_Surface%GroundRad = BladeLength + p_FAST%VTK_Surface%HubRad
!........................................................................................................
! We don't use the rest of this routine for stick-figure output
if (p_FAST%VTK_Type /= VTK_Surf) return
!........................................................................................................
! initialize wave elevation data:
if ( p_FAST%CompHydro == Module_HD ) then
p_FAST%VTK_surface%NWaveElevPts(1) = 25
p_FAST%VTK_surface%NWaveElevPts(2) = 25
call allocAry( InitInData_HD%WaveElevXY, 2, p_FAST%VTK_surface%NWaveElevPts(1)*p_FAST%VTK_surface%NWaveElevPts(2), 'WaveElevXY', ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return
Width = p_FAST%VTK_Surface%GroundRad * VTK_GroundFactor
dx = Width / (p_FAST%VTK_surface%NWaveElevPts(1) - 1)
dy = Width / (p_FAST%VTK_surface%NWaveElevPts(2) - 1)
WidthBy2 = Width / 2.0_SiKi
n = 1
do i=1,p_FAST%VTK_surface%NWaveElevPts(1)
do j=1,p_FAST%VTK_surface%NWaveElevPts(2)
InitInData_HD%WaveElevXY(1,n) = dx*(i-1) - WidthBy2 !+ p_FAST%TurbinePos(1) ! HD takes p_FAST%TurbinePos into account already
InitInData_HD%WaveElevXY(2,n) = dy*(j-1) - WidthBy2 !+ p_FAST%TurbinePos(2)
n = n+1
end do
end do
end if
END SUBROUTINE SetVTKParameters_B4HD
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine sets up the information needed for plotting VTK surfaces.
SUBROUTINE SetVTKParameters(p_FAST, InitOutData_ED, InitOutData_AD, InitInData_HD, InitOutData_HD, ED, BD, AD, HD, ErrStat, ErrMsg)
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< The parameters of the glue code
TYPE(ED_InitOutputType), INTENT(IN ) :: InitOutData_ED !< The initialization output from structural dynamics module
TYPE(AD_InitOutputType), INTENT(INOUT) :: InitOutData_AD !< The initialization output from AeroDyn
TYPE(HydroDyn_InitInputType), INTENT(INOUT) :: InitInData_HD !< The initialization input to HydroDyn
TYPE(HydroDyn_InitOutputType),INTENT(INOUT) :: InitOutData_HD !< The initialization output from HydroDyn
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
REAL(SiKi) :: RefPoint(3), RefLengths(2)
REAL(SiKi) :: x, y
REAL(SiKi) :: TwrDiam_top, TwrDiam_base, TwrRatio, TwrLength
INTEGER(IntKi) :: topNode, baseNode
INTEGER(IntKi) :: NumBl, k
CHARACTER(1024) :: vtkroot
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'SetVTKParameters'
ErrStat = ErrID_None
ErrMsg = ""
! get the name of the output directory for vtk files (in a subdirectory called "vtk" of the output directory), and
! create the VTK directory if it does not exist
call GetPath ( p_FAST%OutFileRoot, p_FAST%VTK_OutFileRoot, vtkroot ) ! the returned p_FAST%VTK_OutFileRoot includes a file separator character at the end
p_FAST%VTK_OutFileRoot = trim(p_FAST%VTK_OutFileRoot) // 'vtk'
call MKDIR( trim(p_FAST%VTK_OutFileRoot) )
p_FAST%VTK_OutFileRoot = trim( p_FAST%VTK_OutFileRoot ) // PathSep // trim(vtkroot)
! calculate the number of digits in 'y_FAST%NOutSteps' (Maximum number of output steps to be written)
! this will be used to pad the write-out step in the VTK filename with zeros in calls to MeshWrVTK()
if (p_FAST%WrVTK == VTK_ModeShapes .AND. p_FAST%VTK_modes%VTKLinTim==1) then
if (p_FAST%NLinTimes < 1) p_FAST%NLinTimes = 1 !in case we reached here with an error
p_FAST%VTK_tWidth = CEILING( log10( real( p_FAST%NLinTimes) ) ) + 1
else
p_FAST%VTK_tWidth = CEILING( log10( real(p_FAST%n_TMax_m1+1, ReKi) / p_FAST%n_VTKTime ) ) + 1
end if
! determine number of blades
NumBl = InitOutData_ED%NumBl
! initialize the vtk data
p_FAST%VTK_Surface%NumSectors = 25
! NOTE: we set p_FAST%VTK_Surface%GroundRad and p_FAST%VTK_Surface%HubRad in SetVTKParameters_B4HD
! write the ground or seabed reference polygon:
RefPoint = p_FAST%TurbinePos
if (p_FAST%CompHydro == MODULE_HD) then
RefLengths = p_FAST%VTK_Surface%GroundRad*VTK_GroundFactor/2.0_SiKi
! note that p_FAST%TurbinePos(3) must be 0 for offshore turbines
RefPoint(3) = p_FAST%TurbinePos(3) - InitOutData_HD%WtrDpth
call WrVTK_Ground ( RefPoint, RefLengths, trim(p_FAST%VTK_OutFileRoot) // '.SeabedSurface', ErrStat2, ErrMsg2 )
RefPoint(3) = p_FAST%TurbinePos(3) - InitOutData_HD%MSL2SWL
call WrVTK_Ground ( RefPoint, RefLengths, trim(p_FAST%VTK_OutFileRoot) // '.StillWaterSurface', ErrStat2, ErrMsg2 )
else
RefLengths = p_FAST%VTK_Surface%GroundRad !array = scalar
call WrVTK_Ground ( RefPoint, RefLengths, trim(p_FAST%VTK_OutFileRoot) // '.GroundSurface', ErrStat2, ErrMsg2 )
end if
!........................................................................................................
! We don't use the rest of this routine for stick-figure output
if (p_FAST%VTK_Type /= VTK_Surf) return
!........................................................................................................
! we're going to create a box using these dimensions
y = ED%y%HubPtMotion%Position(3, 1) - ED%y%NacelleMotion%Position(3, 1)
x = TwoNorm( ED%y%HubPtMotion%Position(1:2,1) - ED%y%NacelleMotion%Position(1:2,1) ) - p_FAST%VTK_Surface%HubRad
p_FAST%VTK_Surface%NacelleBox(:,1) = (/ -x, y, 0.0_SiKi /)
p_FAST%VTK_Surface%NacelleBox(:,2) = (/ x, y, 0.0_SiKi /)
p_FAST%VTK_Surface%NacelleBox(:,3) = (/ x, -y, 0.0_SiKi /)
p_FAST%VTK_Surface%NacelleBox(:,4) = (/ -x, -y, 0.0_SiKi /)
p_FAST%VTK_Surface%NacelleBox(:,5) = (/ -x, -y, 2*y /)
p_FAST%VTK_Surface%NacelleBox(:,6) = (/ x, -y, 2*y /)
p_FAST%VTK_Surface%NacelleBox(:,7) = (/ x, y, 2*y /)
p_FAST%VTK_Surface%NacelleBox(:,8) = (/ -x, y, 2*y /)
!.......................
! tapered tower
!.......................
CALL AllocAry(p_FAST%VTK_Surface%TowerRad,ED%y%TowerLn2Mesh%NNodes,'VTK_Surface%TowerRad',ErrStat2,ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
topNode = ED%y%TowerLn2Mesh%NNodes - 1
baseNode = ED%y%TowerLn2Mesh%refNode
TwrLength = TwoNorm( ED%y%TowerLn2Mesh%position(:,topNode) - ED%y%TowerLn2Mesh%position(:,baseNode) ) ! this is the assumed length of the tower
TwrRatio = TwrLength / 87.6_SiKi ! use ratio of the tower length to the length of the 5MW tower
TwrDiam_top = 3.87*TwrRatio
TwrDiam_base = 6.0*TwrRatio
TwrRatio = 0.5 * (TwrDiam_top - TwrDiam_base) / TwrLength
do k=1,ED%y%TowerLn2Mesh%NNodes
TwrLength = TwoNorm( ED%y%TowerLn2Mesh%position(:,k) - ED%y%TowerLn2Mesh%position(:,baseNode) )
p_FAST%VTK_Surface%TowerRad(k) = 0.5*TwrDiam_Base + TwrRatio*TwrLength
end do
!.......................
! blade surfaces
!.......................
allocate(p_FAST%VTK_Surface%BladeShape(NumBl),stat=ErrStat2)
if (errStat2/=0) then
call setErrStat(ErrID_Fatal,'Error allocating VTK_Surface%BladeShape.',ErrStat,ErrMsg,RoutineName)
return
end if
IF ( p_FAST%CompAero == Module_AD ) THEN ! These meshes may have airfoil data associated with nodes...
IF (ALLOCATED(InitOutData_AD%rotors(1)%BladeShape)) THEN
do k=1,NumBl
call move_alloc( InitOutData_AD%rotors(1)%BladeShape(k)%AirfoilCoords, p_FAST%VTK_Surface%BladeShape(k)%AirfoilCoords )
end do
ELSE
#ifndef USE_DEFAULT_BLADE_SURFACE
call setErrStat(ErrID_Fatal,'Cannot do surface visualization without airfoil coordinates defined in AeroDyn.',ErrStat,ErrMsg,RoutineName)
return
END IF
ELSE
call setErrStat(ErrID_Fatal,'Cannot do surface visualization without using AeroDyn.',ErrStat,ErrMsg,RoutineName)
return
END IF
#else
! AD used without airfoil coordinates specified
rootNode = 1
DO K=1,NumBl
tipNode = AD%Input(1)%rotors(1)%BladeMotion(K)%NNodes
cylNode = min(3,AD%Input(1)%rotors(1)%BladeMotion(K)%Nnodes)
call SetVTKDefaultBladeParams(AD%Input(1)%rotors(1)%BladeMotion(K), p_FAST%VTK_Surface%BladeShape(K), tipNode, rootNode, cylNode, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
END DO
END IF
ELSE IF ( p_FAST%CompElast == Module_BD ) THEN
rootNode = 1
DO K=1,NumBl
tipNode = BD%y(k)%BldMotion%NNodes
cylNode = min(3,BD%y(k)%BldMotion%NNodes)
call SetVTKDefaultBladeParams(BD%y(k)%BldMotion, p_FAST%VTK_Surface%BladeShape(K), tipNode, rootNode, cylNode, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
END DO
ELSE
DO K=1,NumBl
rootNode = ED%y%BladeLn2Mesh(K)%NNodes
tipNode = ED%y%BladeLn2Mesh(K)%NNodes-1
cylNode = min(2,ED%y%BladeLn2Mesh(K)%NNodes)
call SetVTKDefaultBladeParams(ED%y%BladeLn2Mesh(K), p_FAST%VTK_Surface%BladeShape(K), tipNode, rootNode, cylNode, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
END DO
END IF
#endif
!.......................
! wave elevation
!.......................
!bjj: interpolate here instead of each time step?
if ( allocated(InitOutData_HD%WaveElevSeries) ) then
call move_alloc( InitInData_HD%WaveElevXY, p_FAST%VTK_Surface%WaveElevXY )
call move_alloc( InitOutData_HD%WaveElevSeries, p_FAST%VTK_Surface%WaveElev )
! put the following lines in loops to avoid stack-size issues:
do k=1,size(p_FAST%VTK_Surface%WaveElevXY,2)
p_FAST%VTK_Surface%WaveElevXY(:,k) = p_FAST%VTK_Surface%WaveElevXY(:,k) + p_FAST%TurbinePos(1:2)
end do
! note that p_FAST%TurbinePos(3) must be 0 for offshore turbines
!do k=1,size(p_FAST%VTK_Surface%WaveElev,2)
! p_FAST%VTK_Surface%WaveElev(:,k) = p_FAST%VTK_Surface%WaveElev(:,k) + p_FAST%TurbinePos(3) ! not sure this is really accurate if p_FAST%TurbinePos(3) is non-zero
!end do
end if
!.......................
! morison surfaces
!.......................
IF ( HD%Input(1)%Morison%Mesh%Committed ) THEN
!TODO: FIX for visualization GJH 4/23/20
! call move_alloc(InitOutData_HD%Morison%Morison_Rad, p_FAST%VTK_Surface%MorisonRad)
END IF
END SUBROUTINE SetVTKParameters
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine comes up with some default airfoils for blade surfaces for a given blade mesh, M.
SUBROUTINE SetVTKDefaultBladeParams(M, BladeShape, tipNode, rootNode, cylNode, ErrStat, ErrMsg)
TYPE(MeshType), INTENT(IN ) :: M !< The Mesh the defaults should be calculated for
TYPE(FAST_VTK_BLSurfaceType), INTENT(INOUT) :: BladeShape !< BladeShape to set to default values
INTEGER(IntKi), INTENT(IN ) :: rootNode !< Index of root node (innermost node) for this mesh
INTEGER(IntKi), INTENT(IN ) :: tipNode !< Index of tip node (outermost node) for this mesh
INTEGER(IntKi), INTENT(IN ) :: cylNode !< Index of last node to have a cylinder shape
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
REAL(SiKi) :: bladeLength, chord, pitchAxis
REAL(SiKi) :: bladeLengthFract, bladeLengthFract2, ratio, posLength ! temporary quantities
REAL(SiKi) :: cylinderLength, x, y, angle
INTEGER(IntKi) :: i, j
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'SetVTKDefaultBladeParams'
!Note: jmj does not like this default option
integer, parameter :: N = 66
! default airfoil shape coordinates; uses S809 values from http://wind.nrel.gov/airfoils/Shapes/S809_Shape.html:
real, parameter, dimension(N) :: xc=(/ 1.0,0.996203,0.98519,0.967844,0.945073,0.917488,0.885293,0.848455,0.80747,0.763042,0.715952,0.667064,0.617331,0.56783,0.519832,0.474243,0.428461,0.382612,0.33726,0.29297,0.250247,0.209576,0.171409,0.136174,0.104263,0.076035,0.051823,0.03191,0.01659,0.006026,0.000658,0.000204,0.0,0.000213,0.001045,0.001208,0.002398,0.009313,0.02323,0.04232,0.065877,0.093426,0.124111,0.157653,0.193738,0.231914,0.271438,0.311968,0.35337,0.395329,0.438273,0.48192,0.527928,0.576211,0.626092,0.676744,0.727211,0.776432,0.823285,0.86663,0.905365,0.938474,0.965086,0.984478,0.996141,1.0 /)
real, parameter, dimension(N) :: yc=(/ 0.0,0.000487,0.002373,0.00596,0.011024,0.017033,0.023458,0.03028,0.037766,0.045974,0.054872,0.064353,0.074214,0.084095,0.093268,0.099392,0.10176,0.10184,0.10007,0.096703,0.091908,0.085851,0.078687,0.07058,0.061697,0.052224,0.042352,0.032299,0.02229,0.012615,0.003723,0.001942,-0.00002,-0.001794,-0.003477,-0.003724,-0.005266,-0.011499,-0.020399,-0.030269,-0.040821,-0.051923,-0.063082,-0.07373,-0.083567,-0.092442,-0.099905,-0.105281,-0.108181,-0.108011,-0.104552,-0.097347,-0.086571,-0.073979,-0.060644,-0.047441,-0.0351,-0.024204,-0.015163,-0.008204,-0.003363,-0.000487,0.000743,0.000775,0.00029,0.0 /)
call AllocAry(BladeShape%AirfoilCoords, 2, N, M%NNodes, 'BladeShape%AirfoilCoords', ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
! Chord length and pitch axis location are given by scaling law
bladeLength = TwoNorm( M%position(:,tipNode) - M%Position(:,rootNode) )
cylinderLength = TwoNorm( M%Position(:,cylNode) - M%Position(:,rootNode) )
bladeLengthFract = 0.22*bladeLength
bladeLengthFract2 = bladeLength-bladeLengthFract != 0.78*bladeLength
DO i=1,M%Nnodes
posLength = TwoNorm( M%Position(:,i) - M%Position(:,rootNode) )
IF (posLength .LE. bladeLengthFract) THEN
ratio = posLength/bladeLengthFract
chord = (0.06 + 0.02*ratio)*bladeLength
pitchAxis = 0.25 + 0.125*ratio
ELSE
chord = (0.08 - 0.06*(posLength-bladeLengthFract)/bladeLengthFract2)*bladeLength
pitchAxis = 0.375
END IF
IF (posLength .LE. cylinderLength) THEN
! create a cylinder for this node
chord = chord/2.0_SiKi
DO j=1,N
! normalized x,y coordinates for airfoil
x = yc(j)
y = xc(j) - 0.5
angle = ATAN2( y, x)
! x,y coordinates for cylinder
BladeShape%AirfoilCoords(1,j,i) = chord*COS(angle) ! x (note that "chord" is really representing chord/2 here)
BladeShape%AirfoilCoords(2,j,i) = chord*SIN(angle) ! y (note that "chord" is really representing chord/2 here)
END DO
ELSE
! create an airfoil for this node
DO j=1,N
! normalized x,y coordinates for airfoil, assuming an upwind turbine
x = yc(j)
y = xc(j) - pitchAxis
! x,y coordinates for airfoil
BladeShape%AirfoilCoords(1,j,i) = chord*x
BladeShape%AirfoilCoords(2,j,i) = chord*y
END DO
END IF
END DO ! nodes on mesh
END SUBROUTINE SetVTKDefaultBladeParams
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes the ground or seabed reference surface information in VTK format.
!! see VTK file information format for XML, here: http://www.vtk.org/wp-content/uploads/2015/04/file-formats.pdf
SUBROUTINE WrVTK_Ground ( RefPoint, HalfLengths, FileRootName, ErrStat, ErrMsg )
REAL(SiKi), INTENT(IN) :: RefPoint(3) !< reference point (plane will be created around it)
REAL(SiKi), INTENT(IN) :: HalfLengths(2) !< half of the X-Y lengths of plane surrounding RefPoint
CHARACTER(*), INTENT(IN) :: FileRootName !< Name of the file to write the output in (excluding extension)
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Indicates whether an error occurred (see NWTC_Library)
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message associated with the ErrStat
! local variables
INTEGER(IntKi) :: Un ! fortran unit number
INTEGER(IntKi) :: ix ! loop counters
CHARACTER(1024) :: FileName
INTEGER(IntKi), parameter :: NumberOfPoints = 4
INTEGER(IntKi), parameter :: NumberOfLines = 0
INTEGER(IntKi), parameter :: NumberOfPolys = 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*),PARAMETER :: RoutineName = 'WrVTK_Ground'
ErrStat = ErrID_None
ErrMsg = ""
!.................................................................
! write the data that potentially changes each time step:
!.................................................................
! PolyData (.vtp) - Serial vtkPolyData (unstructured) file
FileName = TRIM(FileRootName)//'.vtp'
call WrVTK_header( FileName, NumberOfPoints, NumberOfLines, NumberOfPolys, Un, ErrStat2, ErrMsg2 )
call SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
if (ErrStat >= AbortErrLev) return
! points (nodes, augmented with NumSegments):
WRITE(Un,'(A)') ' <Points>'
WRITE(Un,'(A)') ' <DataArray type="Float32" NumberOfComponents="3" format="ascii">'
WRITE(Un,VTK_AryFmt) RefPoint(1) + HalfLengths(1) , RefPoint(2) + HalfLengths(2), RefPoint(3)
WRITE(Un,VTK_AryFmt) RefPoint(1) + HalfLengths(1) , RefPoint(2) - HalfLengths(2), RefPoint(3)
WRITE(Un,VTK_AryFmt) RefPoint(1) - HalfLengths(1) , RefPoint(2) - HalfLengths(2), RefPoint(3)
WRITE(Un,VTK_AryFmt) RefPoint(1) - HalfLengths(1) , RefPoint(2) + HalfLengths(2), RefPoint(3)
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' </Points>'
WRITE(Un,'(A)') ' <Polys>'
WRITE(Un,'(A)') ' <DataArray type="Int32" Name="connectivity" format="ascii">'
WRITE(Un,'('//trim(num2lstr(NumberOfPoints))//'(i7))') (ix, ix=0,NumberOfPoints-1)
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' <DataArray type="Int32" Name="offsets" format="ascii">'
WRITE(Un,'(i7)') NumberOfPoints
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' </Polys>'
call WrVTK_footer( Un )
END SUBROUTINE WrVTK_Ground
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine sets up the information needed to initialize AeroDyn, then initializes AeroDyn
SUBROUTINE AD_SetInitInput(InitInData_AD14, InitOutData_ED, y_ED, p_FAST, ErrStat, ErrMsg)
! Passed variables:
TYPE(AD14_InitInputType),INTENT(INOUT) :: InitInData_AD14 !< The initialization input to AeroDyn14
TYPE(ED_InitOutputType), INTENT(IN) :: InitOutData_ED !< The initialization output from structural dynamics module
TYPE(ED_OutputType), INTENT(IN) :: y_ED !< The outputs of the structural dynamics module (meshes with position/RefOrientation set)
TYPE(FAST_ParameterType),INTENT(IN) :: p_FAST !< The parameters of the glue code
INTEGER(IntKi) :: ErrStat !< Error status of the operation
CHARACTER(*) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! Local variables
!TYPE(AD_InitOptions) :: ADOptions ! Options for AeroDyn
INTEGER :: K
ErrStat = ErrID_None
ErrMsg = ""
! Set up the AeroDyn parameters
InitInData_AD14%ADFileName = p_FAST%AeroFile
InitInData_AD14%OutRootName = p_FAST%OutFileRoot
InitInData_AD14%WrSumFile = p_FAST%SumPrint
InitInData_AD14%NumBl = InitOutData_ED%NumBl
InitInData_AD14%UseDWM = p_FAST%UseDWM
InitInData_AD14%DWM%IfW%InputFileName = p_FAST%InflowFile
! Hub position and orientation (relative here, but does not need to be)
InitInData_AD14%TurbineComponents%Hub%Position(:) = y_ED%HubPtMotion14%Position(:,1) - y_ED%HubPtMotion14%Position(:,1) ! bjj: was 0; mesh was changed by adding p_ED%HubHt to 3rd component
InitInData_AD14%TurbineComponents%Hub%Orientation(:,:) = y_ED%HubPtMotion14%RefOrientation(:,:,1)
InitInData_AD14%TurbineComponents%Hub%TranslationVel = 0.0_ReKi ! bjj: we don't need this field
InitInData_AD14%TurbineComponents%Hub%RotationVel = 0.0_ReKi ! bjj: we don't need this field
! Blade root position and orientation (relative here, but does not need to be)
IF (.NOT. ALLOCATED( InitInData_AD14%TurbineComponents%Blade ) ) THEN
ALLOCATE( InitInData_AD14%TurbineComponents%Blade( InitInData_AD14%NumBl ), STAT = ErrStat )
IF ( ErrStat /= 0 ) THEN
ErrStat = ErrID_Fatal
ErrMsg = ' Error allocating space for InitInData_AD%TurbineComponents%Blade.'
RETURN
ELSE
ErrStat = ErrID_None !reset to ErrID_None, just in case ErrID_None /= 0
END IF
END IF
DO K=1, InitInData_AD14%NumBl
InitInData_AD14%TurbineComponents%Blade(K)%Position = y_ED%BladeRootMotion14%Position(:,K)
InitInData_AD14%TurbineComponents%Blade(K)%Orientation = y_ED%BladeRootMotion14%RefOrientation(:,:,K)
InitInData_AD14%TurbineComponents%Blade(K)%TranslationVel = 0.0_ReKi ! bjj: we don't need this field
InitInData_AD14%TurbineComponents%Blade(K)%RotationVel = 0.0_ReKi ! bjj: we don't need this field
END DO
! Blade length
IF (p_FAST%CompElast == Module_ED) THEN ! note, we can't get here if we're using BeamDyn....
InitInData_AD14%TurbineComponents%BladeLength = InitOutData_ED%BladeLength
END IF
! Tower mesh ( here only because we currently need line2 meshes to contain the same nodes/elements )
InitInData_AD14%NumTwrNodes = y_ED%TowerLn2Mesh%NNodes - 2
IF (.NOT. ALLOCATED( InitInData_AD14%TwrNodeLocs ) ) THEN
ALLOCATE( InitInData_AD14%TwrNodeLocs( 3, InitInData_AD14%NumTwrNodes ), STAT = ErrStat )
IF ( ErrStat /= 0 ) THEN
ErrStat = ErrID_Fatal
ErrMsg = ' Error allocating space for InitInData_AD%TwrNodeLocs.'
RETURN
ELSE
ErrStat = ErrID_None
END IF
END IF
IF ( InitInData_AD14%NumTwrNodes > 0 ) THEN
InitInData_AD14%TwrNodeLocs = y_ED%TowerLn2Mesh%Position(:,1:InitInData_AD14%NumTwrNodes) ! ED has extra nodes at beginning and top and bottom of tower
END IF
! hub height
InitInData_AD14%HubHt = InitOutData_ED%HubHt
RETURN
END SUBROUTINE AD_SetInitInput
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine sets the number of subcycles (substeps) for modules at initialization, checking to make sure that their requested
!! time step is valid.
SUBROUTINE SetModuleSubstepTime(ModuleID, p_FAST, y_FAST, ErrStat, ErrMsg)
INTEGER(IntKi), INTENT(IN ) :: ModuleID !< ID of the module to check time step and set
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(IN ) :: y_FAST !< Output variables for the glue code
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
ErrStat = ErrID_None
ErrMsg = ""
IF ( EqualRealNos( p_FAST%dt_module( ModuleID ), p_FAST%dt ) ) THEN
p_FAST%n_substeps(ModuleID) = 1
ELSE
IF ( p_FAST%dt_module( ModuleID ) > p_FAST%dt ) THEN
ErrStat = ErrID_Fatal
ErrMsg = "The "//TRIM(y_FAST%Module_Ver(ModuleID)%Name)//" module time step ("//&
TRIM(Num2LStr(p_FAST%dt_module( ModuleID )))// &
" s) cannot be larger than FAST time step ("//TRIM(Num2LStr(p_FAST%dt))//" s)."
ELSE
! calculate the number of subcycles:
p_FAST%n_substeps(ModuleID) = NINT( p_FAST%dt / p_FAST%dt_module( ModuleID ) )
! let's make sure THE module DT is an exact integer divisor of the global (FAST) time step:
IF ( .NOT. EqualRealNos( p_FAST%dt, p_FAST%dt_module( ModuleID ) * p_FAST%n_substeps(ModuleID) ) ) THEN
ErrStat = ErrID_Fatal
ErrMsg = "The "//TRIM(y_FAST%Module_Ver(ModuleID)%Name)//" module time step ("//&
TRIM(Num2LStr(p_FAST%dt_module( ModuleID )))// &
" s) must be an integer divisor of the FAST time step ("//TRIM(Num2LStr(p_FAST%dt))//" s)."
END IF
END IF
END IF
RETURN
END SUBROUTINE SetModuleSubstepTime
!----------------------------------------------------------------------------------------------------------------------------------
!> This writes data to the FAST summary file.
SUBROUTINE FAST_WrSum( p_FAST, y_FAST, MeshMapData, ErrStat, ErrMsg )
TYPE(FAST_ParameterType), INTENT(IN) :: p_FAST !< Glue-code simulation parameters
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Glue-code simulation outputs (changes value of UnSum)
TYPE(FAST_ModuleMapType), INTENT(IN) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status (level)
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Message describing error reported in ErrStat
! local variables
REAL(ReKi) :: TmpRate ! temporary rate for vtk output
INTEGER(IntKi) :: I ! temporary counter
INTEGER(IntKi) :: J ! temporary counter
INTEGER(IntKi) :: Module_Number ! loop counter through the modules
CHARACTER(200) :: Fmt ! temporary format string
CHARACTER(200) :: DescStr ! temporary string to write text
CHARACTER(*), PARAMETER :: NotUsedTxt = " [not called]" ! text written if a module is not called
CHARACTER(ChanLen) :: ChanTxt(2) ! temp strings to help with formatting with unknown ChanLen size
! Get a unit number and open the file:
CALL GetNewUnit( y_FAST%UnSum, ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
CALL OpenFOutFile ( y_FAST%UnSum, TRIM(p_FAST%OutFileRoot)//'.sum', ErrStat, ErrMsg )
IF ( ErrStat >= AbortErrLev ) RETURN
! Add some file information:
!.......................... Module Versions .....................................................
!bjj: modules in this list are ordered by the order they are specified in the FAST input file
WRITE (y_FAST%UnSum,'(/A)') 'FAST Summary File'
WRITE (y_FAST%UnSum,'(/A)') TRIM( y_FAST%FileDescLines(1) )
WRITE (y_FAST%UnSum,'(2X,A)' ) 'compiled with'
Fmt = '(4x,A)'
WRITE (y_FAST%UnSum,Fmt) TRIM( GetNVD( NWTC_Ver ) )
WRITE (y_FAST%UnSum,Fmt) TRIM( GetNVD( y_FAST%Module_Ver( Module_ED ) ) )
DescStr = GetNVD( y_FAST%Module_Ver( Module_BD ) )
IF ( p_FAST%CompElast /= Module_BD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_IfW ) )
IF ( p_FAST%CompInflow /= Module_IfW ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
! I'm not going to write the openfoam module info to the summary file
!DescStr = GetNVD( y_FAST%Module_Ver( Module_OpFM ) )
!IF ( p_FAST%CompInflow /= Module_OpFM ) DescStr = TRIM(DescStr)//NotUsedTxt
!WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_AD14 ) )
IF ( p_FAST%CompAero /= Module_AD14 ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_AD ) )
IF ( p_FAST%CompAero /= Module_AD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_SrvD ) )
IF ( p_FAST%CompServo /= Module_SrvD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_HD ) )
IF ( p_FAST%CompHydro /= Module_HD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_SD ) )
IF ( p_FAST%CompSub /= Module_SD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_ExtPtfm ) )
IF ( p_FAST%CompSub /= Module_ExtPtfm ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_MAP ) )
IF ( p_FAST%CompMooring /= Module_MAP ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_FEAM ) )
IF ( p_FAST%CompMooring /= Module_FEAM ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_MD ) )
IF ( p_FAST%CompMooring /= Module_MD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_Orca ) )
IF ( p_FAST%CompMooring /= Module_Orca ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_IceF ) )
IF ( p_FAST%CompIce /= Module_IceF ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
DescStr = GetNVD( y_FAST%Module_Ver( Module_IceD ) )
IF ( p_FAST%CompIce /= Module_IceD ) DescStr = TRIM(DescStr)//NotUsedTxt
WRITE (y_FAST%UnSum,Fmt) TRIM( DescStr )
!.......................... Information from FAST input File ......................................
! OTHER information we could print here:
! current working directory
! output file root name
! output file time step
! output file format (text/binary)
! coupling method
SELECT CASE ( p_FAST%TurbineType )
CASE ( Type_LandBased )
DescStr = 'Modeling a land-based turbine'
CASE ( Type_Offshore_Fixed )
DescStr = 'Modeling a fixed-bottom offshore turbine'
CASE ( Type_Offshore_Floating )
DescStr = 'Modeling a floating offshore turbine'
CASE DEFAULT ! This should never happen
DescStr=""
END SELECT
WRITE(y_FAST%UnSum,'(//A)') TRIM(DescStr)
WRITE (y_FAST%UnSum,'(A)' ) 'Description from the FAST input file: '
WRITE (y_FAST%UnSum,'(2X,A)') TRIM(p_FAST%FTitle)
!.......................... Requested Features ...................................................
SELECT CASE ( p_FAST%InterpOrder )
CASE (0)
DescStr = ' (nearest neighbor)'
CASE (1)
DescStr = ' (linear)'
CASE (2)
DescStr = ' (quadratic)'
CASE DEFAULT
DescStr = ' ( )'
END SELECT
WRITE(y_FAST%UnSum,'(/A,I1,A)' ) 'Interpolation order for input/output time histories: ', p_FAST%InterpOrder, TRIM(DescStr)
WRITE(y_FAST%UnSum,'( A,I2)' ) 'Number of correction iterations: ', p_FAST%NumCrctn
!.......................... Information About Coupling ...................................................
IF ( ALLOCATED( MeshMapData%Jacobian_Opt1 ) ) then ! we're using option 1
IF ( p_FAST%CompSub /= Module_None .OR. p_FAST%CompElast == Module_BD .OR. p_FAST%CompMooring == Module_Orca ) THEN ! SubDyn-BeamDyn-HydroDyn-ElastoDyn-ExtPtfm
DescStr = 'ElastoDyn, SubDyn, HydroDyn, OrcaFlex, ExtPtfm_MCKF, and/or BeamDyn'
ELSE ! IF ( p_FAST%CompHydro == Module_HD ) THEN
DescStr = "ElastoDyn to HydroDyn"
END IF
WRITE(y_FAST%UnSum,'( A,I6)' ) 'Number of rows in Jacobian matrix used for coupling '//TRIM(DescStr)//': ', &
SIZE(MeshMapData%Jacobian_Opt1, 1)
END IF
!.......................... Time step information: ...................................................
WRITE (y_FAST%UnSum,'(//,2X,A)') " Requested Time Steps "
WRITE (y_FAST%UnSum, '(2X,A)') "-------------------------------------------------"
Fmt = '(2X,A17,2X,A15,2X,A13)'
WRITE (y_FAST%UnSum, Fmt ) "Component ", "Time Step (s) ", "Subcycles (-)"
WRITE (y_FAST%UnSum, Fmt ) "-----------------", "---------------", "-------------"
Fmt = '(2X,A17,2X,'//TRIM(p_FAST%OutFmt)//',:,T37,2X,I8,:,A)'
WRITE (y_FAST%UnSum, Fmt ) "FAST (glue code) ", p_FAST%DT
DO Module_Number=2,NumModules ! assumes glue-code is module number 1 (i.e., MODULE_Glue == 1)
IF (p_FAST%ModuleInitialized(Module_Number)) THEN
WRITE (y_FAST%UnSum, Fmt ) y_FAST%Module_Ver(Module_Number)%Name, p_FAST%DT_module(Module_Number), p_FAST%n_substeps(Module_Number)
END IF
END DO
IF ( p_FAST%n_DT_Out == 1_IntKi ) THEN
WRITE (y_FAST%UnSum, Fmt ) "FAST output files", p_FAST%DT_out, 1_IntKi ! we'll write "1" instead of "1^-1"
ELSE
WRITE (y_FAST%UnSum, Fmt ) "FAST output files", p_FAST%DT_out, p_FAST%n_DT_Out,"^-1"
END IF
IF (p_FAST%WrVTK == VTK_Animate) THEN
TmpRate = p_FAST%DT*p_FAST%n_VTKTime
IF ( p_FAST%n_VTKTime == 1_IntKi ) THEN
WRITE (y_FAST%UnSum, Fmt ) "VTK output files ", p_FAST%DT, 1_IntKi ! we'll write "1" instead of "1^-1"
ELSE
WRITE (y_FAST%UnSum, Fmt ) "VTK output files ", TmpRate, p_FAST%n_VTKTime,"^-1"
END IF
ELSE
TmpRate = p_FAST%VTK_fps
END IF
! bjj: fix this; possibly add names of which files will be generated?
IF (p_FAST%WrVTK == VTK_Animate .or. p_FAST%WrVTK == VTK_ModeShapes) THEN
Fmt = '(2X,A17,2X,'//TRIM(p_FAST%OutFmt)//',:,T37,:,A)'
WRITE (y_FAST%UnSum,'(//,2X,A)') " Requested Visualization Output"
WRITE (y_FAST%UnSum, '(2X,A)') "-------------------------------------------------"
WRITE (y_FAST%UnSum, Fmt ) "Frame rate", 1.0_DbKi/TmpRate, " fps"
END IF
!.......................... Requested Output Channels ............................................
WRITE (y_FAST%UnSum,'(//,2X,A)') " Requested Channels in FAST Output File(s) "
WRITE (y_FAST%UnSum, '(2X,A)') "--------------------------------------------"
Fmt = '(2X,A6,2(2X,A'//TRIM(num2lstr(ChanLen))//'),2X,A)'
ChanTxt(1) = 'Name'
ChanTxt(2) = 'Units'
WRITE (y_FAST%UnSum, Fmt ) "Number", ChanTxt, "Generated by"
ChanTxt = '--------------------' !this ought to be sufficiently long
WRITE (y_FAST%UnSum, Fmt ) "------", ChanTxt, "------------"
Fmt = '(4X,I4,2(2X,A'//TRIM(num2lstr(ChanLen))//'),2X,A)'
I = 0
DO Module_Number = 1,NumModules
DO J = 1,y_FAST%numOuts( Module_Number )
I = I + 1
WRITE (y_FAST%UnSum, Fmt ) I, y_FAST%ChannelNames(I), y_FAST%ChannelUnits(I), TRIM(y_FAST%Module_Ver( Module_Number )%Name)
END DO
END DO
!.......................... End of Summary File ............................................
! bjj: note that I'm not closing the summary file here, though at the present time we don't write to this file again.
! In the future, we may want to write additional information to this file during the simulation.
! bjj 4/21/2015: closing the file now because of restart. If it needs to be open later, we can change it again.
CLOSE( y_FAST%UnSum )
y_FAST%UnSum = -1
END SUBROUTINE FAST_WrSum
!----------------------------------------------------------------------------------------------------------------------------------
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! TIME-STEP SOLVER ROUTINES (includes initialization after first call to calcOutput at t=0)
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!> Routine that calls FAST_Solution0 for one instance of a Turbine data structure. This is a separate subroutine so that the FAST
!! driver programs do not need to change or operate on the individual module level.
SUBROUTINE FAST_Solution0_T(Turbine, ErrStat, ErrMsg)
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
CALL FAST_Solution0(Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg )
END SUBROUTINE FAST_Solution0_T
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls CalcOutput for the first time of the simulation (at t=0). After the initial solve, data arrays are initialized.
SUBROUTINE FAST_Solution0(p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat, ErrMsg )
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi), PARAMETER :: n_t_global = -1 ! loop counter
INTEGER(IntKi), PARAMETER :: n_t_global_next = 0 ! loop counter
REAL(DbKi) :: t_initial ! next simulation time (t_global_next)
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_Solution0'
!NOTE: m_FAST%t_global is t_initial in this routine
ErrStat = ErrID_None
ErrMsg = ""
t_initial = m_FAST%t_global ! which is used in place of t_global_next
y_FAST%WriteThisStep = NeedWriteOutput(n_t_global_next, t_initial, p_FAST)
IF (p_FAST%WrSttsTime) then
CALL SimStatus_FirstTime( m_FAST%TiLstPrn, m_FAST%PrevClockTime, m_FAST%SimStrtTime, m_FAST%UsrTime2, t_initial, p_FAST%TMax, p_FAST%TDesc )
END IF
! Solve input-output relations; this section of code corresponds to Eq. (35) in Gasmi et al. (2013)
! This code will be specific to the underlying modules
! the initial ServoDyn and IfW/Lidar inputs from Simulink:
IF ( p_FAST%CompServo == Module_SrvD ) CALL SrvD_SetExternalInputs( p_FAST, m_FAST, SrvD%Input(1) )
IF ( p_FAST%CompInflow == Module_IfW ) CALL IfW_SetExternalInputs( IfW%p, m_FAST, ED%y, IfW%Input(1) )
CALL CalcOutputs_And_SolveForInputs( n_t_global, t_initial, STATE_CURR, m_FAST%calcJacobian, m_FAST%NextJacCalcTime, &
p_FAST, m_FAST, y_FAST%WriteThisStep, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
!----------------------------------------------------------------------------------------
! Check to see if we should output data this time step:
!----------------------------------------------------------------------------------------
CALL WriteOutputToFile(n_t_global_next, t_initial, p_FAST, y_FAST, ED, BD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! turn off VTK output when
if (p_FAST%WrVTK == VTK_InitOnly) then
! Write visualization data for initialization (and also note that we're ignoring any errors that occur doing so)
call WriteVTK(t_initial, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
end if
!...............
! Copy values of these initial guesses for interpolation/extrapolation and
! initialize predicted states for j_pc loop (use MESH_NEWCOPY here so we can use MESH_UPDATE copy later)
!...............
! Initialize Input-Output arrays for interpolation/extrapolation:
CALL FAST_InitIOarrays( m_FAST%t_global, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END SUBROUTINE FAST_Solution0
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine initializes the input and output arrays stored for extrapolation. They are initialized after the first input-output solve so that the first
!! extrapolations are used with values from the solution, not just initial guesses. It also creates new copies of the state variables, which need to
!! be stored for the predictor-corrector loop.
SUBROUTINE FAST_InitIOarrays( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< start time of the simulation
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(IN ) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(IN ) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn v14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: i, j, k ! loop counters
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_InitIOarrays'
ErrStat = ErrID_None
ErrMsg = ""
! We fill ED%InputTimes with negative times, but the ED%Input values are identical for each of those times; this allows
! us to use, e.g., quadratic interpolation that effectively acts as a zeroth-order extrapolation and first-order extrapolation
! for the first and second time steps. (The interpolation order in the ExtrapInput routines are determined as
! order = SIZE(ED%Input)
DO j = 1, p_FAST%InterpOrder + 1
ED%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL ED_CopyInput (ED%Input(1), ED%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL ED_CopyInput (ED%Input(1), ED%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL ED_CopyContState (ED%x( STATE_CURR), ED%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyDiscState (ED%xd(STATE_CURR), ED%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyConstrState (ED%z( STATE_CURR), ED%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyOtherState (ED%OtherSt( STATE_CURR), ED%OtherSt( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (p_FAST%CompElast == Module_BD ) THEN
DO k = 1,p_FAST%nBeams
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
BD%InputTimes(j,k) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL BD_CopyInput (BD%Input(1,k), BD%Input(j,k), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL BD_CopyInput (BD%Input(1,k), BD%u(k), MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL BD_CopyContState (BD%x( k,STATE_CURR), BD%x( k,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyDiscState (BD%xd(k,STATE_CURR), BD%xd(k,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyConstrState (BD%z( k,STATE_CURR), BD%z( k,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyOtherState (BD%OtherSt( k,STATE_CURR), BD%OtherSt( k,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO ! nBeams
END IF ! CompElast
IF ( p_FAST%CompServo == Module_SrvD ) THEN
! Initialize Input-Output arrays for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
SrvD%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!SrvD_OutputTimes(j) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL SrvD_CopyInput (SrvD%Input(1), SrvD%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL SrvD_CopyInput (SrvD%Input(1), SrvD%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL SrvD_CopyContState (SrvD%x( STATE_CURR), SrvD%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyDiscState (SrvD%xd(STATE_CURR), SrvD%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyConstrState (SrvD%z( STATE_CURR), SrvD%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyOtherState( SrvD%OtherSt(STATE_CURR), SrvD%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF ! CompServo
IF ( p_FAST%CompAero == Module_AD14 ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
AD14%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL AD14_CopyInput (AD14%Input(1), AD14%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL AD14_CopyInput (AD14%Input(1), AD14%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL AD14_CopyContState (AD14%x( STATE_CURR), AD14%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyDiscState (AD14%xd(STATE_CURR), AD14%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyConstrState (AD14%z( STATE_CURR), AD14%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyOtherState( AD14%OtherSt(STATE_CURR), AD14%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
AD%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL AD_CopyInput (AD%Input(1), AD%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL AD_CopyInput (AD%Input(1), AD%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL AD_CopyContState(AD%x(STATE_CURR), AD%x(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyDiscState(AD%xd(STATE_CURR), AD%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyConstrState(AD%z(STATE_CURR), AD%z(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyOtherState(AD%OtherSt(STATE_CURR), AD%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF ! CompAero == Module_AD
IF ( p_FAST%CompInflow == Module_IfW ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
IfW%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!IfW%OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL InflowWind_CopyInput (IfW%Input(1), IfW%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL InflowWind_CopyInput (IfW%Input(1), IfW%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL InflowWind_CopyContState (IfW%x( STATE_CURR), IfW%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyDiscState (IfW%xd(STATE_CURR), IfW%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyConstrState (IfW%z( STATE_CURR), IfW%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyOtherState( IfW%OtherSt(STATE_CURR), IfW%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF ! CompInflow == Module_IfW
IF ( p_FAST%CompHydro == Module_HD ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
HD%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!HD_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL HydroDyn_CopyInput (HD%Input(1), HD%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL HydroDyn_CopyInput (HD%Input(1), HD%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL HydroDyn_CopyContState (HD%x( STATE_CURR), HD%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyDiscState (HD%xd(STATE_CURR), HD%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyConstrState (HD%z( STATE_CURR), HD%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyOtherState( HD%OtherSt(STATE_CURR), HD%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF !CompHydro
IF (p_FAST%CompSub == Module_SD ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
SD%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!SD_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL SD_CopyInput (SD%Input(1), SD%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL SD_CopyInput (SD%Input(1), SD%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL SD_CopyContState (SD%x( STATE_CURR), SD%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyDiscState (SD%xd(STATE_CURR), SD%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyConstrState (SD%z( STATE_CURR), SD%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyOtherState( SD%OtherSt(STATE_CURR), SD%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSE IF (p_FAST%CompSub == Module_ExtPtfm ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
ExtPtfm%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL ExtPtfm_CopyInput (ExtPtfm%Input(1), ExtPtfm%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL ExtPtfm_CopyInput (ExtPtfm%Input(1), ExtPtfm%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL ExtPtfm_CopyContState (ExtPtfm%x( STATE_CURR), ExtPtfm%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyDiscState (ExtPtfm%xd(STATE_CURR), ExtPtfm%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyConstrState (ExtPtfm%z( STATE_CURR), ExtPtfm%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyOtherState( ExtPtfm%OtherSt(STATE_CURR), ExtPtfm%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF ! CompSub
IF (p_FAST%CompMooring == Module_MAP) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
MAPp%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!MAP_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL MAP_CopyInput (MAPp%Input(1), MAPp%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL MAP_CopyInput (MAPp%Input(1), MAPp%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL MAP_CopyContState (MAPp%x( STATE_CURR), MAPp%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MAP_CopyDiscState (MAPp%xd(STATE_CURR), MAPp%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MAP_CopyConstrState (MAPp%z( STATE_CURR), MAPp%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF ( p_FAST%n_substeps( MODULE_MAP ) > 1 ) THEN
CALL MAP_CopyOtherState( MAPp%OtherSt, MAPp%OtherSt_old, MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
ELSEIF (p_FAST%CompMooring == Module_MD) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
MD%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!MD_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL MD_CopyInput (MD%Input(1), MD%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL MD_CopyInput (MD%Input(1), MD%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL MD_CopyContState (MD%x( STATE_CURR), MD%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyDiscState (MD%xd(STATE_CURR), MD%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyConstrState (MD%z( STATE_CURR), MD%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyOtherState( MD%OtherSt(STATE_CURR), MD%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompMooring == Module_FEAM) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
FEAM%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!FEAM_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL FEAM_CopyInput (FEAM%Input(1), FEAM%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL FEAM_CopyInput (FEAM%Input(1), FEAM%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL FEAM_CopyContState (FEAM%x( STATE_CURR), FEAM%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyDiscState (FEAM%xd(STATE_CURR), FEAM%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyConstrState (FEAM%z( STATE_CURR), FEAM%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyOtherState( FEAM%OtherSt(STATE_CURR), FEAM%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompMooring == Module_Orca) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
Orca%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL Orca_CopyInput (Orca%Input(1), Orca%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL Orca_CopyInput (Orca%Input(1), Orca%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL Orca_CopyContState (Orca%x( STATE_CURR), Orca%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyDiscState (Orca%xd(STATE_CURR), Orca%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyConstrState (Orca%z( STATE_CURR), Orca%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyOtherState( Orca%OtherSt(STATE_CURR), Orca%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF ! CompMooring
IF (p_FAST%CompIce == Module_IceF ) THEN
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
IceF%InputTimes(j) = t_initial - (j - 1) * p_FAST%dt
!IceF_OutputTimes(i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL IceFloe_CopyInput (IceF%Input(1), IceF%Input(j), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL IceFloe_CopyInput (IceF%Input(1), IceF%u, MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL IceFloe_CopyContState (IceF%x( STATE_CURR), IceF%x( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyDiscState (IceF%xd(STATE_CURR), IceF%xd(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyConstrState (IceF%z( STATE_CURR), IceF%z( STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyOtherState( IceF%OtherSt(STATE_CURR), IceF%OtherSt(STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompIce == Module_IceD ) THEN
DO i = 1,p_FAST%numIceLegs
! Copy values for interpolation/extrapolation:
DO j = 1, p_FAST%InterpOrder + 1
IceD%InputTimes(j,i) = t_initial - (j - 1) * p_FAST%dt
!IceD%OutputTimes(j,i) = t_initial - (j - 1) * dt
END DO
DO j = 2, p_FAST%InterpOrder + 1
CALL IceD_CopyInput (IceD%Input(1,i), IceD%Input(j,i), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
CALL IceD_CopyInput (IceD%Input(1,i), IceD%u(i), MESH_NEWCOPY, Errstat2, ErrMsg2) ! do this to initialize meshes/allocatable arrays for output of ExtrapInterp routine
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Initialize predicted states for j_pc loop:
CALL IceD_CopyContState (IceD%x( i,STATE_CURR), IceD%x( i,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyDiscState (IceD%xd(i,STATE_CURR), IceD%xd(i,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyConstrState (IceD%z( i,STATE_CURR), IceD%z( i,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyOtherState( IceD%OtherSt(i,STATE_CURR), IceD%OtherSt(i,STATE_PRED), MESH_NEWCOPY, Errstat2, ErrMsg2)
CALL SetErrStat( Errstat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO ! numIceLegs
END IF ! CompIce
END SUBROUTINE FAST_InitIOarrays
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls FAST_Solution for one instance of a Turbine data structure. This is a separate subroutine so that the FAST
!! driver programs do not need to change or operate on the individual module level.
SUBROUTINE FAST_Solution_T(t_initial, n_t_global, Turbine, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< loop counter
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
CALL FAST_Solution(t_initial, n_t_global, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg )
END SUBROUTINE FAST_Solution_T
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine takes data from n_t_global and gets values at n_t_global + 1
SUBROUTINE FAST_Solution(t_initial, n_t_global, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< loop counter
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t_global_next ! next simulation time (m_FAST%t_global + p_FAST%dt)
INTEGER(IntKi) :: n_t_global_next ! n_t_global + 1
INTEGER(IntKi) :: j_pc ! predictor-corrector loop counter
INTEGER(IntKi) :: NumCorrections ! number of corrections for this time step
INTEGER(IntKi), parameter :: MaxCorrections = 20 ! maximum number of corrections allowed
LOGICAL :: WriteThisStep ! Whether WriteOutput values will be printed
INTEGER(IntKi) :: I, k ! generic loop counters
!REAL(ReKi) :: ControlInputGuess ! value of controller inputs
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_Solution'
ErrStat = ErrID_None
ErrMsg = ""
n_t_global_next = n_t_global+1
t_global_next = t_initial + n_t_global_next*p_FAST%DT ! = m_FAST%t_global + p_FAST%dt
y_FAST%WriteThisStep = NeedWriteOutput(n_t_global_next, t_global_next, p_FAST)
!! determine if the Jacobian should be calculated this time
IF ( m_FAST%calcJacobian ) THEN ! this was true (possibly at initialization), so we'll advance the time for the next calculation of the Jacobian
if (p_FAST%CompMooring == Module_Orca .and. n_t_global < 5) then
m_FAST%NextJacCalcTime = m_FAST%t_global + p_FAST%DT ! the jacobian calculated with OrcaFlex at t=0 is incorrect, but is okay on the 2nd step (it's not okay for OrcaFlex version 10, so I increased this to 5)
else
m_FAST%NextJacCalcTime = m_FAST%t_global + p_FAST%DT_UJac
end if
END IF
! set number of corrections to be used for this time step:
IF ( p_FAST%CompElast == Module_BD ) THEN ! BD accelerations have fewer spikes with these corrections on the first several time steps
if (n_t_global > 2) then ! this 2 should probably be related to p_FAST%InterpOrder
NumCorrections = p_FAST%NumCrctn
elseif (n_t_global == 0) then
NumCorrections = max(p_FAST%NumCrctn,16)
else
NumCorrections = max(p_FAST%NumCrctn,1)
end if
ELSE
NumCorrections = p_FAST%NumCrctn
END IF
! the ServoDyn inputs from Simulink are for t, not t+dt, so we're going to overwrite the inputs from
! the previous step before we extrapolate these inputs:
IF ( p_FAST%CompServo == Module_SrvD ) CALL SrvD_SetExternalInputs( p_FAST, m_FAST, SrvD%Input(1) )
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! ## Step 1.a: Extrapolate Inputs
!!
!! gives predicted values at t+dt
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CALL FAST_ExtrapInterpMods( t_global_next, p_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
!! predictor-corrector loop:
j_pc = 0
do while (j_pc <= NumCorrections)
WriteThisStep = y_FAST%WriteThisStep .AND. j_pc==NumCorrections
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! ## Step 1.b: Advance states (yield state and constraint values at t_global_next)
!!
!! STATE_CURR values of x, xd, z, and OtherSt contain values at m_FAST%t_global;
!! STATE_PRED values contain values at t_global_next.
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CALL FAST_AdvanceStates( t_initial, n_t_global, p_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2, WriteThisStep )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! ## Step 1.c: Input-Output Solve
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! save predicted inputs for comparison with corrected value later
!IF (p_FAST%CheckHSSBrTrqC) THEN
! ControlInputGuess = ED%Input(1)%HSSBrTrqC
!END IF
CALL CalcOutputs_And_SolveForInputs( n_t_global, t_global_next, STATE_PRED, m_FAST%calcJacobian, m_FAST%NextJacCalcTime, &
p_FAST, m_FAST, WriteThisStep, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! ## Step 2: Correct (continue in loop)
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
j_pc = j_pc + 1
! ! Check if the predicted inputs were significantly different than the corrected inputs
! ! (values before and after CalcOutputs_And_SolveForInputs)
!if (j_pc > NumCorrections) then
!
! !if (p_FAST%CheckHSSBrTrqC) then
! ! if ( abs(ControlInputGuess - ED%Input(1)%HSSBrTrqC) > 50.0_ReKi ) then ! I randomly picked 50 N-m
! ! NumCorrections = min(p_FAST%NumCrctn + 1, MaxCorrections)
! ! ! print *, 'correction:', t_global_next, NumCorrections
! ! cycle
! ! end if
! !end if
!
! ! check pitch position input to structural code (not implemented, yet)
!end if
enddo ! j_pc
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! ## Step 3: Save all final variables (advance to next time)
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!----------------------------------------------------------------------------------------
!! copy the final predicted states from step t_global_next to actual states for that step
!----------------------------------------------------------------------------------------
! ElastoDyn: copy final predictions to actual states
CALL ED_CopyContState (ED%x( STATE_PRED), ED%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyDiscState (ED%xd(STATE_PRED), ED%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyConstrState (ED%z( STATE_PRED), ED%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ED_CopyOtherState (ED%OtherSt( STATE_PRED), ED%OtherSt( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! BeamDyn: copy final predictions to actual states
IF ( p_FAST%CompElast == Module_BD ) THEN
DO k=1,p_FAST%nBeams
CALL BD_CopyContState (BD%x( k,STATE_PRED), BD%x( k,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyDiscState (BD%xd(k,STATE_PRED), BD%xd(k,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyConstrState (BD%z( k,STATE_PRED), BD%z( k,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL BD_CopyOtherState (BD%OtherSt( k,STATE_PRED), BD%OtherSt( k,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
END IF
! AeroDyn: copy final predictions to actual states; copy current outputs to next
IF ( p_FAST%CompAero == Module_AD14 ) THEN
CALL AD14_CopyContState (AD14%x( STATE_PRED), AD14%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyDiscState (AD14%xd(STATE_PRED), AD14%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyConstrState (AD14%z( STATE_PRED), AD14%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD14_CopyOtherState (AD14%OtherSt(STATE_PRED), AD14%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
CALL AD_CopyContState (AD%x( STATE_PRED), AD%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyDiscState (AD%xd(STATE_PRED), AD%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyConstrState (AD%z( STATE_PRED), AD%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL AD_CopyOtherState (AD%OtherSt(STATE_PRED), AD%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! InflowWind: copy final predictions to actual states; copy current outputs to next
IF ( p_FAST%CompInflow == Module_IfW ) THEN
CALL InflowWind_CopyContState (IfW%x( STATE_PRED), IfW%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyDiscState (IfW%xd(STATE_PRED), IfW%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyConstrState (IfW%z( STATE_PRED), IfW%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL InflowWind_CopyOtherState (IfW%OtherSt( STATE_PRED), IfW%OtherSt( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! ServoDyn: copy final predictions to actual states; copy current outputs to next
IF ( p_FAST%CompServo == Module_SrvD ) THEN
CALL SrvD_CopyContState (SrvD%x( STATE_PRED), SrvD%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyDiscState (SrvD%xd(STATE_PRED), SrvD%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyConstrState (SrvD%z( STATE_PRED), SrvD%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SrvD_CopyOtherState (SrvD%OtherSt( STATE_PRED), SrvD%OtherSt( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! HydroDyn: copy final predictions to actual states
IF ( p_FAST%CompHydro == Module_HD ) THEN
CALL HydroDyn_CopyContState (HD%x( STATE_PRED), HD%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyDiscState (HD%xd(STATE_PRED), HD%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyConstrState (HD%z( STATE_PRED), HD%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL HydroDyn_CopyOtherState (HD%OtherSt(STATE_PRED), HD%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! SubDyn: copy final predictions to actual states
IF ( p_FAST%CompSub == Module_SD ) THEN
CALL SD_CopyContState (SD%x( STATE_PRED), SD%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyDiscState (SD%xd(STATE_PRED), SD%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyConstrState (SD%z( STATE_PRED), SD%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL SD_CopyOtherState (SD%OtherSt(STATE_PRED), SD%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSE IF ( p_FAST%CompSub == Module_ExtPtfm ) THEN
CALL ExtPtfm_CopyContState (ExtPtfm%x( STATE_PRED), ExtPtfm%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyDiscState (ExtPtfm%xd(STATE_PRED), ExtPtfm%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyConstrState (ExtPtfm%z( STATE_PRED), ExtPtfm%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ExtPtfm_CopyOtherState (ExtPtfm%OtherSt(STATE_PRED), ExtPtfm%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! MAP: copy final predictions to actual states
IF (p_FAST%CompMooring == Module_MAP) THEN
CALL MAP_CopyContState (MAPp%x( STATE_PRED), MAPp%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MAP_CopyDiscState (MAPp%xd(STATE_PRED), MAPp%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MAP_CopyConstrState (MAPp%z( STATE_PRED), MAPp%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
!CALL MAP_CopyOtherState (MAPp%OtherSt(STATE_PRED), MAPp%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
! CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompMooring == Module_MD) THEN
CALL MD_CopyContState (MD%x( STATE_PRED), MD%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyDiscState (MD%xd(STATE_PRED), MD%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyConstrState (MD%z( STATE_PRED), MD%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL MD_CopyOtherState (MD%OtherSt(STATE_PRED), MD%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompMooring == Module_FEAM) THEN
CALL FEAM_CopyContState (FEAM%x( STATE_PRED), FEAM%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyDiscState (FEAM%xd(STATE_PRED), FEAM%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyConstrState (FEAM%z( STATE_PRED), FEAM%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL FEAM_CopyOtherState (FEAM%OtherSt( STATE_PRED), FEAM%OtherSt( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF (p_FAST%CompMooring == Module_Orca) THEN
CALL Orca_CopyContState (Orca%x( STATE_PRED), Orca%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyDiscState (Orca%xd(STATE_PRED), Orca%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyConstrState (Orca%z( STATE_PRED), Orca%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL Orca_CopyOtherState (Orca%OtherSt( STATE_PRED), Orca%OtherSt( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! IceFloe: copy final predictions to actual states
IF ( p_FAST%CompIce == Module_IceF ) THEN
CALL IceFloe_CopyContState (IceF%x( STATE_PRED), IceF%x( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyDiscState (IceF%xd(STATE_PRED), IceF%xd(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyConstrState (IceF%z( STATE_PRED), IceF%z( STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceFloe_CopyOtherState (IceF%OtherSt(STATE_PRED), IceF%OtherSt(STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ELSEIF ( p_FAST%CompIce == Module_IceD ) THEN
DO i=1,p_FAST%numIceLegs
CALL IceD_CopyContState (IceD%x( i,STATE_PRED), IceD%x( i,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyDiscState (IceD%xd(i,STATE_PRED), IceD%xd(i,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyConstrState (IceD%z( i,STATE_PRED), IceD%z( i,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL IceD_CopyOtherState (IceD%OtherSt( i,STATE_PRED), IceD%OtherSt( i,STATE_CURR), MESH_UPDATECOPY, Errstat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
END IF
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! We've advanced everything to the next time step:
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!! update the global time
m_FAST%t_global = t_global_next
!----------------------------------------------------------------------------------------
!! Check to see if we should output data this time step:
!----------------------------------------------------------------------------------------
CALL WriteOutputToFile(n_t_global_next, t_global_next, p_FAST, y_FAST, ED, BD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
SrvD, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
!----------------------------------------------------------------------------------------
!! Display simulation status every SttsTime-seconds (i.e., n_SttsTime steps):
!----------------------------------------------------------------------------------------
IF (p_FAST%WrSttsTime) then
IF ( MOD( n_t_global_next, p_FAST%n_SttsTime ) == 0 ) THEN
CALL SimStatus( m_FAST%TiLstPrn, m_FAST%PrevClockTime, m_FAST%t_global, p_FAST%TMax, p_FAST%TDesc )
ENDIF
ENDIF
END SUBROUTINE FAST_Solution
!----------------------------------------------------------------------------------------------------------------------------------
! ROUTINES TO OUTPUT WRITE DATA TO FILE AT EACH REQUSTED TIME STEP
!----------------------------------------------------------------------------------------------------------------------------------
FUNCTION NeedWriteOutput(n_t_global, t_global, p_FAST)
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< Current global time step
REAL(DbKi), INTENT(IN ) :: t_global !< Current global time
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
LOGICAL :: NeedWriteOutput !< Function result; if true, WriteOutput values are needed on this time step
IF ( t_global >= p_FAST%TStart ) THEN ! note that if TStart isn't an multiple of DT_out, we will not necessarially start output to the file at TStart
NeedWriteOutput = MOD( n_t_global, p_FAST%n_DT_Out ) == 0
ELSE
NeedWriteOutput = .FALSE.
END IF
END FUNCTION NeedWriteOutput
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine determines if it's time to write to the output files--based on a previous call to fast_subs::needwriteoutput--, and
!! calls the routine to write to the files with the output data. It should be called after all the output solves for a given time
!! have been completed, and assumes y_FAST\%WriteThisStep has been set.
SUBROUTINE WriteOutputToFile(n_t_global, t_global, p_FAST, y_FAST, ED, BD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
SrvD, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat, ErrMsg)
!...............................................................................................................................
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< Current global time step
REAL(DbKi), INTENT(IN ) :: t_global !< Current global time
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(IN ) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(IN ) :: AD14 !< AeroDyn14 data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(IN ) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(IN ) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(IN ) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(IN ) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(IN ) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(IN ) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(IN ) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(IN ) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(IN ) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(IN ) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(IN ) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
CHARACTER(*), PARAMETER :: RoutineName = 'WriteOutputToFile'
ErrStat = ErrID_None
ErrMsg = ""
! Write time-series channel data
!y_FAST%WriteThisStep = NeedWriteOutput(n_t_global, t_global, p_FAST)
IF ( y_FAST%WriteThisStep ) THEN
! Generate glue-code output file
if (allocated(AD%y%rotors)) then
CALL WrOutputLine( t_global, p_FAST, y_FAST, IfW%y%WriteOutput, OpFM%y%WriteOutput, ED%y%WriteOutput, &
AD%y%rotors(1)%WriteOutput, SrvD%y%WriteOutput, HD%y%WriteOutput, SD%y%WriteOutput, ExtPtfm%y%WriteOutput, MAPp%y%WriteOutput, &
FEAM%y%WriteOutput, MD%y%WriteOutput, Orca%y%WriteOutput, IceF%y%WriteOutput, IceD%y, BD%y, ErrStat, ErrMsg )
else
CALL WrOutputLine( t_global, p_FAST, y_FAST, IfW%y%WriteOutput, OpFM%y%WriteOutput, ED%y%WriteOutput, &
(/0.0_ReKi/), SrvD%y%WriteOutput, HD%y%WriteOutput, SD%y%WriteOutput, ExtPtfm%y%WriteOutput, MAPp%y%WriteOutput, &
FEAM%y%WriteOutput, MD%y%WriteOutput, Orca%y%WriteOutput, IceF%y%WriteOutput, IceD%y, BD%y, ErrStat, ErrMsg )
endif
ENDIF
! Write visualization data (and also note that we're ignoring any errors that occur doing so)
IF ( p_FAST%WrVTK == VTK_Animate ) THEN
IF ( MOD( n_t_global, p_FAST%n_VTKTime ) == 0 ) THEN
call WriteVTK(t_global, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
END IF
END IF
END SUBROUTINE WriteOutputToFile
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes the module output to the primary output file(s).
SUBROUTINE WrOutputLine( t, p_FAST, y_FAST, IfWOutput, OpFMOutput, EDOutput, ADOutput, SrvDOutput, HDOutput, SDOutput, ExtPtfmOutput,&
MAPOutput, FEAMOutput, MDOutput, OrcaOutput, IceFOutput, y_IceD, y_BD, ErrStat, ErrMsg)
IMPLICIT NONE
! Passed variables
REAL(DbKi), INTENT(IN) :: t !< Current simulation time, in seconds
TYPE(FAST_ParameterType), INTENT(IN) :: p_FAST !< Glue-code simulation parameters
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Glue-code simulation outputs
REAL(ReKi), INTENT(IN) :: IfWOutput (:) !< InflowWind WriteOutput values
REAL(ReKi), INTENT(IN) :: OpFMOutput (:) !< OpenFOAM WriteOutput values
REAL(ReKi), INTENT(IN) :: EDOutput (:) !< ElastoDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: ADOutput (:) !< AeroDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: SrvDOutput (:) !< ServoDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: HDOutput (:) !< HydroDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: SDOutput (:) !< SubDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: ExtPtfmOutput (:) !< ExtPtfm_MCKF WriteOutput values
REAL(ReKi), INTENT(IN) :: MAPOutput (:) !< MAP WriteOutput values
REAL(ReKi), INTENT(IN) :: FEAMOutput (:) !< FEAMooring WriteOutput values
REAL(ReKi), INTENT(IN) :: MDOutput (:) !< MoorDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: OrcaOutput (:) !< OrcaFlex interface WriteOutput values
REAL(ReKi), INTENT(IN) :: IceFOutput (:) !< IceFloe WriteOutput values
TYPE(IceD_OutputType), INTENT(IN) :: y_IceD (:) !< IceDyn outputs (WriteOutput values are subset)
TYPE(BD_OutputType), INTENT(IN) :: y_BD (:) !< BeamDyn outputs (WriteOutput values are subset)
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Error message
! Local variables.
CHARACTER(200) :: Frmt ! A string to hold a format specifier
CHARACTER(p_FAST%TChanLen) :: TmpStr ! temporary string to print the time output as text
REAL(ReKi) :: OutputAry(SIZE(y_FAST%ChannelNames)-1)
ErrStat = ErrID_None
ErrMsg = ''
CALL FillOutputAry(p_FAST, y_FAST, IfWOutput, OpFMOutput, EDOutput, ADOutput, SrvDOutput, HDOutput, SDOutput, ExtPtfmOutput, &
MAPOutput, FEAMOutput, MDOutput, OrcaOutput, IceFOutput, y_IceD, y_BD, OutputAry)
IF (p_FAST%WrTxtOutFile) THEN
! Write one line of tabular output:
! Frmt = '(F8.3,'//TRIM(Num2LStr(p%NumOuts))//'(:,A,'//TRIM( p%OutFmt )//'))'
Frmt = '"'//p_FAST%Delim//'"'//p_FAST%OutFmt ! format for array elements from individual modules
! time
WRITE( TmpStr, '('//trim(p_FAST%OutFmt_t)//')' ) t
CALL WrFileNR( y_FAST%UnOu, TmpStr )
! write the individual module output (convert to SiKi if necessary, so that we don't need to print so many digits in the exponent)
CALL WrNumAryFileNR ( y_FAST%UnOu, REAL(OutputAry,SiKi), Frmt, ErrStat, ErrMsg )
!IF ( ErrStat >= AbortErrLev ) RETURN
! write a new line (advance to the next line)
WRITE (y_FAST%UnOu,'()')
END IF
IF (p_FAST%WrBinOutFile) THEN
! Write data to array for binary output file
IF ( y_FAST%n_Out == y_FAST%NOutSteps ) THEN
ErrStat = ErrID_Warn
ErrMsg = 'Not all data could be written to the binary output file.'
!CALL ProgWarn( 'Not all data could be written to the binary output file.' )
!this really would only happen if we have an error somewhere else, right?
!otherwise, we could allocate a new, larger array and move existing data
ELSE
y_FAST%n_Out = y_FAST%n_Out + 1
! store time data
IF ( y_FAST%n_Out == 1_IntKi .OR. p_FAST%WrBinMod == FileFmtID_WithTime ) THEN
y_FAST%TimeData(y_FAST%n_Out) = t ! Time associated with these outputs
END IF
! store individual module data
y_FAST%AllOutData(:, y_FAST%n_Out) = OutputAry
END IF
END IF
RETURN
END SUBROUTINE WrOutputLine
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls FillOutputAry for one instance of a Turbine data structure. This is a separate subroutine so that the FAST
!! driver programs do not need to change or operate on the individual module level. (Called from Simulink interface.)
SUBROUTINE FillOutputAry_T(Turbine, Outputs)
TYPE(FAST_TurbineType), INTENT(IN ) :: Turbine !< all data for one instance of a turbine
REAL(ReKi), INTENT( OUT) :: Outputs(:) !< single array of output
CALL FillOutputAry(Turbine%p_FAST, Turbine%y_FAST, Turbine%IfW%y%WriteOutput, Turbine%OpFM%y%WriteOutput, &
Turbine%ED%y%WriteOutput, Turbine%AD%y%rotors(1)%WriteOutput, Turbine%SrvD%y%WriteOutput, &
Turbine%HD%y%WriteOutput, Turbine%SD%y%WriteOutput, Turbine%ExtPtfm%y%WriteOutput, Turbine%MAP%y%WriteOutput, &
Turbine%FEAM%y%WriteOutput, Turbine%MD%y%WriteOutput, Turbine%Orca%y%WriteOutput, &
Turbine%IceF%y%WriteOutput, Turbine%IceD%y, Turbine%BD%y, Outputs)
END SUBROUTINE FillOutputAry_T
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine concatenates all of the WriteOutput values from the module Output into one array to be written to the FAST
!! output file.
SUBROUTINE FillOutputAry(p_FAST, y_FAST, IfWOutput, OpFMOutput, EDOutput, ADOutput, SrvDOutput, HDOutput, SDOutput, ExtPtfmOutput, &
MAPOutput, FEAMOutput, MDOutput, OrcaOutput, IceFOutput, y_IceD, y_BD, OutputAry)
TYPE(FAST_ParameterType), INTENT(IN) :: p_FAST !< Glue-code simulation parameters
TYPE(FAST_OutputFileType),INTENT(IN) :: y_FAST !< Glue-code simulation outputs
REAL(ReKi), INTENT(IN) :: IfWOutput (:) !< InflowWind WriteOutput values
REAL(ReKi), INTENT(IN) :: OpFMOutput (:) !< OpenFOAM WriteOutput values
REAL(ReKi), INTENT(IN) :: EDOutput (:) !< ElastoDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: ADOutput (:) !< AeroDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: SrvDOutput (:) !< ServoDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: HDOutput (:) !< HydroDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: SDOutput (:) !< SubDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: ExtPtfmOutput (:) !< ExtPtfm_MCKF WriteOutput values
REAL(ReKi), INTENT(IN) :: MAPOutput (:) !< MAP WriteOutput values
REAL(ReKi), INTENT(IN) :: FEAMOutput (:) !< FEAMooring WriteOutput values
REAL(ReKi), INTENT(IN) :: MDOutput (:) !< MoorDyn WriteOutput values
REAL(ReKi), INTENT(IN) :: OrcaOutput (:) !< OrcaFlex interface WriteOutput values
REAL(ReKi), INTENT(IN) :: IceFOutput (:) !< IceFloe WriteOutput values
TYPE(IceD_OutputType), INTENT(IN) :: y_IceD (:) !< IceDyn outputs (WriteOutput values are subset)
TYPE(BD_OutputType), INTENT(IN) :: y_BD (:) !< BeamDyn outputs (WriteOutput values are subset)
REAL(ReKi), INTENT(OUT) :: OutputAry(:) !< single array of output
INTEGER(IntKi) :: i ! loop counter
INTEGER(IntKi) :: indxLast ! The index of the last row value to be written to AllOutData for this time step (column).
INTEGER(IntKi) :: indxNext ! The index of the next row value to be written to AllOutData for this time step (column).
! store individual module data into one array for output
indxLast = 0
indxNext = 1
IF (y_FAST%numOuts(Module_Glue) > 1) THEN ! if we output more than just the time channel....
indxLast = indxNext + SIZE(y_FAST%DriverWriteOutput) - 1
OutputAry(indxNext:indxLast) = y_FAST%DriverWriteOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_IfW) > 0 ) THEN
indxLast = indxNext + SIZE(IfWOutput) - 1
OutputAry(indxNext:indxLast) = IfWOutput
indxNext = IndxLast + 1
ELSEIF ( y_FAST%numOuts(Module_OpFM) > 0 ) THEN
indxLast = indxNext + SIZE(OpFMOutput) - 1
OutputAry(indxNext:indxLast) = OpFMOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_ED) > 0 ) THEN
indxLast = indxNext + SIZE(EDOutput) - 1
OutputAry(indxNext:indxLast) = EDOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_BD) > 0 ) THEN
do i=1,SIZE(y_BD)
indxLast = indxNext + SIZE(y_BD(i)%WriteOutput) - 1
OutputAry(indxNext:indxLast) = y_BD(i)%WriteOutput
indxNext = IndxLast + 1
end do
END IF
IF ( y_FAST%numOuts(Module_AD) > 0 ) THEN
indxLast = indxNext + SIZE(ADOutput) - 1
OutputAry(indxNext:indxLast) = ADOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_SrvD) > 0 ) THEN
indxLast = indxNext + SIZE(SrvDOutput) - 1
OutputAry(indxNext:indxLast) = SrvDOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_HD) > 0 ) THEN
indxLast = indxNext + SIZE(HDOutput) - 1
OutputAry(indxNext:indxLast) = HDOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_SD) > 0 ) THEN
indxLast = indxNext + SIZE(SDOutput) - 1
OutputAry(indxNext:indxLast) = SDOutput
indxNext = IndxLast + 1
ELSE IF ( y_FAST%numOuts(Module_ExtPtfm) > 0 ) THEN
indxLast = indxNext + SIZE(ExtPtfmOutput) - 1
OutputAry(indxNext:indxLast) = ExtPtfmOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_MAP) > 0 ) THEN
indxLast = indxNext + SIZE(MAPOutput) - 1
OutputAry(indxNext:indxLast) = MAPOutput
indxNext = IndxLast + 1
ELSEIF ( y_FAST%numOuts(Module_MD) > 0 ) THEN
indxLast = indxNext + SIZE(MDOutput) - 1
OutputAry(indxNext:indxLast) = MDOutput
indxNext = IndxLast + 1
ELSEIF ( y_FAST%numOuts(Module_FEAM) > 0 ) THEN
indxLast = indxNext + SIZE(FEAMOutput) - 1
OutputAry(indxNext:indxLast) = FEAMOutput
indxNext = IndxLast + 1
ELSEIF ( y_FAST%numOuts(Module_Orca) > 0 ) THEN
indxLast = indxNext + SIZE(OrcaOutput) - 1
OutputAry(indxNext:indxLast) = OrcaOutput
indxNext = IndxLast + 1
END IF
IF ( y_FAST%numOuts(Module_IceF) > 0 ) THEN
indxLast = indxNext + SIZE(IceFOutput) - 1
OutputAry(indxNext:indxLast) = IceFOutput
indxNext = IndxLast + 1
ELSEIF ( y_FAST%numOuts(Module_IceD) > 0 ) THEN
DO i=1,p_FAST%numIceLegs
indxLast = indxNext + SIZE(y_IceD(i)%WriteOutput) - 1
OutputAry(indxNext:indxLast) = y_IceD(i)%WriteOutput
indxNext = IndxLast + 1
END DO
END IF
END SUBROUTINE FillOutputAry
!----------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE WriteVTK(t_global, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
REAL(DbKi), INTENT(IN ) :: t_global !< Current global time
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code (only because we're updating VTK_LastWaveIndx)
TYPE(FAST_ModuleMapType), INTENT(IN ) :: MeshMapData !< Data for mapping between modules
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(IN ) :: SrvD !< ServoDyn data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(IN ) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(IN ) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(IN ) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(IN ) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(IN ) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(IN ) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(IN ) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(IN ) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(IN ) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(IN ) :: IceD !< All the IceDyn data used in time-step loop
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMSg2
CHARACTER(*), PARAMETER :: RoutineName = 'WriteVTK'
IF ( p_FAST%VTK_Type == VTK_Surf ) THEN
CALL WrVTK_Surfaces(t_global, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
ELSE IF ( p_FAST%VTK_Type == VTK_Basic ) THEN
CALL WrVTK_BasicMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
ELSE IF ( p_FAST%VTK_Type == VTK_All ) THEN
CALL WrVTK_AllMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
ELSE IF (p_FAST%VTK_Type==VTK_Old) THEN
CALL WriteInputMeshesToFile( ED%Input(1), AD%Input(1), SD%Input(1), HD%Input(1), MAPp%Input(1), BD%Input(1,:), TRIM(p_FAST%OutFileRoot)//'.InputMeshes.bin', ErrStat2, ErrMsg2)
CALL WriteMotionMeshesToFile(t_global, ED%y, SD%Input(1), SD%y, HD%Input(1), MAPp%Input(1), BD%y, BD%Input(1,:), y_FAST%UnGra, ErrStat2, ErrMsg2, TRIM(p_FAST%OutFileRoot)//'.gra')
!unOut = -1
!CALL MeshWrBin ( unOut, AD%y%BladeLoad(2), ErrStat2, ErrMsg2, 'AD_2_ED_loads.bin'); IF (ErrStat2 /= ErrID_None) CALL WrScr(TRIM(ErrMsg2))
!CALL MeshWrBin ( unOut, ED%Input(1)%BladePtLoads(2),ErrStat2, ErrMsg2, 'AD_2_ED_loads.bin'); IF (ErrStat2 /= ErrID_None) CALL WrScr(TRIM(ErrMsg2))
!CALL MeshMapWrBin( unOut, AD%y%BladeLoad(2), ED%Input(1)%BladePtLoads(2), MeshMapData%AD_L_2_BDED_B(2), ErrStat2, ErrMsg2, 'AD_2_ED_loads.bin' ); IF (ErrStat2 /= ErrID_None) CALL WrScr(TRIM(ErrMsg2))
!close( unOut )
END IF
y_FAST%VTK_count = y_FAST%VTK_count + 1
END SUBROUTINE WriteVTK
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes all the committed meshes to VTK-formatted files. It doesn't bother with returning an error code.
SUBROUTINE WrVTK_AllMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
use FVW_IO, only: WrVTK_FVW
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(IN ) :: y_FAST !< Output variables for the glue code
TYPE(FAST_ModuleMapType), INTENT(IN ) :: MeshMapData !< Data for mapping between modules
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(IN ) :: SrvD !< ServoDyn data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(IN ) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(IN ) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(IN ) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(IN ) :: ExtPtfm !< ExtPtfm data
TYPE(MAP_Data), INTENT(IN ) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(IN ) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(IN ) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(IN ) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(IN ) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(IN ) :: IceD !< All the IceDyn data used in time-step loop
logical :: outputFields ! flag to determine if we want to output the HD mesh fields
INTEGER(IntKi) :: NumBl, k
INTEGER(IntKi) :: j ! counter for StC instance at location
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMSg2
CHARACTER(*), PARAMETER :: RoutineName = 'WrVTK_AllMeshes'
NumBl = 0
if (allocated(ED%y%BladeRootMotion)) then
NumBl = SIZE(ED%y%BladeRootMotion)
end if
! I'm first going to just put all of the meshes that get mapped together, then decide if we're going to print/plot them all
! ElastoDyn
if (allocated(ED%Input)) then
! ElastoDyn outputs (motions)
DO K=1,NumBl
!%BladeLn2Mesh(K) used only when not BD (see below)
call MeshWrVTK(p_FAST%TurbinePos, ED%y%BladeRootMotion(K), trim(p_FAST%VTK_OutFileRoot)//'.ED_BladeRootMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
END DO
call MeshWrVTK(p_FAST%TurbinePos, ED%y%TowerLn2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_TowerLn2Mesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! these will get output with their sibling input meshes
!call MeshWrVTK(p_FAST%TurbinePos, ED%y%HubPtMotion, trim(p_FAST%VTK_OutFileRoot)//'.ED_HubPtMotion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
!call MeshWrVTK(p_FAST%TurbinePos, ED%y%NacelleMotion, trim(p_FAST%VTK_OutFileRoot)//'.ED_NacelleMotion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
!call MeshWrVTK(p_FAST%TurbinePos, ED%y%PlatformPtMesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_PlatformPtMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! ElastoDyn inputs (loads)
! %BladePtLoads used only when not BD (see below)
call MeshWrVTK(p_FAST%TurbinePos, ED%Input(1)%TowerPtLoads, trim(p_FAST%VTK_OutFileRoot)//'.ED_TowerPtLoads', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ED%y%TowerLn2Mesh )
call MeshWrVTK(p_FAST%TurbinePos, ED%Input(1)%HubPtLoad, trim(p_FAST%VTK_OutFileRoot)//'.ED_Hub', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ED%y%HubPtMotion )
call MeshWrVTK(p_FAST%TurbinePos, ED%Input(1)%NacelleLoads, trim(p_FAST%VTK_OutFileRoot)//'.ED_Nacelle' ,y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ED%y%NacelleMotion )
call MeshWrVTK(p_FAST%TurbinePos, ED%Input(1)%PlatformPtMesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_PlatformPtMesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ED%y%PlatformPtMesh )
end if
! BeamDyn
IF ( p_FAST%CompElast == Module_BD .and. allocated(BD%Input) .and. allocated(BD%y)) THEN
do K=1,NumBl
! BeamDyn inputs
!call MeshWrVTK(p_FAST%TurbinePos, BD%Input(1,k)%RootMotion, trim(p_FAST%VTK_OutFileRoot)//'.BD_RootMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, BD%Input(1,k)%HubMotion, trim(p_FAST%VTK_OutFileRoot)//'.BD_HubMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end do
if (allocated(MeshMapData%y_BD_BldMotion_4Loads)) then
do K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, BD%Input(1,k)%DistrLoad, trim(p_FAST%VTK_OutFileRoot)//'.BD_DistrLoad'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, MeshMapData%y_BD_BldMotion_4Loads(k) )
! skipping PointLoad
end do
elseif (p_FAST%BD_OutputSibling) then
do K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, BD%Input(1,k)%DistrLoad, trim(p_FAST%VTK_OutFileRoot)//'.BD_Blade'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, BD%y(k)%BldMotion )
! skipping PointLoad
end do
end if
do K=1,NumBl
! BeamDyn outputs
call MeshWrVTK(p_FAST%TurbinePos, BD%y(k)%ReactionForce, trim(p_FAST%VTK_OutFileRoot)//'.BD_ReactionForce_RootMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, BD%Input(1,k)%RootMotion )
end do
if (.not. p_FAST%BD_OutputSibling) then !otherwise this mesh has been put with the DistrLoad mesh
do K=1,NumBl
! BeamDyn outputs
call MeshWrVTK(p_FAST%TurbinePos, BD%y(k)%BldMotion, trim(p_FAST%VTK_OutFileRoot)//'.BD_BldMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end do
end if
ELSE if (p_FAST%CompElast == Module_ED .and. allocated(ED%Input)) then
! ElastoDyn
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, ED%y%BladeLn2Mesh(K), trim(p_FAST%VTK_OutFileRoot)//'.ED_BladeLn2Mesh_motion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, ED%Input(1)%BladePtLoads(K), trim(p_FAST%VTK_OutFileRoot)//'.ED_BladePtLoads'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ED%y%BladeLn2Mesh(K) )
END DO
END IF
! ServoDyn
if (allocated(SrvD%Input)) then
IF ( ALLOCATED(SrvD%Input(1)%NStC) ) THEN
do j=1,size(SrvD%Input(1)%NStC)
IF ( ALLOCATED(SrvD%Input(1)%NStC(j)%Mesh) ) THEN
IF ( SrvD%Input(1)%NStC(j)%Mesh(1)%Committed ) THEN
!call MeshWrVTK(p_FAST%TurbinePos, SrvD%Input(1)%NStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_NStC_Motion'//trim(num2lstr(j)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, SrvD%y%NStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_NStC'//trim(num2lstr(j)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SrvD%Input(1)%NStC(j)%Mesh(1) )
END IF
ENDIF
enddo
ENDIF
IF ( ALLOCATED(SrvD%Input(1)%TStC) ) THEN
do j=1,size(SrvD%Input(1)%TStC)
IF ( ALLOCATED(SrvD%Input(1)%TStC(j)%Mesh) ) THEN
IF ( SrvD%Input(1)%TStC(j)%Mesh(1)%Committed ) THEN
!call MeshWrVTK(p_FAST%TurbinePos, SrvD%Input(1)%TStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_TStC_Motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, SrvD%y%TStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_TStC'//trim(num2lstr(j)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SrvD%Input(1)%TStC(j)%Mesh(1) )
ENDIF
ENDIF
enddo
ENDIF
IF ( ALLOCATED(SrvD%Input(1)%BStC) ) THEN
do j=1,size(SrvD%Input(1)%BStC)
IF ( ALLOCATED(SrvD%Input(1)%BStC(j)%Mesh) ) THEN
DO K=1,size(SrvD%Input(1)%BStC(j)%Mesh)
!call MeshWrVTK(p_FAST%TurbinePos, SrvD%Input(1)%BStC(j)%Mesh(k), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_BStC_Motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, SrvD%y%BStC(j)%Mesh(k), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_BStC'//trim(num2lstr(j))//'B'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SrvD%Input(1)%BStC(j)%Mesh(k) )
ENDDO
END IF
enddo
ENDIF
IF ( ALLOCATED(SrvD%Input(1)%SStC) ) THEN
do j=1,size(SrvD%Input(1)%SStC)
IF ( ALLOCATED(SrvD%Input(1)%SStC(j)%Mesh) ) THEN
IF ( SrvD%Input(1)%SStC(j)%Mesh(1)%Committed ) THEN
!call MeshWrVTK(p_FAST%TurbinePos, SrvD%Input(1)%SStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_SStC_Motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, SrvD%y%SStC(j)%Mesh(1), trim(p_FAST%VTK_OutFileRoot)//'.SrvD_SStC'//trim(num2lstr(j)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SrvD%Input(1)%SStC(j)%Mesh(1) )
ENDIF
ENDIF
enddo
ENDIF
end if
! AeroDyn
IF ( p_FAST%CompAero == Module_AD .and. allocated(AD%Input)) THEN
if (allocated(AD%Input(1)%rotors(1)%BladeRootMotion)) then
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%rotors(1)%BladeRootMotion(K), trim(p_FAST%VTK_OutFileRoot)//'.AD_BladeRootMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
!call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%BladeMotion(K), trim(p_FAST%VTK_OutFileRoot)//'.AD_BladeMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
END DO
call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%rotors(1)%HubMotion, trim(p_FAST%VTK_OutFileRoot)//'.AD_HubMotion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
!call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%TowerMotion, trim(p_FAST%VTK_OutFileRoot)//'.AD_TowerMotion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, AD%y%rotors(1)%BladeLoad(K), trim(p_FAST%VTK_OutFileRoot)//'.AD_Blade'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, AD%Input(1)%rotors(1)%BladeMotion(k) )
END DO
call MeshWrVTK(p_FAST%TurbinePos, AD%y%rotors(1)%TowerLoad, trim(p_FAST%VTK_OutFileRoot)//'.AD_Tower', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, AD%Input(1)%rotors(1)%TowerMotion )
end if
! FVW submodule of AD15
if (allocated(AD%m%FVW_u)) then
if (allocated(AD%m%FVW_u(1)%WingsMesh)) then
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, AD%m%FVW_u(1)%WingsMesh(k), trim(p_FAST%VTK_OutFileRoot)//'.FVW_WingsMesh'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, AD%Input(1)%rotors(1)%BladeMotion(k) )
!call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%BladeMotion(K), trim(p_FAST%OutFileRoot)//'.AD_BladeMotion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2 )
END DO
! Free wake
call WrVTK_FVW(AD%p%FVW, AD%x(1)%FVW, AD%z(1)%FVW, AD%m%FVW, trim(p_FAST%VTK_OutFileRoot)//'.FVW', y_FAST%VTK_count, p_FAST%VTK_tWidth, bladeFrame=.FALSE.) ! bladeFrame==.FALSE. to output in global coords
end if
end if
END IF
! HydroDyn
IF ( p_FAST%CompHydro == Module_HD .and. allocated(HD%Input)) THEN
!TODO: Fix for Visualizaton GJH 4/23/20
!call MeshWrVTK(p_FAST%TurbinePos, HD%Input(1)%Mesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Mesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2 )
call MeshWrVTK(p_FAST%TurbinePos, HD%Input(1)%Morison%Mesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Morison_Motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
if (HD%y%WamitMesh%Committed) then
! if (p_FAST%CompSub == Module_NONE) then
!TODO call MeshWrVTK(p_FAST%TurbinePos, HD%y%WamitMesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Mesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, HD%Input(1)%WAMITMesh )
! outputFields = .false.
! else
call MeshWrVTK(p_FAST%TurbinePos, HD%y%WamitMesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Mesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, HD%Input(1)%WAMITMesh )
! outputFields = p_FAST%VTK_fields
! end if
endif
if (HD%y%Morison%Mesh%Committed) then
call MeshWrVTK(p_FAST%TurbinePos, HD%y%Morison%Mesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Morison', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, HD%Input(1)%Morison%Mesh )
endif
END IF
! SubDyn
IF ( p_FAST%CompSub == Module_SD .and. allocated(SD%Input)) THEN
!call MeshWrVTK(p_FAST%TurbinePos, SD%Input(1)%TPMesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_TPMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
call MeshWrVTK(p_FAST%TurbinePos, SD%Input(1)%LMesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_LMesh_y2Mesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SD%y%y2Mesh )
call MeshWrVTK(p_FAST%TurbinePos, SD%y%y1Mesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_y1Mesh_TPMesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, SD%Input(1)%TPMesh )
!call MeshWrVTK(p_FAST%TurbinePos, SD%y%y2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_y2Mesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
ELSE IF ( p_FAST%CompSub == Module_ExtPtfm .and. allocated(ExtPtfm%Input)) THEN
call MeshWrVTK(p_FAST%TurbinePos, ExtPtfm%y%PtfmMesh, trim(p_FAST%VTK_OutFileRoot)//'.ExtPtfm', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, ExtPtfm%Input(1)%PtfmMesh )
END IF
! MAP
IF ( p_FAST%CompMooring == Module_MAP ) THEN
if (allocated(MAPp%Input)) then
call MeshWrVTK(p_FAST%TurbinePos, MAPp%y%PtFairleadLoad, trim(p_FAST%VTK_OutFileRoot)//'.MAP_PtFairlead', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, MAPp%Input(1)%PtFairDisplacement )
!call MeshWrVTK(p_FAST%TurbinePos, MAPp%Input(1)%PtFairDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MAP_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end if
! MoorDyn
ELSEIF ( p_FAST%CompMooring == Module_MD ) THEN
if (allocated(MD%Input)) then
call MeshWrVTK(p_FAST%TurbinePos, MD%y%PtFairleadLoad, trim(p_FAST%VTK_OutFileRoot)//'.MD_PtFairlead', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, MD%Input(1)%PtFairleadDisplacement )
!call MeshWrVTK(p_FAST%TurbinePos, MD%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MD_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end if
! FEAMooring
ELSEIF ( p_FAST%CompMooring == Module_FEAM ) THEN
if (allocated(FEAM%Input)) then
call MeshWrVTK(p_FAST%TurbinePos, FEAM%y%PtFairleadLoad, trim(p_FAST%VTK_OutFileRoot)//'.FEAM_PtFairlead', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, FEAM%Input(1)%PtFairleadDisplacement )
!call MeshWrVTK(p_FAST%TurbinePos, FEAM%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.FEAM_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end if
! Orca
ELSEIF ( p_FAST%CompMooring == Module_Orca ) THEN
if (allocated(Orca%Input)) then
call MeshWrVTK(p_FAST%TurbinePos, Orca%y%PtfmMesh, trim(p_FAST%VTK_OutFileRoot)//'.Orca_PtfmMesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, Orca%Input(1)%PtfmMesh )
!call MeshWrVTK(p_FAST%TurbinePos, Orca%Input(1)%PtfmMesh, trim(p_FAST%VTK_OutFileRoot)//'.Orca_PtfmMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end if
END IF
! IceFloe
IF ( p_FAST%CompIce == Module_IceF ) THEN
if (allocated(IceF%Input)) then
call MeshWrVTK(p_FAST%TurbinePos, IceF%y%iceMesh, trim(p_FAST%VTK_OutFileRoot)//'.IceF_iceMesh', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, IceF%Input(1)%iceMesh )
!call MeshWrVTK(p_FAST%TurbinePos, IceF%Input(1)%iceMesh, trim(p_FAST%VTK_OutFileRoot)//'.IceF_iceMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
end if
! IceDyn
ELSEIF ( p_FAST%CompIce == Module_IceD ) THEN
if (allocated(IceD%Input)) then
DO k = 1,p_FAST%numIceLegs
call MeshWrVTK(p_FAST%TurbinePos, IceD%y(k)%PointMesh, trim(p_FAST%VTK_OutFileRoot)//'.IceD_PointMesh'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, IceD%Input(1,k)%PointMesh )
!call MeshWrVTK(p_FAST%TurbinePos, IceD%Input(1,k)%PointMesh, trim(p_FAST%VTK_OutFileRoot)//'.IceD_PointMesh_motion'//trim(num2lstr(k)), y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
END DO
end if
END IF
END SUBROUTINE WrVTK_AllMeshes
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes a minimal subset of meshes (enough to visualize the turbine) to VTK-formatted files. It doesn't bother with
!! returning an error code.
SUBROUTINE WrVTK_BasicMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(IN ) :: y_FAST !< Output variables for the glue code
TYPE(FAST_ModuleMapType), INTENT(IN ) :: MeshMapData !< Data for mapping between modules
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(IN ) :: SrvD !< ServoDyn data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(IN ) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(IN ) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(IN ) :: SD !< SubDyn data
TYPE(MAP_Data), INTENT(IN ) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(IN ) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(IN ) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(IN ) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(IN ) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(IN ) :: IceD !< All the IceDyn data used in time-step loop
logical :: OutputFields
INTEGER(IntKi) :: NumBl, k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMSg2
CHARACTER(*), PARAMETER :: RoutineName = 'WrVTK_BasicMeshes'
NumBl = 0
if (allocated(ED%y%BladeRootMotion)) then
NumBl = SIZE(ED%y%BladeRootMotion)
end if
! Blades
IF ( p_FAST%CompAero == Module_AD ) THEN ! These meshes may have airfoil data associated with nodes...
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, AD%Input(1)%rotors(1)%BladeMotion(K), trim(p_FAST%VTK_OutFileRoot)//'.AD_Blade'//trim(num2lstr(k)), &
y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, Sib=AD%y%rotors(1)%BladeLoad(K) )
END DO
ELSE IF ( p_FAST%CompElast == Module_BD ) THEN
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, BD%y(k)%BldMotion, trim(p_FAST%VTK_OutFileRoot)//'.BD_BldMotion'//trim(num2lstr(k)), &
y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
END DO
ELSE IF ( p_FAST%CompElast == Module_ED ) THEN
DO K=1,NumBl
call MeshWrVTK(p_FAST%TurbinePos, ED%y%BladeLn2Mesh(K), trim(p_FAST%VTK_OutFileRoot)//'.ED_BladeLn2Mesh_motion'//trim(num2lstr(k)), &
y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
END DO
END IF
! Nacelle
call MeshWrVTK(p_FAST%TurbinePos, ED%y%NacelleMotion, trim(p_FAST%VTK_OutFileRoot)//'.ED_Nacelle', y_FAST%VTK_count, &
p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, Sib=ED%Input(1)%NacelleLoads )
! Hub
call MeshWrVTK(p_FAST%TurbinePos, ED%y%HubPtMotion, trim(p_FAST%VTK_OutFileRoot)//'.ED_Hub', y_FAST%VTK_count, &
p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, Sib=ED%Input(1)%HubPtLoad )
! Tower motions
call MeshWrVTK(p_FAST%TurbinePos, ED%y%TowerLn2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_TowerLn2Mesh_motion', &
y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! Substructure
! call MeshWrVTK(p_FAST%TurbinePos, ED%y%PlatformPtMesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_PlatformPtMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! IF ( p_FAST%CompSub == Module_SD ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, SD%Input(1)%TPMesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_TPMesh_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! call MeshWrVTK(p_FAST%TurbinePos, SD%y%y2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_y2Mesh_motion', y_FAST%VTK_count, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! END IF
IF ( p_FAST%CompHydro == Module_HD ) THEN
if (p_FAST%CompSub == Module_NONE) then
call MeshWrVTK(p_FAST%TurbinePos, HD%y%WAMITMesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_AllHdroOrigin', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, HD%Input(1)%WAMITMesh )
outputFields = .false.
else
OutputFields = p_FAST%VTK_fields
end if
!TODO: Fix for Visualization GJH 4/23/20
call MeshWrVTK(p_FAST%TurbinePos, HD%Input(1)%Morison%Mesh, trim(p_FAST%VTK_OutFileRoot)//'.HD_Morison', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, Sib=HD%y%Morison%Mesh )
END IF
! Mooring Lines?
! IF ( p_FAST%CompMooring == Module_MAP ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, MAPp%Input(1)%PtFairDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MAP_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! ELSEIF ( p_FAST%CompMooring == Module_MD ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, MD%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MD_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! ELSEIF ( p_FAST%CompMooring == Module_FEAM ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, FEAM%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'FEAM_PtFair_motion', y_FAST%VTK_count, p_FAST%VTK_fields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth )
! END IF
END SUBROUTINE WrVTK_BasicMeshes
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes a minimal subset of meshes with surfaces to VTK-formatted files. It doesn't bother with
!! returning an error code.
SUBROUTINE WrVTK_Surfaces(t_global, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
use FVW_IO, only: WrVTK_FVW
REAL(DbKi), INTENT(IN ) :: t_global !< Current global time
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code (only because we're updating VTK_LastWaveIndx)
TYPE(FAST_ModuleMapType), INTENT(IN ) :: MeshMapData !< Data for mapping between modules
TYPE(ElastoDyn_Data), INTENT(IN ) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(IN ) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(IN ) :: SrvD !< ServoDyn data
TYPE(AeroDyn_Data), INTENT(IN ) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(IN ) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(IN ) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(IN ) :: SD !< SubDyn data
TYPE(MAP_Data), INTENT(IN ) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(IN ) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(IN ) :: MD !< MoorDyn data
TYPE(OrcaFlex_Data), INTENT(IN ) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(IN ) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(IN ) :: IceD !< All the IceDyn data used in time-step loop
logical, parameter :: OutputFields = .FALSE. ! due to confusion about what fields mean on a surface, we are going to just output the basic meshes if people ask for fields
INTEGER(IntKi) :: NumBl, k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMSg2
CHARACTER(*), PARAMETER :: RoutineName = 'WrVTK_Surfaces'
NumBl = 0
if (allocated(ED%y%BladeRootMotion)) then
NumBl = SIZE(ED%y%BladeRootMotion)
end if
! Ground (written at initialization)
! Wave elevation
if ( allocated( p_FAST%VTK_Surface%WaveElev ) ) call WrVTK_WaveElev( t_global, p_FAST, y_FAST, HD)
! Nacelle
call MeshWrVTK_PointSurface (p_FAST%TurbinePos, ED%y%NacelleMotion, trim(p_FAST%VTK_OutFileRoot)//'.NacelleSurface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth , verts = p_FAST%VTK_Surface%NacelleBox, Sib=ED%Input(1)%NacelleLoads )
! Hub
call MeshWrVTK_PointSurface (p_FAST%TurbinePos, ED%y%HubPtMotion, trim(p_FAST%VTK_OutFileRoot)//'.HubSurface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth , &
NumSegments=p_FAST%VTK_Surface%NumSectors, radius=p_FAST%VTK_Surface%HubRad, Sib=ED%Input(1)%HubPtLoad )
! Tower motions
call MeshWrVTK_Ln2Surface (p_FAST%TurbinePos, ED%y%TowerLn2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.TowerSurface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, p_FAST%VTK_Surface%NumSectors, p_FAST%VTK_Surface%TowerRad )
! Blades
IF ( p_FAST%CompAero == Module_AD ) THEN ! These meshes may have airfoil data associated with nodes...
DO K=1,NumBl
call MeshWrVTK_Ln2Surface (p_FAST%TurbinePos, AD%Input(1)%rotors(1)%BladeMotion(K), trim(p_FAST%VTK_OutFileRoot)//'.Blade'//trim(num2lstr(k))//'Surface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth , verts=p_FAST%VTK_Surface%BladeShape(K)%AirfoilCoords &
,Sib=AD%y%rotors(1)%BladeLoad(k) )
END DO
ELSE IF ( p_FAST%CompElast == Module_BD ) THEN
DO K=1,NumBl
call MeshWrVTK_Ln2Surface (p_FAST%TurbinePos, BD%y(k)%BldMotion, trim(p_FAST%VTK_OutFileRoot)//'.Blade'//trim(num2lstr(k))//'Surface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth , verts=p_FAST%VTK_Surface%BladeShape(K)%AirfoilCoords )
END DO
ELSE IF ( p_FAST%CompElast == Module_ED ) THEN
DO K=1,NumBl
call MeshWrVTK_Ln2Surface (p_FAST%TurbinePos, ED%y%BladeLn2Mesh(K), trim(p_FAST%VTK_OutFileRoot)//'.Blade'//trim(num2lstr(k))//'Surface', &
y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth , verts=p_FAST%VTK_Surface%BladeShape(K)%AirfoilCoords )
END DO
END IF
! Free wake
if (allocated(AD%m%FVW_u)) then
if (allocated(AD%m%FVW_u(1)%WingsMesh)) then
call WrVTK_FVW(AD%p%FVW, AD%x(1)%FVW, AD%z(1)%FVW, AD%m%FVW, trim(p_FAST%VTK_OutFileRoot)//'.FVW', y_FAST%VTK_count, p_FAST%VTK_tWidth, bladeFrame=.FALSE.) ! bladeFrame==.FALSE. to output in global coords
end if
end if
! Platform
! call MeshWrVTK_PointSurface (p_FAST%TurbinePos, ED%y%PlatformPtMesh, trim(p_FAST%VTK_OutFileRoot)//'.PlatformSurface', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, Radius = p_FAST%VTK_Surface%GroundRad )
! Substructure
! call MeshWrVTK(p_FAST%TurbinePos, ED%y%PlatformPtMesh, trim(p_FAST%VTK_OutFileRoot)//'.ED_PlatformPtMesh_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! IF ( p_FAST%CompSub == Module_SD ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, SD%Input(1)%TPMesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_TPMesh_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! call MeshWrVTK(p_FAST%TurbinePos, SD%y%y2Mesh, trim(p_FAST%VTK_OutFileRoot)//'.SD_y2Mesh_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! END IF
!TODO: Fix below section for new Morison GJH 4/23/20
!
!IF ( HD%Input(1)%Morison%Mesh%Committed ) THEN
! !if ( p_FAST%CompSub == Module_NONE ) then ! floating
! ! OutputFields = .false.
! !else
! ! OutputFields = p_FAST%VTK_fields
! !end if
!
! call MeshWrVTK_Ln2Surface (p_FAST%TurbinePos, HD%Input(1)%Morison%Mesh, trim(p_FAST%VTK_OutFileRoot)//'.MorisonSurface', &
! y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2, p_FAST%VTK_tWidth, p_FAST%VTK_Surface%NumSectors, &
! p_FAST%VTK_Surface%MorisonRad, Sib=HD%y%Morison%Mesh )
!END IF
! Mooring Lines?
! IF ( p_FAST%CompMooring == Module_MAP ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, MAPp%Input(1)%PtFairDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MAP_PtFair_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! ELSEIF ( p_FAST%CompMooring == Module_MD ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, MD%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'.MD_PtFair_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! ELSEIF ( p_FAST%CompMooring == Module_FEAM ) THEN
! call MeshWrVTK(p_FAST%TurbinePos, FEAM%Input(1)%PtFairleadDisplacement, trim(p_FAST%VTK_OutFileRoot)//'FEAM_PtFair_motion', y_FAST%VTK_count, OutputFields, ErrStat2, ErrMsg2 )
! END IF
if (p_FAST%VTK_fields) then
call WrVTK_BasicMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
end if
END SUBROUTINE WrVTK_Surfaces
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine writes the wave elevation data for a given time step
SUBROUTINE WrVTK_WaveElev(t_global, p_FAST, y_FAST, HD)
REAL(DbKi), INTENT(IN ) :: t_global !< Current global time
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(HydroDyn_Data), INTENT(IN ) :: HD !< HydroDyn data
! local variables
INTEGER(IntKi) :: Un ! fortran unit number
INTEGER(IntKi) :: n, iy, ix ! loop counters
REAL(SiKi) :: t
CHARACTER(1024) :: FileName
INTEGER(IntKi) :: NumberOfPoints
INTEGER(IntKi), parameter :: NumberOfLines = 0
INTEGER(IntKi) :: NumberOfPolys
CHARACTER(1024) :: Tstr
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*),PARAMETER :: RoutineName = 'WrVTK_WaveElev'
NumberOfPoints = size(p_FAST%VTK_surface%WaveElevXY,2)
! I'm going to make triangles for now. we should probably just make this a structured file at some point
NumberOfPolys = ( p_FAST%VTK_surface%NWaveElevPts(1) - 1 ) * &
( p_FAST%VTK_surface%NWaveElevPts(2) - 1 ) * 2
!.................................................................
! write the data that potentially changes each time step:
!.................................................................
! construct the string for the zero-padded VTK write-out step
write(Tstr, '(i' // trim(Num2LStr(p_FAST%VTK_tWidth)) //'.'// trim(Num2LStr(p_FAST%VTK_tWidth)) // ')') y_FAST%VTK_count
! PolyData (.vtp) - Serial vtkPolyData (unstructured) file
FileName = TRIM(p_FAST%VTK_OutFileRoot)//'.WaveSurface.'//TRIM(Tstr)//'.vtp'
call WrVTK_header( FileName, NumberOfPoints, NumberOfLines, NumberOfPolys, Un, ErrStat2, ErrMsg2 )
if (ErrStat2 >= AbortErrLev) return
! points (nodes, augmented with NumSegments):
WRITE(Un,'(A)') ' <Points>'
WRITE(Un,'(A)') ' <DataArray type="Float32" NumberOfComponents="3" format="ascii">'
! I'm not going to interpolate in time; I'm just going to get the index of the closest wave time value
t = REAL(t_global,SiKi)
call GetWaveElevIndx( t, HD%p%WaveTime, y_FAST%VTK_LastWaveIndx )
n = 1
do ix=1,p_FAST%VTK_surface%NWaveElevPts(1)
do iy=1,p_FAST%VTK_surface%NWaveElevPts(2)
WRITE(Un,VTK_AryFmt) p_FAST%VTK_surface%WaveElevXY(:,n), p_FAST%VTK_surface%WaveElev(y_FAST%VTK_LastWaveIndx,n)
n = n+1
end do
end do
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' </Points>'
WRITE(Un,'(A)') ' <Polys>'
WRITE(Un,'(A)') ' <DataArray type="Int32" Name="connectivity" format="ascii">'
do ix=1,p_FAST%VTK_surface%NWaveElevPts(1)-1
do iy=1,p_FAST%VTK_surface%NWaveElevPts(2)-1
n = p_FAST%VTK_surface%NWaveElevPts(1)*(ix-1)+iy - 1 ! points start at 0
WRITE(Un,'(3(i7))') n, n+1, n+p_FAST%VTK_surface%NWaveElevPts(2)
WRITE(Un,'(3(i7))') n+1, n+1+p_FAST%VTK_surface%NWaveElevPts(2), n+p_FAST%VTK_surface%NWaveElevPts(2)
end do
end do
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' <DataArray type="Int32" Name="offsets" format="ascii">'
do n=1,NumberOfPolys
WRITE(Un,'(i7)') 3*n
end do
WRITE(Un,'(A)') ' </DataArray>'
WRITE(Un,'(A)') ' </Polys>'
call WrVTK_footer( Un )
END SUBROUTINE WrVTK_WaveElev
!----------------------------------------------------------------------------------------------------------------------------------
!> This function returns the index, Ind, of the XAry closest to XValIn, where XAry is assumed to be periodic. It starts
!! searching at the value of Ind from a previous step.
SUBROUTINE GetWaveElevIndx( XValIn, XAry, Ind )
! Argument declarations.
INTEGER, INTENT(INOUT) :: Ind ! Initial and final index into the arrays.
REAL(SiKi), INTENT(IN) :: XAry (:) !< Array of X values to be interpolated.
REAL(SiKi), INTENT(IN) :: XValIn !< X value to be found
INTEGER :: AryLen ! Length of the arrays.
REAL(SiKi) :: XVal !< X to be found (wrapped/periodic)
AryLen = size(XAry)
! Wrap XValIn into the range XAry(1) to XAry(AryLen)
XVal = MOD(XValIn, XAry(AryLen))
! Let's check the limits first.
IF ( XVal <= XAry(1) ) THEN
Ind = 1
RETURN
ELSE IF ( XVal >= XAry(AryLen) ) THEN
Ind = AryLen
RETURN
ELSE
! Set the Ind to the first index if we are at the beginning of XAry
IF ( XVal <= XAry(2) ) THEN
Ind = 1
END IF
END IF
! Let's interpolate!
Ind = MAX( MIN( Ind, AryLen-1 ), 1 )
DO
IF ( XVal < XAry(Ind) ) THEN
Ind = Ind - 1
ELSE IF ( XVal >= XAry(Ind+1) ) THEN
Ind = Ind + 1
ELSE
! XAry(Ind) <= XVal < XAry(Ind+1)
! this would make it the "closest" node, but I'm not going to worry about that for visualization purposes
!if ( XVal > (XAry(Ind+1) + XAry(Ind))/2.0_SiKi ) Ind = Ind + 1
RETURN
END IF
END DO
RETURN
END SUBROUTINE GetWaveElevIndx
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes Input Mesh information to a binary file (for debugging). It both opens and closes the file.
SUBROUTINE WriteInputMeshesToFile(u_ED, u_AD, u_SD, u_HD, u_MAP, u_BD, FileName, ErrStat, ErrMsg)
TYPE(ED_InputType), INTENT(IN) :: u_ED !< ElastoDyn inputs
TYPE(AD_InputType), INTENT(IN) :: u_AD !< AeroDyn inputs
TYPE(SD_InputType), INTENT(IN) :: u_SD !< SubDyn inputs
TYPE(HydroDyn_InputType), INTENT(IN) :: u_HD !< HydroDyn inputs
TYPE(MAP_InputType), INTENT(IN) :: u_MAP !< MAP inputs
TYPE(BD_InputType), INTENT(IN) :: u_BD(:) !< BeamDyn inputs
CHARACTER(*), INTENT(IN) :: FileName !< Name of file to write this information to
INTEGER(IntKi) :: ErrStat !< Error status of the operation
CHARACTER(*) :: ErrMsg !< Error message if ErrStat /= ErrID_None
INTEGER(IntKi) :: unOut
INTEGER(IntKi) :: K_local
INTEGER(B4Ki), PARAMETER :: File_ID = 3
INTEGER(B4Ki) :: NumBl
! Open the binary output file:
unOut=-1
CALL GetNewUnit( unOut, ErrStat, ErrMsg )
CALL OpenBOutFile ( unOut, TRIM(FileName), ErrStat, ErrMsg )
IF (ErrStat /= ErrID_None) RETURN
! note that I'm not doing anything with the errors here, so it won't tell
! you there was a problem writing the data unless it was the last call.
! Add a file identification number (in case we ever have to change this):
WRITE( unOut, IOSTAT=ErrStat ) File_ID
! Add how many blade meshes there are:
NumBl = SIZE(u_ED%BladePtLoads,1) ! Note that NumBl is B4Ki
WRITE( unOut, IOSTAT=ErrStat ) NumBl
! Add all of the input meshes:
DO K_local = 1,NumBl
CALL MeshWrBin( unOut, u_ED%BladePtLoads(K_local), ErrStat, ErrMsg )
END DO
CALL MeshWrBin( unOut, u_ED%TowerPtLoads, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_ED%PlatformPtMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_SD%TPMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_SD%LMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_HD%Morison%Mesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_HD%WAMITMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_MAP%PtFairDisplacement, ErrStat, ErrMsg )
! Add how many BD blade meshes there are:
NumBl = SIZE(u_BD,1) ! Note that NumBl is B4Ki
WRITE( unOut, IOSTAT=ErrStat ) NumBl
DO K_local = 1,NumBl
CALL MeshWrBin( unOut, u_BD(K_local)%RootMotion, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_BD(K_local)%DistrLoad, ErrStat, ErrMsg )
END DO
! Add how many AD blade meshes there are:
NumBl = SIZE(u_AD%rotors(1)%BladeMotion,1) ! Note that NumBl is B4Ki
WRITE( unOut, IOSTAT=ErrStat ) NumBl
DO K_local = 1,NumBl
CALL MeshWrBin( unOut, u_AD%rotors(1)%BladeMotion(k_local), ErrStat, ErrMsg )
END DO
! Close the file
CLOSE(unOut)
END SUBROUTINE WriteInputMeshesToFile
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine writes motion mesh data to a binary file (for rudimentary visualization and debugging). If unOut < 0, a new file
!! will be opened for writing (FileName). It is up to the caller of this routine to close the file.
SUBROUTINE WriteMotionMeshesToFile(time, y_ED, u_SD, y_SD, u_HD, u_MAP, y_BD, u_BD, UnOut, ErrStat, ErrMsg, FileName)
REAL(DbKi), INTENT(IN) :: time !< current simulation time
TYPE(ED_OutputType), INTENT(IN) :: y_ED !< ElastoDyn outputs
TYPE(SD_InputType), INTENT(IN) :: u_SD !< SubDyn inputs
TYPE(SD_OutputType), INTENT(IN) :: y_SD !< SubDyn outputs
TYPE(HydroDyn_InputType), INTENT(IN) :: u_HD !< HydroDyn inputs
TYPE(MAP_InputType), INTENT(IN) :: u_MAP !< MAP inputs
TYPE(BD_OutputType), INTENT(IN) :: y_BD(:) !< BeamDyn outputs
TYPE(BD_InputType), INTENT(IN) :: u_BD(:) !< BeamDyn inputs
INTEGER(IntKi) , INTENT(INOUT) :: unOut !< Unit number to write where this info should be written. If unOut < 0, a new file will be opened and the opened unit number will be returned.
CHARACTER(*), INTENT(IN) :: FileName !< If unOut < 0, FileName will be opened for writing this mesh information.
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status of the operation
CHARACTER(*) , INTENT(OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
REAL(R8Ki) :: t
INTEGER(IntKi) :: K_local
INTEGER(B4Ki), PARAMETER :: File_ID = 101
INTEGER(B4Ki) :: NumBl
t = time ! convert to 8-bytes if necessary (DbKi might not be R8Ki)
! note that I'm not doing anything with the errors here, so it won't tell
! you there was a problem writing the data unless it was the last call.
! Open the binary output file and write a header:
if (unOut<0) then
CALL GetNewUnit( unOut, ErrStat, ErrMsg )
CALL OpenBOutFile ( unOut, TRIM(FileName), ErrStat, ErrMsg )
IF (ErrStat /= ErrID_None) RETURN
! Add a file identification number (in case we ever have to change this):
WRITE( unOut, IOSTAT=ErrStat ) File_ID
! Add how many blade meshes there are:
NumBl = SIZE(y_ED%BladeLn2Mesh,1) ! Note that NumBl is B4Ki
WRITE( unOut, IOSTAT=ErrStat ) NumBl
NumBl = SIZE(y_BD,1) ! Note that NumBl is B4Ki
WRITE( unOut, IOSTAT=ErrStat ) NumBl
end if
WRITE( unOut, IOSTAT=ErrStat ) t
! Add all of the meshes with motions:
DO K_local = 1,SIZE(y_ED%BladeLn2Mesh,1)
CALL MeshWrBin( unOut, y_ED%BladeLn2Mesh(K_local), ErrStat, ErrMsg )
END DO
CALL MeshWrBin( unOut, y_ED%TowerLn2Mesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, y_ED%PlatformPtMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_SD%TPMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, y_SD%y2Mesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_HD%Morison%Mesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_HD%WAMITMesh, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, u_MAP%PtFairDisplacement, ErrStat, ErrMsg )
DO K_local = 1,SIZE(y_BD,1)
CALL MeshWrBin( unOut, u_BD(K_local)%RootMotion, ErrStat, ErrMsg )
CALL MeshWrBin( unOut, y_BD(K_local)%BldMotion, ErrStat, ErrMsg )
END DO
!
! ! Close the file
!CLOSE(unOut)
!
END SUBROUTINE WriteMotionMeshesToFile
!----------------------------------------------------------------------------------------------------------------------------------
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! Linerization routines
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!> Routine that calls FAST_Linearize_T for an array of Turbine data structures if the linearization flag is set for each individual turbine.
SUBROUTINE FAST_Linearize_Tary(t_initial, n_t_global, Turbine, ErrStat, ErrMsg)
REAL(DbKi), INTENT(IN ) :: t_initial !< initial simulation time (almost always 0)
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< integer time step
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine(:) !< all data for one instance of a turbine
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: i_turb, NumTurbines
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_Linearize_Tary'
NumTurbines = SIZE(Turbine)
ErrStat = ErrID_None
ErrMsg = ""
DO i_turb = 1,NumTurbines
CALL FAST_Linearize_T(t_initial, n_t_global, Turbine(i_turb), ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
END DO
END SUBROUTINE FAST_Linearize_Tary
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that performs lineaization at an operating point for a turbine. This is a separate subroutine so that the FAST
!! driver programs do not need to change or operate on the individual module level.
SUBROUTINE FAST_Linearize_T(t_initial, n_t_global, Turbine, ErrStat, ErrMsg)
REAL(DbKi), INTENT(IN ) :: t_initial !< initial simulation time (almost always 0)
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< integer time step
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t_global ! current simulation time
REAL(DbKi) :: next_lin_time ! next simulation time where linearization analysis should be performed
INTEGER(IntKi) :: iLinTime ! loop counter
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_Linearize_T'
ErrStat = ErrID_None
ErrMsg = ""
if ( .not. Turbine%p_FAST%Linearize ) return
if (.not. Turbine%p_FAST%CalcSteady) then
if ( Turbine%m_FAST%Lin%NextLinTimeIndx <= Turbine%p_FAST%NLinTimes ) then !bjj: maybe this logic should go in FAST_Linearize_OP???
next_lin_time = Turbine%m_FAST%Lin%LinTimes( Turbine%m_FAST%Lin%NextLinTimeIndx )
t_global = t_initial + n_t_global*Turbine%p_FAST%dt
if ( EqualRealNos( t_global, next_lin_time ) .or. t_global > next_lin_time ) then
CALL FAST_Linearize_OP(t_global, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
if (Turbine%p_FAST%WrVTK == VTK_ModeShapes) then
if (Turbine%m_FAST%Lin%NextLinTimeIndx > Turbine%p_FAST%NLinTimes) call WrVTKCheckpoint()
end if
end if
end if
else ! CalcSteady
t_global = t_initial + n_t_global*Turbine%p_FAST%dt
call FAST_CalcSteady( n_t_global, t_global, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, Turbine%ED, Turbine%BD, Turbine%SrvD, &
Turbine%AD, Turbine%IfW, Turbine%OpFM, Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, &
Turbine%Orca, Turbine%IceF, Turbine%IceD, ErrStat2, ErrMsg2 )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (Turbine%m_FAST%Lin%FoundSteady) then
do iLinTime=1,Turbine%p_FAST%NLinTimes
t_global = Turbine%m_FAST%Lin%LinTimes(iLinTime)
call SetOperatingPoint(iLinTime, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, Turbine%ED, Turbine%BD, Turbine%SrvD, &
Turbine%AD, Turbine%IfW, Turbine%OpFM, Turbine%HD, Turbine%SD, Turbine%ExtPtfm, &
Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, Turbine%IceF, Turbine%IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (Turbine%p_FAST%DT_UJac < Turbine%p_FAST%TMax) then
Turbine%m_FAST%calcJacobian = .true.
Turbine%m_FAST%NextJacCalcTime = t_global
end if
CALL CalcOutputs_And_SolveForInputs( -1, t_global, STATE_CURR, Turbine%m_FAST%calcJacobian, Turbine%m_FAST%NextJacCalcTime, &
Turbine%p_FAST, Turbine%m_FAST, .false., Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
CALL FAST_Linearize_OP(t_global, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
end do
if (Turbine%p_FAST%WrVTK == VTK_ModeShapes) CALL WrVTKCheckpoint()
end if
end if
return
contains
subroutine WrVTKCheckpoint()
! we are creating a checkpoint file for each turbine, so setting NumTurbines=1 in the file
CALL FAST_CreateCheckpoint_T(t_initial, Turbine%p_FAST%n_TMax_m1+1, 1, Turbine, TRIM(Turbine%p_FAST%OutFileRoot)//'.ModeShapeVTK', ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
end subroutine WrVTKCheckpoint
END SUBROUTINE FAST_Linearize_T
!----------------------------------------------------------------------------------------------------------------------------------
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! PROGRAM EXIT ROUTINES
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!> Routine that calls ExitThisProgram for one instance of a Turbine data structure. This is a separate subroutine so that the FAST
!! driver programs do not need to change or operate on the individual module level.
!! This routine should be called from glue code only (e.g., FAST_Prog.f90). It should not be called in any of these driver routines.
SUBROUTINE ExitThisProgram_T( Turbine, ErrLevel_in, StopTheProgram, ErrLocMsg, SkipRunTimeMsg )
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< Data for one turbine instance
INTEGER(IntKi), INTENT(IN) :: ErrLevel_in !< Error level when Error == .TRUE. (required when Error is .TRUE.)
LOGICAL, INTENT(IN) :: StopTheProgram !< flag indicating if the program should end (false if there are more turbines to end)
CHARACTER(*), OPTIONAL, INTENT(IN) :: ErrLocMsg !< an optional message describing the location of the error
LOGICAL, OPTIONAL, INTENT(IN) :: SkipRunTimeMsg !< an optional message describing run-time stats
LOGICAL :: SkipRunTimes
IF (PRESENT(SkipRunTimeMsg)) THEN
SkipRunTimes = SkipRunTimeMsg
ELSE
SkipRunTimes = .FALSE.
END IF
IF (PRESENT(ErrLocMsg)) THEN
CALL ExitThisProgram( Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrLevel_in, StopTheProgram, ErrLocMsg, SkipRunTimes )
ELSE
CALL ExitThisProgram( Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
Turbine%ED, Turbine%BD, Turbine%SrvD, Turbine%AD14, Turbine%AD, Turbine%IfW, Turbine%OpFM, &
Turbine%HD, Turbine%SD, Turbine%ExtPtfm, Turbine%MAP, Turbine%FEAM, Turbine%MD, Turbine%Orca, &
Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrLevel_in, StopTheProgram, SkipRunTimeMsg=SkipRunTimes )
END IF
END SUBROUTINE ExitThisProgram_T
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine is called when FAST exits. It calls all the modules' end routines and cleans up variables declared in the
!! main program. If there was an error, it also aborts. Otherwise, it prints the run times and performs a normal exit.
!! This routine should not be called from glue code (e.g., FAST_Prog.f90) or ExitThisProgram_T only. It should not be called in any
!! of these driver routines.
SUBROUTINE ExitThisProgram( p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrLevel_in, StopTheProgram, ErrLocMsg, SkipRunTimeMsg )
!...............................................................................................................................
! Passed arguments
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn v14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT(IN) :: ErrLevel_in !< Error level when Error == .TRUE. (required when Error is .TRUE.)
LOGICAL, INTENT(IN) :: StopTheProgram !< flag indicating if the program should end (false if there are more turbines to end)
CHARACTER(*), OPTIONAL, INTENT(IN) :: ErrLocMsg !< an optional message describing the location of the error
LOGICAL, OPTIONAL, INTENT(IN) :: SkipRunTimeMsg !< an optional message describing run-time stats
! Local variables:
INTEGER(IntKi) :: ErrorLevel
LOGICAL :: PrintRunTimes
INTEGER(IntKi) :: ErrStat2 ! Error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! Error message
CHARACTER(1224) :: SimMsg ! optional message to print about where the error took place in the simulation
CHARACTER(*), PARAMETER :: RoutineName = 'ExitThisProgram'
ErrorLevel = ErrLevel_in
! for debugging, let's output the meshes and all of their fields
IF ( ErrorLevel >= AbortErrLev .AND. p_FAST%WrVTK > VTK_None) THEN
p_FAST%VTK_OutFileRoot = trim(p_FAST%VTK_OutFileRoot)//'.DebugError'
p_FAST%VTK_fields = .true.
CALL WrVTK_AllMeshes(p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
end if
! End all modules
CALL FAST_EndMods( p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat2, ErrMsg2 )
IF (ErrStat2 /= ErrID_None) THEN
CALL WrScr( NewLine//RoutineName//':'//TRIM(ErrMsg2)//NewLine )
ErrorLevel = MAX(ErrorLevel,ErrStat2)
END IF
! Destroy all data associated with FAST variables:
CALL FAST_DestroyAll( p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2 )
IF (ErrStat2 /= ErrID_None) THEN
CALL WrScr( NewLine//RoutineName//':'//TRIM(ErrMsg2)//NewLine )
ErrorLevel = MAX(ErrorLevel,ErrStat2)
END IF
!............................................................................................................................
! Set exit error code if there was an error;
!............................................................................................................................
IF ( ErrorLevel >= AbortErrLev ) THEN
IF (PRESENT(ErrLocMsg)) THEN
SimMsg = ErrLocMsg
ELSE
SimMsg = 'after the simulation completed'
END IF
IF (y_FAST%UnSum > 0) THEN
CLOSE(y_FAST%UnSum)
y_FAST%UnSum = -1
END IF
SimMsg = TRIM(FAST_Ver%Name)//' encountered an error '//TRIM(SimMsg)//'.'//NewLine//' Simulation error level: '//TRIM(GetErrStr(ErrorLevel))
if (StopTheProgram) then
CALL ProgAbort( trim(SimMsg), TrapErrors=.FALSE., TimeWait=3._ReKi ) ! wait 3 seconds (in case they double-clicked and got an error)
else
CALL WrScr(trim(SimMsg))
end if
END IF
!............................................................................................................................
! Write simulation times and stop
!............................................................................................................................
if (present(SkipRunTimeMsg)) then
PrintRunTimes = .not. SkipRunTimeMsg
else
PrintRunTimes = .true.
end if
IF (p_FAST%WrSttsTime .and. PrintRunTimes) THEN
CALL RunTimes( m_FAST%StrtTime, m_FAST%UsrTime1, m_FAST%SimStrtTime, m_FAST%UsrTime2, m_FAST%t_global, UnSum=y_FAST%UnSum, DescStrIn=p_FAST%TDesc )
END IF
IF (y_FAST%UnSum > 0) THEN
CLOSE(y_FAST%UnSum)
y_FAST%UnSum = -1
END IF
if (StopTheProgram) then
#if (defined COMPILE_SIMULINK || defined COMPILE_LABVIEW)
! for Simulink, this may not be a normal stop. It might call this after an error in the model.
CALL WrScr( NewLine//' '//TRIM(FAST_Ver%Name)//' completed.'//NewLine )
#else
CALL NormStop( )
#endif
end if
END SUBROUTINE ExitThisProgram
!----------------------------------------------------------------------------------------------------------------------------------
!> This subroutine is called at program termination. It writes any additional output files,
!! deallocates variables for FAST file I/O and closes files.
SUBROUTINE FAST_EndOutput( p_FAST, y_FAST, m_FAST, ErrStat, ErrMsg )
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< FAST Parameters
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< FAST Output
TYPE(FAST_MiscVarType), INTENT(IN ) :: m_FAST !< Miscellaneous variables (only for the final time)
INTEGER(IntKi), INTENT(OUT) :: ErrStat !< Error status
CHARACTER(*), INTENT(OUT) :: ErrMsg !< Message associated with errro status
! local variables
CHARACTER(LEN(y_FAST%FileDescLines)*3) :: FileDesc ! The description of the run, to be written in the binary output file
! Initialize some values
ErrStat = ErrID_None
ErrMsg = ''
!-------------------------------------------------------------------------------------------------
! Write the binary output file if requested
!-------------------------------------------------------------------------------------------------
IF (p_FAST%WrBinOutFile .AND. y_FAST%n_Out > 0) THEN
FileDesc = TRIM(y_FAST%FileDescLines(1))//' '//TRIM(y_FAST%FileDescLines(2))//'; '//TRIM(y_FAST%FileDescLines(3))
CALL WrBinFAST(TRIM(p_FAST%OutFileRoot)//'.outb', Int(p_FAST%WrBinMod, B2Ki), TRIM(FileDesc), &
y_FAST%ChannelNames, y_FAST%ChannelUnits, y_FAST%TimeData, y_FAST%AllOutData(:,1:y_FAST%n_Out), ErrStat, ErrMsg)
IF ( ErrStat /= ErrID_None ) CALL WrScr( TRIM(GetErrStr(ErrStat))//' when writing binary output file: '//TRIM(ErrMsg) )
END IF
!-------------------------------------------------------------------------------------------------
! Close the text tabular output file and summary file (if opened)
!-------------------------------------------------------------------------------------------------
IF (y_FAST%UnOu > 0) THEN ! I/O unit number for the tabular output file
CLOSE( y_FAST%UnOu )
y_FAST%UnOu = -1
END IF
IF (y_FAST%UnSum > 0) THEN ! I/O unit number for the tabular output file
CLOSE( y_FAST%UnSum )
y_FAST%UnSum = -1
END IF
IF (y_FAST%UnGra > 0) THEN ! I/O unit number for the graphics output file
CLOSE( y_FAST%UnGra )
y_FAST%UnGra = -1
END IF
!-------------------------------------------------------------------------------------------------
! Deallocate arrays
!-------------------------------------------------------------------------------------------------
! Output
IF ( ALLOCATED(y_FAST%AllOutData ) ) DEALLOCATE(y_FAST%AllOutData )
IF ( ALLOCATED(y_FAST%TimeData ) ) DEALLOCATE(y_FAST%TimeData )
IF ( ALLOCATED(y_FAST%ChannelNames ) ) DEALLOCATE(y_FAST%ChannelNames )
IF ( ALLOCATED(y_FAST%ChannelUnits ) ) DEALLOCATE(y_FAST%ChannelUnits )
END SUBROUTINE FAST_EndOutput
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine calls the end routines for each module that was previously initialized.
SUBROUTINE FAST_EndMods( p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat, ErrMsg )
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn v14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: i, k ! loop counter
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_EndMods'
!...............................................................................................................................
! End all modules (and write binary FAST output file)
!...............................................................................................................................
ErrStat = ErrID_None
ErrMsg = ""
CALL FAST_EndOutput( p_FAST, y_FAST, m_FAST, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF ( p_FAST%ModuleInitialized(Module_ED) ) THEN
CALL ED_End( ED%Input(1), ED%p, ED%x(STATE_CURR), ED%xd(STATE_CURR), ED%z(STATE_CURR), ED%OtherSt(STATE_CURR), &
ED%y, ED%m, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_BD) ) THEN
DO k=1,p_FAST%nBeams
CALL BD_End(BD%Input(1,k), BD%p(k), BD%x(k,STATE_CURR), BD%xd(k,STATE_CURR), BD%z(k,STATE_CURR), &
BD%OtherSt(k,STATE_CURR), BD%y(k), BD%m(k), ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END DO
END IF
IF ( p_FAST%ModuleInitialized(Module_AD14) ) THEN
CALL AD14_End( AD14%Input(1), AD14%p, AD14%x(STATE_CURR), AD14%xd(STATE_CURR), AD14%z(STATE_CURR), &
AD14%OtherSt(STATE_CURR), AD14%y, AD14%m, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSEIF ( p_FAST%ModuleInitialized(Module_AD) ) THEN
CALL AD_End( AD%Input(1), AD%p, AD%x(STATE_CURR), AD%xd(STATE_CURR), AD%z(STATE_CURR), &
AD%OtherSt(STATE_CURR), AD%y, AD%m, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_IfW) ) THEN
CALL InflowWind_End( IfW%Input(1), IfW%p, IfW%x(STATE_CURR), IfW%xd(STATE_CURR), IfW%z(STATE_CURR), IfW%OtherSt(STATE_CURR), &
IfW%y, IfW%m, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_SrvD) ) THEN
CALL SrvD_End( SrvD%Input(1), SrvD%p, SrvD%x(STATE_CURR), SrvD%xd(STATE_CURR), SrvD%z(STATE_CURR), SrvD%OtherSt(STATE_CURR), &
SrvD%y, SrvD%m, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_HD) ) THEN
CALL HydroDyn_End( HD%Input(1), HD%p, HD%x(STATE_CURR), HD%xd(STATE_CURR), HD%z(STATE_CURR), HD%OtherSt(STATE_CURR), &
HD%y, HD%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_SD) ) THEN
CALL SD_End( SD%Input(1), SD%p, SD%x(STATE_CURR), SD%xd(STATE_CURR), SD%z(STATE_CURR), SD%OtherSt(STATE_CURR), &
SD%y, SD%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSE IF ( p_FAST%ModuleInitialized(Module_ExtPtfm) ) THEN
CALL ExtPtfm_End( ExtPtfm%Input(1), ExtPtfm%p, ExtPtfm%x(STATE_CURR), ExtPtfm%xd(STATE_CURR), ExtPtfm%z(STATE_CURR), &
ExtPtfm%OtherSt(STATE_CURR), ExtPtfm%y, ExtPtfm%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_MAP) ) THEN
CALL MAP_End( MAPp%Input(1), MAPp%p, MAPp%x(STATE_CURR), MAPp%xd(STATE_CURR), MAPp%z(STATE_CURR), MAPp%OtherSt, &
MAPp%y, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSEIF ( p_FAST%ModuleInitialized(Module_MD) ) THEN
CALL MD_End( MD%Input(1), MD%p, MD%x(STATE_CURR), MD%xd(STATE_CURR), MD%z(STATE_CURR), MD%OtherSt(STATE_CURR), &
MD%y, MD%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSEIF ( p_FAST%ModuleInitialized(Module_FEAM) ) THEN
CALL FEAM_End( FEAM%Input(1), FEAM%p, FEAM%x(STATE_CURR), FEAM%xd(STATE_CURR), FEAM%z(STATE_CURR), &
FEAM%OtherSt(STATE_CURR), FEAM%y, FEAM%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSEIF ( p_FAST%ModuleInitialized(Module_Orca) ) THEN
CALL Orca_End( Orca%Input(1), Orca%p, Orca%x(STATE_CURR), Orca%xd(STATE_CURR), Orca%z(STATE_CURR), Orca%OtherSt(STATE_CURR), &
Orca%y, Orca%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END IF
IF ( p_FAST%ModuleInitialized(Module_IceF) ) THEN
CALL IceFloe_End(IceF%Input(1), IceF%p, IceF%x(STATE_CURR), IceF%xd(STATE_CURR), IceF%z(STATE_CURR), &
IceF%OtherSt(STATE_CURR), IceF%y, IceF%m, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
ELSEIF ( p_FAST%ModuleInitialized(Module_IceD) ) THEN
DO i=1,p_FAST%numIceLegs
CALL IceD_End(IceD%Input(1,i), IceD%p(i), IceD%x(i,STATE_CURR), IceD%xd(i,STATE_CURR), IceD%z(i,STATE_CURR), &
IceD%OtherSt(i,STATE_CURR), IceD%y(i), IceD%m(i), ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END DO
END IF
END SUBROUTINE FAST_EndMods
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine calls the destroy routines for each module. (It is basically a duplicate of FAST_DestroyTurbineType().)
SUBROUTINE FAST_DestroyAll( p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat, ErrMsg )
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn v14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_DestroyAll'
! -------------------------------------------------------------------------
! Deallocate/Destroy structures associated with mesh mapping
! -------------------------------------------------------------------------
ErrStat = ErrID_None
ErrMsg = ""
! FAST
CALL FAST_DestroyParam( p_FAST, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
CALL FAST_DestroyOutputFileType( y_FAST, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
CALL FAST_DestroyMisc( m_FAST, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! ElastoDyn
CALL FAST_DestroyElastoDyn_Data( ED, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! BeamDyn
CALL FAST_DestroyBeamDyn_Data( BD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! ServoDyn
CALL FAST_DestroyServoDyn_Data( SrvD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! AeroDyn14
CALL FAST_DestroyAeroDyn14_Data( AD14, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! AeroDyn
CALL FAST_DestroyAeroDyn_Data( AD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! InflowWind
CALL FAST_DestroyInflowWind_Data( IfW, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! OpenFOAM
CALL FAST_DestroyOpenFOAM_Data( OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! HydroDyn
CALL FAST_DestroyHydroDyn_Data( HD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! SubDyn
CALL FAST_DestroySubDyn_Data( SD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! ExtPtfm
CALL FAST_DestroyExtPtfm_Data( ExtPtfm, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! MAP
CALL FAST_DestroyMAP_Data( MAPp, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! FEAMooring
CALL FAST_DestroyFEAMooring_Data( FEAM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! MoorDyn
CALL FAST_DestroyMoorDyn_Data( MD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! Orca
CALL FAST_DestroyOrcaFlex_Data( Orca, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! IceFloe
CALL FAST_DestroyIceFloe_Data( IceF, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! IceDyn
CALL FAST_DestroyIceDyn_Data( IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
! Module (Mesh) Mapping data
CALL FAST_DestroyModuleMapType( MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
END SUBROUTINE FAST_DestroyAll
!----------------------------------------------------------------------------------------------------------------------------------
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! CHECKPOINT/RESTART ROUTINES
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
!> Routine that calls FAST_CreateCheckpoint_T for an array of Turbine data structures.
SUBROUTINE FAST_CreateCheckpoint_Tary(t_initial, n_t_global, Turbine, CheckpointRoot, ErrStat, ErrMsg)
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< loop counter
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine(:) !< all data for all turbines
CHARACTER(*), INTENT(IN ) :: CheckpointRoot !< Rootname of checkpoint file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: NumTurbines ! Number of turbines in this simulation
INTEGER(IntKi) :: i_turb
INTEGER :: Unit
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_CreateCheckpoint_Tary'
NumTurbines = SIZE(Turbine)
ErrStat = ErrID_None
ErrMsg = ""
! TRIM(CheckpointRoot)//'.'//TRIM(Num2LStr(Turbine%TurbID))//
!! This allows us to put all the turbine data in one file.
Unit = -1
DO i_turb = 1,NumTurbines
CALL FAST_CreateCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine(i_turb), CheckpointRoot, ErrStat2, ErrMsg2, Unit )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) then
if (Unit > 0) close(Unit)
RETURN
end if
END DO
END SUBROUTINE FAST_CreateCheckpoint_Tary
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that packs all of the data from one turbine instance into arrays and writes checkpoint files. If Unit is present and
!! greater than 0, it will append the data to an already open file. Otherwise, it opens a new file and writes header information
!! before writing the turbine data to the file.
SUBROUTINE FAST_CreateCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine, CheckpointRoot, ErrStat, ErrMsg, Unit )
USE BladedInterface, ONLY: CallBladedDLL ! Hack for Bladed-style DLL
USE BladedInterface, ONLY: GH_DISCON_STATUS_CHECKPOINT
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
INTEGER(IntKi), INTENT(IN ) :: n_t_global !< loop counter
INTEGER(IntKi), INTENT(IN ) :: NumTurbines !< Number of turbines in this simulation
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine (INTENT(OUT) only because of hack for Bladed DLL)
CHARACTER(*), INTENT(IN ) :: CheckpointRoot !< Rootname of checkpoint file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
INTEGER(IntKi), OPTIONAL, INTENT(INOUT) :: Unit !< unit number for output file
! local variables:
REAL(ReKi), ALLOCATABLE :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE :: IntKiBuf(:)
INTEGER(B4Ki) :: ArraySizes(3)
INTEGER(IntKi) :: unOut ! unit number for output file
INTEGER(IntKi) :: old_avrSwap1 ! previous value of avrSwap(1) !hack for Bladed DLL checkpoint/restore
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_CreateCheckpoint_T'
CHARACTER(1024) :: FileName ! Name of the (output) checkpoint file
CHARACTER(1024) :: DLLFileName ! Name of the (output) checkpoint file
! init error status
ErrStat = ErrID_None
ErrMsg = ""
! Get the arrays of data to be stored in the output file
CALL FAST_PackTurbineType( ReKiBuf, DbKiBuf, IntKiBuf, Turbine, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) then
call cleanup()
RETURN
end if
ArraySizes = 0
IF ( ALLOCATED(ReKiBuf) ) ArraySizes(1) = SIZE(ReKiBuf)
IF ( ALLOCATED(DbKiBuf) ) ArraySizes(2) = SIZE(DbKiBuf)
IF ( ALLOCATED(IntKiBuf) ) ArraySizes(3) = SIZE(IntKiBuf)
FileName = TRIM(CheckpointRoot)//'.chkp'
DLLFileName = TRIM(CheckpointRoot)//'.dll.chkp'
unOut=-1
IF (PRESENT(Unit)) unOut = Unit
IF ( unOut < 0 ) THEN
CALL GetNewUnit( unOut, ErrStat2, ErrMsg2 )
CALL OpenBOutFile ( unOut, FileName, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) then
call cleanup()
IF (.NOT. PRESENT(Unit)) THEN
CLOSE(unOut)
unOut = -1
END IF
RETURN
end if
! checkpoint file header:
WRITE (unOut, IOSTAT=ErrStat2) INT(ReKi ,B4Ki) ! let's make sure we've got the correct number of bytes for reals on restart.
WRITE (unOut, IOSTAT=ErrStat2) INT(DbKi ,B4Ki) ! let's make sure we've got the correct number of bytes for doubles on restart.
WRITE (unOut, IOSTAT=ErrStat2) INT(IntKi ,B4Ki) ! let's make sure we've got the correct number of bytes for integers on restart.
WRITE (unOut, IOSTAT=ErrStat2) AbortErrLev
WRITE (unOut, IOSTAT=ErrStat2) NumTurbines ! Number of turbines
WRITE (unOut, IOSTAT=ErrStat2) t_initial ! initial time
WRITE (unOut, IOSTAT=ErrStat2) n_t_global ! current time step
END IF
! data from current turbine at time step:
WRITE (unOut, IOSTAT=ErrStat2) ArraySizes ! Number of reals, doubles, and integers written to file
WRITE (unOut, IOSTAT=ErrStat2) ReKiBuf ! Packed reals
WRITE (unOut, IOSTAT=ErrStat2) DbKiBuf ! Packed doubles
WRITE (unOut, IOSTAT=ErrStat2) IntKiBuf ! Packed integers
IF ( ALLOCATED(ReKiBuf) ) DEALLOCATE(ReKiBuf)
IF ( ALLOCATED(DbKiBuf) ) DEALLOCATE(DbKiBuf)
IF ( ALLOCATED(IntKiBuf) ) DEALLOCATE(IntKiBuf)
!CALL FAST_CreateCheckpoint(t_initial, n_t_global, Turbine%p_FAST, Turbine%y_FAST, Turbine%m_FAST, &
! Turbine%ED, Turbine%SrvD, Turbine%AD, Turbine%IfW, &
! Turbine%HD, Turbine%SD, Turbine%MAP, Turbine%FEAM, Turbine%MD, &
! Turbine%IceF, Turbine%IceD, Turbine%MeshMapData, ErrStat, ErrMsg )
IF (Turbine%TurbID == NumTurbines .OR. .NOT. PRESENT(Unit)) THEN
CLOSE(unOut)
unOut = -1
END IF
IF (PRESENT(Unit)) Unit = unOut
! A hack to pack Bladed-style DLL data
IF (Turbine%SrvD%p%UseBladedInterface) THEN
if (Turbine%SrvD%m%dll_data%avrSWAP( 1) > 0 ) then
! store value to be overwritten
old_avrSwap1 = Turbine%SrvD%m%dll_data%avrSWAP( 1)
FileName = Turbine%SrvD%m%dll_data%DLL_InFile
! overwrite values:
Turbine%SrvD%m%dll_data%DLL_InFile = DLLFileName
Turbine%SrvD%m%dll_data%avrSWAP(50) = REAL( LEN_TRIM(DLLFileName) ) +1 ! No. of characters in the "INFILE" argument (-) (we add one for the C NULL CHARACTER)
Turbine%SrvD%m%dll_data%avrSWAP( 1) = GH_DISCON_STATUS_CHECKPOINT
Turbine%SrvD%m%dll_data%SimStatus = Turbine%SrvD%m%dll_data%avrSWAP( 1)
CALL CallBladedDLL(Turbine%SrvD%Input(1), Turbine%SrvD%p, Turbine%SrvD%m%dll_data, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! put values back:
Turbine%SrvD%m%dll_data%DLL_InFile = FileName
Turbine%SrvD%m%dll_data%avrSWAP(50) = REAL( LEN_TRIM(FileName) ) +1 ! No. of characters in the "INFILE" argument (-) (we add one for the C NULL CHARACTER)
Turbine%SrvD%m%dll_data%avrSWAP( 1) = old_avrSwap1
Turbine%SrvD%m%dll_data%SimStatus = Turbine%SrvD%m%dll_data%avrSWAP( 1)
end if
END IF
call cleanup()
contains
subroutine cleanup()
IF ( ALLOCATED(ReKiBuf) ) DEALLOCATE(ReKiBuf)
IF ( ALLOCATED(DbKiBuf) ) DEALLOCATE(DbKiBuf)
IF ( ALLOCATED(IntKiBuf) ) DEALLOCATE(IntKiBuf)
end subroutine cleanup
END SUBROUTINE FAST_CreateCheckpoint_T
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls FAST_RestoreFromCheckpoint_T for an array of Turbine data structures.
SUBROUTINE FAST_RestoreFromCheckpoint_Tary(t_initial, n_t_global, Turbine, CheckpointRoot, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time (for comparing with time from checkpoint file)
INTEGER(IntKi), INTENT( OUT) :: n_t_global !< loop counter
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine(:) !< all data for one instance of a turbine !intent(INOUT) instead of (IN) to attempt to avoid memory warnings in gnu compilers
CHARACTER(*), INTENT(IN ) :: CheckpointRoot !< Rootname of checkpoint file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t_initial_out
INTEGER(IntKi) :: NumTurbines_out
INTEGER(IntKi) :: NumTurbines ! Number of turbines in this simulation
INTEGER(IntKi) :: i_turb
INTEGER :: Unit
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_RestoreFromCheckpoint_Tary'
NumTurbines = SIZE(Turbine)
ErrStat = ErrID_None
ErrMsg = ""
! Init NWTC_Library, display copyright and version information:
CALL FAST_ProgStart( FAST_Ver )
! Restore data from checkpoint file
Unit = -1
DO i_turb = 1,NumTurbines
CALL FAST_RestoreFromCheckpoint_T(t_initial_out, n_t_global, NumTurbines_out, Turbine(i_turb), CheckpointRoot, ErrStat2, ErrMsg2, Unit )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (t_initial_out /= t_initial) CALL SetErrStat(ErrID_Fatal, "invalid value of t_initial.", ErrStat, ErrMsg, RoutineName )
IF (NumTurbines_out /= NumTurbines) CALL SetErrStat(ErrID_Fatal, "invalid value of NumTurbines.", ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
END DO
CALL WrScr( ' Restarting simulation at '//TRIM(Num2LStr(n_t_global*Turbine(1)%p_FAST%DT))//' seconds.' )
END SUBROUTINE FAST_RestoreFromCheckpoint_Tary
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine is the inverse of FAST_CreateCheckpoint_T. It reads data from a checkpoint file and populates data structures for
!! the turbine instance.
SUBROUTINE FAST_RestoreFromCheckpoint_T(t_initial, n_t_global, NumTurbines, Turbine, CheckpointRoot, ErrStat, ErrMsg, Unit )
USE BladedInterface, ONLY: CallBladedDLL ! Hack for Bladed-style DLL
USE BladedInterface, ONLY: GH_DISCON_STATUS_RESTARTING
REAL(DbKi), INTENT(INOUT) :: t_initial !< initial time
INTEGER(IntKi), INTENT(INOUT) :: n_t_global !< loop counter
INTEGER(IntKi), INTENT(INOUT) :: NumTurbines !< Number of turbines in this simulation
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine !< all data for one instance of a turbine (bjj: note that is intent INOUT instead of OUT only because of a gfortran compiler memory issue)
CHARACTER(*), INTENT(IN ) :: CheckpointRoot !< Rootname of checkpoint file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
INTEGER(IntKi), OPTIONAL, INTENT(INOUT) :: Unit !< unit number for output file
! local variables:
REAL(ReKi), ALLOCATABLE :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE :: IntKiBuf(:)
INTEGER(B4Ki) :: ArraySizes(3)
INTEGER(IntKi) :: unIn ! unit number for input file
INTEGER(IntKi) :: old_avrSwap1 ! previous value of avrSwap(1) !hack for Bladed DLL checkpoint/restore
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_RestoreFromCheckpoint_T'
CHARACTER(1024) :: FileName ! Name of the (input) checkpoint file
CHARACTER(1024) :: DLLFileName ! Name of the (input) checkpoint file
ErrStat=ErrID_None
ErrMsg=""
FileName = TRIM(CheckpointRoot)//'.chkp'
DLLFileName = TRIM(CheckpointRoot)//'.dll.chkp'
! FileName = TRIM(CheckpointRoot)//'.cp'
unIn=-1
IF (PRESENT(Unit)) unIn = Unit
IF ( unIn < 0 ) THEN
CALL GetNewUnit( unIn, ErrStat2, ErrMsg2 )
CALL OpenBInpFile ( unIn, FileName, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev ) RETURN
! checkpoint file header:
READ (unIn, IOSTAT=ErrStat2) ArraySizes ! let's make sure we've got the correct number of bytes for reals, doubles, and integers on restart.
IF ( ArraySizes(1) /= ReKi ) CALL SetErrStat(ErrID_Fatal,"ReKi on restart is different than when checkpoint file was created.",ErrStat,ErrMsg,RoutineName)
IF ( ArraySizes(2) /= DbKi ) CALL SetErrStat(ErrID_Fatal,"DbKi on restart is different than when checkpoint file was created.",ErrStat,ErrMsg,RoutineName)
IF ( ArraySizes(3) /= IntKi ) CALL SetErrStat(ErrID_Fatal,"IntKi on restart is different than when checkpoint file was created.",ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CLOSE(unIn)
unIn = -1
IF (PRESENT(Unit)) Unit = unIn
RETURN
END IF
READ (unIn, IOSTAT=ErrStat2) AbortErrLev
READ (unIn, IOSTAT=ErrStat2) NumTurbines ! Number of turbines
READ (unIn, IOSTAT=ErrStat2) t_initial ! initial time
READ (unIn, IOSTAT=ErrStat2) n_t_global ! current time step
END IF
! in case the Turbine data structure isn't empty on entry of this routine:
call FAST_DestroyTurbineType( Turbine, ErrStat2, ErrMsg2 )
! data from current time step:
READ (unIn, IOSTAT=ErrStat2) ArraySizes ! Number of reals, doubles, and integers written to file
ALLOCATE(ReKiBuf( ArraySizes(1)), STAT=ErrStat2)
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not allocate ReKiBuf", ErrStat, ErrMsg, RoutineName )
ALLOCATE(DbKiBuf( ArraySizes(2)), STAT=ErrStat2)
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not allocate DbKiBuf", ErrStat, ErrMsg, RoutineName )
ALLOCATE(IntKiBuf(ArraySizes(3)), STAT=ErrStat2)
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not allocate IntKiBuf", ErrStat, ErrMsg, RoutineName )
! Read the packed arrays
IF (ErrStat < AbortErrLev) THEN
READ (unIn, IOSTAT=ErrStat2) ReKiBuf ! Packed reals
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not read ReKiBuf", ErrStat, ErrMsg, RoutineName )
READ (unIn, IOSTAT=ErrStat2) DbKiBuf ! Packed doubles
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not read DbKiBuf", ErrStat, ErrMsg, RoutineName )
READ (unIn, IOSTAT=ErrStat2) IntKiBuf ! Packed integers
IF (ErrStat2 /=0) CALL SetErrStat(ErrID_Fatal, "Could not read IntKiBuf", ErrStat, ErrMsg, RoutineName )
END IF
! Put the arrays back in the data types
IF (ErrStat < AbortErrLev) THEN
CALL FAST_UnpackTurbineType( ReKiBuf, DbKiBuf, IntKiBuf, Turbine, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! close file if necessary (do this after unpacking turbine data, so that TurbID is set)
IF (Turbine%TurbID == NumTurbines .OR. .NOT. PRESENT(Unit)) THEN
CLOSE(unIn)
unIn = -1
END IF
IF (PRESENT(Unit)) Unit = unIn
IF ( ALLOCATED(ReKiBuf) ) DEALLOCATE(ReKiBuf)
IF ( ALLOCATED(DbKiBuf) ) DEALLOCATE(DbKiBuf)
IF ( ALLOCATED(IntKiBuf) ) DEALLOCATE(IntKiBuf)
! A sort-of hack to restore MAP DLL data (in particular Turbine%MAP%OtherSt%C_Obj%object)
! these must be the same variables that are used in MAP_Init because they get allocated in the DLL and
! destroyed in MAP_End (also, inside the DLL)
IF (Turbine%p_FAST%CompMooring == Module_MAP) THEN
CALL MAP_Restart( Turbine%MAP%Input(1), Turbine%MAP%p, Turbine%MAP%x(STATE_CURR), Turbine%MAP%xd(STATE_CURR), &
Turbine%MAP%z(STATE_CURR), Turbine%MAP%OtherSt, Turbine%MAP%y, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF
! A hack to restore Bladed-style DLL data
if (Turbine%SrvD%p%UseBladedInterface) then
if (Turbine%SrvD%m%dll_data%avrSWAP( 1) > 0 ) then ! this isn't allocated if UseBladedInterface is FALSE
! store value to be overwritten
old_avrSwap1 = Turbine%SrvD%m%dll_data%avrSWAP( 1)
FileName = Turbine%SrvD%m%dll_data%DLL_InFile
! overwrite values before calling DLL:
Turbine%SrvD%m%dll_data%DLL_InFile = DLLFileName
Turbine%SrvD%m%dll_data%avrSWAP(50) = REAL( LEN_TRIM(DLLFileName) ) +1 ! No. of characters in the "INFILE" argument (-) (we add one for the C NULL CHARACTER)
Turbine%SrvD%m%dll_data%avrSWAP( 1) = GH_DISCON_STATUS_RESTARTING
Turbine%SrvD%m%dll_data%SimStatus = Turbine%SrvD%m%dll_data%avrSWAP( 1)
CALL CallBladedDLL(Turbine%SrvD%Input(1), Turbine%SrvD%p, Turbine%SrvD%m%dll_data, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! put values back:
Turbine%SrvD%m%dll_data%DLL_InFile = FileName
Turbine%SrvD%m%dll_data%avrSWAP(50) = REAL( LEN_TRIM(FileName) ) +1 ! No. of characters in the "INFILE" argument (-) (we add one for the C NULL CHARACTER)
Turbine%SrvD%m%dll_data%avrSWAP( 1) = old_avrSwap1
Turbine%SrvD%m%dll_data%SimStatus = Turbine%SrvD%m%dll_data%avrSWAP( 1)
end if
end if
! deal with sibling meshes here:
! (ignoring for now; they are not going to be siblings on restart)
! deal with files that were open:
IF (Turbine%p_FAST%WrTxtOutFile) THEN
CALL OpenFunkFileAppend ( Turbine%y_FAST%UnOu, TRIM(Turbine%p_FAST%OutFileRoot)//'.out', ErrStat2, ErrMsg2)
IF ( ErrStat2 >= AbortErrLev ) RETURN
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL WrFileNR ( Turbine%y_FAST%UnOu, '#Restarting here')
WRITE(Turbine%y_FAST%UnOu, '()')
END IF
! (ignoring for now; will have fort.x files if any were open [though I printed a warning about not outputting binary files earlier])
END SUBROUTINE FAST_RestoreFromCheckpoint_T
!----------------------------------------------------------------------------------------------------------------------------------
!----------------------------------------------------------------------------------------------------------------------------------
!> Routine that calls FAST_RestoreForVTKModeShape_T for an array of Turbine data structures.
SUBROUTINE FAST_RestoreForVTKModeShape_Tary(t_initial, Turbine, InputFileName, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time (for comparing with time from checkpoint file)
TYPE(FAST_TurbineType), INTENT(INOUT) :: Turbine(:) !< all data for one instance of a turbine !intent(INOUT) instead of (IN) to attempt to avoid memory warnings in gnu compilers
CHARACTER(*), INTENT(IN ) :: InputFileName !< Name of the input file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: i_turb
INTEGER(IntKi) :: n_t_global !< loop counter
INTEGER(IntKi) :: NumTurbines ! Number of turbines in this simulation
INTEGER(IntKi) :: ErrStat2 ! local error status
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local error message
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_RestoreForVTKModeShape_Tary'
ErrStat = ErrID_None
ErrMsg = ""
NumTurbines = SIZE(Turbine)
if (NumTurbines /=1) then
call SetErrStat(ErrID_Fatal, "Mode-shape visualization is not available for multiple turbines.", ErrStat, ErrMsg, RoutineName)
return
end if
CALL ReadModeShapeFile( Turbine(1)%p_FAST, trim(InputFileName), ErrStat2, ErrMsg2, checkpointOnly=.true. )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev) return
CALL FAST_RestoreFromCheckpoint_Tary( t_initial, n_t_global, Turbine, trim(Turbine(1)%p_FAST%VTK_modes%CheckpointRoot), ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
DO i_turb = 1,NumTurbines
if (.not. allocated(Turbine(i_turb)%m_FAST%Lin%LinTimes)) then
call SetErrStat(ErrID_Fatal, "Mode-shape visualization requires a checkpoint file from a simulation with linearization analysis, but NLinTimes is 0.", ErrStat, ErrMsg, RoutineName)
return
end if
CALL FAST_RestoreForVTKModeShape_T(t_initial, Turbine(i_turb)%p_FAST, Turbine(i_turb)%y_FAST, Turbine(i_turb)%m_FAST, &
Turbine(i_turb)%ED, Turbine(i_turb)%BD, Turbine(i_turb)%SrvD, Turbine(i_turb)%AD14, Turbine(i_turb)%AD, Turbine(i_turb)%IfW, Turbine(i_turb)%OpFM, &
Turbine(i_turb)%HD, Turbine(i_turb)%SD, Turbine(i_turb)%ExtPtfm, Turbine(i_turb)%MAP, Turbine(i_turb)%FEAM, Turbine(i_turb)%MD, Turbine(i_turb)%Orca, &
Turbine(i_turb)%IceF, Turbine(i_turb)%IceD, Turbine(i_turb)%MeshMapData, trim(InputFileName), ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END DO
END SUBROUTINE FAST_RestoreForVTKModeShape_Tary
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine calculates the motions generated by mode shapes and outputs VTK data for it
SUBROUTINE FAST_RestoreForVTKModeShape_T(t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, InputFileName, ErrStat, ErrMsg )
REAL(DbKi), INTENT(IN ) :: t_initial !< initial time
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
TYPE(FAST_OutputFileType),INTENT(INOUT) :: y_FAST !< Output variables for the glue code
TYPE(FAST_MiscVarType), INTENT(INOUT) :: m_FAST !< Miscellaneous variables
TYPE(ElastoDyn_Data), INTENT(INOUT) :: ED !< ElastoDyn data
TYPE(BeamDyn_Data), INTENT(INOUT) :: BD !< BeamDyn data
TYPE(ServoDyn_Data), INTENT(INOUT) :: SrvD !< ServoDyn data
TYPE(AeroDyn14_Data), INTENT(INOUT) :: AD14 !< AeroDyn14 data
TYPE(AeroDyn_Data), INTENT(INOUT) :: AD !< AeroDyn data
TYPE(InflowWind_Data), INTENT(INOUT) :: IfW !< InflowWind data
TYPE(OpenFOAM_Data), INTENT(INOUT) :: OpFM !< OpenFOAM data
TYPE(HydroDyn_Data), INTENT(INOUT) :: HD !< HydroDyn data
TYPE(SubDyn_Data), INTENT(INOUT) :: SD !< SubDyn data
TYPE(ExtPtfm_Data), INTENT(INOUT) :: ExtPtfm !< ExtPtfm_MCKF data
TYPE(MAP_Data), INTENT(INOUT) :: MAPp !< MAP data
TYPE(FEAMooring_Data), INTENT(INOUT) :: FEAM !< FEAMooring data
TYPE(MoorDyn_Data), INTENT(INOUT) :: MD !< Data for the MoorDyn module
TYPE(OrcaFlex_Data), INTENT(INOUT) :: Orca !< OrcaFlex interface data
TYPE(IceFloe_Data), INTENT(INOUT) :: IceF !< IceFloe data
TYPE(IceDyn_Data), INTENT(INOUT) :: IceD !< All the IceDyn data used in time-step loop
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData !< Data for mapping between modules
CHARACTER(*), INTENT(IN ) :: InputFileName !< Name of the input file
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: dt ! time
REAL(DbKi) :: tprime ! time
INTEGER(IntKi) :: nt
INTEGER(IntKi) :: iLinTime ! generic loop counters
INTEGER(IntKi) :: it ! generic loop counters
INTEGER(IntKi) :: iMode ! generic loop counters
INTEGER(IntKi) :: ModeNo ! mode number
INTEGER(IntKi) :: NLinTimes
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'FAST_RestoreForVTKModeShape_T'
CHARACTER(1024) :: VTK_RootName
ErrStat = ErrID_None
ErrMsg = ""
CALL ReadModeShapeFile( p_FAST, trim(InputFileName), ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev) return
call ReadModeShapeMatlabFile( p_FAST, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev ) return
y_FAST%WriteThisStep = .true.
y_FAST%UnSum = -1
NLinTimes = min( p_FAST%VTK_modes%VTKNLinTimes, size(p_FAST%VTK_modes%x_eig_magnitude,2), p_FAST%NLinTimes )
VTK_RootName = p_FAST%VTK_OutFileRoot
select case (p_FAST%VTK_modes%VTKLinTim)
case (1)
do iMode = 1,p_FAST%VTK_modes%VTKLinModes
ModeNo = p_FAST%VTK_modes%VTKModes(iMode)
call GetTimeConstants(p_FAST%VTK_modes%DampedFreq_Hz(ModeNo), p_FAST%VTK_fps, nt, dt, p_FAST%VTK_tWidth )
if (nt > 500) cycle
p_FAST%VTK_OutFileRoot = trim(VTK_RootName)//'.Mode'//trim(num2lstr(ModeNo))
y_FAST%VTK_count = 1 ! we are skipping the reference meshes by starting at 1
do iLinTime = 1,NLinTimes
tprime = m_FAST%Lin%LinTimes(iLinTime) - m_FAST%Lin%LinTimes(1)
if (p_FAST%DT_UJac < p_FAST%TMax) then
m_FAST%calcJacobian = .true.
m_FAST%NextJacCalcTime = m_FAST%Lin%LinTimes(iLinTime)
end if
call SetOperatingPoint(iLinTime, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! set perturbation of states based on x_eig magnitude and phase
call PerturbOP(tprime, iLinTime, ModeNo, p_FAST, y_FAST, ED, BD, SrvD, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, &
IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
CALL CalcOutputs_And_SolveForInputs( -1, m_FAST%Lin%LinTimes(iLinTime), STATE_CURR, m_FAST%calcJacobian, m_FAST%NextJacCalcTime, &
p_FAST, m_FAST, .true., ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
call WriteVTK(m_FAST%Lin%LinTimes(iLinTime), p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
end do ! iLinTime
end do ! iMode
case (2)
do iMode = 1,p_FAST%VTK_modes%VTKLinModes
ModeNo = p_FAST%VTK_modes%VTKModes(iMode)
call GetTimeConstants(p_FAST%VTK_modes%DampedFreq_Hz(ModeNo), p_FAST%VTK_fps, nt, dt, p_FAST%VTK_tWidth )
if (nt > 500) cycle
do iLinTime = 1,NLinTimes
p_FAST%VTK_OutFileRoot = trim(VTK_RootName)//'.Mode'//trim(num2lstr(ModeNo))//'.LinTime'//trim(num2lstr(iLinTime))
y_FAST%VTK_count = 1 ! we are skipping the reference meshes by starting at 1
if (p_FAST%DT_UJac < p_FAST%TMax) then
m_FAST%calcJacobian = .true.
m_FAST%NextJacCalcTime = m_FAST%Lin%LinTimes(iLinTime)
end if
do it = 1,nt
tprime = (it-1)*dt
call SetOperatingPoint(iLinTime, p_FAST, y_FAST, m_FAST, ED, BD, SrvD, AD, IfW, OpFM, HD, SD, ExtPtfm, &
MAPp, FEAM, MD, Orca, IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! set perturbation of states based on x_eig magnitude and phase
call PerturbOP(tprime, iLinTime, ModeNo, p_FAST, y_FAST, ED, BD, SrvD, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, &
IceF, IceD, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
CALL CalcOutputs_And_SolveForInputs( -1, m_FAST%Lin%LinTimes(iLinTime), STATE_CURR, m_FAST%calcJacobian, m_FAST%NextJacCalcTime, &
p_FAST, m_FAST, .true., ED, BD, SrvD, AD14, AD, IfW, OpFM, HD, SD, ExtPtfm, MAPp, FEAM, MD, Orca, IceF, IceD, MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
call WriteVTK(m_FAST%Lin%LinTimes(iLinTime)+tprime, p_FAST, y_FAST, MeshMapData, ED, BD, AD, IfW, OpFM, HD, SD, ExtPtfm, SrvD, MAPp, FEAM, MD, Orca, IceF, IceD)
end do
end do ! iLinTime
end do ! iMode
end select
END SUBROUTINE FAST_RestoreForVTKModeShape_T
!----------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE GetTimeConstants(DampedFreq_Hz, VTK_fps, nt, dt, VTK_tWidth )
REAL(R8Ki), INTENT(IN ) :: DampedFreq_Hz
REAL(DbKi), INTENT(IN ) :: VTK_fps
INTEGER(IntKi), INTENT( OUT) :: nt !< number of steps
REAL(DbKi), INTENT( OUT) :: dt !< time step
INTEGER(IntKi), INTENT( OUT) :: VTK_tWidth
REAL(DbKi) :: cycle_time ! time for one cycle of mode
INTEGER(IntKi) :: NCycles
INTEGER(IntKi), PARAMETER :: MinFrames = 5
if (DampedFreq_Hz <= 0.0_DbKi) then
nt = huge(nt)
dt = epsilon(dt)
VTK_tWidth = 1
return
end if
nt = 1
NCycles = 0
do while (nt<MinFrames)
NCycles = NCycles + 1
cycle_time = NCycles * 1.0_DbKi / DampedFreq_Hz
nt = NINT( max(1.0_DbKi, VTK_fps) * cycle_time )
end do
dt = cycle_time / nt
VTK_tWidth = CEILING( log10( real(nt) ) ) + 1
END SUBROUTINE GetTimeConstants
!----------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE ReadModeShapeMatlabFile(p_FAST, ErrStat, ErrMsg)
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'ReadModeShapeMatlabFile'
INTEGER(4) :: FileType
INTEGER(4) :: nModes
INTEGER(4) :: nStates
INTEGER(4) :: NLinTimes
INTEGER(IntKi) :: iMode
INTEGER(IntKi) :: UnIn
ErrStat = ErrID_None
ErrMsg = ""
! Open data file.
CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2 )
CALL OpenBInpFile ( UnIn, trim(p_FAST%VTK_modes%MatlabFileName), ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
! Process the requested data records of this file.
CALL WrScr ( NewLine//' =======================================================' )
CALL WrScr ( ' Reading in data from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".'//NewLine )
! Read some of the header information.
READ (UnIn, IOSTAT=ErrStat2) FileType ! placeholder for future file format changes
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading FileType from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ (UnIn, IOSTAT=ErrStat2) nModes ! number of modes in the file
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading nModes from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ (UnIn, IOSTAT=ErrStat2) nStates ! number of states in the file
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading nStates from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ (UnIn, IOSTAT=ErrStat2) NLinTimes ! number of linearization times / azimuths in the file
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading NLinTimes from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
ALLOCATE( p_FAST%VTK_Modes%NaturalFreq_Hz(nModes), &
p_FAST%VTK_Modes%DampingRatio( nModes), &
p_FAST%VTK_Modes%DampedFreq_Hz( nModes), STAT=ErrStat2 )
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Error allocating arrays to read from file.', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ(UnIn, IOSTAT=ErrStat2) p_FAST%VTK_Modes%NaturalFreq_Hz ! read entire array
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading NaturalFreq_Hz array from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ(UnIn, IOSTAT=ErrStat2) p_FAST%VTK_Modes%DampingRatio ! read entire array
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading DampingRatio array from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ(UnIn, IOSTAT=ErrStat2) p_FAST%VTK_Modes%DampedFreq_Hz ! read entire array
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading DampedFreq_Hz array from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
if (nModes < p_FAST%VTK_Modes%VTKLinModes) CALL SetErrStat(ErrID_Severe,'Number of modes requested exceeds the number of modes in the linearization analysis file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName)
if (NLinTimes /= p_FAST%NLinTimes) CALL SetErrStat(ErrID_Severe,'Number of times linearization was performed is not the same as the number of linearization times in the linearization analysis file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName)
!Let's read only the number of modes we need to use
nModes = min( nModes, p_FAST%VTK_Modes%VTKLinModes )
ALLOCATE( p_FAST%VTK_Modes%x_eig_magnitude(nStates, NLinTimes, nModes), &
p_FAST%VTK_Modes%x_eig_phase( nStates, NLinTimes, nModes), STAT=ErrStat2 )
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Error allocating arrays to read from file.', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
do iMode = 1,nModes
READ(UnIn, IOSTAT=ErrStat2) p_FAST%VTK_Modes%x_eig_magnitude(:,:,iMode) ! read data for one mode
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading x_eig_magnitude from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
READ(UnIn, IOSTAT=ErrStat2) p_FAST%VTK_Modes%x_eig_phase(:,:,iMode) ! read data for one mode
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat ( ErrID_Fatal, 'Fatal error reading x_eig_phase from file "'//TRIM( p_FAST%VTK_modes%MatlabFileName )//'".', ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF
end do
END SUBROUTINE ReadModeShapeMatlabFile
!----------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE ReadModeShapeFile(p_FAST, InputFile, ErrStat, ErrMsg, checkpointOnly)
TYPE(FAST_ParameterType), INTENT(INOUT) :: p_FAST !< Parameters for the glue code
CHARACTER(*), INTENT(IN ) :: InputFile !< Name of the text input file to read
INTEGER(IntKi), INTENT( OUT) :: ErrStat !< Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg !< Error message if ErrStat /= ErrID_None
LOGICAL, OPTIONAL, INTENT(IN ) :: checkpointOnly !< Whether to return after reading checkpoint file name
! local variables
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'ReadModeShapeFile'
CHARACTER(1024) :: PriPath ! Path name of the primary file
INTEGER(IntKi) :: i
INTEGER(IntKi) :: UnIn
INTEGER(IntKi) :: UnEc
LOGICAL :: VTKLinTimes1
ErrStat = ErrID_None
ErrMsg = ""
UnEc = -1
CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located.
! Open data file.
CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2 )
CALL OpenFInpFile ( UnIn, InputFile, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) RETURN
CALL ReadCom( UnIn, InputFile, 'File header: (line 1)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadCom( UnIn, InputFile, 'File header: (line 2)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
!----------- FILE NAMES ----------------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: File Names', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%CheckpointRoot, 'CheckpointRoot', 'Name of the checkpoint file written by FAST when linearization data was produced', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF ( PathIsRelative( p_FAST%VTK_modes%CheckpointRoot ) ) p_FAST%VTK_modes%CheckpointRoot = TRIM(PriPath)//TRIM(p_FAST%VTK_modes%CheckpointRoot)
if (present(checkpointOnly)) then
if (checkpointOnly) then
call cleanup()
return
end if
end if
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%MatlabFileName, 'MatlabFileName', 'Name of the file with eigenvectors written by Matlab', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF ( ErrStat >= AbortErrLev ) THEN
CALL Cleanup()
RETURN
END IF
IF ( PathIsRelative( p_FAST%VTK_modes%MatlabFileName ) ) p_FAST%VTK_modes%MatlabFileName = TRIM(PriPath)//TRIM(p_FAST%VTK_modes%MatlabFileName)
!----------- VISUALIZATION OPTIONS ------------------------------------------
CALL ReadCom( UnIn, InputFile, 'Section Header: Visualization Options', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%VTKLinModes, 'VTKLinModes', 'Number of modes to visualize', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (p_FAST%VTK_modes%VTKLinModes <= 0) CALL SetErrStat( ErrID_Fatal, "VTKLinModes must be a positive number.", ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev) then
CALL Cleanup()
RETURN
end if
call AllocAry( p_FAST%VTK_modes%VTKModes, p_FAST%VTK_modes%VTKLinModes, 'VTKModes', ErrStat2, ErrMsg2)
call SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if ( ErrStat >= AbortErrLev ) then
call Cleanup()
return
end if
p_FAST%VTK_modes%VTKModes = -1
CALL ReadAry( UnIn, InputFile, p_FAST%VTK_modes%VTKModes, p_FAST%VTK_modes%VTKLinModes, 'VTKModes', 'List of modes to visualize', ErrStat2, ErrMsg2, UnEc )
! note that we don't check the ErrStat here; if the user entered fewer than p_FAST%VTK_modes%VTKLinModes values, we will use the
! last entry to fill in remaining values.
!Check 1st value, we need at least one good value from user or throw error
IF (p_FAST%VTK_modes%VTKModes(1) < 0 ) THEN
call SetErrStat( ErrID_Fatal, "VTKModes must contain positive numbers.", ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
ELSE
DO i = 2, p_FAST%VTK_modes%VTKLinModes
IF ( p_FAST%VTK_modes%VTKModes(i) < 0 ) THEN
p_FAST%VTK_modes%VTKModes(i)=p_FAST%VTK_modes%VTKModes(i-1) + 1
ENDIF
ENDDO
ENDIF
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%VTKLinScale, 'VTKLinScale', 'Mode shape visualization scaling factor', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%VTKLinTim, 'VTKLinTim', 'Switch to make one animation for all LinTimes together (1) or separate animations for each LinTimes(2)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadVar( UnIn, InputFile, VTKLinTimes1, 'VTKLinTimes1', 'If VTKLinTim=2, visualize modes at LinTimes(1) only?', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL ReadVar( UnIn, InputFile, p_FAST%VTK_modes%VTKLinPhase, 'VTKLinPhase', 'Phase when making one animation for all LinTimes together (used only when VTKLinTim=1)', ErrStat2, ErrMsg2, UnEc )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! overwrite these based on inputs:
if (p_FAST%VTK_modes%VTKLinTim == 2) then
p_FAST%VTK_modes%VTKLinPhase = 0 ! "Phase when making one animation for all LinTimes together (used only when VTKLinTim=1)" -
if (VTKLinTimes1) then
p_FAST%VTK_modes%VTKNLinTimes = 1
else
p_FAST%VTK_modes%VTKNLinTimes = p_FAST%NLinTimes
end if
else
p_FAST%VTK_modes%VTKNLinTimes = p_FAST%NLinTimes
end if
contains
SUBROUTINE Cleanup()
IF (UnIn > 0) CLOSE(UnIn)
END SUBROUTINE Cleanup
END SUBROUTINE ReadModeShapeFile
!----------------------------------------------------------------------------------------------------------------------------------
END MODULE FAST_Subs
!----------------------------------------------------------------------------------------------------------------------------------
| apache-2.0 |
ClaudioNahmad/Servicio-Social | Parametros/CosmoMC/CosmoMC-master/source/MpiUtils.f90 | 1 | 4092 | module MpiUtils
implicit none
#ifdef MPI
include "mpif.h"
#endif
integer, parameter :: TTimer_dp = Kind(1.d0)
Type TTimer
real(TTimer_dp) start_time
contains
procedure :: Start => TTimer_Start
procedure :: Time => TTimer_Time
procedure :: WriteTime => TTimer_WriteTime
end type TTimer
contains
function GetMpiRank()
integer GetMpiRank
#ifdef MPI
integer ierror
call mpi_comm_rank(mpi_comm_world,GetMPIrank,ierror)
if (ierror/=MPI_SUCCESS) call MpiStop('MPI fail')
#else
GetMpiRank=0
#endif
end function GetMpiRank
function IsMainMPI()
logical IsMainMPI
IsMainMPI = GetMpiRank() == 0
end function IsMainMPI
subroutine MpiStop(Msg)
character(LEN=*), intent(in), optional :: Msg
integer i
#ifdef MPI
integer ierror, MpiRank
#endif
if (present(Msg)) write(*,*) trim(Msg)
#ifdef MPI
call mpi_comm_rank(mpi_comm_world,MPIrank,ierror)
write (*,*) 'MpiStop: ', MpiRank
call MPI_ABORT(MPI_COMM_WORLD,i)
#endif
i=1 !put breakpoint on this line to debug
stop
end subroutine MpiStop
subroutine MpiStat(MpiID, MpiSize)
implicit none
integer MpiID,MpiSize
#ifdef MPI
integer ierror
call mpi_comm_rank(mpi_comm_world,MpiID,ierror)
if (ierror/=MPI_SUCCESS) call MpiStop('MpiStat: MPI rank')
call mpi_comm_size(mpi_comm_world,MpiSize,ierror)
#else
MpiID=0
MpiSize=1
#endif
end subroutine MpiStat
subroutine MpiQuietWait
!Set MPI thread to sleep, e.g. so can run openmp on cpu instead
#ifdef MPI
integer flag, ierr, STATUS(MPI_STATUS_SIZE)
integer i, MpiId, MpiSize
call MpiStat(MpiID, MpiSize)
if (MpiID/=0) then
do
call MPI_IPROBE(0,0,MPI_COMM_WORLD,flag, MPI_STATUS_IGNORE,ierr)
if (flag/=0) then
call MPI_RECV(i,1,MPI_INTEGER, 0,0,MPI_COMM_WORLD,status,ierr)
exit
end if
call sleep(1)
end do
end if
#endif
end subroutine
subroutine MpiWakeQuietWait
#ifdef MPI
integer j, MpiId, MpiSize, ierr,r
call MpiStat(MpiID, MpiSize)
if (MpiID==0) then
do j=1, MpiSize-1
call MPI_ISSEND(MpiId,1,MPI_INTEGER, j,0,MPI_COMM_WORLD,r,ierr)
end do
end if
#endif
end subroutine MpiWakeQuietWait
subroutine MpiShareString(S, from)
character(LEN=:), allocatable :: S
integer from
#ifdef MPI
integer inlen, rank, ierror
rank = GetMpiRank()
if (rank==from) inlen=len(S)
CALL MPI_Bcast(inlen, 1, MPI_INTEGER, from, MPI_COMM_WORLD, ierror)
if (ierror/=MPI_SUCCESS) call MpiStop('MpiShareString: fail')
if (rank /= from ) allocate(character(inlen)::S)
CALL MPI_Bcast(S, LEN(S), MPI_CHARACTER, from, MPI_COMM_WORLD, ierror)
#endif
end subroutine MpiShareString
function TimerTime()
real(TTimer_dp) time
real(TTimer_dp) :: TimerTime
#ifdef MPI
TimerTime = MPI_WTime()
#else
call cpu_time(time)
TimerTime= time
#endif
end function TimerTime
subroutine TTimer_Start(this)
class(TTimer) :: this
this%start_time = TimerTime()
end subroutine TTimer_Start
real(TTimer_dp) function TTimer_Time(this)
class(TTimer) :: this
TTimer_Time = TimerTime() - this%start_time
end function TTimer_Time
subroutine TTimer_WriteTime(this,Msg, start)
class(TTimer) :: this
character(LEN=*), intent(in), optional :: Msg
real(TTimer_dp), optional :: start
real(TTimer_dp) T, DeltaT
character(LEN=:), allocatable :: tmp
if (present(start)) then
T=start
else
T=this%start_time
end if
DeltaT = TimerTime() - T
if (present(Msg)) then
tmp = trim(Msg)//': '
if (DeltaT > 0.00002 .and. DeltaT < 1000 .and. len_trim(tmp)<24) then
write (*,'(a25,f10.5)') tmp, DeltaT
else
write (*,*) trim(Msg)//': ', DeltaT
end if
end if
if (.not. present(start)) this%start_time = TimerTime()
end subroutine TTimer_WriteTime
end module MpiUtils
| gpl-3.0 |
theDataGeek/pyhsmm | pyhsmm/deps/Eigen3/lapack/dsecnd_NONE.f | 295 | 1282 | *> \brief \b DSECND returns nothing
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* DOUBLE PRECISION FUNCTION DSECND( )
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DSECND returns nothing instead of returning the user time for a process in seconds.
*> If you are using that routine, it means that neither EXTERNAL ETIME,
*> EXTERNAL ETIME_, INTERNAL ETIME, INTERNAL CPU_TIME is available on
*> your machine.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup auxOTHERauxiliary
*
* =====================================================================
DOUBLE PRECISION FUNCTION DSECND( )
*
* -- LAPACK auxiliary routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* =====================================================================
*
DSECND = 0.0D+0
RETURN
*
* End of DSECND
*
END
| mit |
ClaudioNahmad/Servicio-Social | Parametros/CosmoMC/prerrequisitos/plc-2.0/src/lowlike/read_archive_map.f90 | 4 | 2143 | ! ============================================================================
! "Read_Archive_Map" reads a sky map from a binary table in a FITS file. The
! map consists of two columns in the table; the first contains temperature
! and the second contains N_Obs.
!
! Arguments:
! FileName Character The FITS filename.
! Temp Real*4 The array of temperatures.
! NObs Real*4 The array of observation numbers.
! NPix Integer The number of elements in the output arrays.
! Status Integer A status code: 0=success.
!
! Written by Michael R. Greason, SSAI, 07 February 2006.
! ============================================================================
Subroutine Read_Archive_Map (FileName, Temp, NObs, NPix, Status)
!
Character(*), Intent(In) :: FileName
Integer (Kind=4), Intent(Out) :: NPix
Integer (Kind=4), Intent(Out) :: Status
Real (Kind=4), Dimension(:), Intent(Out) :: Temp
Real (Kind=4), Dimension(:), Intent(Out) :: NObs
!
Character (80) :: str
Integer (Kind=4) :: i, n, Unit, blk, typ
Logical :: anyf
! ----------------------------------------------------------------------------
! Open the FITS file.
!
NPix = 0
Status = 0
i = 0
Call FTGIOU (Unit, Status)
Call FTOPEN (Unit, FileName, i, blk, Status)
!
! Select the HDU.
!
i = 1
typ = 0
Do While ((typ .NE. 2) .AND. (Status .EQ. 0))
i = i + 1
Call FTMAHD (Unit, i, typ, Status)
End Do
If ((typ .NE. 2) .OR. (Status .NE. 0)) Then
Print 1, trim(FileName)
Return
End If
!
! Extract the number of pixels in the map.
!
Call FTGNRW (Unit, i, Status)
If (Status .NE. 0) Return
NPix = i
!
! Extract the map.
!
Call FTGCVE (Unit, 1, 1, 1, NPix, 0.0E0, Temp, anyf, Status)
Call FTGCVE (Unit, 2, 1, 1, NPix, 0.0E0, NObs, anyf, Status)
!
! Close the FITS file.
!
Call FTCLOS (Unit, Status)
If (Unit .GE. 50) Call FTFIOU (Unit, Status)
!
Return
! ----------------------------------------------------------------------------
1 Format ('Read_Archive_Map: There is no binary FITS table extension in ',A)
!
End Subroutine Read_Archive_Map
| gpl-3.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/elemental_scalar_args_2.f90 | 19 | 1367 | ! { dg-do run }
! Test the fix for PR55618, in which character scalar function arguments to
! elemental functions would gain an extra indirect reference thus causing
! failures in Vst17.f95, Vst 30.f95 and Vst31.f95 in the iso_varying_string
! testsuite, where elemental tests are done.
!
! Reported by Tobias Burnus <burnus@gcc.gnu.org>
!
integer, dimension (2) :: i = [1,2]
integer :: j = 64
character (len = 2) :: chr1 = "lm"
character (len = 1), dimension (2) :: chr2 = ["r", "s"]
if (any (foo (i, bar()) .ne. ["a", "b"])) STOP 1! This would fail
if (any (foo (i, "xy") .ne. ["x", "y"])) STOP 2! OK - not a function
if (any (foo (i, chr1) .ne. ["l", "m"])) STOP 3! ditto
if (any (foo (i, char (j)) .ne. ["A", "B"])) STOP 4! This would fail
if (any (foo (i, chr2) .ne. ["s", "u"])) STOP 5! OK - not a scalar
if (any (foo (i, bar2()) .ne. ["e", "g"])) STOP 6! OK - not a scalar function
contains
elemental character(len = 1) function foo (arg1, arg2)
integer, intent (in) :: arg1
character(len = *), intent (in) :: arg2
if (len (arg2) > 1) then
foo = arg2(arg1:arg1)
else
foo = char (ichar (arg2) + arg1)
end if
end function
character(len = 2) function bar ()
bar = "ab"
end function
function bar2 () result(res)
character (len = 1), dimension(2) :: res
res = ["d", "e"]
end function
end
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f | 8 | 1269 | C Test program for common block debugging. G. Helffrich 11 July 2004.
C { dg-do compile }
C { dg-skip-if "DWARF-2 only" { "*-*-*" } { "*" } { "-gdwarf-2" } }
C { dg-options "-dA" }
common i,j
common /label/l,m
i = 1
j = 2
k = 3
l = 4
m = 5
call sub
end
subroutine sub
common /label/l,m
logical first
save n
data first /.true./
if (first) then
n = 0
first = .false.
endif
n = n + 1
l = l + 1
return
end
C { dg-final { scan-assembler "DIE\[^\n\]*DW_TAG_common_block" } }
C { dg-final { scan-assembler "(DW_AT_name: \"__BLNK__\"|\"__BLNK__\[^\n\]*\"\[^\n\]*DW_AT_name)" } }
C { dg-final { scan-assembler "DIE\[^\n\]*DW_TAG_variable" } }
C { dg-final { scan-assembler "\"i\[^\n\]*\"\[^\n\]*DW_AT_name" } }
C { dg-final { scan-assembler "\"j\[^\n\]*\"\[^\n\]*DW_AT_name" } }
C { dg-final { scan-assembler "DIE\[^\n\]*DW_TAG_common_block" } }
C { dg-final { scan-assembler "(DW_AT_name: \"label\"|\"label\[^\n\]*\"\[^\n\]*DW_AT_name)" } }
C { dg-final { scan-assembler "DIE\[^\n\]*DW_TAG_variable" } }
C { dg-final { scan-assembler "\"l\[^\n\]*\"\[^\n\]*DW_AT_name" } }
C { dg-final { scan-assembler "\"m\[^\n\]*\"\[^\n\]*DW_AT_name" } }
| gpl-2.0 |
ensemblr/llvm-project-boilerplate | include/llvm/projects/openmp/testsuite/fortran/par_do_ordered.f | 11 | 2042 | <ompts:test>
<ompts:testdescription>Test which checks the omp parallel do ordered directive</ompts:testdescription>
<ompts:ompversion>2.0</ompts:ompversion>
<ompts:directive>omp parallel do ordered</ompts:directive>
<ompts:dependences>par schedule stat</ompts:dependences>
<ompts:testcode>
! **********************************************************
! Helper function is_larger
! **********************************************************
INTEGER FUNCTION i_islarger2(i)
IMPLICIT NONE
INTEGER i
INTEGER last_i,islarger
COMMON /com/ last_i
INCLUDE "omp_testsuite.f"
! print *, "last_i",last_i, "i", i
! last_i is a global variable
IF ( i .GT. last_i ) THEN
islarger = 1
ELSE
islarger = 0
END IF
last_i = i
i_islarger2 = islarger
END FUNCTION
INTEGER FUNCTION <ompts:testcode:functionname>par_do_ordered</ompts:testcode:functionname>()
IMPLICIT NONE
COMMON /com/ last_i
INTEGER known_sum,i, last_i
<ompts:orphan:vars>
INTEGER is_larger,sum,i_islarger2
COMMON /orphvars/ is_larger,sum,i
</ompts:orphan:vars>
sum=0
is_larger=1
last_i=0
!$omp parallel do schedule(static, 1) ordered
DO i=1, 99
<ompts:orphan>
<ompts:check>
!$omp ordered
</ompts:check>
IF( i_islarger2(i) .EQ. 1 .AND. is_larger .EQ. 1 ) THEN
is_larger = 1
ELSE
is_larger = 0
END IF
sum = sum + i
<ompts:check>
!$omp end ordered
</ompts:check>
</ompts:orphan>
END DO
!$omp end parallel do
known_sum = (99*100)/2
!Yi Wen; Sun compiler will fail sometimes
! print *, "sum", sum, "ks", known_sum, "la", is_larger
IF ( known_sum .EQ. sum .AND. is_larger .EQ. 1 ) THEN
<testfunctionname></testfunctionname> = 1
ELSE
<testfunctionname></testfunctionname> = 0
END IF
END FUNCTION
</ompts:testcode>
</ompts:test>
| mit |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/dec_static_2.f90 | 19 | 1236 | ! { dg-do run }
! { dg-options "-fdec-static -fno-automatic -finit-local-zero" }
!
! Test STATIC and AUTOMATIC with -fno-automatic and recursive subroutines.
!
subroutine assert(s, i1, i2)
implicit none
integer, intent(in) :: i1, i2
character(*), intent(in) :: s
if (i1 .ne. i2) then
print *, s, ": expected ", i2, " but was ", i1
STOP 1
endif
endsubroutine
function f (x)
implicit none
integer f
integer, intent(in) :: x
integer, static :: a ! should be SAVEd
a = a + x ! should increment by x every time
f = a
return
endfunction
recursive subroutine g (x)
implicit none
integer, intent(in) :: x
integer, automatic :: a ! should be automatic (in recursive)
a = a + x ! should be set to x every time
call assert ("g%a", a, x)
endsubroutine
subroutine h (x)
implicit none
integer, intent(in) :: x
integer, automatic :: a ! should be automatic (outside recursive)
a = a + x ! should be set to x every time
call assert ("h%a", a, x)
endsubroutine
implicit none
integer :: f
! Should return static value of c; accumulates x
call assert ("f()", f(3), 3)
call assert ("f()", f(4), 7)
call assert ("f()", f(2), 9)
call g(3)
call g(4)
call g(2)
call h(3)
call h(4)
call h(2)
end
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/g77/980519-2.f | 209 | 1605 | c { dg-do compile }
* Date: Fri, 17 Apr 1998 14:12:51 +0200
* From: Jean-Paul Jeannot <jeannot@gx-tech.fr>
* Organization: GX Technology France
* To: egcs-bugs@cygnus.com
* Subject: identified bug in g77 on Alpha
*
* Dear Sir,
*
* You will find below the assembly code of a simple Fortran routine which
* crashes with segmentation fault when storing the first element
* in( jT_f-hd_T ) = Xsp
* whereas everything is fine when commenting this line.
*
* The assembly code (generated with
* -ffast-math -fexpensive-optimizations -fomit-frame-pointer -fno-inline
* or with -O5)
* uses a zapnot instruction to copy an address.
* BUT the zapnot parameter is 15 (copuing 4 bytes) instead of 255 (to copy
* 8 bytes).
*
* I guess this is typically a 64 bit issue. As, from my understanding,
* zapnots are used a lot to copy registers, this may create problems
* elsewhere.
*
* Thanks for your help
*
* Jean-Paul Jeannot
*
subroutine simul_trace( in, Xsp, Ysp, Xrcv, Yrcv )
c Next declaration added on transfer to gfortran testsuite
integer hd_S, hd_Z, hd_T
common /Idim/ jT_f, jT_l, nT, nT_dim
common /Idim/ jZ_f, jZ_l, nZ, nZ_dim
common /Idim/ jZ2_f, jZ2_l, nZ2, nZ2_dim
common /Idim/ jzs_f, jzs_l, nzs, nzs_dim, l_amp
common /Idim/ hd_S, hd_Z, hd_T
common /Idim/ nlay, nlayz
common /Idim/ n_work
common /Idim/ nb_calls
real Xsp, Ysp, Xrcv, Yrcv
real in( jT_f-hd_T : jT_l )
in( jT_f-hd_T ) = Xsp
in( jT_f-hd_T + 1 ) = Ysp
in( jT_f-hd_T + 2 ) = Xrcv
in( jT_f-hd_T + 3 ) = Yrcv
end
| gpl-2.0 |
rofirrim/gcc-tiny | libgomp/testsuite/libgomp.oacc-fortran/collapse-6.f90 | 72 | 1113 | ! { dg-do run }
! collapse3.f90:test3
program collapse6
integer :: i, j, k, a(1:7, -3:5, 12:19), b(1:7, -3:5, 12:19)
integer :: v1, v2, v3, v4, v5, v6, v7, v8, v9
logical :: l, r
l = .false.
r = .false.
a(:, :, :) = 0
b(:, :, :) = 0
v1 = 3
v2 = 6
v3 = -2
v4 = 4
v5 = 13
v6 = 18
v7 = 1
v8 = 1
v9 = 1
!$acc parallel
!$acc loop collapse (3) reduction (.or.:l)
do i = v1, v2, v7
do j = v3, v4, v8
do k = v5, v6, v9
l = l.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
l = l.or.k.lt.13.or.k.gt.18
if (.not.l) a(i, j, k) = a(i, j, k) + 1
end do
end do
end do
!$acc end parallel
do i = v1, v2, v7
do j = v3, v4, v8
do k = v5, v6, v9
r = r.or.i.lt.2.or.i.gt.6.or.j.lt.-2.or.j.gt.4
r = r.or.k.lt.13.or.k.gt.18
if (.not.r) b(i, j, k) = b(i, j, k) + 1
end do
end do
end do
if (l .neqv. r) call abort
do i = v1, v2, v7
do j = v3, v4, v8
do k = v5, v6, v9
if (a(i, j, k) .ne. b(i, j, k)) call abort
end do
end do
end do
end program collapse6
| gpl-2.0 |
OpenFAST/OpenFAST | modules/turbsim/src/BlankModVKM.f90 | 1 | 2650 | MODULE ModifiedvKrm_mod
USE NWTC_Library
IMPLICIT NONE
CONTAINS
!=======================================================================
SUBROUTINE Mod_vKrm ( Ht, Ucmp, Spec )
! This subroutine defines the "Improved" von Karman PSD model.
! The use of this subroutine requires that all variables have the units of meters and seconds.
IMPLICIT NONE
!Passed variables
REAL(ReKi), INTENT(IN) :: Ht ! height
REAL(ReKi), INTENT(IN) :: UCmp ! wind speed
REAL(ReKi), INTENT( OUT) :: Spec (:,:)
Spec = 0.0_ReKi
RETURN
END SUBROUTINE Mod_vKrm
!=======================================================================
SUBROUTINE ScaleMODVKM(Ht,UCmp, LambdaU, LambdaV, LambdaW)
! THIS SUBROUTINE DEFINES HUB SCALE PARMS FOR Modified von KARMAN PSD MODEL
IMPLICIT NONE
REAL(ReKi), INTENT(IN) :: Ht ! height
REAL(ReKi), INTENT(IN) :: UCmp ! wind speed
REAL(ReKi) :: LambdaU
REAL(ReKi) :: LambdaV
REAL(ReKi) :: LambdaW
RETURN
END SUBROUTINE ScaleMODVKM
!=======================================================================
FUNCTION FindZ0(z, sigma, U, f)
! This function is used in the Modified von Karman model to
! determine the necessary surface roughness length for a given sigma.
IMPLICIT NONE
REAL(ReKi) :: FindZ0 ! Estimated surface roughness length
REAL(ReKi),INTENT(IN) :: z ! Hub height
REAL(ReKi),INTENT(IN) :: sigma ! Target std deviation
REAL(ReKi),INTENT(IN) :: U ! Hub height wind speed
REAL(ReKi),INTENT(IN) :: f ! Coriolis parameter
FindZ0 = 1.0 ! a default value
RETURN
END FUNCTION FindZ0
!=======================================================================
FUNCTION CalcDiff(z0Guess, z, sigma, U, f)
! This function calculates the difference between the specified
! sigma and the calculated one.
IMPLICIT NONE
REAL(ReKi) :: CalcDiff ! Output - will be nearly zero if surface roughness is correct
REAL(ReKi), INTENT(IN) :: z0Guess ! estimated surface roughness
REAL(ReKi), INTENT(IN) :: z ! Hub height (m)
REAL(ReKi), INTENT(IN) :: sigma ! Target standard deviation (m/s)
REAL(ReKi), INTENT(IN) :: U ! Mean hub-height wind speed (m/s)
REAL(ReKi), INTENT(IN) :: f ! Coriolis parameter
CalcDiff = 0.0
RETURN
END FUNCTION CalcDiff
!=======================================================================
END MODULE ModifiedvKrm_mod
| apache-2.0 |
Pakketeretet2/lammps | lib/linalg/zung2l.f | 19 | 5288 | *> \brief \b ZUNG2L generates all or part of the unitary matrix Q from a QL factorization determined by cgeqlf (unblocked algorithm).
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download ZUNG2L + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zung2l.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zung2l.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zung2l.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE ZUNG2L( M, N, K, A, LDA, TAU, WORK, INFO )
*
* .. Scalar Arguments ..
* INTEGER INFO, K, LDA, M, N
* ..
* .. Array Arguments ..
* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZUNG2L generates an m by n complex matrix Q with orthonormal columns,
*> which is defined as the last n columns of a product of k elementary
*> reflectors of order m
*>
*> Q = H(k) . . . H(2) H(1)
*>
*> as returned by ZGEQLF.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix Q. M >= 0.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix Q. M >= N >= 0.
*> \endverbatim
*>
*> \param[in] K
*> \verbatim
*> K is INTEGER
*> The number of elementary reflectors whose product defines the
*> matrix Q. N >= K >= 0.
*> \endverbatim
*>
*> \param[in,out] A
*> \verbatim
*> A is COMPLEX*16 array, dimension (LDA,N)
*> On entry, the (n-k+i)-th column must contain the vector which
*> defines the elementary reflector H(i), for i = 1,2,...,k, as
*> returned by ZGEQLF in the last k columns of its array
*> argument A.
*> On exit, the m-by-n matrix Q.
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The first dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*>
*> \param[in] TAU
*> \verbatim
*> TAU is COMPLEX*16 array, dimension (K)
*> TAU(i) must contain the scalar factor of the elementary
*> reflector H(i), as returned by ZGEQLF.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is COMPLEX*16 array, dimension (N)
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> = 0: successful exit
*> < 0: if INFO = -i, the i-th argument has an illegal value
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date December 2016
*
*> \ingroup complex16OTHERcomputational
*
* =====================================================================
SUBROUTINE ZUNG2L( M, N, K, A, LDA, TAU, WORK, INFO )
*
* -- LAPACK computational routine (version 3.7.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* December 2016
*
* .. Scalar Arguments ..
INTEGER INFO, K, LDA, M, N
* ..
* .. Array Arguments ..
COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
COMPLEX*16 ONE, ZERO
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
$ ZERO = ( 0.0D+0, 0.0D+0 ) )
* ..
* .. Local Scalars ..
INTEGER I, II, J, L
* ..
* .. External Subroutines ..
EXTERNAL XERBLA, ZLARF, ZSCAL
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX
* ..
* .. Executable Statements ..
*
* Test the input arguments
*
INFO = 0
IF( M.LT.0 ) THEN
INFO = -1
ELSE IF( N.LT.0 .OR. N.GT.M ) THEN
INFO = -2
ELSE IF( K.LT.0 .OR. K.GT.N ) THEN
INFO = -3
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -5
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'ZUNG2L', -INFO )
RETURN
END IF
*
* Quick return if possible
*
IF( N.LE.0 )
$ RETURN
*
* Initialise columns 1:n-k to columns of the unit matrix
*
DO 20 J = 1, N - K
DO 10 L = 1, M
A( L, J ) = ZERO
10 CONTINUE
A( M-N+J, J ) = ONE
20 CONTINUE
*
DO 40 I = 1, K
II = N - K + I
*
* Apply H(i) to A(1:m-k+i,1:n-k+i) from the left
*
A( M-N+II, II ) = ONE
CALL ZLARF( 'Left', M-N+II, II-1, A( 1, II ), 1, TAU( I ), A,
$ LDA, WORK )
CALL ZSCAL( M-N+II-1, -TAU( I ), A( 1, II ), 1 )
A( M-N+II, II ) = ONE - TAU( I )
*
* Set A(m-k+i+1:m,n-k+i) to zero
*
DO 30 L = M - N + II + 1, M
A( L, II ) = ZERO
30 CONTINUE
40 CONTINUE
RETURN
*
* End of ZUNG2L
*
END
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | libgfortran/generated/_sqrt_r4.F90 | 4 | 1473 | ! Copyright (C) 2002-2021 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 3 of the License, or (at your option) any later version.
!GNU libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_4)
#ifdef HAVE_SQRTF
elemental function _gfortran_specific__sqrt_r4 (parm)
real (kind=4), intent (in) :: parm
real (kind=4) :: _gfortran_specific__sqrt_r4
_gfortran_specific__sqrt_r4 = sqrt (parm)
end function
#endif
#endif
| gpl-2.0 |
ClaudioNahmad/Servicio-Social | Parametros/CosmoMC/prerrequisitos/openmpi-2.0.2/ompi/mpi/fortran/use-mpi-f08/alltoallv_f08.F90 | 1 | 1103 | ! -*- f90 -*-
!
! Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
! All rights reserved.
! $COPYRIGHT$
#include "ompi/mpi/fortran/configure-fortran-output.h"
subroutine MPI_Alltoallv_f08(sendbuf,sendcounts,sdispls,sendtype,recvbuf,&
recvcounts,rdispls,recvtype,comm,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm
use :: mpi_f08, only : ompi_alltoallv_f
implicit none
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf, recvbuf
INTEGER, INTENT(IN) :: sendcounts(*), sdispls(*), recvcounts(*), rdispls(*)
TYPE(MPI_Datatype), INTENT(IN) :: sendtype
TYPE(MPI_Datatype), INTENT(IN) :: recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
integer :: c_ierror
call ompi_alltoallv_f(sendbuf,sendcounts,sdispls,sendtype%MPI_VAL,&
recvbuf,recvcounts,rdispls,recvtype%MPI_VAL,comm%MPI_VAL,c_ierror)
if (present(ierror)) ierror = c_ierror
end subroutine MPI_Alltoallv_f08
| gpl-3.0 |
sonnyhu/scipy | scipy/linalg/src/id_dist/src/dfft.f | 128 | 94317 | C
C FFTPACK
C
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C
C VERSION 4 APRIL 1985
C
C A PACKAGE OF FORTRAN SUBPROGRAMS FOR THE FAST FOURIER
C TRANSFORM OF PERIODIC AND OTHER SYMMETRIC SEQUENCES
C
C BY
C
C PAUL N SWARZTRAUBER
C
C NATIONAL CENTER FOR ATMOSPHERIC RESEARCH BOULDER,COLORADO 80307
C
C WHICH IS SPONSORED BY THE NATIONAL SCIENCE FOUNDATION
C
C * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
C
C
C THIS PACKAGE CONSISTS OF PROGRAMS WHICH PERFORM FAST FOURIER
C TRANSFORMS FOR BOTH COMPLEX AND REAL PERIODIC SEQUENCES AND
C CERTAIN OTHER SYMMETRIC SEQUENCES THAT ARE LISTED BELOW.
C
C 1. DFFTI INITIALIZE DFFTF AND DFFTB
C 2. DFFTF FORWARD TRANSFORM OF A REAL PERIODIC SEQUENCE
C 3. DFFTB BACKWARD TRANSFORM OF A REAL COEFFICIENT ARRAY
C
C 4. DZFFTI INITIALIZE DZFFTF AND DZFFTB
C 5. DZFFTF A SIMPLIFIED REAL PERIODIC FORWARD TRANSFORM
C 6. DZFFTB A SIMPLIFIED REAL PERIODIC BACKWARD TRANSFORM
C
C 7. DSINTI INITIALIZE DSINT
C 8. DSINT SINE TRANSFORM OF A REAL ODD SEQUENCE
C
C 9. DCOSTI INITIALIZE DCOST
C 10. DCOST COSINE TRANSFORM OF A REAL EVEN SEQUENCE
C
C 11. DSINQI INITIALIZE DSINQF AND DSINQB
C 12. DSINQF FORWARD SINE TRANSFORM WITH ODD WAVE NUMBERS
C 13. DSINQB UNNORMALIZED INVERSE OF DSINQF
C
C 14. DCOSQI INITIALIZE DCOSQF AND DCOSQB
C 15. DCOSQF FORWARD COSINE TRANSFORM WITH ODD WAVE NUMBERS
C 16. DCOSQB UNNORMALIZED INVERSE OF DCOSQF
C
C 17. ZFFTI INITIALIZE ZFFTF AND ZFFTB
C 18. ZFFTF FORWARD TRANSFORM OF A COMPLEX PERIODIC SEQUENCE
C 19. ZFFTB UNNORMALIZED INVERSE OF ZFFTF
C
C
C ******************************************************************
C
C SUBROUTINE DFFTI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DFFTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH DFFTF AND DFFTB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C THE SAME WORK ARRAY CAN BE USED FOR BOTH DFFTF AND DFFTB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N. THE CONTENTS OF
C WSAVE MUST NOT BE CHANGED BETWEEN CALLS OF DFFTF OR DFFTB.
C
C ******************************************************************
C
C SUBROUTINE DFFTF(N,R,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DFFTF COMPUTES THE FOURIER COEFFICIENTS OF A REAL
C PERODIC SEQUENCE (FOURIER ANALYSIS). THE TRANSFORM IS DEFINED
C BELOW AT OUTPUT PARAMETER R.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY R TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C N MAY CHANGE SO LONG AS DIFFERENT WORK ARRAYS ARE PROVIDED
C
C R A REAL ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C IN THE PROGRAM THAT CALLS DFFTF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY DFFTF AND DFFTB.
C
C
C OUTPUT PARAMETERS
C
C R R(1) = THE SUM FROM I=1 TO I=N OF R(I)
C
C IF N IS EVEN SET L =N/2 , IF N IS ODD SET L = (N+1)/2
C
C THEN FOR K = 2,...,L
C
C R(2*K-2) = THE SUM FROM I = 1 TO I = N OF
C
C R(I)*COS((K-1)*(I-1)*2*PI/N)
C
C R(2*K-1) = THE SUM FROM I = 1 TO I = N OF
C
C -R(I)*SIN((K-1)*(I-1)*2*PI/N)
C
C IF N IS EVEN
C
C R(N) = THE SUM FROM I = 1 TO I = N OF
C
C (-1)**(I-1)*R(I)
C
C ***** NOTE
C THIS TRANSFORM IS UNNORMALIZED SINCE A CALL OF DFFTF
C FOLLOWED BY A CALL OF DFFTB WILL MULTIPLY THE INPUT
C SEQUENCE BY N.
C
C WSAVE CONTAINS RESULTS WHICH MUST NOT BE DESTROYED BETWEEN
C CALLS OF DFFTF OR DFFTB.
C
C
C ******************************************************************
C
C SUBROUTINE DFFTB(N,R,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DFFTB COMPUTES THE REAL PERODIC SEQUENCE FROM ITS
C FOURIER COEFFICIENTS (FOURIER SYNTHESIS). THE TRANSFORM IS DEFINED
C BELOW AT OUTPUT PARAMETER R.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY R TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C N MAY CHANGE SO LONG AS DIFFERENT WORK ARRAYS ARE PROVIDED
C
C R A REAL ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 2*N+15.
C IN THE PROGRAM THAT CALLS DFFTB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY DFFTF AND DFFTB.
C
C
C OUTPUT PARAMETERS
C
C R FOR N EVEN AND FOR I = 1,...,N
C
C R(I) = R(1)+(-1)**(I-1)*R(N)
C
C PLUS THE SUM FROM K=2 TO K=N/2 OF
C
C 2.*R(2*K-2)*COS((K-1)*(I-1)*2*PI/N)
C
C -2.*R(2*K-1)*SIN((K-1)*(I-1)*2*PI/N)
C
C FOR N ODD AND FOR I = 1,...,N
C
C R(I) = R(1) PLUS THE SUM FROM K=2 TO K=(N+1)/2 OF
C
C 2.*R(2*K-2)*COS((K-1)*(I-1)*2*PI/N)
C
C -2.*R(2*K-1)*SIN((K-1)*(I-1)*2*PI/N)
C
C ***** NOTE
C THIS TRANSFORM IS UNNORMALIZED SINCE A CALL OF DFFTF
C FOLLOWED BY A CALL OF DFFTB WILL MULTIPLY THE INPUT
C SEQUENCE BY N.
C
C WSAVE CONTAINS RESULTS WHICH MUST NOT BE DESTROYED BETWEEN
C CALLS OF DFFTB OR DFFTF.
C
C
C ******************************************************************
C
C SUBROUTINE DZFFTI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DZFFTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH DZFFTF AND DZFFTB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C THE SAME WORK ARRAY CAN BE USED FOR BOTH DZFFTF AND DZFFTB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N.
C
C
C ******************************************************************
C
C SUBROUTINE DZFFTF(N,R,AZERO,A,B,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DZFFTF COMPUTES THE FOURIER COEFFICIENTS OF A REAL
C PERODIC SEQUENCE (FOURIER ANALYSIS). THE TRANSFORM IS DEFINED
C BELOW AT OUTPUT PARAMETERS AZERO,A AND B. DZFFTF IS A SIMPLIFIED
C BUT SLOWER VERSION OF DFFTF.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY R TO BE TRANSFORMED. THE METHOD
C IS MUST EFFICIENT WHEN N IS THE PRODUCT OF SMALL PRIMES.
C
C R A REAL ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C TO BE TRANSFORMED. R IS NOT DESTROYED.
C
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C IN THE PROGRAM THAT CALLS DZFFTF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DZFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY DZFFTF AND DZFFTB.
C
C OUTPUT PARAMETERS
C
C AZERO THE SUM FROM I=1 TO I=N OF R(I)/N
C
C A,B FOR N EVEN B(N/2)=0. AND A(N/2) IS THE SUM FROM I=1 TO
C I=N OF (-1)**(I-1)*R(I)/N
C
C FOR N EVEN DEFINE KMAX=N/2-1
C FOR N ODD DEFINE KMAX=(N-1)/2
C
C THEN FOR K=1,...,KMAX
C
C A(K) EQUALS THE SUM FROM I=1 TO I=N OF
C
C 2./N*R(I)*COS(K*(I-1)*2*PI/N)
C
C B(K) EQUALS THE SUM FROM I=1 TO I=N OF
C
C 2./N*R(I)*SIN(K*(I-1)*2*PI/N)
C
C
C ******************************************************************
C
C SUBROUTINE DZFFTB(N,R,AZERO,A,B,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DZFFTB COMPUTES A REAL PERODIC SEQUENCE FROM ITS
C FOURIER COEFFICIENTS (FOURIER SYNTHESIS). THE TRANSFORM IS
C DEFINED BELOW AT OUTPUT PARAMETER R. DZFFTB IS A SIMPLIFIED
C BUT SLOWER VERSION OF DFFTB.
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE OUTPUT ARRAY R. THE METHOD IS MOST
C EFFICIENT WHEN N IS THE PRODUCT OF SMALL PRIMES.
C
C AZERO THE CONSTANT FOURIER COEFFICIENT
C
C A,B ARRAYS WHICH CONTAIN THE REMAINING FOURIER COEFFICIENTS
C THESE ARRAYS ARE NOT DESTROYED.
C
C THE LENGTH OF THESE ARRAYS DEPENDS ON WHETHER N IS EVEN OR
C ODD.
C
C IF N IS EVEN N/2 LOCATIONS ARE REQUIRED
C IF N IS ODD (N-1)/2 LOCATIONS ARE REQUIRED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C IN THE PROGRAM THAT CALLS DZFFTB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DZFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY DZFFTF AND DZFFTB.
C
C
C OUTPUT PARAMETERS
C
C R IF N IS EVEN DEFINE KMAX=N/2
C IF N IS ODD DEFINE KMAX=(N-1)/2
C
C THEN FOR I=1,...,N
C
C R(I)=AZERO PLUS THE SUM FROM K=1 TO K=KMAX OF
C
C A(K)*COS(K*(I-1)*2*PI/N)+B(K)*SIN(K*(I-1)*2*PI/N)
C
C ********************* COMPLEX NOTATION **************************
C
C FOR J=1,...,N
C
C R(J) EQUALS THE SUM FROM K=-KMAX TO K=KMAX OF
C
C C(K)*EXP(I*K*(J-1)*2*PI/N)
C
C WHERE
C
C C(K) = .5*CMPLX(A(K),-B(K)) FOR K=1,...,KMAX
C
C C(-K) = CONJG(C(K))
C
C C(0) = AZERO
C
C AND I=SQRT(-1)
C
C *************** AMPLITUDE - PHASE NOTATION ***********************
C
C FOR I=1,...,N
C
C R(I) EQUALS AZERO PLUS THE SUM FROM K=1 TO K=KMAX OF
C
C ALPHA(K)*COS(K*(I-1)*2*PI/N+BETA(K))
C
C WHERE
C
C ALPHA(K) = SQRT(A(K)*A(K)+B(K)*B(K))
C
C COS(BETA(K))=A(K)/ALPHA(K)
C
C SIN(BETA(K))=-B(K)/ALPHA(K)
C
C ******************************************************************
C
C SUBROUTINE DSINTI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DSINTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C SUBROUTINE DSINT. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N+1 IS A PRODUCT OF SMALL PRIMES.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WITH AT LEAST INT(2.5*N+15) LOCATIONS.
C DIFFERENT WSAVE ARRAYS ARE REQUIRED FOR DIFFERENT VALUES
C OF N. THE CONTENTS OF WSAVE MUST NOT BE CHANGED BETWEEN
C CALLS OF DSINT.
C
C ******************************************************************
C
C SUBROUTINE DSINT(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DSINT COMPUTES THE DISCRETE FOURIER SINE TRANSFORM
C OF AN ODD SEQUENCE X(I). THE TRANSFORM IS DEFINED BELOW AT
C OUTPUT PARAMETER X.
C
C DSINT IS THE UNNORMALIZED INVERSE OF ITSELF SINCE A CALL OF DSINT
C FOLLOWED BY ANOTHER CALL OF DSINT WILL MULTIPLY THE INPUT SEQUENCE
C X BY 2*(N+1).
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DSINT MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINTI(N,WSAVE).
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N+1 IS THE PRODUCT OF SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C
C WSAVE A WORK ARRAY WITH DIMENSION AT LEAST INT(2.5*N+15)
C IN THE PROGRAM THAT CALLS DSINT. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I)= THE SUM FROM K=1 TO K=N
C
C 2*X(K)*SIN(K*I*PI/(N+1))
C
C A CALL OF DSINT FOLLOWED BY ANOTHER CALL OF
C DSINT WILL MULTIPLY THE SEQUENCE X BY 2*(N+1).
C HENCE DSINT IS THE UNNORMALIZED INVERSE
C OF ITSELF.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT BE
C DESTROYED BETWEEN CALLS OF DSINT.
C
C ******************************************************************
C
C SUBROUTINE DCOSTI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DCOSTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C SUBROUTINE DCOST. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N-1 IS A PRODUCT OF SMALL PRIMES.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C DIFFERENT WSAVE ARRAYS ARE REQUIRED FOR DIFFERENT VALUES
C OF N. THE CONTENTS OF WSAVE MUST NOT BE CHANGED BETWEEN
C CALLS OF DCOST.
C
C ******************************************************************
C
C SUBROUTINE DCOST(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DCOST COMPUTES THE DISCRETE FOURIER COSINE TRANSFORM
C OF AN EVEN SEQUENCE X(I). THE TRANSFORM IS DEFINED BELOW AT OUTPUT
C PARAMETER X.
C
C DCOST IS THE UNNORMALIZED INVERSE OF ITSELF SINCE A CALL OF DCOST
C FOLLOWED BY ANOTHER CALL OF DCOST WILL MULTIPLY THE INPUT SEQUENCE
C X BY 2*(N-1). THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER X
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DCOST MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSTI(N,WSAVE).
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE SEQUENCE X. N MUST BE GREATER THAN 1.
C THE METHOD IS MOST EFFICIENT WHEN N-1 IS A PRODUCT OF
C SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15
C IN THE PROGRAM THAT CALLS DCOST. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I) = X(1)+(-1)**(I-1)*X(N)
C
C + THE SUM FROM K=2 TO K=N-1
C
C 2*X(K)*COS((K-1)*(I-1)*PI/(N-1))
C
C A CALL OF DCOST FOLLOWED BY ANOTHER CALL OF
C DCOST WILL MULTIPLY THE SEQUENCE X BY 2*(N-1)
C HENCE DCOST IS THE UNNORMALIZED INVERSE
C OF ITSELF.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT BE
C DESTROYED BETWEEN CALLS OF DCOST.
C
C ******************************************************************
C
C SUBROUTINE DSINQI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DSINQI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH DSINQF AND DSINQB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C THE SAME WORK ARRAY CAN BE USED FOR BOTH DSINQF AND DSINQB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N. THE CONTENTS OF
C WSAVE MUST NOT BE CHANGED BETWEEN CALLS OF DSINQF OR DSINQB.
C
C ******************************************************************
C
C SUBROUTINE DSINQF(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DSINQF COMPUTES THE FAST FOURIER TRANSFORM OF QUARTER
C WAVE DATA. THAT IS , DSINQF COMPUTES THE COEFFICIENTS IN A SINE
C SERIES REPRESENTATION WITH ONLY ODD WAVE NUMBERS. THE TRANSFORM
C IS DEFINED BELOW AT OUTPUT PARAMETER X.
C
C DSINQB IS THE UNNORMALIZED INVERSE OF DSINQF SINCE A CALL OF DSINQF
C FOLLOWED BY A CALL OF DSINQB WILL MULTIPLY THE INPUT SEQUENCE X
C BY 4*N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DSINQF MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINQI(N,WSAVE).
C
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY X TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C IN THE PROGRAM THAT CALLS DSINQF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINQI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I) = (-1)**(I-1)*X(N)
C
C + THE SUM FROM K=1 TO K=N-1 OF
C
C 2*X(K)*SIN((2*I-1)*K*PI/(2*N))
C
C A CALL OF DSINQF FOLLOWED BY A CALL OF
C DSINQB WILL MULTIPLY THE SEQUENCE X BY 4*N.
C THEREFORE DSINQB IS THE UNNORMALIZED INVERSE
C OF DSINQF.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT
C BE DESTROYED BETWEEN CALLS OF DSINQF OR DSINQB.
C
C ******************************************************************
C
C SUBROUTINE DSINQB(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DSINQB COMPUTES THE FAST FOURIER TRANSFORM OF QUARTER
C WAVE DATA. THAT IS , DSINQB COMPUTES A SEQUENCE FROM ITS
C REPRESENTATION IN TERMS OF A SINE SERIES WITH ODD WAVE NUMBERS.
C THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER X.
C
C DSINQF IS THE UNNORMALIZED INVERSE OF DSINQB SINCE A CALL OF DSINQB
C FOLLOWED BY A CALL OF DSINQF WILL MULTIPLY THE INPUT SEQUENCE X
C BY 4*N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DSINQB MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINQI(N,WSAVE).
C
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY X TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C IN THE PROGRAM THAT CALLS DSINQB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DSINQI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I)= THE SUM FROM K=1 TO K=N OF
C
C 4*X(K)*SIN((2K-1)*I*PI/(2*N))
C
C A CALL OF DSINQB FOLLOWED BY A CALL OF
C DSINQF WILL MULTIPLY THE SEQUENCE X BY 4*N.
C THEREFORE DSINQF IS THE UNNORMALIZED INVERSE
C OF DSINQB.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT
C BE DESTROYED BETWEEN CALLS OF DSINQB OR DSINQF.
C
C ******************************************************************
C
C SUBROUTINE DCOSQI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DCOSQI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH DCOSQF AND DCOSQB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE ARRAY TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15.
C THE SAME WORK ARRAY CAN BE USED FOR BOTH DCOSQF AND DCOSQB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N. THE CONTENTS OF
C WSAVE MUST NOT BE CHANGED BETWEEN CALLS OF DCOSQF OR DCOSQB.
C
C ******************************************************************
C
C SUBROUTINE DCOSQF(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DCOSQF COMPUTES THE FAST FOURIER TRANSFORM OF QUARTER
C WAVE DATA. THAT IS , DCOSQF COMPUTES THE COEFFICIENTS IN A COSINE
C SERIES REPRESENTATION WITH ONLY ODD WAVE NUMBERS. THE TRANSFORM
C IS DEFINED BELOW AT OUTPUT PARAMETER X
C
C DCOSQF IS THE UNNORMALIZED INVERSE OF DCOSQB SINCE A CALL OF DCOSQF
C FOLLOWED BY A CALL OF DCOSQB WILL MULTIPLY THE INPUT SEQUENCE X
C BY 4*N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DCOSQF MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSQI(N,WSAVE).
C
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY X TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 3*N+15
C IN THE PROGRAM THAT CALLS DCOSQF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSQI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I) = X(1) PLUS THE SUM FROM K=2 TO K=N OF
C
C 2*X(K)*COS((2*I-1)*(K-1)*PI/(2*N))
C
C A CALL OF DCOSQF FOLLOWED BY A CALL OF
C DCOSQB WILL MULTIPLY THE SEQUENCE X BY 4*N.
C THEREFORE DCOSQB IS THE UNNORMALIZED INVERSE
C OF DCOSQF.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT
C BE DESTROYED BETWEEN CALLS OF DCOSQF OR DCOSQB.
C
C ******************************************************************
C
C SUBROUTINE DCOSQB(N,X,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE DCOSQB COMPUTES THE FAST FOURIER TRANSFORM OF QUARTER
C WAVE DATA. THAT IS , DCOSQB COMPUTES A SEQUENCE FROM ITS
C REPRESENTATION IN TERMS OF A COSINE SERIES WITH ODD WAVE NUMBERS.
C THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER X.
C
C DCOSQB IS THE UNNORMALIZED INVERSE OF DCOSQF SINCE A CALL OF DCOSQB
C FOLLOWED BY A CALL OF DCOSQF WILL MULTIPLY THE INPUT SEQUENCE X
C BY 4*N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE DCOSQB MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSQI(N,WSAVE).
C
C
C INPUT PARAMETERS
C
C N THE LENGTH OF THE ARRAY X TO BE TRANSFORMED. THE METHOD
C IS MOST EFFICIENT WHEN N IS A PRODUCT OF SMALL PRIMES.
C
C X AN ARRAY WHICH CONTAINS THE SEQUENCE TO BE TRANSFORMED
C
C WSAVE A WORK ARRAY THAT MUST BE DIMENSIONED AT LEAST 3*N+15
C IN THE PROGRAM THAT CALLS DCOSQB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE DCOSQI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C
C OUTPUT PARAMETERS
C
C X FOR I=1,...,N
C
C X(I)= THE SUM FROM K=1 TO K=N OF
C
C 4*X(K)*COS((2*K-1)*(I-1)*PI/(2*N))
C
C A CALL OF DCOSQB FOLLOWED BY A CALL OF
C DCOSQF WILL MULTIPLY THE SEQUENCE X BY 4*N.
C THEREFORE DCOSQF IS THE UNNORMALIZED INVERSE
C OF DCOSQB.
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT
C BE DESTROYED BETWEEN CALLS OF DCOSQB OR DCOSQF.
C
C ******************************************************************
C
C SUBROUTINE ZFFTI(N,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE ZFFTI INITIALIZES THE ARRAY WSAVE WHICH IS USED IN
C BOTH ZFFTF AND ZFFTB. THE PRIME FACTORIZATION OF N TOGETHER WITH
C A TABULATION OF THE TRIGONOMETRIC FUNCTIONS ARE COMPUTED AND
C STORED IN WSAVE.
C
C INPUT PARAMETER
C
C N THE LENGTH OF THE SEQUENCE TO BE TRANSFORMED
C
C OUTPUT PARAMETER
C
C WSAVE A WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 4*N+15
C THE SAME WORK ARRAY CAN BE USED FOR BOTH ZFFTF AND ZFFTB
C AS LONG AS N REMAINS UNCHANGED. DIFFERENT WSAVE ARRAYS
C ARE REQUIRED FOR DIFFERENT VALUES OF N. THE CONTENTS OF
C WSAVE MUST NOT BE CHANGED BETWEEN CALLS OF ZFFTF OR ZFFTB.
C
C ******************************************************************
C
C SUBROUTINE ZFFTF(N,C,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE ZFFTF COMPUTES THE FORWARD COMPLEX DISCRETE FOURIER
C TRANSFORM (THE FOURIER ANALYSIS). EQUIVALENTLY , ZFFTF COMPUTES
C THE FOURIER COEFFICIENTS OF A COMPLEX PERIODIC SEQUENCE.
C THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER C.
C
C THE TRANSFORM IS NOT NORMALIZED. TO OBTAIN A NORMALIZED TRANSFORM
C THE OUTPUT MUST BE DIVIDED BY N. OTHERWISE A CALL OF ZFFTF
C FOLLOWED BY A CALL OF ZFFTB WILL MULTIPLY THE SEQUENCE BY N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE ZFFTF MUST BE
C INITIALIZED BY CALLING SUBROUTINE ZFFTI(N,WSAVE).
C
C INPUT PARAMETERS
C
C
C N THE LENGTH OF THE COMPLEX SEQUENCE C. THE METHOD IS
C MORE EFFICIENT WHEN N IS THE PRODUCT OF SMALL PRIMES. N
C
C C A COMPLEX ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C
C WSAVE A REAL WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 4N+15
C IN THE PROGRAM THAT CALLS ZFFTF. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE ZFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY ZFFTF AND ZFFTB.
C
C OUTPUT PARAMETERS
C
C C FOR J=1,...,N
C
C C(J)=THE SUM FROM K=1,...,N OF
C
C C(K)*EXP(-I*(J-1)*(K-1)*2*PI/N)
C
C WHERE I=SQRT(-1)
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT BE
C DESTROYED BETWEEN CALLS OF SUBROUTINE ZFFTF OR ZFFTB
C
C ******************************************************************
C
C SUBROUTINE ZFFTB(N,C,WSAVE)
C
C ******************************************************************
C
C SUBROUTINE ZFFTB COMPUTES THE BACKWARD COMPLEX DISCRETE FOURIER
C TRANSFORM (THE FOURIER SYNTHESIS). EQUIVALENTLY , ZFFTB COMPUTES
C A COMPLEX PERIODIC SEQUENCE FROM ITS FOURIER COEFFICIENTS.
C THE TRANSFORM IS DEFINED BELOW AT OUTPUT PARAMETER C.
C
C A CALL OF ZFFTF FOLLOWED BY A CALL OF ZFFTB WILL MULTIPLY THE
C SEQUENCE BY N.
C
C THE ARRAY WSAVE WHICH IS USED BY SUBROUTINE ZFFTB MUST BE
C INITIALIZED BY CALLING SUBROUTINE ZFFTI(N,WSAVE).
C
C INPUT PARAMETERS
C
C
C N THE LENGTH OF THE COMPLEX SEQUENCE C. THE METHOD IS
C MORE EFFICIENT WHEN N IS THE PRODUCT OF SMALL PRIMES.
C
C C A COMPLEX ARRAY OF LENGTH N WHICH CONTAINS THE SEQUENCE
C
C WSAVE A REAL WORK ARRAY WHICH MUST BE DIMENSIONED AT LEAST 4N+15
C IN THE PROGRAM THAT CALLS ZFFTB. THE WSAVE ARRAY MUST BE
C INITIALIZED BY CALLING SUBROUTINE ZFFTI(N,WSAVE) AND A
C DIFFERENT WSAVE ARRAY MUST BE USED FOR EACH DIFFERENT
C VALUE OF N. THIS INITIALIZATION DOES NOT HAVE TO BE
C REPEATED SO LONG AS N REMAINS UNCHANGED THUS SUBSEQUENT
C TRANSFORMS CAN BE OBTAINED FASTER THAN THE FIRST.
C THE SAME WSAVE ARRAY CAN BE USED BY ZFFTF AND ZFFTB.
C
C OUTPUT PARAMETERS
C
C C FOR J=1,...,N
C
C C(J)=THE SUM FROM K=1,...,N OF
C
C C(K)*EXP(I*(J-1)*(K-1)*2*PI/N)
C
C WHERE I=SQRT(-1)
C
C WSAVE CONTAINS INITIALIZATION CALCULATIONS WHICH MUST NOT BE
C DESTROYED BETWEEN CALLS OF SUBROUTINE ZFFTF OR ZFFTB
C
C
C
C ["SEND INDEX FOR VFFTPK" DESCRIBES A VECTORIZED VERSION OF FFTPACK]
C
C
C
SUBROUTINE ZFFTB1 (N,C,CH,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
NF = IFAC(2)
NA = 0
L1 = 1
IW = 1
DO 116 K1=1,NF
IP = IFAC(K1+2)
L2 = IP*L1
IDO = N/L2
IDOT = IDO+IDO
IDL1 = IDOT*L1
IF (IP .NE. 4) GO TO 103
IX2 = IW+IDOT
IX3 = IX2+IDOT
IF (NA .NE. 0) GO TO 101
CALL DPASSB4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 102
101 CALL DPASSB4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
102 NA = 1-NA
GO TO 115
103 IF (IP .NE. 2) GO TO 106
IF (NA .NE. 0) GO TO 104
CALL DPASSB2 (IDOT,L1,C,CH,WA(IW))
GO TO 105
104 CALL DPASSB2 (IDOT,L1,CH,C,WA(IW))
105 NA = 1-NA
GO TO 115
106 IF (IP .NE. 3) GO TO 109
IX2 = IW+IDOT
IF (NA .NE. 0) GO TO 107
CALL DPASSB3 (IDOT,L1,C,CH,WA(IW),WA(IX2))
GO TO 108
107 CALL DPASSB3 (IDOT,L1,CH,C,WA(IW),WA(IX2))
108 NA = 1-NA
GO TO 115
109 IF (IP .NE. 5) GO TO 112
IX2 = IW+IDOT
IX3 = IX2+IDOT
IX4 = IX3+IDOT
IF (NA .NE. 0) GO TO 110
CALL DPASSB5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 111
110 CALL DPASSB5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
111 NA = 1-NA
GO TO 115
112 IF (NA .NE. 0) GO TO 113
CALL DPASSB (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
GO TO 114
113 CALL DPASSB (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
114 IF (NAC .NE. 0) NA = 1-NA
115 L1 = L2
IW = IW+(IP-1)*IDOT
116 CONTINUE
IF (NA .EQ. 0) RETURN
N2 = N+N
DO 117 I=1,N2
C(I) = CH(I)
117 CONTINUE
RETURN
END
SUBROUTINE ZFFTB (N,C,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION C(*) ,WSAVE(*)
IF (N .EQ. 1) RETURN
IW1 = N+N+1
IW2 = IW1+N+N
CALL ZFFTB1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2))
RETURN
END
SUBROUTINE ZFFTF1 (N,C,CH,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
NF = IFAC(2)
NA = 0
L1 = 1
IW = 1
DO 116 K1=1,NF
IP = IFAC(K1+2)
L2 = IP*L1
IDO = N/L2
IDOT = IDO+IDO
IDL1 = IDOT*L1
IF (IP .NE. 4) GO TO 103
IX2 = IW+IDOT
IX3 = IX2+IDOT
IF (NA .NE. 0) GO TO 101
CALL DPASSF4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 102
101 CALL DPASSF4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
102 NA = 1-NA
GO TO 115
103 IF (IP .NE. 2) GO TO 106
IF (NA .NE. 0) GO TO 104
CALL DPASSF2 (IDOT,L1,C,CH,WA(IW))
GO TO 105
104 CALL DPASSF2 (IDOT,L1,CH,C,WA(IW))
105 NA = 1-NA
GO TO 115
106 IF (IP .NE. 3) GO TO 109
IX2 = IW+IDOT
IF (NA .NE. 0) GO TO 107
CALL DPASSF3 (IDOT,L1,C,CH,WA(IW),WA(IX2))
GO TO 108
107 CALL DPASSF3 (IDOT,L1,CH,C,WA(IW),WA(IX2))
108 NA = 1-NA
GO TO 115
109 IF (IP .NE. 5) GO TO 112
IX2 = IW+IDOT
IX3 = IX2+IDOT
IX4 = IX3+IDOT
IF (NA .NE. 0) GO TO 110
CALL DPASSF5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 111
110 CALL DPASSF5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
111 NA = 1-NA
GO TO 115
112 IF (NA .NE. 0) GO TO 113
CALL DPASSF (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
GO TO 114
113 CALL DPASSF (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
114 IF (NAC .NE. 0) NA = 1-NA
115 L1 = L2
IW = IW+(IP-1)*IDOT
116 CONTINUE
IF (NA .EQ. 0) RETURN
N2 = N+N
DO 117 I=1,N2
C(I) = CH(I)
117 CONTINUE
RETURN
END
SUBROUTINE ZFFTF (N,C,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION C(*) ,WSAVE(*)
IF (N .EQ. 1) RETURN
IW1 = N+N+1
IW2 = IW1+N+N
CALL ZFFTF1 (N,C,WSAVE,WSAVE(IW1),WSAVE(IW2))
RETURN
END
SUBROUTINE ZFFTI1 (N,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WA(*) ,IFAC(*) ,NTRYH(4)
DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/3,4,2,5/
NL = N
NF = 0
J = 0
101 J = J+1
IF (J-4) 102,102,103
102 NTRY = NTRYH(J)
GO TO 104
103 NTRY = NTRY+2
104 NQ = NL/NTRY
NR = NL-NTRY*NQ
IF (NR) 101,105,101
105 NF = NF+1
IFAC(NF+2) = NTRY
NL = NQ
IF (NTRY .NE. 2) GO TO 107
IF (NF .EQ. 1) GO TO 107
DO 106 I=2,NF
IB = NF-I+2
IFAC(IB+2) = IFAC(IB+1)
106 CONTINUE
IFAC(3) = 2
107 IF (NL .NE. 1) GO TO 104
IFAC(1) = N
IFAC(2) = NF
TPI = 6.2831853071795864769252867665590057D0
ARGH = TPI/DBLE(N)
I = 2
L1 = 1
DO 110 K1=1,NF
IP = IFAC(K1+2)
LD = 0
L2 = L1*IP
IDO = N/L2
IDOT = IDO+IDO+2
IPM = IP-1
DO 109 J=1,IPM
I1 = I
WA(I-1) = 1.0D0
WA(I) = 0.0D0
LD = LD+L1
FI = 0.0D0
ARGLD = DBLE(LD)*ARGH
DO 108 II=4,IDOT,2
I = I+2
FI = FI+1.0D0
ARG = FI*ARGLD
WA(I-1) = DCOS(ARG)
WA(I) = DSIN(ARG)
108 CONTINUE
IF (IP .LE. 5) GO TO 109
WA(I1-1) = WA(I-1)
WA(I1) = WA(I)
109 CONTINUE
L1 = L2
110 CONTINUE
RETURN
END
SUBROUTINE ZFFTI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
IF (N .EQ. 1) RETURN
IW1 = N+N+1
IW2 = IW1+N+N
CALL ZFFTI1 (N,WSAVE(IW1),WSAVE(IW2))
RETURN
END
SUBROUTINE DCOSQB1 (N,X,W,XH)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,W(*) ,XH(*)
NS2 = (N+1)/2
NP2 = N+2
DO 101 I=3,N,2
XIM1 = X(I-1)+X(I)
X(I) = X(I)-X(I-1)
X(I-1) = XIM1
101 CONTINUE
X(1) = X(1)+X(1)
MODN = MOD(N,2)
IF (MODN .EQ. 0) X(N) = X(N)+X(N)
CALL DFFTB (N,X,XH)
DO 102 K=2,NS2
KC = NP2-K
XH(K) = W(K-1)*X(KC)+W(KC-1)*X(K)
XH(KC) = W(K-1)*X(K)-W(KC-1)*X(KC)
102 CONTINUE
IF (MODN .EQ. 0) X(NS2+1) = W(NS2)*(X(NS2+1)+X(NS2+1))
DO 103 K=2,NS2
KC = NP2-K
X(K) = XH(K)+XH(KC)
X(KC) = XH(K)-XH(KC)
103 CONTINUE
X(1) = X(1)+X(1)
RETURN
END
SUBROUTINE DCOSQF1 (N,X,W,XH)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,W(*) ,XH(*)
NS2 = (N+1)/2
NP2 = N+2
DO 101 K=2,NS2
KC = NP2-K
XH(K) = X(K)+X(KC)
XH(KC) = X(K)-X(KC)
101 CONTINUE
MODN = MOD(N,2)
IF (MODN .EQ. 0) XH(NS2+1) = X(NS2+1)+X(NS2+1)
DO 102 K=2,NS2
KC = NP2-K
X(K) = W(K-1)*XH(KC)+W(KC-1)*XH(K)
X(KC) = W(K-1)*XH(K)-W(KC-1)*XH(KC)
102 CONTINUE
IF (MODN .EQ. 0) X(NS2+1) = W(NS2)*XH(NS2+1)
CALL DFFTF (N,X,XH)
DO 103 I=3,N,2
XIM1 = X(I-1)-X(I)
X(I) = X(I-1)+X(I)
X(I-1) = XIM1
103 CONTINUE
RETURN
END
SUBROUTINE DCOSQI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
DATA PIH /1.5707963267948966192313216916397514D0/
DT = PIH/DBLE(N)
FK = 0.0D0
DO 101 K=1,N
FK = FK+1.0D0
WSAVE(K) = DCOS(FK*DT)
101 CONTINUE
CALL DFFTI (N,WSAVE(N+1))
RETURN
END
SUBROUTINE DCOST (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
NM1 = N-1
NP1 = N+1
NS2 = N/2
IF (N-2) 106,101,102
101 X1H = X(1)+X(2)
X(2) = X(1)-X(2)
X(1) = X1H
RETURN
102 IF (N .GT. 3) GO TO 103
X1P3 = X(1)+X(3)
TX2 = X(2)+X(2)
X(2) = X(1)-X(3)
X(1) = X1P3+TX2
X(3) = X1P3-TX2
RETURN
103 C1 = X(1)-X(N)
X(1) = X(1)+X(N)
DO 104 K=2,NS2
KC = NP1-K
T1 = X(K)+X(KC)
T2 = X(K)-X(KC)
C1 = C1+WSAVE(KC)*T2
T2 = WSAVE(K)*T2
X(K) = T1-T2
X(KC) = T1+T2
104 CONTINUE
MODN = MOD(N,2)
IF (MODN .NE. 0) X(NS2+1) = X(NS2+1)+X(NS2+1)
CALL DFFTF (NM1,X,WSAVE(N+1))
XIM2 = X(2)
X(2) = C1
DO 105 I=4,N,2
XI = X(I)
X(I) = X(I-2)-X(I-1)
X(I-1) = XIM2
XIM2 = XI
105 CONTINUE
IF (MODN .NE. 0) X(N) = XIM2
106 RETURN
END
SUBROUTINE DZFFT1 (N,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WA(*) ,IFAC(*) ,NTRYH(4)
DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/4,2,3,5/
1 ,TPI/6.2831853071795864769252867665590057D0/
NL = N
NF = 0
J = 0
101 J = J+1
IF (J-4) 102,102,103
102 NTRY = NTRYH(J)
GO TO 104
103 NTRY = NTRY+2
104 NQ = NL/NTRY
NR = NL-NTRY*NQ
IF (NR) 101,105,101
105 NF = NF+1
IFAC(NF+2) = NTRY
NL = NQ
IF (NTRY .NE. 2) GO TO 107
IF (NF .EQ. 1) GO TO 107
DO 106 I=2,NF
IB = NF-I+2
IFAC(IB+2) = IFAC(IB+1)
106 CONTINUE
IFAC(3) = 2
107 IF (NL .NE. 1) GO TO 104
IFAC(1) = N
IFAC(2) = NF
ARGH = TPI/DBLE(N)
IS = 0
NFM1 = NF-1
L1 = 1
IF (NFM1 .EQ. 0) RETURN
DO 111 K1=1,NFM1
IP = IFAC(K1+2)
L2 = L1*IP
IDO = N/L2
IPM = IP-1
ARG1 = DBLE(L1)*ARGH
CH1 = 1.0D0
SH1 = 0.0D0
DCH1 = DCOS(ARG1)
DSH1 = DSIN(ARG1)
DO 110 J=1,IPM
CH1H = DCH1*CH1-DSH1*SH1
SH1 = DCH1*SH1+DSH1*CH1
CH1 = CH1H
I = IS+2
WA(I-1) = CH1
WA(I) = SH1
IF (IDO .LT. 5) GO TO 109
DO 108 II=5,IDO,2
I = I+2
WA(I-1) = CH1*WA(I-3)-SH1*WA(I-2)
WA(I) = CH1*WA(I-2)+SH1*WA(I-3)
108 CONTINUE
109 IS = IS+IDO
110 CONTINUE
L1 = L2
111 CONTINUE
RETURN
END
SUBROUTINE DCOSQB (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
DATA TSQRT2 /2.8284271247461900976033774484193961D0/
IF (N-2) 101,102,103
101 X(1) = 4.0D0*X(1)
RETURN
102 X1 = 4.0D0*(X(1)+X(2))
X(2) = TSQRT2*(X(1)-X(2))
X(1) = X1
RETURN
103 CALL DCOSQB1 (N,X,WSAVE,WSAVE(N+1))
RETURN
END
SUBROUTINE DCOSQF (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
DATA SQRT2 /1.4142135623730950488016887242096980D0/
IF (N-2) 102,101,103
101 TSQX = SQRT2*X(2)
X(2) = X(1)-TSQX
X(1) = X(1)+TSQX
102 RETURN
103 CALL DCOSQF1 (N,X,WSAVE,WSAVE(N+1))
RETURN
END
SUBROUTINE DCOSTI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
DATA PI /3.1415926535897932384626433832795028D0/
IF (N .LE. 3) RETURN
NM1 = N-1
NP1 = N+1
NS2 = N/2
DT = PI/DBLE(NM1)
FK = 0.0D0
DO 101 K=2,NS2
KC = NP1-K
FK = FK+1.0D0
WSAVE(K) = 2.0D0*DSIN(FK*DT)
WSAVE(KC) = 2.0D0*DCOS(FK*DT)
101 CONTINUE
CALL DFFTI (NM1,WSAVE(N+1))
RETURN
END
SUBROUTINE DZFFTB (N,R,AZERO,A,B,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION R(*) ,A(*) ,B(*) ,WSAVE(*)
IF (N-2) 101,102,103
101 R(1) = AZERO
RETURN
102 R(1) = AZERO+A(1)
R(2) = AZERO-A(1)
RETURN
103 NS2 = (N-1)/2
DO 104 I=1,NS2
R(2*I) = .5D0*A(I)
R(2*I+1) = -.5D0*B(I)
104 CONTINUE
R(1) = AZERO
IF (MOD(N,2) .EQ. 0) R(N) = A(NS2+1)
CALL DFFTB (N,R,WSAVE(N+1))
RETURN
END
SUBROUTINE DZFFTF (N,R,AZERO,A,B,WSAVE)
C
C VERSION 3 JUNE 1979
C
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION R(*) ,A(*) ,B(*) ,WSAVE(*)
IF (N-2) 101,102,103
101 AZERO = R(1)
RETURN
102 AZERO = .5D0*(R(1)+R(2))
A(1) = .5D0*(R(1)-R(2))
RETURN
103 DO 104 I=1,N
WSAVE(I) = R(I)
104 CONTINUE
CALL DFFTF (N,WSAVE,WSAVE(N+1))
CF = 2.0D0/DBLE(N)
CFM = -CF
AZERO = .5D0*CF*WSAVE(1)
NS2 = (N+1)/2
NS2M = NS2-1
DO 105 I=1,NS2M
A(I) = CF*WSAVE(2*I)
B(I) = CFM*WSAVE(2*I+1)
105 CONTINUE
IF (MOD(N,2) .EQ. 1) RETURN
A(NS2) = .5D0*CF*WSAVE(N)
B(NS2) = 0.0D0
RETURN
END
SUBROUTINE DZFFTI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
IF (N .EQ. 1) RETURN
CALL DZFFT1 (N,WSAVE(2*N+1),WSAVE(3*N+1))
RETURN
END
SUBROUTINE DPASSB (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) ,
1 C1(IDO,L1,IP) ,WA(*) ,C2(IDL1,IP),
2 CH2(IDL1,IP)
IDOT = IDO/2
NT = IP*IDL1
IPP2 = IP+2
IPPH = (IP+1)/2
IDP = IP*IDO
C
IF (IDO .LT. L1) GO TO 106
DO 103 J=2,IPPH
JC = IPP2-J
DO 102 K=1,L1
DO 101 I=1,IDO
CH(I,K,J) = CC(I,J,K)+CC(I,JC,K)
CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K)
101 CONTINUE
102 CONTINUE
103 CONTINUE
DO 105 K=1,L1
DO 104 I=1,IDO
CH(I,K,1) = CC(I,1,K)
104 CONTINUE
105 CONTINUE
GO TO 112
106 DO 109 J=2,IPPH
JC = IPP2-J
DO 108 I=1,IDO
DO 107 K=1,L1
CH(I,K,J) = CC(I,J,K)+CC(I,JC,K)
CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K)
107 CONTINUE
108 CONTINUE
109 CONTINUE
DO 111 I=1,IDO
DO 110 K=1,L1
CH(I,K,1) = CC(I,1,K)
110 CONTINUE
111 CONTINUE
112 IDL = 2-IDO
INC = 0
DO 116 L=2,IPPH
LC = IPP2-L
IDL = IDL+IDO
DO 113 IK=1,IDL1
C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2)
C2(IK,LC) = WA(IDL)*CH2(IK,IP)
113 CONTINUE
IDLJ = IDL
INC = INC+IDO
DO 115 J=3,IPPH
JC = IPP2-J
IDLJ = IDLJ+INC
IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP
WAR = WA(IDLJ-1)
WAI = WA(IDLJ)
DO 114 IK=1,IDL1
C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J)
C2(IK,LC) = C2(IK,LC)+WAI*CH2(IK,JC)
114 CONTINUE
115 CONTINUE
116 CONTINUE
DO 118 J=2,IPPH
DO 117 IK=1,IDL1
CH2(IK,1) = CH2(IK,1)+CH2(IK,J)
117 CONTINUE
118 CONTINUE
DO 120 J=2,IPPH
JC = IPP2-J
DO 119 IK=2,IDL1,2
CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC)
CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC)
CH2(IK,J) = C2(IK,J)+C2(IK-1,JC)
CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC)
119 CONTINUE
120 CONTINUE
NAC = 1
IF (IDO .EQ. 2) RETURN
NAC = 0
DO 121 IK=1,IDL1
C2(IK,1) = CH2(IK,1)
121 CONTINUE
DO 123 J=2,IP
DO 122 K=1,L1
C1(1,K,J) = CH(1,K,J)
C1(2,K,J) = CH(2,K,J)
122 CONTINUE
123 CONTINUE
IF (IDOT .GT. L1) GO TO 127
IDIJ = 0
DO 126 J=2,IP
IDIJ = IDIJ+2
DO 125 I=4,IDO,2
IDIJ = IDIJ+2
DO 124 K=1,L1
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
124 CONTINUE
125 CONTINUE
126 CONTINUE
RETURN
127 IDJ = 2-IDO
DO 130 J=2,IP
IDJ = IDJ+IDO
DO 129 K=1,L1
IDIJ = IDJ
DO 128 I=4,IDO,2
IDIJ = IDIJ+2
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
128 CONTINUE
129 CONTINUE
130 CONTINUE
RETURN
END
SUBROUTINE DPASSB2 (IDO,L1,CC,CH,WA1)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) ,
1 WA1(*)
IF (IDO .GT. 2) GO TO 102
DO 101 K=1,L1
CH(1,K,1) = CC(1,1,K)+CC(1,2,K)
CH(1,K,2) = CC(1,1,K)-CC(1,2,K)
CH(2,K,1) = CC(2,1,K)+CC(2,2,K)
CH(2,K,2) = CC(2,1,K)-CC(2,2,K)
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K)
TR2 = CC(I-1,1,K)-CC(I-1,2,K)
CH(I,K,1) = CC(I,1,K)+CC(I,2,K)
TI2 = CC(I,1,K)-CC(I,2,K)
CH(I,K,2) = WA1(I-1)*TI2+WA1(I)*TR2
CH(I-1,K,2) = WA1(I-1)*TR2-WA1(I)*TI2
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSB3 (IDO,L1,CC,CH,WA1,WA2)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5D0,.86602540378443864676372317075293618D0/
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TR2 = CC(1,2,K)+CC(1,3,K)
CR2 = CC(1,1,K)+TAUR*TR2
CH(1,K,1) = CC(1,1,K)+TR2
TI2 = CC(2,2,K)+CC(2,3,K)
CI2 = CC(2,1,K)+TAUR*TI2
CH(2,K,1) = CC(2,1,K)+TI2
CR3 = TAUI*(CC(1,2,K)-CC(1,3,K))
CI3 = TAUI*(CC(2,2,K)-CC(2,3,K))
CH(1,K,2) = CR2-CI3
CH(1,K,3) = CR2+CI3
CH(2,K,2) = CI2+CR3
CH(2,K,3) = CI2-CR3
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TR2 = CC(I-1,2,K)+CC(I-1,3,K)
CR2 = CC(I-1,1,K)+TAUR*TR2
CH(I-1,K,1) = CC(I-1,1,K)+TR2
TI2 = CC(I,2,K)+CC(I,3,K)
CI2 = CC(I,1,K)+TAUR*TI2
CH(I,K,1) = CC(I,1,K)+TI2
CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K))
CI3 = TAUI*(CC(I,2,K)-CC(I,3,K))
DR2 = CR2-CI3
DR3 = CR2+CI3
DI2 = CI2+CR3
DI3 = CI2-CR3
CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2
CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2
CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3
CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSB4 (IDO,L1,CC,CH,WA1,WA2,WA3)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) ,
1 WA1(*) ,WA2(*) ,WA3(*)
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TI1 = CC(2,1,K)-CC(2,3,K)
TI2 = CC(2,1,K)+CC(2,3,K)
TR4 = CC(2,4,K)-CC(2,2,K)
TI3 = CC(2,2,K)+CC(2,4,K)
TR1 = CC(1,1,K)-CC(1,3,K)
TR2 = CC(1,1,K)+CC(1,3,K)
TI4 = CC(1,2,K)-CC(1,4,K)
TR3 = CC(1,2,K)+CC(1,4,K)
CH(1,K,1) = TR2+TR3
CH(1,K,3) = TR2-TR3
CH(2,K,1) = TI2+TI3
CH(2,K,3) = TI2-TI3
CH(1,K,2) = TR1+TR4
CH(1,K,4) = TR1-TR4
CH(2,K,2) = TI1+TI4
CH(2,K,4) = TI1-TI4
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TI1 = CC(I,1,K)-CC(I,3,K)
TI2 = CC(I,1,K)+CC(I,3,K)
TI3 = CC(I,2,K)+CC(I,4,K)
TR4 = CC(I,4,K)-CC(I,2,K)
TR1 = CC(I-1,1,K)-CC(I-1,3,K)
TR2 = CC(I-1,1,K)+CC(I-1,3,K)
TI4 = CC(I-1,2,K)-CC(I-1,4,K)
TR3 = CC(I-1,2,K)+CC(I-1,4,K)
CH(I-1,K,1) = TR2+TR3
CR3 = TR2-TR3
CH(I,K,1) = TI2+TI3
CI3 = TI2-TI3
CR2 = TR1+TR4
CR4 = TR1-TR4
CI2 = TI1+TI4
CI4 = TI1-TI4
CH(I-1,K,2) = WA1(I-1)*CR2-WA1(I)*CI2
CH(I,K,2) = WA1(I-1)*CI2+WA1(I)*CR2
CH(I-1,K,3) = WA2(I-1)*CR3-WA2(I)*CI3
CH(I,K,3) = WA2(I-1)*CI3+WA2(I)*CR3
CH(I-1,K,4) = WA3(I-1)*CR4-WA3(I)*CI4
CH(I,K,4) = WA3(I-1)*CI4+WA3(I)*CR4
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /
1 .30901699437494742410229341718281905D0,
2 .95105651629515357211643933337938214D0,
3 -.80901699437494742410229341718281906D0,
4 .58778525229247312916870595463907276D0/
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TI5 = CC(2,2,K)-CC(2,5,K)
TI2 = CC(2,2,K)+CC(2,5,K)
TI4 = CC(2,3,K)-CC(2,4,K)
TI3 = CC(2,3,K)+CC(2,4,K)
TR5 = CC(1,2,K)-CC(1,5,K)
TR2 = CC(1,2,K)+CC(1,5,K)
TR4 = CC(1,3,K)-CC(1,4,K)
TR3 = CC(1,3,K)+CC(1,4,K)
CH(1,K,1) = CC(1,1,K)+TR2+TR3
CH(2,K,1) = CC(2,1,K)+TI2+TI3
CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3
CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3
CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3
CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3
CR5 = TI11*TR5+TI12*TR4
CI5 = TI11*TI5+TI12*TI4
CR4 = TI12*TR5-TI11*TR4
CI4 = TI12*TI5-TI11*TI4
CH(1,K,2) = CR2-CI5
CH(1,K,5) = CR2+CI5
CH(2,K,2) = CI2+CR5
CH(2,K,3) = CI3+CR4
CH(1,K,3) = CR3-CI4
CH(1,K,4) = CR3+CI4
CH(2,K,4) = CI3-CR4
CH(2,K,5) = CI2-CR5
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TI5 = CC(I,2,K)-CC(I,5,K)
TI2 = CC(I,2,K)+CC(I,5,K)
TI4 = CC(I,3,K)-CC(I,4,K)
TI3 = CC(I,3,K)+CC(I,4,K)
TR5 = CC(I-1,2,K)-CC(I-1,5,K)
TR2 = CC(I-1,2,K)+CC(I-1,5,K)
TR4 = CC(I-1,3,K)-CC(I-1,4,K)
TR3 = CC(I-1,3,K)+CC(I-1,4,K)
CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3
CH(I,K,1) = CC(I,1,K)+TI2+TI3
CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3
CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3
CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3
CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3
CR5 = TI11*TR5+TI12*TR4
CI5 = TI11*TI5+TI12*TI4
CR4 = TI12*TR5-TI11*TR4
CI4 = TI12*TI5-TI11*TI4
DR3 = CR3-CI4
DR4 = CR3+CI4
DI3 = CI3+CR4
DI4 = CI3-CR4
DR5 = CR2+CI5
DR2 = CR2-CI5
DI5 = CI2-CR5
DI2 = CI2+CR5
CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2
CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2
CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3
CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3
CH(I-1,K,4) = WA3(I-1)*DR4-WA3(I)*DI4
CH(I,K,4) = WA3(I-1)*DI4+WA3(I)*DR4
CH(I-1,K,5) = WA4(I-1)*DR5-WA4(I)*DI5
CH(I,K,5) = WA4(I-1)*DI5+WA4(I)*DR5
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSF (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) ,
1 C1(IDO,L1,IP) ,WA(*) ,C2(IDL1,IP),
2 CH2(IDL1,IP)
IDOT = IDO/2
NT = IP*IDL1
IPP2 = IP+2
IPPH = (IP+1)/2
IDP = IP*IDO
C
IF (IDO .LT. L1) GO TO 106
DO 103 J=2,IPPH
JC = IPP2-J
DO 102 K=1,L1
DO 101 I=1,IDO
CH(I,K,J) = CC(I,J,K)+CC(I,JC,K)
CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K)
101 CONTINUE
102 CONTINUE
103 CONTINUE
DO 105 K=1,L1
DO 104 I=1,IDO
CH(I,K,1) = CC(I,1,K)
104 CONTINUE
105 CONTINUE
GO TO 112
106 DO 109 J=2,IPPH
JC = IPP2-J
DO 108 I=1,IDO
DO 107 K=1,L1
CH(I,K,J) = CC(I,J,K)+CC(I,JC,K)
CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K)
107 CONTINUE
108 CONTINUE
109 CONTINUE
DO 111 I=1,IDO
DO 110 K=1,L1
CH(I,K,1) = CC(I,1,K)
110 CONTINUE
111 CONTINUE
112 IDL = 2-IDO
INC = 0
DO 116 L=2,IPPH
LC = IPP2-L
IDL = IDL+IDO
DO 113 IK=1,IDL1
C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2)
C2(IK,LC) = -WA(IDL)*CH2(IK,IP)
113 CONTINUE
IDLJ = IDL
INC = INC+IDO
DO 115 J=3,IPPH
JC = IPP2-J
IDLJ = IDLJ+INC
IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP
WAR = WA(IDLJ-1)
WAI = WA(IDLJ)
DO 114 IK=1,IDL1
C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J)
C2(IK,LC) = C2(IK,LC)-WAI*CH2(IK,JC)
114 CONTINUE
115 CONTINUE
116 CONTINUE
DO 118 J=2,IPPH
DO 117 IK=1,IDL1
CH2(IK,1) = CH2(IK,1)+CH2(IK,J)
117 CONTINUE
118 CONTINUE
DO 120 J=2,IPPH
JC = IPP2-J
DO 119 IK=2,IDL1,2
CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC)
CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC)
CH2(IK,J) = C2(IK,J)+C2(IK-1,JC)
CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC)
119 CONTINUE
120 CONTINUE
NAC = 1
IF (IDO .EQ. 2) RETURN
NAC = 0
DO 121 IK=1,IDL1
C2(IK,1) = CH2(IK,1)
121 CONTINUE
DO 123 J=2,IP
DO 122 K=1,L1
C1(1,K,J) = CH(1,K,J)
C1(2,K,J) = CH(2,K,J)
122 CONTINUE
123 CONTINUE
IF (IDOT .GT. L1) GO TO 127
IDIJ = 0
DO 126 J=2,IP
IDIJ = IDIJ+2
DO 125 I=4,IDO,2
IDIJ = IDIJ+2
DO 124 K=1,L1
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J)
124 CONTINUE
125 CONTINUE
126 CONTINUE
RETURN
127 IDJ = 2-IDO
DO 130 J=2,IP
IDJ = IDJ+IDO
DO 129 K=1,L1
IDIJ = IDJ
DO 128 I=4,IDO,2
IDIJ = IDIJ+2
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)+WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)-WA(IDIJ)*CH(I-1,K,J)
128 CONTINUE
129 CONTINUE
130 CONTINUE
RETURN
END
SUBROUTINE DPASSF2 (IDO,L1,CC,CH,WA1)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) ,
1 WA1(*)
IF (IDO .GT. 2) GO TO 102
DO 101 K=1,L1
CH(1,K,1) = CC(1,1,K)+CC(1,2,K)
CH(1,K,2) = CC(1,1,K)-CC(1,2,K)
CH(2,K,1) = CC(2,1,K)+CC(2,2,K)
CH(2,K,2) = CC(2,1,K)-CC(2,2,K)
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K)
TR2 = CC(I-1,1,K)-CC(I-1,2,K)
CH(I,K,1) = CC(I,1,K)+CC(I,2,K)
TI2 = CC(I,1,K)-CC(I,2,K)
CH(I,K,2) = WA1(I-1)*TI2-WA1(I)*TR2
CH(I-1,K,2) = WA1(I-1)*TR2+WA1(I)*TI2
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSF3 (IDO,L1,CC,CH,WA1,WA2)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5D0,-.86602540378443864676372317075293618D0/
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TR2 = CC(1,2,K)+CC(1,3,K)
CR2 = CC(1,1,K)+TAUR*TR2
CH(1,K,1) = CC(1,1,K)+TR2
TI2 = CC(2,2,K)+CC(2,3,K)
CI2 = CC(2,1,K)+TAUR*TI2
CH(2,K,1) = CC(2,1,K)+TI2
CR3 = TAUI*(CC(1,2,K)-CC(1,3,K))
CI3 = TAUI*(CC(2,2,K)-CC(2,3,K))
CH(1,K,2) = CR2-CI3
CH(1,K,3) = CR2+CI3
CH(2,K,2) = CI2+CR3
CH(2,K,3) = CI2-CR3
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TR2 = CC(I-1,2,K)+CC(I-1,3,K)
CR2 = CC(I-1,1,K)+TAUR*TR2
CH(I-1,K,1) = CC(I-1,1,K)+TR2
TI2 = CC(I,2,K)+CC(I,3,K)
CI2 = CC(I,1,K)+TAUR*TI2
CH(I,K,1) = CC(I,1,K)+TI2
CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K))
CI3 = TAUI*(CC(I,2,K)-CC(I,3,K))
DR2 = CR2-CI3
DR3 = CR2+CI3
DI2 = CI2+CR3
DI3 = CI2-CR3
CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2
CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2
CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3
CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSF4 (IDO,L1,CC,CH,WA1,WA2,WA3)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) ,
1 WA1(*) ,WA2(*) ,WA3(*)
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TI1 = CC(2,1,K)-CC(2,3,K)
TI2 = CC(2,1,K)+CC(2,3,K)
TR4 = CC(2,2,K)-CC(2,4,K)
TI3 = CC(2,2,K)+CC(2,4,K)
TR1 = CC(1,1,K)-CC(1,3,K)
TR2 = CC(1,1,K)+CC(1,3,K)
TI4 = CC(1,4,K)-CC(1,2,K)
TR3 = CC(1,2,K)+CC(1,4,K)
CH(1,K,1) = TR2+TR3
CH(1,K,3) = TR2-TR3
CH(2,K,1) = TI2+TI3
CH(2,K,3) = TI2-TI3
CH(1,K,2) = TR1+TR4
CH(1,K,4) = TR1-TR4
CH(2,K,2) = TI1+TI4
CH(2,K,4) = TI1-TI4
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TI1 = CC(I,1,K)-CC(I,3,K)
TI2 = CC(I,1,K)+CC(I,3,K)
TI3 = CC(I,2,K)+CC(I,4,K)
TR4 = CC(I,2,K)-CC(I,4,K)
TR1 = CC(I-1,1,K)-CC(I-1,3,K)
TR2 = CC(I-1,1,K)+CC(I-1,3,K)
TI4 = CC(I-1,4,K)-CC(I-1,2,K)
TR3 = CC(I-1,2,K)+CC(I-1,4,K)
CH(I-1,K,1) = TR2+TR3
CR3 = TR2-TR3
CH(I,K,1) = TI2+TI3
CI3 = TI2-TI3
CR2 = TR1+TR4
CR4 = TR1-TR4
CI2 = TI1+TI4
CI4 = TI1-TI4
CH(I-1,K,2) = WA1(I-1)*CR2+WA1(I)*CI2
CH(I,K,2) = WA1(I-1)*CI2-WA1(I)*CR2
CH(I-1,K,3) = WA2(I-1)*CR3+WA2(I)*CI3
CH(I,K,3) = WA2(I-1)*CI3-WA2(I)*CR3
CH(I-1,K,4) = WA3(I-1)*CR4+WA3(I)*CI4
CH(I,K,4) = WA3(I-1)*CI4-WA3(I)*CR4
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DPASSF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /
1 .30901699437494742410229341718281905D0,
2 -.95105651629515357211643933337938214D0,
3 -.80901699437494742410229341718281906D0,
4 -.58778525229247312916870595463907276D0/
IF (IDO .NE. 2) GO TO 102
DO 101 K=1,L1
TI5 = CC(2,2,K)-CC(2,5,K)
TI2 = CC(2,2,K)+CC(2,5,K)
TI4 = CC(2,3,K)-CC(2,4,K)
TI3 = CC(2,3,K)+CC(2,4,K)
TR5 = CC(1,2,K)-CC(1,5,K)
TR2 = CC(1,2,K)+CC(1,5,K)
TR4 = CC(1,3,K)-CC(1,4,K)
TR3 = CC(1,3,K)+CC(1,4,K)
CH(1,K,1) = CC(1,1,K)+TR2+TR3
CH(2,K,1) = CC(2,1,K)+TI2+TI3
CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3
CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3
CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3
CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3
CR5 = TI11*TR5+TI12*TR4
CI5 = TI11*TI5+TI12*TI4
CR4 = TI12*TR5-TI11*TR4
CI4 = TI12*TI5-TI11*TI4
CH(1,K,2) = CR2-CI5
CH(1,K,5) = CR2+CI5
CH(2,K,2) = CI2+CR5
CH(2,K,3) = CI3+CR4
CH(1,K,3) = CR3-CI4
CH(1,K,4) = CR3+CI4
CH(2,K,4) = CI3-CR4
CH(2,K,5) = CI2-CR5
101 CONTINUE
RETURN
102 DO 104 K=1,L1
DO 103 I=2,IDO,2
TI5 = CC(I,2,K)-CC(I,5,K)
TI2 = CC(I,2,K)+CC(I,5,K)
TI4 = CC(I,3,K)-CC(I,4,K)
TI3 = CC(I,3,K)+CC(I,4,K)
TR5 = CC(I-1,2,K)-CC(I-1,5,K)
TR2 = CC(I-1,2,K)+CC(I-1,5,K)
TR4 = CC(I-1,3,K)-CC(I-1,4,K)
TR3 = CC(I-1,3,K)+CC(I-1,4,K)
CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3
CH(I,K,1) = CC(I,1,K)+TI2+TI3
CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3
CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3
CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3
CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3
CR5 = TI11*TR5+TI12*TR4
CI5 = TI11*TI5+TI12*TI4
CR4 = TI12*TR5-TI11*TR4
CI4 = TI12*TI5-TI11*TI4
DR3 = CR3-CI4
DR4 = CR3+CI4
DI3 = CI3+CR4
DI4 = CI3-CR4
DR5 = CR2+CI5
DR2 = CR2-CI5
DI5 = CI2-CR5
DI2 = CI2+CR5
CH(I-1,K,2) = WA1(I-1)*DR2+WA1(I)*DI2
CH(I,K,2) = WA1(I-1)*DI2-WA1(I)*DR2
CH(I-1,K,3) = WA2(I-1)*DR3+WA2(I)*DI3
CH(I,K,3) = WA2(I-1)*DI3-WA2(I)*DR3
CH(I-1,K,4) = WA3(I-1)*DR4+WA3(I)*DI4
CH(I,K,4) = WA3(I-1)*DI4-WA3(I)*DR4
CH(I-1,K,5) = WA4(I-1)*DR5+WA4(I)*DI5
CH(I,K,5) = WA4(I-1)*DI5-WA4(I)*DR5
103 CONTINUE
104 CONTINUE
RETURN
END
SUBROUTINE DRADB2 (IDO,L1,CC,CH,WA1)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) ,
1 WA1(*)
DO 101 K=1,L1
CH(1,K,1) = CC(1,1,K)+CC(IDO,2,K)
CH(1,K,2) = CC(1,1,K)-CC(IDO,2,K)
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
DO 104 K=1,L1
DO 103 I=3,IDO,2
IC = IDP2-I
CH(I-1,K,1) = CC(I-1,1,K)+CC(IC-1,2,K)
TR2 = CC(I-1,1,K)-CC(IC-1,2,K)
CH(I,K,1) = CC(I,1,K)-CC(IC,2,K)
TI2 = CC(I,1,K)+CC(IC,2,K)
CH(I-1,K,2) = WA1(I-2)*TR2-WA1(I-1)*TI2
CH(I,K,2) = WA1(I-2)*TI2+WA1(I-1)*TR2
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 DO 106 K=1,L1
CH(IDO,K,1) = CC(IDO,1,K)+CC(IDO,1,K)
CH(IDO,K,2) = -(CC(1,2,K)+CC(1,2,K))
106 CONTINUE
107 RETURN
END
SUBROUTINE DRADB3 (IDO,L1,CC,CH,WA1,WA2)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5D0,.86602540378443864676372317075293618D0/
DO 101 K=1,L1
TR2 = CC(IDO,2,K)+CC(IDO,2,K)
CR2 = CC(1,1,K)+TAUR*TR2
CH(1,K,1) = CC(1,1,K)+TR2
CI3 = TAUI*(CC(1,3,K)+CC(1,3,K))
CH(1,K,2) = CR2-CI3
CH(1,K,3) = CR2+CI3
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
TR2 = CC(I-1,3,K)+CC(IC-1,2,K)
CR2 = CC(I-1,1,K)+TAUR*TR2
CH(I-1,K,1) = CC(I-1,1,K)+TR2
TI2 = CC(I,3,K)-CC(IC,2,K)
CI2 = CC(I,1,K)+TAUR*TI2
CH(I,K,1) = CC(I,1,K)+TI2
CR3 = TAUI*(CC(I-1,3,K)-CC(IC-1,2,K))
CI3 = TAUI*(CC(I,3,K)+CC(IC,2,K))
DR2 = CR2-CI3
DR3 = CR2+CI3
DI2 = CI2+CR3
DI3 = CI2-CR3
CH(I-1,K,2) = WA1(I-2)*DR2-WA1(I-1)*DI2
CH(I,K,2) = WA1(I-2)*DI2+WA1(I-1)*DR2
CH(I-1,K,3) = WA2(I-2)*DR3-WA2(I-1)*DI3
CH(I,K,3) = WA2(I-2)*DI3+WA2(I-1)*DR3
102 CONTINUE
103 CONTINUE
RETURN
END
SUBROUTINE DRADB4 (IDO,L1,CC,CH,WA1,WA2,WA3)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) ,
1 WA1(*) ,WA2(*) ,WA3(*)
DATA SQRT2 /1.4142135623730950488016887242096980D0/
DO 101 K=1,L1
TR1 = CC(1,1,K)-CC(IDO,4,K)
TR2 = CC(1,1,K)+CC(IDO,4,K)
TR3 = CC(IDO,2,K)+CC(IDO,2,K)
TR4 = CC(1,3,K)+CC(1,3,K)
CH(1,K,1) = TR2+TR3
CH(1,K,2) = TR1-TR4
CH(1,K,3) = TR2-TR3
CH(1,K,4) = TR1+TR4
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
DO 104 K=1,L1
DO 103 I=3,IDO,2
IC = IDP2-I
TI1 = CC(I,1,K)+CC(IC,4,K)
TI2 = CC(I,1,K)-CC(IC,4,K)
TI3 = CC(I,3,K)-CC(IC,2,K)
TR4 = CC(I,3,K)+CC(IC,2,K)
TR1 = CC(I-1,1,K)-CC(IC-1,4,K)
TR2 = CC(I-1,1,K)+CC(IC-1,4,K)
TI4 = CC(I-1,3,K)-CC(IC-1,2,K)
TR3 = CC(I-1,3,K)+CC(IC-1,2,K)
CH(I-1,K,1) = TR2+TR3
CR3 = TR2-TR3
CH(I,K,1) = TI2+TI3
CI3 = TI2-TI3
CR2 = TR1-TR4
CR4 = TR1+TR4
CI2 = TI1+TI4
CI4 = TI1-TI4
CH(I-1,K,2) = WA1(I-2)*CR2-WA1(I-1)*CI2
CH(I,K,2) = WA1(I-2)*CI2+WA1(I-1)*CR2
CH(I-1,K,3) = WA2(I-2)*CR3-WA2(I-1)*CI3
CH(I,K,3) = WA2(I-2)*CI3+WA2(I-1)*CR3
CH(I-1,K,4) = WA3(I-2)*CR4-WA3(I-1)*CI4
CH(I,K,4) = WA3(I-2)*CI4+WA3(I-1)*CR4
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 CONTINUE
DO 106 K=1,L1
TI1 = CC(1,2,K)+CC(1,4,K)
TI2 = CC(1,4,K)-CC(1,2,K)
TR1 = CC(IDO,1,K)-CC(IDO,3,K)
TR2 = CC(IDO,1,K)+CC(IDO,3,K)
CH(IDO,K,1) = TR2+TR2
CH(IDO,K,2) = SQRT2*(TR1-TI1)
CH(IDO,K,3) = TI2+TI2
CH(IDO,K,4) = -SQRT2*(TR1+TI1)
106 CONTINUE
107 RETURN
END
SUBROUTINE DRADB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /
1 .30901699437494742410229341718281905D0,
2 .95105651629515357211643933337938214D0,
3 -.80901699437494742410229341718281906D0,
4 .58778525229247312916870595463907276D0/
DO 101 K=1,L1
TI5 = CC(1,3,K)+CC(1,3,K)
TI4 = CC(1,5,K)+CC(1,5,K)
TR2 = CC(IDO,2,K)+CC(IDO,2,K)
TR3 = CC(IDO,4,K)+CC(IDO,4,K)
CH(1,K,1) = CC(1,1,K)+TR2+TR3
CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3
CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3
CI5 = TI11*TI5+TI12*TI4
CI4 = TI12*TI5-TI11*TI4
CH(1,K,2) = CR2-CI5
CH(1,K,3) = CR3-CI4
CH(1,K,4) = CR3+CI4
CH(1,K,5) = CR2+CI5
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
TI5 = CC(I,3,K)+CC(IC,2,K)
TI2 = CC(I,3,K)-CC(IC,2,K)
TI4 = CC(I,5,K)+CC(IC,4,K)
TI3 = CC(I,5,K)-CC(IC,4,K)
TR5 = CC(I-1,3,K)-CC(IC-1,2,K)
TR2 = CC(I-1,3,K)+CC(IC-1,2,K)
TR4 = CC(I-1,5,K)-CC(IC-1,4,K)
TR3 = CC(I-1,5,K)+CC(IC-1,4,K)
CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3
CH(I,K,1) = CC(I,1,K)+TI2+TI3
CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3
CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3
CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3
CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3
CR5 = TI11*TR5+TI12*TR4
CI5 = TI11*TI5+TI12*TI4
CR4 = TI12*TR5-TI11*TR4
CI4 = TI12*TI5-TI11*TI4
DR3 = CR3-CI4
DR4 = CR3+CI4
DI3 = CI3+CR4
DI4 = CI3-CR4
DR5 = CR2+CI5
DR2 = CR2-CI5
DI5 = CI2-CR5
DI2 = CI2+CR5
CH(I-1,K,2) = WA1(I-2)*DR2-WA1(I-1)*DI2
CH(I,K,2) = WA1(I-2)*DI2+WA1(I-1)*DR2
CH(I-1,K,3) = WA2(I-2)*DR3-WA2(I-1)*DI3
CH(I,K,3) = WA2(I-2)*DI3+WA2(I-1)*DR3
CH(I-1,K,4) = WA3(I-2)*DR4-WA3(I-1)*DI4
CH(I,K,4) = WA3(I-2)*DI4+WA3(I-1)*DR4
CH(I-1,K,5) = WA4(I-2)*DR5-WA4(I-1)*DI5
CH(I,K,5) = WA4(I-2)*DI5+WA4(I-1)*DR5
102 CONTINUE
103 CONTINUE
RETURN
END
SUBROUTINE DRADBG (IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) ,
1 C1(IDO,L1,IP) ,C2(IDL1,IP),
2 CH2(IDL1,IP) ,WA(*)
DATA TPI/6.2831853071795864769252867665590057D0/
ARG = TPI/DBLE(IP)
DCP = DCOS(ARG)
DSP = DSIN(ARG)
IDP2 = IDO+2
NBD = (IDO-1)/2
IPP2 = IP+2
IPPH = (IP+1)/2
IF (IDO .LT. L1) GO TO 103
DO 102 K=1,L1
DO 101 I=1,IDO
CH(I,K,1) = CC(I,1,K)
101 CONTINUE
102 CONTINUE
GO TO 106
103 DO 105 I=1,IDO
DO 104 K=1,L1
CH(I,K,1) = CC(I,1,K)
104 CONTINUE
105 CONTINUE
106 DO 108 J=2,IPPH
JC = IPP2-J
J2 = J+J
DO 107 K=1,L1
CH(1,K,J) = CC(IDO,J2-2,K)+CC(IDO,J2-2,K)
CH(1,K,JC) = CC(1,J2-1,K)+CC(1,J2-1,K)
107 CONTINUE
108 CONTINUE
IF (IDO .EQ. 1) GO TO 116
IF (NBD .LT. L1) GO TO 112
DO 111 J=2,IPPH
JC = IPP2-J
DO 110 K=1,L1
DO 109 I=3,IDO,2
IC = IDP2-I
CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K)
CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K)
CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K)
CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K)
109 CONTINUE
110 CONTINUE
111 CONTINUE
GO TO 116
112 DO 115 J=2,IPPH
JC = IPP2-J
DO 114 I=3,IDO,2
IC = IDP2-I
DO 113 K=1,L1
CH(I-1,K,J) = CC(I-1,2*J-1,K)+CC(IC-1,2*J-2,K)
CH(I-1,K,JC) = CC(I-1,2*J-1,K)-CC(IC-1,2*J-2,K)
CH(I,K,J) = CC(I,2*J-1,K)-CC(IC,2*J-2,K)
CH(I,K,JC) = CC(I,2*J-1,K)+CC(IC,2*J-2,K)
113 CONTINUE
114 CONTINUE
115 CONTINUE
116 AR1 = 1.0D0
AI1 = 0.0D0
DO 120 L=2,IPPH
LC = IPP2-L
AR1H = DCP*AR1-DSP*AI1
AI1 = DCP*AI1+DSP*AR1
AR1 = AR1H
DO 117 IK=1,IDL1
C2(IK,L) = CH2(IK,1)+AR1*CH2(IK,2)
C2(IK,LC) = AI1*CH2(IK,IP)
117 CONTINUE
DC2 = AR1
DS2 = AI1
AR2 = AR1
AI2 = AI1
DO 119 J=3,IPPH
JC = IPP2-J
AR2H = DC2*AR2-DS2*AI2
AI2 = DC2*AI2+DS2*AR2
AR2 = AR2H
DO 118 IK=1,IDL1
C2(IK,L) = C2(IK,L)+AR2*CH2(IK,J)
C2(IK,LC) = C2(IK,LC)+AI2*CH2(IK,JC)
118 CONTINUE
119 CONTINUE
120 CONTINUE
DO 122 J=2,IPPH
DO 121 IK=1,IDL1
CH2(IK,1) = CH2(IK,1)+CH2(IK,J)
121 CONTINUE
122 CONTINUE
DO 124 J=2,IPPH
JC = IPP2-J
DO 123 K=1,L1
CH(1,K,J) = C1(1,K,J)-C1(1,K,JC)
CH(1,K,JC) = C1(1,K,J)+C1(1,K,JC)
123 CONTINUE
124 CONTINUE
IF (IDO .EQ. 1) GO TO 132
IF (NBD .LT. L1) GO TO 128
DO 127 J=2,IPPH
JC = IPP2-J
DO 126 K=1,L1
DO 125 I=3,IDO,2
CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC)
CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC)
CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC)
CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC)
125 CONTINUE
126 CONTINUE
127 CONTINUE
GO TO 132
128 DO 131 J=2,IPPH
JC = IPP2-J
DO 130 I=3,IDO,2
DO 129 K=1,L1
CH(I-1,K,J) = C1(I-1,K,J)-C1(I,K,JC)
CH(I-1,K,JC) = C1(I-1,K,J)+C1(I,K,JC)
CH(I,K,J) = C1(I,K,J)+C1(I-1,K,JC)
CH(I,K,JC) = C1(I,K,J)-C1(I-1,K,JC)
129 CONTINUE
130 CONTINUE
131 CONTINUE
132 CONTINUE
IF (IDO .EQ. 1) RETURN
DO 133 IK=1,IDL1
C2(IK,1) = CH2(IK,1)
133 CONTINUE
DO 135 J=2,IP
DO 134 K=1,L1
C1(1,K,J) = CH(1,K,J)
134 CONTINUE
135 CONTINUE
IF (NBD .GT. L1) GO TO 139
IS = -IDO
DO 138 J=2,IP
IS = IS+IDO
IDIJ = IS
DO 137 I=3,IDO,2
IDIJ = IDIJ+2
DO 136 K=1,L1
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
136 CONTINUE
137 CONTINUE
138 CONTINUE
GO TO 143
139 IS = -IDO
DO 142 J=2,IP
IS = IS+IDO
DO 141 K=1,L1
IDIJ = IS
DO 140 I=3,IDO,2
IDIJ = IDIJ+2
C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J)
C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J)
140 CONTINUE
141 CONTINUE
142 CONTINUE
143 RETURN
END
SUBROUTINE DRADF2 (IDO,L1,CC,CH,WA1)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,2,L1) ,CC(IDO,L1,2) ,
1 WA1(*)
DO 101 K=1,L1
CH(1,1,K) = CC(1,K,1)+CC(1,K,2)
CH(IDO,2,K) = CC(1,K,1)-CC(1,K,2)
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
DO 104 K=1,L1
DO 103 I=3,IDO,2
IC = IDP2-I
TR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2)
TI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2)
CH(I,1,K) = CC(I,K,1)+TI2
CH(IC,2,K) = TI2-CC(I,K,1)
CH(I-1,1,K) = CC(I-1,K,1)+TR2
CH(IC-1,2,K) = CC(I-1,K,1)-TR2
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 DO 106 K=1,L1
CH(1,2,K) = -CC(IDO,K,2)
CH(IDO,1,K) = CC(IDO,K,1)
106 CONTINUE
107 RETURN
END
SUBROUTINE DRADF3 (IDO,L1,CC,CH,WA1,WA2)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,3,L1) ,CC(IDO,L1,3) ,
1 WA1(*) ,WA2(*)
DATA TAUR,TAUI /-.5D0,.86602540378443864676372317075293618D0/
DO 101 K=1,L1
CR2 = CC(1,K,2)+CC(1,K,3)
CH(1,1,K) = CC(1,K,1)+CR2
CH(1,3,K) = TAUI*(CC(1,K,3)-CC(1,K,2))
CH(IDO,2,K) = CC(1,K,1)+TAUR*CR2
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
DR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2)
DI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2)
DR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3)
DI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3)
CR2 = DR2+DR3
CI2 = DI2+DI3
CH(I-1,1,K) = CC(I-1,K,1)+CR2
CH(I,1,K) = CC(I,K,1)+CI2
TR2 = CC(I-1,K,1)+TAUR*CR2
TI2 = CC(I,K,1)+TAUR*CI2
TR3 = TAUI*(DI2-DI3)
TI3 = TAUI*(DR3-DR2)
CH(I-1,3,K) = TR2+TR3
CH(IC-1,2,K) = TR2-TR3
CH(I,3,K) = TI2+TI3
CH(IC,2,K) = TI3-TI2
102 CONTINUE
103 CONTINUE
RETURN
END
SUBROUTINE DRADF4 (IDO,L1,CC,CH,WA1,WA2,WA3)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,L1,4) ,CH(IDO,4,L1) ,
1 WA1(*) ,WA2(*) ,WA3(*)
DATA HSQT2 /0.70710678118654752440084436210484904D0/
DO 101 K=1,L1
TR1 = CC(1,K,2)+CC(1,K,4)
TR2 = CC(1,K,1)+CC(1,K,3)
CH(1,1,K) = TR1+TR2
CH(IDO,4,K) = TR2-TR1
CH(IDO,2,K) = CC(1,K,1)-CC(1,K,3)
CH(1,3,K) = CC(1,K,4)-CC(1,K,2)
101 CONTINUE
IF (IDO-2) 107,105,102
102 IDP2 = IDO+2
DO 104 K=1,L1
DO 103 I=3,IDO,2
IC = IDP2-I
CR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2)
CI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2)
CR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3)
CI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3)
CR4 = WA3(I-2)*CC(I-1,K,4)+WA3(I-1)*CC(I,K,4)
CI4 = WA3(I-2)*CC(I,K,4)-WA3(I-1)*CC(I-1,K,4)
TR1 = CR2+CR4
TR4 = CR4-CR2
TI1 = CI2+CI4
TI4 = CI2-CI4
TI2 = CC(I,K,1)+CI3
TI3 = CC(I,K,1)-CI3
TR2 = CC(I-1,K,1)+CR3
TR3 = CC(I-1,K,1)-CR3
CH(I-1,1,K) = TR1+TR2
CH(IC-1,4,K) = TR2-TR1
CH(I,1,K) = TI1+TI2
CH(IC,4,K) = TI1-TI2
CH(I-1,3,K) = TI4+TR3
CH(IC-1,2,K) = TR3-TI4
CH(I,3,K) = TR4+TI3
CH(IC,2,K) = TR4-TI3
103 CONTINUE
104 CONTINUE
IF (MOD(IDO,2) .EQ. 1) RETURN
105 CONTINUE
DO 106 K=1,L1
TI1 = -HSQT2*(CC(IDO,K,2)+CC(IDO,K,4))
TR1 = HSQT2*(CC(IDO,K,2)-CC(IDO,K,4))
CH(IDO,1,K) = TR1+CC(IDO,K,1)
CH(IDO,3,K) = CC(IDO,K,1)-TR1
CH(1,2,K) = TI1-CC(IDO,K,3)
CH(1,4,K) = TI1+CC(IDO,K,3)
106 CONTINUE
107 RETURN
END
SUBROUTINE DRADF5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CC(IDO,L1,5) ,CH(IDO,5,L1) ,
1 WA1(*) ,WA2(*) ,WA3(*) ,WA4(*)
DATA TR11,TI11,TR12,TI12 /
1 .30901699437494742410229341718281905D0,
2 .95105651629515357211643933337938214D0,
3 -.80901699437494742410229341718281906D0,
4 .58778525229247312916870595463907276D0/
DO 101 K=1,L1
CR2 = CC(1,K,5)+CC(1,K,2)
CI5 = CC(1,K,5)-CC(1,K,2)
CR3 = CC(1,K,4)+CC(1,K,3)
CI4 = CC(1,K,4)-CC(1,K,3)
CH(1,1,K) = CC(1,K,1)+CR2+CR3
CH(IDO,2,K) = CC(1,K,1)+TR11*CR2+TR12*CR3
CH(1,3,K) = TI11*CI5+TI12*CI4
CH(IDO,4,K) = CC(1,K,1)+TR12*CR2+TR11*CR3
CH(1,5,K) = TI12*CI5-TI11*CI4
101 CONTINUE
IF (IDO .EQ. 1) RETURN
IDP2 = IDO+2
DO 103 K=1,L1
DO 102 I=3,IDO,2
IC = IDP2-I
DR2 = WA1(I-2)*CC(I-1,K,2)+WA1(I-1)*CC(I,K,2)
DI2 = WA1(I-2)*CC(I,K,2)-WA1(I-1)*CC(I-1,K,2)
DR3 = WA2(I-2)*CC(I-1,K,3)+WA2(I-1)*CC(I,K,3)
DI3 = WA2(I-2)*CC(I,K,3)-WA2(I-1)*CC(I-1,K,3)
DR4 = WA3(I-2)*CC(I-1,K,4)+WA3(I-1)*CC(I,K,4)
DI4 = WA3(I-2)*CC(I,K,4)-WA3(I-1)*CC(I-1,K,4)
DR5 = WA4(I-2)*CC(I-1,K,5)+WA4(I-1)*CC(I,K,5)
DI5 = WA4(I-2)*CC(I,K,5)-WA4(I-1)*CC(I-1,K,5)
CR2 = DR2+DR5
CI5 = DR5-DR2
CR5 = DI2-DI5
CI2 = DI2+DI5
CR3 = DR3+DR4
CI4 = DR4-DR3
CR4 = DI3-DI4
CI3 = DI3+DI4
CH(I-1,1,K) = CC(I-1,K,1)+CR2+CR3
CH(I,1,K) = CC(I,K,1)+CI2+CI3
TR2 = CC(I-1,K,1)+TR11*CR2+TR12*CR3
TI2 = CC(I,K,1)+TR11*CI2+TR12*CI3
TR3 = CC(I-1,K,1)+TR12*CR2+TR11*CR3
TI3 = CC(I,K,1)+TR12*CI2+TR11*CI3
TR5 = TI11*CR5+TI12*CR4
TI5 = TI11*CI5+TI12*CI4
TR4 = TI12*CR5-TI11*CR4
TI4 = TI12*CI5-TI11*CI4
CH(I-1,3,K) = TR2+TR5
CH(IC-1,2,K) = TR2-TR5
CH(I,3,K) = TI2+TI5
CH(IC,2,K) = TI5-TI2
CH(I-1,5,K) = TR3+TR4
CH(IC-1,4,K) = TR3-TR4
CH(I,5,K) = TI3+TI4
CH(IC,4,K) = TI4-TI3
102 CONTINUE
103 CONTINUE
RETURN
END
SUBROUTINE DRADFG (IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) ,
1 C1(IDO,L1,IP) ,C2(IDL1,IP),
2 CH2(IDL1,IP) ,WA(*)
DATA TPI/6.2831853071795864769252867665590057D0/
ARG = TPI/DBLE(IP)
DCP = DCOS(ARG)
DSP = DSIN(ARG)
IPPH = (IP+1)/2
IPP2 = IP+2
IDP2 = IDO+2
NBD = (IDO-1)/2
IF (IDO .EQ. 1) GO TO 119
DO 101 IK=1,IDL1
CH2(IK,1) = C2(IK,1)
101 CONTINUE
DO 103 J=2,IP
DO 102 K=1,L1
CH(1,K,J) = C1(1,K,J)
102 CONTINUE
103 CONTINUE
IF (NBD .GT. L1) GO TO 107
IS = -IDO
DO 106 J=2,IP
IS = IS+IDO
IDIJ = IS
DO 105 I=3,IDO,2
IDIJ = IDIJ+2
DO 104 K=1,L1
CH(I-1,K,J) = WA(IDIJ-1)*C1(I-1,K,J)+WA(IDIJ)*C1(I,K,J)
CH(I,K,J) = WA(IDIJ-1)*C1(I,K,J)-WA(IDIJ)*C1(I-1,K,J)
104 CONTINUE
105 CONTINUE
106 CONTINUE
GO TO 111
107 IS = -IDO
DO 110 J=2,IP
IS = IS+IDO
DO 109 K=1,L1
IDIJ = IS
DO 108 I=3,IDO,2
IDIJ = IDIJ+2
CH(I-1,K,J) = WA(IDIJ-1)*C1(I-1,K,J)+WA(IDIJ)*C1(I,K,J)
CH(I,K,J) = WA(IDIJ-1)*C1(I,K,J)-WA(IDIJ)*C1(I-1,K,J)
108 CONTINUE
109 CONTINUE
110 CONTINUE
111 IF (NBD .LT. L1) GO TO 115
DO 114 J=2,IPPH
JC = IPP2-J
DO 113 K=1,L1
DO 112 I=3,IDO,2
C1(I-1,K,J) = CH(I-1,K,J)+CH(I-1,K,JC)
C1(I-1,K,JC) = CH(I,K,J)-CH(I,K,JC)
C1(I,K,J) = CH(I,K,J)+CH(I,K,JC)
C1(I,K,JC) = CH(I-1,K,JC)-CH(I-1,K,J)
112 CONTINUE
113 CONTINUE
114 CONTINUE
GO TO 121
115 DO 118 J=2,IPPH
JC = IPP2-J
DO 117 I=3,IDO,2
DO 116 K=1,L1
C1(I-1,K,J) = CH(I-1,K,J)+CH(I-1,K,JC)
C1(I-1,K,JC) = CH(I,K,J)-CH(I,K,JC)
C1(I,K,J) = CH(I,K,J)+CH(I,K,JC)
C1(I,K,JC) = CH(I-1,K,JC)-CH(I-1,K,J)
116 CONTINUE
117 CONTINUE
118 CONTINUE
GO TO 121
119 DO 120 IK=1,IDL1
C2(IK,1) = CH2(IK,1)
120 CONTINUE
121 DO 123 J=2,IPPH
JC = IPP2-J
DO 122 K=1,L1
C1(1,K,J) = CH(1,K,J)+CH(1,K,JC)
C1(1,K,JC) = CH(1,K,JC)-CH(1,K,J)
122 CONTINUE
123 CONTINUE
C
AR1 = 1.0D0
AI1 = 0.0D0
DO 127 L=2,IPPH
LC = IPP2-L
AR1H = DCP*AR1-DSP*AI1
AI1 = DCP*AI1+DSP*AR1
AR1 = AR1H
DO 124 IK=1,IDL1
CH2(IK,L) = C2(IK,1)+AR1*C2(IK,2)
CH2(IK,LC) = AI1*C2(IK,IP)
124 CONTINUE
DC2 = AR1
DS2 = AI1
AR2 = AR1
AI2 = AI1
DO 126 J=3,IPPH
JC = IPP2-J
AR2H = DC2*AR2-DS2*AI2
AI2 = DC2*AI2+DS2*AR2
AR2 = AR2H
DO 125 IK=1,IDL1
CH2(IK,L) = CH2(IK,L)+AR2*C2(IK,J)
CH2(IK,LC) = CH2(IK,LC)+AI2*C2(IK,JC)
125 CONTINUE
126 CONTINUE
127 CONTINUE
DO 129 J=2,IPPH
DO 128 IK=1,IDL1
CH2(IK,1) = CH2(IK,1)+C2(IK,J)
128 CONTINUE
129 CONTINUE
C
IF (IDO .LT. L1) GO TO 132
DO 131 K=1,L1
DO 130 I=1,IDO
CC(I,1,K) = CH(I,K,1)
130 CONTINUE
131 CONTINUE
GO TO 135
132 DO 134 I=1,IDO
DO 133 K=1,L1
CC(I,1,K) = CH(I,K,1)
133 CONTINUE
134 CONTINUE
135 DO 137 J=2,IPPH
JC = IPP2-J
J2 = J+J
DO 136 K=1,L1
CC(IDO,J2-2,K) = CH(1,K,J)
CC(1,J2-1,K) = CH(1,K,JC)
136 CONTINUE
137 CONTINUE
IF (IDO .EQ. 1) RETURN
IF (NBD .LT. L1) GO TO 141
DO 140 J=2,IPPH
JC = IPP2-J
J2 = J+J
DO 139 K=1,L1
DO 138 I=3,IDO,2
IC = IDP2-I
CC(I-1,J2-1,K) = CH(I-1,K,J)+CH(I-1,K,JC)
CC(IC-1,J2-2,K) = CH(I-1,K,J)-CH(I-1,K,JC)
CC(I,J2-1,K) = CH(I,K,J)+CH(I,K,JC)
CC(IC,J2-2,K) = CH(I,K,JC)-CH(I,K,J)
138 CONTINUE
139 CONTINUE
140 CONTINUE
RETURN
141 DO 144 J=2,IPPH
JC = IPP2-J
J2 = J+J
DO 143 I=3,IDO,2
IC = IDP2-I
DO 142 K=1,L1
CC(I-1,J2-1,K) = CH(I-1,K,J)+CH(I-1,K,JC)
CC(IC-1,J2-2,K) = CH(I-1,K,J)-CH(I-1,K,JC)
CC(I,J2-1,K) = CH(I,K,J)+CH(I,K,JC)
CC(IC,J2-2,K) = CH(I,K,JC)-CH(I,K,J)
142 CONTINUE
143 CONTINUE
144 CONTINUE
RETURN
END
SUBROUTINE DFFTB1 (N,C,CH,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
NF = IFAC(2)
NA = 0
L1 = 1
IW = 1
DO 116 K1=1,NF
IP = IFAC(K1+2)
L2 = IP*L1
IDO = N/L2
IDL1 = IDO*L1
IF (IP .NE. 4) GO TO 103
IX2 = IW+IDO
IX3 = IX2+IDO
IF (NA .NE. 0) GO TO 101
CALL DRADB4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 102
101 CALL DRADB4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
102 NA = 1-NA
GO TO 115
103 IF (IP .NE. 2) GO TO 106
IF (NA .NE. 0) GO TO 104
CALL DRADB2 (IDO,L1,C,CH,WA(IW))
GO TO 105
104 CALL DRADB2 (IDO,L1,CH,C,WA(IW))
105 NA = 1-NA
GO TO 115
106 IF (IP .NE. 3) GO TO 109
IX2 = IW+IDO
IF (NA .NE. 0) GO TO 107
CALL DRADB3 (IDO,L1,C,CH,WA(IW),WA(IX2))
GO TO 108
107 CALL DRADB3 (IDO,L1,CH,C,WA(IW),WA(IX2))
108 NA = 1-NA
GO TO 115
109 IF (IP .NE. 5) GO TO 112
IX2 = IW+IDO
IX3 = IX2+IDO
IX4 = IX3+IDO
IF (NA .NE. 0) GO TO 110
CALL DRADB5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 111
110 CALL DRADB5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
111 NA = 1-NA
GO TO 115
112 IF (NA .NE. 0) GO TO 113
CALL DRADBG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
GO TO 114
113 CALL DRADBG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
114 IF (IDO .EQ. 1) NA = 1-NA
115 L1 = L2
IW = IW+(IP-1)*IDO
116 CONTINUE
IF (NA .EQ. 0) RETURN
DO 117 I=1,N
C(I) = CH(I)
117 CONTINUE
RETURN
END
SUBROUTINE DFFTB (N,R,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION R(*) ,WSAVE(*)
IF (N .EQ. 1) RETURN
CALL DFFTB1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE DFFTF1 (N,C,CH,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*)
NF = IFAC(2)
NA = 1
L2 = N
IW = N
DO 111 K1=1,NF
KH = NF-K1
IP = IFAC(KH+3)
L1 = L2/IP
IDO = N/L2
IDL1 = IDO*L1
IW = IW-(IP-1)*IDO
NA = 1-NA
IF (IP .NE. 4) GO TO 102
IX2 = IW+IDO
IX3 = IX2+IDO
IF (NA .NE. 0) GO TO 101
CALL DRADF4 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3))
GO TO 110
101 CALL DRADF4 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3))
GO TO 110
102 IF (IP .NE. 2) GO TO 104
IF (NA .NE. 0) GO TO 103
CALL DRADF2 (IDO,L1,C,CH,WA(IW))
GO TO 110
103 CALL DRADF2 (IDO,L1,CH,C,WA(IW))
GO TO 110
104 IF (IP .NE. 3) GO TO 106
IX2 = IW+IDO
IF (NA .NE. 0) GO TO 105
CALL DRADF3 (IDO,L1,C,CH,WA(IW),WA(IX2))
GO TO 110
105 CALL DRADF3 (IDO,L1,CH,C,WA(IW),WA(IX2))
GO TO 110
106 IF (IP .NE. 5) GO TO 108
IX2 = IW+IDO
IX3 = IX2+IDO
IX4 = IX3+IDO
IF (NA .NE. 0) GO TO 107
CALL DRADF5 (IDO,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 110
107 CALL DRADF5 (IDO,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4))
GO TO 110
108 IF (IDO .EQ. 1) NA = 1-NA
IF (NA .NE. 0) GO TO 109
CALL DRADFG (IDO,IP,L1,IDL1,C,C,C,CH,CH,WA(IW))
NA = 1
GO TO 110
109 CALL DRADFG (IDO,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW))
NA = 0
110 L2 = L1
111 CONTINUE
IF (NA .EQ. 1) RETURN
DO 112 I=1,N
C(I) = CH(I)
112 CONTINUE
RETURN
END
SUBROUTINE DFFTF (N,R,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION R(*) ,WSAVE(*)
IF (N .EQ. 1) RETURN
CALL DFFTF1 (N,R,WSAVE,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE DFFTI1 (N,WA,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WA(*) ,IFAC(*) ,NTRYH(4)
DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/4,2,3,5/
NL = N
NF = 0
J = 0
101 J = J+1
IF (J-4) 102,102,103
102 NTRY = NTRYH(J)
GO TO 104
103 NTRY = NTRY+2
104 NQ = NL/NTRY
NR = NL-NTRY*NQ
IF (NR) 101,105,101
105 NF = NF+1
IFAC(NF+2) = NTRY
NL = NQ
IF (NTRY .NE. 2) GO TO 107
IF (NF .EQ. 1) GO TO 107
DO 106 I=2,NF
IB = NF-I+2
IFAC(IB+2) = IFAC(IB+1)
106 CONTINUE
IFAC(3) = 2
107 IF (NL .NE. 1) GO TO 104
IFAC(1) = N
IFAC(2) = NF
TPI = 6.2831853071795864769252867665590057D0
ARGH = TPI/DBLE(N)
IS = 0
NFM1 = NF-1
L1 = 1
IF (NFM1 .EQ. 0) RETURN
DO 110 K1=1,NFM1
IP = IFAC(K1+2)
LD = 0
L2 = L1*IP
IDO = N/L2
IPM = IP-1
DO 109 J=1,IPM
LD = LD+L1
I = IS
ARGLD = DBLE(LD)*ARGH
FI = 0.0D0
DO 108 II=3,IDO,2
I = I+2
FI = FI+1.0D0
ARG = FI*ARGLD
WA(I-1) = DCOS(ARG)
WA(I) = DSIN(ARG)
108 CONTINUE
IS = IS+IDO
109 CONTINUE
L1 = L2
110 CONTINUE
RETURN
END
SUBROUTINE DFFTI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
IF (N .EQ. 1) RETURN
CALL DFFTI1 (N,WSAVE(N+1),WSAVE(2*N+1))
RETURN
END
SUBROUTINE DSINQB (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
IF (N .GT. 1) GO TO 101
X(1) = 4.0D0*X(1)
RETURN
101 NS2 = N/2
DO 102 K=2,N,2
X(K) = -X(K)
102 CONTINUE
CALL DCOSQB (N,X,WSAVE)
DO 103 K=1,NS2
KC = N-K
XHOLD = X(K)
X(K) = X(KC+1)
X(KC+1) = XHOLD
103 CONTINUE
RETURN
END
SUBROUTINE DSINQF (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
IF (N .EQ. 1) RETURN
NS2 = N/2
DO 101 K=1,NS2
KC = N-K
XHOLD = X(K)
X(K) = X(KC+1)
X(KC+1) = XHOLD
101 CONTINUE
CALL DCOSQF (N,X,WSAVE)
DO 102 K=2,N,2
X(K) = -X(K)
102 CONTINUE
RETURN
END
SUBROUTINE DSINQI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
CALL DCOSQI (N,WSAVE)
RETURN
END
SUBROUTINE DSINT1(N,WAR,WAS,XH,X,IFAC)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WAR(*),WAS(*),X(*),XH(*),IFAC(*)
DATA SQRT3 /1.7320508075688772935274463415058723D0/
DO 100 I=1,N
XH(I) = WAR(I)
WAR(I) = X(I)
100 CONTINUE
IF (N-2) 101,102,103
101 XH(1) = XH(1)+XH(1)
GO TO 106
102 XHOLD = SQRT3*(XH(1)+XH(2))
XH(2) = SQRT3*(XH(1)-XH(2))
XH(1) = XHOLD
GO TO 106
103 NP1 = N+1
NS2 = N/2
X(1) = 0.0D0
DO 104 K=1,NS2
KC = NP1-K
T1 = XH(K)-XH(KC)
T2 = WAS(K)*(XH(K)+XH(KC))
X(K+1) = T1+T2
X(KC+1) = T2-T1
104 CONTINUE
MODN = MOD(N,2)
IF (MODN .NE. 0) X(NS2+2) = 4.0D0*XH(NS2+1)
CALL DFFTF1 (NP1,X,XH,WAR,IFAC)
XH(1) = .5D0*X(1)
DO 105 I=3,N,2
XH(I-1) = -X(I)
XH(I) = XH(I-2)+X(I-1)
105 CONTINUE
IF (MODN .NE. 0) GO TO 106
XH(N) = -X(N+1)
106 DO 107 I=1,N
X(I) = WAR(I)
WAR(I) = XH(I)
107 CONTINUE
RETURN
END
SUBROUTINE DSINT (N,X,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(*) ,WSAVE(*)
NP1 = N+1
IW1 = N/2+1
IW2 = IW1+NP1
IW3 = IW2+NP1
CALL DSINT1(N,X,WSAVE,WSAVE(IW1),WSAVE(IW2),WSAVE(IW3))
RETURN
END
SUBROUTINE DSINTI (N,WSAVE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION WSAVE(*)
DATA PI /3.1415926535897932384626433832795028D0/
IF (N .LE. 1) RETURN
NS2 = N/2
NP1 = N+1
DT = PI/DBLE(NP1)
DO 101 K=1,NS2
WSAVE(K) = 2.0D0*DSIN(K*DT)
101 CONTINUE
CALL DFFTI (NP1,WSAVE(NS2+1))
RETURN
END
| bsd-3-clause |
Pakketeretet2/lammps | lib/linalg/dgeqr2.f | 21 | 5130 | *> \brief \b DGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm.
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DGEQR2 + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgeqr2.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgeqr2.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgeqr2.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DGEQR2( M, N, A, LDA, TAU, WORK, INFO )
*
* .. Scalar Arguments ..
* INTEGER INFO, LDA, M, N
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DGEQR2 computes a QR factorization of a real m by n matrix A:
*> A = Q * R.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix A. M >= 0.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in,out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> On entry, the m by n matrix A.
*> On exit, the elements on and above the diagonal of the array
*> contain the min(m,n) by n upper trapezoidal matrix R (R is
*> upper triangular if m >= n); the elements below the diagonal,
*> with the array TAU, represent the orthogonal matrix Q as a
*> product of elementary reflectors (see Further Details).
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*>
*> \param[out] TAU
*> \verbatim
*> TAU is DOUBLE PRECISION array, dimension (min(M,N))
*> The scalar factors of the elementary reflectors (see Further
*> Details).
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION array, dimension (N)
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> = 0: successful exit
*> < 0: if INFO = -i, the i-th argument had an illegal value
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date December 2016
*
*> \ingroup doubleGEcomputational
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> The matrix Q is represented as a product of elementary reflectors
*>
*> Q = H(1) H(2) . . . H(k), where k = min(m,n).
*>
*> Each H(i) has the form
*>
*> H(i) = I - tau * v * v**T
*>
*> where tau is a real scalar, and v is a real vector with
*> v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
*> and tau in TAU(i).
*> \endverbatim
*>
* =====================================================================
SUBROUTINE DGEQR2( M, N, A, LDA, TAU, WORK, INFO )
*
* -- LAPACK computational routine (version 3.7.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* December 2016
*
* .. Scalar Arguments ..
INTEGER INFO, LDA, M, N
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE
PARAMETER ( ONE = 1.0D+0 )
* ..
* .. Local Scalars ..
INTEGER I, K
DOUBLE PRECISION AII
* ..
* .. External Subroutines ..
EXTERNAL DLARF, DLARFG, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Executable Statements ..
*
* Test the input arguments
*
INFO = 0
IF( M.LT.0 ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
INFO = -4
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DGEQR2', -INFO )
RETURN
END IF
*
K = MIN( M, N )
*
DO 10 I = 1, K
*
* Generate elementary reflector H(i) to annihilate A(i+1:m,i)
*
CALL DLARFG( M-I+1, A( I, I ), A( MIN( I+1, M ), I ), 1,
$ TAU( I ) )
IF( I.LT.N ) THEN
*
* Apply H(i) to A(i:m,i+1:n) from the left
*
AII = A( I, I )
A( I, I ) = ONE
CALL DLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAU( I ),
$ A( I, I+1 ), LDA, WORK )
A( I, I ) = AII
END IF
10 CONTINUE
RETURN
*
* End of DGEQR2
*
END
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/alloc_comp_auto_array_2.f90 | 19 | 1331 | ! { dg-do run }
! Tests the fix for PR34820, in which the nullification of the
! automatic array iregion occurred in the caller, rather than the
! callee. Since 'nproc' was not available, an ICE ensued. During
! the bug fix, it was found that the scalar to array assignment
! of derived types with allocatable components did not work and
! the fix of this is tested too.
!
! Contributed by Toon Moene <toon@moene.indiv.nluug.nl>
!
module grid_io
type grid_index_region
integer, allocatable::lons(:)
end type grid_index_region
contains
subroutine read_grid_header()
integer :: npiece = 1
type(grid_index_region),allocatable :: iregion(:)
allocate (iregion(npiece + 1))
call read_iregion(npiece,iregion)
if (size(iregion) .ne. npiece + 1) STOP 1
if (.not.allocated (iregion(npiece)%lons)) STOP 2
if (allocated (iregion(npiece+1)%lons)) STOP 3
if (any (iregion(npiece)%lons .ne. [(i, i = 1, npiece)])) STOP 4
deallocate (iregion)
end subroutine read_grid_header
subroutine read_iregion (nproc,iregion)
integer,intent(in)::nproc
type(grid_index_region), intent(OUT)::iregion(1:nproc)
integer :: iarg(nproc)
iarg = [(i, i = 1, nproc)]
iregion = grid_index_region (iarg) !
end subroutine read_iregion
end module grid_io
use grid_io
call read_grid_header
end
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/fmt_en_rd.f90 | 8 | 9704 | ! { dg-do run }
! PR60128 Invalid outputs with EN descriptors
! Test case provided by Walt Brainerd.
program pr60128
use ISO_FORTRAN_ENV
implicit none
integer, parameter :: j(size(real_kinds)+4)=[REAL_KINDS, [4, 4, 4, 4]]
logical :: l_skip(4) = .false.
integer :: i
integer :: n_tst = 0, n_cnt = 0, n_skip = 0
character(len=20,kind=4) :: s, s1
! Check that the default rounding mode is to nearest and to even on tie.
do i=1,size(real_kinds)
if (i == 1) then
write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(1)), &
real(9.49999905,kind=j(1)), &
real(9.5,kind=j(1)), real(8.5,kind=j(1))
write(s1, '(3PE10.3,2PE10.3)') real(987350.,kind=j(1)), &
real(98765.0,kind=j(1))
else if (i == 2) then
write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(2)), &
real(9.49999905,kind=j(2)), &
real(9.5,kind=j(2)), real(8.5,kind=j(2))
write(s1, '(3PE10.3,2PE10.3)') real(987350.,kind=j(2)), &
real(98765.0,kind=j(2))
else if (i == 3) then
write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(3)), &
real(9.49999905,kind=j(3)), &
real(9.5,kind=j(3)), real(8.5,kind=j(3))
write(s1, '(3PE10.3,2PE10.3)') real(987350.,kind=j(3)), &
real(98765.0,kind=j(3))
else if (i == 4) then
write(s, '(2F4.1,2F4.0)') real(-9.49999905,kind=j(4)), &
real(9.49999905,kind=j(4)), &
real(9.5,kind=j(4)), real(8.5,kind=j(4))
write(s1, '(3PE10.3,2PE10.3)') real(987350.,kind=j(4)), &
real(98765.0,kind=j(4))
end if
if (s /= 4_'-9.5 9.5 10. 8.' .or. s1 /= 4_' 987.4E+03 98.76E+03') then
l_skip(i) = .true.
print "('Unsupported rounding for real(',i0,')')", j(i)
end if
end do
! Original test.
call checkfmt("(en15.2)", -.44444, 4_" -444.44E-03")
! Test for the bug in comment 6.
call checkfmt("(rd,en15.0)", 1.0, 4_" 1.E+00")
call checkfmt("(rd,en15.0)", 1.00000012, 4_" 1.E+00")
call checkfmt("(rd,en15.0)", 0.99999994, 4_" 999.E-03")
call checkfmt("(rd,en15.0)", 10.0, 4_" 10.E+00")
call checkfmt("(rd,en15.0)", 10.0000010, 4_" 10.E+00")
call checkfmt("(rd,en15.0)", 9.99999905, 4_" 9.E+00")
call checkfmt("(ru,en15.0)", 100.0, 4_" 100.E+00")
call checkfmt("(rd,en15.0)", 100.000008, 4_" 100.E+00")
call checkfmt("(rd,en15.0)", 99.9999924, 4_" 99.E+00")
call checkfmt("(rd,en15.0)", 1000.0, 4_" 1.E+03")
call checkfmt("(rd,en15.0)", 1000.00006, 4_" 1.E+03")
call checkfmt("(rd,en15.0)", 999.999939, 4_" 999.E+00")
call checkfmt("(rd,en15.0)", 9.5, 4_" 9.E+00")
call checkfmt("(rd,en15.0)", 9.50000095, 4_" 9.E+00")
call checkfmt("(rd,en15.0)", 9.49999905, 4_" 9.E+00")
call checkfmt("(rd,en15.0)", 99.5, 4_" 99.E+00")
call checkfmt("(rd,en15.0)", 99.5000076, 4_" 99.E+00")
call checkfmt("(rd,en15.0)", 99.4999924, 4_" 99.E+00")
call checkfmt("(rd,en15.0)", 999.5, 4_" 999.E+00")
call checkfmt("(rd,en15.0)", 999.500061, 4_" 999.E+00")
call checkfmt("(rd,en15.0)", 999.499939, 4_" 999.E+00")
call checkfmt("(rd,en15.0)", 9500.0, 4_" 9.E+03")
call checkfmt("(rd,en15.0)", 9500.00098, 4_" 9.E+03")
call checkfmt("(rd,en15.0)", 9499.99902, 4_" 9.E+03")
call checkfmt("(rd,en15.1)", 9950.0, 4_" 9.9E+03")
call checkfmt("(rd,en15.2)", 9995.0, 4_" 9.99E+03")
call checkfmt("(rd,en15.3)", 9999.5, 4_" 9.999E+03")
call checkfmt("(rd,en15.1)", 9.5, 4_" 9.5E+00")
call checkfmt("(rd,en15.1)", 9.50000095, 4_" 9.5E+00")
call checkfmt("(rd,en15.1)", 9.49999905, 4_" 9.4E+00")
call checkfmt("(rd,en15.1)", 0.099951, 4_" 99.9E-03")
call checkfmt("(rd,en15.1)", 0.009951, 4_" 9.9E-03")
call checkfmt("(rd,en15.1)", 0.000999951,4_" 999.9E-06")
call checkfmt("(rd,en15.0)", -1.0, 4_" -1.E+00")
call checkfmt("(rd,en15.0)", -1.00000012, 4_" -2.E+00")
call checkfmt("(rd,en15.0)", -0.99999994, 4_" -1.E+00")
call checkfmt("(rd,en15.0)", -10.0, 4_" -10.E+00")
call checkfmt("(rd,en15.0)", -10.0000010, 4_" -11.E+00")
call checkfmt("(rd,en15.0)", -9.99999905, 4_" -10.E+00")
call checkfmt("(rd,en15.0)", -100.0, 4_" -100.E+00")
call checkfmt("(rd,en15.0)", -100.000008, 4_" -101.E+00")
call checkfmt("(rd,en15.0)", -99.9999924, 4_" -100.E+00")
call checkfmt("(rd,en15.0)", -1000.0, 4_" -1.E+03")
call checkfmt("(rd,en15.0)", -1000.00006, 4_" -2.E+03")
call checkfmt("(rd,en15.0)", -999.999939, 4_" -1.E+03")
call checkfmt("(rd,en15.0)", -9.5, 4_" -10.E+00")
call checkfmt("(rd,en15.0)", -9.50000095, 4_" -10.E+00")
call checkfmt("(rd,en15.0)", -9.49999905, 4_" -10.E+00")
call checkfmt("(rd,en15.0)", -99.5, 4_" -100.E+00")
call checkfmt("(rd,en15.0)", -99.5000076, 4_" -100.E+00")
call checkfmt("(rd,en15.0)", -99.4999924, 4_" -100.E+00")
call checkfmt("(rd,en15.0)", -999.5, 4_" -1.E+03")
call checkfmt("(rd,en15.0)", -999.500061, 4_" -1.E+03")
call checkfmt("(rd,en15.0)", -999.499939, 4_" -1.E+03")
call checkfmt("(rd,en15.0)", -9500.0, 4_" -10.E+03")
call checkfmt("(rd,en15.0)", -9500.00098, 4_" -10.E+03")
call checkfmt("(rd,en15.0)", -9499.99902, 4_" -10.E+03")
call checkfmt("(rd,en15.1)", -9950.0, 4_" -10.0E+03")
call checkfmt("(rd,en15.2)", -9995.0, 4_" -10.00E+03")
call checkfmt("(rd,en15.3)", -9999.5, 4_" -10.000E+03")
call checkfmt("(rd,en15.1)", -9.5, 4_" -9.5E+00")
call checkfmt("(rd,en15.1)", -9.50000095, 4_" -9.6E+00")
call checkfmt("(rd,en15.1)", -9.49999905, 4_" -9.5E+00")
call checkfmt("(rd,en15.1)", -0.099951, 4_" -100.0E-03")
call checkfmt("(rd,en15.1)", -0.009951, 4_" -10.0E-03")
call checkfmt("(rd,en15.1)", -0.000999951,4_" -1.0E-03")
call checkfmt("(rd,en15.1)", 987350., 4_" 987.3E+03")
call checkfmt("(rd,en15.2)", 98735., 4_" 98.73E+03")
call checkfmt("(rd,en15.3)", 9873.5, 4_" 9.873E+03")
call checkfmt("(rd,en15.1)", 987650., 4_" 987.6E+03")
call checkfmt("(rd,en15.2)", 98765., 4_" 98.76E+03")
call checkfmt("(rd,en15.3)", 9876.5, 4_" 9.876E+03")
call checkfmt("(rd,en15.1)", 3.125E-02, 4_" 31.2E-03")
call checkfmt("(rd,en15.1)", 9.375E-02, 4_" 93.7E-03")
call checkfmt("(rd,en15.2)", 1.5625E-02, 4_" 15.62E-03")
call checkfmt("(rd,en15.2)", 4.6875E-02, 4_" 46.87E-03")
call checkfmt("(rd,en15.3)", 7.8125E-03, 4_" 7.812E-03")
call checkfmt("(rd,en15.3)", 2.34375E-02, 4_" 23.437E-03")
call checkfmt("(rd,en15.3)", 9.765625E-04,4_" 976.562E-06")
call checkfmt("(rd,en15.6)", 2.9296875E-03,4_" 2.929687E-03")
call checkfmt("(rd,en15.1)", -987350., 4_" -987.4E+03")
call checkfmt("(rd,en15.2)", -98735., 4_" -98.74E+03")
call checkfmt("(rd,en15.3)", -9873.5, 4_" -9.874E+03")
call checkfmt("(rd,en15.1)", -987650., 4_" -987.7E+03")
call checkfmt("(rd,en15.2)", -98765., 4_" -98.77E+03")
call checkfmt("(rd,en15.3)", -9876.5, 4_" -9.877E+03")
call checkfmt("(rd,en15.1)", -3.125E-02, 4_" -31.3E-03")
call checkfmt("(rd,en15.1)", -9.375E-02, 4_" -93.8E-03")
call checkfmt("(rd,en15.2)", -1.5625E-02, 4_" -15.63E-03")
call checkfmt("(rd,en15.2)", -4.6875E-02, 4_" -46.88E-03")
call checkfmt("(rd,en15.3)", -7.8125E-03, 4_" -7.813E-03")
call checkfmt("(rd,en15.3)", -2.34375E-02, 4_" -23.438E-03")
call checkfmt("(rd,en15.3)", -9.765625E-04,4_" -976.563E-06")
call checkfmt("(rd,en15.6)", -2.9296875E-03,4_" -2.929688E-03")
print *, n_tst, n_cnt, n_skip
if (n_cnt /= 0) stop n_cnt
if (all(.not. l_skip)) print *, "All kinds rounded down"
contains
subroutine checkfmt(fmt, x, cmp)
implicit none
integer :: i
character(len=*), intent(in) :: fmt
real, intent(in) :: x
character(len=*, kind=4), intent(in) :: cmp
do i=1,size(real_kinds)
if (l_skip(i)) cycle
if (i == 1) then
write(s, fmt) real(x,kind=j(1))
else if (i == 2) then
write(s, fmt) real(x,kind=j(2))
else if (i == 3) then
write(s, fmt) real(x,kind=j(3))
else if (i == 4) then
write(s, fmt) real(x,kind=j(4))
end if
n_tst = n_tst + 1
if (s /= cmp) then
if (l_skip(i)) then
n_skip = n_skip + 1
else
print "(a,1x,a,' expected: ',1x,a)", fmt, s, cmp
n_cnt = n_cnt + 1
end if
end if
end do
end subroutine
end program
! { dg-output "All kinds rounded down" { xfail { i?86-*-solaris2.9* hppa*-*-hpux* } } }
! { dg-final { cleanup-saved-temps } }
| gpl-2.0 |
sonnyhu/scipy | scipy/special/cdflib/cdff.f | 109 | 7465 | SUBROUTINE cdff(which,p,q,f,dfn,dfd,status,bound)
C**********************************************************************
C
C SUBROUTINE CDFF( WHICH, P, Q, F, DFN, DFD, STATUS, BOUND )
C Cumulative Distribution Function
C F distribution
C
C
C Function
C
C
C Calculates any one parameter of the F distribution
C given values for the others.
C
C
C Arguments
C
C
C WHICH --> Integer indicating which of the next four argument
C values is to be calculated from the others.
C Legal range: 1..4
C iwhich = 1 : Calculate P and Q from F,DFN and DFD
C iwhich = 2 : Calculate F from P,Q,DFN and DFD
C iwhich = 3 : Calculate DFN from P,Q,F and DFD
C iwhich = 4 : Calculate DFD from P,Q,F and DFN
C INTEGER WHICH
C
C P <--> The integral from 0 to F of the f-density.
C Input range: [0,1].
C DOUBLE PRECISION P
C
C Q <--> 1-P.
C Input range: (0, 1].
C P + Q = 1.0.
C DOUBLE PRECISION Q
C
C F <--> Upper limit of integration of the f-density.
C Input range: [0, +infinity).
C Search range: [0,1E100]
C DOUBLE PRECISION F
C
C DFN < --> Degrees of freedom of the numerator sum of squares.
C Input range: (0, +infinity).
C Search range: [ 1E-100, 1E100]
C DOUBLE PRECISION DFN
C
C DFD < --> Degrees of freedom of the denominator sum of squares.
C Input range: (0, +infinity).
C Search range: [ 1E-100, 1E100]
C DOUBLE PRECISION DFD
C
C STATUS <-- 0 if calculation completed correctly
C -I if input parameter number I is out of range
C 1 if answer appears to be lower than lowest
C search bound
C 2 if answer appears to be higher than greatest
C search bound
C 3 if P + Q .ne. 1
C INTEGER STATUS
C
C BOUND <-- Undefined if STATUS is 0
C
C Bound exceeded by parameter number I if STATUS
C is negative.
C
C Lower search bound if STATUS is 1.
C
C Upper search bound if STATUS is 2.
C
C
C Method
C
C
C Formula 26.6.2 of Abramowitz and Stegun, Handbook of
C Mathematical Functions (1966) is used to reduce the computation
C of the cumulative distribution function for the F variate to
C that of an incomplete beta.
C
C Computation of other parameters involve a seach for a value that
C produces the desired value of P. The search relies on the
C monotinicity of P with the other parameter.
C
C WARNING
C
C The value of the cumulative F distribution is not necessarily
C monotone in either degrees of freedom. There thus may be two
C values that provide a given CDF value. This routine assumes
C monotonicity and will find an arbitrary one of the two values.
C
C**********************************************************************
C .. Parameters ..
DOUBLE PRECISION tol
PARAMETER (tol=1.0D-8)
DOUBLE PRECISION atol
PARAMETER (atol=1.0D-50)
DOUBLE PRECISION zero,inf
PARAMETER (zero=1.0D-100,inf=1.0D100)
C ..
C .. Scalar Arguments ..
DOUBLE PRECISION bound,dfd,dfn,f,p,q
INTEGER status,which
C ..
C .. Local Scalars ..
DOUBLE PRECISION ccum,cum,fx,pq
LOGICAL qhi,qleft,qporq
C ..
C .. External Functions ..
DOUBLE PRECISION spmpar
EXTERNAL spmpar
C ..
C .. External Subroutines ..
EXTERNAL cumf,dinvr,dstinv
C ..
C .. Intrinsic Functions ..
INTRINSIC abs
C ..
IF (.NOT. ((which.LT.1).OR. (which.GT.4))) GO TO 30
IF (.NOT. (which.LT.1)) GO TO 10
bound = 1.0D0
GO TO 20
10 bound = 4.0D0
20 status = -1
RETURN
30 IF (which.EQ.1) GO TO 70
IF (.NOT. ((p.LT.0.0D0).OR. (p.GT.1.0D0))) GO TO 60
IF (.NOT. (p.LT.0.0D0)) GO TO 40
bound = 0.0D0
GO TO 50
40 bound = 1.0D0
50 status = -2
RETURN
60 CONTINUE
70 IF (which.EQ.1) GO TO 110
IF (.NOT. ((q.LE.0.0D0).OR. (q.GT.1.0D0))) GO TO 100
IF (.NOT. (q.LE.0.0D0)) GO TO 80
bound = 0.0D0
GO TO 90
80 bound = 1.0D0
90 status = -3
RETURN
100 CONTINUE
110 IF (which.EQ.2) GO TO 130
IF (.NOT. (f.LT.0.0D0)) GO TO 120
bound = 0.0D0
status = -4
RETURN
120 CONTINUE
130 IF (which.EQ.3) GO TO 150
IF (.NOT. (dfn.LE.0.0D0)) GO TO 140
bound = 0.0D0
status = -5
RETURN
140 CONTINUE
150 IF (which.EQ.4) GO TO 170
IF (.NOT. (dfd.LE.0.0D0)) GO TO 160
bound = 0.0D0
status = -6
RETURN
160 CONTINUE
170 IF (which.EQ.1) GO TO 210
pq = p + q
IF (.NOT. (abs(((pq)-0.5D0)-0.5D0).GT.
+ (3.0D0*spmpar(1)))) GO TO 200
IF (.NOT. (pq.LT.0.0D0)) GO TO 180
bound = 0.0D0
GO TO 190
180 bound = 1.0D0
190 status = 3
RETURN
200 CONTINUE
210 IF (.NOT. (which.EQ.1)) qporq = p .LE. q
IF ((1).EQ. (which)) THEN
CALL cumf(f,dfn,dfd,p,q)
status = 0
ELSE IF ((2).EQ. (which)) THEN
f = 5.0D0
CALL dstinv(0.0D0,inf,0.5D0,0.5D0,5.0D0,atol,tol)
status = 0
CALL dinvr(status,f,fx,qleft,qhi)
220 IF (.NOT. (status.EQ.1)) GO TO 250
CALL cumf(f,dfn,dfd,cum,ccum)
IF (.NOT. (qporq)) GO TO 230
fx = cum - p
GO TO 240
230 fx = ccum - q
240 CALL dinvr(status,f,fx,qleft,qhi)
GO TO 220
250 IF (.NOT. (status.EQ.-1)) GO TO 280
IF (.NOT. (qleft)) GO TO 260
status = 1
bound = 0.0D0
GO TO 270
260 status = 2
bound = inf
270 CONTINUE
280 CONTINUE
ELSE IF ((3).EQ. (which)) THEN
dfn = 5.0D0
CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol)
status = 0
CALL dinvr(status,dfn,fx,qleft,qhi)
290 IF (.NOT. (status.EQ.1)) GO TO 320
CALL cumf(f,dfn,dfd,cum,ccum)
IF (.NOT. (qporq)) GO TO 300
fx = cum - p
GO TO 310
300 fx = ccum - q
310 CALL dinvr(status,dfn,fx,qleft,qhi)
GO TO 290
320 IF (.NOT. (status.EQ.-1)) GO TO 350
IF (.NOT. (qleft)) GO TO 330
status = 1
bound = zero
GO TO 340
330 status = 2
bound = inf
340 CONTINUE
350 CONTINUE
ELSE IF ((4).EQ. (which)) THEN
dfd = 5.0D0
CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol)
status = 0
CALL dinvr(status,dfd,fx,qleft,qhi)
360 IF (.NOT. (status.EQ.1)) GO TO 390
CALL cumf(f,dfn,dfd,cum,ccum)
IF (.NOT. (qporq)) GO TO 370
fx = cum - p
GO TO 380
370 fx = ccum - q
380 CALL dinvr(status,dfd,fx,qleft,qhi)
GO TO 360
390 IF (.NOT. (status.EQ.-1)) GO TO 420
IF (.NOT. (qleft)) GO TO 400
status = 1
bound = zero
GO TO 410
400 status = 2
bound = inf
410 CONTINUE
420 END IF
RETURN
END
| bsd-3-clause |
foss-for-synopsys-dwc-arc-processors/gcc | libgomp/testsuite/libgomp.fortran/target4.f90 | 12 | 1655 | ! { dg-do run }
module target4
contains
subroutine foo (a,m,n)
integer :: m,n,i,j
double precision :: a(m, n), t
!$omp target data map(a) map(to: m, n)
do i=1,n
t = 0.0d0
!$omp target map(t)
!$omp parallel do reduction(+:t)
do j=1,m
t = t + a(j,i) * a(j,i)
end do
!$omp end target
t = 2.0d0 * t
!$omp target
!$omp parallel do
do j=1,m
a(j,i) = a(j,i) * t
end do
!$omp end target
end do
!$omp end target data
end subroutine foo
end module target4
use target4, only : foo
integer :: i, j
double precision :: a(8, 9), res(8, 9)
do i = 1, 8
do j = 1, 9
a(i, j) = i + j
end do
end do
call foo (a, 8, 9)
res = reshape ((/ 1136.0d0, 1704.0d0, 2272.0d0, 2840.0d0, 3408.0d0, 3976.0d0, &
& 4544.0d0, 5112.0d0, 2280.0d0, 3040.0d0, 3800.0d0, 4560.0d0, 5320.0d0, 6080.0d0, &
& 6840.0d0, 7600.0d0, 3936.0d0, 4920.0d0, 5904.0d0, 6888.0d0, 7872.0d0, 8856.0d0, &
& 9840.0d0, 10824.0d0, 6200.0d0, 7440.0d0, 8680.0d0, 9920.0d0, 11160.0d0, 12400.0d0, &
& 13640.0d0, 14880.0d0, 9168.0d0, 10696.0d0, 12224.0d0, 13752.0d0, 15280.0d0, 16808.0d0, &
& 18336.0d0, 19864.0d0, 12936.0d0, 14784.0d0, 16632.0d0, 18480.0d0, 20328.0d0, 22176.0d0, &
& 24024.0d0, 25872.0d0, 17600.0d0, 19800.0d0, 22000.0d0, 24200.0d0, 26400.0d0, 28600.0d0, &
& 30800.0d0, 33000.0d0, 23256.0d0, 25840.0d0, 28424.0d0, 31008.0d0, 33592.0d0, 36176.0d0, &
& 38760.0d0, 41344.0d0, 30000.0d0, 33000.0d0, 36000.0d0, 39000.0d0, 42000.0d0, 45000.0d0, &
& 48000.0d0, 51000.0d0 /), (/ 8, 9 /))
if (any (a /= res)) stop 1
end
| gpl-2.0 |
Pakketeretet2/lammps | lib/linalg/dlaset.f | 23 | 4924 | *> \brief \b DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DLASET + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaset.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaset.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaset.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DLASET( UPLO, M, N, ALPHA, BETA, A, LDA )
*
* .. Scalar Arguments ..
* CHARACTER UPLO
* INTEGER LDA, M, N
* DOUBLE PRECISION ALPHA, BETA
* ..
* .. Array Arguments ..
* DOUBLE PRECISION A( LDA, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DLASET initializes an m-by-n matrix A to BETA on the diagonal and
*> ALPHA on the offdiagonals.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] UPLO
*> \verbatim
*> UPLO is CHARACTER*1
*> Specifies the part of the matrix A to be set.
*> = 'U': Upper triangular part is set; the strictly lower
*> triangular part of A is not changed.
*> = 'L': Lower triangular part is set; the strictly upper
*> triangular part of A is not changed.
*> Otherwise: All of the matrix A is set.
*> \endverbatim
*>
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix A. M >= 0.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in] ALPHA
*> \verbatim
*> ALPHA is DOUBLE PRECISION
*> The constant to which the offdiagonal elements are to be set.
*> \endverbatim
*>
*> \param[in] BETA
*> \verbatim
*> BETA is DOUBLE PRECISION
*> The constant to which the diagonal elements are to be set.
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (LDA,N)
*> On exit, the leading m-by-n submatrix of A is set as follows:
*>
*> if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
*> if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
*> otherwise, A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
*>
*> and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,M).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date December 2016
*
*> \ingroup OTHERauxiliary
*
* =====================================================================
SUBROUTINE DLASET( UPLO, M, N, ALPHA, BETA, A, LDA )
*
* -- LAPACK auxiliary routine (version 3.7.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* December 2016
*
* .. Scalar Arguments ..
CHARACTER UPLO
INTEGER LDA, M, N
DOUBLE PRECISION ALPHA, BETA
* ..
* .. Array Arguments ..
DOUBLE PRECISION A( LDA, * )
* ..
*
* =====================================================================
*
* .. Local Scalars ..
INTEGER I, J
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. Intrinsic Functions ..
INTRINSIC MIN
* ..
* .. Executable Statements ..
*
IF( LSAME( UPLO, 'U' ) ) THEN
*
* Set the strictly upper triangular or trapezoidal part of the
* array to ALPHA.
*
DO 20 J = 2, N
DO 10 I = 1, MIN( J-1, M )
A( I, J ) = ALPHA
10 CONTINUE
20 CONTINUE
*
ELSE IF( LSAME( UPLO, 'L' ) ) THEN
*
* Set the strictly lower triangular or trapezoidal part of the
* array to ALPHA.
*
DO 40 J = 1, MIN( M, N )
DO 30 I = J + 1, M
A( I, J ) = ALPHA
30 CONTINUE
40 CONTINUE
*
ELSE
*
* Set the leading m-by-n submatrix to ALPHA.
*
DO 60 J = 1, N
DO 50 I = 1, M
A( I, J ) = ALPHA
50 CONTINUE
60 CONTINUE
END IF
*
* Set the first min(M,N) diagonal elements to BETA.
*
DO 70 I = 1, MIN( M, N )
A( I, I ) = BETA
70 CONTINUE
*
RETURN
*
* End of DLASET
*
END
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/cshift_1.f90 | 19 | 2644 | ! { dg-do run }
! Take cshift through its paces to make sure no boundary
! cases are wrong.
module kinds
integer, parameter :: sp = selected_real_kind(6) ! Single precision
end module kinds
module replacements
use kinds
contains
subroutine cshift_sp_3_v1 (array, shift, dim, res)
integer, parameter :: wp = sp
real(kind=wp), dimension(:,:,:), intent(in) :: array
integer, intent(in) :: shift, dim
real(kind=wp), dimension(:,:,:), intent(out) :: res
integer :: i,j,k
integer :: sh, rsh
integer :: n
integer :: n2, n3
res = 0
n3 = size(array,3)
n2 = size(array,2)
n1 = size(array,1)
if (dim == 1) then
n = n1
sh = modulo(shift, n)
rsh = n - sh
do k=1, n3
do j=1, n2
do i=1, rsh
res(i,j,k) = array(i+sh,j,k)
end do
do i=rsh+1,n
res(i,j,k) = array(i-rsh,j,k)
end do
end do
end do
else if (dim == 2) then
n = n2
sh = modulo(shift,n)
rsh = n - sh
do k=1, n3
do j=1, rsh
do i=1, n1
res(i,j,k) = array(i,j+sh, k)
end do
end do
do j=rsh+1, n
do i=1, n1
res(i,j,k) = array(i,j-rsh, k)
end do
end do
end do
else if (dim == 3) then
n = n3
sh = modulo(shift, n)
rsh = n - sh
do k=1, rsh
do j=1, n2
do i=1, n1
res(i,j,k) = array(i, j, k+sh)
end do
end do
end do
do k=rsh+1, n
do j=1, n2
do i=1, n1
res(i,j, k) = array(i, j, k-rsh)
end do
end do
end do
else
stop "Wrong argument to dim"
end if
end subroutine cshift_sp_3_v1
end module replacements
program testme
use kinds
use replacements
implicit none
integer, parameter :: wp = sp ! Working precision
INTEGER, PARAMETER :: n = 7
real(kind=wp), dimension(:,:,:), allocatable :: a,b,c
integer i, j, k
real:: t1, t2
integer, parameter :: nrep = 20
allocate (a(n,n,n), b(n,n,n),c(n,n,n))
call random_number(a)
do k = 1,3
do i=-3,3,2
call cshift_sp_3_v1 (a, i, k, b)
c = cshift(a,i,k)
if (any (c /= b)) STOP 1
end do
end do
deallocate (b,c)
allocate (b(n-1,n-1,n-1),c(n-1,n-1,n-1))
do k=1,3
do i=-3,3,2
call cshift_sp_3_v1 (a(1:n-1,1:n-1,1:n-1), i, k, b)
c = cshift(a(1:n-1,1:n-1,1:n-1), i, k)
if (any (c /= b)) STOP 2
end do
end do
end program testme
| gpl-2.0 |
sonnyhu/scipy | scipy/sparse/linalg/eigen/arpack/ARPACK/UTIL/cvout.f | 162 | 8205 | c-----------------------------------------------------------------------
c
c\SCCS Information: @(#)
c FILE: cvout.f SID: 2.1 DATE OF SID: 11/16/95 RELEASE: 2
c
*-----------------------------------------------------------------------
* Routine: CVOUT
*
* Purpose: Complex vector output routine.
*
* Usage: CALL CVOUT (LOUT, N, CX, IDIGIT, IFMT)
*
* Arguments
* N - Length of array CX. (Input)
* CX - Complex array to be printed. (Input)
* IFMT - Format to be used in printing array CX. (Input)
* IDIGIT - Print up to IABS(IDIGIT) decimal digits per number. (In)
* If IDIGIT .LT. 0, printing is done with 72 columns.
* If IDIGIT .GT. 0, printing is done with 132 columns.
*
*-----------------------------------------------------------------------
*
SUBROUTINE CVOUT( LOUT, N, CX, IDIGIT, IFMT )
* ...
* ... SPECIFICATIONS FOR ARGUMENTS
INTEGER N, IDIGIT, LOUT
Complex
& CX( * )
CHARACTER IFMT*( * )
* ...
* ... SPECIFICATIONS FOR LOCAL VARIABLES
INTEGER I, NDIGIT, K1, K2, LLL
CHARACTER*80 LINE
* ...
* ... FIRST EXECUTABLE STATEMENT
*
*
LLL = MIN( LEN( IFMT ), 80 )
DO 10 I = 1, LLL
LINE( I: I ) = '-'
10 CONTINUE
*
DO 20 I = LLL + 1, 80
LINE( I: I ) = ' '
20 CONTINUE
*
WRITE( LOUT, 9999 )IFMT, LINE( 1: LLL )
9999 FORMAT( / 1X, A / 1X, A )
*
IF( N.LE.0 )
$ RETURN
NDIGIT = IDIGIT
IF( IDIGIT.EQ.0 )
$ NDIGIT = 4
*
*=======================================================================
* CODE FOR OUTPUT USING 72 COLUMNS FORMAT
*=======================================================================
*
IF( IDIGIT.LT.0 ) THEN
NDIGIT = -IDIGIT
IF( NDIGIT.LE.4 ) THEN
DO 30 K1 = 1, N, 2
K2 = MIN0( N, K1+1 )
IF (K1.NE.N) THEN
WRITE( LOUT, 9998 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE
WRITE( LOUT, 9997 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
30 CONTINUE
ELSE IF( NDIGIT.LE.6 ) THEN
DO 40 K1 = 1, N, 2
K2 = MIN0( N, K1+1 )
IF (K1.NE.N) THEN
WRITE( LOUT, 9988 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE
WRITE( LOUT, 9987 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
40 CONTINUE
ELSE IF( NDIGIT.LE.8 ) THEN
DO 50 K1 = 1, N, 2
K2 = MIN0( N, K1+1 )
IF (K1.NE.N) THEN
WRITE( LOUT, 9978 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE
WRITE( LOUT, 9977 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
50 CONTINUE
ELSE
DO 60 K1 = 1, N
WRITE( LOUT, 9968 )K1, K1, CX( I )
60 CONTINUE
END IF
*
*=======================================================================
* CODE FOR OUTPUT USING 132 COLUMNS FORMAT
*=======================================================================
*
ELSE
IF( NDIGIT.LE.4 ) THEN
DO 70 K1 = 1, N, 4
K2 = MIN0( N, K1+3 )
IF ((K1+3).LE.N) THEN
WRITE( LOUT, 9958 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+3-N) .EQ. 1) THEN
WRITE( LOUT, 9957 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+3-N) .EQ. 2) THEN
WRITE( LOUT, 9956 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+3-N) .EQ. 1) THEN
WRITE( LOUT, 9955 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
70 CONTINUE
ELSE IF( NDIGIT.LE.6 ) THEN
DO 80 K1 = 1, N, 3
K2 = MIN0( N, K1+2 )
IF ((K1+2).LE.N) THEN
WRITE( LOUT, 9948 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+2-N) .EQ. 1) THEN
WRITE( LOUT, 9947 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+2-N) .EQ. 2) THEN
WRITE( LOUT, 9946 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
80 CONTINUE
ELSE IF( NDIGIT.LE.8 ) THEN
DO 90 K1 = 1, N, 3
K2 = MIN0( N, K1+2 )
IF ((K1+2).LE.N) THEN
WRITE( LOUT, 9938 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+2-N) .EQ. 1) THEN
WRITE( LOUT, 9937 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+2-N) .EQ. 2) THEN
WRITE( LOUT, 9936 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
90 CONTINUE
ELSE
DO 100 K1 = 1, N, 2
K2 = MIN0( N, K1+1 )
IF ((K1+2).LE.N) THEN
WRITE( LOUT, 9928 )K1, K2, ( CX( I ),
$ I = K1, K2 )
ELSE IF ((K1+2-N) .EQ. 1) THEN
WRITE( LOUT, 9927 )K1, K2, ( CX( I ),
$ I = K1, K2 )
END IF
100 CONTINUE
END IF
END IF
WRITE( LOUT, 9994 )
RETURN
*
*=======================================================================
* FORMAT FOR 72 COLUMNS
*=======================================================================
*
* DISPLAY 4 SIGNIFICANT DIGITS
*
9998 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E10.3,',',E10.3,') ') )
9997 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E10.3,',',E10.3,') ') )
*
* DISPLAY 6 SIGNIFICANT DIGITS
*
9988 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E12.5,',',E12.5,') ') )
9987 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E12.5,',',E12.5,') ') )
*
* DISPLAY 8 SIGNIFICANT DIGITS
*
9978 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E14.7,',',E14.7,') ') )
9977 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E14.7,',',E14.7,') ') )
*
* DISPLAY 13 SIGNIFICANT DIGITS
*
9968 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E20.13,',',E20.13,') ') )
*
*=========================================================================
* FORMAT FOR 132 COLUMNS
*=========================================================================
*
* DISPLAY 4 SIGNIFICANT DIGITS
*
9958 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,4('(',E10.3,',',E10.3,') ') )
9957 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,3('(',E10.3,',',E10.3,') ') )
9956 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E10.3,',',E10.3,') ') )
9955 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E10.3,',',E10.3,') ') )
*
* DISPLAY 6 SIGNIFICANT DIGITS
*
9948 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,3('(',E12.5,',',E12.5,') ') )
9947 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E12.5,',',E12.5,') ') )
9946 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E12.5,',',E12.5,') ') )
*
* DISPLAY 8 SIGNIFICANT DIGITS
*
9938 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,3('(',E14.7,',',E14.7,') ') )
9937 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E14.7,',',E14.7,') ') )
9936 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E14.7,',',E14.7,') ') )
*
* DISPLAY 13 SIGNIFICANT DIGITS
*
9928 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,2('(',E20.13,',',E20.13,') ') )
9927 FORMAT( 1X, I4, ' - ', I4, ':', 1X,
$ 1P,1('(',E20.13,',',E20.13,') ') )
*
*
*
9994 FORMAT( 1X, ' ' )
END
| bsd-3-clause |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/derived_init_2.f90 | 2 | 1198 | ! { dg-do run }
! PR 25217: INTENT(OUT) dummies of derived type with default initializers shall
! be (re)initialized upon procedure entry, unless they are ALLOCATABLE.
! Modified to take account of the regression, identified by Martin Tees
! http://gcc.gnu.org/ml/fortran/2006-08/msg00276.html and fixed with
! PR 28788.
module dt
type :: drv
integer :: a(3) = [ 1, 2, 3 ]
character(3) :: s = "abc"
real, pointer :: p => null()
end type drv
end module dt
module subs
contains
subroutine foo(fb)
use dt
type(drv), intent(out) :: fb
call sub (fb)
end subroutine foo
subroutine sub(fa)
use dt
type(drv), intent(out) :: fa
if (any(fa%a /= [ 1, 2, 3 ])) call abort()
if (fa%s /= "abc") call abort()
if (associated(fa%p)) call abort()
end subroutine sub
end module subs
program main
use dt
use subs
implicit none
type(drv) :: aa
type(drv), allocatable :: ab(:)
real, target :: x = 99, y = 999
aa = drv ([ 4, 5, 6], "def", x)
call sub(aa)
aa = drv ([ 7, 8, 9], "ghi", y)
call foo(aa)
end program main
! { dg-final { cleanup-modules "dt subs" } }
| gpl-2.0 |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.dg/allocate_with_source_5.f90 | 48 | 4073 | ! { dg-do run }
!
! Contributed by Juergen Reuter
! Check that pr65548 is fixed.
!
module selectors
type :: selector_t
integer, dimension(:), allocatable :: map
real, dimension(:), allocatable :: weight
contains
procedure :: init => selector_init
end type selector_t
contains
subroutine selector_init (selector, weight)
class(selector_t), intent(out) :: selector
real, dimension(:), intent(in) :: weight
real :: s
integer :: n, i
logical, dimension(:), allocatable :: mask
s = sum (weight)
allocate (mask (size (weight)), source = weight /= 0)
n = count (mask)
if (n > 0) then
allocate (selector%map (n), &
source = pack ([(i, i = 1, size (weight))], mask))
allocate (selector%weight (n), &
source = pack (weight / s, mask))
else
allocate (selector%map (1), source = 1)
allocate (selector%weight (1), source = 0.)
end if
end subroutine selector_init
end module selectors
module phs_base
type :: flavor_t
contains
procedure :: get_mass => flavor_get_mass
end type flavor_t
type :: phs_config_t
integer :: n_in = 0
type(flavor_t), dimension(:,:), allocatable :: flv
end type phs_config_t
type :: phs_t
class(phs_config_t), pointer :: config => null ()
real, dimension(:), allocatable :: m_in
end type phs_t
contains
elemental function flavor_get_mass (flv) result (mass)
real :: mass
class(flavor_t), intent(in) :: flv
mass = 42.0
end function flavor_get_mass
subroutine phs_base_init (phs, phs_config)
class(phs_t), intent(out) :: phs
class(phs_config_t), intent(in), target :: phs_config
phs%config => phs_config
allocate (phs%m_in (phs%config%n_in), &
source = phs_config%flv(:phs_config%n_in, 1)%get_mass ())
end subroutine phs_base_init
end module phs_base
module foo
type :: t
integer :: n
real, dimension(:,:), allocatable :: val
contains
procedure :: make => t_make
generic :: get_int => get_int_array, get_int_element
procedure :: get_int_array => t_get_int_array
procedure :: get_int_element => t_get_int_element
end type t
contains
subroutine t_make (this)
class(t), intent(inout) :: this
real, dimension(:), allocatable :: int
allocate (int (0:this%n-1), source=this%get_int())
end subroutine t_make
pure function t_get_int_array (this) result (array)
class(t), intent(in) :: this
real, dimension(this%n) :: array
array = this%val (0:this%n-1, 4)
end function t_get_int_array
pure function t_get_int_element (this, set) result (element)
class(t), intent(in) :: this
integer, intent(in) :: set
real :: element
element = this%val (set, 4)
end function t_get_int_element
end module foo
module foo2
type :: t2
integer :: n
character(32), dimension(:), allocatable :: md5
contains
procedure :: init => t2_init
end type t2
contains
subroutine t2_init (this)
class(t2), intent(inout) :: this
character(32), dimension(:), allocatable :: md5
allocate (md5 (this%n), source=this%md5)
if (md5(1) /= "tst ") call abort()
if (md5(2) /= " ") call abort()
if (md5(3) /= "fooblabar ") call abort()
end subroutine t2_init
end module foo2
program test
use selectors
use phs_base
use foo
use foo2
type(selector_t) :: sel
type(phs_t) :: phs
type(phs_config_t) :: phs_config
type(t) :: o
type(t2) :: o2
call sel%init([2., 0., 3., 0., 4.])
if (any(sel%map /= [1, 3, 5])) call abort()
if (any(abs(sel%weight - [2., 3., 4.] / 9.) > 1E-6)) call abort()
phs_config%n_in = 2
allocate (phs_config%flv (phs_config%n_in, 1))
call phs_base_init (phs, phs_config)
if (any(abs(phs%m_in - [42.0, 42.0]) > 1E-6)) call abort()
o%n = 2
allocate (o%val(0:1,4))
call o%make()
o2%n = 3
allocate(o2%md5(o2%n))
o2%md5(1) = "tst"
o2%md5(2) = ""
o2%md5(3) = "fooblabar"
call o2%init()
end program test
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/char_result_8.f90 | 188 | 1068 | ! Related to PR 15326. Compare functions that return string pointers with
! functions that return strings.
! { dg-do run }
program main
implicit none
character (len = 30), target :: string
call test (f1 (), 30)
call test (f2 (50), 50)
call test (f3 (), 30)
call test (f4 (70), 70)
call indirect (100)
contains
function f1 ()
character (len = 30) :: f1
f1 = ''
end function f1
function f2 (i)
integer :: i
character (len = i) :: f2
f2 = ''
end function f2
function f3 ()
character (len = 30), pointer :: f3
f3 => string
end function f3
function f4 (i)
integer :: i
character (len = i), pointer :: f4
f4 => string
end function f4
subroutine indirect (i)
integer :: i
call test (f1 (), 30)
call test (f2 (i), i)
call test (f3 (), 30)
call test (f4 (i), i)
end subroutine indirect
subroutine test (string, length)
character (len = *) :: string
integer, intent (in) :: length
if (len (string) .ne. length) call abort
end subroutine test
end program main
| gpl-2.0 |
sonnyhu/scipy | scipy/special/cdflib/exparg.f | 151 | 1233 | DOUBLE PRECISION FUNCTION exparg(l)
C--------------------------------------------------------------------
C IF L = 0 THEN EXPARG(L) = THE LARGEST POSITIVE W FOR WHICH
C EXP(W) CAN BE COMPUTED.
C
C IF L IS NONZERO THEN EXPARG(L) = THE LARGEST NEGATIVE W FOR
C WHICH THE COMPUTED VALUE OF EXP(W) IS NONZERO.
C
C NOTE... ONLY AN APPROXIMATE VALUE FOR EXPARG(L) IS NEEDED.
C--------------------------------------------------------------------
C .. Scalar Arguments ..
INTEGER l
C ..
C .. Local Scalars ..
DOUBLE PRECISION lnb
INTEGER b,m
C ..
C .. External Functions ..
INTEGER ipmpar
EXTERNAL ipmpar
C ..
C .. Intrinsic Functions ..
INTRINSIC dble,dlog
C ..
C .. Executable Statements ..
C
b = ipmpar(4)
IF (b.NE.2) GO TO 10
lnb = .69314718055995D0
GO TO 40
10 IF (b.NE.8) GO TO 20
lnb = 2.0794415416798D0
GO TO 40
20 IF (b.NE.16) GO TO 30
lnb = 2.7725887222398D0
GO TO 40
30 lnb = dlog(dble(b))
C
40 IF (l.EQ.0) GO TO 50
m = ipmpar(9) - 1
exparg = 0.99999D0* (m*lnb)
RETURN
50 m = ipmpar(10)
exparg = 0.99999D0* (m*lnb)
RETURN
END
| bsd-3-clause |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.dg/bit_comparison_1.F90 | 162 | 3927 | ! Test the BGE, BGT, BLE and BLT intrinsics.
!
! { dg-do run }
! { dg-options "-ffree-line-length-none" }
interface run_bge
procedure run_bge1
procedure run_bge2
procedure run_bge4
procedure run_bge8
end interface
interface run_bgt
procedure run_bgt1
procedure run_bgt2
procedure run_bgt4
procedure run_bgt8
end interface
interface run_ble
procedure run_ble1
procedure run_ble2
procedure run_ble4
procedure run_ble8
end interface
interface run_blt
procedure run_blt1
procedure run_blt2
procedure run_blt4
procedure run_blt8
end interface
#define CHECK(I,J,RES) \
if (bge(I,J) .neqv. RES) call abort ; \
if (run_bge(I,J) .neqv. RES) call abort ; \
if (bgt(I,J) .neqv. (RES .and. (I/=J))) call abort ; \
if (run_bgt(I,J) .neqv. (RES .and. (I/=J))) call abort ; \
if (ble(J,I) .neqv. RES) call abort ; \
if (run_ble(J,I) .neqv. RES) call abort ; \
if (blt(J,I) .neqv. (RES .and. (I/=J))) call abort ; \
if (run_blt(J,I) .neqv. (RES .and. (I/=J))) call abort
#define T .true.
#define F .false.
CHECK(0_1, 0_1, T)
CHECK(1_1, 0_1, T)
CHECK(0_1, 107_1, F)
CHECK(5_1, huge(0_1) / 2_1, F)
CHECK(5_1, huge(0_1), F)
CHECK(-1_1, 0_1, T)
CHECK(0_1, -19_1, F)
CHECK(huge(0_1), -19_1, F)
CHECK(0_2, 0_2, T)
CHECK(1_2, 0_2, T)
CHECK(0_2, 107_2, F)
CHECK(5_2, huge(0_2) / 2_2, F)
CHECK(5_2, huge(0_2), F)
CHECK(-1_2, 0_2, T)
CHECK(0_2, -19_2, F)
CHECK(huge(0_2), -19_2, F)
CHECK(0_4, 0_4, T)
CHECK(1_4, 0_4, T)
CHECK(0_4, 107_4, F)
CHECK(5_4, huge(0_4) / 2_4, F)
CHECK(5_4, huge(0_4), F)
CHECK(-1_4, 0_4, T)
CHECK(0_4, -19_4, F)
CHECK(huge(0_4), -19_4, F)
CHECK(0_8, 0_8, T)
CHECK(1_8, 0_8, T)
CHECK(0_8, 107_8, F)
CHECK(5_8, huge(0_8) / 2_8, F)
CHECK(5_8, huge(0_8), F)
CHECK(-1_8, 0_8, T)
CHECK(0_8, -19_8, F)
CHECK(huge(0_8), -19_8, F)
contains
pure logical function run_bge1 (i, j) result(res)
integer(kind=1), intent(in) :: i, j
res = bge(i,j)
end function
pure logical function run_bgt1 (i, j) result(res)
integer(kind=1), intent(in) :: i, j
res = bgt(i,j)
end function
pure logical function run_ble1 (i, j) result(res)
integer(kind=1), intent(in) :: i, j
res = ble(i,j)
end function
pure logical function run_blt1 (i, j) result(res)
integer(kind=1), intent(in) :: i, j
res = blt(i,j)
end function
pure logical function run_bge2 (i, j) result(res)
integer(kind=2), intent(in) :: i, j
res = bge(i,j)
end function
pure logical function run_bgt2 (i, j) result(res)
integer(kind=2), intent(in) :: i, j
res = bgt(i,j)
end function
pure logical function run_ble2 (i, j) result(res)
integer(kind=2), intent(in) :: i, j
res = ble(i,j)
end function
pure logical function run_blt2 (i, j) result(res)
integer(kind=2), intent(in) :: i, j
res = blt(i,j)
end function
pure logical function run_bge4 (i, j) result(res)
integer(kind=4), intent(in) :: i, j
res = bge(i,j)
end function
pure logical function run_bgt4 (i, j) result(res)
integer(kind=4), intent(in) :: i, j
res = bgt(i,j)
end function
pure logical function run_ble4 (i, j) result(res)
integer(kind=4), intent(in) :: i, j
res = ble(i,j)
end function
pure logical function run_blt4 (i, j) result(res)
integer(kind=4), intent(in) :: i, j
res = blt(i,j)
end function
pure logical function run_bge8 (i, j) result(res)
integer(kind=8), intent(in) :: i, j
res = bge(i,j)
end function
pure logical function run_bgt8 (i, j) result(res)
integer(kind=8), intent(in) :: i, j
res = bgt(i,j)
end function
pure logical function run_ble8 (i, j) result(res)
integer(kind=8), intent(in) :: i, j
res = ble(i,j)
end function
pure logical function run_blt8 (i, j) result(res)
integer(kind=8), intent(in) :: i, j
res = blt(i,j)
end function
end
| gpl-2.0 |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.dg/char_result_2.f90 | 174 | 2912 | ! Like char_result_1.f90, but the string arguments are pointers.
! { dg-do run }
pure function double (string)
character (len = *), intent (in) :: string
character (len = len (string) * 2) :: double
double = string // string
end function double
function f1 (string)
character (len = *), pointer :: string
character (len = len (string)) :: f1
f1 = ''
end function f1
function f2 (string1, string2)
character (len = *), pointer :: string1
character (len = len (string1) - 20), pointer :: string2
character (len = len (string1) + len (string2) / 2) :: f2
f2 = ''
end function f2
program main
implicit none
interface
pure function double (string)
character (len = *), intent (in) :: string
character (len = len (string) * 2) :: double
end function double
function f1 (string)
character (len = *), pointer :: string
character (len = len (string)) :: f1
end function f1
function f2 (string1, string2)
character (len = *), pointer :: string1
character (len = len (string1) - 20), pointer :: string2
character (len = len (string1) + len (string2) / 2) :: f2
end function f2
end interface
integer :: a
character (len = 80) :: text
character (len = 70), target :: textt
character (len = 70), pointer :: textp
character (len = 50), pointer :: textp2
a = 42
textp => textt
textp2 => textt(1:50)
call test (f1 (textp), 70)
call test (f2 (textp, textp), 95)
call test (f3 (textp), 105)
call test (f4 (textp), 192)
call test (f5 (textp), 140)
call test (f6 (textp), 29)
call indirect (textp2)
contains
function f3 (string)
integer, parameter :: l1 = 30
character (len = *), pointer :: string
character (len = len (string) + l1 + 5) :: f3
f3 = ''
end function f3
function f4 (string)
character (len = len (text) - 10), pointer :: string
character (len = len (string) + len (text) + a) :: f4
f4 = ''
end function f4
function f5 (string)
character (len = *), pointer :: string
character (len = len (double (string))) :: f5
f5 = ''
end function f5
function f6 (string)
character (len = *), pointer :: string
character (len = len (string (a:))) :: f6
f6 = ''
end function f6
subroutine indirect (textp2)
character (len = 50), pointer :: textp2
call test (f1 (textp), 70)
call test (f2 (textp, textp), 95)
call test (f3 (textp), 105)
call test (f4 (textp), 192)
call test (f5 (textp), 140)
call test (f6 (textp), 29)
call test (f1 (textp2), 50)
call test (f2 (textp2, textp), 65)
call test (f3 (textp2), 85)
call test (f5 (textp2), 100)
call test (f6 (textp2), 9)
end subroutine indirect
subroutine test (string, length)
character (len = *) :: string
integer, intent (in) :: length
if (len (string) .ne. length) call abort
end subroutine test
end program main
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/leadz_trailz_1.f90 | 174 | 3255 | ! { dg-do run }
integer(kind=1) :: i1
integer(kind=2) :: i2
integer(kind=4) :: i4
integer(kind=8) :: i8
i1 = -1
i2 = -1
i4 = -1
i8 = -1
if (leadz(i1) /= 0) call abort
if (leadz(i2) /= 0) call abort
if (leadz(i4) /= 0) call abort
if (leadz(i8) /= 0) call abort
if (trailz(i1) /= 0) call abort
if (trailz(i2) /= 0) call abort
if (trailz(i4) /= 0) call abort
if (trailz(i8) /= 0) call abort
if (leadz(-1_1) /= 0) call abort
if (leadz(-1_2) /= 0) call abort
if (leadz(-1_4) /= 0) call abort
if (leadz(-1_8) /= 0) call abort
if (trailz(-1_1) /= 0) call abort
if (trailz(-1_2) /= 0) call abort
if (trailz(-1_4) /= 0) call abort
if (trailz(-1_8) /= 0) call abort
i1 = -64
i2 = -64
i4 = -64
i8 = -64
if (leadz(i1) /= 0) call abort
if (leadz(i2) /= 0) call abort
if (leadz(i4) /= 0) call abort
if (leadz(i8) /= 0) call abort
if (trailz(i1) /= 6) call abort
if (trailz(i2) /= 6) call abort
if (trailz(i4) /= 6) call abort
if (trailz(i8) /= 6) call abort
if (leadz(-64_1) /= 0) call abort
if (leadz(-64_2) /= 0) call abort
if (leadz(-64_4) /= 0) call abort
if (leadz(-64_8) /= 0) call abort
if (trailz(-64_1) /= 6) call abort
if (trailz(-64_2) /= 6) call abort
if (trailz(-64_4) /= 6) call abort
if (trailz(-64_8) /= 6) call abort
i1 = -108
i2 = -108
i4 = -108
i8 = -108
if (leadz(i1) /= 0) call abort
if (leadz(i2) /= 0) call abort
if (leadz(i4) /= 0) call abort
if (leadz(i8) /= 0) call abort
if (trailz(i1) /= 2) call abort
if (trailz(i2) /= 2) call abort
if (trailz(i4) /= 2) call abort
if (trailz(i8) /= 2) call abort
if (leadz(-108_1) /= 0) call abort
if (leadz(-108_2) /= 0) call abort
if (leadz(-108_4) /= 0) call abort
if (leadz(-108_8) /= 0) call abort
if (trailz(-108_1) /= 2) call abort
if (trailz(-108_2) /= 2) call abort
if (trailz(-108_4) /= 2) call abort
if (trailz(-108_8) /= 2) call abort
i1 = 1
i2 = 1
i4 = 1
i8 = 1
if (leadz(i1) /= bit_size(i1) - 1) call abort
if (leadz(i2) /= bit_size(i2) - 1) call abort
if (leadz(i4) /= bit_size(i4) - 1) call abort
if (leadz(i8) /= bit_size(i8) - 1) call abort
if (trailz(i1) /= 0) call abort
if (trailz(i2) /= 0) call abort
if (trailz(i4) /= 0) call abort
if (trailz(i8) /= 0) call abort
if (leadz(1_1) /= bit_size(1_1) - 1) call abort
if (leadz(1_2) /= bit_size(1_2) - 1) call abort
if (leadz(1_4) /= bit_size(1_4) - 1) call abort
if (leadz(1_8) /= bit_size(1_8) - 1) call abort
if (trailz(1_1) /= 0) call abort
if (trailz(1_2) /= 0) call abort
if (trailz(1_4) /= 0) call abort
if (trailz(1_8) /= 0) call abort
i1 = 64
i2 = 64
i4 = 64
i8 = 64
if (leadz(i1) /= 1) call abort
if (leadz(i2) /= 9) call abort
if (leadz(i4) /= 25) call abort
if (leadz(i8) /= 57) call abort
if (trailz(i1) /= 6) call abort
if (trailz(i2) /= 6) call abort
if (trailz(i4) /= 6) call abort
if (trailz(i8) /= 6) call abort
if (leadz(64_1) /= 1) call abort
if (leadz(64_2) /= 9) call abort
if (leadz(64_4) /= 25) call abort
if (leadz(64_8) /= 57) call abort
if (trailz(64_1) /= 6) call abort
if (trailz(64_2) /= 6) call abort
if (trailz(64_4) /= 6) call abort
if (trailz(64_8) /= 6) call abort
end
| gpl-2.0 |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.dg/goacc/subroutines.f90 | 9 | 1627 | ! Exercise how tree-nested.c handles gang, worker vector and seq.
! { dg-do compile }
program main
integer, parameter :: N = 100
integer :: nonlocal_arg
integer :: nonlocal_a(N)
integer :: nonlocal_i
integer :: nonlocal_j
nonlocal_a (:) = 5
nonlocal_arg = 5
call local ()
call nonlocal ()
contains
subroutine local ()
integer :: local_i
integer :: local_arg
integer :: local_a(N)
integer :: local_j
local_a (:) = 5
local_arg = 5
!$acc kernels loop gang(num:local_arg) worker(local_arg) vector(local_arg)
do local_i = 1, N
local_a(local_i) = 100
!$acc loop seq
do local_j = 1, N
enddo
enddo
!$acc end kernels loop
!$acc kernels loop gang(static:local_arg) worker(local_arg) &
!$acc vector(local_arg)
do local_i = 1, N
local_a(local_i) = 100
!$acc loop seq
do local_j = 1, N
enddo
enddo
!$acc end kernels loop
end subroutine local
subroutine nonlocal ()
nonlocal_a (:) = 5
nonlocal_arg = 5
!$acc kernels loop gang(num:nonlocal_arg) worker(nonlocal_arg) &
!$acc vector(nonlocal_arg)
do nonlocal_i = 1, N
nonlocal_a(nonlocal_i) = 100
!$acc loop seq
do nonlocal_j = 1, N
enddo
enddo
!$acc end kernels loop
!$acc kernels loop gang(static:nonlocal_arg) worker(nonlocal_arg) &
!$acc vector(nonlocal_arg)
do nonlocal_i = 1, N
nonlocal_a(nonlocal_i) = 100
!$acc loop seq
do nonlocal_j = 1, N
enddo
enddo
!$acc end kernels loop
end subroutine nonlocal
end program main
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/goacc/default-2.f | 7 | 2670 | ! OpenACC default clause: invalid syntax.
SUBROUTINE F1
IMPLICIT NONE
!$ACC KERNELS DEFAULT ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT ( ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT ( ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (, ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (, ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT () ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT () ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (,) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (,) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (FIRSTPRIVATE) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (FIRSTPRIVATE) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (PRIVATE) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (PRIVATE) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (SHARED) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (SHARED) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (NONE ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (NONE ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (NONE NONE) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (NONE NONE) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
!$ACC KERNELS DEFAULT (NONE, NONE) ! { dg-error "Failed to match clause" }
!$ACC END KERNELS ! { dg-error "Unexpected" }
!$ACC PARALLEL DEFAULT (NONE, NONE) ! { dg-error "Failed to match clause" }
!$ACC END PARALLEL ! { dg-error "Unexpected" }
END SUBROUTINE F1
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/actual_array_result_1.f90 | 19 | 1462 | ! { dg-do run }
! PR fortan/31692
! Passing array valued results to procedures
!
! Test case contributed by rakuen_himawari@yahoo.co.jp
module one
integer :: flag = 0
contains
function foo1 (n)
integer :: n
integer :: foo1(n)
if (flag == 0) then
call bar1 (n, foo1)
else
call bar2 (n, foo1)
end if
end function
function foo2 (n)
implicit none
integer :: n
integer,ALLOCATABLE :: foo2(:)
allocate (foo2(n))
if (flag == 0) then
call bar1 (n, foo2)
else
call bar2 (n, foo2)
end if
end function
function foo3 (n)
implicit none
integer :: n
integer,ALLOCATABLE :: foo3(:)
allocate (foo3(n))
foo3 = 0
call bar2(n, foo3(2:(n-1))) ! Check that sections are OK
end function
subroutine bar1 (n, array) ! Checks assumed size formal arg.
integer :: n
integer :: array(*)
integer :: i
do i = 1, n
array(i) = i
enddo
end subroutine
subroutine bar2(n, array) ! Checks assumed shape formal arg.
integer :: n
integer :: array(:)
integer :: i
do i = 1, size (array, 1)
array(i) = i
enddo
end subroutine
end module
program main
use one
integer :: n
n = 3
if(any (foo1(n) /= [ 1,2,3 ])) STOP 1
if(any (foo2(n) /= [ 1,2,3 ])) STOP 2
flag = 1
if(any (foo1(n) /= [ 1,2,3 ])) STOP 3
if(any (foo2(n) /= [ 1,2,3 ])) STOP 4
n = 5
if(any (foo3(n) /= [ 0,1,2,3,0 ])) STOP 5
end program
| gpl-2.0 |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.fortran-torture/execute/common.f90 | 191 | 1380 | ! Program to test COMMON and EQUIVALENCE.
program common
real (kind=8) a(8)
real (kind=8) b(5), c(5)
common /com1/b,c
equivalence (a(1), b(2))
b = 100
c = 200
call common_pass
call common_par (a, b,c)
call global_equiv
call local_equiv
end
! Use common block to pass values
subroutine common_pass
real (kind=8) a(8)
real (kind=8) b(5), c(5)
common /com1/b,c
equivalence (a(1), b(2))
if (any (a .ne. (/100,100,100,100,200,200,200,200/))) call abort
end subroutine
! Common variables as argument
subroutine common_par (a, b, c)
real (kind=8) a(8), b(5), c(5)
if (any (a .ne. (/100,100,100,100,200,200,200,200/))) call abort
if (any (b .ne. (/100,100,100,100,100/))) call abort
if (any (c .ne. (/200,200,200,200,200/))) call abort
end subroutine
! Global equivalence
subroutine global_equiv
real (kind=8) a(8), b(5), c(5), x(8), y(4), z(4)
common /com2/b, c, y, z
equivalence (a(1), b(2))
equivalence (x(4), y(1))
b = 100
c = 200
y = 300
z = 400
if (any (a .ne. (/100,100,100,100,200,200,200,200/))) call abort
if (any (x .ne. (/200,200,200,300,300,300,300,400/))) call abort
end
! Local equivalence
subroutine local_equiv
real (kind=8) a(8), b(10)
equivalence (a(1), b(3))
b(1:5) = 100
b(6:10) = 200
if (any (a .ne. (/100,100,100,200,200,200,200,200/))) call abort
end subroutine
| gpl-2.0 |
rofirrim/gcc-tiny | libgomp/testsuite/libgomp.fortran/pr66199-1.f90 | 60 | 1294 | ! PR middle-end/66199
! { dg-do run }
! { dg-options "-O2 -fopenmp" }
integer :: u(1024), v(1024), w(1024), a, b, c, d, e, a1, b1, a2, b2, d1, d2
a = 1
b = 1024
d = 75
!$omp parallel do simd default(none) firstprivate (a, b) shared(u, v, w)
do d = a, b
u(d) = v(d) + w(d)
end do
if (d .ne. 1025) call abort
c = 17
d = 75
!$omp parallel do simd default(none) firstprivate (a, b) shared(u, v, w) &
!$omp& linear(d) linear(c:5) lastprivate(e)
do d = a, b
u(d) = v(d) + w(d)
c = c + 5
e = c
end do
if (d .ne. 1025 .or. c .ne. (17 + 5 * 1024)) call abort
if (e .ne. (17 + 5 * 1024)) call abort
a1 = 0
a2 = 0
b1 = 31
b2 = 31
d1 = 7
d2 = 9
!$omp parallel do simd default(none) firstprivate (a1, b1, a2, b2) &
!$omp& shared(u, v, w) lastprivate(d1, d2) collapse(2)
do d1 = a1, b1
do d2 = a2, b2
u(d1 * 32 + d2 + 1) = v(d1 * 32 + d2 + 1) + w(d1 * 32 + d2 + 1)
end do
end do
if (d1 .ne. 32 .or. d2 .ne. 32) call abort
d1 = 7
d2 = 9
!$omp parallel do simd default(none) firstprivate (a1, b1, a2, b2) &
!$omp& shared(u, v, w) collapse(2)
do d1 = a1, b1
do d2 = a2, b2
u(d1 * 32 + d2 + 1) = v(d1 * 32 + d2 + 1) + w(d1 * 32 + d2 + 1)
end do
end do
if (d1 .ne. 32 .or. d2 .ne. 32) call abort
end
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/g77/980701-0.f | 191 | 1783 | c { dg-do run }
* g77 0.5.23 and previous had bugs involving too little space
* allocated for EQUIVALENCE and COMMON areas needing initial
* padding to meet alignment requirements of the system.
call subr
end
subroutine subr
implicit none
real r1(5), r2(5), r3(5)
real s1(2), s2(2), s3(2)
double precision d1, d2, d3
integer i1, i2, i3
equivalence (r1, s1(2))
equivalence (d1, r1(2))
equivalence (r2, s2(2))
equivalence (d2, r2(2))
equivalence (r3, s3(2))
equivalence (d3, r3(2))
s1(1) = 1.
r1(1) = 1.
d1 = 10.
r1(4) = 1.
r1(5) = 1.
i1 = 1
s2(1) = 2.
r2(1) = 2.
d2 = 20.
r2(4) = 2.
r2(5) = 2.
i2 = 2
s3(1) = 3.
r3(1) = 3.
d3 = 30.
r3(4) = 3.
r3(5) = 3.
i3 = 3
call x (s1, r1, d1, i1, s2, r2, d2, i2, s3, r3, d3, i3)
end
subroutine x (s1, r1, d1, i1, s2, r2, d2, i2, s3, r3, d3, i3)
implicit none
real r1(5), r2(5), r3(5)
real s1(2), s2(2), s3(2)
double precision d1, d2, d3
integer i1, i2, i3
if (s1(1) .ne. 1.) call abort
if (r1(1) .ne. 1.) call abort
if (d1 .ne. 10.) call abort
if (r1(4) .ne. 1.) call abort
if (r1(5) .ne. 1.) call abort
if (i1 .ne. 1) call abort
if (s2(1) .ne. 2.) call abort
if (r2(1) .ne. 2.) call abort
if (d2 .ne. 20.) call abort
if (r2(4) .ne. 2.) call abort
if (r2(5) .ne. 2.) call abort
if (i2 .ne. 2) call abort
if (s3(1) .ne. 3.) call abort
if (r3(1) .ne. 3.) call abort
if (d3 .ne. 30.) call abort
if (r3(4) .ne. 3.) call abort
if (r3(5) .ne. 3.) call abort
if (i3 .ne. 3) call abort
end
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/dshift_1.F90 | 19 | 4048 | ! Test the DSHIFTL and DSHIFTR intrinsics.
!
! { dg-do run }
! { dg-options "-ffree-line-length-none" }
implicit none
interface run_dshiftl
procedure dshiftl_1
procedure dshiftl_2
procedure dshiftl_4
procedure dshiftl_8
end interface
interface run_dshiftr
procedure dshiftr_1
procedure dshiftr_2
procedure dshiftr_4
procedure dshiftr_8
end interface
#define RESL(I,J,SHIFT) \
IOR(SHIFTL(I,SHIFT),SHIFTR(J,BIT_SIZE(J)-SHIFT))
#define RESR(I,J,SHIFT) \
IOR(SHIFTL(I,BIT_SIZE(I)-SHIFT),SHIFTR(J,SHIFT))
#define CHECK(I,J,SHIFT) \
if (dshiftl(I,J,SHIFT) /= RESL(I,J,SHIFT)) STOP 1; \
if (dshiftr(I,J,SHIFT) /= RESR(I,J,SHIFT)) STOP 2; \
if (run_dshiftl(I,J,SHIFT) /= RESL(I,J,SHIFT)) STOP 3; \
if (run_dshiftr(I,J,SHIFT) /= RESR(I,J,SHIFT)) STOP 4
CHECK(0_1,0_1,0)
CHECK(0_1,0_1,1)
CHECK(0_1,0_1,7)
CHECK(0_1,0_1,8)
CHECK(28_1,79_1,0)
CHECK(28_1,79_1,1)
CHECK(28_1,79_1,5)
CHECK(28_1,79_1,7)
CHECK(28_1,79_1,8)
CHECK(-28_1,79_1,0)
CHECK(-28_1,79_1,1)
CHECK(-28_1,79_1,5)
CHECK(-28_1,79_1,7)
CHECK(-28_1,79_1,8)
CHECK(28_1,-79_1,0)
CHECK(28_1,-79_1,1)
CHECK(28_1,-79_1,5)
CHECK(28_1,-79_1,7)
CHECK(28_1,-79_1,8)
CHECK(-28_1,-79_1,0)
CHECK(-28_1,-79_1,1)
CHECK(-28_1,-79_1,5)
CHECK(-28_1,-79_1,7)
CHECK(-28_1,-79_1,8)
CHECK(0_2,0_2,0)
CHECK(0_2,0_2,1)
CHECK(0_2,0_2,7)
CHECK(0_2,0_2,8)
CHECK(28_2,79_2,0)
CHECK(28_2,79_2,1)
CHECK(28_2,79_2,5)
CHECK(28_2,79_2,7)
CHECK(28_2,79_2,8)
CHECK(-28_2,79_2,0)
CHECK(-28_2,79_2,1)
CHECK(-28_2,79_2,5)
CHECK(-28_2,79_2,7)
CHECK(-28_2,79_2,8)
CHECK(28_2,-79_2,0)
CHECK(28_2,-79_2,1)
CHECK(28_2,-79_2,5)
CHECK(28_2,-79_2,7)
CHECK(28_2,-79_2,8)
CHECK(-28_2,-79_2,0)
CHECK(-28_2,-79_2,1)
CHECK(-28_2,-79_2,5)
CHECK(-28_2,-79_2,7)
CHECK(-28_2,-79_2,8)
CHECK(0_4,0_4,0)
CHECK(0_4,0_4,1)
CHECK(0_4,0_4,7)
CHECK(0_4,0_4,8)
CHECK(28_4,79_4,0)
CHECK(28_4,79_4,1)
CHECK(28_4,79_4,5)
CHECK(28_4,79_4,7)
CHECK(28_4,79_4,8)
CHECK(-28_4,79_4,0)
CHECK(-28_4,79_4,1)
CHECK(-28_4,79_4,5)
CHECK(-28_4,79_4,7)
CHECK(-28_4,79_4,8)
CHECK(28_4,-79_4,0)
CHECK(28_4,-79_4,1)
CHECK(28_4,-79_4,5)
CHECK(28_4,-79_4,7)
CHECK(28_4,-79_4,8)
CHECK(-28_4,-79_4,0)
CHECK(-28_4,-79_4,1)
CHECK(-28_4,-79_4,5)
CHECK(-28_4,-79_4,7)
CHECK(-28_4,-79_4,8)
CHECK(0_8,0_8,0)
CHECK(0_8,0_8,1)
CHECK(0_8,0_8,7)
CHECK(0_8,0_8,8)
CHECK(28_8,79_8,0)
CHECK(28_8,79_8,1)
CHECK(28_8,79_8,5)
CHECK(28_8,79_8,7)
CHECK(28_8,79_8,8)
CHECK(-28_8,79_8,0)
CHECK(-28_8,79_8,1)
CHECK(-28_8,79_8,5)
CHECK(-28_8,79_8,7)
CHECK(-28_8,79_8,8)
CHECK(28_8,-79_8,0)
CHECK(28_8,-79_8,1)
CHECK(28_8,-79_8,5)
CHECK(28_8,-79_8,7)
CHECK(28_8,-79_8,8)
CHECK(-28_8,-79_8,0)
CHECK(-28_8,-79_8,1)
CHECK(-28_8,-79_8,5)
CHECK(-28_8,-79_8,7)
CHECK(-28_8,-79_8,8)
contains
function dshiftl_1 (i, j, shift) result(res)
integer(kind=1) :: i, j, res
integer :: shift
res = dshiftl(i,j,shift)
end function
function dshiftl_2 (i, j, shift) result(res)
integer(kind=2) :: i, j, res
integer :: shift
res = dshiftl(i,j,shift)
end function
function dshiftl_4 (i, j, shift) result(res)
integer(kind=4) :: i, j, res
integer :: shift
res = dshiftl(i,j,shift)
end function
function dshiftl_8 (i, j, shift) result(res)
integer(kind=8) :: i, j, res
integer :: shift
res = dshiftl(i,j,shift)
end function
function dshiftr_1 (i, j, shift) result(res)
integer(kind=1) :: i, j, res
integer :: shift
res = dshiftr(i,j,shift)
end function
function dshiftr_2 (i, j, shift) result(res)
integer(kind=2) :: i, j, res
integer :: shift
res = dshiftr(i,j,shift)
end function
function dshiftr_4 (i, j, shift) result(res)
integer(kind=4) :: i, j, res
integer :: shift
res = dshiftr(i,j,shift)
end function
function dshiftr_8 (i, j, shift) result(res)
integer(kind=8) :: i, j, res
integer :: shift
res = dshiftr(i,j,shift)
end function
end
| gpl-2.0 |
wegrzyn/dpi-ecg | eigen/lapack/dlarft.f | 272 | 10222 | *> \brief \b DLARFT
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download DLARFT + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarft.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarft.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarft.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE DLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
*
* .. Scalar Arguments ..
* CHARACTER DIRECT, STOREV
* INTEGER K, LDT, LDV, N
* ..
* .. Array Arguments ..
* DOUBLE PRECISION T( LDT, * ), TAU( * ), V( LDV, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DLARFT forms the triangular factor T of a real block reflector H
*> of order n, which is defined as a product of k elementary reflectors.
*>
*> If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
*>
*> If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
*>
*> If STOREV = 'C', the vector which defines the elementary reflector
*> H(i) is stored in the i-th column of the array V, and
*>
*> H = I - V * T * V**T
*>
*> If STOREV = 'R', the vector which defines the elementary reflector
*> H(i) is stored in the i-th row of the array V, and
*>
*> H = I - V**T * T * V
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] DIRECT
*> \verbatim
*> DIRECT is CHARACTER*1
*> Specifies the order in which the elementary reflectors are
*> multiplied to form the block reflector:
*> = 'F': H = H(1) H(2) . . . H(k) (Forward)
*> = 'B': H = H(k) . . . H(2) H(1) (Backward)
*> \endverbatim
*>
*> \param[in] STOREV
*> \verbatim
*> STOREV is CHARACTER*1
*> Specifies how the vectors which define the elementary
*> reflectors are stored (see also Further Details):
*> = 'C': columnwise
*> = 'R': rowwise
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The order of the block reflector H. N >= 0.
*> \endverbatim
*>
*> \param[in] K
*> \verbatim
*> K is INTEGER
*> The order of the triangular factor T (= the number of
*> elementary reflectors). K >= 1.
*> \endverbatim
*>
*> \param[in] V
*> \verbatim
*> V is DOUBLE PRECISION array, dimension
*> (LDV,K) if STOREV = 'C'
*> (LDV,N) if STOREV = 'R'
*> The matrix V. See further details.
*> \endverbatim
*>
*> \param[in] LDV
*> \verbatim
*> LDV is INTEGER
*> The leading dimension of the array V.
*> If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
*> \endverbatim
*>
*> \param[in] TAU
*> \verbatim
*> TAU is DOUBLE PRECISION array, dimension (K)
*> TAU(i) must contain the scalar factor of the elementary
*> reflector H(i).
*> \endverbatim
*>
*> \param[out] T
*> \verbatim
*> T is DOUBLE PRECISION array, dimension (LDT,K)
*> The k by k triangular factor T of the block reflector.
*> If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
*> lower triangular. The rest of the array is not used.
*> \endverbatim
*>
*> \param[in] LDT
*> \verbatim
*> LDT is INTEGER
*> The leading dimension of the array T. LDT >= K.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date April 2012
*
*> \ingroup doubleOTHERauxiliary
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> The shape of the matrix V and the storage of the vectors which define
*> the H(i) is best illustrated by the following example with n = 5 and
*> k = 3. The elements equal to 1 are not stored.
*>
*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
*>
*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
*> ( v1 1 ) ( 1 v2 v2 v2 )
*> ( v1 v2 1 ) ( 1 v3 v3 )
*> ( v1 v2 v3 )
*> ( v1 v2 v3 )
*>
*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
*>
*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
*> ( v1 v2 v3 ) ( v2 v2 v2 1 )
*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
*> ( 1 v3 )
*> ( 1 )
*> \endverbatim
*>
* =====================================================================
SUBROUTINE DLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
*
* -- LAPACK auxiliary routine (version 3.4.1) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* April 2012
*
* .. Scalar Arguments ..
CHARACTER DIRECT, STOREV
INTEGER K, LDT, LDV, N
* ..
* .. Array Arguments ..
DOUBLE PRECISION T( LDT, * ), TAU( * ), V( LDV, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE, ZERO
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
* ..
* .. Local Scalars ..
INTEGER I, J, PREVLASTV, LASTV
* ..
* .. External Subroutines ..
EXTERNAL DGEMV, DTRMV
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. Executable Statements ..
*
* Quick return if possible
*
IF( N.EQ.0 )
$ RETURN
*
IF( LSAME( DIRECT, 'F' ) ) THEN
PREVLASTV = N
DO I = 1, K
PREVLASTV = MAX( I, PREVLASTV )
IF( TAU( I ).EQ.ZERO ) THEN
*
* H(i) = I
*
DO J = 1, I
T( J, I ) = ZERO
END DO
ELSE
*
* general case
*
IF( LSAME( STOREV, 'C' ) ) THEN
* Skip any trailing zeros.
DO LASTV = N, I+1, -1
IF( V( LASTV, I ).NE.ZERO ) EXIT
END DO
DO J = 1, I-1
T( J, I ) = -TAU( I ) * V( I , J )
END DO
J = MIN( LASTV, PREVLASTV )
*
* T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**T * V(i:j,i)
*
CALL DGEMV( 'Transpose', J-I, I-1, -TAU( I ),
$ V( I+1, 1 ), LDV, V( I+1, I ), 1, ONE,
$ T( 1, I ), 1 )
ELSE
* Skip any trailing zeros.
DO LASTV = N, I+1, -1
IF( V( I, LASTV ).NE.ZERO ) EXIT
END DO
DO J = 1, I-1
T( J, I ) = -TAU( I ) * V( J , I )
END DO
J = MIN( LASTV, PREVLASTV )
*
* T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**T
*
CALL DGEMV( 'No transpose', I-1, J-I, -TAU( I ),
$ V( 1, I+1 ), LDV, V( I, I+1 ), LDV, ONE,
$ T( 1, I ), 1 )
END IF
*
* T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
*
CALL DTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T,
$ LDT, T( 1, I ), 1 )
T( I, I ) = TAU( I )
IF( I.GT.1 ) THEN
PREVLASTV = MAX( PREVLASTV, LASTV )
ELSE
PREVLASTV = LASTV
END IF
END IF
END DO
ELSE
PREVLASTV = 1
DO I = K, 1, -1
IF( TAU( I ).EQ.ZERO ) THEN
*
* H(i) = I
*
DO J = I, K
T( J, I ) = ZERO
END DO
ELSE
*
* general case
*
IF( I.LT.K ) THEN
IF( LSAME( STOREV, 'C' ) ) THEN
* Skip any leading zeros.
DO LASTV = 1, I-1
IF( V( LASTV, I ).NE.ZERO ) EXIT
END DO
DO J = I+1, K
T( J, I ) = -TAU( I ) * V( N-K+I , J )
END DO
J = MAX( LASTV, PREVLASTV )
*
* T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**T * V(j:n-k+i,i)
*
CALL DGEMV( 'Transpose', N-K+I-J, K-I, -TAU( I ),
$ V( J, I+1 ), LDV, V( J, I ), 1, ONE,
$ T( I+1, I ), 1 )
ELSE
* Skip any leading zeros.
DO LASTV = 1, I-1
IF( V( I, LASTV ).NE.ZERO ) EXIT
END DO
DO J = I+1, K
T( J, I ) = -TAU( I ) * V( J, N-K+I )
END DO
J = MAX( LASTV, PREVLASTV )
*
* T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**T
*
CALL DGEMV( 'No transpose', K-I, N-K+I-J,
$ -TAU( I ), V( I+1, J ), LDV, V( I, J ), LDV,
$ ONE, T( I+1, I ), 1 )
END IF
*
* T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
*
CALL DTRMV( 'Lower', 'No transpose', 'Non-unit', K-I,
$ T( I+1, I+1 ), LDT, T( I+1, I ), 1 )
IF( I.GT.1 ) THEN
PREVLASTV = MIN( PREVLASTV, LASTV )
ELSE
PREVLASTV = LASTV
END IF
END IF
T( I, I ) = TAU( I )
END IF
END DO
END IF
RETURN
*
* End of DLARFT
*
END
| gpl-3.0 |
foss-for-synopsys-dwc-arc-processors/gcc | libgfortran/generated/_sin_r16.F90 | 4 | 1474 | ! Copyright (C) 2002-2021 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 3 of the License, or (at your option) any later version.
!GNU libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_16)
#ifdef HAVE_SINL
elemental function _gfortran_specific__sin_r16 (parm)
real (kind=16), intent (in) :: parm
real (kind=16) :: _gfortran_specific__sin_r16
_gfortran_specific__sin_r16 = sin (parm)
end function
#endif
#endif
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | libgfortran/generated/_acos_r4.F90 | 4 | 1473 | ! Copyright (C) 2002-2021 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 3 of the License, or (at your option) any later version.
!GNU libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_4)
#ifdef HAVE_ACOSF
elemental function _gfortran_specific__acos_r4 (parm)
real (kind=4), intent (in) :: parm
real (kind=4) :: _gfortran_specific__acos_r4
_gfortran_specific__acos_r4 = acos (parm)
end function
#endif
#endif
| gpl-2.0 |
rofirrim/gcc-tiny | gcc/testsuite/gfortran.dg/vect/fast-math-vect-8.f90 | 56 | 2073 | ! { dg-do compile }
! { dg-require-effective-target vect_float }
! { dg-require-visibility "" }
module solv_cap
implicit none
public :: init_solve
integer, parameter, public :: dp = 4
real(kind=dp), private :: Pi, Mu0, c0, eps0
logical, private :: UseFFT, UsePreco
real(kind=dp), private :: D1, D2
integer, private, save :: Ng1=0, Ng2=0
integer, private, pointer, dimension(:,:) :: Grid
real(kind=dp), private, allocatable, dimension(:,:) :: G
contains
subroutine init_solve(Grid_in, GrSize1, GrSize2, UseFFT_in, UsePreco_in)
integer, intent(in), target, dimension(:,:) :: Grid_in
real(kind=dp), intent(in) :: GrSize1, GrSize2
logical, intent(in) :: UseFFT_in, UsePreco_in
integer :: i, j
Pi = acos(-1.0_dp)
Mu0 = 4e-7_dp * Pi
c0 = 299792458
eps0 = 1 / (Mu0 * c0**2)
UseFFT = UseFFT_in
UsePreco = UsePreco_in
if(Ng1 /= 0 .and. allocated(G) ) then
deallocate( G )
end if
Grid => Grid_in
Ng1 = size(Grid, 1)
Ng2 = size(Grid, 2)
D1 = GrSize1/Ng1
D2 = GrSize2/Ng2
allocate( G(0:Ng1,0:Ng2) )
write(unit=*, fmt=*) "Calculating G"
do i=0,Ng1
do j=0,Ng2
G(j,i) = Ginteg( -D1/2,-D2/2, D1/2,D2/2, i*D1,j*D2 )
end do
end do
if(UseFFT) then
write(unit=*, fmt=*) "Transforming G"
call FourirG(G,1)
end if
return
contains
function Ginteg(xq1,yq1, xq2,yq2, xp,yp) result(G)
real(kind=dp), intent(in) :: xq1,yq1, xq2,yq2, xp,yp
real(kind=dp) :: G
real(kind=dp) :: x1,x2,y1,y2,t
x1 = xq1-xp
x2 = xq2-xp
y1 = yq1-yp
y2 = yq2-yp
if (x1+x2 < 0) then
t = -x1
x1 = -x2
x2 = t
end if
if (y1+y2 < 0) then
t = -y1
y1 = -y2
y2 = t
end if
G = (x2*y2)-(x1*y2)-(x2*y1)+(x1*y1)
return
end function Ginteg
end subroutine init_solve
end module solv_cap
! { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_intfloat_cvt } } }
| gpl-2.0 |
buaabyl/lm8-gcc | gcc-4.4.3/gcc/testsuite/gfortran.dg/pr37243.f | 8 | 1541 | ! PR rtl-optimization/37243
! { dg-do run }
! { dg-options "-mieee" { target alpha*-*-* } }
! Check if register allocator handles IR flattening correctly.
SUBROUTINE SCHMD(V,M,N,LDV)
IMPLICIT DOUBLE PRECISION(A-H,O-Z)
LOGICAL GOPARR,DSKWRK,MASWRK
DIMENSION V(LDV,N)
COMMON /IOFILE/ IR,IW,IP,IS,IPK,IDAF,NAV,IODA(400)
COMMON /PAR / ME,MASTER,NPROC,IBTYP,IPTIM,GOPARR,DSKWRK,MASWRK
PARAMETER (ZERO=0.0D+00, ONE=1.0D+00, TOL=1.0D-10)
IF (M .EQ. 0) GO TO 180
DO 160 I = 1,M
DUMI = ZERO
DO 100 K = 1,N
100 DUMI = DUMI+V(K,I)*V(K,I)
DUMI = ONE/ SQRT(DUMI)
DO 120 K = 1,N
120 V(K,I) = V(K,I)*DUMI
IF (I .EQ. M) GO TO 160
I1 = I+1
DO 140 J = I1,M
DUM = -DDOT(N,V(1,J),1,V(1,I),1)
CALL DAXPY(N,DUM,V(1,I),1,V(1,J),1)
140 CONTINUE
160 CONTINUE
IF (M .EQ. N) RETURN
180 CONTINUE
I = M
J = 0
200 I0 = I
I = I+1
IF (I .GT. N) RETURN
220 J = J+1
IF (J .GT. N) GO TO 320
DO 240 K = 1,N
240 V(K,I) = ZERO
CALL DAXPY(N,DUM,V(1,I),1,V(1,I),1)
260 CONTINUE
DUMI = ZERO
DO 280 K = 1,N
280 DUMI = DUMI+V(K,I)*V(K,I)
IF ( ABS(DUMI) .LT. TOL) GO TO 220
DO 300 K = 1,N
300 V(K,I) = V(K,I)*DUMI
GO TO 200
320 END
program main
DOUBLE PRECISION V
DIMENSION V(18, 18)
common // v
call schmd(V, 1, 18, 18)
end
subroutine DAXPY
end
FUNCTION DDOT ()
DOUBLE PRECISION DDOT
DDOT = 1
end
| gpl-2.0 |
Pakketeretet2/lammps | lib/linalg/ztptri.f | 18 | 6690 | *> \brief \b ZTPTRI
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
*> \htmlonly
*> Download ZTPTRI + dependencies
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztptri.f">
*> [TGZ]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztptri.f">
*> [ZIP]</a>
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztptri.f">
*> [TXT]</a>
*> \endhtmlonly
*
* Definition:
* ===========
*
* SUBROUTINE ZTPTRI( UPLO, DIAG, N, AP, INFO )
*
* .. Scalar Arguments ..
* CHARACTER DIAG, UPLO
* INTEGER INFO, N
* ..
* .. Array Arguments ..
* COMPLEX*16 AP( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZTPTRI computes the inverse of a complex upper or lower triangular
*> matrix A stored in packed format.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] UPLO
*> \verbatim
*> UPLO is CHARACTER*1
*> = 'U': A is upper triangular;
*> = 'L': A is lower triangular.
*> \endverbatim
*>
*> \param[in] DIAG
*> \verbatim
*> DIAG is CHARACTER*1
*> = 'N': A is non-unit triangular;
*> = 'U': A is unit triangular.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The order of the matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in,out] AP
*> \verbatim
*> AP is COMPLEX*16 array, dimension (N*(N+1)/2)
*> On entry, the upper or lower triangular matrix A, stored
*> columnwise in a linear array. The j-th column of A is stored
*> in the array AP as follows:
*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
*> if UPLO = 'L', AP(i + (j-1)*((2*n-j)/2) = A(i,j) for j<=i<=n.
*> See below for further details.
*> On exit, the (triangular) inverse of the original matrix, in
*> the same packed storage format.
*> \endverbatim
*>
*> \param[out] INFO
*> \verbatim
*> INFO is INTEGER
*> = 0: successful exit
*> < 0: if INFO = -i, the i-th argument had an illegal value
*> > 0: if INFO = i, A(i,i) is exactly zero. The triangular
*> matrix is singular and its inverse can not be computed.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date December 2016
*
*> \ingroup complex16OTHERcomputational
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> A triangular matrix A can be transferred to packed storage using one
*> of the following program segments:
*>
*> UPLO = 'U': UPLO = 'L':
*>
*> JC = 1 JC = 1
*> DO 2 J = 1, N DO 2 J = 1, N
*> DO 1 I = 1, J DO 1 I = J, N
*> AP(JC+I-1) = A(I,J) AP(JC+I-J) = A(I,J)
*> 1 CONTINUE 1 CONTINUE
*> JC = JC + J JC = JC + N - J + 1
*> 2 CONTINUE 2 CONTINUE
*> \endverbatim
*>
* =====================================================================
SUBROUTINE ZTPTRI( UPLO, DIAG, N, AP, INFO )
*
* -- LAPACK computational routine (version 3.7.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* December 2016
*
* .. Scalar Arguments ..
CHARACTER DIAG, UPLO
INTEGER INFO, N
* ..
* .. Array Arguments ..
COMPLEX*16 AP( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
COMPLEX*16 ONE, ZERO
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
$ ZERO = ( 0.0D+0, 0.0D+0 ) )
* ..
* .. Local Scalars ..
LOGICAL NOUNIT, UPPER
INTEGER J, JC, JCLAST, JJ
COMPLEX*16 AJJ
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL XERBLA, ZSCAL, ZTPMV
* ..
* .. Executable Statements ..
*
* Test the input parameters.
*
INFO = 0
UPPER = LSAME( UPLO, 'U' )
NOUNIT = LSAME( DIAG, 'N' )
IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
INFO = -1
ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
INFO = -2
ELSE IF( N.LT.0 ) THEN
INFO = -3
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'ZTPTRI', -INFO )
RETURN
END IF
*
* Check for singularity if non-unit.
*
IF( NOUNIT ) THEN
IF( UPPER ) THEN
JJ = 0
DO 10 INFO = 1, N
JJ = JJ + INFO
IF( AP( JJ ).EQ.ZERO )
$ RETURN
10 CONTINUE
ELSE
JJ = 1
DO 20 INFO = 1, N
IF( AP( JJ ).EQ.ZERO )
$ RETURN
JJ = JJ + N - INFO + 1
20 CONTINUE
END IF
INFO = 0
END IF
*
IF( UPPER ) THEN
*
* Compute inverse of upper triangular matrix.
*
JC = 1
DO 30 J = 1, N
IF( NOUNIT ) THEN
AP( JC+J-1 ) = ONE / AP( JC+J-1 )
AJJ = -AP( JC+J-1 )
ELSE
AJJ = -ONE
END IF
*
* Compute elements 1:j-1 of j-th column.
*
CALL ZTPMV( 'Upper', 'No transpose', DIAG, J-1, AP,
$ AP( JC ), 1 )
CALL ZSCAL( J-1, AJJ, AP( JC ), 1 )
JC = JC + J
30 CONTINUE
*
ELSE
*
* Compute inverse of lower triangular matrix.
*
JC = N*( N+1 ) / 2
DO 40 J = N, 1, -1
IF( NOUNIT ) THEN
AP( JC ) = ONE / AP( JC )
AJJ = -AP( JC )
ELSE
AJJ = -ONE
END IF
IF( J.LT.N ) THEN
*
* Compute elements j+1:n of j-th column.
*
CALL ZTPMV( 'Lower', 'No transpose', DIAG, N-J,
$ AP( JCLAST ), AP( JC+1 ), 1 )
CALL ZSCAL( N-J, AJJ, AP( JC+1 ), 1 )
END IF
JCLAST = JC
JC = JC - N + J - 2
40 CONTINUE
END IF
*
RETURN
*
* End of ZTPTRI
*
END
| gpl-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/write_rewind_2.f | 19 | 1153 | ! { dg-do run }
! PR 26499 Test write with rewind sequences to make sure buffering and
! end-of-file conditions are handled correctly. Derived from test case by Dale
! Ranta. Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
program test
dimension idata(1011)
idata = -42
open(unit=11,form='unformatted')
idata(1) = -705
idata( 1011) = -706
write(11)idata
idata(1) = -706
idata( 1011) = -707
write(11)idata
idata(1) = -707
idata( 1011) = -708
write(11)idata
read(11,end= 1000 )idata
STOP 1
1000 continue
rewind 11
read(11,end= 1001 )idata
if(idata(1).ne. -705.or.idata( 1011).ne. -706)STOP 2
1001 continue
close(11,status='keep')
open(unit=11,form='unformatted')
rewind 11
read(11)idata
if(idata(1).ne.-705)then
STOP 3
endif
read(11)idata
if(idata(1).ne.-706)then
STOP 4
endif
read(11)idata
if(idata(1).ne.-707)then
STOP 5
endif
close(11,status='delete')
stop
end
| gpl-2.0 |
sonnyhu/scipy | scipy/interpolate/fitpack/clocur.f | 115 | 17312 | subroutine clocur(iopt,ipar,idim,m,u,mx,x,w,k,s,nest,n,t,nc,c,fp,
* wrk,lwrk,iwrk,ier)
c given the ordered set of m points x(i) in the idim-dimensional space
c with x(1)=x(m), and given also a corresponding set of strictly in-
c creasing values u(i) and the set of positive numbers w(i),i=1,2,...,m
c subroutine clocur determines a smooth approximating closed spline
c curve s(u), i.e.
c x1 = s1(u)
c x2 = s2(u) u(1) <= u <= u(m)
c .........
c xidim = sidim(u)
c with sj(u),j=1,2,...,idim periodic spline functions of degree k with
c common knots t(j),j=1,2,...,n.
c if ipar=1 the values u(i),i=1,2,...,m must be supplied by the user.
c if ipar=0 these values are chosen automatically by clocur as
c v(1) = 0
c v(i) = v(i-1) + dist(x(i),x(i-1)) ,i=2,3,...,m
c u(i) = v(i)/v(m) ,i=1,2,...,m
c if iopt=-1 clocur calculates the weighted least-squares closed spline
c curve according to a given set of knots.
c if iopt>=0 the number of knots of the splines sj(u) and the position
c t(j),j=1,2,...,n is chosen automatically by the routine. the smooth-
c ness of s(u) is then achieved by minimalizing the discontinuity
c jumps of the k-th derivative of s(u) at the knots t(j),j=k+2,k+3,...,
c n-k-1. the amount of smoothness is determined by the condition that
c f(p)=sum((w(i)*dist(x(i),s(u(i))))**2) be <= s, with s a given non-
c negative constant, called the smoothing factor.
c the fit s(u) is given in the b-spline representation and can be
c evaluated by means of subroutine curev.
c
c calling sequence:
c call clocur(iopt,ipar,idim,m,u,mx,x,w,k,s,nest,n,t,nc,c,
c * fp,wrk,lwrk,iwrk,ier)
c
c parameters:
c iopt : integer flag. on entry iopt must specify whether a weighted
c least-squares closed spline curve (iopt=-1) or a smoothing
c closed spline curve (iopt=0 or 1) must be determined. if
c iopt=0 the routine will start with an initial set of knots
c t(i)=u(1)+(u(m)-u(1))*(i-k-1),i=1,2,...,2*k+2. if iopt=1 the
c routine will continue with the knots found at the last call.
c attention: a call with iopt=1 must always be immediately
c preceded by another call with iopt=1 or iopt=0.
c unchanged on exit.
c ipar : integer flag. on entry ipar must specify whether (ipar=1)
c the user will supply the parameter values u(i),or whether
c (ipar=0) these values are to be calculated by clocur.
c unchanged on exit.
c idim : integer. on entry idim must specify the dimension of the
c curve. 0 < idim < 11.
c unchanged on exit.
c m : integer. on entry m must specify the number of data points.
c m > 1. unchanged on exit.
c u : real array of dimension at least (m). in case ipar=1,before
c entry, u(i) must be set to the i-th value of the parameter
c variable u for i=1,2,...,m. these values must then be
c supplied in strictly ascending order and will be unchanged
c on exit. in case ipar=0, on exit,the array will contain the
c values u(i) as determined by clocur.
c mx : integer. on entry mx must specify the actual dimension of
c the array x as declared in the calling (sub)program. mx must
c not be too small (see x). unchanged on exit.
c x : real array of dimension at least idim*m.
c before entry, x(idim*(i-1)+j) must contain the j-th coord-
c inate of the i-th data point for i=1,2,...,m and j=1,2,...,
c idim. since first and last data point must coincide it
c means that x(j)=x(idim*(m-1)+j),j=1,2,...,idim.
c unchanged on exit.
c w : real array of dimension at least (m). before entry, w(i)
c must be set to the i-th value in the set of weights. the
c w(i) must be strictly positive. w(m) is not used.
c unchanged on exit. see also further comments.
c k : integer. on entry k must specify the degree of the splines.
c 1<=k<=5. it is recommended to use cubic splines (k=3).
c the user is strongly dissuaded from choosing k even,together
c with a small s-value. unchanged on exit.
c s : real.on entry (in case iopt>=0) s must specify the smoothing
c factor. s >=0. unchanged on exit.
c for advice on the choice of s see further comments.
c nest : integer. on entry nest must contain an over-estimate of the
c total number of knots of the splines returned, to indicate
c the storage space available to the routine. nest >=2*k+2.
c in most practical situation nest=m/2 will be sufficient.
c always large enough is nest=m+2*k, the number of knots
c needed for interpolation (s=0). unchanged on exit.
c n : integer.
c unless ier = 10 (in case iopt >=0), n will contain the
c total number of knots of the smoothing spline curve returned
c if the computation mode iopt=1 is used this value of n
c should be left unchanged between subsequent calls.
c in case iopt=-1, the value of n must be specified on entry.
c t : real array of dimension at least (nest).
c on succesful exit, this array will contain the knots of the
c spline curve,i.e. the position of the interior knots t(k+2),
c t(k+3),..,t(n-k-1) as well as the position of the additional
c t(1),t(2),..,t(k+1)=u(1) and u(m)=t(n-k),...,t(n) needed for
c the b-spline representation.
c if the computation mode iopt=1 is used, the values of t(1),
c t(2),...,t(n) should be left unchanged between subsequent
c calls. if the computation mode iopt=-1 is used, the values
c t(k+2),...,t(n-k-1) must be supplied by the user, before
c entry. see also the restrictions (ier=10).
c nc : integer. on entry nc must specify the actual dimension of
c the array c as declared in the calling (sub)program. nc
c must not be too small (see c). unchanged on exit.
c c : real array of dimension at least (nest*idim).
c on succesful exit, this array will contain the coefficients
c in the b-spline representation of the spline curve s(u),i.e.
c the b-spline coefficients of the spline sj(u) will be given
c in c(n*(j-1)+i),i=1,2,...,n-k-1 for j=1,2,...,idim.
c fp : real. unless ier = 10, fp contains the weighted sum of
c squared residuals of the spline curve returned.
c wrk : real array of dimension at least m*(k+1)+nest*(7+idim+5*k).
c used as working space. if the computation mode iopt=1 is
c used, the values wrk(1),...,wrk(n) should be left unchanged
c between subsequent calls.
c lwrk : integer. on entry,lwrk must specify the actual dimension of
c the array wrk as declared in the calling (sub)program. lwrk
c must not be too small (see wrk). unchanged on exit.
c iwrk : integer array of dimension at least (nest).
c used as working space. if the computation mode iopt=1 is
c used,the values iwrk(1),...,iwrk(n) should be left unchanged
c between subsequent calls.
c ier : integer. unless the routine detects an error, ier contains a
c non-positive value on exit, i.e.
c ier=0 : normal return. the close curve returned has a residual
c sum of squares fp such that abs(fp-s)/s <= tol with tol a
c relative tolerance set to 0.001 by the program.
c ier=-1 : normal return. the curve returned is an interpolating
c spline curve (fp=0).
c ier=-2 : normal return. the curve returned is the weighted least-
c squares point,i.e. each spline sj(u) is a constant. in
c this extreme case fp gives the upper bound fp0 for the
c smoothing factor s.
c ier=1 : error. the required storage space exceeds the available
c storage space, as specified by the parameter nest.
c probably causes : nest too small. if nest is already
c large (say nest > m/2), it may also indicate that s is
c too small
c the approximation returned is the least-squares closed
c curve according to the knots t(1),t(2),...,t(n). (n=nest)
c the parameter fp gives the corresponding weighted sum of
c squared residuals (fp>s).
c ier=2 : error. a theoretically impossible result was found during
c the iteration proces for finding a smoothing curve with
c fp = s. probably causes : s too small.
c there is an approximation returned but the corresponding
c weighted sum of squared residuals does not satisfy the
c condition abs(fp-s)/s < tol.
c ier=3 : error. the maximal number of iterations maxit (set to 20
c by the program) allowed for finding a smoothing curve
c with fp=s has been reached. probably causes : s too small
c there is an approximation returned but the corresponding
c weighted sum of squared residuals does not satisfy the
c condition abs(fp-s)/s < tol.
c ier=10 : error. on entry, the input data are controlled on validity
c the following restrictions must be satisfied.
c -1<=iopt<=1, 1<=k<=5, m>1, nest>2*k+2, w(i)>0,i=1,2,...,m
c 0<=ipar<=1, 0<idim<=10, lwrk>=(k+1)*m+nest*(7+idim+5*k),
c nc>=nest*idim, x(j)=x(idim*(m-1)+j), j=1,2,...,idim
c if ipar=0: sum j=1,idim (x(i*idim+j)-x((i-1)*idim+j))**2>0
c i=1,2,...,m-1.
c if ipar=1: u(1)<u(2)<...<u(m)
c if iopt=-1: 2*k+2<=n<=min(nest,m+2*k)
c u(1)<t(k+2)<t(k+3)<...<t(n-k-1)<u(m)
c (u(1)=0 and u(m)=1 in case ipar=0)
c the schoenberg-whitney conditions, i.e. there
c must be a subset of data points uu(j) with
c uu(j) = u(i) or u(i)+(u(m)-u(1)) such that
c t(j) < uu(j) < t(j+k+1), j=k+1,...,n-k-1
c if iopt>=0: s>=0
c if s=0 : nest >= m+2*k
c if one of these conditions is found to be violated,control
c is immediately repassed to the calling program. in that
c case there is no approximation returned.
c
c further comments:
c by means of the parameter s, the user can control the tradeoff
c between closeness of fit and smoothness of fit of the approximation.
c if s is too large, the curve will be too smooth and signal will be
c lost ; if s is too small the curve will pick up too much noise. in
c the extreme cases the program will return an interpolating curve if
c s=0 and the weighted least-squares point if s is very large.
c between these extremes, a properly chosen s will result in a good
c compromise between closeness of fit and smoothness of fit.
c to decide whether an approximation, corresponding to a certain s is
c satisfactory the user is highly recommended to inspect the fits
c graphically.
c recommended values for s depend on the weights w(i). if these are
c taken as 1/d(i) with d(i) an estimate of the standard deviation of
c x(i), a good s-value should be found in the range (m-sqrt(2*m),m+
c sqrt(2*m)). if nothing is known about the statistical error in x(i)
c each w(i) can be set equal to one and s determined by trial and
c error, taking account of the comments above. the best is then to
c start with a very large value of s ( to determine the weighted
c least-squares point and the upper bound fp0 for s) and then to
c progressively decrease the value of s ( say by a factor 10 in the
c beginning, i.e. s=fp0/10, fp0/100,...and more carefully as the
c approximating curve shows more detail) to obtain closer fits.
c to economize the search for a good s-value the program provides with
c different modes of computation. at the first call of the routine, or
c whenever he wants to restart with the initial set of knots the user
c must set iopt=0.
c if iopt=1 the program will continue with the set of knots found at
c the last call of the routine. this will save a lot of computation
c time if clocur is called repeatedly for different values of s.
c the number of knots of the spline returned and their location will
c depend on the value of s and on the complexity of the shape of the
c curve underlying the data. but, if the computation mode iopt=1 is
c used, the knots returned may also depend on the s-values at previous
c calls (if these were smaller). therefore, if after a number of
c trials with different s-values and iopt=1, the user can finally
c accept a fit as satisfactory, it may be worthwhile for him to call
c clocur once more with the selected value for s but now with iopt=0.
c indeed, clocur may then return an approximation of the same quality
c of fit but with fewer knots and therefore better if data reduction
c is also an important objective for the user.
c
c the form of the approximating curve can strongly be affected by
c the choice of the parameter values u(i). if there is no physical
c reason for choosing a particular parameter u, often good results
c will be obtained with the choice of clocur(in case ipar=0), i.e.
c v(1)=0, v(i)=v(i-1)+q(i), i=2,...,m, u(i)=v(i)/v(m), i=1,..,m
c where
c q(i)= sqrt(sum j=1,idim (xj(i)-xj(i-1))**2 )
c other possibilities for q(i) are
c q(i)= sum j=1,idim (xj(i)-xj(i-1))**2
c q(i)= sum j=1,idim abs(xj(i)-xj(i-1))
c q(i)= max j=1,idim abs(xj(i)-xj(i-1))
c q(i)= 1
c
c
c other subroutines required:
c fpbacp,fpbspl,fpchep,fpclos,fpdisc,fpgivs,fpknot,fprati,fprota
c
c references:
c dierckx p. : algorithms for smoothing data with periodic and
c parametric splines, computer graphics and image
c processing 20 (1982) 171-184.
c dierckx p. : algorithms for smoothing data with periodic and param-
c etric splines, report tw55, dept. computer science,
c k.u.leuven, 1981.
c dierckx p. : curve and surface fitting with splines, monographs on
c numerical analysis, oxford university press, 1993.
c
c author:
c p.dierckx
c dept. computer science, k.u. leuven
c celestijnenlaan 200a, b-3001 heverlee, belgium.
c e-mail : Paul.Dierckx@cs.kuleuven.ac.be
c
c creation date : may 1979
c latest update : march 1987
c
c ..
c ..scalar arguments..
real*8 s,fp
integer iopt,ipar,idim,m,mx,k,nest,n,nc,lwrk,ier
c ..array arguments..
real*8 u(m),x(mx),w(m),t(nest),c(nc),wrk(lwrk)
integer iwrk(nest)
c ..local scalars..
real*8 per,tol,dist
integer i,ia1,ia2,ib,ifp,ig1,ig2,iq,iz,i1,i2,j1,j2,k1,k2,lwest,
* maxit,m1,nmin,ncc,j
c ..function references..
real*8 sqrt
c we set up the parameters tol and maxit
maxit = 20
tol = 0.1e-02
c before starting computations a data check is made. if the input data
c are invalid, control is immediately repassed to the calling program.
ier = 10
if(iopt.lt.(-1) .or. iopt.gt.1) go to 90
if(ipar.lt.0 .or. ipar.gt.1) go to 90
if(idim.le.0 .or. idim.gt.10) go to 90
if(k.le.0 .or. k.gt.5) go to 90
k1 = k+1
k2 = k1+1
nmin = 2*k1
if(m.lt.2 .or. nest.lt.nmin) go to 90
ncc = nest*idim
if(mx.lt.m*idim .or. nc.lt.ncc) go to 90
lwest = m*k1+nest*(7+idim+5*k)
if(lwrk.lt.lwest) go to 90
i1 = idim
i2 = m*idim
do 5 j=1,idim
if(x(i1).ne.x(i2)) go to 90
i1 = i1-1
i2 = i2-1
5 continue
if(ipar.ne.0 .or. iopt.gt.0) go to 40
i1 = 0
i2 = idim
u(1) = 0.
do 20 i=2,m
dist = 0.
do 10 j1=1,idim
i1 = i1+1
i2 = i2+1
dist = dist+(x(i2)-x(i1))**2
10 continue
u(i) = u(i-1)+sqrt(dist)
20 continue
if(u(m).le.0.) go to 90
do 30 i=2,m
u(i) = u(i)/u(m)
30 continue
u(m) = 0.1e+01
40 if(w(1).le.0.) go to 90
m1 = m-1
do 50 i=1,m1
if(u(i).ge.u(i+1) .or. w(i).le.0.) go to 90
50 continue
if(iopt.ge.0) go to 70
if(n.le.nmin .or. n.gt.nest) go to 90
per = u(m)-u(1)
j1 = k1
t(j1) = u(1)
i1 = n-k
t(i1) = u(m)
j2 = j1
i2 = i1
do 60 i=1,k
i1 = i1+1
i2 = i2-1
j1 = j1+1
j2 = j2-1
t(j2) = t(i2)-per
t(i1) = t(j1)+per
60 continue
call fpchep(u,m,t,n,k,ier)
if (ier.eq.0) go to 80
go to 90
70 if(s.lt.0.) go to 90
if(s.eq.0. .and. nest.lt.(m+2*k)) go to 90
ier = 0
c we partition the working space and determine the spline approximation.
80 ifp = 1
iz = ifp+nest
ia1 = iz+ncc
ia2 = ia1+nest*k1
ib = ia2+nest*k
ig1 = ib+nest*k2
ig2 = ig1+nest*k2
iq = ig2+nest*k1
call fpclos(iopt,idim,m,u,mx,x,w,k,s,nest,tol,maxit,k1,k2,n,t,
* ncc,c,fp,wrk(ifp),wrk(iz),wrk(ia1),wrk(ia2),wrk(ib),wrk(ig1),
* wrk(ig2),wrk(iq),iwrk,ier)
90 return
end
| bsd-3-clause |
foss-for-synopsys-dwc-arc-processors/gcc | libgfortran/generated/_cos_r8.F90 | 4 | 1467 | ! Copyright (C) 2002-2021 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 3 of the License, or (at your option) any later version.
!GNU libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_8)
#ifdef HAVE_COS
elemental function _gfortran_specific__cos_r8 (parm)
real (kind=8), intent (in) :: parm
real (kind=8) :: _gfortran_specific__cos_r8
_gfortran_specific__cos_r8 = cos (parm)
end function
#endif
#endif
| gpl-2.0 |
OpenFAST/OpenFAST | modules/aerodyn/src/DBEMT_Types.f90 | 1 | 142849 | !STARTOFREGISTRYGENERATEDFILE 'DBEMT_Types.f90'
!
! WARNING This file is generated automatically by the FAST registry.
! Do not edit. Your changes to this file will be lost.
!
! FAST Registry
!*********************************************************************************************************************************
! DBEMT_Types
!.................................................................................................................................
! This file is part of DBEMT.
!
! Copyright (C) 2012-2016 National Renewable Energy Laboratory
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
!
! W A R N I N G : This file was automatically generated from the FAST registry. Changes made to this file may be lost.
!
!*********************************************************************************************************************************
!> This module contains the user-defined types needed in DBEMT. It also contains copy, destroy, pack, and
!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry.
MODULE DBEMT_Types
!---------------------------------------------------------------------------------------------------------------------------------
USE NWTC_Library
IMPLICIT NONE
INTEGER(IntKi), PUBLIC, PARAMETER :: DBEMT_none = 0 ! use BEMT instead (not DBEMT) [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: DBEMT_tauConst = 1 ! use constant tau1 [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: DBEMT_tauVaries = 2 ! use time-dependent tau1 [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: DBEMT_cont_tauConst = 3 ! use continuous formulation with constant tau1 [-]
! ========= DBEMT_InitInputType =======
TYPE, PUBLIC :: DBEMT_InitInputType
INTEGER(IntKi) :: NumBlades !< Number of blades on the turbine [-]
INTEGER(IntKi) :: NumNodes !< Number of nodes on each blade [-]
REAL(ReKi) :: tau1_const !< delay value based on disk-averaged quantities [-]
INTEGER(IntKi) :: DBEMT_Mod !< DBEMT Model. 1 = constant tau1, 2 = time dependent tau1, 3=continuous form with constant tau1 [-]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: rLocal !< Radial distance to blade node from the center of rotation, measured in the rotor plane, needed for DBEMT [m]
END TYPE DBEMT_InitInputType
! =======================
! ========= DBEMT_InitOutputType =======
TYPE, PUBLIC :: DBEMT_InitOutputType
TYPE(ProgDesc) :: Ver !< This module's name, version, and date [-]
END TYPE DBEMT_InitOutputType
! =======================
! ========= DBEMT_ElementContinuousStateType =======
TYPE, PUBLIC :: DBEMT_ElementContinuousStateType
REAL(R8Ki) , DIMENSION(1:2) :: vind !< The filtered induced velocity, [1,i,j] is the axial induced velocity (-Vx*a) at node i on blade j and [2,i,j] is the tantential induced velocity (Vy*a') [m/s]
REAL(R8Ki) , DIMENSION(1:2) :: vind_dot !< Time derivative of the filtered induced velocity, x%vind in CCSD [m/s^2]
REAL(R8Ki) , DIMENSION(1:2) :: vind_1 !< The filtered intermediate induced velocity [m/s]
END TYPE DBEMT_ElementContinuousStateType
! =======================
! ========= DBEMT_ContinuousStateType =======
TYPE, PUBLIC :: DBEMT_ContinuousStateType
TYPE(DBEMT_ElementContinuousStateType) , DIMENSION(:,:), ALLOCATABLE :: element !< The filtered induced velocity [1,i,j] is the axial induced velocity (-Vx*a) at node i on blade j and [2,i,j] is the tantential induced velocity (Vy*a') at node i on blade j [m/s]
END TYPE DBEMT_ContinuousStateType
! =======================
! ========= DBEMT_DiscreteStateType =======
TYPE, PUBLIC :: DBEMT_DiscreteStateType
REAL(SiKi) :: DummyState !< Remove this variable if you have continuous states [-]
END TYPE DBEMT_DiscreteStateType
! =======================
! ========= DBEMT_ConstraintStateType =======
TYPE, PUBLIC :: DBEMT_ConstraintStateType
REAL(SiKi) :: DummyState !< Remove this variable if you have constraint states [-]
END TYPE DBEMT_ConstraintStateType
! =======================
! ========= DBEMT_OtherStateType =======
TYPE, PUBLIC :: DBEMT_OtherStateType
LOGICAL , DIMENSION(:,:), ALLOCATABLE :: areStatesInitialized !< Flag indicating whether the module's states have been initialized properly [-]
REAL(ReKi) :: tau1 !< value of tau1 used in updateStates (for output-to-file only) [-]
REAL(ReKi) :: tau2 !< value of tau2 used in updateStates (equal to k_tau * tau1, not used between time steps) [-]
INTEGER(IntKi) , DIMENSION(:,:), ALLOCATABLE :: n !< time step value used for continuous state integrator [-]
TYPE(DBEMT_ContinuousStateType) , DIMENSION(1:4) :: xdot !< derivative history for continuous state integrators [-]
END TYPE DBEMT_OtherStateType
! =======================
! ========= DBEMT_MiscVarType =======
TYPE, PUBLIC :: DBEMT_MiscVarType
LOGICAL :: FirstWarn_tau1 !< flag so tau1 limit warning doesn't get repeated forever [-]
END TYPE DBEMT_MiscVarType
! =======================
! ========= DBEMT_ParameterType =======
TYPE, PUBLIC :: DBEMT_ParameterType
REAL(DbKi) :: DT !< Time step for continuous state integration & discrete state update [seconds]
INTEGER(IntKi) :: lin_nx = 0 !< Number of continuous states for linearization [-]
INTEGER(IntKi) :: NumBlades !< Number of blades on the turbine [-]
INTEGER(IntKi) :: NumNodes !< Number of nodes on each blade [-]
REAL(ReKi) :: k_0ye !< Filter dynamics constant [default = 0.6 ] [-]
REAL(ReKi) :: tau1_const !< constant version of the delay value [-]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: spanRatio !< static span ratio of each blade node [-]
INTEGER(IntKi) :: DBEMT_Mod !< DBEMT Model. 1 = constant tau1, 2 = time dependent tau1, 3=continuous form of constant tau1 [-]
END TYPE DBEMT_ParameterType
! =======================
! ========= DBEMT_ElementInputType =======
TYPE, PUBLIC :: DBEMT_ElementInputType
REAL(ReKi) , DIMENSION(1:2) :: vind_s !< The unfiltered induced velocity, [1] is the axial induced velocity (-Vx*a) and [2] is the tangential induced velocity (Vy*a') at node i on blade j. Note that the inputs are used only operated on at a particular node and blade, so we don't store all elements [m/s]
REAL(ReKi) , DIMENSION(1:2) :: vind_s_dot !< The first time derivative of the unfiltered induced velocity, u%vind_s [m/s^2]
REAL(ReKi) :: spanRatio !< Normalized span location of blade node [-]
END TYPE DBEMT_ElementInputType
! =======================
! ========= DBEMT_InputType =======
TYPE, PUBLIC :: DBEMT_InputType
REAL(ReKi) :: AxInd_disk !< Disk-averaged axial induction (for time-varying tau) [-]
REAL(ReKi) :: Un_disk !< Disk-averaged normal relative inflow velocity (for time-varying tau) [m/s]
REAL(ReKi) :: R_disk !< Disk-averaged rotor radius (for time-varying tau) [m]
TYPE(DBEMT_ElementInputType) , DIMENSION(:,:), ALLOCATABLE :: element !< The element-level inputs at each blade node [-]
END TYPE DBEMT_InputType
! =======================
! ========= DBEMT_OutputType =======
TYPE, PUBLIC :: DBEMT_OutputType
REAL(ReKi) , DIMENSION(:,:,:), ALLOCATABLE :: vind !< The filtered induced velocity, [1,i,j] is the axial induced velocity (-Vx*a) at node i on blade j and [2,i,j] is the tangential induced velocity (Vy*a') at node i on blade j [m/s]
END TYPE DBEMT_OutputType
! =======================
CONTAINS
SUBROUTINE DBEMT_CopyInitInput( SrcInitInputData, DstInitInputData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_InitInputType), INTENT(IN) :: SrcInitInputData
TYPE(DBEMT_InitInputType), INTENT(INOUT) :: DstInitInputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: i3, i3_l, i3_u ! bounds (upper/lower) for an array dimension 3
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyInitInput'
!
ErrStat = ErrID_None
ErrMsg = ""
DstInitInputData%NumBlades = SrcInitInputData%NumBlades
DstInitInputData%NumNodes = SrcInitInputData%NumNodes
DstInitInputData%tau1_const = SrcInitInputData%tau1_const
DstInitInputData%DBEMT_Mod = SrcInitInputData%DBEMT_Mod
IF (ALLOCATED(SrcInitInputData%rLocal)) THEN
i1_l = LBOUND(SrcInitInputData%rLocal,1)
i1_u = UBOUND(SrcInitInputData%rLocal,1)
i2_l = LBOUND(SrcInitInputData%rLocal,2)
i2_u = UBOUND(SrcInitInputData%rLocal,2)
IF (.NOT. ALLOCATED(DstInitInputData%rLocal)) THEN
ALLOCATE(DstInitInputData%rLocal(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitInputData%rLocal.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitInputData%rLocal = SrcInitInputData%rLocal
ENDIF
END SUBROUTINE DBEMT_CopyInitInput
SUBROUTINE DBEMT_DestroyInitInput( InitInputData, ErrStat, ErrMsg )
TYPE(DBEMT_InitInputType), INTENT(INOUT) :: InitInputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyInitInput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(InitInputData%rLocal)) THEN
DEALLOCATE(InitInputData%rLocal)
ENDIF
END SUBROUTINE DBEMT_DestroyInitInput
SUBROUTINE DBEMT_PackInitInput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_InitInputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackInitInput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! NumBlades
Int_BufSz = Int_BufSz + 1 ! NumNodes
Re_BufSz = Re_BufSz + 1 ! tau1_const
Int_BufSz = Int_BufSz + 1 ! DBEMT_Mod
Int_BufSz = Int_BufSz + 1 ! rLocal allocated yes/no
IF ( ALLOCATED(InData%rLocal) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! rLocal upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%rLocal) ! rLocal
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IntKiBuf(Int_Xferred) = InData%NumBlades
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumNodes
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%tau1_const
Re_Xferred = Re_Xferred + 1
IntKiBuf(Int_Xferred) = InData%DBEMT_Mod
Int_Xferred = Int_Xferred + 1
IF ( .NOT. ALLOCATED(InData%rLocal) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%rLocal,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%rLocal,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%rLocal,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%rLocal,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%rLocal,2), UBOUND(InData%rLocal,2)
DO i1 = LBOUND(InData%rLocal,1), UBOUND(InData%rLocal,1)
ReKiBuf(Re_Xferred) = InData%rLocal(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
END SUBROUTINE DBEMT_PackInitInput
SUBROUTINE DBEMT_UnPackInitInput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_InitInputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: i3, i3_l, i3_u ! bounds (upper/lower) for an array dimension 3
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackInitInput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%NumBlades = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%NumNodes = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%tau1_const = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%DBEMT_Mod = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! rLocal not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%rLocal)) DEALLOCATE(OutData%rLocal)
ALLOCATE(OutData%rLocal(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%rLocal.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%rLocal,2), UBOUND(OutData%rLocal,2)
DO i1 = LBOUND(OutData%rLocal,1), UBOUND(OutData%rLocal,1)
OutData%rLocal(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
END SUBROUTINE DBEMT_UnPackInitInput
SUBROUTINE DBEMT_CopyInitOutput( SrcInitOutputData, DstInitOutputData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_InitOutputType), INTENT(IN) :: SrcInitOutputData
TYPE(DBEMT_InitOutputType), INTENT(INOUT) :: DstInitOutputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyInitOutput'
!
ErrStat = ErrID_None
ErrMsg = ""
CALL NWTC_Library_Copyprogdesc( SrcInitOutputData%Ver, DstInitOutputData%Ver, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE DBEMT_CopyInitOutput
SUBROUTINE DBEMT_DestroyInitOutput( InitOutputData, ErrStat, ErrMsg )
TYPE(DBEMT_InitOutputType), INTENT(INOUT) :: InitOutputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyInitOutput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
CALL NWTC_Library_Destroyprogdesc( InitOutputData%Ver, ErrStat, ErrMsg )
END SUBROUTINE DBEMT_DestroyInitOutput
SUBROUTINE DBEMT_PackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_InitOutputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackInitOutput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! Ver: size of buffers for each call to pack subtype
CALL NWTC_Library_Packprogdesc( Re_Buf, Db_Buf, Int_Buf, InData%Ver, ErrStat2, ErrMsg2, .TRUE. ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! Ver
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! Ver
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! Ver
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
CALL NWTC_Library_Packprogdesc( Re_Buf, Db_Buf, Int_Buf, InData%Ver, ErrStat2, ErrMsg2, OnlySize ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE DBEMT_PackInitOutput
SUBROUTINE DBEMT_UnPackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_InitOutputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackInitOutput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL NWTC_Library_Unpackprogdesc( Re_Buf, Db_Buf, Int_Buf, OutData%Ver, ErrStat2, ErrMsg2 ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE DBEMT_UnPackInitOutput
SUBROUTINE DBEMT_CopyElementContinuousStateType( SrcElementContinuousStateTypeData, DstElementContinuousStateTypeData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_ElementContinuousStateType), INTENT(IN) :: SrcElementContinuousStateTypeData
TYPE(DBEMT_ElementContinuousStateType), INTENT(INOUT) :: DstElementContinuousStateTypeData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyElementContinuousStateType'
!
ErrStat = ErrID_None
ErrMsg = ""
DstElementContinuousStateTypeData%vind = SrcElementContinuousStateTypeData%vind
DstElementContinuousStateTypeData%vind_dot = SrcElementContinuousStateTypeData%vind_dot
DstElementContinuousStateTypeData%vind_1 = SrcElementContinuousStateTypeData%vind_1
END SUBROUTINE DBEMT_CopyElementContinuousStateType
SUBROUTINE DBEMT_DestroyElementContinuousStateType( ElementContinuousStateTypeData, ErrStat, ErrMsg )
TYPE(DBEMT_ElementContinuousStateType), INTENT(INOUT) :: ElementContinuousStateTypeData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyElementContinuousStateType'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE DBEMT_DestroyElementContinuousStateType
SUBROUTINE DBEMT_PackElementContinuousStateType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_ElementContinuousStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackElementContinuousStateType'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Db_BufSz = Db_BufSz + SIZE(InData%vind) ! vind
Db_BufSz = Db_BufSz + SIZE(InData%vind_dot) ! vind_dot
Db_BufSz = Db_BufSz + SIZE(InData%vind_1) ! vind_1
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO i1 = LBOUND(InData%vind,1), UBOUND(InData%vind,1)
DbKiBuf(Db_Xferred) = InData%vind(i1)
Db_Xferred = Db_Xferred + 1
END DO
DO i1 = LBOUND(InData%vind_dot,1), UBOUND(InData%vind_dot,1)
DbKiBuf(Db_Xferred) = InData%vind_dot(i1)
Db_Xferred = Db_Xferred + 1
END DO
DO i1 = LBOUND(InData%vind_1,1), UBOUND(InData%vind_1,1)
DbKiBuf(Db_Xferred) = InData%vind_1(i1)
Db_Xferred = Db_Xferred + 1
END DO
END SUBROUTINE DBEMT_PackElementContinuousStateType
SUBROUTINE DBEMT_UnPackElementContinuousStateType( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_ElementContinuousStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackElementContinuousStateType'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
i1_l = LBOUND(OutData%vind,1)
i1_u = UBOUND(OutData%vind,1)
DO i1 = LBOUND(OutData%vind,1), UBOUND(OutData%vind,1)
OutData%vind(i1) = REAL(DbKiBuf(Db_Xferred), R8Ki)
Db_Xferred = Db_Xferred + 1
END DO
i1_l = LBOUND(OutData%vind_dot,1)
i1_u = UBOUND(OutData%vind_dot,1)
DO i1 = LBOUND(OutData%vind_dot,1), UBOUND(OutData%vind_dot,1)
OutData%vind_dot(i1) = REAL(DbKiBuf(Db_Xferred), R8Ki)
Db_Xferred = Db_Xferred + 1
END DO
i1_l = LBOUND(OutData%vind_1,1)
i1_u = UBOUND(OutData%vind_1,1)
DO i1 = LBOUND(OutData%vind_1,1), UBOUND(OutData%vind_1,1)
OutData%vind_1(i1) = REAL(DbKiBuf(Db_Xferred), R8Ki)
Db_Xferred = Db_Xferred + 1
END DO
END SUBROUTINE DBEMT_UnPackElementContinuousStateType
SUBROUTINE DBEMT_CopyContState( SrcContStateData, DstContStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_ContinuousStateType), INTENT(IN) :: SrcContStateData
TYPE(DBEMT_ContinuousStateType), INTENT(INOUT) :: DstContStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyContState'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcContStateData%element)) THEN
i1_l = LBOUND(SrcContStateData%element,1)
i1_u = UBOUND(SrcContStateData%element,1)
i2_l = LBOUND(SrcContStateData%element,2)
i2_u = UBOUND(SrcContStateData%element,2)
IF (.NOT. ALLOCATED(DstContStateData%element)) THEN
ALLOCATE(DstContStateData%element(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstContStateData%element.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DO i2 = LBOUND(SrcContStateData%element,2), UBOUND(SrcContStateData%element,2)
DO i1 = LBOUND(SrcContStateData%element,1), UBOUND(SrcContStateData%element,1)
CALL DBEMT_Copyelementcontinuousstatetype( SrcContStateData%element(i1,i2), DstContStateData%element(i1,i2), CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
ENDDO
ENDDO
ENDIF
END SUBROUTINE DBEMT_CopyContState
SUBROUTINE DBEMT_DestroyContState( ContStateData, ErrStat, ErrMsg )
TYPE(DBEMT_ContinuousStateType), INTENT(INOUT) :: ContStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyContState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(ContStateData%element)) THEN
DO i2 = LBOUND(ContStateData%element,2), UBOUND(ContStateData%element,2)
DO i1 = LBOUND(ContStateData%element,1), UBOUND(ContStateData%element,1)
CALL DBEMT_Destroyelementcontinuousstatetype( ContStateData%element(i1,i2), ErrStat, ErrMsg )
ENDDO
ENDDO
DEALLOCATE(ContStateData%element)
ENDIF
END SUBROUTINE DBEMT_DestroyContState
SUBROUTINE DBEMT_PackContState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_ContinuousStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackContState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! element allocated yes/no
IF ( ALLOCATED(InData%element) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! element upper/lower bounds for each dimension
! Allocate buffers for subtypes, if any (we'll get sizes from these)
DO i2 = LBOUND(InData%element,2), UBOUND(InData%element,2)
DO i1 = LBOUND(InData%element,1), UBOUND(InData%element,1)
Int_BufSz = Int_BufSz + 3 ! element: size of buffers for each call to pack subtype
CALL DBEMT_Packelementcontinuousstatetype( Re_Buf, Db_Buf, Int_Buf, InData%element(i1,i2), ErrStat2, ErrMsg2, .TRUE. ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! element
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! element
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! element
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
END DO
END DO
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%element) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%element,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%element,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%element,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%element,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%element,2), UBOUND(InData%element,2)
DO i1 = LBOUND(InData%element,1), UBOUND(InData%element,1)
CALL DBEMT_Packelementcontinuousstatetype( Re_Buf, Db_Buf, Int_Buf, InData%element(i1,i2), ErrStat2, ErrMsg2, OnlySize ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END DO
END DO
END IF
END SUBROUTINE DBEMT_PackContState
SUBROUTINE DBEMT_UnPackContState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_ContinuousStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackContState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! element not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%element)) DEALLOCATE(OutData%element)
ALLOCATE(OutData%element(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%element.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%element,2), UBOUND(OutData%element,2)
DO i1 = LBOUND(OutData%element,1), UBOUND(OutData%element,1)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL DBEMT_Unpackelementcontinuousstatetype( Re_Buf, Db_Buf, Int_Buf, OutData%element(i1,i2), ErrStat2, ErrMsg2 ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END DO
END DO
END IF
END SUBROUTINE DBEMT_UnPackContState
SUBROUTINE DBEMT_CopyDiscState( SrcDiscStateData, DstDiscStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_DiscreteStateType), INTENT(IN) :: SrcDiscStateData
TYPE(DBEMT_DiscreteStateType), INTENT(INOUT) :: DstDiscStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyDiscState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstDiscStateData%DummyState = SrcDiscStateData%DummyState
END SUBROUTINE DBEMT_CopyDiscState
SUBROUTINE DBEMT_DestroyDiscState( DiscStateData, ErrStat, ErrMsg )
TYPE(DBEMT_DiscreteStateType), INTENT(INOUT) :: DiscStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyDiscState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE DBEMT_DestroyDiscState
SUBROUTINE DBEMT_PackDiscState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_DiscreteStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackDiscState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_PackDiscState
SUBROUTINE DBEMT_UnPackDiscState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_DiscreteStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackDiscState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyState = REAL(ReKiBuf(Re_Xferred), SiKi)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_UnPackDiscState
SUBROUTINE DBEMT_CopyConstrState( SrcConstrStateData, DstConstrStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_ConstraintStateType), INTENT(IN) :: SrcConstrStateData
TYPE(DBEMT_ConstraintStateType), INTENT(INOUT) :: DstConstrStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyConstrState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstConstrStateData%DummyState = SrcConstrStateData%DummyState
END SUBROUTINE DBEMT_CopyConstrState
SUBROUTINE DBEMT_DestroyConstrState( ConstrStateData, ErrStat, ErrMsg )
TYPE(DBEMT_ConstraintStateType), INTENT(INOUT) :: ConstrStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyConstrState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE DBEMT_DestroyConstrState
SUBROUTINE DBEMT_PackConstrState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_ConstraintStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackConstrState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_PackConstrState
SUBROUTINE DBEMT_UnPackConstrState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_ConstraintStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackConstrState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyState = REAL(ReKiBuf(Re_Xferred), SiKi)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_UnPackConstrState
SUBROUTINE DBEMT_CopyOtherState( SrcOtherStateData, DstOtherStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_OtherStateType), INTENT(IN) :: SrcOtherStateData
TYPE(DBEMT_OtherStateType), INTENT(INOUT) :: DstOtherStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyOtherState'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcOtherStateData%areStatesInitialized)) THEN
i1_l = LBOUND(SrcOtherStateData%areStatesInitialized,1)
i1_u = UBOUND(SrcOtherStateData%areStatesInitialized,1)
i2_l = LBOUND(SrcOtherStateData%areStatesInitialized,2)
i2_u = UBOUND(SrcOtherStateData%areStatesInitialized,2)
IF (.NOT. ALLOCATED(DstOtherStateData%areStatesInitialized)) THEN
ALLOCATE(DstOtherStateData%areStatesInitialized(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstOtherStateData%areStatesInitialized.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstOtherStateData%areStatesInitialized = SrcOtherStateData%areStatesInitialized
ENDIF
DstOtherStateData%tau1 = SrcOtherStateData%tau1
DstOtherStateData%tau2 = SrcOtherStateData%tau2
IF (ALLOCATED(SrcOtherStateData%n)) THEN
i1_l = LBOUND(SrcOtherStateData%n,1)
i1_u = UBOUND(SrcOtherStateData%n,1)
i2_l = LBOUND(SrcOtherStateData%n,2)
i2_u = UBOUND(SrcOtherStateData%n,2)
IF (.NOT. ALLOCATED(DstOtherStateData%n)) THEN
ALLOCATE(DstOtherStateData%n(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstOtherStateData%n.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstOtherStateData%n = SrcOtherStateData%n
ENDIF
DO i1 = LBOUND(SrcOtherStateData%xdot,1), UBOUND(SrcOtherStateData%xdot,1)
CALL DBEMT_CopyContState( SrcOtherStateData%xdot(i1), DstOtherStateData%xdot(i1), CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
ENDDO
END SUBROUTINE DBEMT_CopyOtherState
SUBROUTINE DBEMT_DestroyOtherState( OtherStateData, ErrStat, ErrMsg )
TYPE(DBEMT_OtherStateType), INTENT(INOUT) :: OtherStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyOtherState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(OtherStateData%areStatesInitialized)) THEN
DEALLOCATE(OtherStateData%areStatesInitialized)
ENDIF
IF (ALLOCATED(OtherStateData%n)) THEN
DEALLOCATE(OtherStateData%n)
ENDIF
DO i1 = LBOUND(OtherStateData%xdot,1), UBOUND(OtherStateData%xdot,1)
CALL DBEMT_DestroyContState( OtherStateData%xdot(i1), ErrStat, ErrMsg )
ENDDO
END SUBROUTINE DBEMT_DestroyOtherState
SUBROUTINE DBEMT_PackOtherState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_OtherStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackOtherState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! areStatesInitialized allocated yes/no
IF ( ALLOCATED(InData%areStatesInitialized) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! areStatesInitialized upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%areStatesInitialized) ! areStatesInitialized
END IF
Re_BufSz = Re_BufSz + 1 ! tau1
Re_BufSz = Re_BufSz + 1 ! tau2
Int_BufSz = Int_BufSz + 1 ! n allocated yes/no
IF ( ALLOCATED(InData%n) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! n upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%n) ! n
END IF
! Allocate buffers for subtypes, if any (we'll get sizes from these)
DO i1 = LBOUND(InData%xdot,1), UBOUND(InData%xdot,1)
Int_BufSz = Int_BufSz + 3 ! xdot: size of buffers for each call to pack subtype
CALL DBEMT_PackContState( Re_Buf, Db_Buf, Int_Buf, InData%xdot(i1), ErrStat2, ErrMsg2, .TRUE. ) ! xdot
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! xdot
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! xdot
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! xdot
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
END DO
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%areStatesInitialized) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%areStatesInitialized,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%areStatesInitialized,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%areStatesInitialized,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%areStatesInitialized,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%areStatesInitialized,2), UBOUND(InData%areStatesInitialized,2)
DO i1 = LBOUND(InData%areStatesInitialized,1), UBOUND(InData%areStatesInitialized,1)
IntKiBuf(Int_Xferred) = TRANSFER(InData%areStatesInitialized(i1,i2), IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
ReKiBuf(Re_Xferred) = InData%tau1
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%tau2
Re_Xferred = Re_Xferred + 1
IF ( .NOT. ALLOCATED(InData%n) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%n,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%n,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%n,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%n,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%n,2), UBOUND(InData%n,2)
DO i1 = LBOUND(InData%n,1), UBOUND(InData%n,1)
IntKiBuf(Int_Xferred) = InData%n(i1,i2)
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
DO i1 = LBOUND(InData%xdot,1), UBOUND(InData%xdot,1)
CALL DBEMT_PackContState( Re_Buf, Db_Buf, Int_Buf, InData%xdot(i1), ErrStat2, ErrMsg2, OnlySize ) ! xdot
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END DO
END SUBROUTINE DBEMT_PackOtherState
SUBROUTINE DBEMT_UnPackOtherState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_OtherStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackOtherState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! areStatesInitialized not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%areStatesInitialized)) DEALLOCATE(OutData%areStatesInitialized)
ALLOCATE(OutData%areStatesInitialized(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%areStatesInitialized.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%areStatesInitialized,2), UBOUND(OutData%areStatesInitialized,2)
DO i1 = LBOUND(OutData%areStatesInitialized,1), UBOUND(OutData%areStatesInitialized,1)
OutData%areStatesInitialized(i1,i2) = TRANSFER(IntKiBuf(Int_Xferred), OutData%areStatesInitialized(i1,i2))
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
OutData%tau1 = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%tau2 = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! n not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%n)) DEALLOCATE(OutData%n)
ALLOCATE(OutData%n(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%n.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%n,2), UBOUND(OutData%n,2)
DO i1 = LBOUND(OutData%n,1), UBOUND(OutData%n,1)
OutData%n(i1,i2) = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
i1_l = LBOUND(OutData%xdot,1)
i1_u = UBOUND(OutData%xdot,1)
DO i1 = LBOUND(OutData%xdot,1), UBOUND(OutData%xdot,1)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL DBEMT_UnpackContState( Re_Buf, Db_Buf, Int_Buf, OutData%xdot(i1), ErrStat2, ErrMsg2 ) ! xdot
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END DO
END SUBROUTINE DBEMT_UnPackOtherState
SUBROUTINE DBEMT_CopyMisc( SrcMiscData, DstMiscData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_MiscVarType), INTENT(IN) :: SrcMiscData
TYPE(DBEMT_MiscVarType), INTENT(INOUT) :: DstMiscData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyMisc'
!
ErrStat = ErrID_None
ErrMsg = ""
DstMiscData%FirstWarn_tau1 = SrcMiscData%FirstWarn_tau1
END SUBROUTINE DBEMT_CopyMisc
SUBROUTINE DBEMT_DestroyMisc( MiscData, ErrStat, ErrMsg )
TYPE(DBEMT_MiscVarType), INTENT(INOUT) :: MiscData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyMisc'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE DBEMT_DestroyMisc
SUBROUTINE DBEMT_PackMisc( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_MiscVarType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackMisc'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! FirstWarn_tau1
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%FirstWarn_tau1, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END SUBROUTINE DBEMT_PackMisc
SUBROUTINE DBEMT_UnPackMisc( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_MiscVarType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackMisc'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%FirstWarn_tau1 = TRANSFER(IntKiBuf(Int_Xferred), OutData%FirstWarn_tau1)
Int_Xferred = Int_Xferred + 1
END SUBROUTINE DBEMT_UnPackMisc
SUBROUTINE DBEMT_CopyParam( SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_ParameterType), INTENT(IN) :: SrcParamData
TYPE(DBEMT_ParameterType), INTENT(INOUT) :: DstParamData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyParam'
!
ErrStat = ErrID_None
ErrMsg = ""
DstParamData%DT = SrcParamData%DT
DstParamData%lin_nx = SrcParamData%lin_nx
DstParamData%NumBlades = SrcParamData%NumBlades
DstParamData%NumNodes = SrcParamData%NumNodes
DstParamData%k_0ye = SrcParamData%k_0ye
DstParamData%tau1_const = SrcParamData%tau1_const
IF (ALLOCATED(SrcParamData%spanRatio)) THEN
i1_l = LBOUND(SrcParamData%spanRatio,1)
i1_u = UBOUND(SrcParamData%spanRatio,1)
i2_l = LBOUND(SrcParamData%spanRatio,2)
i2_u = UBOUND(SrcParamData%spanRatio,2)
IF (.NOT. ALLOCATED(DstParamData%spanRatio)) THEN
ALLOCATE(DstParamData%spanRatio(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%spanRatio.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstParamData%spanRatio = SrcParamData%spanRatio
ENDIF
DstParamData%DBEMT_Mod = SrcParamData%DBEMT_Mod
END SUBROUTINE DBEMT_CopyParam
SUBROUTINE DBEMT_DestroyParam( ParamData, ErrStat, ErrMsg )
TYPE(DBEMT_ParameterType), INTENT(INOUT) :: ParamData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyParam'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(ParamData%spanRatio)) THEN
DEALLOCATE(ParamData%spanRatio)
ENDIF
END SUBROUTINE DBEMT_DestroyParam
SUBROUTINE DBEMT_PackParam( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_ParameterType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackParam'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Db_BufSz = Db_BufSz + 1 ! DT
Int_BufSz = Int_BufSz + 1 ! lin_nx
Int_BufSz = Int_BufSz + 1 ! NumBlades
Int_BufSz = Int_BufSz + 1 ! NumNodes
Re_BufSz = Re_BufSz + 1 ! k_0ye
Re_BufSz = Re_BufSz + 1 ! tau1_const
Int_BufSz = Int_BufSz + 1 ! spanRatio allocated yes/no
IF ( ALLOCATED(InData%spanRatio) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! spanRatio upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%spanRatio) ! spanRatio
END IF
Int_BufSz = Int_BufSz + 1 ! DBEMT_Mod
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DbKiBuf(Db_Xferred) = InData%DT
Db_Xferred = Db_Xferred + 1
IntKiBuf(Int_Xferred) = InData%lin_nx
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumBlades
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumNodes
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%k_0ye
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%tau1_const
Re_Xferred = Re_Xferred + 1
IF ( .NOT. ALLOCATED(InData%spanRatio) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%spanRatio,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%spanRatio,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%spanRatio,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%spanRatio,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%spanRatio,2), UBOUND(InData%spanRatio,2)
DO i1 = LBOUND(InData%spanRatio,1), UBOUND(InData%spanRatio,1)
ReKiBuf(Re_Xferred) = InData%spanRatio(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
IntKiBuf(Int_Xferred) = InData%DBEMT_Mod
Int_Xferred = Int_Xferred + 1
END SUBROUTINE DBEMT_PackParam
SUBROUTINE DBEMT_UnPackParam( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_ParameterType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackParam'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DT = DbKiBuf(Db_Xferred)
Db_Xferred = Db_Xferred + 1
OutData%lin_nx = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%NumBlades = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%NumNodes = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%k_0ye = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%tau1_const = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! spanRatio not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%spanRatio)) DEALLOCATE(OutData%spanRatio)
ALLOCATE(OutData%spanRatio(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%spanRatio.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%spanRatio,2), UBOUND(OutData%spanRatio,2)
DO i1 = LBOUND(OutData%spanRatio,1), UBOUND(OutData%spanRatio,1)
OutData%spanRatio(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
OutData%DBEMT_Mod = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
END SUBROUTINE DBEMT_UnPackParam
SUBROUTINE DBEMT_CopyElementInputType( SrcElementInputTypeData, DstElementInputTypeData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_ElementInputType), INTENT(IN) :: SrcElementInputTypeData
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: DstElementInputTypeData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyElementInputType'
!
ErrStat = ErrID_None
ErrMsg = ""
DstElementInputTypeData%vind_s = SrcElementInputTypeData%vind_s
DstElementInputTypeData%vind_s_dot = SrcElementInputTypeData%vind_s_dot
DstElementInputTypeData%spanRatio = SrcElementInputTypeData%spanRatio
END SUBROUTINE DBEMT_CopyElementInputType
SUBROUTINE DBEMT_DestroyElementInputType( ElementInputTypeData, ErrStat, ErrMsg )
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: ElementInputTypeData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyElementInputType'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE DBEMT_DestroyElementInputType
SUBROUTINE DBEMT_PackElementInputType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_ElementInputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackElementInputType'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + SIZE(InData%vind_s) ! vind_s
Re_BufSz = Re_BufSz + SIZE(InData%vind_s_dot) ! vind_s_dot
Re_BufSz = Re_BufSz + 1 ! spanRatio
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO i1 = LBOUND(InData%vind_s,1), UBOUND(InData%vind_s,1)
ReKiBuf(Re_Xferred) = InData%vind_s(i1)
Re_Xferred = Re_Xferred + 1
END DO
DO i1 = LBOUND(InData%vind_s_dot,1), UBOUND(InData%vind_s_dot,1)
ReKiBuf(Re_Xferred) = InData%vind_s_dot(i1)
Re_Xferred = Re_Xferred + 1
END DO
ReKiBuf(Re_Xferred) = InData%spanRatio
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_PackElementInputType
SUBROUTINE DBEMT_UnPackElementInputType( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackElementInputType'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
i1_l = LBOUND(OutData%vind_s,1)
i1_u = UBOUND(OutData%vind_s,1)
DO i1 = LBOUND(OutData%vind_s,1), UBOUND(OutData%vind_s,1)
OutData%vind_s(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
i1_l = LBOUND(OutData%vind_s_dot,1)
i1_u = UBOUND(OutData%vind_s_dot,1)
DO i1 = LBOUND(OutData%vind_s_dot,1), UBOUND(OutData%vind_s_dot,1)
OutData%vind_s_dot(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%spanRatio = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE DBEMT_UnPackElementInputType
SUBROUTINE DBEMT_CopyInput( SrcInputData, DstInputData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_InputType), INTENT(IN) :: SrcInputData
TYPE(DBEMT_InputType), INTENT(INOUT) :: DstInputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyInput'
!
ErrStat = ErrID_None
ErrMsg = ""
DstInputData%AxInd_disk = SrcInputData%AxInd_disk
DstInputData%Un_disk = SrcInputData%Un_disk
DstInputData%R_disk = SrcInputData%R_disk
IF (ALLOCATED(SrcInputData%element)) THEN
i1_l = LBOUND(SrcInputData%element,1)
i1_u = UBOUND(SrcInputData%element,1)
i2_l = LBOUND(SrcInputData%element,2)
i2_u = UBOUND(SrcInputData%element,2)
IF (.NOT. ALLOCATED(DstInputData%element)) THEN
ALLOCATE(DstInputData%element(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputData%element.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DO i2 = LBOUND(SrcInputData%element,2), UBOUND(SrcInputData%element,2)
DO i1 = LBOUND(SrcInputData%element,1), UBOUND(SrcInputData%element,1)
CALL DBEMT_Copyelementinputtype( SrcInputData%element(i1,i2), DstInputData%element(i1,i2), CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
ENDDO
ENDDO
ENDIF
END SUBROUTINE DBEMT_CopyInput
SUBROUTINE DBEMT_DestroyInput( InputData, ErrStat, ErrMsg )
TYPE(DBEMT_InputType), INTENT(INOUT) :: InputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyInput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(InputData%element)) THEN
DO i2 = LBOUND(InputData%element,2), UBOUND(InputData%element,2)
DO i1 = LBOUND(InputData%element,1), UBOUND(InputData%element,1)
CALL DBEMT_Destroyelementinputtype( InputData%element(i1,i2), ErrStat, ErrMsg )
ENDDO
ENDDO
DEALLOCATE(InputData%element)
ENDIF
END SUBROUTINE DBEMT_DestroyInput
SUBROUTINE DBEMT_PackInput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_InputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackInput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! AxInd_disk
Re_BufSz = Re_BufSz + 1 ! Un_disk
Re_BufSz = Re_BufSz + 1 ! R_disk
Int_BufSz = Int_BufSz + 1 ! element allocated yes/no
IF ( ALLOCATED(InData%element) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! element upper/lower bounds for each dimension
! Allocate buffers for subtypes, if any (we'll get sizes from these)
DO i2 = LBOUND(InData%element,2), UBOUND(InData%element,2)
DO i1 = LBOUND(InData%element,1), UBOUND(InData%element,1)
Int_BufSz = Int_BufSz + 3 ! element: size of buffers for each call to pack subtype
CALL DBEMT_Packelementinputtype( Re_Buf, Db_Buf, Int_Buf, InData%element(i1,i2), ErrStat2, ErrMsg2, .TRUE. ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! element
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! element
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! element
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
END DO
END DO
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%AxInd_disk
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%Un_disk
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%R_disk
Re_Xferred = Re_Xferred + 1
IF ( .NOT. ALLOCATED(InData%element) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%element,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%element,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%element,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%element,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%element,2), UBOUND(InData%element,2)
DO i1 = LBOUND(InData%element,1), UBOUND(InData%element,1)
CALL DBEMT_Packelementinputtype( Re_Buf, Db_Buf, Int_Buf, InData%element(i1,i2), ErrStat2, ErrMsg2, OnlySize ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END DO
END DO
END IF
END SUBROUTINE DBEMT_PackInput
SUBROUTINE DBEMT_UnPackInput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_InputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackInput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%AxInd_disk = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%Un_disk = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%R_disk = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! element not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%element)) DEALLOCATE(OutData%element)
ALLOCATE(OutData%element(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%element.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%element,2), UBOUND(OutData%element,2)
DO i1 = LBOUND(OutData%element,1), UBOUND(OutData%element,1)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL DBEMT_Unpackelementinputtype( Re_Buf, Db_Buf, Int_Buf, OutData%element(i1,i2), ErrStat2, ErrMsg2 ) ! element
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END DO
END DO
END IF
END SUBROUTINE DBEMT_UnPackInput
SUBROUTINE DBEMT_CopyOutput( SrcOutputData, DstOutputData, CtrlCode, ErrStat, ErrMsg )
TYPE(DBEMT_OutputType), INTENT(IN) :: SrcOutputData
TYPE(DBEMT_OutputType), INTENT(INOUT) :: DstOutputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: i3, i3_l, i3_u ! bounds (upper/lower) for an array dimension 3
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_CopyOutput'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcOutputData%vind)) THEN
i1_l = LBOUND(SrcOutputData%vind,1)
i1_u = UBOUND(SrcOutputData%vind,1)
i2_l = LBOUND(SrcOutputData%vind,2)
i2_u = UBOUND(SrcOutputData%vind,2)
i3_l = LBOUND(SrcOutputData%vind,3)
i3_u = UBOUND(SrcOutputData%vind,3)
IF (.NOT. ALLOCATED(DstOutputData%vind)) THEN
ALLOCATE(DstOutputData%vind(i1_l:i1_u,i2_l:i2_u,i3_l:i3_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstOutputData%vind.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstOutputData%vind = SrcOutputData%vind
ENDIF
END SUBROUTINE DBEMT_CopyOutput
SUBROUTINE DBEMT_DestroyOutput( OutputData, ErrStat, ErrMsg )
TYPE(DBEMT_OutputType), INTENT(INOUT) :: OutputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_DestroyOutput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(OutputData%vind)) THEN
DEALLOCATE(OutputData%vind)
ENDIF
END SUBROUTINE DBEMT_DestroyOutput
SUBROUTINE DBEMT_PackOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(DBEMT_OutputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_PackOutput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! vind allocated yes/no
IF ( ALLOCATED(InData%vind) ) THEN
Int_BufSz = Int_BufSz + 2*3 ! vind upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%vind) ! vind
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%vind) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%vind,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%vind,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%vind,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%vind,2)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%vind,3)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%vind,3)
Int_Xferred = Int_Xferred + 2
DO i3 = LBOUND(InData%vind,3), UBOUND(InData%vind,3)
DO i2 = LBOUND(InData%vind,2), UBOUND(InData%vind,2)
DO i1 = LBOUND(InData%vind,1), UBOUND(InData%vind,1)
ReKiBuf(Re_Xferred) = InData%vind(i1,i2,i3)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END DO
END IF
END SUBROUTINE DBEMT_PackOutput
SUBROUTINE DBEMT_UnPackOutput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(DBEMT_OutputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: i3, i3_l, i3_u ! bounds (upper/lower) for an array dimension 3
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_UnPackOutput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! vind not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i3_l = IntKiBuf( Int_Xferred )
i3_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%vind)) DEALLOCATE(OutData%vind)
ALLOCATE(OutData%vind(i1_l:i1_u,i2_l:i2_u,i3_l:i3_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%vind.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i3 = LBOUND(OutData%vind,3), UBOUND(OutData%vind,3)
DO i2 = LBOUND(OutData%vind,2), UBOUND(OutData%vind,2)
DO i1 = LBOUND(OutData%vind,1), UBOUND(OutData%vind,1)
OutData%vind(i1,i2,i3) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END DO
END IF
END SUBROUTINE DBEMT_UnPackOutput
SUBROUTINE DBEMT_ElementInputType_ExtrapInterp(u, t, u_out, t_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) ElementInputType u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is given by the size of u
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3 (as appropriate)
!
!..................................................................................................................................
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u(:) ! ElementInputType at t1 > t2 > t3
REAL(DbKi), INTENT(IN ) :: t(:) ! Times associated with the ElementInputTypes
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: u_out ! ElementInputType at tin_out
REAL(DbKi), INTENT(IN ) :: t_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_ElementInputType_ExtrapInterp'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
if ( size(t) .ne. size(u)) then
CALL SetErrStat(ErrID_Fatal,'size(t) must equal size(u)',ErrStat,ErrMsg,RoutineName)
RETURN
endif
order = SIZE(u) - 1
IF ( order .eq. 0 ) THEN
CALL DBEMT_CopyElementInputType(u(1), u_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 1 ) THEN
CALL DBEMT_ElementInputType_ExtrapInterp1(u(1), u(2), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 2 ) THEN
CALL DBEMT_ElementInputType_ExtrapInterp2(u(1), u(2), u(3), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE
CALL SetErrStat(ErrID_Fatal,'size(u) must be less than 4 (order must be less than 3).',ErrStat,ErrMsg,RoutineName)
RETURN
ENDIF
END SUBROUTINE DBEMT_ElementInputType_ExtrapInterp
SUBROUTINE DBEMT_ElementInputType_ExtrapInterp1(u1, u2, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) ElementInputType u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = u1, f(t2) = u2
!
!..................................................................................................................................
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u1 ! ElementInputType at t1 > t2
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u2 ! ElementInputType at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the ElementInputTypes
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: u_out ! ElementInputType at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the ElementInputTypes
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_ElementInputType_ExtrapInterp1'
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / t(2)
DO i1 = LBOUND(u_out%vind_s,1),UBOUND(u_out%vind_s,1)
b = -(u1%vind_s(i1) - u2%vind_s(i1))
u_out%vind_s(i1) = u1%vind_s(i1) + b * ScaleFactor
END DO
DO i1 = LBOUND(u_out%vind_s_dot,1),UBOUND(u_out%vind_s_dot,1)
b = -(u1%vind_s_dot(i1) - u2%vind_s_dot(i1))
u_out%vind_s_dot(i1) = u1%vind_s_dot(i1) + b * ScaleFactor
END DO
b = -(u1%spanRatio - u2%spanRatio)
u_out%spanRatio = u1%spanRatio + b * ScaleFactor
END SUBROUTINE DBEMT_ElementInputType_ExtrapInterp1
SUBROUTINE DBEMT_ElementInputType_ExtrapInterp2(u1, u2, u3, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) ElementInputType u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3
!
!..................................................................................................................................
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u1 ! ElementInputType at t1 > t2 > t3
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u2 ! ElementInputType at t2 > t3
TYPE(DBEMT_ElementInputType), INTENT(IN) :: u3 ! ElementInputType at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the ElementInputTypes
TYPE(DBEMT_ElementInputType), INTENT(INOUT) :: u_out ! ElementInputType at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the ElementInputTypes
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: c ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_ElementInputType_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / (t(2) * t(3) * (t(2) - t(3)))
DO i1 = LBOUND(u_out%vind_s,1),UBOUND(u_out%vind_s,1)
b = (t(3)**2*(u1%vind_s(i1) - u2%vind_s(i1)) + t(2)**2*(-u1%vind_s(i1) + u3%vind_s(i1)))* scaleFactor
c = ( (t(2)-t(3))*u1%vind_s(i1) + t(3)*u2%vind_s(i1) - t(2)*u3%vind_s(i1) ) * scaleFactor
u_out%vind_s(i1) = u1%vind_s(i1) + b + c * t_out
END DO
DO i1 = LBOUND(u_out%vind_s_dot,1),UBOUND(u_out%vind_s_dot,1)
b = (t(3)**2*(u1%vind_s_dot(i1) - u2%vind_s_dot(i1)) + t(2)**2*(-u1%vind_s_dot(i1) + u3%vind_s_dot(i1)))* scaleFactor
c = ( (t(2)-t(3))*u1%vind_s_dot(i1) + t(3)*u2%vind_s_dot(i1) - t(2)*u3%vind_s_dot(i1) ) * scaleFactor
u_out%vind_s_dot(i1) = u1%vind_s_dot(i1) + b + c * t_out
END DO
b = (t(3)**2*(u1%spanRatio - u2%spanRatio) + t(2)**2*(-u1%spanRatio + u3%spanRatio))* scaleFactor
c = ( (t(2)-t(3))*u1%spanRatio + t(3)*u2%spanRatio - t(2)*u3%spanRatio ) * scaleFactor
u_out%spanRatio = u1%spanRatio + b + c * t_out
END SUBROUTINE DBEMT_ElementInputType_ExtrapInterp2
SUBROUTINE DBEMT_Input_ExtrapInterp(u, t, u_out, t_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is given by the size of u
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3 (as appropriate)
!
!..................................................................................................................................
TYPE(DBEMT_InputType), INTENT(IN) :: u(:) ! Input at t1 > t2 > t3
REAL(DbKi), INTENT(IN ) :: t(:) ! Times associated with the Inputs
TYPE(DBEMT_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: t_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Input_ExtrapInterp'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
if ( size(t) .ne. size(u)) then
CALL SetErrStat(ErrID_Fatal,'size(t) must equal size(u)',ErrStat,ErrMsg,RoutineName)
RETURN
endif
order = SIZE(u) - 1
IF ( order .eq. 0 ) THEN
CALL DBEMT_CopyInput(u(1), u_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 1 ) THEN
CALL DBEMT_Input_ExtrapInterp1(u(1), u(2), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 2 ) THEN
CALL DBEMT_Input_ExtrapInterp2(u(1), u(2), u(3), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE
CALL SetErrStat(ErrID_Fatal,'size(u) must be less than 4 (order must be less than 3).',ErrStat,ErrMsg,RoutineName)
RETURN
ENDIF
END SUBROUTINE DBEMT_Input_ExtrapInterp
SUBROUTINE DBEMT_Input_ExtrapInterp1(u1, u2, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = u1, f(t2) = u2
!
!..................................................................................................................................
TYPE(DBEMT_InputType), INTENT(IN) :: u1 ! Input at t1 > t2
TYPE(DBEMT_InputType), INTENT(IN) :: u2 ! Input at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Inputs
TYPE(DBEMT_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Input_ExtrapInterp1'
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / t(2)
b = -(u1%AxInd_disk - u2%AxInd_disk)
u_out%AxInd_disk = u1%AxInd_disk + b * ScaleFactor
b = -(u1%Un_disk - u2%Un_disk)
u_out%Un_disk = u1%Un_disk + b * ScaleFactor
b = -(u1%R_disk - u2%R_disk)
u_out%R_disk = u1%R_disk + b * ScaleFactor
IF (ALLOCATED(u_out%element) .AND. ALLOCATED(u1%element)) THEN
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
DO i1 = LBOUND(u_out%element(i01,i02)%vind_s,1),UBOUND(u_out%element(i01,i02)%vind_s,1)
b = -(u1%element(i01,i02)%vind_s(i1) - u2%element(i01,i02)%vind_s(i1))
u_out%element(i01,i02)%vind_s(i1) = u1%element(i01,i02)%vind_s(i1) + b * ScaleFactor
END DO
ENDDO
ENDDO
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
DO i1 = LBOUND(u_out%element(i01,i02)%vind_s_dot,1),UBOUND(u_out%element(i01,i02)%vind_s_dot,1)
b = -(u1%element(i01,i02)%vind_s_dot(i1) - u2%element(i01,i02)%vind_s_dot(i1))
u_out%element(i01,i02)%vind_s_dot(i1) = u1%element(i01,i02)%vind_s_dot(i1) + b * ScaleFactor
END DO
ENDDO
ENDDO
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
b = -(u1%element(i01,i02)%spanRatio - u2%element(i01,i02)%spanRatio)
u_out%element(i01,i02)%spanRatio = u1%element(i01,i02)%spanRatio + b * ScaleFactor
ENDDO
ENDDO
END IF ! check if allocated
END SUBROUTINE DBEMT_Input_ExtrapInterp1
SUBROUTINE DBEMT_Input_ExtrapInterp2(u1, u2, u3, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3
!
!..................................................................................................................................
TYPE(DBEMT_InputType), INTENT(IN) :: u1 ! Input at t1 > t2 > t3
TYPE(DBEMT_InputType), INTENT(IN) :: u2 ! Input at t2 > t3
TYPE(DBEMT_InputType), INTENT(IN) :: u3 ! Input at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Inputs
TYPE(DBEMT_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: c ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Input_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / (t(2) * t(3) * (t(2) - t(3)))
b = (t(3)**2*(u1%AxInd_disk - u2%AxInd_disk) + t(2)**2*(-u1%AxInd_disk + u3%AxInd_disk))* scaleFactor
c = ( (t(2)-t(3))*u1%AxInd_disk + t(3)*u2%AxInd_disk - t(2)*u3%AxInd_disk ) * scaleFactor
u_out%AxInd_disk = u1%AxInd_disk + b + c * t_out
b = (t(3)**2*(u1%Un_disk - u2%Un_disk) + t(2)**2*(-u1%Un_disk + u3%Un_disk))* scaleFactor
c = ( (t(2)-t(3))*u1%Un_disk + t(3)*u2%Un_disk - t(2)*u3%Un_disk ) * scaleFactor
u_out%Un_disk = u1%Un_disk + b + c * t_out
b = (t(3)**2*(u1%R_disk - u2%R_disk) + t(2)**2*(-u1%R_disk + u3%R_disk))* scaleFactor
c = ( (t(2)-t(3))*u1%R_disk + t(3)*u2%R_disk - t(2)*u3%R_disk ) * scaleFactor
u_out%R_disk = u1%R_disk + b + c * t_out
IF (ALLOCATED(u_out%element) .AND. ALLOCATED(u1%element)) THEN
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
DO i1 = LBOUND(u_out%element(i01,i02)%vind_s,1),UBOUND(u_out%element(i01,i02)%vind_s,1)
b = (t(3)**2*(u1%element(i01,i02)%vind_s(i1) - u2%element(i01,i02)%vind_s(i1)) + t(2)**2*(-u1%element(i01,i02)%vind_s(i1) + u3%element(i01,i02)%vind_s(i1)))* scaleFactor
c = ( (t(2)-t(3))*u1%element(i01,i02)%vind_s(i1) + t(3)*u2%element(i01,i02)%vind_s(i1) - t(2)*u3%element(i01,i02)%vind_s(i1) ) * scaleFactor
u_out%element(i01,i02)%vind_s(i1) = u1%element(i01,i02)%vind_s(i1) + b + c * t_out
END DO
ENDDO
ENDDO
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
DO i1 = LBOUND(u_out%element(i01,i02)%vind_s_dot,1),UBOUND(u_out%element(i01,i02)%vind_s_dot,1)
b = (t(3)**2*(u1%element(i01,i02)%vind_s_dot(i1) - u2%element(i01,i02)%vind_s_dot(i1)) + t(2)**2*(-u1%element(i01,i02)%vind_s_dot(i1) + u3%element(i01,i02)%vind_s_dot(i1)))* scaleFactor
c = ( (t(2)-t(3))*u1%element(i01,i02)%vind_s_dot(i1) + t(3)*u2%element(i01,i02)%vind_s_dot(i1) - t(2)*u3%element(i01,i02)%vind_s_dot(i1) ) * scaleFactor
u_out%element(i01,i02)%vind_s_dot(i1) = u1%element(i01,i02)%vind_s_dot(i1) + b + c * t_out
END DO
ENDDO
ENDDO
DO i02 = LBOUND(u_out%element,2),UBOUND(u_out%element,2)
DO i01 = LBOUND(u_out%element,1),UBOUND(u_out%element,1)
b = (t(3)**2*(u1%element(i01,i02)%spanRatio - u2%element(i01,i02)%spanRatio) + t(2)**2*(-u1%element(i01,i02)%spanRatio + u3%element(i01,i02)%spanRatio))* scaleFactor
c = ( (t(2)-t(3))*u1%element(i01,i02)%spanRatio + t(3)*u2%element(i01,i02)%spanRatio - t(2)*u3%element(i01,i02)%spanRatio ) * scaleFactor
u_out%element(i01,i02)%spanRatio = u1%element(i01,i02)%spanRatio + b + c * t_out
ENDDO
ENDDO
END IF ! check if allocated
END SUBROUTINE DBEMT_Input_ExtrapInterp2
SUBROUTINE DBEMT_Output_ExtrapInterp(y, t, y_out, t_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is given by the size of y
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3 (as appropriate)
!
!..................................................................................................................................
TYPE(DBEMT_OutputType), INTENT(IN) :: y(:) ! Output at t1 > t2 > t3
REAL(DbKi), INTENT(IN ) :: t(:) ! Times associated with the Outputs
TYPE(DBEMT_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: t_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Output_ExtrapInterp'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
if ( size(t) .ne. size(y)) then
CALL SetErrStat(ErrID_Fatal,'size(t) must equal size(y)',ErrStat,ErrMsg,RoutineName)
RETURN
endif
order = SIZE(y) - 1
IF ( order .eq. 0 ) THEN
CALL DBEMT_CopyOutput(y(1), y_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 1 ) THEN
CALL DBEMT_Output_ExtrapInterp1(y(1), y(2), t, y_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 2 ) THEN
CALL DBEMT_Output_ExtrapInterp2(y(1), y(2), y(3), t, y_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE
CALL SetErrStat(ErrID_Fatal,'size(y) must be less than 4 (order must be less than 3).',ErrStat,ErrMsg,RoutineName)
RETURN
ENDIF
END SUBROUTINE DBEMT_Output_ExtrapInterp
SUBROUTINE DBEMT_Output_ExtrapInterp1(y1, y2, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = y1, f(t2) = y2
!
!..................................................................................................................................
TYPE(DBEMT_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2
TYPE(DBEMT_OutputType), INTENT(IN) :: y2 ! Output at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Outputs
TYPE(DBEMT_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Output_ExtrapInterp1'
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i03 ! dim3 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
INTEGER :: i3 ! dim3 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / t(2)
IF (ALLOCATED(y_out%vind) .AND. ALLOCATED(y1%vind)) THEN
DO i3 = LBOUND(y_out%vind,3),UBOUND(y_out%vind,3)
DO i2 = LBOUND(y_out%vind,2),UBOUND(y_out%vind,2)
DO i1 = LBOUND(y_out%vind,1),UBOUND(y_out%vind,1)
b = -(y1%vind(i1,i2,i3) - y2%vind(i1,i2,i3))
y_out%vind(i1,i2,i3) = y1%vind(i1,i2,i3) + b * ScaleFactor
END DO
END DO
END DO
END IF ! check if allocated
END SUBROUTINE DBEMT_Output_ExtrapInterp1
SUBROUTINE DBEMT_Output_ExtrapInterp2(y1, y2, y3, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3
!
!..................................................................................................................................
TYPE(DBEMT_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2 > t3
TYPE(DBEMT_OutputType), INTENT(IN) :: y2 ! Output at t2 > t3
TYPE(DBEMT_OutputType), INTENT(IN) :: y3 ! Output at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Outputs
TYPE(DBEMT_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: c ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'DBEMT_Output_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i03 ! dim3 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
INTEGER :: i3 ! dim3 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / (t(2) * t(3) * (t(2) - t(3)))
IF (ALLOCATED(y_out%vind) .AND. ALLOCATED(y1%vind)) THEN
DO i3 = LBOUND(y_out%vind,3),UBOUND(y_out%vind,3)
DO i2 = LBOUND(y_out%vind,2),UBOUND(y_out%vind,2)
DO i1 = LBOUND(y_out%vind,1),UBOUND(y_out%vind,1)
b = (t(3)**2*(y1%vind(i1,i2,i3) - y2%vind(i1,i2,i3)) + t(2)**2*(-y1%vind(i1,i2,i3) + y3%vind(i1,i2,i3)))* scaleFactor
c = ( (t(2)-t(3))*y1%vind(i1,i2,i3) + t(3)*y2%vind(i1,i2,i3) - t(2)*y3%vind(i1,i2,i3) ) * scaleFactor
y_out%vind(i1,i2,i3) = y1%vind(i1,i2,i3) + b + c * t_out
END DO
END DO
END DO
END IF ! check if allocated
END SUBROUTINE DBEMT_Output_ExtrapInterp2
END MODULE DBEMT_Types
!ENDOFREGISTRYGENERATEDFILE
| apache-2.0 |
OpenFAST/OpenFAST | modules/inflowwind/src/InflowWind_Types.f90 | 1 | 263763 | !STARTOFREGISTRYGENERATEDFILE 'InflowWind_Types.f90'
!
! WARNING This file is generated automatically by the FAST registry.
! Do not edit. Your changes to this file will be lost.
!
! FAST Registry
!*********************************************************************************************************************************
! InflowWind_Types
!.................................................................................................................................
! This file is part of InflowWind.
!
! Copyright (C) 2012-2016 National Renewable Energy Laboratory
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
!
! W A R N I N G : This file was automatically generated from the FAST registry. Changes made to this file may be lost.
!
!*********************************************************************************************************************************
!> This module contains the user-defined types needed in InflowWind. It also contains copy, destroy, pack, and
!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry.
MODULE InflowWind_Types
!---------------------------------------------------------------------------------------------------------------------------------
USE IfW_UniformWind_Types
USE IfW_FFWind_Base_Types
USE IfW_TSFFWind_Types
USE IfW_BladedFFWind_Types
USE IfW_HAWCWind_Types
USE IfW_UserWind_Types
USE IfW_4Dext_Types
USE Lidar_Types
USE NWTC_Library
IMPLICIT NONE
INTEGER(IntKi), PUBLIC, PARAMETER :: Undef_WindNumber = 0 ! This is the code for an undefined WindFileType [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: Steady_WindNumber = 1 ! Steady wind. Calculated internally. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: Uniform_WindNumber = 2 ! Uniform wind. Formally known as a Hub-Height wind file. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: TSFF_WindNumber = 3 ! TurbSim full-field binary file. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: BladedFF_WindNumber = 4 ! Bladed style binary full-field file. Includes native bladed format [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: HAWC_WindNumber = 5 ! HAWC wind file. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: User_WindNumber = 6 ! User defined wind. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: BladedFF_Shr_WindNumber = 7 ! Native Bladed binary full-field file. [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: FDext_WindNumber = 8 ! 4D wind from external souce (i.e., FAST.Farm). [-]
INTEGER(IntKi), PUBLIC, PARAMETER :: Highest_WindNumber = 8 ! Highest wind number supported. [-]
! ========= WindFileMetaData =======
TYPE, PUBLIC :: WindFileMetaData
CHARACTER(1024) :: FileName !< Name of the windfile retrieved [-]
INTEGER(IntKi) :: WindType = 0 !< Type of the windfile [-]
REAL(ReKi) :: RefHt !< Reference height given in file [meters]
LOGICAL :: RefHt_Set !< Reference height was given in file [-]
REAL(DbKi) :: DT !< TimeStep of the wind file -- zero value for none [seconds]
INTEGER(IntKi) :: NumTSteps !< Number of timesteps in the time range of wind file [-]
LOGICAL :: ConstantDT !< Timesteps are the same throughout file [-]
REAL(ReKi) , DIMENSION(1:2) :: TRange !< Time range of the wind file [seconds]
LOGICAL :: TRange_Limited !< TRange limits strictly enforced [-]
REAL(ReKi) , DIMENSION(1:2) :: YRange !< Range in y direction [meters]
LOGICAL :: YRange_Limited !< YRange limits strictly enforced [-]
REAL(ReKi) , DIMENSION(1:2) :: ZRange !< Range in z direction [meters]
LOGICAL :: ZRange_Limited !< ZRange limits strictly enforced [-]
INTEGER(IntKi) :: BinaryFormat !< Binary format identifier [-]
LOGICAL :: IsBinary !< Windfile is a binary file [-]
REAL(ReKi) , DIMENSION(1:3) :: TI !< Turbulence intensity (U,V,W) [-]
LOGICAL :: TI_listed !< Turbulence intesity given in file [-]
REAL(ReKi) :: MWS !< Approximate mean wind speed [-]
END TYPE WindFileMetaData
! =======================
! ========= InflowWind_InputFile =======
TYPE, PUBLIC :: InflowWind_InputFile
LOGICAL :: EchoFlag !< Echo the input file [-]
INTEGER(IntKi) :: WindType = 0 !< Type of windfile [-]
REAL(ReKi) :: PropagationDir !< Direction of wind propagation (meteorological direction) [(degrees)]
REAL(ReKi) :: VFlowAngle !< Vertical (upflow) angle [degrees]
INTEGER(IntKi) :: NWindVel !< Number of points to output the wind velocity (0 to 9) [-]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: WindVxiList !< List of X coordinates for wind velocity measurements [meters]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: WindVyiList !< List of Y coordinates for wind velocity measurements [meters]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: WindVziList !< List of Z coordinates for wind velocity measurements [meters]
REAL(ReKi) :: Steady_HWindSpeed !< Steady wind -- horizontal windspeed [meters/s]
REAL(ReKi) :: Steady_RefHt !< Steady wind -- reference height [meters]
REAL(ReKi) :: Steady_PLexp !< Steady wind -- power law exponent [-]
CHARACTER(1024) :: Uniform_FileName !< Uniform wind -- filename [-]
REAL(ReKi) :: Uniform_RefHt !< Uniform wind -- reference height [meters]
REAL(ReKi) :: Uniform_RefLength !< Uniform wind -- reference length [meters]
CHARACTER(1024) :: TSFF_FileName !< TurbSim Full-Field -- filename [-]
CHARACTER(1024) :: BladedFF_FileName !< Bladed-style Full-Field -- filename [-]
LOGICAL :: BladedFF_TowerFile !< Bladed-style Full-Field -- tower file exists [-]
LOGICAL :: CTTS_CoherentTurb = .FALSE. !< Coherent turbulence data exists [-]
CHARACTER(1024) :: CTTS_FileName !< Name of coherent turbulence file [-]
CHARACTER(1024) :: CTTS_Path !< Path to coherent turbulence binary data files [-]
CHARACTER(1024) :: HAWC_FileName_u !< HAWC -- u component binary data file name [-]
CHARACTER(1024) :: HAWC_FileName_v !< HAWC -- v component binary data file name [-]
CHARACTER(1024) :: HAWC_FileName_w !< HAWC -- w component binary data file name [-]
INTEGER(IntKi) :: HAWC_nx !< HAWC -- number of grids in x direction [-]
INTEGER(IntKi) :: HAWC_ny !< HAWC -- number of grids in y direction [-]
INTEGER(IntKi) :: HAWC_nz !< HAWC -- number of grids in z direction [-]
REAL(ReKi) :: HAWC_dx !< HAWC -- distance between points in x direction [meters]
REAL(ReKi) :: HAWC_dy !< HAWC -- distance between points in y direction [meters]
REAL(ReKi) :: HAWC_dz !< HAWC -- distance between points in z direction [meters]
LOGICAL :: SumPrint !< Write summary info to a file <ROOTNAME>.IfW.Sum [-]
INTEGER(IntKi) :: NumOuts !< Number of parameters in the output list (number of outputs requested) [-]
CHARACTER(ChanLen) , DIMENSION(:), ALLOCATABLE :: OutList !< List of user-requested output channels [-]
INTEGER(IntKi) :: SensorType = SensorType_None !< Sensor type (for lidar/sensor module) [-]
INTEGER(IntKi) :: NumPulseGate !< the number of range gates to return wind speeds at [-]
REAL(ReKi) , DIMENSION(1:3) :: RotorApexOffsetPos !< position of the lidar unit relative to the rotor apex of rotation [m]
LOGICAL :: LidRadialVel !< TRUE => return radial component, FALSE => return 'x' direction estimate [-]
TYPE(IfW_FFWind_InitInputType) :: FF !< scaling data [-]
END TYPE InflowWind_InputFile
! =======================
! ========= InflowWind_InitInputType =======
TYPE, PUBLIC :: InflowWind_InitInputType
CHARACTER(1024) :: InputFileName !< Name of the InflowWind input file to use [-]
LOGICAL :: Linearize = .FALSE. !< Flag that tells this module if the glue code wants to linearize. [-]
LOGICAL :: Use4Dext = .FALSE. !< Flag that tells this module if an external module will pass it 4-D velocity grids. [-]
INTEGER(IntKi) :: NumWindPoints !< Number of wind velocity points expected [-]
LOGICAL :: UseInputFile = .TRUE. !< Should we read everthing from an input file, or do we get it some other way [-]
CHARACTER(1024) :: RootName !< RootName for writing output files [-]
TYPE(FileInfoType) :: PassedFileData !< If we don't use the input file, pass everything through this [-]
LOGICAL :: WindType2UseInputFile = .TRUE. !< Flag for toggling file based IO in wind type 2. [-]
TYPE(FileInfoType) :: WindType2Data !< Optional slot for wind type 2 data if file IO is not used. [-]
TYPE(Lidar_InitInputType) :: lidar !< InitInput for lidar data [-]
TYPE(IfW_4Dext_InitInputType) :: FDext !< InitInput for lidar data [-]
END TYPE InflowWind_InitInputType
! =======================
! ========= InflowWind_InitOutputType =======
TYPE, PUBLIC :: InflowWind_InitOutputType
CHARACTER(ChanLen) , DIMENSION(:), ALLOCATABLE :: WriteOutputHdr !< Names of output-to-file channels [-]
CHARACTER(ChanLen) , DIMENSION(:), ALLOCATABLE :: WriteOutputUnt !< Units of output-to-file channels [-]
TYPE(ProgDesc) :: Ver !< Version information of InflowWind module [-]
TYPE(WindFileMetaData) :: WindFileInfo !< Meta data from the wind file [-]
CHARACTER(LinChanLen) , DIMENSION(:), ALLOCATABLE :: LinNames_y !< Names of the outputs used in linearization [-]
CHARACTER(LinChanLen) , DIMENSION(:), ALLOCATABLE :: LinNames_u !< Names of the inputs used in linearization [-]
LOGICAL , DIMENSION(:), ALLOCATABLE :: RotFrame_y !< Flag that tells FAST/MBC3 if the outputs used in linearization are in the rotating frame [-]
LOGICAL , DIMENSION(:), ALLOCATABLE :: RotFrame_u !< Flag that tells FAST/MBC3 if the inputs used in linearization are in the rotating frame [-]
LOGICAL , DIMENSION(:), ALLOCATABLE :: IsLoad_u !< Flag that tells FAST if the inputs used in linearization are loads (for preconditioning matrix) [-]
END TYPE InflowWind_InitOutputType
! =======================
! ========= InflowWind_MiscVarType =======
TYPE, PUBLIC :: InflowWind_MiscVarType
INTEGER(IntKi) :: TimeIndex = 0 !< An Index into the TData array [-]
TYPE(IfW_UniformWind_MiscVarType) :: UniformWind !< MiscVars from UniformWind [-]
TYPE(IfW_TSFFWind_MiscVarType) :: TSFFWind !< MiscVars from TSFFWind [-]
TYPE(IfW_HAWCWind_MiscVarType) :: HAWCWind !< MiscVars from HAWCWind [-]
TYPE(IfW_BladedFFWind_MiscVarType) :: BladedFFWind !< MiscVars from BladedFFWind [-]
TYPE(IfW_UserWind_MiscVarType) :: UserWind !< MiscVars from UserWind [-]
TYPE(IfW_4Dext_MiscVarType) :: FDext !< MiscVars from FDext [-]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: AllOuts !< An array holding the value of all of the calculated (not only selected) output channels [see OutListParameters.xlsx spreadsheet]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindViUVW !< List of UVW velocities for wind velocity measurements, 3xNWindVel. corresponds to ParamData%WindViXYZ [meters/second]
END TYPE InflowWind_MiscVarType
! =======================
! ========= InflowWind_ParameterType =======
TYPE, PUBLIC :: InflowWind_ParameterType
CHARACTER(1024) :: RootFileName !< Root of the InflowWind input filename [-]
LOGICAL :: CTTS_Flag = .FALSE. !< determines if coherent turbulence is used [-]
LOGICAL :: RotateWindBox = .FALSE. !< determines if wind will be rotated [-]
REAL(DbKi) :: DT !< Time step for cont. state integration & disc. state update [seconds]
REAL(ReKi) :: PropagationDir !< Direction of wind propagation [radians]
REAL(ReKi) :: VFlowAngle !< Vertical (upflow) angle [radians]
REAL(ReKi) , DIMENSION(1:3,1:3) :: RotToWind !< Rotation matrix for rotating from the global XYZ coordinate system to the wind coordinate system (wind along X') [-]
REAL(ReKi) , DIMENSION(1:3,1:3) :: RotFromWind !< Rotation matrix for rotating from the wind coordinate system (wind along X') back to the global XYZ coordinate system. Equal to TRANSPOSE(RotToWind) [-]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindViXYZprime !< List of XYZ coordinates for velocity measurements, translated to the wind coordinate system (prime coordinates). This equals MATMUL( RotToWind, ParamData%WindViXYZ ) [meters]
INTEGER(IntKi) :: WindType = 0 !< Type of wind -- set to Undef_Wind initially [-]
REAL(ReKi) :: ReferenceHeight !< Height of the wind turbine [meters]
REAL(ReKi) , DIMENSION(1:3) :: RefPosition !< Reference position (point where box is rotated) [meters]
INTEGER(IntKi) :: NWindVel !< Number of points in the wind velocity list [-]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindViXYZ !< List of XYZ coordinates for wind velocity measurements, 3xNWindVel [meters]
TYPE(IfW_UniformWind_ParameterType) :: UniformWind !< Parameters from UniformWind [-]
TYPE(IfW_TSFFWind_ParameterType) :: TSFFWind !< Parameters from TSFFWind -- TurbSim full-field format [-]
TYPE(IfW_BladedFFWind_ParameterType) :: BladedFFWind !< Parameters from BladedFFWind -- Bladed-style full-field format [-]
TYPE(IfW_HAWCWind_ParameterType) :: HAWCWind !< Parameters from HAWCWind [-]
TYPE(IfW_UserWind_ParameterType) :: UserWind !< Parameters from UserWind [-]
TYPE(IfW_4Dext_ParameterType) :: FDext !< Parameters from FDext [-]
INTEGER(IntKi) :: NumOuts = 0 !< Number of parameters in the output list (number of outputs requested) [-]
TYPE(OutParmType) , DIMENSION(:), ALLOCATABLE :: OutParam !< Names and units (and other characteristics) of all requested output parameters [-]
INTEGER(IntKi) , DIMENSION(:,:), ALLOCATABLE :: OutParamLinIndx !< Index into WriteOutput for WindViXYZ in linearization analysis [-]
TYPE(Lidar_ParameterType) :: lidar !< Lidar parameter data [-]
END TYPE InflowWind_ParameterType
! =======================
! ========= InflowWind_InputType =======
TYPE, PUBLIC :: InflowWind_InputType
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: PositionXYZ !< Array holding the input positions at a given timestep [meters]
TYPE(Lidar_InputType) :: lidar !< Lidar data [-]
END TYPE InflowWind_InputType
! =======================
! ========= InflowWind_OutputType =======
TYPE, PUBLIC :: InflowWind_OutputType
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: VelocityUVW !< Array holding the U,V,W velocity for a given timestep [meters/sec]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: WriteOutput !< Array with values to output to file [-]
REAL(ReKi) , DIMENSION(1:3) :: DiskVel !< Vector holding the U,V,W average velocity of the disk [meters/sec]
TYPE(Lidar_OutputType) :: lidar !< Lidar data [-]
END TYPE InflowWind_OutputType
! =======================
! ========= InflowWind_ContinuousStateType =======
TYPE, PUBLIC :: InflowWind_ContinuousStateType
REAL(ReKi) :: DummyContState !< Remove this variable if you have continuous states [-]
END TYPE InflowWind_ContinuousStateType
! =======================
! ========= InflowWind_DiscreteStateType =======
TYPE, PUBLIC :: InflowWind_DiscreteStateType
REAL(ReKi) :: DummyDiscState !< Remove this variable if you have discrete states [-]
END TYPE InflowWind_DiscreteStateType
! =======================
! ========= InflowWind_ConstraintStateType =======
TYPE, PUBLIC :: InflowWind_ConstraintStateType
REAL(ReKi) :: DummyConstrState !< Remove this variable if you have constraint states [-]
END TYPE InflowWind_ConstraintStateType
! =======================
! ========= InflowWind_OtherStateType =======
TYPE, PUBLIC :: InflowWind_OtherStateType
REAL(ReKi) :: DummyOtherState !< Remove this variable if you have other states [-]
END TYPE InflowWind_OtherStateType
! =======================
CONTAINS
SUBROUTINE InflowWind_CopyWindFileMetaData( SrcWindFileMetaDataData, DstWindFileMetaDataData, CtrlCode, ErrStat, ErrMsg )
TYPE(WindFileMetaData), INTENT(IN) :: SrcWindFileMetaDataData
TYPE(WindFileMetaData), INTENT(INOUT) :: DstWindFileMetaDataData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyWindFileMetaData'
!
ErrStat = ErrID_None
ErrMsg = ""
DstWindFileMetaDataData%FileName = SrcWindFileMetaDataData%FileName
DstWindFileMetaDataData%WindType = SrcWindFileMetaDataData%WindType
DstWindFileMetaDataData%RefHt = SrcWindFileMetaDataData%RefHt
DstWindFileMetaDataData%RefHt_Set = SrcWindFileMetaDataData%RefHt_Set
DstWindFileMetaDataData%DT = SrcWindFileMetaDataData%DT
DstWindFileMetaDataData%NumTSteps = SrcWindFileMetaDataData%NumTSteps
DstWindFileMetaDataData%ConstantDT = SrcWindFileMetaDataData%ConstantDT
DstWindFileMetaDataData%TRange = SrcWindFileMetaDataData%TRange
DstWindFileMetaDataData%TRange_Limited = SrcWindFileMetaDataData%TRange_Limited
DstWindFileMetaDataData%YRange = SrcWindFileMetaDataData%YRange
DstWindFileMetaDataData%YRange_Limited = SrcWindFileMetaDataData%YRange_Limited
DstWindFileMetaDataData%ZRange = SrcWindFileMetaDataData%ZRange
DstWindFileMetaDataData%ZRange_Limited = SrcWindFileMetaDataData%ZRange_Limited
DstWindFileMetaDataData%BinaryFormat = SrcWindFileMetaDataData%BinaryFormat
DstWindFileMetaDataData%IsBinary = SrcWindFileMetaDataData%IsBinary
DstWindFileMetaDataData%TI = SrcWindFileMetaDataData%TI
DstWindFileMetaDataData%TI_listed = SrcWindFileMetaDataData%TI_listed
DstWindFileMetaDataData%MWS = SrcWindFileMetaDataData%MWS
END SUBROUTINE InflowWind_CopyWindFileMetaData
SUBROUTINE InflowWind_DestroyWindFileMetaData( WindFileMetaDataData, ErrStat, ErrMsg )
TYPE(WindFileMetaData), INTENT(INOUT) :: WindFileMetaDataData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyWindFileMetaData'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE InflowWind_DestroyWindFileMetaData
SUBROUTINE InflowWind_PackWindFileMetaData( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(WindFileMetaData), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackWindFileMetaData'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1*LEN(InData%FileName) ! FileName
Int_BufSz = Int_BufSz + 1 ! WindType
Re_BufSz = Re_BufSz + 1 ! RefHt
Int_BufSz = Int_BufSz + 1 ! RefHt_Set
Db_BufSz = Db_BufSz + 1 ! DT
Int_BufSz = Int_BufSz + 1 ! NumTSteps
Int_BufSz = Int_BufSz + 1 ! ConstantDT
Re_BufSz = Re_BufSz + SIZE(InData%TRange) ! TRange
Int_BufSz = Int_BufSz + 1 ! TRange_Limited
Re_BufSz = Re_BufSz + SIZE(InData%YRange) ! YRange
Int_BufSz = Int_BufSz + 1 ! YRange_Limited
Re_BufSz = Re_BufSz + SIZE(InData%ZRange) ! ZRange
Int_BufSz = Int_BufSz + 1 ! ZRange_Limited
Int_BufSz = Int_BufSz + 1 ! BinaryFormat
Int_BufSz = Int_BufSz + 1 ! IsBinary
Re_BufSz = Re_BufSz + SIZE(InData%TI) ! TI
Int_BufSz = Int_BufSz + 1 ! TI_listed
Re_BufSz = Re_BufSz + 1 ! MWS
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(InData%FileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%FileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IntKiBuf(Int_Xferred) = InData%WindType
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%RefHt
Re_Xferred = Re_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%RefHt_Set, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DbKiBuf(Db_Xferred) = InData%DT
Db_Xferred = Db_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumTSteps
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%ConstantDT, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%TRange,1), UBOUND(InData%TRange,1)
ReKiBuf(Re_Xferred) = InData%TRange(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = TRANSFER(InData%TRange_Limited, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%YRange,1), UBOUND(InData%YRange,1)
ReKiBuf(Re_Xferred) = InData%YRange(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = TRANSFER(InData%YRange_Limited, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%ZRange,1), UBOUND(InData%ZRange,1)
ReKiBuf(Re_Xferred) = InData%ZRange(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = TRANSFER(InData%ZRange_Limited, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%BinaryFormat
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%IsBinary, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%TI,1), UBOUND(InData%TI,1)
ReKiBuf(Re_Xferred) = InData%TI(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = TRANSFER(InData%TI_listed, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%MWS
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_PackWindFileMetaData
SUBROUTINE InflowWind_UnPackWindFileMetaData( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(WindFileMetaData), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackWindFileMetaData'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(OutData%FileName)
OutData%FileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%WindType = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%RefHt = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%RefHt_Set = TRANSFER(IntKiBuf(Int_Xferred), OutData%RefHt_Set)
Int_Xferred = Int_Xferred + 1
OutData%DT = DbKiBuf(Db_Xferred)
Db_Xferred = Db_Xferred + 1
OutData%NumTSteps = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%ConstantDT = TRANSFER(IntKiBuf(Int_Xferred), OutData%ConstantDT)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%TRange,1)
i1_u = UBOUND(OutData%TRange,1)
DO i1 = LBOUND(OutData%TRange,1), UBOUND(OutData%TRange,1)
OutData%TRange(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%TRange_Limited = TRANSFER(IntKiBuf(Int_Xferred), OutData%TRange_Limited)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%YRange,1)
i1_u = UBOUND(OutData%YRange,1)
DO i1 = LBOUND(OutData%YRange,1), UBOUND(OutData%YRange,1)
OutData%YRange(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%YRange_Limited = TRANSFER(IntKiBuf(Int_Xferred), OutData%YRange_Limited)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%ZRange,1)
i1_u = UBOUND(OutData%ZRange,1)
DO i1 = LBOUND(OutData%ZRange,1), UBOUND(OutData%ZRange,1)
OutData%ZRange(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%ZRange_Limited = TRANSFER(IntKiBuf(Int_Xferred), OutData%ZRange_Limited)
Int_Xferred = Int_Xferred + 1
OutData%BinaryFormat = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%IsBinary = TRANSFER(IntKiBuf(Int_Xferred), OutData%IsBinary)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%TI,1)
i1_u = UBOUND(OutData%TI,1)
DO i1 = LBOUND(OutData%TI,1), UBOUND(OutData%TI,1)
OutData%TI(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%TI_listed = TRANSFER(IntKiBuf(Int_Xferred), OutData%TI_listed)
Int_Xferred = Int_Xferred + 1
OutData%MWS = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_UnPackWindFileMetaData
SUBROUTINE InflowWind_CopyInputFile( SrcInputFileData, DstInputFileData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_InputFile), INTENT(IN) :: SrcInputFileData
TYPE(InflowWind_InputFile), INTENT(INOUT) :: DstInputFileData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyInputFile'
!
ErrStat = ErrID_None
ErrMsg = ""
DstInputFileData%EchoFlag = SrcInputFileData%EchoFlag
DstInputFileData%WindType = SrcInputFileData%WindType
DstInputFileData%PropagationDir = SrcInputFileData%PropagationDir
DstInputFileData%VFlowAngle = SrcInputFileData%VFlowAngle
DstInputFileData%NWindVel = SrcInputFileData%NWindVel
IF (ALLOCATED(SrcInputFileData%WindVxiList)) THEN
i1_l = LBOUND(SrcInputFileData%WindVxiList,1)
i1_u = UBOUND(SrcInputFileData%WindVxiList,1)
IF (.NOT. ALLOCATED(DstInputFileData%WindVxiList)) THEN
ALLOCATE(DstInputFileData%WindVxiList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputFileData%WindVxiList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInputFileData%WindVxiList = SrcInputFileData%WindVxiList
ENDIF
IF (ALLOCATED(SrcInputFileData%WindVyiList)) THEN
i1_l = LBOUND(SrcInputFileData%WindVyiList,1)
i1_u = UBOUND(SrcInputFileData%WindVyiList,1)
IF (.NOT. ALLOCATED(DstInputFileData%WindVyiList)) THEN
ALLOCATE(DstInputFileData%WindVyiList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputFileData%WindVyiList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInputFileData%WindVyiList = SrcInputFileData%WindVyiList
ENDIF
IF (ALLOCATED(SrcInputFileData%WindVziList)) THEN
i1_l = LBOUND(SrcInputFileData%WindVziList,1)
i1_u = UBOUND(SrcInputFileData%WindVziList,1)
IF (.NOT. ALLOCATED(DstInputFileData%WindVziList)) THEN
ALLOCATE(DstInputFileData%WindVziList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputFileData%WindVziList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInputFileData%WindVziList = SrcInputFileData%WindVziList
ENDIF
DstInputFileData%Steady_HWindSpeed = SrcInputFileData%Steady_HWindSpeed
DstInputFileData%Steady_RefHt = SrcInputFileData%Steady_RefHt
DstInputFileData%Steady_PLexp = SrcInputFileData%Steady_PLexp
DstInputFileData%Uniform_FileName = SrcInputFileData%Uniform_FileName
DstInputFileData%Uniform_RefHt = SrcInputFileData%Uniform_RefHt
DstInputFileData%Uniform_RefLength = SrcInputFileData%Uniform_RefLength
DstInputFileData%TSFF_FileName = SrcInputFileData%TSFF_FileName
DstInputFileData%BladedFF_FileName = SrcInputFileData%BladedFF_FileName
DstInputFileData%BladedFF_TowerFile = SrcInputFileData%BladedFF_TowerFile
DstInputFileData%CTTS_CoherentTurb = SrcInputFileData%CTTS_CoherentTurb
DstInputFileData%CTTS_FileName = SrcInputFileData%CTTS_FileName
DstInputFileData%CTTS_Path = SrcInputFileData%CTTS_Path
DstInputFileData%HAWC_FileName_u = SrcInputFileData%HAWC_FileName_u
DstInputFileData%HAWC_FileName_v = SrcInputFileData%HAWC_FileName_v
DstInputFileData%HAWC_FileName_w = SrcInputFileData%HAWC_FileName_w
DstInputFileData%HAWC_nx = SrcInputFileData%HAWC_nx
DstInputFileData%HAWC_ny = SrcInputFileData%HAWC_ny
DstInputFileData%HAWC_nz = SrcInputFileData%HAWC_nz
DstInputFileData%HAWC_dx = SrcInputFileData%HAWC_dx
DstInputFileData%HAWC_dy = SrcInputFileData%HAWC_dy
DstInputFileData%HAWC_dz = SrcInputFileData%HAWC_dz
DstInputFileData%SumPrint = SrcInputFileData%SumPrint
DstInputFileData%NumOuts = SrcInputFileData%NumOuts
IF (ALLOCATED(SrcInputFileData%OutList)) THEN
i1_l = LBOUND(SrcInputFileData%OutList,1)
i1_u = UBOUND(SrcInputFileData%OutList,1)
IF (.NOT. ALLOCATED(DstInputFileData%OutList)) THEN
ALLOCATE(DstInputFileData%OutList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputFileData%OutList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInputFileData%OutList = SrcInputFileData%OutList
ENDIF
DstInputFileData%SensorType = SrcInputFileData%SensorType
DstInputFileData%NumPulseGate = SrcInputFileData%NumPulseGate
DstInputFileData%RotorApexOffsetPos = SrcInputFileData%RotorApexOffsetPos
DstInputFileData%LidRadialVel = SrcInputFileData%LidRadialVel
CALL IfW_FFWind_CopyInitInput( SrcInputFileData%FF, DstInputFileData%FF, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE InflowWind_CopyInputFile
SUBROUTINE InflowWind_DestroyInputFile( InputFileData, ErrStat, ErrMsg )
TYPE(InflowWind_InputFile), INTENT(INOUT) :: InputFileData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyInputFile'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(InputFileData%WindVxiList)) THEN
DEALLOCATE(InputFileData%WindVxiList)
ENDIF
IF (ALLOCATED(InputFileData%WindVyiList)) THEN
DEALLOCATE(InputFileData%WindVyiList)
ENDIF
IF (ALLOCATED(InputFileData%WindVziList)) THEN
DEALLOCATE(InputFileData%WindVziList)
ENDIF
IF (ALLOCATED(InputFileData%OutList)) THEN
DEALLOCATE(InputFileData%OutList)
ENDIF
CALL IfW_FFWind_DestroyInitInput( InputFileData%FF, ErrStat, ErrMsg )
END SUBROUTINE InflowWind_DestroyInputFile
SUBROUTINE InflowWind_PackInputFile( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_InputFile), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackInputFile'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! EchoFlag
Int_BufSz = Int_BufSz + 1 ! WindType
Re_BufSz = Re_BufSz + 1 ! PropagationDir
Re_BufSz = Re_BufSz + 1 ! VFlowAngle
Int_BufSz = Int_BufSz + 1 ! NWindVel
Int_BufSz = Int_BufSz + 1 ! WindVxiList allocated yes/no
IF ( ALLOCATED(InData%WindVxiList) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WindVxiList upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindVxiList) ! WindVxiList
END IF
Int_BufSz = Int_BufSz + 1 ! WindVyiList allocated yes/no
IF ( ALLOCATED(InData%WindVyiList) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WindVyiList upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindVyiList) ! WindVyiList
END IF
Int_BufSz = Int_BufSz + 1 ! WindVziList allocated yes/no
IF ( ALLOCATED(InData%WindVziList) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WindVziList upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindVziList) ! WindVziList
END IF
Re_BufSz = Re_BufSz + 1 ! Steady_HWindSpeed
Re_BufSz = Re_BufSz + 1 ! Steady_RefHt
Re_BufSz = Re_BufSz + 1 ! Steady_PLexp
Int_BufSz = Int_BufSz + 1*LEN(InData%Uniform_FileName) ! Uniform_FileName
Re_BufSz = Re_BufSz + 1 ! Uniform_RefHt
Re_BufSz = Re_BufSz + 1 ! Uniform_RefLength
Int_BufSz = Int_BufSz + 1*LEN(InData%TSFF_FileName) ! TSFF_FileName
Int_BufSz = Int_BufSz + 1*LEN(InData%BladedFF_FileName) ! BladedFF_FileName
Int_BufSz = Int_BufSz + 1 ! BladedFF_TowerFile
Int_BufSz = Int_BufSz + 1 ! CTTS_CoherentTurb
Int_BufSz = Int_BufSz + 1*LEN(InData%CTTS_FileName) ! CTTS_FileName
Int_BufSz = Int_BufSz + 1*LEN(InData%CTTS_Path) ! CTTS_Path
Int_BufSz = Int_BufSz + 1*LEN(InData%HAWC_FileName_u) ! HAWC_FileName_u
Int_BufSz = Int_BufSz + 1*LEN(InData%HAWC_FileName_v) ! HAWC_FileName_v
Int_BufSz = Int_BufSz + 1*LEN(InData%HAWC_FileName_w) ! HAWC_FileName_w
Int_BufSz = Int_BufSz + 1 ! HAWC_nx
Int_BufSz = Int_BufSz + 1 ! HAWC_ny
Int_BufSz = Int_BufSz + 1 ! HAWC_nz
Re_BufSz = Re_BufSz + 1 ! HAWC_dx
Re_BufSz = Re_BufSz + 1 ! HAWC_dy
Re_BufSz = Re_BufSz + 1 ! HAWC_dz
Int_BufSz = Int_BufSz + 1 ! SumPrint
Int_BufSz = Int_BufSz + 1 ! NumOuts
Int_BufSz = Int_BufSz + 1 ! OutList allocated yes/no
IF ( ALLOCATED(InData%OutList) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! OutList upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%OutList)*LEN(InData%OutList) ! OutList
END IF
Int_BufSz = Int_BufSz + 1 ! SensorType
Int_BufSz = Int_BufSz + 1 ! NumPulseGate
Re_BufSz = Re_BufSz + SIZE(InData%RotorApexOffsetPos) ! RotorApexOffsetPos
Int_BufSz = Int_BufSz + 1 ! LidRadialVel
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! FF: size of buffers for each call to pack subtype
CALL IfW_FFWind_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%FF, ErrStat2, ErrMsg2, .TRUE. ) ! FF
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! FF
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! FF
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! FF
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%EchoFlag, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%WindType
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%PropagationDir
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%VFlowAngle
Re_Xferred = Re_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NWindVel
Int_Xferred = Int_Xferred + 1
IF ( .NOT. ALLOCATED(InData%WindVxiList) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindVxiList,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindVxiList,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WindVxiList,1), UBOUND(InData%WindVxiList,1)
ReKiBuf(Re_Xferred) = InData%WindVxiList(i1)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( .NOT. ALLOCATED(InData%WindVyiList) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindVyiList,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindVyiList,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WindVyiList,1), UBOUND(InData%WindVyiList,1)
ReKiBuf(Re_Xferred) = InData%WindVyiList(i1)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( .NOT. ALLOCATED(InData%WindVziList) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindVziList,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindVziList,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WindVziList,1), UBOUND(InData%WindVziList,1)
ReKiBuf(Re_Xferred) = InData%WindVziList(i1)
Re_Xferred = Re_Xferred + 1
END DO
END IF
ReKiBuf(Re_Xferred) = InData%Steady_HWindSpeed
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%Steady_RefHt
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%Steady_PLexp
Re_Xferred = Re_Xferred + 1
DO I = 1, LEN(InData%Uniform_FileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%Uniform_FileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
ReKiBuf(Re_Xferred) = InData%Uniform_RefHt
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%Uniform_RefLength
Re_Xferred = Re_Xferred + 1
DO I = 1, LEN(InData%TSFF_FileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%TSFF_FileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%BladedFF_FileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%BladedFF_FileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IntKiBuf(Int_Xferred) = TRANSFER(InData%BladedFF_TowerFile, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%CTTS_CoherentTurb, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO I = 1, LEN(InData%CTTS_FileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%CTTS_FileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%CTTS_Path)
IntKiBuf(Int_Xferred) = ICHAR(InData%CTTS_Path(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%HAWC_FileName_u)
IntKiBuf(Int_Xferred) = ICHAR(InData%HAWC_FileName_u(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%HAWC_FileName_v)
IntKiBuf(Int_Xferred) = ICHAR(InData%HAWC_FileName_v(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(InData%HAWC_FileName_w)
IntKiBuf(Int_Xferred) = ICHAR(InData%HAWC_FileName_w(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IntKiBuf(Int_Xferred) = InData%HAWC_nx
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%HAWC_ny
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%HAWC_nz
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%HAWC_dx
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%HAWC_dy
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%HAWC_dz
Re_Xferred = Re_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%SumPrint, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumOuts
Int_Xferred = Int_Xferred + 1
IF ( .NOT. ALLOCATED(InData%OutList) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%OutList,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%OutList,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%OutList,1), UBOUND(InData%OutList,1)
DO I = 1, LEN(InData%OutList)
IntKiBuf(Int_Xferred) = ICHAR(InData%OutList(i1)(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IntKiBuf(Int_Xferred) = InData%SensorType
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumPulseGate
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%RotorApexOffsetPos,1), UBOUND(InData%RotorApexOffsetPos,1)
ReKiBuf(Re_Xferred) = InData%RotorApexOffsetPos(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = TRANSFER(InData%LidRadialVel, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
CALL IfW_FFWind_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%FF, ErrStat2, ErrMsg2, OnlySize ) ! FF
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE InflowWind_PackInputFile
SUBROUTINE InflowWind_UnPackInputFile( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_InputFile), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackInputFile'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%EchoFlag = TRANSFER(IntKiBuf(Int_Xferred), OutData%EchoFlag)
Int_Xferred = Int_Xferred + 1
OutData%WindType = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%PropagationDir = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%VFlowAngle = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%NWindVel = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindVxiList not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindVxiList)) DEALLOCATE(OutData%WindVxiList)
ALLOCATE(OutData%WindVxiList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindVxiList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WindVxiList,1), UBOUND(OutData%WindVxiList,1)
OutData%WindVxiList(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindVyiList not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindVyiList)) DEALLOCATE(OutData%WindVyiList)
ALLOCATE(OutData%WindVyiList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindVyiList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WindVyiList,1), UBOUND(OutData%WindVyiList,1)
OutData%WindVyiList(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindVziList not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindVziList)) DEALLOCATE(OutData%WindVziList)
ALLOCATE(OutData%WindVziList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindVziList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WindVziList,1), UBOUND(OutData%WindVziList,1)
OutData%WindVziList(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END IF
OutData%Steady_HWindSpeed = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%Steady_RefHt = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%Steady_PLexp = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
DO I = 1, LEN(OutData%Uniform_FileName)
OutData%Uniform_FileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%Uniform_RefHt = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%Uniform_RefLength = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
DO I = 1, LEN(OutData%TSFF_FileName)
OutData%TSFF_FileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%BladedFF_FileName)
OutData%BladedFF_FileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%BladedFF_TowerFile = TRANSFER(IntKiBuf(Int_Xferred), OutData%BladedFF_TowerFile)
Int_Xferred = Int_Xferred + 1
OutData%CTTS_CoherentTurb = TRANSFER(IntKiBuf(Int_Xferred), OutData%CTTS_CoherentTurb)
Int_Xferred = Int_Xferred + 1
DO I = 1, LEN(OutData%CTTS_FileName)
OutData%CTTS_FileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%CTTS_Path)
OutData%CTTS_Path(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%HAWC_FileName_u)
OutData%HAWC_FileName_u(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%HAWC_FileName_v)
OutData%HAWC_FileName_v(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
DO I = 1, LEN(OutData%HAWC_FileName_w)
OutData%HAWC_FileName_w(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%HAWC_nx = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%HAWC_ny = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%HAWC_nz = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%HAWC_dx = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%HAWC_dy = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%HAWC_dz = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%SumPrint = TRANSFER(IntKiBuf(Int_Xferred), OutData%SumPrint)
Int_Xferred = Int_Xferred + 1
OutData%NumOuts = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! OutList not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%OutList)) DEALLOCATE(OutData%OutList)
ALLOCATE(OutData%OutList(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%OutList.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%OutList,1), UBOUND(OutData%OutList,1)
DO I = 1, LEN(OutData%OutList)
OutData%OutList(i1)(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
OutData%SensorType = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%NumPulseGate = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%RotorApexOffsetPos,1)
i1_u = UBOUND(OutData%RotorApexOffsetPos,1)
DO i1 = LBOUND(OutData%RotorApexOffsetPos,1), UBOUND(OutData%RotorApexOffsetPos,1)
OutData%RotorApexOffsetPos(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%LidRadialVel = TRANSFER(IntKiBuf(Int_Xferred), OutData%LidRadialVel)
Int_Xferred = Int_Xferred + 1
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_FFWind_UnpackInitInput( Re_Buf, Db_Buf, Int_Buf, OutData%FF, ErrStat2, ErrMsg2 ) ! FF
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE InflowWind_UnPackInputFile
SUBROUTINE InflowWind_CopyInitInput( SrcInitInputData, DstInitInputData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_InitInputType), INTENT(IN) :: SrcInitInputData
TYPE(InflowWind_InitInputType), INTENT(INOUT) :: DstInitInputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyInitInput'
!
ErrStat = ErrID_None
ErrMsg = ""
DstInitInputData%InputFileName = SrcInitInputData%InputFileName
DstInitInputData%Linearize = SrcInitInputData%Linearize
DstInitInputData%Use4Dext = SrcInitInputData%Use4Dext
DstInitInputData%NumWindPoints = SrcInitInputData%NumWindPoints
DstInitInputData%UseInputFile = SrcInitInputData%UseInputFile
DstInitInputData%RootName = SrcInitInputData%RootName
CALL NWTC_Library_Copyfileinfotype( SrcInitInputData%PassedFileData, DstInitInputData%PassedFileData, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
DstInitInputData%WindType2UseInputFile = SrcInitInputData%WindType2UseInputFile
CALL NWTC_Library_Copyfileinfotype( SrcInitInputData%WindType2Data, DstInitInputData%WindType2Data, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL Lidar_CopyInitInput( SrcInitInputData%lidar, DstInitInputData%lidar, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_4Dext_CopyInitInput( SrcInitInputData%FDext, DstInitInputData%FDext, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE InflowWind_CopyInitInput
SUBROUTINE InflowWind_DestroyInitInput( InitInputData, ErrStat, ErrMsg )
TYPE(InflowWind_InitInputType), INTENT(INOUT) :: InitInputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyInitInput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
CALL NWTC_Library_Destroyfileinfotype( InitInputData%PassedFileData, ErrStat, ErrMsg )
CALL NWTC_Library_Destroyfileinfotype( InitInputData%WindType2Data, ErrStat, ErrMsg )
CALL Lidar_DestroyInitInput( InitInputData%lidar, ErrStat, ErrMsg )
CALL IfW_4Dext_DestroyInitInput( InitInputData%FDext, ErrStat, ErrMsg )
END SUBROUTINE InflowWind_DestroyInitInput
SUBROUTINE InflowWind_PackInitInput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_InitInputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackInitInput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1*LEN(InData%InputFileName) ! InputFileName
Int_BufSz = Int_BufSz + 1 ! Linearize
Int_BufSz = Int_BufSz + 1 ! Use4Dext
Int_BufSz = Int_BufSz + 1 ! NumWindPoints
Int_BufSz = Int_BufSz + 1 ! UseInputFile
Int_BufSz = Int_BufSz + 1*LEN(InData%RootName) ! RootName
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! PassedFileData: size of buffers for each call to pack subtype
CALL NWTC_Library_Packfileinfotype( Re_Buf, Db_Buf, Int_Buf, InData%PassedFileData, ErrStat2, ErrMsg2, .TRUE. ) ! PassedFileData
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! PassedFileData
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! PassedFileData
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! PassedFileData
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 1 ! WindType2UseInputFile
Int_BufSz = Int_BufSz + 3 ! WindType2Data: size of buffers for each call to pack subtype
CALL NWTC_Library_Packfileinfotype( Re_Buf, Db_Buf, Int_Buf, InData%WindType2Data, ErrStat2, ErrMsg2, .TRUE. ) ! WindType2Data
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! WindType2Data
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! WindType2Data
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! WindType2Data
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! lidar: size of buffers for each call to pack subtype
CALL Lidar_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, .TRUE. ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! lidar
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! lidar
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! lidar
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! FDext: size of buffers for each call to pack subtype
CALL IfW_4Dext_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, .TRUE. ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! FDext
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! FDext
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! FDext
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(InData%InputFileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%InputFileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IntKiBuf(Int_Xferred) = TRANSFER(InData%Linearize, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%Use4Dext, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumWindPoints
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%UseInputFile, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DO I = 1, LEN(InData%RootName)
IntKiBuf(Int_Xferred) = ICHAR(InData%RootName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
CALL NWTC_Library_Packfileinfotype( Re_Buf, Db_Buf, Int_Buf, InData%PassedFileData, ErrStat2, ErrMsg2, OnlySize ) ! PassedFileData
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IntKiBuf(Int_Xferred) = TRANSFER(InData%WindType2UseInputFile, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
CALL NWTC_Library_Packfileinfotype( Re_Buf, Db_Buf, Int_Buf, InData%WindType2Data, ErrStat2, ErrMsg2, OnlySize ) ! WindType2Data
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL Lidar_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, OnlySize ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_4Dext_PackInitInput( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, OnlySize ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE InflowWind_PackInitInput
SUBROUTINE InflowWind_UnPackInitInput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_InitInputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackInitInput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(OutData%InputFileName)
OutData%InputFileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%Linearize = TRANSFER(IntKiBuf(Int_Xferred), OutData%Linearize)
Int_Xferred = Int_Xferred + 1
OutData%Use4Dext = TRANSFER(IntKiBuf(Int_Xferred), OutData%Use4Dext)
Int_Xferred = Int_Xferred + 1
OutData%NumWindPoints = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%UseInputFile = TRANSFER(IntKiBuf(Int_Xferred), OutData%UseInputFile)
Int_Xferred = Int_Xferred + 1
DO I = 1, LEN(OutData%RootName)
OutData%RootName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL NWTC_Library_Unpackfileinfotype( Re_Buf, Db_Buf, Int_Buf, OutData%PassedFileData, ErrStat2, ErrMsg2 ) ! PassedFileData
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
OutData%WindType2UseInputFile = TRANSFER(IntKiBuf(Int_Xferred), OutData%WindType2UseInputFile)
Int_Xferred = Int_Xferred + 1
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL NWTC_Library_Unpackfileinfotype( Re_Buf, Db_Buf, Int_Buf, OutData%WindType2Data, ErrStat2, ErrMsg2 ) ! WindType2Data
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL Lidar_UnpackInitInput( Re_Buf, Db_Buf, Int_Buf, OutData%lidar, ErrStat2, ErrMsg2 ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_4Dext_UnpackInitInput( Re_Buf, Db_Buf, Int_Buf, OutData%FDext, ErrStat2, ErrMsg2 ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE InflowWind_UnPackInitInput
SUBROUTINE InflowWind_CopyInitOutput( SrcInitOutputData, DstInitOutputData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_InitOutputType), INTENT(IN) :: SrcInitOutputData
TYPE(InflowWind_InitOutputType), INTENT(INOUT) :: DstInitOutputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyInitOutput'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcInitOutputData%WriteOutputHdr)) THEN
i1_l = LBOUND(SrcInitOutputData%WriteOutputHdr,1)
i1_u = UBOUND(SrcInitOutputData%WriteOutputHdr,1)
IF (.NOT. ALLOCATED(DstInitOutputData%WriteOutputHdr)) THEN
ALLOCATE(DstInitOutputData%WriteOutputHdr(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%WriteOutputHdr.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%WriteOutputHdr = SrcInitOutputData%WriteOutputHdr
ENDIF
IF (ALLOCATED(SrcInitOutputData%WriteOutputUnt)) THEN
i1_l = LBOUND(SrcInitOutputData%WriteOutputUnt,1)
i1_u = UBOUND(SrcInitOutputData%WriteOutputUnt,1)
IF (.NOT. ALLOCATED(DstInitOutputData%WriteOutputUnt)) THEN
ALLOCATE(DstInitOutputData%WriteOutputUnt(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%WriteOutputUnt.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%WriteOutputUnt = SrcInitOutputData%WriteOutputUnt
ENDIF
CALL NWTC_Library_Copyprogdesc( SrcInitOutputData%Ver, DstInitOutputData%Ver, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL InflowWind_Copywindfilemetadata( SrcInitOutputData%WindFileInfo, DstInitOutputData%WindFileInfo, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
IF (ALLOCATED(SrcInitOutputData%LinNames_y)) THEN
i1_l = LBOUND(SrcInitOutputData%LinNames_y,1)
i1_u = UBOUND(SrcInitOutputData%LinNames_y,1)
IF (.NOT. ALLOCATED(DstInitOutputData%LinNames_y)) THEN
ALLOCATE(DstInitOutputData%LinNames_y(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%LinNames_y.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%LinNames_y = SrcInitOutputData%LinNames_y
ENDIF
IF (ALLOCATED(SrcInitOutputData%LinNames_u)) THEN
i1_l = LBOUND(SrcInitOutputData%LinNames_u,1)
i1_u = UBOUND(SrcInitOutputData%LinNames_u,1)
IF (.NOT. ALLOCATED(DstInitOutputData%LinNames_u)) THEN
ALLOCATE(DstInitOutputData%LinNames_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%LinNames_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%LinNames_u = SrcInitOutputData%LinNames_u
ENDIF
IF (ALLOCATED(SrcInitOutputData%RotFrame_y)) THEN
i1_l = LBOUND(SrcInitOutputData%RotFrame_y,1)
i1_u = UBOUND(SrcInitOutputData%RotFrame_y,1)
IF (.NOT. ALLOCATED(DstInitOutputData%RotFrame_y)) THEN
ALLOCATE(DstInitOutputData%RotFrame_y(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%RotFrame_y.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%RotFrame_y = SrcInitOutputData%RotFrame_y
ENDIF
IF (ALLOCATED(SrcInitOutputData%RotFrame_u)) THEN
i1_l = LBOUND(SrcInitOutputData%RotFrame_u,1)
i1_u = UBOUND(SrcInitOutputData%RotFrame_u,1)
IF (.NOT. ALLOCATED(DstInitOutputData%RotFrame_u)) THEN
ALLOCATE(DstInitOutputData%RotFrame_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%RotFrame_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%RotFrame_u = SrcInitOutputData%RotFrame_u
ENDIF
IF (ALLOCATED(SrcInitOutputData%IsLoad_u)) THEN
i1_l = LBOUND(SrcInitOutputData%IsLoad_u,1)
i1_u = UBOUND(SrcInitOutputData%IsLoad_u,1)
IF (.NOT. ALLOCATED(DstInitOutputData%IsLoad_u)) THEN
ALLOCATE(DstInitOutputData%IsLoad_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInitOutputData%IsLoad_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInitOutputData%IsLoad_u = SrcInitOutputData%IsLoad_u
ENDIF
END SUBROUTINE InflowWind_CopyInitOutput
SUBROUTINE InflowWind_DestroyInitOutput( InitOutputData, ErrStat, ErrMsg )
TYPE(InflowWind_InitOutputType), INTENT(INOUT) :: InitOutputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyInitOutput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(InitOutputData%WriteOutputHdr)) THEN
DEALLOCATE(InitOutputData%WriteOutputHdr)
ENDIF
IF (ALLOCATED(InitOutputData%WriteOutputUnt)) THEN
DEALLOCATE(InitOutputData%WriteOutputUnt)
ENDIF
CALL NWTC_Library_Destroyprogdesc( InitOutputData%Ver, ErrStat, ErrMsg )
CALL InflowWind_Destroywindfilemetadata( InitOutputData%WindFileInfo, ErrStat, ErrMsg )
IF (ALLOCATED(InitOutputData%LinNames_y)) THEN
DEALLOCATE(InitOutputData%LinNames_y)
ENDIF
IF (ALLOCATED(InitOutputData%LinNames_u)) THEN
DEALLOCATE(InitOutputData%LinNames_u)
ENDIF
IF (ALLOCATED(InitOutputData%RotFrame_y)) THEN
DEALLOCATE(InitOutputData%RotFrame_y)
ENDIF
IF (ALLOCATED(InitOutputData%RotFrame_u)) THEN
DEALLOCATE(InitOutputData%RotFrame_u)
ENDIF
IF (ALLOCATED(InitOutputData%IsLoad_u)) THEN
DEALLOCATE(InitOutputData%IsLoad_u)
ENDIF
END SUBROUTINE InflowWind_DestroyInitOutput
SUBROUTINE InflowWind_PackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_InitOutputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackInitOutput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! WriteOutputHdr allocated yes/no
IF ( ALLOCATED(InData%WriteOutputHdr) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WriteOutputHdr upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%WriteOutputHdr)*LEN(InData%WriteOutputHdr) ! WriteOutputHdr
END IF
Int_BufSz = Int_BufSz + 1 ! WriteOutputUnt allocated yes/no
IF ( ALLOCATED(InData%WriteOutputUnt) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WriteOutputUnt upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%WriteOutputUnt)*LEN(InData%WriteOutputUnt) ! WriteOutputUnt
END IF
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! Ver: size of buffers for each call to pack subtype
CALL NWTC_Library_Packprogdesc( Re_Buf, Db_Buf, Int_Buf, InData%Ver, ErrStat2, ErrMsg2, .TRUE. ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! Ver
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! Ver
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! Ver
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! WindFileInfo: size of buffers for each call to pack subtype
CALL InflowWind_Packwindfilemetadata( Re_Buf, Db_Buf, Int_Buf, InData%WindFileInfo, ErrStat2, ErrMsg2, .TRUE. ) ! WindFileInfo
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! WindFileInfo
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! WindFileInfo
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! WindFileInfo
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 1 ! LinNames_y allocated yes/no
IF ( ALLOCATED(InData%LinNames_y) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! LinNames_y upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%LinNames_y)*LEN(InData%LinNames_y) ! LinNames_y
END IF
Int_BufSz = Int_BufSz + 1 ! LinNames_u allocated yes/no
IF ( ALLOCATED(InData%LinNames_u) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! LinNames_u upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%LinNames_u)*LEN(InData%LinNames_u) ! LinNames_u
END IF
Int_BufSz = Int_BufSz + 1 ! RotFrame_y allocated yes/no
IF ( ALLOCATED(InData%RotFrame_y) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! RotFrame_y upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%RotFrame_y) ! RotFrame_y
END IF
Int_BufSz = Int_BufSz + 1 ! RotFrame_u allocated yes/no
IF ( ALLOCATED(InData%RotFrame_u) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! RotFrame_u upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%RotFrame_u) ! RotFrame_u
END IF
Int_BufSz = Int_BufSz + 1 ! IsLoad_u allocated yes/no
IF ( ALLOCATED(InData%IsLoad_u) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! IsLoad_u upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%IsLoad_u) ! IsLoad_u
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%WriteOutputHdr) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WriteOutputHdr,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WriteOutputHdr,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WriteOutputHdr,1), UBOUND(InData%WriteOutputHdr,1)
DO I = 1, LEN(InData%WriteOutputHdr)
IntKiBuf(Int_Xferred) = ICHAR(InData%WriteOutputHdr(i1)(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( .NOT. ALLOCATED(InData%WriteOutputUnt) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WriteOutputUnt,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WriteOutputUnt,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WriteOutputUnt,1), UBOUND(InData%WriteOutputUnt,1)
DO I = 1, LEN(InData%WriteOutputUnt)
IntKiBuf(Int_Xferred) = ICHAR(InData%WriteOutputUnt(i1)(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
CALL NWTC_Library_Packprogdesc( Re_Buf, Db_Buf, Int_Buf, InData%Ver, ErrStat2, ErrMsg2, OnlySize ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL InflowWind_Packwindfilemetadata( Re_Buf, Db_Buf, Int_Buf, InData%WindFileInfo, ErrStat2, ErrMsg2, OnlySize ) ! WindFileInfo
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF ( .NOT. ALLOCATED(InData%LinNames_y) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%LinNames_y,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%LinNames_y,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%LinNames_y,1), UBOUND(InData%LinNames_y,1)
DO I = 1, LEN(InData%LinNames_y)
IntKiBuf(Int_Xferred) = ICHAR(InData%LinNames_y(i1)(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( .NOT. ALLOCATED(InData%LinNames_u) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%LinNames_u,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%LinNames_u,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%LinNames_u,1), UBOUND(InData%LinNames_u,1)
DO I = 1, LEN(InData%LinNames_u)
IntKiBuf(Int_Xferred) = ICHAR(InData%LinNames_u(i1)(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( .NOT. ALLOCATED(InData%RotFrame_y) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%RotFrame_y,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%RotFrame_y,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%RotFrame_y,1), UBOUND(InData%RotFrame_y,1)
IntKiBuf(Int_Xferred) = TRANSFER(InData%RotFrame_y(i1), IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
IF ( .NOT. ALLOCATED(InData%RotFrame_u) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%RotFrame_u,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%RotFrame_u,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%RotFrame_u,1), UBOUND(InData%RotFrame_u,1)
IntKiBuf(Int_Xferred) = TRANSFER(InData%RotFrame_u(i1), IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
IF ( .NOT. ALLOCATED(InData%IsLoad_u) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%IsLoad_u,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%IsLoad_u,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%IsLoad_u,1), UBOUND(InData%IsLoad_u,1)
IntKiBuf(Int_Xferred) = TRANSFER(InData%IsLoad_u(i1), IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
END SUBROUTINE InflowWind_PackInitOutput
SUBROUTINE InflowWind_UnPackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_InitOutputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackInitOutput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WriteOutputHdr not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WriteOutputHdr)) DEALLOCATE(OutData%WriteOutputHdr)
ALLOCATE(OutData%WriteOutputHdr(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WriteOutputHdr.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WriteOutputHdr,1), UBOUND(OutData%WriteOutputHdr,1)
DO I = 1, LEN(OutData%WriteOutputHdr)
OutData%WriteOutputHdr(i1)(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WriteOutputUnt not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WriteOutputUnt)) DEALLOCATE(OutData%WriteOutputUnt)
ALLOCATE(OutData%WriteOutputUnt(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WriteOutputUnt.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WriteOutputUnt,1), UBOUND(OutData%WriteOutputUnt,1)
DO I = 1, LEN(OutData%WriteOutputUnt)
OutData%WriteOutputUnt(i1)(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL NWTC_Library_Unpackprogdesc( Re_Buf, Db_Buf, Int_Buf, OutData%Ver, ErrStat2, ErrMsg2 ) ! Ver
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL InflowWind_Unpackwindfilemetadata( Re_Buf, Db_Buf, Int_Buf, OutData%WindFileInfo, ErrStat2, ErrMsg2 ) ! WindFileInfo
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! LinNames_y not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%LinNames_y)) DEALLOCATE(OutData%LinNames_y)
ALLOCATE(OutData%LinNames_y(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%LinNames_y.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%LinNames_y,1), UBOUND(OutData%LinNames_y,1)
DO I = 1, LEN(OutData%LinNames_y)
OutData%LinNames_y(i1)(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! LinNames_u not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%LinNames_u)) DEALLOCATE(OutData%LinNames_u)
ALLOCATE(OutData%LinNames_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%LinNames_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%LinNames_u,1), UBOUND(OutData%LinNames_u,1)
DO I = 1, LEN(OutData%LinNames_u)
OutData%LinNames_u(i1)(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! RotFrame_y not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%RotFrame_y)) DEALLOCATE(OutData%RotFrame_y)
ALLOCATE(OutData%RotFrame_y(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%RotFrame_y.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%RotFrame_y,1), UBOUND(OutData%RotFrame_y,1)
OutData%RotFrame_y(i1) = TRANSFER(IntKiBuf(Int_Xferred), OutData%RotFrame_y(i1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! RotFrame_u not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%RotFrame_u)) DEALLOCATE(OutData%RotFrame_u)
ALLOCATE(OutData%RotFrame_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%RotFrame_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%RotFrame_u,1), UBOUND(OutData%RotFrame_u,1)
OutData%RotFrame_u(i1) = TRANSFER(IntKiBuf(Int_Xferred), OutData%RotFrame_u(i1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! IsLoad_u not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%IsLoad_u)) DEALLOCATE(OutData%IsLoad_u)
ALLOCATE(OutData%IsLoad_u(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%IsLoad_u.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%IsLoad_u,1), UBOUND(OutData%IsLoad_u,1)
OutData%IsLoad_u(i1) = TRANSFER(IntKiBuf(Int_Xferred), OutData%IsLoad_u(i1))
Int_Xferred = Int_Xferred + 1
END DO
END IF
END SUBROUTINE InflowWind_UnPackInitOutput
SUBROUTINE InflowWind_CopyMisc( SrcMiscData, DstMiscData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_MiscVarType), INTENT(IN) :: SrcMiscData
TYPE(InflowWind_MiscVarType), INTENT(INOUT) :: DstMiscData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyMisc'
!
ErrStat = ErrID_None
ErrMsg = ""
DstMiscData%TimeIndex = SrcMiscData%TimeIndex
CALL IfW_UniformWind_CopyMisc( SrcMiscData%UniformWind, DstMiscData%UniformWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_TSFFWind_CopyMisc( SrcMiscData%TSFFWind, DstMiscData%TSFFWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_HAWCWind_CopyMisc( SrcMiscData%HAWCWind, DstMiscData%HAWCWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_BladedFFWind_CopyMisc( SrcMiscData%BladedFFWind, DstMiscData%BladedFFWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_UserWind_CopyMisc( SrcMiscData%UserWind, DstMiscData%UserWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_4Dext_CopyMisc( SrcMiscData%FDext, DstMiscData%FDext, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
IF (ALLOCATED(SrcMiscData%AllOuts)) THEN
i1_l = LBOUND(SrcMiscData%AllOuts,1)
i1_u = UBOUND(SrcMiscData%AllOuts,1)
IF (.NOT. ALLOCATED(DstMiscData%AllOuts)) THEN
ALLOCATE(DstMiscData%AllOuts(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstMiscData%AllOuts.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstMiscData%AllOuts = SrcMiscData%AllOuts
ENDIF
IF (ALLOCATED(SrcMiscData%WindViUVW)) THEN
i1_l = LBOUND(SrcMiscData%WindViUVW,1)
i1_u = UBOUND(SrcMiscData%WindViUVW,1)
i2_l = LBOUND(SrcMiscData%WindViUVW,2)
i2_u = UBOUND(SrcMiscData%WindViUVW,2)
IF (.NOT. ALLOCATED(DstMiscData%WindViUVW)) THEN
ALLOCATE(DstMiscData%WindViUVW(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstMiscData%WindViUVW.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstMiscData%WindViUVW = SrcMiscData%WindViUVW
ENDIF
END SUBROUTINE InflowWind_CopyMisc
SUBROUTINE InflowWind_DestroyMisc( MiscData, ErrStat, ErrMsg )
TYPE(InflowWind_MiscVarType), INTENT(INOUT) :: MiscData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyMisc'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
CALL IfW_UniformWind_DestroyMisc( MiscData%UniformWind, ErrStat, ErrMsg )
CALL IfW_TSFFWind_DestroyMisc( MiscData%TSFFWind, ErrStat, ErrMsg )
CALL IfW_HAWCWind_DestroyMisc( MiscData%HAWCWind, ErrStat, ErrMsg )
CALL IfW_BladedFFWind_DestroyMisc( MiscData%BladedFFWind, ErrStat, ErrMsg )
CALL IfW_UserWind_DestroyMisc( MiscData%UserWind, ErrStat, ErrMsg )
CALL IfW_4Dext_DestroyMisc( MiscData%FDext, ErrStat, ErrMsg )
IF (ALLOCATED(MiscData%AllOuts)) THEN
DEALLOCATE(MiscData%AllOuts)
ENDIF
IF (ALLOCATED(MiscData%WindViUVW)) THEN
DEALLOCATE(MiscData%WindViUVW)
ENDIF
END SUBROUTINE InflowWind_DestroyMisc
SUBROUTINE InflowWind_PackMisc( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_MiscVarType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackMisc'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! TimeIndex
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! UniformWind: size of buffers for each call to pack subtype
CALL IfW_UniformWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%UniformWind, ErrStat2, ErrMsg2, .TRUE. ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! UniformWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! UniformWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! UniformWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! TSFFWind: size of buffers for each call to pack subtype
CALL IfW_TSFFWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%TSFFWind, ErrStat2, ErrMsg2, .TRUE. ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! TSFFWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! TSFFWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! TSFFWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! HAWCWind: size of buffers for each call to pack subtype
CALL IfW_HAWCWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%HAWCWind, ErrStat2, ErrMsg2, .TRUE. ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! HAWCWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! HAWCWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! HAWCWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! BladedFFWind: size of buffers for each call to pack subtype
CALL IfW_BladedFFWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%BladedFFWind, ErrStat2, ErrMsg2, .TRUE. ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! BladedFFWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! BladedFFWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! BladedFFWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! UserWind: size of buffers for each call to pack subtype
CALL IfW_UserWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%UserWind, ErrStat2, ErrMsg2, .TRUE. ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! UserWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! UserWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! UserWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! FDext: size of buffers for each call to pack subtype
CALL IfW_4Dext_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, .TRUE. ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! FDext
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! FDext
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! FDext
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 1 ! AllOuts allocated yes/no
IF ( ALLOCATED(InData%AllOuts) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! AllOuts upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%AllOuts) ! AllOuts
END IF
Int_BufSz = Int_BufSz + 1 ! WindViUVW allocated yes/no
IF ( ALLOCATED(InData%WindViUVW) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! WindViUVW upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindViUVW) ! WindViUVW
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IntKiBuf(Int_Xferred) = InData%TimeIndex
Int_Xferred = Int_Xferred + 1
CALL IfW_UniformWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%UniformWind, ErrStat2, ErrMsg2, OnlySize ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_TSFFWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%TSFFWind, ErrStat2, ErrMsg2, OnlySize ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_HAWCWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%HAWCWind, ErrStat2, ErrMsg2, OnlySize ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_BladedFFWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%BladedFFWind, ErrStat2, ErrMsg2, OnlySize ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_UserWind_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%UserWind, ErrStat2, ErrMsg2, OnlySize ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_4Dext_PackMisc( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, OnlySize ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF ( .NOT. ALLOCATED(InData%AllOuts) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%AllOuts,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%AllOuts,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%AllOuts,1), UBOUND(InData%AllOuts,1)
ReKiBuf(Re_Xferred) = InData%AllOuts(i1)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( .NOT. ALLOCATED(InData%WindViUVW) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViUVW,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViUVW,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViUVW,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViUVW,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%WindViUVW,2), UBOUND(InData%WindViUVW,2)
DO i1 = LBOUND(InData%WindViUVW,1), UBOUND(InData%WindViUVW,1)
ReKiBuf(Re_Xferred) = InData%WindViUVW(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
END SUBROUTINE InflowWind_PackMisc
SUBROUTINE InflowWind_UnPackMisc( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_MiscVarType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackMisc'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%TimeIndex = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_UniformWind_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%UniformWind, ErrStat2, ErrMsg2 ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_TSFFWind_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%TSFFWind, ErrStat2, ErrMsg2 ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_HAWCWind_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%HAWCWind, ErrStat2, ErrMsg2 ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_BladedFFWind_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%BladedFFWind, ErrStat2, ErrMsg2 ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_UserWind_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%UserWind, ErrStat2, ErrMsg2 ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_4Dext_UnpackMisc( Re_Buf, Db_Buf, Int_Buf, OutData%FDext, ErrStat2, ErrMsg2 ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! AllOuts not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%AllOuts)) DEALLOCATE(OutData%AllOuts)
ALLOCATE(OutData%AllOuts(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%AllOuts.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%AllOuts,1), UBOUND(OutData%AllOuts,1)
OutData%AllOuts(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindViUVW not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindViUVW)) DEALLOCATE(OutData%WindViUVW)
ALLOCATE(OutData%WindViUVW(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindViUVW.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%WindViUVW,2), UBOUND(OutData%WindViUVW,2)
DO i1 = LBOUND(OutData%WindViUVW,1), UBOUND(OutData%WindViUVW,1)
OutData%WindViUVW(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
END SUBROUTINE InflowWind_UnPackMisc
SUBROUTINE InflowWind_CopyParam( SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_ParameterType), INTENT(IN) :: SrcParamData
TYPE(InflowWind_ParameterType), INTENT(INOUT) :: DstParamData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyParam'
!
ErrStat = ErrID_None
ErrMsg = ""
DstParamData%RootFileName = SrcParamData%RootFileName
DstParamData%CTTS_Flag = SrcParamData%CTTS_Flag
DstParamData%RotateWindBox = SrcParamData%RotateWindBox
DstParamData%DT = SrcParamData%DT
DstParamData%PropagationDir = SrcParamData%PropagationDir
DstParamData%VFlowAngle = SrcParamData%VFlowAngle
DstParamData%RotToWind = SrcParamData%RotToWind
DstParamData%RotFromWind = SrcParamData%RotFromWind
IF (ALLOCATED(SrcParamData%WindViXYZprime)) THEN
i1_l = LBOUND(SrcParamData%WindViXYZprime,1)
i1_u = UBOUND(SrcParamData%WindViXYZprime,1)
i2_l = LBOUND(SrcParamData%WindViXYZprime,2)
i2_u = UBOUND(SrcParamData%WindViXYZprime,2)
IF (.NOT. ALLOCATED(DstParamData%WindViXYZprime)) THEN
ALLOCATE(DstParamData%WindViXYZprime(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%WindViXYZprime.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstParamData%WindViXYZprime = SrcParamData%WindViXYZprime
ENDIF
DstParamData%WindType = SrcParamData%WindType
DstParamData%ReferenceHeight = SrcParamData%ReferenceHeight
DstParamData%RefPosition = SrcParamData%RefPosition
DstParamData%NWindVel = SrcParamData%NWindVel
IF (ALLOCATED(SrcParamData%WindViXYZ)) THEN
i1_l = LBOUND(SrcParamData%WindViXYZ,1)
i1_u = UBOUND(SrcParamData%WindViXYZ,1)
i2_l = LBOUND(SrcParamData%WindViXYZ,2)
i2_u = UBOUND(SrcParamData%WindViXYZ,2)
IF (.NOT. ALLOCATED(DstParamData%WindViXYZ)) THEN
ALLOCATE(DstParamData%WindViXYZ(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%WindViXYZ.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstParamData%WindViXYZ = SrcParamData%WindViXYZ
ENDIF
CALL IfW_UniformWind_CopyParam( SrcParamData%UniformWind, DstParamData%UniformWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_TSFFWind_CopyParam( SrcParamData%TSFFWind, DstParamData%TSFFWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_BladedFFWind_CopyParam( SrcParamData%BladedFFWind, DstParamData%BladedFFWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_HAWCWind_CopyParam( SrcParamData%HAWCWind, DstParamData%HAWCWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_UserWind_CopyParam( SrcParamData%UserWind, DstParamData%UserWind, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
CALL IfW_4Dext_CopyParam( SrcParamData%FDext, DstParamData%FDext, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
DstParamData%NumOuts = SrcParamData%NumOuts
IF (ALLOCATED(SrcParamData%OutParam)) THEN
i1_l = LBOUND(SrcParamData%OutParam,1)
i1_u = UBOUND(SrcParamData%OutParam,1)
IF (.NOT. ALLOCATED(DstParamData%OutParam)) THEN
ALLOCATE(DstParamData%OutParam(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%OutParam.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DO i1 = LBOUND(SrcParamData%OutParam,1), UBOUND(SrcParamData%OutParam,1)
CALL NWTC_Library_Copyoutparmtype( SrcParamData%OutParam(i1), DstParamData%OutParam(i1), CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
ENDDO
ENDIF
IF (ALLOCATED(SrcParamData%OutParamLinIndx)) THEN
i1_l = LBOUND(SrcParamData%OutParamLinIndx,1)
i1_u = UBOUND(SrcParamData%OutParamLinIndx,1)
i2_l = LBOUND(SrcParamData%OutParamLinIndx,2)
i2_u = UBOUND(SrcParamData%OutParamLinIndx,2)
IF (.NOT. ALLOCATED(DstParamData%OutParamLinIndx)) THEN
ALLOCATE(DstParamData%OutParamLinIndx(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstParamData%OutParamLinIndx.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstParamData%OutParamLinIndx = SrcParamData%OutParamLinIndx
ENDIF
CALL Lidar_CopyParam( SrcParamData%lidar, DstParamData%lidar, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE InflowWind_CopyParam
SUBROUTINE InflowWind_DestroyParam( ParamData, ErrStat, ErrMsg )
TYPE(InflowWind_ParameterType), INTENT(INOUT) :: ParamData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyParam'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(ParamData%WindViXYZprime)) THEN
DEALLOCATE(ParamData%WindViXYZprime)
ENDIF
IF (ALLOCATED(ParamData%WindViXYZ)) THEN
DEALLOCATE(ParamData%WindViXYZ)
ENDIF
CALL IfW_UniformWind_DestroyParam( ParamData%UniformWind, ErrStat, ErrMsg )
CALL IfW_TSFFWind_DestroyParam( ParamData%TSFFWind, ErrStat, ErrMsg )
CALL IfW_BladedFFWind_DestroyParam( ParamData%BladedFFWind, ErrStat, ErrMsg )
CALL IfW_HAWCWind_DestroyParam( ParamData%HAWCWind, ErrStat, ErrMsg )
CALL IfW_UserWind_DestroyParam( ParamData%UserWind, ErrStat, ErrMsg )
CALL IfW_4Dext_DestroyParam( ParamData%FDext, ErrStat, ErrMsg )
IF (ALLOCATED(ParamData%OutParam)) THEN
DO i1 = LBOUND(ParamData%OutParam,1), UBOUND(ParamData%OutParam,1)
CALL NWTC_Library_Destroyoutparmtype( ParamData%OutParam(i1), ErrStat, ErrMsg )
ENDDO
DEALLOCATE(ParamData%OutParam)
ENDIF
IF (ALLOCATED(ParamData%OutParamLinIndx)) THEN
DEALLOCATE(ParamData%OutParamLinIndx)
ENDIF
CALL Lidar_DestroyParam( ParamData%lidar, ErrStat, ErrMsg )
END SUBROUTINE InflowWind_DestroyParam
SUBROUTINE InflowWind_PackParam( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_ParameterType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackParam'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1*LEN(InData%RootFileName) ! RootFileName
Int_BufSz = Int_BufSz + 1 ! CTTS_Flag
Int_BufSz = Int_BufSz + 1 ! RotateWindBox
Db_BufSz = Db_BufSz + 1 ! DT
Re_BufSz = Re_BufSz + 1 ! PropagationDir
Re_BufSz = Re_BufSz + 1 ! VFlowAngle
Re_BufSz = Re_BufSz + SIZE(InData%RotToWind) ! RotToWind
Re_BufSz = Re_BufSz + SIZE(InData%RotFromWind) ! RotFromWind
Int_BufSz = Int_BufSz + 1 ! WindViXYZprime allocated yes/no
IF ( ALLOCATED(InData%WindViXYZprime) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! WindViXYZprime upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindViXYZprime) ! WindViXYZprime
END IF
Int_BufSz = Int_BufSz + 1 ! WindType
Re_BufSz = Re_BufSz + 1 ! ReferenceHeight
Re_BufSz = Re_BufSz + SIZE(InData%RefPosition) ! RefPosition
Int_BufSz = Int_BufSz + 1 ! NWindVel
Int_BufSz = Int_BufSz + 1 ! WindViXYZ allocated yes/no
IF ( ALLOCATED(InData%WindViXYZ) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! WindViXYZ upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WindViXYZ) ! WindViXYZ
END IF
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! UniformWind: size of buffers for each call to pack subtype
CALL IfW_UniformWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%UniformWind, ErrStat2, ErrMsg2, .TRUE. ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! UniformWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! UniformWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! UniformWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! TSFFWind: size of buffers for each call to pack subtype
CALL IfW_TSFFWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%TSFFWind, ErrStat2, ErrMsg2, .TRUE. ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! TSFFWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! TSFFWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! TSFFWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! BladedFFWind: size of buffers for each call to pack subtype
CALL IfW_BladedFFWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%BladedFFWind, ErrStat2, ErrMsg2, .TRUE. ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! BladedFFWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! BladedFFWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! BladedFFWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! HAWCWind: size of buffers for each call to pack subtype
CALL IfW_HAWCWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%HAWCWind, ErrStat2, ErrMsg2, .TRUE. ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! HAWCWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! HAWCWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! HAWCWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! UserWind: size of buffers for each call to pack subtype
CALL IfW_UserWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%UserWind, ErrStat2, ErrMsg2, .TRUE. ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! UserWind
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! UserWind
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! UserWind
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 3 ! FDext: size of buffers for each call to pack subtype
CALL IfW_4Dext_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, .TRUE. ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! FDext
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! FDext
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! FDext
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
Int_BufSz = Int_BufSz + 1 ! NumOuts
Int_BufSz = Int_BufSz + 1 ! OutParam allocated yes/no
IF ( ALLOCATED(InData%OutParam) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! OutParam upper/lower bounds for each dimension
DO i1 = LBOUND(InData%OutParam,1), UBOUND(InData%OutParam,1)
Int_BufSz = Int_BufSz + 3 ! OutParam: size of buffers for each call to pack subtype
CALL NWTC_Library_Packoutparmtype( Re_Buf, Db_Buf, Int_Buf, InData%OutParam(i1), ErrStat2, ErrMsg2, .TRUE. ) ! OutParam
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! OutParam
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! OutParam
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! OutParam
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
END DO
END IF
Int_BufSz = Int_BufSz + 1 ! OutParamLinIndx allocated yes/no
IF ( ALLOCATED(InData%OutParamLinIndx) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! OutParamLinIndx upper/lower bounds for each dimension
Int_BufSz = Int_BufSz + SIZE(InData%OutParamLinIndx) ! OutParamLinIndx
END IF
Int_BufSz = Int_BufSz + 3 ! lidar: size of buffers for each call to pack subtype
CALL Lidar_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, .TRUE. ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! lidar
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! lidar
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! lidar
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(InData%RootFileName)
IntKiBuf(Int_Xferred) = ICHAR(InData%RootFileName(I:I), IntKi)
Int_Xferred = Int_Xferred + 1
END DO ! I
IntKiBuf(Int_Xferred) = TRANSFER(InData%CTTS_Flag, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%RotateWindBox, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
DbKiBuf(Db_Xferred) = InData%DT
Db_Xferred = Db_Xferred + 1
ReKiBuf(Re_Xferred) = InData%PropagationDir
Re_Xferred = Re_Xferred + 1
ReKiBuf(Re_Xferred) = InData%VFlowAngle
Re_Xferred = Re_Xferred + 1
DO i2 = LBOUND(InData%RotToWind,2), UBOUND(InData%RotToWind,2)
DO i1 = LBOUND(InData%RotToWind,1), UBOUND(InData%RotToWind,1)
ReKiBuf(Re_Xferred) = InData%RotToWind(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
DO i2 = LBOUND(InData%RotFromWind,2), UBOUND(InData%RotFromWind,2)
DO i1 = LBOUND(InData%RotFromWind,1), UBOUND(InData%RotFromWind,1)
ReKiBuf(Re_Xferred) = InData%RotFromWind(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
IF ( .NOT. ALLOCATED(InData%WindViXYZprime) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViXYZprime,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViXYZprime,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViXYZprime,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViXYZprime,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%WindViXYZprime,2), UBOUND(InData%WindViXYZprime,2)
DO i1 = LBOUND(InData%WindViXYZprime,1), UBOUND(InData%WindViXYZprime,1)
ReKiBuf(Re_Xferred) = InData%WindViXYZprime(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
IntKiBuf(Int_Xferred) = InData%WindType
Int_Xferred = Int_Xferred + 1
ReKiBuf(Re_Xferred) = InData%ReferenceHeight
Re_Xferred = Re_Xferred + 1
DO i1 = LBOUND(InData%RefPosition,1), UBOUND(InData%RefPosition,1)
ReKiBuf(Re_Xferred) = InData%RefPosition(i1)
Re_Xferred = Re_Xferred + 1
END DO
IntKiBuf(Int_Xferred) = InData%NWindVel
Int_Xferred = Int_Xferred + 1
IF ( .NOT. ALLOCATED(InData%WindViXYZ) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViXYZ,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViXYZ,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%WindViXYZ,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WindViXYZ,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%WindViXYZ,2), UBOUND(InData%WindViXYZ,2)
DO i1 = LBOUND(InData%WindViXYZ,1), UBOUND(InData%WindViXYZ,1)
ReKiBuf(Re_Xferred) = InData%WindViXYZ(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
CALL IfW_UniformWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%UniformWind, ErrStat2, ErrMsg2, OnlySize ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_TSFFWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%TSFFWind, ErrStat2, ErrMsg2, OnlySize ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_BladedFFWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%BladedFFWind, ErrStat2, ErrMsg2, OnlySize ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_HAWCWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%HAWCWind, ErrStat2, ErrMsg2, OnlySize ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_UserWind_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%UserWind, ErrStat2, ErrMsg2, OnlySize ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
CALL IfW_4Dext_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%FDext, ErrStat2, ErrMsg2, OnlySize ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IntKiBuf(Int_Xferred) = InData%NumOuts
Int_Xferred = Int_Xferred + 1
IF ( .NOT. ALLOCATED(InData%OutParam) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%OutParam,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%OutParam,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%OutParam,1), UBOUND(InData%OutParam,1)
CALL NWTC_Library_Packoutparmtype( Re_Buf, Db_Buf, Int_Buf, InData%OutParam(i1), ErrStat2, ErrMsg2, OnlySize ) ! OutParam
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END DO
END IF
IF ( .NOT. ALLOCATED(InData%OutParamLinIndx) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%OutParamLinIndx,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%OutParamLinIndx,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%OutParamLinIndx,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%OutParamLinIndx,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%OutParamLinIndx,2), UBOUND(InData%OutParamLinIndx,2)
DO i1 = LBOUND(InData%OutParamLinIndx,1), UBOUND(InData%OutParamLinIndx,1)
IntKiBuf(Int_Xferred) = InData%OutParamLinIndx(i1,i2)
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
CALL Lidar_PackParam( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, OnlySize ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE InflowWind_PackParam
SUBROUTINE InflowWind_UnPackParam( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_ParameterType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackParam'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
DO I = 1, LEN(OutData%RootFileName)
OutData%RootFileName(I:I) = CHAR(IntKiBuf(Int_Xferred))
Int_Xferred = Int_Xferred + 1
END DO ! I
OutData%CTTS_Flag = TRANSFER(IntKiBuf(Int_Xferred), OutData%CTTS_Flag)
Int_Xferred = Int_Xferred + 1
OutData%RotateWindBox = TRANSFER(IntKiBuf(Int_Xferred), OutData%RotateWindBox)
Int_Xferred = Int_Xferred + 1
OutData%DT = DbKiBuf(Db_Xferred)
Db_Xferred = Db_Xferred + 1
OutData%PropagationDir = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
OutData%VFlowAngle = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
i1_l = LBOUND(OutData%RotToWind,1)
i1_u = UBOUND(OutData%RotToWind,1)
i2_l = LBOUND(OutData%RotToWind,2)
i2_u = UBOUND(OutData%RotToWind,2)
DO i2 = LBOUND(OutData%RotToWind,2), UBOUND(OutData%RotToWind,2)
DO i1 = LBOUND(OutData%RotToWind,1), UBOUND(OutData%RotToWind,1)
OutData%RotToWind(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
i1_l = LBOUND(OutData%RotFromWind,1)
i1_u = UBOUND(OutData%RotFromWind,1)
i2_l = LBOUND(OutData%RotFromWind,2)
i2_u = UBOUND(OutData%RotFromWind,2)
DO i2 = LBOUND(OutData%RotFromWind,2), UBOUND(OutData%RotFromWind,2)
DO i1 = LBOUND(OutData%RotFromWind,1), UBOUND(OutData%RotFromWind,1)
OutData%RotFromWind(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindViXYZprime not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindViXYZprime)) DEALLOCATE(OutData%WindViXYZprime)
ALLOCATE(OutData%WindViXYZprime(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindViXYZprime.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%WindViXYZprime,2), UBOUND(OutData%WindViXYZprime,2)
DO i1 = LBOUND(OutData%WindViXYZprime,1), UBOUND(OutData%WindViXYZprime,1)
OutData%WindViXYZprime(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
OutData%WindType = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%ReferenceHeight = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
i1_l = LBOUND(OutData%RefPosition,1)
i1_u = UBOUND(OutData%RefPosition,1)
DO i1 = LBOUND(OutData%RefPosition,1), UBOUND(OutData%RefPosition,1)
OutData%RefPosition(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
OutData%NWindVel = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WindViXYZ not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WindViXYZ)) DEALLOCATE(OutData%WindViXYZ)
ALLOCATE(OutData%WindViXYZ(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WindViXYZ.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%WindViXYZ,2), UBOUND(OutData%WindViXYZ,2)
DO i1 = LBOUND(OutData%WindViXYZ,1), UBOUND(OutData%WindViXYZ,1)
OutData%WindViXYZ(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_UniformWind_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%UniformWind, ErrStat2, ErrMsg2 ) ! UniformWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_TSFFWind_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%TSFFWind, ErrStat2, ErrMsg2 ) ! TSFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_BladedFFWind_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%BladedFFWind, ErrStat2, ErrMsg2 ) ! BladedFFWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_HAWCWind_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%HAWCWind, ErrStat2, ErrMsg2 ) ! HAWCWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_UserWind_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%UserWind, ErrStat2, ErrMsg2 ) ! UserWind
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL IfW_4Dext_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%FDext, ErrStat2, ErrMsg2 ) ! FDext
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
OutData%NumOuts = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! OutParam not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%OutParam)) DEALLOCATE(OutData%OutParam)
ALLOCATE(OutData%OutParam(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%OutParam.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%OutParam,1), UBOUND(OutData%OutParam,1)
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL NWTC_Library_Unpackoutparmtype( Re_Buf, Db_Buf, Int_Buf, OutData%OutParam(i1), ErrStat2, ErrMsg2 ) ! OutParam
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! OutParamLinIndx not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%OutParamLinIndx)) DEALLOCATE(OutData%OutParamLinIndx)
ALLOCATE(OutData%OutParamLinIndx(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%OutParamLinIndx.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%OutParamLinIndx,2), UBOUND(OutData%OutParamLinIndx,2)
DO i1 = LBOUND(OutData%OutParamLinIndx,1), UBOUND(OutData%OutParamLinIndx,1)
OutData%OutParamLinIndx(i1,i2) = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
END DO
END DO
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL Lidar_UnpackParam( Re_Buf, Db_Buf, Int_Buf, OutData%lidar, ErrStat2, ErrMsg2 ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE InflowWind_UnPackParam
SUBROUTINE InflowWind_CopyInput( SrcInputData, DstInputData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_InputType), INTENT(IN) :: SrcInputData
TYPE(InflowWind_InputType), INTENT(INOUT) :: DstInputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyInput'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcInputData%PositionXYZ)) THEN
i1_l = LBOUND(SrcInputData%PositionXYZ,1)
i1_u = UBOUND(SrcInputData%PositionXYZ,1)
i2_l = LBOUND(SrcInputData%PositionXYZ,2)
i2_u = UBOUND(SrcInputData%PositionXYZ,2)
IF (.NOT. ALLOCATED(DstInputData%PositionXYZ)) THEN
ALLOCATE(DstInputData%PositionXYZ(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstInputData%PositionXYZ.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstInputData%PositionXYZ = SrcInputData%PositionXYZ
ENDIF
CALL Lidar_CopyInput( SrcInputData%lidar, DstInputData%lidar, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE InflowWind_CopyInput
SUBROUTINE InflowWind_DestroyInput( InputData, ErrStat, ErrMsg )
TYPE(InflowWind_InputType), INTENT(INOUT) :: InputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyInput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(InputData%PositionXYZ)) THEN
DEALLOCATE(InputData%PositionXYZ)
ENDIF
CALL Lidar_DestroyInput( InputData%lidar, ErrStat, ErrMsg )
END SUBROUTINE InflowWind_DestroyInput
SUBROUTINE InflowWind_PackInput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_InputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackInput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! PositionXYZ allocated yes/no
IF ( ALLOCATED(InData%PositionXYZ) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! PositionXYZ upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%PositionXYZ) ! PositionXYZ
END IF
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! lidar: size of buffers for each call to pack subtype
CALL Lidar_PackInput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, .TRUE. ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! lidar
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! lidar
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! lidar
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%PositionXYZ) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%PositionXYZ,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%PositionXYZ,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%PositionXYZ,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%PositionXYZ,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%PositionXYZ,2), UBOUND(InData%PositionXYZ,2)
DO i1 = LBOUND(InData%PositionXYZ,1), UBOUND(InData%PositionXYZ,1)
ReKiBuf(Re_Xferred) = InData%PositionXYZ(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
CALL Lidar_PackInput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, OnlySize ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE InflowWind_PackInput
SUBROUTINE InflowWind_UnPackInput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_InputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackInput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! PositionXYZ not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%PositionXYZ)) DEALLOCATE(OutData%PositionXYZ)
ALLOCATE(OutData%PositionXYZ(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%PositionXYZ.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%PositionXYZ,2), UBOUND(OutData%PositionXYZ,2)
DO i1 = LBOUND(OutData%PositionXYZ,1), UBOUND(OutData%PositionXYZ,1)
OutData%PositionXYZ(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL Lidar_UnpackInput( Re_Buf, Db_Buf, Int_Buf, OutData%lidar, ErrStat2, ErrMsg2 ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE InflowWind_UnPackInput
SUBROUTINE InflowWind_CopyOutput( SrcOutputData, DstOutputData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_OutputType), INTENT(IN) :: SrcOutputData
TYPE(InflowWind_OutputType), INTENT(INOUT) :: DstOutputData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyOutput'
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(SrcOutputData%VelocityUVW)) THEN
i1_l = LBOUND(SrcOutputData%VelocityUVW,1)
i1_u = UBOUND(SrcOutputData%VelocityUVW,1)
i2_l = LBOUND(SrcOutputData%VelocityUVW,2)
i2_u = UBOUND(SrcOutputData%VelocityUVW,2)
IF (.NOT. ALLOCATED(DstOutputData%VelocityUVW)) THEN
ALLOCATE(DstOutputData%VelocityUVW(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstOutputData%VelocityUVW.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstOutputData%VelocityUVW = SrcOutputData%VelocityUVW
ENDIF
IF (ALLOCATED(SrcOutputData%WriteOutput)) THEN
i1_l = LBOUND(SrcOutputData%WriteOutput,1)
i1_u = UBOUND(SrcOutputData%WriteOutput,1)
IF (.NOT. ALLOCATED(DstOutputData%WriteOutput)) THEN
ALLOCATE(DstOutputData%WriteOutput(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DstOutputData%WriteOutput.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
DstOutputData%WriteOutput = SrcOutputData%WriteOutput
ENDIF
DstOutputData%DiskVel = SrcOutputData%DiskVel
CALL Lidar_CopyOutput( SrcOutputData%lidar, DstOutputData%lidar, CtrlCode, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
IF (ErrStat>=AbortErrLev) RETURN
END SUBROUTINE InflowWind_CopyOutput
SUBROUTINE InflowWind_DestroyOutput( OutputData, ErrStat, ErrMsg )
TYPE(InflowWind_OutputType), INTENT(INOUT) :: OutputData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyOutput'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
IF (ALLOCATED(OutputData%VelocityUVW)) THEN
DEALLOCATE(OutputData%VelocityUVW)
ENDIF
IF (ALLOCATED(OutputData%WriteOutput)) THEN
DEALLOCATE(OutputData%WriteOutput)
ENDIF
CALL Lidar_DestroyOutput( OutputData%lidar, ErrStat, ErrMsg )
END SUBROUTINE InflowWind_DestroyOutput
SUBROUTINE InflowWind_PackOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_OutputType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackOutput'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Int_BufSz = Int_BufSz + 1 ! VelocityUVW allocated yes/no
IF ( ALLOCATED(InData%VelocityUVW) ) THEN
Int_BufSz = Int_BufSz + 2*2 ! VelocityUVW upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%VelocityUVW) ! VelocityUVW
END IF
Int_BufSz = Int_BufSz + 1 ! WriteOutput allocated yes/no
IF ( ALLOCATED(InData%WriteOutput) ) THEN
Int_BufSz = Int_BufSz + 2*1 ! WriteOutput upper/lower bounds for each dimension
Re_BufSz = Re_BufSz + SIZE(InData%WriteOutput) ! WriteOutput
END IF
Re_BufSz = Re_BufSz + SIZE(InData%DiskVel) ! DiskVel
! Allocate buffers for subtypes, if any (we'll get sizes from these)
Int_BufSz = Int_BufSz + 3 ! lidar: size of buffers for each call to pack subtype
CALL Lidar_PackOutput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, .TRUE. ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN ! lidar
Re_BufSz = Re_BufSz + SIZE( Re_Buf )
DEALLOCATE(Re_Buf)
END IF
IF(ALLOCATED(Db_Buf)) THEN ! lidar
Db_BufSz = Db_BufSz + SIZE( Db_Buf )
DEALLOCATE(Db_Buf)
END IF
IF(ALLOCATED(Int_Buf)) THEN ! lidar
Int_BufSz = Int_BufSz + SIZE( Int_Buf )
DEALLOCATE(Int_Buf)
END IF
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( .NOT. ALLOCATED(InData%VelocityUVW) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%VelocityUVW,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%VelocityUVW,1)
Int_Xferred = Int_Xferred + 2
IntKiBuf( Int_Xferred ) = LBOUND(InData%VelocityUVW,2)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%VelocityUVW,2)
Int_Xferred = Int_Xferred + 2
DO i2 = LBOUND(InData%VelocityUVW,2), UBOUND(InData%VelocityUVW,2)
DO i1 = LBOUND(InData%VelocityUVW,1), UBOUND(InData%VelocityUVW,1)
ReKiBuf(Re_Xferred) = InData%VelocityUVW(i1,i2)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
IF ( .NOT. ALLOCATED(InData%WriteOutput) ) THEN
IntKiBuf( Int_Xferred ) = 0
Int_Xferred = Int_Xferred + 1
ELSE
IntKiBuf( Int_Xferred ) = 1
Int_Xferred = Int_Xferred + 1
IntKiBuf( Int_Xferred ) = LBOUND(InData%WriteOutput,1)
IntKiBuf( Int_Xferred + 1) = UBOUND(InData%WriteOutput,1)
Int_Xferred = Int_Xferred + 2
DO i1 = LBOUND(InData%WriteOutput,1), UBOUND(InData%WriteOutput,1)
ReKiBuf(Re_Xferred) = InData%WriteOutput(i1)
Re_Xferred = Re_Xferred + 1
END DO
END IF
DO i1 = LBOUND(InData%DiskVel,1), UBOUND(InData%DiskVel,1)
ReKiBuf(Re_Xferred) = InData%DiskVel(i1)
Re_Xferred = Re_Xferred + 1
END DO
CALL Lidar_PackOutput( Re_Buf, Db_Buf, Int_Buf, InData%lidar, ErrStat2, ErrMsg2, OnlySize ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Re_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Re_Buf) > 0) ReKiBuf( Re_Xferred:Re_Xferred+SIZE(Re_Buf)-1 ) = Re_Buf
Re_Xferred = Re_Xferred + SIZE(Re_Buf)
DEALLOCATE(Re_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Db_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Db_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Db_Buf) > 0) DbKiBuf( Db_Xferred:Db_Xferred+SIZE(Db_Buf)-1 ) = Db_Buf
Db_Xferred = Db_Xferred + SIZE(Db_Buf)
DEALLOCATE(Db_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
IF(ALLOCATED(Int_Buf)) THEN
IntKiBuf( Int_Xferred ) = SIZE(Int_Buf); Int_Xferred = Int_Xferred + 1
IF (SIZE(Int_Buf) > 0) IntKiBuf( Int_Xferred:Int_Xferred+SIZE(Int_Buf)-1 ) = Int_Buf
Int_Xferred = Int_Xferred + SIZE(Int_Buf)
DEALLOCATE(Int_Buf)
ELSE
IntKiBuf( Int_Xferred ) = 0; Int_Xferred = Int_Xferred + 1
ENDIF
END SUBROUTINE InflowWind_PackOutput
SUBROUTINE InflowWind_UnPackOutput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_OutputType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: i1, i1_l, i1_u ! bounds (upper/lower) for an array dimension 1
INTEGER(IntKi) :: i2, i2_l, i2_u ! bounds (upper/lower) for an array dimension 2
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackOutput'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! VelocityUVW not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
i2_l = IntKiBuf( Int_Xferred )
i2_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%VelocityUVW)) DEALLOCATE(OutData%VelocityUVW)
ALLOCATE(OutData%VelocityUVW(i1_l:i1_u,i2_l:i2_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%VelocityUVW.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i2 = LBOUND(OutData%VelocityUVW,2), UBOUND(OutData%VelocityUVW,2)
DO i1 = LBOUND(OutData%VelocityUVW,1), UBOUND(OutData%VelocityUVW,1)
OutData%VelocityUVW(i1,i2) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END DO
END IF
IF ( IntKiBuf( Int_Xferred ) == 0 ) THEN ! WriteOutput not allocated
Int_Xferred = Int_Xferred + 1
ELSE
Int_Xferred = Int_Xferred + 1
i1_l = IntKiBuf( Int_Xferred )
i1_u = IntKiBuf( Int_Xferred + 1)
Int_Xferred = Int_Xferred + 2
IF (ALLOCATED(OutData%WriteOutput)) DEALLOCATE(OutData%WriteOutput)
ALLOCATE(OutData%WriteOutput(i1_l:i1_u),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating OutData%WriteOutput.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
DO i1 = LBOUND(OutData%WriteOutput,1), UBOUND(OutData%WriteOutput,1)
OutData%WriteOutput(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
END IF
i1_l = LBOUND(OutData%DiskVel,1)
i1_u = UBOUND(OutData%DiskVel,1)
DO i1 = LBOUND(OutData%DiskVel,1), UBOUND(OutData%DiskVel,1)
OutData%DiskVel(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Re_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Re_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Re_Buf = ReKiBuf( Re_Xferred:Re_Xferred+Buf_size-1 )
Re_Xferred = Re_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Db_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Db_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Db_Buf = DbKiBuf( Db_Xferred:Db_Xferred+Buf_size-1 )
Db_Xferred = Db_Xferred + Buf_size
END IF
Buf_size=IntKiBuf( Int_Xferred )
Int_Xferred = Int_Xferred + 1
IF(Buf_size > 0) THEN
ALLOCATE(Int_Buf(Buf_size),STAT=ErrStat2)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating Int_Buf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
Int_Buf = IntKiBuf( Int_Xferred:Int_Xferred+Buf_size-1 )
Int_Xferred = Int_Xferred + Buf_size
END IF
CALL Lidar_UnpackOutput( Re_Buf, Db_Buf, Int_Buf, OutData%lidar, ErrStat2, ErrMsg2 ) ! lidar
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN
IF(ALLOCATED(Re_Buf )) DEALLOCATE(Re_Buf )
IF(ALLOCATED(Db_Buf )) DEALLOCATE(Db_Buf )
IF(ALLOCATED(Int_Buf)) DEALLOCATE(Int_Buf)
END SUBROUTINE InflowWind_UnPackOutput
SUBROUTINE InflowWind_CopyContState( SrcContStateData, DstContStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_ContinuousStateType), INTENT(IN) :: SrcContStateData
TYPE(InflowWind_ContinuousStateType), INTENT(INOUT) :: DstContStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyContState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstContStateData%DummyContState = SrcContStateData%DummyContState
END SUBROUTINE InflowWind_CopyContState
SUBROUTINE InflowWind_DestroyContState( ContStateData, ErrStat, ErrMsg )
TYPE(InflowWind_ContinuousStateType), INTENT(INOUT) :: ContStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyContState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE InflowWind_DestroyContState
SUBROUTINE InflowWind_PackContState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_ContinuousStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackContState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyContState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyContState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_PackContState
SUBROUTINE InflowWind_UnPackContState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_ContinuousStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackContState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyContState = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_UnPackContState
SUBROUTINE InflowWind_CopyDiscState( SrcDiscStateData, DstDiscStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_DiscreteStateType), INTENT(IN) :: SrcDiscStateData
TYPE(InflowWind_DiscreteStateType), INTENT(INOUT) :: DstDiscStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyDiscState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstDiscStateData%DummyDiscState = SrcDiscStateData%DummyDiscState
END SUBROUTINE InflowWind_CopyDiscState
SUBROUTINE InflowWind_DestroyDiscState( DiscStateData, ErrStat, ErrMsg )
TYPE(InflowWind_DiscreteStateType), INTENT(INOUT) :: DiscStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyDiscState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE InflowWind_DestroyDiscState
SUBROUTINE InflowWind_PackDiscState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_DiscreteStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackDiscState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyDiscState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyDiscState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_PackDiscState
SUBROUTINE InflowWind_UnPackDiscState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_DiscreteStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackDiscState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyDiscState = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_UnPackDiscState
SUBROUTINE InflowWind_CopyConstrState( SrcConstrStateData, DstConstrStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_ConstraintStateType), INTENT(IN) :: SrcConstrStateData
TYPE(InflowWind_ConstraintStateType), INTENT(INOUT) :: DstConstrStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyConstrState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstConstrStateData%DummyConstrState = SrcConstrStateData%DummyConstrState
END SUBROUTINE InflowWind_CopyConstrState
SUBROUTINE InflowWind_DestroyConstrState( ConstrStateData, ErrStat, ErrMsg )
TYPE(InflowWind_ConstraintStateType), INTENT(INOUT) :: ConstrStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyConstrState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE InflowWind_DestroyConstrState
SUBROUTINE InflowWind_PackConstrState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_ConstraintStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackConstrState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyConstrState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyConstrState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_PackConstrState
SUBROUTINE InflowWind_UnPackConstrState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_ConstraintStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackConstrState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyConstrState = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_UnPackConstrState
SUBROUTINE InflowWind_CopyOtherState( SrcOtherStateData, DstOtherStateData, CtrlCode, ErrStat, ErrMsg )
TYPE(InflowWind_OtherStateType), INTENT(IN) :: SrcOtherStateData
TYPE(InflowWind_OtherStateType), INTENT(INOUT) :: DstOtherStateData
INTEGER(IntKi), INTENT(IN ) :: CtrlCode
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local
INTEGER(IntKi) :: i,j,k
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_CopyOtherState'
!
ErrStat = ErrID_None
ErrMsg = ""
DstOtherStateData%DummyOtherState = SrcOtherStateData%DummyOtherState
END SUBROUTINE InflowWind_CopyOtherState
SUBROUTINE InflowWind_DestroyOtherState( OtherStateData, ErrStat, ErrMsg )
TYPE(InflowWind_OtherStateType), INTENT(INOUT) :: OtherStateData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_DestroyOtherState'
INTEGER(IntKi) :: i, i1, i2, i3, i4, i5
!
ErrStat = ErrID_None
ErrMsg = ""
END SUBROUTINE InflowWind_DestroyOtherState
SUBROUTINE InflowWind_PackOtherState( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMsg, SizeOnly )
REAL(ReKi), ALLOCATABLE, INTENT( OUT) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT( OUT) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT( OUT) :: IntKiBuf(:)
TYPE(InflowWind_OtherStateType), INTENT(IN) :: InData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
LOGICAL,OPTIONAL, INTENT(IN ) :: SizeOnly
! Local variables
INTEGER(IntKi) :: Re_BufSz
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_BufSz
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_BufSz
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i,i1,i2,i3,i4,i5
LOGICAL :: OnlySize ! if present and true, do not pack, just allocate buffers
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_PackOtherState'
! buffers to store subtypes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
OnlySize = .FALSE.
IF ( PRESENT(SizeOnly) ) THEN
OnlySize = SizeOnly
ENDIF
!
ErrStat = ErrID_None
ErrMsg = ""
Re_BufSz = 0
Db_BufSz = 0
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! DummyOtherState
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating ReKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Db_BufSz .GT. 0 ) THEN
ALLOCATE( DbKiBuf( Db_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating DbKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF ( Int_BufSz .GT. 0 ) THEN
ALLOCATE( IntKiBuf( Int_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal, 'Error allocating IntKiBuf.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
END IF
IF(OnlySize) RETURN ! return early if only trying to allocate buffers (not pack them)
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
ReKiBuf(Re_Xferred) = InData%DummyOtherState
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_PackOtherState
SUBROUTINE InflowWind_UnPackOtherState( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
REAL(ReKi), ALLOCATABLE, INTENT(IN ) :: ReKiBuf(:)
REAL(DbKi), ALLOCATABLE, INTENT(IN ) :: DbKiBuf(:)
INTEGER(IntKi), ALLOCATABLE, INTENT(IN ) :: IntKiBuf(:)
TYPE(InflowWind_OtherStateType), INTENT(INOUT) :: OutData
INTEGER(IntKi), INTENT( OUT) :: ErrStat
CHARACTER(*), INTENT( OUT) :: ErrMsg
! Local variables
INTEGER(IntKi) :: Buf_size
INTEGER(IntKi) :: Re_Xferred
INTEGER(IntKi) :: Db_Xferred
INTEGER(IntKi) :: Int_Xferred
INTEGER(IntKi) :: i
INTEGER(IntKi) :: ErrStat2
CHARACTER(ErrMsgLen) :: ErrMsg2
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_UnPackOtherState'
! buffers to store meshes, if any
REAL(ReKi), ALLOCATABLE :: Re_Buf(:)
REAL(DbKi), ALLOCATABLE :: Db_Buf(:)
INTEGER(IntKi), ALLOCATABLE :: Int_Buf(:)
!
ErrStat = ErrID_None
ErrMsg = ""
Re_Xferred = 1
Db_Xferred = 1
Int_Xferred = 1
OutData%DummyOtherState = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END SUBROUTINE InflowWind_UnPackOtherState
SUBROUTINE InflowWind_Input_ExtrapInterp(u, t, u_out, t_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is given by the size of u
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3 (as appropriate)
!
!..................................................................................................................................
TYPE(InflowWind_InputType), INTENT(IN) :: u(:) ! Input at t1 > t2 > t3
REAL(DbKi), INTENT(IN ) :: t(:) ! Times associated with the Inputs
TYPE(InflowWind_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: t_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Input_ExtrapInterp'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
if ( size(t) .ne. size(u)) then
CALL SetErrStat(ErrID_Fatal,'size(t) must equal size(u)',ErrStat,ErrMsg,RoutineName)
RETURN
endif
order = SIZE(u) - 1
IF ( order .eq. 0 ) THEN
CALL InflowWind_CopyInput(u(1), u_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 1 ) THEN
CALL InflowWind_Input_ExtrapInterp1(u(1), u(2), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 2 ) THEN
CALL InflowWind_Input_ExtrapInterp2(u(1), u(2), u(3), t, u_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE
CALL SetErrStat(ErrID_Fatal,'size(u) must be less than 4 (order must be less than 3).',ErrStat,ErrMsg,RoutineName)
RETURN
ENDIF
END SUBROUTINE InflowWind_Input_ExtrapInterp
SUBROUTINE InflowWind_Input_ExtrapInterp1(u1, u2, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = u1, f(t2) = u2
!
!..................................................................................................................................
TYPE(InflowWind_InputType), INTENT(IN) :: u1 ! Input at t1 > t2
TYPE(InflowWind_InputType), INTENT(IN) :: u2 ! Input at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Inputs
TYPE(InflowWind_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Input_ExtrapInterp1'
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / t(2)
IF (ALLOCATED(u_out%PositionXYZ) .AND. ALLOCATED(u1%PositionXYZ)) THEN
DO i2 = LBOUND(u_out%PositionXYZ,2),UBOUND(u_out%PositionXYZ,2)
DO i1 = LBOUND(u_out%PositionXYZ,1),UBOUND(u_out%PositionXYZ,1)
b = -(u1%PositionXYZ(i1,i2) - u2%PositionXYZ(i1,i2))
u_out%PositionXYZ(i1,i2) = u1%PositionXYZ(i1,i2) + b * ScaleFactor
END DO
END DO
END IF ! check if allocated
CALL Lidar_Input_ExtrapInterp1( u1%lidar, u2%lidar, tin, u_out%lidar, tin_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
END SUBROUTINE InflowWind_Input_ExtrapInterp1
SUBROUTINE InflowWind_Input_ExtrapInterp2(u1, u2, u3, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3
!
!..................................................................................................................................
TYPE(InflowWind_InputType), INTENT(IN) :: u1 ! Input at t1 > t2 > t3
TYPE(InflowWind_InputType), INTENT(IN) :: u2 ! Input at t2 > t3
TYPE(InflowWind_InputType), INTENT(IN) :: u3 ! Input at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Inputs
TYPE(InflowWind_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: c ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Input_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / (t(2) * t(3) * (t(2) - t(3)))
IF (ALLOCATED(u_out%PositionXYZ) .AND. ALLOCATED(u1%PositionXYZ)) THEN
DO i2 = LBOUND(u_out%PositionXYZ,2),UBOUND(u_out%PositionXYZ,2)
DO i1 = LBOUND(u_out%PositionXYZ,1),UBOUND(u_out%PositionXYZ,1)
b = (t(3)**2*(u1%PositionXYZ(i1,i2) - u2%PositionXYZ(i1,i2)) + t(2)**2*(-u1%PositionXYZ(i1,i2) + u3%PositionXYZ(i1,i2)))* scaleFactor
c = ( (t(2)-t(3))*u1%PositionXYZ(i1,i2) + t(3)*u2%PositionXYZ(i1,i2) - t(2)*u3%PositionXYZ(i1,i2) ) * scaleFactor
u_out%PositionXYZ(i1,i2) = u1%PositionXYZ(i1,i2) + b + c * t_out
END DO
END DO
END IF ! check if allocated
CALL Lidar_Input_ExtrapInterp2( u1%lidar, u2%lidar, u3%lidar, tin, u_out%lidar, tin_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
END SUBROUTINE InflowWind_Input_ExtrapInterp2
SUBROUTINE InflowWind_Output_ExtrapInterp(y, t, y_out, t_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is given by the size of y
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3 (as appropriate)
!
!..................................................................................................................................
TYPE(InflowWind_OutputType), INTENT(IN) :: y(:) ! Output at t1 > t2 > t3
REAL(DbKi), INTENT(IN ) :: t(:) ! Times associated with the Outputs
TYPE(InflowWind_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: t_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Output_ExtrapInterp'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
if ( size(t) .ne. size(y)) then
CALL SetErrStat(ErrID_Fatal,'size(t) must equal size(y)',ErrStat,ErrMsg,RoutineName)
RETURN
endif
order = SIZE(y) - 1
IF ( order .eq. 0 ) THEN
CALL InflowWind_CopyOutput(y(1), y_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 1 ) THEN
CALL InflowWind_Output_ExtrapInterp1(y(1), y(2), t, y_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE IF ( order .eq. 2 ) THEN
CALL InflowWind_Output_ExtrapInterp2(y(1), y(2), y(3), t, y_out, t_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
ELSE
CALL SetErrStat(ErrID_Fatal,'size(y) must be less than 4 (order must be less than 3).',ErrStat,ErrMsg,RoutineName)
RETURN
ENDIF
END SUBROUTINE InflowWind_Output_ExtrapInterp
SUBROUTINE InflowWind_Output_ExtrapInterp1(y1, y2, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = y1, f(t2) = y2
!
!..................................................................................................................................
TYPE(InflowWind_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2
TYPE(InflowWind_OutputType), INTENT(IN) :: y2 ! Output at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Outputs
TYPE(InflowWind_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Output_ExtrapInterp1'
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / t(2)
IF (ALLOCATED(y_out%VelocityUVW) .AND. ALLOCATED(y1%VelocityUVW)) THEN
DO i2 = LBOUND(y_out%VelocityUVW,2),UBOUND(y_out%VelocityUVW,2)
DO i1 = LBOUND(y_out%VelocityUVW,1),UBOUND(y_out%VelocityUVW,1)
b = -(y1%VelocityUVW(i1,i2) - y2%VelocityUVW(i1,i2))
y_out%VelocityUVW(i1,i2) = y1%VelocityUVW(i1,i2) + b * ScaleFactor
END DO
END DO
END IF ! check if allocated
IF (ALLOCATED(y_out%WriteOutput) .AND. ALLOCATED(y1%WriteOutput)) THEN
DO i1 = LBOUND(y_out%WriteOutput,1),UBOUND(y_out%WriteOutput,1)
b = -(y1%WriteOutput(i1) - y2%WriteOutput(i1))
y_out%WriteOutput(i1) = y1%WriteOutput(i1) + b * ScaleFactor
END DO
END IF ! check if allocated
DO i1 = LBOUND(y_out%DiskVel,1),UBOUND(y_out%DiskVel,1)
b = -(y1%DiskVel(i1) - y2%DiskVel(i1))
y_out%DiskVel(i1) = y1%DiskVel(i1) + b * ScaleFactor
END DO
CALL Lidar_Output_ExtrapInterp1( y1%lidar, y2%lidar, tin, y_out%lidar, tin_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
END SUBROUTINE InflowWind_Output_ExtrapInterp1
SUBROUTINE InflowWind_Output_ExtrapInterp2(y1, y2, y3, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3
!
!..................................................................................................................................
TYPE(InflowWind_OutputType), INTENT(IN) :: y1 ! Output at t1 > t2 > t3
TYPE(InflowWind_OutputType), INTENT(IN) :: y2 ! Output at t2 > t3
TYPE(InflowWind_OutputType), INTENT(IN) :: y3 ! Output at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Outputs
TYPE(InflowWind_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: b ! temporary for extrapolation/interpolation
REAL(DbKi) :: c ! temporary for extrapolation/interpolation
REAL(DbKi) :: ScaleFactor ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'InflowWind_Output_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i02 ! dim2 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
INTEGER :: i2 ! dim2 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)
IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF
ScaleFactor = t_out / (t(2) * t(3) * (t(2) - t(3)))
IF (ALLOCATED(y_out%VelocityUVW) .AND. ALLOCATED(y1%VelocityUVW)) THEN
DO i2 = LBOUND(y_out%VelocityUVW,2),UBOUND(y_out%VelocityUVW,2)
DO i1 = LBOUND(y_out%VelocityUVW,1),UBOUND(y_out%VelocityUVW,1)
b = (t(3)**2*(y1%VelocityUVW(i1,i2) - y2%VelocityUVW(i1,i2)) + t(2)**2*(-y1%VelocityUVW(i1,i2) + y3%VelocityUVW(i1,i2)))* scaleFactor
c = ( (t(2)-t(3))*y1%VelocityUVW(i1,i2) + t(3)*y2%VelocityUVW(i1,i2) - t(2)*y3%VelocityUVW(i1,i2) ) * scaleFactor
y_out%VelocityUVW(i1,i2) = y1%VelocityUVW(i1,i2) + b + c * t_out
END DO
END DO
END IF ! check if allocated
IF (ALLOCATED(y_out%WriteOutput) .AND. ALLOCATED(y1%WriteOutput)) THEN
DO i1 = LBOUND(y_out%WriteOutput,1),UBOUND(y_out%WriteOutput,1)
b = (t(3)**2*(y1%WriteOutput(i1) - y2%WriteOutput(i1)) + t(2)**2*(-y1%WriteOutput(i1) + y3%WriteOutput(i1)))* scaleFactor
c = ( (t(2)-t(3))*y1%WriteOutput(i1) + t(3)*y2%WriteOutput(i1) - t(2)*y3%WriteOutput(i1) ) * scaleFactor
y_out%WriteOutput(i1) = y1%WriteOutput(i1) + b + c * t_out
END DO
END IF ! check if allocated
DO i1 = LBOUND(y_out%DiskVel,1),UBOUND(y_out%DiskVel,1)
b = (t(3)**2*(y1%DiskVel(i1) - y2%DiskVel(i1)) + t(2)**2*(-y1%DiskVel(i1) + y3%DiskVel(i1)))* scaleFactor
c = ( (t(2)-t(3))*y1%DiskVel(i1) + t(3)*y2%DiskVel(i1) - t(2)*y3%DiskVel(i1) ) * scaleFactor
y_out%DiskVel(i1) = y1%DiskVel(i1) + b + c * t_out
END DO
CALL Lidar_Output_ExtrapInterp2( y1%lidar, y2%lidar, y3%lidar, tin, y_out%lidar, tin_out, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
END SUBROUTINE InflowWind_Output_ExtrapInterp2
END MODULE InflowWind_Types
!ENDOFREGISTRYGENERATEDFILE
| apache-2.0 |
foss-for-synopsys-dwc-arc-processors/gcc | gcc/testsuite/gfortran.dg/internal_pack_6.f90 | 12 | 1343 | ! { dg-do compile }
! { dg-options "-O0 -fdump-tree-original" }
!
! Test the fix for PR41113 and PR41117, in which unnecessary calls
! to internal_pack and internal_unpack were being generated.
!
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
!
MODULE M1
TYPE T1
REAL :: data(10) = [(i, i = 1, 10)]
END TYPE T1
CONTAINS
SUBROUTINE S1(data, i, chksum)
REAL, DIMENSION(*) :: data
integer :: i, j
real :: subsum, chksum
subsum = 0
do j = 1, i
subsum = subsum + data(j)
end do
if (abs(subsum - chksum) > 1e-6) STOP 1
END SUBROUTINE S1
END MODULE
SUBROUTINE S2
use m1
TYPE(T1) :: d
real :: data1(10) = [(i, i = 1, 10)]
REAL :: data(-4:5,-4:5) = reshape ([(real(i), i = 1, 100)], [10,10])
! PR41113
CALL S1(d%data, 10, sum (d%data))
CALL S1(data1, 10, sum (data1))
! PR41117
DO i=-4,5
CALL S1(data(:,i), 10, sum (data(:,i)))
ENDDO
! With the fix for PR41113/7 this is the only time that _internal_pack
! was called. The final part of the fix for PR43072 put paid to it too.
DO i=-4,5
CALL S1(data(-2:,i), 8, sum (data(-2:,i)))
ENDDO
DO i=-4,4
CALL S1(data(:,i:i+1), 20, sum (reshape (data(:,i:i+1), [20])))
ENDDO
DO i=-4,5
CALL S1(data(2,i), 1, data(2,i))
ENDDO
END SUBROUTINE S2
call s2
end
! { dg-final { scan-tree-dump-times "_gfortran_internal_pack" 0 "original" } }
| gpl-2.0 |
yaowee/libflame | lapack-test/3.5.0/LIN/sgtt01.f | 32 | 6864 | *> \brief \b SGTT01
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SGTT01( N, DL, D, DU, DLF, DF, DUF, DU2, IPIV, WORK,
* LDWORK, RWORK, RESID )
*
* .. Scalar Arguments ..
* INTEGER LDWORK, N
* REAL RESID
* ..
* .. Array Arguments ..
* INTEGER IPIV( * )
* REAL D( * ), DF( * ), DL( * ), DLF( * ), DU( * ),
* $ DU2( * ), DUF( * ), RWORK( * ),
* $ WORK( LDWORK, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SGTT01 reconstructs a tridiagonal matrix A from its LU factorization
*> and computes the residual
*> norm(L*U - A) / ( norm(A) * EPS ),
*> where EPS is the machine epsilon.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] N
*> \verbatim
*> N is INTEGTER
*> The order of the matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in] DL
*> \verbatim
*> DL is REAL array, dimension (N-1)
*> The (n-1) sub-diagonal elements of A.
*> \endverbatim
*>
*> \param[in] D
*> \verbatim
*> D is REAL array, dimension (N)
*> The diagonal elements of A.
*> \endverbatim
*>
*> \param[in] DU
*> \verbatim
*> DU is REAL array, dimension (N-1)
*> The (n-1) super-diagonal elements of A.
*> \endverbatim
*>
*> \param[in] DLF
*> \verbatim
*> DLF is REAL array, dimension (N-1)
*> The (n-1) multipliers that define the matrix L from the
*> LU factorization of A.
*> \endverbatim
*>
*> \param[in] DF
*> \verbatim
*> DF is REAL array, dimension (N)
*> The n diagonal elements of the upper triangular matrix U from
*> the LU factorization of A.
*> \endverbatim
*>
*> \param[in] DUF
*> \verbatim
*> DUF is REAL array, dimension (N-1)
*> The (n-1) elements of the first super-diagonal of U.
*> \endverbatim
*>
*> \param[in] DU2
*> \verbatim
*> DU2 is REAL array, dimension (N-2)
*> The (n-2) elements of the second super-diagonal of U.
*> \endverbatim
*>
*> \param[in] IPIV
*> \verbatim
*> IPIV is INTEGER array, dimension (N)
*> The pivot indices; for 1 <= i <= n, row i of the matrix was
*> interchanged with row IPIV(i). IPIV(i) will always be either
*> i or i+1; IPIV(i) = i indicates a row interchange was not
*> required.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is REAL array, dimension (LDWORK,N)
*> \endverbatim
*>
*> \param[in] LDWORK
*> \verbatim
*> LDWORK is INTEGER
*> The leading dimension of the array WORK. LDWORK >= max(1,N).
*> \endverbatim
*>
*> \param[out] RWORK
*> \verbatim
*> RWORK is REAL array, dimension (N)
*> \endverbatim
*>
*> \param[out] RESID
*> \verbatim
*> RESID is REAL
*> The scaled residual: norm(L*U - A) / (norm(A) * EPS)
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SGTT01( N, DL, D, DU, DLF, DF, DUF, DU2, IPIV, WORK,
$ LDWORK, RWORK, RESID )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER LDWORK, N
REAL RESID
* ..
* .. Array Arguments ..
INTEGER IPIV( * )
REAL D( * ), DF( * ), DL( * ), DLF( * ), DU( * ),
$ DU2( * ), DUF( * ), RWORK( * ),
$ WORK( LDWORK, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ONE, ZERO
PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
* ..
* .. Local Scalars ..
INTEGER I, IP, J, LASTJ
REAL ANORM, EPS, LI
* ..
* .. External Functions ..
REAL SLAMCH, SLANGT, SLANHS
EXTERNAL SLAMCH, SLANGT, SLANHS
* ..
* .. Intrinsic Functions ..
INTRINSIC MIN
* ..
* .. External Subroutines ..
EXTERNAL SAXPY, SSWAP
* ..
* .. Executable Statements ..
*
* Quick return if possible
*
IF( N.LE.0 ) THEN
RESID = ZERO
RETURN
END IF
*
EPS = SLAMCH( 'Epsilon' )
*
* Copy the matrix U to WORK.
*
DO 20 J = 1, N
DO 10 I = 1, N
WORK( I, J ) = ZERO
10 CONTINUE
20 CONTINUE
DO 30 I = 1, N
IF( I.EQ.1 ) THEN
WORK( I, I ) = DF( I )
IF( N.GE.2 )
$ WORK( I, I+1 ) = DUF( I )
IF( N.GE.3 )
$ WORK( I, I+2 ) = DU2( I )
ELSE IF( I.EQ.N ) THEN
WORK( I, I ) = DF( I )
ELSE
WORK( I, I ) = DF( I )
WORK( I, I+1 ) = DUF( I )
IF( I.LT.N-1 )
$ WORK( I, I+2 ) = DU2( I )
END IF
30 CONTINUE
*
* Multiply on the left by L.
*
LASTJ = N
DO 40 I = N - 1, 1, -1
LI = DLF( I )
CALL SAXPY( LASTJ-I+1, LI, WORK( I, I ), LDWORK,
$ WORK( I+1, I ), LDWORK )
IP = IPIV( I )
IF( IP.EQ.I ) THEN
LASTJ = MIN( I+2, N )
ELSE
CALL SSWAP( LASTJ-I+1, WORK( I, I ), LDWORK, WORK( I+1, I ),
$ LDWORK )
END IF
40 CONTINUE
*
* Subtract the matrix A.
*
WORK( 1, 1 ) = WORK( 1, 1 ) - D( 1 )
IF( N.GT.1 ) THEN
WORK( 1, 2 ) = WORK( 1, 2 ) - DU( 1 )
WORK( N, N-1 ) = WORK( N, N-1 ) - DL( N-1 )
WORK( N, N ) = WORK( N, N ) - D( N )
DO 50 I = 2, N - 1
WORK( I, I-1 ) = WORK( I, I-1 ) - DL( I-1 )
WORK( I, I ) = WORK( I, I ) - D( I )
WORK( I, I+1 ) = WORK( I, I+1 ) - DU( I )
50 CONTINUE
END IF
*
* Compute the 1-norm of the tridiagonal matrix A.
*
ANORM = SLANGT( '1', N, DL, D, DU )
*
* Compute the 1-norm of WORK, which is only guaranteed to be
* upper Hessenberg.
*
RESID = SLANHS( '1', N, WORK, LDWORK, RWORK )
*
* Compute norm(L*U - A) / (norm(A) * EPS)
*
IF( ANORM.LE.ZERO ) THEN
IF( RESID.NE.ZERO )
$ RESID = ONE / EPS
ELSE
RESID = ( RESID / ANORM ) / EPS
END IF
*
RETURN
*
* End of SGTT01
*
END
| bsd-3-clause |
CavendishAstrophysics/anmap | graphic_lib/plot_getcol2.f | 2 | 1813 | C
C
*+ plot_getcol2
subroutine plot_getcol2(minirt,prompt,default,uv_col,status)
C ------------------------------------------------------------
C
C Read a column position - optionally using the cursor
C
C Given:
C mini-redtape
integer minirt(*)
C prompt
character*(*) prompt
C default string
character*(*) default
C
C Returned:
C UV-position
real*4 uv_col
C
C Updated:
C error status
integer status
C
C The user is prompted for a UV column. If the answer supplied is
C CURSOR then the UV column is read from the creen by positioning the
C graphics CURSOR.
C
C [PA, January 1993]
*-
include '../include/plt_error_defn.inc'
include '/mrao/include/chrlib_functions.inc'
character*80 string
real*4 xy(2)
C read the command line
if (status.ne.0) return
string = ' '
write(string,'(F8.1)') uv_col
call io_getstr(prompt,default,string,status)
if (status.ne.0) then
call cmd_err(status,'UV-column',' ')
return
end if
C test for 'cursor' input mode
call chr_chucas(string)
if (chr_cmatch(string(1:chr_lenb(string)),'CURSOR')) then
C .. use cursor input
call plot_cursor_get( xy, status )
else
C .. normal input
call io_setcli(string(1:chr_lenb(string)))
call io_getr(' ',' ',xy(1),status)
if (status.ne.0) then
call cmd_err(status,'UV-column','Error in input position')
status = ill_pos
return
end if
end if
if (xy(1).lt.float(minirt(1)).or.xy(1).gt.float(minirt(2))) then
status = ill_pos
call cmd_wrerr('UV-column','Position outside map')
return
end if
uv_col = xy(1)
end
| bsd-3-clause |
yaowee/libflame | lapack-test/lapack-timing/LIN/ztimtp.f | 4 | 7911 | SUBROUTINE ZTIMTP( LINE, NN, NVAL, NNS, NSVAL, LA, TIMMIN, A, B,
$ RESLTS, LDR1, LDR2, LDR3, NOUT )
*
* -- LAPACK timing routine (version 3.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* March 31, 1993
*
* .. Scalar Arguments ..
CHARACTER*80 LINE
INTEGER LA, LDR1, LDR2, LDR3, NN, NNS, NOUT
DOUBLE PRECISION TIMMIN
* ..
* .. Array Arguments ..
INTEGER NSVAL( * ), NVAL( * )
DOUBLE PRECISION RESLTS( LDR1, LDR2, LDR3, * )
COMPLEX*16 A( * ), B( * )
* ..
*
* Purpose
* =======
*
* ZTIMTP times ZTPTRI and -TRS.
*
* Arguments
* =========
*
* LINE (input) CHARACTER*80
* The input line that requested this routine. The first six
* characters contain either the name of a subroutine or a
* generic path name. The remaining characters may be used to
* specify the individual routines to be timed. See ATIMIN for
* a full description of the format of the input line.
*
* NN (input) INTEGER
* The number of values of N contained in the vector NVAL.
*
* NVAL (input) INTEGER array, dimension (NN)
* The values of the matrix size N.
*
* NNS (input) INTEGER
* The number of values of NRHS contained in the vector NSVAL.
*
* NSVAL (input) INTEGER array, dimension (NNS)
* The values of the number of right hand sides NRHS.
*
* LA (input) INTEGER
* The size of the arrays A and B.
*
* TIMMIN (input) DOUBLE PRECISION
* The minimum time a subroutine will be timed.
*
* A (workspace) COMPLEX*16 array, dimension (LA)
*
* B (workspace) COMPLEX*16 array, dimension (NMAX*NMAX)
* where NMAX is the maximum value of N in NVAL.
*
* RESLTS (output) DOUBLE PRECISION array, dimension
* (LDR1,LDR2,LDR3,NSUBS)
* The timing results for each subroutine over the relevant
* values of N.
*
* LDR1 (input) INTEGER
* The first dimension of RESLTS. LDR1 >= 1.
*
* LDR2 (input) INTEGER
* The second dimension of RESLTS. LDR2 >= max(1,NN).
*
* LDR3 (input) INTEGER
* The third dimension of RESLTS. LDR3 >= 2.
*
* NOUT (input) INTEGER
* The unit number for output.
*
* =====================================================================
*
* .. Parameters ..
INTEGER NSUBS
PARAMETER ( NSUBS = 2 )
* ..
* .. Local Scalars ..
CHARACTER UPLO
CHARACTER*3 PATH
CHARACTER*6 CNAME
INTEGER I, IC, ICL, IN, INFO, ISUB, IUPLO, LDA, LDB,
$ MAT, N, NRHS
DOUBLE PRECISION OPS, S1, S2, TIME, UNTIME
* ..
* .. Local Arrays ..
LOGICAL TIMSUB( NSUBS )
CHARACTER UPLOS( 2 )
CHARACTER*6 SUBNAM( NSUBS )
INTEGER IDUMMY( 1 ), LAVAL( 1 )
* ..
* .. External Functions ..
LOGICAL LSAME
DOUBLE PRECISION DMFLOP, DOPLA, DSECND
EXTERNAL LSAME, DMFLOP, DOPLA, DSECND
* ..
* .. External Subroutines ..
EXTERNAL ATIMCK, ATIMIN, DPRTBL, ZTIMMG, ZTPTRI, ZTPTRS
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, MOD
* ..
* .. Data statements ..
DATA SUBNAM / 'ZTPTRI', 'ZTPTRS' /
DATA UPLOS / 'U', 'L' /
* ..
* .. Executable Statements ..
*
* Extract the timing request from the input line.
*
PATH( 1: 1 ) = 'Zomplex precision'
PATH( 2: 3 ) = 'TP'
CALL ATIMIN( PATH, LINE, NSUBS, SUBNAM, TIMSUB, NOUT, INFO )
IF( INFO.NE.0 )
$ GO TO 100
*
* Check that N*(N+1)/2 <= LA for the input values.
*
CNAME = LINE( 1: 6 )
LAVAL( 1 ) = LA
CALL ATIMCK( 4, CNAME, NN, NVAL, 1, LAVAL, NOUT, INFO )
IF( INFO.GT.0 ) THEN
WRITE( NOUT, FMT = 9999 )CNAME
GO TO 100
END IF
*
* Do first for UPLO = 'U', then for UPLO = 'L'
*
DO 70 IUPLO = 1, 2
UPLO = UPLOS( IUPLO )
IF( LSAME( UPLO, 'U' ) ) THEN
MAT = 12
ELSE
MAT = -12
END IF
*
* Do for each value of N:
*
DO 60 IN = 1, NN
N = NVAL( IN )
LDA = N*( N+1 ) / 2
LDB = N
IF( MOD( N, 2 ).EQ.0 )
$ LDB = LDB + 1
*
* Time ZTPTRI
*
IF( TIMSUB( 1 ) ) THEN
CALL ZTIMMG( MAT, N, N, A, LDA, 0, 0 )
IC = 0
S1 = DSECND( )
10 CONTINUE
CALL ZTPTRI( UPLO, 'Non-unit', N, A, INFO )
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN ) THEN
CALL ZTIMMG( MAT, N, N, A, LDA, 0, 0 )
GO TO 10
END IF
*
* Subtract the time used in ZTIMMG.
*
ICL = 1
S1 = DSECND( )
20 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
ICL = ICL + 1
IF( ICL.LE.IC ) THEN
CALL ZTIMMG( MAT, N, N, A, LDA, 0, 0 )
GO TO 20
END IF
*
TIME = ( TIME-UNTIME ) / DBLE( IC )
OPS = DOPLA( 'ZTPTRI', N, N, 0, 0, 0 )
RESLTS( 1, IN, IUPLO, 1 ) = DMFLOP( OPS, TIME, INFO )
ELSE
*
* Generate a triangular matrix A.
*
CALL ZTIMMG( MAT, N, N, A, LDA, 0, 0 )
END IF
*
* Time ZTPTRS
*
IF( TIMSUB( 2 ) ) THEN
DO 50 I = 1, NNS
NRHS = NSVAL( I )
CALL ZTIMMG( 0, N, NRHS, B, LDB, 0, 0 )
IC = 0
S1 = DSECND( )
30 CONTINUE
CALL ZTPTRS( UPLO, 'No transpose', 'Non-unit', N,
$ NRHS, A, B, LDB, INFO )
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN ) THEN
CALL ZTIMMG( 0, N, NRHS, B, LDB, 0, 0 )
GO TO 30
END IF
*
* Subtract the time used in ZTIMMG.
*
ICL = 1
S1 = DSECND( )
40 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
ICL = ICL + 1
IF( ICL.LE.IC ) THEN
CALL ZTIMMG( 0, N, NRHS, B, LDB, 0, 0 )
GO TO 40
END IF
*
TIME = ( TIME-UNTIME ) / DBLE( IC )
OPS = DOPLA( 'ZTPTRS', N, NRHS, 0, 0, 0 )
RESLTS( I, IN, IUPLO, 2 ) = DMFLOP( OPS, TIME, INFO )
50 CONTINUE
END IF
60 CONTINUE
70 CONTINUE
*
* Print a table of results.
*
DO 90 ISUB = 1, NSUBS
IF( .NOT.TIMSUB( ISUB ) )
$ GO TO 90
WRITE( NOUT, FMT = 9998 )SUBNAM( ISUB )
DO 80 IUPLO = 1, 2
WRITE( NOUT, FMT = 9997 )SUBNAM( ISUB ), UPLOS( IUPLO )
IF( ISUB.EQ.1 ) THEN
CALL DPRTBL( ' ', 'N', 1, IDUMMY, NN, NVAL, 1,
$ RESLTS( 1, 1, IUPLO, 1 ), LDR1, LDR2, NOUT )
ELSE IF( ISUB.EQ.2 ) THEN
CALL DPRTBL( 'NRHS', 'N', NNS, NSVAL, NN, NVAL, 1,
$ RESLTS( 1, 1, IUPLO, 2 ), LDR1, LDR2, NOUT )
END IF
80 CONTINUE
90 CONTINUE
*
100 CONTINUE
9999 FORMAT( 1X, A6, ' timing run not attempted', / )
9998 FORMAT( / ' *** Speed of ', A6, ' in megaflops ***', / )
9997 FORMAT( 5X, A6, ' with UPLO = ''', A1, '''', / )
RETURN
*
* End of ZTIMTP
*
END
| bsd-3-clause |
PPMLibrary/ppm | src/tree/ppm_tree_alloc.f | 1 | 10477 | !-------------------------------------------------------------------------
! Subroutine : ppm_tree_alloc
!-------------------------------------------------------------------------
! Copyright (c) 2012 CSE Lab (ETH Zurich), MOSAIC Group (ETH Zurich),
! Center for Fluid Dynamics (DTU)
!
!
! This file is part of the Parallel Particle Mesh Library (PPM).
!
! PPM is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License
! as published by the Free Software Foundation, either
! version 3 of the License, or (at your option) any later
! version.
!
! PPM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! and the GNU Lesser General Public License along with PPM. If not,
! see <http://www.gnu.org/licenses/>.
!
! Parallel Particle Mesh Library (PPM)
! ETH Zurich
! CH-8092 Zurich, Switzerland
!-------------------------------------------------------------------------
#if __TYPE == __TREE
#if __KIND == __SINGLE_PRECISION
SUBROUTINE ppm_tree_alloc_ts(iopt,nbox,nbpd,nlevel,min_box, &
& max_box,boxcost,parent,nchld,child,blevel,nbpl,info)
#elif __KIND == __DOUBLE_PRECISION
SUBROUTINE ppm_tree_alloc_td(iopt,nbox,nbpd,nlevel,min_box, &
& max_box,boxcost,parent,nchld,child,blevel,nbpl,info)
#endif
#elif __TYPE == __DECOMP
#if __KIND == __SINGLE_PRECISION
SUBROUTINE ppm_tree_alloc_ds(iopt,nbox,nbpd,min_box,max_box, &
& boxcost,nchld,blevel,info)
#elif __KIND == __DOUBLE_PRECISION
SUBROUTINE ppm_tree_alloc_dd(iopt,nbox,nbpd,min_box,max_box, &
& boxcost,nchld,blevel,info)
#endif
#endif
!!! This routine (re)allocates the tree data structures.
!-------------------------------------------------------------------------
! Modules
!-------------------------------------------------------------------------
USE ppm_module_data
USE ppm_module_data_tree
USE ppm_module_substart
USE ppm_module_substop
USE ppm_module_error
USE ppm_module_alloc
IMPLICIT NONE
#if __KIND == __SINGLE_PRECISION
INTEGER, PARAMETER :: MK = ppm_kind_single
#elif __KIND == __DOUBLE_PRECISION
INTEGER, PARAMETER :: MK = ppm_kind_double
#endif
!-------------------------------------------------------------------------
! Includes
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Arguments
!-------------------------------------------------------------------------
REAL(MK), DIMENSION(:,:), POINTER :: min_box
!!! Lower coordinates of the box.
!!!
!!! 1st index: x,y[,z] +
!!! 2nd: box ID
REAL(MK), DIMENSION(:,:), POINTER :: max_box
!!! Upper coordinates of the box.
!!!
!!! 1st index: x,y[,z] +
!!! 2nd: box ID
REAL(MK), DIMENSION(: ), POINTER :: boxcost
!!! Cost of all the boxes.
INTEGER , DIMENSION(: ), POINTER :: nchld
!!! Number of children of each box.
INTEGER , INTENT(IN ) :: iopt
!!! Allocation mode (passed on to ppm_alloc)
INTEGER , INTENT(IN ) :: nbox
!!! New number of boxes to allocate
INTEGER , INTENT(IN ) :: nbpd
!!! Number of children per parent
INTEGER , INTENT( OUT) :: info
!!! Return status, 0 on success
INTEGER , DIMENSION(: ), POINTER :: blevel
!!! Tree level of each box
#if __TYPE == __TREE
INTEGER , INTENT(IN ) :: nlevel
!!! Number of levels in the tree
INTEGER , DIMENSION(: ), POINTER :: parent
!!! Index of the parent box of each box. `ppm_param_undefined` if no
!!! parent (i.e. root box)
INTEGER , DIMENSION(: ), POINTER :: nbpl
!!! The number of boxes per level
INTEGER , DIMENSION(:,:), POINTER :: child
!!! Indices of all children of a box. 1st index: child ID, 2nd: box ID.
#endif
!-------------------------------------------------------------------------
! Local variables
!-------------------------------------------------------------------------
REAL(MK) :: t0
INTEGER, DIMENSION(2) :: ldc
!-------------------------------------------------------------------------
! Externals
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Initialise
!-------------------------------------------------------------------------
CALL substart('ppm_tree_alloc',t0,info)
!-------------------------------------------------------------------------
! Check input arguments
!-------------------------------------------------------------------------
IF (ppm_debug .GT. 0) THEN
CALL check
IF (info .NE. 0) GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Allocate
!-------------------------------------------------------------------------
IF (have_particles) THEN
ldc(1) = 2
ldc(2) = nbox
CALL ppm_alloc(tree_lhbx,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'pointer to headers TREE_LHBX',__LINE__,info)
GOTO 9999
ENDIF
ENDIF
ldc(1) = ppm_dim
ldc(2) = nbox
CALL ppm_alloc(min_box,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'lower box boundaries MIN_BOX',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(max_box,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'upper box boundaries MAX_BOX',__LINE__,info)
GOTO 9999
ENDIF
IF (have_mesh) THEN
CALL ppm_alloc(Nm_box,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'box grid size NM_BOX',__LINE__,info)
GOTO 9999
ENDIF
ENDIF
ldc(1) = nbox
CALL ppm_alloc(ndiv,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'number of divisible directions NDIV',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(blevel,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'tree levels of boxes BLEVEL',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(boxcost,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'box costs BOXCOST',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(nchld,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'number of children NCHLD',__LINE__,info)
GOTO 9999
ENDIF
#if __TYPE == __TREE
ldc(1) = nbpd
ldc(2) = nbox
CALL ppm_alloc(child,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'list of children CHILD',__LINE__,info)
GOTO 9999
ENDIF
ldc(1) = nbox
CALL ppm_alloc(parent,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'parent pointer PARENT',__LINE__,info)
GOTO 9999
ENDIF
ldc(1) = nlevel
CALL ppm_alloc(nbpl,ldc,iopt,info)
IF (info.NE.0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_tree_alloc', &
& 'number of boxes per level NBPL',__LINE__,info)
GOTO 9999
ENDIF
#endif
!-------------------------------------------------------------------------
! Return
!-------------------------------------------------------------------------
9999 CONTINUE
CALL substop('ppm_tree_alloc',t0,info)
RETURN
CONTAINS
SUBROUTINE check
IF (nbox .LT. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_tree_alloc', &
& 'Number of boxes must be >= 0',__LINE__,info)
GOTO 8888
ENDIF
IF (nbpd .LT. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_tree_alloc', &
& 'Number of boxes per step must be >= 0',__LINE__,info)
GOTO 8888
ENDIF
#if __TYPE == __TREE
IF (nlevel .LT. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_tree_alloc', &
& 'Number of levels must be >= 0',__LINE__,info)
GOTO 8888
ENDIF
#endif
8888 CONTINUE
END SUBROUTINE check
#if __TYPE == __TREE
#if __KIND == __SINGLE_PRECISION
END SUBROUTINE ppm_tree_alloc_ts
#elif __KIND == __DOUBLE_PRECISION
END SUBROUTINE ppm_tree_alloc_td
#endif
#elif __TYPE == __DECOMP
#if __KIND == __SINGLE_PRECISION
END SUBROUTINE ppm_tree_alloc_ds
#elif __KIND == __DOUBLE_PRECISION
END SUBROUTINE ppm_tree_alloc_dd
#endif
#endif
| gpl-3.0 |
yaowee/libflame | lapack-test/3.5.0/MATGEN/dlaran.f | 33 | 4113 | *> \brief \b DLARAN
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* DOUBLE PRECISION FUNCTION DLARAN( ISEED )
*
* .. Array Arguments ..
* INTEGER ISEED( 4 )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DLARAN returns a random real number from a uniform (0,1)
*> distribution.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in,out] ISEED
*> \verbatim
*> ISEED is INTEGER array, dimension (4)
*> On entry, the seed of the random number generator; the array
*> elements must be between 0 and 4095, and ISEED(4) must be
*> odd.
*> On exit, the seed is updated.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup list_temp
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> This routine uses a multiplicative congruential method with modulus
*> 2**48 and multiplier 33952834046453 (see G.S.Fishman,
*> 'Multiplicative congruential random number generators with modulus
*> 2**b: an exhaustive analysis for b = 32 and a partial analysis for
*> b = 48', Math. Comp. 189, pp 331-344, 1990).
*>
*> 48-bit integers are stored in 4 integer array elements with 12 bits
*> per element. Hence the routine is portable across machines with
*> integers of 32 bits or more.
*> \endverbatim
*>
* =====================================================================
DOUBLE PRECISION FUNCTION DLARAN( ISEED )
*
* -- LAPACK auxiliary routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Array Arguments ..
INTEGER ISEED( 4 )
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER M1, M2, M3, M4
PARAMETER ( M1 = 494, M2 = 322, M3 = 2508, M4 = 2549 )
DOUBLE PRECISION ONE
PARAMETER ( ONE = 1.0D+0 )
INTEGER IPW2
DOUBLE PRECISION R
PARAMETER ( IPW2 = 4096, R = ONE / IPW2 )
* ..
* .. Local Scalars ..
INTEGER IT1, IT2, IT3, IT4
DOUBLE PRECISION RNDOUT
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, MOD
* ..
* .. Executable Statements ..
10 CONTINUE
*
* multiply the seed by the multiplier modulo 2**48
*
IT4 = ISEED( 4 )*M4
IT3 = IT4 / IPW2
IT4 = IT4 - IPW2*IT3
IT3 = IT3 + ISEED( 3 )*M4 + ISEED( 4 )*M3
IT2 = IT3 / IPW2
IT3 = IT3 - IPW2*IT2
IT2 = IT2 + ISEED( 2 )*M4 + ISEED( 3 )*M3 + ISEED( 4 )*M2
IT1 = IT2 / IPW2
IT2 = IT2 - IPW2*IT1
IT1 = IT1 + ISEED( 1 )*M4 + ISEED( 2 )*M3 + ISEED( 3 )*M2 +
$ ISEED( 4 )*M1
IT1 = MOD( IT1, IPW2 )
*
* return updated seed
*
ISEED( 1 ) = IT1
ISEED( 2 ) = IT2
ISEED( 3 ) = IT3
ISEED( 4 ) = IT4
*
* convert 48-bit integer to a real number in the interval (0,1)
*
RNDOUT = R*( DBLE( IT1 )+R*( DBLE( IT2 )+R*( DBLE( IT3 )+R*
$ ( DBLE( IT4 ) ) ) ) )
*
IF (RNDOUT.EQ.1.0D+0) THEN
* If a real number has n bits of precision, and the first
* n bits of the 48-bit integer above happen to be all 1 (which
* will occur about once every 2**n calls), then DLARAN will
* be rounded to exactly 1.0.
* Since DLARAN is not supposed to return exactly 0.0 or 1.0
* (and some callers of DLARAN, such as CLARND, depend on that),
* the statistically correct thing to do in this situation is
* simply to iterate again.
* N.B. the case DLARAN = 0.0 should not be possible.
*
GOTO 10
END IF
*
DLARAN = RNDOUT
RETURN
*
* End of DLARAN
*
END
| bsd-3-clause |
njwilson23/scipy | scipy/integrate/quadpack/dqaws.f | 143 | 8961 | subroutine dqaws(f,a,b,alfa,beta,integr,epsabs,epsrel,result,
* abserr,neval,ier,limit,lenw,last,iwork,work)
c***begin prologue dqaws
c***date written 800101 (yymmdd)
c***revision date 830518 (yymmdd)
c***category no. h2a2a1
c***keywords automatic integrator, special-purpose,
c algebraico-logarithmic end-point singularities,
c clenshaw-curtis, globally adaptive
c***author piessens,robert,appl. math. & progr. div. -k.u.leuven
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
c***purpose the routine calculates an approximation result to a given
c definite integral i = integral of f*w over (a,b),
c (where w shows a singular behaviour at the end points
c see parameter integr).
c hopefully satisfying following claim for accuracy
c abs(i-result).le.max(epsabs,epsrel*abs(i)).
c***description
c
c integration of functions having algebraico-logarithmic
c end point singularities
c standard fortran subroutine
c double precision version
c
c parameters
c on entry
c f - double precision
c function subprogram defining the integrand
c function f(x). the actual name for f needs to be
c declared e x t e r n a l in the driver program.
c
c a - double precision
c lower limit of integration
c
c b - double precision
c upper limit of integration, b.gt.a
c if b.le.a, the routine will end with ier = 6.
c
c alfa - double precision
c parameter in the integrand function, alfa.gt.(-1)
c if alfa.le.(-1), the routine will end with
c ier = 6.
c
c beta - double precision
c parameter in the integrand function, beta.gt.(-1)
c if beta.le.(-1), the routine will end with
c ier = 6.
c
c integr - integer
c indicates which weight function is to be used
c = 1 (x-a)**alfa*(b-x)**beta
c = 2 (x-a)**alfa*(b-x)**beta*log(x-a)
c = 3 (x-a)**alfa*(b-x)**beta*log(b-x)
c = 4 (x-a)**alfa*(b-x)**beta*log(x-a)*log(b-x)
c if integr.lt.1 or integr.gt.4, the routine
c will end with ier = 6.
c
c epsabs - double precision
c absolute accuracy requested
c epsrel - double precision
c relative accuracy requested
c if epsabs.le.0
c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
c the routine will end with ier = 6.
c
c on return
c result - double precision
c approximation to the integral
c
c abserr - double precision
c estimate of the modulus of the absolute error,
c which should equal or exceed abs(i-result)
c
c neval - integer
c number of integrand evaluations
c
c ier - integer
c ier = 0 normal and reliable termination of the
c routine. it is assumed that the requested
c accuracy has been achieved.
c ier.gt.0 abnormal termination of the routine
c the estimates for the integral and error
c are less reliable. it is assumed that the
c requested accuracy has not been achieved.
c error messages
c ier = 1 maximum number of subdivisions allowed
c has been achieved. one can allow more
c subdivisions by increasing the value of
c limit (and taking the according dimension
c adjustments into account). however, if
c this yields no improvement it is advised
c to analyze the integrand, in order to
c determine the integration difficulties
c which prevent the requested tolerance from
c being achieved. in case of a jump
c discontinuity or a local singularity
c of algebraico-logarithmic type at one or
c more interior points of the integration
c range, one should proceed by splitting up
c the interval at these points and calling
c the integrator on the subranges.
c = 2 the occurrence of roundoff error is
c detected, which prevents the requested
c tolerance from being achieved.
c = 3 extremely bad integrand behaviour occurs
c at some points of the integration
c interval.
c = 6 the input is invalid, because
c b.le.a or alfa.le.(-1) or beta.le.(-1) or
c or integr.lt.1 or integr.gt.4 or
c (epsabs.le.0 and
c epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
c or limit.lt.2 or lenw.lt.limit*4.
c result, abserr, neval, last are set to
c zero. except when lenw or limit is invalid
c iwork(1), work(limit*2+1) and
c work(limit*3+1) are set to zero, work(1)
c is set to a and work(limit+1) to b.
c
c dimensioning parameters
c limit - integer
c dimensioning parameter for iwork
c limit determines the maximum number of
c subintervals in the partition of the given
c integration interval (a,b), limit.ge.2.
c if limit.lt.2, the routine will end with ier = 6.
c
c lenw - integer
c dimensioning parameter for work
c lenw must be at least limit*4.
c if lenw.lt.limit*4, the routine will end
c with ier = 6.
c
c last - integer
c on return, last equals the number of
c subintervals produced in the subdivision process,
c which determines the significant number of
c elements actually in the work arrays.
c
c work arrays
c iwork - integer
c vector of dimension limit, the first k
c elements of which contain pointers
c to the error estimates over the subintervals,
c such that work(limit*3+iwork(1)), ...,
c work(limit*3+iwork(k)) form a decreasing
c sequence with k = last if last.le.(limit/2+2),
c and k = limit+1-last otherwise
c
c work - double precision
c vector of dimension lenw
c on return
c work(1), ..., work(last) contain the left
c end points of the subintervals in the
c partition of (a,b),
c work(limit+1), ..., work(limit+last) contain
c the right end points,
c work(limit*2+1), ..., work(limit*2+last)
c contain the integral approximations over
c the subintervals,
c work(limit*3+1), ..., work(limit*3+last)
c contain the error estimates.
c
c***references (none)
c***routines called dqawse,xerror
c***end prologue dqaws
c
double precision a,abserr,alfa,b,beta,epsabs,epsrel,f,result,work
integer ier,integr,iwork,last,lenw,limit,lvl,l1,l2,l3,neval
c
dimension iwork(limit),work(lenw)
c
external f
c
c check validity of limit and lenw.
c
c***first executable statement dqaws
ier = 6
neval = 0
last = 0
result = 0.0d+00
abserr = 0.0d+00
if(limit.lt.2.or.lenw.lt.limit*4) go to 10
c
c prepare call for dqawse.
c
l1 = limit+1
l2 = limit+l1
l3 = limit+l2
c
call dqawse(f,a,b,alfa,beta,integr,epsabs,epsrel,limit,result,
* abserr,neval,ier,work(1),work(l1),work(l2),work(l3),iwork,last)
c
c call error handler if necessary.
c
lvl = 0
10 if(ier.eq.6) lvl = 1
if(ier.ne.0) call xerror('abnormal return from dqaws',26,ier,lvl)
return
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/LIN/clavhe.f | 8 | 17508 | *> \brief \b CLAVHE
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE CLAVHE( UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B,
* LDB, INFO )
*
* .. Scalar Arguments ..
* CHARACTER DIAG, TRANS, UPLO
* INTEGER INFO, LDA, LDB, N, NRHS
* ..
* .. Array Arguments ..
* INTEGER IPIV( * )
* COMPLEX A( LDA, * ), B( LDB, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> CLAVHE performs one of the matrix-vector operations
*> x := A*x or x := A^H*x,
*> where x is an N element vector and A is one of the factors
*> from the symmetric factorization computed by CHETRF.
*> CHETRF produces a factorization of the form
*> U * D * U^H or L * D * L^H,
*> where U (or L) is a product of permutation and unit upper (lower)
*> triangular matrices, U^H (or L^H) is the conjugate transpose of
*> U (or L), and D is Hermitian and block diagonal with 1 x 1 and
*> 2 x 2 diagonal blocks. The multipliers for the transformations
*> and the upper or lower triangular parts of the diagonal blocks
*> are stored in the leading upper or lower triangle of the 2-D
*> array A.
*>
*> If TRANS = 'N' or 'n', CLAVHE multiplies either by U or U * D
*> (or L or L * D).
*> If TRANS = 'C' or 'c', CLAVHE multiplies either by U^H or D * U^H
*> (or L^H or D * L^H ).
*> \endverbatim
*
* Arguments:
* ==========
*
*> \verbatim
*> UPLO - CHARACTER*1
*> On entry, UPLO specifies whether the triangular matrix
*> stored in A is upper or lower triangular.
*> UPLO = 'U' or 'u' The matrix is upper triangular.
*> UPLO = 'L' or 'l' The matrix is lower triangular.
*> Unchanged on exit.
*>
*> TRANS - CHARACTER*1
*> On entry, TRANS specifies the operation to be performed as
*> follows:
*> TRANS = 'N' or 'n' x := A*x.
*> TRANS = 'C' or 'c' x := A^H*x.
*> Unchanged on exit.
*>
*> DIAG - CHARACTER*1
*> On entry, DIAG specifies whether the diagonal blocks are
*> assumed to be unit matrices:
*> DIAG = 'U' or 'u' Diagonal blocks are unit matrices.
*> DIAG = 'N' or 'n' Diagonal blocks are non-unit.
*> Unchanged on exit.
*>
*> N - INTEGER
*> On entry, N specifies the order of the matrix A.
*> N must be at least zero.
*> Unchanged on exit.
*>
*> NRHS - INTEGER
*> On entry, NRHS specifies the number of right hand sides,
*> i.e., the number of vectors x to be multiplied by A.
*> NRHS must be at least zero.
*> Unchanged on exit.
*>
*> A - COMPLEX array, dimension( LDA, N )
*> On entry, A contains a block diagonal matrix and the
*> multipliers of the transformations used to obtain it,
*> stored as a 2-D triangular matrix.
*> Unchanged on exit.
*>
*> LDA - INTEGER
*> On entry, LDA specifies the first dimension of A as declared
*> in the calling ( sub ) program. LDA must be at least
*> max( 1, N ).
*> Unchanged on exit.
*>
*> IPIV - INTEGER array, dimension( N )
*> On entry, IPIV contains the vector of pivot indices as
*> determined by CSYTRF or CHETRF.
*> If IPIV( K ) = K, no interchange was done.
*> If IPIV( K ) <> K but IPIV( K ) > 0, then row K was inter-
*> changed with row IPIV( K ) and a 1 x 1 pivot block was used.
*> If IPIV( K ) < 0 and UPLO = 'U', then row K-1 was exchanged
*> with row | IPIV( K ) | and a 2 x 2 pivot block was used.
*> If IPIV( K ) < 0 and UPLO = 'L', then row K+1 was exchanged
*> with row | IPIV( K ) | and a 2 x 2 pivot block was used.
*>
*> B - COMPLEX array, dimension( LDB, NRHS )
*> On entry, B contains NRHS vectors of length N.
*> On exit, B is overwritten with the product A * B.
*>
*> LDB - INTEGER
*> On entry, LDB contains the leading dimension of B as
*> declared in the calling program. LDB must be at least
*> max( 1, N ).
*> Unchanged on exit.
*>
*> INFO - INTEGER
*> INFO is the error flag.
*> On exit, a value of 0 indicates a successful exit.
*> A negative value, say -K, indicates that the K-th argument
*> has an illegal value.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup complex_lin
*
* =====================================================================
SUBROUTINE CLAVHE( UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B,
$ LDB, INFO )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER DIAG, TRANS, UPLO
INTEGER INFO, LDA, LDB, N, NRHS
* ..
* .. Array Arguments ..
INTEGER IPIV( * )
COMPLEX A( LDA, * ), B( LDB, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
COMPLEX ONE
PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ) )
* ..
* .. Local Scalars ..
LOGICAL NOUNIT
INTEGER J, K, KP
COMPLEX D11, D12, D21, D22, T1, T2
* ..
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* ..
* .. External Subroutines ..
EXTERNAL CGEMV, CGERU, CLACGV, CSCAL, CSWAP, XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, CONJG, MAX
* ..
* .. Executable Statements ..
*
* Test the input parameters.
*
INFO = 0
IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
INFO = -1
ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.LSAME( TRANS, 'C' ) )
$ THEN
INFO = -2
ELSE IF( .NOT.LSAME( DIAG, 'U' ) .AND. .NOT.LSAME( DIAG, 'N' ) )
$ THEN
INFO = -3
ELSE IF( N.LT.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -6
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -9
END IF
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'CLAVHE ', -INFO )
RETURN
END IF
*
* Quick return if possible.
*
IF( N.EQ.0 )
$ RETURN
*
NOUNIT = LSAME( DIAG, 'N' )
*------------------------------------------
*
* Compute B := A * B (No transpose)
*
*------------------------------------------
IF( LSAME( TRANS, 'N' ) ) THEN
*
* Compute B := U*B
* where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1))
*
IF( LSAME( UPLO, 'U' ) ) THEN
*
* Loop forward applying the transformations.
*
K = 1
10 CONTINUE
IF( K.GT.N )
$ GO TO 30
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 pivot block
*
* Multiply by the diagonal element if forming U * D.
*
IF( NOUNIT )
$ CALL CSCAL( NRHS, A( K, K ), B( K, 1 ), LDB )
*
* Multiply by P(K) * inv(U(K)) if K > 1.
*
IF( K.GT.1 ) THEN
*
* Apply the transformation.
*
CALL CGERU( K-1, NRHS, ONE, A( 1, K ), 1, B( K, 1 ),
$ LDB, B( 1, 1 ), LDB )
*
* Interchange if P(K) != I.
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
END IF
K = K + 1
ELSE
*
* 2 x 2 pivot block
*
* Multiply by the diagonal block if forming U * D.
*
IF( NOUNIT ) THEN
D11 = A( K, K )
D22 = A( K+1, K+1 )
D12 = A( K, K+1 )
D21 = CONJG( D12 )
DO 20 J = 1, NRHS
T1 = B( K, J )
T2 = B( K+1, J )
B( K, J ) = D11*T1 + D12*T2
B( K+1, J ) = D21*T1 + D22*T2
20 CONTINUE
END IF
*
* Multiply by P(K) * inv(U(K)) if K > 1.
*
IF( K.GT.1 ) THEN
*
* Apply the transformations.
*
CALL CGERU( K-1, NRHS, ONE, A( 1, K ), 1, B( K, 1 ),
$ LDB, B( 1, 1 ), LDB )
CALL CGERU( K-1, NRHS, ONE, A( 1, K+1 ), 1,
$ B( K+1, 1 ), LDB, B( 1, 1 ), LDB )
*
* Interchange if P(K) != I.
*
KP = ABS( IPIV( K ) )
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
END IF
K = K + 2
END IF
GO TO 10
30 CONTINUE
*
* Compute B := L*B
* where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m)) .
*
ELSE
*
* Loop backward applying the transformations to B.
*
K = N
40 CONTINUE
IF( K.LT.1 )
$ GO TO 60
*
* Test the pivot index. If greater than zero, a 1 x 1
* pivot was used, otherwise a 2 x 2 pivot was used.
*
IF( IPIV( K ).GT.0 ) THEN
*
* 1 x 1 pivot block:
*
* Multiply by the diagonal element if forming L * D.
*
IF( NOUNIT )
$ CALL CSCAL( NRHS, A( K, K ), B( K, 1 ), LDB )
*
* Multiply by P(K) * inv(L(K)) if K < N.
*
IF( K.NE.N ) THEN
KP = IPIV( K )
*
* Apply the transformation.
*
CALL CGERU( N-K, NRHS, ONE, A( K+1, K ), 1,
$ B( K, 1 ), LDB, B( K+1, 1 ), LDB )
*
* Interchange if a permutation was applied at the
* K-th step of the factorization.
*
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
END IF
K = K - 1
*
ELSE
*
* 2 x 2 pivot block:
*
* Multiply by the diagonal block if forming L * D.
*
IF( NOUNIT ) THEN
D11 = A( K-1, K-1 )
D22 = A( K, K )
D21 = A( K, K-1 )
D12 = CONJG( D21 )
DO 50 J = 1, NRHS
T1 = B( K-1, J )
T2 = B( K, J )
B( K-1, J ) = D11*T1 + D12*T2
B( K, J ) = D21*T1 + D22*T2
50 CONTINUE
END IF
*
* Multiply by P(K) * inv(L(K)) if K < N.
*
IF( K.NE.N ) THEN
*
* Apply the transformation.
*
CALL CGERU( N-K, NRHS, ONE, A( K+1, K ), 1,
$ B( K, 1 ), LDB, B( K+1, 1 ), LDB )
CALL CGERU( N-K, NRHS, ONE, A( K+1, K-1 ), 1,
$ B( K-1, 1 ), LDB, B( K+1, 1 ), LDB )
*
* Interchange if a permutation was applied at the
* K-th step of the factorization.
*
KP = ABS( IPIV( K ) )
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
END IF
K = K - 2
END IF
GO TO 40
60 CONTINUE
END IF
*--------------------------------------------------
*
* Compute B := A^H * B (conjugate transpose)
*
*--------------------------------------------------
ELSE
*
* Form B := U^H*B
* where U = P(m)*inv(U(m))* ... *P(1)*inv(U(1))
* and U^H = inv(U^H(1))*P(1)* ... *inv(U^H(m))*P(m)
*
IF( LSAME( UPLO, 'U' ) ) THEN
*
* Loop backward applying the transformations.
*
K = N
70 IF( K.LT.1 )
$ GO TO 90
*
* 1 x 1 pivot block.
*
IF( IPIV( K ).GT.0 ) THEN
IF( K.GT.1 ) THEN
*
* Interchange if P(K) != I.
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
*
* Apply the transformation
* y = y - B' conjg(x),
* where x is a column of A and y is a row of B.
*
CALL CLACGV( NRHS, B( K, 1 ), LDB )
CALL CGEMV( 'Conjugate', K-1, NRHS, ONE, B, LDB,
$ A( 1, K ), 1, ONE, B( K, 1 ), LDB )
CALL CLACGV( NRHS, B( K, 1 ), LDB )
END IF
IF( NOUNIT )
$ CALL CSCAL( NRHS, A( K, K ), B( K, 1 ), LDB )
K = K - 1
*
* 2 x 2 pivot block.
*
ELSE
IF( K.GT.2 ) THEN
*
* Interchange if P(K) != I.
*
KP = ABS( IPIV( K ) )
IF( KP.NE.K-1 )
$ CALL CSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ),
$ LDB )
*
* Apply the transformations
* y = y - B' conjg(x),
* where x is a block column of A and y is a block
* row of B.
*
CALL CLACGV( NRHS, B( K, 1 ), LDB )
CALL CGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB,
$ A( 1, K ), 1, ONE, B( K, 1 ), LDB )
CALL CLACGV( NRHS, B( K, 1 ), LDB )
*
CALL CLACGV( NRHS, B( K-1, 1 ), LDB )
CALL CGEMV( 'Conjugate', K-2, NRHS, ONE, B, LDB,
$ A( 1, K-1 ), 1, ONE, B( K-1, 1 ), LDB )
CALL CLACGV( NRHS, B( K-1, 1 ), LDB )
END IF
*
* Multiply by the diagonal block if non-unit.
*
IF( NOUNIT ) THEN
D11 = A( K-1, K-1 )
D22 = A( K, K )
D12 = A( K-1, K )
D21 = CONJG( D12 )
DO 80 J = 1, NRHS
T1 = B( K-1, J )
T2 = B( K, J )
B( K-1, J ) = D11*T1 + D12*T2
B( K, J ) = D21*T1 + D22*T2
80 CONTINUE
END IF
K = K - 2
END IF
GO TO 70
90 CONTINUE
*
* Form B := L^H*B
* where L = P(1)*inv(L(1))* ... *P(m)*inv(L(m))
* and L^H = inv(L^H(m))*P(m)* ... *inv(L^H(1))*P(1)
*
ELSE
*
* Loop forward applying the L-transformations.
*
K = 1
100 CONTINUE
IF( K.GT.N )
$ GO TO 120
*
* 1 x 1 pivot block
*
IF( IPIV( K ).GT.0 ) THEN
IF( K.LT.N ) THEN
*
* Interchange if P(K) != I.
*
KP = IPIV( K )
IF( KP.NE.K )
$ CALL CSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
*
* Apply the transformation
*
CALL CLACGV( NRHS, B( K, 1 ), LDB )
CALL CGEMV( 'Conjugate', N-K, NRHS, ONE, B( K+1, 1 ),
$ LDB, A( K+1, K ), 1, ONE, B( K, 1 ), LDB )
CALL CLACGV( NRHS, B( K, 1 ), LDB )
END IF
IF( NOUNIT )
$ CALL CSCAL( NRHS, A( K, K ), B( K, 1 ), LDB )
K = K + 1
*
* 2 x 2 pivot block.
*
ELSE
IF( K.LT.N-1 ) THEN
*
* Interchange if P(K) != I.
*
KP = ABS( IPIV( K ) )
IF( KP.NE.K+1 )
$ CALL CSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ),
$ LDB )
*
* Apply the transformation
*
CALL CLACGV( NRHS, B( K+1, 1 ), LDB )
CALL CGEMV( 'Conjugate', N-K-1, NRHS, ONE,
$ B( K+2, 1 ), LDB, A( K+2, K+1 ), 1, ONE,
$ B( K+1, 1 ), LDB )
CALL CLACGV( NRHS, B( K+1, 1 ), LDB )
*
CALL CLACGV( NRHS, B( K, 1 ), LDB )
CALL CGEMV( 'Conjugate', N-K-1, NRHS, ONE,
$ B( K+2, 1 ), LDB, A( K+2, K ), 1, ONE,
$ B( K, 1 ), LDB )
CALL CLACGV( NRHS, B( K, 1 ), LDB )
END IF
*
* Multiply by the diagonal block if non-unit.
*
IF( NOUNIT ) THEN
D11 = A( K, K )
D22 = A( K+1, K+1 )
D21 = A( K+1, K )
D12 = CONJG( D21 )
DO 110 J = 1, NRHS
T1 = B( K, J )
T2 = B( K+1, J )
B( K, J ) = D11*T1 + D12*T2
B( K+1, J ) = D21*T1 + D22*T2
110 CONTINUE
END IF
K = K + 2
END IF
GO TO 100
120 CONTINUE
END IF
*
END IF
RETURN
*
* End of CLAVHE
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/zerrgt.f | 32 | 7682 | *> \brief \b ZERRGT
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE ZERRGT( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZERRGT tests the error exits for the COMPLEX*16 tridiagonal
*> routines.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup complex16_lin
*
* =====================================================================
SUBROUTINE ZERRGT( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 2 )
* ..
* .. Local Scalars ..
CHARACTER*2 C2
INTEGER I, INFO
DOUBLE PRECISION ANORM, RCOND
* ..
* .. Local Arrays ..
INTEGER IP( NMAX )
DOUBLE PRECISION D( NMAX ), DF( NMAX ), R1( NMAX ), R2( NMAX ),
$ RW( NMAX )
COMPLEX*16 B( NMAX ), DL( NMAX ), DLF( NMAX ), DU( NMAX ),
$ DU2( NMAX ), DUF( NMAX ), E( NMAX ),
$ EF( NMAX ), W( NMAX ), X( NMAX )
* ..
* .. External Functions ..
LOGICAL LSAMEN
EXTERNAL LSAMEN
* ..
* .. External Subroutines ..
EXTERNAL ALAESM, CHKXER, ZGTCON, ZGTRFS, ZGTTRF, ZGTTRS,
$ ZPTCON, ZPTRFS, ZPTTRF, ZPTTRS
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
C2 = PATH( 2: 3 )
DO 10 I = 1, NMAX
D( I ) = 1.D0
E( I ) = 2.D0
DL( I ) = 3.D0
DU( I ) = 4.D0
10 CONTINUE
ANORM = 1.0D0
OK = .TRUE.
*
IF( LSAMEN( 2, C2, 'GT' ) ) THEN
*
* Test error exits for the general tridiagonal routines.
*
* ZGTTRF
*
SRNAMT = 'ZGTTRF'
INFOT = 1
CALL ZGTTRF( -1, DL, E, DU, DU2, IP, INFO )
CALL CHKXER( 'ZGTTRF', INFOT, NOUT, LERR, OK )
*
* ZGTTRS
*
SRNAMT = 'ZGTTRS'
INFOT = 1
CALL ZGTTRS( '/', 0, 0, DL, E, DU, DU2, IP, X, 1, INFO )
CALL CHKXER( 'ZGTTRS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGTTRS( 'N', -1, 0, DL, E, DU, DU2, IP, X, 1, INFO )
CALL CHKXER( 'ZGTTRS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGTTRS( 'N', 0, -1, DL, E, DU, DU2, IP, X, 1, INFO )
CALL CHKXER( 'ZGTTRS', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL ZGTTRS( 'N', 2, 1, DL, E, DU, DU2, IP, X, 1, INFO )
CALL CHKXER( 'ZGTTRS', INFOT, NOUT, LERR, OK )
*
* ZGTRFS
*
SRNAMT = 'ZGTRFS'
INFOT = 1
CALL ZGTRFS( '/', 0, 0, DL, E, DU, DLF, EF, DUF, DU2, IP, B, 1,
$ X, 1, R1, R2, W, RW, INFO )
CALL CHKXER( 'ZGTRFS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGTRFS( 'N', -1, 0, DL, E, DU, DLF, EF, DUF, DU2, IP, B,
$ 1, X, 1, R1, R2, W, RW, INFO )
CALL CHKXER( 'ZGTRFS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGTRFS( 'N', 0, -1, DL, E, DU, DLF, EF, DUF, DU2, IP, B,
$ 1, X, 1, R1, R2, W, RW, INFO )
CALL CHKXER( 'ZGTRFS', INFOT, NOUT, LERR, OK )
INFOT = 13
CALL ZGTRFS( 'N', 2, 1, DL, E, DU, DLF, EF, DUF, DU2, IP, B, 1,
$ X, 2, R1, R2, W, RW, INFO )
CALL CHKXER( 'ZGTRFS', INFOT, NOUT, LERR, OK )
INFOT = 15
CALL ZGTRFS( 'N', 2, 1, DL, E, DU, DLF, EF, DUF, DU2, IP, B, 2,
$ X, 1, R1, R2, W, RW, INFO )
CALL CHKXER( 'ZGTRFS', INFOT, NOUT, LERR, OK )
*
* ZGTCON
*
SRNAMT = 'ZGTCON'
INFOT = 1
CALL ZGTCON( '/', 0, DL, E, DU, DU2, IP, ANORM, RCOND, W,
$ INFO )
CALL CHKXER( 'ZGTCON', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGTCON( 'I', -1, DL, E, DU, DU2, IP, ANORM, RCOND, W,
$ INFO )
CALL CHKXER( 'ZGTCON', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL ZGTCON( 'I', 0, DL, E, DU, DU2, IP, -ANORM, RCOND, W,
$ INFO )
CALL CHKXER( 'ZGTCON', INFOT, NOUT, LERR, OK )
*
ELSE IF( LSAMEN( 2, C2, 'PT' ) ) THEN
*
* Test error exits for the positive definite tridiagonal
* routines.
*
* ZPTTRF
*
SRNAMT = 'ZPTTRF'
INFOT = 1
CALL ZPTTRF( -1, D, E, INFO )
CALL CHKXER( 'ZPTTRF', INFOT, NOUT, LERR, OK )
*
* ZPTTRS
*
SRNAMT = 'ZPTTRS'
INFOT = 1
CALL ZPTTRS( '/', 1, 0, D, E, X, 1, INFO )
CALL CHKXER( 'ZPTTRS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZPTTRS( 'U', -1, 0, D, E, X, 1, INFO )
CALL CHKXER( 'ZPTTRS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZPTTRS( 'U', 0, -1, D, E, X, 1, INFO )
CALL CHKXER( 'ZPTTRS', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL ZPTTRS( 'U', 2, 1, D, E, X, 1, INFO )
CALL CHKXER( 'ZPTTRS', INFOT, NOUT, LERR, OK )
*
* ZPTRFS
*
SRNAMT = 'ZPTRFS'
INFOT = 1
CALL ZPTRFS( '/', 1, 0, D, E, DF, EF, B, 1, X, 1, R1, R2, W,
$ RW, INFO )
CALL CHKXER( 'ZPTRFS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZPTRFS( 'U', -1, 0, D, E, DF, EF, B, 1, X, 1, R1, R2, W,
$ RW, INFO )
CALL CHKXER( 'ZPTRFS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZPTRFS( 'U', 0, -1, D, E, DF, EF, B, 1, X, 1, R1, R2, W,
$ RW, INFO )
CALL CHKXER( 'ZPTRFS', INFOT, NOUT, LERR, OK )
INFOT = 9
CALL ZPTRFS( 'U', 2, 1, D, E, DF, EF, B, 1, X, 2, R1, R2, W,
$ RW, INFO )
CALL CHKXER( 'ZPTRFS', INFOT, NOUT, LERR, OK )
INFOT = 11
CALL ZPTRFS( 'U', 2, 1, D, E, DF, EF, B, 2, X, 1, R1, R2, W,
$ RW, INFO )
CALL CHKXER( 'ZPTRFS', INFOT, NOUT, LERR, OK )
*
* ZPTCON
*
SRNAMT = 'ZPTCON'
INFOT = 1
CALL ZPTCON( -1, D, E, ANORM, RCOND, RW, INFO )
CALL CHKXER( 'ZPTCON', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZPTCON( 0, D, E, -ANORM, RCOND, RW, INFO )
CALL CHKXER( 'ZPTCON', INFOT, NOUT, LERR, OK )
END IF
*
* Print a summary line.
*
CALL ALAESM( PATH, OK, NOUT )
*
RETURN
*
* End of ZERRGT
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/zchkaa.f | 4 | 33849 | *> \brief \b ZCHKAA
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* PROGRAM ZCHKAA
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZCHKAA is the main test program for the COMPLEX*16 linear equation
*> routines.
*>
*> The program must be driven by a short data file. The first 15 records
*> (not including the first comment line) specify problem dimensions
*> and program options using list-directed input. The remaining lines
*> specify the LAPACK test paths and the number of matrix types to use
*> in testing. An annotated example of a data file can be obtained by
*> deleting the first 3 characters from the following 42 lines:
*> Data file for testing COMPLEX*16 LAPACK linear equation routines
*> 7 Number of values of M
*> 0 1 2 3 5 10 16 Values of M (row dimension)
*> 7 Number of values of N
*> 0 1 2 3 5 10 16 Values of N (column dimension)
*> 1 Number of values of NRHS
*> 2 Values of NRHS (number of right hand sides)
*> 5 Number of values of NB
*> 1 3 3 3 20 Values of NB (the blocksize)
*> 1 0 5 9 1 Values of NX (crossover point)
*> 3 Number of values of RANK
*> 30 50 90 Values of rank (as a % of N)
*> 30.0 Threshold value of test ratio
*> T Put T to test the LAPACK routines
*> T Put T to test the driver routines
*> T Put T to test the error exits
*> ZGE 11 List types on next line if 0 < NTYPES < 11
*> ZGB 8 List types on next line if 0 < NTYPES < 8
*> ZGT 12 List types on next line if 0 < NTYPES < 12
*> ZPO 9 List types on next line if 0 < NTYPES < 9
*> ZPS 9 List types on next line if 0 < NTYPES < 9
*> ZPP 9 List types on next line if 0 < NTYPES < 9
*> ZPB 8 List types on next line if 0 < NTYPES < 8
*> ZPT 12 List types on next line if 0 < NTYPES < 12
*> ZHE 10 List types on next line if 0 < NTYPES < 10
*> ZHR 10 List types on next line if 0 < NTYPES < 10
*> ZHP 10 List types on next line if 0 < NTYPES < 10
*> ZSY 11 List types on next line if 0 < NTYPES < 11
*> ZSR 11 List types on next line if 0 < NTYPES < 11
*> ZSP 11 List types on next line if 0 < NTYPES < 11
*> ZTR 18 List types on next line if 0 < NTYPES < 18
*> ZTP 18 List types on next line if 0 < NTYPES < 18
*> ZTB 17 List types on next line if 0 < NTYPES < 17
*> ZQR 8 List types on next line if 0 < NTYPES < 8
*> ZRQ 8 List types on next line if 0 < NTYPES < 8
*> ZLQ 8 List types on next line if 0 < NTYPES < 8
*> ZQL 8 List types on next line if 0 < NTYPES < 8
*> ZQP 6 List types on next line if 0 < NTYPES < 6
*> ZTZ 3 List types on next line if 0 < NTYPES < 3
*> ZLS 6 List types on next line if 0 < NTYPES < 6
*> ZEQ
*> ZQT
*> ZQX
*> \endverbatim
*
* Parameters:
* ==========
*
*> \verbatim
*> NMAX INTEGER
*> The maximum allowable value for M and N.
*>
*> MAXIN INTEGER
*> The number of different values that can be used for each of
*> M, N, NRHS, NB, NX and RANK
*>
*> MAXRHS INTEGER
*> The maximum number of right hand sides
*>
*> MATMAX INTEGER
*> The maximum number of matrix types to use for testing
*>
*> NIN INTEGER
*> The unit number for input
*>
*> NOUT INTEGER
*> The unit number for output
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2013
*
*> \ingroup complex16_lin
*
* =====================================================================
PROGRAM ZCHKAA
*
* -- LAPACK test routine (version 3.5.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2013
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 132 )
INTEGER MAXIN
PARAMETER ( MAXIN = 12 )
INTEGER MAXRHS
PARAMETER ( MAXRHS = 16 )
INTEGER MATMAX
PARAMETER ( MATMAX = 30 )
INTEGER NIN, NOUT
PARAMETER ( NIN = 5, NOUT = 6 )
INTEGER KDMAX
PARAMETER ( KDMAX = NMAX+( NMAX+1 ) / 4 )
* ..
* .. Local Scalars ..
LOGICAL FATAL, TSTCHK, TSTDRV, TSTERR
CHARACTER C1
CHARACTER*2 C2
CHARACTER*3 PATH
CHARACTER*10 INTSTR
CHARACTER*72 ALINE
INTEGER I, IC, J, K, LA, LAFAC, LDA, NB, NM, NMATS, NN,
$ NNB, NNB2, NNS, NRHS, NTYPES, NRANK,
$ VERS_MAJOR, VERS_MINOR, VERS_PATCH
DOUBLE PRECISION EPS, S1, S2, THREQ, THRESH
* ..
* .. Local Arrays ..
LOGICAL DOTYPE( MATMAX )
INTEGER IWORK( 25*NMAX ), MVAL( MAXIN ),
$ NBVAL( MAXIN ), NBVAL2( MAXIN ),
$ NSVAL( MAXIN ), NVAL( MAXIN ), NXVAL( MAXIN ),
$ RANKVAL( MAXIN ), PIV( NMAX )
DOUBLE PRECISION RWORK( 150*NMAX+2*MAXRHS ), S( 2*NMAX )
COMPLEX*16 A( ( KDMAX+1 )*NMAX, 7 ), B( NMAX*MAXRHS, 4 ),
$ WORK( NMAX, NMAX+MAXRHS+10 )
* ..
* .. External Functions ..
LOGICAL LSAME, LSAMEN
DOUBLE PRECISION DLAMCH, DSECND
EXTERNAL LSAME, LSAMEN, DLAMCH, DSECND
* ..
* .. External Subroutines ..
EXTERNAL ALAREQ, ZCHKEQ, ZCHKGB, ZCHKGE, ZCHKGT, ZCHKHE,
$ ZCHKHE_ROOK, ZCHKHP, ZCHKLQ, ZCHKPB, ZCHKPO,
$ ZCHKPS, ZCHKPP, ZCHKPT, ZCHKQ3, ZCHKQL, ZCHKQP,
$ ZCHKQR, ZCHKRQ, ZCHKSP, ZCHKSY, ZCHKSY_ROOK,
$ ZCHKTB, ZCHKTP, ZCHKTR, ZCHKTZ, ZDRVGB, ZDRVGE,
$ ZDRVGT, ZDRVHE, ZDRVHE_ROOK, ZDRVHP, ZDRVLS,
$ ZDRVPB, ZDRVPO, ZDRVPP, ZDRVPT, ZDRVSP, ZDRVSY,
$ ZDRVSY_ROOK, ILAVER, ZCHKQRT, ZCHKQRTP
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NUNIT
* ..
* .. Arrays in Common ..
INTEGER IPARMS( 100 )
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NUNIT, OK, LERR
COMMON / SRNAMC / SRNAMT
COMMON / CLAENV / IPARMS
* ..
* .. Data statements ..
DATA THREQ / 2.0D0 / , INTSTR / '0123456789' /
* ..
* .. Executable Statements ..
*
#ifdef __FLAME__
CALL FLA_INIT
#endif
S1 = DSECND( )
LDA = NMAX
FATAL = .FALSE.
*
* Read a dummy line.
*
READ( NIN, FMT = * )
*
* Report values of parameters.
*
CALL ILAVER( VERS_MAJOR, VERS_MINOR, VERS_PATCH )
WRITE( NOUT, FMT = 9994 ) VERS_MAJOR, VERS_MINOR, VERS_PATCH
*
* Read the values of M
*
READ( NIN, FMT = * )NM
IF( NM.LT.1 ) THEN
WRITE( NOUT, FMT = 9996 )' NM ', NM, 1
NM = 0
FATAL = .TRUE.
ELSE IF( NM.GT.MAXIN ) THEN
WRITE( NOUT, FMT = 9995 )' NM ', NM, MAXIN
NM = 0
FATAL = .TRUE.
END IF
READ( NIN, FMT = * )( MVAL( I ), I = 1, NM )
DO 10 I = 1, NM
IF( MVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )' M ', MVAL( I ), 0
FATAL = .TRUE.
ELSE IF( MVAL( I ).GT.NMAX ) THEN
WRITE( NOUT, FMT = 9995 )' M ', MVAL( I ), NMAX
FATAL = .TRUE.
END IF
10 CONTINUE
IF( NM.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'M ', ( MVAL( I ), I = 1, NM )
*
* Read the values of N
*
READ( NIN, FMT = * )NN
IF( NN.LT.1 ) THEN
WRITE( NOUT, FMT = 9996 )' NN ', NN, 1
NN = 0
FATAL = .TRUE.
ELSE IF( NN.GT.MAXIN ) THEN
WRITE( NOUT, FMT = 9995 )' NN ', NN, MAXIN
NN = 0
FATAL = .TRUE.
END IF
READ( NIN, FMT = * )( NVAL( I ), I = 1, NN )
DO 20 I = 1, NN
IF( NVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )' N ', NVAL( I ), 0
FATAL = .TRUE.
ELSE IF( NVAL( I ).GT.NMAX ) THEN
WRITE( NOUT, FMT = 9995 )' N ', NVAL( I ), NMAX
FATAL = .TRUE.
END IF
20 CONTINUE
IF( NN.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'N ', ( NVAL( I ), I = 1, NN )
*
* Read the values of NRHS
*
READ( NIN, FMT = * )NNS
IF( NNS.LT.1 ) THEN
WRITE( NOUT, FMT = 9996 )' NNS', NNS, 1
NNS = 0
FATAL = .TRUE.
ELSE IF( NNS.GT.MAXIN ) THEN
WRITE( NOUT, FMT = 9995 )' NNS', NNS, MAXIN
NNS = 0
FATAL = .TRUE.
END IF
READ( NIN, FMT = * )( NSVAL( I ), I = 1, NNS )
DO 30 I = 1, NNS
IF( NSVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )'NRHS', NSVAL( I ), 0
FATAL = .TRUE.
ELSE IF( NSVAL( I ).GT.MAXRHS ) THEN
WRITE( NOUT, FMT = 9995 )'NRHS', NSVAL( I ), MAXRHS
FATAL = .TRUE.
END IF
30 CONTINUE
IF( NNS.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'NRHS', ( NSVAL( I ), I = 1, NNS )
*
* Read the values of NB
*
READ( NIN, FMT = * )NNB
IF( NNB.LT.1 ) THEN
WRITE( NOUT, FMT = 9996 )'NNB ', NNB, 1
NNB = 0
FATAL = .TRUE.
ELSE IF( NNB.GT.MAXIN ) THEN
WRITE( NOUT, FMT = 9995 )'NNB ', NNB, MAXIN
NNB = 0
FATAL = .TRUE.
END IF
READ( NIN, FMT = * )( NBVAL( I ), I = 1, NNB )
DO 40 I = 1, NNB
IF( NBVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )' NB ', NBVAL( I ), 0
FATAL = .TRUE.
END IF
40 CONTINUE
IF( NNB.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'NB ', ( NBVAL( I ), I = 1, NNB )
*
* Set NBVAL2 to be the set of unique values of NB
*
NNB2 = 0
DO 60 I = 1, NNB
NB = NBVAL( I )
DO 50 J = 1, NNB2
IF( NB.EQ.NBVAL2( J ) )
$ GO TO 60
50 CONTINUE
NNB2 = NNB2 + 1
NBVAL2( NNB2 ) = NB
60 CONTINUE
*
* Read the values of NX
*
READ( NIN, FMT = * )( NXVAL( I ), I = 1, NNB )
DO 70 I = 1, NNB
IF( NXVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )' NX ', NXVAL( I ), 0
FATAL = .TRUE.
END IF
70 CONTINUE
IF( NNB.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'NX ', ( NXVAL( I ), I = 1, NNB )
*
* Read the values of RANKVAL
*
READ( NIN, FMT = * )NRANK
IF( NN.LT.1 ) THEN
WRITE( NOUT, FMT = 9996 )' NRANK ', NRANK, 1
NRANK = 0
FATAL = .TRUE.
ELSE IF( NN.GT.MAXIN ) THEN
WRITE( NOUT, FMT = 9995 )' NRANK ', NRANK, MAXIN
NRANK = 0
FATAL = .TRUE.
END IF
READ( NIN, FMT = * )( RANKVAL( I ), I = 1, NRANK )
DO I = 1, NRANK
IF( RANKVAL( I ).LT.0 ) THEN
WRITE( NOUT, FMT = 9996 )' RANK ', RANKVAL( I ), 0
FATAL = .TRUE.
ELSE IF( RANKVAL( I ).GT.100 ) THEN
WRITE( NOUT, FMT = 9995 )' RANK ', RANKVAL( I ), 100
FATAL = .TRUE.
END IF
END DO
IF( NRANK.GT.0 )
$ WRITE( NOUT, FMT = 9993 )'RANK % OF N',
$ ( RANKVAL( I ), I = 1, NRANK )
*
* Read the threshold value for the test ratios.
*
READ( NIN, FMT = * )THRESH
WRITE( NOUT, FMT = 9992 )THRESH
*
* Read the flag that indicates whether to test the LAPACK routines.
*
READ( NIN, FMT = * )TSTCHK
*
* Read the flag that indicates whether to test the driver routines.
*
READ( NIN, FMT = * )TSTDRV
*
* Read the flag that indicates whether to test the error exits.
*
READ( NIN, FMT = * )TSTERR
*
IF( FATAL ) THEN
WRITE( NOUT, FMT = 9999 )
STOP
END IF
*
* Calculate and print the machine dependent constants.
*
EPS = DLAMCH( 'Underflow threshold' )
WRITE( NOUT, FMT = 9991 )'underflow', EPS
EPS = DLAMCH( 'Overflow threshold' )
WRITE( NOUT, FMT = 9991 )'overflow ', EPS
EPS = DLAMCH( 'Epsilon' )
WRITE( NOUT, FMT = 9991 )'precision', EPS
WRITE( NOUT, FMT = * )
NRHS = NSVAL( 1 )
*
80 CONTINUE
*
* Read a test path and the number of matrix types to use.
*
READ( NIN, FMT = '(A72)', END = 140 )ALINE
PATH = ALINE( 1: 3 )
NMATS = MATMAX
I = 3
90 CONTINUE
I = I + 1
IF( I.GT.72 )
$ GO TO 130
IF( ALINE( I: I ).EQ.' ' )
$ GO TO 90
NMATS = 0
100 CONTINUE
C1 = ALINE( I: I )
DO 110 K = 1, 10
IF( C1.EQ.INTSTR( K: K ) ) THEN
IC = K - 1
GO TO 120
END IF
110 CONTINUE
GO TO 130
120 CONTINUE
NMATS = NMATS*10 + IC
I = I + 1
IF( I.GT.72 )
$ GO TO 130
GO TO 100
130 CONTINUE
C1 = PATH( 1: 1 )
C2 = PATH( 2: 3 )
*
* Check first character for correct precision.
*
IF( .NOT.LSAME( C1, 'Zomplex precision' ) ) THEN
WRITE( NOUT, FMT = 9990 )PATH
*
ELSE IF( NMATS.LE.0 ) THEN
*
* Check for a positive number of tests requested.
*
WRITE( NOUT, FMT = 9989 )PATH
*
ELSE IF( LSAMEN( 2, C2, 'GE' ) ) THEN
*
* GE: general matrices
*
NTYPES = 11
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKGE( DOTYPE, NM, MVAL, NN, NVAL, NNB2, NBVAL2, NNS,
$ NSVAL, THRESH, TSTERR, LDA, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVGE( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), B( 1, 4 ), S, WORK,
$ RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'GB' ) ) THEN
*
* GB: general banded matrices
*
LA = ( 2*KDMAX+1 )*NMAX
LAFAC = ( 3*KDMAX+1 )*NMAX
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKGB( DOTYPE, NM, MVAL, NN, NVAL, NNB2, NBVAL2, NNS,
$ NSVAL, THRESH, TSTERR, A( 1, 1 ), LA,
$ A( 1, 3 ), LAFAC, B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVGB( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
$ A( 1, 1 ), LA, A( 1, 3 ), LAFAC, A( 1, 6 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), B( 1, 4 ), S,
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'GT' ) ) THEN
*
* GT: general tridiagonal matrices
*
NTYPES = 12
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKGT( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ A( 1, 1 ), A( 1, 2 ), B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVGT( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
$ A( 1, 1 ), A( 1, 2 ), B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'PO' ) ) THEN
*
* PO: positive definite matrices
*
NTYPES = 9
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKPO( DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVPO( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), B( 1, 4 ), S, WORK,
$ RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'PS' ) ) THEN
*
* PS: positive semi-definite matrices
*
NTYPES = 9
*
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKPS( DOTYPE, NN, NVAL, NNB2, NBVAL2, NRANK,
$ RANKVAL, THRESH, TSTERR, LDA, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), PIV, WORK, RWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'PP' ) ) THEN
*
* PP: positive definite packed matrices
*
NTYPES = 9
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKPP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), A( 1, 3 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK, RWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVPP( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), B( 1, 4 ), S, WORK,
$ RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'PB' ) ) THEN
*
* PB: positive definite banded matrices
*
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKPB( DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVPB( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), B( 1, 4 ), S, WORK,
$ RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'PT' ) ) THEN
*
* PT: positive definite tridiagonal matrices
*
NTYPES = 12
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKPT( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ A( 1, 1 ), S, A( 1, 2 ), B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVPT( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
$ A( 1, 1 ), S, A( 1, 2 ), B( 1, 1 ), B( 1, 2 ),
$ B( 1, 3 ), WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'HE' ) ) THEN
*
* HE: Hermitian indefinite matrices
*
NTYPES = 10
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKHE( DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVHE( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'HR' ) ) THEN
*
* HR: Hermitian indefinite matrices,
* with "rook" (bounded Bunch-Kaufman) pivoting algorithm
*
NTYPES = 10
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKHE_ROOK(DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVHE_ROOK( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), A( 1, 3 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK,
$ RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'HP' ) ) THEN
*
* HP: Hermitian indefinite packed matrices
*
NTYPES = 10
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKHP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), A( 1, 3 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK, RWORK,
$ IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVHP( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'SY' ) ) THEN
*
* SY: symmetric indefinite matrices,
* with partial (Bunch-Kaufman) pivoting algorithm
*
NTYPES = 11
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKSY( DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVSY( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'SR' ) ) THEN
*
* SR: symmetric indefinite matrices,
* with "rook" (bounded Bunch-Kaufman) pivoting algorithm
*
NTYPES = 11
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKSY_ROOK(DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ A( 1, 3 ), B( 1, 1 ), B( 1, 2 ), B( 1, 3 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVSY_ROOK( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), A( 1, 3 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK,
$ RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'SP' ) ) THEN
*
* SP: symmetric indefinite packed matrices,
* with partial (Bunch-Kaufman) pivoting algorithm
*
NTYPES = 11
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), A( 1, 3 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK, RWORK,
$ IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
IF( TSTDRV ) THEN
CALL ZDRVSP( DOTYPE, NN, NVAL, NRHS, THRESH, TSTERR, LDA,
$ A( 1, 1 ), A( 1, 2 ), A( 1, 3 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9988 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'TR' ) ) THEN
*
* TR: triangular matrices
*
NTYPES = 18
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKTR( DOTYPE, NN, NVAL, NNB2, NBVAL2, NNS, NSVAL,
$ THRESH, TSTERR, LDA, A( 1, 1 ), A( 1, 2 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), WORK, RWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'TP' ) ) THEN
*
* TP: triangular packed matrices
*
NTYPES = 18
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKTP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'TB' ) ) THEN
*
* TB: triangular banded matrices
*
NTYPES = 17
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKTB( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ LDA, A( 1, 1 ), A( 1, 2 ), B( 1, 1 ),
$ B( 1, 2 ), B( 1, 3 ), WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'QR' ) ) THEN
*
* QR: QR factorization
*
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKQR( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ NRHS, THRESH, TSTERR, NMAX, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), A( 1, 4 ), A( 1, 5 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), B( 1, 4 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'LQ' ) ) THEN
*
* LQ: LQ factorization
*
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKLQ( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ NRHS, THRESH, TSTERR, NMAX, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), A( 1, 4 ), A( 1, 5 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), B( 1, 4 ),
$ WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'QL' ) ) THEN
*
* QL: QL factorization
*
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKQL( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ NRHS, THRESH, TSTERR, NMAX, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), A( 1, 4 ), A( 1, 5 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), B( 1, 4 ),
$ WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'RQ' ) ) THEN
*
* RQ: RQ factorization
*
NTYPES = 8
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKRQ( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ NRHS, THRESH, TSTERR, NMAX, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), A( 1, 4 ), A( 1, 5 ),
$ B( 1, 1 ), B( 1, 2 ), B( 1, 3 ), B( 1, 4 ),
$ WORK, RWORK, IWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'EQ' ) ) THEN
*
* EQ: Equilibration routines for general and positive definite
* matrices (THREQ should be between 2 and 10)
*
IF( TSTCHK ) THEN
CALL ZCHKEQ( THREQ, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'TZ' ) ) THEN
*
* TZ: Trapezoidal matrix
*
NTYPES = 3
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKTZ( DOTYPE, NM, MVAL, NN, NVAL, THRESH, TSTERR,
$ A( 1, 1 ), A( 1, 2 ), S( 1 ),
$ B( 1, 1 ), WORK, RWORK, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'QP' ) ) THEN
*
* QP: QR factorization with pivoting
*
NTYPES = 6
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTCHK ) THEN
CALL ZCHKQP( DOTYPE, NM, MVAL, NN, NVAL, THRESH, TSTERR,
$ A( 1, 1 ), A( 1, 2 ), S( 1 ),
$ B( 1, 1 ), WORK, RWORK, IWORK, NOUT )
CALL ZCHKQ3( DOTYPE, NM, MVAL, NN, NVAL, NNB, NBVAL, NXVAL,
$ THRESH, A( 1, 1 ), A( 1, 2 ), S( 1 ),
$ B( 1, 1 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'LS' ) ) THEN
*
* LS: Least squares drivers
*
NTYPES = 6
CALL ALAREQ( PATH, NMATS, DOTYPE, NTYPES, NIN, NOUT )
*
IF( TSTDRV ) THEN
CALL ZDRVLS( DOTYPE, NM, MVAL, NN, NVAL, NNS, NSVAL, NNB,
$ NBVAL, NXVAL, THRESH, TSTERR, A( 1, 1 ),
$ A( 1, 2 ), A( 1, 3 ), A( 1, 4 ), A( 1, 5 ),
$ S( 1 ), S( NMAX+1 ), WORK, RWORK, IWORK,
$ NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
*
ELSE IF( LSAMEN( 2, C2, 'QT' ) ) THEN
*
* QT: QRT routines for general matrices
*
IF( TSTCHK ) THEN
CALL ZCHKQRT( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB,
$ NBVAL, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE IF( LSAMEN( 2, C2, 'QX' ) ) THEN
*
* QX: QRT routines for triangular-pentagonal matrices
*
IF( TSTCHK ) THEN
CALL ZCHKQRTP( THRESH, TSTERR, NM, MVAL, NN, NVAL, NNB,
$ NBVAL, NOUT )
ELSE
WRITE( NOUT, FMT = 9989 )PATH
END IF
*
ELSE
*
WRITE( NOUT, FMT = 9990 )PATH
END IF
*
* Go back to get another input line.
*
GO TO 80
*
* Branch to this line when the last record is read.
*
140 CONTINUE
CLOSE ( NIN )
S2 = DSECND( )
WRITE( NOUT, FMT = 9998 )
WRITE( NOUT, FMT = 9997 )S2 - S1
*
9999 FORMAT( / ' Execution not attempted due to input errors' )
9998 FORMAT( / ' End of tests' )
9997 FORMAT( ' Total time used = ', F12.2, ' seconds', / )
9996 FORMAT( ' Invalid input value: ', A4, '=', I6, '; must be >=',
$ I6 )
9995 FORMAT( ' Invalid input value: ', A4, '=', I6, '; must be <=',
$ I6 )
9994 FORMAT( ' Tests of the COMPLEX*16 LAPACK routines ',
$ / ' LAPACK VERSION ', I1, '.', I1, '.', I1,
$ / / ' The following parameter values will be used:' )
9993 FORMAT( 4X, A4, ': ', 10I6, / 11X, 10I6 )
9992 FORMAT( / ' Routines pass computational tests if test ratio is ',
$ 'less than', F8.2, / )
9991 FORMAT( ' Relative machine ', A, ' is taken to be', D16.6 )
9990 FORMAT( / 1X, A3, ': Unrecognized path name' )
9989 FORMAT( / 1X, A3, ' routines were not tested' )
9988 FORMAT( / 1X, A3, ' driver routines were not tested' )
*
#ifdef __FLAME__
CALL FLA_FINALIZE
#endif
*
* End of ZCHKAA
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/LIN/sdrvrfp.f | 8 | 19359 | *> \brief \b SDRVRFP
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SDRVRFP( NOUT, NN, NVAL, NNS, NSVAL, NNT, NTVAL,
* + THRESH, A, ASAV, AFAC, AINV, B,
* + BSAV, XACT, X, ARF, ARFINV,
* + S_WORK_SLATMS, S_WORK_SPOT01, S_TEMP_SPOT02,
* + S_TEMP_SPOT03, S_WORK_SLANSY,
* + S_WORK_SPOT02, S_WORK_SPOT03 )
*
* .. Scalar Arguments ..
* INTEGER NN, NNS, NNT, NOUT
* REAL THRESH
* ..
* .. Array Arguments ..
* INTEGER NVAL( NN ), NSVAL( NNS ), NTVAL( NNT )
* REAL A( * )
* REAL AINV( * )
* REAL ASAV( * )
* REAL B( * )
* REAL BSAV( * )
* REAL AFAC( * )
* REAL ARF( * )
* REAL ARFINV( * )
* REAL XACT( * )
* REAL X( * )
* REAL S_WORK_SLATMS( * )
* REAL S_WORK_SPOT01( * )
* REAL S_TEMP_SPOT02( * )
* REAL S_TEMP_SPOT03( * )
* REAL S_WORK_SLANSY( * )
* REAL S_WORK_SPOT02( * )
* REAL S_WORK_SPOT03( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SDRVRFP tests the LAPACK RFP routines:
*> SPFTRF, SPFTRS, and SPFTRI.
*>
*> This testing routine follow the same tests as DDRVPO (test for the full
*> format Symmetric Positive Definite solver).
*>
*> The tests are performed in Full Format, convertion back and forth from
*> full format to RFP format are performed using the routines STRTTF and
*> STFTTR.
*>
*> First, a specific matrix A of size N is created. There is nine types of
*> different matrixes possible.
*> 1. Diagonal 6. Random, CNDNUM = sqrt(0.1/EPS)
*> 2. Random, CNDNUM = 2 7. Random, CNDNUM = 0.1/EPS
*> *3. First row and column zero 8. Scaled near underflow
*> *4. Last row and column zero 9. Scaled near overflow
*> *5. Middle row and column zero
*> (* - tests error exits from SPFTRF, no test ratios are computed)
*> A solution XACT of size N-by-NRHS is created and the associated right
*> hand side B as well. Then SPFTRF is called to compute L (or U), the
*> Cholesky factor of A. Then L (or U) is used to solve the linear system
*> of equations AX = B. This gives X. Then L (or U) is used to compute the
*> inverse of A, AINV. The following four tests are then performed:
*> (1) norm( L*L' - A ) / ( N * norm(A) * EPS ) or
*> norm( U'*U - A ) / ( N * norm(A) * EPS ),
*> (2) norm(B - A*X) / ( norm(A) * norm(X) * EPS ),
*> (3) norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ),
*> (4) ( norm(X-XACT) * RCOND ) / ( norm(XACT) * EPS ),
*> where EPS is the machine precision, RCOND the condition number of A, and
*> norm( . ) the 1-norm for (1,2,3) and the inf-norm for (4).
*> Errors occur when INFO parameter is not as expected. Failures occur when
*> a test ratios is greater than THRES.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The unit number for output.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER
*> The number of values of N contained in the vector NVAL.
*> \endverbatim
*>
*> \param[in] NVAL
*> \verbatim
*> NVAL is INTEGER array, dimension (NN)
*> The values of the matrix dimension N.
*> \endverbatim
*>
*> \param[in] NNS
*> \verbatim
*> NNS is INTEGER
*> The number of values of NRHS contained in the vector NSVAL.
*> \endverbatim
*>
*> \param[in] NSVAL
*> \verbatim
*> NSVAL is INTEGER array, dimension (NNS)
*> The values of the number of right-hand sides NRHS.
*> \endverbatim
*>
*> \param[in] NNT
*> \verbatim
*> NNT is INTEGER
*> The number of values of MATRIX TYPE contained in the vector NTVAL.
*> \endverbatim
*>
*> \param[in] NTVAL
*> \verbatim
*> NTVAL is INTEGER array, dimension (NNT)
*> The values of matrix type (between 0 and 9 for PO/PP/PF matrices).
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is REAL
*> The threshold value for the test ratios. A result is
*> included in the output file if RESULT >= THRESH. To have
*> every test ratio printed, use THRESH = 0.
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is REAL array, dimension (NMAX*NMAX)
*> \endverbatim
*>
*> \param[out] ASAV
*> \verbatim
*> ASAV is REAL array, dimension (NMAX*NMAX)
*> \endverbatim
*>
*> \param[out] AFAC
*> \verbatim
*> AFAC is REAL array, dimension (NMAX*NMAX)
*> \endverbatim
*>
*> \param[out] AINV
*> \verbatim
*> AINV is REAL array, dimension (NMAX*NMAX)
*> \endverbatim
*>
*> \param[out] B
*> \verbatim
*> B is REAL array, dimension (NMAX*MAXRHS)
*> \endverbatim
*>
*> \param[out] BSAV
*> \verbatim
*> BSAV is REAL array, dimension (NMAX*MAXRHS)
*> \endverbatim
*>
*> \param[out] XACT
*> \verbatim
*> XACT is REAL array, dimension (NMAX*MAXRHS)
*> \endverbatim
*>
*> \param[out] X
*> \verbatim
*> X is REAL array, dimension (NMAX*MAXRHS)
*> \endverbatim
*>
*> \param[out] ARF
*> \verbatim
*> ARF is REAL array, dimension ((NMAX*(NMAX+1))/2)
*> \endverbatim
*>
*> \param[out] ARFINV
*> \verbatim
*> ARFINV is REAL array, dimension ((NMAX*(NMAX+1))/2)
*> \endverbatim
*>
*> \param[out] S_WORK_SLATMS
*> \verbatim
*> S_WORK_SLATMS is REAL array, dimension ( 3*NMAX )
*> \endverbatim
*>
*> \param[out] S_WORK_SPOT01
*> \verbatim
*> S_WORK_SPOT01 is REAL array, dimension ( NMAX )
*> \endverbatim
*>
*> \param[out] S_TEMP_SPOT02
*> \verbatim
*> S_TEMP_SPOT02 is REAL array, dimension ( NMAX*MAXRHS )
*> \endverbatim
*>
*> \param[out] S_TEMP_SPOT03
*> \verbatim
*> S_TEMP_SPOT03 is REAL array, dimension ( NMAX*NMAX )
*> \endverbatim
*>
*> \param[out] S_WORK_SLATMS
*> \verbatim
*> S_WORK_SLATMS is REAL array, dimension ( NMAX )
*> \endverbatim
*>
*> \param[out] S_WORK_SLANSY
*> \verbatim
*> S_WORK_SLANSY is REAL array, dimension ( NMAX )
*> \endverbatim
*>
*> \param[out] S_WORK_SPOT02
*> \verbatim
*> S_WORK_SPOT02 is REAL array, dimension ( NMAX )
*> \endverbatim
*>
*> \param[out] S_WORK_SPOT03
*> \verbatim
*> S_WORK_SPOT03 is REAL array, dimension ( NMAX )
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SDRVRFP( NOUT, NN, NVAL, NNS, NSVAL, NNT, NTVAL,
+ THRESH, A, ASAV, AFAC, AINV, B,
+ BSAV, XACT, X, ARF, ARFINV,
+ S_WORK_SLATMS, S_WORK_SPOT01, S_TEMP_SPOT02,
+ S_TEMP_SPOT03, S_WORK_SLANSY,
+ S_WORK_SPOT02, S_WORK_SPOT03 )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER NN, NNS, NNT, NOUT
REAL THRESH
* ..
* .. Array Arguments ..
INTEGER NVAL( NN ), NSVAL( NNS ), NTVAL( NNT )
REAL A( * )
REAL AINV( * )
REAL ASAV( * )
REAL B( * )
REAL BSAV( * )
REAL AFAC( * )
REAL ARF( * )
REAL ARFINV( * )
REAL XACT( * )
REAL X( * )
REAL S_WORK_SLATMS( * )
REAL S_WORK_SPOT01( * )
REAL S_TEMP_SPOT02( * )
REAL S_TEMP_SPOT03( * )
REAL S_WORK_SLANSY( * )
REAL S_WORK_SPOT02( * )
REAL S_WORK_SPOT03( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ONE, ZERO
PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
INTEGER NTESTS
PARAMETER ( NTESTS = 4 )
* ..
* .. Local Scalars ..
LOGICAL ZEROT
INTEGER I, INFO, IUPLO, LDA, LDB, IMAT, NERRS, NFAIL,
+ NRHS, NRUN, IZERO, IOFF, K, NT, N, IFORM, IIN,
+ IIT, IIS
CHARACTER DIST, CTYPE, UPLO, CFORM
INTEGER KL, KU, MODE
REAL ANORM, AINVNM, CNDNUM, RCONDC
* ..
* .. Local Arrays ..
CHARACTER UPLOS( 2 ), FORMS( 2 )
INTEGER ISEED( 4 ), ISEEDY( 4 )
REAL RESULT( NTESTS )
* ..
* .. External Functions ..
REAL SLANSY
EXTERNAL SLANSY
* ..
* .. External Subroutines ..
EXTERNAL ALADHD, ALAERH, ALASVM, SGET04, STFTTR, SLACPY,
+ SLARHS, SLATB4, SLATMS, SPFTRI, SPFTRF, SPFTRS,
+ SPOT01, SPOT02, SPOT03, SPOTRI, SPOTRF, STRTTF
* ..
* .. Scalars in Common ..
CHARACTER*32 SRNAMT
* ..
* .. Common blocks ..
COMMON / SRNAMC / SRNAMT
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
DATA UPLOS / 'U', 'L' /
DATA FORMS / 'N', 'T' /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
NRUN = 0
NFAIL = 0
NERRS = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
*
DO 130 IIN = 1, NN
*
N = NVAL( IIN )
LDA = MAX( N, 1 )
LDB = MAX( N, 1 )
*
DO 980 IIS = 1, NNS
*
NRHS = NSVAL( IIS )
*
DO 120 IIT = 1, NNT
*
IMAT = NTVAL( IIT )
*
* If N.EQ.0, only consider the first type
*
IF( N.EQ.0 .AND. IIT.GT.1 ) GO TO 120
*
* Skip types 3, 4, or 5 if the matrix size is too small.
*
IF( IMAT.EQ.4 .AND. N.LE.1 ) GO TO 120
IF( IMAT.EQ.5 .AND. N.LE.2 ) GO TO 120
*
* Do first for UPLO = 'U', then for UPLO = 'L'
*
DO 110 IUPLO = 1, 2
UPLO = UPLOS( IUPLO )
*
* Do first for CFORM = 'N', then for CFORM = 'C'
*
DO 100 IFORM = 1, 2
CFORM = FORMS( IFORM )
*
* Set up parameters with SLATB4 and generate a test
* matrix with SLATMS.
*
CALL SLATB4( 'SPO', IMAT, N, N, CTYPE, KL, KU,
+ ANORM, MODE, CNDNUM, DIST )
*
SRNAMT = 'SLATMS'
CALL SLATMS( N, N, DIST, ISEED, CTYPE,
+ S_WORK_SLATMS,
+ MODE, CNDNUM, ANORM, KL, KU, UPLO, A,
+ LDA, S_WORK_SLATMS, INFO )
*
* Check error code from SLATMS.
*
IF( INFO.NE.0 ) THEN
CALL ALAERH( 'SPF', 'SLATMS', INFO, 0, UPLO, N,
+ N, -1, -1, -1, IIT, NFAIL, NERRS,
+ NOUT )
GO TO 100
END IF
*
* For types 3-5, zero one row and column of the matrix to
* test that INFO is returned correctly.
*
ZEROT = IMAT.GE.3 .AND. IMAT.LE.5
IF( ZEROT ) THEN
IF( IIT.EQ.3 ) THEN
IZERO = 1
ELSE IF( IIT.EQ.4 ) THEN
IZERO = N
ELSE
IZERO = N / 2 + 1
END IF
IOFF = ( IZERO-1 )*LDA
*
* Set row and column IZERO of A to 0.
*
IF( IUPLO.EQ.1 ) THEN
DO 20 I = 1, IZERO - 1
A( IOFF+I ) = ZERO
20 CONTINUE
IOFF = IOFF + IZERO
DO 30 I = IZERO, N
A( IOFF ) = ZERO
IOFF = IOFF + LDA
30 CONTINUE
ELSE
IOFF = IZERO
DO 40 I = 1, IZERO - 1
A( IOFF ) = ZERO
IOFF = IOFF + LDA
40 CONTINUE
IOFF = IOFF - IZERO
DO 50 I = IZERO, N
A( IOFF+I ) = ZERO
50 CONTINUE
END IF
ELSE
IZERO = 0
END IF
*
* Save a copy of the matrix A in ASAV.
*
CALL SLACPY( UPLO, N, N, A, LDA, ASAV, LDA )
*
* Compute the condition number of A (RCONDC).
*
IF( ZEROT ) THEN
RCONDC = ZERO
ELSE
*
* Compute the 1-norm of A.
*
ANORM = SLANSY( '1', UPLO, N, A, LDA,
+ S_WORK_SLANSY )
*
* Factor the matrix A.
*
CALL SPOTRF( UPLO, N, A, LDA, INFO )
*
* Form the inverse of A.
*
CALL SPOTRI( UPLO, N, A, LDA, INFO )
*
* Compute the 1-norm condition number of A.
*
AINVNM = SLANSY( '1', UPLO, N, A, LDA,
+ S_WORK_SLANSY )
RCONDC = ( ONE / ANORM ) / AINVNM
*
* Restore the matrix A.
*
CALL SLACPY( UPLO, N, N, ASAV, LDA, A, LDA )
*
END IF
*
* Form an exact solution and set the right hand side.
*
SRNAMT = 'SLARHS'
CALL SLARHS( 'SPO', 'N', UPLO, ' ', N, N, KL, KU,
+ NRHS, A, LDA, XACT, LDA, B, LDA,
+ ISEED, INFO )
CALL SLACPY( 'Full', N, NRHS, B, LDA, BSAV, LDA )
*
* Compute the L*L' or U'*U factorization of the
* matrix and solve the system.
*
CALL SLACPY( UPLO, N, N, A, LDA, AFAC, LDA )
CALL SLACPY( 'Full', N, NRHS, B, LDB, X, LDB )
*
SRNAMT = 'STRTTF'
CALL STRTTF( CFORM, UPLO, N, AFAC, LDA, ARF, INFO )
SRNAMT = 'SPFTRF'
CALL SPFTRF( CFORM, UPLO, N, ARF, INFO )
*
* Check error code from SPFTRF.
*
IF( INFO.NE.IZERO ) THEN
*
* LANGOU: there is a small hick here: IZERO should
* always be INFO however if INFO is ZERO, ALAERH does not
* complain.
*
CALL ALAERH( 'SPF', 'SPFSV ', INFO, IZERO,
+ UPLO, N, N, -1, -1, NRHS, IIT,
+ NFAIL, NERRS, NOUT )
GO TO 100
END IF
*
* Skip the tests if INFO is not 0.
*
IF( INFO.NE.0 ) THEN
GO TO 100
END IF
*
SRNAMT = 'SPFTRS'
CALL SPFTRS( CFORM, UPLO, N, NRHS, ARF, X, LDB,
+ INFO )
*
SRNAMT = 'STFTTR'
CALL STFTTR( CFORM, UPLO, N, ARF, AFAC, LDA, INFO )
*
* Reconstruct matrix from factors and compute
* residual.
*
CALL SLACPY( UPLO, N, N, AFAC, LDA, ASAV, LDA )
CALL SPOT01( UPLO, N, A, LDA, AFAC, LDA,
+ S_WORK_SPOT01, RESULT( 1 ) )
CALL SLACPY( UPLO, N, N, ASAV, LDA, AFAC, LDA )
*
* Form the inverse and compute the residual.
*
IF(MOD(N,2).EQ.0)THEN
CALL SLACPY( 'A', N+1, N/2, ARF, N+1, ARFINV,
+ N+1 )
ELSE
CALL SLACPY( 'A', N, (N+1)/2, ARF, N, ARFINV,
+ N )
END IF
*
SRNAMT = 'SPFTRI'
CALL SPFTRI( CFORM, UPLO, N, ARFINV , INFO )
*
SRNAMT = 'STFTTR'
CALL STFTTR( CFORM, UPLO, N, ARFINV, AINV, LDA,
+ INFO )
*
* Check error code from SPFTRI.
*
IF( INFO.NE.0 )
+ CALL ALAERH( 'SPO', 'SPFTRI', INFO, 0, UPLO, N,
+ N, -1, -1, -1, IMAT, NFAIL, NERRS,
+ NOUT )
*
CALL SPOT03( UPLO, N, A, LDA, AINV, LDA,
+ S_TEMP_SPOT03, LDA, S_WORK_SPOT03,
+ RCONDC, RESULT( 2 ) )
*
* Compute residual of the computed solution.
*
CALL SLACPY( 'Full', N, NRHS, B, LDA,
+ S_TEMP_SPOT02, LDA )
CALL SPOT02( UPLO, N, NRHS, A, LDA, X, LDA,
+ S_TEMP_SPOT02, LDA, S_WORK_SPOT02,
+ RESULT( 3 ) )
*
* Check solution from generated exact solution.
CALL SGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
+ RESULT( 4 ) )
NT = 4
*
* Print information about the tests that did not
* pass the threshold.
*
DO 60 K = 1, NT
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
+ CALL ALADHD( NOUT, 'SPF' )
WRITE( NOUT, FMT = 9999 )'SPFSV ', UPLO,
+ N, IIT, K, RESULT( K )
NFAIL = NFAIL + 1
END IF
60 CONTINUE
NRUN = NRUN + NT
100 CONTINUE
110 CONTINUE
120 CONTINUE
980 CONTINUE
130 CONTINUE
*
* Print a summary of the results.
*
CALL ALASVM( 'SPF', NOUT, NFAIL, NRUN, NERRS )
*
9999 FORMAT( 1X, A6, ', UPLO=''', A1, ''', N =', I5, ', type ', I1,
+ ', test(', I1, ')=', G12.5 )
*
RETURN
*
* End of SDRVRFP
*
END
| bsd-3-clause |
CavendishAstrophysics/anmap | image_lib/image_shift.f | 1 | 2246 | C
C
*+ image_shift
C
subroutine image_shift(minirt,data_in,du,dv,degrid_type,
* data_out,status )
C --------------------------------------------------------
C
C Shift an image by a specified amount on the computing grid
C
C Given:
C mini redtape
integer minirt(8)
C input image data
real*4 data_in(*)
C shift of map on UV grid in U and V
real*8 du, dv
C type of interpolation to use
integer degrid_type
C Returned:
C output image
real*4 data_out(*)
C error return
integer status
C
C
C The input image is shifted by an amount DU, DV on the output grid,
C the map location U,V now becomes the point U+DU, V+DV on the new grid.
C Any pixel on the output map which does not correspond to a location on
C the input map is given the BLANK value.
C
C The type of interpolation to use in the shift must be specified.
*-
C local variables representing U and V on the input map
real*8 u, v, duv_point(2)
equivalence (duv_point(1), u)
equivalence (duv_point(2), v)
C loop counters
integer iu, iv, i, uv_point(2)
equivalence (uv_point(1), iu)
equivalence (uv_point(2), iv)
C window containing real data in output map
integer iu1, iu2, iv1, iv2
C functions
integer iuvmap2
C check status on entry
if (status.ne.0) return
C initialise output map with BLANKs
call filmap(data_out,minirt,minirt(8),status)
C determine useful window on output map
iu1 = minirt(1) + du
iu1 = max(iu1,minirt(1))
iu2 = minirt(2) + du
iu2 = min(iu2,minirt(2))
iv1 = minirt(3) + dv
iv1 = min(iv1,minirt(3))
iv2 = minirt(4) + dv
iv2 = max(iv2,minirt(4))
if (status.ne.0) goto 999
C determine values on the output map
do iv=iv1,iv2,-1
v = float(iv) - dv
do iu = iu1,iu2
i = iuvmap2(minirt,uv_point)
u = float(iu) - du
call ruvval2(minirt,data_in,duv_point,degrid_type,
* data_out(i),status)
end do
end do
C report any error
999 call cmd_err(status,'image_shift',' ')
end
| bsd-3-clause |
hpparvi/psf-centroid | src/gaussian.f90 | 1 | 5705 | !!=== Gaussian profile module ===
!!
!! Routines to calculate an undersampled Gaussian profile (where sigma ~ 1 pixel)
!! accurately by integrating the profile analytically over each pixel.
!!
!! -GPL-
!!
!! Copyright (C) 2013--2016 Hannu Parviainen
!!
!! This program is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License as published by
!! the Free Software Foundation, either version 3 of the License, or
!! (at your option) any later version.
!!
!! This program is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
!! -GPL-
!!
!! Author
!! Hannu Parviainen <hannu.parviainen@physics.ox.ac.uk>
!!
!! Date
!! 4.07.2016
!!
module gaussian
use omp_lib
implicit none
real(8), parameter :: PI = 3.14159265359d0
real(8), parameter :: H_SQRT_PI = 0.5d0*sqrt(PI)
real(8), parameter :: LLC = 0.5d0*log(2.0d0*PI)
real(8), parameter :: FWHM_TO_SIGMA = 1.0d0/(2.0d0*sqrt(2.0d0*log(2.0d0)))
contains
subroutine psf_g1d(center, amplitude, fwhm, npx, flux)
implicit none
real(8), intent(in) :: center, amplitude, fwhm
integer, intent(in) :: npx
real(8), intent(out) :: flux(npx)
real(8) :: aerf(npx+1)
integer :: i
aerf = erf(([(i, i=0,npx)]-center-0.5d0)/(fwhm*FWHM_TO_SIGMA))
flux = amplitude*fwhm*FWHM_TO_SIGMA*H_SQRT_PI*(aerf(2:)-aerf(1:npx))
end subroutine psf_g1d
!! One-dimensional Gaussian
!! ------------------------
subroutine gaussian1d(center, amplitude, fwhm, npx, flux)
implicit none
real(8), intent(in) :: center, amplitude, fwhm
integer, intent(in) :: npx
real(8), intent(out) :: flux(npx)
real(8) :: e1, e2, sigma
integer :: i, wstart, wwidth
flux = 0.0d0
sigma = fwhm * FWHM_TO_SIGMA
wwidth = min(npx, 4*ceiling(fwhm))
wstart = max(0, floor(center) - wwidth/2)
wwidth = min(npx-wstart, wwidth)
e1 = erf((wstart-center-0.5d0) / sigma)
do i = 1, wwidth
e2 = erf((wstart+i-center-0.5d0) / sigma)
flux(wstart+i) = amplitude*sigma*H_SQRT_PI*(e2-e1)
e1 = e2
end do
end subroutine gaussian1d
!! Multithreaded one-dimensional Gaussian
!! --------------------------------------
subroutine gaussian1dmt(center, amplitude, fwhm, npx, nthr, flux)
implicit none
real(8), intent(in) :: center, amplitude, fwhm
integer, intent(in) :: npx, nthr
real(8), intent(out) :: flux(npx)
real(8), allocatable :: aerf(:)
real(8) :: sigma
integer :: i, wstart, wwidth
!$ call omp_set_num_threads(nthr)
flux = 0.0d0
sigma = fwhm * FWHM_TO_SIGMA
wwidth = min(npx, 4*ceiling(fwhm))
wstart = max(0, floor(center) - wwidth/2)
wwidth = min(npx-wstart, wwidth)
allocate(aerf(wwidth+1))
!$omp parallel default(none) shared(flux,aerf,sigma,center,amplitude,wstart,wwidth) private(i)
!$omp do
do i = 0, wwidth
aerf(i+1) = erf((wstart+i-center-0.5d0) / sigma)
end do
!$omp end do
!$omp do
do i = 1, wwidth
flux(wstart+i) = amplitude*sigma*H_SQRT_PI*(aerf(i+1)-aerf(i))
end do
!$omp end do
!$omp end parallel
deallocate(aerf)
end subroutine gaussian1dmt
!! Multiple one-dimensional Gaussian profiles
!! ------------------------------------------
subroutine gaussians1d(centers, amplitudes, fwhm, npx, nlines, flux)
implicit none
integer, intent(in) :: npx, nlines
real(8), intent(in) :: centers(nlines), amplitudes(nlines), fwhm
real(8), intent(out) :: flux(npx)
real(8) :: e1, e2, sigma
integer :: i, iline, wstart, wwidth
flux = 0.0d0
sigma = fwhm * FWHM_TO_SIGMA
wwidth = min(npx, 4*ceiling(fwhm))
do iline = 1, nlines
wstart = max(0, floor(centers(iline)) - wwidth/2)
e1 = erf((wstart-centers(iline)-0.5d0) / sigma)
do i = 1, min(npx-wstart, wwidth)
e2 = erf((wstart+i-centers(iline)-0.5d0) / sigma)
flux(wstart+i) = flux(wstart+i) + amplitudes(iline)*sigma*H_SQRT_PI*(e2-e1)
e1 = e2
end do
end do
end subroutine gaussians1d
real(8) function logl_g1d(center, amplitude, fwhm, error, sky, npx, fobs)
implicit none
integer, intent(in) :: npx
real(8), intent(in) :: center,amplitude,fwhm,error,sky,fobs(npx)
real(8) :: fmod(npx)
call gaussian1d(center, amplitude, fwhm, npx, fmod)
logl_g1d = -LLC*npx - 0.5d0*npx*log(error**2) -0.5d0*sum((fobs - (sky+fmod))**2/error**2)
end function logl_g1d
real(8) function lnlike_gaussian1d(center, amplitude, fwhm, error, sky, npx, fobs)
implicit none
integer, intent(in) :: npx
real(8), intent(in) :: center,amplitude,fwhm,error,sky,fobs(npx)
real(8) :: fmod(npx)
call gaussian1d(center, amplitude, fwhm, npx, fmod)
lnlike_gaussian1d = -LLC*npx - 0.5d0*npx*log(error**2) -0.5d0*sum((fobs - (sky+fmod))**2/error**2)
end function lnlike_gaussian1d
real(8) function lnlike_gaussians1d(centers, amplitudes, fwhm, error, sky, npx, nlines, fobs)
implicit none
integer, intent(in) :: npx, nlines
real(8), intent(in) :: centers(nlines), amplitudes(nlines), fwhm, error, sky, fobs(npx)
real(8) :: fmod(npx)
call gaussians1d(centers, amplitudes, fwhm, npx, nlines, fmod)
lnlike_gaussians1d = -LLC*npx - 0.5d0*npx*log(error**2) -0.5d0*sum((fobs - (sky+fmod))**2/error**2)
end function lnlike_gaussians1d
end module gaussian
| gpl-3.0 |
lesserwhirls/scipy-cwt | scipy/interpolate/fitpack/fpcuro.f | 148 | 2492 | subroutine fpcuro(a,b,c,d,x,n)
c subroutine fpcuro finds the real zeros of a cubic polynomial
c p(x) = a*x**3+b*x**2+c*x+d.
c
c calling sequence:
c call fpcuro(a,b,c,d,x,n)
c
c input parameters:
c a,b,c,d: real values, containing the coefficients of p(x).
c
c output parameters:
c x : real array,length 3, which contains the real zeros of p(x)
c n : integer, giving the number of real zeros of p(x).
c ..
c ..scalar arguments..
real*8 a,b,c,d
integer n
c ..array argument..
real*8 x(3)
c ..local scalars..
integer i
real*8 a1,b1,c1,df,disc,d1,e3,f,four,half,ovfl,pi3,p3,q,r,
* step,tent,three,two,u,u1,u2,y
c ..function references..
real*8 abs,max,datan,atan2,cos,sign,sqrt
c set constants
two = 0.2d+01
three = 0.3d+01
four = 0.4d+01
ovfl =0.1d+05
half = 0.5d+0
tent = 0.1d+0
e3 = tent/0.3d0
pi3 = datan(0.1d+01)/0.75d0
a1 = abs(a)
b1 = abs(b)
c1 = abs(c)
d1 = abs(d)
c test whether p(x) is a third degree polynomial.
if(max(b1,c1,d1).lt.a1*ovfl) go to 300
c test whether p(x) is a second degree polynomial.
if(max(c1,d1).lt.b1*ovfl) go to 200
c test whether p(x) is a first degree polynomial.
if(d1.lt.c1*ovfl) go to 100
c p(x) is a constant function.
n = 0
go to 800
c p(x) is a first degree polynomial.
100 n = 1
x(1) = -d/c
go to 500
c p(x) is a second degree polynomial.
200 disc = c*c-four*b*d
n = 0
if(disc.lt.0.) go to 800
n = 2
u = sqrt(disc)
b1 = b+b
x(1) = (-c+u)/b1
x(2) = (-c-u)/b1
go to 500
c p(x) is a third degree polynomial.
300 b1 = b/a*e3
c1 = c/a
d1 = d/a
q = c1*e3-b1*b1
r = b1*b1*b1+(d1-b1*c1)*half
disc = q*q*q+r*r
if(disc.gt.0.) go to 400
u = sqrt(abs(q))
if(r.lt.0.) u = -u
p3 = atan2(sqrt(-disc),abs(r))*e3
u2 = u+u
n = 3
x(1) = -u2*cos(p3)-b1
x(2) = u2*cos(pi3-p3)-b1
x(3) = u2*cos(pi3+p3)-b1
go to 500
400 u = sqrt(disc)
u1 = -r+u
u2 = -r-u
n = 1
x(1) = sign(abs(u1)**e3,u1)+sign(abs(u2)**e3,u2)-b1
c apply a newton iteration to improve the accuracy of the roots.
500 do 700 i=1,n
y = x(i)
f = ((a*y+b)*y+c)*y+d
df = (three*a*y+two*b)*y+c
step = 0.
if(abs(f).lt.abs(df)*tent) step = f/df
x(i) = y-step
700 continue
800 return
end
| bsd-3-clause |
njwilson23/scipy | scipy/interpolate/fitpack/fpbfout.f | 148 | 5322 | subroutine fpbfou(t,n,par,ress,resc)
c subroutine fpbfou calculates the integrals
c /t(n-3)
c ress(j) = ! nj,4(x)*sin(par*x) dx and
c t(4)/
c /t(n-3)
c resc(j) = ! nj,4(x)*cos(par*x) dx , j=1,2,...n-4
c t(4)/
c where nj,4(x) denotes the cubic b-spline defined on the knots
c t(j),t(j+1),...,t(j+4).
c
c calling sequence:
c call fpbfou(t,n,par,ress,resc)
c
c input parameters:
c t : real array,length n, containing the knots.
c n : integer, containing the number of knots.
c par : real, containing the value of the parameter par.
c
c output parameters:
c ress : real array,length n, containing the integrals ress(j).
c resc : real array,length n, containing the integrals resc(j).
c
c restrictions:
c n >= 10, t(4) < t(5) < ... < t(n-4) < t(n-3).
c ..
c ..scalar arguments..
integer n
real*8 par
c ..array arguments..
real*8 t(n),ress(n),resc(n)
c ..local scalars..
integer i,ic,ipj,is,j,jj,jp1,jp4,k,li,lj,ll,nmj,nm3,nm7
real*8 ak,beta,con1,con2,c1,c2,delta,eps,fac,f1,f2,f3,one,quart,
* sign,six,s1,s2,term
c ..local arrays..
real*8 co(5),si(5),hs(5),hc(5),rs(3),rc(3)
c ..function references..
real*8 cos,sin,abs
c ..
c initialization.
one = 0.1e+01
six = 0.6e+01
eps = 0.1e-07
quart = 0.25e0
con1 = 0.5e-01
con2 = 0.12e+03
nm3 = n-3
nm7 = n-7
if(par.ne.0.) term = six/par
beta = par*t(4)
co(1) = cos(beta)
si(1) = sin(beta)
c calculate the integrals ress(j) and resc(j), j=1,2,3 by setting up
c a divided difference table.
do 30 j=1,3
jp1 = j+1
jp4 = j+4
beta = par*t(jp4)
co(jp1) = cos(beta)
si(jp1) = sin(beta)
call fpcsin(t(4),t(jp4),par,si(1),co(1),si(jp1),co(jp1),
* rs(j),rc(j))
i = 5-j
hs(i) = 0.
hc(i) = 0.
do 10 jj=1,j
ipj = i+jj
hs(ipj) = rs(jj)
hc(ipj) = rc(jj)
10 continue
do 20 jj=1,3
if(i.lt.jj) i = jj
k = 5
li = jp4
do 20 ll=i,4
lj = li-jj
fac = t(li)-t(lj)
hs(k) = (hs(k)-hs(k-1))/fac
hc(k) = (hc(k)-hc(k-1))/fac
k = k-1
li = li-1
20 continue
ress(j) = hs(5)-hs(4)
resc(j) = hc(5)-hc(4)
30 continue
if(nm7.lt.4) go to 160
c calculate the integrals ress(j) and resc(j),j=4,5,...,n-7.
do 150 j=4,nm7
jp4 = j+4
beta = par*t(jp4)
co(5) = cos(beta)
si(5) = sin(beta)
delta = t(jp4)-t(j)
c the way of computing ress(j) and resc(j) depends on the value of
c beta = par*(t(j+4)-t(j)).
beta = delta*par
if(abs(beta).le.one) go to 60
c if !beta! > 1 the integrals are calculated by setting up a divided
c difference table.
do 40 k=1,5
hs(k) = si(k)
hc(k) = co(k)
40 continue
do 50 jj=1,3
k = 5
li = jp4
do 50 ll=jj,4
lj = li-jj
fac = par*(t(li)-t(lj))
hs(k) = (hs(k)-hs(k-1))/fac
hc(k) = (hc(k)-hc(k-1))/fac
k = k-1
li = li-1
50 continue
s2 = (hs(5)-hs(4))*term
c2 = (hc(5)-hc(4))*term
go to 130
c if !beta! <= 1 the integrals are calculated by evaluating a series
c expansion.
60 f3 = 0.
do 70 i=1,4
ipj = i+j
hs(i) = par*(t(ipj)-t(j))
hc(i) = hs(i)
f3 = f3+hs(i)
70 continue
f3 = f3*con1
c1 = quart
s1 = f3
if(abs(f3).le.eps) go to 120
sign = one
fac = con2
k = 5
is = 0
do 110 ic=1,20
k = k+1
ak = k
fac = fac*ak
f1 = 0.
f3 = 0.
do 80 i=1,4
f1 = f1+hc(i)
f2 = f1*hs(i)
hc(i) = f2
f3 = f3+f2
80 continue
f3 = f3*six/fac
if(is.eq.0) go to 90
is = 0
s1 = s1+f3*sign
go to 100
90 sign = -sign
is = 1
c1 = c1+f3*sign
100 if(abs(f3).le.eps) go to 120
110 continue
120 s2 = delta*(co(1)*s1+si(1)*c1)
c2 = delta*(co(1)*c1-si(1)*s1)
130 ress(j) = s2
resc(j) = c2
do 140 i=1,4
co(i) = co(i+1)
si(i) = si(i+1)
140 continue
150 continue
c calculate the integrals ress(j) and resc(j),j=n-6,n-5,n-4 by setting
c up a divided difference table.
160 do 190 j=1,3
nmj = nm3-j
i = 5-j
call fpcsin(t(nm3),t(nmj),par,si(4),co(4),si(i-1),co(i-1),
* rs(j),rc(j))
hs(i) = 0.
hc(i) = 0.
do 170 jj=1,j
ipj = i+jj
hc(ipj) = rc(jj)
hs(ipj) = rs(jj)
170 continue
do 180 jj=1,3
if(i.lt.jj) i = jj
k = 5
li = nmj
do 180 ll=i,4
lj = li+jj
fac = t(lj)-t(li)
hs(k) = (hs(k-1)-hs(k))/fac
hc(k) = (hc(k-1)-hc(k))/fac
k = k-1
li = li+1
180 continue
ress(nmj) = hs(4)-hs(5)
resc(nmj) = hc(4)-hc(5)
190 continue
return
end
| bsd-3-clause |
yaowee/libflame | lapack-test/lapack-timing/EIG/EIGSRC/zlaein.f | 4 | 8445 | SUBROUTINE ZLAEIN( RIGHTV, NOINIT, N, H, LDH, W, V, B, LDB, RWORK,
$ EPS3, SMLNUM, INFO )
*
* -- LAPACK auxiliary routine (instrumented to count operations) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* September 30, 1994
*
* .. Scalar Arguments ..
LOGICAL NOINIT, RIGHTV
INTEGER INFO, LDB, LDH, N
DOUBLE PRECISION EPS3, SMLNUM
COMPLEX*16 W
* ..
* .. Array Arguments ..
DOUBLE PRECISION RWORK( * )
COMPLEX*16 B( LDB, * ), H( LDH, * ), V( * )
* ..
* Common block to return operation count.
* .. Common blocks ..
COMMON / LATIME / OPS, ITCNT
* ..
* .. Scalars in Common ..
DOUBLE PRECISION ITCNT, OPS
* ..
*
* Purpose
* =======
*
* ZLAEIN uses inverse iteration to find a right or left eigenvector
* corresponding to the eigenvalue W of a complex upper Hessenberg
* matrix H.
*
* Arguments
* =========
*
* RIGHTV (input) LOGICAL
* = .TRUE. : compute right eigenvector;
* = .FALSE.: compute left eigenvector.
*
* NOINIT (input) LOGICAL
* = .TRUE. : no initial vector supplied in V
* = .FALSE.: initial vector supplied in V.
*
* N (input) INTEGER
* The order of the matrix H. N >= 0.
*
* H (input) COMPLEX*16 array, dimension (LDH,N)
* The upper Hessenberg matrix H.
*
* LDH (input) INTEGER
* The leading dimension of the array H. LDH >= max(1,N).
*
* W (input) COMPLEX*16
* The eigenvalue of H whose corresponding right or left
* eigenvector is to be computed.
*
* V (input/output) COMPLEX*16 array, dimension (N)
* On entry, if NOINIT = .FALSE., V must contain a starting
* vector for inverse iteration; otherwise V need not be set.
* On exit, V contains the computed eigenvector, normalized so
* that the component of largest magnitude has magnitude 1; here
* the magnitude of a complex number (x,y) is taken to be
* |x| + |y|.
*
* B (workspace) COMPLEX*16 array, dimension (LDB,N)
*
* LDB (input) INTEGER
* The leading dimension of the array B. LDB >= max(1,N).
*
* RWORK (workspace) DOUBLE PRECISION array, dimension (N)
*
* EPS3 (input) DOUBLE PRECISION
* A small machine-dependent value which is used to perturb
* close eigenvalues, and to replace zero pivots.
*
* SMLNUM (input) DOUBLE PRECISION
* A machine-dependent value close to the underflow threshold.
*
* INFO (output) INTEGER
* = 0: successful exit
* = 1: inverse iteration did not converge; V is set to the
* last iterate.
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ONE, TENTH
PARAMETER ( ONE = 1.0D+0, TENTH = 1.0D-1 )
COMPLEX*16 ZERO
PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
* ..
* .. Local Scalars ..
CHARACTER NORMIN, TRANS
INTEGER I, IERR, ITS, J
DOUBLE PRECISION GROWTO, NRMSML, OPST, ROOTN, RTEMP, SCALE,
$ VNORM
COMPLEX*16 CDUM, EI, EJ, TEMP, X
* ..
* .. External Functions ..
INTEGER IZAMAX
DOUBLE PRECISION DZASUM, DZNRM2
COMPLEX*16 ZLADIV
EXTERNAL IZAMAX, DZASUM, DZNRM2, ZLADIV
* ..
* .. External Subroutines ..
EXTERNAL ZDSCAL, ZLATRS
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, DBLE, DIMAG, MAX, SQRT
* ..
* .. Statement Functions ..
DOUBLE PRECISION CABS1
* ..
* .. Statement Function definitions ..
CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
* ..
* .. Executable Statements ..
*
INFO = 0
***
* Initialize
OPST = 0
***
*
* GROWTO is the threshold used in the acceptance test for an
* eigenvector.
*
ROOTN = SQRT( DBLE( N ) )
GROWTO = TENTH / ROOTN
NRMSML = MAX( ONE, EPS3*ROOTN )*SMLNUM
***
OPST = OPST + 4
***
*
* Form B = H - W*I (except that the subdiagonal elements are not
* stored).
*
DO 20 J = 1, N
DO 10 I = 1, J - 1
B( I, J ) = H( I, J )
10 CONTINUE
B( J, J ) = H( J, J ) - W
20 CONTINUE
***
OPST = OPST + 2*N
***
*
IF( NOINIT ) THEN
*
* Initialize V.
*
DO 30 I = 1, N
V( I ) = EPS3
30 CONTINUE
ELSE
*
* Scale supplied initial vector.
*
VNORM = DZNRM2( N, V, 1 )
CALL ZDSCAL( N, ( EPS3*ROOTN ) / MAX( VNORM, NRMSML ), V, 1 )
***
OPST = OPST + ( 6*N+3 )
***
END IF
*
IF( RIGHTV ) THEN
*
* LU decomposition with partial pivoting of B, replacing zero
* pivots by EPS3.
*
DO 60 I = 1, N - 1
EI = H( I+1, I )
IF( CABS1( B( I, I ) ).LT.CABS1( EI ) ) THEN
*
* Interchange rows and eliminate.
*
X = ZLADIV( B( I, I ), EI )
B( I, I ) = EI
DO 40 J = I + 1, N
TEMP = B( I+1, J )
B( I+1, J ) = B( I, J ) - X*TEMP
B( I, J ) = TEMP
40 CONTINUE
ELSE
*
* Eliminate without interchange.
*
IF( B( I, I ).EQ.ZERO )
$ B( I, I ) = EPS3
X = ZLADIV( EI, B( I, I ) )
IF( X.NE.ZERO ) THEN
DO 50 J = I + 1, N
B( I+1, J ) = B( I+1, J ) - X*B( I, J )
50 CONTINUE
END IF
END IF
60 CONTINUE
IF( B( N, N ).EQ.ZERO )
$ B( N, N ) = EPS3
***
* Increment op count for LU decomposition
OPS = OPS + ( N-1 )*( 4*N+11 )
***
*
TRANS = 'N'
*
ELSE
*
* UL decomposition with partial pivoting of B, replacing zero
* pivots by EPS3.
*
DO 90 J = N, 2, -1
EJ = H( J, J-1 )
IF( CABS1( B( J, J ) ).LT.CABS1( EJ ) ) THEN
*
* Interchange columns and eliminate.
*
X = ZLADIV( B( J, J ), EJ )
B( J, J ) = EJ
DO 70 I = 1, J - 1
TEMP = B( I, J-1 )
B( I, J-1 ) = B( I, J ) - X*TEMP
B( I, J ) = TEMP
70 CONTINUE
ELSE
*
* Eliminate without interchange.
*
IF( B( J, J ).EQ.ZERO )
$ B( J, J ) = EPS3
X = ZLADIV( EJ, B( J, J ) )
IF( X.NE.ZERO ) THEN
DO 80 I = 1, J - 1
B( I, J-1 ) = B( I, J-1 ) - X*B( I, J )
80 CONTINUE
END IF
END IF
90 CONTINUE
IF( B( 1, 1 ).EQ.ZERO )
$ B( 1, 1 ) = EPS3
***
* Increment op count for UL decomposition
OPS = OPS + ( N-1 )*( 4*N+11 )
***
*
TRANS = 'C'
*
END IF
*
NORMIN = 'N'
DO 110 ITS = 1, N
*
* Solve U*x = scale*v for a right eigenvector
* or U'*x = scale*v for a left eigenvector,
* overwriting x on v.
*
CALL ZLATRS( 'Upper', TRANS, 'Nonunit', NORMIN, N, B, LDB, V,
$ SCALE, RWORK, IERR )
***
* Increment opcount for triangular solver, assuming that
* ops ZLATRS = ops ZTRSV, with no scaling in CLATRS.
OPS = OPS + 4*N*( N+1 )
***
NORMIN = 'Y'
*
* Test for sufficient growth in the norm of v.
*
VNORM = DZASUM( N, V, 1 )
***
OPST = OPST + 2*N
***
IF( VNORM.GE.GROWTO*SCALE )
$ GO TO 120
*
* Choose new orthogonal starting vector and try again.
*
RTEMP = EPS3 / ( ROOTN+ONE )
V( 1 ) = EPS3
DO 100 I = 2, N
V( I ) = RTEMP
100 CONTINUE
V( N-ITS+1 ) = V( N-ITS+1 ) - EPS3*ROOTN
***
OPST = OPST + 4
***
110 CONTINUE
*
* Failure to find eigenvector in N iterations.
*
INFO = 1
*
120 CONTINUE
*
* Normalize eigenvector.
*
I = IZAMAX( N, V, 1 )
CALL ZDSCAL( N, ONE / CABS1( V( I ) ), V, 1 )
***
OPST = OPST + ( 4*N+2 )
***
*
***
* Compute final op count
OPS = OPS + OPST
***
RETURN
*
* End of ZLAEIN
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/cspt02.f | 32 | 5458 | *> \brief \b CSPT02
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE CSPT02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK,
* RESID )
*
* .. Scalar Arguments ..
* CHARACTER UPLO
* INTEGER LDB, LDX, N, NRHS
* REAL RESID
* ..
* .. Array Arguments ..
* REAL RWORK( * )
* COMPLEX A( * ), B( LDB, * ), X( LDX, * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> CSPT02 computes the residual in the solution of a complex symmetric
*> system of linear equations A*x = b when packed storage is used for
*> the coefficient matrix. The ratio computed is
*>
*> RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS).
*>
*> where EPS is the machine precision.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] UPLO
*> \verbatim
*> UPLO is CHARACTER*1
*> Specifies whether the upper or lower triangular part of the
*> complex symmetric matrix A is stored:
*> = 'U': Upper triangular
*> = 'L': Lower triangular
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of rows and columns of the matrix A. N >= 0.
*> \endverbatim
*>
*> \param[in] NRHS
*> \verbatim
*> NRHS is INTEGER
*> The number of columns of B, the matrix of right hand sides.
*> NRHS >= 0.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is COMPLEX array, dimension (N*(N+1)/2)
*> The original complex symmetric matrix A, stored as a packed
*> triangular matrix.
*> \endverbatim
*>
*> \param[in] X
*> \verbatim
*> X is COMPLEX array, dimension (LDX,NRHS)
*> The computed solution vectors for the system of linear
*> equations.
*> \endverbatim
*>
*> \param[in] LDX
*> \verbatim
*> LDX is INTEGER
*> The leading dimension of the array X. LDX >= max(1,N).
*> \endverbatim
*>
*> \param[in,out] B
*> \verbatim
*> B is COMPLEX array, dimension (LDB,NRHS)
*> On entry, the right hand side vectors for the system of
*> linear equations.
*> On exit, B is overwritten with the difference B - A*X.
*> \endverbatim
*>
*> \param[in] LDB
*> \verbatim
*> LDB is INTEGER
*> The leading dimension of the array B. LDB >= max(1,N).
*> \endverbatim
*>
*> \param[out] RWORK
*> \verbatim
*> RWORK is REAL array, dimension (N)
*> \endverbatim
*>
*> \param[out] RESID
*> \verbatim
*> RESID is REAL
*> The maximum over the number of right hand sides of
*> norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup complex_lin
*
* =====================================================================
SUBROUTINE CSPT02( UPLO, N, NRHS, A, X, LDX, B, LDB, RWORK,
$ RESID )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER UPLO
INTEGER LDB, LDX, N, NRHS
REAL RESID
* ..
* .. Array Arguments ..
REAL RWORK( * )
COMPLEX A( * ), B( LDB, * ), X( LDX, * )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
COMPLEX CONE
PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
* ..
* .. Local Scalars ..
INTEGER J
REAL ANORM, BNORM, EPS, XNORM
* ..
* .. External Functions ..
REAL CLANSP, SCASUM, SLAMCH
EXTERNAL CLANSP, SCASUM, SLAMCH
* ..
* .. External Subroutines ..
EXTERNAL CSPMV
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX
* ..
* .. Executable Statements ..
*
* Quick exit if N = 0 or NRHS = 0
*
IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
RESID = ZERO
RETURN
END IF
*
* Exit with RESID = 1/EPS if ANORM = 0.
*
EPS = SLAMCH( 'Epsilon' )
ANORM = CLANSP( '1', UPLO, N, A, RWORK )
IF( ANORM.LE.ZERO ) THEN
RESID = ONE / EPS
RETURN
END IF
*
* Compute B - A*X for the matrix of right hand sides B.
*
DO 10 J = 1, NRHS
CALL CSPMV( UPLO, N, -CONE, A, X( 1, J ), 1, CONE, B( 1, J ),
$ 1 )
10 CONTINUE
*
* Compute the maximum over the number of right hand sides of
* norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) .
*
RESID = ZERO
DO 20 J = 1, NRHS
BNORM = SCASUM( N, B( 1, J ), 1 )
XNORM = SCASUM( N, X( 1, J ), 1 )
IF( XNORM.LE.ZERO ) THEN
RESID = ONE / EPS
ELSE
RESID = MAX( RESID, ( ( BNORM/ANORM )/XNORM )/EPS )
END IF
20 CONTINUE
*
RETURN
*
* End of CSPT02
*
END
| bsd-3-clause |
wilsonCernWq/Simula | fortran/utils/FoX-4.1.2/sax/m_sax_xml_source.F90 | 3 | 12820 | module m_sax_xml_source
#ifndef DUMMYLIB
use fox_m_fsys_array_str, only: str_vs, vs_str_alloc
use fox_m_fsys_format, only: operator(//)
use m_common_error, only: error_stack, add_error, in_error
use m_common_charset, only: XML_WHITESPACE, XML_INITIALENCODINGCHARS, &
XML_ENCODINGCHARS, XML1_0, XML1_1, isXML1_0_NameChar, &
isLegalChar, isUSASCII, allowed_encoding
use m_common_io, only: io_eor, io_eof
use FoX_utils, only: URI
implicit none
private
type buffer_t
character, dimension(:), pointer :: s
integer :: pos = 1
end type buffer_t
type xml_source_t
!FIXME private
integer :: lun = -1
integer :: xml_version = XML1_0
character, pointer :: encoding(:) => null()
logical :: isUSASCII
character, pointer :: filename(:) => null()
type(URI), pointer :: baseURI => null()
integer :: line = 0
integer :: col = 0
integer :: startChar = 1 ! First character after XML decl
character, pointer :: next_chars(:) => null() ! pushback buffer
type(buffer_t), pointer :: input_string => null()
logical :: pe = .false. ! is this a parameter entity?
logical :: eof = .false.! need to keep track of this at the end of pes
end type xml_source_t
public :: buffer_t
public :: xml_source_t
public :: get_char_from_file
public :: push_file_chars
public :: parse_declaration
contains
function get_char_from_file(f, xv, eof, es) result(string)
type(xml_source_t), intent(inout) :: f
integer, intent(in) :: xv
logical, intent(out) :: eof
type(error_stack), intent(inout) :: es
character(len=1) :: string
integer :: iostat
logical :: pending
character :: c, c2
pending = .false.
eof = .false.
c = read_single_char(f, iostat)
if (iostat==io_eof) then
eof = .true.
return
elseif (iostat/=0) then
call add_error(es, "Error reading "//str_vs(f%filename))
return
endif
if (.not.isLegalChar(c, f%isUSASCII, xv)) then
call add_error(es, "Illegal character found at " &
//str_vs(f%filename)//":"//f%line//":"//f%col)
return
endif
if (c==achar(13)) then
c = achar(10)
c2 = read_single_char(f, iostat)
if (iostat==io_eof) then
! the file has just ended on a single CR. Report is as a LF.
! Ignore the eof just now, it'll be picked up if we need to
! perform another read.
eof = .false.
elseif (iostat/=0) then
call add_error(es, "Error reading "//str_vs(f%filename))
return
elseif (c2/=achar(10)) then
! then we keep c2, otherwise we'd just ignore it.
pending = .true.
endif
endif
string = c
if (pending) then
! we have one character left over, put in the pushback buffer
deallocate(f%next_chars)
allocate(f%next_chars(1))
f%next_chars = c2
endif
if (c==achar(10)) then
f%line = f%line + 1
f%col = 0
else
f%col = f%col + 1
endif
end function get_char_from_file
function read_single_char(f, iostat) result(c)
type(xml_source_t), intent(inout) :: f
integer, intent(out) :: iostat
character :: c
if (f%eof) then
c = ""
iostat = io_eof
return
endif
if (f%lun==-1) then
if (f%input_string%pos>size(f%input_string%s)) then
c = ""
if (f%pe) then
iostat = 0
else
iostat = io_eof
endif
f%eof = .true.
else
iostat = 0
c = f%input_string%s(f%input_string%pos)
f%input_string%pos = f%input_string%pos + 1
endif
else
read (unit=f%lun, iostat=iostat, advance="no", fmt="(a1)") c
if (iostat==io_eor) then
iostat = 0
#ifdef FC_EOR_LF
c = achar(10)
#else
c = achar(13)
#endif
elseif (iostat==io_eof) then
if (f%pe) iostat = 0
c = ""
f%eof = .true.
endif
endif
end function read_single_char
subroutine rewind_source(f)
type(xml_source_t), intent(inout) :: f
if (f%lun==-1) then
f%input_string%pos = 1
else
rewind(f%lun)
endif
end subroutine rewind_source
subroutine push_file_chars(f, s)
type(xml_source_t), intent(inout) :: f
character(len=*), intent(in) :: s
character, dimension(:), pointer :: nc
nc => vs_str_alloc(s//str_vs(f%next_chars))
deallocate(f%next_chars)
f%next_chars => nc
end subroutine push_file_chars
subroutine parse_declaration(f, eof, es, standalone)
type(xml_source_t), intent(inout) :: f
logical, intent(out) :: eof
type(error_stack), intent(inout) :: es
logical, intent(out), optional :: standalone
integer :: parse_state, xd_par
character :: c, q
character, pointer :: ch(:), ch2(:)
integer, parameter :: XD_0 = 0
integer, parameter :: XD_START = 1
integer, parameter :: XD_TARGET = 2
integer, parameter :: XD_MISC = 3
integer, parameter :: XD_PA = 4
integer, parameter :: XD_EQ = 5
integer, parameter :: XD_QUOTE = 6
integer, parameter :: XD_PV = 7
integer, parameter :: XD_END = 8
integer, parameter :: XD_SPACE = 9
integer, parameter :: xd_nothing = 0
integer, parameter :: xd_version = 1
integer, parameter :: xd_encoding = 2
integer, parameter :: xd_standalone = 3
f%xml_version = XML1_0
if (present(standalone)) standalone = .false.
f%startChar = 1
parse_state = XD_0
xd_par = xd_nothing
ch => null()
do
c = get_char_from_file(f, XML1_0, eof, es)
if (eof) then
call rewind_source(f)
exit
elseif (in_error(es)) then
goto 100
endif
f%startChar = f%startChar + 1
select case (parse_state)
case (XD_0)
if (c=="<") then
parse_state = XD_START
else
call rewind_source(f)
exit
endif
case (XD_START)
if (c=="?") then
parse_state = XD_TARGET
ch => vs_str_alloc("")
else
call rewind_source(f)
exit
endif
case (XD_TARGET)
if (isXML1_0_NameChar(c)) then
ch2 => vs_str_alloc(str_vs(ch)//c)
deallocate(ch)
ch => ch2
elseif (verify(c, XML_WHITESPACE)==0 &
.and.str_vs(ch)=="xml") then
deallocate(ch)
parse_state = XD_MISC
else
call rewind_source(f)
deallocate(ch)
exit
endif
case (XD_SPACE)
if (verify(c, XML_WHITESPACE)==0) then
parse_state = XD_MISC
elseif (c=="?") then
parse_state = XD_END
else
call add_error(es, &
"Missing space in XML declaration")
endif
case (XD_MISC)
if (c=="?") then
parse_state = XD_END
elseif (isXML1_0_NameChar(c)) then
ch => vs_str_alloc(c)
parse_state = XD_PA
elseif (verify(c, XML_WHITESPACE)>0) then
call add_error(es, &
"Unexpected character in XML declaration")
endif
case (XD_PA)
if (isXML1_0_NameChar(c)) then
ch2 => vs_str_alloc(str_vs(ch)//c)
deallocate(ch)
ch => ch2
elseif (verify(c, XML_WHITESPACE//"=")==0) then
select case (str_vs(ch))
case ("version")
select case (xd_par)
case (xd_nothing)
xd_par = xd_version
case default
call add_error(es, &
"Cannot specify version twice in XML declaration")
end select
case ("encoding")
select case (xd_par)
case (xd_nothing)
if (present(standalone)) then
call add_error(es, &
"Must specify version before encoding in XML declaration")
else
xd_par = xd_encoding
endif
case (xd_version)
xd_par = xd_encoding
case (xd_encoding)
call add_error(es, &
"Cannot specify encoding twice in XML declaration")
case (xd_standalone)
call add_error(es, &
"Cannot specify encoding after standalone in XML declaration")
end select
case ("standalone")
if (.not.present(standalone)) &
call add_error(es, &
"Cannot specify standalone in text declaration")
select case (xd_par)
case (xd_nothing)
call add_error(es, &
"Must specify version before standalone in XML declaration")
case (xd_version, xd_encoding)
xd_par = xd_standalone
case (xd_standalone)
call add_error(es, &
"Cannot specify standalone twice in XML declaration")
end select
case default
call add_error(es, &
"Unknown parameter "//str_vs(ch)//" in XML declaration, "//&
"expecting version, encoding or standalone")
end select
deallocate(ch)
if (c=="=") then
parse_state = XD_QUOTE
else
parse_state = XD_EQ
endif
else
call add_error(es, &
"Unexpected character found in XML declaration")
endif
case (XD_EQ)
if (c=="=") then
parse_state = XD_QUOTE
elseif (verify(c, XML_WHITESPACE)>0) then
call add_error(es, &
"Unexpected character found in XML declaration; expecting ""=""")
endif
case (XD_QUOTE)
if (verify(c, "'""")==0) then
q = c
parse_state = XD_PV
ch => vs_str_alloc("")
elseif (verify(c, XML_WHITESPACE)>0) then
call add_error(es, &
"Unexpected character found in XML declaration; expecting "" or '")
endif
case (XD_PV)
if (c==q) then
select case (xd_par)
case (xd_version)
if (str_vs(ch)//"x"=="1.0x") then
f%xml_version = XML1_0
deallocate(ch)
elseif (str_vs(ch)//"x"=="1.1x") then
f%xml_version = XML1_1
deallocate(ch)
else
call add_error(es, &
"Unknown version number "//str_vs(ch)//" found in XML declaration; expecting 1.0 or 1.1")
endif
case (xd_encoding)
if (size(ch)==0) then
call add_error(es, &
"Empty value for encoding not allowed in XML declaration")
elseif (size(ch)==1.and.verify(ch(1), XML_INITIALENCODINGCHARS)>0) then
call add_error(es, &
"Invalid encoding found in XML declaration; illegal characters in encoding name")
elseif (size(ch)>1.and. &
(verify(ch(1), XML_INITIALENCODINGCHARS)>0 &
.or.verify(str_vs(ch(2:)), XML_ENCODINGCHARS)>0)) then
call add_error(es, &
"Invalid encoding found in XML declaration; illegal characters in encoding name")
elseif (.not.allowed_encoding(str_vs(ch))) then
call add_error(es, "Unknown character encoding in XML declaration")
else
f%encoding => ch
f%isUSASCII = isUSASCII(str_vs(ch))
ch => null()
endif
case (xd_standalone)
if (str_vs(ch)//"x"=="yesx") then
standalone = .true.
deallocate(ch)
elseif (str_vs(ch)//"x"=="nox") then
standalone = .false.
deallocate(ch)
else
call add_error(es, &
"Invalid value for standalone found in XML declaration; expecting yes or no")
endif
end select
parse_state = XD_SPACE
else
ch2 => vs_str_alloc(str_vs(ch)//c)
deallocate(ch)
ch => ch2
endif
case (XD_END)
if (c==">") then
exit
else
call add_error(es, &
"Unexpected character found in XML declaration; expecting >")
endif
end select
end do
if (.not.associated(f%encoding)) then
if (present(standalone).or.parse_state/=XD_END) then
f%encoding => vs_str_alloc("utf-8")
else
call add_error(es, "Missing encoding in text declaration")
endif
endif
100 if (associated(ch)) deallocate(ch)
! if there is no XML declaraion, or if parsing caused an error, then
if (parse_state/=XD_END.or.in_error(es)) f%startChar = 1
end subroutine parse_declaration
#endif
end module m_sax_xml_source
| mit |
CavendishAstrophysics/anmap | mapcat/ic2_alloc_in.f | 1 | 1191 | C
C
*+ ic2_alloc_in
subroutine ic2_alloc_in(imap,access,map_array,ip_map,status)
C ------------------------------------------------------------
C
C Allocate a map for input
C
C Input:
C Map to allocate for input
integer imap
C Access mode -- icp_DIRECT or icp_SEQUENTIAL
integer access
C Updated:
C Map data
real*4 map_array(*)
C Returned:
C Pointer to map_array and start of IMAP data
integer ip_map
C Status
integer status
C
C The map IMAP is allocated for READ. If the access requested is DIRECT
C then space is allocated in CORE and the map is read in (if not already)
C in core. If the acces requested is SEQUENTIAL then no direct access to
C the map data is performed, but an allocation is made for subsequent
C calls to IC2_ROW_READ and IC2_ROW_WRITE.
C
*-
include 'ic_pars.inc'
if (access.eq.icp_Direct) then
call map_alloc_in(imap,'DIRECT',map_array,ip_map,status)
else
call map_alloc_in(imap,'SEQUENTIAL',map_array,ip_map,status)
endif
999 call mapcat_err(status,'ic2_alloc_in','Fatal allocation error')
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/EIG/sgqrts.f | 32 | 9563 | *> \brief \b SGQRTS
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
* BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
*
* .. Scalar Arguments ..
* INTEGER LDA, LDB, LWORK, M, P, N
* ..
* .. Array Arguments ..
* REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
* $ Q( LDA, * ), B( LDB, * ), BF( LDB, * ),
* $ T( LDB, * ), Z( LDB, * ), BWK( LDB, * ),
* $ TAUA( * ), TAUB( * ), RESULT( 4 ),
* $ RWORK( * ), WORK( LWORK )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SGQRTS tests SGGQRF, which computes the GQR factorization of an
*> N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of rows of the matrices A and B. N >= 0.
*> \endverbatim
*>
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of columns of the matrix A. M >= 0.
*> \endverbatim
*>
*> \param[in] P
*> \verbatim
*> P is INTEGER
*> The number of columns of the matrix B. P >= 0.
*> \endverbatim
*>
*> \param[in] A
*> \verbatim
*> A is REAL array, dimension (LDA,M)
*> The N-by-M matrix A.
*> \endverbatim
*>
*> \param[out] AF
*> \verbatim
*> AF is REAL array, dimension (LDA,N)
*> Details of the GQR factorization of A and B, as returned
*> by SGGQRF, see SGGQRF for further details.
*> \endverbatim
*>
*> \param[out] Q
*> \verbatim
*> Q is REAL array, dimension (LDA,N)
*> The M-by-M orthogonal matrix Q.
*> \endverbatim
*>
*> \param[out] R
*> \verbatim
*> R is REAL array, dimension (LDA,MAX(M,N))
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the arrays A, AF, R and Q.
*> LDA >= max(M,N).
*> \endverbatim
*>
*> \param[out] TAUA
*> \verbatim
*> TAUA is REAL array, dimension (min(M,N))
*> The scalar factors of the elementary reflectors, as returned
*> by SGGQRF.
*> \endverbatim
*>
*> \param[in] B
*> \verbatim
*> B is REAL array, dimension (LDB,P)
*> On entry, the N-by-P matrix A.
*> \endverbatim
*>
*> \param[out] BF
*> \verbatim
*> BF is REAL array, dimension (LDB,N)
*> Details of the GQR factorization of A and B, as returned
*> by SGGQRF, see SGGQRF for further details.
*> \endverbatim
*>
*> \param[out] Z
*> \verbatim
*> Z is REAL array, dimension (LDB,P)
*> The P-by-P orthogonal matrix Z.
*> \endverbatim
*>
*> \param[out] T
*> \verbatim
*> T is REAL array, dimension (LDB,max(P,N))
*> \endverbatim
*>
*> \param[out] BWK
*> \verbatim
*> BWK is REAL array, dimension (LDB,N)
*> \endverbatim
*>
*> \param[in] LDB
*> \verbatim
*> LDB is INTEGER
*> The leading dimension of the arrays B, BF, Z and T.
*> LDB >= max(P,N).
*> \endverbatim
*>
*> \param[out] TAUB
*> \verbatim
*> TAUB is REAL array, dimension (min(P,N))
*> The scalar factors of the elementary reflectors, as returned
*> by SGGRQF.
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is REAL array, dimension (LWORK)
*> \endverbatim
*>
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The dimension of the array WORK, LWORK >= max(N,M,P)**2.
*> \endverbatim
*>
*> \param[out] RWORK
*> \verbatim
*> RWORK is REAL array, dimension (max(N,M,P))
*> \endverbatim
*>
*> \param[out] RESULT
*> \verbatim
*> RESULT is REAL array, dimension (4)
*> The test ratios:
*> RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP)
*> RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP)
*> RESULT(3) = norm( I - Q'*Q ) / ( M*ULP )
*> RESULT(4) = norm( I - Z'*Z ) / ( P*ULP )
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_eig
*
* =====================================================================
SUBROUTINE SGQRTS( N, M, P, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
$ BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER LDA, LDB, LWORK, M, P, N
* ..
* .. Array Arguments ..
REAL A( LDA, * ), AF( LDA, * ), R( LDA, * ),
$ Q( LDA, * ), B( LDB, * ), BF( LDB, * ),
$ T( LDB, * ), Z( LDB, * ), BWK( LDB, * ),
$ TAUA( * ), TAUB( * ), RESULT( 4 ),
$ RWORK( * ), WORK( LWORK )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
REAL ROGUE
PARAMETER ( ROGUE = -1.0E+10 )
* ..
* .. Local Scalars ..
INTEGER INFO
REAL ANORM, BNORM, ULP, UNFL, RESID
* ..
* .. External Functions ..
REAL SLAMCH, SLANGE, SLANSY
EXTERNAL SLAMCH, SLANGE, SLANSY
* ..
* .. External Subroutines ..
EXTERNAL SGEMM, SLACPY, SLASET, SORGQR,
$ SORGRQ, SSYRK
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN, REAL
* ..
* .. Executable Statements ..
*
ULP = SLAMCH( 'Precision' )
UNFL = SLAMCH( 'Safe minimum' )
*
* Copy the matrix A to the array AF.
*
CALL SLACPY( 'Full', N, M, A, LDA, AF, LDA )
CALL SLACPY( 'Full', N, P, B, LDB, BF, LDB )
*
ANORM = MAX( SLANGE( '1', N, M, A, LDA, RWORK ), UNFL )
BNORM = MAX( SLANGE( '1', N, P, B, LDB, RWORK ), UNFL )
*
* Factorize the matrices A and B in the arrays AF and BF.
*
CALL SGGQRF( N, M, P, AF, LDA, TAUA, BF, LDB, TAUB, WORK,
$ LWORK, INFO )
*
* Generate the N-by-N matrix Q
*
CALL SLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
CALL SLACPY( 'Lower', N-1, M, AF( 2,1 ), LDA, Q( 2,1 ), LDA )
CALL SORGQR( N, N, MIN( N, M ), Q, LDA, TAUA, WORK, LWORK, INFO )
*
* Generate the P-by-P matrix Z
*
CALL SLASET( 'Full', P, P, ROGUE, ROGUE, Z, LDB )
IF( N.LE.P ) THEN
IF( N.GT.0 .AND. N.LT.P )
$ CALL SLACPY( 'Full', N, P-N, BF, LDB, Z( P-N+1, 1 ), LDB )
IF( N.GT.1 )
$ CALL SLACPY( 'Lower', N-1, N-1, BF( 2, P-N+1 ), LDB,
$ Z( P-N+2, P-N+1 ), LDB )
ELSE
IF( P.GT.1)
$ CALL SLACPY( 'Lower', P-1, P-1, BF( N-P+2, 1 ), LDB,
$ Z( 2, 1 ), LDB )
END IF
CALL SORGRQ( P, P, MIN( N, P ), Z, LDB, TAUB, WORK, LWORK, INFO )
*
* Copy R
*
CALL SLASET( 'Full', N, M, ZERO, ZERO, R, LDA )
CALL SLACPY( 'Upper', N, M, AF, LDA, R, LDA )
*
* Copy T
*
CALL SLASET( 'Full', N, P, ZERO, ZERO, T, LDB )
IF( N.LE.P ) THEN
CALL SLACPY( 'Upper', N, N, BF( 1, P-N+1 ), LDB, T( 1, P-N+1 ),
$ LDB )
ELSE
CALL SLACPY( 'Full', N-P, P, BF, LDB, T, LDB )
CALL SLACPY( 'Upper', P, P, BF( N-P+1, 1 ), LDB, T( N-P+1, 1 ),
$ LDB )
END IF
*
* Compute R - Q'*A
*
CALL SGEMM( 'Transpose', 'No transpose', N, M, N, -ONE, Q, LDA, A,
$ LDA, ONE, R, LDA )
*
* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) .
*
RESID = SLANGE( '1', N, M, R, LDA, RWORK )
IF( ANORM.GT.ZERO ) THEN
RESULT( 1 ) = ( ( RESID / REAL( MAX(1,M,N) ) ) / ANORM ) / ULP
ELSE
RESULT( 1 ) = ZERO
END IF
*
* Compute T*Z - Q'*B
*
CALL SGEMM( 'No Transpose', 'No transpose', N, P, P, ONE, T, LDB,
$ Z, LDB, ZERO, BWK, LDB )
CALL SGEMM( 'Transpose', 'No transpose', N, P, N, -ONE, Q, LDA,
$ B, LDB, ONE, BWK, LDB )
*
* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
*
RESID = SLANGE( '1', N, P, BWK, LDB, RWORK )
IF( BNORM.GT.ZERO ) THEN
RESULT( 2 ) = ( ( RESID / REAL( MAX(1,P,N ) ) )/BNORM ) / ULP
ELSE
RESULT( 2 ) = ZERO
END IF
*
* Compute I - Q'*Q
*
CALL SLASET( 'Full', N, N, ZERO, ONE, R, LDA )
CALL SSYRK( 'Upper', 'Transpose', N, N, -ONE, Q, LDA, ONE, R,
$ LDA )
*
* Compute norm( I - Q'*Q ) / ( N * ULP ) .
*
RESID = SLANSY( '1', 'Upper', N, R, LDA, RWORK )
RESULT( 3 ) = ( RESID / REAL( MAX( 1, N ) ) ) / ULP
*
* Compute I - Z'*Z
*
CALL SLASET( 'Full', P, P, ZERO, ONE, T, LDB )
CALL SSYRK( 'Upper', 'Transpose', P, P, -ONE, Z, LDB, ONE, T,
$ LDB )
*
* Compute norm( I - Z'*Z ) / ( P*ULP ) .
*
RESID = SLANSY( '1', 'Upper', P, T, LDB, RWORK )
RESULT( 4 ) = ( RESID / REAL( MAX( 1, P ) ) ) / ULP
*
RETURN
*
* End of SGQRTS
*
END
| bsd-3-clause |
CavendishAstrophysics/anmap | image_lib/do_add_flux.f | 1 | 1769 | C
C
*+ do_add_flux
subroutine do_add_flux(map_array,status)
C ----------------------------------------
C
C determine the flux within a specified region
C
C Given:
C map data
real*4 map_array(*)
C Returned:
C error status word
integer status
C
C Only those points whose absolute value is above a specified gate are
C included in the sum. The sum normalized to the CLEAN-BEAM volume is
C also written out.
*-
C Local variables
C mini redtape and uvrange variables
integer minirt(8), iuv(8)
C pointers, counters etc.
integer imap, ip_map, i
integer iout, npts
C results and gate on map
real*4 flux, gate, clean_flux
C data for cleaned maps
real*4 flxnrm, beam(2), position_angle
C check status on entry
if (status.ne.0) return
C find map
call map_getmap('Map : ','Default-Map','READ',imap,status)
call enbeam(flxnrm,beam,position_angle,status)
C get map region
call enminirt(minirt,status)
call enminirt(iuv,status)
call plot_getuv('UV-range : ','*',iuv,status)
call map_alloc_area(imap,iuv,map_array,ip_map,status)
C get gate
gate = 0.0
call io_getr('Gate : ','*',gate,status)
C do sum
call image_addflux(minirt,map_array(ip_map),
* iuv,gate,flux,npts,status)
if (status.ne.0) goto 999
C now clean beam normalized flux
clean_flux = flux*flxnrm
C write out results
call io_enqout(iout)
write(iout,100)imap,(iuv(i), i=1,4),flux,clean_flux
100 format(' Map=',i2,' UV=',4I6,' sum=',1PE12.3,
* ' CLEAN-Flux=',1PE12.3)
999 call map_end_alloc(imap,map_array,status)
call cmd_err(status,'ADD-FLUX','Failed')
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/LIN/ddrvls.f | 29 | 27676 | *> \brief \b DDRVLS
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DDRVLS( DOTYPE, NM, MVAL, NN, NVAL, NNS, NSVAL, NNB,
* NBVAL, NXVAL, THRESH, TSTERR, A, COPYA, B,
* COPYB, C, S, COPYS, WORK, IWORK, NOUT )
*
* .. Scalar Arguments ..
* LOGICAL TSTERR
* INTEGER NM, NN, NNB, NNS, NOUT
* DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
* LOGICAL DOTYPE( * )
* INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
* $ NVAL( * ), NXVAL( * )
* DOUBLE PRECISION A( * ), B( * ), C( * ), COPYA( * ), COPYB( * ),
* $ COPYS( * ), S( * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DDRVLS tests the least squares driver routines DGELS, DGELSS, DGELSX,
*> DGELSY and DGELSD.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] DOTYPE
*> \verbatim
*> DOTYPE is LOGICAL array, dimension (NTYPES)
*> The matrix types to be used for testing. Matrices of type j
*> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
*> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
*> The matrix of type j is generated as follows:
*> j=1: A = U*D*V where U and V are random orthogonal matrices
*> and D has random entries (> 0.1) taken from a uniform
*> distribution (0,1). A is full rank.
*> j=2: The same of 1, but A is scaled up.
*> j=3: The same of 1, but A is scaled down.
*> j=4: A = U*D*V where U and V are random orthogonal matrices
*> and D has 3*min(M,N)/4 random entries (> 0.1) taken
*> from a uniform distribution (0,1) and the remaining
*> entries set to 0. A is rank-deficient.
*> j=5: The same of 4, but A is scaled up.
*> j=6: The same of 5, but A is scaled down.
*> \endverbatim
*>
*> \param[in] NM
*> \verbatim
*> NM is INTEGER
*> The number of values of M contained in the vector MVAL.
*> \endverbatim
*>
*> \param[in] MVAL
*> \verbatim
*> MVAL is INTEGER array, dimension (NM)
*> The values of the matrix row dimension M.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER
*> The number of values of N contained in the vector NVAL.
*> \endverbatim
*>
*> \param[in] NVAL
*> \verbatim
*> NVAL is INTEGER array, dimension (NN)
*> The values of the matrix column dimension N.
*> \endverbatim
*>
*> \param[in] NNS
*> \verbatim
*> NNS is INTEGER
*> The number of values of NRHS contained in the vector NSVAL.
*> \endverbatim
*>
*> \param[in] NSVAL
*> \verbatim
*> NSVAL is INTEGER array, dimension (NNS)
*> The values of the number of right hand sides NRHS.
*> \endverbatim
*>
*> \param[in] NNB
*> \verbatim
*> NNB is INTEGER
*> The number of values of NB and NX contained in the
*> vectors NBVAL and NXVAL. The blocking parameters are used
*> in pairs (NB,NX).
*> \endverbatim
*>
*> \param[in] NBVAL
*> \verbatim
*> NBVAL is INTEGER array, dimension (NNB)
*> The values of the blocksize NB.
*> \endverbatim
*>
*> \param[in] NXVAL
*> \verbatim
*> NXVAL is INTEGER array, dimension (NNB)
*> The values of the crossover point NX.
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is DOUBLE PRECISION
*> The threshold value for the test ratios. A result is
*> included in the output file if RESULT >= THRESH. To have
*> every test ratio printed, use THRESH = 0.
*> \endverbatim
*>
*> \param[in] TSTERR
*> \verbatim
*> TSTERR is LOGICAL
*> Flag that indicates whether error exits are to be tested.
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is DOUBLE PRECISION array, dimension (MMAX*NMAX)
*> where MMAX is the maximum value of M in MVAL and NMAX is the
*> maximum value of N in NVAL.
*> \endverbatim
*>
*> \param[out] COPYA
*> \verbatim
*> COPYA is DOUBLE PRECISION array, dimension (MMAX*NMAX)
*> \endverbatim
*>
*> \param[out] B
*> \verbatim
*> B is DOUBLE PRECISION array, dimension (MMAX*NSMAX)
*> where MMAX is the maximum value of M in MVAL and NSMAX is the
*> maximum value of NRHS in NSVAL.
*> \endverbatim
*>
*> \param[out] COPYB
*> \verbatim
*> COPYB is DOUBLE PRECISION array, dimension (MMAX*NSMAX)
*> \endverbatim
*>
*> \param[out] C
*> \verbatim
*> C is DOUBLE PRECISION array, dimension (MMAX*NSMAX)
*> \endverbatim
*>
*> \param[out] S
*> \verbatim
*> S is DOUBLE PRECISION array, dimension
*> (min(MMAX,NMAX))
*> \endverbatim
*>
*> \param[out] COPYS
*> \verbatim
*> COPYS is DOUBLE PRECISION array, dimension
*> (min(MMAX,NMAX))
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION array,
*> dimension (MMAX*NMAX + 4*NMAX + MMAX).
*> \endverbatim
*>
*> \param[out] IWORK
*> \verbatim
*> IWORK is INTEGER array, dimension (15*NMAX)
*> \endverbatim
*>
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_lin
*
* =====================================================================
SUBROUTINE DDRVLS( DOTYPE, NM, MVAL, NN, NVAL, NNS, NSVAL, NNB,
$ NBVAL, NXVAL, THRESH, TSTERR, A, COPYA, B,
$ COPYB, C, S, COPYS, WORK, IWORK, NOUT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
LOGICAL TSTERR
INTEGER NM, NN, NNB, NNS, NOUT
DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
LOGICAL DOTYPE( * )
INTEGER IWORK( * ), MVAL( * ), NBVAL( * ), NSVAL( * ),
$ NVAL( * ), NXVAL( * )
DOUBLE PRECISION A( * ), B( * ), C( * ), COPYA( * ), COPYB( * ),
$ COPYS( * ), S( * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NTESTS
PARAMETER ( NTESTS = 18 )
INTEGER SMLSIZ
PARAMETER ( SMLSIZ = 25 )
DOUBLE PRECISION ONE, TWO, ZERO
PARAMETER ( ONE = 1.0D0, TWO = 2.0D0, ZERO = 0.0D0 )
* ..
* .. Local Scalars ..
CHARACTER TRANS
CHARACTER*3 PATH
INTEGER CRANK, I, IM, IN, INB, INFO, INS, IRANK,
$ ISCALE, ITRAN, ITYPE, J, K, LDA, LDB, LDWORK,
$ LWLSY, LWORK, M, MNMIN, N, NB, NCOLS, NERRS,
$ NFAIL, NLVL, NRHS, NROWS, NRUN, RANK
DOUBLE PRECISION EPS, NORMA, NORMB, RCOND
* ..
* .. Local Arrays ..
INTEGER ISEED( 4 ), ISEEDY( 4 )
DOUBLE PRECISION RESULT( NTESTS )
* ..
* .. External Functions ..
DOUBLE PRECISION DASUM, DLAMCH, DQRT12, DQRT14, DQRT17
EXTERNAL DASUM, DLAMCH, DQRT12, DQRT14, DQRT17
* ..
* .. External Subroutines ..
EXTERNAL ALAERH, ALAHD, ALASVM, DAXPY, DERRLS, DGELS,
$ DGELSD, DGELSS, DGELSX, DGELSY, DGEMM, DLACPY,
$ DLARNV, DLASRT, DQRT13, DQRT15, DQRT16, DSCAL,
$ XLAENV
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, INT, LOG, MAX, MIN, SQRT
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, IOUNIT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, IOUNIT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
PATH( 1: 1 ) = 'Double precision'
PATH( 2: 3 ) = 'LS'
NRUN = 0
NFAIL = 0
NERRS = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
EPS = DLAMCH( 'Epsilon' )
*
* Threshold for rank estimation
*
RCOND = SQRT( EPS ) - ( SQRT( EPS )-EPS ) / 2
*
* Test the error exits
*
CALL XLAENV( 2, 2 )
CALL XLAENV( 9, SMLSIZ )
IF( TSTERR )
$ CALL DERRLS( PATH, NOUT )
*
* Print the header if NM = 0 or NN = 0 and THRESH = 0.
*
IF( ( NM.EQ.0 .OR. NN.EQ.0 ) .AND. THRESH.EQ.ZERO )
$ CALL ALAHD( NOUT, PATH )
INFOT = 0
CALL XLAENV( 2, 2 )
CALL XLAENV( 9, SMLSIZ )
*
DO 150 IM = 1, NM
M = MVAL( IM )
LDA = MAX( 1, M )
*
DO 140 IN = 1, NN
N = NVAL( IN )
MNMIN = MIN( M, N )
LDB = MAX( 1, M, N )
*
DO 130 INS = 1, NNS
NRHS = NSVAL( INS )
NLVL = MAX( INT( LOG( MAX( ONE, DBLE( MNMIN ) ) /
$ DBLE( SMLSIZ+1 ) ) / LOG( TWO ) ) + 1, 0 )
LWORK = MAX( 1, ( M+NRHS )*( N+2 ), ( N+NRHS )*( M+2 ),
$ M*N+4*MNMIN+MAX( M, N ), 12*MNMIN+2*MNMIN*SMLSIZ+
$ 8*MNMIN*NLVL+MNMIN*NRHS+(SMLSIZ+1)**2 )
*
DO 120 IRANK = 1, 2
DO 110 ISCALE = 1, 3
ITYPE = ( IRANK-1 )*3 + ISCALE
IF( .NOT.DOTYPE( ITYPE ) )
$ GO TO 110
*
IF( IRANK.EQ.1 ) THEN
*
* Test DGELS
*
* Generate a matrix of scaling type ISCALE
*
CALL DQRT13( ISCALE, M, N, COPYA, LDA, NORMA,
$ ISEED )
DO 40 INB = 1, NNB
NB = NBVAL( INB )
CALL XLAENV( 1, NB )
CALL XLAENV( 3, NXVAL( INB ) )
*
DO 30 ITRAN = 1, 2
IF( ITRAN.EQ.1 ) THEN
TRANS = 'N'
NROWS = M
NCOLS = N
ELSE
TRANS = 'T'
NROWS = N
NCOLS = M
END IF
LDWORK = MAX( 1, NCOLS )
*
* Set up a consistent rhs
*
IF( NCOLS.GT.0 ) THEN
CALL DLARNV( 2, ISEED, NCOLS*NRHS,
$ WORK )
CALL DSCAL( NCOLS*NRHS,
$ ONE / DBLE( NCOLS ), WORK,
$ 1 )
END IF
CALL DGEMM( TRANS, 'No transpose', NROWS,
$ NRHS, NCOLS, ONE, COPYA, LDA,
$ WORK, LDWORK, ZERO, B, LDB )
CALL DLACPY( 'Full', NROWS, NRHS, B, LDB,
$ COPYB, LDB )
*
* Solve LS or overdetermined system
*
IF( M.GT.0 .AND. N.GT.0 ) THEN
CALL DLACPY( 'Full', M, N, COPYA, LDA,
$ A, LDA )
CALL DLACPY( 'Full', NROWS, NRHS,
$ COPYB, LDB, B, LDB )
END IF
SRNAMT = 'DGELS '
CALL DGELS( TRANS, M, N, NRHS, A, LDA, B,
$ LDB, WORK, LWORK, INFO )
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DGELS ', INFO, 0,
$ TRANS, M, N, NRHS, -1, NB,
$ ITYPE, NFAIL, NERRS,
$ NOUT )
*
* Check correctness of results
*
LDWORK = MAX( 1, NROWS )
IF( NROWS.GT.0 .AND. NRHS.GT.0 )
$ CALL DLACPY( 'Full', NROWS, NRHS,
$ COPYB, LDB, C, LDB )
CALL DQRT16( TRANS, M, N, NRHS, COPYA,
$ LDA, B, LDB, C, LDB, WORK,
$ RESULT( 1 ) )
*
IF( ( ITRAN.EQ.1 .AND. M.GE.N ) .OR.
$ ( ITRAN.EQ.2 .AND. M.LT.N ) ) THEN
*
* Solving LS system
*
RESULT( 2 ) = DQRT17( TRANS, 1, M, N,
$ NRHS, COPYA, LDA, B, LDB,
$ COPYB, LDB, C, WORK,
$ LWORK )
ELSE
*
* Solving overdetermined system
*
RESULT( 2 ) = DQRT14( TRANS, M, N,
$ NRHS, COPYA, LDA, B, LDB,
$ WORK, LWORK )
END IF
*
* Print information about the tests that
* did not pass the threshold.
*
DO 20 K = 1, 2
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )TRANS, M,
$ N, NRHS, NB, ITYPE, K,
$ RESULT( K )
NFAIL = NFAIL + 1
END IF
20 CONTINUE
NRUN = NRUN + 2
30 CONTINUE
40 CONTINUE
END IF
*
* Generate a matrix of scaling type ISCALE and rank
* type IRANK.
*
CALL DQRT15( ISCALE, IRANK, M, N, NRHS, COPYA, LDA,
$ COPYB, LDB, COPYS, RANK, NORMA, NORMB,
$ ISEED, WORK, LWORK )
*
* workspace used: MAX(M+MIN(M,N),NRHS*MIN(M,N),2*N+M)
*
* Initialize vector IWORK.
*
DO 50 J = 1, N
IWORK( J ) = 0
50 CONTINUE
LDWORK = MAX( 1, M )
*
* Test DGELSX
*
* DGELSX: Compute the minimum-norm solution X
* to min( norm( A * X - B ) ) using a complete
* orthogonal factorization.
*
CALL DLACPY( 'Full', M, N, COPYA, LDA, A, LDA )
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, B, LDB )
*
SRNAMT = 'DGELSX'
CALL DGELSX( M, N, NRHS, A, LDA, B, LDB, IWORK,
$ RCOND, CRANK, WORK, INFO )
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DGELSX', INFO, 0, ' ', M, N,
$ NRHS, -1, NB, ITYPE, NFAIL, NERRS,
$ NOUT )
*
* workspace used: MAX( MNMIN+3*N, 2*MNMIN+NRHS )
*
* Test 3: Compute relative error in svd
* workspace: M*N + 4*MIN(M,N) + MAX(M,N)
*
RESULT( 3 ) = DQRT12( CRANK, CRANK, A, LDA, COPYS,
$ WORK, LWORK )
*
* Test 4: Compute error in solution
* workspace: M*NRHS + M
*
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, WORK,
$ LDWORK )
CALL DQRT16( 'No transpose', M, N, NRHS, COPYA,
$ LDA, B, LDB, WORK, LDWORK,
$ WORK( M*NRHS+1 ), RESULT( 4 ) )
*
* Test 5: Check norm of r'*A
* workspace: NRHS*(M+N)
*
RESULT( 5 ) = ZERO
IF( M.GT.CRANK )
$ RESULT( 5 ) = DQRT17( 'No transpose', 1, M, N,
$ NRHS, COPYA, LDA, B, LDB, COPYB,
$ LDB, C, WORK, LWORK )
*
* Test 6: Check if x is in the rowspace of A
* workspace: (M+NRHS)*(N+2)
*
RESULT( 6 ) = ZERO
*
IF( N.GT.CRANK )
$ RESULT( 6 ) = DQRT14( 'No transpose', M, N,
$ NRHS, COPYA, LDA, B, LDB, WORK,
$ LWORK )
*
* Print information about the tests that did not
* pass the threshold.
*
DO 60 K = 3, 6
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9998 )M, N, NRHS, NB,
$ ITYPE, K, RESULT( K )
NFAIL = NFAIL + 1
END IF
60 CONTINUE
NRUN = NRUN + 4
*
* Loop for testing different block sizes.
*
DO 100 INB = 1, NNB
NB = NBVAL( INB )
CALL XLAENV( 1, NB )
CALL XLAENV( 3, NXVAL( INB ) )
*
* Test DGELSY
*
* DGELSY: Compute the minimum-norm solution X
* to min( norm( A * X - B ) )
* using the rank-revealing orthogonal
* factorization.
*
* Initialize vector IWORK.
*
DO 70 J = 1, N
IWORK( J ) = 0
70 CONTINUE
*
* Set LWLSY to the adequate value.
*
LWLSY = MAX( 1, MNMIN+2*N+NB*( N+1 ),
$ 2*MNMIN+NB*NRHS )
*
CALL DLACPY( 'Full', M, N, COPYA, LDA, A, LDA )
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, B,
$ LDB )
*
SRNAMT = 'DGELSY'
CALL DGELSY( M, N, NRHS, A, LDA, B, LDB, IWORK,
$ RCOND, CRANK, WORK, LWLSY, INFO )
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DGELSY', INFO, 0, ' ', M,
$ N, NRHS, -1, NB, ITYPE, NFAIL,
$ NERRS, NOUT )
*
* Test 7: Compute relative error in svd
* workspace: M*N + 4*MIN(M,N) + MAX(M,N)
*
RESULT( 7 ) = DQRT12( CRANK, CRANK, A, LDA,
$ COPYS, WORK, LWORK )
*
* Test 8: Compute error in solution
* workspace: M*NRHS + M
*
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, WORK,
$ LDWORK )
CALL DQRT16( 'No transpose', M, N, NRHS, COPYA,
$ LDA, B, LDB, WORK, LDWORK,
$ WORK( M*NRHS+1 ), RESULT( 8 ) )
*
* Test 9: Check norm of r'*A
* workspace: NRHS*(M+N)
*
RESULT( 9 ) = ZERO
IF( M.GT.CRANK )
$ RESULT( 9 ) = DQRT17( 'No transpose', 1, M,
$ N, NRHS, COPYA, LDA, B, LDB,
$ COPYB, LDB, C, WORK, LWORK )
*
* Test 10: Check if x is in the rowspace of A
* workspace: (M+NRHS)*(N+2)
*
RESULT( 10 ) = ZERO
*
IF( N.GT.CRANK )
$ RESULT( 10 ) = DQRT14( 'No transpose', M, N,
$ NRHS, COPYA, LDA, B, LDB,
$ WORK, LWORK )
*
* Test DGELSS
*
* DGELSS: Compute the minimum-norm solution X
* to min( norm( A * X - B ) )
* using the SVD.
*
CALL DLACPY( 'Full', M, N, COPYA, LDA, A, LDA )
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, B,
$ LDB )
SRNAMT = 'DGELSS'
CALL DGELSS( M, N, NRHS, A, LDA, B, LDB, S,
$ RCOND, CRANK, WORK, LWORK, INFO )
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DGELSS', INFO, 0, ' ', M,
$ N, NRHS, -1, NB, ITYPE, NFAIL,
$ NERRS, NOUT )
*
* workspace used: 3*min(m,n) +
* max(2*min(m,n),nrhs,max(m,n))
*
* Test 11: Compute relative error in svd
*
IF( RANK.GT.0 ) THEN
CALL DAXPY( MNMIN, -ONE, COPYS, 1, S, 1 )
RESULT( 11 ) = DASUM( MNMIN, S, 1 ) /
$ DASUM( MNMIN, COPYS, 1 ) /
$ ( EPS*DBLE( MNMIN ) )
ELSE
RESULT( 11 ) = ZERO
END IF
*
* Test 12: Compute error in solution
*
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, WORK,
$ LDWORK )
CALL DQRT16( 'No transpose', M, N, NRHS, COPYA,
$ LDA, B, LDB, WORK, LDWORK,
$ WORK( M*NRHS+1 ), RESULT( 12 ) )
*
* Test 13: Check norm of r'*A
*
RESULT( 13 ) = ZERO
IF( M.GT.CRANK )
$ RESULT( 13 ) = DQRT17( 'No transpose', 1, M,
$ N, NRHS, COPYA, LDA, B, LDB,
$ COPYB, LDB, C, WORK, LWORK )
*
* Test 14: Check if x is in the rowspace of A
*
RESULT( 14 ) = ZERO
IF( N.GT.CRANK )
$ RESULT( 14 ) = DQRT14( 'No transpose', M, N,
$ NRHS, COPYA, LDA, B, LDB,
$ WORK, LWORK )
*
* Test DGELSD
*
* DGELSD: Compute the minimum-norm solution X
* to min( norm( A * X - B ) ) using a
* divide and conquer SVD.
*
* Initialize vector IWORK.
*
DO 80 J = 1, N
IWORK( J ) = 0
80 CONTINUE
*
CALL DLACPY( 'Full', M, N, COPYA, LDA, A, LDA )
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, B,
$ LDB )
*
SRNAMT = 'DGELSD'
CALL DGELSD( M, N, NRHS, A, LDA, B, LDB, S,
$ RCOND, CRANK, WORK, LWORK, IWORK,
$ INFO )
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'DGELSD', INFO, 0, ' ', M,
$ N, NRHS, -1, NB, ITYPE, NFAIL,
$ NERRS, NOUT )
*
* Test 15: Compute relative error in svd
*
IF( RANK.GT.0 ) THEN
CALL DAXPY( MNMIN, -ONE, COPYS, 1, S, 1 )
RESULT( 15 ) = DASUM( MNMIN, S, 1 ) /
$ DASUM( MNMIN, COPYS, 1 ) /
$ ( EPS*DBLE( MNMIN ) )
ELSE
RESULT( 15 ) = ZERO
END IF
*
* Test 16: Compute error in solution
*
CALL DLACPY( 'Full', M, NRHS, COPYB, LDB, WORK,
$ LDWORK )
CALL DQRT16( 'No transpose', M, N, NRHS, COPYA,
$ LDA, B, LDB, WORK, LDWORK,
$ WORK( M*NRHS+1 ), RESULT( 16 ) )
*
* Test 17: Check norm of r'*A
*
RESULT( 17 ) = ZERO
IF( M.GT.CRANK )
$ RESULT( 17 ) = DQRT17( 'No transpose', 1, M,
$ N, NRHS, COPYA, LDA, B, LDB,
$ COPYB, LDB, C, WORK, LWORK )
*
* Test 18: Check if x is in the rowspace of A
*
RESULT( 18 ) = ZERO
IF( N.GT.CRANK )
$ RESULT( 18 ) = DQRT14( 'No transpose', M, N,
$ NRHS, COPYA, LDA, B, LDB,
$ WORK, LWORK )
*
* Print information about the tests that did not
* pass the threshold.
*
DO 90 K = 7, NTESTS
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9998 )M, N, NRHS, NB,
$ ITYPE, K, RESULT( K )
NFAIL = NFAIL + 1
END IF
90 CONTINUE
NRUN = NRUN + 12
*
100 CONTINUE
110 CONTINUE
120 CONTINUE
130 CONTINUE
140 CONTINUE
150 CONTINUE
*
* Print a summary of the results.
*
CALL ALASVM( PATH, NOUT, NFAIL, NRUN, NERRS )
*
9999 FORMAT( ' TRANS=''', A1, ''', M=', I5, ', N=', I5, ', NRHS=', I4,
$ ', NB=', I4, ', type', I2, ', test(', I2, ')=', G12.5 )
9998 FORMAT( ' M=', I5, ', N=', I5, ', NRHS=', I4, ', NB=', I4,
$ ', type', I2, ', test(', I2, ')=', G12.5 )
RETURN
*
* End of DDRVLS
*
END
| bsd-3-clause |
ericmckean/nacl-llvm-branches.llvm-gcc-trunk | gcc/testsuite/gfortran.dg/used_dummy_types_6.f90 | 52 | 1422 | ! { dg-do compile }
! Tests the fix for PR30554, the USE statements in potential_energy
! would cause a segfault because the pointer_info for nfree coming
! from constraint would not find the existing symtree coming directly
! from atom.
!
! The last two modules came up subsequently to the original fix. The
! PRIVATE statement caused a revival of the original problem. This
! was tracked down to an interaction between the symbols being set
! referenced during module read and the application of the access
! attribute.
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
MODULE ATOMS
INTEGER :: NFREE = 0
END MODULE ATOMS
MODULE CONSTRAINT
USE ATOMS, ONLY: NFREE
CONTAINS
SUBROUTINE ENERGY_CONSTRAINT ( HESSIAN )
REAL , DIMENSION(1:(3*NFREE*(3*NFREE+1))/2):: HESSIAN
END SUBROUTINE ENERGY_CONSTRAINT
END MODULE CONSTRAINT
MODULE POTENTIAL_ENERGY
USE ATOMS
USE CONSTRAINT, ONLY : ENERGY_CONSTRAINT
END MODULE POTENTIAL_ENERGY
MODULE P_CONSTRAINT
USE ATOMS, ONLY: NFREE
PRIVATE
PUBLIC :: ENERGY_CONSTRAINT
CONTAINS
SUBROUTINE ENERGY_CONSTRAINT ( HESSIAN )
REAL , DIMENSION(1:(3*NFREE*(3*NFREE+1))/2):: HESSIAN
END SUBROUTINE ENERGY_CONSTRAINT
END MODULE P_CONSTRAINT
MODULE P_POTENTIAL_ENERGY
USE ATOMS
USE CONSTRAINT, ONLY : ENERGY_CONSTRAINT
END MODULE P_POTENTIAL_ENERGY
! { dg-final { cleanup-modules "atoms constraint potential_energy p_constraint p_potential_energy" } }
| gpl-2.0 |
yaowee/libflame | src/flablas/f2c/dsdot.f | 13 | 2551 | *DECK DSDOT
DOUBLE PRECISION FUNCTION DSDOT (N, SX, INCX, SY, INCY)
C***BEGIN PROLOGUE DSDOT
C***PURPOSE Compute the inner product of two vectors with extended
C precision accumulation and result.
C***LIBRARY SLATEC (BLAS)
C***CATEGORY D1A4
C***TYPE DOUBLE PRECISION (DSDOT-D, DCDOT-C)
C***KEYWORDS BLAS, COMPLEX VECTORS, DOT PRODUCT, INNER PRODUCT,
C LINEAR ALGEBRA, VECTOR
C***AUTHOR Lawson, C. L., (JPL)
C Hanson, R. J., (SNLA)
C Kincaid, D. R., (U. of Texas)
C Krogh, F. T., (JPL)
C***DESCRIPTION
C
C B L A S Subprogram
C Description of Parameters
C
C --Input--
C N number of elements in input vector(s)
C SX single precision vector with N elements
C INCX storage spacing between elements of SX
C SY single precision vector with N elements
C INCY storage spacing between elements of SY
C
C --Output--
C DSDOT double precision dot product (zero if N.LE.0)
C
C Returns D.P. dot product accumulated in D.P., for S.P. SX and SY
C DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY),
C where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
C defined in a similar way using INCY.
C
C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
C Krogh, Basic linear algebra subprograms for Fortran
C usage, Algorithm No. 539, Transactions on Mathematical
C Software 5, 3 (September 1979), pp. 308-323.
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 791001 DATE WRITTEN
C 890831 Modified array declarations. (WRB)
C 890831 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 920310 Corrected definition of LX in DESCRIPTION. (WRB)
C 920501 Reformatted the REFERENCES section. (WRB)
C***END PROLOGUE DSDOT
REAL SX(*),SY(*)
C***FIRST EXECUTABLE STATEMENT DSDOT
DSDOT = 0.0D0
IF (N .LE. 0) RETURN
IF (INCX.EQ.INCY .AND. INCX.GT.0) GO TO 20
C
C Code for unequal or nonpositive increments.
C
KX = 1
KY = 1
IF (INCX .LT. 0) KX = 1+(1-N)*INCX
IF (INCY .LT. 0) KY = 1+(1-N)*INCY
DO 10 I = 1,N
DSDOT = DSDOT + DBLE(SX(KX))*DBLE(SY(KY))
KX = KX + INCX
KY = KY + INCY
10 CONTINUE
RETURN
C
C Code for equal, positive, non-unit increments.
C
20 NS = N*INCX
DO 30 I = 1,NS,INCX
DSDOT = DSDOT + DBLE(SX(I))*DBLE(SY(I))
30 CONTINUE
RETURN
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/zerrgex.f | 32 | 20741 | *> \brief \b ZERRGEX
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE ZERRGE( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZERRGE tests the error exits for the COMPLEX*16 routines
*> for general matrices.
*>
*> Note that this file is used only when the XBLAS are available,
*> otherwise zerrge.f defines this subroutine.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup complex16_lin
*
* =====================================================================
SUBROUTINE ZERRGE( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 4 )
* ..
* .. Local Scalars ..
CHARACTER EQ
CHARACTER*2 C2
INTEGER I, INFO, J, N_ERR_BNDS, NPARAMS
DOUBLE PRECISION ANRM, CCOND, RCOND, BERR
* ..
* .. Local Arrays ..
INTEGER IP( NMAX )
DOUBLE PRECISION R( NMAX ), R1( NMAX ), R2( NMAX ), CS( NMAX ),
$ RS( NMAX )
COMPLEX*16 A( NMAX, NMAX ), AF( NMAX, NMAX ), B( NMAX ),
$ W( 2*NMAX ), X( NMAX ), ERR_BNDS_N( NMAX, 3 ),
$ ERR_BNDS_C( NMAX, 3 ), PARAMS
* ..
* .. External Functions ..
LOGICAL LSAMEN
EXTERNAL LSAMEN
* ..
* .. External Subroutines ..
EXTERNAL ALAESM, CHKXER, ZGBCON, ZGBEQU, ZGBRFS, ZGBTF2,
$ ZGBTRF, ZGBTRS, ZGECON, ZGEEQU, ZGERFS, ZGETF2,
$ ZGETRF, ZGETRI, ZGETRS, ZGEEQUB, ZGERFSX,
$ ZGBEQUB, ZGBRFSX
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE, DCMPLX
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
C2 = PATH( 2: 3 )
*
* Set the variables to innocuous values.
*
DO 20 J = 1, NMAX
DO 10 I = 1, NMAX
A( I, J ) = DCMPLX( 1.D0 / DBLE( I+J ),
$ -1.D0 / DBLE( I+J ) )
AF( I, J ) = DCMPLX( 1.D0 / DBLE( I+J ),
$ -1.D0 / DBLE( I+J ) )
10 CONTINUE
B( J ) = 0.D0
R1( J ) = 0.D0
R2( J ) = 0.D0
W( J ) = 0.D0
X( J ) = 0.D0
CS( J ) = 0.D0
RS( J ) = 0.D0
IP( J ) = J
20 CONTINUE
OK = .TRUE.
*
* Test error exits of the routines that use the LU decomposition
* of a general matrix.
*
IF( LSAMEN( 2, C2, 'GE' ) ) THEN
*
* ZGETRF
*
SRNAMT = 'ZGETRF'
INFOT = 1
CALL ZGETRF( -1, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGETRF', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGETRF( 0, -1, A, 1, IP, INFO )
CALL CHKXER( 'ZGETRF', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGETRF( 2, 1, A, 1, IP, INFO )
CALL CHKXER( 'ZGETRF', INFOT, NOUT, LERR, OK )
*
* ZGETF2
*
SRNAMT = 'ZGETF2'
INFOT = 1
CALL ZGETF2( -1, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGETF2', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGETF2( 0, -1, A, 1, IP, INFO )
CALL CHKXER( 'ZGETF2', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGETF2( 2, 1, A, 1, IP, INFO )
CALL CHKXER( 'ZGETF2', INFOT, NOUT, LERR, OK )
*
* ZGETRI
*
SRNAMT = 'ZGETRI'
INFOT = 1
CALL ZGETRI( -1, A, 1, IP, W, 1, INFO )
CALL CHKXER( 'ZGETRI', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGETRI( 2, A, 1, IP, W, 2, INFO )
CALL CHKXER( 'ZGETRI', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGETRI( 2, A, 2, IP, W, 1, INFO )
CALL CHKXER( 'ZGETRI', INFOT, NOUT, LERR, OK )
*
* ZGETRS
*
SRNAMT = 'ZGETRS'
INFOT = 1
CALL ZGETRS( '/', 0, 0, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGETRS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGETRS( 'N', -1, 0, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGETRS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGETRS( 'N', 0, -1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGETRS', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL ZGETRS( 'N', 2, 1, A, 1, IP, B, 2, INFO )
CALL CHKXER( 'ZGETRS', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL ZGETRS( 'N', 2, 1, A, 2, IP, B, 1, INFO )
CALL CHKXER( 'ZGETRS', INFOT, NOUT, LERR, OK )
*
* ZGERFS
*
SRNAMT = 'ZGERFS'
INFOT = 1
CALL ZGERFS( '/', 0, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1, R2, W,
$ R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGERFS( 'N', -1, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1, R2,
$ W, R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGERFS( 'N', 0, -1, A, 1, AF, 1, IP, B, 1, X, 1, R1, R2,
$ W, R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL ZGERFS( 'N', 2, 1, A, 1, AF, 2, IP, B, 2, X, 2, R1, R2, W,
$ R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL ZGERFS( 'N', 2, 1, A, 2, AF, 1, IP, B, 2, X, 2, R1, R2, W,
$ R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL ZGERFS( 'N', 2, 1, A, 2, AF, 2, IP, B, 1, X, 2, R1, R2, W,
$ R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
INFOT = 12
CALL ZGERFS( 'N', 2, 1, A, 2, AF, 2, IP, B, 2, X, 1, R1, R2, W,
$ R, INFO )
CALL CHKXER( 'ZGERFS', INFOT, NOUT, LERR, OK )
*
* ZGERFSX
*
N_ERR_BNDS = 3
NPARAMS = 0
SRNAMT = 'ZGERFSX'
INFOT = 1
CALL ZGERFSX( '/', EQ, 0, 0, A, 1, AF, 1, IP, RS, CS, B, 1, X,
$ 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 2
EQ = '/'
CALL ZGERFSX( 'N', EQ, 2, 1, A, 1, AF, 2, IP, RS, CS, B, 2, X,
$ 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 3
EQ = 'R'
CALL ZGERFSX( 'N', EQ, -1, 0, A, 1, AF, 1, IP, RS, CS, B, 1, X,
$ 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGERFSX( 'N', EQ, 0, -1, A, 1, AF, 1, IP, RS, CS, B, 1, X,
$ 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGERFSX( 'N', EQ, 2, 1, A, 1, AF, 2, IP, RS, CS, B, 2, X,
$ 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL ZGERFSX( 'N', EQ, 2, 1, A, 2, AF, 1, IP, RS, CS, B, 2, X,
$ 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 13
EQ = 'C'
CALL ZGERFSX( 'N', EQ, 2, 1, A, 2, AF, 2, IP, RS, CS, B, 1, X,
$ 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
INFOT = 15
CALL ZGERFSX( 'N', EQ, 2, 1, A, 2, AF, 2, IP, RS, CS, B, 2, X,
$ 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N, ERR_BNDS_C,
$ NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGERFSX', INFOT, NOUT, LERR, OK )
*
* ZGECON
*
SRNAMT = 'ZGECON'
INFOT = 1
CALL ZGECON( '/', 0, A, 1, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGECON', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGECON( '1', -1, A, 1, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGECON', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGECON( '1', 2, A, 1, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGECON', INFOT, NOUT, LERR, OK )
*
* ZGEEQU
*
SRNAMT = 'ZGEEQU'
INFOT = 1
CALL ZGEEQU( -1, 0, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQU', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGEEQU( 0, -1, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQU', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGEEQU( 2, 2, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQU', INFOT, NOUT, LERR, OK )
*
* ZGEEQUB
*
SRNAMT = 'ZGEEQUB'
INFOT = 1
CALL ZGEEQUB( -1, 0, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQUB', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGEEQUB( 0, -1, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQUB', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGEEQUB( 2, 2, A, 1, R1, R2, RCOND, CCOND, ANRM, INFO )
CALL CHKXER( 'ZGEEQUB', INFOT, NOUT, LERR, OK )
*
* Test error exits of the routines that use the LU decomposition
* of a general band matrix.
*
ELSE IF( LSAMEN( 2, C2, 'GB' ) ) THEN
*
* ZGBTRF
*
SRNAMT = 'ZGBTRF'
INFOT = 1
CALL ZGBTRF( -1, 0, 0, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTRF', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBTRF( 0, -1, 0, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTRF', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBTRF( 1, 1, -1, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTRF', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBTRF( 1, 1, 0, -1, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTRF', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBTRF( 2, 2, 1, 1, A, 3, IP, INFO )
CALL CHKXER( 'ZGBTRF', INFOT, NOUT, LERR, OK )
*
* ZGBTF2
*
SRNAMT = 'ZGBTF2'
INFOT = 1
CALL ZGBTF2( -1, 0, 0, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTF2', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBTF2( 0, -1, 0, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTF2', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBTF2( 1, 1, -1, 0, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTF2', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBTF2( 1, 1, 0, -1, A, 1, IP, INFO )
CALL CHKXER( 'ZGBTF2', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBTF2( 2, 2, 1, 1, A, 3, IP, INFO )
CALL CHKXER( 'ZGBTF2', INFOT, NOUT, LERR, OK )
*
* ZGBTRS
*
SRNAMT = 'ZGBTRS'
INFOT = 1
CALL ZGBTRS( '/', 0, 0, 0, 1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBTRS( 'N', -1, 0, 0, 1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBTRS( 'N', 1, -1, 0, 1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBTRS( 'N', 1, 0, -1, 1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL ZGBTRS( 'N', 1, 0, 0, -1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL ZGBTRS( 'N', 2, 1, 1, 1, A, 3, IP, B, 2, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL ZGBTRS( 'N', 2, 0, 0, 1, A, 1, IP, B, 1, INFO )
CALL CHKXER( 'ZGBTRS', INFOT, NOUT, LERR, OK )
*
* ZGBRFS
*
SRNAMT = 'ZGBRFS'
INFOT = 1
CALL ZGBRFS( '/', 0, 0, 0, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBRFS( 'N', -1, 0, 0, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBRFS( 'N', 1, -1, 0, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBRFS( 'N', 1, 0, -1, 0, A, 1, AF, 1, IP, B, 1, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL ZGBRFS( 'N', 1, 0, 0, -1, A, 1, AF, 1, IP, B, 1, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL ZGBRFS( 'N', 2, 1, 1, 1, A, 2, AF, 4, IP, B, 2, X, 2, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 9
CALL ZGBRFS( 'N', 2, 1, 1, 1, A, 3, AF, 3, IP, B, 2, X, 2, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 12
CALL ZGBRFS( 'N', 2, 0, 0, 1, A, 1, AF, 1, IP, B, 1, X, 2, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
INFOT = 14
CALL ZGBRFS( 'N', 2, 0, 0, 1, A, 1, AF, 1, IP, B, 2, X, 1, R1,
$ R2, W, R, INFO )
CALL CHKXER( 'ZGBRFS', INFOT, NOUT, LERR, OK )
*
* ZGBRFSX
*
N_ERR_BNDS = 3
NPARAMS = 0
SRNAMT = 'ZGBRFSX'
INFOT = 1
CALL ZGBRFSX( '/', EQ, 0, 0, 0, 0, A, 1, AF, 1, IP, RS, CS, B,
$ 1, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 2
EQ = '/'
CALL ZGBRFSX( 'N', EQ, 2, 1, 1, 1, A, 1, AF, 2, IP, RS, CS, B,
$ 2, X, 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 3
EQ = 'R'
CALL ZGBRFSX( 'N', EQ, -1, 1, 1, 0, A, 1, AF, 1, IP, RS, CS, B,
$ 1, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 4
EQ = 'R'
CALL ZGBRFSX( 'N', EQ, 2, -1, 1, 1, A, 3, AF, 4, IP, RS, CS, B,
$ 1, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 5
EQ = 'R'
CALL ZGBRFSX( 'N', EQ, 2, 1, -1, 1, A, 3, AF, 4, IP, RS, CS, B,
$ 1, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBRFSX( 'N', EQ, 0, 0, 0, -1, A, 1, AF, 1, IP, RS, CS, B,
$ 1, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL ZGBRFSX( 'N', EQ, 2, 1, 1, 1, A, 1, AF, 2, IP, RS, CS, B,
$ 2, X, 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL ZGBRFSX( 'N', EQ, 2, 1, 1, 1, A, 3, AF, 3, IP, RS, CS, B,
$ 2, X, 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 13
EQ = 'C'
CALL ZGBRFSX( 'N', EQ, 2, 1, 1, 1, A, 3, AF, 5, IP, RS, CS, B,
$ 1, X, 2, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
INFOT = 15
CALL ZGBRFSX( 'N', EQ, 2, 1, 1, 1, A, 3, AF, 5, IP, RS, CS, B,
$ 2, X, 1, RCOND, BERR, N_ERR_BNDS, ERR_BNDS_N,
$ ERR_BNDS_C, NPARAMS, PARAMS, W, R, INFO )
CALL CHKXER( 'ZGBRFSX', INFOT, NOUT, LERR, OK )
*
* ZGBCON
*
SRNAMT = 'ZGBCON'
INFOT = 1
CALL ZGBCON( '/', 0, 0, 0, A, 1, IP, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGBCON', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBCON( '1', -1, 0, 0, A, 1, IP, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGBCON', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBCON( '1', 1, -1, 0, A, 1, IP, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGBCON', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBCON( '1', 1, 0, -1, A, 1, IP, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGBCON', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBCON( '1', 2, 1, 1, A, 3, IP, ANRM, RCOND, W, R, INFO )
CALL CHKXER( 'ZGBCON', INFOT, NOUT, LERR, OK )
*
* ZGBEQU
*
SRNAMT = 'ZGBEQU'
INFOT = 1
CALL ZGBEQU( -1, 0, 0, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQU', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBEQU( 0, -1, 0, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQU', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBEQU( 1, 1, -1, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQU', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBEQU( 1, 1, 0, -1, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQU', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBEQU( 2, 2, 1, 1, A, 2, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQU', INFOT, NOUT, LERR, OK )
*
* ZGBEQUB
*
SRNAMT = 'ZGBEQUB'
INFOT = 1
CALL ZGBEQUB( -1, 0, 0, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQUB', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL ZGBEQUB( 0, -1, 0, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQUB', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL ZGBEQUB( 1, 1, -1, 0, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQUB', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL ZGBEQUB( 1, 1, 0, -1, A, 1, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQUB', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL ZGBEQUB( 2, 2, 1, 1, A, 2, R1, R2, RCOND, CCOND, ANRM,
$ INFO )
CALL CHKXER( 'ZGBEQUB', INFOT, NOUT, LERR, OK )
END IF
*
* Print a summary line.
*
CALL ALAESM( PATH, OK, NOUT )
*
RETURN
*
* End of ZERRGE
*
END
| bsd-3-clause |
pablooliveira/cere | examples/NPB3.0-SER/LU/setcoeff.f | 17 | 4373 |
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine setcoeff
c---------------------------------------------------------------------
c---------------------------------------------------------------------
implicit none
include 'applu.incl'
c---------------------------------------------------------------------
c local variables
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c set up coefficients
c---------------------------------------------------------------------
dxi = 1.0d+00 / ( nx0 - 1 )
deta = 1.0d+00 / ( ny0 - 1 )
dzeta = 1.0d+00 / ( nz0 - 1 )
tx1 = 1.0d+00 / ( dxi * dxi )
tx2 = 1.0d+00 / ( 2.0d+00 * dxi )
tx3 = 1.0d+00 / dxi
ty1 = 1.0d+00 / ( deta * deta )
ty2 = 1.0d+00 / ( 2.0d+00 * deta )
ty3 = 1.0d+00 / deta
tz1 = 1.0d+00 / ( dzeta * dzeta )
tz2 = 1.0d+00 / ( 2.0d+00 * dzeta )
tz3 = 1.0d+00 / dzeta
c---------------------------------------------------------------------
c diffusion coefficients
c---------------------------------------------------------------------
dx1 = 0.75d+00
dx2 = dx1
dx3 = dx1
dx4 = dx1
dx5 = dx1
dy1 = 0.75d+00
dy2 = dy1
dy3 = dy1
dy4 = dy1
dy5 = dy1
dz1 = 1.00d+00
dz2 = dz1
dz3 = dz1
dz4 = dz1
dz5 = dz1
c---------------------------------------------------------------------
c fourth difference dissipation
c---------------------------------------------------------------------
dssp = ( max (dx1, dy1, dz1 ) ) / 4.0d+00
c---------------------------------------------------------------------
c coefficients of the exact solution to the first pde
c---------------------------------------------------------------------
ce(1,1) = 2.0d+00
ce(1,2) = 0.0d+00
ce(1,3) = 0.0d+00
ce(1,4) = 4.0d+00
ce(1,5) = 5.0d+00
ce(1,6) = 3.0d+00
ce(1,7) = 5.0d-01
ce(1,8) = 2.0d-02
ce(1,9) = 1.0d-02
ce(1,10) = 3.0d-02
ce(1,11) = 5.0d-01
ce(1,12) = 4.0d-01
ce(1,13) = 3.0d-01
c---------------------------------------------------------------------
c coefficients of the exact solution to the second pde
c---------------------------------------------------------------------
ce(2,1) = 1.0d+00
ce(2,2) = 0.0d+00
ce(2,3) = 0.0d+00
ce(2,4) = 0.0d+00
ce(2,5) = 1.0d+00
ce(2,6) = 2.0d+00
ce(2,7) = 3.0d+00
ce(2,8) = 1.0d-02
ce(2,9) = 3.0d-02
ce(2,10) = 2.0d-02
ce(2,11) = 4.0d-01
ce(2,12) = 3.0d-01
ce(2,13) = 5.0d-01
c---------------------------------------------------------------------
c coefficients of the exact solution to the third pde
c---------------------------------------------------------------------
ce(3,1) = 2.0d+00
ce(3,2) = 2.0d+00
ce(3,3) = 0.0d+00
ce(3,4) = 0.0d+00
ce(3,5) = 0.0d+00
ce(3,6) = 2.0d+00
ce(3,7) = 3.0d+00
ce(3,8) = 4.0d-02
ce(3,9) = 3.0d-02
ce(3,10) = 5.0d-02
ce(3,11) = 3.0d-01
ce(3,12) = 5.0d-01
ce(3,13) = 4.0d-01
c---------------------------------------------------------------------
c coefficients of the exact solution to the fourth pde
c---------------------------------------------------------------------
ce(4,1) = 2.0d+00
ce(4,2) = 2.0d+00
ce(4,3) = 0.0d+00
ce(4,4) = 0.0d+00
ce(4,5) = 0.0d+00
ce(4,6) = 2.0d+00
ce(4,7) = 3.0d+00
ce(4,8) = 3.0d-02
ce(4,9) = 5.0d-02
ce(4,10) = 4.0d-02
ce(4,11) = 2.0d-01
ce(4,12) = 1.0d-01
ce(4,13) = 3.0d-01
c---------------------------------------------------------------------
c coefficients of the exact solution to the fifth pde
c---------------------------------------------------------------------
ce(5,1) = 5.0d+00
ce(5,2) = 4.0d+00
ce(5,3) = 3.0d+00
ce(5,4) = 2.0d+00
ce(5,5) = 1.0d-01
ce(5,6) = 4.0d-01
ce(5,7) = 3.0d-01
ce(5,8) = 5.0d-02
ce(5,9) = 4.0d-02
ce(5,10) = 3.0d-02
ce(5,11) = 1.0d-01
ce(5,12) = 3.0d-01
ce(5,13) = 2.0d-01
return
end
| lgpl-3.0 |
PPMLibrary/ppm | src/map/ppm_map_field_global_symm.f | 1 | 25921 | !-------------------------------------------------------------------------
! Subroutine : ppm_map_field_global_symm
!-------------------------------------------------------------------------
! Copyright (c) 2012 CSE Lab (ETH Zurich), MOSAIC Group (ETH Zurich),
! Center for Fluid Dynamics (DTU)
!
!
! This file is part of the Parallel Particle Mesh Library (PPM).
!
! PPM is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License
! as published by the Free Software Foundation, either
! version 3 of the License, or (at your option) any later
! version.
!
! PPM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! and the GNU Lesser General Public License along with PPM. If not,
! see <http://www.gnu.org/licenses/>.
!
! Parallel Particle Mesh Library (PPM)
! ETH Zurich
! CH-8092 Zurich, Switzerland
!-------------------------------------------------------------------------
SUBROUTINE ppm_map_field_global_symm(topoid,target_topoid, &
& meshid,target_meshid,info)
!!! This routine maps field data between two topologies
!!! using a global mapping (i.e. every processor
!!! communicates with every other). Source mesh must be
!!! on the current field topology. Global lists with
!!! all mesh blocks that have to be send and/or
!!! received are built in this routine. Push, pop and
!!! send will use these lists.
!!!
!!! [WARNING]
!!! This routine has not been tested, reviewed, or checked. Comments
!!! and documentation are wrong. This routine might kill your cat or
!!! worse.
!!!
!!! [NOTE]
!!! The first part of the send/recv lists contains the
!!! on-processor data.
!!!
!!! [CAUTION]
!!! Side effect: this routine uses the same global
!!! send/recv buffers, pointers and lists as the
!!! particle mapping routines (reason: these buffers
!!! can be large => memory issues). Field and particle
!!! mappings can therefore never overlap, but one must
!!! be completed before the other starts.
!-------------------------------------------------------------------------
! Includes
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Modules
!-------------------------------------------------------------------------
USE ppm_module_data
USE ppm_module_data_mesh
USE ppm_module_typedef
USE ppm_module_substart
USE ppm_module_substop
USE ppm_module_error
USE ppm_module_alloc
USE ppm_module_write
USE ppm_module_check_id
USE ppm_module_mesh_block_intersect
IMPLICIT NONE
!-------------------------------------------------------------------------
! Arguments
!-------------------------------------------------------------------------
INTEGER , INTENT(IN ) :: topoid
!!! Topology ID of source
!!!
!!! CAUTION: used to be target topo ID
INTEGER , INTENT(IN ) :: target_topoid
!!! Topology ID of target
INTEGER , INTENT(IN ) :: meshid
!!! Mesh ID of source
INTEGER , INTENT(IN ) :: target_meshid
!!! Mesh ID of target
INTEGER , INTENT( OUT) :: info
!!! Return status, 0 upon success
!-------------------------------------------------------------------------
! Local variables
!-------------------------------------------------------------------------
INTEGER, DIMENSION(3) :: ldu
INTEGER, DIMENSION(ppm_dim) :: iblockstart,nblocksize,offset
INTEGER, DIMENSION(ppm_dim) :: ghostsize
INTEGER :: i,j,idom,sendrank,recvrank
INTEGER :: iopt,iset,ibuffer,pdim
INTEGER :: nsendlist,nsend
INTEGER :: nrecvlist
CHARACTER(ppm_char) :: mesg
REAL(ppm_kind_double) :: t0
LOGICAL, DIMENSION(3) :: lsymm
LOGICAL :: valid
TYPE(ppm_t_topo), POINTER :: topo
TYPE(ppm_t_topo), POINTER :: target_topo
TYPE(ppm_t_equi_mesh), POINTER :: mesh
TYPE(ppm_t_equi_mesh), POINTER :: target_mesh
!-------------------------------------------------------------------------
! Externals
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Initialise
!-------------------------------------------------------------------------
CALL substart('ppm_map_field_global_symm',t0,info)
pdim = ppm_dim
!-------------------------------------------------------------------------
! Check arguments
!-------------------------------------------------------------------------
IF (ppm_debug .GT. 0) THEN
CALL check
IF (info .NE. 0) GOTO 9999
ENDIF
topo => ppm_topo(topoid)%t
target_topo => ppm_topo(target_topoid)%t
mesh => topo%mesh(meshid)
target_mesh => target_topo%mesh(meshid)
IF (ppm_buffer_set .GT. 0) THEN
info = ppm_error_warning
CALL ppm_error(ppm_err_map_incomp,'ppm_map_field_global_symm', &
& 'Buffer was not empty. Possible loss of data!',__LINE__,info)
ENDIF
!-------------------------------------------------------------------------
! Save the map type for the subsequent calls (used for checks!)
!-------------------------------------------------------------------------
ppm_map_type = ppm_param_map_global
!-------------------------------------------------------------------------
! Check if origin and target meshes are compatible (i.e. have the
! same number of grid points in the whole comput. domain)
!-------------------------------------------------------------------------
IF (ppm_debug .GT. 0) THEN
DO i=1,pdim
IF (mesh%Nm(i) .NE. target_mesh%Nm(i)) THEN
info = ppm_error_notice
CALL ppm_error(ppm_err_bad_mesh,'ppm_map_field_global_symm', &
& 'source and destination meshes are incompatible',__LINE__,info)
ENDIF
ENDDO
ENDIF
!-------------------------------------------------------------------------
! Allocate memory for the local temporary sendlists
!-------------------------------------------------------------------------
iopt = ppm_param_alloc_fit
ldu(1) = topo%nsublist
CALL ppm_alloc(isendfromsub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local send source sub list ISENDFROMSUB',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(isendtosub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local send destination sub list ISENDTOSUB',__LINE__,info)
GOTO 9999
ENDIF
ldu(1) = pdim
ldu(2) = topo%nsublist
CALL ppm_alloc(isendblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local send block start list ISENDBLKSTART',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(isendblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local send block size list ISENDBLKSIZE',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(ioffset,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local send block offset list IOFFSET',__LINE__,info)
GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Find intersecting mesh domains to be sent
!-------------------------------------------------------------------------
nsendlist = 0
ghostsize = 0
offset = 0
DO i=1,topo%nsublist
idom = topo%isublist(i)
lsymm(1:pdim) = .TRUE.
IF (topo%subs_bc(2,idom) .NE. 0) lsymm(1) = .FALSE.
IF (topo%subs_bc(4,idom) .NE. 0) lsymm(2) = .FALSE.
IF (topo%subs_bc(6,idom) .NE. 0) lsymm(3) = .FALSE.
DO j=1,target_topo%nsubs
CALL ppm_mesh_block_intersect(topoid,target_topoid,meshid,target_meshid,&
& idom,j,offset,ghostsize,nsendlist, &
& isendfromsub,isendtosub,isendblkstart,isendblksize, &
& ioffset,info,lsymm)
IF (info .NE. 0) GOTO 9999
ENDDO
ENDDO
!-------------------------------------------------------------------------
! Allocate memory for the local temporary receive lists
!-------------------------------------------------------------------------
iopt = ppm_param_alloc_fit
ldu(1) = target_topo%nsublist
CALL ppm_alloc(irecvfromsub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local recv source sub list IRECVFROMSUB',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(irecvtosub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local recv destination sub list IRECVTOSUB',__LINE__,info)
GOTO 9999
ENDIF
ldu(1) = pdim
ldu(2) = target_topo%nsublist
CALL ppm_alloc(irecvblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local recv block start list IRECVBLKSTART',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(irecvblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'local recv block size list IRECVBLKSIZE',__LINE__,info)
GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Find intersecting mesh domains to be received
!-------------------------------------------------------------------------
nrecvlist = 0
! loop over fromtopo first and THEN over totopo in order to get the
! same ordering of mesh blocks as in the sendlist. This is crutial
! for the push and the pop to work properly !!!
DO j=1,topo%nsubs
lsymm(1:pdim) = .TRUE.
IF (topo%subs_bc(2,j) .NE. 0) lsymm(1) = .FALSE.
IF (topo%subs_bc(4,j) .NE. 0) lsymm(2) = .FALSE.
IF (topo%subs_bc(6,j) .NE. 0) lsymm(3) = .FALSE.
DO i=1,target_topo%nsublist
idom = target_topo%isublist(i)
CALL ppm_mesh_block_intersect(topoid,target_topoid,meshid,target_meshid,&
& j,idom,offset,ghostsize,nrecvlist,irecvfromsub, &
& irecvtosub,irecvblkstart,irecvblksize,ioffset,info,lsymm)
IF (info .NE. 0) GOTO 9999
ENDDO
ENDDO
!-------------------------------------------------------------------------
! Allocate memory for the global mesh sendlists
!-------------------------------------------------------------------------
iopt = ppm_param_alloc_fit
ldu(1) = nsendlist
CALL ppm_alloc(ppm_mesh_isendfromsub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'source send sub list PPM_MESH_ISENDFROMSUB',__LINE__,info)
GOTO 9999
ENDIF
ldu(1) = pdim
ldu(2) = nsendlist
CALL ppm_alloc(ppm_mesh_isendblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'send block start list PPM_MESH_ISENDBLKSTART',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(ppm_mesh_isendblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'send block size list PPM_MESH_ISENDBLKSIZE',__LINE__,info)
GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Allocate memory for the global mesh receive lists
!-------------------------------------------------------------------------
iopt = ppm_param_alloc_fit
ldu(1) = nrecvlist
CALL ppm_alloc(ppm_mesh_irecvtosub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'destination recv sub list PPM_MESH_IRECVTOSUB',__LINE__,info)
GOTO 9999
ENDIF
ldu(1) = pdim
ldu(2) = nrecvlist
CALL ppm_alloc(ppm_mesh_irecvblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'recv block start list PPM_MESH_IRECVBLKSTART',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(ppm_mesh_irecvblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'recv block size list PPM_MESH_IRECVBLKSIZE',__LINE__,info)
GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Allocate memory for the global send/recv lists
!-------------------------------------------------------------------------
ldu(1) = ppm_nproc
CALL ppm_alloc(ppm_isendlist,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'global send rank list PPM_ISENDLIST',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(ppm_irecvlist,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'global recv rank list PPM_IRECVLIST',__LINE__,info)
GOTO 9999
ENDIF
ldu(1) = ppm_nproc + 1
CALL ppm_alloc(ppm_psendbuffer,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'global send buffer pointer PPM_PSENDBUFFER',__LINE__,info)
GOTO 9999
ENDIF
CALL ppm_alloc(ppm_precvbuffer,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_fatal
CALL ppm_error(ppm_err_alloc,'ppm_map_field_global_symm', &
& 'global recv buffer pointer PPM_PRECVBUFFER',__LINE__,info)
GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Reset the number of buffer entries
!-------------------------------------------------------------------------
ppm_buffer_set = 0
!-------------------------------------------------------------------------
! loop over all processors; First is the processor itself
!-------------------------------------------------------------------------
sendrank = ppm_rank - 1
recvrank = ppm_rank + 1
ppm_psendbuffer(1) = 1
ppm_precvbuffer(1) = 1
ppm_nsendlist = 0
ppm_nrecvlist = 0
ppm_nsendbuffer = 0 ! data length in buffer
ppm_nrecvbuffer = 0 ! data length in buffer
iset = 0
ibuffer = 0
DO i=1,ppm_nproc
!----------------------------------------------------------------------
! compute the next processor
!----------------------------------------------------------------------
sendrank = sendrank + 1
IF (sendrank.GE.ppm_nproc) sendrank = sendrank - ppm_nproc
recvrank = recvrank - 1
IF (recvrank.LT. 0) recvrank = recvrank + ppm_nproc
!----------------------------------------------------------------------
! Store the processor to which we will send to
!----------------------------------------------------------------------
ppm_nsendlist = ppm_nsendlist + 1
ppm_isendlist(ppm_nsendlist) = sendrank
!----------------------------------------------------------------------
! Store the processor to which we will recv from
!----------------------------------------------------------------------
ppm_nrecvlist = ppm_nrecvlist + 1
ppm_irecvlist(ppm_nrecvlist) = recvrank
!----------------------------------------------------------------------
! Find all mesh blocks that are sent and store them.
! To get all mesh blocks that are sent in round
! i=1,ppm_nsendlist:
! dest_rank = ppm_isendlist(i)
! ilo = ppm_psendbuffer(i)
! ihi = ppm_psendbuffer(i+1)-1
! DO j=ilo,ihi
! SEND(ppm_mesh_isendblk(:,j) of sub ppm_mesh_isendfromsub(j) to
! processor dest_rank to sub ppm_mesh_isendtosub(j))
! ENDDO
!----------------------------------------------------------------------
ibuffer = ppm_nsendlist + 1
ppm_psendbuffer(ibuffer) = ppm_psendbuffer(ppm_nsendlist)
DO j=1,nsendlist
IF (target_topo%sub2proc(isendtosub(j)) .EQ. sendrank) THEN
ppm_psendbuffer(ibuffer) = ppm_psendbuffer(ibuffer) + 1
iset = ppm_psendbuffer(ibuffer) - 1
ppm_mesh_isendfromsub(iset) = isendfromsub(j)
ppm_mesh_isendblkstart(1:pdim,iset) = isendblkstart(1:pdim,j)
ppm_mesh_isendblksize(1:pdim,iset) = isendblksize(1:pdim,j)
IF (ppm_debug .GT. 1) THEN
IF (ppm_dim .EQ. 2) THEN
WRITE(mesg,'(2(A,2I4),A,I3)') ' sending ', &
& isendblkstart(1:2,j),' of size ',isendblksize(1:2,j),&
& ' to ',sendrank
ELSEIF (ppm_dim .EQ. 3) THEN
WRITE(mesg,'(2(A,3I4),A,I3)') ' sending ', &
& isendblkstart(1:3,j),' of size ',isendblksize(1:3,j),&
& ' to ',sendrank
ENDIF
CALL ppm_write(ppm_rank,'ppm_map_field_global_symm',&
& mesg,info)
ENDIF
ENDIF
ENDDO
!----------------------------------------------------------------------
! Find all mesh blocks that are received and store them.
! To get all mesh blocks that are received in round
! i=1,ppm_nrecvlist:
! source_rank = ppm_irecvlist(i)
! ilo = ppm_precvbuffer(i)
! ihi = ppm_precvbuffer(i+1)-1
! DO j=ilo,ihi
! RECV(ppm_mesh_irecvblk(:,j) of sub ppm_mesh_irecvfromsub(j)
! from processor source_rank to sub ppm_mesh_irecvtosub(j))
! ENDDO
!----------------------------------------------------------------------
ibuffer = ppm_nrecvlist + 1
ppm_precvbuffer(ibuffer) = ppm_precvbuffer(ppm_nrecvlist)
DO j=1,nrecvlist
IF (topo%sub2proc(irecvfromsub(j)) .EQ. recvrank) THEN
ppm_precvbuffer(ibuffer) = ppm_precvbuffer(ibuffer) + 1
iset = ppm_precvbuffer(ibuffer) - 1
ppm_mesh_irecvtosub(iset) = irecvtosub(j)
ppm_mesh_irecvblkstart(1:pdim,iset) = irecvblkstart(1:pdim,j)
ppm_mesh_irecvblksize(1:pdim,iset) = irecvblksize(1:pdim,j)
IF (ppm_debug .GT. 1) THEN
IF (ppm_dim .EQ. 2) THEN
WRITE(mesg,'(2(A,2I4),A,I3)') ' recving ', &
& irecvblkstart(1:2,j),' of size ',irecvblksize(1:2,j),&
& ' from ',recvrank
ELSEIF (ppm_dim .EQ. 3) THEN
WRITE(mesg,'(2(A,3I4),A,I3)') ' recving ', &
& irecvblkstart(1:3,j),' of size ',irecvblksize(1:3,j),&
& ' from ',recvrank
ENDIF
CALL ppm_write(ppm_rank,'ppm_map_field_global_symm',&
& mesg,info)
ENDIF
ENDIF
ENDDO
ENDDO
!-------------------------------------------------------------------------
! Deallocate memory of the local lists
!-------------------------------------------------------------------------
iopt = ppm_param_dealloc
CALL ppm_alloc(isendfromsub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local send source sub list ISENDFROMSUB',__LINE__,info)
ENDIF
CALL ppm_alloc(isendtosub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local send destination sub list ISENDTOSUB',__LINE__,info)
ENDIF
CALL ppm_alloc(isendblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local send block start list ISENDBLKSTART',__LINE__,info)
ENDIF
CALL ppm_alloc(isendblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local send block size list ISENDBLKSIZE',__LINE__,info)
ENDIF
CALL ppm_alloc(irecvfromsub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local recv source sub list IRECVFROMSUB',__LINE__,info)
ENDIF
CALL ppm_alloc(irecvtosub,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local recv destination sub list IRECVTOSUB',__LINE__,info)
ENDIF
CALL ppm_alloc(irecvblkstart,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local recv block start list IRECVBLKSTART',__LINE__,info)
ENDIF
CALL ppm_alloc(irecvblksize,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local recv block size list IRECVBLKSIZE',__LINE__,info)
ENDIF
CALL ppm_alloc(ioffset,ldu,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_map_field_global_symm', &
& 'local recv block offset list IOFFSET',__LINE__,info)
ENDIF
!-------------------------------------------------------------------------
! Return
!-------------------------------------------------------------------------
9999 CONTINUE
CALL substop('ppm_map_field_global_symm',t0,info)
RETURN
CONTAINS
SUBROUTINE check
CALL ppm_check_topoid(target_topoid,valid,info)
IF (.NOT. valid) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_map_field_global_symm', &
& 'target topoid not valid',__LINE__,info)
GOTO 8888
ENDIF
CALL ppm_check_meshid(topoid,meshid,valid,info)
IF (.NOT. valid) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_map_field_global_symm', &
& 'source meshid not valid',__LINE__,info)
GOTO 8888
ENDIF
CALL ppm_check_meshid(target_topoid,target_meshid,valid,info)
IF (.NOT. valid) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_argument,'ppm_map_field_global_symm', &
& 'destination meshid not valid',__LINE__,info)
GOTO 8888
ENDIF
8888 CONTINUE
END SUBROUTINE check
END SUBROUTINE ppm_map_field_global_symm
| gpl-3.0 |
yaowee/libflame | lapack-test/3.4.2/LIN/ddrvrf4.f | 32 | 11010 | *> \brief \b DDRVRF4
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DDRVRF4( NOUT, NN, NVAL, THRESH, C1, C2, LDC, CRF, A,
* + LDA, D_WORK_DLANGE )
*
* .. Scalar Arguments ..
* INTEGER LDA, LDC, NN, NOUT
* DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
* INTEGER NVAL( NN )
* DOUBLE PRECISION A( LDA, * ), C1( LDC, * ), C2( LDC, *),
* + CRF( * ), D_WORK_DLANGE( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DDRVRF4 tests the LAPACK RFP routines:
*> DSFRK
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The unit number for output.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER
*> The number of values of N contained in the vector NVAL.
*> \endverbatim
*>
*> \param[in] NVAL
*> \verbatim
*> NVAL is INTEGER array, dimension (NN)
*> The values of the matrix dimension N.
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is DOUBLE PRECISION
*> The threshold value for the test ratios. A result is
*> included in the output file if RESULT >= THRESH. To
*> have every test ratio printed, use THRESH = 0.
*> \endverbatim
*>
*> \param[out] C1
*> \verbatim
*> C1 is DOUBLE PRECISION array,
*> dimension (LDC,NMAX)
*> \endverbatim
*>
*> \param[out] C2
*> \verbatim
*> C2 is DOUBLE PRECISION array,
*> dimension (LDC,NMAX)
*> \endverbatim
*>
*> \param[in] LDC
*> \verbatim
*> LDC is INTEGER
*> The leading dimension of the array A.
*> LDA >= max(1,NMAX).
*> \endverbatim
*>
*> \param[out] CRF
*> \verbatim
*> CRF is DOUBLE PRECISION array,
*> dimension ((NMAX*(NMAX+1))/2).
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is DOUBLE PRECISION array,
*> dimension (LDA,NMAX)
*> \endverbatim
*>
*> \param[in] LDA
*> \verbatim
*> LDA is INTEGER
*> The leading dimension of the array A. LDA >= max(1,NMAX).
*> \endverbatim
*>
*> \param[out] D_WORK_DLANGE
*> \verbatim
*> D_WORK_DLANGE is DOUBLE PRECISION array, dimension (NMAX)
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_lin
*
* =====================================================================
SUBROUTINE DDRVRF4( NOUT, NN, NVAL, THRESH, C1, C2, LDC, CRF, A,
+ LDA, D_WORK_DLANGE )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER LDA, LDC, NN, NOUT
DOUBLE PRECISION THRESH
* ..
* .. Array Arguments ..
INTEGER NVAL( NN )
DOUBLE PRECISION A( LDA, * ), C1( LDC, * ), C2( LDC, *),
+ CRF( * ), D_WORK_DLANGE( * )
* ..
*
* =====================================================================
* ..
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
INTEGER NTESTS
PARAMETER ( NTESTS = 1 )
* ..
* .. Local Scalars ..
CHARACTER UPLO, CFORM, TRANS
INTEGER I, IFORM, IIK, IIN, INFO, IUPLO, J, K, N,
+ NFAIL, NRUN, IALPHA, ITRANS
DOUBLE PRECISION ALPHA, BETA, EPS, NORMA, NORMC
* ..
* .. Local Arrays ..
CHARACTER UPLOS( 2 ), FORMS( 2 ), TRANSS( 2 )
INTEGER ISEED( 4 ), ISEEDY( 4 )
DOUBLE PRECISION RESULT( NTESTS )
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DLARND, DLANGE
EXTERNAL DLAMCH, DLARND, DLANGE
* ..
* .. External Subroutines ..
EXTERNAL DSYRK, DSFRK, DTFTTR, DTRTTF
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX
* ..
* .. Scalars in Common ..
CHARACTER*32 SRNAMT
* ..
* .. Common blocks ..
COMMON / SRNAMC / SRNAMT
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
DATA UPLOS / 'U', 'L' /
DATA FORMS / 'N', 'T' /
DATA TRANSS / 'N', 'T' /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
NRUN = 0
NFAIL = 0
INFO = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
EPS = DLAMCH( 'Precision' )
*
DO 150 IIN = 1, NN
*
N = NVAL( IIN )
*
DO 140 IIK = 1, NN
*
K = NVAL( IIN )
*
DO 130 IFORM = 1, 2
*
CFORM = FORMS( IFORM )
*
DO 120 IUPLO = 1, 2
*
UPLO = UPLOS( IUPLO )
*
DO 110 ITRANS = 1, 2
*
TRANS = TRANSS( ITRANS )
*
DO 100 IALPHA = 1, 4
*
IF ( IALPHA.EQ. 1) THEN
ALPHA = ZERO
BETA = ZERO
ELSE IF ( IALPHA.EQ. 2) THEN
ALPHA = ONE
BETA = ZERO
ELSE IF ( IALPHA.EQ. 3) THEN
ALPHA = ZERO
BETA = ONE
ELSE
ALPHA = DLARND( 2, ISEED )
BETA = DLARND( 2, ISEED )
END IF
*
* All the parameters are set:
* CFORM, UPLO, TRANS, M, N,
* ALPHA, and BETA
* READY TO TEST!
*
NRUN = NRUN + 1
*
IF ( ITRANS.EQ.1 ) THEN
*
* In this case we are NOTRANS, so A is N-by-K
*
DO J = 1, K
DO I = 1, N
A( I, J) = DLARND( 2, ISEED )
END DO
END DO
*
NORMA = DLANGE( 'I', N, K, A, LDA,
+ D_WORK_DLANGE )
*
ELSE
*
* In this case we are TRANS, so A is K-by-N
*
DO J = 1,N
DO I = 1, K
A( I, J) = DLARND( 2, ISEED )
END DO
END DO
*
NORMA = DLANGE( 'I', K, N, A, LDA,
+ D_WORK_DLANGE )
*
END IF
*
* Generate C1 our N--by--N symmetric matrix.
* Make sure C2 has the same upper/lower part,
* (the one that we do not touch), so
* copy the initial C1 in C2 in it.
*
DO J = 1, N
DO I = 1, N
C1( I, J) = DLARND( 2, ISEED )
C2(I,J) = C1(I,J)
END DO
END DO
*
* (See comment later on for why we use DLANGE and
* not DLANSY for C1.)
*
NORMC = DLANGE( 'I', N, N, C1, LDC,
+ D_WORK_DLANGE )
*
SRNAMT = 'DTRTTF'
CALL DTRTTF( CFORM, UPLO, N, C1, LDC, CRF,
+ INFO )
*
* call dsyrk the BLAS routine -> gives C1
*
SRNAMT = 'DSYRK '
CALL DSYRK( UPLO, TRANS, N, K, ALPHA, A, LDA,
+ BETA, C1, LDC )
*
* call dsfrk the RFP routine -> gives CRF
*
SRNAMT = 'DSFRK '
CALL DSFRK( CFORM, UPLO, TRANS, N, K, ALPHA, A,
+ LDA, BETA, CRF )
*
* convert CRF in full format -> gives C2
*
SRNAMT = 'DTFTTR'
CALL DTFTTR( CFORM, UPLO, N, CRF, C2, LDC,
+ INFO )
*
* compare C1 and C2
*
DO J = 1, N
DO I = 1, N
C1(I,J) = C1(I,J)-C2(I,J)
END DO
END DO
*
* Yes, C1 is symmetric so we could call DLANSY,
* but we want to check the upper part that is
* supposed to be unchanged and the diagonal that
* is supposed to be real -> DLANGE
*
RESULT(1) = DLANGE( 'I', N, N, C1, LDC,
+ D_WORK_DLANGE )
RESULT(1) = RESULT(1)
+ / MAX( ABS( ALPHA ) * NORMA
+ + ABS( BETA ) , ONE )
+ / MAX( N , 1 ) / EPS
*
IF( RESULT(1).GE.THRESH ) THEN
IF( NFAIL.EQ.0 ) THEN
WRITE( NOUT, * )
WRITE( NOUT, FMT = 9999 )
END IF
WRITE( NOUT, FMT = 9997 ) 'DSFRK',
+ CFORM, UPLO, TRANS, N, K, RESULT(1)
NFAIL = NFAIL + 1
END IF
*
100 CONTINUE
110 CONTINUE
120 CONTINUE
130 CONTINUE
140 CONTINUE
150 CONTINUE
*
* Print a summary of the results.
*
IF ( NFAIL.EQ.0 ) THEN
WRITE( NOUT, FMT = 9996 ) 'DSFRK', NRUN
ELSE
WRITE( NOUT, FMT = 9995 ) 'DSFRK', NFAIL, NRUN
END IF
*
9999 FORMAT( 1X, ' *** Error(s) or Failure(s) while testing DSFRK
+ ***')
9997 FORMAT( 1X, ' Failure in ',A5,', CFORM=''',A1,''',',
+ ' UPLO=''',A1,''',',' TRANS=''',A1,''',', ' N=',I3,', K =', I3,
+ ', test=',G12.5)
9996 FORMAT( 1X, 'All tests for ',A5,' auxiliary routine passed the ',
+ 'threshold ( ',I5,' tests run)')
9995 FORMAT( 1X, A6, ' auxiliary routine: ',I5,' out of ',I5,
+ ' tests failed to pass the threshold')
*
RETURN
*
* End of DDRVRF4
*
END
| bsd-3-clause |
pablooliveira/cere | tests/test_09/flux_lam.f | 7 | 5501 | subroutine flux(q,e,f,g,ev,fv,gv,Re,Pr,gm,nx,ny,nz,
$ dx,dy,dz)
implicit none
integer nx,ny,nz
real*8 gm,Re,Pr,dx,dy,dz
real*8 q(5,nx,ny,nz),e(5,nx,ny,nz),f(5,nx,ny,nz),g(5,nx,ny,nz),
1 ev(5,nx,ny,nz),fv(5,nx,ny,nz),gv(5,nx,ny,nz)
real*8 u(nx,ny,nz),v(nx,ny,nz),w(nx,ny,nz),p(nx,ny,nz),
1 ro(nx,ny,nz),
2 mu(nx,ny,nz)
real*8 t0,t1,t2,t3
integer im1,im2,ip1,ip2,jm1,jm2,jp1,jp2,km1,km2,kp1,kp2,i,j,k,l
real*8 dx2,dy2,dz2
dx2=2.0d0*dx
dy2=2.0d0*dy
dz2=2.0d0*dz
do k=1,nz
do j=1,ny
do i=1,nx
ro(i,j,k)=q(1,i,j,k)
u(i,j,k)=q(2,i,j,k)/ro(i,j,k)
v(i,j,k)=q(3,i,j,k)/ro(i,j,k)
w(i,j,k)=q(4,i,j,k)/ro(i,j,k)
p(i,j,k)=(gm-1.0d0)*(q(5,i,j,k)-0.5d0*ro(i,j,k)*
1 (u(i,j,k)**2+v(i,j,k)**2+w(i,j,k)**2))
mu(i,j,k)=(gm*p(i,j,k)/ro(i,j,k))**0.75d0
C Euler's fluxes
e(1,i,j,k)=ro(i,j,k)*u(i,j,k)
e(2,i,j,k)=ro(i,j,k)*u(i,j,k)*u(i,j,k)+p(i,j,k)
e(3,i,j,k)=ro(i,j,k)*u(i,j,k)*v(i,j,k)
e(4,i,j,k)=ro(i,j,k)*u(i,j,k)*w(i,j,k)
e(5,i,j,k)=u(i,j,k)*(q(5,i,j,k)+p(i,j,k))
f(1,i,j,k)=ro(i,j,k)*v(i,j,k)
f(2,i,j,k)=ro(i,j,k)*v(i,j,k)*u(i,j,k)
f(3,i,j,k)=ro(i,j,k)*v(i,j,k)*v(i,j,k)+p(i,j,k)
f(4,i,j,k)=ro(i,j,k)*v(i,j,k)*w(i,j,k)
f(5,i,j,k)=v(i,j,k)*(q(5,i,j,k)+p(i,j,k))
g(1,i,j,k)=ro(i,j,k)*w(i,j,k)
g(2,i,j,k)=ro(i,j,k)*w(i,j,k)*u(i,j,k)
g(3,i,j,k)=ro(i,j,k)*w(i,j,k)*v(i,j,k)
g(4,i,j,k)=ro(i,j,k)*w(i,j,k)*w(i,j,k)+p(i,j,k)
g(5,i,j,k)=w(i,j,k)*(q(5,i,j,k)+p(i,j,k))
enddo
enddo
enddo
do k=1,nz
km2=mod(k+nz-3,nz)+1
km1=mod(k+nz-2,nz)+1
kp1=mod(k,nz)+1
kp2=mod(k+1,nz)+1
do j=1,ny
jm2=mod(j+ny-3,ny)+1
jm1=mod(j+ny-2,ny)+1
jp1=mod(j,ny)+1
jp2=mod(j+1,ny)+1
do i=1,nx
im2=mod(i+nx-3,nx)+1
im1=mod(i+nx-2,nx)+1
ip1=mod(i,nx)+1
ip2=mod(i+1,nx)+1
C Viscous fluxes
ev(1,i,j,k)=0.0d0
t0=0.5*(mu(i,j,k)+mu(ip1,j,k))
t3=gm*p(i,j,k)/ro(i,j,k)
t1=(v(i,jp1,k)-v(i,jm1,k))/dy2
t2=(w(i,j,kp1)-w(i,j,km1))/dz2
ev(2,i,j,k)=t0/3.0d0*(4.0d0*(u(ip1,j,k)-u(i,j,k))/dx-
1 (t1+(v(ip1,jp1,k)-v(ip1,jm1,k))/dy2+
2 t2+(w(ip1,j,kp1)-w(ip1,j,km1))/dz2))
t1=(u(i,jp1,k)-u(i,jm1,k))/dy2
ev(3,i,j,k)=t0*((t1+(u(ip1,jp1,k)
1 -u(ip1,jm1,k))/dy2)/2.0d0+
2 (v(ip1,j,k)-v(i,j,k))/dx)
t2=(u(i,j,kp1)-u(i,j,km1))/dz2
ev(4,i,j,k)=t0*((t2+(u(ip1,j,kp1)
1 -u(ip1,j,km1))/dz2)/2.0d0+
2 (w(ip1,j,k)-w(i,j,k))/dx)
ev(5,i,j,k)=0.5d0*((u(ip1,j,k)+u(i,j,k))*ev(2,i,j,k)+
1 (v(ip1,j,k)+v(i,j,k))*ev(3,i,j,k)+
2 (w(ip1,j,k)+w(i,j,k))*ev(4,i,j,k))+
3 t0/Pr/(gm-1.0d0)*(gm*p(ip1,j,k)/ro(ip1,j,k)-t3)/dx
c ************************************************************
fv(1,i,j,k)=0.0d0
t0=(mu(i,j,k)+mu(i,jp1,k))/2.0d0
t1=(v(ip1,j,k)-v(im1,j,k))/dx2
fv(2,i,j,k)=t0*(((v(ip1,jp1,k)
2 -v(im1,jp1,k))/dx2+t1)/2.0d0+
1 (u(i,jp1,k)-u(i,j,k))/dy)
t1=(u(ip1,j,k)-u(im1,j,k))/dx2
t2=(w(i,j,kp1)-w(i,j,km1))/dz2
fv(3,i,j,k)=t0/3.0d0*(4.0d0*(v(i,jp1,k)-v(i,j,k))/dy-
1 ((u(ip1,jp1,k)-u(im1,jp1,k))/dx2+t1+
2 (w(i,jp1,kp1)-w(i,jp1,km1))/dz2+t2))
fv(4,i,j,k)=t0*(
1 0.5d0*((u(ip1,jp1,k)-u(im1,jp1,k))/dx2+t1)+
2 (w(i,jp1,k)-w(i,j,k))/dy)
fv(5,i,j,k)=0.5*(
1 (u(i,jp1,k)+u(i,j,k))*fv(2,i,j,k)+
2 (v(i,jp1,k)+v(i,j,k))*fv(3,i,j,k)+
3 (w(i,jp1,k)+w(i,j,k))*fv(4,i,j,k))+
4 t0/Pr/(gm-1.0d0)*(gm*p(i,jp1,k)/ro(i,jp1,k)-t3)/dy
C *************************************************************
gv(1,i,j,k)=0.0d0
t0=(mu(i,j,k)+mu(i,j,kp1))/2.0d0
t1=(w(ip1,j,k)-w(im1,j,k))/dx2
gv(2,i,j,k)=t0*(
1 ((w(ip1,j,kp1)-w(im1,j,kp1))/dx2+t1)/2.0d0+
2 (u(i,j,kp1)-u(i,j,k))/dz)
t1=(w(i,jp1,k)-w(i,jm1,k))/dy2
gv(3,i,j,k)=t0*(
1 ((w(i,jp1,kp1)-w(i,jm1,kp1))/dy2+t1)/2.0d0+
2 (v(i,j,kp1)-v(i,j,k))/dz)
t1=(u(ip1,j,k)-u(im1,j,k))/dx2
t2=(v(i,jp1,k)-v(i,jm1,k))/dy2
gv(4,i,j,k)=t0/3.0d0*(4.0d0*(w(i,j,kp1)-w(i,j,k))/dz-
1 ((u(ip1,j,kp1)-u(im1,j,kp1))/dx2+t1+
2 (v(i,jp1,kp1)-v(i,jm1,kp1))/dy2+t2))
gv(5,i,j,k)=0.5d0*(
1 (u(i,j,kp1)+u(i,j,k))*gv(2,i,j,k)+
2 (v(i,j,kp1)+v(i,j,k))*gv(3,i,j,k)+
4 (w(i,j,kp1)+w(i,j,k))*gv(4,i,j,k))+
5 t0/Pr/(gm-1.0d0)*(gm*p(i,j,kp1)/ro(i,j,kp1)-t3)/dz
enddo
enddo
enddo
return
end
| lgpl-3.0 |
PPMLibrary/ppm | src/neighlist/ppm_clist_destroy.f | 1 | 6314 | !-------------------------------------------------------------------------
! Subroutine : ppm_clist_destroy
!-------------------------------------------------------------------------
! Copyright (c) 2012 CSE Lab (ETH Zurich), MOSAIC Group (ETH Zurich),
! Center for Fluid Dynamics (DTU)
!
!
! This file is part of the Parallel Particle Mesh Library (PPM).
!
! PPM is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License
! as published by the Free Software Foundation, either
! version 3 of the License, or (at your option) any later
! version.
!
! PPM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! and the GNU Lesser General Public License along with PPM. If not,
! see <http://www.gnu.org/licenses/>.
!
! Parallel Particle Mesh Library (PPM)
! ETH Zurich
! CH-8092 Zurich, Switzerland
!-------------------------------------------------------------------------
SUBROUTINE ppm_clist_destroy(clist,info)
!!! Properly deallocates the cell list it is passed.
!!!
!!! [NOTE]
!!! At least using pgf90, this routine is actually not necessary as
!!! `DEALLOCATE(clist)` would be sufficient (no memory leak would
!!! occur according to Valgrind). But since this might be a
!!! compiler-dependent feature we do it the orthodox way for the sake
!!! of portability.
!-------------------------------------------------------------------------
! Modules
!-------------------------------------------------------------------------
USE ppm_module_data
USE ppm_module_typedef
USE ppm_module_substart
USE ppm_module_substop
USE ppm_module_error
USE ppm_module_alloc
IMPLICIT NONE
!-------------------------------------------------------------------------
! Arguments
!-------------------------------------------------------------------------
TYPE(ppm_t_clist), DIMENSION(:), POINTER :: clist
!!! Cell list which is to be deallocated.
INTEGER , INTENT( OUT) :: info
!!! Returns status, 0 upon success
!-------------------------------------------------------------------------
! Local variables
!-------------------------------------------------------------------------
! timer
REAL(ppm_kind_double) :: t0
! counters
INTEGER :: i
! for allocate
INTEGER, DIMENSION(2) :: lda
INTEGER :: iopt
!-------------------------------------------------------------------------
! Externals
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Initialise
!-------------------------------------------------------------------------
CALL substart('ppm_clist_destroy',t0,info)
!-------------------------------------------------------------------------
! Check arguments
!-------------------------------------------------------------------------
IF (ppm_debug .GT. 0) THEN
CALL check
IF (info .NE. 0) GOTO 9999
ENDIF
!-------------------------------------------------------------------------
! Free cell list memory. At least using pgf90, this is actually not
! necessary as DEALLOCATE(clist) would be sufficient (no memory leak
! would occur according to Valgrind). But since this might be a
! compiler-dependent feature we do it the orthodox way for the sake
! of portability.
!-------------------------------------------------------------------------
iopt = ppm_param_dealloc
IF (ASSOCIATED(clist)) THEN
DO i=1,size(clist,1)
CALL ppm_alloc(clist(i)%nm,lda,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_clist_destroy',&
& 'cell list CLIST%LHBX',__LINE__,info)
ENDIF
CALL ppm_alloc(clist(i)%lhbx,lda,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_clist_destroy',&
& 'cell list CLIST%NM',__LINE__,info)
ENDIF
CALL ppm_alloc(clist(i)%lpdx,lda,iopt,info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_clist_destroy',&
& 'cell list CLIST%LPDX',__LINE__,info)
ENDIF
ENDDO
DEALLOCATE(clist, STAT=info)
IF (info .NE. 0) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_dealloc,'ppm_clist_destroy',&
& 'cell list CLIST',__LINE__,info)
ENDIF
NULLIFY(clist)
ENDIF
!-------------------------------------------------------------------------
! Return
!-------------------------------------------------------------------------
9999 CONTINUE
CALL substop('ppm_clist_destroy',t0,info)
RETURN
CONTAINS
SUBROUTINE check
IF (.NOT. ppm_initialized) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_ppm_noinit,'ppm_clist_destroy',&
& 'Please call ppm_init first!',__LINE__,info)
GOTO 8888
ENDIF
IF (.NOT. ASSOCIATED(clist)) THEN
info = ppm_error_error
CALL ppm_error(ppm_err_ppm_noinit,'ppm_clist_destroy',&
& 'clist is not associated!',__LINE__,info)
GOTO 8888
ENDIF
8888 CONTINUE
END SUBROUTINE check
END SUBROUTINE ppm_clist_destroy
| gpl-3.0 |
yaowee/libflame | lapack-test/3.4.2/EIG/derred.f | 29 | 16342 | *> \brief \b DERRED
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DERRED( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DERRED tests the error exits for the eigenvalue driver routines for
*> DOUBLE PRECISION matrices:
*>
*> PATH driver description
*> ---- ------ -----------
*> SEV DGEEV find eigenvalues/eigenvectors for nonsymmetric A
*> SES DGEES find eigenvalues/Schur form for nonsymmetric A
*> SVX DGEEVX SGEEV + balancing and condition estimation
*> SSX DGEESX SGEES + balancing and condition estimation
*> DBD DGESVD compute SVD of an M-by-N matrix A
*> DGESDD compute SVD of an M-by-N matrix A (by divide and
*> conquer)
*> DGEJSV compute SVD of an M-by-N matrix A where M >= N
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_eig
*
* =====================================================================
SUBROUTINE DERRED( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
DOUBLE PRECISION ONE, ZERO
PARAMETER ( NMAX = 4, ONE = 1.0D0, ZERO = 0.0D0 )
* ..
* .. Local Scalars ..
CHARACTER*2 C2
INTEGER I, IHI, ILO, INFO, J, NT, SDIM
DOUBLE PRECISION ABNRM
* ..
* .. Local Arrays ..
LOGICAL B( NMAX )
INTEGER IW( 2*NMAX )
DOUBLE PRECISION A( NMAX, NMAX ), R1( NMAX ), R2( NMAX ),
$ S( NMAX ), U( NMAX, NMAX ), VL( NMAX, NMAX ),
$ VR( NMAX, NMAX ), VT( NMAX, NMAX ),
$ W( 4*NMAX ), WI( NMAX ), WR( NMAX )
* ..
* .. External Subroutines ..
EXTERNAL CHKXER, DGEES, DGEESX, DGEEV, DGEEVX, DGEJSV,
$ DGESDD, DGESVD
* ..
* .. External Functions ..
LOGICAL DSLECT, LSAMEN
EXTERNAL DSLECT, LSAMEN
* ..
* .. Intrinsic Functions ..
INTRINSIC LEN_TRIM
* ..
* .. Arrays in Common ..
LOGICAL SELVAL( 20 )
DOUBLE PRECISION SELWI( 20 ), SELWR( 20 )
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT, SELDIM, SELOPT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
COMMON / SSLCT / SELOPT, SELDIM, SELVAL, SELWR, SELWI
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
C2 = PATH( 2: 3 )
*
* Initialize A
*
DO 20 J = 1, NMAX
DO 10 I = 1, NMAX
A( I, J ) = ZERO
10 CONTINUE
20 CONTINUE
DO 30 I = 1, NMAX
A( I, I ) = ONE
30 CONTINUE
OK = .TRUE.
NT = 0
*
IF( LSAMEN( 2, C2, 'EV' ) ) THEN
*
* Test DGEEV
*
SRNAMT = 'DGEEV '
INFOT = 1
CALL DGEEV( 'X', 'N', 0, A, 1, WR, WI, VL, 1, VR, 1, W, 1,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEEV( 'N', 'X', 0, A, 1, WR, WI, VL, 1, VR, 1, W, 1,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGEEV( 'N', 'N', -1, A, 1, WR, WI, VL, 1, VR, 1, W, 1,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGEEV( 'N', 'N', 2, A, 1, WR, WI, VL, 1, VR, 1, W, 6,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 9
CALL DGEEV( 'V', 'N', 2, A, 2, WR, WI, VL, 1, VR, 1, W, 8,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 11
CALL DGEEV( 'N', 'V', 2, A, 2, WR, WI, VL, 1, VR, 1, W, 8,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
INFOT = 13
CALL DGEEV( 'V', 'V', 1, A, 1, WR, WI, VL, 1, VR, 1, W, 3,
$ INFO )
CALL CHKXER( 'DGEEV ', INFOT, NOUT, LERR, OK )
NT = NT + 7
*
ELSE IF( LSAMEN( 2, C2, 'ES' ) ) THEN
*
* Test DGEES
*
SRNAMT = 'DGEES '
INFOT = 1
CALL DGEES( 'X', 'N', DSLECT, 0, A, 1, SDIM, WR, WI, VL, 1, W,
$ 1, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEES( 'N', 'X', DSLECT, 0, A, 1, SDIM, WR, WI, VL, 1, W,
$ 1, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEES( 'N', 'S', DSLECT, -1, A, 1, SDIM, WR, WI, VL, 1, W,
$ 1, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL DGEES( 'N', 'S', DSLECT, 2, A, 1, SDIM, WR, WI, VL, 1, W,
$ 6, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
INFOT = 11
CALL DGEES( 'V', 'S', DSLECT, 2, A, 2, SDIM, WR, WI, VL, 1, W,
$ 6, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
INFOT = 13
CALL DGEES( 'N', 'S', DSLECT, 1, A, 1, SDIM, WR, WI, VL, 1, W,
$ 2, B, INFO )
CALL CHKXER( 'DGEES ', INFOT, NOUT, LERR, OK )
NT = NT + 6
*
ELSE IF( LSAMEN( 2, C2, 'VX' ) ) THEN
*
* Test DGEEVX
*
SRNAMT = 'DGEEVX'
INFOT = 1
CALL DGEEVX( 'X', 'N', 'N', 'N', 0, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEEVX( 'N', 'X', 'N', 'N', 0, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGEEVX( 'N', 'N', 'X', 'N', 0, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEEVX( 'N', 'N', 'N', 'X', 0, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGEEVX( 'N', 'N', 'N', 'N', -1, A, 1, WR, WI, VL, 1, VR,
$ 1, ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DGEEVX( 'N', 'N', 'N', 'N', 2, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 11
CALL DGEEVX( 'N', 'V', 'N', 'N', 2, A, 2, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 6, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 13
CALL DGEEVX( 'N', 'N', 'V', 'N', 2, A, 2, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 6, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 21
CALL DGEEVX( 'N', 'N', 'N', 'N', 1, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 1, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 21
CALL DGEEVX( 'N', 'V', 'N', 'N', 1, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 2, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
INFOT = 21
CALL DGEEVX( 'N', 'N', 'V', 'V', 1, A, 1, WR, WI, VL, 1, VR, 1,
$ ILO, IHI, S, ABNRM, R1, R2, W, 3, IW, INFO )
CALL CHKXER( 'DGEEVX', INFOT, NOUT, LERR, OK )
NT = NT + 11
*
ELSE IF( LSAMEN( 2, C2, 'SX' ) ) THEN
*
* Test DGEESX
*
SRNAMT = 'DGEESX'
INFOT = 1
CALL DGEESX( 'X', 'N', DSLECT, 'N', 0, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 1, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEESX( 'N', 'X', DSLECT, 'N', 0, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 1, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEESX( 'N', 'N', DSLECT, 'X', 0, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 1, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGEESX( 'N', 'N', DSLECT, 'N', -1, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 1, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DGEESX( 'N', 'N', DSLECT, 'N', 2, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 6, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 12
CALL DGEESX( 'V', 'N', DSLECT, 'N', 2, A, 2, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 6, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
INFOT = 16
CALL DGEESX( 'N', 'N', DSLECT, 'N', 1, A, 1, SDIM, WR, WI, VL,
$ 1, R1( 1 ), R2( 1 ), W, 2, IW, 1, B, INFO )
CALL CHKXER( 'DGEESX', INFOT, NOUT, LERR, OK )
NT = NT + 7
*
ELSE IF( LSAMEN( 2, C2, 'BD' ) ) THEN
*
* Test DGESVD
*
SRNAMT = 'DGESVD'
INFOT = 1
CALL DGESVD( 'X', 'N', 0, 0, A, 1, S, U, 1, VT, 1, W, 1, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGESVD( 'N', 'X', 0, 0, A, 1, S, U, 1, VT, 1, W, 1, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGESVD( 'O', 'O', 0, 0, A, 1, S, U, 1, VT, 1, W, 1, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGESVD( 'N', 'N', -1, 0, A, 1, S, U, 1, VT, 1, W, 1,
$ INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGESVD( 'N', 'N', 0, -1, A, 1, S, U, 1, VT, 1, W, 1,
$ INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL DGESVD( 'N', 'N', 2, 1, A, 1, S, U, 1, VT, 1, W, 5, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 9
CALL DGESVD( 'A', 'N', 2, 1, A, 2, S, U, 1, VT, 1, W, 5, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
INFOT = 11
CALL DGESVD( 'N', 'A', 1, 2, A, 1, S, U, 1, VT, 1, W, 5, INFO )
CALL CHKXER( 'DGESVD', INFOT, NOUT, LERR, OK )
NT = 8
IF( OK ) THEN
WRITE( NOUT, FMT = 9999 )SRNAMT( 1:LEN_TRIM( SRNAMT ) ),
$ NT
ELSE
WRITE( NOUT, FMT = 9998 )
END IF
*
* Test DGESDD
*
SRNAMT = 'DGESDD'
INFOT = 1
CALL DGESDD( 'X', 0, 0, A, 1, S, U, 1, VT, 1, W, 1, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGESDD( 'N', -1, 0, A, 1, S, U, 1, VT, 1, W, 1, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGESDD( 'N', 0, -1, A, 1, S, U, 1, VT, 1, W, 1, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGESDD( 'N', 2, 1, A, 1, S, U, 1, VT, 1, W, 5, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL DGESDD( 'A', 2, 1, A, 2, S, U, 1, VT, 1, W, 5, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL DGESDD( 'A', 1, 2, A, 1, S, U, 1, VT, 1, W, 5, IW, INFO )
CALL CHKXER( 'DGESDD', INFOT, NOUT, LERR, OK )
NT = 6
IF( OK ) THEN
WRITE( NOUT, FMT = 9999 )SRNAMT( 1:LEN_TRIM( SRNAMT ) ),
$ NT
ELSE
WRITE( NOUT, FMT = 9998 )
END IF
*
* Test DGEJSV
*
SRNAMT = 'DGEJSV'
INFOT = 1
CALL DGEJSV( 'X', 'U', 'V', 'R', 'N', 'N',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEJSV( 'G', 'X', 'V', 'R', 'N', 'N',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGEJSV( 'G', 'U', 'X', 'R', 'N', 'N',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEJSV( 'G', 'U', 'V', 'X', 'N', 'N',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGEJSV( 'G', 'U', 'V', 'R', 'X', 'N',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 6
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'X',
$ 0, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'N',
$ -1, 0, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'N',
$ 0, -1, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'N',
$ 2, 1, A, 1, S, U, 1, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 13
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'N',
$ 2, 2, A, 2, S, U, 1, VT, 2,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
INFOT = 14
CALL DGEJSV( 'G', 'U', 'V', 'R', 'N', 'N',
$ 2, 2, A, 2, S, U, 2, VT, 1,
$ W, 1, IW, INFO)
CALL CHKXER( 'DGEJSV', INFOT, NOUT, LERR, OK )
NT = 11
IF( OK ) THEN
WRITE( NOUT, FMT = 9999 )SRNAMT( 1:LEN_TRIM( SRNAMT ) ),
$ NT
ELSE
WRITE( NOUT, FMT = 9998 )
END IF
END IF
*
* Print a summary line.
*
IF( .NOT.LSAMEN( 2, C2, 'BD' ) ) THEN
IF( OK ) THEN
WRITE( NOUT, FMT = 9999 )SRNAMT( 1:LEN_TRIM( SRNAMT ) ),
$ NT
ELSE
WRITE( NOUT, FMT = 9998 )
END IF
END IF
*
9999 FORMAT( 1X, A, ' passed the tests of the error exits (', I3,
$ ' tests done)' )
9998 FORMAT( ' *** ', A, ' failed the tests of the error exits ***' )
RETURN
*
* End of DERRED
END
| bsd-3-clause |
CavendishAstrophysics/anmap | nmr_tools/nmr_a2sp.f | 1 | 3055 | C f1dxy.f
C
C MPH V1 930505
C
C based on f1dre.f
C
C inputs: filenames, file size, mm/pixel
C
C output: data in std. output format (header,x,y)
C x=0 corresponds to image centre i.e. slice position in
C simple xy imaging
C x dimension in real*4
C
C
C standard include files
include '/mrao/include/chrlib_functions.inc'
include '../include/spec_global.inc'
include '../include/spec_pars.inc'
C file and directory name
character*256 fname,fout
character*1 next_byte
integer error,rec,ichan,len,status,i
integer result(16384*4)
real*4 x,xpix,xpixl,xpixr
character cline*(1024)
status = 0
C
C We have allowed for 16K (=16384) array size
C
ichan = 10
C
C
call io_enqline( cline, status )
call io_setcli( cline )
call io_getwrd( 'Binary-file : ',' ',fname,i,status)
call io_getwrd( 'Output-file : ',' ',fout,i,status)
call io_geti('Data-set-length : ','1024',len,status)
call io_getr('X-scale : ','1.0',xpix,status)
if (xpix.lt.0.0) then
call io_getr('X-left : ','1.0',xpixl,status)
call io_getr('X-right : ','1.0',xpixr,status)
endif
len = 2*len
if (status.ne.0) stop
if (len .gt.0 .and. len .le. 16384) goto 70
print *,'*** NMR_A2SP : Illegal data set length : ',len/2
stop
C++++++ BINARY OLD, DIRECT ACCESS, LRECL = 1 BYTE
70 OPEN (UNIT = ICHAN,FILE = FNAME,FORM = 'BINARY',
+ STATUS = 'OLD',ACCESS = 'DIRECT',RECL = 1,
+ IOSTAT = ERROR )
OPEN (UNIT = 2,FILE = FOUT(1:chr_lenb(fout)),
+ STATUS = 'NEW',IOSTAT = ERROR )
C
C The intensity information starts at this byte in the file
C
rec=769
do 10 i = 1 ,len
result(i)=0
read(ichan,REC=rec)next_byte
result(i)=ichar(next_byte)
rec=rec+1
read(ichan,REC=rec)next_byte
result(i)=result(i)+ichar(next_byte)*256
rec=rec+1
read(ichan,REC=rec)next_byte
result(i)=result(i)+ichar(next_byte)*256*256
10 rec=rec+1
C ... output real values only
close (ichan)
print *,'Done read rec = ',rec
do 20 i=1 , len
C ... check for negative numbers
if(result(i).gt.16777216/2)then
result(i)=result(i)-16777216
end if
20 continue
C .. output results
C .. output std header for sp_display compatibility
print *,'.. outputting standard header: '
write(2,9999)len/2
9999 format('%ndata ',I4/
* '%ncols 3'/
* '%title 1D image')
C x range runs from -len/2*xpix to len/2*xpix
C note len include RE and IM components so len/2*2 = len
print *,'.. outputting data'
if (xpix.gt.0.0) then
xpixl = (-float(len)/4.0)*xpix
else
xpix = (xpixr - xpixl)/float(len/2 - 1)
endif
do i=1,len,2
x=((i-1)/2)*xpix + xpixl
write(2,100) x,result(i),result(i+1)
100 format(f10.4,4x,i8,4x,i8)
end do
close (2)
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/serrqp.f | 29 | 3803 | *> \brief \b SERRQP
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SERRQP( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SERRQP tests the error exits for SGEQPF and SGEQP3.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SERRQP( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 3 )
* ..
* .. Local Scalars ..
CHARACTER*2 C2
INTEGER INFO, LW
* ..
* .. Local Arrays ..
INTEGER IP( NMAX )
REAL A( NMAX, NMAX ), TAU( NMAX ), W( 3*NMAX+1 )
* ..
* .. External Functions ..
LOGICAL LSAMEN
EXTERNAL LSAMEN
* ..
* .. External Subroutines ..
EXTERNAL ALAESM, CHKXER, SGEQP3, SGEQPF
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
C2 = PATH( 2: 3 )
LW = 3*NMAX + 1
A( 1, 1 ) = 1.0E+0
A( 1, 2 ) = 2.0E+0
A( 2, 2 ) = 3.0E+0
A( 2, 1 ) = 4.0E+0
OK = .TRUE.
*
IF( LSAMEN( 2, C2, 'QP' ) ) THEN
*
* Test error exits for QR factorization with pivoting
*
* SGEQPF
*
SRNAMT = 'SGEQPF'
INFOT = 1
CALL SGEQPF( -1, 0, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL SGEQPF( 0, -1, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL SGEQPF( 2, 0, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
*
* SGEQP3
*
SRNAMT = 'SGEQP3'
INFOT = 1
CALL SGEQP3( -1, 0, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL SGEQP3( 1, -1, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL SGEQP3( 2, 3, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL SGEQP3( 2, 2, A, 2, IP, TAU, W, LW-10, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
END IF
*
* Print a summary line.
*
CALL ALAESM( PATH, OK, NOUT )
*
RETURN
*
* End of SERRQP
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/LIN/serrqp.f | 29 | 3803 | *> \brief \b SERRQP
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SERRQP( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SERRQP tests the error exits for SGEQPF and SGEQP3.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SERRQP( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 3 )
* ..
* .. Local Scalars ..
CHARACTER*2 C2
INTEGER INFO, LW
* ..
* .. Local Arrays ..
INTEGER IP( NMAX )
REAL A( NMAX, NMAX ), TAU( NMAX ), W( 3*NMAX+1 )
* ..
* .. External Functions ..
LOGICAL LSAMEN
EXTERNAL LSAMEN
* ..
* .. External Subroutines ..
EXTERNAL ALAESM, CHKXER, SGEQP3, SGEQPF
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
C2 = PATH( 2: 3 )
LW = 3*NMAX + 1
A( 1, 1 ) = 1.0E+0
A( 1, 2 ) = 2.0E+0
A( 2, 2 ) = 3.0E+0
A( 2, 1 ) = 4.0E+0
OK = .TRUE.
*
IF( LSAMEN( 2, C2, 'QP' ) ) THEN
*
* Test error exits for QR factorization with pivoting
*
* SGEQPF
*
SRNAMT = 'SGEQPF'
INFOT = 1
CALL SGEQPF( -1, 0, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL SGEQPF( 0, -1, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL SGEQPF( 2, 0, A, 1, IP, TAU, W, INFO )
CALL CHKXER( 'SGEQPF', INFOT, NOUT, LERR, OK )
*
* SGEQP3
*
SRNAMT = 'SGEQP3'
INFOT = 1
CALL SGEQP3( -1, 0, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL SGEQP3( 1, -1, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL SGEQP3( 2, 3, A, 1, IP, TAU, W, LW, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL SGEQP3( 2, 2, A, 2, IP, TAU, W, LW-10, INFO )
CALL CHKXER( 'SGEQP3', INFOT, NOUT, LERR, OK )
END IF
*
* Print a summary line.
*
CALL ALAESM( PATH, OK, NOUT )
*
RETURN
*
* End of SERRQP
*
END
| bsd-3-clause |
CavendishAstrophysics/anmap | anm_lib/iocmd_pars2tcl.f | 1 | 3199 | C
C
*+ iocmd_pars2tcl
subroutine iocmd_pars2tcl(interp,status)
C ----------------------------------------
C
C List information on procedures and parameters
C
C Given:
C interpreter data structure
integer interp(*)
C Returned:
C error return code
integer status
C
C Information in PARAMETERS or PROCEDURES are listed on the current
C output device
*-
include '/mrao/include/cmd_lang_param.inc'
include '/mrao/include/cmd_lang_comms.inc'
include '/mrao/include/chrlib_functions.inc'
C counters
integer n, nn, i, i1, i2, mm
C string variables
character*256 text, string, var
character*256 name
C check status on entry
if (status.ne.0) return
do n=1,len_list
name = param_list(n)
if (name(1:1).eq.'%') then
string = name(2:256)
else
string = name
endif
call chr_chlcas( string )
call chr_chswap( string, '-', '_' )
name = ' '
var = string(1:chr_lenb(string))
string = paramtext_list(n)
text = string(1:chr_lenb(string))//char(0)
if (chr_lenb(param_list(n)).gt.0) then
if (paramtype_list(1,n).eq.paramtype_string) then
name = var(1:chr_lenb(var)) // char(0)
call iocmd_tclset( interp, name, text )
elseif (paramtype_list(1,n).eq.paramtype_char) then
i1 = paramtype_list(2,n)
i2 = paramtype_list(2,n) + paramtype_list(3,n) - 1
text = param_char(i1:i2)//char(0)
name = var(1:chr_lenb(var)) // char(0)
call iocmd_tclset( interp, name, text )
elseif (paramtype_list(1,n).eq.paramtype_integer) then
mm = 0
do nn=paramtype_list(2,n),
* paramtype_list(2,n)+paramtype_list(3,n)-1
mm = mm + 1
text = ' '
string = ' '
call chr_chitoc( param_integer(nn), string, i)
text = string(1:i)//char(0)
name = var(1:chr_lenb(var)) // char(0)
if (mm.eq.1) then
call iocmd_tclset( interp, name, text )
else
call iocmd_tclapplist( interp, name, text )
endif
end do
elseif (paramtype_list(1,n).eq.paramtype_real) then
mm = 0
do nn=paramtype_list(2,n),
* paramtype_list(2,n)+paramtype_list(3,n)-1
mm = mm + 1
text = ' '
string = ' '
call chr_chrtoc( param_real(nn), string, i)
text = string(1:i)//char(0)
name = var(1:chr_lenb(var)) // char(0)
if (mm.eq.1) then
call iocmd_tclset( interp, name, text )
else
call iocmd_tclapplist( interp, name, text )
endif
end do
end if
end if
enddo
call cmd_err(status,'iocmd_pars2tcl',' ')
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/EIG/dort01.f | 32 | 6323 | *> \brief \b DORT01
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DORT01( ROWCOL, M, N, U, LDU, WORK, LWORK, RESID )
*
* .. Scalar Arguments ..
* CHARACTER ROWCOL
* INTEGER LDU, LWORK, M, N
* DOUBLE PRECISION RESID
* ..
* .. Array Arguments ..
* DOUBLE PRECISION U( LDU, * ), WORK( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DORT01 checks that the matrix U is orthogonal by computing the ratio
*>
*> RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
*> or
*> RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.
*>
*> Alternatively, if there isn't sufficient workspace to form
*> I - U*U' or I - U'*U, the ratio is computed as
*>
*> RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
*> or
*> RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.
*>
*> where EPS is the machine precision. ROWCOL is used only if m = n;
*> if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is
*> assumed to be 'R'.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] ROWCOL
*> \verbatim
*> ROWCOL is CHARACTER
*> Specifies whether the rows or columns of U should be checked
*> for orthogonality. Used only if M = N.
*> = 'R': Check for orthogonal rows of U
*> = 'C': Check for orthogonal columns of U
*> \endverbatim
*>
*> \param[in] M
*> \verbatim
*> M is INTEGER
*> The number of rows of the matrix U.
*> \endverbatim
*>
*> \param[in] N
*> \verbatim
*> N is INTEGER
*> The number of columns of the matrix U.
*> \endverbatim
*>
*> \param[in] U
*> \verbatim
*> U is DOUBLE PRECISION array, dimension (LDU,N)
*> The orthogonal matrix U. U is checked for orthogonal columns
*> if m > n or if m = n and ROWCOL = 'C'. U is checked for
*> orthogonal rows if m < n or if m = n and ROWCOL = 'R'.
*> \endverbatim
*>
*> \param[in] LDU
*> \verbatim
*> LDU is INTEGER
*> The leading dimension of the array U. LDU >= max(1,M).
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is DOUBLE PRECISION array, dimension (LWORK)
*> \endverbatim
*>
*> \param[in] LWORK
*> \verbatim
*> LWORK is INTEGER
*> The length of the array WORK. For best performance, LWORK
*> should be at least N*(N+1) if ROWCOL = 'C' or M*(M+1) if
*> ROWCOL = 'R', but the test will be done even if LWORK is 0.
*> \endverbatim
*>
*> \param[out] RESID
*> \verbatim
*> RESID is DOUBLE PRECISION
*> RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or
*> RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_eig
*
* =====================================================================
SUBROUTINE DORT01( ROWCOL, M, N, U, LDU, WORK, LWORK, RESID )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER ROWCOL
INTEGER LDU, LWORK, M, N
DOUBLE PRECISION RESID
* ..
* .. Array Arguments ..
DOUBLE PRECISION U( LDU, * ), WORK( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
* ..
* .. Local Scalars ..
CHARACTER TRANSU
INTEGER I, J, K, LDWORK, MNMIN
DOUBLE PRECISION EPS, TMP
* ..
* .. External Functions ..
LOGICAL LSAME
DOUBLE PRECISION DDOT, DLAMCH, DLANSY
EXTERNAL LSAME, DDOT, DLAMCH, DLANSY
* ..
* .. External Subroutines ..
EXTERNAL DLASET, DSYRK
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, DBLE, MAX, MIN
* ..
* .. Executable Statements ..
*
RESID = ZERO
*
* Quick return if possible
*
IF( M.LE.0 .OR. N.LE.0 )
$ RETURN
*
EPS = DLAMCH( 'Precision' )
IF( M.LT.N .OR. ( M.EQ.N .AND. LSAME( ROWCOL, 'R' ) ) ) THEN
TRANSU = 'N'
K = N
ELSE
TRANSU = 'T'
K = M
END IF
MNMIN = MIN( M, N )
*
IF( ( MNMIN+1 )*MNMIN.LE.LWORK ) THEN
LDWORK = MNMIN
ELSE
LDWORK = 0
END IF
IF( LDWORK.GT.0 ) THEN
*
* Compute I - U*U' or I - U'*U.
*
CALL DLASET( 'Upper', MNMIN, MNMIN, ZERO, ONE, WORK, LDWORK )
CALL DSYRK( 'Upper', TRANSU, MNMIN, K, -ONE, U, LDU, ONE, WORK,
$ LDWORK )
*
* Compute norm( I - U*U' ) / ( K * EPS ) .
*
RESID = DLANSY( '1', 'Upper', MNMIN, WORK, LDWORK,
$ WORK( LDWORK*MNMIN+1 ) )
RESID = ( RESID / DBLE( K ) ) / EPS
ELSE IF( TRANSU.EQ.'T' ) THEN
*
* Find the maximum element in abs( I - U'*U ) / ( m * EPS )
*
DO 20 J = 1, N
DO 10 I = 1, J
IF( I.NE.J ) THEN
TMP = ZERO
ELSE
TMP = ONE
END IF
TMP = TMP - DDOT( M, U( 1, I ), 1, U( 1, J ), 1 )
RESID = MAX( RESID, ABS( TMP ) )
10 CONTINUE
20 CONTINUE
RESID = ( RESID / DBLE( M ) ) / EPS
ELSE
*
* Find the maximum element in abs( I - U*U' ) / ( n * EPS )
*
DO 40 J = 1, M
DO 30 I = 1, J
IF( I.NE.J ) THEN
TMP = ZERO
ELSE
TMP = ONE
END IF
TMP = TMP - DDOT( N, U( J, 1 ), LDU, U( I, 1 ), LDU )
RESID = MAX( RESID, ABS( TMP ) )
30 CONTINUE
40 CONTINUE
RESID = ( RESID / DBLE( N ) ) / EPS
END IF
RETURN
*
* End of DORT01
*
END
| bsd-3-clause |
astrofrog/hyperion | src/mpi/mpi_routines.f90 | 1 | 18259 | module mpi_routines
use mpi
use mpi_core
use core_lib
use grid_physics
use setup
use performance
implicit none
save
private
! MPI errors
integer :: ierr
! MPI status
integer,dimension(mpi_status_size) :: status
! Variable to signal first-time use for mp_n_photons
logical :: first = .true.
! Pre-defined tags
integer,parameter :: tag1 = 50, tag2 = 60
logical :: debug = .false.
public :: mp_reset_first
public :: mp_n_photons
public :: mp_collect_physical_arrays
public :: mp_broadcast_specific_energy
public :: mp_collect_images
public :: mp_broadcast_convergence
public :: mp_set_random_seed
real(dp) :: time_curr
integer(idp) :: n_completed, n_photons_chunk
integer(idp) :: n_steps = 10
integer(idp) :: n_stats_last
public :: mp_sync
interface mp_sync
module procedure mp_sync_integer4
module procedure mp_sync_integer8
module procedure mp_sync_real4
module procedure mp_sync_real8
end interface mp_sync
contains
subroutine mp_reset_first()
implicit none
first = .true.
time_curr = 0._dp
n_completed = 0
n_photons_chunk = 0
n_stats_last = 0
end subroutine mp_reset_first
subroutine mp_n_photons(n_photons_tot, n_photons_curr, n_photons_stats, n_photons)
implicit none
! Total number of photons, and size of a chunk
integer(idp),intent(in) :: n_photons_tot, n_photons_stats
! Number of photons requested so far
integer(idp),intent(inout) :: n_photons_curr
! Number of photons to compute this time
integer(idp),intent(out) :: n_photons
! Number of photons used for MPI transfer
integer(idp),volatile,allocatable :: n_photons_send(:)
! Loop variable and dummy variable
integer :: ir
real(dp), volatile :: dum_dp
! Flag for MPI test
logical :: flag
! Request variables
integer,allocatable,save :: request(:)
integer :: request_dum
! Whether a process has been asked to stop
logical,allocatable :: stopped(:)
logical,allocatable,save :: started(:)
real(dp),save :: time1 = -1._dp
real(dp) :: time2
real(dp),allocatable,volatile,save :: dtime(:)
if(debug) write(*,'("[mpi_routines] rank ",I0," requesting number of photons")') rank
if(time1 < 0._dp) call cpu_time(time1)
call cpu_time(time2)
select case(rank)
case(rank_main)
! Find the number of photons per chunk
if(n_photons_chunk == 0) then
n_photons_chunk = max(nint(real(n_photons_tot, dp) / real(nproc, dp) / real(n_steps, dp)), 1)
end if
time_curr = time_curr + time2-time1
if(.not.allocated(request)) allocate(request(nproc-1))
if(.not.allocated(dtime)) allocate(dtime(nproc-1))
if(.not.allocated(n_photons_send)) allocate(n_photons_send(nproc-1))
if(.not.allocated(stopped)) then
allocate(stopped(nproc-1))
stopped = .false.
end if
if(.not.allocated(started)) then
allocate(started(nproc-1))
started = .false.
end if
! Loop over processes
do ir=1,nproc-1
if(.not.first) then
! Test whether previous request was received
call mpi_test(request(ir), flag, status, ierr)
if(flag) time_curr = time_curr + dtime(ir)
else
! Set flag to true to force sending a request
flag = .true.
end if
if (flag) then
! If all photons have been requested, we exit the loop and wrap things up
if(n_photons_curr == n_photons_tot) exit
if(n_photons_curr > n_photons_tot) stop "n_photons_curr > n_photons_tot"
! Find how many photons to request and increment counter
if(n_photons_tot - n_photons_curr <= n_photons_chunk * nproc) then
n_photons_send(ir) = max(nint(real(n_photons_chunk, dp) / 10._dp), 1)
else
n_photons_send(ir) = n_photons_chunk
end if
if(n_photons_curr + n_photons_send(ir) > n_photons_tot) n_photons_send(ir) = n_photons_tot - n_photons_curr
n_photons_curr = n_photons_curr + n_photons_send(ir)
! Send number of photons and initialize receive for status check
call mpi_isend(n_photons_send(ir), 1, mpi_integer8, ir, tag1, mpi_comm_world, request_dum, ierr)
call mpi_irecv(dtime(ir), 1, mpi_real8, ir, tag2, mpi_comm_world, request(ir), ierr)
if(first) started(ir) = .true.
end if
end do
if(n_photons_curr > n_photons_tot) stop "n_photons_curr > n_photons_tot"
if(n_photons_curr == n_photons_tot) then
if(debug) write(*,'("[mpi_routines] master rank now checking all clients are stopped")')
! Loop until all processes are finished
do while(.not.all(stopped))
call microsleep(200000)
! Loop over processes
do ir=1,nproc-1
if(started(ir).and..not.stopped(ir)) then
! Test if last valid request was received
call mpi_test(request(ir), flag, status, ierr)
! If it was, send out a final request
if(flag) then
n_photons_send(ir) = 0_idp
call mpi_isend(n_photons_send(ir), 1, mpi_integer8, ir, tag1, mpi_comm_world, request_dum, ierr)
call mpi_irecv(dum_dp, 1, mpi_real8, ir, tag2, mpi_comm_world, request(ir), ierr)
stopped(ir) = .true.
if(debug) write(*,'("[mpi_routines] send abort signal to rank ",I0)') ir
else
if(debug) write(*,'("[mpi_routines] rank ",I0," is not ready for abort signal")') ir
end if
else if(.not.started(ir)) then
n_photons_send(ir) = 0_idp
call mpi_isend(n_photons_send(ir), 1, mpi_integer8, ir, tag1, mpi_comm_world, request_dum, ierr)
call mpi_irecv(dum_dp, 1, mpi_real8, ir, tag2, mpi_comm_world, request(ir), ierr)
started(ir) = .true.
stopped(ir) = .true.
if(debug) write(*,'("[mpi_routines] send abort signal to rank ",I0)') ir
end if
end do
end do
if(debug) write(*,'("[mpi_routines] master rank now waiting for all jobs to complete")')
! Wait for all acknowledgements of final request
call mpi_waitall(nproc-1, request, mpi_statuses_ignore, ierr)
! Set number of photons to 0 for main process too
n_photons = 0
else
! Set number of photons to a fraction of the normal chunk size
n_photons = max(nint(real(n_photons_chunk, dp) / 10._dp), 1)
if(n_photons_curr + n_photons > n_photons_tot) n_photons = n_photons_tot - n_photons_curr
n_photons_curr = n_photons_curr + n_photons
end if
if(first) first=.false.
if(n_photons_stats > 0) then
if(n_photons_curr >= n_stats_last + n_photons_stats) then
if(n_photons_curr > 0) call perf_numbers(n_photons_curr, time_curr)
n_stats_last = n_photons_curr - mod(n_photons_curr, n_photons_stats)
end if
else
if(n_photons_curr >= n_stats_last + n_photons_chunk) then
if(n_photons_curr > 0) call perf_numbers(n_photons_curr, time_curr)
n_stats_last = n_photons_curr - mod(n_photons_curr, n_photons_chunk)
end if
end if
case default
! Receive number of photons and send acknowledgments
call mpi_recv(n_photons, 1, mpi_integer8, rank_main, tag1, mpi_comm_world, status, ierr)
call mpi_isend(time2-time1, 1, mpi_real8, rank_main, tag2, mpi_comm_world, request_dum, ierr)
if(n_photons > n_photons_tot) stop "n_photons > n_photons_tot"
end select
time1 = time2
if(debug) write(*,'("[mpi_routines] rank ",I0," will compute ",I0," photons")') rank,n_photons
end subroutine mp_n_photons
subroutine mp_set_random_seed(seed)
implicit none
integer :: seed
call set_seed(seed + rank)
end subroutine mp_set_random_seed
subroutine mp_collect_physical_arrays()
implicit none
real(dp) :: tmp
real(dp) :: dummy_dp
integer(idp) :: dummy_idp
real(dp),allocatable :: tmp_2d(:,:)
integer(idp),allocatable :: tmp_int_1d(:)
if(main_process()) then
allocate(tmp_2d(size(specific_energy_sum,1),size(specific_energy_sum,2)))
call mpi_reduce(specific_energy_sum, tmp_2d, size(specific_energy_sum), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr)
specific_energy_sum = tmp_2d
deallocate(tmp_2d)
else
call mpi_reduce(specific_energy_sum, dummy_dp, size(specific_energy_sum), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr)
end if
if(allocated(n_photons)) then
if(main_process()) then
allocate(tmp_int_1d(size(n_photons,1)))
call mpi_reduce(n_photons, tmp_int_1d, size(n_photons), mpi_integer8, mpi_sum, rank_main, mpi_comm_world, ierr)
n_photons = tmp_int_1d
deallocate(tmp_int_1d)
else
call mpi_reduce(n_photons, dummy_idp, size(n_photons), mpi_integer8, mpi_sum, rank_main, mpi_comm_world, ierr)
end if
end if
end subroutine mp_collect_physical_arrays
subroutine mp_broadcast_specific_energy()
implicit none
call mpi_bcast(specific_energy, size(specific_energy), mpi_real8, rank_main, mpi_comm_world, ierr)
call mpi_bcast(energy_abs_tot, size(energy_abs_tot), mpi_real8, rank_main, mpi_comm_world, ierr)
end subroutine mp_broadcast_specific_energy
subroutine mp_broadcast_convergence(converged)
implicit none
logical,intent(inout) :: converged
call mpi_bcast(converged, 1, mpi_logical, rank_main, mpi_comm_world, ierr)
end subroutine mp_broadcast_convergence
subroutine mp_sync_integer4(value)
implicit none
integer,intent(inout) :: value
integer :: tmp
call mpi_allreduce(value, tmp, 1, mpi_integer4, mpi_sum, mpi_comm_world, ierr)
value = tmp
end subroutine mp_sync_integer4
subroutine mp_sync_integer8(value)
implicit none
integer(idp),intent(inout) :: value
integer(idp) :: tmp
call mpi_allreduce(value, tmp, 1, mpi_integer8, mpi_sum, mpi_comm_world, ierr)
value = tmp
end subroutine mp_sync_integer8
subroutine mp_sync_real4(value)
implicit none
real(sp),intent(inout) :: value
real(sp) :: tmp
call mpi_allreduce(value, tmp, 1, mpi_real4, mpi_sum, mpi_comm_world, ierr)
value = tmp
end subroutine mp_sync_real4
subroutine mp_sync_real8(value)
implicit none
real(dp),intent(inout) :: value
real(dp) :: tmp
call mpi_allreduce(value, tmp, 1, mpi_real8, mpi_sum, mpi_comm_world, ierr)
value = tmp
end subroutine mp_sync_real8
subroutine mp_collect_images()
use binned_images
use peeled_images
implicit none
integer :: ip
real(dp),allocatable :: cube4d(:,:,:,:)
real(dp),allocatable :: cube5d(:,:,:,:,:)
if(make_binned_images) then
if(binned_image%compute_sed) then
allocate(cube4d(binned_image%n_nu,binned_image%n_ap,binned_image%n_view,binned_image%n_orig))
call mpi_reduce(binned_image%sed%i, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed%i = cube4d
call mpi_reduce(binned_image%sed%q, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed%q = cube4d
call mpi_reduce(binned_image%sed%u, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed%u = cube4d
call mpi_reduce(binned_image%sed%v, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed%v = cube4d
if(binned_image%uncertainties) then
call mpi_reduce(binned_image%sed2%i, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed2%i = cube4d
call mpi_reduce(binned_image%sed2%q, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed2%q = cube4d
call mpi_reduce(binned_image%sed2%u, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed2%u = cube4d
call mpi_reduce(binned_image%sed2%v, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sed2%v = cube4d
call mpi_reduce(binned_image%sedn, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%sedn = cube4d
end if
deallocate(cube4d)
end if
if(binned_image%compute_image) then
allocate(cube5d(binned_image%n_nu,binned_image%n_x,binned_image%n_y,binned_image%n_view,binned_image%n_orig))
call mpi_reduce(binned_image%img%i, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img%i = cube5d
call mpi_reduce(binned_image%img%q, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img%q = cube5d
call mpi_reduce(binned_image%img%u, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img%u = cube5d
call mpi_reduce(binned_image%img%v, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img%v = cube5d
if(binned_image%uncertainties) then
call mpi_reduce(binned_image%img2%i, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img2%i = cube5d
call mpi_reduce(binned_image%img2%q, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img2%q = cube5d
call mpi_reduce(binned_image%img2%u, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img2%u = cube5d
call mpi_reduce(binned_image%img2%v, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%img2%v = cube5d
call mpi_reduce(binned_image%imgn, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; binned_image%imgn = cube5d
end if
deallocate(cube5d)
end if
end if
if(make_peeled_images) then
do ip=1,n_groups
if(peeled_image(ip)%compute_sed) then
allocate(cube4d(peeled_image(ip)%n_nu,peeled_image(ip)%n_ap,peeled_image(ip)%n_view,peeled_image(ip)%n_orig))
call mpi_reduce(peeled_image(ip)%sed%i, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed%i = cube4d
call mpi_reduce(peeled_image(ip)%sed%q, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed%q = cube4d
call mpi_reduce(peeled_image(ip)%sed%u, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed%u = cube4d
call mpi_reduce(peeled_image(ip)%sed%v, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed%v = cube4d
if(peeled_image(ip)%uncertainties) then
call mpi_reduce(peeled_image(ip)%sed2%i, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed2%i = cube4d
call mpi_reduce(peeled_image(ip)%sed2%q, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed2%q = cube4d
call mpi_reduce(peeled_image(ip)%sed2%u, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed2%u = cube4d
call mpi_reduce(peeled_image(ip)%sed2%v, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sed2%v = cube4d
call mpi_reduce(peeled_image(ip)%sedn, cube4d, size(cube4d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%sedn = cube4d
end if
deallocate(cube4d)
end if
if(peeled_image(ip)%compute_image) then
allocate(cube5d(peeled_image(ip)%n_nu,peeled_image(ip)%n_x,peeled_image(ip)%n_y,peeled_image(ip)%n_view,peeled_image(ip)%n_orig))
call mpi_reduce(peeled_image(ip)%img%i, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img%i = cube5d
call mpi_reduce(peeled_image(ip)%img%q, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img%q = cube5d
call mpi_reduce(peeled_image(ip)%img%u, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img%u = cube5d
call mpi_reduce(peeled_image(ip)%img%v, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img%v = cube5d
if(peeled_image(ip)%uncertainties) then
call mpi_reduce(peeled_image(ip)%img2%i, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img2%i = cube5d
call mpi_reduce(peeled_image(ip)%img2%q, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img2%q = cube5d
call mpi_reduce(peeled_image(ip)%img2%u, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img2%u = cube5d
call mpi_reduce(peeled_image(ip)%img2%v, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%img2%v = cube5d
call mpi_reduce(peeled_image(ip)%imgn, cube5d, size(cube5d), mpi_real8, mpi_sum, rank_main, mpi_comm_world, ierr) ; peeled_image(ip)%imgn = cube5d
end if
deallocate(cube5d)
end if
end do
end if
end subroutine mp_collect_images
end module mpi_routines
| bsd-2-clause |
njwilson23/scipy | scipy/sparse/linalg/eigen/arpack/ARPACK/UTIL/iswap.f | 168 | 1227 | subroutine iswap (n,sx,incx,sy,incy)
c
c interchanges two vectors.
c uses unrolled loops for increments equal to 1.
c jack dongarra, linpack, 3/11/78.
c
integer sx(1),sy(1),stemp
integer i,incx,incy,ix,iy,m,mp1,n
c
if(n.le.0)return
if(incx.eq.1.and.incy.eq.1)go to 20
c
c code for unequal increments or equal increments not equal
c to 1
c
ix = 1
iy = 1
if(incx.lt.0)ix = (-n+1)*incx + 1
if(incy.lt.0)iy = (-n+1)*incy + 1
do 10 i = 1,n
stemp = sx(ix)
sx(ix) = sy(iy)
sy(iy) = stemp
ix = ix + incx
iy = iy + incy
10 continue
return
c
c code for both increments equal to 1
c
c
c clean-up loop
c
20 m = mod(n,3)
if( m .eq. 0 ) go to 40
do 30 i = 1,m
stemp = sx(i)
sx(i) = sy(i)
sy(i) = stemp
30 continue
if( n .lt. 3 ) return
40 mp1 = m + 1
do 50 i = mp1,n,3
stemp = sx(i)
sx(i) = sy(i)
sy(i) = stemp
stemp = sx(i + 1)
sx(i + 1) = sy(i + 1)
sy(i + 1) = stemp
stemp = sx(i + 2)
sx(i + 2) = sy(i + 2)
sy(i + 2) = stemp
50 continue
return
end
| bsd-3-clause |
PPMLibrary/ppm | src/ppm_module_map_part_partial.f | 1 | 3102 | !--*- f90 -*--------------------------------------------------------------
! Module : ppm_module_map_part_partial
!-------------------------------------------------------------------------
! Copyright (c) 2012 CSE Lab (ETH Zurich), MOSAIC Group (ETH Zurich),
! Center for Fluid Dynamics (DTU)
!
!
! This file is part of the Parallel Particle Mesh Library (PPM).
!
! PPM is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License
! as published by the Free Software Foundation, either
! version 3 of the License, or (at your option) any later
! version.
!
! PPM is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! and the GNU Lesser General Public License along with PPM. If not,
! see <http://www.gnu.org/licenses/>.
!
! Parallel Particle Mesh Library (PPM)
! ETH Zurich
! CH-8092 Zurich, Switzerland
!-------------------------------------------------------------------------
!-------------------------------------------------------------------------
! Define types
!-------------------------------------------------------------------------
#define __SINGLE_PRECISION 1
#define __DOUBLE_PRECISION 2
MODULE ppm_module_map_part_partial
!!! This module provides the mapping routines for partial particle
!!! mapping
!----------------------------------------------------------------------
! Work lists
!----------------------------------------------------------------------
INTEGER, DIMENSION(:), POINTER :: ilist1 => NULL()
INTEGER, DIMENSION(:), POINTER :: ilist2 => NULL()
INTEGER, DIMENSION(:), POINTER :: part2proc => NULL()
INTEGER, DIMENSION(:), POINTER :: ineighsubs => NULL()
PRIVATE :: ilist1,ilist2,part2proc,ineighsubs
!----------------------------------------------------------------------
! Define interfaces to ppm_map_part_partial
!----------------------------------------------------------------------
INTERFACE ppm_map_part_partial
MODULE PROCEDURE ppm_map_part_partial_d
MODULE PROCEDURE ppm_map_part_partial_s
END INTERFACE
!----------------------------------------------------------------------
! include the source
!----------------------------------------------------------------------
CONTAINS
#define __KIND __SINGLE_PRECISION
#include "map/ppm_map_part_partial.f"
#undef __KIND
#define __KIND __DOUBLE_PRECISION
#include "map/ppm_map_part_partial.f"
#undef __KIND
END MODULE ppm_module_map_part_partial
| gpl-3.0 |
yaowee/libflame | src/flablas/f2c/ctpmv.f | 11 | 11126 | SUBROUTINE CTPMV ( UPLO, TRANS, DIAG, N, AP, X, INCX )
* .. Scalar Arguments ..
INTEGER INCX, N
CHARACTER*1 DIAG, TRANS, UPLO
* .. Array Arguments ..
COMPLEX AP( * ), X( * )
* ..
*
* Purpose
* =======
*
* CTPMV performs one of the matrix-vector operations
*
* x := A*x, or x := A'*x, or x := conjg( A' )*x,
*
* where x is an n element vector and A is an n by n unit, or non-unit,
* upper or lower triangular matrix, supplied in packed form.
*
* Parameters
* ==========
*
* UPLO - CHARACTER*1.
* On entry, UPLO specifies whether the matrix is an upper or
* lower triangular matrix as follows:
*
* UPLO = 'U' or 'u' A is an upper triangular matrix.
*
* UPLO = 'L' or 'l' A is a lower triangular matrix.
*
* Unchanged on exit.
*
* TRANS - CHARACTER*1.
* On entry, TRANS specifies the operation to be performed as
* follows:
*
* TRANS = 'N' or 'n' x := A*x.
*
* TRANS = 'T' or 't' x := A'*x.
*
* TRANS = 'C' or 'c' x := conjg( A' )*x.
*
* Unchanged on exit.
*
* DIAG - CHARACTER*1.
* On entry, DIAG specifies whether or not A is unit
* triangular as follows:
*
* DIAG = 'U' or 'u' A is assumed to be unit triangular.
*
* DIAG = 'N' or 'n' A is not assumed to be unit
* triangular.
*
* Unchanged on exit.
*
* N - INTEGER.
* On entry, N specifies the order of the matrix A.
* N must be at least zero.
* Unchanged on exit.
*
* AP - COMPLEX array of DIMENSION at least
* ( ( n*( n + 1 ) )/2 ).
* Before entry with UPLO = 'U' or 'u', the array AP must
* contain the upper triangular matrix packed sequentially,
* column by column, so that AP( 1 ) contains a( 1, 1 ),
* AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 )
* respectively, and so on.
* Before entry with UPLO = 'L' or 'l', the array AP must
* contain the lower triangular matrix packed sequentially,
* column by column, so that AP( 1 ) contains a( 1, 1 ),
* AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 )
* respectively, and so on.
* Note that when DIAG = 'U' or 'u', the diagonal elements of
* A are not referenced, but are assumed to be unity.
* Unchanged on exit.
*
* X - COMPLEX array of dimension at least
* ( 1 + ( n - 1 )*abs( INCX ) ).
* Before entry, the incremented array X must contain the n
* element vector x. On exit, X is overwritten with the
* tranformed vector x.
*
* INCX - INTEGER.
* On entry, INCX specifies the increment for the elements of
* X. INCX must not be zero.
* Unchanged on exit.
*
*
* Level 2 Blas routine.
*
* -- Written on 22-October-1986.
* Jack Dongarra, Argonne National Lab.
* Jeremy Du Croz, Nag Central Office.
* Sven Hammarling, Nag Central Office.
* Richard Hanson, Sandia National Labs.
*
*
* .. Parameters ..
COMPLEX ZERO
PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
* .. Local Scalars ..
COMPLEX TEMP
INTEGER I, INFO, IX, J, JX, K, KK, KX
LOGICAL NOCONJ, NOUNIT
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* .. External Subroutines ..
EXTERNAL XERBLA
* .. Intrinsic Functions ..
INTRINSIC CONJG
* ..
* .. Executable Statements ..
*
* Test the input parameters.
*
INFO = 0
IF ( .NOT.LSAME( UPLO , 'U' ).AND.
$ .NOT.LSAME( UPLO , 'L' ) )THEN
INFO = 1
ELSE IF( .NOT.LSAME( TRANS, 'N' ).AND.
$ .NOT.LSAME( TRANS, 'T' ).AND.
$ .NOT.LSAME( TRANS, 'C' ) )THEN
INFO = 2
ELSE IF( .NOT.LSAME( DIAG , 'U' ).AND.
$ .NOT.LSAME( DIAG , 'N' ) )THEN
INFO = 3
ELSE IF( N.LT.0 )THEN
INFO = 4
ELSE IF( INCX.EQ.0 )THEN
INFO = 7
END IF
IF( INFO.NE.0 )THEN
CALL XERBLA( 'CTPMV ', INFO )
RETURN
END IF
*
* Quick return if possible.
*
IF( N.EQ.0 )
$ RETURN
*
NOCONJ = LSAME( TRANS, 'T' )
NOUNIT = LSAME( DIAG , 'N' )
*
* Set up the start point in X if the increment is not unity. This
* will be ( N - 1 )*INCX too small for descending loops.
*
IF( INCX.LE.0 )THEN
KX = 1 - ( N - 1 )*INCX
ELSE IF( INCX.NE.1 )THEN
KX = 1
END IF
*
* Start the operations. In this version the elements of AP are
* accessed sequentially with one pass through AP.
*
IF( LSAME( TRANS, 'N' ) )THEN
*
* Form x:= A*x.
*
IF( LSAME( UPLO, 'U' ) )THEN
KK = 1
IF( INCX.EQ.1 )THEN
DO 20, J = 1, N
IF( X( J ).NE.ZERO )THEN
TEMP = X( J )
K = KK
DO 10, I = 1, J - 1
X( I ) = X( I ) + TEMP*AP( K )
K = K + 1
10 CONTINUE
IF( NOUNIT )
$ X( J ) = X( J )*AP( KK + J - 1 )
END IF
KK = KK + J
20 CONTINUE
ELSE
JX = KX
DO 40, J = 1, N
IF( X( JX ).NE.ZERO )THEN
TEMP = X( JX )
IX = KX
DO 30, K = KK, KK + J - 2
X( IX ) = X( IX ) + TEMP*AP( K )
IX = IX + INCX
30 CONTINUE
IF( NOUNIT )
$ X( JX ) = X( JX )*AP( KK + J - 1 )
END IF
JX = JX + INCX
KK = KK + J
40 CONTINUE
END IF
ELSE
KK = ( N*( N + 1 ) )/2
IF( INCX.EQ.1 )THEN
DO 60, J = N, 1, -1
IF( X( J ).NE.ZERO )THEN
TEMP = X( J )
K = KK
DO 50, I = N, J + 1, -1
X( I ) = X( I ) + TEMP*AP( K )
K = K - 1
50 CONTINUE
IF( NOUNIT )
$ X( J ) = X( J )*AP( KK - N + J )
END IF
KK = KK - ( N - J + 1 )
60 CONTINUE
ELSE
KX = KX + ( N - 1 )*INCX
JX = KX
DO 80, J = N, 1, -1
IF( X( JX ).NE.ZERO )THEN
TEMP = X( JX )
IX = KX
DO 70, K = KK, KK - ( N - ( J + 1 ) ), -1
X( IX ) = X( IX ) + TEMP*AP( K )
IX = IX - INCX
70 CONTINUE
IF( NOUNIT )
$ X( JX ) = X( JX )*AP( KK - N + J )
END IF
JX = JX - INCX
KK = KK - ( N - J + 1 )
80 CONTINUE
END IF
END IF
ELSE
*
* Form x := A'*x or x := conjg( A' )*x.
*
IF( LSAME( UPLO, 'U' ) )THEN
KK = ( N*( N + 1 ) )/2
IF( INCX.EQ.1 )THEN
DO 110, J = N, 1, -1
TEMP = X( J )
K = KK - 1
IF( NOCONJ )THEN
IF( NOUNIT )
$ TEMP = TEMP*AP( KK )
DO 90, I = J - 1, 1, -1
TEMP = TEMP + AP( K )*X( I )
K = K - 1
90 CONTINUE
ELSE
IF( NOUNIT )
$ TEMP = TEMP*CONJG( AP( KK ) )
DO 100, I = J - 1, 1, -1
TEMP = TEMP + CONJG( AP( K ) )*X( I )
K = K - 1
100 CONTINUE
END IF
X( J ) = TEMP
KK = KK - J
110 CONTINUE
ELSE
JX = KX + ( N - 1 )*INCX
DO 140, J = N, 1, -1
TEMP = X( JX )
IX = JX
IF( NOCONJ )THEN
IF( NOUNIT )
$ TEMP = TEMP*AP( KK )
DO 120, K = KK - 1, KK - J + 1, -1
IX = IX - INCX
TEMP = TEMP + AP( K )*X( IX )
120 CONTINUE
ELSE
IF( NOUNIT )
$ TEMP = TEMP*CONJG( AP( KK ) )
DO 130, K = KK - 1, KK - J + 1, -1
IX = IX - INCX
TEMP = TEMP + CONJG( AP( K ) )*X( IX )
130 CONTINUE
END IF
X( JX ) = TEMP
JX = JX - INCX
KK = KK - J
140 CONTINUE
END IF
ELSE
KK = 1
IF( INCX.EQ.1 )THEN
DO 170, J = 1, N
TEMP = X( J )
K = KK + 1
IF( NOCONJ )THEN
IF( NOUNIT )
$ TEMP = TEMP*AP( KK )
DO 150, I = J + 1, N
TEMP = TEMP + AP( K )*X( I )
K = K + 1
150 CONTINUE
ELSE
IF( NOUNIT )
$ TEMP = TEMP*CONJG( AP( KK ) )
DO 160, I = J + 1, N
TEMP = TEMP + CONJG( AP( K ) )*X( I )
K = K + 1
160 CONTINUE
END IF
X( J ) = TEMP
KK = KK + ( N - J + 1 )
170 CONTINUE
ELSE
JX = KX
DO 200, J = 1, N
TEMP = X( JX )
IX = JX
IF( NOCONJ )THEN
IF( NOUNIT )
$ TEMP = TEMP*AP( KK )
DO 180, K = KK + 1, KK + N - J
IX = IX + INCX
TEMP = TEMP + AP( K )*X( IX )
180 CONTINUE
ELSE
IF( NOUNIT )
$ TEMP = TEMP*CONJG( AP( KK ) )
DO 190, K = KK + 1, KK + N - J
IX = IX + INCX
TEMP = TEMP + CONJG( AP( K ) )*X( IX )
190 CONTINUE
END IF
X( JX ) = TEMP
JX = JX + INCX
KK = KK + ( N - J + 1 )
200 CONTINUE
END IF
END IF
END IF
*
RETURN
*
* End of CTPMV .
*
END
| bsd-3-clause |
lesserwhirls/scipy-cwt | scipy/integrate/quadpack/dqawce.f | 143 | 12260 | subroutine dqawce(f,a,b,c,epsabs,epsrel,limit,result,abserr,neval,
* ier,alist,blist,rlist,elist,iord,last)
c***begin prologue dqawce
c***date written 800101 (yymmdd)
c***revision date 830518 (yymmdd)
c***category no. h2a2a1,j4
c***keywords automatic integrator, special-purpose,
c cauchy principal value, clenshaw-curtis method
c***author piessens,robert,appl. math. & progr. div. - k.u.leuven
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
c*** purpose the routine calculates an approximation result to a
c cauchy principal value i = integral of f*w over (a,b)
c (w(x) = 1/(x-c), (c.ne.a, c.ne.b), hopefully satisfying
c following claim for accuracy
c abs(i-result).le.max(epsabs,epsrel*abs(i))
c***description
c
c computation of a cauchy principal value
c standard fortran subroutine
c double precision version
c
c parameters
c on entry
c f - double precision
c function subprogram defining the integrand
c function f(x). the actual name for f needs to be
c declared e x t e r n a l in the driver program.
c
c a - double precision
c lower limit of integration
c
c b - double precision
c upper limit of integration
c
c c - double precision
c parameter in the weight function, c.ne.a, c.ne.b
c if c = a or c = b, the routine will end with
c ier = 6.
c
c epsabs - double precision
c absolute accuracy requested
c epsrel - double precision
c relative accuracy requested
c if epsabs.le.0
c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
c the routine will end with ier = 6.
c
c limit - integer
c gives an upper bound on the number of subintervals
c in the partition of (a,b), limit.ge.1
c
c on return
c result - double precision
c approximation to the integral
c
c abserr - double precision
c estimate of the modulus of the absolute error,
c which should equal or exceed abs(i-result)
c
c neval - integer
c number of integrand evaluations
c
c ier - integer
c ier = 0 normal and reliable termination of the
c routine. it is assumed that the requested
c accuracy has been achieved.
c ier.gt.0 abnormal termination of the routine
c the estimates for integral and error are
c less reliable. it is assumed that the
c requested accuracy has not been achieved.
c error messages
c ier = 1 maximum number of subdivisions allowed
c has been achieved. one can allow more sub-
c divisions by increasing the value of
c limit. however, if this yields no
c improvement it is advised to analyze the
c the integrand, in order to determine the
c the integration difficulties. if the
c position of a local difficulty can be
c determined (e.g. singularity,
c discontinuity within the interval) one
c will probably gain from splitting up the
c interval at this point and calling
c appropriate integrators on the subranges.
c = 2 the occurrence of roundoff error is detec-
c ted, which prevents the requested
c tolerance from being achieved.
c = 3 extremely bad integrand behaviour
c occurs at some interior points of
c the integration interval.
c = 6 the input is invalid, because
c c = a or c = b or
c (epsabs.le.0 and
c epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
c or limit.lt.1.
c result, abserr, neval, rlist(1), elist(1),
c iord(1) and last are set to zero. alist(1)
c and blist(1) are set to a and b
c respectively.
c
c alist - double precision
c vector of dimension at least limit, the first
c last elements of which are the left
c end points of the subintervals in the partition
c of the given integration range (a,b)
c
c blist - double precision
c vector of dimension at least limit, the first
c last elements of which are the right
c end points of the subintervals in the partition
c of the given integration range (a,b)
c
c rlist - double precision
c vector of dimension at least limit, the first
c last elements of which are the integral
c approximations on the subintervals
c
c elist - double precision
c vector of dimension limit, the first last
c elements of which are the moduli of the absolute
c error estimates on the subintervals
c
c iord - integer
c vector of dimension at least limit, the first k
c elements of which are pointers to the error
c estimates over the subintervals, so that
c elist(iord(1)), ..., elist(iord(k)) with k = last
c if last.le.(limit/2+2), and k = limit+1-last
c otherwise, form a decreasing sequence
c
c last - integer
c number of subintervals actually produced in
c the subdivision process
c
c***references (none)
c***routines called d1mach,dqc25c,dqpsrt
c***end prologue dqawce
c
double precision a,aa,abserr,alist,area,area1,area12,area2,a1,a2,
* b,bb,blist,b1,b2,c,dabs,dmax1,d1mach,elist,epmach,epsabs,epsrel,
* errbnd,errmax,error1,erro12,error2,errsum,f,result,rlist,uflow
integer ier,iord,iroff1,iroff2,k,krule,last,limit,maxerr,nev,
* neval,nrmax
c
dimension alist(limit),blist(limit),rlist(limit),elist(limit),
* iord(limit)
c
external f
c
c list of major variables
c -----------------------
c
c alist - list of left end points of all subintervals
c considered up to now
c blist - list of right end points of all subintervals
c considered up to now
c rlist(i) - approximation to the integral over
c (alist(i),blist(i))
c elist(i) - error estimate applying to rlist(i)
c maxerr - pointer to the interval with largest
c error estimate
c errmax - elist(maxerr)
c area - sum of the integrals over the subintervals
c errsum - sum of the errors over the subintervals
c errbnd - requested accuracy max(epsabs,epsrel*
c abs(result))
c *****1 - variable for the left subinterval
c *****2 - variable for the right subinterval
c last - index for subdivision
c
c
c machine dependent constants
c ---------------------------
c
c epmach is the largest relative spacing.
c uflow is the smallest positive magnitude.
c
c***first executable statement dqawce
epmach = d1mach(4)
uflow = d1mach(1)
c
c
c test on validity of parameters
c ------------------------------
c
ier = 6
neval = 0
last = 0
alist(1) = a
blist(1) = b
rlist(1) = 0.0d+00
elist(1) = 0.0d+00
iord(1) = 0
result = 0.0d+00
abserr = 0.0d+00
if(c.eq.a.or.c.eq.b.or.(epsabs.le.0.0d+00.and
* .epsrel.lt.dmax1(0.5d+02*epmach,0.5d-28))) go to 999
c
c first approximation to the integral
c -----------------------------------
c
aa=a
bb=b
if (a.le.b) go to 10
aa=b
bb=a
10 ier=0
krule = 1
call dqc25c(f,aa,bb,c,result,abserr,krule,neval)
last = 1
rlist(1) = result
elist(1) = abserr
iord(1) = 1
alist(1) = a
blist(1) = b
c
c test on accuracy
c
errbnd = dmax1(epsabs,epsrel*dabs(result))
if(limit.eq.1) ier = 1
if(abserr.lt.dmin1(0.1d-01*dabs(result),errbnd)
* .or.ier.eq.1) go to 70
c
c initialization
c --------------
c
alist(1) = aa
blist(1) = bb
rlist(1) = result
errmax = abserr
maxerr = 1
area = result
errsum = abserr
nrmax = 1
iroff1 = 0
iroff2 = 0
c
c main do-loop
c ------------
c
do 40 last = 2,limit
c
c bisect the subinterval with nrmax-th largest
c error estimate.
c
a1 = alist(maxerr)
b1 = 0.5d+00*(alist(maxerr)+blist(maxerr))
b2 = blist(maxerr)
if(c.le.b1.and.c.gt.a1) b1 = 0.5d+00*(c+b2)
if(c.gt.b1.and.c.lt.b2) b1 = 0.5d+00*(a1+c)
a2 = b1
krule = 2
call dqc25c(f,a1,b1,c,area1,error1,krule,nev)
neval = neval+nev
call dqc25c(f,a2,b2,c,area2,error2,krule,nev)
neval = neval+nev
c
c improve previous approximations to integral
c and error and test for accuracy.
c
area12 = area1+area2
erro12 = error1+error2
errsum = errsum+erro12-errmax
area = area+area12-rlist(maxerr)
if(dabs(rlist(maxerr)-area12).lt.0.1d-04*dabs(area12)
* .and.erro12.ge.0.99d+00*errmax.and.krule.eq.0)
* iroff1 = iroff1+1
if(last.gt.10.and.erro12.gt.errmax.and.krule.eq.0)
* iroff2 = iroff2+1
rlist(maxerr) = area1
rlist(last) = area2
errbnd = dmax1(epsabs,epsrel*dabs(area))
if(errsum.le.errbnd) go to 15
c
c test for roundoff error and eventually set error flag.
c
if(iroff1.ge.6.and.iroff2.gt.20) ier = 2
c
c set error flag in the case that number of interval
c bisections exceeds limit.
c
if(last.eq.limit) ier = 1
c
c set error flag in the case of bad integrand behaviour
c at a point of the integration range.
c
if(dmax1(dabs(a1),dabs(b2)).le.(0.1d+01+0.1d+03*epmach)
* *(dabs(a2)+0.1d+04*uflow)) ier = 3
c
c append the newly-created intervals to the list.
c
15 if(error2.gt.error1) go to 20
alist(last) = a2
blist(maxerr) = b1
blist(last) = b2
elist(maxerr) = error1
elist(last) = error2
go to 30
20 alist(maxerr) = a2
alist(last) = a1
blist(last) = b1
rlist(maxerr) = area2
rlist(last) = area1
elist(maxerr) = error2
elist(last) = error1
c
c call subroutine dqpsrt to maintain the descending ordering
c in the list of error estimates and select the subinterval
c with nrmax-th largest error estimate (to be bisected next).
c
30 call dqpsrt(limit,last,maxerr,errmax,elist,iord,nrmax)
c ***jump out of do-loop
if(ier.ne.0.or.errsum.le.errbnd) go to 50
40 continue
c
c compute final result.
c ---------------------
c
50 result = 0.0d+00
do 60 k=1,last
result = result+rlist(k)
60 continue
abserr = errsum
70 if (aa.eq.b) result=-result
999 return
end
| bsd-3-clause |
lesserwhirls/scipy-cwt | scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/ssortr.f | 162 | 5308 | c-----------------------------------------------------------------------
c\BeginDoc
c
c\Name: ssortr
c
c\Description:
c Sort the array X1 in the order specified by WHICH and optionally
c applies the permutation to the array X2.
c
c\Usage:
c call ssortr
c ( WHICH, APPLY, N, X1, X2 )
c
c\Arguments
c WHICH Character*2. (Input)
c 'LM' -> X1 is sorted into increasing order of magnitude.
c 'SM' -> X1 is sorted into decreasing order of magnitude.
c 'LA' -> X1 is sorted into increasing order of algebraic.
c 'SA' -> X1 is sorted into decreasing order of algebraic.
c
c APPLY Logical. (Input)
c APPLY = .TRUE. -> apply the sorted order to X2.
c APPLY = .FALSE. -> do not apply the sorted order to X2.
c
c N Integer. (INPUT)
c Size of the arrays.
c
c X1 Real array of length N. (INPUT/OUTPUT)
c The array to be sorted.
c
c X2 Real array of length N. (INPUT/OUTPUT)
c Only referenced if APPLY = .TRUE.
c
c\EndDoc
c
c-----------------------------------------------------------------------
c
c\BeginLib
c
c\Author
c Danny Sorensen Phuong Vu
c Richard Lehoucq CRPC / Rice University
c Dept. of Computational & Houston, Texas
c Applied Mathematics
c Rice University
c Houston, Texas
c
c\Revision history:
c 12/16/93: Version ' 2.1'.
c Adapted from the sort routine in LANSO.
c
c\SCCS Information: @(#)
c FILE: sortr.F SID: 2.3 DATE OF SID: 4/19/96 RELEASE: 2
c
c\EndLib
c
c-----------------------------------------------------------------------
c
subroutine ssortr (which, apply, n, x1, x2)
c
c %------------------%
c | Scalar Arguments |
c %------------------%
c
character*2 which
logical apply
integer n
c
c %-----------------%
c | Array Arguments |
c %-----------------%
c
Real
& x1(0:n-1), x2(0:n-1)
c
c %---------------%
c | Local Scalars |
c %---------------%
c
integer i, igap, j
Real
& temp
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
igap = n / 2
c
if (which .eq. 'SA') then
c
c X1 is sorted into decreasing order of algebraic.
c
10 continue
if (igap .eq. 0) go to 9000
do 30 i = igap, n-1
j = i-igap
20 continue
c
if (j.lt.0) go to 30
c
if (x1(j).lt.x1(j+igap)) then
temp = x1(j)
x1(j) = x1(j+igap)
x1(j+igap) = temp
if (apply) then
temp = x2(j)
x2(j) = x2(j+igap)
x2(j+igap) = temp
end if
else
go to 30
endif
j = j-igap
go to 20
30 continue
igap = igap / 2
go to 10
c
else if (which .eq. 'SM') then
c
c X1 is sorted into decreasing order of magnitude.
c
40 continue
if (igap .eq. 0) go to 9000
do 60 i = igap, n-1
j = i-igap
50 continue
c
if (j.lt.0) go to 60
c
if (abs(x1(j)).lt.abs(x1(j+igap))) then
temp = x1(j)
x1(j) = x1(j+igap)
x1(j+igap) = temp
if (apply) then
temp = x2(j)
x2(j) = x2(j+igap)
x2(j+igap) = temp
end if
else
go to 60
endif
j = j-igap
go to 50
60 continue
igap = igap / 2
go to 40
c
else if (which .eq. 'LA') then
c
c X1 is sorted into increasing order of algebraic.
c
70 continue
if (igap .eq. 0) go to 9000
do 90 i = igap, n-1
j = i-igap
80 continue
c
if (j.lt.0) go to 90
c
if (x1(j).gt.x1(j+igap)) then
temp = x1(j)
x1(j) = x1(j+igap)
x1(j+igap) = temp
if (apply) then
temp = x2(j)
x2(j) = x2(j+igap)
x2(j+igap) = temp
end if
else
go to 90
endif
j = j-igap
go to 80
90 continue
igap = igap / 2
go to 70
c
else if (which .eq. 'LM') then
c
c X1 is sorted into increasing order of magnitude.
c
100 continue
if (igap .eq. 0) go to 9000
do 120 i = igap, n-1
j = i-igap
110 continue
c
if (j.lt.0) go to 120
c
if (abs(x1(j)).gt.abs(x1(j+igap))) then
temp = x1(j)
x1(j) = x1(j+igap)
x1(j+igap) = temp
if (apply) then
temp = x2(j)
x2(j) = x2(j+igap)
x2(j+igap) = temp
end if
else
go to 120
endif
j = j-igap
go to 110
120 continue
igap = igap / 2
go to 100
end if
c
9000 continue
return
c
c %---------------%
c | End of ssortr |
c %---------------%
c
end
| bsd-3-clause |
ericmckean/nacl-llvm-branches.llvm-gcc-trunk | libgfortran/generated/_asinh_r8.F90 | 11 | 1732 | ! Copyright 2002 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran is free software; you can redistribute it and/or
!modify it under the terms of the GNU General Public
!License as published by the Free Software Foundation; either
!version 2 of the License, or (at your option) any later version.
!In addition to the permissions in the GNU General Public License, the
!Free Software Foundation gives you unlimited permission to link the
!compiled version of this file into combinations with other programs,
!and to distribute those combinations without any restriction coming
!from the use of this file. (The General Public License restrictions
!do apply in other respects; for example, they cover modification of
!the file, and distribution when not linked into a combine
!executable.)
!
!GNU libgfortran is distributed in the hope that it will be useful,
!but WITHOUT ANY WARRANTY; without even the implied warranty of
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!GNU General Public License for more details.
!
!You should have received a copy of the GNU General Public
!License along with libgfortran; see the file COPYING. If not,
!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
!Boston, MA 02110-1301, USA.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_8)
#ifdef HAVE_ASINH
elemental function specific__asinh_r8 (parm)
real (kind=8), intent (in) :: parm
real (kind=8) :: specific__asinh_r8
specific__asinh_r8 = asinh (parm)
end function
#endif
#endif
| gpl-2.0 |
yaowee/libflame | lapack-test/3.5.0/EIG/ilaenv.f | 31 | 10260 | *> \brief \b ILAENV
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* INTEGER FUNCTION ILAENV( ISPEC, NAME, OPTS, N1, N2, N3,
* N4 )
*
* .. Scalar Arguments ..
* CHARACTER*( * ) NAME, OPTS
* INTEGER ISPEC, N1, N2, N3, N4
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ILAENV returns problem-dependent parameters for the local
*> environment. See ISPEC for a description of the parameters.
*>
*> In this version, the problem-dependent parameters are contained in
*> the integer array IPARMS in the common block CLAENV and the value
*> with index ISPEC is copied to ILAENV. This version of ILAENV is
*> to be used in conjunction with XLAENV in TESTING and TIMING.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] ISPEC
*> \verbatim
*> ISPEC is INTEGER
*> Specifies the parameter to be returned as the value of
*> ILAENV.
*> = 1: the optimal blocksize; if this value is 1, an unblocked
*> algorithm will give the best performance.
*> = 2: the minimum block size for which the block routine
*> should be used; if the usable block size is less than
*> this value, an unblocked routine should be used.
*> = 3: the crossover point (in a block routine, for N less
*> than this value, an unblocked routine should be used)
*> = 4: the number of shifts, used in the nonsymmetric
*> eigenvalue routines
*> = 5: the minimum column dimension for blocking to be used;
*> rectangular blocks must have dimension at least k by m,
*> where k is given by ILAENV(2,...) and m by ILAENV(5,...)
*> = 6: the crossover point for the SVD (when reducing an m by n
*> matrix to bidiagonal form, if max(m,n)/min(m,n) exceeds
*> this value, a QR factorization is used first to reduce
*> the matrix to a triangular form.)
*> = 7: the number of processors
*> = 8: the crossover point for the multishift QR and QZ methods
*> for nonsymmetric eigenvalue problems.
*> = 9: maximum size of the subproblems at the bottom of the
*> computation tree in the divide-and-conquer algorithm
*> =10: ieee NaN arithmetic can be trusted not to trap
*> =11: infinity arithmetic can be trusted not to trap
*> 12 <= ISPEC <= 16:
*> xHSEQR or one of its subroutines,
*> see IPARMQ for detailed explanation
*>
*> Other specifications (up to 100) can be added later.
*> \endverbatim
*>
*> \param[in] NAME
*> \verbatim
*> NAME is CHARACTER*(*)
*> The name of the calling subroutine.
*> \endverbatim
*>
*> \param[in] OPTS
*> \verbatim
*> OPTS is CHARACTER*(*)
*> The character options to the subroutine NAME, concatenated
*> into a single character string. For example, UPLO = 'U',
*> TRANS = 'T', and DIAG = 'N' for a triangular routine would
*> be specified as OPTS = 'UTN'.
*> \endverbatim
*>
*> \param[in] N1
*> \verbatim
*> N1 is INTEGER
*> \endverbatim
*>
*> \param[in] N2
*> \verbatim
*> N2 is INTEGER
*> \endverbatim
*>
*> \param[in] N3
*> \verbatim
*> N3 is INTEGER
*> \endverbatim
*>
*> \param[in] N4
*> \verbatim
*> N4 is INTEGER
*>
*> Problem dimensions for the subroutine NAME; these may not all
*> be required.
*> \endverbatim
*>
*> \result ILAENV
*> \verbatim
*> ILAENV is INTEGER
*> >= 0: the value of the parameter specified by ISPEC
*> < 0: if ILAENV = -k, the k-th argument had an illegal value.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup aux_eig
*
*> \par Further Details:
* =====================
*>
*> \verbatim
*>
*> The following conventions have been used when calling ILAENV from the
*> LAPACK routines:
*> 1) OPTS is a concatenation of all of the character options to
*> subroutine NAME, in the same order that they appear in the
*> argument list for NAME, even if they are not used in determining
*> the value of the parameter specified by ISPEC.
*> 2) The problem dimensions N1, N2, N3, N4 are specified in the order
*> that they appear in the argument list for NAME. N1 is used
*> first, N2 second, and so on, and unused problem dimensions are
*> passed a value of -1.
*> 3) The parameter value returned by ILAENV is checked for validity in
*> the calling subroutine. For example, ILAENV is used to retrieve
*> the optimal blocksize for STRTRI as follows:
*>
*> NB = ILAENV( 1, 'STRTRI', UPLO // DIAG, N, -1, -1, -1 )
*> IF( NB.LE.1 ) NB = MAX( 1, N )
*> \endverbatim
*>
* =====================================================================
INTEGER FUNCTION ILAENV( ISPEC, NAME, OPTS, N1, N2, N3,
$ N4 )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*( * ) NAME, OPTS
INTEGER ISPEC, N1, N2, N3, N4
* ..
*
* =====================================================================
*
* .. Intrinsic Functions ..
INTRINSIC INT, MIN, REAL
* ..
* .. External Functions ..
INTEGER IEEECK
EXTERNAL IEEECK
* ..
* .. Arrays in Common ..
INTEGER IPARMS( 100 )
* ..
* .. Common blocks ..
COMMON / CLAENV / IPARMS
* ..
* .. Save statement ..
SAVE / CLAENV /
* ..
* .. Executable Statements ..
*
IF( ISPEC.GE.1 .AND. ISPEC.LE.5 ) THEN
*
* Return a value from the common block.
*
ILAENV = IPARMS( ISPEC )
*
ELSE IF( ISPEC.EQ.6 ) THEN
*
* Compute SVD crossover point.
*
ILAENV = INT( REAL( MIN( N1, N2 ) )*1.6E0 )
*
ELSE IF( ISPEC.GE.7 .AND. ISPEC.LE.9 ) THEN
*
* Return a value from the common block.
*
ILAENV = IPARMS( ISPEC )
*
ELSE IF( ISPEC.EQ.10 ) THEN
*
* IEEE NaN arithmetic can be trusted not to trap
*
C ILAENV = 0
ILAENV = 1
IF( ILAENV.EQ.1 ) THEN
ILAENV = IEEECK( 1, 0.0, 1.0 )
END IF
*
ELSE IF( ISPEC.EQ.11 ) THEN
*
* Infinity arithmetic can be trusted not to trap
*
C ILAENV = 0
ILAENV = 1
IF( ILAENV.EQ.1 ) THEN
ILAENV = IEEECK( 0, 0.0, 1.0 )
END IF
*
ELSE IF(( ISPEC.GE.12 ) .AND. (ISPEC.LE.16)) THEN
*
* 12 <= ISPEC <= 16: xHSEQR or one of its subroutines.
*
ILAENV = IPARMS( ISPEC )
* WRITE(*,*) 'ISPEC = ',ISPEC,' ILAENV =',ILAENV
* ILAENV = IPARMQ( ISPEC, NAME, OPTS, N1, N2, N3, N4 )
*
ELSE
*
* Invalid value for ISPEC
*
ILAENV = -1
END IF
*
RETURN
*
* End of ILAENV
*
END
INTEGER FUNCTION IPARMQ( ISPEC, NAME, OPTS, N, ILO, IHI, LWORK )
*
INTEGER INMIN, INWIN, INIBL, ISHFTS, IACC22
PARAMETER ( INMIN = 12, INWIN = 13, INIBL = 14,
$ ISHFTS = 15, IACC22 = 16 )
INTEGER NMIN, K22MIN, KACMIN, NIBBLE, KNWSWP
PARAMETER ( NMIN = 11, K22MIN = 14, KACMIN = 14,
$ NIBBLE = 14, KNWSWP = 500 )
REAL TWO
PARAMETER ( TWO = 2.0 )
* ..
* .. Scalar Arguments ..
INTEGER IHI, ILO, ISPEC, LWORK, N
CHARACTER NAME*( * ), OPTS*( * )
* ..
* .. Local Scalars ..
INTEGER NH, NS
* ..
* .. Intrinsic Functions ..
INTRINSIC LOG, MAX, MOD, NINT, REAL
* ..
* .. Executable Statements ..
IF( ( ISPEC.EQ.ISHFTS ) .OR. ( ISPEC.EQ.INWIN ) .OR.
$ ( ISPEC.EQ.IACC22 ) ) THEN
*
* ==== Set the number simultaneous shifts ====
*
NH = IHI - ILO + 1
NS = 2
IF( NH.GE.30 )
$ NS = 4
IF( NH.GE.60 )
$ NS = 10
IF( NH.GE.150 )
$ NS = MAX( 10, NH / NINT( LOG( REAL( NH ) ) / LOG( TWO ) ) )
IF( NH.GE.590 )
$ NS = 64
IF( NH.GE.3000 )
$ NS = 128
IF( NH.GE.6000 )
$ NS = 256
NS = MAX( 2, NS-MOD( NS, 2 ) )
END IF
*
IF( ISPEC.EQ.INMIN ) THEN
*
*
* ===== Matrices of order smaller than NMIN get sent
* . to LAHQR, the classic double shift algorithm.
* . This must be at least 11. ====
*
IPARMQ = NMIN
*
ELSE IF( ISPEC.EQ.INIBL ) THEN
*
* ==== INIBL: skip a multi-shift qr iteration and
* . whenever aggressive early deflation finds
* . at least (NIBBLE*(window size)/100) deflations. ====
*
IPARMQ = NIBBLE
*
ELSE IF( ISPEC.EQ.ISHFTS ) THEN
*
* ==== NSHFTS: The number of simultaneous shifts =====
*
IPARMQ = NS
*
ELSE IF( ISPEC.EQ.INWIN ) THEN
*
* ==== NW: deflation window size. ====
*
IF( NH.LE.KNWSWP ) THEN
IPARMQ = NS
ELSE
IPARMQ = 3*NS / 2
END IF
*
ELSE IF( ISPEC.EQ.IACC22 ) THEN
*
* ==== IACC22: Whether to accumulate reflections
* . before updating the far-from-diagonal elements
* . and whether to use 2-by-2 block structure while
* . doing it. A small amount of work could be saved
* . by making this choice dependent also upon the
* . NH=IHI-ILO+1.
*
IPARMQ = 0
IF( NS.GE.KACMIN )
$ IPARMQ = 1
IF( NS.GE.K22MIN )
$ IPARMQ = 2
*
ELSE
* ===== invalid value of ispec =====
IPARMQ = -1
*
END IF
*
* ==== End of IPARMQ ====
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/schksp.f | 32 | 17764 | *> \brief \b SCHKSP
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
* NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
* IWORK, NOUT )
*
* .. Scalar Arguments ..
* LOGICAL TSTERR
* INTEGER NMAX, NN, NNS, NOUT
* REAL THRESH
* ..
* .. Array Arguments ..
* LOGICAL DOTYPE( * )
* INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
* REAL A( * ), AFAC( * ), AINV( * ), B( * ),
* $ RWORK( * ), WORK( * ), X( * ), XACT( * )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SCHKSP tests SSPTRF, -TRI, -TRS, -RFS, and -CON
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] DOTYPE
*> \verbatim
*> DOTYPE is LOGICAL array, dimension (NTYPES)
*> The matrix types to be used for testing. Matrices of type j
*> (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) =
*> .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used.
*> \endverbatim
*>
*> \param[in] NN
*> \verbatim
*> NN is INTEGER
*> The number of values of N contained in the vector NVAL.
*> \endverbatim
*>
*> \param[in] NVAL
*> \verbatim
*> NVAL is INTEGER array, dimension (NN)
*> The values of the matrix dimension N.
*> \endverbatim
*>
*> \param[in] NNS
*> \verbatim
*> NNS is INTEGER
*> The number of values of NRHS contained in the vector NSVAL.
*> \endverbatim
*>
*> \param[in] NSVAL
*> \verbatim
*> NSVAL is INTEGER array, dimension (NNS)
*> The values of the number of right hand sides NRHS.
*> \endverbatim
*>
*> \param[in] THRESH
*> \verbatim
*> THRESH is REAL
*> The threshold value for the test ratios. A result is
*> included in the output file if RESULT >= THRESH. To have
*> every test ratio printed, use THRESH = 0.
*> \endverbatim
*>
*> \param[in] TSTERR
*> \verbatim
*> TSTERR is LOGICAL
*> Flag that indicates whether error exits are to be tested.
*> \endverbatim
*>
*> \param[in] NMAX
*> \verbatim
*> NMAX is INTEGER
*> The maximum value permitted for N, used in dimensioning the
*> work arrays.
*> \endverbatim
*>
*> \param[out] A
*> \verbatim
*> A is REAL array, dimension
*> (NMAX*(NMAX+1)/2)
*> \endverbatim
*>
*> \param[out] AFAC
*> \verbatim
*> AFAC is REAL array, dimension
*> (NMAX*(NMAX+1)/2)
*> \endverbatim
*>
*> \param[out] AINV
*> \verbatim
*> AINV is REAL array, dimension
*> (NMAX*(NMAX+1)/2)
*> \endverbatim
*>
*> \param[out] B
*> \verbatim
*> B is REAL array, dimension (NMAX*NSMAX)
*> where NSMAX is the largest entry in NSVAL.
*> \endverbatim
*>
*> \param[out] X
*> \verbatim
*> X is REAL array, dimension (NMAX*NSMAX)
*> \endverbatim
*>
*> \param[out] XACT
*> \verbatim
*> XACT is REAL array, dimension (NMAX*NSMAX)
*> \endverbatim
*>
*> \param[out] WORK
*> \verbatim
*> WORK is REAL array, dimension
*> (NMAX*max(2,NSMAX))
*> \endverbatim
*>
*> \param[out] RWORK
*> \verbatim
*> RWORK is REAL array,
*> dimension (NMAX+2*NSMAX)
*> \endverbatim
*>
*> \param[out] IWORK
*> \verbatim
*> IWORK is INTEGER array, dimension (2*NMAX)
*> \endverbatim
*>
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_lin
*
* =====================================================================
SUBROUTINE SCHKSP( DOTYPE, NN, NVAL, NNS, NSVAL, THRESH, TSTERR,
$ NMAX, A, AFAC, AINV, B, X, XACT, WORK, RWORK,
$ IWORK, NOUT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
LOGICAL TSTERR
INTEGER NMAX, NN, NNS, NOUT
REAL THRESH
* ..
* .. Array Arguments ..
LOGICAL DOTYPE( * )
INTEGER IWORK( * ), NSVAL( * ), NVAL( * )
REAL A( * ), AFAC( * ), AINV( * ), B( * ),
$ RWORK( * ), WORK( * ), X( * ), XACT( * )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO
PARAMETER ( ZERO = 0.0E+0 )
INTEGER NTYPES
PARAMETER ( NTYPES = 10 )
INTEGER NTESTS
PARAMETER ( NTESTS = 8 )
* ..
* .. Local Scalars ..
LOGICAL TRFCON, ZEROT
CHARACTER DIST, PACKIT, TYPE, UPLO, XTYPE
CHARACTER*3 PATH
INTEGER I, I1, I2, IMAT, IN, INFO, IOFF, IRHS, IUPLO,
$ IZERO, J, K, KL, KU, LDA, MODE, N, NERRS,
$ NFAIL, NIMAT, NPP, NRHS, NRUN, NT
REAL ANORM, CNDNUM, RCOND, RCONDC
* ..
* .. Local Arrays ..
CHARACTER UPLOS( 2 )
INTEGER ISEED( 4 ), ISEEDY( 4 )
REAL RESULT( NTESTS )
* ..
* .. External Functions ..
LOGICAL LSAME
REAL SGET06, SLANSP
EXTERNAL LSAME, SGET06, SLANSP
* ..
* .. External Subroutines ..
EXTERNAL ALAERH, ALAHD, ALASUM, SCOPY, SERRSY, SGET04,
$ SLACPY, SLARHS, SLATB4, SLATMS, SPPT02, SPPT03,
$ SPPT05, SSPCON, SSPRFS, SSPT01, SSPTRF, SSPTRI,
$ SSPTRS
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, MIN
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NUNIT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NUNIT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Data statements ..
DATA ISEEDY / 1988, 1989, 1990, 1991 /
DATA UPLOS / 'U', 'L' /
* ..
* .. Executable Statements ..
*
* Initialize constants and the random number seed.
*
PATH( 1: 1 ) = 'Single precision'
PATH( 2: 3 ) = 'SP'
NRUN = 0
NFAIL = 0
NERRS = 0
DO 10 I = 1, 4
ISEED( I ) = ISEEDY( I )
10 CONTINUE
*
* Test the error exits
*
IF( TSTERR )
$ CALL SERRSY( PATH, NOUT )
INFOT = 0
*
* Do for each value of N in NVAL
*
DO 170 IN = 1, NN
N = NVAL( IN )
LDA = MAX( N, 1 )
XTYPE = 'N'
NIMAT = NTYPES
IF( N.LE.0 )
$ NIMAT = 1
*
IZERO = 0
DO 160 IMAT = 1, NIMAT
*
* Do the tests only if DOTYPE( IMAT ) is true.
*
IF( .NOT.DOTYPE( IMAT ) )
$ GO TO 160
*
* Skip types 3, 4, 5, or 6 if the matrix size is too small.
*
ZEROT = IMAT.GE.3 .AND. IMAT.LE.6
IF( ZEROT .AND. N.LT.IMAT-2 )
$ GO TO 160
*
* Do first for UPLO = 'U', then for UPLO = 'L'
*
DO 150 IUPLO = 1, 2
UPLO = UPLOS( IUPLO )
IF( LSAME( UPLO, 'U' ) ) THEN
PACKIT = 'C'
ELSE
PACKIT = 'R'
END IF
*
* Set up parameters with SLATB4 and generate a test matrix
* with SLATMS.
*
CALL SLATB4( PATH, IMAT, N, N, TYPE, KL, KU, ANORM, MODE,
$ CNDNUM, DIST )
*
SRNAMT = 'SLATMS'
CALL SLATMS( N, N, DIST, ISEED, TYPE, RWORK, MODE,
$ CNDNUM, ANORM, KL, KU, PACKIT, A, LDA, WORK,
$ INFO )
*
* Check error code from SLATMS.
*
IF( INFO.NE.0 ) THEN
CALL ALAERH( PATH, 'SLATMS', INFO, 0, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
GO TO 150
END IF
*
* For types 3-6, zero one or more rows and columns of
* the matrix to test that INFO is returned correctly.
*
IF( ZEROT ) THEN
IF( IMAT.EQ.3 ) THEN
IZERO = 1
ELSE IF( IMAT.EQ.4 ) THEN
IZERO = N
ELSE
IZERO = N / 2 + 1
END IF
*
IF( IMAT.LT.6 ) THEN
*
* Set row and column IZERO to zero.
*
IF( IUPLO.EQ.1 ) THEN
IOFF = ( IZERO-1 )*IZERO / 2
DO 20 I = 1, IZERO - 1
A( IOFF+I ) = ZERO
20 CONTINUE
IOFF = IOFF + IZERO
DO 30 I = IZERO, N
A( IOFF ) = ZERO
IOFF = IOFF + I
30 CONTINUE
ELSE
IOFF = IZERO
DO 40 I = 1, IZERO - 1
A( IOFF ) = ZERO
IOFF = IOFF + N - I
40 CONTINUE
IOFF = IOFF - IZERO
DO 50 I = IZERO, N
A( IOFF+I ) = ZERO
50 CONTINUE
END IF
ELSE
IOFF = 0
IF( IUPLO.EQ.1 ) THEN
*
* Set the first IZERO rows and columns to zero.
*
DO 70 J = 1, N
I2 = MIN( J, IZERO )
DO 60 I = 1, I2
A( IOFF+I ) = ZERO
60 CONTINUE
IOFF = IOFF + J
70 CONTINUE
ELSE
*
* Set the last IZERO rows and columns to zero.
*
DO 90 J = 1, N
I1 = MAX( J, IZERO )
DO 80 I = I1, N
A( IOFF+I ) = ZERO
80 CONTINUE
IOFF = IOFF + N - J
90 CONTINUE
END IF
END IF
ELSE
IZERO = 0
END IF
*
* Compute the L*D*L' or U*D*U' factorization of the matrix.
*
NPP = N*( N+1 ) / 2
CALL SCOPY( NPP, A, 1, AFAC, 1 )
SRNAMT = 'SSPTRF'
CALL SSPTRF( UPLO, N, AFAC, IWORK, INFO )
*
* Adjust the expected value of INFO to account for
* pivoting.
*
K = IZERO
IF( K.GT.0 ) THEN
100 CONTINUE
IF( IWORK( K ).LT.0 ) THEN
IF( IWORK( K ).NE.-K ) THEN
K = -IWORK( K )
GO TO 100
END IF
ELSE IF( IWORK( K ).NE.K ) THEN
K = IWORK( K )
GO TO 100
END IF
END IF
*
* Check error code from SSPTRF.
*
IF( INFO.NE.K )
$ CALL ALAERH( PATH, 'SSPTRF', INFO, K, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
IF( INFO.NE.0 ) THEN
TRFCON = .TRUE.
ELSE
TRFCON = .FALSE.
END IF
*
*+ TEST 1
* Reconstruct matrix from factors and compute residual.
*
CALL SSPT01( UPLO, N, A, AFAC, IWORK, AINV, LDA, RWORK,
$ RESULT( 1 ) )
NT = 1
*
*+ TEST 2
* Form the inverse and compute the residual.
*
IF( .NOT.TRFCON ) THEN
CALL SCOPY( NPP, AFAC, 1, AINV, 1 )
SRNAMT = 'SSPTRI'
CALL SSPTRI( UPLO, N, AINV, IWORK, WORK, INFO )
*
* Check error code from SSPTRI.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'SSPTRI', INFO, 0, UPLO, N, N,
$ -1, -1, -1, IMAT, NFAIL, NERRS, NOUT )
*
CALL SPPT03( UPLO, N, A, AINV, WORK, LDA, RWORK,
$ RCONDC, RESULT( 2 ) )
NT = 2
END IF
*
* Print information about the tests that did not pass
* the threshold.
*
DO 110 K = 1, NT
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, K,
$ RESULT( K )
NFAIL = NFAIL + 1
END IF
110 CONTINUE
NRUN = NRUN + NT
*
* Do only the condition estimate if INFO is not 0.
*
IF( TRFCON ) THEN
RCONDC = ZERO
GO TO 140
END IF
*
DO 130 IRHS = 1, NNS
NRHS = NSVAL( IRHS )
*
*+ TEST 3
* Solve and compute residual for A * X = B.
*
SRNAMT = 'SLARHS'
CALL SLARHS( PATH, XTYPE, UPLO, ' ', N, N, KL, KU,
$ NRHS, A, LDA, XACT, LDA, B, LDA, ISEED,
$ INFO )
CALL SLACPY( 'Full', N, NRHS, B, LDA, X, LDA )
*
SRNAMT = 'SSPTRS'
CALL SSPTRS( UPLO, N, NRHS, AFAC, IWORK, X, LDA,
$ INFO )
*
* Check error code from SSPTRS.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'SSPTRS', INFO, 0, UPLO, N, N,
$ -1, -1, NRHS, IMAT, NFAIL, NERRS,
$ NOUT )
*
CALL SLACPY( 'Full', N, NRHS, B, LDA, WORK, LDA )
CALL SPPT02( UPLO, N, NRHS, A, X, LDA, WORK, LDA,
$ RWORK, RESULT( 3 ) )
*
*+ TEST 4
* Check solution from generated exact solution.
*
CALL SGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
$ RESULT( 4 ) )
*
*+ TESTS 5, 6, and 7
* Use iterative refinement to improve the solution.
*
SRNAMT = 'SSPRFS'
CALL SSPRFS( UPLO, N, NRHS, A, AFAC, IWORK, B, LDA, X,
$ LDA, RWORK, RWORK( NRHS+1 ), WORK,
$ IWORK( N+1 ), INFO )
*
* Check error code from SSPRFS.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'SSPRFS', INFO, 0, UPLO, N, N,
$ -1, -1, NRHS, IMAT, NFAIL, NERRS,
$ NOUT )
*
CALL SGET04( N, NRHS, X, LDA, XACT, LDA, RCONDC,
$ RESULT( 5 ) )
CALL SPPT05( UPLO, N, NRHS, A, B, LDA, X, LDA, XACT,
$ LDA, RWORK, RWORK( NRHS+1 ),
$ RESULT( 6 ) )
*
* Print information about the tests that did not pass
* the threshold.
*
DO 120 K = 3, 7
IF( RESULT( K ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9998 )UPLO, N, NRHS, IMAT,
$ K, RESULT( K )
NFAIL = NFAIL + 1
END IF
120 CONTINUE
NRUN = NRUN + 5
130 CONTINUE
*
*+ TEST 8
* Get an estimate of RCOND = 1/CNDNUM.
*
140 CONTINUE
ANORM = SLANSP( '1', UPLO, N, A, RWORK )
SRNAMT = 'SSPCON'
CALL SSPCON( UPLO, N, AFAC, IWORK, ANORM, RCOND, WORK,
$ IWORK( N+1 ), INFO )
*
* Check error code from SSPCON.
*
IF( INFO.NE.0 )
$ CALL ALAERH( PATH, 'SSPCON', INFO, 0, UPLO, N, N, -1,
$ -1, -1, IMAT, NFAIL, NERRS, NOUT )
*
RESULT( 8 ) = SGET06( RCOND, RCONDC )
*
* Print the test ratio if it is .GE. THRESH.
*
IF( RESULT( 8 ).GE.THRESH ) THEN
IF( NFAIL.EQ.0 .AND. NERRS.EQ.0 )
$ CALL ALAHD( NOUT, PATH )
WRITE( NOUT, FMT = 9999 )UPLO, N, IMAT, 8,
$ RESULT( 8 )
NFAIL = NFAIL + 1
END IF
NRUN = NRUN + 1
150 CONTINUE
160 CONTINUE
170 CONTINUE
*
* Print a summary of the results.
*
CALL ALASUM( PATH, NOUT, NFAIL, NRUN, NERRS )
*
9999 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', type ', I2, ', test ',
$ I2, ', ratio =', G12.5 )
9998 FORMAT( ' UPLO = ''', A1, ''', N =', I5, ', NRHS=', I3, ', type ',
$ I2, ', test(', I2, ') =', G12.5 )
RETURN
*
* End of SCHKSP
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.4.2/EIG/sget37.f | 32 | 19246 | *> \brief \b SGET37
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SGET37( RMAX, LMAX, NINFO, KNT, NIN )
*
* .. Scalar Arguments ..
* INTEGER KNT, NIN
* ..
* .. Array Arguments ..
* INTEGER LMAX( 3 ), NINFO( 3 )
* REAL RMAX( 3 )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SGET37 tests STRSNA, a routine for estimating condition numbers of
*> eigenvalues and/or right eigenvectors of a matrix.
*>
*> The test matrices are read from a file with logical unit number NIN.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[out] RMAX
*> \verbatim
*> RMAX is REAL array, dimension (3)
*> Value of the largest test ratio.
*> RMAX(1) = largest ratio comparing different calls to STRSNA
*> RMAX(2) = largest error in reciprocal condition
*> numbers taking their conditioning into account
*> RMAX(3) = largest error in reciprocal condition
*> numbers not taking their conditioning into
*> account (may be larger than RMAX(2))
*> \endverbatim
*>
*> \param[out] LMAX
*> \verbatim
*> LMAX is INTEGER array, dimension (3)
*> LMAX(i) is example number where largest test ratio
*> RMAX(i) is achieved. Also:
*> If SGEHRD returns INFO nonzero on example i, LMAX(1)=i
*> If SHSEQR returns INFO nonzero on example i, LMAX(2)=i
*> If STRSNA returns INFO nonzero on example i, LMAX(3)=i
*> \endverbatim
*>
*> \param[out] NINFO
*> \verbatim
*> NINFO is INTEGER array, dimension (3)
*> NINFO(1) = No. of times SGEHRD returned INFO nonzero
*> NINFO(2) = No. of times SHSEQR returned INFO nonzero
*> NINFO(3) = No. of times STRSNA returned INFO nonzero
*> \endverbatim
*>
*> \param[out] KNT
*> \verbatim
*> KNT is INTEGER
*> Total number of examples tested.
*> \endverbatim
*>
*> \param[in] NIN
*> \verbatim
*> NIN is INTEGER
*> Input logical unit number
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_eig
*
* =====================================================================
SUBROUTINE SGET37( RMAX, LMAX, NINFO, KNT, NIN )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER KNT, NIN
* ..
* .. Array Arguments ..
INTEGER LMAX( 3 ), NINFO( 3 )
REAL RMAX( 3 )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE, TWO
PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0 )
REAL EPSIN
PARAMETER ( EPSIN = 5.9605E-8 )
INTEGER LDT, LWORK
PARAMETER ( LDT = 20, LWORK = 2*LDT*( 10+LDT ) )
* ..
* .. Local Scalars ..
INTEGER I, ICMP, IFND, INFO, ISCL, J, KMIN, M, N
REAL BIGNUM, EPS, SMLNUM, TNRM, TOL, TOLIN, V,
$ VIMIN, VMAX, VMUL, VRMIN
* ..
* .. Local Arrays ..
LOGICAL SELECT( LDT )
INTEGER IWORK( 2*LDT ), LCMP( 3 )
REAL DUM( 1 ), LE( LDT, LDT ), RE( LDT, LDT ),
$ S( LDT ), SEP( LDT ), SEPIN( LDT ),
$ SEPTMP( LDT ), SIN( LDT ), STMP( LDT ),
$ T( LDT, LDT ), TMP( LDT, LDT ), VAL( 3 ),
$ WI( LDT ), WIIN( LDT ), WITMP( LDT ),
$ WORK( LWORK ), WR( LDT ), WRIN( LDT ),
$ WRTMP( LDT )
* ..
* .. External Functions ..
REAL SLAMCH, SLANGE
EXTERNAL SLAMCH, SLANGE
* ..
* .. External Subroutines ..
EXTERNAL SCOPY, SGEHRD, SHSEQR, SLABAD, SLACPY, SSCAL,
$ STREVC, STRSNA
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, REAL, SQRT
* ..
* .. Executable Statements ..
*
EPS = SLAMCH( 'P' )
SMLNUM = SLAMCH( 'S' ) / EPS
BIGNUM = ONE / SMLNUM
CALL SLABAD( SMLNUM, BIGNUM )
*
* EPSIN = 2**(-24) = precision to which input data computed
*
EPS = MAX( EPS, EPSIN )
RMAX( 1 ) = ZERO
RMAX( 2 ) = ZERO
RMAX( 3 ) = ZERO
LMAX( 1 ) = 0
LMAX( 2 ) = 0
LMAX( 3 ) = 0
KNT = 0
NINFO( 1 ) = 0
NINFO( 2 ) = 0
NINFO( 3 ) = 0
*
VAL( 1 ) = SQRT( SMLNUM )
VAL( 2 ) = ONE
VAL( 3 ) = SQRT( BIGNUM )
*
* Read input data until N=0. Assume input eigenvalues are sorted
* lexicographically (increasing by real part, then decreasing by
* imaginary part)
*
10 CONTINUE
READ( NIN, FMT = * )N
IF( N.EQ.0 )
$ RETURN
DO 20 I = 1, N
READ( NIN, FMT = * )( TMP( I, J ), J = 1, N )
20 CONTINUE
DO 30 I = 1, N
READ( NIN, FMT = * )WRIN( I ), WIIN( I ), SIN( I ), SEPIN( I )
30 CONTINUE
TNRM = SLANGE( 'M', N, N, TMP, LDT, WORK )
*
* Begin test
*
DO 240 ISCL = 1, 3
*
* Scale input matrix
*
KNT = KNT + 1
CALL SLACPY( 'F', N, N, TMP, LDT, T, LDT )
VMUL = VAL( ISCL )
DO 40 I = 1, N
CALL SSCAL( N, VMUL, T( 1, I ), 1 )
40 CONTINUE
IF( TNRM.EQ.ZERO )
$ VMUL = ONE
*
* Compute eigenvalues and eigenvectors
*
CALL SGEHRD( N, 1, N, T, LDT, WORK( 1 ), WORK( N+1 ), LWORK-N,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 1 ) = KNT
NINFO( 1 ) = NINFO( 1 ) + 1
GO TO 240
END IF
DO 60 J = 1, N - 2
DO 50 I = J + 2, N
T( I, J ) = ZERO
50 CONTINUE
60 CONTINUE
*
* Compute Schur form
*
CALL SHSEQR( 'S', 'N', N, 1, N, T, LDT, WR, WI, DUM, 1, WORK,
$ LWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 2 ) = KNT
NINFO( 2 ) = NINFO( 2 ) + 1
GO TO 240
END IF
*
* Compute eigenvectors
*
CALL STREVC( 'Both', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, N, M, WORK, INFO )
*
* Compute condition numbers
*
CALL STRSNA( 'Both', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, S, SEP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
*
* Sort eigenvalues and condition numbers lexicographically
* to compare with inputs
*
CALL SCOPY( N, WR, 1, WRTMP, 1 )
CALL SCOPY( N, WI, 1, WITMP, 1 )
CALL SCOPY( N, S, 1, STMP, 1 )
CALL SCOPY( N, SEP, 1, SEPTMP, 1 )
CALL SSCAL( N, ONE / VMUL, SEPTMP, 1 )
DO 80 I = 1, N - 1
KMIN = I
VRMIN = WRTMP( I )
VIMIN = WITMP( I )
DO 70 J = I + 1, N
IF( WRTMP( J ).LT.VRMIN ) THEN
KMIN = J
VRMIN = WRTMP( J )
VIMIN = WITMP( J )
END IF
70 CONTINUE
WRTMP( KMIN ) = WRTMP( I )
WITMP( KMIN ) = WITMP( I )
WRTMP( I ) = VRMIN
WITMP( I ) = VIMIN
VRMIN = STMP( KMIN )
STMP( KMIN ) = STMP( I )
STMP( I ) = VRMIN
VRMIN = SEPTMP( KMIN )
SEPTMP( KMIN ) = SEPTMP( I )
SEPTMP( I ) = VRMIN
80 CONTINUE
*
* Compare condition numbers for eigenvalues
* taking their condition numbers into account
*
V = MAX( TWO*REAL( N )*EPS*TNRM, SMLNUM )
IF( TNRM.EQ.ZERO )
$ V = ONE
DO 90 I = 1, N
IF( V.GT.SEPTMP( I ) ) THEN
TOL = ONE
ELSE
TOL = V / SEPTMP( I )
END IF
IF( V.GT.SEPIN( I ) ) THEN
TOLIN = ONE
ELSE
TOLIN = V / SEPIN( I )
END IF
TOL = MAX( TOL, SMLNUM / EPS )
TOLIN = MAX( TOLIN, SMLNUM / EPS )
IF( EPS*( SIN( I )-TOLIN ).GT.STMP( I )+TOL ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I )-TOLIN.GT.STMP( I )+TOL ) THEN
VMAX = ( SIN( I )-TOLIN ) / ( STMP( I )+TOL )
ELSE IF( SIN( I )+TOLIN.LT.EPS*( STMP( I )-TOL ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I )+TOLIN.LT.STMP( I )-TOL ) THEN
VMAX = ( STMP( I )-TOL ) / ( SIN( I )+TOLIN )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 2 ) ) THEN
RMAX( 2 ) = VMAX
IF( NINFO( 2 ).EQ.0 )
$ LMAX( 2 ) = KNT
END IF
90 CONTINUE
*
* Compare condition numbers for eigenvectors
* taking their condition numbers into account
*
DO 100 I = 1, N
IF( V.GT.SEPTMP( I )*STMP( I ) ) THEN
TOL = SEPTMP( I )
ELSE
TOL = V / STMP( I )
END IF
IF( V.GT.SEPIN( I )*SIN( I ) ) THEN
TOLIN = SEPIN( I )
ELSE
TOLIN = V / SIN( I )
END IF
TOL = MAX( TOL, SMLNUM / EPS )
TOLIN = MAX( TOLIN, SMLNUM / EPS )
IF( EPS*( SEPIN( I )-TOLIN ).GT.SEPTMP( I )+TOL ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I )-TOLIN.GT.SEPTMP( I )+TOL ) THEN
VMAX = ( SEPIN( I )-TOLIN ) / ( SEPTMP( I )+TOL )
ELSE IF( SEPIN( I )+TOLIN.LT.EPS*( SEPTMP( I )-TOL ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I )+TOLIN.LT.SEPTMP( I )-TOL ) THEN
VMAX = ( SEPTMP( I )-TOL ) / ( SEPIN( I )+TOLIN )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 2 ) ) THEN
RMAX( 2 ) = VMAX
IF( NINFO( 2 ).EQ.0 )
$ LMAX( 2 ) = KNT
END IF
100 CONTINUE
*
* Compare condition numbers for eigenvalues
* without taking their condition numbers into account
*
DO 110 I = 1, N
IF( SIN( I ).LE.REAL( 2*N )*EPS .AND. STMP( I ).LE.
$ REAL( 2*N )*EPS ) THEN
VMAX = ONE
ELSE IF( EPS*SIN( I ).GT.STMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I ).GT.STMP( I ) ) THEN
VMAX = SIN( I ) / STMP( I )
ELSE IF( SIN( I ).LT.EPS*STMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I ).LT.STMP( I ) ) THEN
VMAX = STMP( I ) / SIN( I )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 3 ) ) THEN
RMAX( 3 ) = VMAX
IF( NINFO( 3 ).EQ.0 )
$ LMAX( 3 ) = KNT
END IF
110 CONTINUE
*
* Compare condition numbers for eigenvectors
* without taking their condition numbers into account
*
DO 120 I = 1, N
IF( SEPIN( I ).LE.V .AND. SEPTMP( I ).LE.V ) THEN
VMAX = ONE
ELSE IF( EPS*SEPIN( I ).GT.SEPTMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I ).GT.SEPTMP( I ) ) THEN
VMAX = SEPIN( I ) / SEPTMP( I )
ELSE IF( SEPIN( I ).LT.EPS*SEPTMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I ).LT.SEPTMP( I ) ) THEN
VMAX = SEPTMP( I ) / SEPIN( I )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 3 ) ) THEN
RMAX( 3 ) = VMAX
IF( NINFO( 3 ).EQ.0 )
$ LMAX( 3 ) = KNT
END IF
120 CONTINUE
*
* Compute eigenvalue condition numbers only and compare
*
VMAX = ZERO
DUM( 1 ) = -ONE
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 130 I = 1, N
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
130 CONTINUE
*
* Compute eigenvector condition numbers only and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 140 I = 1, N
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
140 CONTINUE
*
* Compute all condition numbers using SELECT and compare
*
DO 150 I = 1, N
SELECT( I ) = .TRUE.
150 CONTINUE
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Bothcond', 'Some', SELECT, N, T, LDT, LE, LDT,
$ RE, LDT, STMP, SEPTMP, N, M, WORK, N, IWORK,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 160 I = 1, N
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
160 CONTINUE
*
* Compute eigenvalue condition numbers using SELECT and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 170 I = 1, N
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
170 CONTINUE
*
* Compute eigenvector condition numbers using SELECT and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 180 I = 1, N
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
180 CONTINUE
IF( VMAX.GT.RMAX( 1 ) ) THEN
RMAX( 1 ) = VMAX
IF( NINFO( 1 ).EQ.0 )
$ LMAX( 1 ) = KNT
END IF
*
* Select first real and first complex eigenvalue
*
IF( WI( 1 ).EQ.ZERO ) THEN
LCMP( 1 ) = 1
IFND = 0
DO 190 I = 2, N
IF( IFND.EQ.1 .OR. WI( I ).EQ.ZERO ) THEN
SELECT( I ) = .FALSE.
ELSE
IFND = 1
LCMP( 2 ) = I
LCMP( 3 ) = I + 1
CALL SCOPY( N, RE( 1, I ), 1, RE( 1, 2 ), 1 )
CALL SCOPY( N, RE( 1, I+1 ), 1, RE( 1, 3 ), 1 )
CALL SCOPY( N, LE( 1, I ), 1, LE( 1, 2 ), 1 )
CALL SCOPY( N, LE( 1, I+1 ), 1, LE( 1, 3 ), 1 )
END IF
190 CONTINUE
IF( IFND.EQ.0 ) THEN
ICMP = 1
ELSE
ICMP = 3
END IF
ELSE
LCMP( 1 ) = 1
LCMP( 2 ) = 2
IFND = 0
DO 200 I = 3, N
IF( IFND.EQ.1 .OR. WI( I ).NE.ZERO ) THEN
SELECT( I ) = .FALSE.
ELSE
LCMP( 3 ) = I
IFND = 1
CALL SCOPY( N, RE( 1, I ), 1, RE( 1, 3 ), 1 )
CALL SCOPY( N, LE( 1, I ), 1, LE( 1, 3 ), 1 )
END IF
200 CONTINUE
IF( IFND.EQ.0 ) THEN
ICMP = 2
ELSE
ICMP = 3
END IF
END IF
*
* Compute all selected condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Bothcond', 'Some', SELECT, N, T, LDT, LE, LDT,
$ RE, LDT, STMP, SEPTMP, N, M, WORK, N, IWORK,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 210 I = 1, ICMP
J = LCMP( I )
IF( SEPTMP( I ).NE.SEP( J ) )
$ VMAX = ONE / EPS
IF( STMP( I ).NE.S( J ) )
$ VMAX = ONE / EPS
210 CONTINUE
*
* Compute selected eigenvalue condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 220 I = 1, ICMP
J = LCMP( I )
IF( STMP( I ).NE.S( J ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
220 CONTINUE
*
* Compute selected eigenvector condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 230 I = 1, ICMP
J = LCMP( I )
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( J ) )
$ VMAX = ONE / EPS
230 CONTINUE
IF( VMAX.GT.RMAX( 1 ) ) THEN
RMAX( 1 ) = VMAX
IF( NINFO( 1 ).EQ.0 )
$ LMAX( 1 ) = KNT
END IF
240 CONTINUE
GO TO 10
*
* End of SGET37
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/EIG/sget37.f | 32 | 19246 | *> \brief \b SGET37
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SGET37( RMAX, LMAX, NINFO, KNT, NIN )
*
* .. Scalar Arguments ..
* INTEGER KNT, NIN
* ..
* .. Array Arguments ..
* INTEGER LMAX( 3 ), NINFO( 3 )
* REAL RMAX( 3 )
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SGET37 tests STRSNA, a routine for estimating condition numbers of
*> eigenvalues and/or right eigenvectors of a matrix.
*>
*> The test matrices are read from a file with logical unit number NIN.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[out] RMAX
*> \verbatim
*> RMAX is REAL array, dimension (3)
*> Value of the largest test ratio.
*> RMAX(1) = largest ratio comparing different calls to STRSNA
*> RMAX(2) = largest error in reciprocal condition
*> numbers taking their conditioning into account
*> RMAX(3) = largest error in reciprocal condition
*> numbers not taking their conditioning into
*> account (may be larger than RMAX(2))
*> \endverbatim
*>
*> \param[out] LMAX
*> \verbatim
*> LMAX is INTEGER array, dimension (3)
*> LMAX(i) is example number where largest test ratio
*> RMAX(i) is achieved. Also:
*> If SGEHRD returns INFO nonzero on example i, LMAX(1)=i
*> If SHSEQR returns INFO nonzero on example i, LMAX(2)=i
*> If STRSNA returns INFO nonzero on example i, LMAX(3)=i
*> \endverbatim
*>
*> \param[out] NINFO
*> \verbatim
*> NINFO is INTEGER array, dimension (3)
*> NINFO(1) = No. of times SGEHRD returned INFO nonzero
*> NINFO(2) = No. of times SHSEQR returned INFO nonzero
*> NINFO(3) = No. of times STRSNA returned INFO nonzero
*> \endverbatim
*>
*> \param[out] KNT
*> \verbatim
*> KNT is INTEGER
*> Total number of examples tested.
*> \endverbatim
*>
*> \param[in] NIN
*> \verbatim
*> NIN is INTEGER
*> Input logical unit number
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_eig
*
* =====================================================================
SUBROUTINE SGET37( RMAX, LMAX, NINFO, KNT, NIN )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER KNT, NIN
* ..
* .. Array Arguments ..
INTEGER LMAX( 3 ), NINFO( 3 )
REAL RMAX( 3 )
* ..
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO, ONE, TWO
PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0, TWO = 2.0E0 )
REAL EPSIN
PARAMETER ( EPSIN = 5.9605E-8 )
INTEGER LDT, LWORK
PARAMETER ( LDT = 20, LWORK = 2*LDT*( 10+LDT ) )
* ..
* .. Local Scalars ..
INTEGER I, ICMP, IFND, INFO, ISCL, J, KMIN, M, N
REAL BIGNUM, EPS, SMLNUM, TNRM, TOL, TOLIN, V,
$ VIMIN, VMAX, VMUL, VRMIN
* ..
* .. Local Arrays ..
LOGICAL SELECT( LDT )
INTEGER IWORK( 2*LDT ), LCMP( 3 )
REAL DUM( 1 ), LE( LDT, LDT ), RE( LDT, LDT ),
$ S( LDT ), SEP( LDT ), SEPIN( LDT ),
$ SEPTMP( LDT ), SIN( LDT ), STMP( LDT ),
$ T( LDT, LDT ), TMP( LDT, LDT ), VAL( 3 ),
$ WI( LDT ), WIIN( LDT ), WITMP( LDT ),
$ WORK( LWORK ), WR( LDT ), WRIN( LDT ),
$ WRTMP( LDT )
* ..
* .. External Functions ..
REAL SLAMCH, SLANGE
EXTERNAL SLAMCH, SLANGE
* ..
* .. External Subroutines ..
EXTERNAL SCOPY, SGEHRD, SHSEQR, SLABAD, SLACPY, SSCAL,
$ STREVC, STRSNA
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX, REAL, SQRT
* ..
* .. Executable Statements ..
*
EPS = SLAMCH( 'P' )
SMLNUM = SLAMCH( 'S' ) / EPS
BIGNUM = ONE / SMLNUM
CALL SLABAD( SMLNUM, BIGNUM )
*
* EPSIN = 2**(-24) = precision to which input data computed
*
EPS = MAX( EPS, EPSIN )
RMAX( 1 ) = ZERO
RMAX( 2 ) = ZERO
RMAX( 3 ) = ZERO
LMAX( 1 ) = 0
LMAX( 2 ) = 0
LMAX( 3 ) = 0
KNT = 0
NINFO( 1 ) = 0
NINFO( 2 ) = 0
NINFO( 3 ) = 0
*
VAL( 1 ) = SQRT( SMLNUM )
VAL( 2 ) = ONE
VAL( 3 ) = SQRT( BIGNUM )
*
* Read input data until N=0. Assume input eigenvalues are sorted
* lexicographically (increasing by real part, then decreasing by
* imaginary part)
*
10 CONTINUE
READ( NIN, FMT = * )N
IF( N.EQ.0 )
$ RETURN
DO 20 I = 1, N
READ( NIN, FMT = * )( TMP( I, J ), J = 1, N )
20 CONTINUE
DO 30 I = 1, N
READ( NIN, FMT = * )WRIN( I ), WIIN( I ), SIN( I ), SEPIN( I )
30 CONTINUE
TNRM = SLANGE( 'M', N, N, TMP, LDT, WORK )
*
* Begin test
*
DO 240 ISCL = 1, 3
*
* Scale input matrix
*
KNT = KNT + 1
CALL SLACPY( 'F', N, N, TMP, LDT, T, LDT )
VMUL = VAL( ISCL )
DO 40 I = 1, N
CALL SSCAL( N, VMUL, T( 1, I ), 1 )
40 CONTINUE
IF( TNRM.EQ.ZERO )
$ VMUL = ONE
*
* Compute eigenvalues and eigenvectors
*
CALL SGEHRD( N, 1, N, T, LDT, WORK( 1 ), WORK( N+1 ), LWORK-N,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 1 ) = KNT
NINFO( 1 ) = NINFO( 1 ) + 1
GO TO 240
END IF
DO 60 J = 1, N - 2
DO 50 I = J + 2, N
T( I, J ) = ZERO
50 CONTINUE
60 CONTINUE
*
* Compute Schur form
*
CALL SHSEQR( 'S', 'N', N, 1, N, T, LDT, WR, WI, DUM, 1, WORK,
$ LWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 2 ) = KNT
NINFO( 2 ) = NINFO( 2 ) + 1
GO TO 240
END IF
*
* Compute eigenvectors
*
CALL STREVC( 'Both', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, N, M, WORK, INFO )
*
* Compute condition numbers
*
CALL STRSNA( 'Both', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, S, SEP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
*
* Sort eigenvalues and condition numbers lexicographically
* to compare with inputs
*
CALL SCOPY( N, WR, 1, WRTMP, 1 )
CALL SCOPY( N, WI, 1, WITMP, 1 )
CALL SCOPY( N, S, 1, STMP, 1 )
CALL SCOPY( N, SEP, 1, SEPTMP, 1 )
CALL SSCAL( N, ONE / VMUL, SEPTMP, 1 )
DO 80 I = 1, N - 1
KMIN = I
VRMIN = WRTMP( I )
VIMIN = WITMP( I )
DO 70 J = I + 1, N
IF( WRTMP( J ).LT.VRMIN ) THEN
KMIN = J
VRMIN = WRTMP( J )
VIMIN = WITMP( J )
END IF
70 CONTINUE
WRTMP( KMIN ) = WRTMP( I )
WITMP( KMIN ) = WITMP( I )
WRTMP( I ) = VRMIN
WITMP( I ) = VIMIN
VRMIN = STMP( KMIN )
STMP( KMIN ) = STMP( I )
STMP( I ) = VRMIN
VRMIN = SEPTMP( KMIN )
SEPTMP( KMIN ) = SEPTMP( I )
SEPTMP( I ) = VRMIN
80 CONTINUE
*
* Compare condition numbers for eigenvalues
* taking their condition numbers into account
*
V = MAX( TWO*REAL( N )*EPS*TNRM, SMLNUM )
IF( TNRM.EQ.ZERO )
$ V = ONE
DO 90 I = 1, N
IF( V.GT.SEPTMP( I ) ) THEN
TOL = ONE
ELSE
TOL = V / SEPTMP( I )
END IF
IF( V.GT.SEPIN( I ) ) THEN
TOLIN = ONE
ELSE
TOLIN = V / SEPIN( I )
END IF
TOL = MAX( TOL, SMLNUM / EPS )
TOLIN = MAX( TOLIN, SMLNUM / EPS )
IF( EPS*( SIN( I )-TOLIN ).GT.STMP( I )+TOL ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I )-TOLIN.GT.STMP( I )+TOL ) THEN
VMAX = ( SIN( I )-TOLIN ) / ( STMP( I )+TOL )
ELSE IF( SIN( I )+TOLIN.LT.EPS*( STMP( I )-TOL ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I )+TOLIN.LT.STMP( I )-TOL ) THEN
VMAX = ( STMP( I )-TOL ) / ( SIN( I )+TOLIN )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 2 ) ) THEN
RMAX( 2 ) = VMAX
IF( NINFO( 2 ).EQ.0 )
$ LMAX( 2 ) = KNT
END IF
90 CONTINUE
*
* Compare condition numbers for eigenvectors
* taking their condition numbers into account
*
DO 100 I = 1, N
IF( V.GT.SEPTMP( I )*STMP( I ) ) THEN
TOL = SEPTMP( I )
ELSE
TOL = V / STMP( I )
END IF
IF( V.GT.SEPIN( I )*SIN( I ) ) THEN
TOLIN = SEPIN( I )
ELSE
TOLIN = V / SIN( I )
END IF
TOL = MAX( TOL, SMLNUM / EPS )
TOLIN = MAX( TOLIN, SMLNUM / EPS )
IF( EPS*( SEPIN( I )-TOLIN ).GT.SEPTMP( I )+TOL ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I )-TOLIN.GT.SEPTMP( I )+TOL ) THEN
VMAX = ( SEPIN( I )-TOLIN ) / ( SEPTMP( I )+TOL )
ELSE IF( SEPIN( I )+TOLIN.LT.EPS*( SEPTMP( I )-TOL ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I )+TOLIN.LT.SEPTMP( I )-TOL ) THEN
VMAX = ( SEPTMP( I )-TOL ) / ( SEPIN( I )+TOLIN )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 2 ) ) THEN
RMAX( 2 ) = VMAX
IF( NINFO( 2 ).EQ.0 )
$ LMAX( 2 ) = KNT
END IF
100 CONTINUE
*
* Compare condition numbers for eigenvalues
* without taking their condition numbers into account
*
DO 110 I = 1, N
IF( SIN( I ).LE.REAL( 2*N )*EPS .AND. STMP( I ).LE.
$ REAL( 2*N )*EPS ) THEN
VMAX = ONE
ELSE IF( EPS*SIN( I ).GT.STMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I ).GT.STMP( I ) ) THEN
VMAX = SIN( I ) / STMP( I )
ELSE IF( SIN( I ).LT.EPS*STMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SIN( I ).LT.STMP( I ) ) THEN
VMAX = STMP( I ) / SIN( I )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 3 ) ) THEN
RMAX( 3 ) = VMAX
IF( NINFO( 3 ).EQ.0 )
$ LMAX( 3 ) = KNT
END IF
110 CONTINUE
*
* Compare condition numbers for eigenvectors
* without taking their condition numbers into account
*
DO 120 I = 1, N
IF( SEPIN( I ).LE.V .AND. SEPTMP( I ).LE.V ) THEN
VMAX = ONE
ELSE IF( EPS*SEPIN( I ).GT.SEPTMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I ).GT.SEPTMP( I ) ) THEN
VMAX = SEPIN( I ) / SEPTMP( I )
ELSE IF( SEPIN( I ).LT.EPS*SEPTMP( I ) ) THEN
VMAX = ONE / EPS
ELSE IF( SEPIN( I ).LT.SEPTMP( I ) ) THEN
VMAX = SEPTMP( I ) / SEPIN( I )
ELSE
VMAX = ONE
END IF
IF( VMAX.GT.RMAX( 3 ) ) THEN
RMAX( 3 ) = VMAX
IF( NINFO( 3 ).EQ.0 )
$ LMAX( 3 ) = KNT
END IF
120 CONTINUE
*
* Compute eigenvalue condition numbers only and compare
*
VMAX = ZERO
DUM( 1 ) = -ONE
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 130 I = 1, N
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
130 CONTINUE
*
* Compute eigenvector condition numbers only and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'All', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 140 I = 1, N
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
140 CONTINUE
*
* Compute all condition numbers using SELECT and compare
*
DO 150 I = 1, N
SELECT( I ) = .TRUE.
150 CONTINUE
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Bothcond', 'Some', SELECT, N, T, LDT, LE, LDT,
$ RE, LDT, STMP, SEPTMP, N, M, WORK, N, IWORK,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 160 I = 1, N
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
160 CONTINUE
*
* Compute eigenvalue condition numbers using SELECT and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 170 I = 1, N
IF( STMP( I ).NE.S( I ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
170 CONTINUE
*
* Compute eigenvector condition numbers using SELECT and compare
*
CALL SCOPY( N, DUM, 0, STMP, 1 )
CALL SCOPY( N, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 180 I = 1, N
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( I ) )
$ VMAX = ONE / EPS
180 CONTINUE
IF( VMAX.GT.RMAX( 1 ) ) THEN
RMAX( 1 ) = VMAX
IF( NINFO( 1 ).EQ.0 )
$ LMAX( 1 ) = KNT
END IF
*
* Select first real and first complex eigenvalue
*
IF( WI( 1 ).EQ.ZERO ) THEN
LCMP( 1 ) = 1
IFND = 0
DO 190 I = 2, N
IF( IFND.EQ.1 .OR. WI( I ).EQ.ZERO ) THEN
SELECT( I ) = .FALSE.
ELSE
IFND = 1
LCMP( 2 ) = I
LCMP( 3 ) = I + 1
CALL SCOPY( N, RE( 1, I ), 1, RE( 1, 2 ), 1 )
CALL SCOPY( N, RE( 1, I+1 ), 1, RE( 1, 3 ), 1 )
CALL SCOPY( N, LE( 1, I ), 1, LE( 1, 2 ), 1 )
CALL SCOPY( N, LE( 1, I+1 ), 1, LE( 1, 3 ), 1 )
END IF
190 CONTINUE
IF( IFND.EQ.0 ) THEN
ICMP = 1
ELSE
ICMP = 3
END IF
ELSE
LCMP( 1 ) = 1
LCMP( 2 ) = 2
IFND = 0
DO 200 I = 3, N
IF( IFND.EQ.1 .OR. WI( I ).NE.ZERO ) THEN
SELECT( I ) = .FALSE.
ELSE
LCMP( 3 ) = I
IFND = 1
CALL SCOPY( N, RE( 1, I ), 1, RE( 1, 3 ), 1 )
CALL SCOPY( N, LE( 1, I ), 1, LE( 1, 3 ), 1 )
END IF
200 CONTINUE
IF( IFND.EQ.0 ) THEN
ICMP = 2
ELSE
ICMP = 3
END IF
END IF
*
* Compute all selected condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Bothcond', 'Some', SELECT, N, T, LDT, LE, LDT,
$ RE, LDT, STMP, SEPTMP, N, M, WORK, N, IWORK,
$ INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 210 I = 1, ICMP
J = LCMP( I )
IF( SEPTMP( I ).NE.SEP( J ) )
$ VMAX = ONE / EPS
IF( STMP( I ).NE.S( J ) )
$ VMAX = ONE / EPS
210 CONTINUE
*
* Compute selected eigenvalue condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Eigcond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 220 I = 1, ICMP
J = LCMP( I )
IF( STMP( I ).NE.S( J ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
220 CONTINUE
*
* Compute selected eigenvector condition numbers
*
CALL SCOPY( ICMP, DUM, 0, STMP, 1 )
CALL SCOPY( ICMP, DUM, 0, SEPTMP, 1 )
CALL STRSNA( 'Veccond', 'Some', SELECT, N, T, LDT, LE, LDT, RE,
$ LDT, STMP, SEPTMP, N, M, WORK, N, IWORK, INFO )
IF( INFO.NE.0 ) THEN
LMAX( 3 ) = KNT
NINFO( 3 ) = NINFO( 3 ) + 1
GO TO 240
END IF
DO 230 I = 1, ICMP
J = LCMP( I )
IF( STMP( I ).NE.DUM( 1 ) )
$ VMAX = ONE / EPS
IF( SEPTMP( I ).NE.SEP( J ) )
$ VMAX = ONE / EPS
230 CONTINUE
IF( VMAX.GT.RMAX( 1 ) ) THEN
RMAX( 1 ) = VMAX
IF( NINFO( 1 ).EQ.0 )
$ LMAX( 1 ) = KNT
END IF
240 CONTINUE
GO TO 10
*
* End of SGET37
*
END
| bsd-3-clause |
yaowee/libflame | lapack-test/lapack-timing/EIG/dtim21.f | 4 | 43887 | SUBROUTINE DTIM21( LINE, NSIZES, NN, NTYPES, DOTYPE, NPARMS, NNB,
$ NSHFTS, MAXBS, LDAS, TIMMIN, NOUT, ISEED, A, H,
$ Z, W, WORK, LWORK, LLWORK, IWORK, TIMES, LDT1,
$ LDT2, LDT3, OPCNTS, LDO1, LDO2, LDO3, INFO )
*
* -- LAPACK timing routine (version 3.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* September 30, 1994
*
* .. Scalar Arguments ..
CHARACTER*80 LINE
INTEGER INFO, LDO1, LDO2, LDO3, LDT1, LDT2, LDT3,
$ LWORK, NOUT, NPARMS, NSIZES, NTYPES
DOUBLE PRECISION TIMMIN
* ..
* .. Array Arguments ..
LOGICAL DOTYPE( * ), LLWORK( * )
INTEGER ISEED( * ), IWORK( * ), LDAS( * ), MAXBS( * ),
$ NN( * ), NNB( * ), NSHFTS( * )
DOUBLE PRECISION A( * ), H( * ), OPCNTS( LDO1, LDO2, LDO3, * ),
$ TIMES( LDT1, LDT2, LDT3, * ), W( * ),
$ WORK( * ), Z( * )
* ..
*
* Purpose
* =======
*
* DTIM21 times the LAPACK routines for the DOUBLE PRECISION
* non-symmetric eigenvalue problem.
*
* For each N value in NN(1:NSIZES) and .TRUE. value in
* DOTYPE(1:NTYPES), a matrix will be generated and used to test the
* selected routines. Thus, NSIZES*(number of .TRUE. values in
* DOTYPE) matrices will be generated.
*
* Arguments
* =========
*
* LINE (input) CHARACTER*80
* On entry, LINE contains the input line which requested
* this routine. This line may contain a subroutine name,
* such as DGEHRD, indicating that only routine SGEHRD will
* be timed, or it may contain a generic name, such as DHS.
* In this case, the rest of the line is scanned for the
* first 12 non-blank characters, corresponding to the twelve
* combinations of subroutine and options:
* LAPACK:
* 1: DGEHRD
* 2: DHSEQR(JOB='E')
* 3: DHSEQR(JOB='S')
* 4: DHSEQR(JOB='I')
* 5: DTREVC(JOB='L')
* 6: DTREVC(JOB='R')
* 7: DHSEIN(JOB='L')
* 8: DHSEIN(JOB='R')
* EISPACK:
* 9: ORTHES (compare with DGEHRD)
* 10: HQR (compare w/ DHSEQR -- JOB='E')
* 11: HQR2 (compare w/ DHSEQR(JOB='I') plus DTREVC(JOB='R'))
* 12: INVIT (compare with DHSEIN)
* If a character is 'T' or 't', the corresponding routine in
* this path is timed. If the entire line is blank, all the
* routines in the path are timed.
*
* NSIZES (input) INTEGER
* The number of values of N contained in the vector NN.
*
* NN (input) INTEGER array, dimension( NSIZES )
* The values of the matrix size N to be tested. For each
* N value in the array NN, and each .TRUE. value in DOTYPE,
* a matrix A will be generated and used to test the routines.
*
* NTYPES (input) INTEGER
* The number of types in DOTYPE. Only the first MAXTYP
* elements will be examined. Exception: if NSIZES=1 and
* NTYPES=MAXTYP+1, and DOTYPE=MAXTYP*f,t, then the input
* value of A will be used.
*
* DOTYPE (input) LOGICAL
* If DOTYPE(j) is .TRUE., then a matrix of type j will be
* generated. The matrix A has the form X**(-1) T X, where
* X is orthogonal (for j=1--4) or has condition sqrt(ULP)
* (for j=5--8), and T has random O(1) entries in the upper
* triangle and:
* (j=1,5) evenly spaced entries 1, ..., ULP with random signs
* (j=2,6) geometrically spaced entries 1, ..., ULP with random
* signs
* (j=3,7) "clustered" entries 1, ULP,..., ULP with random
* signs
* (j=4,8) real or complex conjugate paired eigenvalues
* randomly chosen from ( ULP, 1 )
* on the diagonal.
*
* NPARMS (input) INTEGER
* The number of values in each of the arrays NNB, NSHFTS,
* MAXBS, and LDAS. For each matrix A generated according to
* NN and DOTYPE, tests will be run with (NB,NSHIFT,MAXB,LDA)=
* (NNB(1), NSHFTS(1), MAXBS(1), LDAS(1)),...,
* (NNB(NPARMS), NSHFTS(NPARMS), MAXBS(NPARMS), LDAS(NPARMS))
*
* NNB (input) INTEGER array, dimension( NPARMS )
* The values of the blocksize ("NB") to be tested.
*
* NSHFTS (input) INTEGER array, dimension( NPARMS )
* The values of the number of shifts ("NSHIFT") to be tested.
*
* MAXBS (input) INTEGER array, dimension( NPARMS )
* The values of "MAXB", the size of largest submatrix to be
* processed by DLAHQR (EISPACK method), to be tested.
*
* LDAS (input) INTEGER array, dimension( NPARMS )
* The values of LDA, the leading dimension of all matrices,
* to be tested.
*
* TIMMIN (input) DOUBLE PRECISION
* The minimum time a subroutine will be timed.
*
* NOUT (input) INTEGER
* If NOUT > 0 then NOUT specifies the unit number
* on which the output will be printed. If NOUT <= 0, no
* output is printed.
*
* ISEED (input/output) INTEGER array, dimension( 4 )
* The random seed used by the random number generator, used
* by the test matrix generator. It is used and updated on
* each call to DTIM21
*
* A (workspace) DOUBLE PRECISION array,
* dimension( max(NN)*max(LDAS) )
* (a) During the testing of DGEHRD, the original matrix to
* be tested.
* (b) Later, the Schur form of the original matrix.
*
* H (workspace) DOUBLE PRECISION array,
* dimension( max(NN)*max(LDAS) )
* The Hessenberg form of the original matrix.
*
* Z (workspace) DOUBLE PRECISION array,
* dimension( max(NN)*max(LDAS) )
* Various output arrays: from DGEHRD and DHSEQR, the
* orthogonal reduction matrices; from DTREVC and DHSEIN,
* the eigenvector matrices.
*
* W (workspace) DOUBLE PRECISION array,
* dimension( 2*max(LDAS) )
* Treated as an LDA x 2 matrix whose 1st column holds WR, the
* real parts of the eigenvalues, and whose 2nd column holds
* WI, the imaginary parts of the eigenvalues of A.
*
* WORK (workspace) DOUBLE PRECISION array, dimension( LWORK )
*
* LWORK (input) INTEGER
* Number of elements in WORK. It must be at least
* (a) max(NN)*( 3*max(NNB) + 2 )
* (b) max(NN)*( max(NNB+NSHFTS) + 1 )
* (c) max(NSHFTS)*( max(NSHFTS) + max(NN) )
* (d) max(MAXBS)*( max(MAXBS) + max(NN) )
* (e) ( max(NN) + 2 )**2 + max(NN)
* (f) NSIZES*NTYPES*NPARMS
*
* LLWORK (workspace) LOGICAL array, dimension( max( max(NN), NPARMS ))
*
* IWORK (workspace) INTEGER array, dimension( 2*max(NN) )
* Workspace needed for parameters IFAILL and IFAILR in call
* to DHSEIN.
*
* TIMES (output) DOUBLE PRECISION array,
* dimension (LDT1,LDT2,LDT3,NSUBS)
* TIMES(i,j,k,l) will be set to the run time (in seconds) for
* subroutine l, with N=NN(k), matrix type j, and LDA=LDAS(i),
* MAXB=MAXBS(i), NBLOCK=NNB(i), and NSHIFT=NSHFTS(i).
*
* LDT1 (input) INTEGER
* The first dimension of TIMES. LDT1 >= min( 1, NPARMS ).
*
* LDT2 (input) INTEGER
* The second dimension of TIMES. LDT2 >= min( 1, NTYPES ).
*
* LDT3 (input) INTEGER
* The third dimension of TIMES. LDT3 >= min( 1, NSIZES ).
*
* OPCNTS (output) DOUBLE PRECISION array,
* dimension (LDO1,LDO2,LDO3,NSUBS)
* OPCNTS(i,j,k,l) will be set to the number of floating-point
* operations executed by subroutine l, with N=NN(k), matrix
* type j, and LDA=LDAS(i), MAXB=MAXBS(i), NBLOCK=NNB(i), and
* NSHIFT=NSHFTS(i).
*
* LDO1 (input) INTEGER
* The first dimension of OPCNTS. LDO1 >= min( 1, NPARMS ).
*
* LDO2 (input) INTEGER
* The second dimension of OPCNTS. LDO2 >= min( 1, NTYPES ).
*
* LDO3 (input) INTEGER
* The third dimension of OPCNTS. LDO3 >= min( 1, NSIZES ).
*
* INFO (output) INTEGER
* Error flag. It will be set to zero if no error occurred.
*
* =====================================================================
*
* .. Parameters ..
INTEGER MAXTYP, NSUBS
PARAMETER ( MAXTYP = 8, NSUBS = 12 )
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
* ..
* .. Local Scalars ..
LOGICAL RUNHQR, RUNHRD, RUNORT, RUNQRE, RUNQRS
INTEGER IC, ICONDS, IINFO, IMODE, IN, IPAR, ISUB,
$ ITEMP, ITYPE, J, J1, J2, J3, J4, JC, JR, LASTL,
$ LASTNL, LDA, LDAMIN, LDH, LDT, LDW, MAXB,
$ MBMAX, MTYPES, N, NB, NBMAX, NMAX, NSBMAX,
$ NSHIFT, NSMAX
DOUBLE PRECISION CONDS, RTULP, RTULPI, S1, S2, TIME, ULP,
$ ULPINV, UNTIME
* ..
* .. Local Arrays ..
LOGICAL TIMSUB( NSUBS )
CHARACTER ADUMMA( 1 )
CHARACTER*4 PNAMES( 4 )
CHARACTER*9 SUBNAM( NSUBS )
INTEGER INPARM( NSUBS ), IOLDSD( 4 ), KCONDS( MAXTYP ),
$ KMODE( MAXTYP )
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DOPLA, DSECND
EXTERNAL DLAMCH, DOPLA, DSECND
* ..
* .. External Subroutines ..
EXTERNAL ATIMIN, DGEHRD, DHSEIN, DHSEQR, DLACPY, DLASET,
$ DLATME, DPRTBE, DTREVC, HQR, HQR2, INVIT,
$ ORTHES, XLAENV
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, DBLE, MAX, MIN, SQRT
* ..
* .. Scalars in Common ..
DOUBLE PRECISION ITCNT, OPS
* ..
* .. Common blocks ..
COMMON / LATIME / OPS, ITCNT
* ..
* .. Data statements ..
DATA SUBNAM / 'DGEHRD', 'DHSEQR(E)', 'DHSEQR(S)',
$ 'DHSEQR(V)', 'DTREVC(L)', 'DTREVC(R)',
$ 'DHSEIN(L)', 'DHSEIN(R)', 'ORTHES', 'HQR',
$ 'HQR2', 'INVIT' /
DATA INPARM / 2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1 /
DATA PNAMES / 'LDA', 'NB', 'NS', 'MAXB' /
DATA KMODE / 4, 3, 1, 5, 4, 3, 1, 5 /
DATA KCONDS / 4*1, 4*2 /
* ..
* .. Executable Statements ..
*
* Quick Return
*
INFO = 0
IF( NSIZES.LE.0 .OR. NTYPES.LE.0 .OR. NPARMS.LE.0 )
$ RETURN
*
* Extract the timing request from the input line.
*
CALL ATIMIN( 'DHS', LINE, NSUBS, SUBNAM, TIMSUB, NOUT, INFO )
IF( INFO.NE.0 )
$ RETURN
*
* Compute Maximum Values
*
NMAX = 0
DO 10 J1 = 1, NSIZES
NMAX = MAX( NMAX, NN( J1 ) )
10 CONTINUE
*
LDAMIN = 2*MAX( 1, NMAX )
NBMAX = 0
NSMAX = 0
MBMAX = 0
NSBMAX = 0
DO 20 J1 = 1, NPARMS
LDAMIN = MIN( LDAMIN, LDAS( J1 ) )
NBMAX = MAX( NBMAX, NNB( J1 ) )
NSMAX = MAX( NSMAX, NSHFTS( J1 ) )
MBMAX = MAX( MBMAX, MAXBS( J1 ) )
NSBMAX = MAX( NSBMAX, NNB( J1 )+NSHFTS( J1 ) )
20 CONTINUE
*
* Check that N <= LDA for the input values.
*
IF( NMAX.GT.LDAMIN ) THEN
INFO = -10
WRITE( NOUT, FMT = 9999 )LINE( 1: 6 )
9999 FORMAT( 1X, A, ' timing run not attempted -- N > LDA', / )
RETURN
END IF
*
* Check LWORK
*
IF( LWORK.LT.MAX( NMAX*MAX( 3*NBMAX+2, NSBMAX+1 ),
$ NSMAX*( NSMAX+NMAX ), MBMAX*( MBMAX+NMAX ),
$ ( NMAX+1 )*( NMAX+4 ), NSIZES*NTYPES*NPARMS ) ) THEN
INFO = -19
WRITE( NOUT, FMT = 9998 )LINE( 1: 6 )
9998 FORMAT( 1X, A, ' timing run not attempted -- LWORK too small.',
$ / )
RETURN
END IF
*
* Check to see whether DGEHRD or DHSEQR must be run.
*
* RUNQRE -- if DHSEQR must be run to get eigenvalues.
* RUNQRS -- if DHSEQR must be run to get Schur form.
* RUNHRD -- if DGEHRD must be run.
*
RUNQRS = .FALSE.
RUNQRE = .FALSE.
RUNHRD = .FALSE.
IF( TIMSUB( 5 ) .OR. TIMSUB( 6 ) )
$ RUNQRS = .TRUE.
IF( ( TIMSUB( 7 ) .OR. TIMSUB( 8 ) ) )
$ RUNQRE = .TRUE.
IF( TIMSUB( 2 ) .OR. TIMSUB( 3 ) .OR. TIMSUB( 4 ) .OR. RUNQRS .OR.
$ RUNQRE )RUNHRD = .TRUE.
IF( TIMSUB( 3 ) .OR. TIMSUB( 4 ) .OR. RUNQRS )
$ RUNQRE = .FALSE.
IF( TIMSUB( 4 ) )
$ RUNQRS = .FALSE.
*
* Check to see whether ORTHES or HQR must be run.
*
* RUNHQR -- if HQR must be run to get eigenvalues.
* RUNORT -- if ORTHES must be run.
*
RUNHQR = .FALSE.
RUNORT = .FALSE.
IF( TIMSUB( 12 ) )
$ RUNHQR = .TRUE.
IF( TIMSUB( 10 ) .OR. TIMSUB( 11 ) .OR. RUNHQR )
$ RUNORT = .TRUE.
IF( TIMSUB( 10 ) .OR. TIMSUB( 11 ) )
$ RUNHQR = .FALSE.
IF( TIMSUB( 9 ) )
$ RUNORT = .FALSE.
*
* Various Constants
*
ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
ULPINV = ONE / ULP
RTULP = SQRT( ULP )
RTULPI = ONE / RTULP
*
* Zero out OPCNTS, TIMES
*
DO 60 J4 = 1, NSUBS
DO 50 J3 = 1, NSIZES
DO 40 J2 = 1, NTYPES
DO 30 J1 = 1, NPARMS
OPCNTS( J1, J2, J3, J4 ) = ZERO
TIMES( J1, J2, J3, J4 ) = ZERO
30 CONTINUE
40 CONTINUE
50 CONTINUE
60 CONTINUE
*
* Do for each value of N:
*
DO 620 IN = 1, NSIZES
*
N = NN( IN )
*
* Do for each .TRUE. value in DOTYPE:
*
MTYPES = MIN( MAXTYP, NTYPES )
IF( NTYPES.EQ.MAXTYP+1 .AND. NSIZES.EQ.1 )
$ MTYPES = NTYPES
DO 610 ITYPE = 1, MTYPES
IF( .NOT.DOTYPE( ITYPE ) )
$ GO TO 610
*
* Save random number seed for error messages
*
DO 70 J = 1, 4
IOLDSD( J ) = ISEED( J )
70 CONTINUE
*
*-----------------------------------------------------------------------
*
* Time the LAPACK Routines
*
* Generate A
*
IF( ITYPE.LE.MAXTYP ) THEN
IMODE = KMODE( ITYPE )
ICONDS = KCONDS( ITYPE )
IF( ICONDS.EQ.1 ) THEN
CONDS = ONE
ELSE
CONDS = RTULPI
END IF
ADUMMA( 1 ) = ' '
CALL DLATME( N, 'S', ISEED, WORK, IMODE, ULPINV, ONE,
$ ADUMMA, 'T', 'T', 'T', WORK( N+1 ), 4,
$ CONDS, N, N, ONE, A, N, WORK( 2*N+1 ),
$ IINFO )
END IF
*
* Time DGEHRD for each pair NNB(j), LDAS(j)
*
IF( TIMSUB( 1 ) ) THEN
DO 110 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
NB = MIN( N, NNB( IPAR ) )
*
* If this combination of (NB,LDA) has occurred before,
* just use that value.
*
LASTNL = 0
DO 80 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) .AND. NB.EQ.
$ MIN( N, NNB( J ) ) )LASTNL = J
80 CONTINUE
*
IF( LASTNL.EQ.0 ) THEN
CALL XLAENV( 1, NB )
CALL XLAENV( 2, 2 )
CALL XLAENV( 3, NB )
*
* Time DGEHRD
*
IC = 0
OPS = ZERO
S1 = DSECND( )
90 CONTINUE
CALL DLACPY( 'Full', N, N, A, N, H, LDA )
*
CALL DGEHRD( N, 1, N, H, LDA, WORK, WORK( N+1 ),
$ LWORK-N, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 1 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
*
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 90
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 100 J = 1, IC
CALL DLACPY( 'Full', N, N, A, N, Z, LDA )
100 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 1 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 1 ) = DOPLA( 'DGEHRD', N,
$ 1, N, 0, NB )
ELSE
OPCNTS( IPAR, ITYPE, IN, 1 ) = OPCNTS( LASTNL,
$ ITYPE, IN, 1 )
TIMES( IPAR, ITYPE, IN, 1 ) = TIMES( LASTNL, ITYPE,
$ IN, 1 )
END IF
110 CONTINUE
LDH = LDA
ELSE
IF( RUNHRD ) THEN
CALL DLACPY( 'Full', N, N, A, N, H, N )
*
CALL DGEHRD( N, 1, N, H, N, WORK, WORK( N+1 ),
$ LWORK-N, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 1 ), IINFO, N,
$ ITYPE, 0, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
LDH = N
END IF
END IF
*
* Time DHSEQR with JOB='E' for each 4-tuple
* NNB(j), NSHFTS(j), MAXBS(j), LDAS(j)
*
IF( TIMSUB( 2 ) ) THEN
DO 140 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
NB = 1
NSHIFT = NSHFTS( IPAR )
MAXB = MAXBS( IPAR )
CALL XLAENV( 4, NSHIFT )
CALL XLAENV( 8, MAXB )
*
* Time DHSEQR with JOB='E'
*
IC = 0
OPS = ZERO
S1 = DSECND( )
120 CONTINUE
CALL DLACPY( 'Full', N, N, H, LDH, A, LDA )
*
CALL DHSEQR( 'E', 'N', N, 1, N, A, LDA, W, W( LDA+1 ),
$ Z, LDA, WORK, LWORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 2 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
*
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 120
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 130 J = 1, IC
CALL DLACPY( 'Full', N, N, H, LDH, Z, LDA )
130 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 2 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 2 ) = OPS / DBLE( IC )
140 CONTINUE
LDT = 0
LDW = LDA
ELSE
IF( RUNQRE ) THEN
CALL DLACPY( 'Full', N, N, H, LDH, A, N )
*
CALL DHSEQR( 'E', 'N', N, 1, N, A, N, W, W( N+1 ), Z,
$ N, WORK, LWORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 2 ), IINFO, N,
$ ITYPE, 0, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
LDT = 0
LDW = N
END IF
END IF
*
* Time DHSEQR with JOB='S' for each 4-tuple
* NNB(j), NSHFTS(j), MAXBS(j), LDAS(j)
*
IF( TIMSUB( 3 ) ) THEN
DO 170 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
NSHIFT = NSHFTS( IPAR )
MAXB = MAXBS( IPAR )
NB = 1
CALL XLAENV( 4, NSHIFT )
CALL XLAENV( 8, MAXB )
*
* Time DHSEQR with JOB='S'
*
IC = 0
OPS = ZERO
S1 = DSECND( )
150 CONTINUE
CALL DLACPY( 'Full', N, N, H, LDH, A, LDA )
*
CALL DHSEQR( 'S', 'N', N, 1, N, A, LDA, W, W( LDA+1 ),
$ Z, LDA, WORK, LWORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 3 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
*
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 150
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 160 J = 1, IC
CALL DLACPY( 'Full', N, N, H, LDH, Z, LDA )
160 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 3 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 3 ) = OPS / DBLE( IC )
170 CONTINUE
LDT = LDA
LDW = LDA
ELSE
IF( RUNQRS ) THEN
CALL DLACPY( 'Full', N, N, H, LDH, A, N )
*
CALL DHSEQR( 'S', 'N', N, 1, N, A, N, W, W( N+1 ), Z,
$ N, WORK, LWORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 3 ), IINFO, N,
$ ITYPE, 0, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
LDT = N
LDW = N
END IF
END IF
*
* Time DHSEQR with JOB='I' for each 4-tuple
* NNB(j), NSHFTS(j), MAXBS(j), LDAS(j)
*
IF( TIMSUB( 4 ) ) THEN
DO 200 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
NSHIFT = NSHFTS( IPAR )
MAXB = MAXBS( IPAR )
NB = 1
CALL XLAENV( 4, NSHIFT )
CALL XLAENV( 8, MAXB )
*
* Time DHSEQR with JOB='I'
*
IC = 0
OPS = ZERO
S1 = DSECND( )
180 CONTINUE
CALL DLACPY( 'Full', N, N, H, LDH, A, LDA )
*
CALL DHSEQR( 'S', 'I', N, 1, N, A, LDA, W, W( LDA+1 ),
$ Z, LDA, WORK, LWORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 4 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
*
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 180
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 190 J = 1, IC
CALL DLACPY( 'Full', N, N, H, LDH, Z, LDA )
190 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 4 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 4 ) = OPS / DBLE( IC )
200 CONTINUE
LDT = LDA
LDW = LDA
END IF
*
* Time DTREVC and DHSEIN with various values of LDA
*
* Select All Eigenvectors
*
DO 210 J = 1, N
LLWORK( J ) = .TRUE.
210 CONTINUE
*
DO 370 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
*
* If this value of LDA has come up before, just use
* the value previously computed.
*
LASTL = 0
DO 220 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) )
$ LASTL = J
220 CONTINUE
*
* Time DTREVC
*
IF( ( TIMSUB( 5 ) .OR. TIMSUB( 6 ) ) .AND. LASTL.EQ.0 )
$ THEN
*
* Copy T (which is in A) if necessary to get right LDA.
*
IF( LDA.GT.LDT ) THEN
DO 240 JC = N, 1, -1
DO 230 JR = N, 1, -1
A( JR+( JC-1 )*LDA ) = A( JR+( JC-1 )*LDT )
230 CONTINUE
240 CONTINUE
ELSE IF( LDA.LT.LDT ) THEN
DO 260 JC = 1, N
DO 250 JR = 1, N
A( JR+( JC-1 )*LDA ) = A( JR+( JC-1 )*LDT )
250 CONTINUE
260 CONTINUE
END IF
LDT = LDA
*
* Time DTREVC for Left Eigenvectors
*
IF( TIMSUB( 5 ) ) THEN
IC = 0
OPS = ZERO
S1 = DSECND( )
270 CONTINUE
*
CALL DTREVC( 'L', 'A', LLWORK, N, A, LDA, Z, LDA,
$ Z, LDA, N, ITEMP, WORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 5 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 270
*
TIMES( IPAR, ITYPE, IN, 5 ) = TIME / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 5 ) = OPS / DBLE( IC )
END IF
*
* Time DTREVC for Right Eigenvectors
*
IF( TIMSUB( 6 ) ) THEN
IC = 0
OPS = ZERO
S1 = DSECND( )
280 CONTINUE
CALL DTREVC( 'R', 'A', LLWORK, N, A, LDA, Z, LDA,
$ Z, LDA, N, ITEMP, WORK, IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 6 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 280
*
TIMES( IPAR, ITYPE, IN, 6 ) = TIME / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 6 ) = OPS / DBLE( IC )
END IF
ELSE
IF( TIMSUB( 5 ) ) THEN
OPCNTS( IPAR, ITYPE, IN, 5 ) = OPCNTS( LASTL,
$ ITYPE, IN, 5 )
TIMES( IPAR, ITYPE, IN, 5 ) = TIMES( LASTL, ITYPE,
$ IN, 5 )
END IF
IF( TIMSUB( 6 ) ) THEN
OPCNTS( IPAR, ITYPE, IN, 6 ) = OPCNTS( LASTL,
$ ITYPE, IN, 6 )
TIMES( IPAR, ITYPE, IN, 6 ) = TIMES( LASTL, ITYPE,
$ IN, 6 )
END IF
END IF
*
* Time DHSEIN
*
IF( ( TIMSUB( 7 ) .OR. TIMSUB( 8 ) ) .AND. LASTL.EQ.0 )
$ THEN
*
* Copy H if necessary to get right LDA.
*
IF( LDA.GT.LDH ) THEN
DO 300 JC = N, 1, -1
DO 290 JR = N, 1, -1
H( JR+( JC-1 )*LDA ) = H( JR+( JC-1 )*LDH )
290 CONTINUE
W( JC+LDA ) = W( JC+LDH )
300 CONTINUE
ELSE IF( LDA.LT.LDH ) THEN
DO 320 JC = 1, N
DO 310 JR = 1, N
H( JR+( JC-1 )*LDA ) = H( JR+( JC-1 )*LDH )
310 CONTINUE
W( JC+LDA ) = W( JC+LDH )
320 CONTINUE
END IF
LDH = LDA
*
* Copy W if necessary to get right LDA.
*
IF( LDA.GT.LDW ) THEN
DO 330 J = N, 1, -1
W( J+LDA ) = W( J+LDW )
330 CONTINUE
ELSE IF( LDA.LT.LDW ) THEN
DO 340 J = 1, N
W( J+LDA ) = W( J+LDW )
340 CONTINUE
END IF
LDW = LDA
*
* Time DHSEIN for Left Eigenvectors
*
IF( TIMSUB( 7 ) ) THEN
IC = 0
OPS = ZERO
S1 = DSECND( )
350 CONTINUE
*
CALL DHSEIN( 'L', 'Q', 'N', LLWORK, N, H, LDA, W,
$ W( LDA+1 ), Z, LDA, Z, LDA, N, ITEMP,
$ WORK, IWORK, IWORK( N+1 ), IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 7 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 350
*
TIMES( IPAR, ITYPE, IN, 7 ) = TIME / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 7 ) = OPS / DBLE( IC )
END IF
*
* Time DHSEIN for Right Eigenvectors
*
IF( TIMSUB( 8 ) ) THEN
IC = 0
OPS = ZERO
S1 = DSECND( )
360 CONTINUE
*
CALL DHSEIN( 'R', 'Q', 'N', LLWORK, N, H, LDA, W,
$ W( LDA+1 ), Z, LDA, Z, LDA, N, ITEMP,
$ WORK, IWORK, IWORK( N+1 ), IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 8 ), IINFO, N,
$ ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 360
*
TIMES( IPAR, ITYPE, IN, 8 ) = TIME / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 8 ) = OPS / DBLE( IC )
END IF
ELSE
IF( TIMSUB( 7 ) ) THEN
OPCNTS( IPAR, ITYPE, IN, 7 ) = OPCNTS( LASTL,
$ ITYPE, IN, 7 )
TIMES( IPAR, ITYPE, IN, 7 ) = TIMES( LASTL, ITYPE,
$ IN, 7 )
END IF
IF( TIMSUB( 8 ) ) THEN
OPCNTS( IPAR, ITYPE, IN, 8 ) = OPCNTS( LASTL,
$ ITYPE, IN, 8 )
TIMES( IPAR, ITYPE, IN, 8 ) = TIMES( LASTL, ITYPE,
$ IN, 8 )
END IF
END IF
370 CONTINUE
*
*-----------------------------------------------------------------------
*
* Time the EISPACK Routines
*
* Restore random number seed
*
DO 380 J = 1, 4
ISEED( J ) = IOLDSD( J )
380 CONTINUE
*
* Re-generate A
*
IF( ITYPE.LE.MAXTYP ) THEN
IMODE = KMODE( ITYPE )
IF( ICONDS.EQ.1 ) THEN
CONDS = ONE
ELSE
CONDS = RTULPI
END IF
CALL DLATME( N, 'S', ISEED, WORK, IMODE, ULPINV, ONE,
$ ADUMMA, 'T', 'T', 'T', WORK( N+1 ), 4,
$ CONDS, N, N, ONE, A, N, WORK( 2*N+1 ),
$ IINFO )
END IF
*
* Time ORTHES for each LDAS(j)
*
IF( TIMSUB( 9 ) ) THEN
DO 420 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
*
* If this value of LDA has come up before, just use
* the value previously computed.
*
LASTL = 0
DO 390 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) )
$ LASTL = J
390 CONTINUE
*
IF( LASTL.EQ.0 ) THEN
*
* Time ORTHES
*
IC = 0
OPS = ZERO
S1 = DSECND( )
*
400 CONTINUE
CALL DLACPY( 'Full', N, N, A, N, H, LDA )
*
CALL ORTHES( LDA, N, 1, N, H, WORK )
*
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 400
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 410 J = 1, IC
CALL DLACPY( 'Full', N, N, A, N, Z, LDA )
410 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
* OPS1 = ( 20*N**3 - 3*N**2 - 23*N ) / 6 - 17
*
TIMES( IPAR, ITYPE, IN, 9 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 9 ) = OPS / DBLE( IC )
ELSE
OPCNTS( IPAR, ITYPE, IN, 9 ) = OPCNTS( LASTL,
$ ITYPE, IN, 9 )
TIMES( IPAR, ITYPE, IN, 9 ) = TIMES( LASTL, ITYPE,
$ IN, 9 )
END IF
LDH = LDA
420 CONTINUE
ELSE
IF( RUNORT ) THEN
CALL DLACPY( 'Full', N, N, A, N, H, N )
*
CALL ORTHES( N, N, 1, N, H, WORK )
*
LDH = N
END IF
END IF
*
* Time HQR for each LDAS(j)
*
IF( TIMSUB( 10 ) ) THEN
DO 460 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
*
* If this value of LDA has come up before, just use
* the value previously computed.
*
LASTL = 0
DO 430 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) )
$ LASTL = J
430 CONTINUE
*
IF( LASTL.EQ.0 ) THEN
*
* Time HQR
*
IC = 0
OPS = ZERO
S1 = DSECND( )
440 CONTINUE
CALL DLACPY( 'Full', N, N, H, LDH, A, LDA )
*
CALL HQR( LDA, N, 1, N, A, W, W( LDA+1 ), IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 10 ), IINFO,
$ N, ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 440
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 450 J = 1, IC
CALL DLACPY( 'Full', N, N, H, LDH, Z, LDA )
450 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 10 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 10 ) = OPS / DBLE( IC )
ELSE
OPCNTS( IPAR, ITYPE, IN, 10 ) = OPCNTS( LASTL,
$ ITYPE, IN, 10 )
TIMES( IPAR, ITYPE, IN, 10 ) = TIMES( LASTL, ITYPE,
$ IN, 10 )
END IF
LDW = LDA
460 CONTINUE
ELSE
IF( RUNHQR ) THEN
CALL DLACPY( 'Full', N, N, A, N, H, N )
*
CALL HQR( N, N, 1, N, A, W, W( N+1 ), IINFO )
*
LDW = N
END IF
END IF
*
* Time HQR2 for each LDAS(j)
*
IF( TIMSUB( 11 ) ) THEN
DO 500 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
*
* If this value of LDA has come up before, just use
* the value previously computed.
*
LASTL = 0
DO 470 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) )
$ LASTL = J
470 CONTINUE
*
IF( LASTL.EQ.0 ) THEN
*
* Time HQR2
*
IC = 0
OPS = ZERO
S1 = DSECND( )
480 CONTINUE
CALL DLACPY( 'Full', N, N, H, LDH, A, LDA )
CALL DLASET( 'Full', N, N, ZERO, ONE, Z, LDA )
*
CALL HQR2( LDA, N, 1, N, A, W, W( LDA+1 ), Z,
$ IINFO )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 11 ), IINFO,
$ N, ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 480
*
* Subtract the time used in DLACPY.
*
S1 = DSECND( )
DO 490 J = 1, IC
CALL DLACPY( 'Full', N, N, H, LDH, Z, LDA )
490 CONTINUE
S2 = DSECND( )
UNTIME = S2 - S1
*
TIMES( IPAR, ITYPE, IN, 11 ) = MAX( TIME-UNTIME,
$ ZERO ) / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 11 ) = OPS / DBLE( IC )
ELSE
OPCNTS( IPAR, ITYPE, IN, 11 ) = OPCNTS( LASTL,
$ ITYPE, IN, 11 )
TIMES( IPAR, ITYPE, IN, 11 ) = TIMES( LASTL, ITYPE,
$ IN, 11 )
END IF
LDW = LDA
500 CONTINUE
END IF
*
* Time INVIT for each LDAS(j)
*
* Select All Eigenvectors
*
DO 510 J = 1, N
LLWORK( J ) = .TRUE.
510 CONTINUE
*
IF( TIMSUB( 12 ) ) THEN
DO 600 IPAR = 1, NPARMS
LDA = LDAS( IPAR )
*
* If this value of LDA has come up before, just use
* the value previously computed.
*
LASTL = 0
DO 520 J = 1, IPAR - 1
IF( LDA.EQ.LDAS( J ) )
$ LASTL = J
520 CONTINUE
*
IF( LASTL.EQ.0 ) THEN
*
* Copy H if necessary to get right LDA.
*
IF( LDA.GT.LDH ) THEN
DO 540 JC = N, 1, -1
DO 530 JR = N, 1, -1
H( JR+( JC-1 )*LDA ) = H( JR+( JC-1 )*
$ LDH )
530 CONTINUE
540 CONTINUE
ELSE IF( LDA.LT.LDH ) THEN
DO 560 JC = 1, N
DO 550 JR = 1, N
H( JR+( JC-1 )*LDA ) = H( JR+( JC-1 )*
$ LDH )
550 CONTINUE
560 CONTINUE
END IF
LDH = LDA
*
* Copy W if necessary to get right LDA.
*
IF( LDA.GT.LDW ) THEN
DO 570 J = N, 1, -1
W( J+LDA ) = W( J+LDW )
570 CONTINUE
ELSE IF( LDA.LT.LDW ) THEN
DO 580 J = 1, N
W( J+LDA ) = W( J+LDW )
580 CONTINUE
END IF
LDW = LDA
*
* Time INVIT for right eigenvectors.
*
IC = 0
OPS = ZERO
S1 = DSECND( )
590 CONTINUE
*
CALL INVIT( LDA, N, H, W, W( LDA+1 ), LLWORK, N,
$ ITEMP, Z, IINFO, WORK( 2*N+1 ), WORK,
$ WORK( N+1 ) )
*
IF( IINFO.NE.0 ) THEN
WRITE( NOUT, FMT = 9997 )SUBNAM( 12 ), IINFO,
$ N, ITYPE, IPAR, IOLDSD
INFO = ABS( IINFO )
GO TO 610
END IF
S2 = DSECND( )
TIME = S2 - S1
IC = IC + 1
IF( TIME.LT.TIMMIN )
$ GO TO 590
*
* TIME = TIME / DOUBLE PRECISION( IC )
* OPS1 = OPS / DOUBLE PRECISION( IC )
* OPCNTS( IPAR, ITYPE, IN, 12 ) = OPS1
* TIMES( IPAR, ITYPE, IN, 12 ) = DMFLOP( OPS1, TIME,
* $ IINFO )
*
TIMES( IPAR, ITYPE, IN, 12 ) = TIME / DBLE( IC )
OPCNTS( IPAR, ITYPE, IN, 12 ) = OPS / DBLE( IC )
ELSE
OPCNTS( IPAR, ITYPE, IN, 12 ) = OPCNTS( LASTL,
$ ITYPE, IN, 12 )
TIMES( IPAR, ITYPE, IN, 12 ) = TIMES( LASTL, ITYPE,
$ IN, 12 )
END IF
600 CONTINUE
END IF
*
610 CONTINUE
620 CONTINUE
*
*-----------------------------------------------------------------------
*
* Print a table of results for each timed routine.
*
ISUB = 1
IF( TIMSUB( ISUB ) ) THEN
CALL DPRTBE( SUBNAM( ISUB ), MTYPES, DOTYPE, NSIZES, NN,
$ INPARM( ISUB ), PNAMES, NPARMS, LDAS, NNB, NSHFTS,
$ MAXBS, OPCNTS( 1, 1, 1, ISUB ), LDO1, LDO2,
$ TIMES( 1, 1, 1, ISUB ), LDT1, LDT2, WORK, LLWORK,
$ NOUT )
END IF
*
DO 630 IN = 1, NPARMS
NNB( IN ) = 1
630 CONTINUE
*
DO 640 ISUB = 2, NSUBS
IF( TIMSUB( ISUB ) ) THEN
CALL DPRTBE( SUBNAM( ISUB ), MTYPES, DOTYPE, NSIZES, NN,
$ INPARM( ISUB ), PNAMES, NPARMS, LDAS, NNB,
$ NSHFTS, MAXBS, OPCNTS( 1, 1, 1, ISUB ), LDO1,
$ LDO2, TIMES( 1, 1, 1, ISUB ), LDT1, LDT2, WORK,
$ LLWORK, NOUT )
END IF
640 CONTINUE
*
RETURN
*
* End of DTIM21
*
9997 FORMAT( ' DTIM21: ', A, ' returned INFO=', I6, '.', / 9X, 'N=',
$ I6, ', ITYPE=', I6, ', IPAR=', I6, ', ISEED=(',
$ 3( I5, ',' ), I5, ')' )
*
END
| bsd-3-clause |
CavendishAstrophysics/anmap | graphic_lib/graphic_get_grline.f | 1 | 15831 | *+ graphic_get_grline
subroutine graphic_get_grline( gopt, ntb, ib, tb, s )
C -----------------------------------------------------
C
C Read a description for graphics line options from the user
C
include '../include/plt_buffer_defn.inc'
C
C Updated:
C graphics line options structure
integer gopt(*)
C Given:
C number of text buffers
integer ntb
C Updated:
C index to text buffers
integer ib(ntb)
C text buffers
character*(ltb) tb(ntb)
C error status
integer s
C
C A series of options are presented to the user to modify the graphics
C line options for the grline structure
C-
include '../include/plt_basic_defn.inc'
include '../include/plt_grline_defn.inc'
include '/mrao/include/chrlib_functions.inc'
include '/mrao/include/iolib_functions.inc'
include '/mrao/include/iolib_constants.inc'
C local variables
integer l, lf, ls, lcli
integer nopt
character*60 option(28), opt, string*80
character*(iolen_file) file
character*256 function
C check status on entry
if ( s.ne.0 ) return
C copy the structure to the standard definition
do l = 1,len_grline
grline(l) = gopt(l)
enddo
C get default options if not initialised
if (grline_status.eq.0) then
call graphic_default_grline( grline, 3, s )
endif
C setup sub-options for this command
option(1) ='reset-style ...... reset style options'
option(2) ='reset-file ....... reset file name(s) & columns'
option(3) ='file ............. set file name for X & Y axes'
option(4) ='list ............. set list names for X & Y axes'
option(5) ='function ......... set function to plot'
option(6) ='x-file ........... set file name for X axis'
option(7) ='y-file ........... set file name for Y axis'
option(8) ='x-column ......... specify the X-column in x-file'
option(9) ='y-column ......... specify the Y-column in y-file'
option(10)='x-offset ......... specify absolute offset in X'
option(11)='y-offset ......... specify absolute offset in X'
option(12)='x-scale .......... specify scaling in X'
option(13)='y-scale .......... specify scaling in Y'
option(14)='x-auto-scale ..... auto-scale in X to line 1'
option(15)='y-auto-scale ..... auto-scale in Y to line 1'
option(16)='x-error-bar ...... request error bars in X'
option(17)='y-error-bar ...... request error bars in Y'
option(18)='x-limits ......... request limits in X'
option(19)='y-limits ......... request limits in Y'
option(20)='log-scale ........ select log scale in X & Y'
option(21)='x-log-scale ...... select log scale in X'
option(22)='y-log-scale ...... select log scale in Y'
option(23)='line-style ....... set line-style for line'
option(24)='error-style ...... set style for error bars'
option(25)='symbol-type ...... (de-)select marking data points'
option(26)='line-type ........ set line type (none/std./hist.)'
option(27)='symbol-style ..... set text style for symbols'
option(28)='key-display ...... add this line to key (if shown)'
nopt = 28
* print *,'get option'
1 call io_getopt( 'Option (?=list) : ','reset-style',option,nopt,
* opt,s)
* print *,'decoding'
C take action on options
if (chr_cmatch(opt,'reset-style')) then
call graphic_default_grline(grline,1,s)
elseif (chr_cmatch(opt,'reset-file')) then
call graphic_default_grline(grline,2,s)
elseif (chr_cmatch(opt,'file')) then
if (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('File-name : ',file(1:chr_lenb(file)),
* file,lf,s)
if (s.eq.0) then
if (grline_x_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_x_file,s)
endif
if (grline_y_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_y_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_x_file = l
grline_y_file = l
endif
elseif (chr_cmatch(opt,'function')) then
if (grline_func_opt.eq.grline_func_defined .and.
* grline_func_defn.ne.0) then
call graphic_enq_text(ntb,ib,tb,
* grline_func_defn,function,s)
else
function = ' '
endif
call io_getwrd('Function (in quotes) : ','*',
* function,lf,s)
if (s.eq.0) then
if (grline_func_defn.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_func_defn,s)
endif
endif
call graphic_put_text(ntb,ib,tb,function(1:lf),
* grline_func_defn,s)
if (s.eq.0) then
grline_func_opt = grline_func_defined
endif
elseif (chr_cmatch(opt,'list')) then
if (grline_list_opt.eq.grline_list_defined .and.
* grline_list_defn.ne.0) then
call graphic_enq_text(ntb,ib,tb,
* grline_list_defn,function,s)
else
function = ' '
endif
call io_getwrd('X and Y lists (in quotes) : ','*',
* function,lf,s)
if (s.eq.0) then
if (grline_list_defn.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_list_defn,s)
endif
endif
call graphic_put_text(ntb,ib,tb,function(1:lf),
* grline_list_defn,s)
if (s.eq.0) then
grline_list_opt = grline_list_defined
endif
elseif (chr_cmatch(opt,'x-file')) then
if (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('X-file-name : ',file(1:chr_lenb(file)),
* file,lf,s)
if (s.eq.0) then
if (grline_x_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_x_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_x_file = l
endif
elseif (chr_cmatch(opt,'y-file')) then
if (grline_y_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_y_file,file,s)
elseif (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('Y-file-name : ',file(1:chr_lenb(file)),
* file,lf,s)
if (s.eq.0) then
if (grline_y_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_y_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_y_file = l
endif
elseif (chr_cmatch(opt,'x-column')) then
call io_geti('X-column : ','*',grline_x_col,s)
elseif (chr_cmatch(opt,'y-column')) then
call io_geti('Y-column : ','*',grline_y_col,s)
elseif (chr_cmatch(opt,'x-offset')) then
call io_getr('Offset-in-x : ','*',grline_offset_x,s)
elseif (chr_cmatch(opt,'y-offset')) then
call io_getr('Offset-in-y : ','*',grline_offset_y,s)
elseif (chr_cmatch(opt,'x-scale')) then
call io_getr('Scale-x : ','*',grline_scale_x,s)
elseif (chr_cmatch(opt,'y-scale')) then
call io_getr('Scale-y : ','*',grline_scale_y,s)
elseif (chr_cmatch(opt,'x-auto-scale')) then
grline_auto_x = io_onoff('X-auto-scaling (on/off) : ',
* 'off',s)
elseif (chr_cmatch(opt,'log-scale')) then
if (io_onoff('X-log-scaling (on/off) : ','off',s)) then
grline_x_log = .true.
grline_y_log = .true.
endif
elseif (chr_cmatch(opt,'x-log-scale')) then
grline_x_log = io_onoff('X-log-scaling (on/off) : ',
* 'off',s)
elseif (chr_cmatch(opt,'y-log-scale')) then
grline_y_log = io_onoff('Y-log-scaling (on/off) : ',
* 'off',s)
elseif (chr_cmatch(opt,'y-auto-scale')) then
grline_auto_y = io_onoff('Y-auto-scaling (on/off) : ',
* 'off',s)
elseif (chr_cmatch(opt,'line-style')) then
call graphic_get_line_opt(grline_line_opt,s)
elseif (chr_cmatch(opt,'error-style')) then
call io_getr('Size of error-top-x : ','*',grline_ex_top,s)
call io_getr('Size of error-top-y : ','*',grline_ey_top,s)
call graphic_get_line_opt(grline_error_opt,s)
elseif (chr_cmatch(opt,'symbol-style')) then
call graphic_get_text_opt(grline_text_opt,s)
elseif (chr_cmatch(opt,'symbol-type')) then
call io_geti('Line-display (0=none >0=symbol) : ',
* '*',grline_symbol,s)
elseif (chr_cmatch(opt,'line-type')) then
call io_geti('Line-display (0=none 1=line 2=histogram) : ',
* '*',grline_type,s)
elseif (chr_cmatch(opt,'y-error-bar')) then
if (io_yesno('Display-y-error-bar ? ','no',s)) then
grline_ey_opt = 1
if (grline_list_opt.eq.grline_list_defined) then
call io_getwrd('Y-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
else
if (grline_ey_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_ey_file,file,s)
elseif (grline_y_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_y_file,file,s)
elseif (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('File-y-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
call io_geti('Column-error-bar-y : ','3',grline_ey_col,s)
endif
if (s.eq.0) then
if (grline_ey_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_ey_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_ey_file = l
endif
else
grline_ey_opt = 0
endif
elseif (chr_cmatch(opt,'x-error-bar')) then
if (io_yesno('Display-x-error-bar ? ','no',s)) then
grline_ex_opt = 1
if (grline_list_opt.eq.grline_list_defined) then
call io_getwrd('X-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
else
if (grline_ex_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_ex_file,file,s)
elseif (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('File-x-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
call io_geti('Column-error-bar-y : ','3',grline_ex_col,s)
endif
if (s.eq.0) then
if (grline_ex_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_ex_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_ex_file = l
endif
else
grline_ex_opt = 0
endif
elseif (chr_cmatch(opt,'y-limits')) then
if (io_yesno('Display-y-limits ? ','no',s)) then
grline_ey_opt = 2
if (grline_list_opt.eq.grline_list_defined) then
call io_getwrd('Y-limit-list : ',
* file(1:chr_lenb(file)),file,lf,s)
else
if (grline_ey_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_ey_file,file,s)
elseif (grline_y_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_y_file,file,s)
elseif (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('File-y-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
call io_geti('1st-Column-y-limit : ','3',
* grline_ey_col,s)
endif
if (s.eq.0) then
if (grline_ey_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_ey_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_ey_file = l
endif
else
grline_ey_opt = 0
endif
elseif (chr_cmatch(opt,'x-limits')) then
if (io_yesno('Display-x-limits ? ','no',s)) then
grline_ex_opt = 2
if (grline_list_opt.eq.grline_list_defined) then
call io_getwrd('X-limit-list : ',
* file(1:chr_lenb(file)),file,lf,s)
else
if (grline_ex_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_ex_file,file,s)
elseif (grline_x_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_x_file,file,s)
elseif (grline_y_file.ne.0) then
call graphic_enq_text(ntb,ib,tb,grline_y_file,file,s)
else
file = 'data.dat'
endif
call io_getwrd('File-x-error-bar : ',
* file(1:chr_lenb(file)),file,lf,s)
call io_geti('1st-Column-x-limit : ','3',
* grline_ex_col,s)
endif
if (s.eq.0) then
if (grline_ex_file.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_ex_file,s)
endif
endif
call graphic_put_text(ntb,ib,tb,file(1:lf),l,s)
if (s.eq.0) then
grline_ex_file = l
endif
else
grline_ex_opt = 0
endif
elseif (chr_cmatch(opt,'key-display')) then
call io_geti(
* 'Key-option (0=off 1=file-name 2=supplied-text) : ',
* '*',grline_key_opt,s)
if (grline_key_opt.eq.2) then
call io_getwrd('Key-string (''in quotes'') : ',
* ' ',string,ls,s)
if (s.eq.0) then
if (grline_key_text.ne.0) then
call graphic_delete_text(ntb,ib,tb,grline_key_text,s)
endif
endif
call graphic_put_text(ntb,ib,tb,string(1:ls),
* grline_key_text,s)
endif
endif
call io_enqcli(file,lcli)
if (lcli.gt.0) goto 1
C copy structure to output
if (s.eq.0) then
if (grline_status.eq.0) grline_status = 1
do l=1,len_grline
gopt(l) = grline(l)
enddo
endif
999 continue
call cmd_err( s, 'graphic_get_grline', ' ')
end
| bsd-3-clause |
yaowee/libflame | lapack-test/3.5.0/LIN/derrql.f | 32 | 9420 | *> \brief \b DERRQL
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE DERRQL( PATH, NUNIT )
*
* .. Scalar Arguments ..
* CHARACTER*3 PATH
* INTEGER NUNIT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> DERRQL tests the error exits for the DOUBLE PRECISION routines
*> that use the QL decomposition of a general matrix.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] PATH
*> \verbatim
*> PATH is CHARACTER*3
*> The LAPACK path name for the routines to be tested.
*> \endverbatim
*>
*> \param[in] NUNIT
*> \verbatim
*> NUNIT is INTEGER
*> The unit number for output.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup double_lin
*
* =====================================================================
SUBROUTINE DERRQL( PATH, NUNIT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
CHARACTER*3 PATH
INTEGER NUNIT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER NMAX
PARAMETER ( NMAX = 2 )
* ..
* .. Local Scalars ..
INTEGER I, INFO, J
* ..
* .. Local Arrays ..
DOUBLE PRECISION A( NMAX, NMAX ), AF( NMAX, NMAX ), B( NMAX ),
$ W( NMAX ), X( NMAX )
* ..
* .. External Subroutines ..
EXTERNAL ALAESM, CHKXER, DGEQL2, DGEQLF, DGEQLS, DORG2L,
$ DORGQL, DORM2L, DORMQL
* ..
* .. Scalars in Common ..
LOGICAL LERR, OK
CHARACTER*32 SRNAMT
INTEGER INFOT, NOUT
* ..
* .. Common blocks ..
COMMON / INFOC / INFOT, NOUT, OK, LERR
COMMON / SRNAMC / SRNAMT
* ..
* .. Intrinsic Functions ..
INTRINSIC DBLE
* ..
* .. Executable Statements ..
*
NOUT = NUNIT
WRITE( NOUT, FMT = * )
*
* Set the variables to innocuous values.
*
DO 20 J = 1, NMAX
DO 10 I = 1, NMAX
A( I, J ) = 1.D0 / DBLE( I+J )
AF( I, J ) = 1.D0 / DBLE( I+J )
10 CONTINUE
B( J ) = 0.D0
W( J ) = 0.D0
X( J ) = 0.D0
20 CONTINUE
OK = .TRUE.
*
* Error exits for QL factorization
*
* DGEQLF
*
SRNAMT = 'DGEQLF'
INFOT = 1
CALL DGEQLF( -1, 0, A, 1, B, W, 1, INFO )
CALL CHKXER( 'DGEQLF', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEQLF( 0, -1, A, 1, B, W, 1, INFO )
CALL CHKXER( 'DGEQLF', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEQLF( 2, 1, A, 1, B, W, 1, INFO )
CALL CHKXER( 'DGEQLF', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DGEQLF( 1, 2, A, 1, B, W, 1, INFO )
CALL CHKXER( 'DGEQLF', INFOT, NOUT, LERR, OK )
*
* DGEQL2
*
SRNAMT = 'DGEQL2'
INFOT = 1
CALL DGEQL2( -1, 0, A, 1, B, W, INFO )
CALL CHKXER( 'DGEQL2', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEQL2( 0, -1, A, 1, B, W, INFO )
CALL CHKXER( 'DGEQL2', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DGEQL2( 2, 1, A, 1, B, W, INFO )
CALL CHKXER( 'DGEQL2', INFOT, NOUT, LERR, OK )
*
* DGEQLS
*
SRNAMT = 'DGEQLS'
INFOT = 1
CALL DGEQLS( -1, 0, 0, A, 1, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEQLS( 0, -1, 0, A, 1, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DGEQLS( 1, 2, 0, A, 1, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DGEQLS( 0, 0, -1, A, 1, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DGEQLS( 2, 1, 0, A, 1, X, B, 2, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL DGEQLS( 2, 1, 0, A, 2, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL DGEQLS( 1, 1, 2, A, 1, X, B, 1, W, 1, INFO )
CALL CHKXER( 'DGEQLS', INFOT, NOUT, LERR, OK )
*
* DORGQL
*
SRNAMT = 'DORGQL'
INFOT = 1
CALL DORGQL( -1, 0, 0, A, 1, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORGQL( 0, -1, 0, A, 1, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORGQL( 1, 2, 0, A, 1, X, W, 2, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORGQL( 0, 0, -1, A, 1, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORGQL( 1, 1, 2, A, 1, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORGQL( 2, 1, 0, A, 1, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
INFOT = 8
CALL DORGQL( 2, 2, 0, A, 2, X, W, 1, INFO )
CALL CHKXER( 'DORGQL', INFOT, NOUT, LERR, OK )
*
* DORG2L
*
SRNAMT = 'DORG2L'
INFOT = 1
CALL DORG2L( -1, 0, 0, A, 1, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORG2L( 0, -1, 0, A, 1, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORG2L( 1, 2, 0, A, 1, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORG2L( 0, 0, -1, A, 1, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORG2L( 2, 1, 2, A, 2, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORG2L( 2, 1, 0, A, 1, X, W, INFO )
CALL CHKXER( 'DORG2L', INFOT, NOUT, LERR, OK )
*
* DORMQL
*
SRNAMT = 'DORMQL'
INFOT = 1
CALL DORMQL( '/', 'N', 0, 0, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORMQL( 'L', '/', 0, 0, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORMQL( 'L', 'N', -1, 0, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DORMQL( 'L', 'N', 0, -1, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORMQL( 'L', 'N', 0, 0, -1, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORMQL( 'L', 'N', 0, 1, 1, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORMQL( 'R', 'N', 1, 0, 1, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DORMQL( 'L', 'N', 2, 1, 0, A, 1, X, AF, 2, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DORMQL( 'R', 'N', 1, 2, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL DORMQL( 'L', 'N', 2, 1, 0, A, 2, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 12
CALL DORMQL( 'L', 'N', 1, 2, 0, A, 1, X, AF, 1, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
INFOT = 12
CALL DORMQL( 'R', 'N', 2, 1, 0, A, 1, X, AF, 2, W, 1, INFO )
CALL CHKXER( 'DORMQL', INFOT, NOUT, LERR, OK )
*
* DORM2L
*
SRNAMT = 'DORM2L'
INFOT = 1
CALL DORM2L( '/', 'N', 0, 0, 0, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 2
CALL DORM2L( 'L', '/', 0, 0, 0, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 3
CALL DORM2L( 'L', 'N', -1, 0, 0, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 4
CALL DORM2L( 'L', 'N', 0, -1, 0, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORM2L( 'L', 'N', 0, 0, -1, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORM2L( 'L', 'N', 0, 1, 1, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 5
CALL DORM2L( 'R', 'N', 1, 0, 1, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DORM2L( 'L', 'N', 2, 1, 0, A, 1, X, AF, 2, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 7
CALL DORM2L( 'R', 'N', 1, 2, 0, A, 1, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
INFOT = 10
CALL DORM2L( 'L', 'N', 2, 1, 0, A, 2, X, AF, 1, W, INFO )
CALL CHKXER( 'DORM2L', INFOT, NOUT, LERR, OK )
*
* Print a summary line.
*
CALL ALAESM( PATH, OK, NOUT )
*
RETURN
*
* End of DERRQL
*
END
| bsd-3-clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.