-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlpt_read.F90
More file actions
executable file
·3556 lines (3223 loc) · 135 KB
/
lpt_read.F90
File metadata and controls
executable file
·3556 lines (3223 loc) · 135 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
MODULE LPT_Read_Module
IMPLICIT NONE
CHARACTER(LEN=500) :: InputC
INTEGER,ALLOCATABLE :: InputI(:)
REAL(8),ALLOCATABLE :: InputR(:)
REAL(8),ALLOCATABLE,TARGET :: SnapUCurr(:,:,:)
REAL(8),ALLOCATABLE,TARGET :: SnapUWind(:,:,:)
REAL(8),ALLOCATABLE,TARGET :: SnapVCurr(:,:,:)
REAL(8),ALLOCATABLE,TARGET :: SnapVWind(:,:,:)
REAL(8),ALLOCATABLE,TARGET :: SnapWCurr(:,:,:)
REAL(8) :: Times(2)
CONTAINS
SUBROUTINE LPT_Read
USE LPT_Comm_Module
USE LPT_Data_Module
IMPLICIT NONE
INTEGER :: Snap
REAL(8) :: JunkR
#if VERBOSE > 1
CALL LPT_Print(0,"INFO","Entering the LPT_Read routine.")
#endif
! Read the user-specified parameters from the input file.
CALL LPT_Read_Parameters
! Read the initial locations of the particles, if necessary.
IF(INDEX(ParticleInputMethod,"READINITIALCONDITIONS").GT.0)THEN
CALL LPT_Read_Initial_Conditions
ELSEIF(INDEX(ParticleInputMethod,"READFROMFILE").GT.0)THEN
NumParticlesLocal = 0
WRITE(HeaderParticles,'(A,A)') "Particles from "// &
& TRIM(ADJUSTL(ParticleFile))
ELSE
NumParticlesLocal = 0
WRITE(HeaderParticles,'(A)') "Particles from Source"
ENDIF
! Read the unstructured mesh.
IF(INDEX(MeshFileOrigin,"ADCIRC").GT.0)THEN
CALL LPT_Read_Unstructured_Mesh
ELSEIF(INDEX(MeshFileOrigin,"HYCOM").GT.0)THEN
CALL LPT_Read_HYCOM_Mesh
ENDIF
! These calls will open the files and read the headers,
! but not actually read any information. Some of this info,
! such as the number of layers (NumLayers), will be needed
! in the next few routines.
CALL LPT_Read_Velocity_Field("C",Times(1))
CALL LPT_Read_Velocity_Field("W",Times(1))
#ifdef MPI
! Send the number of layers, so the tracking cores
! can allocate the arrays.
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageI)) DEALLOCATE(MessageI)
ALLOCATE(MessageI(1))
MessageI(1) = NumLayers
CALL LPT_Comm_Distribute(DummyC,MessageI,DummyR,"I", &
& "The number of layers could not be passed to " &
& //"the tracking cores.")
NumLayers = MessageI(1)
! Send the sigma layers if necessary.
IF(NumLayers.GT.1)THEN
IF(.NOT.ALLOCATED(Sigma)) ALLOCATE(Sigma(1:NumLayers))
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(NumLayers))
MessageR(:) = Sigma(:)
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The sigma layers could not be passed to the " &
& //"tracking cores.")
Sigma(:) = MessageR(:)
ENDIF
ENDIF
#endif
#if VERBOSE > 1
CALL LPT_Print(0,"INFO","Exiting the LPT_Read routine.")
#endif
! We're done here.
RETURN
END SUBROUTINE
SUBROUTINE LPT_Read_Parameters
USE LPT_Comm_Module
USE LPT_Data_Module
IMPLICIT NONE
CHARACTER(LEN=100) :: InputFile
CHARACTER(LEN=100) :: JunkC
CHARACTER(LEN=100) :: JunkC1
INTEGER :: IA
INTEGER :: IARGC
INTEGER :: IERR
LOGICAL :: InputFileExists
LOGICAL :: InputFileFound
#if VERBOSE > 1
CALL LPT_Print(0,"INFO","Entering the LPT_Read_Parameters " &
& //"routine.")
#endif
! Obtain the input file name.
IF(MyRank.EQ.0)THEN
InputFileFound = .FALSE.
IF(IARGC().GT.0)THEN
IA = 0
DO WHILE (IA.LT.IARGC())
IA = IA + 1
CALL GETARG(IA,JunkC)
IF(JunkC(1:2).EQ."-I")THEN
InputFileFound = .TRUE.
IA = IA + 1
CALL GETARG(IA,JunkC)
READ(JunkC,'(A)') InputFile
ENDIF
ENDDO
ENDIF
IF(.NOT.InputFileFound)THEN
WRITE(*,'(A,$)') "Enter name of input file: "
READ(*,'(A)') InputFile
ENDIF
#ifdef DEBUG
INQUIRE(FILE=TRIM(InputFile),EXIST=InputFileExists)
IF(.NOT.InputFileExists)THEN
CALL LPT_Print(0,"FATAL ERROR","Could not find the input " &
& //"file: "//TRIM(InputFile)//".")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(.NOT.UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(InputFile)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The name of the input file could not be passed to " &
& //"the tracker cores.")
WRITE(InputFile,'(A)') TRIM(MessageC)
ENDIF
#endif
#if VERBOSE > 0
CALL LPT_Print(0,"INFO","The input file is " &
& //TRIM(InputFile)//".")
#endif
! Open the input file.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
OPEN(UNIT=11,FILE=TRIM(InputFile),ACTION='READ', &
& DELIM='APOSTROPHE',IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The input file " &
& //"could not be opened for reading.")
ENDIF
#endif
#if VERBOSE > 1
CALL LPT_Print(0,"INFO","The input file was opened.")
#endif
ENDIF
! Read the timing information.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=TimingInformation,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The timing " &
& //"information could not be read from the input " &
& //"file.")
ENDIF
#endif
SimulationLength = SimulationLength/3600.D0
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = SimulationLength
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The tracking simulation length could not be " &
& //"passed to the tracking cores.")
SimulationLength = MessageR(1)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = SimulationLength
CALL LPT_Comm_To_Writer(DummyC,DummyI,MessageR,"R", &
& "The tracking simulation length could not be " &
& //"passed to the writer core.")
SimulationLength = MessageR(1)
ENDIF
#endif
#ifdef DEBUG
IF(SimulationLength.LT.-98.D0)THEN
CALL LPT_Print(0,"FATAL ERROR","The tracking simulation " &
& //"length must be provided in the input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = StartingTime
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The starting time of the tracking simulation " &
& //"could not be passed to the tracking cores.")
StartingTime = MessageR(1)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = StartingTime
CALL LPT_Comm_To_Writer(DummyC,DummyI,MessageR,"R", &
& "The starting time of the tracking simulation " &
& //"could not be passed to the writer core.")
StartingTime = MessageR(1)
ENDIF
#endif
#ifdef DEBUG
IF(StartingTime.LT.-98.D0)THEN
CALL LPT_Print(0,"FATAL ERROR","The starting time of the " &
& //"tracking simulation must be provided in the " &
& //"input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageI)) DEALLOCATE(MessageI)
ALLOCATE(MessageI(1))
MessageI(1) = NumTrackingSnaps
CALL LPT_Comm_Distribute(DummyC,MessageI,DummyR,"I", &
& "The number of tracking snaps could not be passed " &
& //"to the tracking cores.")
NumTrackingSnaps = MessageI(1)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageI)) DEALLOCATE(MessageI)
ALLOCATE(MessageI(1))
MessageI(1) = NumTrackingSnaps
CALL LPT_Comm_To_Writer(DummyC,MessageI,DummyR,"I", &
& "The number of tracking snaps could not be passed " &
& //"to the writer core.")
NumTrackingSnaps = MessageI(1)
ENDIF
#endif
#ifdef DEBUG
IF(NumTrackingSnaps.LT.-98)THEN
CALL LPT_Print(0,"FATAL ERROR","The number of tracking snaps "&
& //"must be provided in the input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = MinimumTimeStep
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The minimum time step could not be passed to the " &
& //"tracking cores.")
MinimumTimeStep = MessageR(1)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = MinimumTimeStep
CALL LPT_Comm_To_Writer(DummyC,DummyI,MessageR,"R", &
& "The minimum time step could not be passed to the " &
& //"writer core.")
MinimumTimeStep = MessageR(1)
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageI)) DEALLOCATE(MessageI)
ALLOCATE(MessageI(1))
MessageI(1) = LatticeSearchBins
CALL LPT_Comm_Distribute(DummyC,MessageI,DummyR,"I", &
& "The number of lattice search bins could not be " &
& //"passed to the tracking cores.")
LatticeSearchBins = MessageI(1)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageI)) DEALLOCATE(MessageI)
ALLOCATE(MessageI(1))
MessageI(1) = LatticeSearchBins
CALL LPT_Comm_To_Writer(DummyC,MessageI,DummyR,"I", &
& "The number of lattice search bins could not be " &
& //"passed to the writer core.")
LatticeSearchBins = MessageI(1)
ENDIF
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(F15.6)') SimulationLength
CALL LPT_Print(0,"INFO","The tracking simulation length is " &
& //TRIM(ADJUSTL(JunkC))//" hours.")
WRITE(JunkC,'(F15.6)') StartingTime/3600.D0
CALL LPT_Print(0,"INFO","The starting time of the tracking " &
& //"is "//TRIM(ADJUSTL(JunkC))//" hours.")
WRITE(JunkC,'(I24)') NumTrackingSnaps
CALL LPT_Print(0,"INFO","There are "//TRIM(ADJUSTL(JunkC)) &
& //" tracking snaps.")
WRITE(JunkC,'(F15.6)') MinimumTimeStep
CALL LPT_Print(0,"INFO","The minimum time step is " &
& //TRIM(ADJUSTL(JunkC))//" hours.")
WRITE(JunkC,'(I24)') LatticeSearchBins
CALL LPT_Print(0,"INFO","The lattice search will use " &
& //TRIM(ADJUSTL(JunkC))//" bins.")
ENDIF
#endif
! Read the information about the current velocity field.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=CurrentField,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The parameters for " &
& //"the current field could not be read from the " &
& //"input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFile)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The name of the current velocities file could not " &
& //"be passed to the tracking cores.")
WRITE(CurrentFile,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFile)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The name of the current velocities file could not " &
& //"be passed to the writer core.")
WRITE(CurrentFile,'(A)') TRIM(MessageC)
ENDIF
#endif
#ifdef DEBUG
IF(INDEX(CurrentFile,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The name of the current " &
& //"velocities file must be provided in the input " &
& //"file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFileOrigin)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The origin of the current velocities file could " &
& //"not be passed to the tracking cores.")
WRITE(CurrentFileOrigin,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFileOrigin)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The origin of the current velocities file could " &
& //"not be passed to the writer core.")
WRITE(CurrentFileOrigin,'(A)') TRIM(MessageC)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(CurrentFileOrigin)
#ifdef DEBUG
IF(INDEX(CurrentFileOrigin,"ADCIRC").LE.0.AND. &
& INDEX(CurrentFileOrigin,"HYCOM").LE.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The origin of the current " &
& //"velocities file must be specified as either " &
& //"'ADCIRC' or 'NetCDF' in the input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFileFormat)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The format of the current velocities file could " &
& //"not be passed to the tracking cores.")
WRITE(CurrentFileFormat,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentFileFormat)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The format of the current velocities file could " &
& //"not be passed to the writer core.")
WRITE(CurrentFileFormat,'(A)') TRIM(MessageC)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(CurrentFileFormat)
#ifdef DEBUG
IF(INDEX(CurrentFileFormat,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the current " &
& //"velocities file must be specified in the input " &
& //"file.")
ENDIF
IF((INDEX(CurrentFileFormat,"ASCII").LE.0).AND. &
& (INDEX(CurrentFileFormat,"NETCDF").LE.0))THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the current " &
& //"velocities file must be specified as either " &
& //"'ASCII' or 'NetCDF' in the input file.")
ENDIF
IF(INDEX(CurrentFileOrigin,"HYCOM").GT.0.AND. &
& INDEX(CurrentFileFormat,"NETCDF").LE.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The current velocities file " &
& //"was obtained from HYCOM, so its format must be " &
& //"specified as 'NetCDF' in the input file.")
ENDIF
#ifndef NETCDF
IF(INDEX(CurrentFileFormat,"NETCDF").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The current velocities file " &
& //"is formatted for NetCDF, but this program has " &
& //"not been compiled with support for NetCDF.")
ENDIF
#endif
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentDimensions)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The dimensions of the current velocities could " &
& //"not be passed to the tracking cores.")
WRITE(CurrentDimensions,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(CurrentDimensions)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The dimensions of the current velocities could " &
& //"not be passed to the writer core.")
WRITE(CurrentDimensions,'(A)') TRIM(MessageC)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(CurrentDimensions)
#ifdef DEBUG
IF((INDEX(CurrentDimensions,"2D").LE.0).AND. &
& (INDEX(CurrentDimensions,"3D").LE.0))THEN
CALL LPT_Print(0,"FATAL ERROR","The current velocity field " &
& //"must be specified in 2D or 3D.")
ENDIF
IF(INDEX(CurrentFileOrigin,"HYCOM").GT.0.AND. &
& INDEX(CurrentDimensions,"3D").LE.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The current velocity field " &
& //"was obtained from HYCOM, so its dimensions must " &
& //"specified as 3D in the input file.")
ENDIF
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(A)') TRIM(CurrentFile)
CALL LPT_Print(0,"INFO","The current velocities will be " &
& //"read from "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(CurrentFileOrigin)
CALL LPT_Print(0,"INFO","The current velocities file was " &
& //"obtained from "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(CurrentFileFormat)
CALL LPT_Print(0,"INFO","The current velocities file is in " &
& //TRIM(ADJUSTL(JunkC))//" format.")
WRITE(JunkC,'(A)') TRIM(CurrentDimensions)
CALL LPT_Print(0,"INFO","The current velocity field is in " &
& //TRIM(ADJUSTL(JunkC))//".")
ENDIF
#endif
! Read the information about the wind velocity field.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=WindField,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"WARNING","The parameters for " &
& //"the wind field could not be read from the " &
& //"input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(WindFile)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The name of the wind velocities file could not be " &
& //"passed to the tracking cores.")
WRITE(WindFile,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(WindFile)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The name of the wind velocities file could not be " &
& //"passed to the writer core.")
WRITE(WindFile,'(A)') TRIM(MessageC)
ENDIF
#endif
IF(INDEX(WindFile,"NULL").LE.0)THEN
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') TRIM(WindFileFormat)
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The format of the wind velocities file could " &
& //"not be passed to the tracking cores.")
WRITE(WindFileFormat,'(A)') TRIM(MessageC)
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') TRIM(WindFileFormat)
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The format of the wind velocities file could " &
& //"be passed to the writer core.")
WRITE(WindFileFormat,'(A)') TRIM(MessageC)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(WindFileFormat)
#ifdef DEBUG
IF(INDEX(WindFileFormat,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the wind " &
& //"velocities file must be specified in the " &
& //"input file.")
ENDIF
IF((INDEX(WindFileFormat,"ASCII").LE.0).AND. &
& (INDEX(WindFileFormat,"NETCDF").LE.0))THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the wind " &
& //"velocities file must be specified as either " &
& //"ASCII or NetCDF.")
ENDIF
#ifndef NETCDF
IF(INDEX(WindFileFormat,"NETCDF").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The wind velocities file " &
& //"is formatted for NetCDF, but this program has "&
& //"not been compiled with support for NetCDF.")
ENDIF
#endif
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(A)') TRIM(WindFile)
CALL LPT_Print(0,"INFO","The wind velocities will be " &
& //"read from "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(WindFileFormat)
CALL LPT_Print(0,"INFO","The wind velocities file is in " &
& //TRIM(ADJUSTL(JunkC))//" format.")
ENDIF
#endif
ENDIF
! Read the information about the file containing the initial
! locations of the particles.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=ParticleInput,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The information " &
& //"about the particle input could not be read " &
& //"from the input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') ParticleInputMethod
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The method for particle input could not be passed " &
& //"to the tracking cores.")
WRITE(ParticleInputMethod,'(A)') MessageC
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') ParticleInputMethod
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The method for particle input could not be passed " &
& //"to the writer core.")
WRITE(ParticleInputMethod,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(ParticleInputMethod)
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') ParticleInputCoordinates
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The coordinate system for the particles could " &
& //"not be passed to the tracking cores.")
WRITE(ParticleInputCoordinates,'(A)') MessageC
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') ParticleInputCoordinates
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The coordinate system for the particles could " &
& //"not be passed to the write core.")
WRITE(ParticleInputCoordinates,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(ParticleInputCoordinates)
IF(INDEX(ParticleInputMethod,"READINITIALCONDITIONS").GT.0.OR. &
& INDEX(ParticleInputMethod,"READFROMFILE").GT.0)THEN
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') ParticleFile
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The name of the file containing the initial " &
& //"locations of the particles could not be " &
& //"passed to the tracking cores.")
WRITE(ParticleFile,'(A)') MessageC
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') ParticleFile
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The name of the file containing the initial " &
& //"locations of the particles could not be " &
& //"passed to the writer core.")
WRITE(ParticleFile,'(A)') MessageC
ENDIF
#endif
#ifdef DEBUG
IF(INDEX(ParticleFile,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The name of the file " &
& //"containing the initial locations of the " &
& //"particles must be specified in the input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') ParticleFileFormat
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The format of the file containing the initial " &
& //"locations of the particles could not be " &
& //"to the tracking cores.")
WRITE(ParticleFileFormat,'(A)') MessageC
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') ParticleFileFormat
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The format of the file containing the initial " &
& //"locations of the particles could not be " &
& //"passed to the writer core.")
WRITE(ParticleFileFormat,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(ParticleFileFormat)
#ifdef DEBUG
IF(INDEX(ParticleFileFormat,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the file " &
& //"containing the initial locations of the " &
& //"particles must be specified in the input file.")
ENDIF
IF((INDEX(ParticleFileFormat,"ASCII").LE.0).AND. &
& (INDEX(ParticleFileFormat,"NETCDF").LE.0))THEN
CALL LPT_Print(0,"FATAL ERROR","The format of the file " &
& //"containing the initial conditions of the " &
& //"particles must be specified as either " &
& //"ASCII or NetCDF.")
ENDIF
#ifndef NETCDF
IF(INDEX(ParticleFileFormat,"NETCDF").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The file containing the " &
& //"initial locations of the particles is " &
& //"formatted for NetCDF, but this program has " &
& //"not been compiled with support for NetCDF.")
ENDIF
#endif
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(A)') TRIM(ParticleFile)
CALL LPT_Print(0,"INFO","The initial locations of the " &
& //"particles will be read from " &
& //TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(ParticleFileFormat)
CALL LPT_Print(0,"INFO","The file containing the initial " &
& //"locations of the particles is in " &
& //TRIM(ADJUSTL(JunkC))//" format.")
WRITE(JunkC,'(A)') TRIM(ParticleInputCoordinates)
CALL LPT_Print(0,"INFO","The particles are given in " &
& //TRIM(ADJUSTL(JunkC))//" coordinates.")
ENDIF
#endif
ELSEIF(INDEX(ParticleInputMethod,"SOURCE").GT.0)THEN
#ifdef MPI
IF(UseReaderCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1:3))
MessageR(1) = ParticleSourceX
MessageR(2) = ParticleSourceY
MessageR(3) = ParticleSourceZ
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The (x,y,z) location of the particle source " &
& //"could not be passed to the tracking cores.")
ParticleSourceX = MessageR(1)
ParticleSourceY = MessageR(2)
ParticleSourceZ = MessageR(3)
ENDIF
IF(UseWriterCore)THEN
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1:3))
MessageR(1) = ParticleSourceX
MessageR(2) = ParticleSourceY
MessageR(3) = ParticleSourceZ
CALL LPT_Comm_To_Writer(DummyC,DummyI,MessageR,"R", &
& "The (x,y,z) location of the particle source " &
& //"could not be passed to the writer core.")
ParticleSourceX = MessageR(1)
ParticleSourceY = MessageR(2)
ParticleSourceZ = MessageR(3)
ENDIF
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(F15.6)') ParticleSourceX
CALL LPT_Print(0,"INFO","The particles will originate " &
& //"from a x-location of " &
& //TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(F15.6)') ParticleSourceY
CALL LPT_Print(0,"INFO","The particles will originate " &
& //"from a y-location of " &
& //TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(F15.6)') ParticleSourceZ
CALL LPT_Print(0,"INFO","The particles will originate " &
& //"from a z-location of " &
& //TRIM(ADJUSTL(JunkC))//".")
ENDIF
#endif
ELSE
CALL LPT_Print(0,"FATAL ERROR","The particle input method " &
& //"must be specified as either 'ReadFromFile' or " &
& //"'ReadInitialConditions' or 'Source' in the " &
& //"parameters file.")
ENDIF
! Read the information about the output settings.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=OutputSettings,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"WARNING","The information " &
& //"about the output settings could not be read " &
& //"from the input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') OutputFileName
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The output file name could not be passed to the " &
& //"tracking cores.")
WRITE(OutputFileName,'(A)') MessageC
WRITE(MessageC,'(A)') OutputFileFormat
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The output file format could not be passed to the " &
& //"tracking cores.")
WRITE(OutputFileFormat,'(A)') MessageC
ENDIF
IF(UseWriterCore)THEN
WRITE(MessageC,'(A)') OutputFileName
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The output file name could not be passed to the " &
& //"writer core.")
WRITE(OutputFileName,'(A)') MessageC
WRITE(MessageC,'(A)') OutputFileFormat
CALL LPT_Comm_To_Writer(MessageC,DummyI,DummyR,"C", &
& "The output file format could not be passed to the " &
& //"writer core.")
WRITE(OutputFileFormat,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(OutputFileFormat)
#ifdef DEBUG
IF(INDEX(OutputFileName,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The output file name must " &
& //"be specified in the parameters file.")
ENDIF
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
CALL LPT_Print(0,"INFO","The output will be written to " &
& //TRIM(ADJUSTL(OutputFileName))//".")
CALL LPT_Print(0,"INFO","The output will be written in the " &
& //"'"//TRIM(ADJUSTL(OutputFileFormat))//"' format.")
ENDIF
#endif
! Read the information about the unstructured mesh.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=UnstructuredMesh,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The information " &
& //"about the file containing the unstructured " &
& //"mesh could not be read from the input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') MeshFile
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The name of the file containing the unstructured " &
& //"mesh could not be passed to the tracking cores.")
WRITE(MeshFile,'(A)') MessageC
ENDIF
#endif
#ifdef DEBUG
IF(INDEX(MeshFile,"NULL").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The name of the file " &
& //"containing the unstructured mesh must be " &
& //"specified in the input file.")
ENDIF
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') MeshFileOrigin
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The origin of the file containing the unstructured "&
& //"mesh could not be passed to the tracking cores.")
WRITE(MeshFileOrigin,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(MeshFileOrigin)
#ifdef DEBUG
#ifndef NETCDF
IF(INDEX(MeshFileOrigin,"HYCOM").GT.0)THEN
CALL LPT_Print(0,"FATAL ERROR","The mesh file was obtained " &
& //"from HYCOM and is presumed to be in NetCDF " &
& //"format, but this code was not compiled with " &
& //"NetCDF support.")
ENDIF
#endif
#endif
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') MeshCoordinates
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The coordinate system for the unstructured mesh " &
& //"could not be passed to the tracking cores.")
WRITE(MeshCoordinates,'(A)') MessageC
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(MeshCoordinates)
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(A)') TRIM(MeshFile)
CALL LPT_Print(0,"INFO","The unstructured mesh will be read " &
& //"from "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(MeshFileOrigin)
CALL LPT_Print(0,"INFO","The unstructured mesh was obtained " &
& //"from "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(A)') TRIM(MeshCoordinates)
CALL LPT_Print(0,"INFO","The unstructured mesh is given in " &
& //TRIM(ADJUSTL(JunkC))//" coordinates.")
ENDIF
#endif
! Read the information about the velocity combination.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=VelocityCombination,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","The information " &
& //"about the velocity combination could not be " &
& //"read from the input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') CombinationMethod
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The method for the velocity combination could not " &
& //"be passed to the tracking cores.")
WRITE(CombinationMethod,'(A)') MessageC
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(1))
MessageR(1) = PercentageCurrent
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The currents percentage to be used in the velocity "&
& //"combination could not be passed to the tracking " &
& //"cores.")
PercentageCurrent = MessageR(1)
MessageR(1) = PercentageWind
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The winds percentage to be used in the velocity " &
& //"combination could not be passed to the tracking " &
& //"cores.")
PercentageWind = MessageR(1)
MessageR(1) = AngleWind
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The wind adjustment angle to be used in the " &
& //"velocity combination could not be passed to the " &
& //"tracking cores.")
AngleWind = MessageR(1)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(CombinationMethod)
#ifdef DEBUG
IF(INDEX(WindFile,"NULL").GT.0.AND.PercentageWind.GT.0.D0)THEN
CALL LPT_Print(MyRank,"FATAL ERROR","To include a non-zero " &
& //"percentage of the wind velocities, you must " &
& //"specify the information about the wind file.")
ENDIF
#endif
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
WRITE(JunkC,'(A)') TRIM(CombinationMethod)
CALL LPT_Print(0,"INFO","The velocities will be combined by " &
& //"using the '"//TRIM(ADJUSTL(JunkC))//"' method.")
WRITE(JunkC,'(F15.6)') PercentageCurrent
CALL LPT_Print(0,"INFO","The combination will include a " &
& //"current fraction of "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(F15.6)') PercentageWind
CALL LPT_Print(0,"INFO","The combination will include a " &
& //"wind fraction of "//TRIM(ADJUSTL(JunkC))//".")
WRITE(JunkC,'(F15.6)') AngleWind
CALL LPT_Print(0,"INFO","The combination will include a " &
& //"wind adjustment angle of "//TRIM(ADJUSTL(JunkC)) &
& //".")
ENDIF
#endif
! Read the information about the velocity combination.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)
READ(11,NML=Diffusion,IOSTAT=IERR)
#ifdef DEBUG
IF(IERR.NE.0)THEN
CALL LPT_Print(0,"WARNING","The information " &
& //"about the horizontal diffusion could not be " &
& //"read from the input file.")
ENDIF
#endif
ENDIF
#ifdef MPI
IF(UseReaderCore)THEN
WRITE(MessageC,'(A)') DiffusionMethod
CALL LPT_Comm_Distribute(MessageC,DummyI,DummyR,"C", &
& "The method for the diffusion could not be passed " &
& //"to the tracking cores.")
WRITE(DiffusionMethod,'(A)') MessageC
IF(ALLOCATED(MessageR)) DEALLOCATE(MessageR)
ALLOCATE(MessageR(2))
MessageR(1) = Cx
MessageR(2) = Cy
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The diffusion scaling coefficients could not be " &
& //"passed to the tracking cores.")
Cx = MessageR(1)
Cy = MessageR(2)
MessageR(1) = Evx
MessageR(2) = Evy
CALL LPT_Comm_Distribute(DummyC,DummyI,MessageR,"R", &
& "The diffusion turbulence coefficients could not " &
& //"be passed to the tracking cores.")
Evx = MessageR(1)
Evy = MessageR(2)
ENDIF
#endif
CALL LPT_Read_Capitalize_Word(DiffusionMethod)
#if VERBOSE > 0
IF(MyRank.EQ.0)THEN
IF(INDEX(DiffusionMethod,"NULL").LE.0)THEN
CALL LPT_Print(0,"INFO","The horizontal diffusion will " &
& //"use the "//TRIM(ADJUSTL(DiffusionMethod)) &
& //" method.")
WRITE(JunkC,'(F15.6)') Cx
WRITE(JunkC1,'(F15.6)') Cy
CALL LPT_Print(0,"INFO","The horizontal diffusion will " &
& //"use scaling coefficients of " &
& //TRIM(ADJUSTL(JunkC))//" and " &
& //TRIM(ADJUSTL(JunkC1))//".")
WRITE(JunkC,'(F15.6)') Evx
WRITE(JunkC1,'(F15.6)') Evy
CALL LPT_Print(0,"INFO","The horizontal diffusion will " &
& //"use turbulence coefficients of " &
& //TRIM(ADJUSTL(JunkC))//" and " &
& //TRIM(ADJUSTL(JunkC1))//".")
ELSE
CALL LPT_Print(0,"INFO","The horizontal diffusion will " &
& //"not be considered.")
ENDIF
ENDIF
#endif
! Read the information about the water properties.
IF((.NOT.UseReaderCore.AND.AmTrackerCore).OR.(MyRank.EQ.0))THEN
REWIND(11)