String returned from C# to Fortran - problem

onkelhotte
Total Points:
2,880
Status Points:
2,380
Brown Belt
November 24, 2008 11:45 PM PST
Rate
 
#1
In C# I use StringBuilder to exchange strings with Fortran.
Here are two examples to get and put a character*4 value:
C#
	public static void putusername(string value)
	{
		StringBuilder stringBuilderValue = new StringBuilder(value.Substring(0, System.Math.Min(value.Length, 4)));
		PUT_USERNAME(stringBuilderValue, 4);
	}

	public static string getusername()
	{
		StringBuilder stringBuilderValue = new StringBuilder(4);
		GET_USERNAME(stringBuilderValue, 4);
		return stringBuilderValue.ToString();
	}


Fortran:
	subroutine put_dateiname(value)
		use globaleVariablen
		implicit none
		character*255 dateiname
		dateiname = value
	end subroutine put_dateiname
!
	subroutine put_username(value)
		use globaleVariablen
		implicit none
		character*4 username
		username = value
	end subroutine put_username


Intel Software Network Forums Statistics

8290 users have contributed to 31236 threads and 99111 posts to date.
In the past 24 hours, we have 7 new thread(s) 20 new posts(s), and 30 new user(s).

In the past 3 days, the most popular thread for everyone has been comparison cilk++, openmp, pthreads first results The most posts were made to comparison cilk++, openmp, pthreads first results The post with the most views is Very amusing...  Escalated as

Please welcome our newest member zq.x