[396] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
| 5 | /* Copyright (C) 2005 Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
| 6 | /* Cyril Mazauric (Cyril.Mazauric@imag.fr) */ |
---|
| 7 | /* */ |
---|
| 8 | /* This program is free software; you can redistribute it and/or modify */ |
---|
| 9 | /* it */ |
---|
| 10 | /* */ |
---|
| 11 | /* This program is distributed in the hope that it will be useful, */ |
---|
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
---|
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
---|
| 14 | /* GNU General Public License for more details. */ |
---|
| 15 | /* */ |
---|
| 16 | /******************************************************************************/ |
---|
| 17 | #include <stdio.h> |
---|
| 18 | #include <stdlib.h> |
---|
| 19 | #include <string.h> |
---|
| 20 | #include "decl.h" |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | /******************************************************************************/ |
---|
| 24 | /* associate */ |
---|
| 25 | /******************************************************************************/ |
---|
| 26 | /* This subroutine is used to open a file */ |
---|
| 27 | /******************************************************************************/ |
---|
| 28 | FILE * associate (char *filename) |
---|
| 29 | { |
---|
| 30 | char filefich[LONGNOM]; |
---|
| 31 | sprintf(filefich,"%s/%s",nomdir,filename); |
---|
| 32 | return fopen (filefich, "w"); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | /******************************************************************************/ |
---|
| 37 | /* associateaplus */ |
---|
| 38 | /******************************************************************************/ |
---|
| 39 | /* This subroutine is used to open a file with option a+ */ |
---|
| 40 | /******************************************************************************/ |
---|
| 41 | FILE * associateaplus (char *filename) |
---|
| 42 | { |
---|
| 43 | char filefich[LONGNOM]; |
---|
| 44 | sprintf(filefich,"%s/%s",nomdir,filename); |
---|
| 45 | return fopen (filefich, "a+"); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | /******************************************************************************/ |
---|
| 50 | /* setposcur */ |
---|
| 51 | /******************************************************************************/ |
---|
| 52 | /* This subroutine is used to know the current position in the file */ |
---|
| 53 | /******************************************************************************/ |
---|
| 54 | /* */ |
---|
| 55 | /* setposcur ---------> position in file */ |
---|
| 56 | /* */ |
---|
| 57 | /******************************************************************************/ |
---|
| 58 | long int setposcur() |
---|
| 59 | { |
---|
| 60 | fflush(fortranout); |
---|
| 61 | return ftell(fortranout); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /******************************************************************************/ |
---|
| 65 | /* setposcurinoldfortranout */ |
---|
| 66 | /******************************************************************************/ |
---|
| 67 | /* This subroutine is used to know the position in the oldfortranout */ |
---|
| 68 | /******************************************************************************/ |
---|
| 69 | /* */ |
---|
| 70 | /* setposcurinoldfortranout ---------> position in file */ |
---|
| 71 | /* */ |
---|
| 72 | /******************************************************************************/ |
---|
| 73 | long int setposcurinoldfortranout() |
---|
| 74 | { |
---|
| 75 | fflush(oldfortranout); |
---|
| 76 | return ftell(oldfortranout); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /******************************************************************************/ |
---|
| 80 | /* decl_0_modifdeclarationssave */ |
---|
| 81 | /******************************************************************************/ |
---|
| 82 | /* Firstpass 0 */ |
---|
| 83 | /* We should modify this declaration in the file fortranout. case SAVE */ |
---|
| 84 | /******************************************************************************/ |
---|
| 85 | void decl_0_modifdeclarationssave(listvar *listtomodify) |
---|
| 86 | { |
---|
| 87 | if ( VariableIsParameter == 0 && SaveDeclare == 1) |
---|
| 88 | { |
---|
| 89 | if (firstpass == 0) |
---|
| 90 | { |
---|
| 91 | pos_end = setposcur(); |
---|
| 92 | RemoveWordSET(fortranout,pos_cur, |
---|
| 93 | pos_end-pos_cur); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /******************************************************************************/ |
---|
| 99 | /* OPTI_0_copyuse */ |
---|
| 100 | /******************************************************************************/ |
---|
| 101 | /* Firstpass 0 */ |
---|
| 102 | /* We should write in the fortranout the USE tok_name */ |
---|
| 103 | /* read in the original file */ |
---|
| 104 | /******************************************************************************/ |
---|
| 105 | /* */ |
---|
| 106 | /******************************************************************************/ |
---|
| 107 | void OPTI_0_copyuse(char *namemodule) |
---|
| 108 | { |
---|
| 109 | if (firstpass == 0 && OPTI_0_IsTabvarsUseInArgument() == 1 ) |
---|
| 110 | { |
---|
| 111 | /* We should write this declaration into the original subroutine too */ |
---|
| 112 | fprintf(oldfortranout," USE %s \n",namemodule); |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | /******************************************************************************/ |
---|
| 117 | /* OPTI_0_copyuseonly */ |
---|
| 118 | /******************************************************************************/ |
---|
| 119 | /* Firstpass 0 */ |
---|
| 120 | /* We should write in the fortranout the USE tok_name, only */ |
---|
| 121 | /* read in the original file */ |
---|
| 122 | /******************************************************************************/ |
---|
| 123 | /* */ |
---|
| 124 | /******************************************************************************/ |
---|
| 125 | void OPTI_0_copyuseonly(char *namemodule) |
---|
| 126 | { |
---|
| 127 | if (firstpass == 0 && OPTI_0_IsTabvarsUseInArgument() == 1 ) |
---|
| 128 | { |
---|
| 129 | /* We should write this declaration into the original subroutine too */ |
---|
| 130 | fprintf(oldfortranout," USE %s , ONLY : \n",namemodule); |
---|
| 131 | } |
---|
| 132 | } |
---|