Commit daa256ff authored by Emmanuelle Sarrazin's avatar Emmanuelle Sarrazin

Module initialisation

parents
cmake_minimum_required(VERSION 2.8.9)
project(MPIModule)
set(MPIModule_LIBRARIES MPIModule)
if(NOT OTB_SOURCE_DIR)
find_package(OTB REQUIRED)
set(OTB_CMAKE_DIR /work/hpc/sarrazie/otb/OTB-develop/CMake/)
set(OTB_SOURCE_DIR /work/hpc/sarrazie/otb/OTB-develop/)
list(APPEND CMAKE_MODULE_PATH ${OTB_CMAKE_DIR})
include(OTBModuleExternal)
else()
otb_module_impl()
endif()
This diff is collapsed.
General
=======
This is a template module for the ORFEO
Toolbox(https://www.orfeo-toolbox.org/). It is designed to work with OTBv5
modular system and to be places in OTB/Module/Remote.
This module is empty it is just a template to be used as a starting point for a
module with actual content. It contains the template for sources (src folder),
test (test folder) and application (app folder).
Getting Started
===============
The official OTB Wiki documentation on adding an external module is here:
http://wiki.orfeo-toolbox.org/index.php/How_to_write_a_remote_module
Remote Module
-------------
After a module has been created as a git repository it can be included
as a remote module, which enables automatic fetching. Add a file in
"OTB/Modules/Remote" called "YourModule.remote.cmake", for this module
it would be "ExternalExample.remote.cmake" with the followlowing contents:
otb_fetch_module(ExternalTemplate
"A template for a module."
GIT_REPOSITORY https://github.com/orfeotoolbox/otbExternalModuleTemplate
GIT_TAG master
)
Editing
=======
The CMakeLists.txt and otb-modules need to be modified with the name of the
module, something along the following:
sed 's/ExternalTemplate/MyModule/g' CMakeLists.txt otb-module.cmake
There is the inplace option to sed, but it's not portable, so do this change by
hand or look up the option in sed.
Then hack away at you code in include, src, test and app folders.
License
=======
This software is distributed under the Apache License. Please see LICENSE for
details.
Author
======
Manuel Grizonnet
Thanks
======
It is a fork of the ITK template module provided by Bradley Lowekamp
(https://github.com/blowekamp/itkExternalTemplate.git) which was adapted for the
ORFEO ToolBox.
OTB_CREATE_APPLICATION(NAME MPIHelloApp
SOURCES otbMPIHelloApp.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES}
)
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
class EmptyApp : public otb::Wrapper::Application
{
public:
typedef EmptyApp Self;
typedef itk::SmartPointer<Self> Pointer;
itkNewMacro(Self);
itkTypeMacro(EmptyApp, otb::Wrapper::Application);
private:
void DoInit()
{
SetName("EmptyApp");
SetDescription("Empty application.");
}
void DoUpdateParameters()
{
}
void DoExecute()
{
int ThisDoesNothing = 0;
}
};
OTB_APPLICATION_EXPORT(EmptyApp)
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __MPIConfig_h
#define __MPIConfig_h
#include <mpi.h>
namespace otb
{
namespace mpi
{
/** \class MPIConfig
*
* Manage MPI ressources
*
*/
class MPIConfig
{
public:
/**
* Initialize the MPI environment.
*
* If the MPI environment has not already been initialized,
* initializes MPI with a call to MPI_Init.
*
* @param argc Number of arguments
*
* @param argv Array of arguments
*
* @param abort_on_exception When true, this object will abort the
* program if it is destructed due to an uncaught exception.
*/
MPIConfig(int& argc, char** &argv, bool abortOnException = true);
/**
* Shuts down the MPI environment.
*/
~MPIConfig();
/**
* Abort all MPI processes.
*
* @param errcode
*/
void abort(int errcode);
/**
* Determine if the MPI environment has already been initialized.
*
* @returns @c true if the MPI environment has been initialized.
*/
bool initialized();
/**
* Determine if the MPI environment has already been finalized.
*
* @returns @c true if the MPI environment has been finalized.
*/
bool finalized();
private:
/// Whether this environment object called MPI_Init
bool m_initialized;
/// Whether we should abort if the destructor is
bool m_abortOnException;
};
} // end namespace mpi
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbMPIConfig.txx"
#endif
#endif // MPIConfig
#include "otbMPIConfig.h"
set(DOCUMENTATION "OTB module template.")
# OTB_module() defines the module dependencies in ExternalTemplate
# ExternalTemplate depends on OTBCommon and OTBApplicationEngine
# The testing module in ExternalTemplate depends on OTBTestKernel
# and OTBCommandLine
# define the dependencies of the include module and the tests
otb_module(MPIModule
DEPENDS
OTBMPI
OTBCommon
OTBApplicationEngine
TEST_DEPENDS
OTBMPI
OTBTestKernel
OTBCommandLine
DESCRIPTION
"${DOCUMENTATION}"
)
#${otb-module} will be the name of this module and will not need to be
#changed when this module is renamed.
set(${otb-module}_SRC
otbMPIConfig.cpp
)
add_library(${otb-module} ${${otb-module}_SRC})
target_link_libraries(${otb-module} ${OTBCommon_LIBRARIES})
otb_module_target(${otb-module})
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbMPIConfig.h"
#include <exception>
namespace otb
{
namespace mpi
{
MPIConfig::MPIConfig(int& argc, char** &argv, bool abortOnException)
: m_initialized(false),
m_abortOnException(abortOnException)
{
if (!initialized()) {
MPI_Init, (&argc, &argv);
m_initialized = true;
}
}
MPIConfig::~MPIConfig()
{
}
void MPIConfig::abort(int errcode)
{
}
bool MPIConfig::initialized()
{
int flag;
return flag != 0;
}
bool MPIConfig::finalized()
{
int flag;
return flag != 0;
}
} // End namespace mpi
} // end namespace otb
otb_module_test()
#${otb-module} will be the name of this module and will not need to be
#changed when this module is renamed.
set(${otb-module}Tests
otbMPIModuleTestDriver.cxx
otbMPIHelloTest.cxx
)
add_executable(otbMPIModuleTestDriver ${${otb-module}Tests})
target_link_libraries(otbMPIModuleTestDriver ${${otb-module}-Test_LIBRARIES})
otb_module_target_label(otbMPIModuleTestDriver)
otb_add_test(NAME otbMPIHelloTest
COMMAND otbMPIModuleTestDriver otbMPIHelloTest)
#test application
otb_test_application(NAME otbMPIHelloAppTest
APP MPIHelloApp)
#include <cstdlib>
int otbEmptyTest( int , char ** )
{
return EXIT_SUCCESS;
}
#include "otbTestMain.h"
void RegisterTests()
{
REGISTER_TEST(otbEmptyTest);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment