From eca15f45d9ae31c601ff260c6a3d5b163025e798 Mon Sep 17 00:00:00 2001 From: Theophile Terraz <theophile.terraz@inrae.fr> Date: Thu, 16 Jun 2022 11:56:19 +0200 Subject: [PATCH] debug TS + compil CGNS --- code/Makefile | 22 +++++++---- code/modules_comptage.f90 | 77 ++++++++++++++++++++++++++++++++------- code/rubar20.f90 | 71 ++++++++++++++++++++++++++++++++---- 3 files changed, 140 insertions(+), 30 deletions(-) diff --git a/code/Makefile b/code/Makefile index cecb2d7..fc61788 100644 --- a/code/Makefile +++ b/code/Makefile @@ -8,10 +8,12 @@ OMP_FLAG = -fopenmp MPI_FLAG = mpifort -cpp -DWITH_MPI # change to debug_flag to enable debug features COMPILE_FLAG = $(OPTIM_FLAG) +# COMPILE_FLAG = $(DEBUG_FLAG) # METIS_FLAG = -DWITH_METIS NB_PROC = 2 # CGNS_PATH=~/Codes/CGNS/install CGNS_PATH=/usr +CGNS_FLAG= -I $(CGNS_PATH)/include -lcgns #Fichiers compilés MPI = _MPI @@ -40,15 +42,19 @@ COMPT = module_messages.f90 #Ci-dessous des options de calcul prédéfinis pour effectuer la vérification automatique #en eau claire et en transport solide define AUTO_EC - -D TRANSPORT_SOLIDE=0 + -D TRANSPORT_SOLIDE=0 endef define AUTO_TS - -D TRANSPORT_SOLIDE=1 -D SEDVAR=1 -D VH=1 -D VNH=0 + -D TRANSPORT_SOLIDE=1 -D SEDVAR=1 -D VH=1 -D VNH=0 endef define AUTO_METIS - -D WITH_METIS=0 + -D WITH_METIS=0 +endef + +define AUTO_CGNS + -D WITH_CGNS=0 endef @@ -65,25 +71,25 @@ sequentiel : sequentiel_eau_claire sequentiel_ts eau_claire : sequentiel_eau_claire mpi_eau_claire sequentiel_eau_claire : - $(F90) $(AUTO_EC) $(COMPILE_FLAG) $(MODULES) $(SRC) -o $(PROG)$(VERSION) -I $(CGNS_PATH)/include -lcgns + $(F90) $(AUTO_CGNS) $(AUTO_EC) $(COMPILE_FLAG) $(MODULES) $(SRC) -o $(PROG)$(VERSION) $(CGNS_FLAG) # time -p sh ../DataFileComparator/UnitTest.bash #Compilation éxécution d'un cas test en transport solide sequentiel_ts : - $(F90) $(AUTO_TS) $(COMPILE_FLAG) $(MODULES) $(FCT_TS_LOCAL) $(SRC) -o $(PROG)$(TS)$(VERSION) -I $(CGNS_PATH)/include -lcgns + $(F90) $(AUTO_CGNS) $(AUTO_TS) $(COMPILE_FLAG) $(MODULES) $(FCT_TS_LOCAL) $(SRC) -o $(PROG)$(TS)$(VERSION) $(CGNS_FLAG) # mpirun -np $(NB_PROC) $(PROG)$(MPI)$(VERSION) ../cas_tests/uclbenchmark/ucl4T0/ucl4T0 #Compilation OpenMp (UnderDeveloppement) openmp : - $(F90) $(COMPILE_FLAG) $(OMP_FLAG) $(MODULES) $(SRC) -o $(PROG)$(OMP)$(VERSION) + $(F90) $(AUTO_CGNS) $(COMPILE_FLAG) $(OMP_FLAG) $(MODULES) $(SRC) -o $(PROG)$(OMP)$(VERSION) #Compilation MPI mpi_eau_claire : - $(MPI_FLAG) $(METIS_FLAG) $(AUTO_EC) $(COMPILE_FLAG) $(MODULES) $(COMPT) $(SRC) $(METIS_LIB) -o $(PROG)$(MPI)$(VERSION) -I $(CGNS_PATH)/include -lcgns + $(MPI_FLAG) $(AUTO_CGNS) $(AUTO_METIS) $(AUTO_EC) $(COMPILE_FLAG) $(MODULES) $(COMPT) $(SRC) $(METIS_LIB) -o $(PROG)$(MPI)$(VERSION) $(CGNS_FLAG) #Compilation MPI mpi_ts : - $(MPI_FLAG) $(METIS_FLAG) $(AUTO_TS) $(COMPILE_FLAG) $(MODULES) $(COMPT) $(FCT_TS_LOCAL) $(SRC) $(METIS_LIB) -o $(PROG)$(MPI)$(TS)$(VERSION) -I $(CGNS_PATH)/include -lcgns + $(MPI_FLAG) $(AUTO_METIS) $(AUTO_TS) $(COMPILE_FLAG) $(MODULES) $(COMPT) $(FCT_TS_LOCAL) $(SRC) $(METIS_LIB) -o $(PROG)$(MPI)$(TS)$(VERSION) $(CGNS_FLAG) # #Compilation MPI avec option de débuggage # mpidebug : diff --git a/code/modules_comptage.f90 b/code/modules_comptage.f90 index 166187f..7174f8a 100644 --- a/code/modules_comptage.f90 +++ b/code/modules_comptage.f90 @@ -526,7 +526,7 @@ #ifdef WITH_MPI integer,dimension(mpi_status_size)::status #endif /* WITH_MPI */ -#ifdef WITH_METIS +#if WITH_METIS integer,dimension(:),allocatable :: eptr, nodes, npart integer(kind=c_int) :: nntot, ncommon integer, pointer :: vwgt=>null(), vsize=>null(), mopts=>null() @@ -539,9 +539,9 @@ ne_loc(:)=0 card = ne/np - surplus = mod(ne, np) + surplus = modulo(ne, np) -#ifdef WITH_METIS +#if WITH_METIS nntot = 0 do i=1,ne nntot = nntot+nne(i) @@ -568,13 +568,14 @@ ! allocate(itri(ne)) ! xe(:)=xe(:)*(-1) ! call indexArrayReal(ne, xe, itri) +! call test_tri(ne, ye, itri) ! xe(:)=xe(:)*(-1) k=1 ! compteur des mailles globales ! do i=np-1,0,-1 do i=0,np-1 if (i<surplus) then do j=1,card+1 -! ! machine(itri(k))=i ! numero de la machine qui traite la maille k +! machine(itri(k))=i ! numero de la machine qui traite la maille k machine(k)=i ! numero de la machine qui traite la maille k ne_loc(i)=ne_loc(i)+1 ! nombre de mailles traitées par la machine i k=k+1 @@ -588,6 +589,7 @@ end do end if end do +! call test_machine(ne, machine, np) ! ! if (np.eq.2) then ! ! machine(:)=0 ! ! ne_loc(0)=ne @@ -911,9 +913,8 @@ do ibouv=1,nbouv i1=ie1(ouv(ibouv)) - i2=ie1(ouv(ibouv)) + i2=ie2(ouv(ibouv)) if (machine(i1)/=machine(i2))then - print*,"relocate second cell of ouv ",ibouv ne_loc(machine(i2))=ne_loc(machine(i2))-1 machine(i2)=machine(i1) ne_loc(machine(i1))=ne_loc(machine(i1))+1 @@ -950,9 +951,9 @@ ie=ieva(ia,2) end if if (machine(ie)/=machine_aretes30(i)) then - print*,'------------------------------------------------------' - print*,' un ouvrage breche interfere dans un groupe d''aretes' - print*,'------------------------------------------------------' + print*,'-----------------------------------------------' + print*,' un ouvrage interfere dans un groupe d''aretes ' + print*,'-----------------------------------------------' #ifdef WITH_MPI call mpi_finalize(statinfo) #endif /* mpi */ @@ -972,7 +973,7 @@ ie=ieva(ia,2) end if if (machine(ie)/=machine_aretes60(i)) then - print*,'------------------------------------------------------' + print*,'------------------------------------------------' print*,' 000 00 00 000 0000' print*,' 0 0 0 0 0 0 0 0' print*,' 000 0000 00 0 0 000' @@ -985,10 +986,10 @@ print*,' 0 0 0 0 0 0 0 0 0 ' print*,' 000 0 0 0 0 0 0 000 0000 @' print*,' ' - print*,' un ouvrage breche interfere dans un groupe d''aretes' + print*,' un ouvrage interfere dans un groupe d''aretes' print*,' choisissez une autre répartition du maillage' print*,' puis relancez les calculs' - print*,'------------------------------------------------------' + print*,'------------------------------------------------' #ifdef WITH_MPI call mpi_finalize(statinfo) #endif /* mpi */ @@ -1107,8 +1108,8 @@ subroutine indexArrayReal(n,Array,Index) implicit none integer, intent(in) :: n - real(wp), intent(in) :: Array(n) - integer, intent(out) :: Index(n) + real(wp), intent(in), allocatable :: Array(:) + integer, intent(inout), allocatable :: Index(:) integer, parameter :: nn=15, nstack=50 integer :: k,i,j,indext,jstack,l,r integer :: istack(nstack) @@ -1194,5 +1195,53 @@ end subroutine swap end subroutine indexArrayReal +! subroutine test_tri(n,Array,Index) +! integer, intent(in) :: n +! real(wp), intent(in),allocatable :: Array(:) +! integer, intent(in),allocatable :: Index(:) +! integer :: i, j, npb +! npb = 0 +! print*,"size(itri)",size(Index),"ne",n +! do i=1,n +! if (index(i) < 1 .or. index(i) > n) then +! print*,"*** probleme tri ",npb +! print*,"itri(",i,") = ",index(i) +! end if +! enddo +! do i=2,n +! do j=1,i-1 +! if (Array(index(i)) < Array(index(j))) then +! npb = npb + 1 +! print*,"*** probleme tri ",npb +! end if +! enddo +! enddo +! npb = 0 +! do i=1,n +! do j=1,n +! if (i .ne. j) then +! if (index(i) == index(j)) then +! npb = npb + 1 +! print*,"*** probleme tri, deux indices identiques ",npb +! end if +! end if +! enddo +! enddo +! end subroutine test_tri + +! subroutine test_machine(n,Array,np) +! integer, intent(in) :: n,np +! integer, intent(in),allocatable :: Array(:) +! integer :: i, npb +! npb = 0 +! do i=1,n +! if (Array(i) >= np .or. Array(i)<0) then +! npb = npb + 1 +! print*,"*** probleme machine ",npb +! print*,"*** maille ",i," to machine ",Array(i) +! end if +! enddo +! end subroutine test_machine + end module diff --git a/code/rubar20.f90 b/code/rubar20.f90 index 7562c28..234b4e4 100644 --- a/code/rubar20.f90 +++ b/code/rubar20.f90 @@ -473,8 +473,10 @@ #if TRANSPORT_SOLIDE use module_ts #endif +#if WITH_CGNS use cgns use cgns_data +#endif !$ use omp_lib implicit none @@ -505,8 +507,10 @@ integer je,iev real(wp) :: rcet,cetr #endif +#if WITH_CGNS integer :: ier, isize(3), index_field, index_flow, index_flow2, index_coord, index_motion character(LEN=32) :: field_name +#endif #ifdef WITH_MPI allocate(mess_qouv1(na),mess_qouv2(na)) @@ -673,10 +677,18 @@ qvet(ie) = -999.999 endif enddo +! do ie = 1,ne +! if(.not. eau(ie))then +! het(ie) = 0.0 +! quet(ie) = 0.0 +! qvet(ie) = 0.0 +! endif +! enddo write(id_tps,'(f15.3)')tm write(id_tps,'(8f10.5)') (het(ie),ie=1,ne) write(id_tps,'(8f10.5)') (quet(ie),ie=1,ne) write(id_tps,'(8f10.5)') (qvet(ie),ie=1,ne) +#if WITH_CGNS !!! test cgns !!! nb_timesteps_cgns = nb_timesteps_cgns+1 ! call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) @@ -690,10 +702,12 @@ call d_push_back(times_cgns,tm) call cg_sol_write_f(index_file,index_base,index_zone,sol_names%values(nb_timesteps_cgns),CellCenter,index_flow,ier) call cg_sol_write_f(index_file,index_base,index_zone,sol_names2%values(nb_timesteps_cgns),Vertex,index_flow2,ier) + call cg_field_write_f(index_file,index_base,index_zone,index_flow,integer,'proc',machine(1:ne),index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'het',het,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'quet',quet,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'qvet',qvet,index_field,ier) !!! fin test cgns !!! +#endif #if TRANSPORT_SOLIDE ! ecriture des concentrations dans tpc @@ -717,7 +731,9 @@ else write(id_tpc,'(8f10.7)') (ce(ie),ie=1,ne) endif +#if WITH_CGNS call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'ce',ce,index_field,ier) +#endif if(solute)then ! si solute et derive on ecrit dans vitfro et dhe la vitesse de surface fonction du vent @@ -725,17 +741,21 @@ call vitsur endif write(id_tpc,'(8f10.5)') (dhe(ie),ie=1,ne) - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) write(id_tpc,'(8f10.5)') (vitfro(ie),ie=1,ne) +#if WITH_CGNS + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'vitfro',vitfro,index_field,ier) +#endif ! si pas des solutes :limites a vitfro et dhe et ecriture zfn else #if SEDVAR if(sedvar)then write(id_tpc,'(8f10.5)') (diame(ie),ie=1,ne) - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'diame',diame,index_field,ier) write(id_tpc,'(8f10.5)') (sigmae(ie),ie=1,ne) +#if WITH_CGNS + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'diame',diame,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'sigmae',sigmae,index_field,ier) +#endif call ecrsed(tm) else !end if sedvar @@ -777,9 +797,11 @@ else write(id_tpc,'(8f10.7)') (dhe(ie),ie=1,ne) endif - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) write(id_tpc,'(8f10.5)') (vitfro(ie),ie=1,ne) +#if WITH_CGNS + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'vitfro',vitfro,index_field,ier) +#endif #if SEDVAR ! fin du if sur sedvar @@ -808,7 +830,9 @@ elseif(minzfn.gt.-9999.9.and.maxzfn.lt.99999.9)then write(id_zfn,'(10f8.2)')(zfn(in)+dzfn(in),in=1,nn) endif +#if WITH_CGNS call cg_field_write_f(index_file,index_base,index_zone,index_flow2,RealDouble,'dzfn',dzfn,index_field,ier) +#endif ! dzfn ecrit si on ne réactualise pas la topo write(id_dzf,'(f15.3)')tm write(id_dzf,'(10f8.5)')& @@ -834,6 +858,7 @@ write(id_zfn,'(10f8.2)')(zfn(in),in=1,nn) endif +#if WITH_CGNS write(sol_names_temp,'(A19,I0)')'ArbitraryGridMotion',nb_timesteps_cgns call c32_push_back(gridmotionpointers, sol_names_temp) ! write(gridmotionpointers(nb_timesteps_cgns),'(A19,I0)')'ArbitraryGridMotion',nb_timesteps_cgns @@ -852,6 +877,7 @@ call cg_gopath_f(index_file,sol_names_temp,ier) call cg_array_write_f('CoordinateZ',RealDouble,1,sizeof(zfn),zfn,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow2,RealDouble,'zfn',zfn,index_field,ier) +#endif ! fin du if sur opendz endif ! fin du if sur solute @@ -1386,8 +1412,10 @@ #if TRANSPORT_SOLIDE use module_ts #endif +#if WITH_CGNS use cgns use cgns_data +#endif implicit none !include 'rubar20_common.for' @@ -1405,8 +1433,10 @@ real(WP) :: maxce,maxdhe,mindhe,maxzfn,minzfn,volaf,volde integer :: in #endif +#if WITH_CGNS integer :: ier, isize(3), index_flow, index_flow2, index_field, index_coord, index_motion character(LEN=32) :: field_name +#endif #if ENG @@ -1565,10 +1595,9 @@ write(id_tps,'(8f10.5)') (que(ie),ie=1,ne) write(id_tps,'(8f10.5)') (qve(ie),ie=1,ne) close(id_tps) +#if WITH_CGNS !!! test cgns !!! nb_timesteps_cgns = nb_timesteps_cgns+1 -! call cg_open_f('grid.cgns',CG_MODE_MODIFY,index_file,ier) -! if (ier .ne. CG_OK) call cg_error_exit_f index_base=1 index_zone=1 write(sol_names_temp,'(a4,i0)')"Cell",nb_timesteps_cgns @@ -1579,9 +1608,11 @@ call cg_sol_write_f(index_file,index_base,index_zone,sol_names%values(nb_timesteps_cgns),CellCenter,index_flow,ier) call cg_sol_write_f(index_file,index_base,index_zone,sol_names2%values(nb_timesteps_cgns),Vertex,index_flow2,ier) ! call cg_field_write_f(index_file,index_base,index_zone,index_flow2,RealDouble,'Z',zfn,index_field,ier) + call cg_field_write_f(index_file,index_base,index_zone,index_flow,integer,'proc',machine(1:ne),index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'het',het,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'quet',quet,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'qvet',qvet,index_field,ier) +#endif #if TRANSPORT_SOLIDE @@ -1615,7 +1646,9 @@ else write(id_tpc,'(8f10.7)') (ce(ie),ie=1,ne) endif +#if WITH_CGNS call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'ce',ce,index_field,ier) +#endif ! if(conckg)then ! write(id_tpc,'(8f10.5)') ! :(min(cet(ie)*dens,9999.999d0),ie=1,ne) @@ -1631,9 +1664,11 @@ endif write(id_tpc,'(8f10.5)') (dhe(ie),ie=1,ne) - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) write(id_tpc,'(8f10.5)') (vitfro(ie),ie=1,ne) +#if WITH_CGNS + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'vitfro',vitfro,index_field,ier) +#endif ! si pas des solutes :limites a vitfro et dhe et ecriture zfn else @@ -1642,8 +1677,10 @@ write(id_tpc,'(8f10.5)') (diame(ie),ie=1,ne) write(id_tpc,'(8f10.5)') (sigmae(ie),ie=1,ne) +#if WITH_CGNS call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'diame',diame,index_field,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'sigmae',sigmae,index_field,ier) +#endif call ecrsed(tm) close(37) else @@ -1686,10 +1723,12 @@ else write(id_tpc,'(8f10.7)') (dhe(ie),ie=1,ne) endif - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) write(id_tpc,'(8f10.5)') (vitfro(ie),ie=1,ne) - call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'vitfro',vitfro,index_field,ier) close(id_tpc) +#if WITH_CGNS + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'dhe',dhe,index_field,ier) + call cg_field_write_f(index_file,index_base,index_zone,index_flow,RealDouble,'vitfro',vitfro,index_field,ier) +#endif #if SEDVAR ! fin du if sur sedvar @@ -1718,7 +1757,9 @@ elseif(minzfn.gt.-9999.9.and.maxzfn.lt.99999.9)then write(id_zfn,'(10f8.2)')(zfn(in)+dzfn(in),in=1,nn) endif +#if WITH_CGNS call cg_field_write_f(index_file,index_base,index_zone,index_flow2,RealDouble,'dzfn',dzfn,index_field,ier) +#endif ! dzfn ecrit si on ne réactualise pas la topo write(id_dzf,'(f15.3)')tm write(id_dzf,'(10f8.5)')& @@ -1743,6 +1784,7 @@ elseif(minzfn.gt.-9999.9.and.maxzfn.lt.99999.9)then write(id_zfn,'(10f8.2)')(zfn(in),in=1,nn) endif +#if WITH_CGNS write(sol_names_temp,'(A19,I0)')'ArbitraryGridMotion',nb_timesteps_cgns call c32_push_back(gridmotionpointers, sol_names_temp) ! write(gridmotionpointers(nb_timesteps_cgns),'(A19,I0)')'ArbitraryGridMotion',nb_timesteps_cgns @@ -1761,6 +1803,7 @@ call cg_gopath_f(index_file,sol_names_temp,ier) call cg_array_write_f('CoordinateZ',RealDouble,1,sizeof(zfn),zfn,ier) call cg_field_write_f(index_file,index_base,index_zone,index_flow2,RealDouble,'zfn',zfn,index_field,ier) +#endif ! fin du if sur opendz endif close(id_zfn) @@ -1769,6 +1812,7 @@ ! endif #endif +#if WITH_CGNS dim(1)=32 dim(2)=nb_timesteps_cgns call cg_biter_write_f(index_file,index_base,'TimeIterValues',nb_timesteps_cgns,ier) @@ -1796,6 +1840,7 @@ call c32_deallocate(gridmotionpointers) call c32_deallocate(gridcoordpointers) !!! fin test cgns !!! +#endif @@ -9209,8 +9254,10 @@ #if TRANSPORT_SOLIDE use module_ts #endif +#if WITH_CGNS use cgns use cgns_data +#endif ! lecture/edition donnees maillage implicit none ! implicit logical (a-z) @@ -9226,9 +9273,11 @@ ! integer iltmax,ialt(nltmax),nblt(nltmax),i integer,dimension(:),allocatable::nae,neve,nna integer::nevnmx +#if WITH_CGNS integer :: ier, index_coord, index_flow integer,dimension(:,:),allocatable :: ine_cgns integer :: isize(3) +#endif !common/nvois/nne !common/etud/etude @@ -9366,6 +9415,7 @@ ! endif 121 close(ifdm) if (me==scribe)then +#if WITH_CGNS !!! test cgns !!! isize(1)=nn isize(2)=ne @@ -9407,6 +9457,7 @@ deallocate(ine_cgns) nb_timesteps_cgns=0 !!! fin test cgns !!! +#endif ! edition donnees maillage if (if.eq.0) goto 300 if (if.eq.21.or.if.eq.23.or.if.eq.25.or.if.eq.27) then @@ -21732,8 +21783,12 @@ end ! do jn=1,nne(ie) ! in=ine(ie,jn) #ifdef WITH_MPI + call message_group_calcul(dhe) call message_group_calcul(zfe) call message_group_calcul(cofr) + call message_group_calcul(fra) + call message_group_calcul(fre) + call message_group_calcul_logical(eau) #if SEDVAR if(sedvar)then call message_group_calcul(diame2) -- GitLab