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 trunk/AGRIF/LIB – NEMO

source: trunk/AGRIF/LIB/WriteInFile.c @ 530

Last change on this file since 530 was 530, checked in by opalod, 17 years ago

RB: update of the conv for IOM and NEC MPI library

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 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@imag.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.0                                                                */
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, char *s,int returnlineornot) 
46{
47  char temp[61];
48  char *tmp;
49  int size;
50
51
52  if (strlen (s) <= 60)
53    {
54      if ( returnlineornot == 0 ) fprintf (filout, "     & %s", s);
55      else fprintf (filout, "     & %s\n", s);
56      if ( returnlineornot == 0 ) colnum=colnum+strlen(s)+6;
57      else colnum=0;
58    }
59  else
60    {
61      strncpy (temp, s, 60);
62      strcpy (&temp[60], "\0");
63
64      tmp = strrchr(temp, '+');
65
66      if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, '-');
67      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, '/');
68      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, '*');
69      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, '%');
70      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, ',');
71      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, ':');
72      if ( !tmp || strlen(tmp) == 60  ) tmp = strrchr(temp, ')');
73      if ( tmp )
74      {
75         size = strlen(tmp);
76      }
77      else
78      {
79         size = 0 ;
80      }
81
82      strcpy (&temp[60-size], "\0");
83
84      if ( fortran77 == 0 ) fprintf (filout, "     & %s  &\n", temp);
85      else fprintf (filout, "     & %s  \n", temp);
86      colnum=0;
87      tofich_reste (filout, (char *) &s[60-size],returnlineornot);
88    }
89}
90
91/******************************************************************************/
92/*                            tofich                                          */
93/******************************************************************************/
94/* This subroutine is used to write the string s into the fileout             */
95/******************************************************************************/
96void tofich (FILE * filout, char *s, int returnlineornot)   
97{
98  char temp[61];
99  char *tmp;
100  int size;
101 
102  if (strlen (s) <= 60)
103    {
104      if ( returnlineornot == 0 ) fprintf (filout, "      %s", s);
105      else fprintf (filout, "      %s\n", s);
106      if ( returnlineornot == 0 ) colnum=colnum+strlen(s)+6;
107      else colnum=0;
108    }
109  else
110    {
111      strncpy (temp, s, 60);
112      strcpy (&temp[60], "\0");
113
114      tmp = strrchr(temp, ',');
115      if ( !tmp  || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '+');
116      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, '-');
117      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, '/');
118      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, '*');
119      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, '%');
120      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, ',');
121      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, ':');
122      if ( !tmp  || strlen(tmp) == strlen(temp)  ) tmp = strrchr(temp, ')');
123      if ( tmp )
124      {
125         size = strlen(tmp);
126      }
127      else
128      {
129         size = 0 ;
130      }
131
132      strcpy (&temp[60-size], "\0");
133
134      if ( fortran77 == 0 ) fprintf (filout, "      %s  &\n", temp);
135      else fprintf (filout, "      %s  \n", temp);
136      colnum=0;
137      tofich_reste (filout, (char *) &s[60-size], returnlineornot);
138    }
139}
140
141/******************************************************************************/
142/*                       tofich_blanc                                         */
143/******************************************************************************/
144/* This subroutine is used to write size blank into the fileout               */
145/******************************************************************************/
146void tofich_blanc (FILE * filout, int size)
147{
148  int i;
149 
150  if (size <= 65)
151    {
152      fprintf (filout, "%*s\n",size,EmptyChar);
153    }
154  else
155    {
156      i=0;
157      do
158      {
159         fprintf (filout, "%*s\n",65,EmptyChar);
160         i = i+1;
161      } while ( i <= size / 65 );
162         fprintf (filout, "%*s\n",size%65,EmptyChar);
163    }
164}
165
166
167/******************************************************************************/
168/*                           RemoveWordSET_0                                  */
169/******************************************************************************/
170/* This subroutine is used to remove a sentence in the file filout            */
171/******************************************************************************/
172void RemoveWordSET_0(FILE * filout, long int position, long int sizetoremove)
173{
174   if ( firstpass == 0 )
175   {
176      fseek(filout,position,SEEK_SET);
177      tofich_blanc(filout,sizetoremove);
178   }
179}
180
181
182/******************************************************************************/
183/*                         RemoveWordCUR_0                                    */
184/******************************************************************************/
185/* This subroutine is used to remove a sentence in the file filout            */
186/******************************************************************************/
187void RemoveWordCUR_0(FILE * filout, long int position, long int sizetoremove)
188{
189   if ( firstpass == 0 )
190   {
191      fseek(filout,position,SEEK_CUR);
192      tofich_blanc(filout,sizetoremove);
193   }
194}
Note: See TracBrowser for help on using the repository browser.