From d1237c000f83cb06bb45e0e5bc7113404b2e61a7 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Thu, 16 Dec 2021 11:08:32 +0100
Subject: [PATCH] Philippe 16/12/2021: Cray: add OPENACC targets for
 compilation + improve Rules

---
 src/Rules.LXcray.mk | 73 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 56 insertions(+), 17 deletions(-)

diff --git a/src/Rules.LXcray.mk b/src/Rules.LXcray.mk
index e19e4a4b6..29c16bde8 100644
--- a/src/Rules.LXcray.mk
+++ b/src/Rules.LXcray.mk
@@ -9,24 +9,35 @@
 ##########################################################
 #OBJDIR_PATH=/home/escj/azertyuiopqsdfghjklm/wxcvbn/azertyuiopqsdfghjklmwxcvbn
 #
-#OPT_BASE   =  -r8 -g -w -assume nosource_include -assume byterecl -fpe0 -ftz -fpic -traceback  -fp-model precise -switch fe_inline_all_arg_copy_inout
-OPT_BASE   =  -sreal64 -hpic -em -ef
+OPT_BASE   =  -hpic -em -ef
 OPT_PERF0  =  -O0 -g
-OPT_PERF2  =  -O2 -hflex_mp=intolerant -Ofp0 -hnoomp
 OPT_PERF1  =  -O1 -hflex_mp=intolerant -Ofp0 -hnoomp -hcpu=istanbul -hfp0 -K trap=fp
-# –hcpu=Istanbul –hfp0
-#OPT_CHECK  =  -CB -ftrapuv 
+OPT_PERF2  =  -O2 -hflex_mp=intolerant -Ofp0 -hnoomp
+#
+OPT_NOOPENACC     = -hnoacc
+OPT_OPENACC       = -hacc
+#
 OPT_CHECK  =  -Rbc
-OPT_I8     =  -sdefault64
+OPT_I8     =  -sinteger64
+OPT_R8     =  -sreal64
 #
-# Integer 4/8 option
+ifeq "$(VER_USER)" "ZSOLVER"
+CPPFLAGS  += -DCARTESIANGEOMETRY -DOVERLAPCOMMS -DPIECEWISELINEAR
+PROG_LIST += MG_MAIN MG_MAIN_MNH_ALL
+endif
 #
+# Real/integer 4/8 option
+#
+MNH_REAL  ?=8
 MNH_INT   ?=4
 #
+ifneq "$(MNH_REAL)" "4"
+OPT_BASE           += $(OPT_R8)
+endif
+#
 OPT_BASE_I4       := $(OPT_BASE)
 ifeq "$(MNH_INT)" "8"
-#OPT_BASE         += $(OPT_I8)
-OPT_BASE           = -sdefault64 -hpic -em -ef
+OPT_BASE          += $(OPT_I8)
 LFI_INT           ?=8
 else
 LFI_INT           ?=4
@@ -42,17 +53,48 @@ OPT0      = $(OPT_BASE) $(OPT_PERF0) $(OPT_CHECK)
 OPT_NOCB  = $(OPT_BASE) $(OPT_PERF0)
 CFLAGS   += -g
 endif
-ifeq "$(OPTLEVEL)" "O2PAR"
-PAR= -homp
-OPT       = $(OPT_BASE) $(OPT_PERF2) $(PAR)
-OPT0      = $(OPT_BASE) $(OPT_PERF0) $(PAR)
-OPT_NOCB  = $(OPT_BASE) $(OPT_PERF2) $(PAR)
+#
+ifeq "$(OPTLEVEL)" "OPENACC"
+CPPFLAGS    += -DMNH_OPENACC
+OPT       = $(OPT_BASE) $(OPT_OPENACC) $(OPT_PERF2)
+OPT0      = $(OPT_BASE) $(OPT_OPENACC) $(OPT_PERF0)
+OPT_NOCB  = $(OPT_BASE) $(OPT_OPENACC) $(OPT_PERF2)
+#CXXFLAGS = -acc -Kieee -Mnofma $(OPT_OPENACC)
+#OBJS_REPROD= spll_mode_sum_ll.o
+#$(OBJS_REPROD) : OPT = $(OPT_BASE) $(OPT_OPENACC) $(OPT_PERF2) -Mvect=nosimd -Minfo=all -g
+#OBJS_O1_OPENACC= spll_ice4_tendencies.o spll_turb_ver_thermo_flux.o
+#$(OBJS_O1_OPENACC) : OPT = $(OPT_BASE) $(OPT_OPENACC) $(OPT_PERF1)
 endif
+#
+ifeq "$(OPTLEVEL)" "OPENACCDEFONLY"
+CPPFLAGS    += -DMNH_OPENACC -D_FAKEOPENACC
+OPT       = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2)
+OPT0      = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF0)
+OPT_NOCB  = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2)
+#CXXFLAGS = -Kieee -Mnofma $(OPT_NOOPENACC)
+#OBJS_REPROD= spll_mode_sum_ll.o
+#$(OBJS_REPROD) : OPT = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2) -Mvect=nosimd -Minfo=all -g
+endif
+#
+ifeq "$(OPTLEVEL)" "NOOPENACC"
+OPT       = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2)
+OPT0      = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF0)
+OPT_NOCB  = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2)
+#CXXFLAGS = -Kieee -Mnofma $(OPT_NOOPENACC)
+#OBJS_REPROD= spll_mode_sum_ll.o
+#$(OBJS_REPROD) : OPT = $(OPT_BASE) $(OPT_NOOPENACC) $(OPT_PERF2) -Mvect=nosimd -Minfo=all -g
+endif
+#
 ifeq "$(OPTLEVEL)" "O2NOVEC"
 OPT       = $(OPT_BASE) $(OPT_PERF2) -O vector0
 OPT0      = $(OPT_BASE) $(OPT_PERF0) -O vector0
 OPT_NOCB  = $(OPT_BASE) $(OPT_PERF2) -O vector0
 endif
+ifeq "$(OPTLEVEL)" "O2"
+OPT       = $(OPT_BASE) $(OPT_PERF2)
+OPT0      = $(OPT_BASE) $(OPT_PERF0)
+OPT_NOCB  = $(OPT_BASE) $(OPT_PERF2)
+endif
 ifeq "$(OPTLEVEL)" "O1"
 OPT       = $(OPT_BASE) $(OPT_PERF1) 
 OPT0      = $(OPT_BASE) $(OPT_PERF0) 
@@ -157,6 +199,3 @@ OBJS_I4=spll_modd_netcdf.o
 $(OBJS_I4) : OPT = $(OPT_BASE_I4)
 endif
 
-#mpi.mod : 
-#	ln -sf /opt/cray/mpt/5.6.3/gni/mpich2-cray/74/include/MPI.mod $(OBJDIR_MASTER)/mpi.mod
-
-- 
GitLab