From 6d0b25bd188111454fefaa61a142591da361b765 Mon Sep 17 00:00:00 2001 From: allen Date: Thu, 14 Oct 1999 09:19:57 +0000 Subject: Added CCTK_FortranString which turns a C string into a fortran string Note that the fortran string has to have its length predefined, this routine returns also the number of characters which are used git-svn-id: http://svn.cactuscode.org/flesh/trunk@1022 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/Misc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/util') diff --git a/src/util/Misc.c b/src/util/Misc.c index bde592a5..25726f91 100644 --- a/src/util/Misc.c +++ b/src/util/Misc.c @@ -956,3 +956,47 @@ int CCTK_RegexMatch(const char *string, return(1); } + +/*@@ + @routine getoutpfx + @date Thu Jan 22 14:44:39 1998 + @author Paul Walker + @desc + Change a C string into a Fortran string + @enddesc +@@*/ + + +void FORTRAN_NAME(CCTK_FortranString)(int *nchar, char **cstring,ONE_FORTSTRING_ARG) +{ + + ONE_FORTSTRING_CREATE(fstring) + int i; + + if (strlen(*cstring) > cctk_strlen1) + { + char *message; + message = (char *)malloc( (200+strlen(*cstring))*sizeof(char) ); + sprintf(message,"Cannot output %s to char* of length %d", + *cstring,cctk_strlen1); + CCTK_Warn (1,__LINE__,__FILE__,"Cactus",message); + free(message); + *nchar = -1; + } + + for (i=0;i