Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${debug_flags}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${release_flags}")

# Sources to compile - everything except those matching the regex
file(GLOB_RECURSE sources src/*.f90 vendor/*.f90)
file(GLOB_RECURSIVE sources
src/*.f90
src/Data/*.f90
src/Contaminant/*.f90
vendor/*.f90
)
list(FILTER sources EXCLUDE REGEX ".*vendor/feh/example/.*f90$")
list(FILTER sources EXCLUDE REGEX ".*vendor/feh/tests/.*f90$")
list(FILTER sources EXCLUDE REGEX ".*vendor/datetime-fortran/tests/.*f90$")
Expand All @@ -47,4 +52,4 @@ file(WRITE "src/VersionModule.f90" ${version_file_new})
# Compile to executable and link to NetCDF
add_executable(nanofase ${sources})
target_include_directories(nanofase PUBLIC "${NETCDF_INCLUDES}")
target_link_libraries(nanofase PRIVATE "${NETCDF_LIBRARIES_F90}")
target_link_libraries(nanofase PRIVATE "${NETCDF_LIBRARIES_F90}")
134 changes: 68 additions & 66 deletions Makefile.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,90 +32,92 @@ COMP_META = $(COMPILE_TIME) $(GIT_HASH) $(GIT_RELEASE)
AUTOPARALLEL = 0
N_THREADS = 4
ifeq ($(AUTOPARALLEL), 1)
COMMON_FLAGS += -floop-parallelize-all -ftree-parallelize-loops=${N_THREADS}
COMMON_FLAGS += -floop-parallelize-all -ftree-parallelize-loops=${N_THREADS}
endif

# Objects to generate, in dependency order
OBJECTS_ = ErrorInstance.o \
Result.o \
ErrorHandler.o \
ErrorCriteria.o \
mo_types.o \
mo_netcdf.o \
datetime_module.o \
sparskit.o \
Spoof.o \
mod_strptime.o \
VersionModule.o \
DefaultsModule.o \
GlobalsModule.o \
UtilModule.o \
LoggerModule.o \
DataInputModule.o \
AbstractBiotaModule.o \
BiotaSoilModule.o \
BiotaWaterModule.o \
AbstractReactorModule.o \
ReactorModule.o \
FineSedimentModule.o \
AbstractBedSedimentLayerModule.o \
BedSedimentLayerModule.o \
AbstractBedSedimentModule.o \
BedSedimentModule.o \
DiffuseSourceModule.o \
PointSourceModule.o \
FlowModule.o \
WaterBodyModule.o \
ReachModule.o \
RiverReachModule.o \
EstuaryReachModule.o \
AbstractSoilLayerModule.o \
SoilLayerModule.o \
AbstractSoilProfileModule.o \
SoilProfileModule.o \
CropModule.o \
AbstractGridCellModule.o \
GridCellModule.o \
AbstractEnvironmentModule.o \
EnvironmentModule.o \
NetCDFOutputModule.o \
NetCDFAggregatedOutputModule.o \
DataOutputModule.o \
CheckpointModule.o \
main.o
Result.o \
ErrorHandler.o \
ErrorCriteria.o \
mo_types.o \
mo_netcdf.o \
datetime_module.o \
sparskit.o \
Spoof.o \
mod_strptime.o \
VersionModule.o \
DefaultsModule.o \
GlobalsModule.o \
UtilModule.o \
LoggerModule.o \
DataInputModule.o \
ContaminantModule.o \
FlowModule.o \
AbstractBiotaModule.o \
BiotaSoilModule.o \
BiotaWaterModule.o \
AbstractReactorModule.o \
ReactorModule.o \
FineSedimentModule.o \
AbstractBedSedimentLayerModule.o \
BedSedimentLayerModule.o \
AbstractBedSedimentModule.o \
BedSedimentModule.o \
DiffuseSourceModule.o \
PointSourceModule.o \
AbstractSoilLayerModule.o \
SoilLayerModule.o \
AbstractSoilProfileModule.o \
SoilProfileModule.o \
CropModule.o \
WaterBodyModule.o \
ReachModule.o \
RiverReachModule.o \
EstuaryReachModule.o \
AbstractGridCellModule.o \
GridCellModule.o \
AbstractEnvironmentModule.o \
EnvironmentModule.o \
NetCDFOutputModule.o \
NetCDFAggregatedOutputModule.o \
DataOutputModule.o \
CheckpointModule.o \
main.o

# Add the build dir to each object name
OBJECTS = $(addprefix build/, $(OBJECTS_))

# Where to look for the source files
VPATH = vendor/feh/src \
vendor/mo_netcdf/src \
vendor/datetime-fortran/src \
vendor/spoof/src \
src \
src/Data \
src/Logger \
src/Biota \
src/Reactor \
src/BedSedimentLayer \
src/BedSediment \
src/Source \
src/WaterBody \
src/Soil \
src/GridCell \
src/Environment
vendor/mo_netcdf/src \
vendor/datetime-fortran/src \
vendor/spoof/src \
src \
src/Data \
src/Logger \
src/Biota \
src/Reactor \
src/BedSedimentLayer \
src/BedSediment \
src/Source \
src/WaterBody \
src/Soil \
src/GridCell \
src/Environment \
src/Contaminant

# Write the model version (from git) to file
MODEL_VERSION := $(shell sed -i "s/\".*\"/\"${GIT_RELEASE}\"/g" src/VersionModule.f90)

$(EXEC_FILE): $(OBJECTS)
$(FC) $(FLAGS) -o $(BUILD_DIR)/$@ $^ $(NETCDF)
echo $(COMP_META) > $(BUILD_DIR)/comp_meta
$(FC) $(FLAGS) -o $(BUILD_DIR)/$@ $^ $(NETCDF)
echo $(COMP_META) > $(BUILD_DIR)/comp_meta
$(BUILD_DIR)/%.o: %.f90
$(FC) -c $< -o $@ -J$(BUILD_DIR) $(FLAGS) $(NETCDF)
$(FC) -c $< -o $@ -J$(BUILD_DIR) $(FLAGS) $(NETCDF)
release: FLAGS = ${RELEASE_FLAGS} ${COMMON_FLAGS}
release: $(EXEC_FILE)
fast: FLAGS = ${FAST_FLAGS} ${COMMON_FLAGS}
fast: $(EXEC_FILE)
clean:
rm -f $(BUILD_DIR)/*.mod $(BUILD_DIR)/*.o $(BUILD_DIR)/$(EXEC_FILE) $(BUILD_DIR)/comp_meta
rm -f $(BUILD_DIR)/*.mod $(BUILD_DIR)/*.o $(BUILD_DIR)/$(EXEC_FILE) $(BUILD_DIR)/comp_meta
132 changes: 61 additions & 71 deletions config.example/test-scenario.example.nml
Original file line number Diff line number Diff line change
@@ -1,104 +1,94 @@
!! NanoFASE model test scenario example config file
!! ------------------------------------------------
!! This file provideds a full list of config options that can be provided to
!! the NanoFASE model. When used as is (alongside the data stored at
!! data.example/test-scenario.nc), this runs the model for a 12-cell,
!! 10-timestep test scenario.
!! This file provides the main configuration options for the model run.

! One of the quirks of Fortran namelist files is that you can't saved implicitly sized
! arrays to variables in Fortran code without knowing their length. The way around this
! is to specify the array lengths as separate variables in a group read in before the
! arrays themselves. This is that group.
&allocatable_array_sizes
n_soil_layers = 3 ! Number of soil layers to model
n_sediment_layers = 4 ! Number of sediment layers to model
n_nm_size_classes = 5 ! Number of NM size classes
n_spm_size_classes = 5 ! Number of SPM size classes
n_fractional_compositions = 2 ! Number of fractional compositions for sediment
n_soil_layers = 3 ! Number of soil layers to model
n_sediment_layers = 4 ! Number of sediment layers to model
n_contaminant_size_classes = 5 ! Number of contaminant size classes
n_spm_size_classes = 5 ! Number of SPM size classes
n_fractional_compositions = 2 ! Number of fractional compositions for sediment
/

! Control the config options specific to the NMs
&nanomaterial
nm_size_classes = 10e-9, 30e-9, 100e-9, 300e-9, 1000e-9 ! Diameter of NM in each binned size class [m]
n_nm_forms = 1 ! Number of NM forms (core, shell, coating, corona etc)
n_nm_extra_states = 2 ! Number of extra NM states, other than heteroaggregated to SPM
/
&contaminant
n_contaminant_extra_states = 2 ! Number of extra contaminant states, other than heteroaggregated to SPM
n_contaminant_forms = 2 ! Number of contaminant forms (e.g., pristine, transformed)
/

! Paths to data. For info on compiling data for the NanoFASE model, see the nanofase-data repo: https://github.com/NERC-CEH/nanofase-data
&data
input_file = "data.example/test-scenario.nc" ! Path to NetCDF input data, which includes most of the spatial and temporally resolved data
constants_file = "data.example/constants_test-scenario.nml" ! Path to constants namelist file, which includes most of the non-spatiotemporal input data
output_path = "output/" ! Path to store the output data
input_file = "data.example/test-scenario.nc" ! Path to NetCDF input data
constants_file = "data.example/constants_test-scenario.nml" ! Path to constants namelist file
output_path = "output/" ! Path to store the output data
/

&output
write_csv = .true. ! Should we write output data to CSV files?
write_netcdf = .true. ! Should we write output data to a NetCDF file?
netcdf_write_mode = 'end' ! When should we write to the NetCDF file? Every time step ('itr') or at the end of the run ('end'). Every time step is slower, end uses much more memory
write_metadata_as_comment = .true. ! Should output data metadata (e.g. column descriptions) be included as comments at top of CSV files?
include_waterbody_breakdown = .false. ! For surface water and sediment output, include breakdown over waterbodies or aggregate at grid cell level?
include_sediment_layer_breakdown = .true. ! Include breakdown of data over sediment layers?
include_soil_layer_breakdown = .false. ! Include breaedown of data over soil layers?
include_soil_state_breakdown = .false. ! Include breakdown of NM state - free vs attached to soil matrix
soil_pec_units = 'kg/kg' ! What units to use for soil PEC - kg/kg or kg/m3? NOT CURRENTLY IN USE
sediment_pec_units = 'kg/kg' ! What units to use for sediment PEC - kg/kg or kg/m3? NOT CURRENTLY IN USE
include_soil_erosion_yields = .true. ! Should soil erosion yields be included in soil output?
include_sediment_fluxes = .true. ! Should sediment fluxes to/from waterbodies be included?
write_csv = .true.
write_netcdf = .true.
netcdf_write_mode = 'end'
write_metadata_as_comment = .true.
include_waterbody_breakdown = .false.
include_sediment_layer_breakdown = .true.
include_soil_layer_breakdown = .false.
include_soil_state_breakdown = .false.
soil_pec_units = 'kg/kg'
sediment_pec_units = 'kg/kg'
include_soil_erosion_yields = .true.
include_sediment_fluxes = .true.
include_spm_size_class_breakdown = .false.
write_compartment_stats = .false.
/

&run
description = "12 cell, 10 timestep test scenario" ! Not used by model, but included in output data
write_to_log = .false. ! Should we write logs to file?
timestep = 86400 ! Length of each time step, in seconds
n_timesteps = 10 ! Number of time steps
start_date = "2015-01-01" ! Start date for model run, in YYYY-MM-DD format
epsilon = 1e-20, ! Precision for numerical simulations
error_output = .true. ! Should error handling be turned on? Be careful if not, things might go wrong!
trigger_warnings = .false. ! Should errors that are non-critical (warnings) be triggered (printed to the console)?
log_file_path = "log/" ! Where to place model logs
output_hash = "" ! Append all output file names with this value. Useful for parallel model runs. Max 32 characters (e.g. hex string).
ignore_nm = .false. ! If .true., this tells the model we're not interested in NM and misses out costly computations. Useful for sediment calibration, NM PECs will be invalid
warm_up_period = 10 ! Warm up period before main simulation begin.
simulation_mask = "" ! Path to simulation mask, if only running for part of the data's area (empty string indicates no mask)
description = "12 cell, 10 timestep test scenario"
write_to_log = .false.
timestep = 86400
n_timesteps = 10
start_date = "2015-01-01"
epsilon = 1e-20
error_output = .true.
trigger_warnings = .false.
log_file_path = "log/"
output_hash = ""
ignore_contaminant = .false.
warm_up_period = 10
simulation_mask = ""
bash_colors = .true.
/

! Checkpointing is the ability to save a model run so that it can be reinstated from file. This is useful if, for example,
! you want to have a standard "warm-up" period for the model which you don't want to run every time you run the model.
! The checkpoint file is a binary file and this may cause issues transferring to different architectures
&checkpoint
checkpoint_file = "./checkpoint.dat" ! Location of checkpoint file to read from and/or save to
save_checkpoint = .false. ! Save a checkpoint file when the run is finished? Defaults to false
reinstate_checkpoint = .false. ! Reinstate a checkpoint from checkpoint_file? Defaults to false
preserve_timestep = .false. ! Should the timestep from the checkpoint be used as a starting timestep in a reinstated run?
checkpoint_file = "./checkpoint.dat"
save_checkpoint = .false.
reinstate_checkpoint = .false.
preserve_timestep = .false.
save_checkpoint_after_warm_up = .false.
/

&steady_state
run_to_steady_state = .false. ! Should the model be run until steady state by iterating over current simulation input data?
mode = 'sediment_size_distribution' ! Mode defines what variable will be used to assess steady state
delta = 1e-4
run_to_steady_state = .false.
mode = 'sediment_size_distribution'
delta = 1e-4
/

&soil
soil_layer_depth = 0.05, 0.15, 0.2 ! Depth of each soil layer. Array of length &allocatable_array_sizes > n_soil_layers
include_bioturbation = .true. ! Should bioturbation be modelled?
include_attachment = .true. ! Should attachment be modelled?
include_soil_erosion = .true. ! Should soil erosion be modelled?
soil_layer_depth = 0.05, 0.15, 0.2
include_bioturbation = .true.
include_attachment = .true.
include_soil_erosion = .true.
include_clay_enrichment = .false.
/

&sediment
sediment_layer_depth = 0.01, 0.01, 0.01, 0.01 ! Depth of each sediment layer. Array of length &allocatable_array_sizes > n_sediment_layers
spm_size_classes = 0.002e-3, 0.06e-3, 0.2e-3, 0.6e-3, 2.0e-3 ! Diameter of SPM in each binned size class [m]
include_bed_sediment = .true. ! Should bed sediment be modelled?
sediment_particle_densities = 1500, 2600 ! Density of sediment particles in each fractional composition class [kg/m3]
sediment_layer_depth = 0.01, 0.01, 0.01, 0.01
spm_size_classes = 0.002e-3, 0.06e-3, 0.2e-3, 0.6e-3, 2.0e-3
/

&water
min_stream_slope = 0.0001 ! Impose a minimum stream slope. Defaults to 0.0001, must be greater than 0
min_estuary_timestep = 3600 ! Minimum timestep length to use when modelling estuarine dynamics [s]. Defaults to 1 hour
include_estuary = .true. ! Should we model estuaries, or treat them as rivers?
include_bank_erosion = .true. ! Should we model the input of sediment via bank erosion?
min_stream_slope = 0.0001
min_estuary_timestep = 3600
include_estuary = .true.
include_bank_erosion = .true.
/

&sources
include_point_sources = .true. ! Should point sources be included?
include_point_sources = .true.
/
Loading