Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Addition of a shared filter infrastructure #522

Closed
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ endif
RM = rm -f
CPP = cpp -P -traditional
RANLIB = ranlib
PRE_CORE_TARGETS=

ifdef CORE

Expand Down Expand Up @@ -581,6 +582,7 @@ endif
CORE="$(CORE)"\
AUTOCLEAN="$(AUTOCLEAN)" \
GEN_F90="$(GEN_F90)" \
PRE_CORE_TARGETS="$(PRE_CORE_TARGETS)" \
NAMELIST_SUFFIX="$(NAMELIST_SUFFIX)" \
EXE_NAME="$(EXE_NAME)"

Expand Down
11 changes: 8 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ ops: $(AUTOCLEAN_DEPS) externals frame
( cd operators; $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" all )
ln -sf operators/libops.a libops.a

dycore: $(AUTOCLEAN_DEPS) build_tools externals frame ops
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" REG_PARSE="$(PWD)/tools/registry/parse" gen_includes )
filters: $(AUTOCLEAN_DEPS) externals frame ops
( cd filters; $(MAKE) CPPFLGAS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" all)
ln -sf filters/libfilters.a libfilters.a

dycore: $(AUTOCLEAN_DEPS) build_tools externals frame ops $(PRE_CORE_TARGETS)
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" REG_PATH="$(PWD)/tools/registry/" REG_PARSE="parse" FILTER_PARSE="filter-parse" gen_includes )
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" NL_GEN="$(PWD)/tools/input_gen/namelist_gen" ST_GEN="$(PWD)/tools/input_gen/streams_gen" core_input_gen )
( cd core_$(CORE); $(MAKE) CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" all )
ln -sf core_$(CORE)/libdycore.a libdycore.a
Expand All @@ -58,9 +62,10 @@ ifeq "$(AUTOCLEAN)" "true"
@echo "*********************************************************************************************"
@echo ""
endif
$(RM) libframework.a libops.a libdycore.a lib$(CORE).a *.o
$(RM) libframework.a libops.a libdycore.a libfilters.a lib$(CORE).a *.o
( cd tools; $(MAKE) clean )
( cd external; $(MAKE) clean )
( cd filters; $(MAKE) clean )
( cd framework; $(MAKE) clean )
( cd operators; $(MAKE) clean )
( cd driver; $(MAKE) clean )
9 changes: 7 additions & 2 deletions src/Makefile.in.ACME
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include $(CASEROOT)/Macros

PRE_CORE_TARGETS =

ifneq ($(wildcard core_$(CORE)/build_options.mk), ) # Check for build_options.mk
include core_$(CORE)/build_options.mk
else # ELSE Use Default Options
Expand All @@ -22,6 +24,8 @@ else
ESMFDIR = noesmf
endif

override PRE_CORE_TARGETS += filters

RM = rm -f
CPP = cpp -P -traditional
FC=$(MPIFC)
Expand Down Expand Up @@ -53,12 +57,13 @@ all:
( $(MAKE) mpas RM="$(RM)" CPP="$(CPP)" NETCDF="$(NETCDF)" PNETCDF="$(PNETCDF)" \
PIO="$(PIO)" FC="$(FC)" CC="$(CC)" SFC="$(SFC)" SCC="$(SCC)" \
CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" FCINCLUDES="$(FCINCLUDES)" \
FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" )
FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" PRE_CORE_TARGETS="$(PRE_CORE_TARGETS)" )

mpas: externals frame ops dycore drver
mpas: externals frame ops dycore drver $(PRE_CORE_TARGETS)
ar ru lib$(COMPONENT).a framework/*.o
ar ru lib$(COMPONENT).a operators/*.o
ar ru lib$(COMPONENT).a external/ezxml/*.o
ar ru lib$(COMPONENT).a filters/*.o
ar ru lib$(COMPONENT).a `find core_$(CORE)/ -type f -name "*.o"` # Find command finds objects in any subdirectories
ar ru lib$(COMPONENT).a $(DRIVER)/*.o

Expand Down
9 changes: 7 additions & 2 deletions src/Makefile.in.CESM
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include $(CASEROOT)/Macros

PRE_CORE_TARGETS =

ifneq ($(wildcard core_$(CORE)/build_options.mk), ) # Check for build_options.mk
include core_$(CORE)/build_options.mk
else # ELSE Use Default Options
Expand All @@ -22,6 +24,8 @@ else
ESMFDIR = noesmf
endif

override PRE_CORE_TARGETS += filters

RM = rm -f
CPP = cpp -P -traditional
FC=$(MPIFC)
Expand Down Expand Up @@ -53,12 +57,13 @@ all:
( $(MAKE) mpas RM="$(RM)" CPP="$(CPP)" NETCDF="$(NETCDF)" PNETCDF="$(PNETCDF)" \
PIO="$(PIO)" FC="$(FC)" CC="$(CC)" SFC="$(SFC)" SCC="$(SCC)" \
CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)" FCINCLUDES="$(FCINCLUDES)" \
FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" )
FFLAGS="$(FFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" PRE_CORE_TARGETS="$(PRE_CORE_TARGETS)" )

mpas: externals frame ops dycore drver
mpas: externals frame ops dycore drver $(PRE_CORE_TARGETS)
ar ru lib$(COMPONENT).a framework/*.o
ar ru lib$(COMPONENT).a operators/*.o
ar ru lib$(COMPONENT).a external/ezxml/*.o
ar ru lib$(COMPONENT).a filters/*.o
ar ru lib$(COMPONENT).a `find core_$(CORE)/ -type f -name "*.o"` # Find command finds objects in any subdirectories
ar ru lib$(COMPONENT).a $(DRIVER)/*.o

Expand Down
2 changes: 1 addition & 1 deletion src/core_atmosphere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand Down
2 changes: 1 addition & 1 deletion src/core_init_atmosphere/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand Down
2 changes: 1 addition & 1 deletion src/core_landice/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand Down
2 changes: 1 addition & 1 deletion src/core_ocean/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand Down
2 changes: 1 addition & 1 deletion src/core_sw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand Down
7 changes: 4 additions & 3 deletions src/core_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ core_input_gen:
gen_includes:
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) Registry.xml > Registry_processed.xml
(if [ ! -d inc ]; then mkdir -p inc; fi) # To generate *.inc files
(cd inc; $(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(REG_PARSE) < ../Registry_processed.xml )
(cd inc; $(REG_PATH)/$(FILTER_PARSE) < ../Registry_processed.xml )

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Expand All @@ -41,7 +42,7 @@ clean:
$(RM) $@ $*.mod
ifeq "$(GEN_F90)" "true"
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) $< > $*.f90
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators -I../external/esmf_time_f90
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators -I../filters -I../external/esmf_time_f90
else
$(FC) $(CPPFLAGS) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I../framework -I../operators -I../external/esmf_time_f90
$(FC) $(CPPFLAGS) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I../framework -I../operators -I../filters -I../external/esmf_time_f90
endif
18 changes: 18 additions & 0 deletions src/core_test/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,22 @@
<var name="cellsOnVertex" type="integer" dimensions="vertexDegree nVertices"/>
<var name="kiteAreasOnVertex" type="real" dimensions="vertexDegree nVertices"/>
</var_struct>
<filters>
<filter name="testComputeInterval1" module_name="mpas_filter_test_compute_interval"/>
<filter name="testComputeInterval2" module_name="mpas_filter_test_compute_interval"/>
</filters>
<nml_record name="testComputeInterval1">
<nml_option name="config_testComputeInterval1_enable" type="logical" default_value=".false."/>
<nml_option name="config_testComputeInterval1_compute_interval" type="character" default_value="dt"/>
<nml_option name="config_testComputeInterval1_stream_name" type="character" default_value="none"/>
<nml_option name="config_testComputeInterval1_compute_on_startup" type="logical" default_value=".false."/>
<nml_option name="config_testComputeInterval1_write_on_startup" type="logical" default_value=".false."/>
</nml_record>
<nml_record name="testComputeInterval2">
<nml_option name="config_testComputeInterval2_enable" type="logical" default_value=".false."/>
<nml_option name="config_testComputeInterval2_compute_interval" type="character" default_value="0000_00:05:00"/>
<nml_option name="config_testComputeInterval2_stream_name" type="character" default_value="none"/>
<nml_option name="config_testComputeInterval2_compute_on_startup" type="logical" default_value=".false."/>
<nml_option name="config_testComputeInterval2_write_on_startup" type="logical" default_value=".false."/>
</nml_record>
</registry>
6 changes: 6 additions & 0 deletions src/core_test/build_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ EXE_NAME=test_model
NAMELIST_SUFFIX=test
override CPPFLAGS += -DCORE_TEST

ifneq ( , $(findstring filters, $(PRE_CORE_TARGETS) ) )
override PRE_CORE_TARGETS += filters
FCINCLUDES += -I$(PWD)/src/filters
LIBS += -lfilters
endif

report_builds:
@echo "CORE=test"
11 changes: 10 additions & 1 deletion src/core_test/mpas_test_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module test_core

use mpas_framework
use mpas_timekeeping
use mpas_stream_manager
use mpas_filter_driver

type (MPAS_Clock_type), pointer :: clock

Expand Down Expand Up @@ -53,6 +55,8 @@ function test_core_init(domain, startTimeStamp) result(iErr)!{{{
startTime = mpas_get_clock_time(clock, MPAS_START_TIME, iErr)
call mpas_get_time(startTime, dateTimeString=startTimeStamp)

call mpas_filter_driver_init(domain % core % filters, domain, iErr=iErr)

end function test_core_init!}}}


Expand Down Expand Up @@ -85,12 +89,15 @@ function test_core_run(domain) result(iErr)!{{{
type (mpas_pool_type), pointer :: pool
type (mpas_pool_iterator_type) :: itr


iErr = 0

call mpas_unit_test_fix_periodicity(iErr)
call mpas_unit_test_triangle_signed_area_sphere(iErr)

call mpas_filter_driver_compute(domain % core % filters, domain, iErr = iErr)

call mpas_stream_mgr_write(domain % streamManager, iErr = iErr)

end function test_core_run!}}}

!***********************************************************************
Expand Down Expand Up @@ -118,6 +125,8 @@ function test_core_finalize(domain) result(iErr)!{{{

iErr = 0

call mpas_filter_driver_finalize(domain % core % filters, domain, iErr=iErr)

call mpas_destroy_clock(clock, iErr)

end function test_core_finalize!}}}
Expand Down
3 changes: 3 additions & 0 deletions src/core_test/mpas_test_core_interface.F
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ subroutine test_setup_core(core)!{{{
core % setup_decomposed_dimensions => test_setup_decomposed_dimensions
core % setup_block => test_setup_block
core % setup_namelist => test_setup_namelists
core % setup_filter_list => test_setup_filters

core % Conventions = 'MPAS'
core % source = 'MPAS'
Expand Down Expand Up @@ -272,5 +273,7 @@ end function test_setup_block!}}}

#include "inc/namelist_defines.inc"

#include "inc/filter_function.inc"

end module test_core_interface

16 changes: 16 additions & 0 deletions src/driver/mpas_subdriver.F
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ subroutine mpas_init()
use mpas_c_interfacing, only : mpas_f_to_c_string, mpas_c_to_f_string
use mpas_timekeeping, only : mpas_get_clock_time, mpas_get_time
use mpas_bootstrapping, only : mpas_bootstrap_framework_phase1, mpas_bootstrap_framework_phase2
use mpas_filter_list, only : mpas_filter_list_create_list

implicit none

Expand Down Expand Up @@ -146,6 +147,10 @@ end subroutine xml_stream_get_attributes
domain_ptr => corelist % domainlist
domain_ptr % core => corelist

allocate(corelist % filters)
call mpas_filter_list_create_list(corelist % filters)
call mpas_pool_create_pool(corelist % filterLists)

call mpas_allocate_domain(domain_ptr)

!
Expand Down Expand Up @@ -182,6 +187,13 @@ end subroutine xml_stream_get_attributes
call test_setup_domain(domain_ptr)
#endif

if ( associated(corelist % setup_filter_list) ) then
iErr = corelist % setup_filter_list(corelist % filters, corelist % filterLists)
if ( iErr /= 0 ) then
call mpas_dmpar_global_abort('ERROR: Filter setup failed for core ' // trim(corelist % coreName))
end if
end if

if ( readNamelistArg ) then
domain_ptr % namelist_filename = namelistFile
end if
Expand Down Expand Up @@ -330,6 +342,7 @@ end subroutine mpas_run
subroutine mpas_finalize()

use mpas_stream_manager, only : MPAS_stream_mgr_finalize
use mpas_filter_list, only : mpas_filter_list_destroy_list

implicit none

Expand All @@ -355,7 +368,10 @@ subroutine mpas_finalize()

call mpas_framework_finalize(domain_ptr % dminfo, domain_ptr)

call mpas_filter_list_destroy_list(corelist % filters)

deallocate(corelist % domainlist)
deallocate(corelist % filters)
deallocate(corelist)

end subroutine mpas_finalize
Expand Down
26 changes: 26 additions & 0 deletions src/filters/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.SUFFIXES: .F .c .o

FILTER_OBJS = mpas_filter_test_compute_interval.o

all: filters

filters: mpas_filter_driver.o $(FILTER_OBJS)
ar -ru libfilters.a mpas_filter_driver.o $(FILTER_OBJS)

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

.F.o:
$(RM) $@ $*.mod
ifeq "$(GEN_F90)" "true"
$(CPP) $(CPPFLAGS) $(CPPINCLUDES) $< > $*.f90
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I../framework -I../operators
else
$(FC) $(CPPFLAGS) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I../framework -I../operators
endif

.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) $(CPPINCLUDES) -I../framework -I../operators -c $<
Loading