2 patches for repository http://www.lmm.jussieu.fr/~zaleski/darcs/SurferMPI: Sun Mar 18 19:32:58 CET 2012 Stephane Zaleski <stephane.zaleski@upmc.fr> * Surfer now works with parameter file name as line command argument. Mon Mar 19 13:32:41 CET 2012 Stephane Zaleski <stephane.zaleski@upmc.fr> * Surfer now outputs in cgd format New patches: [Surfer now works with parameter file name as line command argument. Stephane Zaleski <stephane.zaleski@upmc.fr>**20120318183258 Ignore-this: a3c0914eefac56dbf061119cd1878dab ] { hunk ./Main/Surfer.f 19 PARAMETER (RORDER = .FALSE.) INTEGER v12345678912345a INTEGER v12345678912345b -C + +C.... Command line stuff + + integer count + CHARACTER(len=132) arg + +C.... Fortran/C interface + + interface + subroutine gp_parfile(string) bind(C, name="GP_parfile") + use iso_c_binding, only: c_char + character(kind=c_char) :: string(*) + end subroutine gp_parfile + end interface +C + count = command_argument_count() + if (count.lt.1) then + CALL get_command_argument(0, arg) + print *,'Warning: ',TRIM(arg),' called with no arguments' + print *,'will use standard input as parameter file.' + else + CALL get_command_argument(1, arg) + print *,'Debugging: parfile name is ',TRIM(arg) + call gp_parfile(TRIM(arg)) + endif + + C.... Starting MPI. CALL MPI_INIT(IERR00) DEBUG_MPI = GP_IFETCH("debug_mpi",0,"DEFAULT") hunk ./Makefile 16 MACHINE=LINUX # Define your C compiler and flags -CC= mpicc +CC= openmpicc CFLAGS = -O -c # Define extra compiling option hunk ./Makefile 23 OPTS= -DANSI -DLINUX -DHAVE_MPI # Define Fortran compiler and flags -FC = mpif77 +FC = openmpif77 FFLAGS = -O3 -ffixed-line-length-132 # -fno-second-underscore FPRES = -O3 -ffixed-line-length-132 # -fno-second-underscore FFLAGS = -O3 -ffixed-line-length-132 -funderscoring # -fno-second-underscore hunk ./Makefile 30 FPRES = -O3 -ffixed-line-length-132 -funderscoring # -fno-second-underscore # Define your C pre-processor (for FORTRAN file) -CPP=/usr/lib/cpp +CPP=cpp CPPFLAGS=-P # # END SECTION FOR LINUX hunk ./Makefile 39 # # Define the root directory where is Surfer3D -# ROOTDIR=$(HOME)/simulation/Surfer3D-MPIquart ROOTDIR= # Location where to look for local include files hunk ./Makefile 45 SRCINC = ../include -#GPLIB= -L/usr/local/lib -lgp GPLIB= -L$(HOME)/lib -lgpcMPI SRCLIB= -L../source -lsrc hunk ./NOTES 8 - each time the boundary side rings are filled, they should also be sent and received from the neighbors, thus make_bc should be called. +--- + +18/03 fix relax_times + + hunk ./README 13 INSTALLATION AND RUN - You should install Getpar-0.5 first. - SurferMPI works like Surfer except that the parameter file must be + You should install GetparC first. + The parameter file must be named "parJ". Copy your parameter file into parJ and do % mpirun -np xxx Surfer hunk ./source/pres_solver_alg.f 44 INTRINSIC MIN0,MAX0 SAVE conv_rate DATA conv_rate /0.5d0/ - + INTEGER MAX_RELAX_TIMES, nitermax + INTEGER MIN_RELAX_TIMES, nitermin + INTEGER GP_IFETCH + DOUBLE PRECISION GP_DFETCH + EXTERNAL GP_IFETCH,GP_DFETCH c for MPI hunk ./source/pres_solver_alg.f 57 double precision conv_total lcomm2d = comm2d + MAX_RELAX_TIMES = GP_ifetch('relaxfine',4,'SEVERE') + MIN_RELAX_TIMES = GP_ifetch('relaxfine',4,'SEVERE') + nitermin = GP_ifetch('nitermin',1,'WARNING') + c SUBROUTINES: copy, rstrct, abcei, fill0, slvsml, interp, c relax, resid, addint c*** hunk ./source/pres_solver_alg.f 128 RELAX_TIMES_OLD=RELAX_TIMES if (conv_total .gt. 0.6) then - RELAX_TIMES=RELAX_TIMES + 1 + RELAX_TIMES=MIN0(RELAX_TIMES + 1,MAX_RELAX_TIMES) write(*,*) 'PPRANK = ',PPRANK, % " convergence rate deteriorating, nbr iterations = " % ,relax_times, " conv local =",conv_rate, "conv rate =",conv_total hunk ./source/pres_solver_alg.f 133 else if (conv_total .lt. 0.1) then - RELAX_TIMES = MAX0(RELAX_TIMES - 1,1) + RELAX_TIMES = MAX0(RELAX_TIMES - 1,MIN_RELAX_TIMES) write(*,*) 'PPRANK = ',PPRANK, % " convergence rate improving, nbr iterations = " % ,relax_times, " conv local =",conv_rate, " conv rate =",conv_total hunk ./source/pres_solver_alg.f 148 & write(*,*) "beginning MG Norm2 div total = ",norm endif - if(NCYCLE.lt.2) STOP 'NCYCLE too small' + if(NCYCLE.lt.1) STOP 'NCYCLE too small' do n=1,NCYCLE c Test if we can exit loop hunk ./source/pres_solver_alg.f 153 c - if(norm.lt.mineps.and.n.gt.1) then + if(norm.lt.mineps.and.n.ge.nitermin) then call copy(zu(ia(NG)),zd(ia(NG)),nfx,nfy,nfz) c commented out by Denis ???? } [Surfer now outputs in cgd format Stephane Zaleski <stephane.zaleski@upmc.fr>**20120319123241 Ignore-this: f6aedec87f62556f66f2459be135200a ] { hunk ./Makefile 17 # Define your C compiler and flags CC= openmpicc -CFLAGS = -O -c +CFLAGS = -O -c -I$(HOME)/include # Define extra compiling option OPTS= -DANSI -DLINUX -DHAVE_MPI hunk ./source/Makefile 13 LIB = libsrc.a OBJS1 = get_par.o inipres.o momentum.o stresses.o time_step.o sweep.o flux3d.o alpha3d.o -OBJS2 = utilf.o debug.o datbfile.o v5dconv.o prepjet.o dump.o cleanup.o levelset2vof.o +OBJS2 = utilf.o debug.o writecgd.o datbfile.o v5dconv.o prepjet.o dump.o cleanup.o levelset2vof.o OBJS3 = pres_solver_alg.o inipres.o nappe.o bupdat3D.o infotp.o mpi_utils.o prepring.o OBJS = $(OBJS1) $(OBJS2) $(OBJS3) hunk ./source/time_step.f 29 c Output some fields c if(mod(t,tstore_c).eq.0) then - call datbfile(u,v,w,zcc(ia(ng)),nx,ny,nz,t,pprank) +c call datbfile(u,v,w,zcc(ia(ng)),nx,ny,nz,t,pprank) c call v5dconv(u,v,w,zcc(ia(ng)),nx,ny,nz,t) hunk ./source/time_step.f 31 + call writecgd(u,v,w,zcc(ia(ng)),nx,ny,nz,t,pprank) endif c*** c Checkpoint every tcheck steps addfile ./source/writecgd.c hunk ./source/writecgd.c 1 +#include <stdio.h> +#include <stdlib.h> +#include "surferC.h" +#include "gp.h" + +void writecgd_(double *u, double *v, double *w, double *cc, int *nx, int *ny, int *nz, int *t, int *PPRANK) +{ + int i,j,k,e; + int dim; + char s[256]; + FILE *fptr; + int npts[3]; + /* Debugging */ + + /* printf("at beginning of datbfile\n"); */ + if(*PPRANK != 0 ) return; + + e=1; + char varname[2]="T"; + char * rootname = GP_sfetch("rootname","surfer","WARNING"); + double boxL = GP_dfetch("length",1.,"DEFAULT"); + double dx = boxL/(*nx-2.); + sprintf(s, "%s-%s-%d.cgd",rootname,varname,*t); + npts[0]=*nx; + npts[1]=*ny; + npts[2]=*nz; + fptr = fopen(s, "wb"); + fprintf(fptr,"3 x y z %d %d %d \n",*nx -2*e,*ny -2*e,*nz-2*e); + for(dim=0;dim<3;dim++) + { + for(i=0;i<(npts[dim]-2*e);i++) + { + double coord; + coord=-boxL/2.0 + dx*0.5 + dx*i; + fprintf(fptr,"%g ",coord); + } + fprintf(fptr,"\n"); + } + for(i=e;i<*nx-e;i++) + for(j=e;j<*ny-e;j++) + for(k=e;k<*nz-e;k++) + { + fprintf(fptr,"%g \n",*(cc + i + j* *nx + k * *nx * *ny)); + } + fclose(fptr); + +} } Context: [minor change zaleski@lmm.jussieu.fr (on landau)**20070227102413] [minor bug (PPRANK missing) corrected zaleski@lmm.jussieu.fr (on landau)**20070226160113] [added zapout function stephane.zaleski@upmc.fr**20070223153828] [Added ring simulation zaleski@lmm.jussieu.fr (at home)**20060711224917] [debugging on bernoulli zaleski@lmm.jussieu.fr (at bernoulli)**20060711083740] [debug zaleski@lmm.jussieu.fr (at home)**20060710205347] [removed some output zaleski@lmm.jussieu.fr (at home)**20060710205054] [Removed some bugs, seems to work zaleski@lmm.jussieu.fr (at home)**20060606110949] [This is an intermediate buggy version zaleski@lmm.jussieu.fr (at home)**20060605101846] [Made SurferMPI look more like Surfer3D zaleski@lmm.jussieu.fr (at home)**20060604153729] [Attempt to fix INF in convergence rate bug (crude commenting out of PPRANK=0) zaleski@lmm.jussieu.fr**20060602153407] [Added nappe functions by Anne Bague zaleski@lmm.jussieu.fr (at home)**20060602135124] [fixed README zaleski@lmm.jussieu.fr (at home)**20060520082633] [removed spurious data files zaleski@lmm.jussieu.fr (at home)**20060520082058] [First version that seems to work with attached test files. zaleski@lmm.jussieu.fr (at home)**20060520081755 This version mimics the old Leboissetier+Pages version but fixes the multigrid bug. ] [debogage zaleski@lmm.jussieu.fr (at home)**20060516213446] [further updating of MPI version zaleski@lmm.jussieu.fr (at home)**20060516194855] [reducing differences with scalar version zaleski@lmm.jussieu.fr (at home)**20060515232218] [Initial revision zaleski@lmm.jussieu.fr**20060515174104] Patch bundle hash: 1958f3588b0aa2b784f65ee6cad3c644dfffd3e1