- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using Intel Visual Fortran composer XE for Windows.
The code as listed in the following gives output as expected. In this simplified code, the first executable statement to evaluate string50 replaced a complicate procedure in my original complicate code, in which function NF_GET_ATT_TEXT in a netCDF library is used to read the string from a data file.
When I ran my original program, the output of TRIM(string50) corresponding to Print statement 1 came out as expected but char64 in Print statement 2 gave a string of strange special characters.
If I have the trim statement repeated, then both Print statement 3 and 4 came out as expected. Alternatively, if I have the first trim statement break down to two statements to evaluate char64, as shown in the commented statements at the end of the code, then everything is fine.
Could you please tell me what could have caused Print statement 2 to give strange characters?
Wen
P.S. This problem appeared also when I was using Vs. 11.1.067 but not when Vs. 9.1 was used.
**********
program simplified
INTEGER, PARAMETER :: Length64 = 64
CHARACTER (LEN=50), SAVE :: string50
CHARACTER(Length64) :: char64='###'
string50 = 'STRING50 ' ! In my original code, this string is read thru
! a function NF_GET_ATT_TEXT in a netCDF library.
char64 = trim(string50)
print *,'*', TRIM(string50), '*' ! Print statement 1
print *,'*', char64, '*' ! Print statement 2
char64 = trim(string50)
print *,'*', TRIM(string50), '*' ! Print statement 3
print *,'*', char64, '*' ! Print statement 4
! char64 = string50
! char64 = trim(char64)
! print *,'*', char64, '*' ! Print statement 5
stop
end program simplified
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
print *,'*', trim(char64), '*' ! Print statement 2
Regards,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
print *,'*', trim(char64), '*' ! Print statement 2
resulted in
*[NUL][SOH]9[SOH]49[EOT][FF][NUL][NUL][NUL]*
print *,'*', char64, '*' ! Print statement 2
came out
*[NUL][SOH]9[SOH]49[EOT][FF][NUL][NUL][NUL] *
Wen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suggest that the problem is in the NF_GET_ATT_TEXT function. A quick search on the net located a number of discussions about how this returns data, and issues arround calling it from C and Fortran. I do not know if all of the issues (from 2006) have been properly resolved.
Suggest you do some hunting. One place I found was http://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg03733.html
Regards,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you are trying to use netcdf from fortran the programs at the webpage:
http://www.whigg.cn/yanhm/fortran.htm
might help you. The are usefull in 32bit environments. I have no problems to use those programs with IVF 11.1.048.
Frank
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page