/* Copyright 2010 SIMPACK AG, Germany Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* * This file provides a sample wrapper for various OpenCRG C-routines from FORTAN * * It is to be considered as an example only without any warranty concerning its applicability to a certain setup * * The original file was provided by SIMPACK AG, Gilching, Germany * * Date | Editor | Comment *------------+--------------------+------------------------------------------------------------------------------------ * 2010-08-10 | M.Dupuis | modified according to comments from J. Rauh; prepared for publication * 2010-06-30 | M.Baumann | [17807:5] added FOR_C version of FTN_NAME() macro to avoid __stdcall decorations * 2010-06-22 | G.Hippmann | [18440:8] author * * \brief Wrapper for Delft-Tyre (Fortran) -> OpenCRG road (C) calls * */ /* Includes */ #include "crgBaseLib.h" /* OpenCRG enums and prototypes */ /* Macros */ /* Platformspecific function name extensions */ #ifdef LINUX #define FTN_NAME( NAME ) NAME##_ #elif WINDOWS #if defined(FOR_C) #define FTN_NAME( NAME ) NAME #else #define FTN_NAME( NAME ) __stdcall NAME #endif #else #define FTN_NAME( NAME ) NAME #endif /* Functions */ int FTN_NAME(crgloaderreadfile)( const char* S1, int L1 ) { char *filenam; int i, l; int dataSetId; /* --- copy FORTRAN string to C string --- */ filenam = malloc(L1+1); l = -1; for (i = 0; i < L1; i++) if ((filenam[i] = *S1++) != ' ') /* drop trailing blanks */ l = i; l++; filenam[l] = '\0'; /* --- now load the file --- */ dataSetId = crgLoaderReadFile(filenam); free(filenam); return dataSetId; } void FTN_NAME(crgdatasetmodifiersapply)( const int* dataSetId ) { /* dataSetId: call by value -> reference */ crgDataSetModifiersApply( *dataSetId ); } int FTN_NAME(crgcontactpointcreate)( const int* dataSetId ) { /* dataSetId: call by value -> reference */ return crgContactPointCreate( *dataSetId ); } int FTN_NAME(crgevalxy2z)( const int* cpId, double* x, double* y, double* z ) { /* cpId, x, y: call by value -> reference */ return crgEvalxy2z( *cpId, *x, *y, z ); } int FTN_NAME(crgdatasetrelease)( const int* dataSetId ) { /* dataSetId: call by value -> reference */ return crgDataSetRelease( *dataSetId ); }