1 |
C $Header: /u/gcmpack/MITgcm/pkg/atm_ocn_coupler/coupler.F,v 1.6 2015/11/12 20:03:35 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
CBOP 0 |
5 |
C !ROUTINE: COUPLER |
6 |
|
7 |
C !INTERFACE: |
8 |
PROGRAM COUPLER |
9 |
|
10 |
C !DESCRIPTION: |
11 |
C *==========================================================* |
12 |
C | PROGRAM COUPLER |
13 |
C | o Main routine for 'Coupler' component. 'Coupler' |
14 |
C | component coordiantes the exchange of data between |
15 |
C | component models in a coupled model experiment. |
16 |
C *==========================================================* |
17 |
C | This version uses the MIT Coupler "checkpoint1" library |
18 |
C | calls. |
19 |
C *==========================================================* |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
C == Global variables == |
24 |
#include "mpif.h" |
25 |
#include "CPL_PARAMS.h" |
26 |
|
27 |
C !LOCAL VARIABLES: |
28 |
C I :: Loop counter |
29 |
C rc :: MPI return code |
30 |
C msgUnit :: log-file I/O unit |
31 |
INTEGER I |
32 |
INTEGER rc |
33 |
INTEGER msgUnit |
34 |
CEOP |
35 |
|
36 |
C Initialise the coupler component |
37 |
CALL INITIALISE( |
38 |
O msgUnit ) |
39 |
|
40 |
C Perform registration with other components |
41 |
CALL ACCEPT_COMPONENT_REGISTRATIONS |
42 |
|
43 |
C Send Coupler-params to both components |
44 |
CALL CPL_SEND_ATM_CPLPARMS( msgUnit ) |
45 |
CALL CPL_SEND_OCN_CPLPARMS( msgUnit ) |
46 |
|
47 |
C Coordinate the transfer configuration information between components |
48 |
CALL EXCH_COMPONENT_CONFIGS( msgUnit ) |
49 |
|
50 |
DO I=1,nCouplingSteps |
51 |
|
52 |
IF ( cpl_sequential.EQ.1 ) THEN |
53 |
C- Sequential coupling |
54 |
|
55 |
C Receive ATM updated state |
56 |
CALL CPL_RECV_ATM_FIELDS( msgUnit, I ) |
57 |
C Send out ATM fields to OCN |
58 |
CALL CPL_SEND_OCN_FIELDS( msgUnit, I ) |
59 |
|
60 |
C Receive OCN updated state |
61 |
CALL CPL_RECV_OCN_FIELDS( msgUnit, I ) |
62 |
C Send out OCN fields to ATM |
63 |
CALL CPL_SEND_ATM_FIELDS( msgUnit, I ) |
64 |
|
65 |
ELSE |
66 |
C- Synchronous coupling |
67 |
|
68 |
C Receive updated state |
69 |
CALL CPL_RECV_OCN_FIELDS( msgUnit, I ) |
70 |
CALL CPL_RECV_ATM_FIELDS( msgUnit, I ) |
71 |
|
72 |
C Send out fields |
73 |
CALL CPL_SEND_ATM_FIELDS( msgUnit, I ) |
74 |
CALL CPL_SEND_OCN_FIELDS( msgUnit, I ) |
75 |
|
76 |
ENDIF |
77 |
|
78 |
ENDDO |
79 |
|
80 |
C o Finalize MPI |
81 |
C First wait for everybody to finish. Nobody should call |
82 |
C MPI_Finalize before all the component modules are |
83 |
C ready to finish. On some systems once one participant |
84 |
C gets to MPI_Finalize then its unclear what will |
85 |
C happen after that. If everybody does on MPI_Barrier |
86 |
C on COMM_WORLD then we will be OK. |
87 |
CALL MPI_BARRIER( MPI_COMM_WORLD, rc ) |
88 |
CALL MPI_FINALIZE(rc) |
89 |
|
90 |
STOP |
91 |
END |