PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

ascii weird behaviour

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Jean Martonne



Joined: 09 May 2006
Posts: 2

PostPosted: Wed May 10, 2006 4:22 am    Post subject: ascii weird behaviour Reply with quote

Hi all,

I'm trying to make MM5 works on my PC with Debian distro.
It would be nice if someone could give me some hint about this error I got when running PREGRID after a succesful compilation:


Situation:

-I execute the pregrid.csh script that starts 'pregrid_on84.exe'
-'pregrid_on84.exe' make a call to 'rd_on84()' fortran routine.
-From there, a call is made to 'ron84_record()' fortran routine.
-From there, a last call is made to COPEN() which resides in a C code.


Erroneous result:

-The name of file to be opened arrives bad to COPEN().
-There are many garbage chars appended to real file name.


Original file name (sent by fortran code): ON84FILE
File name when arrives cio.c: "ON84FILE –Unknown nk: NULLrd_on84.fNot using field number PRESSUREPSFC`Í"


I compile the codes as following (default package settings):

================================
Code:
compile cio.c:
cc -DDEC -DBIT32 -I. -c cio.c

create library:
ar ru ./libpgu.a  [...several objects...] cio.o

Compile codes:
/lib/cpp -I. -c -P -DDEC -DBIT32 -traditional ron84_record.F > ron84_record.f
pgf90 -c Mfreeform -byteswapio -I. ron84_record.f

/lib/cpp -I. -c -P -DDEC -DBIT32 -traditional rd_on84.F > rd_on84.f
pgf90 -c Mfreeform -byteswapio -I. rd_on84.f

Link and creation of executable:
pgf90 -o pregrid_on84.exe rd_on84.o ron_record.o libpgu.a
=========================================


I guess it must be someting dealing with null termination of strings and the way it differs between fortran and C


Thanks for your suggestions

Jean
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Wed May 10, 2006 3:30 pm    Post subject: Reply with quote

Hi Jean,

It looks like a program error to me. The Fortran character string 'on84flnm' has length of 9 and does not end with a blank or NULL. This is fine except that the copen routine in cio.c does expect a blank or NULL to end the string. I think the best solution is to append a '\0' to the end of 'on84flnm' when COPEN is called. Also, if you look at other pregridder directories, such as grib.misc's rd_grib.F at line 134, you'll see that this is exactly what is done.

To fix, change line 31 to ron84_record.F
Code:
call COPEN(iunit, ifd, trim(on84flnm)//char(0), 1, ierr, -1)


Hope this helps,
Mat
Back to top
View user's profile
Jean Martonne



Joined: 09 May 2006
Posts: 2

PostPosted: Fri May 12, 2006 11:56 pm    Post subject: you are right Reply with quote

Hi Mat,


thank you very much for your fast reply.
It is exactly as you explained and now it works fine.


Jean
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group