1 | ! |
---|
2 | ! $Id: mod_const_mpi.F90 1965 2014-02-11 10:42:52Z emillour $ |
---|
3 | ! |
---|
4 | MODULE mod_const_mpi |
---|
5 | IMPLICIT NONE |
---|
6 | INTEGER,SAVE :: COMM_LMDZ |
---|
7 | INTEGER,SAVE :: MPI_REAL_LMDZ |
---|
8 | |
---|
9 | |
---|
10 | CONTAINS |
---|
11 | |
---|
12 | SUBROUTINE Init_const_mpi |
---|
13 | #ifdef CPP_IOIPSL |
---|
14 | USE IOIPSL, ONLY: getin |
---|
15 | #else |
---|
16 | ! if not using IOIPSL, we still need to use (a local version of) getin |
---|
17 | USE ioipsl_getincom, only: getin |
---|
18 | #endif |
---|
19 | ! Use of Oasis-MCT coupler |
---|
20 | #ifdef CPP_OMCT |
---|
21 | USE mod_prism |
---|
22 | #endif |
---|
23 | IMPLICIT NONE |
---|
24 | #ifdef CPP_MPI |
---|
25 | INCLUDE 'mpif.h' |
---|
26 | #endif |
---|
27 | |
---|
28 | INTEGER :: ierr |
---|
29 | INTEGER :: comp_id |
---|
30 | INTEGER :: thread_required |
---|
31 | INTEGER :: thread_provided |
---|
32 | CHARACTER(len = 6) :: type_ocean |
---|
33 | |
---|
34 | !$OMP MASTER |
---|
35 | type_ocean = 'force ' |
---|
36 | CALL getin('type_ocean', type_ocean) |
---|
37 | !$OMP END MASTER |
---|
38 | !$OMP BARRIER |
---|
39 | |
---|
40 | IF (type_ocean=='couple') THEN |
---|
41 | #ifdef CPP_COUPLE |
---|
42 | !$OMP MASTER |
---|
43 | CALL prism_init_comp_proto (comp_id, 'lmdz.x', ierr) |
---|
44 | CALL prism_get_localcomm_proto(COMM_LMDZ,ierr) |
---|
45 | !$OMP END MASTER |
---|
46 | #endif |
---|
47 | #ifdef CPP_MPI |
---|
48 | MPI_REAL_LMDZ=MPI_REAL8 |
---|
49 | #endif |
---|
50 | ELSE |
---|
51 | CALL init_mpi |
---|
52 | ENDIF |
---|
53 | |
---|
54 | END SUBROUTINE Init_const_mpi |
---|
55 | |
---|
56 | SUBROUTINE Init_mpi |
---|
57 | #ifdef CPP_XIOS |
---|
58 | USE wxios, only: wxios_init |
---|
59 | #endif |
---|
60 | IMPLICIT NONE |
---|
61 | #ifdef CPP_MPI |
---|
62 | INCLUDE 'mpif.h' |
---|
63 | #endif |
---|
64 | INTEGER :: ierr |
---|
65 | INTEGER :: thread_required |
---|
66 | INTEGER :: thread_provided |
---|
67 | |
---|
68 | #ifdef CPP_MPI |
---|
69 | !$OMP MASTER |
---|
70 | thread_required=MPI_THREAD_SERIALIZED |
---|
71 | |
---|
72 | CALL MPI_INIT_THREAD(thread_required,thread_provided,ierr) |
---|
73 | IF (thread_provided < thread_required) THEN |
---|
74 | PRINT *,'Warning : The multithreaded level of MPI librairy do not provide the requiered level', & |
---|
75 | ' in mod_const_mpi::Init_const_mpi' |
---|
76 | ENDIF |
---|
77 | COMM_LMDZ=MPI_COMM_WORLD |
---|
78 | MPI_REAL_LMDZ=MPI_REAL8 |
---|
79 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
80 | ! Initialisation de XIOS |
---|
81 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
82 | #ifdef CPP_XIOS |
---|
83 | CALL wxios_init("LMDZ", outcom=COMM_LMDZ) |
---|
84 | #endif |
---|
85 | !$OMP END MASTER |
---|
86 | #else |
---|
87 | #ifdef CPP_XIOS |
---|
88 | !$OMP MASTER |
---|
89 | CALL wxios_init("LMDZ") |
---|
90 | !$OMP END MASTER |
---|
91 | #endif |
---|
92 | #endif |
---|
93 | |
---|
94 | END SUBROUTINE Init_mpi |
---|
95 | |
---|
96 | END MODULE mod_const_mpi |
---|