Skip to content

Commit

Permalink
reverted Makefile to manual dependency specification for better compa…
Browse files Browse the repository at this point in the history
…tibility; minor revisions on alcon.F90
  • Loading branch information
wenjundeng committed Sep 27, 2012
1 parent 925f077 commit aae0810
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 56 deletions.
59 changes: 28 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
MPIF90 := mpif90

# compiling options
FFLAGS := -O2
FFLAGS := -O3

# MPI executor
MPIEXEC := mpiexec
Expand All @@ -35,42 +35,39 @@ MPIEXEC := mpiexec
NPE := 2


# module object files
MODOBJ := alcon_input.o alcon_eqdata.o alcon_solver.o alcon_output.o \
cspline_petsc.o

.PHONY : build run clean cleanoutput

build : alcon

# SLEPc variables
-include $(SLEPC_DIR)/conf/slepc_variables

# first layer dependency files .d1
-include $(MODOBJ:.o=.d1)

# use GNU tools to build module dependency files .d1
# each .d1 file gives rules to generate corresponding .d2 file
# .d2 files are generated by Fortran compiler with -MM option
# corresponding .mod files are generated when compiler generates .d2 files
$(MODOBJ:.o=.d1) : %.d1 : %.F90
@echo 'making $@...'
@echo '-include $(@:.d1=.d2)' > $@
@exec echo -n '$(@:.d1=.d2) : $< ' >> $@
@exec sed -n 's/^[ \t]*use \([^ \t,]*\).*$$/\1.mod/p' $< | sort | uniq | paste -s --delimiters=" " >> $@
@exec echo -e '\t$$(MPIF90) $(FFLAGS) -MM $$< $$(FCPPFLAGS) > $$@' >> $@
@echo 'finished making $@'

# compile main program and link all modules
alcon : alcon.F90 $(MODOBJ)
$(MPIF90) $(FFLAGS) -o $@ $^ $(FCPPFLAGS) $(SLEPC_LIB)

# compile testcsp
testcsp : testcsp.F90 cspline_petsc.o
$(MPIF90) $(FFLAGS) -o $@ $^ $(FCPPFLAGS) $(SLEPC_LIB)

# compile modules
$(MODOBJ) : %.o : %.F90 %.d2
alcon : alcon.o alcon_input.o alcon_eqdata.o alcon_solver.o alcon_output.o \
cspline_petsc.o
$(MPIF90) $(FFLAGS) -o $@ $^ $(SLEPC_LIB)

testcsp : testcsp.o cspline_petsc.o
$(MPIF90) $(FFLAGS) -o $@ $^ $(SLEPC_LIB)

testcsp.o : testcsp.F90 cspline_petsc.o
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

alcon.o : alcon.F90 alcon_input.o alcon_eqdata.o alcon_solver.o
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

cspline_petsc.o : cspline_petsc.F90
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

alcon_input.o : alcon_input.F90
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

alcon_eqdata.o : alcon_eqdata.F90 alcon_input.o cspline_petsc.o
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

alcon_solver.o : alcon_solver.F90 alcon_input.o alcon_output.o
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

alcon_output.o : alcon_output.F90 alcon_input.o
$(MPIF90) $(FFLAGS) -c -o $@ $< $(FCPPFLAGS)

run : alcon cleanoutput
Expand All @@ -81,7 +78,7 @@ runtestcsp : testcsp
$(MPIEXEC) -n $(NPE) ./$< 2>&1 | tee $<.log

clean :
rm -f alcon testcsp *.o *.mod *.d1 *.d2 *.log
rm -f alcon testcsp *.o *.mod *.log

cleanoutput :
rm -f output/*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ALCON
=====
version 2012-08-24 23:04:13-04:00
version 2012-09-26 21:32:19-04:00
---------------------------------

ALCON is a code for solving ideal MHD Alfven continua in tokamaks,
Expand Down
42 changes: 18 additions & 24 deletions alcon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ program alcon
#include "finclude/petsc.h90"
#include "finclude/slepc.h"

character(25), parameter :: version = '2012-08-24 23:04:13-04:00'
character(25), parameter :: version = '2012-09-26 21:32:19-04:00'

! indexing variables
PetscInt :: i
Expand Down Expand Up @@ -59,14 +59,16 @@ program alcon
call MPI_Comm_rank(MPI_COMM_WORLD, mype, ierr)
CHKERRQ(ierr)
if (mype == 0) then
write (*, "(a)") "Error: ALCON requires complex version of PETSc. Please re-compiled it with complex version of PETSc."
write (*, "(a)") "Error: ALCON requires complex version of PETSc. Please use complex version of PETSc."
end if
call MPI_Finalize(ierr)
CHKERRQ(ierr)
stop 1
#endif

! initialization
!!!!!!!!!!!!!!!!!!
! initialization !
!!!!!!!!!!!!!!!!!!
call SlepcInitialize(PETSC_NULL_CHARACTER, ierr)
CHKERRQ(ierr)
wt1 = MPI_Wtime() ! record start time
Expand Down Expand Up @@ -154,7 +156,9 @@ program alcon
CHKERRQ(ierr)
end if

! radial domain and solver decomposition
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! radial domain and solver decomposition !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call MPI_Comm_size(MPI_COMM_WORLD, npe, ierr)
CHKERRQ(ierr)
ndom_rad = ceiling(real(npe) / npe_solver)
Expand Down Expand Up @@ -197,7 +201,7 @@ program alcon
write (*, "(a)") trim(adjustl(msg))
end if

! solver initialization, create PETSc and SLEPc objects
! solver initialization, create PETSc and SLEPc objects !
call alcon_solver_init(comm_solver)

if (verbosity >= 1) then
Expand All @@ -217,7 +221,9 @@ program alcon
iprogress = 1
end if

! main loop over radial grids
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! main loop over radial grids !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
do irad = irad_low, irad_high
!do irad = 1, nrad
!do irad = iraddiag - 1, iraddiag
Expand All @@ -238,22 +244,6 @@ program alcon
! [Nuclear Fusion 52, 043006 (2012)](http://wdeng.info/?p=117)
call alcon_solver_prepare(irad)

! this doesn't work anymore after radial domain decomposition
! so here set condition to "verbosity >= 10" to disable it
if (verbosity >= 10 .and. mydom_rad == 0) then
! print out matA, matB on irad == 1 and irad == iraddiag
if (irad == 1 .or. irad == iraddiag) then
call PetscPrintf(MPI_COMM_WORLD, "Info: matA:\n", ierr)
CHKERRQ(ierr)
call MatView(acs_matA, PETSC_VIEWER_STDOUT_WORLD, ierr)
CHKERRQ(ierr)
call PetscPrintf(MPI_COMM_WORLD, "Info: matB:\n", ierr)
CHKERRQ(ierr)
call MatView(acs_matB, PETSC_VIEWER_STDOUT_WORLD, ierr)
CHKERRQ(ierr)
end if
end if

! solve for eigenvalues (continua frequencies) and output
call alcon_solver_solve(acdprofile(1, irad), acdprofile(5, irad))
end do
Expand All @@ -262,7 +252,9 @@ program alcon
CHKERRQ(ierr)
end if


!!!!!!!!!!
! output !
!!!!!!!!!!
if (verbosity >= 1) then
call PetscPrintf(MPI_COMM_WORLD, "Info: writing data output files...\n", ierr)
CHKERRQ(ierr)
Expand All @@ -284,10 +276,12 @@ program alcon
CHKERRQ(ierr)
end if

!!!!!!!!!!!!!!!!
! finalization !
!!!!!!!!!!!!!!!!
! solver finalization, destroy PETSc and SLEPc objects
call alcon_solver_final


if (verbosity >= 1) then
wt2 = MPI_Wtime()
call PetscPrintf(MPI_COMM_WORLD, "Info: time spent by ALCON: " // sec2text(wt2 - wt1) // "\n", ierr)
Expand Down

0 comments on commit aae0810

Please sign in to comment.