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.
UtilFile.c in trunk/AGRIF/LIB – NEMO

source: trunk/AGRIF/LIB/UtilFile.c @ 1200

Last change on this file since 1200 was 1200, checked in by rblod, 16 years ago

Adapt Agrif to the new SBC and correct several bugs for agrif (restart writing and reading), see ticket #133
Note : this fix does not work yet on NEC computerq (sxf90/360)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.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/******************************************************************************/
42/*                            associate                                       */
43/******************************************************************************/
44/* This subroutine is used to open a file                                     */
45/******************************************************************************/
46FILE * associate (char *filename)
47{
48  char filefich[LONG_C];
49  sprintf(filefich,"%s/%s",nomdir,filename);
50  return fopen (filefich, "w");
51}
52
53
54/******************************************************************************/
55/*                          associateaplus                                    */
56/******************************************************************************/
57/* This subroutine is used to open a file with option a+                      */
58/******************************************************************************/
59FILE * associateaplus (char *filename)
60{
61  char filefich[LONG_C];
62  sprintf(filefich,"%s/%s",nomdir,filename);
63  return fopen (filefich, "a+");
64}
65
66
67/******************************************************************************/
68/*                           setposcurname                                       */
69/******************************************************************************/
70/* This subroutine is used to know the current position in the file in argument    */
71/******************************************************************************/
72/*                                                                            */
73/*                      setposcur ---------> position in file                 */
74/*                                                                            */
75/******************************************************************************/
76long int setposcurname(FILE *fileout)
77{
78   fflush(fileout);
79   return ftell(fileout);
80}
81
82/******************************************************************************/
83/*                           setposcur                                        */
84/******************************************************************************/
85/* This subroutine is used to know the current position in the file           */
86/******************************************************************************/
87/*                                                                            */
88/*                      setposcur ---------> position in file                 */
89/*                                                                            */
90/******************************************************************************/
91long int setposcur()
92{
93   fflush(fortranout);
94   return ftell(fortranout);
95}
96
97/******************************************************************************/
98/*                      setposcurinoldfortranout                              */
99/******************************************************************************/
100/* This subroutine is used to know the position in the oldfortranout         */
101/******************************************************************************/
102/*                                                                            */
103/*             setposcurinoldfortranout ---------> position in file           */
104/*                                                                            */
105/******************************************************************************/
106long int setposcurinoldfortranout()
107{
108   fflush(oldfortranout);
109   return ftell(oldfortranout);
110}
111
112/******************************************************************************/
113/*                         copyuse_0                                          */
114/******************************************************************************/
115/* Firstpass 0                                                                */
116/* We should write in the fortranout the USE tok_name                         */
117/* read in the original file                                                  */
118/******************************************************************************/
119/*                                                                            */
120/******************************************************************************/
121void copyuse_0(char *namemodule)
122{
123   if (firstpass == 0 && IsTabvarsUseInArgument_0() == 1 )
124   {
125      /* We should write this declaration into the original subroutine too    */
126      fprintf(oldfortranout,"      USE %s \n",namemodule);
127   }
128}
129
130/******************************************************************************/
131/*                         copyuseonly_0                                      */
132/******************************************************************************/
133/* Firstpass 0                                                                */
134/* We should write in the fortranout the USE tok_name, only                   */
135/* read in the original file                                                  */
136/******************************************************************************/
137/*                                                                            */
138/******************************************************************************/
139void copyuseonly_0(char *namemodule)
140{
141   if (firstpass == 0 && IsTabvarsUseInArgument_0() == 1 )
142   {
143      /* We should write this declaration into the original subroutine too    */
144      fprintf(oldfortranout,"      USE %s , ONLY : \n",namemodule);
145   }
146}
Note: See TracBrowser for help on using the repository browser.