diff options
author | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-10-14 09:19:57 +0000 |
---|---|---|
committer | allen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 1999-10-14 09:19:57 +0000 |
commit | 6d0b25bd188111454fefaa61a142591da361b765 (patch) | |
tree | ef32e1928aa03899934e3db1d902e40633580457 /src/util/Misc.c | |
parent | 4b2d8eb04fed8e779426bd8f94758c8e5d21b6af (diff) |
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
Diffstat (limited to 'src/util/Misc.c')
-rw-r--r-- | src/util/Misc.c | 44 |
1 files changed, 44 insertions, 0 deletions
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<strlen(*cstring);i++) + { + cctk_str1[i] = (*cstring)[i]; + } + + for (i=strlen(*cstring);i<cctk_strlen1;i++) + { + cctk_str1[i] = ' '; + } + + cctk_str1[strlen(*cstring)] = '\0'; + + *nchar = strlen(*cstring); + +} + |