00001 /* 00002 $URL: https://repos.deltares.nl/repos/openda/openda_1/public/trunk/core/native/src/cta/cta_time.c $ 00003 $Revision: 2751 $, $Date: 2011-09-09 08:58:46 +0200 (Fri, 09 Sep 2011) $ 00004 00005 OpenDA 00006 Copyright (C) 2013 Nils van Velzen 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /** 00024 * OpenDA support the concept of resultwriters. The Data assimilation algorithm 00025 * will presents intermediate results and information on the computations to the 00026 * result writer. Each implementation of a resultwriter can then handle this data 00027 * in its own way. 00028 * 00029 * To implement an native resultwriter the following methods need to be implemented. 00030 * Note: for explanation on variables see resultwriter function methods. All strings 00031 * have a len_... containing the result of strlen (used for using c-strings in Fortran) 00032 * 00033 * C: 00034 * 00035 * void putmessage(int iDWriter, CTA_Tree config, char* workingDir, char* message, int *retval, 00036 * int len_workingDir, int len_message); 00037 * 00038 * void putvalue(int iDWriter, CTA_Tree config, char* workingDir, int id, int handle, 00039 * int outputlevel, char* context, int iteration, int &retval, 00040 * len_workingDir, len_id, len_context); 00041 * 00042 * void putiterationreport(int iDWriter, CTA_Tree config, char *workingDir, int iteration, 00043 * double cost, CTA_Vector handle, int *retval, int len_workingDir); 00044 * 00045 * void freewriter(int iDWriter); 00046 * 00047 * Fortran 2003: 00048 * 00049 * interface 00050 * subroutine putmessage(iDWriter, config, workingDir, message, retval, & 00051 * len_workingDir, len_message) & 00052 * bind(C, NAME='putmessage') 00053 * use iso_c_binding 00054 * implicit none 00055 * include 'cta_f90.inc' 00056 * 00057 * integer(C_INT), VALUE ::iDWriter, config, len_workingDir, len_message 00058 * integer(C_INT) ::retval 00059 * character(kind=c_char) ::workingdir(*), message(*) 00060 * end subroutine putmessage 00061 * end interface 00062 * 00063 * 00064 * interface 00065 * subroutine putvalue(iDWriter, config, workingDir, id, handle, & 00066 * outputlevel, context, iteration, retval, & 00067 * len_workingDir, len_id, len_context) & 00068 * bind(C, NAME='putvalue') 00069 * use iso_c_binding 00070 * implicit none 00071 * include 'cta_f90.inc' 00072 * integer(C_INT), VALUE ::iDWriter, config, handle, outputlevel, iteration, & 00073 * len_workingDir, len_id, len_context 00074 * integer(C_INT) ::retval 00075 * character(kind=c_char) ::workingdir(*), id(*), context(*) 00076 * 00077 * end subroutine putvalue 00078 * end interface 00079 * 00080 * interface 00081 * subroutine putiterationreport(iDWriter, config, workingDir, iteration, cost, & 00082 * handle, retval, len_workingDir) & 00083 * bind(C, NAME='putiterationreport') 00084 * use iso_c_binding 00085 * implicit none 00086 * include 'cta_f90.inc' 00087 * integer(C_INT), VALUE ::iDWriter, config, iteration, handle, len_workingDir 00088 * real(C_DOUBLE), VALUE ::cost 00089 * integer(C_INT) ::retval 00090 * character(kind=c_char) ::workingdir(*) 00091 * end subroutine putiterationreport 00092 * end interface 00093 * 00094 * interface 00095 * subroutine freewriter(iDWriter) & 00096 * bind(C, NAME='freewriter') 00097 * use iso_c_binding 00098 * implicit none 00099 * include 'cta_f90.inc' 00100 * integer(C_INT), VALUE ::iDWriter 00101 * end subroutine freewriter 00102 * end interface 00103 00104 * 00105 * The resultwriter must have an xml-configuration file containing at least the following 00106 * (additional field may be used for private usage by the implementation) 00107 * Note name of library and funtion name must correspond to the user implementation. 00108 * 00109 * <?xml version="1.0" encoding="UTF-8"?> 00110 * <openda_native xmlns:xi="http://www.w3.org/2001/XInclude"> 00111 * <CTA_FUNCTION id="putvalue" name="putvalue" library="libresultwriter.so" function="putvalue" /> 00112 * <CTA_FUNCTION id="putmessage" name="putmessage" library="libresultwriter.so" function="putmessage" /> 00113 * <CTA_FUNCTION id="putiterationreport" name="putiterationreport" library="libresultwriter.so" function="putiterationreport" /> 00114 * <CTA_FUNCTION id="freewriter" name="freewriter" library="libresultwriter.so" function="freewriter" /> 00115 * </openda_native> 00116 * 00117 * 00118 * 00119 * @author nils van velzen 00120 * 00121 */ 00122 00123 #ifndef CTA_RESULTWRITER_H 00124 #define CTA_RESULTWRITER_H 00125 #include "cta_system.h" 00126 #include "cta_handles.h" 00127 #include "cta_datatypes.h" 00128 /* Function Handle */ 00129 #ifdef __cplusplus 00130 extern "C" { 00131 #endif 00132 00133 00134 /** \brief Handle a string message send to the resultwriter 00135 * 00136 * \param IDWriter I ID of this resultwriter (Counter of number of native result writers) 00137 * \param config I Name of XML configuration file containting the function pointers and additional information 00138 * \param workingDir I Full path to working directory 00139 * \param message I Message send to resultwriter 00140 * 00141 * \return error status: CTA_OK if successful 00142 */ 00143 CTAEXPORT int CTA_Resultwriter_putmessage(int iDWriter, char* config, char *workingDir, char *message); 00144 00145 /** \brief Handle a string message send to the resultwriter 00146 * 00147 * \param IDWriter I ID of this resultwriter (Counter of number of native result writers) 00148 * \param config I Name of XML configuration file containting the function pointers and additional information 00149 * \param workingDir I Full path to working directory 00150 * \param id I Name of the variable/array send to the resultwriter 00151 * \param handle I Handle (Vector or TreeVector) of variable 00152 * \param outputLevel I Selected output level (see opendabridge for possible values) 00153 * \param context I Location from which the resultwriter was called 00154 * \param iteration I Iteration number from which the resultwriter was called 00155 * 00156 * \return error status: CTA_OK if successful 00157 */ 00158 CTAEXPORT int CTA_Resultwriter_putvalue(int idwriter, char*config, char *workingdir, char *id, int handle, int outputlevel, char *context, int iteration); 00159 00160 /** \brief Handle a string message send to the resultwriter 00161 * 00162 * \param IDWriter I ID of this resultwriter (Counter of number of native result writers) 00163 * \param config I Name of XML configuration file containting the function pointers and additional information 00164 * \param workingDir I Full path to working directory 00165 * \param iteration I Iteration number from which the resultwriter was called 00166 * \param cost I Value of cost function 00167 * \param handle I Handle (Vector or TreeVector) of the current parameters 00168 * 00169 * \return error status: CTA_OK if successful 00170 */ 00171 CTAEXPORT int CTA_Resultwriter_putiterationreport(int idwriter, char*config, char *workingDir, int iteration, double cost, int handle); 00172 00173 /** \brief Free a resultwriter (close output files etc). 00174 * 00175 * \param IDWriter I ID of this resultwriter (Counter of number of native result writers) 00176 * 00177 * \return error status: CTA_OK if successful 00178 */ 00179 CTAEXPORT int CTA_Resultwriter_free(int idwriter); 00180 00181 00182 #ifdef __cplusplus 00183 } 00184 #endif 00185 #endif 00186 00187