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