00001 /* 00002 COSTA: Problem solving environment for data assimilation 00003 Copyright (C) 2005 Nils van Velzen 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 /** 00021 \file cta_file.h 00022 \brief Functions for the implementation of CTA_FILE objects. 00023 */ 00024 00025 #ifndef CTA_FILE_H 00026 #define CTA_FILE_H 00027 00028 #include <stdio.h> 00029 #include "cta_system.h" 00030 #include "cta_string.h" 00031 #include "cta_handles.h" 00032 #include "cta_datatypes.h" 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 /* Function Handle */ 00038 typedef CTA_Handle CTA_File; 00039 00040 /* functions */ 00041 00042 /** \brief Create a new COSTA file 00043 * for holding a C file descriptor of a FORTRAN file LUN 00044 * 00045 * \note This call does not open a file. 00046 * No FORTRAN support in this version 00047 * 00048 * \param hfile O receives handle of created file 00049 * \return CTA_OK if successful 00050 */ 00051 CTAEXPORT int CTA_File_Create(CTA_File *hfile); 00052 00053 /** \brief Free a new COSTA file-handle 00054 * 00055 * \note The File is not closed (in this version) 00056 * 00057 * \param hfile IO handle of COSTA file CTA_NULL on return 00058 * \return CTA_OK if successful 00059 */ 00060 CTAEXPORT int CTA_File_Free (CTA_File *hfile); 00061 00062 /** \brief Get the C-file descriptor of the COSTA file 00063 * 00064 * \note 00065 * 00066 * \param hfile I handle of COSTA file-handle 00067 * \param file O receives file descriptor 00068 * \return CTA_OK if successful 00069 */ 00070 CTAEXPORT int CTA_File_Get (CTA_File hfile, FILE **file); 00071 00072 /** \brief Get the NETCDF file id of the COSTA file 00073 * 00074 * \note 00075 * 00076 * \param hfile I handle of COSTA file-handle 00077 * \param ncid O receives NETCDF file id 00078 * \return CTA_OK if successful 00079 */ 00080 CTAEXPORT int CTA_File_GetNetcdf(CTA_File hfile,int *ncid); 00081 00082 00083 /** \brief Set the C-file descriptor of the COSTA file 00084 * 00085 * \note 00086 * 00087 * \param hfile IO handle of COSTA file-handle 00088 * \param file I file descriptor 00089 * \return CTA_OK if successful 00090 */ 00091 CTAEXPORT int CTA_File_Set (CTA_File hfile, FILE *file); 00092 00093 /** \brief Open a C-file and set descriptor 00094 * 00095 * \note 00096 * 00097 * \param hfile I provide a valid handle of COSTA file 00098 * \param sname I file path 00099 * \param smode I open-mode (see C fopen documentation) 00100 * if CTA_NULL is provided, the file will be 00101 * opened with read/write access (file pointer at begin 00102 * of file) 00103 * \return CTA_OK if successful 00104 */ 00105 CTAEXPORT int CTA_File_Open (CTA_File hfile, CTA_String sname, CTA_String smode); 00106 00107 /** \brief check whether file is a NETCDF file 00108 * 00109 * \param hfile I provide a valid handle of COSTA file 00110 * \param isnetcdf O CTA_TRUE if file is NETCDF file CTA_FALSE otherwise 00111 * 00112 * \return CTA_OK if successful 00113 */ 00114 CTAEXPORT int CTA_File_IsNetcdf(CTA_File hfile, int *isnetcdf); 00115 00116 00117 /** \brief Write a string to file 00118 * 00119 * \note 00120 * 00121 * \param hfile I handle of COSTA file 00122 * \param str I string that must be written to file 00123 * \param eol I Add end of line, CTA_TRUE for adding end of line or CTA_FALSE otherwise 00124 * \return CTA_OK if successful 00125 */ 00126 CTAEXPORT int CTA_File_WriteStr(CTA_File hfile, char *str, int eol); 00127 00128 #ifdef __cplusplus 00129 } 00130 #endif 00131 00132 #endif 00133