-
Notifications
You must be signed in to change notification settings - Fork 519
Expand file tree
/
Copy pathMoorDyn.f90
More file actions
4946 lines (3944 loc) · 271 KB
/
MoorDyn.f90
File metadata and controls
4946 lines (3944 loc) · 271 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!**********************************************************************************************************************************
! LICENSING
! Copyright (C) 2020-2021 Alliance for Sustainable Energy, LLC
! Copyright (C) 2015-2019 Matthew Hall
!
! This file is part of MoorDyn.
!
! 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 MoorDyn
USE MoorDyn_Types
USE MoorDyn_IO
USE NWTC_Library
USE MoorDyn_Line
USE MoorDyn_Point
USE MoorDyn_Rod
USE MoorDyn_Body
USE MoorDyn_Misc
IMPLICIT NONE
PRIVATE
TYPE(ProgDesc), PARAMETER :: MD_ProgDesc = ProgDesc( 'MoorDyn', 'v2.3.8', '2025-02-27' )
INTEGER(IntKi), PARAMETER :: wordy = 0 ! verbosity level. >1 = more console output
PUBLIC :: MD_Init
PUBLIC :: MD_UpdateStates
PUBLIC :: MD_CalcOutput
PUBLIC :: MD_CalcContStateDeriv
PUBLIC :: MD_End
PUBLIC :: MD_JacobianPContState
PUBLIC :: MD_JacobianPInput
PUBLIC :: MD_JacobianPDiscState
PUBLIC :: MD_JacobianPConstrState
PUBLIC :: MD_GetOP
CONTAINS
!========================================= MD_Init ===================================
SUBROUTINE MD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, ErrStat, ErrMsg)
IMPLICIT NONE
TYPE(MD_InitInputType), INTENT(IN ) :: InitInp ! INTENT(INOUT) : Input data for initialization routine
TYPE(MD_InputType), INTENT( OUT) :: u ! INTENT( OUT) : An initial guess for the input; input mesh must be defined
TYPE(MD_ParameterType), INTENT( OUT) :: p ! INTENT( OUT) : Parameters
TYPE(MD_ContinuousStateType), INTENT( OUT) :: x ! INTENT( OUT) : Initial continuous states
TYPE(MD_DiscreteStateType), INTENT( OUT) :: xd ! INTENT( OUT) : Initial discrete states
TYPE(MD_ConstraintStateType), INTENT( OUT) :: z ! INTENT( OUT) : Initial guess of the constraint states
TYPE(MD_OtherStateType), INTENT( OUT) :: other ! INTENT( OUT) : Initial other states
TYPE(MD_OutputType), INTENT( OUT) :: y ! INTENT( OUT) : Initial system outputs (outputs are not calculated; only the output mesh is initialized)
TYPE(MD_MiscVarType), INTENT( OUT) :: m ! INTENT( OUT) : Initial misc/optimization variables
REAL(DbKi), INTENT(INOUT) :: DTcoupling ! Coupling interval in seconds: the rate that Output is the actual coupling interval
TYPE(MD_InitOutputType), INTENT( OUT) :: InitOut ! Output for initialization routine
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
TYPE(MD_InputFileType) :: InputFileDat ! Data read from input file for setup, but not stored after Init
type(FileInfoType) :: FileInfo_In !< The derived type for holding the full input file for parsing -- we may pass this in the future
! CHARACTER(1024) :: priPath ! The path to the primary MoorDyn input file
REAL(DbKi) :: t ! instantaneous time, to be used during IC generation
INTEGER(IntKi) :: l ! index
INTEGER(IntKi) :: il ! index
INTEGER(IntKi) :: iil ! index
INTEGER(IntKi) :: Success ! flag for checking whether line is attached to failure point
INTEGER(IntKi) :: I ! Current line number of input file
INTEGER(IntKi) :: J ! index
INTEGER(IntKi) :: K ! index
INTEGER(IntKi) :: Itemp ! index
INTEGER(IntKi) :: iTurb ! index for turbine in FAST.Farm applications
INTEGER(IntKi) :: Converged ! flag indicating whether the dynamic relaxation has converged
INTEGER(IntKi) :: N ! convenience integer for readability: number of segments in the line
! REAL(ReKi) :: rPos(3) ! array for setting fairlead reference positions in mesh
REAL(ReKi) :: OrMat(3,3) ! rotation matrix for setting fairlead positions correctly if there is initial platform rotation
REAL(ReKi) :: OrMat2(3,3)
REAL(R8Ki) :: OrMatRef(3,3)
REAL(DbKi), ALLOCATABLE :: FairTensIC(:,:)! array of size nCpldCons, 3 to store three latest fairlead tensions of each line
! CHARACTER(20) :: TempString ! temporary string for incidental use
INTEGER(IntKi) :: ErrStat2 ! Error status of the operation
CHARACTER(ErrMsgLen) :: ErrMsg2 ! Error message if ErrStat2 /= ErrID_None
REAL(DbKi) :: dtM ! actual mooring dynamics time step
INTEGER(IntKi) :: NdtM ! number of time steps to integrate through with RK2
! INTEGER(IntKi) :: ntWave ! number of time steps of wave data
TYPE(MD_InputType) :: u_array(1) ! a size-one array for u to make call to TimeStep happy
REAL(DbKi) :: t_array(1) ! a size-one array saying time is 0 to make call to TimeStep happy
TYPE(MD_InputType) :: u_interp ! interpolated instantaneous input values to be calculated for each mooring time step
CHARACTER(MaxWrScrLen) :: Message
! Local variables for reading file input (Previously in MDIO_ReadInput)
INTEGER(IntKi) :: UnEc ! The local unit number for this module's echo file
! INTEGER(IntKi) :: UnOut ! for outputing wave kinematics data
! CHARACTER(200) :: Frmt ! a string to hold a format statement
! CHARACTER(1024) :: EchoFile ! Name of MoorDyn echo file
CHARACTER(1024) :: Line ! String to temporarially hold value of read line
CHARACTER(20) :: LineOutString ! String to temporarially hold characters specifying line output options
CHARACTER(20) :: OptString ! String to temporarially hold name of option variable
CHARACTER(40) :: OptValue ! String to temporarially hold value of options variable input
CHARACTER(40) :: DepthValue ! Temporarily stores the optional WtrDpth setting for MD, which could be a number or a filename
CHARACTER(40) :: WaterKinValue ! Temporarily stores the optional WaterKin setting for MD, which is typically a filename
INTEGER(IntKi) :: nOpts ! number of options lines in input file
CHARACTER(40) :: TempString1 !
CHARACTER(40) :: TempString2 !
CHARACTER(40) :: TempString3 !
CHARACTER(40) :: TempString4 !
CHARACTER(40) :: TempString5 !
CHARACTER(40) :: TempStrings(6) ! Array of 6 strings used when parsing comma-separated items
! CHARACTER(1024) :: FileName !
REAL(DbKi) :: depth ! local water depth interpolated from bathymetry grid [m]
Real(DbKi) :: nvec(3) ! local seabed surface normal vector (positive out)
CHARACTER(25) :: let1 ! strings used for splitting and parsing identifiers
CHARACTER(25) :: num1
CHARACTER(25) :: let2
CHARACTER(25) :: num2
CHARACTER(25) :: let3
REAL(DbKi) :: tempArray(6)
REAL(ReKi) :: rRef(6) ! used to pass positions to mesh (real type precision)
REAL(DbKi) :: rRefDub(3)
INTEGER(IntKi) :: TempIDnums(100) ! array to hold IdNums of controlled lines for each CtrlChan
! for reading output channels
CHARACTER(ChanLen),ALLOCATABLE :: OutList(:) ! array of output channel request (moved here from InitInput)
INTEGER :: MaxAryLen = 1000 ! Maximum length of the array being read
INTEGER :: NumWords ! Number of words contained on a line
INTEGER :: Nx
INTEGER :: QuoteCh ! Character position.
CHARACTER(*), PARAMETER :: RoutineName = 'MD_Init'
ErrStat = ErrID_None
ErrMsg = ""
m%zeros6 = 0.0_DbKi
! Initialize the NWTC Subroutine Library
CALL NWTC_Init( )
! Display the module information
CALL DispNVD( MD_ProgDesc )
InitOut%Ver = MD_ProgDesc
CALL WrScr(' This is MoorDyn v2, with significant input file changes from v1.')
CALL DispCopyrightLicense( MD_ProgDesc%Name)
!---------------------------------------------------------------------------------------------
! Get all the inputs taken care of
!---------------------------------------------------------------------------------------------
p%RootName = TRIM(InitInp%RootName)//'.MD' ! all files written from this module will have this root name
! set default values for the simulation settings
! these defaults are based on the glue code
p%dtM0 = DTcoupling ! default to the coupling interval (but will likely need to be smaller)
p%Tmax = InitInp%Tmax
p%g = InitInp%g
p%rhoW = InitInp%rhoW
! TODO: add MSL2SWL from OpenFAST <<<<
! set the following to some defaults
p%kBot = 3.0E6
p%cBot = 3.0E5
InputFileDat%dtIC = 2.0_DbKi
InputFileDat%TMaxIC = 60.0_DbKi
InputFileDat%CdScaleIC = 4.0_ReKi
InputFileDat%threshIC = 0.01_ReKi
p%WaveKin = 0_IntKi
p%Current = 0_IntKi
p%dtOut = 0.0_DbKi
p%mu_kT = 0.0_DbKi
p%mu_kA = 0.0_DbKi
p%mc = 1.0_DbKi
p%cv = 200.0_DbKi
p%VisMeshes = InitInp%VisMeshes ! Visualization meshes requested by glue code
DepthValue = "" ! Start off as empty string, to only be filled if MD setting is specified (otherwise InitInp%WtrDepth is used)
! DepthValue and InitInp%WtrDepth are processed later by setupBathymetry.
WaterKinValue = ""
m%PtfmInit = InitInp%PtfmInit(:,1) ! is this copying necssary in case this is an individual instance in FAST.Farm?
! Check if this MoorDyn instance is being run from FAST.Farm (indicated by FarmSize > 0)
if (InitInp%FarmSize > 0) then
CALL WrScr(' >>> MoorDyn is running in array mode <<< ')
! could make sure the size of this is right: SIZE(InitInp%FarmCoupledKinematics)
p%nTurbines = InitInp%FarmSize
else ! FarmSize==0 indicates normal, FAST module mode
p%nTurbines = 1 ! if a regular FAST module mode, we treat it like a nTurbine=1 farm case
END IF
! allocate some parameter arrays that are for each turbine (size 1 if regular OpenFAST use)
allocate( p%nCpldBodies( p%nTurbines))
allocate( p%nCpldRods ( p%nTurbines))
allocate( p%nCpldPoints ( p%nTurbines))
allocate( p%TurbineRefPos(3, p%nTurbines))
! initialize the arrays (to zero, except for passed in farm turbine reference positions)
p%nCpldBodies = 0
p%nCpldRods = 0
p%nCpldPoints = 0
if (InitInp%FarmSize > 0) then
p%TurbineRefPos = InitInp%TurbineRefPos ! copy over turbine reference positions for later use
else
p%TurbineRefPos = 0.0_DbKi ! for now assuming this is zero for FAST use
end if
!---------------------------------------------------------------------------------------------
! read input file and create cross-referenced mooring system objects
!---------------------------------------------------------------------------------------------
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ""
CALL WrScr( ' Parsing MoorDyn input file: '//trim(InitInp%FileName) )
! -----------------------------------------------------------------
! Read the primary MoorDyn input file, or copy from passed input
if (InitInp%UsePrimaryInputFile) then
! Read the entire input file, minus any comment lines, into the FileInfo_In
! data structure in memory for further processing.
call ProcessComFile( InitInp%FileName, FileInfo_In, ErrStat2, ErrMsg2 )
CALL GetPath( InitInp%FileName, p%PriPath ) ! Input files will be relative to the path where the primary input file is located.
else
call NWTC_Library_CopyFileInfoType( InitInp%PassedPrimaryInputData, FileInfo_In, MESH_NEWCOPY, ErrStat2, ErrMsg2 )
p%PriPath = ""
endif
if (Failed()) return;
! For diagnostic purposes, the following can be used to display the contents
! of the FileInfo_In data structure.
!call Print_FileInfo_Struct( CU, FileInfo_In ) ! CU is the screen -- different number on different systems.
! Parse the FileInfo_In structure of data from the inputfile into the InitInp%InputFile structure
! CALL ParsePrimaryFileInfo_BuildModel( PriPath, InitInp, FileInfo_In, InputFileDat, p, m, UnEc, ErrStat2, ErrMsg2 )
! if (Failed()) return;
!NOTE: This could be split into a separate routine for easier to read code
!-------------------------------------------------------------------------------------------------
! Parsing of input file from the FileInfo_In data structure
! - FileInfo_Type is essentially a string array with some metadata.
!-------------------------------------------------------------------------------------------------
UnEc = -1
nOpts = 0 ! Setting here rather than implied save
! ----------------- go through file contents a first time, counting each entry -----------------------
i = 0 ! set line number counter to before first line
Line = NextLine(i); ! Get the line and increment counter. See description of routine.
do while ( i <= FileInfo_In%NumLines )
if (INDEX(Line, "---") > 0) then ! look for a header line
if ( ( INDEX(Line, "LINE DICTIONARY") > 0) .or. ( INDEX(Line, "LINE TYPES") > 0) ) then ! if line dictionary header
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nLineTypes = p%nLineTypes + 1
Line = NextLine(i)
END DO
else if ( (INDEX(Line, "ROD DICTIONARY") > 0) .or. ( INDEX(Line, "ROD TYPES") > 0) ) then ! if rod dictionary header
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nRodTypes = p%nRodTypes + 1
Line = NextLine(i)
END DO
else if ((INDEX(Line, "BODIES") > 0 ) .or. (INDEX(Line, "BODY LIST") > 0 ) .or. (INDEX(Line, "BODY PROPERTIES") > 0 )) then
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nBodies = p%nBodies + 1
Line = NextLine(i)
END DO
else if ((INDEX(Line, "RODS") > 0 ) .or. (INDEX(Line, "ROD LIST") > 0) .or. (INDEX(Line, "ROD PROPERTIES") > 0)) then ! if rod properties header
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nRods = p%nRods + 1
Line = NextLine(i)
END DO
else if ((INDEX(Line, "POINTS") > 0 ) .or. (INDEX(Line, "CONNECTION PROPERTIES") > 0) .or. (INDEX(Line, "NODE PROPERTIES") > 0) .or. (INDEX(Line, "POINT PROPERTIES") > 0) .or. (INDEX(Line, "POINT LIST") > 0) ) then ! if node properties header
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nPoints = p%nPoints + 1
Line = NextLine(i)
END DO
else if ((INDEX(Line, "LINES") > 0 ) .or. (INDEX(Line, "LINE PROPERTIES") > 0) .or. (INDEX(Line, "LINE LIST") > 0) ) then ! if line properties header
! skip following two lines (label line and unit line)
i=i+2
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nLines = p%nLines + 1
Line = NextLine(i)
END DO
else if (INDEX(Line, "EXTERNAL LOADS") > 0) then ! if external load and damping header
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nExtLds = p%nExtLds + 1
Line = NextLine(i)
END DO
else if (INDEX(Line, "CONTROL") > 0) then ! if control conditions header
IF (wordy > 1) print *, " Reading control channels: ";
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nCtrlChans = p%nCtrlChans + 1
Line = NextLine(i)
END DO
else if (INDEX(Line, "FAILURE") > 0) then ! if failure conditions header
IF (wordy > 1) print *, " Reading failure conditions: ";
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! find how many elements of this type there are
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
p%nFails = p%nFails + 1
Line = NextLine(i)
END DO
else if (INDEX(Line, "OPTIONS") > 0) then ! if options header
IF (wordy > 0) print *, "Reading Options"
! don't skip any lines (no column headers for the options section)
! process each line in this section
Line = NextLine(i)
DO while (INDEX(Line, "---") == 0) ! while we DON'T find another header line
! parse out entries: value, option keyword
READ(Line,*,IOSTAT=ErrStat2) OptValue, OptString ! look at first two entries, ignore remaining words in line, which should be comments
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat( ErrID_Fatal, 'Failed to read options.', ErrStat, ErrMsg, RoutineName ) ! would be nice to specify which line had the error
CALL CleanUp()
RETURN
END IF
CALL Conv2UC(OptString)
! check all possible options types and see if OptString is one of them, in which case set the variable.
if ( OptString == 'WRITELOG') THEN
read (OptValue,*) p%writeLog
if (p%writeLog > 0) then ! if not zero, open a log file for output
CALL GetNewUnit( p%UnLog )
CALL OpenFOutFile ( p%UnLog, TRIM(p%RootName)//'.log', ErrStat, ErrMsg )
IF ( ErrStat > AbortErrLev ) THEN
ErrMsg = ' Failed to open MoorDyn log file: '//TRIM(ErrMsg)
RETURN
END IF
write(p%UnLog,'(A)', IOSTAT=ErrStat2) "MoorDyn v2 log file with output level "//TRIM(Num2LStr(p%writeLog))
write(p%UnLog,'(A)', IOSTAT=ErrStat2) "Note: options above the writeLog line in the input file will not be recorded."
write(p%UnLog,'(A)', IOSTAT=ErrStat2) " Input File Summary:"
end if
else if ( OptString == 'DTM') THEN
read (OptValue,*) p%dtM0
else if ( OptString == 'G') then
read (OptValue,*) p%g
else if (( OptString == 'RHOW') .or. ( OptString == 'RHO')) then
read (OptValue,*) p%rhoW
else if (( OptString == 'WTRDPTH') .or. ( OptString == 'DEPTH') .or. ( OptString == 'WATERDEPTH')) then
read (OptValue,*) DepthValue ! water depth input read in as a string to be processed by setupBathymetry
else if (( OptString == 'KBOT') .or. ( OptString == 'KB')) then
read (OptValue,*) p%kBot
else if (( OptString == 'CBOT') .or. ( OptString == 'CB')) then
read (OptValue,*) p%cBot
else if ( OptString == 'DTIC') then
read (OptValue,*) InputFileDat%dtIC
else if ( OptString == 'TMAXIC') then
read (OptValue,*) InputFileDat%TMaxIC
else if ( OptString == 'CDSCALEIC') then
read (OptValue,*) InputFileDat%CdScaleIC
else if ( OptString == 'THRESHIC') then
read (OptValue,*) InputFileDat%threshIC
else if ( OptString == 'WATERKIN') then
read (OptValue,*) WaterKinValue
else if ( OptString == 'DTOUT') then
read (OptValue,*) p%dtOut
else if ( OptString == 'MU_KT') then
read (OptValue,*) p%mu_kT
else if ( OptString == 'MU_KA') then
read (OptValue,*) p%mu_kA
else if ( OptString == 'MC') then
read (OptValue,*) p%mc
else if ( OptString == 'CV') then
read (OptValue,*) p%cv
else if ( OptString == 'INERTIALF') then
read (OptValue,*) p%inertialF
else if ( OptString == 'INERTIALF_RAMPT') then
read (OptValue,*) p%inertialF_rampT
else if ( OptString == 'OUTSWITCH') then
read (OptValue,*) p%OutSwitch
else
CALL SetErrStat( ErrID_Warn, 'Unable to interpret input '//trim(OptString)//' in OPTIONS section.', ErrStat, ErrMsg, RoutineName )
end if
nOpts = nOpts + 1
Line = NextLine(i)
END DO
if (p%writeLog > 1) then
write(p%UnLog, '(A)' ) " - Options List:"
write(p%UnLog, '(A17,f12.4)') " dtm : ", p%dtM0
write(p%UnLog, '(A17,f12.4)') " g : ", p%g
write(p%UnLog, '(A17,f12.4)') " rhoW : ", p%rhoW
write(p%UnLog, '(A17,A)' ) " Depth : ", DepthValue ! water depth input read in as a string to be processed by setupBathymetry
write(p%UnLog, '(A17,f12.4)') " kBot : ", p%kBot
write(p%UnLog, '(A17,f12.4)') " cBot : ", p%cBot
write(p%UnLog, '(A17,f12.4)') " dtIC : ", InputFileDat%dtIC
write(p%UnLog, '(A17,f12.4)') " TMaxIC : ", InputFileDat%TMaxIC
write(p%UnLog, '(A17,f12.4)') " CdScaleIC: ", InputFileDat%CdScaleIC
write(p%UnLog, '(A17,f12.4)') " threshIC : ", InputFileDat%threshIC
write(p%UnLog, '(A17,A)' ) " WaterKin : ", WaterKinValue
write(p%UnLog, '(A17,f12.4)') " dtOut : ", p%dtOut
write(p%UnLog, '(A17,f12.4)') " mu_kT : ", p%mu_kT
write(p%UnLog, '(A17,f12.4)') " mu_kA : ", p%mu_kA
write(p%UnLog, '(A17,f12.4)') " mc : ", p%mc
write(p%UnLog, '(A17,f12.4)') " cv : ", p%cv
end if
else if (INDEX(Line, "OUTPUT") > 0) then ! if output header
! we don't need to count this section...
Line = NextLine(i)
else ! otherwise ignore this line that isn't a recognized header line and read the next line
Line = NextLine(i)
end if
else ! otherwise ignore this line, which doesn't have the "---" or header line and read the next line
Line = NextLine(i)
end if
end do
p%nPointsExtra = p%nPoints + 2*p%nLines ! set maximum number of points, accounting for possible detachment of each line end and a point for that
IF (wordy > 0) print *, " Identified ", p%nLineTypes , "LineTypes in input file."
IF (wordy > 0) print *, " Identified ", p%nRodTypes , "RodTypes in input file."
IF (wordy > 0) print *, " Identified ", p%nBodies , "Bodies in input file."
IF (wordy > 0) print *, " Identified ", p%nRods , "Rods in input file."
IF (wordy > 0) print *, " Identified ", p%nPoints , "Points in input file."
IF (wordy > 0) print *, " Identified ", p%nLines , "Lines in input file."
IF (wordy > 0) print *, " Identified ", nOpts , "Options in input file."
! set up seabed bathymetry
CALL setupBathymetry(DepthValue, InitInp%WtrDepth, m%BathymetryGrid, m%BathGrid_Xs, m%BathGrid_Ys, ErrStat2, ErrMsg2)
CALL getDepthFromBathymetry(m%BathymetryGrid, m%BathGrid_Xs, m%BathGrid_Ys, 0.0_DbKi, 0.0_DbKi, p%WtrDpth, nvec) ! set depth at 0,0 as nominal for waves etc
! set up wave and current kinematics
CALL setupWaterKin(WaterKinValue, p, InitInp%Tmax, ErrStat2, ErrMsg2); if(Failed()) return
! ----------------------------- misc checks to be sorted -----------------------------
! make sure nLineTypes isn't zero
IF ( p%nLineTypes < 1 ) THEN
CALL SetErrStat( ErrID_Fatal, 'nLineTypes parameter must be greater than zero.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! make sure NLines is at least one
IF ( p%NLines < 1 ) THEN
CALL SetErrStat( ErrID_Fatal, 'NLines parameter must be at least 1.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! ----------------------------- allocate necessary arrays ----------------------------
! Allocate object arrays
ALLOCATE(m%LineTypeList(p%nLineTypes), STAT = ErrStat2 ); if(AllocateFailed("LineTypeList")) return
ALLOCATE(m%RodTypeList( p%nRodTypes ), STAT = ErrStat2 ); if(AllocateFailed("LineTypeList")) return
ALLOCATE(m%BodyList( p%nBodies ), STAT = ErrStat2 ); if(AllocateFailed("BodyList" )) return
ALLOCATE(m%RodList( p%nRods ), STAT = ErrStat2 ); if(AllocateFailed("RodList" )) return
ALLOCATE(m%PointList( p%nPointsExtra), STAT = ErrStat2 ); if(AllocateFailed("PointList" )) return
ALLOCATE(m%LineList( p%nLines ), STAT = ErrStat2 ); if(AllocateFailed("LineList" )) return
ALLOCATE(m%ExtLdList( p%nExtLds ), STAT = ErrStat2 ); if(AllocateFailed("ExtLdList" )) return
ALLOCATE(m%FailList( p%nFails ), STAT = ErrStat2 ); if(AllocateFailed("FailList" )) return
! Allocate associated index arrays (note: some are allocated larger than will be used, for simplicity)
ALLOCATE(m%BodyStateIs1(p%nBodies ), m%BodyStateIsN(p%nBodies ), STAT=ErrStat2); if(AllocateFailed("BodyStateIs1/N")) return
ALLOCATE(m%RodStateIs1(p%nRods ), m%RodStateIsN(p%nRods ), STAT=ErrStat2); if(AllocateFailed("RodStateIs1/N" )) return
ALLOCATE(m%PointStateIs1(p%nPointsExtra), m%PointStateIsN(p%nPointsExtra), STAT=ErrStat2); if(AllocateFailed("PointStateIs1/N" )) return
ALLOCATE(m%LineStateIs1(p%nLines) , m%LineStateIsN(p%nLines) , STAT=ErrStat2); if(AllocateFailed("LineStateIs1/N")) return
ALLOCATE(m%FreeBodyIs( p%nBodies ), STAT=ErrStat2); if(AllocateFailed("FreeBodyIs")) return
ALLOCATE(m%FreeRodIs( p%nRods ), STAT=ErrStat2); if(AllocateFailed("FreeRodIs")) return
ALLOCATE(m%FreePointIs(p%nPointsExtra), STAT=ErrStat2); if(AllocateFailed("FreePointIs")) return
ALLOCATE(m%CpldBodyIs(p%nBodies , p%nTurbines), STAT=ErrStat2); if(AllocateFailed("CpldBodyIs")) return
ALLOCATE(m%CpldRodIs( p%nRods , p%nTurbines), STAT=ErrStat2); if(AllocateFailed("CpldRodIs")) return
ALLOCATE(m%CpldPointIs(p%nPointsExtra, p%nTurbines), STAT=ErrStat2); if(AllocateFailed("CpldPointIs")) return
! ---------------------- now go through again and process file contents --------------------
call Body_Setup( m%GroundBody, m%zeros6, p, ErrStat2, ErrMsg2)
CALL CheckError( ErrStat2, ErrMsg2 )
IF (ErrStat >= AbortErrLev) RETURN
! note: no longer worrying about "Echo" option
Nx = 0 ! set state counter to zero
i = 0 ! set line number counter to before first line
Line = NextLine(i)
do while ( i <= FileInfo_In%NumLines )
if (INDEX(Line, "---") > 0) then ! look for a header line
CALL Conv2UC(Line) ! allow lowercase section header names as well
!-------------------------------------------------------------------------------------------
if ( ( INDEX(Line, "LINE DICTIONARY") > 0) .or. ( INDEX(Line, "LINE TYPES") > 0) ) then ! if line dictionary header
IF (wordy > 0) print *, "Reading line types"
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! process each line
DO l = 1,p%nLineTypes
!read into a line
Line = NextLine(i)
! check for correct number of columns in current line
IF ( CountWords( Line ) /= 10 ) THEN
CALL SetErrStat( ErrID_Fatal, ' Unable to parse Line type '//trim(Num2LStr(l))//' on row '//trim(Num2LStr(i))//' in input file. Row has wrong number of columns. Must be 10 columns.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! parse out entries: Name Diam MassDenInAir EA cIntDamp EI Cd Ca CdAx CaAx
READ(Line,*,IOSTAT=ErrStat2) m%LineTypeList(l)%name, m%LineTypeList(l)%d, &
m%LineTypeList(l)%w, tempString1, tempString2, tempString3, &
m%LineTypeList(l)%Cdn, m%LineTypeList(l)%Can, m%LineTypeList(l)%Cdt, m%LineTypeList(l)%Cat
IF ( ErrStat2 /= ErrID_None ) THEN
CALL SetErrStat( ErrID_Fatal, 'Failed to process line type inputs of entry '//trim(Num2LStr(l))//'. Check formatting and correct number of columns.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
!TODO: add check if %name is maximum length, which might indicate the full name was too long <<<
! process stiffness coefficients
CALL SplitByBars(tempString1, N, tempStrings)
if (N > 3) then
CALL SetErrStat( ErrID_Fatal, 'A line type EA entry can have at most 3 (bar-separated) values.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
else if (N==3) then ! visco-elastic case, load dependent dynamic stiffness!
m%LineTypeList(l)%ElasticMod = 3
read(tempStrings(2), *) m%LineTypeList(l)%alphaMBL
read(tempStrings(3), *) m%LineTypeList(l)%vbeta
else if (N==2) then ! visco-elastic case, constant dynamic stiffness!
m%LineTypeList(l)%ElasticMod = 2
read(tempStrings(2), *) m%LineTypeList(l)%EA_D
else
m%LineTypeList(l)%ElasticMod = 1 ! normal case
end if
! get the regular/static coefficient or relation in all cases (can be from a lookup table)
CALL getCoefficientOrCurve(tempStrings(1), m%LineTypeList(l)%EA, &
m%LineTypeList(l)%nEApoints, &
m%LineTypeList(l)%stiffXs, &
m%LineTypeList(l)%stiffYs, ErrStat2, ErrMsg2)
! process damping coefficients
CALL SplitByBars(tempString2, N, tempStrings)
if (N > m%LineTypeList(l)%ElasticMod) then
CALL SetErrStat( ErrID_Fatal, 'A line type BA entry cannot have more (bar-separated) values than its EA entry.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
else if (N==2) then ! visco-elastic case when two BA values provided
read(tempStrings(2), *) m%LineTypeList(l)%BA_D
else if (m%LineTypeList(l)%ElasticMod > 1) then ! case where there is no dynamic damping for viscoelastic model (will it work)?
CALL WrScr("Warning, viscoelastic model being used with zero damping on the dynamic stiffness.")
if (p%writeLog > 0) then
write(p%UnLog,'(A)') "Warning, viscoelastic model being used with zero damping on the dynamic stiffness."
end if
end if
! get the regular/static coefficient or relation in all cases (can be from a lookup table?)
CALL getCoefficientOrCurve(tempStrings(1), m%LineTypeList(l)%BA, &
m%LineTypeList(l)%nBApoints, &
m%LineTypeList(l)%dampXs, &
m%LineTypeList(l)%dampYs, ErrStat2, ErrMsg2)
! process bending stiffness coefficients (which might use lookup tables)
CALL getCoefficientOrCurve(tempString3, m%LineTypeList(l)%EI, &
m%LineTypeList(l)%nEIpoints, &
m%LineTypeList(l)%bstiffXs, &
m%LineTypeList(l)%bstiffYs, ErrStat2, ErrMsg2)
! specify IdNum of line type for error checking
m%LineTypeList(l)%IdNum = l
! write lineType information to log file
if (p%writeLog > 1) then
write(p%UnLog, '(A)' ) " - LineType"//trim(num2lstr(l))//":"
write(p%UnLog, '(A12,A)' ) " name: ", trim(m%LineTypeList(l)%name)
write(p%UnLog, '(A12,f12.4)') " d : ", m%LineTypeList(l)%d
write(p%UnLog, '(A12,f12.4)') " w : ", m%LineTypeList(l)%w
write(p%UnLog, '(A12,f12.4)') " Cdn : ", m%LineTypeList(l)%Cdn
write(p%UnLog, '(A12,f12.4)') " Can : ", m%LineTypeList(l)%Can
write(p%UnLog, '(A12,f12.4)') " Cdt : ", m%LineTypeList(l)%Cdt
write(p%UnLog, '(A12,f12.4)') " Cat : ", m%LineTypeList(l)%Cat
end if
IF ( ErrStat2 /= ErrID_None ) THEN
CALL SetErrStat( ErrID_Fatal, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
END DO
!-------------------------------------------------------------------------------------------
else if ( (INDEX(Line, "ROD DICTIONARY") > 0) .or. ( INDEX(Line, "ROD TYPES") > 0) ) then ! if rod dictionary header
IF (wordy > 0) print *, "Reading rod types"
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! process each line
DO l = 1,p%nRodTypes
!read into a line
Line = NextLine(i)
! check for correct number of columns in current line (bjj: I'm not going to throw an error if there are extra columns in this line, e.g. comments)
IF ( CountWords( Line ) < 7 ) THEN
CALL SetErrStat( ErrID_Fatal, ' Unable to parse Rod Type '//trim(Num2LStr(l))//' on row '//trim(Num2LStr(i))//' in input file. Row has wrong number of columns. Must be 7 columns.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! parse out entries: Name Diam MassDen Cd Ca CdEnd CaEnd
IF (ErrStat2 == 0) THEN
READ(Line,*,IOSTAT=ErrStat2) m%RodTypeList(l)%name, m%RodTypeList(l)%d, m%RodTypeList(l)%w, &
m%RodTypeList(l)%Cdn, m%RodTypeList(l)%Can, m%RodTypeList(l)%CdEnd, m%RodTypeList(l)%CaEnd
m%RodTypeList(l)%Cdt = 0.0_DbKi ! not used
m%RodTypeList(l)%Cat = 0.0_DbKi ! not used
END IF
! specify IdNum of rod type for error checking
m%RodTypeList(l)%IdNum = l
! write rodType information to log file
if (p%writeLog > 1) then
write(p%UnLog, '(A)' ) " - RodType"//trim(num2lstr(l))//":"
write(p%UnLog, '(A14,A)' ) " name: ", trim(m%RodTypeList(l)%name)
write(p%UnLog, '(A14,f12.4)') " d : ", m%RodTypeList(l)%d
write(p%UnLog, '(A14,f12.4)') " w : ", m%RodTypeList(l)%w
write(p%UnLog, '(A14,f12.4)') " Cdn : ", m%RodTypeList(l)%Cdn
write(p%UnLog, '(A14,f12.4)') " Can : ", m%RodTypeList(l)%Can
write(p%UnLog, '(A14,f12.4)') " CdEnd : ", m%RodTypeList(l)%CdEnd
write(p%UnLog, '(A14,f12.4)') " CaEnd : ", m%RodTypeList(l)%CaEnd
end if
IF ( ErrStat2 /= ErrID_None ) THEN
CALL SetErrStat( ErrID_Fatal, 'Failed to process rod type properties for rod '//trim(Num2LStr(l))//'. Check formatting and correct number of columns.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
END DO
!-------------------------------------------------------------------------------------------
else if ((INDEX(Line, "BODIES") > 0 ) .or. (INDEX(Line, "BODY LIST") > 0 ) .or. (INDEX(Line, "BODY PROPERTIES") > 0 )) then
! skip following two lines (label line and unit line)
Line = NextLine(i)
Line = NextLine(i)
! process each body
DO l = 1,p%nBodies
!read into a line
Line = NextLine(i)
! check for correct number of columns in current line
IF ( CountWords( Line ) /= 14 ) THEN
CALL SetErrStat( ErrID_Fatal, ' Unable to parse Body '//trim(Num2LStr(l))//' on row '//trim(Num2LStr(i))//' in input file. Row has wrong number of columns. Must be 14 columns.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! parse out entries: ID Attachment X0 Y0 Z0 r0 p0 y0 M CG* I* V CdA* Ca*
IF (ErrStat2 == 0) THEN
READ(Line,*,IOSTAT=ErrStat2) m%BodyList(l)%IdNum, tempString1, &
tempArray(1), tempArray(2), tempArray(3), tempArray(4), tempArray(5), tempArray(6), &
m%BodyList(l)%bodyM, tempString2, tempString3, m%BodyList(l)%bodyV, tempString4, tempString5
END IF
! process CG
CALL SplitByBars(tempString2, N, tempStrings)
if (N == 1) then ! if only one entry, it is the z coordinate
m%BodyList(l)%rCG(1) = 0.0_DbKi
m%BodyList(l)%rCG(2) = 0.0_DbKi
READ(tempString2, *) m%BodyList(l)%rCG(3)
else if (N==3) then ! all three coordinates provided
READ(tempStrings(1), *) m%BodyList(l)%rCG(1)
READ(tempStrings(2), *) m%BodyList(l)%rCG(2)
READ(tempStrings(3), *) m%BodyList(l)%rCG(3)
else
CALL SetErrStat( ErrID_Fatal, 'Body '//trim(Num2LStr(l))//' CG entry (col 10) must have 1 or 3 numbers.' , ErrStat, ErrMsg, RoutineName )
end if
! process moments of inertia
CALL SplitByBars(tempString3, N, tempStrings)
if (N == 1) then ! if only one entry, use it for all directions
READ(tempString3, *) m%BodyList(l)%BodyI(1)
m%BodyList(l)%BodyI(2) = m%BodyList(l)%BodyI(1)
m%BodyList(l)%BodyI(3) = m%BodyList(l)%BodyI(1)
else if (N==3) then ! all three directions provided separately
READ(tempStrings(1), *) m%BodyList(l)%BodyI(1)
READ(tempStrings(2), *) m%BodyList(l)%BodyI(2)
READ(tempStrings(3), *) m%BodyList(l)%BodyI(3)
else
CALL SetErrStat( ErrID_Fatal, 'Body '//trim(Num2LStr(l))//' inertia entry (col 11) must have 1 or 3 numbers.' , ErrStat, ErrMsg, RoutineName )
end if
! process drag ceofficient by area product
CALL SplitByBars(tempString4, N, tempStrings)
if (N == 1) then ! if only one entry, use it for all directions
READ(tempString4, *) m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(2) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(3) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(4) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(5) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(6) = m%BodyList(l)%BodyCdA(1)
else if (N ==2) then
READ(tempStrings(1), *) m%BodyList(l)%BodyCdA(1)
READ(tempStrings(4), *) m%BodyList(l)%BodyCdA(4)
m%BodyList(l)%BodyCdA(2) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(3) = m%BodyList(l)%BodyCdA(1)
m%BodyList(l)%BodyCdA(5) = m%BodyList(l)%BodyCdA(4)
m%BodyList(l)%BodyCdA(6) = m%BodyList(l)%BodyCdA(4)
else if (N==3) then ! all three coordinates provided
READ(tempStrings(1), *) m%BodyList(l)%BodyCdA(1)
READ(tempStrings(2), *) m%BodyList(l)%BodyCdA(2)
READ(tempStrings(3), *) m%BodyList(l)%BodyCdA(3)
READ(tempStrings(1), *) m%BodyList(l)%BodyCdA(4)
READ(tempStrings(2), *) m%BodyList(l)%BodyCdA(5)
READ(tempStrings(3), *) m%BodyList(l)%BodyCdA(6)
else if (N==6) then
READ(tempStrings(1), *) m%BodyList(l)%BodyCdA(1)
READ(tempStrings(2), *) m%BodyList(l)%BodyCdA(2)
READ(tempStrings(3), *) m%BodyList(l)%BodyCdA(3)
READ(tempStrings(4), *) m%BodyList(l)%BodyCdA(4)
READ(tempStrings(5), *) m%BodyList(l)%BodyCdA(5)
READ(tempStrings(6), *) m%BodyList(l)%BodyCdA(6)
else
CALL SetErrStat( ErrID_Fatal, 'Body '//trim(Num2LStr(l))//' CdA entry (col 13) must have 1 or 3 numbers.' , ErrStat, ErrMsg, RoutineName )
end if
! process added mass coefficient
CALL SplitByBars(tempString5, N, tempStrings)
if (N == 1) then ! if only one entry, use it for all directions
READ(tempString5, *) m%BodyList(l)%BodyCa(1)
m%BodyList(l)%BodyCa(2) = m%BodyList(l)%BodyCa(1)
m%BodyList(l)%BodyCa(3) = m%BodyList(l)%BodyCa(1)
else if (N==3) then ! all three coordinates provided
READ(tempStrings(1), *) m%BodyList(l)%BodyCa(1)
READ(tempStrings(2), *) m%BodyList(l)%BodyCa(2)
READ(tempStrings(3), *) m%BodyList(l)%BodyCa(3)
else
CALL SetErrStat( ErrID_Fatal, 'Body '//trim(Num2LStr(l))//' Ca entry (col 14) must have 1 or 3 numbers.' , ErrStat, ErrMsg, RoutineName )
end if
IF ( ErrStat2 /= 0 ) THEN
CALL WrScr(' Unable to parse Body '//trim(Num2LStr(l))//' on row '//trim(Num2LStr(i))//' in input file.') ! Specific screen output because errors likely
CALL WrScr(' Ensure row has all 13 columns needed in MDv2 input file (13th Dec 2021).')
CALL SetErrStat( ErrID_Fatal, 'Failed to read bodies.' , ErrStat, ErrMsg, RoutineName )
if (p%writeLog > 0) then
write(p%UnLog,'(A)') ' Unable to parse Body '//trim(Num2LStr(l))//' on row '//trim(Num2LStr(i))//' in input file.'
write(p%UnLog,'(A)') ' Ensure row has all 13 columns needed in MDv2 input file (13th Dec 2021).'
end if
CALL CleanUp()
RETURN
END IF
!----------- process body type -----------------
call DecomposeString(tempString1, let1, num1, let2, num2, let3) ! note: this call is overkill (it's just a string) but leaving it here for potential future expansions
if ((let1 == "ANCHOR") .or. (let1 == "FIXED") .or. (let1 == "FIX")) then ! if a fixed body (this would just be used if someone wanted to temporarly fix a body that things were attached to)
m%BodyList(l)%typeNum = 1
m%BodyList(l)%r6 = tempArray ! set initial body position and orientation
else if ((let1 == "COUPLED") .or. (let1 == "VESSEL") .or. (let1 == "CPLD") .or. (let1 == "VES")) then ! if a coupled body
m%BodyList(l)%typeNum = -1
p%nCpldBodies(1)=p%nCpldBodies(1)+1 ! add this body to coupled list
m%CpldBodyIs(p%nCpldBodies(1),1) = l
! body initial position due to coupling will be adjusted later
else if ((let1 == "VESSELPINNED") .or. (let1 == "VESPIN") .or. (let1 == "COUPLEDPINNED") .or. (let1 == "CPLDPIN")) then ! if a pinned coupled body, add to list and add
m%BodyList(l)%typeNum = 2
p%nCpldBodies(1)=p%nCpldBodies(1)+1 ! add
p%nFreeBodies =p%nFreeBodies+1 ! add this pinned body to the free list because it is half free
m%BodyStateIs1(p%nFreeBodies) = Nx+1
m%BodyStateIsN(p%nFreeBodies) = Nx+6
Nx = Nx + 6 ! add 6 state variables for each pinned body
m%CpldBodyIs(p%nCpldBodies(1),1) = l
m%FreeBodyIs(p%nFreeBodies) = l
else if ((let1 == "TURBINE") .or. (let1 == "T")) then ! turbine-coupled in FAST.Farm case
if (len_trim(num1) > 0) then
READ(num1, *) J ! convert to int, representing turbine index
if ((J <= p%nTurbines) .and. (J > 0)) then
m%BodyList(l)%typeNum = -1 ! set as coupled type
p%nCpldBodies(J)=p%nCpldBodies(J)+1 ! increment counter for the appropriate turbine
m%CpldBodyIs(p%nCpldBodies(J),J) = l
CALL WrScr(' added Body '//TRIM(int2lstr(l))//' for turbine '//trim(int2lstr(J)))
if (p%writeLog > 0) then
write(p%UnLog,'(A)') ' Added Body '//TRIM(int2lstr(l))//' for turbine '//trim(int2lstr(J))
end if
else
CALL SetErrStat( ErrID_Fatal, "Turbine ID out of bounds for Body "//trim(Num2LStr(l))//".", ErrStat, ErrMsg, RoutineName )
return
end if
else
CALL SetErrStat( ErrID_Fatal, "No number provided for Body "//trim(Num2LStr(l))//" Turbine attachment.", ErrStat, ErrMsg, RoutineName )
return
end if
else if (let1 == "FREE") then ! if a free body
m%BodyList(l)%typeNum = 0
p%nFreeBodies=p%nFreeBodies+1
m%BodyStateIs1(p%nFreeBodies) = Nx+1
m%BodyStateIsN(p%nFreeBodies) = Nx+12
Nx = Nx + 12 ! add 12 state variables for free Body
m%FreeBodyIs(p%nFreeBodies) = l
m%BodyList(l)%r6 = tempArray ! set initial body position and orientation
else
CALL SetErrStat( ErrID_Fatal, "Unidentified Body type string for Body "//trim(Num2LStr(l))//": "//trim(tempString1), ErrStat, ErrMsg, RoutineName )
return
end if
! check for sequential IdNums
IF ( m%BodyList(l)%IdNum .NE. l ) THEN
CALL SetErrStat( ErrID_Fatal, 'Body numbers must be sequential starting from 1.', ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! set up body
CALL Body_Setup( m%BodyList(l), tempArray, p, ErrStat2, ErrMsg2)
CALL CheckError( ErrStat2, ErrMsg2 )
IF (ErrStat >= AbortErrLev) RETURN
IF ( ErrStat2 /= 0 ) THEN
CALL SetErrStat( ErrID_Fatal, 'Failed to read data for body '//trim(Num2LStr(l)), ErrStat, ErrMsg, RoutineName )
CALL CleanUp()
RETURN
END IF
! write body information to log file
if (p%writeLog > 1) then
write(p%UnLog, '(A)' ) " - Body"//trim(num2lstr(l))//":"
write(p%UnLog, '(A14,I2)' ) " id : ", m%BodyList(l)%IdNum
write(p%UnLog, '(A14,A)' ) " attach: ", trim(tempString1)
write(p%UnLog, '(A14,f12.4)') " v : ", m%BodyList(l)%bodyV
write(p%UnLog, '(A14,f12.4)') " m : ", m%BodyList(l)%bodyM
write(p%UnLog, '(A14,A)' ) " I : ", trim(num2lstr(m%BodyList(l)%BodyI(1)))//", "//trim(num2lstr(m%BodyList(l)%BodyI(2)))//", "//trim(num2lstr(m%BodyList(l)%BodyI(3)))
write(p%UnLog, '(A14,A)' ) " rCG : ", trim(num2lstr(m%BodyList(l)%rCG(1)))//", "//trim(num2lstr(m%BodyList(l)%rCG(2)))//", "//trim(num2lstr(m%BodyList(l)%rCG(3)))
write(p%UnLog, '(A14,A)' ) " CdA : ", trim(num2lstr(m%BodyList(l)%BodyCdA(1)))//", "//trim(num2lstr(m%BodyList(l)%BodyCdA(2)))//", "//trim(num2lstr(m%BodyList(l)%BodyCdA(3)))//", "//trim(num2lstr(m%BodyList(l)%BodyCdA(4)))//", "//trim(num2lstr(m%BodyList(l)%BodyCdA(5)))//", "//trim(num2lstr(m%BodyList(l)%BodyCdA(6)))
write(p%UnLog, '(A14,A)' ) " Ca : ", trim(num2lstr(m%BodyList(l)%BodyCa(1)))//", "//trim(num2lstr(m%BodyList(l)%BodyCa(2)))//", "//trim(num2lstr(m%BodyList(l)%BodyCa(3)))//", "//trim(num2lstr(m%BodyList(l)%BodyCa(4)))//", "//trim(num2lstr(m%BodyList(l)%BodyCa(5)))//", "//trim(num2lstr(m%BodyList(l)%BodyCa(6)))
end if