-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3initmd.ftn
4174 lines (4147 loc) · 172 KB
/
w3initmd.ftn
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
#include "w3macros.h"
!/ ------------------------------------------------------------------- /
MODULE W3INITMD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 05-Jun-2018 |
!/ +-----------------------------------+
!/
!/ 28-Dec-2004 : Origination (out of W3WAVEMD). ( version 3.06 )
!/ Multiple grid version.
!/ 03-Jan-2005 : Add US2x to MPI communication. ( version 3.06 )
!/ 04-Jan-2005 : Add grid output flags to W3INIT. ( version 3.06 )
!/ 07-Feb-2005 : Combined vs. separate test output. ( version 3.07 )
!/ 04-May-2005 : Change to MPI_COMM_WAVE. ( version 3.07 )
!/ 21-Jul-2005 : Add output fields. ( version 3.07 )
!/ 09-Nov-2005 : Drying out of points added. ( version 3.08 )
!/ 13-Jun-2006 : Splitting STORE in G/SSTORE. ( version 3.09 )
!/ 26-Jun-2006 : adding wiring for output type 6. ( version 3.09 )
!/ 27-Jun-2006 : Adding file name preamble. ( version 3.09 )
!/ 04-Jul-2006 : Consolidate stress arrays. ( version 3.09 )
!/ 02-Aug-2006 : Adding W3MPIP. ( version 3.10 )
!/ 02-Nov-2006 : Adding partitioning options. ( version 3.10 )
!/ 11-Jan-2007 : Updating IAPPRO computation. ( version 3.10 )
!/ 02-Apr-2007 : Add partitioned field data. ( version 3.11 )
!/ Add user-defined field data.
!/ 01-May-2007 : Move O7a output to W3IOPP. ( version 3.11 )
!/ 08-May-2007 : Starting from calm as an option. ( version 3.11 )
!/ 17-May-2007 : Adding NTPROC/NAPROC separation. ( version 3.11 )
!/ 21-Jun-2007 : Dedicated output processes. ( version 3.11 )
!/ 29-Feb-2008 : Add NEC compiler directives. ( version 3.13 )
!/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
!/ 23-Jul-2009 : Implement unstructured grids ( version 3.14 )
!/ 30-Oct-2009 : Implement run-time grid selection. ( version 3.14 )
!/ (W. E. Rogers & T. J. Campbell, NRL)
!/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
!/ (W. E. Rogers & T. J. Campbell, NRL)
!/ 06-Dec-2010 : Change from GLOBAL (logical) to ICLOSE (integer) to
!/ specify index closure for a grid. ( version 3.14 )
!/ (T. J. Campbell, NRL)
!/ 02-Sep.2012 : Set up for > 999 test files. ( version 4.10 )
!/ Reset UST initialization.
!/ 03-Sep-2012 : Switch test file on/off (TSTOUT) ( version 4.10 )
!/ 03-Sep-2012 : Clean up of UG grids ( version 4.08 )
!/ 30-Sep-2012 : Implemetation of tidal constituents ( version 4.09 )
!/ 07-Dec-2012 : Initialize UST non-zero. ( version 4.11 )
!/ 12-Dec-2012 : Changes for SMC grid. JG_Li ( version 4.11 )
!/ 26-Dec-2012 : Modify field output MPI for new ( version 4.11 )
!/ structure and smaller memory footprint.
!/ 02-Jul-2013 : Bug fix MPI_FLOAT -> MPI_REAL. ( version 4.11 )
!/ 10-Oct-2013 : CG and WN values at DMIN for ISEA=0 ( version 4.12 )
!/ 14-Nov-2013 : Remove UST(DIR) initialization. ( version 4.13 )
!/ 15-Dec-2013 : Adds fluxes to ice ( version 5.01 )
!/ 01-May-2017 : Adds directional MSS parameters ( version 6.04 )
!/ 05-Jun-2018 : Adds PDLIB/MEMCHECK/DEBUG ( version 6.04 )
!/ 21-Aug-2018 : Add WBT parameter ( version 6.06 )
!/ 26-Aug-2018 : UOST (Mentaschi et al. 2015, 2018) ( version 6.06 )
!/
!/ Copyright 2009-2013 National Weather Service (NWS),
!/ National Oceanic and Atmospheric Administration. All rights
!/ reserved. WAVEWATCH III is a trademark of the NWS.
!/ No unauthorized use without permission.
!/
!/ Note: Changes in version numbers not logged above.
!/
! 1. Purpose :
!
! 2. Variables and types :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! CRITOS R.P. Public Critical percentage of resources used
! for output to trigger warning.
! WWVER C*10 Public Model version number.
! SWITCHES C*256 Public switches taken from bin/switch
! ----------------------------------------------------------------
!
! 3. Subroutines and functions :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! W3INIT Subr. Public Wave model initialization.
! W3MPII Subr. Public Initialize MPI data transpose.
! W3MPIO Subr. Public Initialize MPI output gathering.
! W3MPIP Subr. Public Initialize MPI point output gathering.
! ----------------------------------------------------------------
!
! 4. Subroutines and functions used :
!
! See subroutine documentation.
!
! 5. Remarks :
!
! 6. Switches :
!
! !/SHRD Switch for shared / distributed memory architecture.
! !/DIST Id.
! !/MPI Id.
!
! !/S Enable subroutine tracing.
! !/Tn Enable test output.
! !/MPIT Enable test output (MPI).
!
! 7. Source code :
!
!/ ------------------------------------------------------------------- /
PUBLIC
!/
REAL, PARAMETER :: CRITOS = 15.
CHARACTER(LEN=10), PARAMETER :: WWVER = '6.07 '
CHARACTER(LEN=512), PARAMETER :: SWITCHES = &
'PUT_SW1' // &
'PUT_SW2' // &
'PUT_SW3'
!/
CONTAINS
!/ ------------------------------------------------------------------- /
SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT,FLGRD, &
FLGR2, FLGD, FLG2, NPT, XPT, YPT, PNAMES, &
IPRT, PRTFRM, MPI_COMM, FLAGSTIDEIN )
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 03-Sep-2012 |
!/ +-----------------------------------+
!/
!/ 17-Mar-1999 : Distributed FORTRAN 77 version. ( version 1.18 )
!/ 13-Jan-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
!/ Major changes to logistics.
!/ 14-Feb-2000 : Exact-NL added. ( version 2.01 )
!/ 24-Jan-2001 : Flat grid version. ( version 2.06 )
!/ 24-Jan-2002 : Zero time step for data ass. ( version 2.17 )
!/ 18-Feb-2002 : Point output diagnostics added. ( version 2.18 )
!/ 13-Nov-2002 : Add stress vector. ( version 3.00 )
!/ 20-Aug-2003 : Output server options added. ( version 3.04 )
!/ 28-Dec-2004 : Multiple grid version. ( version 3.06 )
!/ Taken out of W3WAVE.
!/ 04-Jan-2005 : Add grid output flags to par list. ( version 3.06 )
!/ 07-Feb-2005 : Combined vs. separate test output. ( version 3.07 )
!/ 04-May-2005 : Change to MPI_COMM_WAVE. ( version 3.07 )
!/ 09-Nov-2005 : Drying out of points added. ( version 3.08 )
!/ 26-Jun-2006 : adding wiring for output type 6. ( version 3.09 )
!/ 27-Jun-2006 : Adding file name preamble. ( version 3.09 )
!/ 02-Aug-2006 : Adding W3MPIP. ( version 3.10 )
!/ 02-Nov-2006 : Adding partitioning options. ( version 3.10 )
!/ 11-Jan-2007 : Updating IAPPRO computation. ( version 3.10 )
!/ 01-May-2007 : Move O7a output to W3IOPP. ( version 3.11 )
!/ 08-May-2007 : Starting from calm as an option. ( version 3.11 )
!/ 17-May-2007 : Adding NTPROC/NAPROC separation. ( version 3.11 )
!/ 21-Jun-2007 : Dedicated output processes. ( version 3.11
!/ 13-Sep-2009 : Add coupling option ( version 3.14 )
!/ 30-Oct-2009 : Implement run-time grid selection. ( version 3.14 )
!/ (W. E. Rogers & T. J. Campbell, NRL)
!/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
!/ (W. E. Rogers & T. J. Campbell, NRL)
!/ 29-Oct-2010 : Implement unstructured grids ( version 3.14.1 )
!/ (A. Roland and F. Ardhuin)
!/ 06-Dec-2010 : Change from GLOBAL (logical) to ICLOSE (integer) to
!/ specify index closure for a grid. ( version 3.14 )
!/ (T. J. Campbell, NRL)
!/ 02-Sep.2012 : Set up for > 999 test files. ( version 4.10 )
!/ 03-Sep-2012 : Switch test file on/off (TSTOUT) ( version 4.10 )
!/ 03-Sep-2012 : Clean up of UG grids ( version 4.08 )
!/
! 1. Purpose :
!
! Initialize WAVEWATCH III.
!
! 2. Method :
!
! Initialize data structure and wave fields from data files.
! Initialize grid from local and instantaneous data.
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! IMOD Int. I Model number.
! FEXT Char I Extension of data files.
! MDS I.A. I Array with dataset numbers (see below),
! saved as NDS in W3ODATMD.
! 1: General output unit number ("log file").
! 2: Error output unit number.
! 3: Test output unit number.
! 4: "screen", i.e., direct output location,
! can be the screen or the output file of
! the shell.
! 5: Model definition file unit number.
! 6: Restart file unit number.
! 7: Grid output file unit number.
! 8: Point output file unit number.
! 9: Input boundary data file unit number.
! 10: Output boundary data file unit number
! (first).
! 11: Track information file unit number.
! 12: Track output file unit number.
! MTRACE I.A. I Array with subroutine tracing information.
! 1: Output unit number for trace.
! 2: Maximum number of trace prints.
! ODAT I.A. I Output data, five parameters per output type
! 1-5 Data for OTYPE = 1; gridded fields.
! 1 YYYMMDD for first output.
! 2 HHMMSS for first output.
! 3 Output interval in seconds.
! 4 YYYMMDD for last output.
! 5 HHMMSS for last output.
! 6-10 Id. for OTYPE = 2; point output.
! 11-15 Id. for OTYPE = 3; track point output.
! 16-20 Id. for OTYPE = 4; restart files.
! 21-25 Id. for OTYPE = 5; boundary data.
! 31-35 Id. for OTYPE = 7; coupling data.
! FLGRD L.A. I Flags for gridded output.
! FLGR2 L.A. I Flags for coupling output.
! NPT Int. I Number of output points
! X/YPT R.A. I Coordinates of output points.
! PNAMES C.A. I Output point names.
! IPRT I.A. I Partitioning grid info.
! PRTFRM I.A. I Partitioning format flag.
! MPI_COMM Int. I MPI communicator to be used for model.
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! W3SETG Subr. W3GDATMD Point to data structure.
! W3SETW Subr. W3WDATMD Point to data structure.
! W3DIMW Subr. Id. Set array sizes in data structure.
! W3SETA Subr. W3ADATMD Point to data structure.
! W3DIMA Subr. Id. Set array sizes in data structure.
! W3SETI Subr. W3IDATMD Point to data structure.
! W3DIMI Subr. Id. Set array sizes in data structure.
! W3SETO Subr. W3ODATMD Point to data structure.
! W3DMO5 Subr. Id. Set array sizes in data structure.
! ITRACE Subr. W3SERVMD Subroutine tracing initialization.
! STRACE Subr. Id. Subroutine tracing.
! EXTCDE Subr. Id. Program abort.
! WWDATE Subr. Id. System date.
! WWTIME Subr. Id. System time.
! DSEC21 Func. W3TIMEMD Compute time difference.
! TICK21 Func. Id. Advance the clock.
! STME21 Func. Id. Print the time readable.
! PRTBLK Func. W3ARRYMD Print plot of array.
! W3IOGR Subr. W3IOGRMD Read/write model definition file.
! W3IORS Subr. W3IORSMD Read/write restart file.
! W3IOPP Subr. W3IOPOMD Preprocess point output.
! CALL MPI_COMM_SIZE, CALL MPI_COMM_RANK
! Subr. mpif.h Standard MPI routines.
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Any program shell or integrated model which uses WAVEWATCH III.
!
! 6. Error messages :
!
! On opening of log file only. Other error messages are generated
! by W3IOGR and W3IORS.
!
! 7. Remarks :
!
! - The log file is called 'log.FEXT', where FEXT is passed to
! the routine.
! - The test output file is called 'test.FEXT' in shared memory
! version or testNNN.FEXT in distributed memory version.
! - A water level and ice coverage are transferred with the
! restart file. To assure consistency within the model, the
! water level and ice coverage are re-evaluated at the 0th
! time step in the actual wave model routine.
! - When running regtests in cases where disk is non-local
! (i.e. NFS used), there can be a huge improvment in compute
! time by using /var/tmp/ for log files.
! See commented line at "OPEN (MDS(1),FILE=..."
!
! 8. Structure :
!
! ----------------------------------------------------
! 1. Set-up of idata structures and I/O.
! a Point to proper data structures.
! b Number of processors and processor number.
! c Open files.
! d Dataset unit numbers
! e Subroutine tracing
! f Initial and test outputs
! 2. Model definition.
! a Read model definition file ( W3IOGR )
! b Save MAPSTA.
! c MPP preparation
! 3. Model initialization.
! a Read restart file. ( W3IORS )
! b Compare grid and restart MAPSTA.
! c Initialize with winds if requested (set flag).
! d Initialize calm conditions if requested.
! e Preparations for prop. scheme.
! 4. Set-up output times.
! a Unpack ODAT.
! b Check if output available.
! c Get first time per output and overall.
! d Prepare point output ( W3IOPP )
! 5. Define wavenumber grid.
! a Calculate depth.
! b Fill wavenumber and group velocity arrays.
! 6. Initialize arrays.
! 7. Write info to log file.
! 8. Final MPI set up ( W3MPII , W3MPIO , W3MPIP )
! ----------------------------------------------------
!
! 9. Switches :
!
! !/SHRD Switch for shared / distributed memory architecture.
! !/DIST Id.
! !/MPI Id.
!
! !/S Enable subroutine tracing.
! !/Tn Enable test output.
!
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
USE CONSTANTS
!/MEMCHECK USE MallocInfo_m
!/
USE W3GDATMD, ONLY: W3SETG, P2MSF, E3DF, US3DF, USSPF
USE W3WDATMD, ONLY: W3SETW, W3DIMW
USE W3ADATMD, ONLY: W3SETA, W3DIMA, P2SMS, HS, EF, US3D, USSP
!/MEMCHECK USE W3ADATMD, ONLY: MALLINFOS
USE W3IDATMD, ONLY: W3SETI, W3DIMI
USE W3ODATMD, ONLY: W3SETO, W3DMO5
USE W3IOGOMD, ONLY: W3FLGRDUPDT
USE W3IOGRMD, ONLY: W3IOGR
USE W3IORSMD, ONLY: W3IORS
USE W3IOPOMD, ONLY: W3IOPP
USE W3SERVMD, ONLY: ITRACE, EXTCDE, WWDATE, WWTIME
!/S USE W3SERVMD, ONLY: STRACE
USE W3TIMEMD, ONLY: DSEC21, TICK21, STME21
USE W3ARRYMD, ONLY: PRTBLK
!/
USE W3GDATMD, ONLY: NX, NY, NSEA, NSEAL, MAPSTA, MAPST2, MAPFS, &
MAPSF, FLAGLL, &
ICLOSE, ZB, TRNX, TRNY, DMIN, DTCFL, DTMAX, &
FLCK, NK, NTH, NSPEC, SIG, GNAME
!/PDLIB USE W3GDATMD, ONLY : FLCTH
USE W3WDATMD, ONLY: TIME, TLEV, TICE, WLV, UST, USTDIR, VA
USE W3ODATMD, ONLY: NDSO, NDSE, NDST, SCREEN, NDS, NTPROC, &
NAPROC, IAPROC, NAPLOG, NAPOUT, NAPERR, &
NAPFLD, NAPPNT, NAPTRK, NAPRST, NAPBPT, &
NAPPRT, TOFRST, DTOUT, TONEXT, TOLAST, &
FLOUT, FLOGRD, FLBPO, NOPTS, PTNME, &
PTLOC, IPTINT, PTIFAC, UNDEF, IDOUT, FLBPI, &
OUTPTS, FNMPRE, IX0, IXN, IXS, IY0, IYN, &
IYS, FLFORM, IOSTYP, UNIPTS, UPPROC, NOTYPE,&
FLOGR2, NOGRP, NGRPP, FLOGD, FLOG2
USE W3ADATMD, ONLY: NSEALM, IAPPRO, FLCOLD, FLIWND, DW, CG, WN, &
UA, UD, U10, U10D, AS
!/MPI USE W3ADATMD, ONLY: MPI_COMM_WAVE, MPI_COMM_WCMP
USE W3IDATMD, ONLY: FLLEV, FLCUR, FLWIND, FLICE, FLMDN, FLMTH, &
FLMVS, FLIC1, FLIC2, FLIC3, FLIC4, FLIC5
USE W3DISPMD, ONLY: WAVNU1, WAVNU3
USE W3PARALL, ONLY : AC_tot
USE W3PARALL, ONLY: SET_UP_NSEAL_NSEALM
!/PDLIB USE W3PARALL, ONLY: SYNCHRONIZE_IPGL_ETC_ARRAY, ISEA_TO_JSEA
!/PDLIB use yowNodepool, only: npa
!/PDLIB use yowRankModule, only : rank
USE W3GDATMD, ONLY: GTYPE, UNGTYPE
!/PDLIB USE PDLIB_W3PROFSMD, ONLY : PDLIB_MAPSTA_INIT, VA_SETUP_IOBPD
!/PDLIB USE PDLIB_W3PROFSMD, ONLY : BLOCK_SOLVER_INIT, PDLIB_STYLE_INIT
!/PDLIB use yowDatapool, only: istatus
!/SETUP USE W3WAVSET, ONLY : PREPARATION_FD_SCHEME
!/SETUP USE W3WDATMD, ONLY: ZETA_SETUP
!/SETUP USE W3GDATMD, ONLY : DO_CHANGE_WLV
USE W3GDATMD, ONLY: FSN,FSPSI,FSFCT,FSNIMP, FSTOTALIMP, FSTOTALEXP
USE W3GDATMD, ONLY: FSREFRACTION, FSFREQSHIFT
USE W3PARALL, ONLY: INIT_GET_JSEA_ISPROC, INIT_GET_ISEA
!/TIMINGS USE W3PARALL, ONLY: PRINT_MY_TIME
!/PDLIB!/DEBUGCOH USE PDLIB_W3PROFSMD, ONLY: ALL_VA_INTEGRAL_PRINT, TEST_MPI_STATUS
!/PDLIB!/DEBUGINIT USE PDLIB_W3PROFSMD, ONLY: PRINT_WN_STATISTIC
!/UOST USE W3UOSTMD, ONLY: UOST_SETGRID
!/
IMPLICIT NONE
!
!/MPI INCLUDE "mpif.h"
!/
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: IMOD, MDS(13), MTRACE(2), &
ODAT(35), NPT, IPRT(6), MPI_COMM
LOGICAL, INTENT(IN) :: IsMulti
REAL, INTENT(INOUT) :: XPT(NPT), YPT(NPT)
LOGICAL, INTENT(INOUT) :: FLGRD(NOGRP,NGRPP), FLGD(NOGRP),&
FLGR2(NOGRP,NGRPP), FLG2(NOGRP),&
PRTFRM
CHARACTER, INTENT(IN) :: FEXT*(*)
CHARACTER(LEN=10), INTENT(IN) :: PNAMES(NPT)
LOGICAL, INTENT(IN), OPTIONAL :: FLAGSTIDEIN(4)
INTEGER :: NSEALout, NSEALMout
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
integer :: IRANK, I, ISTAT
INTEGER :: IE, IFL, IFT, IERR, NTTOT, NTLOC, &
NTTARG, IK, IP, ITH, INTYPE, IX, IY, &
J, J0, TOUT(2), TLST(2), ISEA, IS, &
K, I1, I2, JSEA, NTTMAX
!/DIST INTEGER :: ISTEP, ISP, IW
!/MPI INTEGER :: IERR_MPI, BGROUP, LGROUP
!/S INTEGER, SAVE :: IENT = 0
!/T INTEGER :: NX0, NXN
!/T INTEGER, ALLOCATABLE :: MAPOUT(:,:)
!/MPI INTEGER, ALLOCATABLE :: TMPRNK(:)
INTEGER, ALLOCATABLE :: NT(:), MAPTST(:,:)
!/T INTEGER, SAVE :: NXS = 49
REAL :: DTTST, DEPTH, FRACOS
REAL :: FACTOR
REAL :: WLVeff
!/T REAL, ALLOCATABLE :: XOUT(:,:)
LOGICAL :: OPENED
CHARACTER(LEN=8) :: STTIME
CHARACTER(LEN=10) :: STDATE
INTEGER :: ISPROC
!/DIST CHARACTER(LEN=12) :: FORMAT
CHARACTER(LEN=23) :: DTME21
CHARACTER(LEN=30) :: LFILE, TFILE
!/PDLIB INTEGER :: IScal(1), IPROC
!/
!/ ------------------------------------------------------------------- /
!
! 1. Set-up of data structures and I/O ----------------------------- /
! 1.a Point to proper data structures.
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 1")
CALL W3SETO ( IMOD, MDS(2), MDS(3) )
CALL W3SETG ( IMOD, MDS(2), MDS(3) )
CALL W3SETW ( IMOD, MDS(2), MDS(3) )
CALL W3SETA ( IMOD, MDS(2), MDS(3) )
CALL W3SETI ( IMOD, MDS(2), MDS(3) )
!/UOST CALL UOST_SETGRID(IMOD)
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 2")
!/DEBUGINIT WRITE(740+IAPROC,*) 'Beginning of W3INIT'
!/DEBUGINIT WRITE(740+IAPROC,*) ' FLGR2(10,1)=', FLGR2(10,1)
!/DEBUGINIT WRITE(740+IAPROC,*) ' FLGR2(10,2)=', FLGR2(10,2)
!/DEBUGINIT FLUSH(740+IAPROC)
!/TIMINGS CALL PRINT_MY_TIME("Case 2")
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 1'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!
! 1.b Number of processors and processor number.
! Overwrite some initializations from W3ODATMD.
!
! *******************************************************
! *** NOTE : OUTPUT PROCESSOR ASSIGNMENT NEEDS TO BE ***
! *** CONSISTENT WITH ASSIGNMENT IN WMINIT. ***
! *******************************************************
!
!/SHRD NTPROC = 1
!/SHRD NAPROC = 1
!/SHRD IAPROC = 1
!/SHRD IOSTYP = 1
!
!/MPI MPI_COMM_WAVE = MPI_COMM
!/MPI CALL MPI_COMM_SIZE ( MPI_COMM_WAVE, NTPROC, IERR_MPI )
!/MPI NAPROC = NTPROC
!/MPI CALL MPI_COMM_RANK ( MPI_COMM_WAVE, IAPROC, IERR_MPI )
!/MPI IAPROC = IAPROC + 1
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 3")
IF ( IOSTYP .LE. 1 ) THEN
!
NAPFLD = MAX(1,NAPROC-1)
NAPPNT = MAX(1,NAPROC-2)
NAPTRK = MAX(1,NAPROC-5)
NAPRST = NAPROC
NAPBPT = MAX(1,NAPROC-3)
NAPPRT = MAX(1,NAPROC-4)
!
ELSE
!
NAPPNT = NAPROC
IF ( UNIPTS .AND. UPPROC ) NAPROC = MAX(1,NTPROC - 1)
NAPFLD = NAPROC
NAPRST = NAPROC
NAPBPT = NAPROC
NAPTRK = NAPROC
NAPPRT = NAPROC
!
IF ( IOSTYP .EQ. 2 ) THEN
NAPROC = MAX(1,NAPROC-1)
ELSE IF ( IOSTYP .EQ. 3 ) THEN
!
! For field or coupling output
!
IF ( ODAT( 3).GT.0 .OR. ODAT(33).GT.0 ) THEN
NAPFLD = NAPROC
NAPROC = MAX(1,NAPROC-1)
END IF
IF ( ODAT(13).GT.0 ) THEN
NAPTRK = NAPROC
NAPROC = MAX(1,NAPROC-1)
END IF
IF ( ODAT(28).GT.0 ) THEN
NAPPRT = NAPROC
NAPROC = MAX(1,NAPROC-1)
END IF
IF ( ODAT( 8).GT.0 ) NAPPNT = NAPROC
IF ( ODAT(18).GT.0 ) NAPRST = NAPROC
IF ( ODAT(23).GT.0 ) NAPBPT = NAPROC
IF ( ( ODAT( 8).GT.0 .OR. ODAT(18).GT.0 .OR. &
ODAT(23).GT.0 ) ) NAPROC = MAX(1,NAPROC-1)
END IF
END IF
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 4")
FRACOS = 100. * REAL(NTPROC-NAPROC) / REAL(NTPROC)
IF ( FRACOS.GT.CRITOS .AND. IAPROC.EQ.NAPERR ) &
WRITE (NDSE,8002) FRACOS
!
!/MPI IF ( NAPROC .EQ. NTPROC ) THEN
!/MPI MPI_COMM_WCMP = MPI_COMM_WAVE
!/MPI ELSE
!/MPI CALL MPI_COMM_GROUP ( MPI_COMM_WAVE, BGROUP, IERR_MPI )
!/MPI ALLOCATE ( TMPRNK(NAPROC) )
!/MPI DO J=1, NAPROC
!/MPI TMPRNK(J) = J - 1
!/MPI END DO
!/MPI CALL MPI_GROUP_INCL ( BGROUP, NAPROC, TMPRNK, LGROUP, &
!/MPI IERR_MPI )
!/MPI CALL MPI_COMM_CREATE ( MPI_COMM_WAVE, LGROUP, &
!/MPI MPI_COMM_WCMP, IERR_MPI )
!/MPI CALL MPI_GROUP_FREE ( LGROUP, IERR_MPI )
!/MPI CALL MPI_GROUP_FREE ( BGROUP, IERR_MPI )
!/MPI DEALLOCATE ( TMPRNK )
!/MPI END IF
!!!/PDLIB CALL W3SETG(IMOD, NDSE, NDST)
!
LPDLIB = .FALSE.
!/PDLIB LPDLIB = .TRUE.
IF (FSTOTALIMP .and. .NOT. LPDLIB) THEN
WRITE(NDSE,*) 'IMPTOTAL is selected'
WRITE(NDSE,*) 'But PDLIB is not'
STOP 'Stop, case 1'
ELSE IF (FSTOTALEXP .and. .NOT. LPDLIB) THEN
WRITE(NDSE,*) 'EXPTOTAL is selected'
WRITE(NDSE,*) 'But PDLIB is not'
STOP 'Stop, case 1'
END IF
!
! 1.c Open files without unpacking MDS ,,,
!
IE = LEN_TRIM(FEXT)
LFILE = 'log.' // FEXT(:IE)
IFL = LEN_TRIM(LFILE)
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 5")
!/SHRD TFILE = 'test.' // FEXT(:IE)
!/DIST IW = 1 + INT ( LOG10 ( REAL(NAPROC) + 0.5 ) )
!/DIST IW = MAX ( 3 , MIN ( 9 , IW ) )
!/DIST WRITE (FORMAT,'(A5,I1.1,A1,I1.1,A4)') &
!/DIST '(A4,I', IW, '.', IW, ',2A)'
!/DIST WRITE (TFILE,FORMAT) 'test', &
!/DIST OUTPTS(IMOD)%IAPROC, '.', FEXT(:IE)
IFT = LEN_TRIM(TFILE)
J = LEN_TRIM(FNMPRE)
!
IF ( OUTPTS(IMOD)%IAPROC .EQ. OUTPTS(IMOD)%NAPLOG ) &
!/DEBUGINIT WRITE(*,*) '1: w3initmd f=', TRIM(FNMPRE(:J)//LFILE(:IFL))
OPEN (MDS(1),FILE=FNMPRE(:J)//LFILE(:IFL),ERR=888,IOSTAT=IERR)
!
IF ( MDS(3).NE.MDS(1) .AND. MDS(3).NE.MDS(4) .AND. TSTOUT ) THEN
INQUIRE (MDS(3),OPENED=OPENED)
!/DEBUGINIT WRITE(*,*) '2: w3initmd f=', TRIM(FNMPRE(:J)//TFILE(:IFT))
IF ( .NOT. OPENED ) OPEN &
(MDS(3),FILE=FNMPRE(:J)//TFILE(:IFT),ERR=889,IOSTAT=IERR)
END IF
!
! 1.d Dataset unit numbers
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 6")
NDS = MDS
NDSO = NDS(1)
NDSE = NDS(2)
NDST = NDS(3)
SCREEN = NDS(4)
!
! 1.e Subroutine tracing
!
CALL ITRACE ( MTRACE(1), MTRACE(2) )
!
! 1.f Initial and test outputs
!
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 2'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 7")
IF ( IAPROC .EQ. NAPLOG ) THEN
CALL WWDATE ( STDATE )
CALL WWTIME ( STTIME )
WRITE (NDSO,900) WWVER, STDATE, STTIME
END IF
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 2a'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!/S CALL STRACE (IENT, 'W3INIT')
!/T WRITE(NDST,9000) IMOD, FEXT(:IE)
!/T WRITE (NDST,9001) NTPROC, NAPROC, IAPROC, NAPLOG, NAPOUT, &
!/T NAPERR, NAPFLD, NAPPNT, NAPTRK, NAPRST, NAPBPT, NAPPRT
!/T WRITE (NDST,9002) NDSO, NDSE, NDST, SCREEN
!/T WRITE (NDST,9003) LFILE(:IFL), TFILE(:IFT)
!
! 2. Model defintition ---------------------------------------------- /
! 2.a Read model defintition file
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 8")
CALL W3IOGR ( 'READ', NDS(5), IMOD, FEXT )
!/PDLIB IF (GTYPE .ne. UNGTYPE) THEN
!/SETUP CALL PREPARATION_FD_SCHEME(IMOD)
!/PDLIB ELSE
!/PDLIB!/DEBUGINIT WRITE(*,*) 'Before PDLIB_STYLE_INIT, IMOD=', IMOD
!/PDLIB CALL PDLIB_STYLE_INIT(IMOD)
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'After set up of NSEAL, NSEALM=', NSEALM
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'After PDLIB_STYLE_INIT'
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'allocated(ISEA_TO_JSEA)=', allocated(ISEA_TO_JSEA)
!/PDLIB!/DEBUGINIT FLUSH(740+IAPROC)
!/TIMINGS CALL PRINT_MY_TIME("After PDLIB_STYLE_INIT")
!/PDLIB!/DEBUGINIT WRITE(*,*) 'After PDLIB_STYLE_INIT, IMOD=', IMOD
!/PDLIB CALL SYNCHRONIZE_IPGL_ETC_ARRAY(IMOD, IsMulti)
!/PDLIB END IF
! Update of output parameter flags based on mod_def parameters (for 3D arrays)
!/DEBUGINIT WRITE(740+IAPROC,*) 'Before W3FLGRDUPDT'
!/DEBUGINIT FLUSH(740+IAPROC)
CALL W3FLGRDUPDT ( NDSO, NDSE, FLGRD, FLGR2, FLGD, FLG2 )
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 9")
!/TIMINGS CALL PRINT_MY_TIME("After W3FLGRDUPDT")
IF ( FLAGLL ) THEN
FACTOR = 1.
ELSE
FACTOR = 1.E-3
END IF
IF ( IAPROC .EQ. NAPLOG ) WRITE (NDSO,920)
!
! 2.b Save MAPSTA
!
ALLOCATE ( MAPTST(NY,NX) )
MAPTST = MAPSTA
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 2b'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!
! 2.c MPP preparation
! 2.c.1 Set simple counters and variables
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 10")
CALL SET_UP_NSEAL_NSEALM(NSEALout, NSEALMout)
NSEAL=NSEALout
NSEALM=NSEALMout
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 2c'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!/DEBUGINIT WRITE(740+IAPROC,*) 'After set up of NSEAL, NSEAL=', NSEAL
!/DEBUGINIT WRITE(740+IAPROC,*) 'After set up of NSEAL, NSEALM=', NSEALM
!/DEBUGINIT WRITE(740+IAPROC,*) 'NSEA=', NSEA, ' NSPEC=', NSPEC
!/DEBUGINIT FLUSH(740+IAPROC)
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 11")
!/DIST IF ( NSEA .LT. NAPROC ) GOTO 820
!/DIST IF ((LPDLIB .eqv. .FALSE.).or.(GTYPE .NE. UNGTYPE)) THEN
!/DIST IF ( NSPEC .LT. NAPROC ) GOTO 821
!/DIST END IF
!/DEBUGINIT WRITE(740+IAPROC,*) 'Before PDLIB related allocations'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB IF ((IAPROC .LE. NAPROC).and.(GTYPE .eq. UNGTYPE)) THEN
!/DEBUGINIT WRITE(740+IAPROC,*) 'After test 1'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB IF (FSNIMP .or. FSTOTALIMP) THEN
!/DEBUGINIT WRITE(740+IAPROC,*) 'Before BLOCK_SOLVER_INIT'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB CALL BLOCK_SOLVER_INIT()
!/DEBUGINIT WRITE(740+IAPROC,*) 'After BLOCK_SOLVER_INIT'
!/DEBUGINIT FLUSH(740+IAPROC)
!/TIMINGS CALL PRINT_MY_TIME("After BLOCK_SOLVER_INIT")
!/PDLIB ELSE IF (FSTOTALEXP) THEN
!/DEBUGINIT WRITE(740+IAPROC,*) 'Before AC_tot allocation'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB allocate(AC_tot(NSPEC, npa), stat=istat)
!/DEBUGINIT WRITE(740+IAPROC,*) 'After AC_tot allocation'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB ENDIF
!/PDLIB END IF
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 2d'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 12")
!
!
! 2.c.2 Allocate arrays
!
IF ( IAPROC .LE. NAPROC ) THEN
!/DEBUGINIT WRITE(740+IAPROC,*) 'Calling W3DIMW at W3INIT, case 1'
!/DEBUGINIT FLUSH(740+IAPROC)
CALL W3DIMW ( IMOD, NDSE, NDST )
ELSE
!/DEBUGINIT WRITE(740+IAPROC,*) 'Calling W3DIMW at W3INIT, case 2'
!/DEBUGINIT FLUSH(740+IAPROC)
CALL W3DIMW ( IMOD, NDSE, NDST, .FALSE. )
END IF
!/DEBUGINIT WRITE(740+IAPROC,*) ' 1: NSEAL=', NSEAL
!/DEBUGINIT WRITE(740+IAPROC,*) ' maxval(UST)=', maxval(UST)
!/DEBUGINIT FLUSH(740+IAPROC)
!/TIMINGS CALL PRINT_MY_TIME("After W3DIMW")
CALL W3DIMA ( IMOD, NDSE, NDST )
CALL W3DIMI ( IMOD, NDSE, NDST , FLAGSTIDEIN )
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 13")
!/TIMINGS CALL PRINT_MY_TIME("After W3DIMI")
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 3'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
! 2.c.3 Calculated expected number of prop. calls per processor
!
NTTOT = 0
DO IK=1, NK
NTLOC = 1 + INT(DTMAX/(DTCFL*SIG(IK)/SIG(1))-0.001)
NTTOT = NTTOT + NTLOC*NTH
END DO
NTTARG = 1 + (NTTOT-1)/NAPROC
NTTARG = NTTARG + INT(DTMAX/(DTCFL*SIG(NK)/SIG(1))-0.001)
NTTMAX = NTTARG + 5
!
! 2.c.4 Initialize IAPPRO
!
IAPPRO = 1
ALLOCATE ( NT(NSPEC) )
NT = NTTOT
!/DIST IF ((LPDLIB .eqv. .FALSE.).or.(GTYPE .NE. UNGTYPE)) THEN
!
!/DIST DO
!
! 2.c.5 First sweep filling IAPPRO
!
!/DIST DO IP=1, NAPROC
!/DIST ISTEP = IP
!/DIST ISP = 0
!/DIST NT(IP) = 0
!/DIST DO J=1, 1+NSPEC/NAPROC
!/DIST ISP = ISP + ISTEP
!/DIST IF ( MOD(J,2) .EQ. 1 ) THEN
!/DIST ISTEP = 2*(NAPROC-IP) + 1
!/DIST ELSE
!/DIST ISTEP = 2*IP - 1
!/DIST END IF
!/DIST IF ( ISP .LE. NSPEC ) THEN
!/DIST IK = 1 + (ISP-1)/NTH
!/DIST NTLOC = 1 + INT(DTMAX/(DTCFL*SIG(IK)/SIG(1))-0.001)
!/DIST IF ( NT(IP)+NTLOC .LE. NTTARG ) THEN
!/DIST IAPPRO(ISP) = IP
!/DIST NT(IP) = NT(IP) + NTLOC
!/DIST ELSE
!/DIST IAPPRO(ISP) = -1
!/DIST END IF
!/DIST END IF
!/DIST END DO
!/DIST END DO
!
! 2.c.6 Second sweep filling IAPPRO
!
!/DIST DO IP=1, NAPROC
!/DIST IF ( NT(IP) .LT. NTTARG ) THEN
!/DIST DO ISP=1, NSPEC
!/DIST IF ( IAPPRO(ISP) .EQ. -1 ) THEN
!/DIST IK = 1 + (ISP-1)/NTH
!/DIST NTLOC = 1 + INT(DTMAX/(DTCFL*SIG(IK)/SIG(1))-0.001)
!/DIST IF ( NT(IP)+NTLOC .LE. NTTARG ) THEN
!/DIST IAPPRO(ISP) = IP
!/DIST NT(IP) = NT(IP) + NTLOC
!/DIST END IF
!/DIST END IF
!/DIST END DO
!/DIST END IF
!/DIST END DO
!
! 2.c.7 Check if all served
!
!/DIST IF ( MINVAL(IAPPRO(1:NSPEC)) .GT. 0 ) THEN
!/DIST EXIT
!/DIST ELSE
!/DIST NTTARG = NTTARG + 1
!/DIST IF ( NTTARG .GE. NTTMAX ) EXIT
!/DIST IF ( IAPROC .EQ. NAPERR ) WRITE (NDSE,8028)
!/DIST END IF
!
!/DIST END DO
!/DIST END IF
!
!!/DEBUGMPI CALL TEST_MPI_STATUS("Case 14")
!/TIMINGS CALL PRINT_MY_TIME("After Case 14")
! 2.c.8 Test output
!
!/T WRITE (NDST,9020)
!/T DO IP=1, NAPROC
!/T WRITE (NDST,9021) IP, NT(IP), NTTARG
!/T END DO
!
!/T WRITE (NDST,9025)
!/T DO IK=NK, 1, -1
!/T WRITE (NDST,9026) IK, (IAPPRO(ITH+(IK-1)*NTH),ITH=1,MIN(24,NTH))
!/T IF ( NTH .GT. 24 ) WRITE (NDST,9027) &
!/T (IAPPRO(ITH+(IK-1)*NTH),ITH=25,NTH)
!/T END DO
!
! 2.c.9 Test if any spectral points are left out
!
!/DIST IF ((LPDLIB .eqv. .FALSE.).or.(GTYPE .NE. UNGTYPE)) THEN
!/DIST DO ISP=1, NSPEC
!/DIST IF ( IAPPRO(ISP) .EQ. -1. ) GOTO 829
!/DIST END DO
!/DIST END IF
!
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 4'
!/DEBUGINIT FLUSH(740+IAPROC)
DEALLOCATE ( NT )
!
! 3. Model initialization ------------------------------------------- /
! 3.a Read restart file
!
VA(:,:) = 0.
!/DEBUGMPI CALL TEST_MPI_STATUS("Case 15")
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 4.0'
!/DEBUGINIT WRITE(740+IAPROC,*) ' 1: min/max/sum(VA)=', minval(VA), maxval(VA), sum(VA)
!/DEBUGINIT WRITE(740+IAPROC,*) ' 1: NSEAL=', NSEAL
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "Before W3IORS call")
!/DEBUGINIT WRITE(740+IAPROC,*) ' After ALL_VA_INTEGRAL_PRINT'
!/DEBUGINIT FLUSH(740+IAPROC)
!/TIMINGS CALL PRINT_MY_TIME("Before W3IORS")
CALL W3IORS ( 'READ', NDS(6), SIG(NK), INTYPE, IMOD )
!/TIMINGS CALL PRINT_MY_TIME("After W3IORS")
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 3a'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!/DEBUGINIT WRITE(740+IAPROC,*) ' 2: min/max/sum(VA)=', minval(VA), maxval(VA), sum(VA)
!/DEBUGINIT WRITE(740+IAPROC,*) ' 2: NSEAL=', NSEAL
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "After W3IORS call")
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 4.1'
!/DEBUGINIT WRITE(740+IAPROC,*) ' sum(VA)=', sum(VA)
!/DEBUGINIT FLUSH(740+IAPROC)
FLCOLD = INTYPE.LE.1 .OR. INTYPE.EQ.4
IF ( IAPROC .EQ. NAPLOG ) THEN
IF (INTYPE.EQ.0) THEN
WRITE (NDSO,930) 'cold start (idealized).'
ELSE IF ( INTYPE .EQ. 1 ) THEN
WRITE (NDSO,930) 'cold start (wind).'
ELSE IF ( INTYPE .EQ. 4 ) THEN
WRITE (NDSO,930) 'cold start (calm).'
ELSE
WRITE (NDSO,930) 'full restart.'
END IF
END IF
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 4.2'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "W3INIT, step 4.2")
!/TIMINGS CALL PRINT_MY_TIME("After restart inits")
!
! 3.b Compare MAPSTA from grid and restart
!
DO IX=1, NX
DO IY=1, NY
IF ( ABS(MAPSTA(IY,IX)).EQ.2 .OR. &
ABS(MAPTST(IY,IX)).EQ.2 ) THEN
MAPSTA(IY,IX) = SIGN ( MAPTST(IY,IX) , MAPSTA(IY,IX) )
END IF
END DO
END DO
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 3b'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 4.3'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "W3INIT, step 4.3")
!
! 3.b2 Set MAPSTA associated to PDLIB
!
!/PDLIB IF (GTYPE .eq. UNGTYPE) THEN
!/PDLIB CALL PDLIB_MAPSTA_INIT(IMOD)
!/PDLIB END IF
!
! 3.c Initialization from wind fields
!
FLIWND = INTYPE.EQ.1
!/T IF ( FLIWND ) WRITE (NDST,9030)
!
! 3.d Initialization with calm conditions
!
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 5'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "W3INIT, step 5")
IF ( INTYPE .EQ. 4 ) THEN
VA(:,:) = 0.
!/T WRITE (NDST,9031)
END IF
!/MEMCHECK WRITE(740+IAPROC,*) 'memcheck_____:', 'WW3_INIT SECTION 4'
!/MEMCHECK call getMallocInfo(mallinfos)
!/MEMCHECK call printMallInfo(IAPROC,mallInfos)
!
! 3.e Prepare propagation scheme
!
IF ( .NOT. FLCUR ) FLCK = .FALSE.
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT definition of FSREFR and FRFREQ'
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'FSTOTALIMP=', FSTOTALIMP
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'FSREFRACTION=', FSREFRACTION
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'FSFREQSHIFT=', FSFREQSHIFT
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) 'Before FLCTH=', FLCTH, 'FLCK=', FLCK
!/PDLIB IF (FSTOTALIMP .and. FSREFRACTION) THEN
!/PDLIB FLCTH = .FALSE.
!/PDLIB END IF
!/PDLIB IF (FSTOTALIMP .and. FSFREQSHIFT) THEN
!/PDLIB FLCK = .FALSE.
!/PDLIB END IF
!/PDLIB!/DEBUGINIT WRITE(740+IAPROC,*) ' After FLCTH=', FLCTH, 'FLCK=', FLCK
!
! 4. Set-up output times -------------------------------------------- *
! 4.a Unpack ODAT
!
DO J=1, NOTYPE
J0 = (J-1)*5
TONEXT(1,J) = ODAT(J0+1)
TONEXT(2,J) = ODAT(J0+2)
DTOUT ( J) = REAL ( ODAT(J0+3) )
TOLAST(1,J) = ODAT(J0+4)
TOLAST(2,J) = ODAT(J0+5)
END DO
!
! 4.b Check if output available
!
FLOUT(1) = .FALSE.
FLOGRD = FLGRD
FLOGD = FLGD
DO J=1, NOGRP
DO K=1, NGRPP
FLOUT(1) = FLOUT(1) .OR. FLOGRD(J,K)
END DO
END DO
!/DEBUGINIT WRITE(740+IAPROC,*) 'W3INIT, aft BLOCK_SOLVER_INIT, step 6'
!/DEBUGINIT FLUSH(740+IAPROC)
!/PDLIB!/DEBUGCOH CALL ALL_VA_INTEGRAL_PRINT(IMOD, "W3INIT, step 6")
!
FLOUT(7) = .FALSE.
FLOGR2 = FLGR2
FLOG2 = FLG2
DO J=1, NOGRP
DO K=1, NGRPP
FLOUT(7) = FLOUT(7) .OR. FLOGR2(J,K)
END DO
END DO
!
FLOUT(2) = NPT .GT. 0
!
FLOUT(3) = .TRUE.
!
FLOUT(4) = .TRUE.
!
FLOUT(5) = FLBPO
IF ( FLBPO ) THEN
CALL W3DMO5 ( IMOD, NDSE, NDST, 4 )
ELSE
DTOUT(5) = 0.
END IF
!
IX0 = MAX ( 1, IPRT(1) )
IXN = MIN ( NX, IPRT(2) )
IXS = MAX ( 1, IPRT(3) )
IY0 = MAX ( 1, IPRT(4) )
IYN = MIN ( NY, IPRT(5) )
IYS = MAX ( 1, IPRT(6) )
FLFORM = PRTFRM
FLOUT(6) = IX0.LE.IXN .AND. IY0.LE.IYN