Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,21 @@ CPPINCLUDES =
FCINCLUDES =
LIBS =

NUOPC ?= false
MPAS_NUOPC_PREFIX ?= $(CURDIR)
MPAS_NUOPC_LIBDIR ?= $(MPAS_NUOPC_PREFIX)/lib
MPAS_NUOPC_MODDIR ?= $(MPAS_NUOPC_PREFIX)/mod
ifneq ($(filter on ON 1 TRUE,$(NUOPC)),)
override NUOPC := true
endif
ifeq ($(NUOPC), true)
MPAS_ESMF = external
override CPPFLAGS += -DMPAS_NO_ESMF_INIT
NUOPC_MESSAGE="MPAS was built with NUOPC cap libraries."
else
NUOPC_MESSAGE="MPAS was built without NUOPC cap libraries."
endif

export MPAS_ESMF ?= embedded
ifeq "$(MPAS_ESMF)" "external"
ifeq ($(wildcard $(ESMFMKFILE)), )
Expand Down Expand Up @@ -806,6 +821,7 @@ ifneq "$(LAPACK)" ""
endif

RM = rm -f
RMDIR = rmdir
CPP = cpp -P -traditional
RANLIB = ranlib

Expand Down Expand Up @@ -1537,6 +1553,10 @@ SCOTCH_MESSAGE = "MPAS was NOT linked with the Scotch graph partitioning library
endif

mpas_main: $(MAIN_DEPS)
ifeq "$(NUOPC)" "true"
if [ ! -d $(MPAS_NUOPC_LIBDIR) ]; then mkdir -p $(MPAS_NUOPC_LIBDIR); fi
if [ ! -d $(MPAS_NUOPC_MODDIR) ]; then mkdir -p $(MPAS_NUOPC_MODDIR); fi
endif
cd src; $(MAKE) FC="$(FC)" \
CC="$(CC)" \
CXX="$(CXX)" \
Expand All @@ -1558,7 +1578,11 @@ mpas_main: $(MAIN_DEPS)
AUTOCLEAN_DEPS="$(AUTOCLEAN_DEPS)" \
GEN_F90="$(GEN_F90)" \
NAMELIST_SUFFIX="$(NAMELIST_SUFFIX)" \
EXE_NAME="$(EXE_NAME)"
EXE_NAME="$(EXE_NAME)" \
MPAS_NUOPC_PREFIX="$(MPAS_NUOPC_PREFIX)" \
MPAS_NUOPC_LIBDIR="$(MPAS_NUOPC_LIBDIR)" \
MPAS_NUOPC_MODDIR="$(MPAS_NUOPC_MODDIR)" \
NUOPC="$(NUOPC)"

if [ -e src/$(EXE_NAME) ]; then mv src/$(EXE_NAME) .; fi
( cd src/core_$(CORE); $(MAKE) ROOT_DIR="$(PWD)" post_build )
Expand All @@ -1582,14 +1606,24 @@ endif
@echo $(TIMER_MESSAGE)
@echo $(IO_MESSAGE)
@echo $(ESMF_MESSAGE)
@echo $(NUOPC_MESSAGE)
@echo "*******************************************************************************"
clean:
cd src; $(MAKE) clean RM="$(RM)" CORE="$(CORE)" AUTOCLEAN="$(AUTOCLEAN)"
cd src; $(MAKE) clean RM="$(RM)" CORE="$(CORE)" AUTOCLEAN="$(AUTOCLEAN)" \
MPAS_NUOPC_PREFIX="$(MPAS_NUOPC_PREFIX)" \
MPAS_NUOPC_LIBDIR="$(MPAS_NUOPC_LIBDIR)" \
MPAS_NUOPC_MODDIR="$(MPAS_NUOPC_MODDIR)" \
NUOPC="$(NUOPC)"
$(RM) $(EXE_NAME)
$(RM) namelist.$(NAMELIST_SUFFIX).defaults
$(RM) streams.$(NAMELIST_SUFFIX).defaults
if [ -f .build_opts.framework ]; then $(RM) .build_opts.framework; fi
if [ -f .build_opts.$(CORE) ]; then $(RM) .build_opts.$(CORE); fi
ifeq "$(NUOPC)" "true"
@# uninstall the NUOPC library and module directories
if [ -d "$(MPAS_NUOPC_LIBDIR)" ]; then $(RMDIR) "$(MPAS_NUOPC_LIBDIR)" || true; fi
if [ -d "$(MPAS_NUOPC_MODDIR)" ]; then $(RMDIR) "$(MPAS_NUOPC_MODDIR)" || true; fi
endif

core_error:
@echo ""
Expand Down Expand Up @@ -1641,6 +1675,7 @@ errmsg:
@echo " MPAS_ESMF=opt - Selects the ESMF library to be used for MPAS. Options are:"
@echo " MPAS_ESMF=embedded - Use the embedded ESMF timekeeping library (default)"
@echo " MPAS_ESMF=external - Use an external ESMF library, determined by ESMFMKFILE"
@echo " NUOPC=true - builds NUOPC library (libmpas_nuopc.a) and installs to lib/ with mod files to mod/. Default is false."
@echo ""
@echo "Ensure that NETCDF, PNETCDF, PIO, and PAPI (if USE_PAPI=true) are environment variables"
@echo "that point to the absolute paths for the libraries."
Expand Down
39 changes: 37 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ include Makefile.in.$(ESM)

else

all: mpas
BUILD_ALL = mpas
ifeq "$(NUOPC)" "true"
BUILD_ALL = nuopc_lib
endif

all: $(BUILD_ALL)

mpas: $(AUTOCLEAN_DEPS) externals frame ops dycore drver
$(LINKER) $(LDFLAGS) -o $(EXE_NAME) driver/*.o -L. -ldycore -lops -lframework $(LIBS) $(MPAS_ESMF_INC) $(MPAS_ESMF_LIB)
Expand Down Expand Up @@ -35,8 +40,29 @@ dycore: $(AUTOCLEAN_DEPS) build_tools externals frame ops
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" all )
ln -sf core_$(CORE)/libdycore.a libdycore.a

nuopc_lib: $(AUTOCLEAN_DEPS) externals frame ops dycore drver
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" FFLAGS="$(FFLAGS)" FCINCLUDES="$(FCINCLUDES)" nuopc )
ar rcs $(MPAS_NUOPC_LIBDIR)/libmpas_nuopc.a \
core_$(CORE)/nuopc/*.o \
core_$(CORE)/libphys/*.o \
core_$(CORE)/*.o \
core_$(CORE)/diagnostics/*.o \
core_$(CORE)/libchem/*.o \
core_$(CORE)/dynamics/*.o \
driver/*.o \
framework/*.o \
operators/*.o \
external/ezxml/*.o \
external/SMIOL/*.o
ranlib $(MPAS_NUOPC_LIBDIR)/libmpas_nuopc.a
cp core_$(CORE)/nuopc/mpas_nuopc_*.mod $(MPAS_NUOPC_MODDIR)/.

clean: clean_shared clean_core
CLEAN_ALL = clean_shared clean_core
ifeq "$(NUOPC)" "true"
CLEAN_ALL += clean_nuopc
endif

clean: $(CLEAN_ALL)

clean_core:
ifeq "$(AUTOCLEAN)" "true"
Expand Down Expand Up @@ -64,3 +90,12 @@ endif
( cd framework; $(MAKE) clean )
( cd operators; $(MAKE) clean )
( cd driver; $(MAKE) clean )

clean_nuopc:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgduda
What are your thoughts on cleaning the MPAS_NUOPC_LIBDIR and MPAS_NUOPC_MODDIR? I wanted the ability to install it in user defined directories but cleaning it from user defined directories can be unsafe. Say the MPAS_NUOPC_PREFIX is /usr, MPAS_NUOPC_LIBDIR is /lib, and MPAS_NUOPC_MODDIR is /include. Should I remove the clean functionality or do something different? Do we want to be able to delete the <MPAS_DIR>/lib and <MPAS_DIR>/mod directories when cleaning?

$(info )
$(info *********************************************************************************************)
$(info The NUOPC library will be cleaned.)
$(info *********************************************************************************************)
$(info )
$(RM) $(MPAS_NUOPC_LIBDIR)/libmpas_nuopc.a
$(RM) $(MPAS_NUOPC_MODDIR)/mpas_nuopc_*.mod
4 changes: 4 additions & 0 deletions src/core_atmosphere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ utilities: $(PHYSCORE)
atmcore: $(PHYSCORE) dycore diagcore $(OBJS)
ar -ru libdycore.a $(OBJS) dynamics/*.o $(PHYS_OBJS) $(CHEM_OBJS) diagnostics/*.o

nuopc: $(PHYSCORE) dycore diagcore $(OBJS)
( cd nuopc; $(MAKE) all )

mpas_atm_core_interface.o: mpas_atm_core.o

mpas_atm_core.o: dycore diagcore mpas_atm_threading.o mpas_atm_halos.o
Expand All @@ -81,6 +84,7 @@ clean:
( cd dynamics; $(MAKE) clean )
( cd diagnostics; $(MAKE) clean )
( cd utils; $(MAKE) clean )
( cd nuopc; $(MAKE) clean )
( cd ../..; rm -f *TBL )
( cd ../..; rm -f *DATA* )
$(RM) -r libphys
Expand Down
16 changes: 16 additions & 0 deletions src/core_atmosphere/nuopc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.SUFFIXES: .F90 .o

OBJS = mpas_nuopc_atm.o

all: $(OBJS)

clean:
$(RM) *.o *.mod
@# Certain systems with intel compilers generate *.i files
@# This removes them during the clean process
$(RM) *.i

%.o: %.F90
$(RM) $@ $*.mod
$(FC) $(CPPFLAGS) $(PHYSICS) $(FFLAGS) -c $< -o $@ $(CPPINCLUDES) $(FCINCLUDES) $(MPAS_ESMF_INC)

Loading