Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fortran standard and Tapenade update #16

Merged
merged 15 commits into from
Oct 12, 2022
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# fprettify (#15)
579c967b339ca163fbaa4487ca37e04251bc17aa
1 change: 1 addition & 0 deletions .github/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ extends:
IMAGE: private
COVERAGE: true
TAPENADE: true
TAPENADE_VERSION: "3.16"
FPRETTIFY: true
17 changes: 12 additions & 5 deletions common_CS.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ MAKE_CLEAN_ARGUMENTS = *~ *.o *.mod *.il *.stb c_* *.a
# * *
# ******************************************************************

FF90_ALL_FLAGS = -I$(MODDIR) $(CGNS_INCLUDE_FLAGS) \
$(FF90_GEN_FLAGS) $(FF90_OPT_FLAGS) -DUSE_COMPLEX

CC_ALL_FLAGS = -I$(MODDIR) $(CGNS_INCLUDE_FLAGS) \
$(CC_GEN_FLAGS) $(CC_OPT_FLAGS)
FF77_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(FF77_FLAGS)

FF90_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(FF90_FLAGS) \
-DUSE_COMPLEX

CC_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(C_FLAGS)
14 changes: 10 additions & 4 deletions common_real.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ MAKE_CLEAN_ARGUMENTS = *~ *.o *.mod *.il *.stb c_* *.a
# * *
# ******************************************************************

FF90_ALL_FLAGS = -I$(MODDIR) $(CGNS_INCLUDE_FLAGS) \
$(FF90_GEN_FLAGS) $(FF90_OPT_FLAGS)
FF77_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(FF77_FLAGS)

CC_ALL_FLAGS = -I$(MODDIR) $(CGNS_INCLUDE_FLAGS) \
$(CC_GEN_FLAGS) $(CC_OPT_FLAGS)
FF90_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(FF90_FLAGS)

CC_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(C_FLAGS)
8 changes: 3 additions & 5 deletions config/defaults/config_LINUX_GFORTRAN.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ CGNS_INCLUDE_FLAGS=-I$(CGNS_HOME)/include
CGNS_LINKER_FLAGS=-L$(CGNS_HOME)/lib -lcgns

# ------- Define Compiler Flags ----------------------------------------
FF90_GEN_FLAGS = -fPIC -g -fbounds-check
CC_GEN_FLAGS = -fPIC

FF90_OPT_FLAGS = -fPIC -fdefault-real-8 -O2 -fdefault-double-8
CC_OPT_FLAGS = -O2
FF77_FLAGS = -fPIC -O2 -fdefault-real-8 -fdefault-double-8 -g -fbounds-check
FF90_FLAGS = ${FF77_FLAGS} -std=f2008
C_FLAGS = -fPIC -O2

# ------- Define Archiver and Flags -----------------------------------
AR = ar
Expand Down
10 changes: 4 additions & 6 deletions config/defaults/config_LINUX_INTEL.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ CGNS_INCLUDE_FLAGS=-I$(CGNS_HOME)/include
CGNS_LINKER_FLAGS=-L$(CGNS_HOME)/lib -lcgns

# ------- Define Compiler Flags ----------------------------------------
FF90_GEN_FLAGS = -DHAS_ISNAN -fPIC -r8 -O2 -g
CC_GEN_FLAGS = -DHAS_ISNAN -O -fPIC

FF90_OPT_FLAGS = -DHAS_ISNAN -fPIC -r8 -O2 -g
CC_OPT_FLAGS = -DHAS_ISNAN -O -fPIC
FF77_FLAGS = -fPIC -r8 -O2 -g
FF90_FLAGS = ${FF77_FLAGS} -std08
C_FLAGS = -fPIC -O2

# ------- Define Archiver and Flags -----------------------------------
AR = ar
AR_FLAGS = -rvs

# ------- Define Linker Flags ------------------------------------------
LINKER = $(FF90)
LINKER_FLAGS = -nofor_main
LINKER_FLAGS = -nofor-main

# Define potentially different python, python-config and f2py executables:
PYTHON = python
Expand Down
8 changes: 1 addition & 7 deletions rulesSources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
@echo

%.o: %.f
$(FF90) $(FF90_ALL_FLAGS) -c $< -o $(OBJDIR)/$(@F)
@echo
@echo " --- Compiled $*.f successfully ---"
@echo

%.o: %.F
$(FF90) $(FF90_ALL_FLAGS) -c $< -o $(OBJDIR)/$(@F)
$(FF90) $(FF77_ALL_FLAGS) -c $< -o $(OBJDIR)/$(@F)
@echo
@echo " --- Compiled $*.f successfully ---"
@echo
Expand Down
6 changes: 3 additions & 3 deletions src/ADT/adtLocalSearch.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ subroutine intersectionTreeSearch(jj, inpBBox, &
! * *
! ****************************************************************
!
use Utilities ! ../utilities/Utilities.F90
use utilities ! ../utilities/utilities.F90
implicit none
!
! Subroutine arguments.
Expand Down Expand Up @@ -1726,7 +1726,7 @@ subroutine intersectionTreeSearch(jj, inpBBox, &
BBoxB = xBBox(:, kk)

! Check bounding box intersection
! computeBBoxIntersection defined in Utilities.F90 of the utilities foldes
! computeBBoxIntersection defined in utilities.F90 of the utilities foldes
call computeBBoxIntersection(BBoxA, BBoxB, BBoxAB, overlap)

if (overlap) then
Expand All @@ -1752,7 +1752,7 @@ subroutine intersectionTreeSearch(jj, inpBBox, &
BBoxB(4:6) = ADTree(kk)%xMax(4:6)

! Check bounding box intersection
! computeBBoxIntersection defined in Utilities.F90 of the utilities foldes
! computeBBoxIntersection defined in utilities.F90 of the utilities foldes
call computeBBoxIntersection(BBoxA, BBoxB, BBoxAB, overlap)

if (overlap) then
Expand Down
2 changes: 1 addition & 1 deletion src/ADT/adtProjections.F90
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ subroutine dotProd(a, b, c)

! This subroutine simply computes a dot product c = a.dot.b
! This function is redundant with the one defined in
! Utilities.F90, but I decided to do it in order to
! utilities.F90, but I decided to do it in order to
! keep ADT independent of other pySurf modules.
!
! Ney Secco 2016-10
Expand Down
5 changes: 2 additions & 3 deletions src/ADT/adtSearch.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2493,10 +2493,9 @@ subroutine search(nCoor, coor, procID, &

! Complete the nonblocking sends of the interpolated data.

nProcRecvCur = 2 * nProcRecvCur
do i = 1, nProcRecvCur
call mpi_waitany(nProcRecvCur, sendRecvRequest, sizeMessage, &
status, ierr)
call mpi_waitany(nProcRecvCur, sendRecvRequest(1, :), sizeMessage, status, ierr)
call mpi_waitany(nProcRecvCur, sendRecvRequest(2, :), sizeMessage, status, ierr)
end do

! Release the memory of the buffers used in the nonblocking
Expand Down
6 changes: 3 additions & 3 deletions src/CGNSInterface/cgnsAPI.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module CGNSapi
real(kind=realType), dimension(:, :), allocatable, save :: coor
integer(kind=intType), dimension(:, :), allocatable, save :: triaConn, quadsConn, barsConn
integer(kind=intType), dimension(:), allocatable, save :: surfTriaPtr, surfQuadsPtr, curveBarsPtr
character*32, dimension(:), allocatable, save :: surfNames, curveNames
character(len=32), dimension(:), allocatable, save :: surfNames, curveNames

! coor: real(3,numNodes) -> X,Y,Z coordinates of all nodes
! triaConn: real(3,numTria) -> Triangles connectivity
Expand Down Expand Up @@ -143,8 +143,8 @@ subroutine retrieveData(numCoor, numTriaConn, numQuadsConn, numBarsConn, &
integer(kind=intType), intent(out), dimension(numSurfTriaPtr) :: surfTriaPtrData
integer(kind=intType), intent(out), dimension(numSurfQuadsPtr) :: surfQuadsPtrData
integer(kind=intType), intent(out), dimension(numCurveBarsPtr) :: curveBarsPtrData
character*32, intent(out), dimension(numSurfNames) :: surfNamesData
character*32, intent(out), dimension(numCurveNames) :: curveNamesData
character(len=32), intent(out), dimension(numSurfNames) :: surfNamesData
character(len=32), intent(out), dimension(numCurveNames) :: curveNamesData

! EXECUTION

Expand Down
8 changes: 4 additions & 4 deletions src/CGNSInterface/cgnsInterface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ subroutine readCGNSmain(cgns_file, comm, coor, triaConn, quadsConn, barsConn, &
real(kind=realType), intent(out), dimension(:, :), allocatable :: coor
integer(kind=intType), intent(out), dimension(:, :), allocatable :: triaConn, quadsConn, barsConn
integer(kind=intType), intent(out), dimension(:), allocatable :: surfTriaPtr, surfQuadsPtr, curveBarsPtr
character*32, intent(out), dimension(:), allocatable :: surfNames, curveNames
character(len=32), intent(out), dimension(:), allocatable :: surfNames, curveNames

! Working
integer(kind=intType) :: cg, ierr, i, myid
Expand All @@ -46,7 +46,7 @@ subroutine readCGNSmain(cgns_file, comm, coor, triaConn, quadsConn, barsConn, &
integer(kind=intType) :: iSurf, iCurve
integer(kind=intType) :: nSurfSectionsTot, nCurveSectionsTot

character*32 :: baseName, secName
character(len=32) :: baseName, secName

print *, '======================'
print *, cgns_file
Expand Down Expand Up @@ -289,8 +289,8 @@ subroutine readUnstructuredCGNS(cg, allNodes)
integer(kind=intType) :: ierr, base, dims(3), iZone
integer(kind=intType) :: nNodes, nCells
integer(kind=intType) :: tmpSym, nSymm
character*32 :: zoneName, bocoName, famName
character*32 :: secName
character(len=32) :: zoneName, bocoName, famName
character(len=32) :: secName

integer(kind=intType) :: nbocos, boco
integer(kind=intType) :: nVertices, nElements, nzones
Expand Down
8 changes: 4 additions & 4 deletions src/adjoint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ FF90_OBJECTS_1 = adBuffer.o \

FF90_OBJECTS_2 = intersection_b.o \
intersection_d.o \
adtprojections_b.o \
adtprojections_d.o \
curveutils_d.o \
curveutils_b.o
adtProjections_b.o \
adtProjections_d.o \
curveUtils_d.o \
curveUtils_b.o

default: all

Expand Down
9 changes: 4 additions & 5 deletions src/adjoint/Makefile_tapenade
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
INPUT_FILES = \
../common/precision.F90 \
../common/constants.F90 \
../intersections/Intersection.F90 \
../utilities/Utilities.F90 \
../intersections/intersection.F90 \
../utilities/utilities.F90 \
../curveSearch/curveUtils.F90 \
../ADT/adtProjections.F90 \

Expand All @@ -28,14 +28,13 @@ default:
done

# Generate forward mode
tapenade -d -head $(ROUTINES) $(INPUT_FILES_NODIR)
tapenade -d -tgtmodulename "_d" -head $(ROUTINES) $(INPUT_FILES_NODIR)

# Generate backward mode
tapenade -b -head $(ROUTINES) $(INPUT_FILES_NODIR)
tapenade -b -adjmodulename "_b" -head $(ROUTINES) $(INPUT_FILES_NODIR)

# Remove modules that are not useful, but were differentiated anyway
rm precision_*
rm constants_*

# Edit AD code to use original modules that should not be differentiated
sed -i -e 's/PRECISION_D/PRECISION/' -e 's/CONSTANTS_D/CONSTANTS/' *_d.f90
Expand Down
Loading