From 3f0b3f19f414464c772740d178fa85dcf887cae2 Mon Sep 17 00:00:00 2001 From: Sean Bryan Date: Wed, 23 Oct 2024 16:31:20 +1100 Subject: [PATCH] Add skeleton for driver initialisation routine --- CMakeLists.txt | 3 +++ src/offline/cable_driver.F90 | 3 +++ src/offline/cable_driver_init.F90 | 21 +++++++++++++++++++++ src/offline/cable_mpidrv.F90 | 3 ++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/offline/cable_driver_init.F90 diff --git a/CMakeLists.txt b/CMakeLists.txt index d980cd603..cbcecae1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,7 @@ target_link_libraries(cable_common_objlib PRIVATE PkgConfig::NETCDF) add_executable( cable src/offline/cable_driver.F90 + src/offline/cable_driver_init.F90 "$" ) target_link_libraries(cable PRIVATE PkgConfig::NETCDF) @@ -167,8 +168,10 @@ if(CABLE_MPI) src/offline/cable_mpimaster.F90 src/offline/cable_mpiworker.F90 src/science/pop/pop_mpi.F90 + src/offline/cable_driver_init.F90 "$" ) + target_compile_definitions(cable-mpi PRIVATE __MPI__) target_link_libraries(cable-mpi PRIVATE PkgConfig::NETCDF MPI::MPI_Fortran) install(TARGETS cable-mpi RUNTIME) endif() diff --git a/src/offline/cable_driver.F90 b/src/offline/cable_driver.F90 index 5d8ec690c..25e1c0cd6 100644 --- a/src/offline/cable_driver.F90 +++ b/src/offline/cable_driver.F90 @@ -59,6 +59,7 @@ !============================================================================== PROGRAM cable_offline_driver + USE cable_driver_init_mod USE cable_def_types_mod USE cable_IO_vars_module, ONLY: logn,gswpfile,ncciy,leaps, & verbose, fixedCO2,output,check,patchout, & @@ -307,6 +308,8 @@ PROGRAM cable_offline_driver ! END header + CALL cable_driver_init() + cable_runtime%offline = .TRUE. !check to see if first argument passed to cable is !the name of the namelist file diff --git a/src/offline/cable_driver_init.F90 b/src/offline/cable_driver_init.F90 new file mode 100644 index 000000000..525b5d4bf --- /dev/null +++ b/src/offline/cable_driver_init.F90 @@ -0,0 +1,21 @@ +MODULE cable_driver_init_mod + !! Module containing routines for CABLE offline driver initialisation + IMPLICIT NONE + PRIVATE + + PUBLIC :: cable_driver_init + +CONTAINS + + SUBROUTINE cable_driver_init() + !! Model initialisation routine for the CABLE offline driver. + +#ifdef __MPI__ + ! MPI specific initialisation +#else + ! Serial specific initialisation +#endif + + END SUBROUTINE cable_driver_init + +END MODULE cable_driver_init_mod diff --git a/src/offline/cable_mpidrv.F90 b/src/offline/cable_mpidrv.F90 index 9a0cb6dbf..52bdb48de 100644 --- a/src/offline/cable_mpidrv.F90 +++ b/src/offline/cable_mpidrv.F90 @@ -20,6 +20,7 @@ PROGRAM mpi_driver USE mpi + USE cable_driver_init_mod USE cable_mpicommon USE cable_mpimaster @@ -31,7 +32,7 @@ PROGRAM mpi_driver INTEGER :: comm, np, rank, ierr REAL :: etime ! Declare the type of etime() - + CALL cable_driver_init() CALL MPI_Init (ierr) CALL MPI_Comm_dup (MPI_COMM_WORLD, comm, ierr)