New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
WriteInFile.c in NEMO/branches/UKMO/r8395_coupling_sequence/NEMOGCM/EXTERNAL/AGRIF/LIB – NEMO

source: NEMO/branches/UKMO/r8395_coupling_sequence/NEMOGCM/EXTERNAL/AGRIF/LIB/WriteInFile.c @ 10761

Last change on this file since 10761 was 10761, checked in by jcastill, 5 years ago

Remove svn keys

File size: 7.2 KB
Line 
1/******************************************************************************/
2/*                                                                            */
3/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
4/*                                                                            */
5/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
6/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
7/* This software is governed by the CeCILL-C license under French law and     */
8/* abiding by the rules of distribution of free software.  You can  use,      */
9/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
10/* license as circulated by CEA, CNRS and INRIA at the following URL          */
11/* "http://www.cecill.info".                                                  */
12/*                                                                            */
13/* As a counterpart to the access to the source code and  rights to copy,     */
14/* modify and redistribute granted by the license, users are provided only    */
15/* with a limited warranty  and the software's author,  the holder of the     */
16/* economic rights,  and the successive licensors  have only  limited         */
17/* liability.                                                                 */
18/*                                                                            */
19/* In this respect, the user's attention is drawn to the risks associated     */
20/* with loading,  using,  modifying and/or developing or reproducing the      */
21/* software by the user in light of its specific status of free software,     */
22/* that may mean  that it is complicated to manipulate,  and  that  also      */
23/* therefore means  that it is reserved for developers  and  experienced      */
24/* professionals having in-depth computer knowledge. Users are therefore      */
25/* encouraged to load and test the software's suitability as regards their    */
26/* requirements in conditions enabling the security of their systems and/or   */
27/* data to be ensured and,  more generally, to use and operate it in the      */
28/* same conditions as regards security.                                       */
29/*                                                                            */
30/* The fact that you are presently reading this means that you have had       */
31/* knowledge of the CeCILL-C license and that you accept its terms.           */
32/******************************************************************************/
33/* version 1.7                                                                */
34/******************************************************************************/
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include "decl.h"
39
40/******************************************************************************/
41/*                            tofich_reste                                    */
42/******************************************************************************/
43/* This subroutine is used to write the string s into the fileout             */
44/******************************************************************************/
45void tofich_reste (FILE * filout, const char *s, int do_returnline)
46{
47    const size_t line_length = 66;
48    char temp[line_length+1];
49    size_t s_length;
50
51    s_length = strlen(s);
52
53    if ( !strcmp(&s[strlen(s)-1], "\n") )
54        s_length = strlen(s)-1;
55
56    if ( s_length <= line_length )
57    {
58        if ( do_returnline ) fprintf(filout, "     &%s\n", s);
59        else                 fprintf(filout, "&%s", s);
60    }
61    else
62    {
63        strncpy(temp, s, line_length);
64        temp[line_length] = '\0';
65        if ( retour77 == 0 && (s_length-strlen(temp) > 0) )
66                fprintf(filout, "     &%s&\n", temp);
67        else    fprintf(filout, "     &%s\n", temp);
68
69        if ( s_length-strlen(temp) > 0 )
70            tofich_reste(filout, (char *) &s[line_length], do_returnline);
71    }
72}
73
74/******************************************************************************/
75/*                            tofich                                          */
76/******************************************************************************/
77/* This subroutine is used to write the string s into the fileout             */
78/******************************************************************************/
79void tofich (FILE * filout, const char *s, int do_returnline)
80{
81    const size_t line_length = 66;
82    char temp[line_length+1];
83    size_t s_length;
84
85    s_length = strlen(s);
86
87    if ( !strcmp(&s[strlen(s)-1], "\n") )
88        s_length = strlen(s)-1;
89
90    if ( s_length <= line_length )
91    {
92        if ( do_returnline ) fprintf(filout, "      %s\n", s);
93        else                 fprintf(filout, "%s", s);
94    }
95    else
96    {
97        strncpy(temp, s, line_length);
98        temp[line_length] = '\0';
99
100        if ( retour77 == 0 )    fprintf(filout, "      %s&\n", temp);
101        else                    fprintf(filout, "      %s\n", temp);
102
103        tofich_reste(filout, (char *) &s[line_length], do_returnline);
104    }
105}
106
107/******************************************************************************/
108/*                       tofich_blanc                                         */
109/******************************************************************************/
110/* This subroutine is used to write size blank into the fileout               */
111/******************************************************************************/
112void tofich_blanc (FILE * filout, int size)
113{
114    const char* empty_char = " ";
115    int i = 0;
116
117    if (size <= 65)
118        fprintf(filout, "%*s\n", size, empty_char);
119    else
120    {
121        do
122        {
123            fprintf(filout, "%*s\n", 65, empty_char);
124            i++;
125        }
126        while ( i <= size / 65 );
127
128        fprintf(filout, "%*s\n", size%65, empty_char);
129    }
130}
131
132/******************************************************************************/
133/*                           RemoveWordSET_0                                  */
134/******************************************************************************/
135/* This subroutine is used to remove a sentence in the file filout            */
136/******************************************************************************/
137void RemoveWordSET_0(FILE * filout, long int position, int sizetoremove)
138{
139    if ( inside_type_declare || firstpass ) return;
140
141    fseek(filout, position, SEEK_SET);
142    tofich_blanc(filout, sizetoremove);
143    fseek(filout, position, SEEK_SET);
144}
145
146/******************************************************************************/
147/*                         RemoveWordCUR_0                                    */
148/******************************************************************************/
149/* This subroutine is used to remove a sentence in the file filout            */
150/******************************************************************************/
151void RemoveWordCUR_0(FILE * filout, int sizetoremove)
152{
153    if ( inside_type_declare || firstpass ) return;
154
155    fseek(filout, (long int)(-sizetoremove), SEEK_CUR);
156    tofich_blanc(filout, sizetoremove);
157    fseek(filout, (long int)(-sizetoremove), SEEK_CUR);
158    if ( strstr(fortran_text, "\n") )   fprintf(filout, "\n");
159}
Note: See TracBrowser for help on using the repository browser.