1 /* This file is part of MED. 2 * 3 * COPYRIGHT (C) 1999 - 2019 EDF R&D, CEA/DEN 4 * MED is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * MED is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with MED. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 19 #include <med.h> 20 #include "med_config.h" 21 #include "med_outils.h" 22 #include <string.h> 23 #include <stdlib.h> 24 25 extern void *MedVersionedApiF; 26 extern void f77ApiIsSet(void * obj); 27 28 #define nedfouvr F77_FUNC(edfouvr,EDFOUVR) 29 #define nedfferm F77_FUNC(edfferm,EDFFERM) 30 #define nedflfde F77_FUNC(edflfde,EDFLFDE) 31 #define nedffien F77_FUNC(edffien,EDFFIEN) 32 #define nedffide F77_FUNC(edffide,EDFFIDE) 33 #define nedffoco F77_FUNC(edffoco,EDFFOCO) 34 #define nedfveco F77_FUNC(edfveco,EDFVECO) 35 #define nedfveli F77_FUNC(edfveli,EDFVELI) 36 #define nedfvedo F77_FUNC(edfvedo,EDFVEDO) 37 #define nedfmont F77_FUNC(edfmont,EDFMONT) 38 #define nedfdemo F77_FUNC(edfdemo,EDFDEMO) 39 40 #ifdef PPRO_NT 41 med_idt EDFOUVR(char * nom,unsigned int bidon,med_int * acces,med_int * lon)42 EDFOUVR (char *nom, unsigned int bidon, med_int * acces, 43 med_int *lon) 44 #else 45 med_idt 46 nedfouvr (char *nom,med_int * acces,med_int *lon) 47 #endif 48 { 49 char *fn; 50 med_idt ret; 51 52 /* Cette méthode a pour unique but de forcer la construction 53 de l'objet MedVersionedApiF et donc la mise à jour de MedVersionedApi 54 avec les APis fortran. Certains compilateurs suppriment le symbole MedVersionedApiF 55 croyant qu'il nest pas utilisé et la mise à jour de MedVersionedApi n'est 56 alors pas effectuée.*/ 57 f77ApiIsSet(MedVersionedApiF); 58 59 fn = _MED2cstring(nom, (int) * lon); 60 if (!fn) return(-1); 61 62 ret = MEDouvrir(fn,(med_mode_acces) *acces); 63 64 _MEDcstringFree(fn); 65 66 return(ret); 67 } 68 69 #ifdef PPRO_NT 70 med_int EDFFERM(med_idt * fid)71 EDFFERM(med_idt * fid) 72 #else 73 med_int 74 nedfferm(med_idt * fid) 75 #endif 76 { 77 med_int ret; 78 ret = (med_int) MEDfermer(* fid); 79 80 return(ret); 81 } 82 83 #ifdef PPRO_NT 84 med_int EDFLFDE(med_idt * fid)85 EDFLFDE(med_idt *fid) 86 #else 87 med_int 88 nedflfde (med_idt *fid) 89 #endif 90 { 91 med_int longueur; 92 93 longueur = MEDlFichDes(*fid); 94 95 return longueur; 96 } 97 98 #ifdef PPRO_NT 99 med_int EDFFIEN(med_idt * fid,med_int * quoi,char * str,unsigned int bidon1)100 EDFFIEN(med_idt *fid,med_int *quoi,char *str, unsigned int bidon1) 101 #else 102 med_int 103 nedffien (med_idt *fid,med_int *quoi,char *str) 104 #endif 105 { 106 med_int ret; 107 med_int longueur; 108 char * fs1; 109 110 /* Solution temporaire */ 111 longueur = MEDlFichDes(*fid); 112 /* ISCRUTE(longueur); */ 113 fs1 = (char *) malloc(sizeof(char)*longueur+1); 114 115 ret = (med_int) MEDfichEntete(*fid,(med_fich_info) *quoi,(char *) fs1); 116 117 strncpy(str,fs1,longueur); 118 _MEDfstring(str,longueur); 119 free(fs1); 120 121 return ret; 122 } 123 124 #ifdef PPRO_NT 125 int EDFFIDE(med_idt * fid,char * des,unsigned int bidon1,med_int * lon1)126 EDFFIDE(med_idt *fid,char *des, unsigned int bidon1,med_int *lon1) 127 #else 128 med_int 129 nedffide(med_idt *fid,char *des,med_int *lon1) 130 #endif 131 { 132 med_int ret; 133 char *fn1; 134 135 fn1 = _MED1cstring((char *)des,(int )*lon1,MED_TAILLE_DESC); 136 137 ret = MEDfichDesEcr(*fid,(char*)fn1); 138 139 _MEDcstringFree(fn1); 140 141 return ret; 142 } 143 144 145 #ifdef PPRO_NT 146 med_int EDFFOCO(char * nom,unsigned int bidon,med_int * lon)147 EDFFOCO (char *nom, unsigned int bidon, med_int *lon) 148 #else 149 med_int 150 nedffoco (char *nom,med_int *lon) 151 #endif 152 { 153 char *fn; 154 int ret; 155 156 fn = _MED2cstring(nom, (int) * lon); 157 if (!fn) 158 return(-1); 159 160 ret = (med_int) MEDformatConforme(fn); 161 162 _MEDcstringFree(fn); 163 164 return(ret); 165 } 166 167 #ifdef PPRO_NT 168 med_int EDFVECO(char * nom,unsigned int bidon,med_int * lon)169 EDFVECO (char *nom, unsigned int bidon, med_int *lon) 170 #else 171 med_int 172 nedfveco (char *nom,med_int *lon) 173 #endif 174 { 175 char *fn; 176 med_int ret; 177 178 fn = _MED2cstring(nom, (int) * lon); 179 if (!fn) 180 return(-1); 181 182 ret = (med_int) MEDversionConforme(fn); 183 184 _MEDcstringFree(fn); 185 186 return(ret); 187 } 188 189 #ifdef PPRO_NT 190 med_int EDFVELI(med_idt * fid,med_int * maj,med_int * min,med_int * rel)191 EDFVELI (med_idt *fid, med_int *maj, med_int *min, med_int *rel) 192 #else 193 med_int 194 nedfveli (med_idt *fid, med_int *maj, med_int *min, med_int *rel) 195 #endif 196 { 197 med_int ret; 198 199 ret = (med_int) MEDversionLire(*fid, (med_int *) maj, (med_int *) min, (med_int *) rel); 200 201 return(ret); 202 } 203 204 #ifdef PPRO_NT 205 med_int EDFVEDO(med_int * maj,med_int * min,med_int * rel)206 EDFVEDO (med_int *maj, med_int *min, med_int *rel) 207 #else 208 med_int 209 nedfvedo (med_int *maj, med_int *min, med_int *rel) 210 #endif 211 { 212 med_int ret; 213 214 ret = 0; 215 216 MEDversionDonner((med_int *) maj, (med_int *) min, (med_int *) rel); 217 218 return(ret); 219 } 220 221 #ifdef PPRO_NT 222 med_idt EDFMONT(med_idt * fid,char * acces,unsigned int bidon,med_int * lon,med_int * type)223 EDFMONT (med_idt *fid, char *acces, unsigned int bidon, med_int *lon, med_int *type) 224 #else 225 med_idt 226 nedfmont (med_idt *fid, char *acces, med_int *lon, med_int *type) 227 #endif 228 { 229 char *fn; 230 med_idt ret; 231 232 fn = _MED2cstring(acces, (int) * lon); 233 if (!fn) 234 return(-1); 235 236 ret = (med_idt) MEDmonter(*fid,(const char *) fn, (med_type_donnee) *type); 237 238 _MEDcstringFree(fn); 239 240 return(ret); 241 } 242 243 244 #ifdef PPRO_NT 245 med_int EDFDEMO(med_idt * fid,med_idt * mid,med_int * type)246 EDFDEMO (med_idt *fid, med_idt *mid, med_int *type) 247 #else 248 med_int 249 nedfdemo (med_idt *fid, med_idt *mid, med_int *type) 250 #endif 251 { 252 int ret; 253 254 ret = (med_int) MEDdemonter(*fid,*mid, (med_type_donnee) *type); 255 256 return (ret); 257 } 258