source: LMDZ6/trunk/libf/phylmd/create_etat0_limit_unstruct.F90 @ 3470

Last change on this file since 3470 was 3470, checked in by yann meurdesoif, 6 years ago

Clean finalize for etat0_limit creation with dynamico. Avoid dead-lock with xios_server that are waiting for an mpi_finalize.

YM

File size: 3.4 KB
Line 
1MODULE etat0_limit_unstruct_mod
2
3  LOGICAL, SAVE  :: create_etat0_limit
4!$OMP THREADPRIVATE(create_etat0_limit)
5
6
7
8
9CONTAINS
10 
11  SUBROUTINE init_etat0_limit_unstruct
12#ifdef CPP_XIOS
13  USE xios
14  USE mod_phys_lmdz_para
15  USE mod_grid_phy_lmdz
16  USE ioipsl, ONLY : getin, ioget_year_len
17  USE time_phylmdz_mod, ONLY : annee_ref
18  USE create_etat0_unstruct_mod
19  IMPLICIT NONE
20 
21    INTEGER :: iflag_phys,i
22    INTEGER :: ndays
23    REAL,ALLOCATABLE :: value(:)
24   
25      IF (grid_type==unstructured) THEN
26        IF (is_master) CALL getin("iflag_phys",iflag_phys)
27        CALL bcast(iflag_phys)
28       
29        IF (is_master) CALL getin('create_etat0_limit',create_etat0_limit)
30        CALL bcast(create_etat0_limit)
31       
32        ndays=ioget_year_len(annee_ref)
33        ALLOCATE(value(ndays))
34        DO i=1,ndays
35          value(i)=i-1
36        ENDDO
37       
38        IF (is_omp_master) CALL xios_set_axis_attr("time_year",n_glo=ndays,value=value)
39       
40        IF (create_etat0_limit) THEN
41          IF (iflag_phys<100) THEN
42            IF (is_omp_master) CALL xios_set_fieldgroup_attr("etat0_limit_read",read_access=.TRUE.,enabled=.TRUE.)
43            IF (is_omp_master) CALL xios_set_filegroup_attr("etat0_limit_read",enabled=.TRUE.)
44          ENDIF
45          IF (is_omp_master) CALL xios_set_file_attr("limit_write",enabled=.TRUE.)
46          CALL init_create_etat0_unstruct
47        ENDIF
48     
49      ENDIF 
50
51#endif
52  END SUBROUTINE init_etat0_limit_unstruct
53 
54  SUBROUTINE create_etat0_limit_unstruct
55#ifdef CPP_XIOS
56  USE mod_grid_phy_lmdz
57  USE create_etat0_unstruct_mod
58  USE create_limit_unstruct_mod
59  USE phyaqua_mod
60  USE mod_phys_lmdz_para
61  USE ioipsl, ONLY : getin
62  USE dimphy
63  USE xios
64  USE print_control_mod, ONLY: lunout
65  IMPLICIT NONE
66      INTEGER :: iflag_phys
67      INTEGER :: ierr
68      IF (grid_type==unstructured) THEN
69 
70        IF (is_master) CALL getin("iflag_phys",iflag_phys)
71        CALL bcast(iflag_phys)
72
73        IF (iflag_phys<100) THEN
74          IF ( create_etat0_limit) THEN
75              CALL create_etat0_unstruct
76              CALL create_limit_unstruct
77              IF (is_omp_master)  THEN
78                CALL xios_context_finalize()
79                CALL xios_set_current_context("icosagcm")   ! very bad, need to find an other solution
80                CALL xios_context_finalize()
81                CALL xios_finalize()
82#ifdef CPP_MPI   
83                CALL MPI_Finalize(ierr)
84#endif
85                WRITE(lunout,*)   'create_etat0_limit_unstruct, Initial state file are created, all is fine'
86                STOP 0
87              ENDIF
88!$OMP BARRIER
89              STOP 'create_etat0_limit_unstruct, Initial state file are created, all is fine'
90          ENDIF
91        ELSE
92          IF (create_etat0_limit) THEN
93            CALL iniaqua(klon,iflag_phys)
94              IF (is_omp_master)  THEN
95                CALL xios_context_finalize()
96                CALL xios_set_current_context("icosagcm")   ! very bad, need to find an other solution
97                CALL xios_context_finalize()
98                CALL xios_finalize()
99#ifdef CPP_MPI
100                CALL MPI_Finalize(ierr)
101#endif
102              ENDIF
103!$OMP BARRIER
104              WRITE(lunout,*)   'create_etat0_limit_unstruct, Initial state file are created, all is fine'
105              STOP 0
106          ENDIF
107        ENDIF
108      ENDIF
109       
110#endif
111  END SUBROUTINE create_etat0_limit_unstruct
112 
113END MODULE etat0_limit_unstruct_mod
114
Note: See TracBrowser for help on using the repository browser.