Commit 34cf5823 authored by ymeur's avatar ymeur
Browse files

Fix bug introduced in the last commit. Global indexes for output was depending...

Fix bug introduced in the last commit. Global indexes for output was depending of the configuration (nb proc), ie a restart could not be read correctly for a new start if number of process was changing.
YM
parent c15834a7
Pipeline #152945 failed with stages
in 2 minutes and 35 seconds
......@@ -125,11 +125,15 @@ CONTAINS
cell_glo_tot(:)= -1
CALL MPI_ALLGATHERV(ind_glo, ncell, MPI_INTEGER, ind_glo_tot, ncell_mpi, displ, MPI_INTEGER, comm_icosa,ierr)
ncell_glo=0
DO i=1,ncell_tot
IF (cell_glo_tot(ind_glo_tot(i))==-1) THEN
cell_glo_tot(ind_glo_tot(i))=ncell_glo
ncell_glo=ncell_glo+1
cell_glo_tot(ind_glo_tot(i))= 0
ENDDO
ncell_glo=0
DO i=0,ncell_glo_tot-1
IF (cell_glo_tot(i)/=-1) THEN
cell_glo_tot(i) = ncell_glo
ncell_glo=ncell_glo + 1
ENDIF
ENDDO
......@@ -208,11 +212,15 @@ CONTAINS
cell_glo_tot(:)= -1
CALL MPI_ALLGATHERV(ind_glo, ncell, MPI_INTEGER, ind_glo_tot, ncell_mpi, displ, MPI_INTEGER, comm_icosa,ierr)
ncell_glo=0
DO i=1,ncell_tot
IF (cell_glo_tot(ind_glo_tot(i))==-1) THEN
cell_glo_tot(ind_glo_tot(i))=ncell_glo
ncell_glo=ncell_glo+1
cell_glo_tot(ind_glo_tot(i))= 0
ENDDO
ncell_glo=0
DO i=0,ncell_glo_tot*6-1
IF (cell_glo_tot(i)/=-1) THEN
cell_glo_tot(i) = ncell_glo
ncell_glo=ncell_glo + 1
ENDIF
ENDDO
......@@ -346,16 +354,18 @@ CONTAINS
USE geometry
USE mpi_mod
USE time_mod
USE metric, ONLY : vup,vdown, cell_glo
USE metric, ONLY : vup,vdown, cell_glo, ncell_glo_tot=>ncell_glo
USE icosa,ONLY : getin
IMPLICIT NONE
TYPE(xios_context) :: ctx_hdl
TYPE(xios_duration) :: dtime
INTEGER :: ncell, ncell_tot, ncell_glo(0:mpi_size-1), displ
INTEGER :: ncell, ncell_tot, ncell_mpi(0:mpi_size-1), displ(0:mpi_size-1), ncell_glo
INTEGER :: ind, i,j,k,l,ij
REAL(rstd),ALLOCATABLE :: lon(:), lat(:), bounds_lon(:,:), bounds_lat(:,:)
INTEGER, ALLOCATABLE :: ind_glo(:)
TYPE(t_domain),POINTER :: d
INTEGER,ALLOCATABLE :: cell_glo_tot(:)
INTEGER,ALLOCATABLE :: ind_glo_tot(:)
CHARACTER(len=255) :: etat0_type
LOGICAL :: read_metric_
......@@ -375,14 +385,14 @@ CONTAINS
ENDDO
ncell_i=ncell
CALL MPI_ALLGATHER(ncell,1,MPI_INTEGER,ncell_glo,1,MPI_INTEGER,comm_icosa,ierr)
CALL MPI_ALLGATHER(ncell,1,MPI_INTEGER,ncell_mpi,1,MPI_INTEGER,comm_icosa,ierr)
displ=0
DO i=1,mpi_rank
displ=displ+ncell_glo(i-1)
displ(0)=0
DO i=1,mpi_size-1
displ(i)=displ(i-1)+ncell_mpi(i-1)
ENDDO
ncell_tot=sum(ncell_glo(:))
ncell_tot=sum(ncell_mpi(:))
ALLOCATE(lon(ncell), lat(ncell), bounds_lon(0:5,ncell), bounds_lat(0:5,ncell), ind_glo(ncell))
......@@ -407,12 +417,36 @@ CONTAINS
ENDDO
ENDDO
ENDDO
ALLOCATE(ind_glo_tot(ncell_tot))
ALLOCATE(cell_glo_tot(0:ncell_glo_tot-1))
cell_glo_tot(:)= -1
CALL MPI_ALLGATHERV(ind_glo, ncell, MPI_INTEGER, ind_glo_tot, ncell_mpi, displ, MPI_INTEGER, comm_icosa,ierr)
DO i=1,ncell_tot
cell_glo_tot(ind_glo_tot(i))= 0
ENDDO
ncell_glo=0
DO i=0,ncell_glo_tot-1
IF (cell_glo_tot(i)/=-1) THEN
cell_glo_tot(i) = ncell_glo
ncell_glo=ncell_glo + 1
ENDIF
ENDDO
CALL xios_set_domain_attr("i",ni_glo=ncell_tot, ibegin=displ, ni=ncell)
DO i=1,ncell
ind_glo(i)=cell_glo_tot(ind_glo(i))
ENDDO
CALL xios_set_domain_attr("i",ni_glo=ncell_glo, ibegin=displ(mpi_rank), ni=ncell)
CALL xios_set_domain_attr("i", data_dim=1, type='unstructured' , nvertex=6, i_index=ind_glo)
CALL xios_set_domain_attr("i",lonvalue_1d=lon, latvalue_1d=lat, bounds_lon_1d=bounds_lon, bounds_lat_1d=bounds_lat)
DEALLOCATE(lon, lat, bounds_lon, bounds_lat,ind_glo)
DEALLOCATE(lon, lat, bounds_lon, bounds_lat,ind_glo, ind_glo_tot, cell_glo_tot)
dtime%second=1
CALL xios_set_timestep(dtime)
......@@ -434,7 +468,8 @@ CONTAINS
!$OMP BARRIER
END SUBROUTINE xios_init_write_field_input
SUBROUTINE xios_write_field(name,field)
USE field_mod
IMPLICIT NONE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment