-
Notifications
You must be signed in to change notification settings - Fork 237
/
coupler.F
88 lines (69 loc) · 2.41 KB
/
coupler.F
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
CBOP 0
C !ROUTINE: COUPLER
C !INTERFACE:
PROGRAM COUPLER
C !DESCRIPTION:
C *==========================================================*
C | PROGRAM COUPLER
C | o Main routine for 'Coupler' component. 'Coupler'
C | component coordiantes the exchange of data between
C | component models in a coupled model experiment.
C *==========================================================*
C | This version uses the MIT Coupler "checkpoint1" library
C | calls.
C *==========================================================*
C !USES:
IMPLICIT NONE
C == Global variables ==
#include "mpif.h"
#include "CPL_PARAMS.h"
C !LOCAL VARIABLES:
C I :: Loop counter
C rc :: MPI return code
C msgUnit :: log-file I/O unit
INTEGER I
INTEGER rc
INTEGER msgUnit
CEOP
C Initialise the coupler component
CALL INITIALISE(
O msgUnit )
C Perform registration with other components
CALL ACCEPT_COMPONENT_REGISTRATIONS
C Send Coupler-params to both components
CALL CPL_SEND_ATM_CPLPARMS( msgUnit )
CALL CPL_SEND_OCN_CPLPARMS( msgUnit )
C Coordinate the transfer configuration information between components
CALL EXCH_COMPONENT_CONFIGS( msgUnit )
DO I=1,nCouplingSteps
IF ( cpl_sequential.EQ.1 ) THEN
C- Sequential coupling
C Receive ATM updated state
CALL CPL_RECV_ATM_FIELDS( msgUnit, I )
C Send out ATM fields to OCN
CALL CPL_SEND_OCN_FIELDS( msgUnit, I )
C Receive OCN updated state
CALL CPL_RECV_OCN_FIELDS( msgUnit, I )
C Send out OCN fields to ATM
CALL CPL_SEND_ATM_FIELDS( msgUnit, I )
ELSE
C- Synchronous coupling
C Receive updated state
CALL CPL_RECV_OCN_FIELDS( msgUnit, I )
CALL CPL_RECV_ATM_FIELDS( msgUnit, I )
C Send out fields
CALL CPL_SEND_ATM_FIELDS( msgUnit, I )
CALL CPL_SEND_OCN_FIELDS( msgUnit, I )
ENDIF
ENDDO
C o Finalize MPI
C First wait for everybody to finish. Nobody should call
C MPI_Finalize before all the component modules are
C ready to finish. On some systems once one participant
C gets to MPI_Finalize then its unclear what will
C happen after that. If everybody does on MPI_Barrier
C on COMM_WORLD then we will be OK.
CALL MPI_BARRIER( MPI_COMM_WORLD, rc )
CALL MPI_FINALIZE(rc)
STOP
END