-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3oacpmd.ftn
1029 lines (1019 loc) · 38.9 KB
/
w3oacpmd.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 W3OACPMD
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ July-2013 : Origination. ( version 4.18 )
!/ For upgrades see subroutines.
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
!/ Copyright 2009-2012 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.
!/
! 1. Purpose :
!
! Generic Module used for coupling applications with OASIS3-MCT
!
! 2. Variables and types :
!
! 3. Subroutines and functions :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! CPL_OASIS_INIT Subr. Public Initialize the coupling
! CPL_OASIS_GRID Subr. Public Grids defintion
! CPL_OASIS_DEFINE Subr. Public Partition definition
! CPL_OASIS_SND Subr. Public Send fields to ocean/atmos model
! CPL_OASIS_RCV Subr. Public Receive fields from ocean/atmos model
! CPL_OASIS_FINALIZE Subr. Public Finalize the coupling
! ----------------------------------------------------------------
!
! 4. Subroutines and functions used :
!
! Name Type Module Description
! --------------------------------------------------------------------
! GET_LIST_EXCH_FIELD Subr. W3OACPMD List of the exchanged fields
! STRSPLIT Subr. W3SERVMD Splits string into words
! --------------------------------------------------------------------
!
! 5. Remarks
!
! Module adapted from WRF-OASIS routine implemented by
! Sebastien Masson (IPSL), Guillaume Samson (Legos) and Eric Maisonnave (Cerfacs)
!
! 6. Switches :
! 7. Source code :
!
!/ ------------------------------------------------------------------- /
!
USE MOD_OASIS ! OASIS3-MCT module
!
IMPLICIT NONE
PRIVATE
!
INTEGER :: IL_COMPID ! Component model ID returned by oasis_init_comp
CHARACTER(LEN=6) :: CL_MODEL_NAME = 'wwatch' ! Model name (same as in namcouple)
INTEGER :: IL_ERR ! Return error code
INTEGER, PUBLIC :: IL_NB_RCV, IL_NB_SND ! Number of coupling fields
INTEGER, PARAMETER :: IP_MAXFLD=50 ! Maximum number of coupling fields
INTEGER :: NNODES ! Total numbers of cell in the grid
!
TYPE, PUBLIC :: CPL_FIELD ! Type for coupling field information
CHARACTER(LEN = 8) :: CL_FIELD_NAME ! Name of the coupling field
INTEGER :: IL_FIELD_ID ! Field ID
END TYPE CPL_FIELD
!
TYPE(CPL_FIELD), DIMENSION(IP_MAXFLD), PUBLIC :: RCV_FLD, SND_FLD ! Coupling fields
!
INTEGER, PUBLIC :: ID_OASIS_TIME=0 ! time counter for coupling exchanges
!
! * Accessibility
PUBLIC CPL_OASIS_INIT
PUBLIC CPL_OASIS_GRID
PUBLIC CPL_OASIS_DEFINE
PUBLIC CPL_OASIS_SND
PUBLIC CPL_OASIS_RCV
PUBLIC CPL_OASIS_FINALIZE
!
CONTAINS
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_INIT(ID_LCOMM)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
! 1. Purpose :
!
! Initialize the coupling
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ID_LCOMM Int. O MPI communicator
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! WW3_SHEL Prog. - Main program
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!
! * Argument
INTEGER, INTENT(OUT) :: ID_LCOMM ! Model local communicator
!
!----------------------------------------------------------------------
! * Executable part
!
!! Initialize the coupling
CALL OASIS_INIT_COMP(IL_COMPID, CL_MODEL_NAME, IL_ERR)
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_INIT', 'Problem during oasis_init_comp')
ENDIF
!
!! Get the value of a local MPI communicator to be used by WW3 for its internal parallelisation
CALL OASIS_GET_LOCALCOMM(ID_LCOMM, IL_ERR)
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_INIT', 'Problem during oasis_get_localcomm')
ENDIF
!
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_INIT
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_GRID(LD_MASTER,ID_LCOMM)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | V. Garnier |
!/ | M. Accensi |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/ Sept-2016 : Correct bug MPI (J. Pianezze) ( version 5.12 )
!/
! 1. Purpose :
!
! Grid data file definition
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! LD_MASTER Bool. I Flag to know the master process
! ID_LCOMM Int. I MPI communicator
! ----------------------------------------------------------------
!
! 4. Subroutines used :
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! WW3_SHEL Prog. - Main program
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!
USE CONSTANTS, ONLY: RADIUS, DERA
USE W3GDATMD, ONLY: NX, NY, FLAGLL, XGRD, YGRD, MAPSTA, &
& HPFAC, HQFAC, GTYPE, &
& UNGTYPE, RLGTYPE, CLGTYPE
!/MPI INCLUDE "mpif.h"
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
LOGICAL, INTENT(IN) :: LD_MASTER ! MASTER process or not
INTEGER, INTENT(IN) :: ID_LCOMM ! Model local communicator
!
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER, ALLOCATABLE :: MASK(:,:)
INTEGER :: I, IX, IY, NXW, NXE, NYS, NYN, INODE, IERR_MPI
REAL, ALLOCATABLE :: LON(:,:),LAT(:,:),AREA(:,:), &
CORLON(:,:,:),CORLAT(:,:,:)
REAL :: FACTOR
!/ ------------------------------------------------------------------- /
!
IF (LD_MASTER) THEN
!
IF (FLAGLL) THEN
FACTOR = 1.
ELSE
FACTOR = 1. / (RADIUS * DERA)
END IF
!
! 0. Create grids file
! --------------------------------
CALL OASIS_START_GRIDS_WRITING(IERR_MPI)
!
! 1. Get the lat/lon/corners,areas and masks
! -------------------------------------------
IF (GTYPE .EQ. RLGTYPE .OR. GTYPE .EQ. CLGTYPE) THEN
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NNODES = NX*NY
NXW=1
NXE=NX
NYS=1
NYN=NY
!
! lat/lon
ALLOCATE ( LON(NNODES,1), LAT(NNODES,1) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
LON(I,1)=XGRD(IY,IX)*FACTOR
LAT(I,1)=YGRD(IY,IX)*FACTOR
END DO
END DO
!
! areas, corners
ALLOCATE ( AREA(NNODES,1), CORLON(NNODES,1,4), CORLAT(NNODES,1,4) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
CORLON(I,1,1)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,2)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,3)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,4)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,1)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,2)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,3)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,4)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
AREA(I,1)=HPFAC(IY,IX)*HQFAC(IY,IX)
END DO
END DO
!
! Model grid mask
ALLOCATE ( MASK(NNODES,1) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
! Get the mask : 0 - sea / 1 - open boundary cells (the land is already excluded)
IF ((MAPSTA(IY,IX) .EQ. 1)) THEN
MASK(I,1) = 0
ELSE
MASK(I,1) = 1
END IF
END DO
END DO
ELSE
!
! 1.2. Unstructured grids
! ----------------------------------
WRITE(*,*) 'TO BE IMPLEMENT FOR UNSTRUCTURED GRIDS'
STOP
END IF
!
CALL OASIS_WRITE_GRID('ww3t',NNODES,1,LON,LAT)
CALL OASIS_WRITE_CORNER('ww3t',NNODES,1,4,CORLON,CORLAT)
CALL OASIS_WRITE_AREA('ww3t',NNODES,1,AREA)
CALL OASIS_WRITE_MASK('ww3t',NNODES,1,MASK)
!
! 2. Terminate grid writing
! -------------------------
CALL OASIS_TERMINATE_GRIDS_WRITING()
!
DEALLOCATE(LON)
DEALLOCATE(LAT)
DEALLOCATE(CORLON)
DEALLOCATE(CORLAT)
DEALLOCATE(AREA)
DEALLOCATE(MASK)
!
ENDIF
!
!/MPI CALL MPI_BCAST(NNODES,1,MPI_INTEGER,0,ID_LCOMM,IERR_MPI)
!
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_GRID
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | V. Garnier |
!/ | M. Accensi |
!/ | FORTRAN 90 |
!/ | Last update : 08-Jun-2018 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add coupling for unstructured grids ( version 5.07 )
!/ (R. Baraille & J. Pianezze)
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/ 08-Jun-2018 : use INIT_GET_ISEA ( version 6.04 )
!/
! 1. Purpose :
!
! Partition definition and coupling fields declaration
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDSO Int. I Id. of the output file
! RCV_STR Char. I Name of receive fields
! SND_STR Char. I Name of send fields
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! GET_LIST_EXCH_FIELD Subr. W3OACPMD List of the exchanged fields
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! WW3_SHEL Prog. - Main program
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!
USE W3GDATMD, ONLY: NSEAL,NSEA, NX, NY, MAPSTA, MAPSF, GTYPE, &
& UNGTYPE, RLGTYPE, CLGTYPE
USE W3ODATMD, ONLY: NAPROC, IAPROC
USE W3PARALL, ONLY : INIT_GET_ISEA
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: NDSO
CHARACTER(LEN=1024), INTENT(IN) :: RCV_STR,SND_STR
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IB_I,I
INTEGER :: IL_PART_ID ! PartitionID
INTEGER, ALLOCATABLE, DIMENSION(:) :: ILA_PARAL ! Description of the local partition in the global index space
INTEGER, DIMENSION(4) :: ILA_SHAPE ! Vector giving the min & max index for each dim of the fields
INTEGER, DIMENSION(2) :: ILA_VAR_NODIMS ! rank of fields & number of bundles (1 with OASIS3-MCT)
INTEGER :: ISEA, JSEA, IX, IY
INTEGER :: NHXW, NHXE, NHYS, NHYN ! size of the halo at the western, eastern, southern, northern boundaries
LOGICAL :: LL_MPI_FILE ! to check if there an mpi.txt file for domain decompasition
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
IF (GTYPE .EQ. RLGTYPE .OR. GTYPE .EQ. CLGTYPE) THEN
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NHXW = 1 ; NHXE = NX ; NHYS = 1 ; NHYN = NY
NHXW = NHXW - 1
NHXE = NX - NHXE
NHYS = NHYS - 1
NHYN = NY - NHYN
!
ALLOCATE(ILA_PARAL(2+NSEAL*2))
!
! * Define the partition : OASIS ORANGE partition
ILA_PARAL(1) = 3
!
! * total number of segments of the global domain
ILA_PARAL(2) = NSEAL
!
DO JSEA=1, NSEAL
CALL INIT_GET_ISEA(ISEA,JSEA)
IX = MAPSF(ISEA,1)
IY = MAPSF(ISEA,2)
ILA_PARAL(JSEA*2+1) = (IY - NHYN -1)*(NX - NHXE - NHXW) + (IX - NHXW - 1)
ILA_PARAL(JSEA*2+2) = 1
END DO
!
ELSE
!
! 1.2. Unstructured grids
! ----------------------------------
WRITE(*,*) 'TO BE VERIFY FOR UNSTRUCTURED GRIDS'
STOP
!
DO JSEA=1,NSEAL
ILA_PARAL(JSEA*2+1) = (IAPROC-1) + (JSEA-1)*NAPROC
ILA_PARAL(JSEA*2+2) = 1
END DO
!
ENDIF
!
! 2. Partition definition
! ----------------------------------
CALL OASIS_DEF_PARTITION(IL_PART_ID, ILA_PARAL,IL_ERR,NNODES)
IF(IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_partition')
ENDIF
!
! 3. Coupling fields declaration
! ----------------------------------
ILA_SHAPE(:) = (/1, NSEAL, 1, 1 /)
!
ILA_VAR_NODIMS(1) = 2 ! rank of fields array
ILA_VAR_NODIMS(2) = 1 ! always 1 with OASIS3-MCT 2.0
!
CALL GET_LIST_EXCH_FIELD(NDSO, RCV_FLD, SND_FLD, IL_NB_RCV, IL_NB_SND, RCV_STR, SND_STR)
!
! 3.1 Send coupling fields
! ----------------------------------
DO IB_I = 1, IL_NB_SND
CALL OASIS_DEF_VAR (SND_FLD(IB_I)%IL_FIELD_ID &
& , SND_FLD(IB_I)%CL_FIELD_NAME &
& , IL_PART_ID &
& , ILA_VAR_NODIMS &
& , OASIS_OUT &
& , ILA_SHAPE &
& , OASIS_REAL &
& , IL_ERR )
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_var')
ENDIF
ENDDO
!
! 3.2 Received coupling fields
! ----------------------------------
DO IB_I = 1, IL_NB_RCV
CALL OASIS_DEF_VAR (RCV_FLD(IB_I)%IL_FIELD_ID &
& , RCV_FLD(IB_I)%CL_FIELD_NAME &
& , IL_PART_ID &
& , ILA_VAR_NODIMS &
& , OASIS_IN &
& , ILA_SHAPE &
& , OASIS_REAL &
& , IL_ERR )
!
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_var')
ENDIF
ENDDO
!
! 4. End of definition phase
! ----------------------------------
CALL OASIS_ENDDEF(IL_ERR)
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_enddef')
ENDIF
!
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_DEFINE
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_SND(ID_NB, ID_TIME, RDA_FIELD, LD_ACTION)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
! 1. Purpose :
!
! In the model time step loop, each process sends its parts of the coupling field
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ID_NB Int. I Number of the field to be send
! ID_TIME Int. I Atmosphere time-step in seconds
! RDA_FIELD Real I Coupling field array to be send
! LD_ACTION Bool. O Action performed
! ----------------------------------------------------------------
!
! 4. Subroutines used :
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! SND_FIELDS_TO_ATMOS Subr. W3AGCMMD Send fields to atmos. model
! SND_FIELDS_TO_OCEAN Subr. W3OGCMMD Send fields to ocean model
! SND_FIELDS_TO_ICE Subr. W3IGCMMD Send fields to ice model
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: ID_NB ! Number of the field to be send
INTEGER, INTENT(IN) :: ID_TIME ! Atmosphere time-step in seconds
REAL(KIND=8), DIMENSION(:,:), INTENT(IN) :: RDA_FIELD ! Coupling field array to be send
LOGICAL, INTENT(OUT) :: LD_ACTION ! Action performed
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IL_INFO ! OASIS3-MCT info argument
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
CALL OASIS_PUT ( SND_FLD(ID_NB)%IL_FIELD_ID &
& , ID_TIME &
& , RDA_FIELD &
& , IL_INFO &
& )
LD_ACTION = IL_INFO == OASIS_SENT .OR. IL_INFO == OASIS_TOREST .OR. &
& IL_INFO == OASIS_SENTOUT .OR. IL_INFO == OASIS_TORESTOUT
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_SND
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_RCV(ID_NB, ID_TIME, RDA_FIELD, LD_ACTION)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
! 1. Purpose :
!
! In the model time step loop, each process receives its parts of the coupling field
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! ID_NB Int. I Number of the field to be received
! ID_TIME Int. I Ocean time-step in seconds
! RDA_FIELD Real I Coupling field array to be received
! LD_ACTION Bool. O Action performed
! ----------------------------------------------------------------
!
! 4. Subroutines used :
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! RCV_FIELDS_FROM_ATMOS Subr. W3AGCMMD Receive fields from atmos. model
! RCV_FIELDS_FROM_OCEAN Subr. W3OGCMMD Receive fields from ocean model
! RCV_FIELDS_FROM_ICE Subr. W3IGCMMD Receive fields from ice model
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
INTEGER, INTENT(IN) :: ID_NB ! Number of the field to be received
INTEGER, INTENT(IN) :: ID_TIME ! Ocean time-step in seconds
REAL(KIND=8), DIMENSION(:,:), INTENT(OUT) :: RDA_FIELD ! Coupling field array to be received
LOGICAL, INTENT(OUT) :: LD_ACTION ! Action performed
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IL_INFO ! OASIS3-MCT info argument
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
CALL OASIS_GET ( RCV_fld(ID_NB)%IL_FIELD_ID &
& , ID_TIME &
& , RDA_FIELD &
& , IL_INFO &
& )
!
LD_ACTION = IL_INFO == OASIS_RECVD .OR. IL_INFO == OASIS_FROMREST .OR. &
& IL_INFO == OASIS_RECVOUT .OR. IL_INFO == OASIS_FROMRESTOUT
!
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_RCV
!/ ------------------------------------------------------------------- /
SUBROUTINE CPL_OASIS_FINALIZE
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
! 1. Purpose :
!
! Terminate the coupling
!
! 2. Method :
! 3. Parameters :
! 4. Subroutines used :
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! WW3_SHEL Prog. - Main program
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
CALL OASIS_TERMINATE(IL_ERR)
!
IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_FINALIZE', 'Problem during oasis_terminate')
ENDIF
!
!/ ------------------------------------------------------------------- /
END SUBROUTINE CPL_OASIS_FINALIZE
!/ ------------------------------------------------------------------- /
SUBROUTINE GET_LIST_EXCH_FIELD(NDSO, RCV, SND, ID_NB_RCV, ID_NB_SND, RCV_STR, SND_STR)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | A. Thevenin |
!/ | V. Garnier |
!/ | A.C. Bennis |
!/ | FORTRAN 90 |
!/ | Last update : April-2016 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ Mar-2014 : J. Pianezze (LPO) : Add atmospheric fields ( version 5.07 )
!/ Apr-2015 : M. Accensi (LPO) : Add fields selection ( version 5.07 )
!/ Apr-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/
! 1. Purpose :
!
! Provides the list of coupling fields
!
! 2. Method :
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
! NDSO Int. I Id. of the output file
! RCV Type I/O Received variables
! SND Type I/O Send variables
! ID_NB_RCV Int. I/O Number of received variables
! ID_NB_SND Int. I/O Number of send variables
! RCV_STR Char. I Name of the received variables
! SND_STR Char I Name of the send variables
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!
! Name Type Module Description
! ----------------------------------------------------------------
! STRSPLIT Subr. W3SERVMD Splits string into words
! ----------------------------------------------------------------
!
! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! CPL_OASIS_DEFINE Subr. W3OACPMD Partition definition
! ----------------------------------------------------------------
!
! 6. Error messages :
! 7. Remarks :
! 8. Structure :
! 9. Switches :
! 10. Source code :
!
!/ ------------------------------------------------------------------- /
!
USE W3SERVMD, ONLY: STRSPLIT
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
TYPE(CPL_FIELD), DIMENSION(IP_MAXFLD), INTENT (INOUT) :: RCV, SND
INTEGER, INTENT(INOUT) :: ID_NB_RCV, ID_NB_SND
INTEGER, INTENT(IN) :: NDSO
CHARACTER(LEN=1024), INTENT(IN) :: RCV_STR, SND_STR
!/
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
CHARACTER(LEN=100) :: OUT_NAMES(50), TESTSTR
INTEGER :: IOUT
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
!
! 1. Coupling fields received by WW3
! ----------------------------------
ID_NB_RCV = 0
!
OUT_NAMES(:)=''
CALL STRSPLIT(RCV_STR,OUT_NAMES)
IOUT=0
DO WHILE (LEN_TRIM(OUT_NAMES(IOUT+1)).NE.0)
TESTSTR=OUT_NAMES(IOUT+1)
SELECT CASE(TRIM(TESTSTR(1:6)))
!
!
! OCEAM MODEL VARIABLES
!
!/OASOCM CASE('DRY')
!/OASOCM ! wet-drying at the middle of the cell
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDH'
!
!/OASOCM ! wet-drying at u-location
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDU'
!
!/OASOCM ! wet-drying at v-location
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDV'
!
!/OASOCM CASE('SSH')
!/OASOCM ! ssh : sea surface height (m)
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__SSH'
!
!/OASOCM CASE('CUR')
!/OASOCM ! uz : sea surface zonal currents (m.s-1)
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OSSU'
!
!/OASOCM ! vz : sea surface meridional currents (m.s-1)
!/OASOCM ID_NB_RCV=ID_NB_RCV+1
!/OASOCM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OSSV'
!
!
! ATMOSPHERE MODEL VARIABLES
!
!/OASACM CASE('WND')
!/OASACM ! U10 : 10m u-wind speed (m.s-1)
!/OASACM ID_NB_RCV=ID_NB_RCV+1
!/OASACM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__U10'
!
!/OASACM ! V10 : 10m v-wind speed (m.s-1)
!/OASACM ID_NB_RCV=ID_NB_RCV+1
!/OASACM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__V10'
!
!
! ICE MODEL VARIABLES
!
!/OASICM CASE('IC1')
!/OASICM ! IC1 : ice thickness (m)
!/OASICM ID_NB_RCV=ID_NB_RCV+1
!/OASICM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__IC1'
!
!/OASICM CASE('IC5')
!/OASICM ! ICEF : ice floe diameters (m)
!/OASICM ID_NB_RCV=ID_NB_RCV+1
!/OASICM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__IC5'
!
!/OASICM CASE('ICE')
!/OASICM ! ICE : ice concentration (n.d)
!/OASICM ID_NB_RCV=ID_NB_RCV+1
!/OASICM RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3__ICE'
!
CASE DEFAULT
WRITE (NDSO,1001) TRIM(TESTSTR(1:6))
END SELECT
IOUT=IOUT+1
END DO
!
! 2. Coupling fields sent by WW3
! ----------------------------------
ID_NB_SND = 0
!
OUT_NAMES(:)=''
CALL STRSPLIT(SND_STR,OUT_NAMES)
IOUT=0
DO WHILE (LEN_TRIM(OUT_NAMES(IOUT+1)).NE.0)
TESTSTR=OUT_NAMES(IOUT+1)
SELECT CASE(TRIM(TESTSTR(1:6)))
!
!
! OCEAM MODEL VARIABLES
!
!/OASOCM CASE('OHS')
!/OASOCM ! Significant wave height (m)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__OHS'
!
!/OASOCM CASE('DRY')
!/OASOCM ! mask to manage wet-drying
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_ODRY'
!
!/OASOCM CASE('T0M1')
!/OASOCM ! T0M1 / wave_t0m1 : mean period (s)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_T0M1'
!
!/OASOCM CASE('DIR')
!/OASOCM ! THM / wave_thm : cosinus of mean direction (n/a)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_CDIR'
!
!/OASOCM ! THM / wave_thm : sinus of mean direction (n/a)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_SDIR'
!
!/OASOCM CASE('BHD')
!/OASOCM ! BHD / wave_bhd : wave-induced Bernoulli head pressure (bhd in N.m-1)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__BHD'
!
!/OASOCM CASE('TWO')
!/OASOCM ! tauox / wave_tauox : x-component of the wave-ocean momentum flux (tauox in m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TWOX'
!
!/OASOCM ! tauoy / wave_tauoy : y-component of the wave-ocean momentum flux (tauox in m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TWOY'
!
!/OASOCM CASE('FOC')
!/OASOCM ! phioc / wave_phioc : Wave-to-ocean TKE flux (phioc in W.m-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__FOC'
!
!/OASOCM CASE('TBB')
!/OASOCM ! Momentum flux due to bottom friction, u component (m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TBBX'
!
!/OASOCM ! Momentum flux due to bottom friction, v component (m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TBBY'
!
!/OASOCM CASE('FBB')
!/OASOCM ! phibbl / wave_phibbl : Energy flux due to bottom friction (phioc in W.m-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__FBB'
!
!/OASOCM CASE('UBR')
!/OASOCM ! uba / wave_ubrx : x component of the rms amplitude of orbital velocity of the waves (m/s)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_UBRX'
!
!/OASOCM ! uba / wave_ubry : y component of the rms amplitude of orbital velocity of the waves (m/s)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_UBRY'
!
!/OASOCM CASE('TAW')
!/OASOCM ! tauwix / wave_tauwix : Net wave-supported stress, u component (tauwix in m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TAWX'
!
!/OASOCM ! tauwiy / wave_tauwiy : ! Net wave-supported stress, v component (tauwix in m2.s-2)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TAWY'
!
!/OASOCM CASE('LM')
!/OASOCM ! wlm / wave_wlm : mean length wave (m)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3___LM'
!
!/OASOCM CASE('TUS')
!/OASOCM ! Volume transport associated to Stokes drift, u component (m2.s-1)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TUSX'
!
!/OASOCM ! Volume transport associated to Stokes drift, v component (m2.s-1)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_TUSY'
!
!/OASOCM CASE('USS')
!/OASOCM ! Surface Stokes drift, u component (m.s-1)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_USSX'
!
!/OASOCM ! Surface Stokes drift, v component (m.s-1)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_USSY'
!
!/OASOCM CASE('OCHA')
!/OASOCM ! Charnock Coefficient (-)
!/OASOCM ID_NB_SND = ID_NB_SND +1
!/OASOCM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_OCHA'
!
! ATMOSPHERE MODEL VARIABLES
!
!/OASACM CASE('AHS')
!/OASACM ! Significant wave height (m)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__AHS'
!
!/OASACM CASE('CUR')
!/OASACM ! Ocean sea surface current (m.s-1)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_WSSU'
!
!/OASACM ! Ocean sea surface current (m.s-1)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_WSSV'
!
!/OASACM CASE('ACHA')
!/OASACM ! Charnock Coefficient (-)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_ACHA'
!
!/OASACM CASE('FP')
!/OASACM ! Peak frequency (s-1)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3___FP'
!
!/OASACM CASE('TP')
!/OASACM ! Peak period (s)
!/OASACM ID_NB_SND = ID_NB_SND +1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3___TP'
!
!/OASACM CASE('FWS')
!/OASACM ! Wind_sea_mean_period_T0M1 (s)
!/OASACM ID_NB_SND=ID_NB_SND+1
!/OASACM SND(ID_NB_SND)%CL_FIELD_NAME='WW3__FWS'
!
!
! ICE MODEL VARIABLES
!
!/OASICM CASE('IC5')
!/OASICM ! Ice floe diameters (m)
!/OASICM ID_NB_SND = ID_NB_SND +1
!/OASICM SND(ID_NB_SND)%CL_FIELD_NAME='WW3_ICEF'
!
!/OASICM CASE('TWI')