My Project
 All Classes Files Functions Variables Macros
mod_const_mpi.F90
Go to the documentation of this file.
1 !
2 ! $Id: mod_const_mpi.F90 1700 2012-12-20 14:43:19Z lguez $
3 !
4 MODULE mod_const_mpi
5 
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
15 #else
16 ! if not using IOIPSL, we still need to use (a local version of) getin
17  USE ioipsl_getincom
18 #endif
19 
20  IMPLICIT NONE
21 #ifdef CPP_MPI
22  include 'mpif.h'
23 #endif
24  INTEGER :: ierr
25  INTEGER :: comp_id
26  INTEGER :: thread_required
27  INTEGER :: thread_provided
28  CHARACTER(len = 6) :: type_ocean
29 
30 !$OMP MASTER
31  type_ocean = 'force '
32  CALL getin('type_ocean', type_ocean)
33 !$OMP END MASTER
34 !$OMP BARRIER
35 
36  IF (type_ocean=='couple') THEN
37 #ifdef CPP_COUPLE
38 !$OMP MASTER
39  CALL prism_init_comp_proto(comp_id, 'lmdz.x', ierr)
40  CALL prism_get_localcomm_proto(comm_lmdz,ierr)
41 !$OMP END MASTER
42 #endif
43 #ifdef CPP_MPI
44  mpi_real_lmdz=mpi_real8
45 #endif
46  ELSE
47  CALL init_mpi
48  ENDIF
49 
50  END SUBROUTINE init_const_mpi
51 
52  SUBROUTINE init_mpi
53  IMPLICIT NONE
54 #ifdef CPP_MPI
55  include 'mpif.h'
56 #endif
57  INTEGER :: ierr
58  INTEGER :: thread_required
59  INTEGER :: thread_provided
60 
61 #ifdef CPP_MPI
62 !$OMP MASTER
63  thread_required=mpi_thread_serialized
64 
65  CALL mpi_init_thread(thread_required,thread_provided,ierr)
66  IF (thread_provided < thread_required) THEN
67  print *,'Warning : The multithreaded level of MPI librairy do not provide the requiered level', &
68  ' in mod_const_mpi::Init_const_mpi'
69  ENDIF
70  comm_lmdz=mpi_comm_world
71  mpi_real_lmdz=mpi_real8
72 !$OMP END MASTER
73 #endif
74 
75  END SUBROUTINE init_mpi
76 
77 END MODULE mod_const_mpi